From 5b48bd35a5828ea80fcfd03ae6d36602a4d71009 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 28 Dec 2020 13:53:18 +0100 Subject: [PATCH 001/312] WIP: operations DSL --- truffle/mx.truffle/suite.py | 27 + .../test/example/TestOperations.java | 227 ++++ .../test/example/TestOperationsBuilder.java | 1108 +++++++++++++++++ .../test/example/TestOperationsTest.java | 167 +++ .../api/operation/GenerateOperations.java | 13 + .../truffle/api/operation/Operation.java | 80 ++ .../api/operation/OperationPointer.java | 24 + .../api/operation/OperationsBuilder.java | 26 + .../truffle/api/operation/OperationsNode.java | 16 + 9 files changed, 1688 insertions(+) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 9ac3dee2b221..071f5251afcd 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -278,6 +278,33 @@ "javaCompliance" : "11+", "workingSets" : "API,Truffle", }, + + "com.oracle.truffle.api.operation" : { + "subDir" : "src", + "sourceDirs" : ["src"], + "dependencies" : ["com.oracle.truffle.polyglot"], + "checkstyle" : "com.oracle.truffle.api", + "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], + "javaCompliance" : "8+", + "workingSets" : "API,Truffle", + }, + + "com.oracle.truffle.api.operation.test" : { + "subDir" : "src", + "sourceDirs" : ["src"], + "dependencies" : [ + "com.oracle.truffle.polyglot", + "com.oracle.truffle.api.test", + "com.oracle.truffle.api.operation", + "mx:JUNIT", + ], + "checkstyle" : "com.oracle.truffle.dsl.processor", + "javaCompliance" : "8+", + "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], + "workingSets" : "API,Truffle,Codegen,Test", + "jacoco" : "exclude", + }, + "com.oracle.truffle.api.dsl" : { "subDir" : "src", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java new file mode 100644 index 000000000000..4a7322a0fc15 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -0,0 +1,227 @@ +package com.oracle.truffle.api.operation.test.example; + +import static com.oracle.truffle.api.operation.Operation.Kind.CONDITIONAL; +import static com.oracle.truffle.api.operation.Operation.Kind.LOCAL; +import static com.oracle.truffle.api.operation.Operation.Kind.META; +import static com.oracle.truffle.api.operation.Operation.Kind.NODE; +import static com.oracle.truffle.api.operation.Operation.Kind.PROFILE; +import static com.oracle.truffle.api.operation.Operation.Kind.REPEATING; +import static com.oracle.truffle.api.operation.Operation.Kind.RETURN; +import static com.oracle.truffle.api.operation.Operation.Kind.SOURCE; +import static com.oracle.truffle.api.operation.Operation.Kind.TAG; +import static com.oracle.truffle.api.operation.Operation.Kind.UNWIND; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.ProvidedTags; +import com.oracle.truffle.api.instrumentation.StandardTags.RootBodyTag; +import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.Operation.EndInput; +import com.oracle.truffle.api.operation.Operation.LocalInput; +import com.oracle.truffle.api.operation.Operation.OnBuild; +import com.oracle.truffle.api.operation.Operation.OnEnter; +import com.oracle.truffle.api.operation.Operation.OnExecute; +import com.oracle.truffle.api.operation.Operation.StartInput; +import com.oracle.truffle.api.operation.Operation.StaticInput; +import com.oracle.truffle.api.operation.OperationPointer; +import com.oracle.truffle.api.profiles.ConditionProfile; + +@GenerateOperations +class TestOperations { + + @Operation(value = LOCAL) + static class Body { + + @OnEnter + static int[] locals(VirtualFrame frame, @LocalInput int[] locals, + @EndInput int localCount, + @EndInput int argumentCount) { + assert locals == null : "locals alraedy created"; + int[] newLocals = new int[localCount]; + Object[] arguments = frame.getArguments(); + for (int i = 0; i < argumentCount; i++) { + newLocals[i] = (int) arguments[i]; + } + return newLocals; + } + } + + @Operation(NODE) + static class ReadLocal { + + @OnExecute + static int doDefault(@LocalInput int[] locals, + @StartInput int localIndex) { + return locals[localIndex]; + } + } + + @Operation(NODE) + static class WriteLocal { + + @OnExecute + static void doDefault(@LocalInput int[] locals, + @StartInput short localIndex, + int value) { + locals[localIndex] = value; + } + } + + @Operation(META) + static class LocalNames { + + @OnExecute + static String[] localNames(@EndInput String[] localNames) { + // validate ? + return localNames; + } + } + + @Operation(REPEATING) + static class While { + + @OnExecute + static boolean doDefault(boolean condition) { + return condition; + } + } + + @Operation(CONDITIONAL) + static class If { + + @OnExecute + static boolean execute(boolean condition) { + return condition; + } + } + + @Operation(UNWIND) + static class BreakWhile { + + @OnBuild + static OperationPointer skipLoops(@StaticInput OperationPointer current, @StartInput int skipIndex) { + int whileIndex = 0; + while (current.parent()) { + if (current.get() == TestOperations.While.class) { + if (whileIndex == skipIndex) { + break; + } + whileIndex++; + } + } + return current; + } + + } + + @Operation(RETURN) + static class Return { + + @OnEnter + static Object doDefault(Object v) { + return v; + } + + } + + @Operation(UNWIND) + static class ContinueWhile extends TestOperations.BreakWhile { + // inherited from BreakWhile + + @OnBuild + static OperationPointer onBuild(@StaticInput OperationPointer current, @StartInput int skipIndex) { + return BreakWhile.skipLoops(current, skipIndex); + } + } + + @Operation(PROFILE) + static class Condition { + @Specialization + static boolean doCondition(boolean input, @Cached("createCountingProfile()") ConditionProfile profile) { + return profile.profile(input); + } + } + + @Operation(SOURCE) + static class Source { + } + + @Operation(TAG) + @ProvidedTags(StatementTag.class) + static class Statement { + } + + @Operation(TAG) + @ProvidedTags(TestOperations.RootTag.class) + static class RootTag { + } + + @Operation(TAG) + @ProvidedTags(RootBodyTag.class) + static class RootBody { + } + + @Operation(NODE) + static class LessThan { + + @OnExecute + static boolean doDefault(int left, int right) { + return left < right; + } + } + + @Operation(NODE) + static class GreaterThan { + + @OnExecute + static boolean doDefault(int left, int right) { + return left > right; + } + + } + + @Operation(NODE) + static class ConstantInt { + + @OnExecute + static int value(@StartInput int constant) { + return constant; + } + + } + + @Operation(NODE) + static class Add { + + @OnExecute + static int doAdd(int left, int right) { + return left + right; + } + + } + + @Operation(NODE) + static class ConstantString { + + @OnExecute + static String value(@StartInput String input) { + return input; + } + + } + + @Operation(NODE) + static class NoOp { + } + + @FunctionalInterface + interface SourceOffsetProvider { + + int currentIndex(Object source); + + } + +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java new file mode 100644 index 000000000000..0c20d3096101 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java @@ -0,0 +1,1108 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.Arrays; +import java.util.NoSuchElementException; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.CompilerDirectives.ValueType; +import com.oracle.truffle.api.HostCompilerDirectives; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.memory.ByteArraySupport; +import com.oracle.truffle.api.nodes.ControlFlowException; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.Operation.Kind; +import com.oracle.truffle.api.operation.OperationPointer; +import com.oracle.truffle.api.operation.OperationsBuilder; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.test.example.TestOperations.Add; +import com.oracle.truffle.api.operation.test.example.TestOperations.Body; +import com.oracle.truffle.api.operation.test.example.TestOperations.ConstantInt; +import com.oracle.truffle.api.operation.test.example.TestOperations.ConstantString; +import com.oracle.truffle.api.operation.test.example.TestOperations.GreaterThan; +import com.oracle.truffle.api.operation.test.example.TestOperations.If; +import com.oracle.truffle.api.operation.test.example.TestOperations.ReadLocal; +import com.oracle.truffle.api.operation.test.example.TestOperations.SourceOffsetProvider; + +abstract class TestOperationsBuilder extends OperationsBuilder { + + private TestOperationsBuilder() { + } + + private void startTag(int opCode) { + } + + private void endTag(int opCode) { + } + + public void startSource(Object source, SourceOffsetProvider provider) { + } + + public void endSource() { + } + + private void endSourceOp() { + + } + + private boolean verifyStart(int opAdd) { + return true; + } + + private boolean verifyEnd(int opAdd) { + return true; + } + + public void startBody() { + + } + + public void endBody(int localCount, int argumentCount) { + + } + + public void startStatement() { + + } + + public void endStatement() { + + } + + public void startReturn() { + + } + + public void startAdd() { + + } + + public void endAdd() { + + } + + public void startWhile() { + } + + public void endWhile() { + } + + public void startIf() { + } + + public void startGreaterThan() { + } + + public void startLessThan() { + } + + public void endLessThan() { + } + + public void endGreaterThan() { + } + + public void endIf() { + } + + public void endReturn() { + } + + public void startLocalWrite(int localIndex) { + } + + public void endLocalWrite() { + } + + public void pushLocalRead(int varIndex) { + } + + public void pushNoOp() { + } + + public int resolveVariableRead(String identifier) { + return 0; + } + + public void pushConstantInt(int value) { + } + + public void pushBreakWhile(int skipIndex) { + } + + public void pushContinueWhile(int skipIndex) { + } + + public abstract OperationsNode build(); + + public void reset() { + } + + public static TestOperationsBuilder createASTBuilder() { + return new ASTInterpreterBuilder(); + } + + public static TestOperationsBuilder createBytecodeBuilder() { + return new BytecodeInterpreterBuilder(); + } + + @ValueType + static final class ASTPointer extends OperationPointer { + + ASTNode node; + + ASTPointer(ASTNode node) { + this.node = node; + } + + @Override + public boolean parent() { + this.node = (ASTNode) node.getParent(); + return this.node != null; + } + + @Override + public void child(int childIndex) { + node = node.childAt(childIndex); + } + + @Override + public int childCount() { + return node.childCount(); + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public Class get() throws NoSuchElementException { + return null; + } + + @Override + public Kind getKind() throws NoSuchElementException { + return get().getAnnotation(Operation.class).value(); + } + + @Override + public T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException { + return expectedClass.cast(node.getConstant(constantIndex)); + } + + } + + static final class AST extends OperationsNode { + + @Child ASTNode content; + + AST(ASTNode content) { + this.content = content; + } + + @Override + public Object execute(VirtualFrame frame) { + try { + return content.execute(frame, null); + } catch (ReturnException e) { + return e.value; + } + } + + @Override + public OperationPointer createPointer() { + return new ASTPointer(content); + } + + @Override + public Object continueAt(VirtualFrame frame, OperationPointer index) { + throw new UnsupportedOperationException(); + } + + @Override + public OperationsNode copyUninitialized() { + throw new UnsupportedOperationException(); + } + + } + + static abstract class ASTNode extends Node { + + abstract int execute(VirtualFrame frame, int[] locals); + + void onBuild() { + } + + ASTNode childAt(int childIndex) { + int index = 0; + for (Node child : getChildren()) { + if (child instanceof ASTNode) { + if (index == childIndex) { + return (ASTNode) child; + } + index++; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new ArrayIndexOutOfBoundsException(String.valueOf(childIndex)); + } + + @TruffleBoundary + int childCount() { + int count = 0; + for (Node node : getChildren()) { + if (node instanceof ASTNode) { + count++; + } + } + return count; + } + + Class getOperation() { + return null; + } + + Object getConstant(int index) { + throw new ArrayIndexOutOfBoundsException(); + } + + } + + static final class AddNode extends ASTNode { + + @Child private ASTNode left; + @Child private ASTNode right; + + @Override + int execute(VirtualFrame frame, int[] locals) { + int leftValue = left.execute(frame, locals); + int rightValue = right.execute(frame, locals); + return TestOperations.Add.doAdd(leftValue, rightValue); + } + + } + + static final class GreaterThanNode extends ASTNode { + + @Child private ASTNode left; + @Child private ASTNode right; + + @Override + int execute(VirtualFrame frame, int[] locals) { + int leftValue = left.execute(frame, locals); + int rightValue = right.execute(frame, locals); + return TestOperations.GreaterThan.doDefault(leftValue, rightValue) ? 1 : 0; + } + + } + + static final class ReturnNode extends ASTNode { + + @Child ASTNode operand; + + @Override + int execute(VirtualFrame frame, int[] locals) { + int v = operand.execute(frame, locals); + throw new ReturnException(v); + } + + } + + static final class ReturnException extends ControlFlowException { + + final Object value; + + ReturnException(Object value) { + this.value = value; + } + } + + static final class BodyNode extends ASTNode { + + @Child private ASTNode child; + @CompilationFinal private int localCount; + @CompilationFinal private int argumentCount; + + @Override + int execute(VirtualFrame frame, int[] locals) { + int[] newLocals = Body.locals(frame, locals, localCount, argumentCount); + return child.execute(frame, newLocals); + } + + } + + static final class ConstantNode extends ASTNode { + + private final int constantValue; + + ConstantNode(int constantValue) { + this.constantValue = constantValue; + } + + @Override + int execute(VirtualFrame frame, int[] locals) { + return constantValue; + } + + } + + static final class LocalReadNode extends ASTNode { + + private final int index; + + LocalReadNode(int index) { + this.index = index; + } + + @Override + int execute(VirtualFrame frame, int[] locals) { + return ReadLocal.doDefault(locals, index); + } + + } + + static final class IfNode extends ASTNode { + + @Child private ASTNode condition; + @Child private ASTNode thenNode; + @Child private ASTNode elseNode; + + @Override + int execute(VirtualFrame frame, int[] locals) { + boolean cond = condition.execute(frame, locals) != 0; + if (TestOperations.If.execute(cond)) { + return thenNode.execute(frame, locals); + } else { + return elseNode.execute(frame, locals); + } + } + + } + + static final class ASTInterpreterBuilder extends TestOperationsBuilder { + + final ASTNode[] nodeStack = new ASTNode[1024]; + + int currentIndex = -1; + + @Override + public void pushConstantInt(int value) { + pushNode(new ConstantNode(value)); + } + + @Override + public void pushLocalRead(int localIndex) { + assert assertEnclosingBody(); + pushNode(new LocalReadNode(localIndex)); + } + + @Override + public void startBody() { + pushNode(new BodyNode()); + } + + @Override + public void startGreaterThan() { + pushNode(new GreaterThanNode()); + } + + @Override + public void endGreaterThan() { + ASTNode right = popNode(ASTNode.class); + ASTNode left = popNode(ASTNode.class); + GreaterThanNode op = peekNode(GreaterThanNode.class); + op.left = left; + op.right = right; + } + + @Override + public void endBody(int localCount, int argumentCount) { + ASTNode child = popNode(ASTNode.class); + BodyNode locals = peekNode(BodyNode.class); + locals.child = child; + locals.localCount = localCount; + locals.argumentCount = argumentCount; + } + + @Override + public void startReturn() { + pushNode(new ReturnNode()); + } + + private boolean assertEnclosingBody() { + BodyNode body = findNode(BodyNode.class); + if (body == null) { + throw new AssertionError("No enclosing Body operation found but expected by operations use of LocalInput."); + } + return true; + } + + @SuppressWarnings("unchecked") + private T findNode(Class nodeClass) { + for (int i = 0; i < nodeStack.length; i++) { + ASTNode node = nodeStack[i]; + if (nodeClass.isInstance(node)) { + return nodeClass.cast(node); + } + } + return null; + } + + @Override + public void endReturn() { + ASTNode node = popNode(ASTNode.class); + peekNode(ReturnNode.class).operand = node; + } + + @Override + public void startAdd() { + pushNode(new AddNode()); + } + + @Override + public void endAdd() { + ASTNode right = popNode(ASTNode.class); + ASTNode left = popNode(ASTNode.class); + AddNode add = peekNode(AddNode.class); + add.left = left; + add.right = right; + } + + @Override + public void startIf() { + pushNode(new IfNode()); + } + + @Override + public void endIf() { + ASTNode elseBranch = popNode(ASTNode.class); + ASTNode thenBranch = popNode(ASTNode.class); + ASTNode condition = popNode(ASTNode.class); + IfNode op = peekNode(IfNode.class); + op.condition = condition; + op.thenNode = thenBranch; + op.elseNode = elseBranch; + } + + private void pushNode(ASTNode node) { + nodeStack[++currentIndex] = node; + } + + private T popNode(Class nodeClass) { + if (currentIndex == -1) { + throw new IllegalStateException("No nodes on stack."); + } + ASTNode node = nodeStack[currentIndex]; + nodeStack[currentIndex--] = null; + return nodeClass.cast(node); + } + + private T peekNode(Class nodeClass) { + return nodeClass.cast(nodeStack[currentIndex]); + } + + @Override + public OperationsNode build() { + ASTNode node = popNode(ASTNode.class); + AST ast = new AST(node); + node.adoptChildren(); + node.onBuild(); + onBuild(ast); + return ast; + } + + @Override + public void reset() { + if (currentIndex != -1) { + Arrays.fill(nodeStack, 0, currentIndex, null); + } + } + + @Override + public String toString() { + return "ASTInterpreterBuilder"; + } + + } + + static final class BytecodePointer extends OperationPointer { + + private final byte[] bytecodes; + private int bci; + + BytecodePointer(byte[] bytecodes) { + this.bytecodes = bytecodes; + } + + @Override + public boolean parent() { + return false; + } + + @Override + public void child(int childIndex) { + } + + @Override + public int childCount() { + return 0; + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public Class get() throws NoSuchElementException { + return null; + } + + @Override + public Kind getKind() throws NoSuchElementException { + return null; + } + + @Override + public T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException { + return null; + } + + } + + static final class BytecodeNode extends OperationsNode { + + private static final int OP_BODY = 1; + private static final int OP_READ_LOCAL = 2; + private static final int OP_WRITE_LOCAL = 3; + private static final int OP_IF = 4; + private static final int OP_BREAK_WHILE = 5; + private static final int OP_CONTINUE_WHILE = 6; + private static final int OP_LESS_THAN = 7; + private static final int OP_GREATER_THAN = 8; + private static final int OP_CONSTANT_INT = 9; + private static final int OP_CONSTANT_STRING_BYTE = 10; + private static final int OP_CONSTANT_STRING_SHORT = 11; + private static final int OP_ADD = 12; + private static final int OP_RETURN = 13; + + private static final int OP_BRANCH = 14; + + private static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); + + @CompilationFinal(dimensions = 1) private final byte[] bytecodes; + private final int maxStack; + @CompilationFinal(dimensions = 1) final Object[] finalData; + @CompilationFinal(dimensions = 1) final Object[] mutableData; + + protected BytecodeNode(byte[] bytecodes, int maxStack, Object[] finalData, Object[] mutableData) { + this.bytecodes = bytecodes; + this.maxStack = maxStack; + this.finalData = finalData; + this.mutableData = mutableData; + } + + @Override + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @HostCompilerDirectives.BytecodeInterpreterSwitch + public Object execute(VirtualFrame frame) { + byte[] b = this.bytecodes; // bytecodes + int bLength = b.length; + int bci = 0; // bytecode index + int sp = 0; // stack pointer + final int[] pStack = new int[maxStack]; + final Object[] rStack = new Object[maxStack]; + final Object[] constants = this.finalData; + + int[] locals = null; + while (bci < bLength) { + int op = b[bci++]; + switch (op) { + case OP_BODY: + locals = Body.locals(frame, locals, BYTES.getInt(b, bci), BYTES.getInt(b, bci + 4)); + bci += 8; + break; + case OP_ADD: + executeAdd(pStack, sp); + sp--; + break; + case OP_RETURN: + Object value = TestOperations.Return.doDefault(pStack[sp - 1]); + sp--; + return value; + case OP_READ_LOCAL: + writeInt(pStack, sp, ReadLocal.doDefault(locals, BYTES.getInt(b, bci))); + sp++; + bci += 4; + break; + case OP_GREATER_THAN: + executeGreaterThan(pStack, sp); + sp--; + break; + case OP_CONSTANT_INT: + writeInt(pStack, sp, ConstantInt.value(BYTES.getInt(b, bci))); + sp++; + bci += 4; + break; + case OP_CONSTANT_STRING_BYTE: + writeObject(rStack, sp, ConstantString.value(readByteConstantString(b, bci, constants))); + bci += 1; + sp++; + break; + case OP_CONSTANT_STRING_SHORT: + writeObject(rStack, sp, ConstantString.value(readShortConstantString(b, bci, constants))); + bci += 2; + sp++; + break; + case OP_IF: + if (If.execute(readInt(pStack, sp - 1) == 1)) { + bci += 4; + } else { + bci = BYTES.getInt(b, bci); + } + break; + default: + throw new UnsupportedOperationException(String.valueOf(op)); + + } + } + return null; + } + + private static int bytecodeIndexOf(byte[] b, int byteIndex) { + int bLength = b.length; + int bci = 0; // bytecode index + int bytecodeIndex = 0; + while (bci < bLength) { + if (bci == byteIndex) { + return bytecodeIndex; + } + int op = b[bci++]; + try { + bci += bytecodeSize(op); + } catch (UnsupportedOperationException e) { + return -1; + } + bytecodeIndex++; + } + return -1; + } + + private static int bytecodeSize(int op) { + switch (op) { + case OP_BODY: + return 8; + case OP_ADD: + case OP_RETURN: + case OP_GREATER_THAN: + return 0; + case OP_CONSTANT_STRING_BYTE: + return 1; + case OP_CONSTANT_STRING_SHORT: + return 2; + case OP_READ_LOCAL: + case OP_CONSTANT_INT: + case OP_IF: + case OP_BRANCH: + return 4; + default: + throw new UnsupportedOperationException(String.valueOf(op)); + } + } + + private static String printBytecodes(String indent, byte[] b, Object[] constants) { + StringBuilder s = new StringBuilder(); + int bLength = b.length; + int bci = 0; // bytecode index + + while (bci < bLength) { + s.append(indent); + s.append(bci).append(":"); + int op = b[bci++]; + switch (op) { + case OP_BODY: + s.append("Body"); + s.append(" locals:").append(BYTES.getInt(b, bci)); + s.append(" arguments:").append(BYTES.getInt(b, bci + 4)); + bci += 8; + break; + case OP_ADD: + s.append("Add"); + break; + case OP_GREATER_THAN: + s.append("GreaterThan"); + break; + case OP_RETURN: + s.append("Return"); + break; + case OP_READ_LOCAL: + s.append("ReadLocal"); + s.append(" index:").append(BYTES.getInt(b, bci)); + bci += 4; + break; + case OP_CONSTANT_INT: + s.append("ConstantInt"); + s.append(" value:").append(BYTES.getInt(b, bci)); + bci += 4; + break; + case OP_CONSTANT_STRING_BYTE: + s.append("ConstantString"); + s.append(" value:\"").append(readByteConstantString(b, bci, constants)).append("\""); + bci += 1; + break; + case OP_CONSTANT_STRING_SHORT: + s.append("ConstantString"); + s.append(" value:\"").append(readShortConstantString(b, bci, constants)).append("\""); + bci += 2; + break; + case OP_IF: + s.append("If"); + s.append(" !target:").append(BYTES.getInt(b, bci)); + bci += 4; + break; + case OP_BRANCH: + s.append("Branch"); + s.append(" target:").append(BYTES.getInt(b, bci)); + bci += 4; + break; + case 0: + break; + default: + throw new UnsupportedOperationException(String.valueOf(op) + "\n" + s.toString()); + } + s.append(System.lineSeparator()); + } + return s.toString(); + } + + private static String formatTarget(int target) { + return "0x" + Integer.toHexString(target); + } + + private static String readByteConstantString(byte[] bytecodes, int bci, Object[] constants) { + return (String) constants[Byte.toUnsignedInt(BYTES.getByte(bytecodes, bci))]; + } + + private static String readShortConstantString(byte[] bytecodes, int bci, Object[] constants) { + return (String) constants[Short.toUnsignedInt(BYTES.getShort(bytecodes, bci))]; + } + + @Override + public OperationPointer createPointer() { + return null; + } + + private static void executeAdd(int[] stack, int stackPointer) { + int right = readInt(stack, stackPointer - 1); + int left = readInt(stack, stackPointer - 2); + writeInt(stack, stackPointer - 2, Add.doAdd(left, right)); + } + + private static void executeGreaterThan(int[] stack, int stackPointer) { + int right = readInt(stack, stackPointer - 1); + int left = readInt(stack, stackPointer - 2); + writeInt(stack, stackPointer - 2, GreaterThan.doDefault(left, right) ? 1 : 0); + } + + private static void writeInt(int[] stack, int index, int value) { + stack[index] = value; + } + + private static void writeObject(Object[] stack, int index, Object value) { + // TODO + } + + private static int readInt(int[] stack, int index) { + int result = stack[index]; + if (CompilerDirectives.inCompiledCode()) { + // Needed to avoid keeping track of popped slots in FrameStates. + stack[index] = 0; + } + return result; + } + + @Override + public OperationsNode copyUninitialized() { + throw new UnsupportedOperationException(); + } + + @Override + public Object continueAt(VirtualFrame frame, OperationPointer index) { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return printBytecodes("", this.bytecodes, this.finalData); + } + + } + + final static class BytecodeInterpreterBuilder extends TestOperationsBuilder { + + private static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); + + private static final int SHORT_MASK = 0x000000AF; + private static final int WIDE_MASK = 0x0000AFFF; + + private byte[] byteBuffer = new byte[1024]; + private int bufferIndex; + + private int[] opBuffer = new int[1024]; + private int opIndex; + + private int finalBufferIndex; + private Object[] finalBuffer = new Object[1024]; + + private int stackSize; + private int maxStack; + + BytecodeInterpreterBuilder() { + this.opIndex = 0; + } + + @Override + public OperationsNode build() { + byte[] bc = Arrays.copyOf(byteBuffer, bufferIndex); + Object[] imBuffer = Arrays.copyOf(finalBuffer, finalBufferIndex); + Object[] mutableBuffer = new Object[0]; + BytecodeNode bcNode = new BytecodeNode(bc, maxStack, imBuffer, mutableBuffer); + onBuild(bcNode); + return bcNode; + } + + @Override + public void startBody() { + pushStack(); + writeOp(BytecodeNode.OP_BODY); + writeInt(0); // patched in end + writeInt(0); // patched in end + } + + @Override + public void endBody(int localCount, int argumentCount) { + popStack(); // child + int index = peekStack(BytecodeNode.OP_BODY); + BYTES.putInt(byteBuffer, index + 1, localCount); + BYTES.putInt(byteBuffer, index + 5, argumentCount); + } + + @Override + public void pushLocalRead(int index) { + pushStack(); + writeOp(BytecodeNode.OP_READ_LOCAL); + writeInt(index); + stackChange(1); + } + + @Override + public void startReturn() { + pushStack(); + } + + @Override + public void endReturn() { + popStack(); + peekStack(BytecodeNode.OP_RETURN); + writeOp(BytecodeNode.OP_RETURN); + stackChange(-1); + } + + @Override + public void reset() { + bufferIndex = 0; + opIndex = 0; + finalBufferIndex = 0; + stackSize = 0; + maxStack = 0; + } + + @Override + public void startGreaterThan() { + pushStack(); + } + + @Override + public void endGreaterThan() { + popStack(); // right + popStack(); // left + peekStack(BytecodeNode.OP_ADD); + + writeOp(BytecodeNode.OP_GREATER_THAN); + stackChange(-1); + } + + @Override + public void startIf() { + pushStack(); + } + + @Override + public void endIf() { + int elseBranch = popStack(); + int thenIndex = popStack(); // then index + int condition = popStack(); + + insertSpace(thenIndex, 5); + elseBranch += 5; + writeByte(byteBuffer, thenIndex, BytecodeNode.OP_IF); + writeInt(byteBuffer, thenIndex + 1, elseBranch + 5); // else index + + insertSpace(elseBranch, 5); + writeByte(byteBuffer, elseBranch, BytecodeNode.OP_BRANCH); + writeInt(byteBuffer, elseBranch + 1, bufferIndex); + } + + private void insertSpace(int index, int bytes) { + System.arraycopy(byteBuffer, index, byteBuffer, index + bytes, byteBuffer.length - index - bytes); + Arrays.fill(byteBuffer, index, index + bytes, (byte) 0); + bufferIndex += bytes; + } + + @Override + public void pushConstantInt(int value) { + pushStack(); + writeOp(BytecodeNode.OP_CONSTANT_INT); + writeInt(value); + stackChange(1); + } + + @Override + public void startAdd() { + pushStack(); + } + + @Override + public void endAdd() { + popStack(); // right + popStack(); // left + peekStack(BytecodeNode.OP_ADD); + + writeOp(BytecodeNode.OP_ADD); + stackChange(-1); + } + + public void stackChange(int change) { + stackSize += change; + if (stackSize > maxStack) { + maxStack = stackSize; + } + } + + protected final void pushRef(int cpIndex) { + pushShort(cpIndex); + } + + private void pushByte(int v) { + ensureSize(1); + writeByte(byteBuffer, bufferIndex, v); + bufferIndex = bufferIndex + 1; + } + + private void pushShort(int v) { + ensureSize(2); + writeShort(byteBuffer, bufferIndex, v); + bufferIndex = bufferIndex + 2; + } + + private void ensureSize(int length) { + if (bufferIndex + length >= byteBuffer.length) { + byteBuffer = Arrays.copyOf(byteBuffer, byteBuffer.length << 1); + } + } + + private void writeInt(int v) { + ensureSize(4); + writeInt(byteBuffer, bufferIndex, v); + bufferIndex = bufferIndex + 4; + } + + private int popInt() { + bufferIndex = bufferIndex - 4; + return readInt(byteBuffer, bufferIndex); + } + + private int popShort() { + bufferIndex = bufferIndex - 2; + return readShort(byteBuffer, bufferIndex); + } + + private int popByte() { + bufferIndex = bufferIndex - 1; + return readByte(byteBuffer, bufferIndex); + } + + private static void writeInt(byte[] b, int index, int v) { + BYTES.putInt(b, index, v); + } + + private static void writeByte(byte[] b, int index, int v) { + BYTES.putByte(b, index, (byte) (v & 0x000000FF)); + } + + private static void writeShort(byte[] b, int index, int v) { + BYTES.putShort(b, index, (short) (v & 0x0000FFFF)); + } + + private static int readInt(byte[] b, int index) { + return BYTES.getInt(b, index); + } + + private static int readShort(byte[] b, int index) { + return BYTES.getShort(b, index); + } + + private static int readByte(byte[] b, int index) { + return BYTES.getByte(b, index); + } + + private int peekOp(int skip) { + return opBuffer[opIndex - skip - 1]; + } + + private void writeOp(int op) { + if ((op & SHORT_MASK) == op) { + pushByte(op); + } else if ((op & WIDE_MASK) == op) { + pushShort(op); + } else { + writeInt(op); + } + } + + private void pushStack() { + int i = opIndex++; + if (i >= opBuffer.length) { + opBuffer = Arrays.copyOf(opBuffer, opBuffer.length << 1); + } + opBuffer[i] = bufferIndex; + } + + private int popStack() { + return opBuffer[--opIndex]; + } + + private int peekStack(int expectedOp) { + int op = opBuffer[opIndex - 1]; + + return op; + } + + @Override + public String toString() { + if (bufferIndex == 0) { + return "BytecodeInterpreterBuilder"; + } + String s = BytecodeNode.printBytecodes(" ", Arrays.copyOf(byteBuffer, bufferIndex + 1), + Arrays.copyOf(finalBuffer, finalBufferIndex + 1)); + return "BytecodeInterpreterBuilder[\n" + s + "]"; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java new file mode 100644 index 000000000000..cec8e9a321d4 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java @@ -0,0 +1,167 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.test.example.TestOperations.SourceOffsetProvider; +import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest; +import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest.TestRun; + +@RunWith(Parameterized.class) +public class TestOperationsTest { + + private static final TestSourceOffsetProvider PROVIDER = new TestSourceOffsetProvider(); + + public static class TestSourceOffsetProvider implements SourceOffsetProvider { + + public int currentIndex(Object source) { + return 0; + } + } + + @Parameter // first data value (0) is default + public /* NOT private */ TestOperationsBuilder builder; + + @Parameters(name = "{0}") + public static List data() { + return Arrays.asList(TestOperationsBuilder.createBytecodeBuilder(), TestOperationsBuilder.createASTBuilder()); + } + + private static class OperationsRootNode extends RootNode { + + @Child private OperationsNode executable; + + protected OperationsRootNode(OperationsNode executable) { + super(null); + this.executable = executable; + } + + @Override + public Object execute(VirtualFrame frame) { + return this.executable.execute(frame); + } + + } + + private static void parseAdd(TestOperationsBuilder b) { + // simple test: + // function foo(a, b) { + // return (a + b); + // } + b.startBody(); + b.startSource("test", PROVIDER); + b.startReturn(); + b.startAdd(); + b.pushLocalRead(0); + b.pushLocalRead(1); + b.endAdd(); + b.endReturn(); + b.endSource(); + b.endBody(2, 2); + } + + private static void parseMax(TestOperationsBuilder b) { + // control flow test: + // function max(a, b) { + // if (a > b) { + // return a; + // } else { + // return b; + // } + b.startBody(); + b.startIf(); + + b.startGreaterThan(); + b.pushLocalRead(0); // a + b.pushLocalRead(1); // b + b.endGreaterThan(); + + b.startReturn(); + b.pushLocalRead(0); // a + b.endReturn(); + + b.startReturn(); + b.pushLocalRead(1); // b + b.endReturn(); + + b.endIf(); + b.endBody(2, 2); + } + + @Test + public void testAdd() { + runTest(TestOperationsTest::parseAdd, 42, 20, 22); + } + + @Test + public void testMax() { + runTest(TestOperationsTest::parseMax, 42, 42, 13); + runTest(TestOperationsTest::parseMax, 42, 13, 42); + } + + @Test + public void testSumLoop() { + runTest(TestOperationsTest::parseSumLoop, 42, 10); + } + + private void runTest(Consumer parse, Object expectedResult, Object... args) { + TestOperationsBuilder b = builder; + parse.accept(b); + OperationsNode executable = b.build(); + b.reset(); + System.out.println(executable); + CallTarget target = Truffle.getRuntime().createCallTarget(new OperationsRootNode(executable)); + Object result = target.call(args); + Assert.assertEquals(expectedResult, result); + } + + private static void parseSumLoop(TestOperationsBuilder b) { + // control flow test: + // function sum(length) { + // sum = 0; + // i = 0; + // while (i < length) { + // sum += i; + // } + + b.startBody(); + b.startLocalWrite(1); + b.pushConstantInt(0); + b.endLocalWrite(); + + b.startLocalWrite(2); + b.pushConstantInt(0); + b.endLocalWrite(); + + b.startWhile(); + + b.startLessThan(); + b.pushLocalRead(1); // i + b.pushLocalRead(0); // length + b.endLessThan(); + + b.startLocalWrite(2); + b.startAdd(); + b.pushLocalRead(2); + b.pushLocalRead(1); + b.endAdd(); + b.endLocalWrite(); + + b.endWhile(); + b.endBody(3, 1); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java new file mode 100644 index 000000000000..222b7f618cdf --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -0,0 +1,13 @@ +package com.oracle.truffle.api.operation; + +public @interface GenerateOperations { + + boolean generateASTBuilder() default true; + + boolean generateBytecodeBuilder() default true; + + boolean generateContinueAt() default true; + + String statistics() default ""; + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java new file mode 100644 index 000000000000..d900b4869291 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -0,0 +1,80 @@ +package com.oracle.truffle.api.operation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface Operation { + + public enum Kind { + PROFILE, + SOURCE, + NODE, + REPEATING, + CONDITIONAL, + UNWIND, + RETURN, + TAG, + META, + LOCAL, + } + + Kind value(); + + int delegateInputs() default 0; + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.PARAMETER}) + public @interface LocalInput { + String value() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.PARAMETER}) + public @interface StaticInput { + String value() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.PARAMETER}) + public @interface StaticOutput { + String value() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.PARAMETER}) + public @interface StartInput { + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.PARAMETER}) + public @interface EndInput { + } + + /** + * Event is executed when the AST is built. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD}) + public @interface OnBuild { + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD}) + public @interface OnEnter { + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD}) + public @interface OnExecute { + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD}) + public @interface OnQuickening { + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java new file mode 100644 index 000000000000..0962493b67c5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java @@ -0,0 +1,24 @@ +package com.oracle.truffle.api.operation; + +import java.util.NoSuchElementException; + +public abstract class OperationPointer { + + protected OperationPointer() { + } + + public abstract boolean parent(); + + public abstract void child(int childIndex); + + public abstract int childCount(); + + public abstract boolean isValid(); + + public abstract Class get() throws NoSuchElementException; + + public abstract Operation.Kind getKind() throws NoSuchElementException; + + public abstract T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException; + +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java new file mode 100644 index 000000000000..a65725d1925c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -0,0 +1,26 @@ +package com.oracle.truffle.api.operation; + +import java.io.OutputStream; + +public abstract class OperationsBuilder { + + private OperationsStatistics statistics; + + protected final void onBuild(OperationsNode executable) { + if (statistics == null) { + return; + } + executable.createPointer(); + } + + public void setCollectStatistics(boolean statistics) { + this.statistics = new OperationsStatistics(); + } + + private static final class OperationsStatistics { + } + + public void dumpStatistics(OutputStream stream) { + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java new file mode 100644 index 000000000000..b0f0b3303a7e --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -0,0 +1,16 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +public abstract class OperationsNode extends Node { + + public abstract OperationPointer createPointer(); + + public abstract Object execute(VirtualFrame frame); + + public abstract Object continueAt(VirtualFrame frame, OperationPointer index); + + public abstract OperationsNode copyUninitialized(); + +} From 299ab256c619d3ba431060f55a6ea60faa164adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 28 Feb 2022 13:39:24 +0100 Subject: [PATCH 002/312] [wip] SL example dsl --- truffle/mx.truffle/suite.py | 4 +- .../operation/test/example/SlOperations.java | 61 + .../test/example/SlOperationsBuilder.java | 90 ++ .../test/example/SlOperationsBuilderImpl.java | 386 ++++++ .../test/example/SlOperationsBuilderNode.java | 321 +++++ .../test/example/TestOperations.java | 227 ---- .../test/example/TestOperationsBuilder.java | 1108 ----------------- .../test/example/TestOperationsTest.java | 205 +-- .../api/operation/GenerateOperations.java | 16 +- .../truffle/api/operation/Operation.java | 69 - .../truffle/api/operation/OperationLabel.java | 4 + .../api/operation/OperationPointer.java | 24 - .../api/operation/OperationsBuilder.java | 2 +- .../truffle/api/operation/OperationsNode.java | 6 +- 14 files changed, 999 insertions(+), 1524 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 071f5251afcd..5bff7eeb532f 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -285,7 +285,7 @@ "dependencies" : ["com.oracle.truffle.polyglot"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], - "javaCompliance" : "8+", + "javaCompliance" : "11+", "workingSets" : "API,Truffle", }, @@ -299,7 +299,7 @@ "mx:JUNIT", ], "checkstyle" : "com.oracle.truffle.dsl.processor", - "javaCompliance" : "8+", + "javaCompliance" : "11+", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "workingSets" : "API,Truffle,Codegen,Test", "jacoco" : "exclude", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java new file mode 100644 index 000000000000..cb9e000de62f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -0,0 +1,61 @@ +package com.oracle.truffle.api.operation.test.example; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.sl.runtime.SLBigNumber; + +// TODO: where to attach this once we don't have a wrapper class? +@GenerateOperations +class SlOperations { + @Operation + static class AddOperation { + // @Specialization(rewriteOn = ArithmeticException.class) + public static long add(long left, long right) { + return Math.addExact(left, right); + } + + // @Specialization + @TruffleBoundary + public static SLBigNumber add(SLBigNumber left, SLBigNumber right) { + return new SLBigNumber(left.getValue().add(right.getValue())); + } + + // @Specialization(guards = "isString(left, right)") + @TruffleBoundary + public static String add(Object left, Object right) { + return left.toString() + right.toString(); + } + + public static boolean isString(Object a, Object b) { + return a instanceof String || b instanceof String; + } + + // @Fallback + public static Object typeError(Object left, Object right) { + // throw SLException.typeError(this, left, right); + throw new RuntimeException("oh no: " + left + " + " + right); + } + } + + @Operation + static class LessThanOperation { + + // @Specialization + public static boolean lessThan(long left, long right) { + return left < right; + } + + // @Specialization + @TruffleBoundary + public static boolean lessThan(SLBigNumber left, SLBigNumber right) { + return left.compareTo(right) < 0; + } + + // @Fallback + public static Object typeError(Object left, Object right) { + // throw SLException.typeError(this, left, right); + throw new RuntimeException("oh no: " + left + " < " + right); + } + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java new file mode 100644 index 000000000000..cd5c97a814bb --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java @@ -0,0 +1,90 @@ +package com.oracle.truffle.api.operation.test.example; + +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationsNode; + +// TODO: the abstract / concrete distinction was in prototype, do we need it? +abstract class SlOperationsBuilder { + + public static SlOperationsBuilder createBuilder() { + return new SlOperationsBuilderImpl(); + } + + public abstract void reset(); + + public abstract OperationsNode build(); + + // labels + + public abstract OperationLabel createLabel(); + + public abstract void markLabel(OperationLabel label); + + // if_then + + public abstract void beginIfThen(); + + public abstract void endIfThen(); + + // if_then_else + + public abstract void beginIfThenElse(); + + public abstract void endIfThenElse(); + + // while + + public abstract void beginWhile(); + + public abstract void endWhile(); + + // block + + public abstract void beginBlock(); + + public abstract void endBlock(); + + // const_object + + public abstract void emitConstObject(Object value); + + // const_long + + public abstract void emitConstLong(long value); + + // load_local + + public abstract void emitLoadLocal(int index); + + // store_local + + public abstract void beginStoreLocal(int index); + + public abstract void endStoreLocal(); + + // load_argument + + public abstract void emitLoadArgument(int index); + + // return + + public abstract void beginReturn(); + + public abstract void endReturn(); + + // branch + + public abstract void emitBranch(OperationLabel label); + + // AddOperation + + public abstract void beginAddOperation(); + + public abstract void endAddOperation(); + + // LessThanOperation + + public abstract void beginLessThanOperation(); + + public abstract void endLessThanOperation(); +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java new file mode 100644 index 000000000000..5143b585df04 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java @@ -0,0 +1,386 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.ArrayList; +import java.util.Arrays; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.memory.ByteArraySupport; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.test.example.SlOperations.AddOperation; +import com.oracle.truffle.api.operation.test.example.SlOperations.LessThanOperation; + +class SlOperationsBuilderImpl extends SlOperationsBuilder { + + public SlOperationsBuilderImpl() { + reset(); + } + + static final byte PRIM_OP_NOP = 0; + static final byte PRIM_OP_JUMP_FALSE = 1; + static final byte PRIM_OP_UNCOND_JUMP = 2; + static final byte PRIM_OP_CONST_OBJECT = 3; + static final byte PRIM_OP_POP = 4; + static final byte PRIM_OP_RETURN = 5; + static final byte PRIM_OP_LOAD_ARGUMENT = 6; + static final byte PRIM_OP_LOAD_LOCAL = 8; + static final byte PRIM_OP_STORE_LOCAL = 9; + static final byte OP_ADD_OPERATION = 20; + static final byte OP_LESS_THAN_OPERATION = 21; + + static final int IMM_DEST_LENGTH = 2; + + static final void putDestination(byte[] bc, int bci, int value) { + BYTES.putShort(bc, bci, (short) value); + } + + static final int IMM_CONST_LENGTH = 2; + + static final void putConst(byte[] bc, int bci, Object value, ArrayList consts) { + int index = consts.size(); + consts.add(value); + BYTES.putShort(bc, bci, (short) index); + } + + static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); + + private static class SlOperationsOperationLabelImpl extends OperationLabel { + final int pointer; + + static final SlOperationsBuilderImpl.SlOperationsOperationLabelImpl ZERO = new SlOperationsOperationLabelImpl(0); + + SlOperationsOperationLabelImpl(int ptr) { + pointer = ptr; + } + } + + private static class SlOperationsBytecodeNode extends OperationsNode { + + final byte[] bc; + final Object[] consts; + + public SlOperationsBytecodeNode(byte[] bc, Object[] consts) { + this.bc = bc; + this.consts = consts; + } + + @Override + public String dump() { + return SlOperationsBuilderNode.dump(bc, consts); + } + + @Override + public Object execute(VirtualFrame frame) { + return continueAt(frame, SlOperationsOperationLabelImpl.ZERO); + } + + @Override + public Object continueAt(VirtualFrame frame, OperationLabel startIndex) { + + final Object[] stack = new Object[1024]; + final Object[] locals = new Object[1024]; + + int sp = 0; + int bci = ((SlOperationsBuilderImpl.SlOperationsOperationLabelImpl) startIndex).pointer; + + Object returnValue; + loop: while (true) { + int nextBci; + + // System.out.println(" op: " + bc[bci]); + switch (bc[bci]) { + case PRIM_OP_NOP: + nextBci = bci + 1; + break; + case PRIM_OP_JUMP_FALSE: { + boolean value = (boolean) stack[sp - 1]; + sp -= 1; + if (value) { + nextBci = bci + 3; + } else { + nextBci = BYTES.getShort(bc, bci + 1); + } + break; + } + case PRIM_OP_UNCOND_JUMP: { + nextBci = BYTES.getShort(bc, bci + 1); + break; + } + case PRIM_OP_CONST_OBJECT: { + Object value = consts[BYTES.getShort(bc, bci + 1)]; + stack[sp] = value; + sp += 1; + nextBci = bci + 3; + break; + } + case PRIM_OP_POP: + sp -= 1; + nextBci = bci + 1; + break; + case PRIM_OP_LOAD_ARGUMENT: { + int index = BYTES.getShort(bc, bci + 1); + Object value = frame.getArguments()[index]; + stack[sp++] = value; + nextBci = bci + 3; + break; + } + case PRIM_OP_LOAD_LOCAL: { + int index = BYTES.getShort(bc, bci + 1); + Object value = locals[index]; + stack[sp++] = value; + nextBci = bci + 3; + break; + } + case PRIM_OP_STORE_LOCAL: { + int index = BYTES.getShort(bc, bci + 1); + Object value = stack[--sp]; + locals[index] = value; + nextBci = bci + 3; + break; + } + case PRIM_OP_RETURN: { + returnValue = stack[sp - 1]; + break loop; + } + case OP_ADD_OPERATION: { + Object arg1 = stack[sp - 2]; + Object arg2 = stack[sp - 1]; + Object result = AddOperation.add((long) arg1, (long) arg2); + stack[sp - 2] = result; + sp -= 1; + nextBci = bci + 1; + break; + } + case OP_LESS_THAN_OPERATION: { + Object arg1 = stack[sp - 2]; + Object arg2 = stack[sp - 1]; + Object result = LessThanOperation.lessThan((long) arg1, (long) arg2); + stack[sp - 2] = result; + sp -= 1; + nextBci = bci + 1; + break; + } + default: + throw new RuntimeException("invalid opcode: " + bc[bci]); + } + // System.out.printf(" stack: "); + // for (int i = 0; i < sp; i++) { + // System.out.printf("(%s) %s, ", stack[i].getClass().getName(), stack[i]); + // } + // System.out.println(); + bci = nextBci; + } + + return returnValue; + } + + @Override + public OperationsNode copyUninitialized() { + // TODO Auto-generated method stub + return null; + } + + } + + ArrayList typeStack = new ArrayList<>(); + ArrayList> childStack = new ArrayList<>(); + ArrayList argStack = new ArrayList<>(); + + static class SlOperationsLabel extends OperationLabel { + private boolean marked = false; + private ArrayList toBackfill; + private boolean hasValue = false; + private int value = 0; + + void resolve(byte[] bc, int labelValue) { + assert !hasValue; + hasValue = true; + value = labelValue; + + if (toBackfill != null) { + for (int bci : toBackfill) { + putDestination(bc, bci, value); + } + toBackfill = null; + } + } + + void putValue(byte[] bc, int bci) { + if (hasValue) { + putDestination(bc, bci, value); + } else { + if (toBackfill == null) + toBackfill = new ArrayList<>(); + toBackfill.add(bci); + } + } + } + + @Override + public void reset() { + typeStack.clear(); + childStack.clear(); + childStack.add(new ArrayList<>()); + argStack.clear(); + } + + @Override + public OperationsNode build() { + assert childStack.size() == 1; + SlOperationsBuilderNode[] operations = childStack.get(0).toArray(EMPTY_CHILDREN); + SlOperationsBuilderNode rootNode = new SlOperationsBuilderNode(SlOperationsBuilderNode.Type.BLOCK, new Object[0], operations); + + System.out.printf("resulting tree: %s\n", rootNode); + + byte[] bc = new byte[65535]; + ArrayList consts = new ArrayList<>(); + int len = rootNode.build(bc, 0, consts); + Object[] constsArr = consts.toArray(Object[]::new); + byte[] bcCopy = Arrays.copyOf(bc, len); + + SlOperationsBuilderImpl.SlOperationsBytecodeNode bcnode = new SlOperationsBytecodeNode(bcCopy, constsArr); + return bcnode; + } + + private static final SlOperationsBuilderNode[] EMPTY_CHILDREN = new SlOperationsBuilderNode[0]; + + private void beginOperation(SlOperationsBuilderNode.Type type, Object... arguments) { + assert arguments.length == type.argCount; + typeStack.add(type); + childStack.add(new ArrayList<>()); + argStack.add(arguments); + } + + private void endOperation(SlOperationsBuilderNode.Type type) { + SlOperationsBuilderNode.Type type2 = typeStack.remove(typeStack.size() - 1); + assert type == type2 : "unbalanced begin/ends"; + Object[] args = argStack.remove(argStack.size() - 1); + SlOperationsBuilderNode[] children = childStack.remove(childStack.size() - 1).toArray(EMPTY_CHILDREN); + + SlOperationsBuilderNode node = new SlOperationsBuilderNode(type, args, children); + childStack.get(childStack.size() - 1).add(node); + } + + private void emitOperation(SlOperationsBuilderNode.Type type, Object... args) { + SlOperationsBuilderNode node = new SlOperationsBuilderNode(type, args, EMPTY_CHILDREN); + childStack.get(childStack.size() - 1).add(node); + } + + @Override + public void beginIfThen() { + beginOperation(SlOperationsBuilderNode.Type.IF_THEN); + } + + @Override + public void endIfThen() { + endOperation(SlOperationsBuilderNode.Type.IF_THEN); + } + + @Override + public void beginIfThenElse() { + beginOperation(SlOperationsBuilderNode.Type.IF_THEN_ELSE); + } + + @Override + public void endIfThenElse() { + endOperation(SlOperationsBuilderNode.Type.IF_THEN_ELSE); + } + + @Override + public void beginWhile() { + beginOperation(SlOperationsBuilderNode.Type.WHILE); + } + + @Override + public void endWhile() { + endOperation(SlOperationsBuilderNode.Type.WHILE); + } + + @Override + public void beginBlock() { + beginOperation(SlOperationsBuilderNode.Type.BLOCK); + } + + @Override + public void endBlock() { + endOperation(SlOperationsBuilderNode.Type.BLOCK); + } + + @Override + public void emitConstObject(Object value) { + emitOperation(SlOperationsBuilderNode.Type.CONST_OBJECT, value); + } + + @Override + public void emitConstLong(long value) { + emitOperation(SlOperationsBuilderNode.Type.CONST_LONG, value); + } + + @Override + public void emitLoadLocal(int index) { + emitOperation(SlOperationsBuilderNode.Type.LOAD_LOCAL, index); + } + + @Override + public void beginStoreLocal(int index) { + beginOperation(SlOperationsBuilderNode.Type.STORE_LOCAL, index); + } + + @Override + public void endStoreLocal() { + endOperation(SlOperationsBuilderNode.Type.STORE_LOCAL); + } + + @Override + public void emitLoadArgument(int index) { + emitOperation(SlOperationsBuilderNode.Type.LOAD_ARGUMENT, index); + } + + @Override + public void beginAddOperation() { + beginOperation(SlOperationsBuilderNode.Type.OP_ADD_OPERATION); + } + + @Override + public void endAddOperation() { + endOperation(SlOperationsBuilderNode.Type.OP_ADD_OPERATION); + } + + @Override + public void beginReturn() { + beginOperation(SlOperationsBuilderNode.Type.RETURN); + } + + @Override + public void endReturn() { + endOperation(SlOperationsBuilderNode.Type.RETURN); + } + + @Override + public void beginLessThanOperation() { + beginOperation(SlOperationsBuilderNode.Type.OP_LESS_THAN_OPERATION); + } + + @Override + public void endLessThanOperation() { + endOperation(SlOperationsBuilderNode.Type.OP_LESS_THAN_OPERATION); + } + + @Override + public OperationLabel createLabel() { + return new SlOperationsLabel(); + } + + @Override + public void markLabel(OperationLabel label) { + SlOperationsLabel lbl = (SlOperationsLabel) label; + assert !lbl.marked; + lbl.marked = true; + emitOperation(SlOperationsBuilderNode.Type.LABEL, label); + } + + @Override + public void emitBranch(OperationLabel label) { + emitOperation(SlOperationsBuilderNode.Type.BRANCH, label); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java new file mode 100644 index 000000000000..26c2e6bb43b5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java @@ -0,0 +1,321 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.ArrayList; + +import com.oracle.truffle.api.operation.test.example.SlOperationsBuilderImpl.SlOperationsLabel; + +class SlOperationsBuilderNode { + + private enum ValueResult { + NEVER, + ALWAYS, + DIVERGES + } + + public enum Type { + // primitive + BLOCK(0, -1), + IF_THEN(0, 2), + IF_THEN_ELSE(0, 3), + WHILE(0, 2), + CONST_OBJECT(1, 0), + CONST_LONG(1, 0), + LOAD_LOCAL(1, 0), + STORE_LOCAL(1, 1), + LOAD_ARGUMENT(1, 0), + RETURN(0, 1), + LABEL(1, 0), + BRANCH(1, 0), + // custom + OP_ADD_OPERATION(0, 2), + OP_LESS_THAN_OPERATION(0, 2); + + public final int argCount; + public final int childCount; + + private Type(int argCount, int childCount) { + this.argCount = argCount; + this.childCount = childCount; + } + } + + public final SlOperationsBuilderNode.Type type; + public final Object[] arguments; + public final SlOperationsBuilderNode[] children; + private final SlOperationsBuilderNode.ValueResult producesValue; + + public SlOperationsBuilderNode(SlOperationsBuilderNode.Type type, Object[] arguments, SlOperationsBuilderNode[] children) { + assert arguments.length == type.argCount; + assert type.childCount == -1 || children.length == type.childCount; + this.type = type; + this.arguments = arguments; + this.children = children; + + switch (type) { + case BLOCK: + if (children.length == 0) + producesValue = ValueResult.NEVER; + else + producesValue = children[children.length - 1].producesValue; + break; + case IF_THEN_ELSE: + assert children[0].producesValue != ValueResult.NEVER; + if (children[1].producesValue == ValueResult.NEVER || children[2].producesValue == ValueResult.NEVER) { + producesValue = ValueResult.NEVER; + } else { + producesValue = ValueResult.ALWAYS; + } + break; + case IF_THEN: + case WHILE: + case STORE_LOCAL: + assert children[0].producesValue != ValueResult.NEVER; + producesValue = ValueResult.NEVER; + break; + case OP_ADD_OPERATION: + case OP_LESS_THAN_OPERATION: + case CONST_OBJECT: + case CONST_LONG: + case LOAD_LOCAL: + case LOAD_ARGUMENT: + for (SlOperationsBuilderNode child : children) { + assert child.producesValue != ValueResult.NEVER : "" + this; + } + producesValue = ValueResult.ALWAYS; + break; + case RETURN: + case BRANCH: + producesValue = ValueResult.DIVERGES; + break; + case LABEL: + producesValue = ValueResult.NEVER; + break; + default: + throw new RuntimeException(); + + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("("); + sb.append(type); + for (SlOperationsBuilderNode child : children) { + sb.append(" "); + sb.append(child); + } + sb.append(")"); + return sb.toString(); + } + + final int build(byte[] bc, int inBci, ArrayList consts) { + int bci = inBci; + // System.out.println("building " + this); + + switch (type) { + case BLOCK: { + for (int i = 0; i < children.length; i++) { + bci = children[i].build(bc, bci, consts); + if (i != children.length - 1 && children[i].producesValue == ValueResult.ALWAYS) { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; + } + } + break; + } + case IF_THEN: { + bci = children[0].build(bc, bci, consts); + + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; + int targetDest = bci; + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + + bci = children[1].build(bc, bci, consts); + if (children[1].producesValue == ValueResult.ALWAYS) + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; + + SlOperationsBuilderImpl.putDestination(bc, targetDest, bci); + break; + } + case IF_THEN_ELSE: { + bci = children[0].build(bc, bci, consts); + + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; + int elseDest = bci; + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + + bci = children[1].build(bc, bci, consts); + if (children[1].producesValue == ValueResult.ALWAYS && producesValue == ValueResult.NEVER) + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; + + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; + int endDest = bci; + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + + SlOperationsBuilderImpl.putDestination(bc, elseDest, bci); + + bci = children[2].build(bc, bci, consts); + if (children[2].producesValue == ValueResult.ALWAYS && producesValue == ValueResult.NEVER) + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; + + SlOperationsBuilderImpl.putDestination(bc, endDest, bci); + break; + } + case WHILE: { + int startBci = bci; + + bci = children[0].build(bc, bci, consts); + + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; + int endDest = bci; + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + + bci = children[1].build(bc, bci, consts); + if (children[1].producesValue == ValueResult.ALWAYS) + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; + + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; + SlOperationsBuilderImpl.putDestination(bc, bci, startBci); + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + + SlOperationsBuilderImpl.putDestination(bc, endDest, bci); + break; + } + case LABEL: { + SlOperationsLabel label = (SlOperationsLabel) arguments[0]; + label.resolve(bc, bci); + break; + } + case BRANCH: { + SlOperationsLabel label = (SlOperationsLabel) arguments[0]; + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; + label.putValue(bc, bci); + bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; + break; + } + case CONST_OBJECT: + case CONST_LONG: + case LOAD_LOCAL: + case STORE_LOCAL: + case LOAD_ARGUMENT: + case RETURN: + case OP_ADD_OPERATION: + case OP_LESS_THAN_OPERATION: { + for (SlOperationsBuilderNode child : children) { + bci = child.build(bc, bci, consts); + } + + switch (type) { + case CONST_LONG: + case CONST_OBJECT: { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_CONST_OBJECT; + SlOperationsBuilderImpl.putConst(bc, bci, arguments[0], consts); + bci += SlOperationsBuilderImpl.IMM_CONST_LENGTH; + break; + } + case LOAD_LOCAL: { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_LOAD_LOCAL; + SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); + bci += 2; + break; + } + case STORE_LOCAL: { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_STORE_LOCAL; + SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); + bci += 2; + break; + } + case LOAD_ARGUMENT: { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_LOAD_ARGUMENT; + SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); + bci += 2; + break; + } + case RETURN: { + bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_RETURN; + break; + } + case OP_ADD_OPERATION: { + bc[bci++] = SlOperationsBuilderImpl.OP_ADD_OPERATION; + break; + } + case OP_LESS_THAN_OPERATION: { + bc[bci++] = SlOperationsBuilderImpl.OP_LESS_THAN_OPERATION; + break; + } + } + break; + } + default: { + throw new RuntimeException("" + type); + } + } + + return bci; + } + + public static String dump(byte[] bc, Object[] consts) { + StringBuilder sb = new StringBuilder(); + + for (int bci = 0; bci < bc.length;) { + sb.append(String.format(" %04x ", bci)); + switch (bc[bci]) { + case SlOperationsBuilderImpl.PRIM_OP_NOP: + sb.append("nop"); + bci += 1; + break; + case SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE: + sb.append(String.format("jp_f %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); + bci += 3; + break; + + case SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP: + sb.append(String.format("jp %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); + bci += 3; + break; + case SlOperationsBuilderImpl.PRIM_OP_CONST_OBJECT: { + int index = SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1); + sb.append(String.format("const #%d // (%s) %s", index, consts[index].getClass().getName(), consts[index])); + bci += 3; + break; + } + case SlOperationsBuilderImpl.PRIM_OP_POP: + sb.append("pop"); + bci += 1; + break; + case SlOperationsBuilderImpl.PRIM_OP_RETURN: + sb.append("ret"); + bci += 1; + break; + case SlOperationsBuilderImpl.PRIM_OP_LOAD_ARGUMENT: + sb.append(String.format("ldarg %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); + bci += 3; + break; + case SlOperationsBuilderImpl.PRIM_OP_LOAD_LOCAL: + sb.append(String.format("ldloc %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); + bci += 3; + break; + case SlOperationsBuilderImpl.PRIM_OP_STORE_LOCAL: + sb.append(String.format("stloc %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); + bci += 3; + break; + case SlOperationsBuilderImpl.OP_ADD_OPERATION: + sb.append("op AddOperation"); + bci += 1; + break; + case SlOperationsBuilderImpl.OP_LESS_THAN_OPERATION: + sb.append("op LessThanOperation"); + bci += 1; + break; + default: + sb.append(String.format("unknown %02x", bc[bci])); + bci += 1; + break; + } + sb.append("\n"); + } + + return sb.toString(); + } + +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java deleted file mode 100644 index 4a7322a0fc15..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import static com.oracle.truffle.api.operation.Operation.Kind.CONDITIONAL; -import static com.oracle.truffle.api.operation.Operation.Kind.LOCAL; -import static com.oracle.truffle.api.operation.Operation.Kind.META; -import static com.oracle.truffle.api.operation.Operation.Kind.NODE; -import static com.oracle.truffle.api.operation.Operation.Kind.PROFILE; -import static com.oracle.truffle.api.operation.Operation.Kind.REPEATING; -import static com.oracle.truffle.api.operation.Operation.Kind.RETURN; -import static com.oracle.truffle.api.operation.Operation.Kind.SOURCE; -import static com.oracle.truffle.api.operation.Operation.Kind.TAG; -import static com.oracle.truffle.api.operation.Operation.Kind.UNWIND; - -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrumentation.ProvidedTags; -import com.oracle.truffle.api.instrumentation.StandardTags.RootBodyTag; -import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; -import com.oracle.truffle.api.operation.GenerateOperations; -import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.Operation.EndInput; -import com.oracle.truffle.api.operation.Operation.LocalInput; -import com.oracle.truffle.api.operation.Operation.OnBuild; -import com.oracle.truffle.api.operation.Operation.OnEnter; -import com.oracle.truffle.api.operation.Operation.OnExecute; -import com.oracle.truffle.api.operation.Operation.StartInput; -import com.oracle.truffle.api.operation.Operation.StaticInput; -import com.oracle.truffle.api.operation.OperationPointer; -import com.oracle.truffle.api.profiles.ConditionProfile; - -@GenerateOperations -class TestOperations { - - @Operation(value = LOCAL) - static class Body { - - @OnEnter - static int[] locals(VirtualFrame frame, @LocalInput int[] locals, - @EndInput int localCount, - @EndInput int argumentCount) { - assert locals == null : "locals alraedy created"; - int[] newLocals = new int[localCount]; - Object[] arguments = frame.getArguments(); - for (int i = 0; i < argumentCount; i++) { - newLocals[i] = (int) arguments[i]; - } - return newLocals; - } - } - - @Operation(NODE) - static class ReadLocal { - - @OnExecute - static int doDefault(@LocalInput int[] locals, - @StartInput int localIndex) { - return locals[localIndex]; - } - } - - @Operation(NODE) - static class WriteLocal { - - @OnExecute - static void doDefault(@LocalInput int[] locals, - @StartInput short localIndex, - int value) { - locals[localIndex] = value; - } - } - - @Operation(META) - static class LocalNames { - - @OnExecute - static String[] localNames(@EndInput String[] localNames) { - // validate ? - return localNames; - } - } - - @Operation(REPEATING) - static class While { - - @OnExecute - static boolean doDefault(boolean condition) { - return condition; - } - } - - @Operation(CONDITIONAL) - static class If { - - @OnExecute - static boolean execute(boolean condition) { - return condition; - } - } - - @Operation(UNWIND) - static class BreakWhile { - - @OnBuild - static OperationPointer skipLoops(@StaticInput OperationPointer current, @StartInput int skipIndex) { - int whileIndex = 0; - while (current.parent()) { - if (current.get() == TestOperations.While.class) { - if (whileIndex == skipIndex) { - break; - } - whileIndex++; - } - } - return current; - } - - } - - @Operation(RETURN) - static class Return { - - @OnEnter - static Object doDefault(Object v) { - return v; - } - - } - - @Operation(UNWIND) - static class ContinueWhile extends TestOperations.BreakWhile { - // inherited from BreakWhile - - @OnBuild - static OperationPointer onBuild(@StaticInput OperationPointer current, @StartInput int skipIndex) { - return BreakWhile.skipLoops(current, skipIndex); - } - } - - @Operation(PROFILE) - static class Condition { - @Specialization - static boolean doCondition(boolean input, @Cached("createCountingProfile()") ConditionProfile profile) { - return profile.profile(input); - } - } - - @Operation(SOURCE) - static class Source { - } - - @Operation(TAG) - @ProvidedTags(StatementTag.class) - static class Statement { - } - - @Operation(TAG) - @ProvidedTags(TestOperations.RootTag.class) - static class RootTag { - } - - @Operation(TAG) - @ProvidedTags(RootBodyTag.class) - static class RootBody { - } - - @Operation(NODE) - static class LessThan { - - @OnExecute - static boolean doDefault(int left, int right) { - return left < right; - } - } - - @Operation(NODE) - static class GreaterThan { - - @OnExecute - static boolean doDefault(int left, int right) { - return left > right; - } - - } - - @Operation(NODE) - static class ConstantInt { - - @OnExecute - static int value(@StartInput int constant) { - return constant; - } - - } - - @Operation(NODE) - static class Add { - - @OnExecute - static int doAdd(int left, int right) { - return left + right; - } - - } - - @Operation(NODE) - static class ConstantString { - - @OnExecute - static String value(@StartInput String input) { - return input; - } - - } - - @Operation(NODE) - static class NoOp { - } - - @FunctionalInterface - interface SourceOffsetProvider { - - int currentIndex(Object source); - - } - -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java deleted file mode 100644 index 0c20d3096101..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsBuilder.java +++ /dev/null @@ -1,1108 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.Arrays; -import java.util.NoSuchElementException; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.CompilerDirectives.ValueType; -import com.oracle.truffle.api.HostCompilerDirectives; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.memory.ByteArraySupport; -import com.oracle.truffle.api.nodes.ControlFlowException; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.Operation.Kind; -import com.oracle.truffle.api.operation.OperationPointer; -import com.oracle.truffle.api.operation.OperationsBuilder; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.test.example.TestOperations.Add; -import com.oracle.truffle.api.operation.test.example.TestOperations.Body; -import com.oracle.truffle.api.operation.test.example.TestOperations.ConstantInt; -import com.oracle.truffle.api.operation.test.example.TestOperations.ConstantString; -import com.oracle.truffle.api.operation.test.example.TestOperations.GreaterThan; -import com.oracle.truffle.api.operation.test.example.TestOperations.If; -import com.oracle.truffle.api.operation.test.example.TestOperations.ReadLocal; -import com.oracle.truffle.api.operation.test.example.TestOperations.SourceOffsetProvider; - -abstract class TestOperationsBuilder extends OperationsBuilder { - - private TestOperationsBuilder() { - } - - private void startTag(int opCode) { - } - - private void endTag(int opCode) { - } - - public void startSource(Object source, SourceOffsetProvider provider) { - } - - public void endSource() { - } - - private void endSourceOp() { - - } - - private boolean verifyStart(int opAdd) { - return true; - } - - private boolean verifyEnd(int opAdd) { - return true; - } - - public void startBody() { - - } - - public void endBody(int localCount, int argumentCount) { - - } - - public void startStatement() { - - } - - public void endStatement() { - - } - - public void startReturn() { - - } - - public void startAdd() { - - } - - public void endAdd() { - - } - - public void startWhile() { - } - - public void endWhile() { - } - - public void startIf() { - } - - public void startGreaterThan() { - } - - public void startLessThan() { - } - - public void endLessThan() { - } - - public void endGreaterThan() { - } - - public void endIf() { - } - - public void endReturn() { - } - - public void startLocalWrite(int localIndex) { - } - - public void endLocalWrite() { - } - - public void pushLocalRead(int varIndex) { - } - - public void pushNoOp() { - } - - public int resolveVariableRead(String identifier) { - return 0; - } - - public void pushConstantInt(int value) { - } - - public void pushBreakWhile(int skipIndex) { - } - - public void pushContinueWhile(int skipIndex) { - } - - public abstract OperationsNode build(); - - public void reset() { - } - - public static TestOperationsBuilder createASTBuilder() { - return new ASTInterpreterBuilder(); - } - - public static TestOperationsBuilder createBytecodeBuilder() { - return new BytecodeInterpreterBuilder(); - } - - @ValueType - static final class ASTPointer extends OperationPointer { - - ASTNode node; - - ASTPointer(ASTNode node) { - this.node = node; - } - - @Override - public boolean parent() { - this.node = (ASTNode) node.getParent(); - return this.node != null; - } - - @Override - public void child(int childIndex) { - node = node.childAt(childIndex); - } - - @Override - public int childCount() { - return node.childCount(); - } - - @Override - public boolean isValid() { - return false; - } - - @Override - public Class get() throws NoSuchElementException { - return null; - } - - @Override - public Kind getKind() throws NoSuchElementException { - return get().getAnnotation(Operation.class).value(); - } - - @Override - public T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException { - return expectedClass.cast(node.getConstant(constantIndex)); - } - - } - - static final class AST extends OperationsNode { - - @Child ASTNode content; - - AST(ASTNode content) { - this.content = content; - } - - @Override - public Object execute(VirtualFrame frame) { - try { - return content.execute(frame, null); - } catch (ReturnException e) { - return e.value; - } - } - - @Override - public OperationPointer createPointer() { - return new ASTPointer(content); - } - - @Override - public Object continueAt(VirtualFrame frame, OperationPointer index) { - throw new UnsupportedOperationException(); - } - - @Override - public OperationsNode copyUninitialized() { - throw new UnsupportedOperationException(); - } - - } - - static abstract class ASTNode extends Node { - - abstract int execute(VirtualFrame frame, int[] locals); - - void onBuild() { - } - - ASTNode childAt(int childIndex) { - int index = 0; - for (Node child : getChildren()) { - if (child instanceof ASTNode) { - if (index == childIndex) { - return (ASTNode) child; - } - index++; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new ArrayIndexOutOfBoundsException(String.valueOf(childIndex)); - } - - @TruffleBoundary - int childCount() { - int count = 0; - for (Node node : getChildren()) { - if (node instanceof ASTNode) { - count++; - } - } - return count; - } - - Class getOperation() { - return null; - } - - Object getConstant(int index) { - throw new ArrayIndexOutOfBoundsException(); - } - - } - - static final class AddNode extends ASTNode { - - @Child private ASTNode left; - @Child private ASTNode right; - - @Override - int execute(VirtualFrame frame, int[] locals) { - int leftValue = left.execute(frame, locals); - int rightValue = right.execute(frame, locals); - return TestOperations.Add.doAdd(leftValue, rightValue); - } - - } - - static final class GreaterThanNode extends ASTNode { - - @Child private ASTNode left; - @Child private ASTNode right; - - @Override - int execute(VirtualFrame frame, int[] locals) { - int leftValue = left.execute(frame, locals); - int rightValue = right.execute(frame, locals); - return TestOperations.GreaterThan.doDefault(leftValue, rightValue) ? 1 : 0; - } - - } - - static final class ReturnNode extends ASTNode { - - @Child ASTNode operand; - - @Override - int execute(VirtualFrame frame, int[] locals) { - int v = operand.execute(frame, locals); - throw new ReturnException(v); - } - - } - - static final class ReturnException extends ControlFlowException { - - final Object value; - - ReturnException(Object value) { - this.value = value; - } - } - - static final class BodyNode extends ASTNode { - - @Child private ASTNode child; - @CompilationFinal private int localCount; - @CompilationFinal private int argumentCount; - - @Override - int execute(VirtualFrame frame, int[] locals) { - int[] newLocals = Body.locals(frame, locals, localCount, argumentCount); - return child.execute(frame, newLocals); - } - - } - - static final class ConstantNode extends ASTNode { - - private final int constantValue; - - ConstantNode(int constantValue) { - this.constantValue = constantValue; - } - - @Override - int execute(VirtualFrame frame, int[] locals) { - return constantValue; - } - - } - - static final class LocalReadNode extends ASTNode { - - private final int index; - - LocalReadNode(int index) { - this.index = index; - } - - @Override - int execute(VirtualFrame frame, int[] locals) { - return ReadLocal.doDefault(locals, index); - } - - } - - static final class IfNode extends ASTNode { - - @Child private ASTNode condition; - @Child private ASTNode thenNode; - @Child private ASTNode elseNode; - - @Override - int execute(VirtualFrame frame, int[] locals) { - boolean cond = condition.execute(frame, locals) != 0; - if (TestOperations.If.execute(cond)) { - return thenNode.execute(frame, locals); - } else { - return elseNode.execute(frame, locals); - } - } - - } - - static final class ASTInterpreterBuilder extends TestOperationsBuilder { - - final ASTNode[] nodeStack = new ASTNode[1024]; - - int currentIndex = -1; - - @Override - public void pushConstantInt(int value) { - pushNode(new ConstantNode(value)); - } - - @Override - public void pushLocalRead(int localIndex) { - assert assertEnclosingBody(); - pushNode(new LocalReadNode(localIndex)); - } - - @Override - public void startBody() { - pushNode(new BodyNode()); - } - - @Override - public void startGreaterThan() { - pushNode(new GreaterThanNode()); - } - - @Override - public void endGreaterThan() { - ASTNode right = popNode(ASTNode.class); - ASTNode left = popNode(ASTNode.class); - GreaterThanNode op = peekNode(GreaterThanNode.class); - op.left = left; - op.right = right; - } - - @Override - public void endBody(int localCount, int argumentCount) { - ASTNode child = popNode(ASTNode.class); - BodyNode locals = peekNode(BodyNode.class); - locals.child = child; - locals.localCount = localCount; - locals.argumentCount = argumentCount; - } - - @Override - public void startReturn() { - pushNode(new ReturnNode()); - } - - private boolean assertEnclosingBody() { - BodyNode body = findNode(BodyNode.class); - if (body == null) { - throw new AssertionError("No enclosing Body operation found but expected by operations use of LocalInput."); - } - return true; - } - - @SuppressWarnings("unchecked") - private T findNode(Class nodeClass) { - for (int i = 0; i < nodeStack.length; i++) { - ASTNode node = nodeStack[i]; - if (nodeClass.isInstance(node)) { - return nodeClass.cast(node); - } - } - return null; - } - - @Override - public void endReturn() { - ASTNode node = popNode(ASTNode.class); - peekNode(ReturnNode.class).operand = node; - } - - @Override - public void startAdd() { - pushNode(new AddNode()); - } - - @Override - public void endAdd() { - ASTNode right = popNode(ASTNode.class); - ASTNode left = popNode(ASTNode.class); - AddNode add = peekNode(AddNode.class); - add.left = left; - add.right = right; - } - - @Override - public void startIf() { - pushNode(new IfNode()); - } - - @Override - public void endIf() { - ASTNode elseBranch = popNode(ASTNode.class); - ASTNode thenBranch = popNode(ASTNode.class); - ASTNode condition = popNode(ASTNode.class); - IfNode op = peekNode(IfNode.class); - op.condition = condition; - op.thenNode = thenBranch; - op.elseNode = elseBranch; - } - - private void pushNode(ASTNode node) { - nodeStack[++currentIndex] = node; - } - - private T popNode(Class nodeClass) { - if (currentIndex == -1) { - throw new IllegalStateException("No nodes on stack."); - } - ASTNode node = nodeStack[currentIndex]; - nodeStack[currentIndex--] = null; - return nodeClass.cast(node); - } - - private T peekNode(Class nodeClass) { - return nodeClass.cast(nodeStack[currentIndex]); - } - - @Override - public OperationsNode build() { - ASTNode node = popNode(ASTNode.class); - AST ast = new AST(node); - node.adoptChildren(); - node.onBuild(); - onBuild(ast); - return ast; - } - - @Override - public void reset() { - if (currentIndex != -1) { - Arrays.fill(nodeStack, 0, currentIndex, null); - } - } - - @Override - public String toString() { - return "ASTInterpreterBuilder"; - } - - } - - static final class BytecodePointer extends OperationPointer { - - private final byte[] bytecodes; - private int bci; - - BytecodePointer(byte[] bytecodes) { - this.bytecodes = bytecodes; - } - - @Override - public boolean parent() { - return false; - } - - @Override - public void child(int childIndex) { - } - - @Override - public int childCount() { - return 0; - } - - @Override - public boolean isValid() { - return false; - } - - @Override - public Class get() throws NoSuchElementException { - return null; - } - - @Override - public Kind getKind() throws NoSuchElementException { - return null; - } - - @Override - public T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException { - return null; - } - - } - - static final class BytecodeNode extends OperationsNode { - - private static final int OP_BODY = 1; - private static final int OP_READ_LOCAL = 2; - private static final int OP_WRITE_LOCAL = 3; - private static final int OP_IF = 4; - private static final int OP_BREAK_WHILE = 5; - private static final int OP_CONTINUE_WHILE = 6; - private static final int OP_LESS_THAN = 7; - private static final int OP_GREATER_THAN = 8; - private static final int OP_CONSTANT_INT = 9; - private static final int OP_CONSTANT_STRING_BYTE = 10; - private static final int OP_CONSTANT_STRING_SHORT = 11; - private static final int OP_ADD = 12; - private static final int OP_RETURN = 13; - - private static final int OP_BRANCH = 14; - - private static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); - - @CompilationFinal(dimensions = 1) private final byte[] bytecodes; - private final int maxStack; - @CompilationFinal(dimensions = 1) final Object[] finalData; - @CompilationFinal(dimensions = 1) final Object[] mutableData; - - protected BytecodeNode(byte[] bytecodes, int maxStack, Object[] finalData, Object[] mutableData) { - this.bytecodes = bytecodes; - this.maxStack = maxStack; - this.finalData = finalData; - this.mutableData = mutableData; - } - - @Override - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @HostCompilerDirectives.BytecodeInterpreterSwitch - public Object execute(VirtualFrame frame) { - byte[] b = this.bytecodes; // bytecodes - int bLength = b.length; - int bci = 0; // bytecode index - int sp = 0; // stack pointer - final int[] pStack = new int[maxStack]; - final Object[] rStack = new Object[maxStack]; - final Object[] constants = this.finalData; - - int[] locals = null; - while (bci < bLength) { - int op = b[bci++]; - switch (op) { - case OP_BODY: - locals = Body.locals(frame, locals, BYTES.getInt(b, bci), BYTES.getInt(b, bci + 4)); - bci += 8; - break; - case OP_ADD: - executeAdd(pStack, sp); - sp--; - break; - case OP_RETURN: - Object value = TestOperations.Return.doDefault(pStack[sp - 1]); - sp--; - return value; - case OP_READ_LOCAL: - writeInt(pStack, sp, ReadLocal.doDefault(locals, BYTES.getInt(b, bci))); - sp++; - bci += 4; - break; - case OP_GREATER_THAN: - executeGreaterThan(pStack, sp); - sp--; - break; - case OP_CONSTANT_INT: - writeInt(pStack, sp, ConstantInt.value(BYTES.getInt(b, bci))); - sp++; - bci += 4; - break; - case OP_CONSTANT_STRING_BYTE: - writeObject(rStack, sp, ConstantString.value(readByteConstantString(b, bci, constants))); - bci += 1; - sp++; - break; - case OP_CONSTANT_STRING_SHORT: - writeObject(rStack, sp, ConstantString.value(readShortConstantString(b, bci, constants))); - bci += 2; - sp++; - break; - case OP_IF: - if (If.execute(readInt(pStack, sp - 1) == 1)) { - bci += 4; - } else { - bci = BYTES.getInt(b, bci); - } - break; - default: - throw new UnsupportedOperationException(String.valueOf(op)); - - } - } - return null; - } - - private static int bytecodeIndexOf(byte[] b, int byteIndex) { - int bLength = b.length; - int bci = 0; // bytecode index - int bytecodeIndex = 0; - while (bci < bLength) { - if (bci == byteIndex) { - return bytecodeIndex; - } - int op = b[bci++]; - try { - bci += bytecodeSize(op); - } catch (UnsupportedOperationException e) { - return -1; - } - bytecodeIndex++; - } - return -1; - } - - private static int bytecodeSize(int op) { - switch (op) { - case OP_BODY: - return 8; - case OP_ADD: - case OP_RETURN: - case OP_GREATER_THAN: - return 0; - case OP_CONSTANT_STRING_BYTE: - return 1; - case OP_CONSTANT_STRING_SHORT: - return 2; - case OP_READ_LOCAL: - case OP_CONSTANT_INT: - case OP_IF: - case OP_BRANCH: - return 4; - default: - throw new UnsupportedOperationException(String.valueOf(op)); - } - } - - private static String printBytecodes(String indent, byte[] b, Object[] constants) { - StringBuilder s = new StringBuilder(); - int bLength = b.length; - int bci = 0; // bytecode index - - while (bci < bLength) { - s.append(indent); - s.append(bci).append(":"); - int op = b[bci++]; - switch (op) { - case OP_BODY: - s.append("Body"); - s.append(" locals:").append(BYTES.getInt(b, bci)); - s.append(" arguments:").append(BYTES.getInt(b, bci + 4)); - bci += 8; - break; - case OP_ADD: - s.append("Add"); - break; - case OP_GREATER_THAN: - s.append("GreaterThan"); - break; - case OP_RETURN: - s.append("Return"); - break; - case OP_READ_LOCAL: - s.append("ReadLocal"); - s.append(" index:").append(BYTES.getInt(b, bci)); - bci += 4; - break; - case OP_CONSTANT_INT: - s.append("ConstantInt"); - s.append(" value:").append(BYTES.getInt(b, bci)); - bci += 4; - break; - case OP_CONSTANT_STRING_BYTE: - s.append("ConstantString"); - s.append(" value:\"").append(readByteConstantString(b, bci, constants)).append("\""); - bci += 1; - break; - case OP_CONSTANT_STRING_SHORT: - s.append("ConstantString"); - s.append(" value:\"").append(readShortConstantString(b, bci, constants)).append("\""); - bci += 2; - break; - case OP_IF: - s.append("If"); - s.append(" !target:").append(BYTES.getInt(b, bci)); - bci += 4; - break; - case OP_BRANCH: - s.append("Branch"); - s.append(" target:").append(BYTES.getInt(b, bci)); - bci += 4; - break; - case 0: - break; - default: - throw new UnsupportedOperationException(String.valueOf(op) + "\n" + s.toString()); - } - s.append(System.lineSeparator()); - } - return s.toString(); - } - - private static String formatTarget(int target) { - return "0x" + Integer.toHexString(target); - } - - private static String readByteConstantString(byte[] bytecodes, int bci, Object[] constants) { - return (String) constants[Byte.toUnsignedInt(BYTES.getByte(bytecodes, bci))]; - } - - private static String readShortConstantString(byte[] bytecodes, int bci, Object[] constants) { - return (String) constants[Short.toUnsignedInt(BYTES.getShort(bytecodes, bci))]; - } - - @Override - public OperationPointer createPointer() { - return null; - } - - private static void executeAdd(int[] stack, int stackPointer) { - int right = readInt(stack, stackPointer - 1); - int left = readInt(stack, stackPointer - 2); - writeInt(stack, stackPointer - 2, Add.doAdd(left, right)); - } - - private static void executeGreaterThan(int[] stack, int stackPointer) { - int right = readInt(stack, stackPointer - 1); - int left = readInt(stack, stackPointer - 2); - writeInt(stack, stackPointer - 2, GreaterThan.doDefault(left, right) ? 1 : 0); - } - - private static void writeInt(int[] stack, int index, int value) { - stack[index] = value; - } - - private static void writeObject(Object[] stack, int index, Object value) { - // TODO - } - - private static int readInt(int[] stack, int index) { - int result = stack[index]; - if (CompilerDirectives.inCompiledCode()) { - // Needed to avoid keeping track of popped slots in FrameStates. - stack[index] = 0; - } - return result; - } - - @Override - public OperationsNode copyUninitialized() { - throw new UnsupportedOperationException(); - } - - @Override - public Object continueAt(VirtualFrame frame, OperationPointer index) { - throw new UnsupportedOperationException(); - } - - @Override - public String toString() { - return printBytecodes("", this.bytecodes, this.finalData); - } - - } - - final static class BytecodeInterpreterBuilder extends TestOperationsBuilder { - - private static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); - - private static final int SHORT_MASK = 0x000000AF; - private static final int WIDE_MASK = 0x0000AFFF; - - private byte[] byteBuffer = new byte[1024]; - private int bufferIndex; - - private int[] opBuffer = new int[1024]; - private int opIndex; - - private int finalBufferIndex; - private Object[] finalBuffer = new Object[1024]; - - private int stackSize; - private int maxStack; - - BytecodeInterpreterBuilder() { - this.opIndex = 0; - } - - @Override - public OperationsNode build() { - byte[] bc = Arrays.copyOf(byteBuffer, bufferIndex); - Object[] imBuffer = Arrays.copyOf(finalBuffer, finalBufferIndex); - Object[] mutableBuffer = new Object[0]; - BytecodeNode bcNode = new BytecodeNode(bc, maxStack, imBuffer, mutableBuffer); - onBuild(bcNode); - return bcNode; - } - - @Override - public void startBody() { - pushStack(); - writeOp(BytecodeNode.OP_BODY); - writeInt(0); // patched in end - writeInt(0); // patched in end - } - - @Override - public void endBody(int localCount, int argumentCount) { - popStack(); // child - int index = peekStack(BytecodeNode.OP_BODY); - BYTES.putInt(byteBuffer, index + 1, localCount); - BYTES.putInt(byteBuffer, index + 5, argumentCount); - } - - @Override - public void pushLocalRead(int index) { - pushStack(); - writeOp(BytecodeNode.OP_READ_LOCAL); - writeInt(index); - stackChange(1); - } - - @Override - public void startReturn() { - pushStack(); - } - - @Override - public void endReturn() { - popStack(); - peekStack(BytecodeNode.OP_RETURN); - writeOp(BytecodeNode.OP_RETURN); - stackChange(-1); - } - - @Override - public void reset() { - bufferIndex = 0; - opIndex = 0; - finalBufferIndex = 0; - stackSize = 0; - maxStack = 0; - } - - @Override - public void startGreaterThan() { - pushStack(); - } - - @Override - public void endGreaterThan() { - popStack(); // right - popStack(); // left - peekStack(BytecodeNode.OP_ADD); - - writeOp(BytecodeNode.OP_GREATER_THAN); - stackChange(-1); - } - - @Override - public void startIf() { - pushStack(); - } - - @Override - public void endIf() { - int elseBranch = popStack(); - int thenIndex = popStack(); // then index - int condition = popStack(); - - insertSpace(thenIndex, 5); - elseBranch += 5; - writeByte(byteBuffer, thenIndex, BytecodeNode.OP_IF); - writeInt(byteBuffer, thenIndex + 1, elseBranch + 5); // else index - - insertSpace(elseBranch, 5); - writeByte(byteBuffer, elseBranch, BytecodeNode.OP_BRANCH); - writeInt(byteBuffer, elseBranch + 1, bufferIndex); - } - - private void insertSpace(int index, int bytes) { - System.arraycopy(byteBuffer, index, byteBuffer, index + bytes, byteBuffer.length - index - bytes); - Arrays.fill(byteBuffer, index, index + bytes, (byte) 0); - bufferIndex += bytes; - } - - @Override - public void pushConstantInt(int value) { - pushStack(); - writeOp(BytecodeNode.OP_CONSTANT_INT); - writeInt(value); - stackChange(1); - } - - @Override - public void startAdd() { - pushStack(); - } - - @Override - public void endAdd() { - popStack(); // right - popStack(); // left - peekStack(BytecodeNode.OP_ADD); - - writeOp(BytecodeNode.OP_ADD); - stackChange(-1); - } - - public void stackChange(int change) { - stackSize += change; - if (stackSize > maxStack) { - maxStack = stackSize; - } - } - - protected final void pushRef(int cpIndex) { - pushShort(cpIndex); - } - - private void pushByte(int v) { - ensureSize(1); - writeByte(byteBuffer, bufferIndex, v); - bufferIndex = bufferIndex + 1; - } - - private void pushShort(int v) { - ensureSize(2); - writeShort(byteBuffer, bufferIndex, v); - bufferIndex = bufferIndex + 2; - } - - private void ensureSize(int length) { - if (bufferIndex + length >= byteBuffer.length) { - byteBuffer = Arrays.copyOf(byteBuffer, byteBuffer.length << 1); - } - } - - private void writeInt(int v) { - ensureSize(4); - writeInt(byteBuffer, bufferIndex, v); - bufferIndex = bufferIndex + 4; - } - - private int popInt() { - bufferIndex = bufferIndex - 4; - return readInt(byteBuffer, bufferIndex); - } - - private int popShort() { - bufferIndex = bufferIndex - 2; - return readShort(byteBuffer, bufferIndex); - } - - private int popByte() { - bufferIndex = bufferIndex - 1; - return readByte(byteBuffer, bufferIndex); - } - - private static void writeInt(byte[] b, int index, int v) { - BYTES.putInt(b, index, v); - } - - private static void writeByte(byte[] b, int index, int v) { - BYTES.putByte(b, index, (byte) (v & 0x000000FF)); - } - - private static void writeShort(byte[] b, int index, int v) { - BYTES.putShort(b, index, (short) (v & 0x0000FFFF)); - } - - private static int readInt(byte[] b, int index) { - return BYTES.getInt(b, index); - } - - private static int readShort(byte[] b, int index) { - return BYTES.getShort(b, index); - } - - private static int readByte(byte[] b, int index) { - return BYTES.getByte(b, index); - } - - private int peekOp(int skip) { - return opBuffer[opIndex - skip - 1]; - } - - private void writeOp(int op) { - if ((op & SHORT_MASK) == op) { - pushByte(op); - } else if ((op & WIDE_MASK) == op) { - pushShort(op); - } else { - writeInt(op); - } - } - - private void pushStack() { - int i = opIndex++; - if (i >= opBuffer.length) { - opBuffer = Arrays.copyOf(opBuffer, opBuffer.length << 1); - } - opBuffer[i] = bufferIndex; - } - - private int popStack() { - return opBuffer[--opIndex]; - } - - private int peekStack(int expectedOp) { - int op = opBuffer[opIndex - 1]; - - return op; - } - - @Override - public String toString() { - if (bufferIndex == 0) { - return "BytecodeInterpreterBuilder"; - } - String s = BytecodeNode.printBytecodes(" ", Arrays.copyOf(byteBuffer, bufferIndex + 1), - Arrays.copyOf(finalBuffer, finalBufferIndex + 1)); - return "BytecodeInterpreterBuilder[\n" + s + "]"; - } - - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java index cec8e9a321d4..ccca1145ea59 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java @@ -1,45 +1,21 @@ package com.oracle.truffle.api.operation.test.example; -import java.util.Arrays; -import java.util.List; import java.util.function.Consumer; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.runners.JUnit4; import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.test.example.TestOperations.SourceOffsetProvider; -import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest; -import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest.TestRun; -@RunWith(Parameterized.class) +@RunWith(JUnit4.class) public class TestOperationsTest { - private static final TestSourceOffsetProvider PROVIDER = new TestSourceOffsetProvider(); - - public static class TestSourceOffsetProvider implements SourceOffsetProvider { - - public int currentIndex(Object source) { - return 0; - } - } - - @Parameter // first data value (0) is default - public /* NOT private */ TestOperationsBuilder builder; - - @Parameters(name = "{0}") - public static List data() { - return Arrays.asList(TestOperationsBuilder.createBytecodeBuilder(), TestOperationsBuilder.createASTBuilder()); - } - private static class OperationsRootNode extends RootNode { @Child private OperationsNode executable; @@ -56,112 +32,181 @@ public Object execute(VirtualFrame frame) { } - private static void parseAdd(TestOperationsBuilder b) { + private static void parseAdd(SlOperationsBuilder b) { // simple test: // function foo(a, b) { // return (a + b); // } - b.startBody(); - b.startSource("test", PROVIDER); - b.startReturn(); - b.startAdd(); - b.pushLocalRead(0); - b.pushLocalRead(1); - b.endAdd(); + b.beginReturn(); + b.beginAddOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(1); + b.endAddOperation(); b.endReturn(); - b.endSource(); - b.endBody(2, 2); } - private static void parseMax(TestOperationsBuilder b) { + private static void parseMax(SlOperationsBuilder b) { // control flow test: // function max(a, b) { - // if (a > b) { - // return a; - // } else { + // if (a < b) { // return b; + // } else { + // return a; // } - b.startBody(); - b.startIf(); + b.beginIfThenElse(); - b.startGreaterThan(); - b.pushLocalRead(0); // a - b.pushLocalRead(1); // b - b.endGreaterThan(); + b.beginLessThanOperation(); + b.emitLoadArgument(0); // a + b.emitLoadArgument(1); // b + b.endLessThanOperation(); - b.startReturn(); - b.pushLocalRead(0); // a + b.beginReturn(); + b.emitLoadArgument(1); // b b.endReturn(); - b.startReturn(); - b.pushLocalRead(1); // b + b.beginReturn(); + b.emitLoadArgument(0); // a b.endReturn(); - b.endIf(); - b.endBody(2, 2); + b.endIfThenElse(); } @Test public void testAdd() { - runTest(TestOperationsTest::parseAdd, 42, 20, 22); + runTest(TestOperationsTest::parseAdd, 42L, 20L, 22L); } @Test public void testMax() { - runTest(TestOperationsTest::parseMax, 42, 42, 13); - runTest(TestOperationsTest::parseMax, 42, 13, 42); + runTest(TestOperationsTest::parseMax, 42L, 42L, 13L); + runTest(TestOperationsTest::parseMax, 42L, 13L, 42L); } @Test public void testSumLoop() { - runTest(TestOperationsTest::parseSumLoop, 42, 10); + runTest(TestOperationsTest::parseSumLoop, 45L, 10L); + } + + @Test + public void testBreakLoop() { + runTest(TestOperationsTest::parseBreakLoop, 6L, 5L); + runTest(TestOperationsTest::parseBreakLoop, 10L, 15L); } - private void runTest(Consumer parse, Object expectedResult, Object... args) { - TestOperationsBuilder b = builder; + private static void runTest(Consumer parse, Object expectedResult, Object... args) { + SlOperationsBuilder b = SlOperationsBuilder.createBuilder(); parse.accept(b); OperationsNode executable = b.build(); + System.out.println(executable.dump()); b.reset(); System.out.println(executable); - CallTarget target = Truffle.getRuntime().createCallTarget(new OperationsRootNode(executable)); + CallTarget target = new OperationsRootNode(executable).getCallTarget(); Object result = target.call(args); Assert.assertEquals(expectedResult, result); } - private static void parseSumLoop(TestOperationsBuilder b) { + private static void parseSumLoop(SlOperationsBuilder b) { // control flow test: // function sum(length) { // sum = 0; // i = 0; // while (i < length) { // sum += i; + // i += 1; + // } + // return sum; + + b.beginStoreLocal(0); // sum + b.emitConstLong(0); + b.endStoreLocal(); + + b.beginStoreLocal(1); // i + b.emitConstLong(0); + b.endStoreLocal(); + + b.beginWhile(); + + b.beginLessThanOperation(); + b.emitLoadLocal(1); // i + b.emitLoadArgument(0); // length + b.endLessThanOperation(); + + b.beginBlock(); + + b.beginStoreLocal(0); // sum + b.beginAddOperation(); + b.emitLoadLocal(0); + b.emitLoadLocal(1); // i + b.endAddOperation(); + b.endStoreLocal(); + + b.beginStoreLocal(1); + b.beginAddOperation(); + b.emitLoadLocal(1); + b.emitConstLong(1); + b.endAddOperation(); + b.endStoreLocal(); + + b.endBlock(); + + b.endWhile(); + + b.beginReturn(); + b.emitLoadLocal(0); + b.endReturn(); + } + + private static void parseBreakLoop(SlOperationsBuilder b) { + // function breakLoop(input) { + // i = 0; + // while (i < 10) { + // if (input < i) break; + // i += 1; // } + // return i; + + b.beginStoreLocal(0); // i + b.emitConstLong(0); + b.endStoreLocal(); + + OperationLabel breakLbl = b.createLabel(); + + b.beginWhile(); + + b.beginLessThanOperation(); + b.emitLoadLocal(0); // i + b.emitConstLong(10); + b.endLessThanOperation(); - b.startBody(); - b.startLocalWrite(1); - b.pushConstantInt(0); - b.endLocalWrite(); + b.beginBlock(); - b.startLocalWrite(2); - b.pushConstantInt(0); - b.endLocalWrite(); + b.beginIfThen(); - b.startWhile(); + b.beginLessThanOperation(); + b.emitLoadArgument(0); // input + b.emitLoadLocal(0); // i + b.endLessThanOperation(); - b.startLessThan(); - b.pushLocalRead(1); // i - b.pushLocalRead(0); // length - b.endLessThan(); + b.emitBranch(breakLbl); - b.startLocalWrite(2); - b.startAdd(); - b.pushLocalRead(2); - b.pushLocalRead(1); - b.endAdd(); - b.endLocalWrite(); + b.endIfThen(); + + b.beginStoreLocal(0); + b.beginAddOperation(); + b.emitLoadLocal(0); + b.emitConstLong(1); + b.endAddOperation(); + b.endStoreLocal(); + + b.endBlock(); b.endWhile(); - b.endBody(3, 1); + + b.markLabel(breakLbl); + + b.beginReturn(); + b.emitLoadLocal(0); + b.endReturn(); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index 222b7f618cdf..890c42f8a9f5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -1,13 +1,11 @@ package com.oracle.truffle.api.operation; -public @interface GenerateOperations { - - boolean generateASTBuilder() default true; - - boolean generateBytecodeBuilder() default true; - - boolean generateContinueAt() default true; - - String statistics() default ""; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface GenerateOperations { } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index d900b4869291..6686067af2dd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -8,73 +8,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Operation { - - public enum Kind { - PROFILE, - SOURCE, - NODE, - REPEATING, - CONDITIONAL, - UNWIND, - RETURN, - TAG, - META, - LOCAL, - } - - Kind value(); - - int delegateInputs() default 0; - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.PARAMETER}) - public @interface LocalInput { - String value() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.PARAMETER}) - public @interface StaticInput { - String value() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.PARAMETER}) - public @interface StaticOutput { - String value() default ""; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.PARAMETER}) - public @interface StartInput { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.PARAMETER}) - public @interface EndInput { - } - - /** - * Event is executed when the AST is built. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface OnBuild { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface OnEnter { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface OnExecute { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface OnQuickening { - } - } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java new file mode 100644 index 000000000000..3289d438e83f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java @@ -0,0 +1,4 @@ +package com.oracle.truffle.api.operation; + +public abstract class OperationLabel { +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java deleted file mode 100644 index 0962493b67c5..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationPointer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.oracle.truffle.api.operation; - -import java.util.NoSuchElementException; - -public abstract class OperationPointer { - - protected OperationPointer() { - } - - public abstract boolean parent(); - - public abstract void child(int childIndex); - - public abstract int childCount(); - - public abstract boolean isValid(); - - public abstract Class get() throws NoSuchElementException; - - public abstract Operation.Kind getKind() throws NoSuchElementException; - - public abstract T getConstant(Class expectedClass, int constantIndex) throws NoSuchElementException; - -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index a65725d1925c..d439b67c708c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -10,7 +10,7 @@ protected final void onBuild(OperationsNode executable) { if (statistics == null) { return; } - executable.createPointer(); + // executable.createPointer(); } public void setCollectStatistics(boolean statistics) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index b0f0b3303a7e..c2db1078b47e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -4,13 +4,11 @@ import com.oracle.truffle.api.nodes.Node; public abstract class OperationsNode extends Node { - - public abstract OperationPointer createPointer(); - public abstract Object execute(VirtualFrame frame); - public abstract Object continueAt(VirtualFrame frame, OperationPointer index); + public abstract Object continueAt(VirtualFrame frame, OperationLabel index); public abstract OperationsNode copyUninitialized(); + public abstract String dump(); } From 50e2b7084c34042f27391b78246d0c6beb07c023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 2 Mar 2022 13:47:38 +0100 Subject: [PATCH 003/312] [wip] code generation (partial) --- truffle/mx.truffle/suite.py | 4 +- .../operation/test/example/SlOperations.java | 2 +- .../test/example/SlOperationsBuilderImpl.java | 14 +- .../test/example/SlOperationsBuilderNode.java | 6 +- .../test/example/TestOperationsGenTest.java | 212 ++++++ .../api/operation/OperationsBuilder.java | 6 + .../truffle/api/operation/OperationsNode.java | 2 +- .../dsl/processor/TruffleProcessor.java | 4 + .../truffle/dsl/processor/TruffleTypes.java | 13 + .../dsl/processor/model/MessageContainer.java | 4 + .../OperationsBytecodeCodeGenerator.java | 601 ++++++++++++++++ .../operations/OperationsCodeGenerator.java | 639 ++++++++++++++++++ .../processor/operations/OperationsData.java | 128 ++++ .../operations/OperationsParser.java | 120 ++++ 14 files changed, 1738 insertions(+), 17 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 5bff7eeb532f..775dbe35a96c 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -269,7 +269,7 @@ "com.oracle.truffle.api.library" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api.dsl", "com.oracle.truffle.api.utilities"], + "dependencies" : ["com.oracle.truffle.api.dsl", "com.oracle.truffle.api.utilities", "com.oracle.truffle.api.operation"], "requires" : [ "jdk.unsupported", # sun.misc.Unsafe ], @@ -282,7 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.polyglot"], + "dependencies" : ["com.oracle.truffle.api"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index cb9e000de62f..f5a2ff4e2050 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -27,7 +27,7 @@ public static String add(Object left, Object right) { return left.toString() + right.toString(); } - public static boolean isString(Object a, Object b) { + protected static boolean isString(Object a, Object b) { return a instanceof String || b instanceof String; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java index 5143b585df04..ee58815eb69a 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Stack; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.memory.ByteArraySupport; @@ -173,18 +174,11 @@ public Object continueAt(VirtualFrame frame, OperationLabel startIndex) { return returnValue; } - - @Override - public OperationsNode copyUninitialized() { - // TODO Auto-generated method stub - return null; - } - } - ArrayList typeStack = new ArrayList<>(); - ArrayList> childStack = new ArrayList<>(); - ArrayList argStack = new ArrayList<>(); + Stack typeStack = new Stack<>(); + Stack> childStack = new Stack<>(); + Stack argStack = new Stack<>(); static class SlOperationsLabel extends OperationLabel { private boolean marked = false; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java index 26c2e6bb43b5..1df46a9a26cb 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java @@ -256,7 +256,7 @@ final int build(byte[] bc, int inBci, ArrayList consts) { public static String dump(byte[] bc, Object[] consts) { StringBuilder sb = new StringBuilder(); - + for (int bci = 0; bci < bc.length;) { sb.append(String.format(" %04x ", bci)); switch (bc[bci]) { @@ -268,7 +268,7 @@ public static String dump(byte[] bc, Object[] consts) { sb.append(String.format("jp_f %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); bci += 3; break; - + case SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP: sb.append(String.format("jp %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); bci += 3; @@ -314,7 +314,7 @@ public static String dump(byte[] bc, Object[] consts) { } sb.append("\n"); } - + return sb.toString(); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java new file mode 100644 index 000000000000..a48b55452f20 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -0,0 +1,212 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.function.Consumer; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationsNode; + +@RunWith(JUnit4.class) +public class TestOperationsGenTest { + + private static class OperationsRootNode extends RootNode { + + @Child private OperationsNode executable; + + protected OperationsRootNode(OperationsNode executable) { + super(null); + this.executable = executable; + } + + @Override + public Object execute(VirtualFrame frame) { + return this.executable.execute(frame); + } + + } + + private static void parseAdd(SlOperationsBuilderino b) { + // simple test: + // function foo(a, b) { + // return (a + b); + // } + b.beginReturn(); + b.beginAddOperation(); + b.emitLoadArgument((short) 0); + b.emitLoadArgument((short) 1); + b.endAddOperation(); + b.endReturn(); + } + + private static void parseMax(SlOperationsBuilderino b) { + // control flow test: + // function max(a, b) { + // if (a < b) { + // return b; + // } else { + // return a; + // } + b.beginIfThenElse(); + + b.beginLessThanOperation(); + b.emitLoadArgument((short) 0); // a + b.emitLoadArgument((short) 1); // b + b.endLessThanOperation(); + + b.beginReturn(); + b.emitLoadArgument((short) 1); // b + b.endReturn(); + + b.beginReturn(); + b.emitLoadArgument((short) 0); // a + b.endReturn(); + + b.endIfThenElse(); + } + + @Test + public void testAdd() { + runTest(TestOperationsGenTest::parseAdd, 42L, 20L, 22L); + } + + @Test + public void testMax() { + runTest(TestOperationsGenTest::parseMax, 42L, 42L, 13L); + runTest(TestOperationsGenTest::parseMax, 42L, 13L, 42L); + } + + @Test + public void testSumLoop() { + runTest(TestOperationsGenTest::parseSumLoop, 45L, 10L); + } + + @Test + public void testBreakLoop() { + runTest(TestOperationsGenTest::parseBreakLoop, 6L, 5L); + runTest(TestOperationsGenTest::parseBreakLoop, 10L, 15L); + } + + private static void runTest(Consumer parse, Object expectedResult, Object... args) { + SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); + parse.accept(b); + OperationsNode executable = b.build(); + System.out.println(executable.dump()); + b.reset(); + System.out.println(executable); + CallTarget target = new OperationsRootNode(executable).getCallTarget(); + Object result = target.call(args); + Assert.assertEquals(expectedResult, result); + } + + private static void parseSumLoop(SlOperationsBuilderino b) { + // control flow test: + // function sum(length) { + // sum = 0; + // i = 0; + // while (i < length) { + // sum += i; + // i += 1; + // } + // return sum; + + b.beginStoreLocal((short) 0); // sum + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginStoreLocal((short) 1); // i + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginWhile(); + + b.beginLessThanOperation(); + b.emitLoadLocal((short) 1); // i + b.emitLoadArgument((short) 0); // length + b.endLessThanOperation(); + + b.beginBlock(); + + b.beginStoreLocal((short) 0); // sum + b.beginAddOperation(); + b.emitLoadLocal((short) 0); + b.emitLoadLocal((short) 1); // i + b.endAddOperation(); + b.endStoreLocal(); + + b.beginStoreLocal((short) 1); + b.beginAddOperation(); + b.emitLoadLocal((short) 1); + b.emitConstObject(1L); + b.endAddOperation(); + b.endStoreLocal(); + + b.endBlock(); + + b.endWhile(); + + b.beginReturn(); + b.emitLoadLocal((short) 0); + b.endReturn(); + } + + private static void parseBreakLoop(SlOperationsBuilderino b) { + // function breakLoop(input) { + // i = 0; + // while (i < 10) { + // if (input < i) break; + // i += 1; + // } + // return i; + + b.beginStoreLocal((short) 0); // i + b.emitConstObject(0L); + b.endStoreLocal(); + + OperationLabel breakLbl = b.createLabel(); + + b.beginWhile(); + + b.beginLessThanOperation(); + b.emitLoadLocal((short) 0); // i + b.emitConstObject(10L); + b.endLessThanOperation(); + + b.beginBlock(); + + b.beginIfThen(); + + b.beginLessThanOperation(); + b.emitLoadArgument((short) 0); // input + b.emitLoadLocal((short) 0); // i + b.endLessThanOperation(); + + b.emitBranch(breakLbl); + + b.endIfThen(); + + b.beginStoreLocal((short) 0); + b.beginAddOperation(); + b.emitLoadLocal((short) 0); + b.emitConstObject(1L); + b.endAddOperation(); + b.endStoreLocal(); + + b.endBlock(); + + b.endWhile(); + + b.markLabel(breakLbl); + + b.beginReturn(); + b.emitLoadLocal((short) 0); + b.endReturn(); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index d439b67c708c..4d3f2c38ce45 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,6 +1,8 @@ package com.oracle.truffle.api.operation; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Stack; public abstract class OperationsBuilder { @@ -17,6 +19,10 @@ public void setCollectStatistics(boolean statistics) { this.statistics = new OperationsStatistics(); } + public abstract void reset(); + + public abstract OperationsNode build(); + private static final class OperationsStatistics { } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index c2db1078b47e..3d110047729d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -8,7 +8,7 @@ public abstract class OperationsNode extends Node { public abstract Object continueAt(VirtualFrame frame, OperationLabel index); - public abstract OperationsNode copyUninitialized(); +// public abstract OperationsNode copyUninitialized(); public abstract String dump(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java index 4cd53fbd9241..6d1e54af3ee7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java @@ -68,6 +68,8 @@ import com.oracle.truffle.dsl.processor.library.ExportsParser; import com.oracle.truffle.dsl.processor.library.LibraryGenerator; import com.oracle.truffle.dsl.processor.library.LibraryParser; +import com.oracle.truffle.dsl.processor.operations.OperationsCodeGenerator; +import com.oracle.truffle.dsl.processor.operations.OperationsParser; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; import com.oracle.truffle.dsl.processor.parser.TypeSystemParser; @@ -187,6 +189,7 @@ public void callback(TypeElement template) { @Override public Set getSupportedAnnotationTypes() { Set annotations = new HashSet<>(); + annotations.add(TruffleTypes.GenerateOperations_Name); annotations.add(TruffleTypes.Specialization_Name); annotations.add(TruffleTypes.Fallback_Name); annotations.add(TruffleTypes.TypeSystemReference_Name); @@ -203,6 +206,7 @@ public Set getSupportedAnnotationTypes() { private static List> createGenerators() { List> generators = new ArrayList<>(); + generators.add(new AnnotationProcessor<>(new OperationsParser(), new OperationsCodeGenerator())); generators.add(new AnnotationProcessor<>(new TypeSystemParser(), new TypeSystemCodeGenerator())); generators.add(new AnnotationProcessor<>(NodeParser.createDefaultParser(), new NodeCodeGenerator())); generators.add(new AnnotationProcessor<>(new LibraryParser(), new LibraryGenerator())); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 9f24dbdf8813..a7b5e26e0b25 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -220,6 +220,19 @@ public class TruffleTypes { public final DeclaredType TypeSystemReference = c.getDeclaredType(TypeSystemReference_Name); public final DeclaredType UnsupportedSpecializationException = c.getDeclaredType(UnsupportedSpecializationException_Name); + // Operations DSL API + public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; + public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; + public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; + public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; + public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + + public final DeclaredType GenerateOperations = c.getDeclaredType(GenerateOperations_Name); + public final DeclaredType Operation = c.getDeclaredType(Operation_Name); + public final DeclaredType OperationLabel = c.getDeclaredType(OperationLabel_Name); + public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); + public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); + // Library API public static final String EagerExportProvider_Name = "com.oracle.truffle.api.library.EagerExportProvider"; public static final String CachedLibrary_Name = "com.oracle.truffle.api.library.CachedLibrary"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java index 8df1655eefa2..29dff48d1f8a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java @@ -73,6 +73,10 @@ public final void addWarning(AnnotationValue value, String text, Object... param getMessages().add(new Message(null, value, null, this, String.format(text, params), Kind.WARNING)); } + public final void addWarning(Element enclosedElement, String text, Object... params) { + getMessages().add(new Message(null, null, enclosedElement, this, String.format(text, params), Kind.WARNING)); + } + public final void addError(String text, Object... params) { addError((AnnotationValue) null, text, params); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java new file mode 100644 index 000000000000..5ea8017de414 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -0,0 +1,601 @@ +package com.oracle.truffle.dsl.processor.operations; + +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationsData.Operation; + +class OperationsBytecodeCodeGenerator { + + final int BC_CONSTS_TARGET_LENGTH = 2; + + private final TruffleTypes types; + private final ProcessorContext context; + + private CodeTreeBuilder builder; + + private static final int COMMON_OP_PRIM_JUMP_FALSE = 0; + private static final int COMMON_OP_PRIM_JUMP_UNCOND = 1; + private static final int COMMON_OP_PRIM_POP = 2; + static String[] commonOpcodeNames = new String[]{ + "PRIM_JUMP_FALSE", + "PRIM_JUMP_UNCOND", + "PRIM_POP", + }; + + CodeVariableElement[] commonOpcodeConstants; + + private int labelCounter = 0; + private int backrefCounter = 0; + + private final DeclaredType byteArraySupportType; + + private final CodeTree leBytes; + + OperationsBytecodeCodeGenerator(TruffleTypes types, ProcessorContext context) { + this.types = types; + this.context = context; + + byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); + leBytes = CodeTreeBuilder.createBuilder() // + .startCall(CodeTreeBuilder.singleType(byteArraySupportType), "littleEndian") // + .end().build(); + } + + class Builder { + + private final CodeTreeBuilder builder; + + public Builder(CodeTreeBuilder builder) { + this.builder = builder; + } + + public void buildOperation(OperationsData.Operation operation) { + switch (operation.type) { + case CUSTOM: + case PRIM_CONST_OBJECT: + case PRIM_LOAD_LOCAL: + case PRIM_STORE_LOCAL: + case PRIM_LOAD_ARGUMENT: + case PRIM_RETURN: + buildSimple(operation); + break; + case PRIM_BLOCK: + buildBlock(); + break; + case PRIM_IF_THEN: + buildIfThen(); + break; + case PRIM_IF_THEN_ELSE: + buildIfThenElse(); + break; + case PRIM_WHILE: + buildWhile(); + break; + default: + // TODO + break; + } + } + + private void buildSimple(Operation operation) { + for (int i = 0; i < operation.children; i++) { + buildChildCall(i); + } + + buildOp(operation, 0); + + int argIdx = 0; + for (TypeMirror argType : operation.getArguments(types, context)) { + switch (argType.getKind()) { + case BYTE: + putByte("(byte) arguments[" + argIdx + "]"); + break; + case BOOLEAN: + putByte("((boolean) arguments[" + argIdx + "]) ? 1 : 0"); + break; + case CHAR: + putShort("(short)(char) arguments[" + argIdx + "]"); + break; + case SHORT: + putShort("(short) arguments[" + argIdx + "]"); + break; + case INT: + putInt("(int) arguments[" + argIdx + "]"); + break; + case LONG: + putLong("(long) arguments[" + argIdx + "]"); + break; + default: + if (argType.equals(types.OperationLabel)) { + // TODO: resolve + } else { + // TODO: constant pool + } + putShort("(short) 0"); + break; + } + argIdx++; + } + } + + private void buildBlock() { + builder.startFor(); + builder.string("int i = 0; i < children.length; i++"); + builder.end(); + + builder.startBlock(); + + buildChildCall("i"); + + builder.end(); + } + + private void buildIfThen() { + buildChildCall(0); + + buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); + int afterBackref = reserveDestination(); + + buildChildCall(1); + + fillReservedDestination(afterBackref); + } + + private void buildIfThenElse() { + buildChildCall(0); + + buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); + int elseBackref = reserveDestination(); + + buildChildCall(1); + + buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); + int afterBackref = reserveDestination(); + + fillReservedDestination(elseBackref); + + buildChildCall(2); + + fillReservedDestination(afterBackref); + } + + private void buildWhile() { + + int startLabel = saveLabel(); + buildChildCall(0); + + buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); + int afterBackref = reserveDestination(); + + buildChildCall(1); + + buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); + fillSavedLabel(startLabel); + + fillReservedDestination(afterBackref); + } + + private void buildChildCall(int id) { + buildChildCall("" + id); + } + + private void buildChildCall(String id) { + builder.startStatement(); + builder.string("bci = "); + builder.startCall("children[" + id + "]", builder.findMethod()); + builder.string("bc"); + builder.string("bci"); + builder.end(); + builder.end(); + } + + private void buildCommonOp(int id) { + builder.startStatement(); + builder.string("bc[bci++] = " + commonOpcodeConstants[id].getName()); + builder.end(); + } + + private void buildOp(Operation operation, int id) { + builder.startStatement(); + builder.string("bc[bci++] = " + operation.getOpcodeConstant()[id].getName()); + builder.end(); + } + + private int saveLabel() { + int id = labelCounter++; + + builder.startStatement(); + builder.string("int label_" + id + " = bci"); + builder.end(); + + return id; + } + + private int reserveDestination() { + int id = backrefCounter++; + + builder.startStatement(); + builder.string("int backref_" + id + " = bci"); + builder.end(); + + builder.startStatement(); + builder.string("bci += " + BC_CONSTS_TARGET_LENGTH); + builder.end(); + + return id; + } + + private void fillReservedDestination(int target) { + fillLabel("backref_" + target, "bci"); + } + + private void fillSavedLabel(int label) { + fillLabel("bci", "label_" + label); + builder.startStatement(); + builder.string("bci += " + BC_CONSTS_TARGET_LENGTH); + builder.end(); + } + + private void fillLabel(String dest, String label) { + builder.startStatement(); + CodeTree le = CodeTreeBuilder.createBuilder().startCall(CodeTreeBuilder.singleType(byteArraySupportType), "littleEndian").end().build(); + builder.startCall(le, "putShort"); + builder.string("bc"); + builder.string(dest); + builder.string("(short) " + label); + builder.end(2); + } + + private void putByte(String value) { + builder.startStatement(); + builder.string("bc[bci++] = " + value); + builder.end(); + } + + private void putBytesHelper(String method, String value, int length) { + builder.startStatement(); + builder.startCall(leBytes, method); + builder.string("bc"); + builder.string("bci"); + builder.string(value); + builder.end(2); + + builder.startStatement(); + builder.string("bci += " + length); + builder.end(); + } + + private void putShort(String value) { + putBytesHelper("putShort", value, 2); + } + + private void putInt(String value) { + putBytesHelper("putInt", value, 4); + } + + private void putLong(String value) { + putBytesHelper("putLong", value, 8); + } + } + + abstract class ReaderCommon { + protected final CodeTreeBuilder builder; + + protected boolean doNotBreak = false; + + protected ReaderCommon(CodeTreeBuilder builder) { + this.builder = builder; + } + + void buildCommonOperations() { + startOperation(commonOpcodeConstants[COMMON_OP_PRIM_JUMP_FALSE].getName()); + buildJumpFalseOperation(); + endOperation(); + + startOperation(commonOpcodeConstants[COMMON_OP_PRIM_JUMP_UNCOND].getName()); + buildJumpUncondOperation(); + endOperation(); + + startOperation(commonOpcodeConstants[COMMON_OP_PRIM_POP].getName()); + buildPopOperation(); + endOperation(); + } + + void buildOperation(Operation op) { + if (op.type.numOpcodes == 0) + return; + + doNotBreak = false; + startOperation(op.getOpcodeConstant()[0].getName()); + switch (op.type) { + case CUSTOM: + buildCustomOperation(op); + break; + case PRIM_LOAD_LOCAL: + buildLoadLocal(op); + break; + case PRIM_STORE_LOCAL: + buildStoreLocal(op); + break; + case PRIM_CONST_OBJECT: + buildConstObject(op); + break; + case PRIM_LOAD_ARGUMENT: + buildLoadArgument(op); + break; + case PRIM_RETURN: + buildReturn(op); + break; + } + endOperation(); + } + + private void getBytesHelper(String var, String method, String offset) { + builder.startStatement(); + builder.string(var + " = "); + builder.startCall(leBytes, method); + builder.string("bc"); + builder.string("bci + " + offset); + builder.end(2); + } + + protected void getByte(String var, String offset) { + builder.statement("byte " + var + " = bc[bci + " + offset + "]"); + } + + protected void getShort(String var, String offset) { + getBytesHelper(var, "getShort", offset); + } + + protected void getInt(String var, String offset) { + getBytesHelper(var, "getInt", offset); + } + + protected abstract void buildJumpFalseOperation(); + + protected abstract void buildJumpUncondOperation(); + + protected abstract void buildPopOperation(); + + protected abstract void buildCustomOperation(Operation op); + + protected abstract void buildConstObject(Operation op); + + protected abstract void buildLoadLocal(Operation op); + + protected abstract void buildStoreLocal(Operation op); + + protected abstract void buildLoadArgument(Operation op); + + protected abstract void buildReturn(Operation op); + + private void startOperation(String name) { + builder.startCase().string(name).end(); + builder.startBlock(); + } + + private void endOperation() { + if (!doNotBreak) { + builder.statement("break"); + } + builder.end(); + } + } + + class Executor extends ReaderCommon { + + Executor(CodeTreeBuilder builder) { + super(builder); + } + + @Override + protected void buildJumpFalseOperation() { + popValue("boolean", "condition"); + + builder.startIf().string("condition").end(); + + builder.startBlock(); + gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); + builder.end(); + + builder.startElseBlock(); + gotoDestination(1); + builder.end(); + + } + + @Override + protected void buildJumpUncondOperation() { + gotoDestination(1); + } + + @Override + protected void buildPopOperation() { + builder.statement("stack[--sp] = null"); + gotoRelative(1); + } + + @Override + protected void buildCustomOperation(Operation op) { + // read all child values + + for (int i = op.children - 1; i >= 0; i--) { + popValue("Object", "value" + i); + } + + // TODO: read all arguments + + // TODO: invoke + + // TODO: push result + + gotoRelative(1); + } + + @Override + protected void buildConstObject(Operation op) { + + getShort("int index", "1"); + pushValue("locals[index]"); + + gotoRelative(1 + 2); + } + + @Override + protected void buildLoadLocal(Operation op) { + + getShort("int index", "1"); + pushValue("locals[index]"); + + gotoRelative(1 + 2); + } + + @Override + protected void buildStoreLocal(Operation op) { + + getShort("int index", "1"); + popValue("Object", "value"); + builder.statement("locals[index] = value"); + + gotoRelative(1 + 2); + } + + @Override + protected void buildLoadArgument(Operation op) { + getShort("int index", "1"); + pushValue("frame.getArguments()[index]"); + + gotoRelative(1 + 2); + } + + @Override + protected void buildReturn(Operation op) { + popValue("Object", "rv"); + builder.statement("returnValue = rv"); + builder.statement("break loop"); + doNotBreak = true; + } + + private void gotoDestination(int offset) { + gotoDestination("" + offset); + } + + private void gotoDestination(String offset) { + getShort("nextBci", offset); + } + + private void gotoRelative(int offset) { + builder.statement("nextBci = bci + " + offset); + } + + private void popValue(String type, String name) { + String cast = type.equals("Object") ? "" : "(" + type + ") "; + builder.declaration(type, name, cast + "stack[--sp]"); + } + + private void pushValue(String value) { + builder.statement("stack[sp++] = " + value); + } + + } + + class Dumper extends ReaderCommon { + + protected Dumper(CodeTreeBuilder builder) { + super(builder); + } + + @Override + protected void buildJumpFalseOperation() { + appendOpcode("brfalse"); + getShort("int dest", "1"); + append("dest"); + gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); + } + + @Override + protected void buildJumpUncondOperation() { + appendOpcode("br"); + getShort("int dest", "1"); + append("dest"); + gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); + } + + @Override + protected void buildPopOperation() { + appendOpcode("pop"); + gotoRelative(1); + } + + @Override + protected void buildCustomOperation(Operation op) { + // TODO Auto-generated method stub + appendOpcode("op"); + append("\"" + op.getName() + "\""); + gotoRelative(1); + } + + @Override + protected void buildConstObject(Operation op) { + appendOpcode("ldconst"); + getShort("int index", "1"); + append("index"); + gotoRelative(1 + 2); + } + + @Override + protected void buildLoadLocal(Operation op) { + appendOpcode("ldloc"); + getShort("int index", "1"); + append("index"); + gotoRelative(1 + 2); + } + + @Override + protected void buildStoreLocal(Operation op) { + appendOpcode("stloc"); + getShort("int index", "1"); + appendDest("index"); + gotoRelative(1 + 2); + } + + @Override + protected void buildLoadArgument(Operation op) { + appendOpcode("ldarg"); + getShort("int index", "1"); + append("index"); + gotoRelative(1 + 2); + } + + @Override + protected void buildReturn(Operation op) { + appendOpcode("return"); + gotoRelative(1); + } + + private void appendOpcode(String op) { + String opPadded = String.format("%-8s", op); + append("\"" + opPadded + "\""); + } + + private void appendDest(String code) { + append("String.format(\"%04x\", " + code + ")"); + } + + private void append(String code) { + builder.statement("sb.append(" + code + ")"); + builder.statement("sb.append(' ')"); + } + + private void gotoRelative(int offset) { + builder.statement("bci += " + offset); + } + + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java new file mode 100644 index 000000000000..4f951786ea3d --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -0,0 +1,639 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.Stack; + +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.AnnotationProcessor; +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +public class OperationsCodeGenerator extends CodeTypeElementFactory { + + private class OperationsCodeGeneratorImpl { + + private ProcessorContext context; + private AnnotationProcessor processor; + private OperationsData m; + + private CodeTypeElement builderType; + private CodeTypeElement builderImplType; + private CodeTypeElement builderNodeType; + private CodeTypeElement builderLabelImplType; + private CodeTypeElement builderBytecodeNodeType; + + private CodeVariableElement argumentStackField; + private CodeVariableElement childStackField; + private CodeVariableElement typeStackField; + + private CodeExecutableElement doBeginOperationMethod; + private CodeExecutableElement doEndOperationMethod; + private CodeExecutableElement doEmitOperationMethod; + + private OperationsBytecodeCodeGenerator bytecodeBuilderGenerator; + + OperationsCodeGeneratorImpl(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { + this.context = context; + this.processor = processor; + this.m = m; + + this.bytecodeBuilderGenerator = new OperationsBytecodeCodeGenerator(types, context); + } + + /** + * Creates the builder class itself. This class only contains abstract methods, the builder + * implementation class, and the createBuilder method. + * + * @return The created builder class + */ + CodeTypeElement createBuilder() { + + String simpleName = m.getTemplateType().getSimpleName() + "Builderino"; + builderType = GeneratorUtils.createClass(m, null, Set.of(Modifier.ABSTRACT, Modifier.PUBLIC), simpleName, types.OperationsBuilder); + + createLabelMethods(builderType, true); + for (OperationsData.Operation op : m.getOperations()) { + createBeginEnd(builderType, op, true); + } + + createBuilderImpl(); + createCreateBuilder(); + + return builderType; + } + + /** + * Create the implementation class. This class implements the begin/end methods, and in + * general does the most of the build-time heavy lifting. + */ + private void createBuilderImpl() { + String simpleName = m.getTemplateType().getSimpleName() + "BuilderinoImpl"; + builderImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, builderType.asType()); + + createBuilderNodeTypeConstants(); + createBuilderNodeOpcodeConstants(); + + createBuilderImplNode(); + createBuilderLabelImpl(); + createBuilderBytecodeNode(); + + childStackField = createStackField("child", generic(context.getTypeElement(ArrayList.class), builderNodeType.asType())); + argumentStackField = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); + typeStackField = createStackField("type", context.getType(Integer.class)); + + { + CodeExecutableElement mReset = new CodeExecutableElement( + Set.of(Modifier.PUBLIC), + context.getType(void.class), "reset"); + + CodeTreeBuilder builder = mReset.getBuilder(); + builder.startStatement().string("childStack.clear()").end(); + builder.startStatement().string("childStack.add(new ArrayList<>())").end(); + builder.startStatement().string("argumentStack.clear()").end(); + builder.startStatement().string("typeStack.clear()").end(); + + builderImplType.add(mReset); + } + + createBuildMethod(); + + { + CodeExecutableElement ctor = new CodeExecutableElement(null, simpleName); + + CodeTreeBuilder builder = ctor.getBuilder(); + builder.startStatement().string("reset()").end(); + + builderImplType.add(ctor); + } + + createHelperEmitMethods(); + + createLabelMethods(builderImplType, false); + + for (OperationsData.Operation op : m.getOperations()) { + createBeginEnd(builderImplType, op, false); + } + + builderType.add(builderImplType); + } + + private void createBuildMethod() { + CodeExecutableElement mBuild = new CodeExecutableElement(Set.of(Modifier.PUBLIC), types.OperationsNode, "build"); + + CodeTreeBuilder builder = mBuild.getBuilder(); + + builder.startAssert(); + builder.string("childStack.size() == 1"); + builder.end(); + + builder.declaration(arrayOf(builderNodeType.asType()), "operations", "childStack.get(0).toArray(new " + builderNodeType.getSimpleName() + "[0])"); + builder.declaration(builderNodeType.asType(), "rootNode", "new " + builderNodeType.getSimpleName() + "(TYPE_PRIM_BLOCK, new Object[0], operations)"); + builder.declaration("byte[]", "bc", "new byte[65535]"); + builder.declaration("int", "len", "rootNode.build(bc, 0)"); + builder.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, len)"); + + builder.startReturn(); + builder.startNew(builderBytecodeNodeType.asType()); + builder.string("bcCopy"); + builder.end(2); + + builderImplType.add(mBuild); + + } + + private void createBuilderLabelImpl() { + String simpleName = builderImplType.getSimpleName() + "Label"; + builderLabelImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationLabel); + + builderImplType.add(builderLabelImplType); + } + + private void createLabelMethods(CodeTypeElement target, boolean isAbstract) { + Set modifiers = isAbstract ? Set.of(Modifier.PUBLIC, Modifier.ABSTRACT) : Set.of(Modifier.PUBLIC); + + CodeExecutableElement mCreateLabel = new CodeExecutableElement(modifiers, types.OperationLabel, "createLabel"); + CodeExecutableElement mMarkLabel = new CodeExecutableElement(modifiers, context.getType(void.class), "markLabel", new CodeVariableElement(types.OperationLabel, "label")); + + target.add(mCreateLabel); + target.add(mMarkLabel); + + if (isAbstract) + return; + { + CodeTreeBuilder builder = mCreateLabel.getBuilder(); + builder.startReturn(); + builder.startNew(builderLabelImplType.asType()); + builder.end(2); + } + } + + /** + * Create the BuilderNode class. + * + * This class represents the built method internally. Right now it only supports generating + * the bytecode, but in the future it will support analysis and finding super-instructions. + */ + private void createBuilderImplNode() { + String simpleName = builderImplType.getSimpleName() + "Node"; + builderNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, null); + + createBuilderNodeFields(); + builderNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType)); + + createBuilderNodeBuildMethod(); + + builderImplType.add(builderNodeType); + } + + private void createBuilderNodeFields() { + Set modifiers = Set.of(Modifier.PRIVATE, Modifier.FINAL); + builderNodeType.add(new CodeVariableElement(modifiers, context.getType(int.class), "type")); + builderNodeType.add(new CodeVariableElement(modifiers, new ArrayCodeTypeMirror(context.getType(Object.class)), "arguments")); + builderNodeType.add(new CodeVariableElement(modifiers, new ArrayCodeTypeMirror(builderNodeType.asType()), "children")); + } + + private void createBuilderNodeBuildMethod() { + CodeVariableElement bc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + CodeVariableElement startBci = new CodeVariableElement(context.getType(int.class), "startBci"); + CodeExecutableElement method = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", bc, startBci); + CodeTreeBuilder builder = method.getBuilder(); + + builder.declaration("int", "bci", "startBci"); + + OperationsBytecodeCodeGenerator.Builder gen = bytecodeBuilderGenerator.new Builder(builder); + + builder.startSwitch(); + builder.string("this.type"); + builder.end(); + builder.startBlock(); + + for (OperationsData.Operation op : m.getOperations()) { + builder.startCase(); + builder.string(op.getTypeConstant().getName()); + builder.end(); + + builder.startBlock(); + + gen.buildOperation(op); + + builder.startStatement().string("break").end(); + builder.end(); + } + + builder.end(); + + builder.startReturn().string("bci").end(); + + builderNodeType.add(method); + } + + /** + * Create the node type constants. + * + * Instead of having a proper hierarchy of node types, we just use one BuilderNode class, + * with this type representing which node it is. + */ + private void createBuilderNodeTypeConstants() { + int i = 0; + for (OperationsData.Operation op : m.getOperations()) { + CodeVariableElement el = new CodeVariableElement( + Set.of(Modifier.STATIC, Modifier.PRIVATE, Modifier.FINAL), + context.getType(int.class), "TYPE_" + op.getScreamCaseName()); + CodeTreeBuilder ctb = el.createInitBuilder(); + ctb.string("" + i); + i++; + + op.setTypeConstant(el); + builderImplType.add(el); + } + } + + private void createBuilderNodeOpcodeConstants() { + int i = 0; + + { + int numCommon = OperationsBytecodeCodeGenerator.commonOpcodeNames.length; + CodeVariableElement[] commonOpcodes = new CodeVariableElement[numCommon]; + for (int j = 0; j < numCommon; j++) { + commonOpcodes[j] = createBuilderNodeOpcodeConstant(i++, OperationsBytecodeCodeGenerator.commonOpcodeNames[j]); + } + bytecodeBuilderGenerator.commonOpcodeConstants = commonOpcodes; + } + + for (OperationsData.Operation op : m.getOperations()) { + if (op.type.numOpcodes == 0) + continue; + + CodeVariableElement[] opcodes = new CodeVariableElement[op.type.numOpcodes]; + for (int j = 0; j < op.type.numOpcodes; j++) { + opcodes[j] = createBuilderNodeOpcodeConstant(i++, op.getScreamCaseName() + "_" + j); + } + + op.setOpcodeConstant(opcodes); + } + } + + private CodeVariableElement createBuilderNodeOpcodeConstant(int i, String name) { + CodeVariableElement el = new CodeVariableElement( + Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), + context.getType(byte.class), + "OPC_" + name, + "" + i); + builderImplType.add(el); + return el; + } + + /** + * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the + * executable Truffle node. + */ + private void createBuilderBytecodeNode() { + String simpleName = builderType.getSimpleName() + "BytecodeNode"; + builderBytecodeNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationsNode); + + builderBytecodeNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(byte.class)), "bc")); + builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); + + createBuilderBytecodeNodeExecute(); + + builderImplType.add(builderBytecodeNodeType); + } + + private void createBuilderBytecodeNodeExecute() { + { + CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); + + CodeTreeBuilder builder = mExecute.getBuilder(); + builder.startReturn(); + builder.startCall("continueAt"); + + builder.string("frame"); + builder.string("null"); + + builder.end(2); + + builderBytecodeNodeType.add(mExecute); + } + + { + CodeExecutableElement mContinueAt = new CodeExecutableElement( + Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", + new CodeVariableElement(types.VirtualFrame, "frame"), + new CodeVariableElement(types.OperationLabel, "startIndex")); + + CodeTreeBuilder builder = mContinueAt.getBuilder(); + + OperationsBytecodeCodeGenerator.Executor gen = bytecodeBuilderGenerator.new Executor(builder); + + builder.declaration("final Object[]", "stack", "new Object[1024]"); + builder.declaration("final Object[]", "locals", "new Object[1024]"); + builder.declaration("int", "sp", "0"); + builder.declaration("int", "bci", "0"); + + builder.statement("Object returnValue"); + + builder.string("loop: "); + builder.startWhile().string("true").end(); + builder.startBlock(); + + builder.statement("int nextBci"); + + builder.startSwitch().string("bc[bci]").end(); + builder.startBlock(); + + gen.buildCommonOperations(); + + for (OperationsData.Operation op : m.getOperations()) { + gen.buildOperation(op); + } + + builder.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); + + builder.end(); // switch block + + builder.statement("bci = nextBci"); + builder.end(); // while block + + builder.startReturn().string("returnValue").end(); + + builderBytecodeNodeType.add(mContinueAt); + } + + { + CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); + + CodeTreeBuilder builder = mDump.getBuilder(); + + OperationsBytecodeCodeGenerator.Dumper gen = bytecodeBuilderGenerator.new Dumper(builder); + + builder.declaration("int", "bci", "0"); + builder.declaration("StringBuilder", "sb", "new StringBuilder()"); + + builder.startWhile().string("bci < bc.length").end(); + builder.startBlock(); // while block + + builder.statement("sb.append(String.format(\" %04x \", bci))"); + + builder.startSwitch().string("bc[bci]").end(); + builder.startBlock(); + + gen.buildCommonOperations(); + + for (OperationsData.Operation op : m.getOperations()) { + gen.buildOperation(op); + } + + builder.caseDefault().startCaseBlock(); + builder.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); + builder.statement("break"); + builder.end(); // default case block + builder.end(); // switch block + + builder.statement("sb.append(\"\\n\")"); + + builder.end(); // while block + + builder.startReturn().string("sb.toString()").end(); + + builderBytecodeNodeType.add(mDump); + } + } + + /** + * Creates the doBeginOperation, doEndOperation and doEmitOperation helper methods. They + * look as follows: + * + *
+         * private void doBeginOperation(int type, Object... arguments) {
+         *     typeStack.add(type);
+         *     childStack.add(new ArrayList<>());
+         *     argumentStack.add(arguments);
+         * }
+         *
+         * private void doEndOperation(int type) {
+         *     int topType = typeStack.pop();
+         *     assert topType == type;
+         *     Object[] args = argumentStack.pop();
+         *     SlOperationsBuilderinoImplNode[] children = childStack.pop().toArray(new SlOperationsBuilderinoImplNode[0]);
+         *     SlOperationsBuilderinoImplNode result = new SlOperationsBuilderinoImplNode(type, args, children);
+         *     childStack.peek().add(result);
+         * }
+         *
+         * private void doEmitOperation(int type, Object... arguments) {
+         *     SlOperationsBuilderinoImplNode result = new SlOperationsBuilderinoImplNode(type, arguments, new SlOperationsBuilderinoImplNode[0]);
+         *     childStack.peek().add(result);
+         * }
+         * 
+ */ + private void createHelperEmitMethods() { + Set modPrivate = Set.of(Modifier.PRIVATE); + + { + doBeginOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doBeginOperation"); + doBeginOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + doBeginOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); + + CodeTreeBuilder builder = doBeginOperationMethod.getBuilder(); + + builder.startStatement(); + builder.string("typeStack.add(type)"); + builder.end(); + + builder.startStatement(); + builder.string("childStack.add(new ArrayList<>())"); + builder.end(); + + builder.startStatement(); + builder.string("argumentStack.add(arguments)"); + builder.end(); + + builderImplType.add(doBeginOperationMethod); + } + + { + doEndOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doEndOperation"); + doEndOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + + CodeTreeBuilder builder = doEndOperationMethod.getBuilder(); + + builder.startStatement(); + builder.string("int topType = typeStack.pop()"); + builder.end(); + + builder.startAssert(); + builder.string("topType == type"); + builder.end(); + + builder.startStatement(); + builder.string("Object[] args = argumentStack.pop()"); + builder.end(); + + builder.declaration(new ArrayCodeTypeMirror(builderNodeType.asType()), "children", + "childStack.pop().toArray(new " + builderNodeType.getSimpleName() + "[0])"); + + builder.declaration(builderNodeType.asType(), "result", + "new " + builderNodeType.getSimpleName() + "(type, args, children)"); + + builder.startStatement(); + builder.string("childStack.peek().add(result)"); + builder.end(); + + builderImplType.add(doEndOperationMethod); + + } + + { + doEmitOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doEmitOperation"); + doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); + + CodeTreeBuilder builder = doEmitOperationMethod.getBuilder(); + + builder.declaration(builderNodeType.asType(), "result", + "new " + builderNodeType.getSimpleName() + "(type, arguments, new " + builderNodeType.getSimpleName() + "[0])"); + + builder.startStatement(); + builder.string("childStack.peek().add(result)"); + builder.end(); + + builderImplType.add(doEmitOperationMethod); + } + } + + /** + * Create the begin/end methods, or the emit method if the operation takes no children. + * + * @param target + * @param operation + * @param isAbstract + */ + private void createBeginEnd(CodeTypeElement target, OperationsData.Operation operation, boolean isAbstract) { + Set mods = isAbstract ? Set.of(Modifier.PUBLIC, Modifier.ABSTRACT) : Set.of(Modifier.PUBLIC); + + if (operation.children == 0) { + CodeExecutableElement mEmit = new CodeExecutableElement(mods, context.getType(void.class), "emit" + operation.getName()); + + createBeginParameters(operation, mEmit); + + target.add(mEmit); + + if (isAbstract) + return; + + CodeTreeBuilder builder = mEmit.getBuilder(); + builder.startStatement(); + builder.startCall(null, doEmitOperationMethod); + builder.field(null, operation.getTypeConstant()); + for (int i = 0; i < operation.getArguments(types, context).size(); i++) { + builder.string("arg" + i); + } + builder.end(2); + } else { + CodeExecutableElement mBegin = new CodeExecutableElement(mods, context.getType(void.class), "begin" + operation.getName()); + CodeExecutableElement mEnd = new CodeExecutableElement(mods, context.getType(void.class), "end" + operation.getName()); + + createBeginParameters(operation, mBegin); + + target.add(mBegin); + target.add(mEnd); + + if (isAbstract) + return; + + { + CodeTreeBuilder builder = mBegin.getBuilder(); + builder.startStatement(); + builder.startCall(null, doBeginOperationMethod); + builder.field(null, operation.getTypeConstant()); + for (int i = 0; i < operation.getArguments(types, context).size(); i++) { + builder.string("arg" + i); + } + builder.end(2); + } + + { + CodeTreeBuilder builder = mEnd.getBuilder(); + builder.startStatement(); + builder.startCall(null, doEndOperationMethod); + builder.field(null, operation.getTypeConstant()); + builder.end(2); + } + } + } + + /** + * Create the parameters of a begin or emit method, from given operation description. + * + * @param operation + * @param method + */ + private void createBeginParameters(OperationsData.Operation operation, CodeExecutableElement method) { + int i = 0; + for (TypeMirror argType : operation.getArguments(types, context)) { + method.addParameter(new CodeVariableElement(argType, "arg" + i)); + i++; + } + } + + private void createCreateBuilder() { + CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.STATIC), builderType.asType(), "createBuilder"); + CodeTreeBuilder builder = method.getBuilder(); + + builder.startReturn(); + builder.startNew(builderImplType.asType()); + builder.end(); + builder.end(); + + builderType.add(method); + } + + /** + * Creates a stack field. + * + * @param name the name of the stack field. It will get {@code "Stack"} appended to it. + * @param argType the type of the stack elements + * @return the created stack field + */ + private CodeVariableElement createStackField(String name, TypeMirror argType) { + TypeMirror stackType = generic(context.getTypeElement(Stack.class), argType); + CodeVariableElement element = new CodeVariableElement( + Set.of(Modifier.PRIVATE, Modifier.FINAL), + stackType, + name + "Stack"); + CodeTreeBuilder ctb = element.createInitBuilder(); + ctb.string("new Stack<>()"); + + builderImplType.add(element); + return element; + } + + } + + private static TypeMirror generic(TypeElement el, TypeMirror... params) { + return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); + } + + private static TypeMirror arrayOf(TypeMirror el) { + return new ArrayCodeTypeMirror(el); + } + + @Override + public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { + OperationsCodeGeneratorImpl impl = new OperationsCodeGeneratorImpl(context, processor, m); + return List.of(impl.createBuilder()); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java new file mode 100644 index 000000000000..6e16f3c44dbf --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -0,0 +1,128 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.Template; + +public class OperationsData extends Template { + + enum OperationType { + CUSTOM(null), + PRIM_BLOCK("Block", 0), + PRIM_IF_THEN("IfThen", 0), + PRIM_IF_THEN_ELSE("IfThenElse", 0), + PRIM_WHILE("While", 0), + PRIM_CONST_OBJECT("ConstObject"), + PRIM_LOAD_LOCAL("LoadLocal"), + PRIM_STORE_LOCAL("StoreLocal"), + PRIM_LOAD_ARGUMENT("LoadArgument"), + PRIM_RETURN("Return"), + PRIM_BRANCH("Branch", 0); + + final String name; + final int numOpcodes; + + OperationType(String name) { + this(name, 1); + } + + OperationType(String name, int numOpcodes) { + this.name = name; + this.numOpcodes = numOpcodes; + } + } + + static class Operation { + final OperationType type; + final List arguments; + final int children; + final TypeElement typeElement; + final boolean returnsValue; + + CodeVariableElement typeConstant; + CodeVariableElement[] opcodeConstant; + + Operation(OperationType type, List arguments, int children, TypeElement typeElement, boolean returnsValue) { + this.type = type; + this.arguments = arguments; + this.children = children; + this.typeElement = typeElement; + this.returnsValue = returnsValue; + } + + public String getName() { + if (type == OperationType.CUSTOM) { + return typeElement.getSimpleName().toString(); + } else { + return type.name; + } + } + + public String getScreamCaseName() { + if (type == OperationType.CUSTOM) { + return "OP_" + typeElement.getSimpleName().toString().replaceAll("([a-z])([A-Z])", "$1_$2").toUpperCase(); + } else { + return type.toString(); + } + } + + public CodeVariableElement getTypeConstant() { + return typeConstant; + } + + public void setTypeConstant(CodeVariableElement typeConstant) { + this.typeConstant = typeConstant; + } + + public CodeVariableElement[] getOpcodeConstant() { + return opcodeConstant; + } + + public void setOpcodeConstant(CodeVariableElement[] opcodeConstant) { + this.opcodeConstant = opcodeConstant; + } + + public Collection getArguments(TruffleTypes types, ProcessorContext ctx) { + switch (type) { + case CUSTOM: + return arguments; + case PRIM_CONST_OBJECT: + return List.of(ctx.getType(Object.class)); + case PRIM_LOAD_LOCAL: + case PRIM_STORE_LOCAL: + case PRIM_LOAD_ARGUMENT: + return List.of(ctx.getType(short.class)); + case PRIM_BRANCH: + return List.of(types.OperationLabel); + case PRIM_BLOCK: + case PRIM_IF_THEN: + case PRIM_IF_THEN_ELSE: + case PRIM_WHILE: + case PRIM_RETURN: + return List.of(); + default: + throw new IllegalArgumentException("bad type: " + type); + } + } + } + + private final List operations = new ArrayList<>(); + + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { + super(context, templateType, annotation); + } + + public List getOperations() { + return operations; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java new file mode 100644 index 000000000000..d720c33f133c --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -0,0 +1,120 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationType; +import com.oracle.truffle.dsl.processor.parser.AbstractParser; + +public class OperationsParser extends AbstractParser { + + private static AnnotationMirror getAnnotationMirror(List mirror, DeclaredType type) { + for (AnnotationMirror m : mirror) { + if (m.getAnnotationType().equals(type)) { + return m; + } + } + return null; + } + + @Override + protected OperationsData parse(Element element, List mirror) { + + TypeElement typeElement = (TypeElement) element; + AnnotationMirror generateOperationsMirror = getAnnotationMirror(mirror, types.GenerateOperations); + + OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); + + addPrimitives(data); + + for (Element e : typeElement.getEnclosedElements()) { + AnnotationMirror operationMirror = getAnnotationMirror(e.getAnnotationMirrors(), types.Operation); + if (operationMirror == null) { + continue; + } + + if (!(e instanceof TypeElement)) { + data.addError(e, "@Operation can only be attached to classes"); + continue; + } + + processOperation(data, (TypeElement) e); + + } + + return data; + } + + private static void addPrimitives(OperationsData data) { + addPrimitiveOperation(data, OperationType.PRIM_BLOCK, -1, true); + addPrimitiveOperation(data, OperationType.PRIM_IF_THEN, 2, true); + addPrimitiveOperation(data, OperationType.PRIM_IF_THEN_ELSE, 3, true); + addPrimitiveOperation(data, OperationType.PRIM_WHILE, 2, false); + addPrimitiveOperation(data, OperationType.PRIM_CONST_OBJECT, 0, true); + addPrimitiveOperation(data, OperationType.PRIM_LOAD_LOCAL, 0, true); + addPrimitiveOperation(data, OperationType.PRIM_STORE_LOCAL, 1, false); + addPrimitiveOperation(data, OperationType.PRIM_LOAD_ARGUMENT, 0, true); + addPrimitiveOperation(data, OperationType.PRIM_RETURN, 1, true); + addPrimitiveOperation(data, OperationType.PRIM_BRANCH, 0, false); + } + + private static void addPrimitiveOperation(OperationsData data, OperationType type, int numChildren, boolean returnsValue) { + data.getOperations().add(new OperationsData.Operation(type, List.of(), numChildren, null, returnsValue)); + } + + private void processOperation(OperationsData data, TypeElement te) { + List operationFunctions = new ArrayList<>(); + for (Element el : te.getEnclosedElements()) { + if (el instanceof ExecutableElement) { + ExecutableElement cel = (ExecutableElement) el; + if (isOperationFunction(cel)) { + operationFunctions.add(cel); + } + } + } + + if (operationFunctions.isEmpty()) { + data.addWarning(te, "Operation contains no operation functions (public static methods)"); + return; + } + + ExecutableElement first = operationFunctions.get(0); + List arguments = List.of(); // TODO + int numChildren = first.getParameters().size(); + boolean returnsValue = !first.getReturnType().equals(context.getType(void.class)); + + for (ExecutableElement fun : operationFunctions) { + // check all functions have the same number of parameters + int numChildParameters = fun.getParameters().size(); + boolean funReturnsValue = !fun.getReturnType().equals(context.getType(void.class)); + if (numChildParameters != numChildren) { + data.addWarning(fun, "Expected %d child parameters, found %d", numChildren, numChildParameters); + } + if (funReturnsValue != returnsValue) { + data.addWarning(fun, "Not all functions return values!"); + } + } + + data.getOperations().add(new OperationsData.Operation(OperationType.CUSTOM, arguments, numChildren, te, true)); + } + + private static boolean isOperationFunction(ExecutableElement el) { + return el.getModifiers().contains(Modifier.PUBLIC) && el.getModifiers().contains(Modifier.STATIC); + } + + @Override + public DeclaredType getAnnotationType() { + return types.GenerateOperations; + } + +} From 9caacf99f4d89ee0deb6c25979bbc2197e84763a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 3 Mar 2022 11:38:01 +0100 Subject: [PATCH 004/312] [wip] more code generation --- .../operation/test/example/SlOperations.java | 47 +---- .../api/operation/BuilderOperationLabel.java | 45 +++++ .../truffle/dsl/processor/TruffleTypes.java | 2 + .../OperationsBytecodeCodeGenerator.java | 184 +++++++++++++++--- .../operations/OperationsCodeGenerator.java | 98 +++++++--- .../processor/operations/OperationsData.java | 12 +- .../operations/OperationsParser.java | 5 +- 7 files changed, 293 insertions(+), 100 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index f5a2ff4e2050..3aed2e36e030 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -1,61 +1,22 @@ package com.oracle.truffle.api.operation.test.example; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.sl.runtime.SLBigNumber; // TODO: where to attach this once we don't have a wrapper class? @GenerateOperations class SlOperations { @Operation static class AddOperation { - // @Specialization(rewriteOn = ArithmeticException.class) - public static long add(long left, long right) { - return Math.addExact(left, right); - } - - // @Specialization - @TruffleBoundary - public static SLBigNumber add(SLBigNumber left, SLBigNumber right) { - return new SLBigNumber(left.getValue().add(right.getValue())); - } - - // @Specialization(guards = "isString(left, right)") - @TruffleBoundary - public static String add(Object left, Object right) { - return left.toString() + right.toString(); - } - - protected static boolean isString(Object a, Object b) { - return a instanceof String || b instanceof String; - } - - // @Fallback - public static Object typeError(Object left, Object right) { - // throw SLException.typeError(this, left, right); - throw new RuntimeException("oh no: " + left + " + " + right); + public static Object add(Object lhs, Object rhs) { + return (long) lhs + (long) rhs; } } @Operation static class LessThanOperation { - - // @Specialization - public static boolean lessThan(long left, long right) { - return left < right; - } - - // @Specialization - @TruffleBoundary - public static boolean lessThan(SLBigNumber left, SLBigNumber right) { - return left.compareTo(right) < 0; - } - - // @Fallback - public static Object typeError(Object left, Object right) { - // throw SLException.typeError(this, left, right); - throw new RuntimeException("oh no: " + left + " < " + right); + public static Object lessThan(Object lhs, Object rhs) { + return (long) lhs < (long) rhs; } } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java new file mode 100644 index 000000000000..45f15174e572 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java @@ -0,0 +1,45 @@ +package com.oracle.truffle.api.operation; + +import java.util.ArrayList; + +import com.oracle.truffle.api.memory.ByteArraySupport; + +// not public api +public class BuilderOperationLabel extends OperationLabel { + private boolean marked = false; + private ArrayList toBackfill; + private boolean hasValue = false; + private int value = 0; + + public void resolve(byte[] bc, int labelValue) { + assert !hasValue; + hasValue = true; + value = labelValue; + + if (toBackfill != null) { + for (int bci : toBackfill) { + putDestination(bc, bci, value); + } + toBackfill = null; + } + } + + public void setMarked() { + assert !marked; + marked = true; + } + + public void putValue(byte[] bc, int bci) { + if (hasValue) { + putDestination(bc, bci, value); + } else { + if (toBackfill == null) + toBackfill = new ArrayList<>(); + toBackfill.add(bci); + } + } + + private static void putDestination(byte[] bc, int bci, int value) { + ByteArraySupport.littleEndian().putShort(bc, bci, (short) value); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index a7b5e26e0b25..5319b1d063f6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -221,12 +221,14 @@ public class TruffleTypes { public final DeclaredType UnsupportedSpecializationException = c.getDeclaredType(UnsupportedSpecializationException_Name); // Operations DSL API + public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); public final DeclaredType GenerateOperations = c.getDeclaredType(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredType(Operation_Name); public final DeclaredType OperationLabel = c.getDeclaredType(OperationLabel_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 5ea8017de414..c8eca880c559 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -33,18 +33,90 @@ class OperationsBytecodeCodeGenerator { private int labelCounter = 0; private int backrefCounter = 0; - private final DeclaredType byteArraySupportType; - private final CodeTree leBytes; OperationsBytecodeCodeGenerator(TruffleTypes types, ProcessorContext context) { this.types = types; this.context = context; - byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); - leBytes = CodeTreeBuilder.createBuilder() // - .startCall(CodeTreeBuilder.singleType(byteArraySupportType), "littleEndian") // - .end().build(); + leBytes = CodeTreeBuilder.singleString("LE_BYTES"); + } + + private CodeTree castToLabel(String arg) { + return CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel, CodeTreeBuilder.singleString(arg)).build(); + } + + private static final int RV_ALWAYS = 0; + private static final int RV_NEVER = 1; + private static final int RV_DIVERGES = 2; + + class ReturnsValueChecker { + private final CodeTreeBuilder builder; + + public ReturnsValueChecker(CodeTreeBuilder builder) { + this.builder = builder; + } + + public void buildOperation(OperationsData.Operation operation) { + switch (operation.type) { + case CUSTOM: + buildSimple(operation, operation.returnsValue ? RV_ALWAYS : RV_NEVER); + break; + case PRIM_STORE_LOCAL: + case PRIM_LABEL: + buildSimple(operation, RV_NEVER); + break; + case PRIM_CONST_OBJECT: + case PRIM_LOAD_LOCAL: + case PRIM_LOAD_ARGUMENT: + buildSimple(operation, RV_ALWAYS); + break; + case PRIM_BRANCH: + case PRIM_RETURN: + buildSimple(operation, RV_DIVERGES); + break; + case PRIM_IF_THEN: + case PRIM_WHILE: + buildCondAndBody(); + break; + case PRIM_IF_THEN_ELSE: + buildIfThenElse(); + break; + case PRIM_BLOCK: + buildBlock(); + break; + default: + throw new UnsupportedOperationException("unknown operation type: " + operation.type); + } + } + + private void buildSimple(OperationsData.Operation operation, int rv) { + for (int i = 0; i < operation.children; i++) { + builder.startAssert().string("children[" + i + "].returnsValue != " + RV_NEVER).end(); + } + + builder.statement("this.returnsValue = " + rv); + } + + private void buildCondAndBody() { + builder.startAssert().string("children[0].returnsValue != " + RV_NEVER).end(); + builder.statement("this.returnsValue = " + RV_NEVER); + } + + private void buildIfThenElse() { + builder.startAssert().string("children[0].returnsValue != " + RV_NEVER).end(); + builder.startIf().string("children[1].returnsValue != " + RV_NEVER + " && children[2].returnsValue != " + RV_NEVER).end(); + builder.startBlock(); + builder.statement("this.returnsValue = " + RV_ALWAYS); + builder.end(); + builder.startElseBlock(); + builder.statement("this.returnsValue = " + RV_NEVER); + builder.end(); + } + + private void buildBlock() { + builder.statement("this.returnsValue = children[children.length - 1].returnsValue"); + } } class Builder { @@ -77,21 +149,29 @@ public void buildOperation(OperationsData.Operation operation) { case PRIM_WHILE: buildWhile(); break; - default: - // TODO + case PRIM_LABEL: + buildLabel(); break; + case PRIM_BRANCH: + buildBranch(); + break; + default: + throw new IllegalArgumentException("unknown operation type: " + operation.type); } } private void buildSimple(Operation operation) { for (int i = 0; i < operation.children; i++) { + builder.lineComment("child" + i); buildChildCall(i); } + builder.lineComment("opcode"); buildOp(operation, 0); int argIdx = 0; for (TypeMirror argType : operation.getArguments(types, context)) { + builder.lineComment("argument" + argIdx + ": " + argType.toString()); switch (argType.getKind()) { case BYTE: putByte("(byte) arguments[" + argIdx + "]"); @@ -112,12 +192,9 @@ private void buildSimple(Operation operation) { putLong("(long) arguments[" + argIdx + "]"); break; default: - if (argType.equals(types.OperationLabel)) { - // TODO: resolve - } else { - // TODO: constant pool - } - putShort("(short) 0"); + builder.declaration("short", "index", "(short) constPool.size()"); + builder.statement("constPool.add(arguments[" + argIdx + "])"); + putShort("index"); break; } argIdx++; @@ -133,6 +210,11 @@ private void buildBlock() { buildChildCall("i"); + builder.startIf().string("i != children.length - 1").end(); + builder.startBlock(); + buildPopChild("i"); + builder.end(); + builder.end(); } @@ -143,6 +225,7 @@ private void buildIfThen() { int afterBackref = reserveDestination(); buildChildCall(1); + buildPopChild(1); fillReservedDestination(afterBackref); } @@ -155,6 +238,11 @@ private void buildIfThenElse() { buildChildCall(1); + builder.startIf().string("returnsValue != " + RV_ALWAYS).end(); + builder.startBlock(); + buildPopChild(1); + builder.end(); + buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); int afterBackref = reserveDestination(); @@ -162,6 +250,11 @@ private void buildIfThenElse() { buildChildCall(2); + builder.startIf().string("returnsValue != " + RV_ALWAYS).end(); + builder.startBlock(); + buildPopChild(2); + builder.end(); + fillReservedDestination(afterBackref); } @@ -174,6 +267,7 @@ private void buildWhile() { int afterBackref = reserveDestination(); buildChildCall(1); + buildPopChild(1); buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); fillSavedLabel(startLabel); @@ -181,6 +275,19 @@ private void buildWhile() { fillReservedDestination(afterBackref); } + private void buildLabel() { + builder.declaration(types.BuilderOperationLabel, "label", CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel, + CodeTreeBuilder.singleString("arguments[0]"))); + builder.startStatement().startCall("label", "resolve").string("bc").string("bci").end(2); + } + + private void buildBranch() { + buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); + builder.declaration(types.BuilderOperationLabel, "lbl", castToLabel("arguments[0]")); + builder.startStatement().startCall("lbl", "putValue").string("bc").string("bci").end(2); + builder.statement("bci += " + BC_CONSTS_TARGET_LENGTH); + } + private void buildChildCall(int id) { buildChildCall("" + id); } @@ -191,10 +298,25 @@ private void buildChildCall(String id) { builder.startCall("children[" + id + "]", builder.findMethod()); builder.string("bc"); builder.string("bci"); + builder.string("constPool"); builder.end(); builder.end(); } + private void buildPopChild(int id) { + buildPopChild("" + id); + } + + private void buildPopChild(String id) { + builder.startIf(); + builder.string("children[" + id + "].returnsValue == " + RV_ALWAYS); + builder.end(); + + builder.startBlock(); + buildCommonOp(COMMON_OP_PRIM_POP); + builder.end(); + } + private void buildCommonOp(int id) { builder.startStatement(); builder.string("bc[bci++] = " + commonOpcodeConstants[id].getName()); @@ -244,8 +366,7 @@ private void fillSavedLabel(int label) { private void fillLabel(String dest, String label) { builder.startStatement(); - CodeTree le = CodeTreeBuilder.createBuilder().startCall(CodeTreeBuilder.singleType(byteArraySupportType), "littleEndian").end().build(); - builder.startCall(le, "putShort"); + builder.startCall(leBytes, "putShort"); builder.string("bc"); builder.string(dest); builder.string("(short) " + label); @@ -431,9 +552,21 @@ protected void buildCustomOperation(Operation op) { // TODO: read all arguments - // TODO: invoke + builder.startStatement(); + if (op.returnsValue) { + builder.string("Object result = "); + } + builder.startStaticCall(op.mainMethod); + + for (int i = 0; i < op.children; i++) { + builder.string("value" + i); + } + + builder.end(2); - // TODO: push result + if (op.returnsValue) { + pushValue("result"); + } gotoRelative(1); } @@ -442,7 +575,7 @@ protected void buildCustomOperation(Operation op) { protected void buildConstObject(Operation op) { getShort("int index", "1"); - pushValue("locals[index]"); + pushValue("constPool[index]"); gotoRelative(1 + 2); } @@ -515,7 +648,7 @@ protected Dumper(CodeTreeBuilder builder) { protected void buildJumpFalseOperation() { appendOpcode("brfalse"); getShort("int dest", "1"); - append("dest"); + appendHexa("dest"); gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); } @@ -523,7 +656,7 @@ protected void buildJumpFalseOperation() { protected void buildJumpUncondOperation() { appendOpcode("br"); getShort("int dest", "1"); - append("dest"); + appendHexa("dest"); gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); } @@ -546,6 +679,7 @@ protected void buildConstObject(Operation op) { appendOpcode("ldconst"); getShort("int index", "1"); append("index"); + append("\"// (\" + constPool[index].getClass().getName() + \") \" + constPool[index]"); gotoRelative(1 + 2); } @@ -553,7 +687,7 @@ protected void buildConstObject(Operation op) { protected void buildLoadLocal(Operation op) { appendOpcode("ldloc"); getShort("int index", "1"); - append("index"); + appendHexa("index"); gotoRelative(1 + 2); } @@ -561,7 +695,7 @@ protected void buildLoadLocal(Operation op) { protected void buildStoreLocal(Operation op) { appendOpcode("stloc"); getShort("int index", "1"); - appendDest("index"); + appendHexa("index"); gotoRelative(1 + 2); } @@ -569,7 +703,7 @@ protected void buildStoreLocal(Operation op) { protected void buildLoadArgument(Operation op) { appendOpcode("ldarg"); getShort("int index", "1"); - append("index"); + appendHexa("index"); gotoRelative(1 + 2); } @@ -584,7 +718,7 @@ private void appendOpcode(String op) { append("\"" + opPadded + "\""); } - private void appendDest(String code) { + private void appendHexa(String code) { append("String.format(\"%04x\", " + code + ")"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 4f951786ea3d..62aeda56e5cb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -8,6 +8,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.AnnotationProcessor; @@ -20,6 +21,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationType; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -83,10 +85,21 @@ private void createBuilderImpl() { String simpleName = m.getTemplateType().getSimpleName() + "BuilderinoImpl"; builderImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, builderType.asType()); + { + DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); + CodeVariableElement leBytes = new CodeVariableElement( + Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), + byteArraySupportType, "LE_BYTES"); + CodeTreeBuilder builder = leBytes.createInitBuilder(); + builder.startStaticCall(byteArraySupportType, "littleEndian").end(); + builderImplType.add(leBytes); + } + createBuilderNodeTypeConstants(); createBuilderNodeOpcodeConstants(); createBuilderImplNode(); + createBuilderLabelImpl(); createBuilderBytecodeNode(); @@ -142,12 +155,15 @@ private void createBuildMethod() { builder.declaration(arrayOf(builderNodeType.asType()), "operations", "childStack.get(0).toArray(new " + builderNodeType.getSimpleName() + "[0])"); builder.declaration(builderNodeType.asType(), "rootNode", "new " + builderNodeType.getSimpleName() + "(TYPE_PRIM_BLOCK, new Object[0], operations)"); builder.declaration("byte[]", "bc", "new byte[65535]"); - builder.declaration("int", "len", "rootNode.build(bc, 0)"); + builder.declaration("ArrayList", "constPool", "new ArrayList<>()"); + builder.declaration("int", "len", "rootNode.build(bc, 0, constPool)"); builder.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, len)"); + builder.declaration("Object[]", "cpCopy", "constPool.toArray(new Object[0])"); builder.startReturn(); builder.startNew(builderBytecodeNodeType.asType()); builder.string("bcCopy"); + builder.string("cpCopy"); builder.end(2); builderImplType.add(mBuild); @@ -156,8 +172,7 @@ private void createBuildMethod() { private void createBuilderLabelImpl() { String simpleName = builderImplType.getSimpleName() + "Label"; - builderLabelImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationLabel); - + builderLabelImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); builderImplType.add(builderLabelImplType); } @@ -178,6 +193,13 @@ private void createLabelMethods(CodeTypeElement target, boolean isAbstract) { builder.startNew(builderLabelImplType.asType()); builder.end(2); } + + { + CodeTreeBuilder builder = mMarkLabel.getBuilder(); + builder.declaration(builderLabelImplType.asType(), "lbl", "(" + builderLabelImplType.getSimpleName() + ") label"); + builder.startStatement().startCall("lbl", "setMarked").end(2); + builder.startStatement().startCall("doEmitOperation").string("TYPE_PRIM_LABEL").string("lbl").end(2); + } } /** @@ -191,7 +213,38 @@ private void createBuilderImplNode() { builderNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, null); createBuilderNodeFields(); - builderNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType)); + + { + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType); + + CodeTreeBuilder builder = ctor.getBuilder(); + + OperationsBytecodeCodeGenerator.ReturnsValueChecker gen = bytecodeBuilderGenerator.new ReturnsValueChecker(builder); + + builder.startSwitch().string("type").end(); + builder.startBlock(); + + for (OperationsData.Operation op : m.getOperations()) { + builder.startCase().string(op.getTypeConstant().getName()).end(); + builder.startBlock(); + + gen.buildOperation(op); + + builder.statement("break"); + builder.end(); + } + + builder.caseDefault(); + builder.startCaseBlock(); + builder.tree(GeneratorUtils.createShouldNotReachHere("")); + builder.end(2); + + builder.end(); + + builderNodeType.add(ctor); + } + + builderNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue")); createBuilderNodeBuildMethod(); @@ -208,7 +261,8 @@ private void createBuilderNodeFields() { private void createBuilderNodeBuildMethod() { CodeVariableElement bc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); CodeVariableElement startBci = new CodeVariableElement(context.getType(int.class), "startBci"); - CodeExecutableElement method = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", bc, startBci); + CodeVariableElement constPool = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), context.getType(Object.class)), "constPool"); + CodeExecutableElement method = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", bc, startBci, constPool); CodeTreeBuilder builder = method.getBuilder(); builder.declaration("int", "bci", "startBci"); @@ -242,9 +296,6 @@ private void createBuilderNodeBuildMethod() { /** * Create the node type constants. - * - * Instead of having a proper hierarchy of node types, we just use one BuilderNode class, - * with this type representing which node it is. */ private void createBuilderNodeTypeConstants() { int i = 0; @@ -305,6 +356,7 @@ private void createBuilderBytecodeNode() { builderBytecodeNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationsNode); builderBytecodeNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(byte.class)), "bc")); + builderBytecodeNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(Object.class)), "constPool")); builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); createBuilderBytecodeNodeExecute(); @@ -448,17 +500,9 @@ private void createHelperEmitMethods() { CodeTreeBuilder builder = doBeginOperationMethod.getBuilder(); - builder.startStatement(); - builder.string("typeStack.add(type)"); - builder.end(); - - builder.startStatement(); - builder.string("childStack.add(new ArrayList<>())"); - builder.end(); - - builder.startStatement(); - builder.string("argumentStack.add(arguments)"); - builder.end(); + builder.statement("typeStack.add(type)"); + builder.statement("childStack.add(new ArrayList<>())"); + builder.statement("argumentStack.add(arguments)"); builderImplType.add(doBeginOperationMethod); } @@ -469,17 +513,13 @@ private void createHelperEmitMethods() { CodeTreeBuilder builder = doEndOperationMethod.getBuilder(); - builder.startStatement(); - builder.string("int topType = typeStack.pop()"); - builder.end(); + builder.statement("int topType = typeStack.pop()"); builder.startAssert(); builder.string("topType == type"); builder.end(); - builder.startStatement(); - builder.string("Object[] args = argumentStack.pop()"); - builder.end(); + builder.statement("Object[] args = argumentStack.pop()"); builder.declaration(new ArrayCodeTypeMirror(builderNodeType.asType()), "children", "childStack.pop().toArray(new " + builderNodeType.getSimpleName() + "[0])"); @@ -487,9 +527,7 @@ private void createHelperEmitMethods() { builder.declaration(builderNodeType.asType(), "result", "new " + builderNodeType.getSimpleName() + "(type, args, children)"); - builder.startStatement(); - builder.string("childStack.peek().add(result)"); - builder.end(); + builder.statement("childStack.peek().add(result)"); builderImplType.add(doEndOperationMethod); @@ -521,6 +559,10 @@ private void createHelperEmitMethods() { * @param isAbstract */ private void createBeginEnd(CodeTypeElement target, OperationsData.Operation operation, boolean isAbstract) { + + if (operation.type == OperationType.PRIM_LABEL) + return; + Set mods = isAbstract ? Set.of(Modifier.PUBLIC, Modifier.ABSTRACT) : Set.of(Modifier.PUBLIC); if (operation.children == 0) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 6e16f3c44dbf..c391f7dadf00 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -5,6 +5,7 @@ import java.util.List; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; @@ -26,7 +27,8 @@ enum OperationType { PRIM_STORE_LOCAL("StoreLocal"), PRIM_LOAD_ARGUMENT("LoadArgument"), PRIM_RETURN("Return"), - PRIM_BRANCH("Branch", 0); + PRIM_BRANCH("Branch", 0), + PRIM_LABEL("Label", 0); final String name; final int numOpcodes; @@ -46,16 +48,18 @@ static class Operation { final List arguments; final int children; final TypeElement typeElement; + final ExecutableElement mainMethod; final boolean returnsValue; CodeVariableElement typeConstant; CodeVariableElement[] opcodeConstant; - Operation(OperationType type, List arguments, int children, TypeElement typeElement, boolean returnsValue) { + Operation(OperationType type, List arguments, int children, TypeElement typeElement, ExecutableElement mainMethod, boolean returnsValue) { this.type = type; this.arguments = arguments; this.children = children; this.typeElement = typeElement; + this.mainMethod = mainMethod; this.returnsValue = returnsValue; } @@ -84,6 +88,9 @@ public void setTypeConstant(CodeVariableElement typeConstant) { } public CodeVariableElement[] getOpcodeConstant() { + if (opcodeConstant == null) { + throw new IllegalArgumentException("Opcode constant not defined for " + type); + } return opcodeConstant; } @@ -108,6 +115,7 @@ public Collection getArguments(TruffleTypes types, Process case PRIM_IF_THEN_ELSE: case PRIM_WHILE: case PRIM_RETURN: + case PRIM_LABEL: return List.of(); default: throw new IllegalArgumentException("bad type: " + type); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index d720c33f133c..cb491d152a06 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -66,10 +66,11 @@ private static void addPrimitives(OperationsData data) { addPrimitiveOperation(data, OperationType.PRIM_LOAD_ARGUMENT, 0, true); addPrimitiveOperation(data, OperationType.PRIM_RETURN, 1, true); addPrimitiveOperation(data, OperationType.PRIM_BRANCH, 0, false); + addPrimitiveOperation(data, OperationType.PRIM_LABEL, 0, false); } private static void addPrimitiveOperation(OperationsData data, OperationType type, int numChildren, boolean returnsValue) { - data.getOperations().add(new OperationsData.Operation(type, List.of(), numChildren, null, returnsValue)); + data.getOperations().add(new OperationsData.Operation(type, List.of(), numChildren, null, null, returnsValue)); } private void processOperation(OperationsData data, TypeElement te) { @@ -105,7 +106,7 @@ private void processOperation(OperationsData data, TypeElement te) { } } - data.getOperations().add(new OperationsData.Operation(OperationType.CUSTOM, arguments, numChildren, te, true)); + data.getOperations().add(new OperationsData.Operation(OperationType.CUSTOM, arguments, numChildren, te, first, true)); } private static boolean isOperationFunction(ExecutableElement el) { From 44df7ada8871a9f515b8087271a7b55e2f68ee34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 7 Mar 2022 12:51:10 +0100 Subject: [PATCH 005/312] [wip] refactor and implement UncachedNode dispatch --- .../operation/test/example/SlOperations.java | 24 +- .../test/example/TestOperationsGenTest.java | 6 +- .../api/operation/OperationsBuilder.java | 26 +- .../api/operation/OperationsConstantPool.java | 35 + .../truffle/dsl/processor/TruffleTypes.java | 2 + .../processor/generator/GeneratorUtils.java | 10 + .../dsl/processor/java/ElementUtils.java | 5 +- .../processor/java/model/CodeTreeBuilder.java | 16 + .../dsl/processor/operations/Instruction.java | 427 ++++++++ .../dsl/processor/operations/Operation.java | 280 +++++ .../operations/OperationGeneratorUtils.java | 81 ++ .../OperationsBytecodeCodeGenerator.java | 735 ------------- .../operations/OperationsCodeGenerator.java | 987 +++++++++--------- .../processor/operations/OperationsData.java | 129 +-- .../operations/OperationsParser.java | 42 +- .../dsl/processor/parser/NodeParser.java | 4 + 16 files changed, 1429 insertions(+), 1380 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index 3aed2e36e030..425bead09508 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -1,22 +1,34 @@ package com.oracle.truffle.api.operation.test.example; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -// TODO: where to attach this once we don't have a wrapper class? @GenerateOperations -class SlOperations { +public class SlOperations { + @Operation static class AddOperation { - public static Object add(Object lhs, Object rhs) { - return (long) lhs + (long) rhs; + // @Cached(inline = true) MyOtherNode node; + + @Specialization + public static long add(long lhs, long rhs) { + return lhs + rhs; } + + @Specialization + public static String addStrings(String lhs, String rhs) { + return lhs + rhs; + } } @Operation static class LessThanOperation { - public static Object lessThan(Object lhs, Object rhs) { - return (long) lhs < (long) rhs; + @Specialization + public static boolean lessThan(long lhs, long rhs) { + return lhs < rhs; } } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index a48b55452f20..7ac4bf29df79 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -74,6 +74,7 @@ private static void parseMax(SlOperationsBuilderino b) { @Test public void testAdd() { runTest(TestOperationsGenTest::parseAdd, 42L, 20L, 22L); + runTest(TestOperationsGenTest::parseAdd, "foobar", "foo", "bar"); } @Test @@ -94,9 +95,12 @@ public void testBreakLoop() { } private static void runTest(Consumer parse, Object expectedResult, Object... args) { + System.out.println("------------------------------------"); SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); parse.accept(b); + System.out.println(" building"); OperationsNode executable = b.build(); + System.out.println(" dumping"); System.out.println(executable.dump()); b.reset(); System.out.println(executable); @@ -202,7 +206,7 @@ private static void parseBreakLoop(SlOperationsBuilderino b) { b.endWhile(); - b.markLabel(breakLbl); + b.emitLabel(breakLbl); b.beginReturn(); b.emitLoadLocal((short) 0); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 4d3f2c38ce45..d578e76cb88b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,32 +1,8 @@ package com.oracle.truffle.api.operation; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Stack; - public abstract class OperationsBuilder { - private OperationsStatistics statistics; - - protected final void onBuild(OperationsNode executable) { - if (statistics == null) { - return; - } - // executable.createPointer(); - } - - public void setCollectStatistics(boolean statistics) { - this.statistics = new OperationsStatistics(); - } - - public abstract void reset(); - public abstract OperationsNode build(); - private static final class OperationsStatistics { - } - - public void dumpStatistics(OutputStream stream) { - } - + public abstract void reset(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java new file mode 100644 index 000000000000..78c8c28863fe --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java @@ -0,0 +1,35 @@ +package com.oracle.truffle.api.operation; + +import java.util.ArrayList; + +public class OperationsConstantPool { + + private ArrayList values = new ArrayList<>(); + private boolean frozen = false; + private Object[] frozenValues = null; + + public synchronized int add(Object o) { + if (frozen) + throw new IllegalStateException("constant pool already frozen"); + int idx = values.indexOf(o); + if (idx == -1) { + idx = values.size(); + values.add(o); + } + return idx; + } + + public synchronized void freeze() { + frozen = true; + } + + public synchronized Object[] getValues() { + freeze(); + if (frozenValues == null) { + frozenValues = values.toArray(); + values = null; + } + return frozenValues; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 5319b1d063f6..5f3d4d1301f4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -226,6 +226,7 @@ public class TruffleTypes { public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; + public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); @@ -233,6 +234,7 @@ public class TruffleTypes { public final DeclaredType Operation = c.getDeclaredType(Operation_Name); public final DeclaredType OperationLabel = c.getDeclaredType(OperationLabel_Name); public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); + public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); // Library API diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 14f096e910f3..cb16bcf7948d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -352,6 +352,16 @@ public static CodeExecutableElement override(DeclaredType type, String methodNam return CodeExecutableElement.clone(method); } + public static CodeExecutableElement overrideImplement(TypeElement typeElement, String methodName) { + ExecutableElement method = ElementUtils.findMethod(typeElement, methodName); + if (method == null) { + return null; + } + CodeExecutableElement result = CodeExecutableElement.clone(method); + result.getModifiers().remove(Modifier.ABSTRACT); + return result; + } + public static void addThrownExceptions(CodeExecutableElement executable, List thrownTypes) { outer: for (TypeMirror thrownType : thrownTypes) { for (TypeMirror type : executable.getThrownTypes()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 4eb3343c932f..ff765dea3d1f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -99,7 +99,10 @@ public static ExecutableElement findMethod(Class type, String methodName) { public static ExecutableElement findMethod(DeclaredType type, String methodName) { ProcessorContext context = ProcessorContext.getInstance(); - TypeElement typeElement = context.getTypeElement(type); + return findMethod(context.getTypeElement(type), methodName); + } + + public static ExecutableElement findMethod(TypeElement typeElement, String methodName) { for (ExecutableElement method : ElementFilter.methodsIn(typeElement.getEnclosedElements())) { if (method.getSimpleName().toString().equals(methodName)) { return method; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index 4ecab659ecaa..ff73d4f8ddca 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -148,6 +148,10 @@ public static CodeTree singleType(TypeMirror s) { return createBuilder().type(s).build(); } + public static CodeTree singleVariable(VariableElement s) { + return createBuilder().variable(s).build(); + } + private CodeTreeBuilder push(CodeTreeKind kind) { return push(new BuilderCodeTree(currentElement, kind, null, null), kind == NEW_LINE); } @@ -239,6 +243,10 @@ public CodeTreeBuilder startCall(String callSite) { return startCall((CodeTree) null, callSite); } + public CodeTreeBuilder startCall(VariableElement receiver, String callSite) { + return startCall(receiver.getSimpleName().toString(), callSite); + } + public CodeTreeBuilder startCall(String receiver, ExecutableElement method) { if (receiver == null && method.getModifiers().contains(Modifier.STATIC)) { return startStaticCall(method.getEnclosingElement().asType(), method.getSimpleName().toString()); @@ -983,6 +991,14 @@ public CodeTreeBuilder startAssign(String receiver, VariableElement field) { return startStatement().field(receiver, field).string(" = "); } + public CodeTreeBuilder startAssign(VariableElement variable) { + return startStatement().string(variable.getSimpleName().toString()).string(" = "); + } + + public CodeTreeBuilder variable(VariableElement variable) { + return string(variable.getSimpleName().toString()); + } + public CodeTreeBuilder field(String receiver, VariableElement field) { if (receiver == null && field.getModifiers().contains(Modifier.STATIC)) { return staticReference(field); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java new file mode 100644 index 000000000000..9b3d37f9c910 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -0,0 +1,427 @@ +package com.oracle.truffle.dsl.processor.operations; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +abstract class Instruction { + + static class ExecutorVariables { + CodeVariableElement bci; + CodeVariableElement nextBci; + CodeVariableElement bc; + CodeVariableElement consts; + CodeVariableElement stack; + CodeVariableElement sp; + CodeVariableElement locals; + CodeVariableElement funArgs; + CodeVariableElement returnValue; + + CodeVariableElement[] arguments; + CodeVariableElement[] children; + CodeVariableElement result; + + public ExecutorVariables(CodeVariableElement bci, CodeVariableElement nextBci, CodeVariableElement bc, CodeVariableElement consts, CodeVariableElement stack, CodeVariableElement sp, + CodeVariableElement locals, CodeVariableElement funArgs, CodeVariableElement returnValue) { + this.bci = bci; + this.nextBci = nextBci; + this.bc = bc; + this.consts = consts; + this.stack = stack; + this.sp = sp; + this.locals = locals; + this.funArgs = funArgs; + this.returnValue = returnValue; + this.arguments = null; + this.children = null; + this.result = null; + } + + } + + enum ArgumentType { + BYTE(1), + SHORT(2), + JUMP_TARGET(2), + LOCAL(2), + FUN_ARG(2), + LOCAL_INDEX(2), + CONSTANT_POOL(2); + + public final int length; + + public TypeMirror toType(ProcessorContext context, TruffleTypes types) { + switch (this) { + case BYTE: + return context.getType(byte.class); + case LOCAL: + case FUN_ARG: + case LOCAL_INDEX: + case SHORT: + return context.getType(short.class); + case JUMP_TARGET: + return types.OperationLabel; + case CONSTANT_POOL: + return context.getType(Object.class); + default: + throw new IllegalArgumentException(this.toString()); + } + } + + private ArgumentType(int length) { + this.length = length; + } + + public TypeMirror toExecType(ProcessorContext context, TruffleTypes types) { + switch (this) { + case BYTE: + return context.getType(byte.class); + case SHORT: + case JUMP_TARGET: + case LOCAL_INDEX: + return context.getType(short.class); + case LOCAL: + case FUN_ARG: + case CONSTANT_POOL: + return context.getType(Object.class); + default: + throw new IllegalArgumentException(this.toString()); + } + } + + CodeTree createReaderCode(ExecutorVariables vars, CodeTree offset) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + switch (this) { + case BYTE: + b.variable(vars.bc).string("[").tree(offset).string("]"); + break; + case SHORT: + case JUMP_TARGET: + case LOCAL_INDEX: + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.tree(offset); + b.end(); + break; + case CONSTANT_POOL: + b.variable(vars.consts); + b.string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.tree(offset); + b.end(); + b.string("]"); + break; + case FUN_ARG: + b.variable(vars.funArgs); + b.string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.tree(offset); + b.end(); + b.string("]"); + break; + case LOCAL: + b.variable(vars.locals); + b.string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.tree(offset); + b.end(); + b.string("]"); + break; + default: + throw new IllegalArgumentException(this.toString()); + } + return b.build(); + } + + CodeTree createDumperReaderCode(CodeVariableElement varBc, CodeTree offset) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + switch (this) { + case BYTE: + b.variable(varBc).string("[").tree(offset).string("]"); + break; + case SHORT: + case JUMP_TARGET: + case LOCAL_INDEX: + case FUN_ARG: + case CONSTANT_POOL: + case LOCAL: + b.startCall("LE_BYTES", "getShort"); + b.variable(varBc); + b.tree(offset); + b.end(); + break; + default: + throw new IllegalArgumentException(this.toString()); + } + return b.build(); + } + + CodeTree createDumperCode(CodeVariableElement varBc, CodeTree offset, CodeVariableElement sb) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement(); + b.startCall(sb, "append"); + b.startCall("String", "format"); + switch (this) { + case BYTE: + case SHORT: + case LOCAL: + case LOCAL_INDEX: + case FUN_ARG: + case CONSTANT_POOL: + b.doubleQuote("%d "); + break; + case JUMP_TARGET: + b.doubleQuote("%04x "); + break; + default: + throw new IllegalArgumentException(this.toString()); + } + b.tree(createDumperReaderCode(varBc, offset)); + b.end(3); + + return b.build(); + } + } + + final int opcodeNumber; + final ArgumentType[] arguments; + final int stackPops; + final int stackPushes; + + protected Instruction(int opcodeNumber, int stackPops, int stackPushes, ArgumentType... arguments) { + this.opcodeNumber = opcodeNumber; + this.stackPops = stackPops; + this.stackPushes = stackPushes; + this.arguments = arguments; + } + + public int length() { + int l = 1; + for (ArgumentType arg : arguments) { + l += arg.length; + } + return l; + } + + public boolean isDivergent() { + return false; + } + + CodeTree createEmitterCode( + TruffleTypes types, + Operation.EmitterVariables vars, + String... varArguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.lineComment("opcode"); + + // TODO: support multibyte ops + OperationGeneratorUtils.buildWriteByte(b, Integer.toString(opcodeNumber), vars.bc, vars.bci); + + for (int i = 0; i < arguments.length; i++) { + b.lineComment("argument" + i); + String argv = varArguments[i]; + switch (arguments[i]) { + case BYTE: + OperationGeneratorUtils.buildWriteByte(b, argv, vars.bc, vars.bci); + break; + case LOCAL: + case LOCAL_INDEX: + case FUN_ARG: + case SHORT: + OperationGeneratorUtils.buildWriteShort(b, "(short) " + argv, vars.bc, vars.bci); + break; + case CONSTANT_POOL: + b.declaration("int", "argidx_" + i, CodeTreeBuilder.createBuilder().startCall(CodeTreeBuilder.singleVariable(vars.consts), "add").string(argv).end().build()); + OperationGeneratorUtils.buildWriteShort(b, "(short) argidx_" + i, vars.bc, vars.bci); + break; + case JUMP_TARGET: + b.declaration(types.BuilderOperationLabel, "lbl_" + i, "(" + types.BuilderOperationLabel.asElement().getSimpleName() + ") " + argv); + b.startStatement().startCall("lbl_" + i, "putValue").variable(vars.bc).variable(vars.bci).end(2); + b.startAssign(vars.bci).variable(vars.bci).string("+ 2").end(); + break; + default: + throw new IllegalArgumentException("unknown argument type " + arguments[i]); + } + } + + return b.build(); + } + + abstract CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars); + + CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); + return b.build(); + } + + static class StoreLocal extends Instruction { + protected StoreLocal(int opcodeNumber) { + super(opcodeNumber, 1, 0, ArgumentType.LOCAL_INDEX); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement(); + b.variable(vars.locals).string("[").variable(vars.arguments[0]).string("] ="); + b.variable(vars.children[0]); + b.end(); + + return b.build(); + } + } + + static class JumpUncond extends Instruction { + protected JumpUncond(int opcodeNumber) { + super(opcodeNumber, 0, 0, ArgumentType.JUMP_TARGET); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.nextBci).tree(OperationGeneratorUtils.buildReadShort(vars.bc, vars.bci.getName() + " + 1")).end(); + return b.build(); + } + + @Override + CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { + return null; + } + } + + static class JumpFalse extends Instruction { + protected JumpFalse(int opcodeNumber) { + super(opcodeNumber, 1, 0, ArgumentType.JUMP_TARGET); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().string("(boolean) ").variable(vars.children[0]).end(); + b.startBlock(); + b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); + b.end(); + b.startElseBlock(); + b.startAssign(vars.nextBci).variable(vars.arguments[0]).end(); + b.end(); + + return b.build(); + } + + @Override + CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { + return null; + } + } + + static class Pop extends Instruction { + protected Pop(int opcodeNumber) { + super(opcodeNumber, 1, 0); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement().variable(vars.sp).string(" -= 1").end(); + return b.build(); + } + + } + + static class Return extends Instruction { + protected Return(int opcodeNumber) { + super(opcodeNumber, 1, 0); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.returnValue).variable(vars.children[0]).end(); + b.statement("break loop"); + return b.build(); + } + + @Override + public boolean isDivergent() { + return true; + } + } + + static abstract class SimplePushInstruction extends Instruction { + protected SimplePushInstruction(int opcodeNumber, ArgumentType... arguments) { + super(opcodeNumber, 0, 1, arguments); + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.result).variable(vars.arguments[0]).end(); + return b.build(); + } + } + + static class ConstObject extends SimplePushInstruction { + protected ConstObject(int opcodeNumber) { + super(opcodeNumber, ArgumentType.CONSTANT_POOL); + } + } + + static class LoadLocal extends SimplePushInstruction { + protected LoadLocal(int opcodeNumber) { + super(opcodeNumber, ArgumentType.LOCAL); + } + } + + static class LoadArgument extends SimplePushInstruction { + protected LoadArgument(int opcodeNumber) { + super(opcodeNumber, ArgumentType.FUN_ARG); + } + } + + static class Custom extends Instruction { + private final TypeElement type; + + private VariableElement uncachedInstance; + + public TypeElement getType() { + return type; + } + + protected Custom(int opcodeNumber, TypeElement type, ExecutableElement mainMethod) { + super(opcodeNumber, mainMethod.getParameters().size(), 1); + this.type = type; + } + + public void setUncachedInstance(VariableElement uncachedInstance) { + this.uncachedInstance = uncachedInstance; + } + + @Override + CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.result); + b.startCall(CodeTreeBuilder.createBuilder().staticReference(uncachedInstance).build(), "execute"); + for (CodeVariableElement child : vars.children) { + b.variable(child); + } + b.end(); + b.end(); + return b.build(); + } + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java new file mode 100644 index 000000000000..f1c15cd383fb --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -0,0 +1,280 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; + +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +abstract class Operation { + + static class EmitterVariables { + final CodeExecutableElement self; + final CodeVariableElement bc; + final CodeVariableElement bci; + final CodeVariableElement consts; + final CodeVariableElement children; + final CodeVariableElement arguments; + + public EmitterVariables(CodeExecutableElement self, CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement consts, CodeVariableElement children, + CodeVariableElement arguments) { + this.self = self; + this.bc = bc; + this.bci = bci; + this.consts = consts; + this.children = children; + this.arguments = arguments; + } + + } + + public static final int VARIABLE_CHILDREN = -1; + + protected final String name; + protected final int type; + protected final int children; + protected final Instruction[] instructions; + + public static final int COMMON_OPCODE_JUMP_UNCOND = 0; + public static final int COMMON_OPCODE_JUMP_FALSE = 1; + public static final int COMMON_OPCODE_POP = 2; + protected static final int NUM_COMMON_OPCODES = 3; + + protected Instruction[] commonInstructions; + + static Instruction[] createCommonOpcodes(int start) { + Instruction[] commonOpcodes = new Instruction[NUM_COMMON_OPCODES]; + commonOpcodes[COMMON_OPCODE_JUMP_UNCOND] = new Instruction.JumpUncond(start); + commonOpcodes[COMMON_OPCODE_JUMP_FALSE] = new Instruction.JumpFalse(start + 1); + commonOpcodes[COMMON_OPCODE_POP] = new Instruction.Pop(start + 2); + return commonOpcodes; + } + + protected Operation(String name, int type, int children, Instruction... opcodes) { + this.name = name; + this.type = type; + this.children = children; + this.instructions = opcodes; + } + + public void setCommonInstructions(Instruction[] commonInstructions) { + this.commonInstructions = commonInstructions; + } + + public String getName() { + return name; + } + + public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { + ArrayList arr = new ArrayList<>(); + + for (Instruction inst : instructions) { + for (Instruction.ArgumentType art : inst.arguments) { + arr.add(art.toType(context, types)); + } + } + + return arr.toArray(new TypeMirror[arr.size()]); + } + + public boolean hasChildren() { + return children != 0; + } + + public int getType() { + return type; + } + + public abstract CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars); + + static class SimpleOperation extends Operation { + + SimpleOperation(String name, int type, Instruction opcode) { + super(name, type, opcode.stackPops, opcode); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + for (int i = 0; i < children; i++) { + OperationGeneratorUtils.buildChildCall(b, Integer.toString(i), vars); + } + + String[] arguments = new String[instructions[0].arguments.length]; + + for (int i = 0; i < arguments.length; i++) { + arguments[i] = vars.arguments.getName() + "[" + i + "]"; + } + + b.tree(instructions[0].createEmitterCode(types, vars, arguments)); + + return b.build(); + } + } + + static class CustomOperation extends SimpleOperation { + + public CustomOperation(String name, int type, Instruction.Custom opcode) { + super(name, type, opcode); + } + + public Instruction.Custom getCustomInstruction() { + return (Instruction.Custom) instructions[0]; + } + + } + + static abstract class PseudoOperation extends Operation { + public PseudoOperation(String name, int type, int children) { + super(name, type, children); + } + } + + static class Block extends PseudoOperation { + public Block(int type) { + super("Block", type, VARIABLE_CHILDREN); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startFor().string("int i = 0; i < " + vars.children.getName() + ".length; i++").end(); + b.startBlock(); + OperationGeneratorUtils.buildChildCall(b, "i", vars); + b.end(); + + return b.build(); + } + + } + + static class IfThen extends PseudoOperation { + public IfThen(int type) { + super("IfThen", type, 2); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // <> + OperationGeneratorUtils.buildChildCall(b, "0", vars); + + // jump_false end + OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); + b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); + b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + + // <> + OperationGeneratorUtils.buildChildCall(b, "1", vars); + + // end: + OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + + return b.build(); + } + + } + + static class IfThenElse extends PseudoOperation { + public IfThenElse(int type) { + super("IfThenElse", type, 3); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // <> + OperationGeneratorUtils.buildChildCall(b, "0", vars); + + // jump_false else + OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); + b.declaration("int", "fwdref_else", CodeTreeBuilder.singleVariable(vars.bci)); + b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + + // <> + OperationGeneratorUtils.buildChildCall(b, "1", vars); + + // jump_uncond end + OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_UNCOND].opcodeNumber, vars.bc, vars.bci); + b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); + b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + + // else: + OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_else", vars.bc, vars.bci); + + // <> + OperationGeneratorUtils.buildChildCall(b, "2", vars); + + // end: + OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + + return b.build(); + } + + } + + static class While extends PseudoOperation { + public While(int type) { + super("While", type, 2); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // start: + b.declaration("int", "backref_start", CodeTreeBuilder.singleVariable(vars.bci)); + + // <> + OperationGeneratorUtils.buildChildCall(b, "0", vars); + + // jump_false end + OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); + b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); + b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + + // <> + OperationGeneratorUtils.buildChildCall(b, "1", vars); + + // jump start + OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_UNCOND].opcodeNumber, vars.bc, vars.bci); + OperationGeneratorUtils.buildWriteShort(b, "backref_start", vars.bc, vars.bci); + + // end: + OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + + return b.build(); + } + } + + static class Label extends PseudoOperation { + public Label(int type) { + super("Label", type, 0); + } + + @Override + public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration(types.BuilderOperationLabel, "lbl", CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel).variable(vars.arguments).string("[0]").build()); + b.startStatement().startCall("lbl", "resolve").variable(vars.bc).variable(vars.bci).end(2); + + return b.build(); + } + + @Override + public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { + return new TypeMirror[]{types.OperationLabel}; + } + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java new file mode 100644 index 000000000000..1e7ba4d66218 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -0,0 +1,81 @@ +package com.oracle.truffle.dsl.processor.operations; + +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +public class OperationGeneratorUtils { + + static void buildWriteByte( + CodeTreeBuilder b, + String value, + CodeVariableElement varBc, + CodeVariableElement varBci) { + b.startStatement(); + b.variable(varBc).string("[").variable(varBci).string("++] = ", value); + b.end(); + } + + static CodeTree buildReadByte( + CodeVariableElement varBc, + String from) { + return CodeTreeBuilder.singleString(varBc.getName() + "[" + from + "]"); + } + + static CodeTree buildPop( + CodeVariableElement varStack, + CodeVariableElement varSp) { + return CodeTreeBuilder.createBuilder().variable(varStack).string("[--").variable(varSp).string("]").build(); + } + + static CodeTree buildPush( + CodeVariableElement varStack, + CodeVariableElement varSp, + String value) { + return CodeTreeBuilder.createBuilder().startStatement().variable(varStack).string("[").variable(varSp).string("++] = " + value).build(); + } + + static void buildWriteShort( + CodeTreeBuilder b, + String value, + CodeVariableElement varBc, + CodeVariableElement varBci) { + b.startStatement(); + b.startCall("LE_BYTES", "putShort"); + b.variable(varBc).variable(varBci).string("(short)" + value); + b.end(2); // call, statement + + b.startStatement(); + b.variable(varBci).string(" += 2"); + b.end(); + } + + static CodeTree buildReadShort( + CodeVariableElement varBc, + String from) { + return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort").variable(varBc).string(from).end().build(); + } + + static void buildWriteForwardReference( + CodeTreeBuilder b, + String varFwdRef, + CodeVariableElement varBc, + CodeVariableElement varBci) { + b.startStatement(); + b.startCall("LE_BYTES", "putShort"); + b.variable(varBc).string(varFwdRef); + b.startGroup().string("(short) ").variable(varBci).end(); + b.end(2); // call, statement + } + + static void buildChildCall( + CodeTreeBuilder b, + String i, + Operation.EmitterVariables vars) { + b.startAssign(vars.bci); + b.startCall(vars.children.getSimpleName().toString() + "[" + i + "]", vars.self); + b.variable(vars.bc).variable(vars.bci).variable(vars.consts); + b.end(2); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java deleted file mode 100644 index c8eca880c559..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ /dev/null @@ -1,735 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations; - -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationsData.Operation; - -class OperationsBytecodeCodeGenerator { - - final int BC_CONSTS_TARGET_LENGTH = 2; - - private final TruffleTypes types; - private final ProcessorContext context; - - private CodeTreeBuilder builder; - - private static final int COMMON_OP_PRIM_JUMP_FALSE = 0; - private static final int COMMON_OP_PRIM_JUMP_UNCOND = 1; - private static final int COMMON_OP_PRIM_POP = 2; - static String[] commonOpcodeNames = new String[]{ - "PRIM_JUMP_FALSE", - "PRIM_JUMP_UNCOND", - "PRIM_POP", - }; - - CodeVariableElement[] commonOpcodeConstants; - - private int labelCounter = 0; - private int backrefCounter = 0; - - private final CodeTree leBytes; - - OperationsBytecodeCodeGenerator(TruffleTypes types, ProcessorContext context) { - this.types = types; - this.context = context; - - leBytes = CodeTreeBuilder.singleString("LE_BYTES"); - } - - private CodeTree castToLabel(String arg) { - return CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel, CodeTreeBuilder.singleString(arg)).build(); - } - - private static final int RV_ALWAYS = 0; - private static final int RV_NEVER = 1; - private static final int RV_DIVERGES = 2; - - class ReturnsValueChecker { - private final CodeTreeBuilder builder; - - public ReturnsValueChecker(CodeTreeBuilder builder) { - this.builder = builder; - } - - public void buildOperation(OperationsData.Operation operation) { - switch (operation.type) { - case CUSTOM: - buildSimple(operation, operation.returnsValue ? RV_ALWAYS : RV_NEVER); - break; - case PRIM_STORE_LOCAL: - case PRIM_LABEL: - buildSimple(operation, RV_NEVER); - break; - case PRIM_CONST_OBJECT: - case PRIM_LOAD_LOCAL: - case PRIM_LOAD_ARGUMENT: - buildSimple(operation, RV_ALWAYS); - break; - case PRIM_BRANCH: - case PRIM_RETURN: - buildSimple(operation, RV_DIVERGES); - break; - case PRIM_IF_THEN: - case PRIM_WHILE: - buildCondAndBody(); - break; - case PRIM_IF_THEN_ELSE: - buildIfThenElse(); - break; - case PRIM_BLOCK: - buildBlock(); - break; - default: - throw new UnsupportedOperationException("unknown operation type: " + operation.type); - } - } - - private void buildSimple(OperationsData.Operation operation, int rv) { - for (int i = 0; i < operation.children; i++) { - builder.startAssert().string("children[" + i + "].returnsValue != " + RV_NEVER).end(); - } - - builder.statement("this.returnsValue = " + rv); - } - - private void buildCondAndBody() { - builder.startAssert().string("children[0].returnsValue != " + RV_NEVER).end(); - builder.statement("this.returnsValue = " + RV_NEVER); - } - - private void buildIfThenElse() { - builder.startAssert().string("children[0].returnsValue != " + RV_NEVER).end(); - builder.startIf().string("children[1].returnsValue != " + RV_NEVER + " && children[2].returnsValue != " + RV_NEVER).end(); - builder.startBlock(); - builder.statement("this.returnsValue = " + RV_ALWAYS); - builder.end(); - builder.startElseBlock(); - builder.statement("this.returnsValue = " + RV_NEVER); - builder.end(); - } - - private void buildBlock() { - builder.statement("this.returnsValue = children[children.length - 1].returnsValue"); - } - } - - class Builder { - - private final CodeTreeBuilder builder; - - public Builder(CodeTreeBuilder builder) { - this.builder = builder; - } - - public void buildOperation(OperationsData.Operation operation) { - switch (operation.type) { - case CUSTOM: - case PRIM_CONST_OBJECT: - case PRIM_LOAD_LOCAL: - case PRIM_STORE_LOCAL: - case PRIM_LOAD_ARGUMENT: - case PRIM_RETURN: - buildSimple(operation); - break; - case PRIM_BLOCK: - buildBlock(); - break; - case PRIM_IF_THEN: - buildIfThen(); - break; - case PRIM_IF_THEN_ELSE: - buildIfThenElse(); - break; - case PRIM_WHILE: - buildWhile(); - break; - case PRIM_LABEL: - buildLabel(); - break; - case PRIM_BRANCH: - buildBranch(); - break; - default: - throw new IllegalArgumentException("unknown operation type: " + operation.type); - } - } - - private void buildSimple(Operation operation) { - for (int i = 0; i < operation.children; i++) { - builder.lineComment("child" + i); - buildChildCall(i); - } - - builder.lineComment("opcode"); - buildOp(operation, 0); - - int argIdx = 0; - for (TypeMirror argType : operation.getArguments(types, context)) { - builder.lineComment("argument" + argIdx + ": " + argType.toString()); - switch (argType.getKind()) { - case BYTE: - putByte("(byte) arguments[" + argIdx + "]"); - break; - case BOOLEAN: - putByte("((boolean) arguments[" + argIdx + "]) ? 1 : 0"); - break; - case CHAR: - putShort("(short)(char) arguments[" + argIdx + "]"); - break; - case SHORT: - putShort("(short) arguments[" + argIdx + "]"); - break; - case INT: - putInt("(int) arguments[" + argIdx + "]"); - break; - case LONG: - putLong("(long) arguments[" + argIdx + "]"); - break; - default: - builder.declaration("short", "index", "(short) constPool.size()"); - builder.statement("constPool.add(arguments[" + argIdx + "])"); - putShort("index"); - break; - } - argIdx++; - } - } - - private void buildBlock() { - builder.startFor(); - builder.string("int i = 0; i < children.length; i++"); - builder.end(); - - builder.startBlock(); - - buildChildCall("i"); - - builder.startIf().string("i != children.length - 1").end(); - builder.startBlock(); - buildPopChild("i"); - builder.end(); - - builder.end(); - } - - private void buildIfThen() { - buildChildCall(0); - - buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); - int afterBackref = reserveDestination(); - - buildChildCall(1); - buildPopChild(1); - - fillReservedDestination(afterBackref); - } - - private void buildIfThenElse() { - buildChildCall(0); - - buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); - int elseBackref = reserveDestination(); - - buildChildCall(1); - - builder.startIf().string("returnsValue != " + RV_ALWAYS).end(); - builder.startBlock(); - buildPopChild(1); - builder.end(); - - buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); - int afterBackref = reserveDestination(); - - fillReservedDestination(elseBackref); - - buildChildCall(2); - - builder.startIf().string("returnsValue != " + RV_ALWAYS).end(); - builder.startBlock(); - buildPopChild(2); - builder.end(); - - fillReservedDestination(afterBackref); - } - - private void buildWhile() { - - int startLabel = saveLabel(); - buildChildCall(0); - - buildCommonOp(COMMON_OP_PRIM_JUMP_FALSE); - int afterBackref = reserveDestination(); - - buildChildCall(1); - buildPopChild(1); - - buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); - fillSavedLabel(startLabel); - - fillReservedDestination(afterBackref); - } - - private void buildLabel() { - builder.declaration(types.BuilderOperationLabel, "label", CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel, - CodeTreeBuilder.singleString("arguments[0]"))); - builder.startStatement().startCall("label", "resolve").string("bc").string("bci").end(2); - } - - private void buildBranch() { - buildCommonOp(COMMON_OP_PRIM_JUMP_UNCOND); - builder.declaration(types.BuilderOperationLabel, "lbl", castToLabel("arguments[0]")); - builder.startStatement().startCall("lbl", "putValue").string("bc").string("bci").end(2); - builder.statement("bci += " + BC_CONSTS_TARGET_LENGTH); - } - - private void buildChildCall(int id) { - buildChildCall("" + id); - } - - private void buildChildCall(String id) { - builder.startStatement(); - builder.string("bci = "); - builder.startCall("children[" + id + "]", builder.findMethod()); - builder.string("bc"); - builder.string("bci"); - builder.string("constPool"); - builder.end(); - builder.end(); - } - - private void buildPopChild(int id) { - buildPopChild("" + id); - } - - private void buildPopChild(String id) { - builder.startIf(); - builder.string("children[" + id + "].returnsValue == " + RV_ALWAYS); - builder.end(); - - builder.startBlock(); - buildCommonOp(COMMON_OP_PRIM_POP); - builder.end(); - } - - private void buildCommonOp(int id) { - builder.startStatement(); - builder.string("bc[bci++] = " + commonOpcodeConstants[id].getName()); - builder.end(); - } - - private void buildOp(Operation operation, int id) { - builder.startStatement(); - builder.string("bc[bci++] = " + operation.getOpcodeConstant()[id].getName()); - builder.end(); - } - - private int saveLabel() { - int id = labelCounter++; - - builder.startStatement(); - builder.string("int label_" + id + " = bci"); - builder.end(); - - return id; - } - - private int reserveDestination() { - int id = backrefCounter++; - - builder.startStatement(); - builder.string("int backref_" + id + " = bci"); - builder.end(); - - builder.startStatement(); - builder.string("bci += " + BC_CONSTS_TARGET_LENGTH); - builder.end(); - - return id; - } - - private void fillReservedDestination(int target) { - fillLabel("backref_" + target, "bci"); - } - - private void fillSavedLabel(int label) { - fillLabel("bci", "label_" + label); - builder.startStatement(); - builder.string("bci += " + BC_CONSTS_TARGET_LENGTH); - builder.end(); - } - - private void fillLabel(String dest, String label) { - builder.startStatement(); - builder.startCall(leBytes, "putShort"); - builder.string("bc"); - builder.string(dest); - builder.string("(short) " + label); - builder.end(2); - } - - private void putByte(String value) { - builder.startStatement(); - builder.string("bc[bci++] = " + value); - builder.end(); - } - - private void putBytesHelper(String method, String value, int length) { - builder.startStatement(); - builder.startCall(leBytes, method); - builder.string("bc"); - builder.string("bci"); - builder.string(value); - builder.end(2); - - builder.startStatement(); - builder.string("bci += " + length); - builder.end(); - } - - private void putShort(String value) { - putBytesHelper("putShort", value, 2); - } - - private void putInt(String value) { - putBytesHelper("putInt", value, 4); - } - - private void putLong(String value) { - putBytesHelper("putLong", value, 8); - } - } - - abstract class ReaderCommon { - protected final CodeTreeBuilder builder; - - protected boolean doNotBreak = false; - - protected ReaderCommon(CodeTreeBuilder builder) { - this.builder = builder; - } - - void buildCommonOperations() { - startOperation(commonOpcodeConstants[COMMON_OP_PRIM_JUMP_FALSE].getName()); - buildJumpFalseOperation(); - endOperation(); - - startOperation(commonOpcodeConstants[COMMON_OP_PRIM_JUMP_UNCOND].getName()); - buildJumpUncondOperation(); - endOperation(); - - startOperation(commonOpcodeConstants[COMMON_OP_PRIM_POP].getName()); - buildPopOperation(); - endOperation(); - } - - void buildOperation(Operation op) { - if (op.type.numOpcodes == 0) - return; - - doNotBreak = false; - startOperation(op.getOpcodeConstant()[0].getName()); - switch (op.type) { - case CUSTOM: - buildCustomOperation(op); - break; - case PRIM_LOAD_LOCAL: - buildLoadLocal(op); - break; - case PRIM_STORE_LOCAL: - buildStoreLocal(op); - break; - case PRIM_CONST_OBJECT: - buildConstObject(op); - break; - case PRIM_LOAD_ARGUMENT: - buildLoadArgument(op); - break; - case PRIM_RETURN: - buildReturn(op); - break; - } - endOperation(); - } - - private void getBytesHelper(String var, String method, String offset) { - builder.startStatement(); - builder.string(var + " = "); - builder.startCall(leBytes, method); - builder.string("bc"); - builder.string("bci + " + offset); - builder.end(2); - } - - protected void getByte(String var, String offset) { - builder.statement("byte " + var + " = bc[bci + " + offset + "]"); - } - - protected void getShort(String var, String offset) { - getBytesHelper(var, "getShort", offset); - } - - protected void getInt(String var, String offset) { - getBytesHelper(var, "getInt", offset); - } - - protected abstract void buildJumpFalseOperation(); - - protected abstract void buildJumpUncondOperation(); - - protected abstract void buildPopOperation(); - - protected abstract void buildCustomOperation(Operation op); - - protected abstract void buildConstObject(Operation op); - - protected abstract void buildLoadLocal(Operation op); - - protected abstract void buildStoreLocal(Operation op); - - protected abstract void buildLoadArgument(Operation op); - - protected abstract void buildReturn(Operation op); - - private void startOperation(String name) { - builder.startCase().string(name).end(); - builder.startBlock(); - } - - private void endOperation() { - if (!doNotBreak) { - builder.statement("break"); - } - builder.end(); - } - } - - class Executor extends ReaderCommon { - - Executor(CodeTreeBuilder builder) { - super(builder); - } - - @Override - protected void buildJumpFalseOperation() { - popValue("boolean", "condition"); - - builder.startIf().string("condition").end(); - - builder.startBlock(); - gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); - builder.end(); - - builder.startElseBlock(); - gotoDestination(1); - builder.end(); - - } - - @Override - protected void buildJumpUncondOperation() { - gotoDestination(1); - } - - @Override - protected void buildPopOperation() { - builder.statement("stack[--sp] = null"); - gotoRelative(1); - } - - @Override - protected void buildCustomOperation(Operation op) { - // read all child values - - for (int i = op.children - 1; i >= 0; i--) { - popValue("Object", "value" + i); - } - - // TODO: read all arguments - - builder.startStatement(); - if (op.returnsValue) { - builder.string("Object result = "); - } - builder.startStaticCall(op.mainMethod); - - for (int i = 0; i < op.children; i++) { - builder.string("value" + i); - } - - builder.end(2); - - if (op.returnsValue) { - pushValue("result"); - } - - gotoRelative(1); - } - - @Override - protected void buildConstObject(Operation op) { - - getShort("int index", "1"); - pushValue("constPool[index]"); - - gotoRelative(1 + 2); - } - - @Override - protected void buildLoadLocal(Operation op) { - - getShort("int index", "1"); - pushValue("locals[index]"); - - gotoRelative(1 + 2); - } - - @Override - protected void buildStoreLocal(Operation op) { - - getShort("int index", "1"); - popValue("Object", "value"); - builder.statement("locals[index] = value"); - - gotoRelative(1 + 2); - } - - @Override - protected void buildLoadArgument(Operation op) { - getShort("int index", "1"); - pushValue("frame.getArguments()[index]"); - - gotoRelative(1 + 2); - } - - @Override - protected void buildReturn(Operation op) { - popValue("Object", "rv"); - builder.statement("returnValue = rv"); - builder.statement("break loop"); - doNotBreak = true; - } - - private void gotoDestination(int offset) { - gotoDestination("" + offset); - } - - private void gotoDestination(String offset) { - getShort("nextBci", offset); - } - - private void gotoRelative(int offset) { - builder.statement("nextBci = bci + " + offset); - } - - private void popValue(String type, String name) { - String cast = type.equals("Object") ? "" : "(" + type + ") "; - builder.declaration(type, name, cast + "stack[--sp]"); - } - - private void pushValue(String value) { - builder.statement("stack[sp++] = " + value); - } - - } - - class Dumper extends ReaderCommon { - - protected Dumper(CodeTreeBuilder builder) { - super(builder); - } - - @Override - protected void buildJumpFalseOperation() { - appendOpcode("brfalse"); - getShort("int dest", "1"); - appendHexa("dest"); - gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); - } - - @Override - protected void buildJumpUncondOperation() { - appendOpcode("br"); - getShort("int dest", "1"); - appendHexa("dest"); - gotoRelative(1 + BC_CONSTS_TARGET_LENGTH); - } - - @Override - protected void buildPopOperation() { - appendOpcode("pop"); - gotoRelative(1); - } - - @Override - protected void buildCustomOperation(Operation op) { - // TODO Auto-generated method stub - appendOpcode("op"); - append("\"" + op.getName() + "\""); - gotoRelative(1); - } - - @Override - protected void buildConstObject(Operation op) { - appendOpcode("ldconst"); - getShort("int index", "1"); - append("index"); - append("\"// (\" + constPool[index].getClass().getName() + \") \" + constPool[index]"); - gotoRelative(1 + 2); - } - - @Override - protected void buildLoadLocal(Operation op) { - appendOpcode("ldloc"); - getShort("int index", "1"); - appendHexa("index"); - gotoRelative(1 + 2); - } - - @Override - protected void buildStoreLocal(Operation op) { - appendOpcode("stloc"); - getShort("int index", "1"); - appendHexa("index"); - gotoRelative(1 + 2); - } - - @Override - protected void buildLoadArgument(Operation op) { - appendOpcode("ldarg"); - getShort("int index", "1"); - appendHexa("index"); - gotoRelative(1 + 2); - } - - @Override - protected void buildReturn(Operation op) { - appendOpcode("return"); - gotoRelative(1); - } - - private void appendOpcode(String op) { - String opPadded = String.format("%-8s", op); - append("\"" + opPadded + "\""); - } - - private void appendHexa(String code) { - append("String.format(\"%04x\", " + code + ")"); - } - - private void append(String code) { - builder.statement("sb.append(" + code + ")"); - builder.statement("sb.append(' ')"); - } - - private void gotoRelative(int offset) { - builder.statement("bci += " + offset); - } - - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 62aeda56e5cb..eb321903cc9b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -6,662 +6,660 @@ import java.util.Set; import java.util.Stack; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; +import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.AnnotationProcessor; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationType; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.operations.Instruction.ExecutorVariables; +import com.oracle.truffle.dsl.processor.operations.Operation.EmitterVariables; +import com.oracle.truffle.dsl.processor.parser.NodeParser; public class OperationsCodeGenerator extends CodeTypeElementFactory { - private class OperationsCodeGeneratorImpl { + private ProcessorContext context; + private AnnotationProcessor processor; + private OperationsData m; + + private final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); + private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); + private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); + private final Set MOD_PUBLIC_STATIC_FINAL = Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL); + private final Set MOD_PUBLIC_STATIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.ABSTRACT); + private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + + /** + * Creates the builder class itself. This class only contains abstract methods, the builder + * implementation class, and the createBuilder method. + * + * @return The created builder class + */ + CodeTypeElement createBuilder(String simpleName) { + CodeTypeElement typBuilder = GeneratorUtils.createClass(m, null, MOD_PUBLIC_ABSTRACT, simpleName, types.OperationsBuilder); + + CodeExecutableElement metCreateLabel = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLabel, "createLabel"); + typBuilder.add(metCreateLabel); + + // begin/end or emit methods + for (Operation op : m.getOperations()) { + TypeMirror[] args = op.getBuilderArgumentTypes(context, types); + CodeVariableElement[] params = new CodeVariableElement[args.length]; + + for (int i = 0; i < params.length; i++) { + params[i] = new CodeVariableElement(args[i], "arg" + i); + } + + if (op.hasChildren()) { + CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "begin" + op.getName(), params); + typBuilder.add(metBegin); - private ProcessorContext context; - private AnnotationProcessor processor; - private OperationsData m; + CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "end" + op.getName()); + typBuilder.add(metEnd); + } else { + CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "emit" + op.getName(), params); + typBuilder.add(metEmit); + } - private CodeTypeElement builderType; - private CodeTypeElement builderImplType; - private CodeTypeElement builderNodeType; - private CodeTypeElement builderLabelImplType; - private CodeTypeElement builderBytecodeNodeType; + if (op instanceof Operation.CustomOperation) { + Operation.CustomOperation customOp = (Operation.CustomOperation) op; + List genNode = createOperationNode(customOp.getCustomInstruction()); + typBuilder.addAll(genNode); + } + } - private CodeVariableElement argumentStackField; - private CodeVariableElement childStackField; - private CodeVariableElement typeStackField; + if (m.hasErrors()) + return typBuilder; - private CodeExecutableElement doBeginOperationMethod; - private CodeExecutableElement doEndOperationMethod; - private CodeExecutableElement doEmitOperationMethod; + CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); + typBuilder.add(typBuilderImpl); - private OperationsBytecodeCodeGenerator bytecodeBuilderGenerator; + { + CodeExecutableElement metCreateBuilder = new CodeExecutableElement(MOD_PUBLIC_STATIC, typBuilder.asType(), "createBuilder"); + CodeTreeBuilder b = metCreateBuilder.getBuilder(); + b.startReturn().startNew(typBuilderImpl.asType()).end(2); + typBuilder.add(metCreateBuilder); + } - OperationsCodeGeneratorImpl(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { - this.context = context; - this.processor = processor; - this.m = m; + return typBuilder; + } - this.bytecodeBuilderGenerator = new OperationsBytecodeCodeGenerator(types, context); + /** + * Create the implementation class. This class implements the begin/end methods, and in general + * does the most of the build-time heavy lifting. + */ + private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { + String simpleName = m.getTemplateType().getSimpleName() + "BuilderinoImpl"; + CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); + + DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); + CodeVariableElement leBytes = new CodeVariableElement( + MOD_PRIVATE_STATIC_FINAL, + byteArraySupportType, "LE_BYTES"); + leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); + typBuilderImpl.add(leBytes); + + CodeTypeElement builderNodeType = createBuilderImplNode(simpleName + "Node"); + typBuilderImpl.add(builderNodeType); + + CodeTypeElement builderLabelImplType = createBuilderLabelImpl(simpleName + "Label"); + typBuilderImpl.add(builderLabelImplType); + + CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(simpleName + "BytecodeNode"); + typBuilderImpl.add(builderBytecodeNodeType); + + CodeVariableElement childStackField = createStackField("child", generic(context.getTypeElement(ArrayList.class), builderNodeType.asType())); + typBuilderImpl.add(childStackField); + + CodeVariableElement argumentStackField = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); + typBuilderImpl.add(argumentStackField); + + CodeVariableElement typeStackField = createStackField("type", context.getType(Integer.class)); + typBuilderImpl.add(typeStackField); + + { + CodeExecutableElement metReset = new CodeExecutableElement( + Set.of(Modifier.PUBLIC), + context.getType(void.class), "reset"); + typBuilderImpl.add(metReset); + + CodeTreeBuilder b = metReset.getBuilder(); + b.startStatement().startCall(childStackField.getName(), "clear").end(2); + b.startStatement().startCall(childStackField.getName(), "add").string("new ArrayList<>()").end(2); + b.startStatement().startCall(argumentStackField.getName(), "clear").end(2); + b.startStatement().startCall(typeStackField.getName(), "clear").end(2); } - /** - * Creates the builder class itself. This class only contains abstract methods, the builder - * implementation class, and the createBuilder method. - * - * @return The created builder class - */ - CodeTypeElement createBuilder() { + { + CodeExecutableElement mBuild = new CodeExecutableElement(Set.of(Modifier.PUBLIC), types.OperationsNode, "build"); + typBuilderImpl.add(mBuild); - String simpleName = m.getTemplateType().getSimpleName() + "Builderino"; - builderType = GeneratorUtils.createClass(m, null, Set.of(Modifier.ABSTRACT, Modifier.PUBLIC), simpleName, types.OperationsBuilder); + CodeTreeBuilder b = mBuild.getBuilder(); - createLabelMethods(builderType, true); - for (OperationsData.Operation op : m.getOperations()) { - createBeginEnd(builderType, op, true); - } + b.startAssert(); + b.string("childStack.size() == 1"); + b.end(); - createBuilderImpl(); - createCreateBuilder(); + b.declaration(arrayOf(builderNodeType.asType()), "operations", "childStack.get(0).toArray(new " + builderNodeType.getSimpleName() + "[0])"); + b.declaration(builderNodeType.asType(), "rootNode", "new " + builderNodeType.getSimpleName() + "(0, new Object[0], operations)"); + b.declaration("byte[]", "bc", "new byte[65535]"); + b.declaration(types.OperationsConstantPool, "constPool", "new OperationsConstantPool()"); + b.declaration("int", "len", "rootNode.build(bc, 0, constPool)"); + b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, len)"); + b.declaration("Object[]", "cpCopy", "constPool.getValues()"); + + b.startReturn(); + b.startNew(builderBytecodeNodeType.asType()); + b.string("bcCopy"); + b.string("cpCopy"); + b.end(2); - return builderType; } - /** - * Create the implementation class. This class implements the begin/end methods, and in - * general does the most of the build-time heavy lifting. - */ - private void createBuilderImpl() { - String simpleName = m.getTemplateType().getSimpleName() + "BuilderinoImpl"; - builderImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, builderType.asType()); + { + CodeExecutableElement ctor = new CodeExecutableElement(null, simpleName); - { - DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); - CodeVariableElement leBytes = new CodeVariableElement( - Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), - byteArraySupportType, "LE_BYTES"); - CodeTreeBuilder builder = leBytes.createInitBuilder(); - builder.startStaticCall(byteArraySupportType, "littleEndian").end(); - builderImplType.add(leBytes); - } + CodeTreeBuilder builder = ctor.getBuilder(); + builder.startStatement().string("reset()").end(); - createBuilderNodeTypeConstants(); - createBuilderNodeOpcodeConstants(); + typBuilderImpl.add(ctor); + } - createBuilderImplNode(); + { + CodeExecutableElement metDoBeginOperation = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doBeginOperation"); + metDoBeginOperation.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + metDoBeginOperation.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); - createBuilderLabelImpl(); - createBuilderBytecodeNode(); + CodeTreeBuilder builder = metDoBeginOperation.getBuilder(); - childStackField = createStackField("child", generic(context.getTypeElement(ArrayList.class), builderNodeType.asType())); - argumentStackField = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); - typeStackField = createStackField("type", context.getType(Integer.class)); + builder.statement("typeStack.add(type)"); + builder.statement("childStack.add(new ArrayList<>())"); + builder.statement("argumentStack.add(arguments)"); - { - CodeExecutableElement mReset = new CodeExecutableElement( - Set.of(Modifier.PUBLIC), - context.getType(void.class), "reset"); + typBuilderImpl.add(metDoBeginOperation); + } - CodeTreeBuilder builder = mReset.getBuilder(); - builder.startStatement().string("childStack.clear()").end(); - builder.startStatement().string("childStack.add(new ArrayList<>())").end(); - builder.startStatement().string("argumentStack.clear()").end(); - builder.startStatement().string("typeStack.clear()").end(); + { + CodeExecutableElement doEndOperationMethod = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEndOperation"); + doEndOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - builderImplType.add(mReset); - } + CodeTreeBuilder builder = doEndOperationMethod.getBuilder(); - createBuildMethod(); + builder.statement("int topType = typeStack.pop()"); - { - CodeExecutableElement ctor = new CodeExecutableElement(null, simpleName); + builder.startAssert(); + builder.string("topType == type"); + builder.end(); - CodeTreeBuilder builder = ctor.getBuilder(); - builder.startStatement().string("reset()").end(); + builder.statement("Object[] args = argumentStack.pop()"); - builderImplType.add(ctor); - } + builder.declaration(new ArrayCodeTypeMirror(builderNodeType.asType()), "children", + "childStack.pop().toArray(new " + builderNodeType.getSimpleName() + "[0])"); - createHelperEmitMethods(); + builder.declaration(builderNodeType.asType(), "result", + "new " + builderNodeType.getSimpleName() + "(type, args, children)"); - createLabelMethods(builderImplType, false); + builder.statement("childStack.peek().add(result)"); - for (OperationsData.Operation op : m.getOperations()) { - createBeginEnd(builderImplType, op, false); - } + typBuilderImpl.add(doEndOperationMethod); - builderType.add(builderImplType); } - private void createBuildMethod() { - CodeExecutableElement mBuild = new CodeExecutableElement(Set.of(Modifier.PUBLIC), types.OperationsNode, "build"); - - CodeTreeBuilder builder = mBuild.getBuilder(); + { + CodeExecutableElement doEmitOperationMethod = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEmitOperation"); + doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); - builder.startAssert(); - builder.string("childStack.size() == 1"); - builder.end(); + CodeTreeBuilder builder = doEmitOperationMethod.getBuilder(); - builder.declaration(arrayOf(builderNodeType.asType()), "operations", "childStack.get(0).toArray(new " + builderNodeType.getSimpleName() + "[0])"); - builder.declaration(builderNodeType.asType(), "rootNode", "new " + builderNodeType.getSimpleName() + "(TYPE_PRIM_BLOCK, new Object[0], operations)"); - builder.declaration("byte[]", "bc", "new byte[65535]"); - builder.declaration("ArrayList", "constPool", "new ArrayList<>()"); - builder.declaration("int", "len", "rootNode.build(bc, 0, constPool)"); - builder.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, len)"); - builder.declaration("Object[]", "cpCopy", "constPool.toArray(new Object[0])"); - - builder.startReturn(); - builder.startNew(builderBytecodeNodeType.asType()); - builder.string("bcCopy"); - builder.string("cpCopy"); - builder.end(2); + builder.declaration(builderNodeType.asType(), "result", + "new " + builderNodeType.getSimpleName() + "(type, arguments, new " + builderNodeType.getSimpleName() + "[0])"); - builderImplType.add(mBuild); + builder.startStatement(); + builder.string("childStack.peek().add(result)"); + builder.end(); + typBuilderImpl.add(doEmitOperationMethod); } - private void createBuilderLabelImpl() { - String simpleName = builderImplType.getSimpleName() + "Label"; - builderLabelImplType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); - builderImplType.add(builderLabelImplType); - } + { + CodeExecutableElement mCreateLabel = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); - private void createLabelMethods(CodeTypeElement target, boolean isAbstract) { - Set modifiers = isAbstract ? Set.of(Modifier.PUBLIC, Modifier.ABSTRACT) : Set.of(Modifier.PUBLIC); + CodeTreeBuilder b = mCreateLabel.getBuilder(); + b.startReturn(); + b.startNew(builderLabelImplType.asType()); + b.end(2); - CodeExecutableElement mCreateLabel = new CodeExecutableElement(modifiers, types.OperationLabel, "createLabel"); - CodeExecutableElement mMarkLabel = new CodeExecutableElement(modifiers, context.getType(void.class), "markLabel", new CodeVariableElement(types.OperationLabel, "label")); + typBuilderImpl.add(mCreateLabel); + } - target.add(mCreateLabel); - target.add(mMarkLabel); + for (Operation op : m.getOperations()) { + TypeMirror[] args = op.getBuilderArgumentTypes(context, types); + CodeVariableElement[] params = new CodeVariableElement[args.length]; - if (isAbstract) - return; - { - CodeTreeBuilder builder = mCreateLabel.getBuilder(); - builder.startReturn(); - builder.startNew(builderLabelImplType.asType()); - builder.end(2); + for (int i = 0; i < params.length; i++) { + params[i] = new CodeVariableElement(args[i], "arg" + i); } - { - CodeTreeBuilder builder = mMarkLabel.getBuilder(); - builder.declaration(builderLabelImplType.asType(), "lbl", "(" + builderLabelImplType.getSimpleName() + ") label"); - builder.startStatement().startCall("lbl", "setMarked").end(2); - builder.startStatement().startCall("doEmitOperation").string("TYPE_PRIM_LABEL").string("lbl").end(2); + if (op.hasChildren()) { + { + CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.getName()); + CodeTreeBuilder b = metBegin.getBuilder(); + b.startStatement().startCall("doBeginOperation"); + b.string("" + op.getType()); + for (int i = 0; i < params.length; i++) { + b.string("arg" + i); + } + b.end(2); + typBuilderImpl.add(metBegin); + } + + { + CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.getName()); + CodeTreeBuilder b = metEnd.getBuilder(); + b.startStatement().startCall("doEndOperation"); + b.string("" + op.getType()); + b.end(2); + typBuilderImpl.add(metEnd); + } + } else { + CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.getName()); + { + CodeTreeBuilder b = metEmit.getBuilder(); + b.startStatement().startCall("doEmitOperation"); + b.string("" + op.getType()); + for (int i = 0; i < params.length; i++) { + b.string("arg" + i); + } + b.end(2); + } + typBuilderImpl.add(metEmit); } } - /** - * Create the BuilderNode class. - * - * This class represents the built method internally. Right now it only supports generating - * the bytecode, but in the future it will support analysis and finding super-instructions. - */ - private void createBuilderImplNode() { - String simpleName = builderImplType.getSimpleName() + "Node"; - builderNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, null); - - createBuilderNodeFields(); - - { - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType); + return typBuilderImpl; + } - CodeTreeBuilder builder = ctor.getBuilder(); + private CodeTypeElement createBuilderLabelImpl(String simpleName) { + return GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); + } - OperationsBytecodeCodeGenerator.ReturnsValueChecker gen = bytecodeBuilderGenerator.new ReturnsValueChecker(builder); + /** + * Create the BuilderNode class. + * + * This class represents the built method internally. Right now it only supports generating the + * bytecode, but in the future it will support analysis and finding super-instructions. + */ + private CodeTypeElement createBuilderImplNode(String simpleName) { + CodeTypeElement builderNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, null); - builder.startSwitch().string("type").end(); - builder.startBlock(); + CodeVariableElement fldType = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(int.class), "type"); + builderNodeType.add(fldType); - for (OperationsData.Operation op : m.getOperations()) { - builder.startCase().string(op.getTypeConstant().getName()).end(); - builder.startBlock(); + CodeVariableElement fldArguments = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "arguments"); + builderNodeType.add(fldArguments); - gen.buildOperation(op); + CodeVariableElement fldChildren = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(builderNodeType.asType()), "children"); + builderNodeType.add(fldChildren); - builder.statement("break"); - builder.end(); - } + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType); + builderNodeType.add(ctor); - builder.caseDefault(); - builder.startCaseBlock(); - builder.tree(GeneratorUtils.createShouldNotReachHere("")); - builder.end(2); + CodeVariableElement fldReturnsValue = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue"); + // builderNodeType.add(fldReturnsValue); - builder.end(); + { + CodeVariableElement argBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); + CodeVariableElement argConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); + CodeExecutableElement metBuild = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", argBc, argStartBci, argConstPool); - builderNodeType.add(ctor); + { + DeclaredType typSw = context.getDeclaredType(SuppressWarnings.class); + CodeAnnotationMirror annSw = new CodeAnnotationMirror(typSw); + annSw.setElementValue(annSw.findExecutableElement("value"), new CodeAnnotationValue("cast")); + metBuild.addAnnotationMirror(annSw); } - builderNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue")); - - createBuilderNodeBuildMethod(); - - builderImplType.add(builderNodeType); - } - - private void createBuilderNodeFields() { - Set modifiers = Set.of(Modifier.PRIVATE, Modifier.FINAL); - builderNodeType.add(new CodeVariableElement(modifiers, context.getType(int.class), "type")); - builderNodeType.add(new CodeVariableElement(modifiers, new ArrayCodeTypeMirror(context.getType(Object.class)), "arguments")); - builderNodeType.add(new CodeVariableElement(modifiers, new ArrayCodeTypeMirror(builderNodeType.asType()), "children")); - } - - private void createBuilderNodeBuildMethod() { - CodeVariableElement bc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); - CodeVariableElement startBci = new CodeVariableElement(context.getType(int.class), "startBci"); - CodeVariableElement constPool = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), context.getType(Object.class)), "constPool"); - CodeExecutableElement method = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", bc, startBci, constPool); - CodeTreeBuilder builder = method.getBuilder(); + CodeTreeBuilder b = metBuild.getBuilder(); - builder.declaration("int", "bci", "startBci"); + CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); + b.declaration("int", varBci.getName(), argStartBci.getName()); - OperationsBytecodeCodeGenerator.Builder gen = bytecodeBuilderGenerator.new Builder(builder); + b.startSwitch().field("this", fldType).end().startBlock(); - builder.startSwitch(); - builder.string("this.type"); - builder.end(); - builder.startBlock(); + for (Operation op : m.getOperations()) { + b.startCase().string("" + op.getType() + " /* " + op.getName() + " */").end(); - for (OperationsData.Operation op : m.getOperations()) { - builder.startCase(); - builder.string(op.getTypeConstant().getName()); - builder.end(); + b.startBlock(); - builder.startBlock(); + EmitterVariables vars = new EmitterVariables(metBuild, argBc, varBci, argConstPool, fldChildren, fldArguments); - gen.buildOperation(op); + b.tree(op.createEmitterCode(types, vars)); - builder.startStatement().string("break").end(); - builder.end(); + b.startStatement().string("break").end(); + b.end(); } - builder.end(); + b.end(); // switchBlock - builder.startReturn().string("bci").end(); + b.startReturn().string("bci").end(); - builderNodeType.add(method); + builderNodeType.add(metBuild); } - /** - * Create the node type constants. - */ - private void createBuilderNodeTypeConstants() { - int i = 0; - for (OperationsData.Operation op : m.getOperations()) { - CodeVariableElement el = new CodeVariableElement( - Set.of(Modifier.STATIC, Modifier.PRIVATE, Modifier.FINAL), - context.getType(int.class), "TYPE_" + op.getScreamCaseName()); - CodeTreeBuilder ctb = el.createInitBuilder(); - ctb.string("" + i); - i++; - - op.setTypeConstant(el); - builderImplType.add(el); - } - } + return builderNodeType; + } - private void createBuilderNodeOpcodeConstants() { - int i = 0; + /** + * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the + * executable Truffle node. + */ + private CodeTypeElement createBuilderBytecodeNode(String simpleName) { + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationsNode); - { - int numCommon = OperationsBytecodeCodeGenerator.commonOpcodeNames.length; - CodeVariableElement[] commonOpcodes = new CodeVariableElement[numCommon]; - for (int j = 0; j < numCommon; j++) { - commonOpcodes[j] = createBuilderNodeOpcodeConstant(i++, OperationsBytecodeCodeGenerator.commonOpcodeNames[j]); - } - bytecodeBuilderGenerator.commonOpcodeConstants = commonOpcodes; - } - - for (OperationsData.Operation op : m.getOperations()) { - if (op.type.numOpcodes == 0) - continue; + CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); + builderBytecodeNodeType.add(fldBc); - CodeVariableElement[] opcodes = new CodeVariableElement[op.type.numOpcodes]; - for (int j = 0; j < op.type.numOpcodes; j++) { - opcodes[j] = createBuilderNodeOpcodeConstant(i++, op.getScreamCaseName() + "_" + j); - } + CodeVariableElement fldConsts = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(Object.class)), "consts"); + builderBytecodeNodeType.add(fldConsts); - op.setOpcodeConstant(opcodes); - } - } + builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); - private CodeVariableElement createBuilderNodeOpcodeConstant(int i, String name) { - CodeVariableElement el = new CodeVariableElement( - Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), - context.getType(byte.class), - "OPC_" + name, - "" + i); - builderImplType.add(el); - return el; - } + { + CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); - /** - * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the - * executable Truffle node. - */ - private void createBuilderBytecodeNode() { - String simpleName = builderType.getSimpleName() + "BytecodeNode"; - builderBytecodeNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationsNode); + CodeTreeBuilder builder = mExecute.getBuilder(); + builder.startReturn(); + builder.startCall("continueAt"); - builderBytecodeNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(byte.class)), "bc")); - builderBytecodeNodeType.add(new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(Object.class)), "constPool")); - builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); + builder.string("frame"); + builder.string("null"); - createBuilderBytecodeNodeExecute(); + builder.end(2); - builderImplType.add(builderBytecodeNodeType); + builderBytecodeNodeType.add(mExecute); } - private void createBuilderBytecodeNodeExecute() { - { - CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); - - CodeTreeBuilder builder = mExecute.getBuilder(); - builder.startReturn(); - builder.startCall("continueAt"); + { + CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); + CodeVariableElement argStartIndex = new CodeVariableElement(types.OperationLabel, "startIndex"); + CodeExecutableElement mContinueAt = new CodeExecutableElement( + Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", + argFrame, argStartIndex); - builder.string("frame"); - builder.string("null"); + CodeTreeBuilder b = mContinueAt.getBuilder(); - builder.end(2); - - builderBytecodeNodeType.add(mExecute); - } + CodeVariableElement varStack = new CodeVariableElement(arrayOf(context.getType(Object.class)), "stack"); + CodeVariableElement varLocals = new CodeVariableElement(arrayOf(context.getType(Object.class)), "locals"); + CodeVariableElement varFunArgs = new CodeVariableElement(arrayOf(context.getType(Object.class)), "funArgs"); + CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); + CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - { - CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", - new CodeVariableElement(types.VirtualFrame, "frame"), - new CodeVariableElement(types.OperationLabel, "startIndex")); + b.declaration("final Object[]", varStack.getName(), "new Object[1024]"); + b.declaration("final Object[]", varLocals.getName(), "new Object[1024]"); + b.declaration("final Object[]", varFunArgs.getName(), "frame.getArguments()"); + b.declaration("int", varSp.getName(), "0"); + b.declaration("int", varBci.getName(), "0"); - CodeTreeBuilder builder = mContinueAt.getBuilder(); + CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); + b.statement("Object " + varReturnValue.getName()); - OperationsBytecodeCodeGenerator.Executor gen = bytecodeBuilderGenerator.new Executor(builder); + b.string("loop: "); + b.startWhile().string("true").end(); + b.startBlock(); + CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); + b.statement("int nextBci"); - builder.declaration("final Object[]", "stack", "new Object[1024]"); - builder.declaration("final Object[]", "locals", "new Object[1024]"); - builder.declaration("int", "sp", "0"); - builder.declaration("int", "bci", "0"); + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); - builder.statement("Object returnValue"); + ExecutorVariables vars = new ExecutorVariables(varBci, varNextBci, fldBc, fldConsts, varStack, varSp, varLocals, varFunArgs, varReturnValue); - builder.string("loop: "); - builder.startWhile().string("true").end(); - builder.startBlock(); + for (Instruction op : m.getInstructions()) { - builder.statement("int nextBci"); + b.startCase().string("" + op.opcodeNumber + " /* " + op.getClass().getSimpleName() + " */").end(); - builder.startSwitch().string("bc[bci]").end(); - builder.startBlock(); + b.startBlock(); - gen.buildCommonOperations(); + CodeVariableElement[] pops = new CodeVariableElement[op.stackPops]; + for (int i = op.stackPops - 1; i >= 0; i--) { + pops[i] = new CodeVariableElement(context.getType(Object.class), "value" + i); + b.declaration("Object", pops[i].getName(), varStack.getName() + "[--" + varSp.getName() + "]"); + } - for (OperationsData.Operation op : m.getOperations()) { - gen.buildOperation(op); + CodeVariableElement[] args = new CodeVariableElement[op.arguments.length]; + int ofs = 1; + for (int i = 0; i < op.arguments.length; i++) { + args[i] = new CodeVariableElement(op.arguments[i].toExecType(context, types), "arg" + i); + b.declaration(args[i].asType(), args[i].getName(), + op.arguments[i].createReaderCode(vars, CodeTreeBuilder.singleString(varBci.getName() + " + " + ofs))); + ofs += op.arguments[i].length; } - builder.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); + vars.arguments = args; + vars.children = pops; + if (op.stackPushes > 0) { + vars.result = new CodeVariableElement(context.getType(Object.class), "result"); + b.statement("Object " + vars.result.getName()); + } - builder.end(); // switch block + b.tree(op.createExecutorCode(types, vars)); - builder.statement("bci = nextBci"); - builder.end(); // while block + if (op.stackPushes > 0) { + b.statement(varStack.getName() + "[" + varSp.getName() + "++] = " + vars.result.getName()); + } - builder.startReturn().string("returnValue").end(); + if (!op.isDivergent()) { + b.tree(op.createNextBciCode(types, vars)); + b.statement("break"); + } - builderBytecodeNodeType.add(mContinueAt); + b.end(); } - { - CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); - - CodeTreeBuilder builder = mDump.getBuilder(); - - OperationsBytecodeCodeGenerator.Dumper gen = bytecodeBuilderGenerator.new Dumper(builder); + b.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); - builder.declaration("int", "bci", "0"); - builder.declaration("StringBuilder", "sb", "new StringBuilder()"); + b.end(); // switch block - builder.startWhile().string("bci < bc.length").end(); - builder.startBlock(); // while block + b.statement("bci = nextBci"); + b.end(); // while block - builder.statement("sb.append(String.format(\" %04x \", bci))"); + b.startReturn().string("returnValue").end(); - builder.startSwitch().string("bc[bci]").end(); - builder.startBlock(); + builderBytecodeNodeType.add(mContinueAt); + } - gen.buildCommonOperations(); + { + CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); - for (OperationsData.Operation op : m.getOperations()) { - gen.buildOperation(op); - } + CodeTreeBuilder b = mDump.getBuilder(); + CodeVariableElement varSb = new CodeVariableElement(context.getType(StringBuilder.class), "sb"); - builder.caseDefault().startCaseBlock(); - builder.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); - builder.statement("break"); - builder.end(); // default case block - builder.end(); // switch block + b.declaration("int", "bci", "0"); + b.declaration("StringBuilder", "sb", "new StringBuilder()"); - builder.statement("sb.append(\"\\n\")"); + b.startWhile().string("bci < bc.length").end(); + b.startBlock(); // while block - builder.end(); // while block + b.statement("sb.append(String.format(\" %04x \", bci))"); - builder.startReturn().string("sb.toString()").end(); + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); - builderBytecodeNodeType.add(mDump); - } - } + for (Instruction op : m.getInstructions()) { + b.startCase().string("" + op.opcodeNumber).end(); + b.startBlock(); - /** - * Creates the doBeginOperation, doEndOperation and doEmitOperation helper methods. They - * look as follows: - * - *
-         * private void doBeginOperation(int type, Object... arguments) {
-         *     typeStack.add(type);
-         *     childStack.add(new ArrayList<>());
-         *     argumentStack.add(arguments);
-         * }
-         *
-         * private void doEndOperation(int type) {
-         *     int topType = typeStack.pop();
-         *     assert topType == type;
-         *     Object[] args = argumentStack.pop();
-         *     SlOperationsBuilderinoImplNode[] children = childStack.pop().toArray(new SlOperationsBuilderinoImplNode[0]);
-         *     SlOperationsBuilderinoImplNode result = new SlOperationsBuilderinoImplNode(type, args, children);
-         *     childStack.peek().add(result);
-         * }
-         *
-         * private void doEmitOperation(int type, Object... arguments) {
-         *     SlOperationsBuilderinoImplNode result = new SlOperationsBuilderinoImplNode(type, arguments, new SlOperationsBuilderinoImplNode[0]);
-         *     childStack.peek().add(result);
-         * }
-         * 
- */ - private void createHelperEmitMethods() { - Set modPrivate = Set.of(Modifier.PRIVATE); + b.statement("sb.append(\"" + op.getClass().getSimpleName() + " \")"); - { - doBeginOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doBeginOperation"); - doBeginOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - doBeginOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); + CodeVariableElement[] args = new CodeVariableElement[op.arguments.length]; + int ofs = 1; + for (int i = 0; i < op.arguments.length; i++) { + args[i] = new CodeVariableElement(op.arguments[i].toExecType(context, types), "arg" + i); + b.tree(op.arguments[i].createDumperCode(fldBc, CodeTreeBuilder.singleString("bci + " + ofs), varSb)); + ofs += op.arguments[i].length; + } - CodeTreeBuilder builder = doBeginOperationMethod.getBuilder(); + b.statement("bci += " + op.length()); - builder.statement("typeStack.add(type)"); - builder.statement("childStack.add(new ArrayList<>())"); - builder.statement("argumentStack.add(arguments)"); + b.statement("break"); - builderImplType.add(doBeginOperationMethod); + b.end(); } - { - doEndOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doEndOperation"); - doEndOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - - CodeTreeBuilder builder = doEndOperationMethod.getBuilder(); + b.caseDefault().startCaseBlock(); + b.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); + b.statement("break"); + b.end(); // default case block + b.end(); // switch block - builder.statement("int topType = typeStack.pop()"); + b.statement("sb.append(\"\\n\")"); - builder.startAssert(); - builder.string("topType == type"); - builder.end(); + b.end(); // while block - builder.statement("Object[] args = argumentStack.pop()"); + b.startReturn().string("sb.toString()").end(); - builder.declaration(new ArrayCodeTypeMirror(builderNodeType.asType()), "children", - "childStack.pop().toArray(new " + builderNodeType.getSimpleName() + "[0])"); - - builder.declaration(builderNodeType.asType(), "result", - "new " + builderNodeType.getSimpleName() + "(type, args, children)"); - - builder.statement("childStack.peek().add(result)"); + builderBytecodeNodeType.add(mDump); + } - builderImplType.add(doEndOperationMethod); + return builderBytecodeNodeType; + } - } + /** + * Creates a stack field. + * + * @param name the name of the stack field. It will get {@code "Stack"} appended to it. + * @param argType the type of the stack elements + * @return the created stack field + */ + private CodeVariableElement createStackField(String name, TypeMirror argType) { + TypeMirror stackType = generic(context.getTypeElement(Stack.class), argType); + CodeVariableElement element = new CodeVariableElement( + Set.of(Modifier.PRIVATE, Modifier.FINAL), + stackType, + name + "Stack"); + CodeTreeBuilder ctb = element.createInitBuilder(); + ctb.string("new Stack<>()"); + + return element; + } - { - doEmitOperationMethod = new CodeExecutableElement(modPrivate, context.getType(void.class), "doEmitOperation"); - doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); + private List createOperationNode(Instruction.Custom instr) { + TypeElement t = instr.getType(); - CodeTreeBuilder builder = doEmitOperationMethod.getBuilder(); + PackageElement pack = ElementUtils.findPackageElement(t); + CodeTypeElement typProxy = new CodeTypeElement(MOD_PUBLIC_STATIC_ABSTRACT, ElementKind.CLASS, pack, + t.getSimpleName() + "Gen"); - builder.declaration(builderNodeType.asType(), "result", - "new " + builderNodeType.getSimpleName() + "(type, arguments, new " + builderNodeType.getSimpleName() + "[0])"); + typProxy.setSuperClass(types.Node); + typProxy.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); + GeneratorUtils.addGeneratedBy(context, typProxy, t); - builder.startStatement(); - builder.string("childStack.peek().add(result)"); - builder.end(); + { + CodeExecutableElement metExecute = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, + context.getType(Object.class), "execute"); + typProxy.add(metExecute); - builderImplType.add(doEmitOperationMethod); + for (int i = 0; i < instr.stackPops; i++) { + metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); } } - /** - * Create the begin/end methods, or the emit method if the operation takes no children. - * - * @param target - * @param operation - * @param isAbstract - */ - private void createBeginEnd(CodeTypeElement target, OperationsData.Operation operation, boolean isAbstract) { - - if (operation.type == OperationType.PRIM_LABEL) - return; - - Set mods = isAbstract ? Set.of(Modifier.PUBLIC, Modifier.ABSTRACT) : Set.of(Modifier.PUBLIC); - - if (operation.children == 0) { - CodeExecutableElement mEmit = new CodeExecutableElement(mods, context.getType(void.class), "emit" + operation.getName()); + for (ExecutableElement el : ElementFilter.methodsIn(instr.getType().getEnclosedElements())) { + if (el.getModifiers().containsAll(MOD_PUBLIC_STATIC)) { + CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), + el.getSimpleName().toString()); + for (VariableElement par : el.getParameters()) { + metProxy.addParameter(par); + } + for (AnnotationMirror ann : el.getAnnotationMirrors()) { + metProxy.addAnnotationMirror(ann); + } - createBeginParameters(operation, mEmit); + CodeTreeBuilder b = metProxy.getBuilder(); - target.add(mEmit); + if (metProxy.getReturnType().getKind() != TypeKind.VOID) { + b.startReturn(); + } - if (isAbstract) - return; + b.startStaticCall(el); + for (VariableElement par : el.getParameters()) { + b.variable(par); + } + b.end(); - CodeTreeBuilder builder = mEmit.getBuilder(); - builder.startStatement(); - builder.startCall(null, doEmitOperationMethod); - builder.field(null, operation.getTypeConstant()); - for (int i = 0; i < operation.getArguments(types, context).size(); i++) { - builder.string("arg" + i); + if (metProxy.getReturnType().getKind() != TypeKind.VOID) { + b.end(); } - builder.end(2); - } else { - CodeExecutableElement mBegin = new CodeExecutableElement(mods, context.getType(void.class), "begin" + operation.getName()); - CodeExecutableElement mEnd = new CodeExecutableElement(mods, context.getType(void.class), "end" + operation.getName()); - createBeginParameters(operation, mBegin); + typProxy.add(metProxy); + } + } - target.add(mBegin); - target.add(mEnd); + List result = new ArrayList<>(2); + result.add(typProxy); - if (isAbstract) - return; + NodeParser parser = NodeParser.createDefaultParser(); + NodeData data = parser.parse(typProxy); + if (data == null) { + m.addError(t, "Could not generate node data"); + return List.of(); + } + NodeCodeGenerator gen = new NodeCodeGenerator(); + CodeTypeElement genResult = gen.create(context, processor, data).get(0); - { - CodeTreeBuilder builder = mBegin.getBuilder(); - builder.startStatement(); - builder.startCall(null, doBeginOperationMethod); - builder.field(null, operation.getTypeConstant()); - for (int i = 0; i < operation.getArguments(types, context).size(); i++) { - builder.string("arg" + i); - } - builder.end(2); - } + CodeTypeElement genUncached = null; - { - CodeTreeBuilder builder = mEnd.getBuilder(); - builder.startStatement(); - builder.startCall(null, doEndOperationMethod); - builder.field(null, operation.getTypeConstant()); - builder.end(2); - } + for (TypeElement el : ElementFilter.typesIn(genResult.getEnclosedElements())) { + if (el.getSimpleName().toString().equals("Uncached")) { + genUncached = (CodeTypeElement) el; + break; } } - /** - * Create the parameters of a begin or emit method, from given operation description. - * - * @param operation - * @param method - */ - private void createBeginParameters(OperationsData.Operation operation, CodeExecutableElement method) { - int i = 0; - for (TypeMirror argType : operation.getArguments(types, context)) { - method.addParameter(new CodeVariableElement(argType, "arg" + i)); - i++; - } - } + assert genUncached != null; - private void createCreateBuilder() { - CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.STATIC), builderType.asType(), "createBuilder"); - CodeTreeBuilder builder = method.getBuilder(); + genUncached.setSimpleName(CodeNames.of(t.getSimpleName() + "Uncached")); + GeneratorUtils.addGeneratedBy(context, genUncached, t); - builder.startReturn(); - builder.startNew(builderImplType.asType()); - builder.end(); - builder.end(); + { + CodeVariableElement fldInstance = new CodeVariableElement(MOD_PUBLIC_STATIC_FINAL, genUncached.asType(), "INSTANCE"); + CodeTreeBuilder b = fldInstance.createInitBuilder(); + b.startNew(genUncached.asType()); + b.end(); + genUncached.add(fldInstance); - builderType.add(method); + instr.setUncachedInstance(fldInstance); } - /** - * Creates a stack field. - * - * @param name the name of the stack field. It will get {@code "Stack"} appended to it. - * @param argType the type of the stack elements - * @return the created stack field - */ - private CodeVariableElement createStackField(String name, TypeMirror argType) { - TypeMirror stackType = generic(context.getTypeElement(Stack.class), argType); - CodeVariableElement element = new CodeVariableElement( - Set.of(Modifier.PRIVATE, Modifier.FINAL), - stackType, - name + "Stack"); - CodeTreeBuilder ctb = element.createInitBuilder(); - ctb.string("new Stack<>()"); - - builderImplType.add(element); - return element; - } + result.add(genUncached); + return result; } private static TypeMirror generic(TypeElement el, TypeMirror... params) { @@ -674,8 +672,25 @@ private static TypeMirror arrayOf(TypeMirror el) { @Override public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { - OperationsCodeGeneratorImpl impl = new OperationsCodeGeneratorImpl(context, processor, m); - return List.of(impl.createBuilder()); + this.context = context; + this.processor = processor; + this.m = m; + + String simpleName = m.getTemplateType().getSimpleName() + "Builderino"; + + try { + return List.of(createBuilder(simpleName)); + } catch (Exception e) { + CodeTypeElement el = GeneratorUtils.createClass(m, null, MOD_PUBLIC_ABSTRACT, simpleName, null); + CodeTreeBuilder b = el.createDocBuilder(); + + b.lineComment(e.getClass().getName() + ": " + e.getMessage()); + for (StackTraceElement ste : e.getStackTrace()) { + b.lineComment(" at " + ste.toString()); + } + + return List.of(el); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index c391f7dadf00..bba56fcbb6dd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -2,135 +2,48 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.Template; public class OperationsData extends Template { + private final List operations = new ArrayList<>(); - enum OperationType { - CUSTOM(null), - PRIM_BLOCK("Block", 0), - PRIM_IF_THEN("IfThen", 0), - PRIM_IF_THEN_ELSE("IfThenElse", 0), - PRIM_WHILE("While", 0), - PRIM_CONST_OBJECT("ConstObject"), - PRIM_LOAD_LOCAL("LoadLocal"), - PRIM_STORE_LOCAL("StoreLocal"), - PRIM_LOAD_ARGUMENT("LoadArgument"), - PRIM_RETURN("Return"), - PRIM_BRANCH("Branch", 0), - PRIM_LABEL("Label", 0); - - final String name; - final int numOpcodes; - - OperationType(String name) { - this(name, 1); - } - - OperationType(String name, int numOpcodes) { - this.name = name; - this.numOpcodes = numOpcodes; - } + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { + super(context, templateType, annotation); } - static class Operation { - final OperationType type; - final List arguments; - final int children; - final TypeElement typeElement; - final ExecutableElement mainMethod; - final boolean returnsValue; - - CodeVariableElement typeConstant; - CodeVariableElement[] opcodeConstant; - - Operation(OperationType type, List arguments, int children, TypeElement typeElement, ExecutableElement mainMethod, boolean returnsValue) { - this.type = type; - this.arguments = arguments; - this.children = children; - this.typeElement = typeElement; - this.mainMethod = mainMethod; - this.returnsValue = returnsValue; - } - - public String getName() { - if (type == OperationType.CUSTOM) { - return typeElement.getSimpleName().toString(); - } else { - return type.name; - } - } - - public String getScreamCaseName() { - if (type == OperationType.CUSTOM) { - return "OP_" + typeElement.getSimpleName().toString().replaceAll("([a-z])([A-Z])", "$1_$2").toUpperCase(); - } else { - return type.toString(); - } - } - - public CodeVariableElement getTypeConstant() { - return typeConstant; - } - - public void setTypeConstant(CodeVariableElement typeConstant) { - this.typeConstant = typeConstant; - } + public List getOperations() { + return operations; + } - public CodeVariableElement[] getOpcodeConstant() { - if (opcodeConstant == null) { - throw new IllegalArgumentException("Opcode constant not defined for " + type); - } - return opcodeConstant; - } + public Collection getInstructions() { + Set instrs = new HashSet<>(); - public void setOpcodeConstant(CodeVariableElement[] opcodeConstant) { - this.opcodeConstant = opcodeConstant; + for (Instruction insn : getOperations().get(0).commonInstructions) { + instrs.add(insn); } - public Collection getArguments(TruffleTypes types, ProcessorContext ctx) { - switch (type) { - case CUSTOM: - return arguments; - case PRIM_CONST_OBJECT: - return List.of(ctx.getType(Object.class)); - case PRIM_LOAD_LOCAL: - case PRIM_STORE_LOCAL: - case PRIM_LOAD_ARGUMENT: - return List.of(ctx.getType(short.class)); - case PRIM_BRANCH: - return List.of(types.OperationLabel); - case PRIM_BLOCK: - case PRIM_IF_THEN: - case PRIM_IF_THEN_ELSE: - case PRIM_WHILE: - case PRIM_RETURN: - case PRIM_LABEL: - return List.of(); - default: - throw new IllegalArgumentException("bad type: " + type); + for (Operation op : getOperations()) { + for (Instruction insn : op.instructions) { + instrs.add(insn); } } - } - - private final List operations = new ArrayList<>(); - public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { - super(context, templateType, annotation); + return instrs; } - public List getOperations() { - return operations; + public Collection getCustomOperations() { + return operations.stream()// + .filter(x -> x instanceof Operation.CustomOperation)// + .map(x -> (Operation.CustomOperation) x)// + .toList(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index cb491d152a06..18f6e4058c1d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,7 +1,6 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import javax.lang.model.element.AnnotationMirror; @@ -10,10 +9,8 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationType; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { @@ -27,6 +24,9 @@ private static AnnotationMirror getAnnotationMirror(List mirror) { @@ -55,22 +55,27 @@ protected OperationsData parse(Element element, List mirror) { return data; } - private static void addPrimitives(OperationsData data) { - addPrimitiveOperation(data, OperationType.PRIM_BLOCK, -1, true); - addPrimitiveOperation(data, OperationType.PRIM_IF_THEN, 2, true); - addPrimitiveOperation(data, OperationType.PRIM_IF_THEN_ELSE, 3, true); - addPrimitiveOperation(data, OperationType.PRIM_WHILE, 2, false); - addPrimitiveOperation(data, OperationType.PRIM_CONST_OBJECT, 0, true); - addPrimitiveOperation(data, OperationType.PRIM_LOAD_LOCAL, 0, true); - addPrimitiveOperation(data, OperationType.PRIM_STORE_LOCAL, 1, false); - addPrimitiveOperation(data, OperationType.PRIM_LOAD_ARGUMENT, 0, true); - addPrimitiveOperation(data, OperationType.PRIM_RETURN, 1, true); - addPrimitiveOperation(data, OperationType.PRIM_BRANCH, 0, false); - addPrimitiveOperation(data, OperationType.PRIM_LABEL, 0, false); + private void addPrimitives(OperationsData data) { + Instruction[] commonOpcodes = Operation.createCommonOpcodes(opcodeId); + opcodeId += commonOpcodes.length; + + addPrimitive(data, commonOpcodes, new Operation.Block(opId++)); + addPrimitive(data, commonOpcodes, new Operation.IfThen(opId++)); + addPrimitive(data, commonOpcodes, new Operation.IfThenElse(opId++)); + addPrimitive(data, commonOpcodes, new Operation.While(opId++)); + addPrimitive(data, commonOpcodes, new Operation.Label(opId++)); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("LoadLocal", opId++, new Instruction.LoadLocal(opcodeId++))); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("StoreLocal", opId++, new Instruction.StoreLocal(opcodeId++))); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("LoadArgument", opId++, new Instruction.LoadArgument(opcodeId++))); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("ConstObject", opId++, new Instruction.ConstObject(opcodeId++))); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("Return", opId++, new Instruction.Return(opcodeId++))); + addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("Branch", opId++, commonOpcodes[Operation.COMMON_OPCODE_JUMP_UNCOND])); + } - private static void addPrimitiveOperation(OperationsData data, OperationType type, int numChildren, boolean returnsValue) { - data.getOperations().add(new OperationsData.Operation(type, List.of(), numChildren, null, null, returnsValue)); + private static void addPrimitive(OperationsData data, Instruction[] commonOpcodes, Operation op) { + op.setCommonInstructions(commonOpcodes); + data.getOperations().add(op); } private void processOperation(OperationsData data, TypeElement te) { @@ -106,7 +111,8 @@ private void processOperation(OperationsData data, TypeElement te) { } } - data.getOperations().add(new OperationsData.Operation(OperationType.CUSTOM, arguments, numChildren, te, first, true)); + Operation op = new Operation.CustomOperation(te.getSimpleName().toString(), opId++, new Instruction.Custom(opcodeId++, te, first)); + data.getOperations().add(op); } private static boolean isOperationFunction(ExecutableElement el) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index e2ce8b4f3744..1bd50cea2e22 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -284,6 +284,10 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } + if (mode == ParseMode.DEFAULT && !getRepeatedAnnotation(templateType.getAnnotationMirrors(), types.Operation).isEmpty()) { + return null; + } + List lookupTypes = collectSuperClasses(new ArrayList(), templateType); NodeData node = parseNodeData(templateType, lookupTypes); From 265a43bdc49aec216c7fb9c1685071cb544efddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 7 Mar 2022 14:17:20 +0100 Subject: [PATCH 006/312] [wip] use frame for stack/locals --- .../operation/test/example/SlOperations.java | 2 +- .../test/example/SlOperationsBuilder.java | 90 ----- .../test/example/SlOperationsBuilderImpl.java | 380 ------------------ .../test/example/SlOperationsBuilderNode.java | 321 --------------- .../test/example/TestOperationsGenTest.java | 18 +- .../test/example/TestOperationsTest.java | 212 ---------- .../truffle/api/operation/OperationsNode.java | 17 +- .../dsl/processor/operations/Instruction.java | 23 +- .../dsl/processor/operations/Operation.java | 94 +++++ .../operations/OperationsCodeGenerator.java | 39 +- 10 files changed, 153 insertions(+), 1043 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index 425bead09508..75fa1bb22f9f 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -21,7 +21,7 @@ public static long add(long lhs, long rhs) { @Specialization public static String addStrings(String lhs, String rhs) { return lhs + rhs; - } + } } @Operation diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java deleted file mode 100644 index cd5c97a814bb..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilder.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationsNode; - -// TODO: the abstract / concrete distinction was in prototype, do we need it? -abstract class SlOperationsBuilder { - - public static SlOperationsBuilder createBuilder() { - return new SlOperationsBuilderImpl(); - } - - public abstract void reset(); - - public abstract OperationsNode build(); - - // labels - - public abstract OperationLabel createLabel(); - - public abstract void markLabel(OperationLabel label); - - // if_then - - public abstract void beginIfThen(); - - public abstract void endIfThen(); - - // if_then_else - - public abstract void beginIfThenElse(); - - public abstract void endIfThenElse(); - - // while - - public abstract void beginWhile(); - - public abstract void endWhile(); - - // block - - public abstract void beginBlock(); - - public abstract void endBlock(); - - // const_object - - public abstract void emitConstObject(Object value); - - // const_long - - public abstract void emitConstLong(long value); - - // load_local - - public abstract void emitLoadLocal(int index); - - // store_local - - public abstract void beginStoreLocal(int index); - - public abstract void endStoreLocal(); - - // load_argument - - public abstract void emitLoadArgument(int index); - - // return - - public abstract void beginReturn(); - - public abstract void endReturn(); - - // branch - - public abstract void emitBranch(OperationLabel label); - - // AddOperation - - public abstract void beginAddOperation(); - - public abstract void endAddOperation(); - - // LessThanOperation - - public abstract void beginLessThanOperation(); - - public abstract void endLessThanOperation(); -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java deleted file mode 100644 index ee58815eb69a..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderImpl.java +++ /dev/null @@ -1,380 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Stack; - -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.memory.ByteArraySupport; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.test.example.SlOperations.AddOperation; -import com.oracle.truffle.api.operation.test.example.SlOperations.LessThanOperation; - -class SlOperationsBuilderImpl extends SlOperationsBuilder { - - public SlOperationsBuilderImpl() { - reset(); - } - - static final byte PRIM_OP_NOP = 0; - static final byte PRIM_OP_JUMP_FALSE = 1; - static final byte PRIM_OP_UNCOND_JUMP = 2; - static final byte PRIM_OP_CONST_OBJECT = 3; - static final byte PRIM_OP_POP = 4; - static final byte PRIM_OP_RETURN = 5; - static final byte PRIM_OP_LOAD_ARGUMENT = 6; - static final byte PRIM_OP_LOAD_LOCAL = 8; - static final byte PRIM_OP_STORE_LOCAL = 9; - static final byte OP_ADD_OPERATION = 20; - static final byte OP_LESS_THAN_OPERATION = 21; - - static final int IMM_DEST_LENGTH = 2; - - static final void putDestination(byte[] bc, int bci, int value) { - BYTES.putShort(bc, bci, (short) value); - } - - static final int IMM_CONST_LENGTH = 2; - - static final void putConst(byte[] bc, int bci, Object value, ArrayList consts) { - int index = consts.size(); - consts.add(value); - BYTES.putShort(bc, bci, (short) index); - } - - static final ByteArraySupport BYTES = ByteArraySupport.littleEndian(); - - private static class SlOperationsOperationLabelImpl extends OperationLabel { - final int pointer; - - static final SlOperationsBuilderImpl.SlOperationsOperationLabelImpl ZERO = new SlOperationsOperationLabelImpl(0); - - SlOperationsOperationLabelImpl(int ptr) { - pointer = ptr; - } - } - - private static class SlOperationsBytecodeNode extends OperationsNode { - - final byte[] bc; - final Object[] consts; - - public SlOperationsBytecodeNode(byte[] bc, Object[] consts) { - this.bc = bc; - this.consts = consts; - } - - @Override - public String dump() { - return SlOperationsBuilderNode.dump(bc, consts); - } - - @Override - public Object execute(VirtualFrame frame) { - return continueAt(frame, SlOperationsOperationLabelImpl.ZERO); - } - - @Override - public Object continueAt(VirtualFrame frame, OperationLabel startIndex) { - - final Object[] stack = new Object[1024]; - final Object[] locals = new Object[1024]; - - int sp = 0; - int bci = ((SlOperationsBuilderImpl.SlOperationsOperationLabelImpl) startIndex).pointer; - - Object returnValue; - loop: while (true) { - int nextBci; - - // System.out.println(" op: " + bc[bci]); - switch (bc[bci]) { - case PRIM_OP_NOP: - nextBci = bci + 1; - break; - case PRIM_OP_JUMP_FALSE: { - boolean value = (boolean) stack[sp - 1]; - sp -= 1; - if (value) { - nextBci = bci + 3; - } else { - nextBci = BYTES.getShort(bc, bci + 1); - } - break; - } - case PRIM_OP_UNCOND_JUMP: { - nextBci = BYTES.getShort(bc, bci + 1); - break; - } - case PRIM_OP_CONST_OBJECT: { - Object value = consts[BYTES.getShort(bc, bci + 1)]; - stack[sp] = value; - sp += 1; - nextBci = bci + 3; - break; - } - case PRIM_OP_POP: - sp -= 1; - nextBci = bci + 1; - break; - case PRIM_OP_LOAD_ARGUMENT: { - int index = BYTES.getShort(bc, bci + 1); - Object value = frame.getArguments()[index]; - stack[sp++] = value; - nextBci = bci + 3; - break; - } - case PRIM_OP_LOAD_LOCAL: { - int index = BYTES.getShort(bc, bci + 1); - Object value = locals[index]; - stack[sp++] = value; - nextBci = bci + 3; - break; - } - case PRIM_OP_STORE_LOCAL: { - int index = BYTES.getShort(bc, bci + 1); - Object value = stack[--sp]; - locals[index] = value; - nextBci = bci + 3; - break; - } - case PRIM_OP_RETURN: { - returnValue = stack[sp - 1]; - break loop; - } - case OP_ADD_OPERATION: { - Object arg1 = stack[sp - 2]; - Object arg2 = stack[sp - 1]; - Object result = AddOperation.add((long) arg1, (long) arg2); - stack[sp - 2] = result; - sp -= 1; - nextBci = bci + 1; - break; - } - case OP_LESS_THAN_OPERATION: { - Object arg1 = stack[sp - 2]; - Object arg2 = stack[sp - 1]; - Object result = LessThanOperation.lessThan((long) arg1, (long) arg2); - stack[sp - 2] = result; - sp -= 1; - nextBci = bci + 1; - break; - } - default: - throw new RuntimeException("invalid opcode: " + bc[bci]); - } - // System.out.printf(" stack: "); - // for (int i = 0; i < sp; i++) { - // System.out.printf("(%s) %s, ", stack[i].getClass().getName(), stack[i]); - // } - // System.out.println(); - bci = nextBci; - } - - return returnValue; - } - } - - Stack typeStack = new Stack<>(); - Stack> childStack = new Stack<>(); - Stack argStack = new Stack<>(); - - static class SlOperationsLabel extends OperationLabel { - private boolean marked = false; - private ArrayList toBackfill; - private boolean hasValue = false; - private int value = 0; - - void resolve(byte[] bc, int labelValue) { - assert !hasValue; - hasValue = true; - value = labelValue; - - if (toBackfill != null) { - for (int bci : toBackfill) { - putDestination(bc, bci, value); - } - toBackfill = null; - } - } - - void putValue(byte[] bc, int bci) { - if (hasValue) { - putDestination(bc, bci, value); - } else { - if (toBackfill == null) - toBackfill = new ArrayList<>(); - toBackfill.add(bci); - } - } - } - - @Override - public void reset() { - typeStack.clear(); - childStack.clear(); - childStack.add(new ArrayList<>()); - argStack.clear(); - } - - @Override - public OperationsNode build() { - assert childStack.size() == 1; - SlOperationsBuilderNode[] operations = childStack.get(0).toArray(EMPTY_CHILDREN); - SlOperationsBuilderNode rootNode = new SlOperationsBuilderNode(SlOperationsBuilderNode.Type.BLOCK, new Object[0], operations); - - System.out.printf("resulting tree: %s\n", rootNode); - - byte[] bc = new byte[65535]; - ArrayList consts = new ArrayList<>(); - int len = rootNode.build(bc, 0, consts); - Object[] constsArr = consts.toArray(Object[]::new); - byte[] bcCopy = Arrays.copyOf(bc, len); - - SlOperationsBuilderImpl.SlOperationsBytecodeNode bcnode = new SlOperationsBytecodeNode(bcCopy, constsArr); - return bcnode; - } - - private static final SlOperationsBuilderNode[] EMPTY_CHILDREN = new SlOperationsBuilderNode[0]; - - private void beginOperation(SlOperationsBuilderNode.Type type, Object... arguments) { - assert arguments.length == type.argCount; - typeStack.add(type); - childStack.add(new ArrayList<>()); - argStack.add(arguments); - } - - private void endOperation(SlOperationsBuilderNode.Type type) { - SlOperationsBuilderNode.Type type2 = typeStack.remove(typeStack.size() - 1); - assert type == type2 : "unbalanced begin/ends"; - Object[] args = argStack.remove(argStack.size() - 1); - SlOperationsBuilderNode[] children = childStack.remove(childStack.size() - 1).toArray(EMPTY_CHILDREN); - - SlOperationsBuilderNode node = new SlOperationsBuilderNode(type, args, children); - childStack.get(childStack.size() - 1).add(node); - } - - private void emitOperation(SlOperationsBuilderNode.Type type, Object... args) { - SlOperationsBuilderNode node = new SlOperationsBuilderNode(type, args, EMPTY_CHILDREN); - childStack.get(childStack.size() - 1).add(node); - } - - @Override - public void beginIfThen() { - beginOperation(SlOperationsBuilderNode.Type.IF_THEN); - } - - @Override - public void endIfThen() { - endOperation(SlOperationsBuilderNode.Type.IF_THEN); - } - - @Override - public void beginIfThenElse() { - beginOperation(SlOperationsBuilderNode.Type.IF_THEN_ELSE); - } - - @Override - public void endIfThenElse() { - endOperation(SlOperationsBuilderNode.Type.IF_THEN_ELSE); - } - - @Override - public void beginWhile() { - beginOperation(SlOperationsBuilderNode.Type.WHILE); - } - - @Override - public void endWhile() { - endOperation(SlOperationsBuilderNode.Type.WHILE); - } - - @Override - public void beginBlock() { - beginOperation(SlOperationsBuilderNode.Type.BLOCK); - } - - @Override - public void endBlock() { - endOperation(SlOperationsBuilderNode.Type.BLOCK); - } - - @Override - public void emitConstObject(Object value) { - emitOperation(SlOperationsBuilderNode.Type.CONST_OBJECT, value); - } - - @Override - public void emitConstLong(long value) { - emitOperation(SlOperationsBuilderNode.Type.CONST_LONG, value); - } - - @Override - public void emitLoadLocal(int index) { - emitOperation(SlOperationsBuilderNode.Type.LOAD_LOCAL, index); - } - - @Override - public void beginStoreLocal(int index) { - beginOperation(SlOperationsBuilderNode.Type.STORE_LOCAL, index); - } - - @Override - public void endStoreLocal() { - endOperation(SlOperationsBuilderNode.Type.STORE_LOCAL); - } - - @Override - public void emitLoadArgument(int index) { - emitOperation(SlOperationsBuilderNode.Type.LOAD_ARGUMENT, index); - } - - @Override - public void beginAddOperation() { - beginOperation(SlOperationsBuilderNode.Type.OP_ADD_OPERATION); - } - - @Override - public void endAddOperation() { - endOperation(SlOperationsBuilderNode.Type.OP_ADD_OPERATION); - } - - @Override - public void beginReturn() { - beginOperation(SlOperationsBuilderNode.Type.RETURN); - } - - @Override - public void endReturn() { - endOperation(SlOperationsBuilderNode.Type.RETURN); - } - - @Override - public void beginLessThanOperation() { - beginOperation(SlOperationsBuilderNode.Type.OP_LESS_THAN_OPERATION); - } - - @Override - public void endLessThanOperation() { - endOperation(SlOperationsBuilderNode.Type.OP_LESS_THAN_OPERATION); - } - - @Override - public OperationLabel createLabel() { - return new SlOperationsLabel(); - } - - @Override - public void markLabel(OperationLabel label) { - SlOperationsLabel lbl = (SlOperationsLabel) label; - assert !lbl.marked; - lbl.marked = true; - emitOperation(SlOperationsBuilderNode.Type.LABEL, label); - } - - @Override - public void emitBranch(OperationLabel label) { - emitOperation(SlOperationsBuilderNode.Type.BRANCH, label); - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java deleted file mode 100644 index 1df46a9a26cb..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperationsBuilderNode.java +++ /dev/null @@ -1,321 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.ArrayList; - -import com.oracle.truffle.api.operation.test.example.SlOperationsBuilderImpl.SlOperationsLabel; - -class SlOperationsBuilderNode { - - private enum ValueResult { - NEVER, - ALWAYS, - DIVERGES - } - - public enum Type { - // primitive - BLOCK(0, -1), - IF_THEN(0, 2), - IF_THEN_ELSE(0, 3), - WHILE(0, 2), - CONST_OBJECT(1, 0), - CONST_LONG(1, 0), - LOAD_LOCAL(1, 0), - STORE_LOCAL(1, 1), - LOAD_ARGUMENT(1, 0), - RETURN(0, 1), - LABEL(1, 0), - BRANCH(1, 0), - // custom - OP_ADD_OPERATION(0, 2), - OP_LESS_THAN_OPERATION(0, 2); - - public final int argCount; - public final int childCount; - - private Type(int argCount, int childCount) { - this.argCount = argCount; - this.childCount = childCount; - } - } - - public final SlOperationsBuilderNode.Type type; - public final Object[] arguments; - public final SlOperationsBuilderNode[] children; - private final SlOperationsBuilderNode.ValueResult producesValue; - - public SlOperationsBuilderNode(SlOperationsBuilderNode.Type type, Object[] arguments, SlOperationsBuilderNode[] children) { - assert arguments.length == type.argCount; - assert type.childCount == -1 || children.length == type.childCount; - this.type = type; - this.arguments = arguments; - this.children = children; - - switch (type) { - case BLOCK: - if (children.length == 0) - producesValue = ValueResult.NEVER; - else - producesValue = children[children.length - 1].producesValue; - break; - case IF_THEN_ELSE: - assert children[0].producesValue != ValueResult.NEVER; - if (children[1].producesValue == ValueResult.NEVER || children[2].producesValue == ValueResult.NEVER) { - producesValue = ValueResult.NEVER; - } else { - producesValue = ValueResult.ALWAYS; - } - break; - case IF_THEN: - case WHILE: - case STORE_LOCAL: - assert children[0].producesValue != ValueResult.NEVER; - producesValue = ValueResult.NEVER; - break; - case OP_ADD_OPERATION: - case OP_LESS_THAN_OPERATION: - case CONST_OBJECT: - case CONST_LONG: - case LOAD_LOCAL: - case LOAD_ARGUMENT: - for (SlOperationsBuilderNode child : children) { - assert child.producesValue != ValueResult.NEVER : "" + this; - } - producesValue = ValueResult.ALWAYS; - break; - case RETURN: - case BRANCH: - producesValue = ValueResult.DIVERGES; - break; - case LABEL: - producesValue = ValueResult.NEVER; - break; - default: - throw new RuntimeException(); - - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("("); - sb.append(type); - for (SlOperationsBuilderNode child : children) { - sb.append(" "); - sb.append(child); - } - sb.append(")"); - return sb.toString(); - } - - final int build(byte[] bc, int inBci, ArrayList consts) { - int bci = inBci; - // System.out.println("building " + this); - - switch (type) { - case BLOCK: { - for (int i = 0; i < children.length; i++) { - bci = children[i].build(bc, bci, consts); - if (i != children.length - 1 && children[i].producesValue == ValueResult.ALWAYS) { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; - } - } - break; - } - case IF_THEN: { - bci = children[0].build(bc, bci, consts); - - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; - int targetDest = bci; - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - - bci = children[1].build(bc, bci, consts); - if (children[1].producesValue == ValueResult.ALWAYS) - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; - - SlOperationsBuilderImpl.putDestination(bc, targetDest, bci); - break; - } - case IF_THEN_ELSE: { - bci = children[0].build(bc, bci, consts); - - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; - int elseDest = bci; - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - - bci = children[1].build(bc, bci, consts); - if (children[1].producesValue == ValueResult.ALWAYS && producesValue == ValueResult.NEVER) - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; - - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; - int endDest = bci; - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - - SlOperationsBuilderImpl.putDestination(bc, elseDest, bci); - - bci = children[2].build(bc, bci, consts); - if (children[2].producesValue == ValueResult.ALWAYS && producesValue == ValueResult.NEVER) - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; - - SlOperationsBuilderImpl.putDestination(bc, endDest, bci); - break; - } - case WHILE: { - int startBci = bci; - - bci = children[0].build(bc, bci, consts); - - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE; - int endDest = bci; - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - - bci = children[1].build(bc, bci, consts); - if (children[1].producesValue == ValueResult.ALWAYS) - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_POP; - - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; - SlOperationsBuilderImpl.putDestination(bc, bci, startBci); - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - - SlOperationsBuilderImpl.putDestination(bc, endDest, bci); - break; - } - case LABEL: { - SlOperationsLabel label = (SlOperationsLabel) arguments[0]; - label.resolve(bc, bci); - break; - } - case BRANCH: { - SlOperationsLabel label = (SlOperationsLabel) arguments[0]; - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP; - label.putValue(bc, bci); - bci += SlOperationsBuilderImpl.IMM_DEST_LENGTH; - break; - } - case CONST_OBJECT: - case CONST_LONG: - case LOAD_LOCAL: - case STORE_LOCAL: - case LOAD_ARGUMENT: - case RETURN: - case OP_ADD_OPERATION: - case OP_LESS_THAN_OPERATION: { - for (SlOperationsBuilderNode child : children) { - bci = child.build(bc, bci, consts); - } - - switch (type) { - case CONST_LONG: - case CONST_OBJECT: { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_CONST_OBJECT; - SlOperationsBuilderImpl.putConst(bc, bci, arguments[0], consts); - bci += SlOperationsBuilderImpl.IMM_CONST_LENGTH; - break; - } - case LOAD_LOCAL: { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_LOAD_LOCAL; - SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); - bci += 2; - break; - } - case STORE_LOCAL: { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_STORE_LOCAL; - SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); - bci += 2; - break; - } - case LOAD_ARGUMENT: { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_LOAD_ARGUMENT; - SlOperationsBuilderImpl.BYTES.putShort(bc, bci, (short) (int) arguments[0]); - bci += 2; - break; - } - case RETURN: { - bc[bci++] = SlOperationsBuilderImpl.PRIM_OP_RETURN; - break; - } - case OP_ADD_OPERATION: { - bc[bci++] = SlOperationsBuilderImpl.OP_ADD_OPERATION; - break; - } - case OP_LESS_THAN_OPERATION: { - bc[bci++] = SlOperationsBuilderImpl.OP_LESS_THAN_OPERATION; - break; - } - } - break; - } - default: { - throw new RuntimeException("" + type); - } - } - - return bci; - } - - public static String dump(byte[] bc, Object[] consts) { - StringBuilder sb = new StringBuilder(); - - for (int bci = 0; bci < bc.length;) { - sb.append(String.format(" %04x ", bci)); - switch (bc[bci]) { - case SlOperationsBuilderImpl.PRIM_OP_NOP: - sb.append("nop"); - bci += 1; - break; - case SlOperationsBuilderImpl.PRIM_OP_JUMP_FALSE: - sb.append(String.format("jp_f %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); - bci += 3; - break; - - case SlOperationsBuilderImpl.PRIM_OP_UNCOND_JUMP: - sb.append(String.format("jp %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); - bci += 3; - break; - case SlOperationsBuilderImpl.PRIM_OP_CONST_OBJECT: { - int index = SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1); - sb.append(String.format("const #%d // (%s) %s", index, consts[index].getClass().getName(), consts[index])); - bci += 3; - break; - } - case SlOperationsBuilderImpl.PRIM_OP_POP: - sb.append("pop"); - bci += 1; - break; - case SlOperationsBuilderImpl.PRIM_OP_RETURN: - sb.append("ret"); - bci += 1; - break; - case SlOperationsBuilderImpl.PRIM_OP_LOAD_ARGUMENT: - sb.append(String.format("ldarg %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); - bci += 3; - break; - case SlOperationsBuilderImpl.PRIM_OP_LOAD_LOCAL: - sb.append(String.format("ldloc %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); - bci += 3; - break; - case SlOperationsBuilderImpl.PRIM_OP_STORE_LOCAL: - sb.append(String.format("stloc %04x", SlOperationsBuilderImpl.BYTES.getShort(bc, bci + 1))); - bci += 3; - break; - case SlOperationsBuilderImpl.OP_ADD_OPERATION: - sb.append("op AddOperation"); - bci += 1; - break; - case SlOperationsBuilderImpl.OP_LESS_THAN_OPERATION: - sb.append("op LessThanOperation"); - bci += 1; - break; - default: - sb.append(String.format("unknown %02x", bc[bci])); - bci += 1; - break; - } - sb.append("\n"); - } - - return sb.toString(); - } - -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index 7ac4bf29df79..855a37b0de96 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -16,22 +16,6 @@ @RunWith(JUnit4.class) public class TestOperationsGenTest { - private static class OperationsRootNode extends RootNode { - - @Child private OperationsNode executable; - - protected OperationsRootNode(OperationsNode executable) { - super(null); - this.executable = executable; - } - - @Override - public Object execute(VirtualFrame frame) { - return this.executable.execute(frame); - } - - } - private static void parseAdd(SlOperationsBuilderino b) { // simple test: // function foo(a, b) { @@ -104,7 +88,7 @@ private static void runTest(Consumer parse, Object expec System.out.println(executable.dump()); b.reset(); System.out.println(executable); - CallTarget target = new OperationsRootNode(executable).getCallTarget(); + CallTarget target = executable.getCallTarget(); Object result = target.call(args); Assert.assertEquals(expectedResult, result); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java deleted file mode 100644 index ccca1145ea59..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsTest.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.function.Consumer; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationsNode; - -@RunWith(JUnit4.class) -public class TestOperationsTest { - - private static class OperationsRootNode extends RootNode { - - @Child private OperationsNode executable; - - protected OperationsRootNode(OperationsNode executable) { - super(null); - this.executable = executable; - } - - @Override - public Object execute(VirtualFrame frame) { - return this.executable.execute(frame); - } - - } - - private static void parseAdd(SlOperationsBuilder b) { - // simple test: - // function foo(a, b) { - // return (a + b); - // } - b.beginReturn(); - b.beginAddOperation(); - b.emitLoadArgument(0); - b.emitLoadArgument(1); - b.endAddOperation(); - b.endReturn(); - } - - private static void parseMax(SlOperationsBuilder b) { - // control flow test: - // function max(a, b) { - // if (a < b) { - // return b; - // } else { - // return a; - // } - b.beginIfThenElse(); - - b.beginLessThanOperation(); - b.emitLoadArgument(0); // a - b.emitLoadArgument(1); // b - b.endLessThanOperation(); - - b.beginReturn(); - b.emitLoadArgument(1); // b - b.endReturn(); - - b.beginReturn(); - b.emitLoadArgument(0); // a - b.endReturn(); - - b.endIfThenElse(); - } - - @Test - public void testAdd() { - runTest(TestOperationsTest::parseAdd, 42L, 20L, 22L); - } - - @Test - public void testMax() { - runTest(TestOperationsTest::parseMax, 42L, 42L, 13L); - runTest(TestOperationsTest::parseMax, 42L, 13L, 42L); - } - - @Test - public void testSumLoop() { - runTest(TestOperationsTest::parseSumLoop, 45L, 10L); - } - - @Test - public void testBreakLoop() { - runTest(TestOperationsTest::parseBreakLoop, 6L, 5L); - runTest(TestOperationsTest::parseBreakLoop, 10L, 15L); - } - - private static void runTest(Consumer parse, Object expectedResult, Object... args) { - SlOperationsBuilder b = SlOperationsBuilder.createBuilder(); - parse.accept(b); - OperationsNode executable = b.build(); - System.out.println(executable.dump()); - b.reset(); - System.out.println(executable); - CallTarget target = new OperationsRootNode(executable).getCallTarget(); - Object result = target.call(args); - Assert.assertEquals(expectedResult, result); - } - - private static void parseSumLoop(SlOperationsBuilder b) { - // control flow test: - // function sum(length) { - // sum = 0; - // i = 0; - // while (i < length) { - // sum += i; - // i += 1; - // } - // return sum; - - b.beginStoreLocal(0); // sum - b.emitConstLong(0); - b.endStoreLocal(); - - b.beginStoreLocal(1); // i - b.emitConstLong(0); - b.endStoreLocal(); - - b.beginWhile(); - - b.beginLessThanOperation(); - b.emitLoadLocal(1); // i - b.emitLoadArgument(0); // length - b.endLessThanOperation(); - - b.beginBlock(); - - b.beginStoreLocal(0); // sum - b.beginAddOperation(); - b.emitLoadLocal(0); - b.emitLoadLocal(1); // i - b.endAddOperation(); - b.endStoreLocal(); - - b.beginStoreLocal(1); - b.beginAddOperation(); - b.emitLoadLocal(1); - b.emitConstLong(1); - b.endAddOperation(); - b.endStoreLocal(); - - b.endBlock(); - - b.endWhile(); - - b.beginReturn(); - b.emitLoadLocal(0); - b.endReturn(); - } - - private static void parseBreakLoop(SlOperationsBuilder b) { - // function breakLoop(input) { - // i = 0; - // while (i < 10) { - // if (input < i) break; - // i += 1; - // } - // return i; - - b.beginStoreLocal(0); // i - b.emitConstLong(0); - b.endStoreLocal(); - - OperationLabel breakLbl = b.createLabel(); - - b.beginWhile(); - - b.beginLessThanOperation(); - b.emitLoadLocal(0); // i - b.emitConstLong(10); - b.endLessThanOperation(); - - b.beginBlock(); - - b.beginIfThen(); - - b.beginLessThanOperation(); - b.emitLoadArgument(0); // input - b.emitLoadLocal(0); // i - b.endLessThanOperation(); - - b.emitBranch(breakLbl); - - b.endIfThen(); - - b.beginStoreLocal(0); - b.beginAddOperation(); - b.emitLoadLocal(0); - b.emitConstLong(1); - b.endAddOperation(); - b.endStoreLocal(); - - b.endBlock(); - - b.endWhile(); - - b.markLabel(breakLbl); - - b.beginReturn(); - b.emitLoadLocal(0); - b.endReturn(); - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 3d110047729d..7c7c17bc1d2e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,10 +1,23 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; -public abstract class OperationsNode extends Node { - public abstract Object execute(VirtualFrame frame); +public abstract class OperationsNode extends RootNode { + + private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals) { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(maxStack + maxLocals); + b.addSlots(maxLocals + maxStack, FrameSlotKind.Object); + return b.build(); + } + + protected OperationsNode(int maxStack, int maxLocals) { + super(null, createFrameDescriptor(maxStack, maxLocals)); + } public abstract Object continueAt(VirtualFrame frame, OperationLabel index); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 9b3d37f9c910..637d792cb7c9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -18,26 +18,24 @@ static class ExecutorVariables { CodeVariableElement nextBci; CodeVariableElement bc; CodeVariableElement consts; - CodeVariableElement stack; CodeVariableElement sp; - CodeVariableElement locals; CodeVariableElement funArgs; + CodeVariableElement frame; CodeVariableElement returnValue; CodeVariableElement[] arguments; CodeVariableElement[] children; CodeVariableElement result; - public ExecutorVariables(CodeVariableElement bci, CodeVariableElement nextBci, CodeVariableElement bc, CodeVariableElement consts, CodeVariableElement stack, CodeVariableElement sp, - CodeVariableElement locals, CodeVariableElement funArgs, CodeVariableElement returnValue) { + public ExecutorVariables(CodeVariableElement bci, CodeVariableElement nextBci, CodeVariableElement bc, CodeVariableElement consts, CodeVariableElement sp, CodeVariableElement funArgs, + CodeVariableElement frame, CodeVariableElement returnValue) { this.bci = bci; this.nextBci = nextBci; this.bc = bc; this.consts = consts; - this.stack = stack; this.sp = sp; - this.locals = locals; this.funArgs = funArgs; + this.frame = frame; this.returnValue = returnValue; this.arguments = null; this.children = null; @@ -129,13 +127,13 @@ CodeTree createReaderCode(ExecutorVariables vars, CodeTree offset) { b.string("]"); break; case LOCAL: - b.variable(vars.locals); - b.string("["); + b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "getValue"); + b.startGroup(); + b.string("32 + "); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); b.tree(offset); - b.end(); - b.string("]"); + b.end(3); break; default: throw new IllegalArgumentException(this.toString()); @@ -277,9 +275,10 @@ CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement(); - b.variable(vars.locals).string("[").variable(vars.arguments[0]).string("] ="); + b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "setObject"); + b.startGroup().string("32 + ").variable(vars.arguments[0]).end(); b.variable(vars.children[0]); - b.end(); + b.end(2); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index f1c15cd383fb..3039ebc9bf79 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -30,11 +30,26 @@ public EmitterVariables(CodeExecutableElement self, CodeVariableElement bc, Code this.children = children; this.arguments = arguments; } + } + + static class CtorVariables { + final CodeVariableElement children; + final CodeVariableElement arguments; + final CodeVariableElement returnsValue; + public CtorVariables(CodeVariableElement children, CodeVariableElement arguments, CodeVariableElement returnsValue) { + this.children = children; + this.arguments = arguments; + this.returnsValue = returnsValue; + } } public static final int VARIABLE_CHILDREN = -1; + public static final int RETURNS_VALUE_NEVER = 0; + public static final int RETURNS_VALUE_ALWAYS = 1; + public static final int RETURNS_VALUE_DIVERGE = 2; + protected final String name; protected final int type; protected final int children; @@ -90,6 +105,8 @@ public int getType() { return type; } + public abstract CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars); + public abstract CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars); static class SimpleOperation extends Operation { @@ -116,6 +133,21 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { return b.build(); } + + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + for (int i = 0; i < children; i++) { + b.startAssert().variable(vars.children).string("[" + i + "].").variable(vars.returnsValue).string(" != " + RETURNS_VALUE_NEVER).end(); + } + + b.startAssign("this", vars.returnsValue); + b.string(this.instructions[0].stackPushes > 0 ? "" + RETURNS_VALUE_ALWAYS : "" + RETURNS_VALUE_NEVER); + b.end(); + + return b.build(); + } } static class CustomOperation extends SimpleOperation { @@ -153,6 +185,25 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { return b.build(); } + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().variable(vars.children).string(".length > 0").end(); + b.startBlock(); + + b.startAssign("this", vars.returnsValue); + b.variable(vars.children).string("[").variable(vars.children).string(".length - 1].").variable(vars.returnsValue); + b.end(2); + + b.startElseBlock(); + + b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER); + b.end(2); + + return b.build(); + } + } static class IfThen extends PseudoOperation { @@ -181,6 +232,15 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { return b.build(); } + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + + return b.build(); + } + } static class IfThenElse extends PseudoOperation { @@ -220,6 +280,22 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { return b.build(); } + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssert().variable(vars.children).string("[0].").variable(vars.returnsValue).string("!= " + RETURNS_VALUE_NEVER).end(); + + b.declaration("int", "rv_1", "children[1].returnsValue"); + b.declaration("int", "rv_2", "children[2].returnsValue"); + + b.startIf().string("rv_1 == " + RETURNS_VALUE_NEVER + " || rv_2 == " + RETURNS_VALUE_NEVER).end(); + b.startBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(2); + b.startElseBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_ALWAYS).end(2); + + return b.build(); + } + } static class While extends PseudoOperation { @@ -254,6 +330,15 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { return b.build(); } + + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + + return b.build(); + } } static class Label extends PseudoOperation { @@ -275,6 +360,15 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { return new TypeMirror[]{types.OperationLabel}; } + + @Override + public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + + return b.build(); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index eb321903cc9b..8cb119ab5e8f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -174,6 +174,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startReturn(); b.startNew(builderBytecodeNodeType.asType()); + b.string("32"); + b.string("32"); b.string("bcCopy"); b.string("cpCopy"); b.end(2); @@ -330,7 +332,32 @@ private CodeTypeElement createBuilderImplNode(String simpleName) { builderNodeType.add(ctor); CodeVariableElement fldReturnsValue = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue"); - // builderNodeType.add(fldReturnsValue); + builderNodeType.add(fldReturnsValue); + + { + CodeTreeBuilder b = ctor.getBuilder(); + + b.startSwitch().field("this", fldType).end().startBlock(); + + for (Operation op : m.getOperations()) { + b.startCase().string("" + op.getType() + " /* " + op.getName() + " */").end(); + + b.startBlock(); + + Operation.CtorVariables vars = new Operation.CtorVariables(fldChildren, fldArguments, fldReturnsValue); + + b.tree(op.createReturnsValueCode(types, vars)); + + b.startStatement().string("break").end(); + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); // default case block + + b.end(); + } { CodeVariableElement argBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); @@ -414,14 +441,10 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeTreeBuilder b = mContinueAt.getBuilder(); - CodeVariableElement varStack = new CodeVariableElement(arrayOf(context.getType(Object.class)), "stack"); - CodeVariableElement varLocals = new CodeVariableElement(arrayOf(context.getType(Object.class)), "locals"); CodeVariableElement varFunArgs = new CodeVariableElement(arrayOf(context.getType(Object.class)), "funArgs"); CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("final Object[]", varStack.getName(), "new Object[1024]"); - b.declaration("final Object[]", varLocals.getName(), "new Object[1024]"); b.declaration("final Object[]", varFunArgs.getName(), "frame.getArguments()"); b.declaration("int", varSp.getName(), "0"); b.declaration("int", varBci.getName(), "0"); @@ -438,7 +461,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startSwitch().string("bc[bci]").end(); b.startBlock(); - ExecutorVariables vars = new ExecutorVariables(varBci, varNextBci, fldBc, fldConsts, varStack, varSp, varLocals, varFunArgs, varReturnValue); + ExecutorVariables vars = new ExecutorVariables(varBci, varNextBci, fldBc, fldConsts, varSp, varFunArgs, argFrame, varReturnValue); for (Instruction op : m.getInstructions()) { @@ -449,7 +472,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeVariableElement[] pops = new CodeVariableElement[op.stackPops]; for (int i = op.stackPops - 1; i >= 0; i--) { pops[i] = new CodeVariableElement(context.getType(Object.class), "value" + i); - b.declaration("Object", pops[i].getName(), varStack.getName() + "[--" + varSp.getName() + "]"); + b.declaration("Object", pops[i].getName(), argFrame.getName() + ".getValue(--" + varSp.getName() + ")"); } CodeVariableElement[] args = new CodeVariableElement[op.arguments.length]; @@ -471,7 +494,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.tree(op.createExecutorCode(types, vars)); if (op.stackPushes > 0) { - b.statement(varStack.getName() + "[" + varSp.getName() + "++] = " + vars.result.getName()); + b.statement(argFrame.getName() + ".setObject(" + varSp.getName() + "++, " + vars.result.getName() + ")"); } if (!op.isDivergent()) { From 9a9f8e45e3c8afd6958b8194301d1e9612a1c0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 7 Mar 2022 15:02:25 +0100 Subject: [PATCH 007/312] [wip] calculate and use maxStack & maxLocals --- .../truffle/api/operation/OperationsNode.java | 5 ++ .../dsl/processor/operations/Instruction.java | 4 +- .../dsl/processor/operations/Operation.java | 47 +++++++++++++---- .../operations/OperationsCodeGenerator.java | 50 +++++++++++++++++-- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 7c7c17bc1d2e..8a0324484275 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -15,8 +15,13 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals return b.build(); } + protected final int maxStack; + protected final int maxLocals; + protected OperationsNode(int maxStack, int maxLocals) { super(null, createFrameDescriptor(maxStack, maxLocals)); + this.maxLocals = maxLocals; + this.maxStack = maxStack; } public abstract Object continueAt(VirtualFrame frame, OperationLabel index); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 637d792cb7c9..1bee78d18b71 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -129,7 +129,7 @@ CodeTree createReaderCode(ExecutorVariables vars, CodeTree offset) { case LOCAL: b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "getValue"); b.startGroup(); - b.string("32 + "); + b.string("maxStack + "); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); b.tree(offset); @@ -276,7 +276,7 @@ CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { b.startStatement(); b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "setObject"); - b.startGroup().string("32 + ").variable(vars.arguments[0]).end(); + b.startGroup().string("maxStack + ").variable(vars.arguments[0]).end(); b.variable(vars.children[0]); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 3039ebc9bf79..b60303dce623 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -1,6 +1,7 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.Collection; import javax.lang.model.type.TypeMirror; @@ -10,6 +11,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Instruction.ArgumentType; abstract class Operation { @@ -36,11 +38,15 @@ static class CtorVariables { final CodeVariableElement children; final CodeVariableElement arguments; final CodeVariableElement returnsValue; + final CodeVariableElement maxStack; + final CodeVariableElement maxLocals; - public CtorVariables(CodeVariableElement children, CodeVariableElement arguments, CodeVariableElement returnsValue) { + public CtorVariables(CodeVariableElement children, CodeVariableElement arguments, CodeVariableElement returnsValue, CodeVariableElement maxStack, CodeVariableElement maxLocals) { this.children = children; this.arguments = arguments; this.returnsValue = returnsValue; + this.maxStack = maxStack; + this.maxLocals = maxLocals; } } @@ -88,13 +94,22 @@ public String getName() { public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { ArrayList arr = new ArrayList<>(); + for (Instruction.ArgumentType art : getArgumentTypes()) { + arr.add(art.toType(context, types)); + } + + return arr.toArray(new TypeMirror[arr.size()]); + } + + public Collection getArgumentTypes() { + ArrayList arr = new ArrayList<>(); for (Instruction inst : instructions) { for (Instruction.ArgumentType art : inst.arguments) { - arr.add(art.toType(context, types)); + arr.add(art); } } - return arr.toArray(new TypeMirror[arr.size()]); + return arr; } public boolean hasChildren() { @@ -105,7 +120,11 @@ public int getType() { return type; } - public abstract CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars); + public boolean keepsChildValues() { + return false; + } + + public abstract CodeTree createCtorCode(TruffleTypes types, CtorVariables vars); public abstract CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars); @@ -135,9 +154,11 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + // returnsValue + for (int i = 0; i < children; i++) { b.startAssert().variable(vars.children).string("[" + i + "].").variable(vars.returnsValue).string(" != " + RETURNS_VALUE_NEVER).end(); } @@ -148,6 +169,11 @@ public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { return b.build(); } + + @Override + public boolean keepsChildValues() { + return true; + } } static class CustomOperation extends SimpleOperation { @@ -186,7 +212,7 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().variable(vars.children).string(".length > 0").end(); @@ -233,7 +259,7 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); @@ -281,7 +307,7 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssert().variable(vars.children).string("[0].").variable(vars.returnsValue).string("!= " + RETURNS_VALUE_NEVER).end(); @@ -292,7 +318,6 @@ public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { b.startIf().string("rv_1 == " + RETURNS_VALUE_NEVER + " || rv_2 == " + RETURNS_VALUE_NEVER).end(); b.startBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(2); b.startElseBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_ALWAYS).end(2); - return b.build(); } @@ -332,7 +357,7 @@ public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); @@ -362,7 +387,7 @@ public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTyp } @Override - public CodeTree createReturnsValueCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 8cb119ab5e8f..3016b09bafac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -34,6 +34,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.operations.Instruction.ArgumentType; import com.oracle.truffle.dsl.processor.operations.Instruction.ExecutorVariables; import com.oracle.truffle.dsl.processor.operations.Operation.EmitterVariables; import com.oracle.truffle.dsl.processor.parser.NodeParser; @@ -174,8 +175,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startReturn(); b.startNew(builderBytecodeNodeType.asType()); - b.string("32"); - b.string("32"); + b.string("rootNode.maxStack"); + b.string("rootNode.maxLocals"); b.string("bcCopy"); b.string("cpCopy"); b.end(2); @@ -334,19 +335,60 @@ private CodeTypeElement createBuilderImplNode(String simpleName) { CodeVariableElement fldReturnsValue = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue"); builderNodeType.add(fldReturnsValue); + CodeVariableElement fldMaxStack = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "maxStack"); + builderNodeType.add(fldMaxStack); + + CodeVariableElement fldMaxLocals = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "maxLocals"); + builderNodeType.add(fldMaxLocals); + { CodeTreeBuilder b = ctor.getBuilder(); b.startSwitch().field("this", fldType).end().startBlock(); + Operation.CtorVariables vars = new Operation.CtorVariables(fldChildren, fldArguments, fldReturnsValue, fldMaxStack, fldMaxLocals); + for (Operation op : m.getOperations()) { b.startCase().string("" + op.getType() + " /* " + op.getName() + " */").end(); b.startBlock(); - Operation.CtorVariables vars = new Operation.CtorVariables(fldChildren, fldArguments, fldReturnsValue); + b.tree(op.createCtorCode(types, vars)); + + b.statement("int maxStack_ = 1"); + b.statement("int maxLocals_ = 0"); + + if (op.children == Operation.VARIABLE_CHILDREN) { + b.startFor().string("int i = 0; i < children.length; i++").end(); + b.startBlock(); + + String extra = op.keepsChildValues() ? " + i" : ""; + b.statement("if (maxStack_ < children[i].maxStack" + extra + ") maxStack_ = children[i].maxStack" + extra); + + b.statement("if (maxLocals_ < children[i].maxLocals) maxLocals_ = children[i].maxLocals"); + + b.end(); + } else { + for (int i = 0; i < op.children; i++) { + String extra = op.keepsChildValues() ? " + " + i : ""; + b.statement("if (maxStack_ < children[" + i + "].maxStack" + extra + ") maxStack_ = children[" + i + "].maxStack" + extra); + + b.statement("if (maxLocals_ < children[" + i + "].maxLocals) maxLocals_ = children[" + i + "].maxLocals"); + } + } + + int argIdx = 0; + for (ArgumentType arg : op.getArgumentTypes()) { + if (arg == ArgumentType.LOCAL || arg == ArgumentType.LOCAL_INDEX) { + b.statement("if (maxLocals_ < (short) arguments[" + argIdx + "] + 1) maxLocals_ = (short) arguments[" + argIdx + "] + 1"); + } + argIdx++; + } + + b.statement("maxStack = maxStack_"); + b.statement("maxLocals = maxLocals_"); - b.tree(op.createReturnsValueCode(types, vars)); + b.statement("System.out.println(\"" + op.getName() + " \" + maxStack + \" \" + maxLocals)"); b.startStatement().string("break").end(); b.end(); From f2ddb8957c855fa1ef8e05eb085cb1b413125eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 8 Mar 2022 22:13:09 +0100 Subject: [PATCH 008/312] [wip] stuff --- .../operation/test/example/SlOperations.java | 9 + .../test/example/TestOperationsGenTest.java | 24 + .../processor/generator/GeneratorUtils.java | 7 + .../dsl/processor/operations/Argument.java | 176 +++++ .../dsl/processor/operations/Instruction.java | 600 +++++++++--------- .../dsl/processor/operations/Operation.java | 530 ++++++++-------- .../operations/OperationGeneratorUtils.java | 119 ++-- .../operations/OperationsBuilder.java | 63 ++ .../operations/OperationsCodeGenerator.java | 540 ++++++++-------- .../processor/operations/OperationsData.java | 33 +- .../operations/OperationsParser.java | 54 +- 11 files changed, 1227 insertions(+), 928 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index 75fa1bb22f9f..bcb88e2898c1 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation.test.example; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -31,4 +32,12 @@ public static boolean lessThan(long lhs, long rhs) { return lhs < rhs; } } + + @Operation + static class VeryComplexOperation { + @Specialization + public static long bla(long a1, Object... a2) { + return a1 + a2.length; + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index 855a37b0de96..2b7567d26368 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -78,6 +78,11 @@ public void testBreakLoop() { runTest(TestOperationsGenTest::parseBreakLoop, 10L, 15L); } + @Test + public void testVeryComplex() { + runTest(TestOperationsGenTest::parseVeryComplex, 10L); + } + private static void runTest(Consumer parse, Object expectedResult, Object... args) { System.out.println("------------------------------------"); SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); @@ -197,4 +202,23 @@ private static void parseBreakLoop(SlOperationsBuilderino b) { b.endReturn(); } + private static void parseVeryComplex(SlOperationsBuilderino b) { + // function veryComplex() { + // return veryComplex(1, 2, 3, 4, 5) + 6 + // } + + b.beginReturn(); + b.beginAddOperation(); + b.emitConstObject(6L); + b.beginVeryComplexOperation(); + b.emitConstObject(1L); + b.emitConstObject(2L); + b.emitConstObject(3L); + b.emitConstObject(4L); + b.emitConstObject(5L); + b.endVeryComplexOperation(); + b.endAddOperation(); + b.endReturn(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index cb16bcf7948d..5308f34211e7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -129,6 +129,13 @@ public static CodeTree createTransferToInterpreter() { return builder.build(); } + public static CodeTree createInCompiledCode() { + ProcessorContext context = ProcessorContext.getInstance(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.startStaticCall(context.getTypes().CompilerDirectives, "inCompiledCode").end(); + return builder.build(); + } + public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) { TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); ExecutableElement constructor = findConstructor(superClass); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java new file mode 100644 index 000000000000..88b524bb2ffe --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java @@ -0,0 +1,176 @@ +package com.oracle.truffle.dsl.processor.operations; + +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; + +public abstract class Argument { + + public final int length; + + protected Argument(int length) { + this.length = length; + } + + public abstract CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value); + + public abstract CodeTree createReadCode(ExecuteVariables vars, CodeTree offset); + + public CodeTree createReadCode(ExecuteVariables vars, int offset) { + return createReadCode(vars, CodeTreeBuilder.createBuilder().variable(vars.bci).string(" + " + offset).build()); + } + + public boolean isImplicit() { + return false; + } + + public abstract TypeMirror toBuilderArgumentType(); + + public static class Integer extends Argument { + public Integer(int length) { + super(length); + assert length == 1 || length == 2; + } + + @Override + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement(); + if (length == 1) { + b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); + b.cast(ProcessorContext.getInstance().getType(byte.class)); + b.variable(value); + } else { + b.startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.variable(vars.bci); + b.startGroup(); + b.cast(ProcessorContext.getInstance().getType(byte.class)); + b.variable(value); + b.end(2); + } + b.end(); + return b.build(); + } + + @Override + public TypeMirror toBuilderArgumentType() { + return ProcessorContext.getInstance().getType(int.class); + } + + @Override + public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { + if (length == 1) { + return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").tree(offset).string("]").build(); + } else { + return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // + .variable(vars.bc) // + .tree(offset) // + .end().build(); + } + } + } + + public static class VarArgsCount extends Integer { + + private final int minCount; + + public VarArgsCount(int minCount) { + super(1); + this.minCount = minCount; + } + + @Override + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement(); + b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); + b.cast(ProcessorContext.getInstance().getType(byte.class)); + b.startParantheses(); + b.variable(vars.numChildren).string(" - " + minCount); + b.end(2); + return b.build(); + } + + @Override + public boolean isImplicit() { + return true; + } + } + + public static class BranchTarget extends Argument { + + public BranchTarget() { + super(2); + } + + @Override + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement(); + if (((DeclaredType) value.getType()).asElement().getSimpleName().toString().equals("BuilderOperationLabel")) { + b.startCall(value.getName(), "putValue"); + } else { + b.startCall("((BuilderOperationLabel) " + value.getName() + ")", "putValue"); + + } + b.variable(vars.bc); + b.variable(vars.bci); + b.end(2); + return b.build(); + } + + @Override + public TypeMirror toBuilderArgumentType() { + return ProcessorContext.getInstance().getTypes().OperationLabel; + } + + @Override + public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // + .variable(vars.bc) // + .tree(offset) // + .end().build(); + } + } + + public static class Const extends Argument { + public Const() { + super(2); + } + + @Override + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement(); + b.startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.variable(vars.bci); + b.startGroup().string("(short) "); + b.startCall(vars.consts, "add"); + b.variable(value); + b.end(4); + return b.build(); + } + + @Override + public TypeMirror toBuilderArgumentType() { + return ProcessorContext.getInstance().getType(Object.class); + } + + @Override + public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder().variable(vars.consts).string("[")// + .startCall("LE_BYTES", "getShort") // + .variable(vars.bc) // + .tree(offset) // + .end().string("]").build(); + } + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 1bee78d18b71..ed0c19013492 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -1,426 +1,438 @@ package com.oracle.truffle.dsl.processor.operations; -import javax.lang.model.element.ExecutableElement; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.*; + +import java.util.List; + import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; + +public abstract class Instruction { -abstract class Instruction { + public final String name; + public final int id; + public final Argument[] arguments; - static class ExecutorVariables { + public static class ExecuteVariables { + CodeVariableElement bc; CodeVariableElement bci; CodeVariableElement nextBci; - CodeVariableElement bc; - CodeVariableElement consts; - CodeVariableElement sp; - CodeVariableElement funArgs; + CodeVariableElement frame; + CodeVariableElement sp; + CodeVariableElement consts; CodeVariableElement returnValue; + CodeVariableElement maxStack; + } - CodeVariableElement[] arguments; - CodeVariableElement[] children; - CodeVariableElement result; - - public ExecutorVariables(CodeVariableElement bci, CodeVariableElement nextBci, CodeVariableElement bc, CodeVariableElement consts, CodeVariableElement sp, CodeVariableElement funArgs, - CodeVariableElement frame, CodeVariableElement returnValue) { - this.bci = bci; - this.nextBci = nextBci; - this.bc = bc; - this.consts = consts; - this.sp = sp; - this.funArgs = funArgs; - this.frame = frame; - this.returnValue = returnValue; - this.arguments = null; - this.children = null; - this.result = null; - } - + public Instruction(String name, int id, Argument... arguments) { + this.name = name; + this.id = id; + this.arguments = arguments; } - enum ArgumentType { - BYTE(1), - SHORT(2), - JUMP_TARGET(2), - LOCAL(2), - FUN_ARG(2), - LOCAL_INDEX(2), - CONSTANT_POOL(2); - - public final int length; - - public TypeMirror toType(ProcessorContext context, TruffleTypes types) { - switch (this) { - case BYTE: - return context.getType(byte.class); - case LOCAL: - case FUN_ARG: - case LOCAL_INDEX: - case SHORT: - return context.getType(short.class); - case JUMP_TARGET: - return types.OperationLabel; - case CONSTANT_POOL: - return context.getType(Object.class); - default: - throw new IllegalArgumentException(this.toString()); - } + public int length() { + int len = 1; + for (Argument arg : getArgumentTypes()) { + len += arg.length; } + return len; + } - private ArgumentType(int length) { - this.length = length; - } - - public TypeMirror toExecType(ProcessorContext context, TruffleTypes types) { - switch (this) { - case BYTE: - return context.getType(byte.class); - case SHORT: - case JUMP_TARGET: - case LOCAL_INDEX: - return context.getType(short.class); - case LOCAL: - case FUN_ARG: - case CONSTANT_POOL: - return context.getType(Object.class); - default: - throw new IllegalArgumentException(this.toString()); - } - } + public List getArgumentTypes() { + return List.of(arguments); + } - CodeTree createReaderCode(ExecutorVariables vars, CodeTree offset) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - switch (this) { - case BYTE: - b.variable(vars.bc).string("[").tree(offset).string("]"); - break; - case SHORT: - case JUMP_TARGET: - case LOCAL_INDEX: - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.tree(offset); - b.end(); - break; - case CONSTANT_POOL: - b.variable(vars.consts); - b.string("["); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.tree(offset); - b.end(); - b.string("]"); - break; - case FUN_ARG: - b.variable(vars.funArgs); - b.string("["); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.tree(offset); - b.end(); - b.string("]"); - break; - case LOCAL: - b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "getValue"); - b.startGroup(); - b.string("maxStack + "); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.tree(offset); - b.end(3); - break; - default: - throw new IllegalArgumentException(this.toString()); - } - return b.build(); - } + public abstract CodeTree createPushCountCode(BuilderVariables vars); - CodeTree createDumperReaderCode(CodeVariableElement varBc, CodeTree offset) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - switch (this) { - case BYTE: - b.variable(varBc).string("[").tree(offset).string("]"); - break; - case SHORT: - case JUMP_TARGET: - case LOCAL_INDEX: - case FUN_ARG: - case CONSTANT_POOL: - case LOCAL: - b.startCall("LE_BYTES", "getShort"); - b.variable(varBc); - b.tree(offset); - b.end(); - break; - default: - throw new IllegalArgumentException(this.toString()); - } - return b.build(); - } + protected abstract CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2); - CodeTree createDumperCode(CodeVariableElement varBc, CodeTree offset, CodeVariableElement sb) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public abstract CodeTree createExecuteCode(ExecuteVariables vars); - b.startStatement(); - b.startCall(sb, "append"); - b.startCall("String", "format"); - switch (this) { - case BYTE: - case SHORT: - case LOCAL: - case LOCAL_INDEX: - case FUN_ARG: - case CONSTANT_POOL: - b.doubleQuote("%d "); - break; - case JUMP_TARGET: - b.doubleQuote("%04x "); - break; - default: - throw new IllegalArgumentException(this.toString()); - } - b.tree(createDumperReaderCode(varBc, offset)); - b.end(3); + public CodeTree createExecuteEpilogue(ExecuteVariables vars) { - return b.build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (isNormalControlFlow()) { + b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); } - } - final int opcodeNumber; - final ArgumentType[] arguments; - final int stackPops; - final int stackPushes; + b.statement("break"); - protected Instruction(int opcodeNumber, int stackPops, int stackPushes, ArgumentType... arguments) { - this.opcodeNumber = opcodeNumber; - this.stackPops = stackPops; - this.stackPushes = stackPushes; - this.arguments = arguments; + return b.build(); } - public int length() { - int l = 1; - for (ArgumentType arg : arguments) { - l += arg.length; - } - return l; + public CodeTree createBreakCode(ExecuteVariables vars) { + return CodeTreeBuilder.createBuilder().statement("break").build(); } - public boolean isDivergent() { - return false; + public boolean isNormalControlFlow() { + return true; } - CodeTree createEmitterCode( - TruffleTypes types, - Operation.EmitterVariables vars, - String... varArguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] argValues) { - b.lineComment("opcode"); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // TODO: support multibyte ops - OperationGeneratorUtils.buildWriteByte(b, Integer.toString(opcodeNumber), vars.bc, vars.bci); + b.startStatement(); + b.variable(vars.bc).string("[").variable(vars.bci).string("++]"); + b.string(" = "); + b.string("" + id + " /* " + name + " */"); + b.end(); + assert argValues.length == arguments.length; for (int i = 0; i < arguments.length; i++) { - b.lineComment("argument" + i); - String argv = varArguments[i]; - switch (arguments[i]) { - case BYTE: - OperationGeneratorUtils.buildWriteByte(b, argv, vars.bc, vars.bci); - break; - case LOCAL: - case LOCAL_INDEX: - case FUN_ARG: - case SHORT: - OperationGeneratorUtils.buildWriteShort(b, "(short) " + argv, vars.bc, vars.bci); - break; - case CONSTANT_POOL: - b.declaration("int", "argidx_" + i, CodeTreeBuilder.createBuilder().startCall(CodeTreeBuilder.singleVariable(vars.consts), "add").string(argv).end().build()); - OperationGeneratorUtils.buildWriteShort(b, "(short) argidx_" + i, vars.bc, vars.bci); - break; - case JUMP_TARGET: - b.declaration(types.BuilderOperationLabel, "lbl_" + i, "(" + types.BuilderOperationLabel.asElement().getSimpleName() + ") " + argv); - b.startStatement().startCall("lbl_" + i, "putValue").variable(vars.bc).variable(vars.bci).end(2); - b.startAssign(vars.bci).variable(vars.bci).string("+ 2").end(); - break; - default: - throw new IllegalArgumentException("unknown argument type " + arguments[i]); - } + b.tree(arguments[i].createBuildCode(vars, argValues[i])); + b.startAssign(vars.bci).variable(vars.bci).string(" + " + arguments[i].length).end(); } return b.build(); } - abstract CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars); + abstract static class SimpleInstruction extends Instruction { - CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); - return b.build(); - } + private final int pushCount; + private final int popCount; - static class StoreLocal extends Instruction { - protected StoreLocal(int opcodeNumber) { - super(opcodeNumber, 1, 0, ArgumentType.LOCAL_INDEX); + public SimpleInstruction(String name, int id, int pushCount, int popCount, Argument... arguments) { + super(name, id, arguments); + this.pushCount = pushCount; + this.popCount = popCount; } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("" + pushCount); + } + + @Override + public CodeTree createExecuteEpilogue(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); - b.startCall(CodeTreeBuilder.singleVariable(vars.frame), "setObject"); - b.startGroup().string("maxStack + ").variable(vars.arguments[0]).end(); - b.variable(vars.children[0]); - b.end(2); + for (int i = 0; i < (popCount - pushCount); i++) { + createClearStackSlot(vars, i); + } + b.startAssign(vars.sp).variable(vars.sp).string(" + " + (pushCount - popCount)).end(); + b.tree(super.createExecuteEpilogue(vars)); return b.build(); } } - static class JumpUncond extends Instruction { - protected JumpUncond(int opcodeNumber) { - super(opcodeNumber, 0, 0, ArgumentType.JUMP_TARGET); + public static class Pop extends SimpleInstruction { + public Pop(int id) { + super("pop", id, 0, 1); } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.nextBci).tree(OperationGeneratorUtils.buildReadShort(vars.bc, vars.bci.getName() + " + 1")).end(); - return b.build(); + public CodeTree createExecuteCode(ExecuteVariables vars) { + return null; } @Override - CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { - return null; + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("-1"); } } - static class JumpFalse extends Instruction { - protected JumpFalse(int opcodeNumber) { - super(opcodeNumber, 1, 0, ArgumentType.JUMP_TARGET); + public static class BranchFalse extends SimpleInstruction { + public BranchFalse(int id) { + super("br.false", id, 0, 1, new Argument.BranchTarget()); } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createExecuteCode(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().string("(boolean) ").variable(vars.children[0]).end(); + b.declaration("Object", "condition", createReadStack(vars, 0)); + b.startIf().string("(boolean) condition").end(); b.startBlock(); b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); - b.end(); - b.startElseBlock(); - b.startAssign(vars.nextBci).variable(vars.arguments[0]).end(); + b.end().startElseBlock(); + b.startAssign(vars.nextBci).tree(arguments[0].createReadCode(vars, 1)).end(); b.end(); return b.build(); } @Override - CodeTree createNextBciCode(TruffleTypes types, ExecutorVariables vars) { - return null; + public boolean isNormalControlFlow() { + return false; + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("-1"); } } - static class Pop extends Instruction { - protected Pop(int opcodeNumber) { - super(opcodeNumber, 1, 0); + public static class Branch extends SimpleInstruction { + public Branch(int id) { + super("br", id, 0, 0, new Argument.BranchTarget()); } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createExecuteCode(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().variable(vars.sp).string(" -= 1").end(); + + b.startAssign(vars.nextBci).tree(arguments[0].createReadCode(vars, 1)).end(); + return b.build(); } + @Override + public boolean isNormalControlFlow() { + return false; + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("0"); + } } - static class Return extends Instruction { - protected Return(int opcodeNumber) { - super(opcodeNumber, 1, 0); + public static class ConstObject extends SimpleInstruction { + public ConstObject(int id) { + super("const", id, 1, 0, new Argument.Const()); } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createExecuteCode(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.returnValue).variable(vars.children[0]).end(); - b.statement("break loop"); + + b.tree(createWriteStackObject(vars, 1, arguments[0].createReadCode(vars, 1))); + return b.build(); } @Override - public boolean isDivergent() { - return true; + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("1"); } } - static abstract class SimplePushInstruction extends Instruction { - protected SimplePushInstruction(int opcodeNumber, ArgumentType... arguments) { - super(opcodeNumber, 0, 1, arguments); + public static class Return extends SimpleInstruction { + public Return(int id) { + super("ret", id, 0, 1); } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createExecuteCode(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.result).variable(vars.arguments[0]).end(); + + b.startAssign(vars.returnValue).tree(createReadStack(vars, 0)).end(); + return b.build(); } - } - static class ConstObject extends SimplePushInstruction { - protected ConstObject(int opcodeNumber) { - super(opcodeNumber, ArgumentType.CONSTANT_POOL); + @Override + public CodeTree createExecuteEpilogue(ExecuteVariables vars) { + return CodeTreeBuilder.createBuilder().statement("break loop").build(); + } + + @Override + public boolean isNormalControlFlow() { + return false; + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("0"); } } - static class LoadLocal extends SimplePushInstruction { - protected LoadLocal(int opcodeNumber) { - super(opcodeNumber, ArgumentType.LOCAL); + public static class LoadArgument extends SimpleInstruction { + public LoadArgument(int id) { + super("ldarg", id, 1, 0, new Argument.Integer(2)); + } + + @Override + public CodeTree createExecuteCode(ExecuteVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); + + CodeTree val = CodeTreeBuilder.createBuilder()// + .startCall(vars.frame, "getArguments").end()// + .string("[index]").build(); + + b.tree(createWriteStackObject(vars, 1, val)); + + return b.build(); + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("1"); } } - static class LoadArgument extends SimplePushInstruction { - protected LoadArgument(int opcodeNumber) { - super(opcodeNumber, ArgumentType.FUN_ARG); + public static class LoadLocal extends SimpleInstruction { + public LoadLocal(int id) { + super("ldloc", id, 1, 0, new Argument.Integer(2)); + } + + @Override + public CodeTree createExecuteCode(ExecuteVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); + + CodeTree val = createReadLocal(vars, CodeTreeBuilder.singleString("index")); + + b.tree(createWriteStackObject(vars, 1, val)); + + return b.build(); + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("1"); } } - static class Custom extends Instruction { - private final TypeElement type; + public static class StoreLocal extends SimpleInstruction { + public StoreLocal(int id) { + super("starg", id, 0, 1, new Argument.Integer(2)); + } + + @Override + public CodeTree createExecuteCode(ExecuteVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); + + CodeTree val = createReadStack(vars, 0); + + b.tree(createWriteLocal(vars, CodeTreeBuilder.singleString("index"), val)); + + return b.build(); + } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("-1"); + } + + @Override + public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] argValues) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - private VariableElement uncachedInstance; + b.startIf().variable(vars.maxLocal).string(" < ").variable(argValues[0]).end(); + b.startAssign(vars.maxLocal).variable(argValues[0]).end(); + b.tree(super.createBuildCode(vars, argValues)); - public TypeElement getType() { - return type; + return b.build(); } + } + + public static class Custom extends Instruction { - protected Custom(int opcodeNumber, TypeElement type, ExecutableElement mainMethod) { - super(opcodeNumber, mainMethod.getParameters().size(), 1); + public final int stackPops; + public final boolean isVarArgs; + public final TypeElement type; + + private CodeVariableElement uncachedInstance; + + public Custom(String name, int id, int stackPops, boolean isVarArgs, TypeElement type, Argument... arguments) { + super(name, id, arguments); + this.stackPops = stackPops; + this.isVarArgs = isVarArgs; this.type = type; } - public void setUncachedInstance(VariableElement uncachedInstance) { + @Override + public int length() { + return super.length() + (isVarArgs ? 1 : 0); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("1"); // TODO: support void + + } + + public void setUncachedInstance(CodeVariableElement uncachedInstance) { this.uncachedInstance = uncachedInstance; } @Override - CodeTree createExecutorCode(TruffleTypes types, ExecutorVariables vars) { + public CodeTree createExecuteEpilogue(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.result); - b.startCall(CodeTreeBuilder.createBuilder().staticReference(uncachedInstance).build(), "execute"); - for (CodeVariableElement child : vars.children) { - b.variable(child); + + for (int i = 0; i < stackPops - 1; i++) { + createClearStackSlot(vars, i); } - b.end(); - b.end(); + + b.startAssign(vars.sp).variable(vars.sp).string(" + " + (1 - stackPops)).end(); + + b.tree(super.createExecuteEpilogue(vars)); + + return b.build(); + } + + @Override + public CodeTree createExecuteCode(ExecuteVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + CodeTree[] vals = new CodeTree[stackPops]; + if (isVarArgs) { + b.declaration("byte", "varArgCount", arguments[0].createReadCode(vars, 1)); + b.declaration("Object[]", "varArgs", "new Object[varArgCount]"); + + b.startFor().string("int i = 0; i < varArgCount; i++").end(); + b.startBlock(); + + String stackIndex = "i - varArgCount + 1"; + + b.startStatement(); + b.string("varArgs[i] = "); + b.tree(createReadStack(vars, CodeTreeBuilder.singleString(stackIndex))); + b.end(); + + b.end(); + + vals[stackPops - 1] = CodeTreeBuilder.singleString("varArgs"); + + for (int i = 1; i < stackPops; i++) { + String stackIndex2 = "- (varArgCount + " + i + ")"; + vals[vals.length - 1 - i] = createReadStack(vars, CodeTreeBuilder.singleString(stackIndex2)); + } + + } else { + for (int i = 0; i < stackPops; i++) { + vals[vals.length - 1 - i] = createReadStack(vars, -i); + } + } + + int resultOffset = 1 - stackPops; + + CodeTree instance = CodeTreeBuilder.createBuilder() // + .staticReference(uncachedInstance) // + .build(); + + CodeTreeBuilder bCall = CodeTreeBuilder.createBuilder(); + bCall.startCall(instance, "execute"); + for (int i = 0; i < stackPops; i++) { + bCall.tree(vals[i]); + } + bCall.end(2); + + b.tree(createWriteStackObject(vars, resultOffset, bCall.build())); + return b.build(); } + + @Override + protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + return CodeTreeBuilder.singleString("(1 - " + vars.numChildren.getName() + ")"); + } + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index b60303dce623..43039d712ed6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -1,399 +1,417 @@ package com.oracle.truffle.dsl.processor.operations; -import java.util.ArrayList; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.getTypes; + import java.util.Collection; +import java.util.List; import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Instruction.ArgumentType; - -abstract class Operation { - - static class EmitterVariables { - final CodeExecutableElement self; - final CodeVariableElement bc; - final CodeVariableElement bci; - final CodeVariableElement consts; - final CodeVariableElement children; - final CodeVariableElement arguments; - - public EmitterVariables(CodeExecutableElement self, CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement consts, CodeVariableElement children, - CodeVariableElement arguments) { - this.self = self; - this.bc = bc; - this.bci = bci; - this.consts = consts; - this.children = children; - this.arguments = arguments; - } - } - - static class CtorVariables { - final CodeVariableElement children; - final CodeVariableElement arguments; - final CodeVariableElement returnsValue; - final CodeVariableElement maxStack; - final CodeVariableElement maxLocals; - - public CtorVariables(CodeVariableElement children, CodeVariableElement arguments, CodeVariableElement returnsValue, CodeVariableElement maxStack, CodeVariableElement maxLocals) { - this.children = children; - this.arguments = arguments; - this.returnsValue = returnsValue; - this.maxStack = maxStack; - this.maxLocals = maxLocals; - } - } +public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; - public static final int RETURNS_VALUE_NEVER = 0; - public static final int RETURNS_VALUE_ALWAYS = 1; - public static final int RETURNS_VALUE_DIVERGE = 2; - - protected final String name; - protected final int type; - protected final int children; - protected final Instruction[] instructions; - - public static final int COMMON_OPCODE_JUMP_UNCOND = 0; - public static final int COMMON_OPCODE_JUMP_FALSE = 1; - public static final int COMMON_OPCODE_POP = 2; - protected static final int NUM_COMMON_OPCODES = 3; + public final OperationsBuilder builder; + public final String name; + public final int id; + public final int children; - protected Instruction[] commonInstructions; - - static Instruction[] createCommonOpcodes(int start) { - Instruction[] commonOpcodes = new Instruction[NUM_COMMON_OPCODES]; - commonOpcodes[COMMON_OPCODE_JUMP_UNCOND] = new Instruction.JumpUncond(start); - commonOpcodes[COMMON_OPCODE_JUMP_FALSE] = new Instruction.JumpFalse(start + 1); - commonOpcodes[COMMON_OPCODE_POP] = new Instruction.Pop(start + 2); - return commonOpcodes; - } - - protected Operation(String name, int type, int children, Instruction... opcodes) { + protected Operation(OperationsBuilder builder, String name, int id, int children) { + this.builder = builder; this.name = name; - this.type = type; + this.id = id; this.children = children; - this.instructions = opcodes; } - public void setCommonInstructions(Instruction[] commonInstructions) { - this.commonInstructions = commonInstructions; + public final boolean isVariableChildren() { + return children == VARIABLE_CHILDREN; } - public String getName() { - return name; - } + public static class BuilderVariables { + CodeVariableElement bc; + CodeVariableElement bci; + CodeVariableElement consts; - public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { - ArrayList arr = new ArrayList<>(); + CodeVariableElement stackUtility; - for (Instruction.ArgumentType art : getArgumentTypes()) { - arr.add(art.toType(context, types)); - } + CodeVariableElement lastChildPushCount; + CodeVariableElement childIndex; + CodeVariableElement numChildren; + CodeVariableElement[] arguments; - return arr.toArray(new TypeMirror[arr.size()]); + CodeVariableElement curStack; + CodeVariableElement maxStack; + CodeVariableElement maxLocal; } - public Collection getArgumentTypes() { - ArrayList arr = new ArrayList<>(); - for (Instruction inst : instructions) { - for (Instruction.ArgumentType art : inst.arguments) { - arr.add(art); - } - } + public int minimumChildren() { + assert isVariableChildren() : "should only be called for variadics"; + return 0; + } - return arr; + public List getArguments() { + return List.of(); } - public boolean hasChildren() { - return children != 0; + public final List getBuilderArgumentTypes() { + return getArguments().stream().map(x -> x.toBuilderArgumentType()).toList(); } - public int getType() { - return type; + public CodeTree createBeginCode(BuilderVariables vars) { + return null; } - public boolean keepsChildValues() { - return false; + public CodeTree createAfterChildCode(BuilderVariables vars) { + return null; } - public abstract CodeTree createCtorCode(TruffleTypes types, CtorVariables vars); + public CodeTree createBeforeChildCode(BuilderVariables vars) { + return null; + } + + public CodeTree createEndCode(BuilderVariables vars) { + return null; + } - public abstract CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars); + public abstract CodeTree createPushCountCode(BuilderVariables vars); - static class SimpleOperation extends Operation { + public static class Custom extends Operation { + final Instruction.Custom instruction; - SimpleOperation(String name, int type, Instruction opcode) { - super(name, type, opcode.stackPops, opcode); + protected Custom(OperationsBuilder builder, String name, int id, int children, Instruction.Custom instruction) { + super(builder, name, id, instruction.isVarArgs ? VARIABLE_CHILDREN : children); + this.instruction = instruction; } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - for (int i = 0; i < children; i++) { - OperationGeneratorUtils.buildChildCall(b, Integer.toString(i), vars); - } - - String[] arguments = new String[instructions[0].arguments.length]; - - for (int i = 0; i < arguments.length; i++) { - arguments[i] = vars.arguments.getName() + "[" + i + "]"; - } - - b.tree(instructions[0].createEmitterCode(types, vars, arguments)); - - return b.build(); + public CodeTree createPushCountCode(BuilderVariables vars) { + return instruction.createPushCountCode(vars); } @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - // returnsValue - - for (int i = 0; i < children; i++) { - b.startAssert().variable(vars.children).string("[" + i + "].").variable(vars.returnsValue).string(" != " + RETURNS_VALUE_NEVER).end(); - } - - b.startAssign("this", vars.returnsValue); - b.string(this.instructions[0].stackPushes > 0 ? "" + RETURNS_VALUE_ALWAYS : "" + RETURNS_VALUE_NEVER); - b.end(); + public List getArguments() { + return instruction.getArgumentTypes(); + } - return b.build(); + @Override + public CodeTree createEndCode(BuilderVariables vars) { + return createEmitInstruction(vars, instruction, vars.arguments); } @Override - public boolean keepsChildValues() { - return true; + public int minimumChildren() { + if (instruction.isVarArgs) { + return instruction.stackPops - 1; + } else { + return super.minimumChildren(); + } } } - static class CustomOperation extends SimpleOperation { + public static class Simple extends Operation { - public CustomOperation(String name, int type, Instruction.Custom opcode) { - super(name, type, opcode); - } + private final Instruction instruction; - public Instruction.Custom getCustomInstruction() { - return (Instruction.Custom) instructions[0]; + protected Simple(OperationsBuilder builder, String name, int id, int children, Instruction instruction) { + super(builder, name, id, children); + this.instruction = instruction; } - } + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - static abstract class PseudoOperation extends Operation { - public PseudoOperation(String name, int type, int children) { - super(name, type, children); - } - } + b.tree(createEmitInstruction(vars, instruction, vars.arguments)); - static class Block extends PseudoOperation { - public Block(int type) { - super("Block", type, VARIABLE_CHILDREN); + return b.build(); } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public CodeTree createPushCountCode(BuilderVariables vars) { + return this.instruction.createPushCountCode(vars); + } - b.startFor().string("int i = 0; i < " + vars.children.getName() + ".length; i++").end(); - b.startBlock(); - OperationGeneratorUtils.buildChildCall(b, "i", vars); - b.end(); + @Override + public List getArguments() { + return instruction.getArgumentTypes(); + } + } - return b.build(); + public static class Block extends Operation { + protected Block(OperationsBuilder builder, int id) { + super(builder, "Block", id, VARIABLE_CHILDREN); } @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createBeforeChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().variable(vars.children).string(".length > 0").end(); - b.startBlock(); - - b.startAssign("this", vars.returnsValue); - b.variable(vars.children).string("[").variable(vars.children).string(".length - 1].").variable(vars.returnsValue); - b.end(2); + b.startIf().variable(vars.childIndex).string(" != 0").end(); + b.startBlock(); // { - b.startElseBlock(); + b.tree(createPopLastChildCode(vars)); - b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER); - b.end(2); + b.end(); // } return b.build(); } + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleVariable(vars.lastChildPushCount); + } } - static class IfThen extends PseudoOperation { - public IfThen(int type) { - super("IfThen", type, 2); + public static class IfThen extends Operation { + protected IfThen(OperationsBuilder builder, int id) { + super(builder, "IfThen", id, 2); } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + public CodeTree createAfterChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // <> - OperationGeneratorUtils.buildChildCall(b, "0", vars); + b.startIf().variable(vars.childIndex).string(" == 0").end(); + b.startBlock(); + { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - // jump_false end - OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); - b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); - b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - // <> - OperationGeneratorUtils.buildChildCall(b, "1", vars); + // utilstack: ... + b.tree(createPushUtility(varEndLabel, vars)); + // utilstack ..., endLabel - // end: - OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); + } + b.end().startElseBlock(); + { + b.tree(createPopLastChildCode(vars)); - return b.build(); - } + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + // utilstack ..., endLabel + b.tree(createPopUtility(varEndLabel, vars)); + // utilstack ... - b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + b.tree(createEmitLabel(vars, varEndLabel)); + } + b.end(); return b.build(); } + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } } - static class IfThenElse extends PseudoOperation { - public IfThenElse(int type) { - super("IfThenElse", type, 3); + public static class IfThenElse extends Operation { + + private final boolean hasValue; + + public IfThenElse(OperationsBuilder builder, int id, boolean hasValue) { + super(builder, hasValue ? "Conditional" : "IfThenElse", id, 3); + this.hasValue = hasValue; } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString(hasValue ? "1" : "0"); + } - // <> - OperationGeneratorUtils.buildChildCall(b, "0", vars); + @Override + public CodeTree createAfterChildCode(BuilderVariables vars) { - // jump_false else - OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); - b.declaration("int", "fwdref_else", CodeTreeBuilder.singleVariable(vars.bci)); - b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + // <> + // brfalse elseLabel // <> - OperationGeneratorUtils.buildChildCall(b, "1", vars); + // br endLabel + // elseLabel: - // jump_uncond end - OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_UNCOND].opcodeNumber, vars.bc, vars.bci); - b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); - b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); + // <> + // endLabel: - // else: - OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_else", vars.bc, vars.bci); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // <> - OperationGeneratorUtils.buildChildCall(b, "2", vars); + b.startIf().variable(vars.childIndex).string(" == 0").end(); + b.startBlock(); + { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - // end: - OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); + b.declaration(getTypes().BuilderOperationLabel, varElseLabel.getName(), createCreateLabel()); - return b.build(); - } + // utilstack: ... + b.tree(createPushUtility(varElseLabel, vars)); + // utilstack ..., elseLabel - @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varElseLabel)); + } + b.end(); + b.startElseIf().variable(vars.childIndex).string(" == 1").end(); + b.startBlock(); // { + { + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); + + if (hasValue) { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + } else { + b.tree(createPopLastChildCode(vars)); + } + + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + + // utilstack ..., elseLabel + b.tree(createPopUtility(varElseLabel, vars)); + // utilstack ... + b.tree(createPushUtility(varEndLabel, vars)); + // utilstack ..., endLabel + + b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(createEmitLabel(vars, varElseLabel)); + } + b.end().startElseBlock(); + { + + if (hasValue) { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + } else { + b.tree(createPopLastChildCode(vars)); + } - b.startAssert().variable(vars.children).string("[0].").variable(vars.returnsValue).string("!= " + RETURNS_VALUE_NEVER).end(); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration("int", "rv_1", "children[1].returnsValue"); - b.declaration("int", "rv_2", "children[2].returnsValue"); + // utilstack ..., endLabel + b.tree(createPopUtility(varEndLabel, vars)); + // utilstack ... + + b.tree(createEmitLabel(vars, varEndLabel)); + } + b.end(); - b.startIf().string("rv_1 == " + RETURNS_VALUE_NEVER + " || rv_2 == " + RETURNS_VALUE_NEVER).end(); - b.startBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(2); - b.startElseBlock().startAssign(vars.returnsValue).string("" + RETURNS_VALUE_ALWAYS).end(2); return b.build(); } - } - static class While extends PseudoOperation { - public While(int type) { - super("While", type, 2); + public static class While extends Operation { + public While(OperationsBuilder builder, int id) { + super(builder, "While", id, 2); } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { + public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // start: - b.declaration("int", "backref_start", CodeTreeBuilder.singleVariable(vars.bci)); - - // <> - OperationGeneratorUtils.buildChildCall(b, "0", vars); - - // jump_false end - OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_FALSE].opcodeNumber, vars.bc, vars.bci); - b.declaration("int", "fwdref_end", CodeTreeBuilder.singleVariable(vars.bci)); - b.startAssign(vars.bci).variable(vars.bci).string(" + 2").end(); - - // <> - OperationGeneratorUtils.buildChildCall(b, "1", vars); + CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); + b.declaration(getTypes().BuilderOperationLabel, varStartLabel.getName(), createCreateLabel()); - // jump start - OperationGeneratorUtils.buildWriteByte(b, "" + commonInstructions[COMMON_OPCODE_JUMP_UNCOND].opcodeNumber, vars.bc, vars.bci); - OperationGeneratorUtils.buildWriteShort(b, "backref_start", vars.bc, vars.bci); + b.tree(createEmitLabel(vars, varStartLabel)); - // end: - OperationGeneratorUtils.buildWriteForwardReference(b, "fwdref_end", vars.bc, vars.bci); + b.tree(createPushUtility(varStartLabel, vars)); + // utilstack: ..., startLabel return b.build(); } @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { + public CodeTree createAfterChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + b.startIf().variable(vars.childIndex).string(" == 0").end(); + b.startBlock(); + { + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + + // utilstack: ..., startLabel + b.tree(createPushUtility(varEndLabel, vars)); + // utilstack ..., startLabel, endLabel + + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); + } + b.end().startElseBlock(); + { + b.tree(createPopLastChildCode(vars)); + + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); + + // utilstack ..., startLabel, endLabel + b.tree(createPopUtility(varEndLabel, vars)); + b.tree(createPopUtility(varStartLabel, vars)); + // utilstack ... + + b.tree(createEmitInstruction(vars, builder.commonBranch, varStartLabel)); + + b.tree(createEmitLabel(vars, varEndLabel)); + } + + b.end(); return b.build(); } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } } - static class Label extends PseudoOperation { - public Label(int type) { - super("Label", type, 0); + public static class Label extends Operation { + public Label(OperationsBuilder builder, int id) { + super(builder, "Label", id, 0); } @Override - public CodeTree createEmitterCode(TruffleTypes types, EmitterVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration(types.BuilderOperationLabel, "lbl", CodeTreeBuilder.createBuilder().cast(types.BuilderOperationLabel).variable(vars.arguments).string("[0]").build()); - b.startStatement().startCall("lbl", "resolve").variable(vars.bc).variable(vars.bci).end(2); - - return b.build(); + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); } @Override - public TypeMirror[] getBuilderArgumentTypes(ProcessorContext context, TruffleTypes types) { - return new TypeMirror[]{types.OperationLabel}; + public CodeTree createEndCode(BuilderVariables vars) { + return createEmitLabel(vars, CodeTreeBuilder.singleString("((BuilderOperationLabel) " + vars.arguments[0].getName() + ")")); } @Override - public CodeTree createCtorCode(TruffleTypes types, CtorVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public List getArguments() { + return List.of(new Argument.BranchTarget()); + } + } + + protected static final CodeTree createPopUtility(TypeMirror type, BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "pop").end().build(); + } - b.startAssign("this", vars.returnsValue).string("" + RETURNS_VALUE_NEVER).end(); + protected static final CodeTree createPopUtility(CodeVariableElement target, BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().declaration(target.asType(), target.getName(), createPopUtility(target.asType(), vars)).build(); + } - return b.build(); - } + protected static final CodeTree createPushUtility(CodeVariableElement target, BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().startStatement().startCall(vars.stackUtility, "push").variable(target).end(2).build(); + } + + protected final CodeTree createPopLastChildCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); + b.startBlock(); // { + + b.tree(createEmitInstruction(vars, builder.commonPop)); + + b.end(); // } + return b.build(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 1e7ba4d66218..5fbba2d5407b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -1,81 +1,88 @@ package com.oracle.truffle.dsl.processor.operations; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class OperationGeneratorUtils { - static void buildWriteByte( - CodeTreeBuilder b, - String value, - CodeVariableElement varBc, - CodeVariableElement varBci) { - b.startStatement(); - b.variable(varBc).string("[").variable(varBci).string("++] = ", value); - b.end(); + public static TruffleTypes getTypes() { + return ProcessorContext.getInstance().getTypes(); } - static CodeTree buildReadByte( - CodeVariableElement varBc, - String from) { - return CodeTreeBuilder.singleString(varBc.getName() + "[" + from + "]"); + // new + + public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement... arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign(vars.curStack).variable(vars.curStack).string(" + ").tree(instr.createStackEffect(vars, arguments)).end(); + b.startIf().variable(vars.maxStack).string(" < ").variable(vars.curStack).end(); + b.startAssign(vars.maxStack).variable(vars.curStack).end(); + // b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); + b.tree(instr.createBuildCode(vars, arguments)); + return b.build(); + } + + public static CodeTree createCreateLabel() { + return CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderOperationLabel).end().build(); } - static CodeTree buildPop( - CodeVariableElement varStack, - CodeVariableElement varSp) { - return CodeTreeBuilder.createBuilder().variable(varStack).string("[--").variable(varSp).string("]").build(); + public static CodeTree createEmitLabel(BuilderVariables vars, CodeTree label) { + return CodeTreeBuilder.createBuilder().startStatement().startCall(label, "resolve").variable(vars.bc).variable(vars.bci).end(2).build(); } - static CodeTree buildPush( - CodeVariableElement varStack, - CodeVariableElement varSp, - String value) { - return CodeTreeBuilder.createBuilder().startStatement().variable(varStack).string("[").variable(varSp).string("++] = " + value).build(); + public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElement label) { + return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); } - static void buildWriteShort( - CodeTreeBuilder b, - String value, - CodeVariableElement varBc, - CodeVariableElement varBci) { - b.startStatement(); - b.startCall("LE_BYTES", "putShort"); - b.variable(varBc).variable(varBci).string("(short)" + value); - b.end(2); // call, statement + public static CodeTree createClearStackSlot(ExecuteVariables vars, int offset) { + return CodeTreeBuilder.createBuilder() // + .startIf().tree(GeneratorUtils.createInCompiledCode()).end() // + .startBlock() // + .startStatement() // + .startCall(vars.frame, "clear") // + .startGroup().variable(vars.sp).string(" + " + (offset - 1))// + .end(4).build(); + } + + public static CodeTree createReadStack(ExecuteVariables vars, int offset) { + return CodeTreeBuilder.createBuilder() // + .startCall(vars.frame, "getValue") // + .startGroup().variable(vars.sp).string(" + " + (offset - 1)).end()// + .end(2).build(); + } - b.startStatement(); - b.variable(varBci).string(" += 2"); - b.end(); + public static CodeTree createReadStack(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder() // + .startCall(vars.frame, "getValue") // + .startGroup().variable(vars.sp).string(" - 1 + ").tree(offset).end()// + .end(2).build(); } - static CodeTree buildReadShort( - CodeVariableElement varBc, - String from) { - return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort").variable(varBc).string(from).end().build(); + public static CodeTree createWriteStackObject(ExecuteVariables vars, int offset, CodeTree value) { + return CodeTreeBuilder.createBuilder() // + .startStatement().startCall(vars.frame, "setObject") // + .startGroup().variable(vars.sp).string(" + " + (offset - 1)).end()// + .tree(value) // + .end(3).build(); } - static void buildWriteForwardReference( - CodeTreeBuilder b, - String varFwdRef, - CodeVariableElement varBc, - CodeVariableElement varBci) { - b.startStatement(); - b.startCall("LE_BYTES", "putShort"); - b.variable(varBc).string(varFwdRef); - b.startGroup().string("(short) ").variable(varBci).end(); - b.end(2); // call, statement + public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder() // + .startCall(vars.frame, "getValue") // + .startGroup().variable(vars.maxStack).string(" + ").tree(offset).end()// + .end(2).build(); } - static void buildChildCall( - CodeTreeBuilder b, - String i, - Operation.EmitterVariables vars) { - b.startAssign(vars.bci); - b.startCall(vars.children.getSimpleName().toString() + "[" + i + "]", vars.self); - b.variable(vars.bc).variable(vars.bci).variable(vars.consts); - b.end(2); + public static CodeTree createWriteLocal(ExecuteVariables vars, CodeTree offset, CodeTree value) { + return CodeTreeBuilder.createBuilder() // + .startStatement().startCall(vars.frame, "setObject") // + .startGroup().variable(vars.maxStack).string(" + ").tree(offset).end() // + .tree(value) // + .end(3).build(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java new file mode 100644 index 000000000000..22292a7c23e8 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java @@ -0,0 +1,63 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; + +public class OperationsBuilder { + + private int instructionId = 1; + private int operationId = 1; + + public Instruction commonPop; + public Instruction commonBranch; + public Instruction commonBranchFalse; + + public final ArrayList instructions = new ArrayList<>(); + public final ArrayList operations = new ArrayList<>(); + + public OperationsBuilder() { + createCommonInstructions(); + createBuiltinOperations(); + } + + private void createCommonInstructions() { + commonPop = add(new Instruction.Pop(instructionId++)); + commonBranch = add(new Instruction.Branch(instructionId++)); + commonBranchFalse = add(new Instruction.BranchFalse(instructionId++)); + } + + private void createBuiltinOperations() { + add(new Operation.Block(this, operationId++)); + add(new Operation.IfThen(this, operationId++)); + add(new Operation.IfThenElse(this, operationId++, false)); + add(new Operation.IfThenElse(this, operationId++, true)); + add(new Operation.While(this, operationId++)); + + add(new Operation.Label(this, operationId++)); + add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); + add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new Instruction.ConstObject(instructionId++)))); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new Instruction.LoadArgument(instructionId++)))); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new Instruction.LoadLocal(instructionId++)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new Instruction.StoreLocal(instructionId++)))); + add(new Operation.Simple(this, "Return", operationId++, 1, add(new Instruction.Return(instructionId++)))); + } + + public Instruction add(Instruction elem) { + instructions.add(elem); + return elem; + } + + public Operation add(Operation elem) { + operations.add(elem); + return elem; + } + + public int getNextInstructionId() { + // TODO Auto-generated method stub + return instructionId++; + } + + public int getNextOperationId() { + // TODO Auto-generated method stub + return operationId++; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 3016b09bafac..8f51a9b704d8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -25,18 +25,17 @@ import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeNames; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.operations.Instruction.ArgumentType; -import com.oracle.truffle.dsl.processor.operations.Instruction.ExecutorVariables; -import com.oracle.truffle.dsl.processor.operations.Operation.EmitterVariables; +import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.parser.NodeParser; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -68,27 +67,33 @@ CodeTypeElement createBuilder(String simpleName) { // begin/end or emit methods for (Operation op : m.getOperations()) { - TypeMirror[] args = op.getBuilderArgumentTypes(context, types); - CodeVariableElement[] params = new CodeVariableElement[args.length]; + List args = op.getArguments(); + ArrayList params = new ArrayList<>(); - for (int i = 0; i < params.length; i++) { - params[i] = new CodeVariableElement(args[i], "arg" + i); + for (int i = 0; i < args.size(); i++) { + if (args.get(i).isImplicit()) { + continue; + } + + params.add(new CodeVariableElement(args.get(i).toBuilderArgumentType(), "arg" + i)); } - if (op.hasChildren()) { - CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "begin" + op.getName(), params); + CodeVariableElement[] paramsArr = params.toArray(new CodeVariableElement[params.size()]); + + if (op.children != 0) { + CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "begin" + op.name, paramsArr); typBuilder.add(metBegin); - CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "end" + op.getName()); + CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "end" + op.name); typBuilder.add(metEnd); } else { - CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "emit" + op.getName(), params); + CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "emit" + op.name, paramsArr); typBuilder.add(metEmit); } - if (op instanceof Operation.CustomOperation) { - Operation.CustomOperation customOp = (Operation.CustomOperation) op; - List genNode = createOperationNode(customOp.getCustomInstruction()); + if (op instanceof Operation.Custom) { + Operation.Custom customOp = (Operation.Custom) op; + List genNode = createOperationNode(customOp.instruction); typBuilder.addAll(genNode); } } @@ -124,23 +129,62 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); typBuilderImpl.add(leBytes); - CodeTypeElement builderNodeType = createBuilderImplNode(simpleName + "Node"); - typBuilderImpl.add(builderNodeType); - CodeTypeElement builderLabelImplType = createBuilderLabelImpl(simpleName + "Label"); typBuilderImpl.add(builderLabelImplType); CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(simpleName + "BytecodeNode"); typBuilderImpl.add(builderBytecodeNodeType); - CodeVariableElement childStackField = createStackField("child", generic(context.getTypeElement(ArrayList.class), builderNodeType.asType())); - typBuilderImpl.add(childStackField); + CodeVariableElement fldChildIndexStack = createStackField("childIndex", context.getType(Integer.class)); + typBuilderImpl.add(fldChildIndexStack); + + CodeVariableElement fldArgumentStack = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); + typBuilderImpl.add(fldArgumentStack); + + CodeVariableElement fldTypeStack = createStackField("type", context.getType(Integer.class)); + typBuilderImpl.add(fldTypeStack); + + CodeVariableElement fldUtilityStack = createStackField("utility", context.getType(Object.class)); + typBuilderImpl.add(fldUtilityStack); + + CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + typBuilderImpl.add(fldBc); + { + CodeTreeBuilder b = fldBc.createInitBuilder(); + b.string("new byte[65535]"); + } + + CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lashPush"); + typBuilderImpl.add(fldLastPush); + + CodeVariableElement fldMaxLocal = new CodeVariableElement(context.getType(int.class), "maxLocal"); + typBuilderImpl.add(fldMaxLocal); + + CodeVariableElement fldMaxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); + typBuilderImpl.add(fldMaxStack); - CodeVariableElement argumentStackField = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); - typBuilderImpl.add(argumentStackField); + CodeVariableElement fldCurStack = new CodeVariableElement(context.getType(int.class), "curStack"); + typBuilderImpl.add(fldCurStack); + + CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); + typBuilderImpl.add(fldBci); + + CodeVariableElement fldConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); + typBuilderImpl.add(fldConstPool); + { + CodeTreeBuilder b = fldConstPool.createInitBuilder(); + b.startNew(types.OperationsConstantPool).end(); + } - CodeVariableElement typeStackField = createStackField("type", context.getType(Integer.class)); - typBuilderImpl.add(typeStackField); + BuilderVariables vars = new BuilderVariables(); + vars.bc = fldBc; + vars.bci = fldBci; + vars.lastChildPushCount = fldLastPush; + vars.stackUtility = fldUtilityStack; + vars.consts = fldConstPool; + vars.maxStack = fldMaxStack; + vars.curStack = fldCurStack; + vars.maxLocal = fldMaxLocal; { CodeExecutableElement metReset = new CodeExecutableElement( @@ -149,10 +193,15 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(metReset); CodeTreeBuilder b = metReset.getBuilder(); - b.startStatement().startCall(childStackField.getName(), "clear").end(2); - b.startStatement().startCall(childStackField.getName(), "add").string("new ArrayList<>()").end(2); - b.startStatement().startCall(argumentStackField.getName(), "clear").end(2); - b.startStatement().startCall(typeStackField.getName(), "clear").end(2); + b.startAssign(fldBci).string("0").end(); + b.startAssign(fldCurStack).string("0").end(); + b.startAssign(fldMaxStack).string("0").end(); + b.startAssign(fldMaxLocal).string("-1").end(); + b.startStatement().startCall(fldChildIndexStack.getName(), "clear").end(2); + b.startStatement().startCall(fldChildIndexStack.getName(), "add").string("0").end(2); + b.startStatement().startCall(fldArgumentStack.getName(), "clear").end(2); + b.startStatement().startCall(fldTypeStack.getName(), "clear").end(2); + b.startStatement().startCall(fldTypeStack.getName(), "add").string("0").end(2); } { @@ -162,21 +211,16 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mBuild.getBuilder(); b.startAssert(); - b.string("childStack.size() == 1"); + b.string(fldChildIndexStack.getName() + ".size() == 1"); b.end(); - b.declaration(arrayOf(builderNodeType.asType()), "operations", "childStack.get(0).toArray(new " + builderNodeType.getSimpleName() + "[0])"); - b.declaration(builderNodeType.asType(), "rootNode", "new " + builderNodeType.getSimpleName() + "(0, new Object[0], operations)"); - b.declaration("byte[]", "bc", "new byte[65535]"); - b.declaration(types.OperationsConstantPool, "constPool", "new OperationsConstantPool()"); - b.declaration("int", "len", "rootNode.build(bc, 0, constPool)"); - b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, len)"); + b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, bci)"); b.declaration("Object[]", "cpCopy", "constPool.getValues()"); b.startReturn(); b.startNew(builderBytecodeNodeType.asType()); - b.string("rootNode.maxStack"); - b.string("rootNode.maxLocals"); + b.variable(fldMaxStack); + b.startGroup().variable(fldMaxLocal).string(" + 1").end(); b.string("bcCopy"); b.string("cpCopy"); b.end(2); @@ -193,255 +237,223 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } { - CodeExecutableElement metDoBeginOperation = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doBeginOperation"); - metDoBeginOperation.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - metDoBeginOperation.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); - - CodeTreeBuilder builder = metDoBeginOperation.getBuilder(); + CodeExecutableElement mCreateLabel = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); - builder.statement("typeStack.add(type)"); - builder.statement("childStack.add(new ArrayList<>())"); - builder.statement("argumentStack.add(arguments)"); + CodeTreeBuilder b = mCreateLabel.getBuilder(); + b.startReturn(); + b.startNew(builderLabelImplType.asType()); + b.end(2); - typBuilderImpl.add(metDoBeginOperation); + typBuilderImpl.add(mCreateLabel); } - { - CodeExecutableElement doEndOperationMethod = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEndOperation"); - doEndOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); + CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); + CodeTreeBuilder b = mBeforeChild.getBuilder(); + + CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); + b.declaration("int", varChildIndex.getName(), "childIndexStack.peek()"); - CodeTreeBuilder builder = doEndOperationMethod.getBuilder(); + vars.childIndex = varChildIndex; - builder.statement("int topType = typeStack.pop()"); + b.startSwitch().startCall(fldTypeStack, "peek").end(2); + b.startBlock(); - builder.startAssert(); - builder.string("topType == type"); - builder.end(); + for (Operation parentOp : m.getOperations()) { - builder.statement("Object[] args = argumentStack.pop()"); + CodeTree afterChild = parentOp.createBeforeChildCode(vars); + if (afterChild == null) + continue; - builder.declaration(new ArrayCodeTypeMirror(builderNodeType.asType()), "children", - "childStack.pop().toArray(new " + builderNodeType.getSimpleName() + "[0])"); + b.startCase().string(parentOp.id + " /* " + parentOp.name + " */").end(); + b.startBlock(); - builder.declaration(builderNodeType.asType(), "result", - "new " + builderNodeType.getSimpleName() + "(type, args, children)"); + b.tree(afterChild); - builder.statement("childStack.peek().add(result)"); + b.statement("break"); + b.end(); + } - typBuilderImpl.add(doEndOperationMethod); + b.end(); - } + vars.childIndex = null; + typBuilderImpl.add(mBeforeChild); + } { - CodeExecutableElement doEmitOperationMethod = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEmitOperation"); - doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(int.class), "type")); - doEmitOperationMethod.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); - - CodeTreeBuilder builder = doEmitOperationMethod.getBuilder(); + CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); + CodeTreeBuilder b = mAfterChild.getBuilder(); - builder.declaration(builderNodeType.asType(), "result", - "new " + builderNodeType.getSimpleName() + "(type, arguments, new " + builderNodeType.getSimpleName() + "[0])"); + CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); + b.declaration("int", varChildIndex.getName(), "childIndexStack.pop()"); + b.startStatement().startCall(fldChildIndexStack, "push").string(varChildIndex.getName() + " + 1").end(2); - builder.startStatement(); - builder.string("childStack.peek().add(result)"); - builder.end(); + vars.childIndex = varChildIndex; - typBuilderImpl.add(doEmitOperationMethod); - } + b.startSwitch().startCall(fldTypeStack, "peek").end(2); + b.startBlock(); - { - CodeExecutableElement mCreateLabel = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); + for (Operation parentOp : m.getOperations()) { - CodeTreeBuilder b = mCreateLabel.getBuilder(); - b.startReturn(); - b.startNew(builderLabelImplType.asType()); - b.end(2); + CodeTree afterChild = parentOp.createAfterChildCode(vars); + if (afterChild == null) + continue; - typBuilderImpl.add(mCreateLabel); - } + b.startCase().string(parentOp.id + " /* " + parentOp.name + " */").end(); + b.startBlock(); - for (Operation op : m.getOperations()) { - TypeMirror[] args = op.getBuilderArgumentTypes(context, types); - CodeVariableElement[] params = new CodeVariableElement[args.length]; + b.tree(afterChild); - for (int i = 0; i < params.length; i++) { - params[i] = new CodeVariableElement(args[i], "arg" + i); + b.statement("break"); + b.end(); } - if (op.hasChildren()) { - { - CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.getName()); - CodeTreeBuilder b = metBegin.getBuilder(); - b.startStatement().startCall("doBeginOperation"); - b.string("" + op.getType()); - for (int i = 0; i < params.length; i++) { - b.string("arg" + i); - } - b.end(2); - typBuilderImpl.add(metBegin); - } - - { - CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.getName()); - CodeTreeBuilder b = metEnd.getBuilder(); - b.startStatement().startCall("doEndOperation"); - b.string("" + op.getType()); - b.end(2); - typBuilderImpl.add(metEnd); - } - } else { - CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.getName()); - { - CodeTreeBuilder b = metEmit.getBuilder(); - b.startStatement().startCall("doEmitOperation"); - b.string("" + op.getType()); - for (int i = 0; i < params.length; i++) { - b.string("arg" + i); - } - b.end(2); - } - typBuilderImpl.add(metEmit); - } - } + b.end(); - return typBuilderImpl; - } + vars.childIndex = null; - private CodeTypeElement createBuilderLabelImpl(String simpleName) { - return GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); - } - - /** - * Create the BuilderNode class. - * - * This class represents the built method internally. Right now it only supports generating the - * bytecode, but in the future it will support analysis and finding super-instructions. - */ - private CodeTypeElement createBuilderImplNode(String simpleName) { - CodeTypeElement builderNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, null); + typBuilderImpl.add(mAfterChild); + } - CodeVariableElement fldType = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(int.class), "type"); - builderNodeType.add(fldType); + for (Operation op : m.getOperations()) { + List args = op.getBuilderArgumentTypes(); + CodeVariableElement[] params = new CodeVariableElement[args.size()]; - CodeVariableElement fldArguments = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "arguments"); - builderNodeType.add(fldArguments); + for (int i = 0; i < params.length; i++) { + params[i] = new CodeVariableElement(args.get(i), "arg" + i); + } - CodeVariableElement fldChildren = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(builderNodeType.asType()), "children"); - builderNodeType.add(fldChildren); + if (op.children != 0) { + CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.name); + typBuilderImpl.add(metBegin); - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderNodeType); - builderNodeType.add(ctor); + CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.name); + typBuilderImpl.add(metEnd); - CodeVariableElement fldReturnsValue = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "returnsValue"); - builderNodeType.add(fldReturnsValue); + { + // doBeforeChild(); - CodeVariableElement fldMaxStack = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "maxStack"); - builderNodeType.add(fldMaxStack); + // typeStack.push(ID); + // childIndexStack.push(0); - CodeVariableElement fldMaxLocals = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), context.getType(int.class), "maxLocals"); - builderNodeType.add(fldMaxLocals); + // Object[] args = new Object[...]; + // args[x] = arg_x;... + // argumentStack.push(args); - { - CodeTreeBuilder b = ctor.getBuilder(); + // << begin >> - b.startSwitch().field("this", fldType).end().startBlock(); + CodeTreeBuilder b = metBegin.getBuilder(); - Operation.CtorVariables vars = new Operation.CtorVariables(fldChildren, fldArguments, fldReturnsValue, fldMaxStack, fldMaxLocals); + b.startStatement().startCall(fldTypeStack, "push").string("" + op.id).end(2); + b.startStatement().startCall(fldChildIndexStack, "push").string("0").end(2); - for (Operation op : m.getOperations()) { - b.startCase().string("" + op.getType() + " /* " + op.getName() + " */").end(); + vars.arguments = metBegin.getParameters().toArray(new CodeVariableElement[0]); - b.startBlock(); + if (vars.arguments.length > 0) { + b.declaration("Object[]", "args", "new Object[" + vars.arguments.length + "]"); + for (int i = 0; i < vars.arguments.length; i++) { + b.statement("args[" + i + "] = " + vars.arguments[i].getName()); + } - b.tree(op.createCtorCode(types, vars)); + b.startStatement().startCall(fldArgumentStack, "push").string("args").end(2); + } - b.statement("int maxStack_ = 1"); - b.statement("int maxLocals_ = 0"); + b.statement("doBeforeChild()"); + b.tree(op.createBeginCode(vars)); - if (op.children == Operation.VARIABLE_CHILDREN) { - b.startFor().string("int i = 0; i < children.length; i++").end(); - b.startBlock(); + vars.arguments = null; - String extra = op.keepsChildValues() ? " + i" : ""; - b.statement("if (maxStack_ < children[i].maxStack" + extra + ") maxStack_ = children[i].maxStack" + extra); + } - b.statement("if (maxLocals_ < children[i].maxLocals) maxLocals_ = children[i].maxLocals"); + { + // assert typeStack.pop() == ID; + // int numChildren = childIndexStack.pop(); + // Object[] args = argumentsStack.pop(); + // Object arg_x = (...) args[x]; ... + // << end >> - b.end(); - } else { - for (int i = 0; i < op.children; i++) { - String extra = op.keepsChildValues() ? " + " + i : ""; - b.statement("if (maxStack_ < children[" + i + "].maxStack" + extra + ") maxStack_ = children[" + i + "].maxStack" + extra); + // doAfterChild(); + CodeTreeBuilder b = metEnd.getBuilder(); - b.statement("if (maxLocals_ < children[" + i + "].maxLocals) maxLocals_ = children[" + i + "].maxLocals"); + b.startAssert().startCall(fldTypeStack, "pop").end().string(" == " + op.id).end(); + + vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); + b.declaration("int", "numChildren", "childIndexStack.pop()"); + + if (!op.isVariableChildren()) { + b.startAssert(); + b.string("numChildren == " + op.children + " : "); + b.doubleQuote(op.name + " expected " + op.children + " children, got "); + b.string(" + numChildren"); + b.end(); + } else { + b.startAssert(); + b.string("numChildren > " + op.minimumChildren() + " : "); + b.doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got "); + b.string(" + numChildren"); + b.end(); } - } - int argIdx = 0; - for (ArgumentType arg : op.getArgumentTypes()) { - if (arg == ArgumentType.LOCAL || arg == ArgumentType.LOCAL_INDEX) { - b.statement("if (maxLocals_ < (short) arguments[" + argIdx + "] + 1) maxLocals_ = (short) arguments[" + argIdx + "] + 1"); - } - argIdx++; - } + List argInfo = op.getArguments(); - b.statement("maxStack = maxStack_"); - b.statement("maxLocals = maxLocals_"); + if (argInfo.size() > 0) { + if (metBegin.getParameters().size() > 0) { + // some non-implicit parameters + b.declaration("Object[]", "args", fldArgumentStack.getName() + ".pop()"); + } - b.statement("System.out.println(\"" + op.getName() + " \" + maxStack + \" \" + maxLocals)"); + int actualParamIndex = 0; - b.startStatement().string("break").end(); - b.end(); - } + CodeVariableElement[] varArgs = new CodeVariableElement[argInfo.size()]; + for (int i = 0; i < argInfo.size(); i++) { + if (argInfo.get(i).isImplicit()) + continue; - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); // default case block + varArgs[i] = new CodeVariableElement(argInfo.get(i).toBuilderArgumentType(), "arg_" + i); - b.end(); - } + CodeTreeBuilder b2 = CodeTreeBuilder.createBuilder(); + b2.maybeCast(context.getType(Object.class), argInfo.get(i).toBuilderArgumentType()); + b2.string("args[" + i + "]"); - { - CodeVariableElement argBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); - CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); - CodeVariableElement argConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); - CodeExecutableElement metBuild = new CodeExecutableElement(Set.of(), context.getType(int.class), "build", argBc, argStartBci, argConstPool); - - { - DeclaredType typSw = context.getDeclaredType(SuppressWarnings.class); - CodeAnnotationMirror annSw = new CodeAnnotationMirror(typSw); - annSw.setElementValue(annSw.findExecutableElement("value"), new CodeAnnotationValue("cast")); - metBuild.addAnnotationMirror(annSw); - } + b.declaration(argInfo.get(i).toBuilderArgumentType(), "arg_" + i, b2.build()); + } - CodeTreeBuilder b = metBuild.getBuilder(); + vars.arguments = varArgs; + } - CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("int", varBci.getName(), argStartBci.getName()); + b.tree(op.createEndCode(vars)); + b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); - b.startSwitch().field("this", fldType).end().startBlock(); + b.statement("doAfterChild()"); - for (Operation op : m.getOperations()) { - b.startCase().string("" + op.getType() + " /* " + op.getName() + " */").end(); + vars.arguments = null; + vars.numChildren = null; - b.startBlock(); + } + } else { + CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); + { + CodeTreeBuilder b = metEmit.getBuilder(); - EmitterVariables vars = new EmitterVariables(metBuild, argBc, varBci, argConstPool, fldChildren, fldArguments); + vars.arguments = metEmit.getParameters().toArray(new CodeVariableElement[0]); - b.tree(op.createEmitterCode(types, vars)); + b.statement("doBeforeChild()"); + b.tree(op.createBeginCode(vars)); + b.tree(op.createEndCode(vars)); + b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); + b.statement("doAfterChild()"); - b.startStatement().string("break").end(); - b.end(); + vars.arguments = null; + } + typBuilderImpl.add(metEmit); } + } - b.end(); // switchBlock - - b.startReturn().string("bci").end(); + return typBuilderImpl; - builderNodeType.add(metBuild); - } + } - return builderNodeType; + private CodeTypeElement createBuilderLabelImpl(String simpleName) { + return GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); } /** @@ -459,6 +471,11 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); + ExecuteVariables vars = new ExecuteVariables(); + vars.bc = fldBc; + vars.consts = fldConsts; + vars.maxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); + { CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); @@ -500,49 +517,21 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); b.statement("int nextBci"); + vars.bci = varBci; + vars.nextBci = varNextBci; + vars.frame = argFrame; + vars.sp = varSp; + vars.returnValue = varReturnValue; + b.startSwitch().string("bc[bci]").end(); b.startBlock(); - ExecutorVariables vars = new ExecutorVariables(varBci, varNextBci, fldBc, fldConsts, varSp, varFunArgs, argFrame, varReturnValue); - for (Instruction op : m.getInstructions()) { - - b.startCase().string("" + op.opcodeNumber + " /* " + op.getClass().getSimpleName() + " */").end(); - + b.startCase().string(op.id + " /* " + op.name + " */").end(); b.startBlock(); - CodeVariableElement[] pops = new CodeVariableElement[op.stackPops]; - for (int i = op.stackPops - 1; i >= 0; i--) { - pops[i] = new CodeVariableElement(context.getType(Object.class), "value" + i); - b.declaration("Object", pops[i].getName(), argFrame.getName() + ".getValue(--" + varSp.getName() + ")"); - } - - CodeVariableElement[] args = new CodeVariableElement[op.arguments.length]; - int ofs = 1; - for (int i = 0; i < op.arguments.length; i++) { - args[i] = new CodeVariableElement(op.arguments[i].toExecType(context, types), "arg" + i); - b.declaration(args[i].asType(), args[i].getName(), - op.arguments[i].createReaderCode(vars, CodeTreeBuilder.singleString(varBci.getName() + " + " + ofs))); - ofs += op.arguments[i].length; - } - - vars.arguments = args; - vars.children = pops; - if (op.stackPushes > 0) { - vars.result = new CodeVariableElement(context.getType(Object.class), "result"); - b.statement("Object " + vars.result.getName()); - } - - b.tree(op.createExecutorCode(types, vars)); - - if (op.stackPushes > 0) { - b.statement(argFrame.getName() + ".setObject(" + varSp.getName() + "++, " + vars.result.getName() + ")"); - } - - if (!op.isDivergent()) { - b.tree(op.createNextBciCode(types, vars)); - b.statement("break"); - } + b.tree(op.createExecuteCode(vars)); + b.tree(op.createExecuteEpilogue(vars)); b.end(); } @@ -556,6 +545,12 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startReturn().string("returnValue").end(); + vars.bci = null; + vars.nextBci = null; + vars.frame = null; + vars.sp = null; + vars.returnValue = null; + builderBytecodeNodeType.add(mContinueAt); } @@ -568,6 +563,8 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.declaration("int", "bci", "0"); b.declaration("StringBuilder", "sb", "new StringBuilder()"); + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + b.startWhile().string("bci < bc.length").end(); b.startBlock(); // while block @@ -577,21 +574,18 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startBlock(); for (Instruction op : m.getInstructions()) { - b.startCase().string("" + op.opcodeNumber).end(); + b.startCase().string("" + op.id).end(); b.startBlock(); - b.statement("sb.append(\"" + op.getClass().getSimpleName() + " \")"); + b.statement("sb.append(\"" + op.name + " \")"); - CodeVariableElement[] args = new CodeVariableElement[op.arguments.length]; int ofs = 1; for (int i = 0; i < op.arguments.length; i++) { - args[i] = new CodeVariableElement(op.arguments[i].toExecType(context, types), "arg" + i); - b.tree(op.arguments[i].createDumperCode(fldBc, CodeTreeBuilder.singleString("bci + " + ofs), varSb)); + b.startStatement().string("sb.append(").tree(op.arguments[i].createReadCode(vars, ofs)).string(")").end(); ofs += op.arguments[i].length; } b.statement("bci += " + op.length()); - b.statement("break"); b.end(); @@ -609,6 +603,8 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startReturn().string("sb.toString()").end(); + vars.bci = null; + builderBytecodeNodeType.add(mDump); } @@ -634,8 +630,8 @@ private CodeVariableElement createStackField(String name, TypeMirror argType) { return element; } - private List createOperationNode(Instruction.Custom instr) { - TypeElement t = instr.getType(); + private List createOperationNode(Instruction.Custom instruction) { + TypeElement t = instruction.type; PackageElement pack = ElementUtils.findPackageElement(t); CodeTypeElement typProxy = new CodeTypeElement(MOD_PUBLIC_STATIC_ABSTRACT, ElementKind.CLASS, pack, @@ -650,12 +646,18 @@ private List createOperationNode(Instruction.Custom instr) { context.getType(Object.class), "execute"); typProxy.add(metExecute); - for (int i = 0; i < instr.stackPops; i++) { - metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); + for (int i = 0; i < instruction.stackPops; i++) { + CodeVariableElement par; + if (i == instruction.stackPops - 1 && instruction.isVarArgs) { + par = new CodeVariableElement(arrayOf(context.getType(Object.class)), "arg" + i); + } else { + par = new CodeVariableElement(context.getType(Object.class), "arg" + i); + } + metExecute.addParameter(par); } } - for (ExecutableElement el : ElementFilter.methodsIn(instr.getType().getEnclosedElements())) { + for (ExecutableElement el : ElementFilter.methodsIn(instruction.type.getEnclosedElements())) { if (el.getModifiers().containsAll(MOD_PUBLIC_STATIC)) { CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), el.getSimpleName().toString()); @@ -719,7 +721,7 @@ private List createOperationNode(Instruction.Custom instr) { b.end(); genUncached.add(fldInstance); - instr.setUncachedInstance(fldInstance); + instruction.setUncachedInstance(fldInstance); } result.add(genUncached); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index bba56fcbb6dd..219c35a11eea 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -13,37 +13,30 @@ import com.oracle.truffle.dsl.processor.model.Template; public class OperationsData extends Template { - private final List operations = new ArrayList<>(); + + private final OperationsBuilder builder = new OperationsBuilder(); public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } - public List getOperations() { - return operations; + public OperationsBuilder getOperationsBuilder() { + return builder; } public Collection getInstructions() { - Set instrs = new HashSet<>(); - - for (Instruction insn : getOperations().get(0).commonInstructions) { - instrs.add(insn); - } - - for (Operation op : getOperations()) { - for (Instruction insn : op.instructions) { - instrs.add(insn); - } - } - - return instrs; + return builder.instructions; } - public Collection getCustomOperations() { - return operations.stream()// - .filter(x -> x instanceof Operation.CustomOperation)// - .map(x -> (Operation.CustomOperation) x)// + public Collection getCustomOperations() { + return builder.operations.stream()// + .filter(x -> x instanceof Operation.Custom)// + .map(x -> (Operation.Custom) x)// .toList(); } + public Collection getOperations() { + return builder.operations; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 18f6e4058c1d..4e9867e604b9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -24,9 +24,6 @@ private static AnnotationMirror getAnnotationMirror(List mirror) { @@ -35,8 +32,6 @@ protected OperationsData parse(Element element, List mirror) { OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); - addPrimitives(data); - for (Element e : typeElement.getEnclosedElements()) { AnnotationMirror operationMirror = getAnnotationMirror(e.getAnnotationMirrors(), types.Operation); if (operationMirror == null) { @@ -55,29 +50,6 @@ protected OperationsData parse(Element element, List mirror) { return data; } - private void addPrimitives(OperationsData data) { - Instruction[] commonOpcodes = Operation.createCommonOpcodes(opcodeId); - opcodeId += commonOpcodes.length; - - addPrimitive(data, commonOpcodes, new Operation.Block(opId++)); - addPrimitive(data, commonOpcodes, new Operation.IfThen(opId++)); - addPrimitive(data, commonOpcodes, new Operation.IfThenElse(opId++)); - addPrimitive(data, commonOpcodes, new Operation.While(opId++)); - addPrimitive(data, commonOpcodes, new Operation.Label(opId++)); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("LoadLocal", opId++, new Instruction.LoadLocal(opcodeId++))); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("StoreLocal", opId++, new Instruction.StoreLocal(opcodeId++))); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("LoadArgument", opId++, new Instruction.LoadArgument(opcodeId++))); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("ConstObject", opId++, new Instruction.ConstObject(opcodeId++))); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("Return", opId++, new Instruction.Return(opcodeId++))); - addPrimitive(data, commonOpcodes, new Operation.SimpleOperation("Branch", opId++, commonOpcodes[Operation.COMMON_OPCODE_JUMP_UNCOND])); - - } - - private static void addPrimitive(OperationsData data, Instruction[] commonOpcodes, Operation op) { - op.setCommonInstructions(commonOpcodes); - data.getOperations().add(op); - } - private void processOperation(OperationsData data, TypeElement te) { List operationFunctions = new ArrayList<>(); for (Element el : te.getEnclosedElements()) { @@ -96,23 +68,39 @@ private void processOperation(OperationsData data, TypeElement te) { ExecutableElement first = operationFunctions.get(0); List arguments = List.of(); // TODO - int numChildren = first.getParameters().size(); + int numParams = first.getParameters().size(); boolean returnsValue = !first.getReturnType().equals(context.getType(void.class)); for (ExecutableElement fun : operationFunctions) { // check all functions have the same number of parameters int numChildParameters = fun.getParameters().size(); boolean funReturnsValue = !fun.getReturnType().equals(context.getType(void.class)); - if (numChildParameters != numChildren) { - data.addWarning(fun, "Expected %d child parameters, found %d", numChildren, numChildParameters); + if (numChildParameters != numParams) { + data.addWarning(fun, "Expected %d child parameters, found %d", numParams, numChildParameters); } if (funReturnsValue != returnsValue) { data.addWarning(fun, "Not all functions return values!"); } } - Operation op = new Operation.CustomOperation(te.getSimpleName().toString(), opId++, new Instruction.Custom(opcodeId++, te, first)); - data.getOperations().add(op); + OperationsBuilder builder = data.getOperationsBuilder(); + + Instruction.Custom instr; + if (first.isVarArgs()) { + instr = new Instruction.Custom( + "custom." + te.getSimpleName(), + builder.getNextInstructionId(), + numParams, first.isVarArgs(), te, + new Argument.VarArgsCount(numParams - 1)); + } else { + instr = new Instruction.Custom( + "custom." + te.getSimpleName(), + builder.getNextInstructionId(), + numParams, first.isVarArgs(), te); + } + builder.add(instr); + Operation.Custom op = new Operation.Custom(builder, te.getSimpleName().toString(), builder.getNextOperationId(), numParams, instr); + builder.add(op); } private static boolean isOperationFunction(ExecutableElement el) { From 2d697e36818bf9bdaa792e356020477857d2d631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 8 Mar 2022 22:45:23 +0100 Subject: [PATCH 009/312] [wip] support void operations --- .../operation/test/example/SlOperations.java | 13 ++++++-- .../test/example/TestOperationsGenTest.java | 33 +++++++++++++++++-- .../truffle/api/operation/OperationsNode.java | 1 + .../dsl/processor/operations/Instruction.java | 17 ++++++---- .../operations/OperationGeneratorUtils.java | 2 +- .../operations/OperationsCodeGenerator.java | 10 +++--- .../operations/OperationsParser.java | 9 ++--- 7 files changed, 64 insertions(+), 21 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index bcb88e2898c1..7a73b319797a 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -1,9 +1,8 @@ package com.oracle.truffle.api.operation.test.example; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.GenerateUncached; +import java.util.List; + import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; @@ -40,4 +39,12 @@ public static long bla(long a1, Object... a2) { return a1 + a2.length; } } + + @Operation + static class AddToListOperation { + @Specialization + public static void bla(List a1, Object a2) { + a1.add(a2); + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index 2b7567d26368..c5ed918cabfa 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -1,5 +1,7 @@ package com.oracle.truffle.api.operation.test.example; +import java.util.ArrayList; +import java.util.List; import java.util.function.Consumer; import org.junit.Assert; @@ -8,8 +10,6 @@ import org.junit.runners.JUnit4; import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; @@ -83,6 +83,11 @@ public void testVeryComplex() { runTest(TestOperationsGenTest::parseVeryComplex, 10L); } + @Test + public void testVoidOperation() { + runTest(TestOperationsGenTest::parseVoidOperation, List.of(1, 2, 3), new ArrayList(), 1, 2, 3); + } + private static void runTest(Consumer parse, Object expectedResult, Object... args) { System.out.println("------------------------------------"); SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); @@ -221,4 +226,28 @@ private static void parseVeryComplex(SlOperationsBuilderino b) { b.endReturn(); } + private static void parseVoidOperation(SlOperationsBuilderino b) { + // function veryComplex(l1, a, b, c) { + // addToList(l1, a); + // ... + // return l1; + // } + + b.beginAddToListOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(1); + b.endAddToListOperation(); + b.beginAddToListOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(2); + b.endAddToListOperation(); + b.beginAddToListOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(3); + b.endAddToListOperation(); + b.beginReturn(); + b.emitLoadArgument(0); + b.endReturn(); + } + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 8a0324484275..3e37d86d9a77 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -20,6 +20,7 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals protected OperationsNode(int maxStack, int maxLocals) { super(null, createFrameDescriptor(maxStack, maxLocals)); + System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); this.maxLocals = maxLocals; this.maxStack = maxStack; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index ed0c19013492..1f400a6f20a8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -334,15 +334,17 @@ public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] arg public static class Custom extends Instruction { public final int stackPops; + public final int stackPushes; public final boolean isVarArgs; public final TypeElement type; private CodeVariableElement uncachedInstance; - public Custom(String name, int id, int stackPops, boolean isVarArgs, TypeElement type, Argument... arguments) { + public Custom(String name, int id, int stackPops, boolean isVarArgs, boolean isVoid, TypeElement type, Argument... arguments) { super(name, id, arguments); this.stackPops = stackPops; this.isVarArgs = isVarArgs; + this.stackPushes = isVoid ? 0 : 1; this.type = type; } @@ -353,8 +355,7 @@ public int length() { @Override public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("1"); // TODO: support void - + return CodeTreeBuilder.singleString("" + stackPushes); } public void setUncachedInstance(CodeVariableElement uncachedInstance) { @@ -369,7 +370,7 @@ public CodeTree createExecuteEpilogue(ExecuteVariables vars) { createClearStackSlot(vars, i); } - b.startAssign(vars.sp).variable(vars.sp).string(" + " + (1 - stackPops)).end(); + b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops)).end(); b.tree(super.createExecuteEpilogue(vars)); @@ -423,14 +424,18 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } bCall.end(2); - b.tree(createWriteStackObject(vars, resultOffset, bCall.build())); + if (stackPushes > 0) { + b.tree(createWriteStackObject(vars, resultOffset, bCall.build())); + } else { + b.statement(bCall.build()); + } return b.build(); } @Override protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { - return CodeTreeBuilder.singleString("(1 - " + vars.numChildren.getName() + ")"); + return CodeTreeBuilder.singleString("(" + this.stackPushes + " - " + vars.numChildren.getName() + ")"); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 5fbba2d5407b..22c1413c7d86 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -22,7 +22,7 @@ public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction b.startAssign(vars.curStack).variable(vars.curStack).string(" + ").tree(instr.createStackEffect(vars, arguments)).end(); b.startIf().variable(vars.maxStack).string(" < ").variable(vars.curStack).end(); b.startAssign(vars.maxStack).variable(vars.curStack).end(); - // b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); + b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); b.tree(instr.createBuildCode(vars, arguments)); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 8f51a9b704d8..8c1037941479 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -642,8 +642,8 @@ private List createOperationNode(Instruction.Custom instruction GeneratorUtils.addGeneratedBy(context, typProxy, t); { - CodeExecutableElement metExecute = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, - context.getType(Object.class), "execute"); + TypeMirror retType = instruction.stackPushes > 0 ? context.getType(Object.class) : context.getType(void.class); + CodeExecutableElement metExecute = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, retType, "execute"); typProxy.add(metExecute); for (int i = 0; i < instruction.stackPops; i++) { @@ -672,6 +672,8 @@ private List createOperationNode(Instruction.Custom instruction if (metProxy.getReturnType().getKind() != TypeKind.VOID) { b.startReturn(); + } else { + b.startStatement(); } b.startStaticCall(el); @@ -680,9 +682,7 @@ private List createOperationNode(Instruction.Custom instruction } b.end(); - if (metProxy.getReturnType().getKind() != TypeKind.VOID) { - b.end(); - } + b.end(); typProxy.add(metProxy); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 4e9867e604b9..68994b11738f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -9,6 +9,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.parser.AbstractParser; @@ -69,12 +70,12 @@ private void processOperation(OperationsData data, TypeElement te) { ExecutableElement first = operationFunctions.get(0); List arguments = List.of(); // TODO int numParams = first.getParameters().size(); - boolean returnsValue = !first.getReturnType().equals(context.getType(void.class)); + boolean returnsValue = first.getReturnType().getKind() != TypeKind.VOID; for (ExecutableElement fun : operationFunctions) { // check all functions have the same number of parameters int numChildParameters = fun.getParameters().size(); - boolean funReturnsValue = !fun.getReturnType().equals(context.getType(void.class)); + boolean funReturnsValue = fun.getReturnType().getKind() != TypeKind.VOID; if (numChildParameters != numParams) { data.addWarning(fun, "Expected %d child parameters, found %d", numParams, numChildParameters); } @@ -90,13 +91,13 @@ private void processOperation(OperationsData data, TypeElement te) { instr = new Instruction.Custom( "custom." + te.getSimpleName(), builder.getNextInstructionId(), - numParams, first.isVarArgs(), te, + numParams, first.isVarArgs(), !returnsValue, te, new Argument.VarArgsCount(numParams - 1)); } else { instr = new Instruction.Custom( "custom." + te.getSimpleName(), builder.getNextInstructionId(), - numParams, first.isVarArgs(), te); + numParams, first.isVarArgs(), !returnsValue, te); } builder.add(instr); Operation.Custom op = new Operation.Custom(builder, te.getSimpleName().toString(), builder.getNextOperationId(), numParams, instr); From f8ece48ba8503719ac636120aaefe182c40b8e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 10 Mar 2022 08:11:28 +0100 Subject: [PATCH 010/312] [wip] exception handling --- .../operation/test/example/SlOperations.java | 8 ++ .../test/example/TestOperationsGenTest.java | 39 ++++++ .../operation/BuilderExceptionHandler.java | 14 ++ .../truffle/api/operation/OperationsNode.java | 2 +- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Argument.java | 31 +++++ .../dsl/processor/operations/Instruction.java | 11 +- .../dsl/processor/operations/Operation.java | 126 ++++++++++++++++++ .../operations/OperationGeneratorUtils.java | 2 +- .../operations/OperationsBuilder.java | 1 + .../operations/OperationsCodeGenerator.java | 57 +++++++- 11 files changed, 283 insertions(+), 10 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index 7a73b319797a..de1e5d4b3281 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -47,4 +47,12 @@ public static void bla(List a1, Object a2) { a1.add(a2); } } + + @Operation + static class ThrowOperation { + @Specialization + public static void perform() { + throw new RuntimeException("haha"); + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index c5ed918cabfa..bb003d6880c6 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -88,6 +88,12 @@ public void testVoidOperation() { runTest(TestOperationsGenTest::parseVoidOperation, List.of(1, 2, 3), new ArrayList(), 1, 2, 3); } + @Test + public void testTryCatchOperation() { + runTest(TestOperationsGenTest::parseTryCatchOperation, 0L, 1L); + runTest(TestOperationsGenTest::parseTryCatchOperation, 1L, -1L); + } + private static void runTest(Consumer parse, Object expectedResult, Object... args) { System.out.println("------------------------------------"); SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); @@ -250,4 +256,37 @@ private static void parseVoidOperation(SlOperationsBuilderino b) { b.endReturn(); } + private static void parseTryCatchOperation(SlOperationsBuilderino b) { + // function tryCatch(x) { + // try { + // if (x < 0) throw(...) + // } catch { + // return 1 + // } + // return 0 + + b.beginTryCatch(); + + b.beginIfThen(); + + b.beginLessThanOperation(); + b.emitLoadArgument(0); + b.emitConstObject(0L); + b.endLessThanOperation(); + + b.emitThrowOperation(); + + b.endIfThen(); + + b.beginReturn(); + b.emitConstObject(1L); + b.endReturn(); + + b.endTryCatch(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + } + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java new file mode 100644 index 000000000000..a6d624c29161 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java @@ -0,0 +1,14 @@ +package com.oracle.truffle.api.operation; + +public class BuilderExceptionHandler { + public int startBci; + public int startStack; + public int endBci; + public int exceptionIndex; + public int handlerBci; + + @Override + public String toString() { + return String.format("{start=%04x, end=%04x, handler=%04x}", startBci, endBci, handlerBci); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 3e37d86d9a77..f6b1bbf89673 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -20,7 +20,7 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals protected OperationsNode(int maxStack, int maxLocals) { super(null, createFrameDescriptor(maxStack, maxLocals)); - System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); + // System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); this.maxLocals = maxLocals; this.maxStack = maxStack; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 5f3d4d1301f4..ca2af8ca6502 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -221,6 +221,7 @@ public class TruffleTypes { public final DeclaredType UnsupportedSpecializationException = c.getDeclaredType(UnsupportedSpecializationException_Name); // Operations DSL API + public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; @@ -229,6 +230,7 @@ public class TruffleTypes { public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + public final DeclaredType BuilderExceptionHandler = c.getDeclaredType(BuilderExceptionHandler_Name); public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); public final DeclaredType GenerateOperations = c.getDeclaredType(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredType(Operation_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java index 88b524bb2ffe..452e0771275a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java @@ -32,6 +32,8 @@ public boolean isImplicit() { public abstract TypeMirror toBuilderArgumentType(); + public abstract CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset); + public static class Integer extends Argument { public Integer(int length) { super(length); @@ -75,6 +77,14 @@ public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { .end().build(); } } + + @Override + public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder().startStatement() // + .startCall("sb", "append") // + .tree(createReadCode(vars, offset)) // + .end(2).build(); + } } public static class VarArgsCount extends Integer { @@ -138,6 +148,16 @@ public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { .tree(offset) // .end().build(); } + + @Override + public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder().startStatement() // + .startCall("sb", "append") // + .startCall("String", "format") // + .doubleQuote("%04x") // + .tree(createReadCode(vars, offset)) // + .end(3).build(); + } } public static class Const extends Argument { @@ -172,5 +192,16 @@ public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { .tree(offset) // .end().string("]").build(); } + + @Override + public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { + return CodeTreeBuilder.createBuilder().startStatement() // + .startCall("sb", "append") // + .startCall("String", "format") // + .doubleQuote("(%s) %s") // + .startCall(createReadCode(vars, offset), "getClass().getSimpleName").end() // + .tree(createReadCode(vars, offset)) // + .end(3).build(); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 1f400a6f20a8..3c86fa0dd6b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -22,12 +22,13 @@ public static class ExecuteVariables { CodeVariableElement bc; CodeVariableElement bci; CodeVariableElement nextBci; - + CodeVariableElement returnValue; CodeVariableElement frame; CodeVariableElement sp; + CodeVariableElement consts; - CodeVariableElement returnValue; CodeVariableElement maxStack; + CodeVariableElement handlers; } public Instruction(String name, int id, Argument... arguments) { @@ -435,7 +436,11 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { @Override protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { - return CodeTreeBuilder.singleString("(" + this.stackPushes + " - " + vars.numChildren.getName() + ")"); + if (this.isVarArgs) { + return CodeTreeBuilder.singleString("(" + this.stackPushes + " - " + vars.numChildren.getName() + ")"); + } else { + return CodeTreeBuilder.singleString(this.stackPushes - this.stackPops + ""); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 43039d712ed6..c10bf3c0f3b1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -7,9 +7,13 @@ import java.util.Collection; import java.util.List; +import java.util.Stack; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; @@ -37,6 +41,7 @@ public static class BuilderVariables { CodeVariableElement bc; CodeVariableElement bci; CodeVariableElement consts; + CodeVariableElement exteptionHandlers; CodeVariableElement stackUtility; @@ -391,6 +396,103 @@ public List getArguments() { } } + public static class TryCatch extends Operation { + public TryCatch(OperationsBuilder builder, int id) { + super(builder, "TryCatch", id, 2); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); + b.startStatement().variable(varBeh).string(".startStack = ").variable(vars.curStack).end(); + b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); + + // ... + b.tree(createPushUtility(varBeh, vars)); + // ..., beh + + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + + // utilstack: ..., beh + b.tree(createPushUtility(varEndLabel, vars)); + // utilstack ..., beh, endLabel + + return b.build(); + } + + @Override + public CodeTree createAfterChildCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(createPopLastChildCode(vars)); + + b.startIf().variable(vars.childIndex).string(" == 0").end(); + b.startBlock(); + + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + + // utilstack ..., beh, endLabel + b.tree(createPeekUtility(varEndLabel, vars, 0)); + b.tree(createPeekUtility(varBeh, vars, 1)); + + b.startStatement().variable(varBeh).string(".endBci = ").variable(vars.bci).end(); + + b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + + b.end().startElseBlock(); + + b.end(); + + return b.build(); + } + + @Override + public CodeTree createBeforeChildCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().variable(vars.childIndex).string(" == 1").end(); + b.startBlock(); + + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + + // utilstack ..., beh, endLabel + b.tree(createPeekUtility(varEndLabel, vars, 0)); + b.tree(createPeekUtility(varBeh, vars, 1)); + + b.startAssign(vars.curStack).variable(varBeh).string(".startStack").end(); + b.startStatement().variable(varBeh).string(".handlerBci = ").variable(vars.bci).end(); + + b.end(); + + return b.build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + b.tree(createPopUtility(varEndLabel, vars)); + b.tree(createPopUtility(varBeh, vars)); + + b.tree(createEmitLabel(vars, CodeTreeBuilder.singleVariable(varEndLabel))); + + return b.build(); + } + } + protected static final CodeTree createPopUtility(TypeMirror type, BuilderVariables vars) { return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "pop").end().build(); } @@ -403,6 +505,30 @@ protected static final CodeTree createPushUtility(CodeVariableElement target, Bu return CodeTreeBuilder.createBuilder().startStatement().startCall(vars.stackUtility, "push").variable(target).end(2).build(); } + /** + * 0 = TOS, 1 = TOS-1, ... + * + * @param target + * @param vars + * @param offset + * @return + */ + protected static final CodeTree createPeekUtility(CodeVariableElement target, BuilderVariables vars, int offset) { + return CodeTreeBuilder.createBuilder().declaration(target.asType(), target.getName(), createPeekUtility(target.asType(), vars, offset)).build(); + } + + protected static final CodeTree createPeekUtility(TypeMirror type, BuilderVariables vars, int offset) { + if (offset == 0) { + return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "peek").end().build(); + } else { + return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "get") // + .startGroup() // + .startCall(vars.stackUtility, "size").end() // + .string(" - " + (offset + 1)) // + .end(2).build(); + } + } + protected final CodeTree createPopLastChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 22c1413c7d86..5fbba2d5407b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -22,7 +22,7 @@ public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction b.startAssign(vars.curStack).variable(vars.curStack).string(" + ").tree(instr.createStackEffect(vars, arguments)).end(); b.startIf().variable(vars.maxStack).string(" < ").variable(vars.curStack).end(); b.startAssign(vars.maxStack).variable(vars.curStack).end(); - b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); + // b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); b.tree(instr.createBuildCode(vars, arguments)); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java index 22292a7c23e8..01667f898a4a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java @@ -31,6 +31,7 @@ private void createBuiltinOperations() { add(new Operation.IfThenElse(this, operationId++, false)); add(new Operation.IfThenElse(this, operationId++, true)); add(new Operation.While(this, operationId++)); + add(new Operation.TryCatch(this, operationId++)); add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 8c1037941479..318f34da6429 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -154,6 +154,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("new byte[65535]"); } + CodeVariableElement fldExceptionHandlers = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.BuilderExceptionHandler), "exceptionHandlers"); + typBuilderImpl.add(fldExceptionHandlers); + { + CodeTreeBuilder b = fldExceptionHandlers.createInitBuilder(); + b.string("new ArrayList<>()"); + } + CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lashPush"); typBuilderImpl.add(fldLastPush); @@ -185,6 +192,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.maxStack = fldMaxStack; vars.curStack = fldCurStack; vars.maxLocal = fldMaxLocal; + vars.exteptionHandlers = fldExceptionHandlers; { CodeExecutableElement metReset = new CodeExecutableElement( @@ -202,6 +210,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startStatement().startCall(fldArgumentStack.getName(), "clear").end(2); b.startStatement().startCall(fldTypeStack.getName(), "clear").end(2); b.startStatement().startCall(fldTypeStack.getName(), "add").string("0").end(2); + b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); } { @@ -216,6 +225,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, bci)"); b.declaration("Object[]", "cpCopy", "constPool.getValues()"); + b.declaration("BuilderExceptionHandler[]", "handlers", fldExceptionHandlers.getName() + ".toArray(new BuilderExceptionHandler[0])"); b.startReturn(); b.startNew(builderBytecodeNodeType.asType()); @@ -223,6 +233,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startGroup().variable(fldMaxLocal).string(" + 1").end(); b.string("bcCopy"); b.string("cpCopy"); + b.string("handlers"); b.end(2); } @@ -343,6 +354,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = metBegin.getBuilder(); + b.statement("doBeforeChild()"); + b.startStatement().startCall(fldTypeStack, "push").string("" + op.id).end(2); b.startStatement().startCall(fldChildIndexStack, "push").string("0").end(2); @@ -357,7 +370,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startStatement().startCall(fldArgumentStack, "push").string("args").end(2); } - b.statement("doBeforeChild()"); b.tree(op.createBeginCode(vars)); vars.arguments = null; @@ -408,6 +420,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (argInfo.get(i).isImplicit()) continue; + // TODO: this does not work with mixing implicit and real args + varArgs[i] = new CodeVariableElement(argInfo.get(i).toBuilderArgumentType(), "arg_" + i); CodeTreeBuilder b2 = CodeTreeBuilder.createBuilder(); @@ -469,12 +483,16 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeVariableElement fldConsts = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(Object.class)), "consts"); builderBytecodeNodeType.add(fldConsts); + CodeVariableElement fldHandlers = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(types.BuilderExceptionHandler), "handlers"); + builderBytecodeNodeType.add(fldHandlers); + builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); ExecuteVariables vars = new ExecuteVariables(); vars.bc = fldBc; vars.consts = fldConsts; vars.maxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); + vars.handlers = fldHandlers; { CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); @@ -500,11 +518,9 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeTreeBuilder b = mContinueAt.getBuilder(); - CodeVariableElement varFunArgs = new CodeVariableElement(arrayOf(context.getType(Object.class)), "funArgs"); CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("final Object[]", varFunArgs.getName(), "frame.getArguments()"); b.declaration("int", varSp.getName(), "0"); b.declaration("int", varBci.getName(), "0"); @@ -523,6 +539,8 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { vars.sp = varSp; vars.returnValue = varReturnValue; + b.startTryBlock(); + b.startSwitch().string("bc[bci]").end(); b.startBlock(); @@ -540,6 +558,28 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.end(); // switch block + b.end().startCatchBlock(context.getType(Throwable.class), "ex"); + + b.startFor().string("int handlerIndex = 0; handlerIndex < " + vars.handlers.getName() + ".length; handlerIndex++").end(); + b.startBlock(); + + b.declaration(types.BuilderExceptionHandler, "handler", vars.handlers.getName() + "[handlerIndex]"); + b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); + b.statement("continue"); + + b.startAssign(varSp).string("handler.startStack").end(); + // TODO check exception type + // TODO put exception in local + + b.statement("bci = handler.handlerBci"); + b.statement("continue loop"); + + b.end(); // for (handlerIndex ...) + + b.startThrow().string("ex").end(); + + b.end(); // catch block + b.statement("bci = nextBci"); b.end(); // while block @@ -558,7 +598,6 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); CodeTreeBuilder b = mDump.getBuilder(); - CodeVariableElement varSb = new CodeVariableElement(context.getType(StringBuilder.class), "sb"); b.declaration("int", "bci", "0"); b.declaration("StringBuilder", "sb", "new StringBuilder()"); @@ -581,7 +620,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { int ofs = 1; for (int i = 0; i < op.arguments.length; i++) { - b.startStatement().string("sb.append(").tree(op.arguments[i].createReadCode(vars, ofs)).string(")").end(); + b.tree(op.arguments[i].getDumpCode(vars, CodeTreeBuilder.singleString("bci + " + ofs))); ofs += op.arguments[i].length; } @@ -601,6 +640,13 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.end(); // while block + b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); + b.startBlock(); + + b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); + + b.end(); + b.startReturn().string("sb.toString()").end(); vars.bci = null; @@ -738,6 +784,7 @@ private static TypeMirror arrayOf(TypeMirror el) { } @Override + @SuppressWarnings("hiding") public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { this.context = context; this.processor = processor; From fde89336dff6e3d75a2922661c9b3e9876d793da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 10 Mar 2022 08:48:46 +0100 Subject: [PATCH 011/312] [wip] --- .../operation/test/example/SlOperations.java | 26 +++++ .../test/example/TestOperationsGenTest.java | 99 +++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java index de1e5d4b3281..4891efaa82cd 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java @@ -55,4 +55,30 @@ public static void perform() { throw new RuntimeException("haha"); } } + + @Operation + static class IsThruthyOperation { + @Specialization + public static boolean testString(String s) { + return s != null && s.length() > 0; + } + + @Specialization + public static boolean testLong(long l) { + return l > 0; + } + } + + @Operation + static class IsFalseyOperation { + @Specialization + public static boolean testString(String s) { + return s == null || s.length() == 0; + } + + @Specialization + public static boolean testLong(long l) { + return l <= 0; + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index bb003d6880c6..195d425a77cb 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -78,6 +78,11 @@ public void testBreakLoop() { runTest(TestOperationsGenTest::parseBreakLoop, 10L, 15L); } + @Test + public void testBlockPopping() { + runTest(TestOperationsGenTest::parseBlockPopping, 5L); + } + @Test public void testVeryComplex() { runTest(TestOperationsGenTest::parseVeryComplex, 10L); @@ -94,6 +99,13 @@ public void testTryCatchOperation() { runTest(TestOperationsGenTest::parseTryCatchOperation, 1L, -1L); } + @Test + public void testBooleanIfThingy() { + runTest(TestOperationsGenTest::parseBooleanIfThingy, 1L, 1L, -1L); + runTest(TestOperationsGenTest::parseBooleanIfThingy, 2L, -1L, 2L); + runTest(TestOperationsGenTest::parseBooleanIfThingy, -1L, -3L, -4L); + } + private static void runTest(Consumer parse, Object expectedResult, Object... args) { System.out.println("------------------------------------"); SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); @@ -213,6 +225,25 @@ private static void parseBreakLoop(SlOperationsBuilderino b) { b.endReturn(); } + private static void parseBlockPopping(SlOperationsBuilderino b) { + // function blockPopping() { + // return 1 + {2; 3; 4} + // } + + b.beginReturn(); + b.beginAddOperation(); + b.emitConstObject(1L); + + b.beginBlock(); + b.emitConstObject(2L); + b.emitConstObject(3L); + b.emitConstObject(4L); + b.endBlock(); + + b.endAddOperation(); + b.endReturn(); + } + private static void parseVeryComplex(SlOperationsBuilderino b) { // function veryComplex() { // return veryComplex(1, 2, 3, 4, 5) + 6 @@ -289,4 +320,72 @@ private static void parseTryCatchOperation(SlOperationsBuilderino b) { b.endReturn(); } + private static void beginBooleanAnd(SlOperationsBuilderino b, int i) { + // a && b -> { l0 = a; if (isFalsey(l0)) { l0 = b }; l0 } + + b.beginBlock(); + b.beginStoreLocal(i); + } + + private static void middleBooleanAnd(SlOperationsBuilderino b, int i) { + b.endStoreLocal(); + + b.beginIfThen(); + + b.beginIsFalseyOperation(); + b.emitLoadLocal(i); + b.endIsFalseyOperation(); + + b.beginStoreLocal(i); + } + + private static void endBooleanAnd(SlOperationsBuilderino b, int i) { + b.endStoreLocal(); + + b.endIfThen(); + + b.emitLoadLocal(i); + + b.endBlock(); + } + + private static void parseBooleanIfThingy(SlOperationsBuilderino b) { + + // function test(x, y) { + // try { + // return x && y && throw(); + // } catch { + // return -1; + // } + + b.beginTryCatch(); + { + b.beginReturn(); + { + + beginBooleanAnd(b, 0); + { + b.emitLoadArgument(0); + } + middleBooleanAnd(b, 0); + { + + beginBooleanAnd(b, 1); + b.emitLoadArgument(1); + middleBooleanAnd(b, 1); + b.emitThrowOperation(); + endBooleanAnd(b, 1); + } + endBooleanAnd(b, 0); + } + b.endReturn(); + + b.beginReturn(); + b.emitConstObject(-1L); + b.endReturn(); + } + b.endTryCatch(); + + } + } From a09ad4765a2524e3a29dbbf97093314653a459af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 10 Mar 2022 11:14:31 +0100 Subject: [PATCH 012/312] [wip] --- ...{SlOperations.java => TestOperations.java} | 2 +- .../test/example/TestOperationsGenTest.java | 172 ++++++++++-------- .../truffle/api/operation/OperationsNode.java | 7 +- .../operation/tracing/InstructionTrace.java | 25 +++ .../api/operation/tracing/NodeTrace.java | 13 ++ .../truffle/dsl/processor/TruffleTypes.java | 4 + .../dsl/processor/operations/Operation.java | 6 + .../operations/OperationGeneratorUtils.java | 4 +- .../operations/OperationsCodeGenerator.java | 103 ++++++++++- .../processor/operations/OperationsData.java | 10 + .../operations/OperationsParser.java | 2 + 11 files changed, 260 insertions(+), 88 deletions(-) rename truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/{SlOperations.java => TestOperations.java} (98%) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java similarity index 98% rename from truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java rename to truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 4891efaa82cd..53e4398948ce 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -7,7 +7,7 @@ import com.oracle.truffle.api.operation.Operation; @GenerateOperations -public class SlOperations { +public class TestOperations { @Operation static class AddOperation { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index 195d425a77cb..55f1dde59241 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -12,116 +12,140 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.tracing.InstructionTrace; @RunWith(JUnit4.class) public class TestOperationsGenTest { - private static void parseAdd(SlOperationsBuilderino b) { - // simple test: - // function foo(a, b) { - // return (a + b); - // } - b.beginReturn(); - b.beginAddOperation(); - b.emitLoadArgument((short) 0); - b.emitLoadArgument((short) 1); - b.endAddOperation(); - b.endReturn(); - } - - private static void parseMax(SlOperationsBuilderino b) { - // control flow test: - // function max(a, b) { - // if (a < b) { - // return b; - // } else { - // return a; - // } - b.beginIfThenElse(); - - b.beginLessThanOperation(); - b.emitLoadArgument((short) 0); // a - b.emitLoadArgument((short) 1); // b - b.endLessThanOperation(); - - b.beginReturn(); - b.emitLoadArgument((short) 1); // b - b.endReturn(); - - b.beginReturn(); - b.emitLoadArgument((short) 0); // a - b.endReturn(); - - b.endIfThenElse(); + private static OperationsNode doBuild(Consumer bm) { + TestOperationsBuilder builder = TestOperationsBuilder.createBuilder(); + bm.accept(builder); + return builder.build(); } @Test public void testAdd() { - runTest(TestOperationsGenTest::parseAdd, 42L, 20L, 22L); - runTest(TestOperationsGenTest::parseAdd, "foobar", "foo", "bar"); + OperationsNode node = doBuild(TestOperationsGenTest::parseAdd); + runTest(node, 42L, 20L, 22L); + runTest(node, "foobar", "foo", "bar"); + runTest(node, 100L, 120L, -20L); + + InstructionTrace[] instructions = node.getNodeTrace().getInstructions(); + + Assert.assertEquals(3, instructions[0].getHitCount()); + Assert.assertEquals(3, instructions[1].getHitCount()); + Assert.assertEquals(3, instructions[2].getHitCount()); + Assert.assertEquals(3, instructions[3].getHitCount()); } @Test public void testMax() { - runTest(TestOperationsGenTest::parseMax, 42L, 42L, 13L); - runTest(TestOperationsGenTest::parseMax, 42L, 13L, 42L); + OperationsNode node = doBuild(TestOperationsGenTest::parseMax); + runTest(node, 42L, 42L, 13L); + runTest(node, 42L, 42L, 13L); + runTest(node, 42L, 13L, 42L); + runTest(node, 42L, 13L, 42L); + + InstructionTrace[] instructions = node.getNodeTrace().getInstructions(); + + Assert.assertEquals(4, instructions[0].getHitCount()); + Assert.assertEquals(2, instructions[instructions.length - 1].getHitCount()); } @Test public void testSumLoop() { - runTest(TestOperationsGenTest::parseSumLoop, 45L, 10L); + OperationsNode node = doBuild(TestOperationsGenTest::parseSumLoop); + runTest(node, 45L, 10L); } @Test public void testBreakLoop() { - runTest(TestOperationsGenTest::parseBreakLoop, 6L, 5L); - runTest(TestOperationsGenTest::parseBreakLoop, 10L, 15L); + OperationsNode node = doBuild(TestOperationsGenTest::parseBreakLoop); + runTest(node, 6L, 5L); + runTest(node, 10L, 15L); } @Test public void testBlockPopping() { - runTest(TestOperationsGenTest::parseBlockPopping, 5L); + OperationsNode node = doBuild(TestOperationsGenTest::parseBlockPopping); + runTest(node, 5L); } @Test public void testVeryComplex() { - runTest(TestOperationsGenTest::parseVeryComplex, 10L); + OperationsNode node = doBuild(TestOperationsGenTest::parseVeryComplex); + runTest(node, 10L); } @Test public void testVoidOperation() { - runTest(TestOperationsGenTest::parseVoidOperation, List.of(1, 2, 3), new ArrayList(), 1, 2, 3); + OperationsNode node = doBuild(TestOperationsGenTest::parseVoidOperation); + runTest(node, List.of(1, 2, 3), new ArrayList(), 1, 2, 3); } @Test public void testTryCatchOperation() { - runTest(TestOperationsGenTest::parseTryCatchOperation, 0L, 1L); - runTest(TestOperationsGenTest::parseTryCatchOperation, 1L, -1L); + OperationsNode node = doBuild(TestOperationsGenTest::parseTryCatchOperation); + runTest(node, 0L, 1L); + runTest(node, 1L, -1L); } @Test public void testBooleanIfThingy() { - runTest(TestOperationsGenTest::parseBooleanIfThingy, 1L, 1L, -1L); - runTest(TestOperationsGenTest::parseBooleanIfThingy, 2L, -1L, 2L); - runTest(TestOperationsGenTest::parseBooleanIfThingy, -1L, -3L, -4L); + OperationsNode node = doBuild(TestOperationsGenTest::parseBooleanIfThingy); + runTest(node, 1L, 1L, -1L); + runTest(node, 2L, -1L, 2L); + runTest(node, -1L, -3L, -4L); } - private static void runTest(Consumer parse, Object expectedResult, Object... args) { - System.out.println("------------------------------------"); - SlOperationsBuilderino b = SlOperationsBuilderino.createBuilder(); - parse.accept(b); - System.out.println(" building"); - OperationsNode executable = b.build(); - System.out.println(" dumping"); - System.out.println(executable.dump()); - b.reset(); + private static void runTest(OperationsNode executable, Object expectedResult, Object... args) { System.out.println(executable); CallTarget target = executable.getCallTarget(); Object result = target.call(args); + System.out.println(executable.dump()); Assert.assertEquals(expectedResult, result); } - private static void parseSumLoop(SlOperationsBuilderino b) { + private static void parseAdd(TestOperationsBuilder b) { + // simple test: + // function foo(a, b) { + // return (a + b); + // } + b.beginReturn(); + b.beginAddOperation(); + b.emitLoadArgument((short) 0); + b.emitLoadArgument((short) 1); + b.endAddOperation(); + b.endReturn(); + } + + private static void parseMax(TestOperationsBuilder b) { + // control flow test: + // function max(a, b) { + // if (a < b) { + // return b; + // } else { + // return a; + // } + b.beginIfThenElse(); + + b.beginLessThanOperation(); + b.emitLoadArgument((short) 0); // a + b.emitLoadArgument((short) 1); // b + b.endLessThanOperation(); + + b.beginReturn(); + b.emitLoadArgument((short) 1); // b + b.endReturn(); + + b.beginReturn(); + b.emitLoadArgument((short) 0); // a + b.endReturn(); + + b.endIfThenElse(); + } + + private static void parseSumLoop(TestOperationsBuilder b) { // control flow test: // function sum(length) { // sum = 0; @@ -172,7 +196,7 @@ private static void parseSumLoop(SlOperationsBuilderino b) { b.endReturn(); } - private static void parseBreakLoop(SlOperationsBuilderino b) { + private static void parseBreakLoop(TestOperationsBuilder b) { // function breakLoop(input) { // i = 0; // while (i < 10) { @@ -225,7 +249,7 @@ private static void parseBreakLoop(SlOperationsBuilderino b) { b.endReturn(); } - private static void parseBlockPopping(SlOperationsBuilderino b) { + private static void parseBlockPopping(TestOperationsBuilder b) { // function blockPopping() { // return 1 + {2; 3; 4} // } @@ -244,7 +268,7 @@ private static void parseBlockPopping(SlOperationsBuilderino b) { b.endReturn(); } - private static void parseVeryComplex(SlOperationsBuilderino b) { + private static void parseVeryComplex(TestOperationsBuilder b) { // function veryComplex() { // return veryComplex(1, 2, 3, 4, 5) + 6 // } @@ -263,7 +287,7 @@ private static void parseVeryComplex(SlOperationsBuilderino b) { b.endReturn(); } - private static void parseVoidOperation(SlOperationsBuilderino b) { + private static void parseVoidOperation(TestOperationsBuilder b) { // function veryComplex(l1, a, b, c) { // addToList(l1, a); // ... @@ -287,7 +311,7 @@ private static void parseVoidOperation(SlOperationsBuilderino b) { b.endReturn(); } - private static void parseTryCatchOperation(SlOperationsBuilderino b) { + private static void parseTryCatchOperation(TestOperationsBuilder b) { // function tryCatch(x) { // try { // if (x < 0) throw(...) @@ -296,7 +320,7 @@ private static void parseTryCatchOperation(SlOperationsBuilderino b) { // } // return 0 - b.beginTryCatch(); + b.beginTryCatch(1); b.beginIfThen(); @@ -320,14 +344,14 @@ private static void parseTryCatchOperation(SlOperationsBuilderino b) { b.endReturn(); } - private static void beginBooleanAnd(SlOperationsBuilderino b, int i) { + private static void beginBooleanAnd(TestOperationsBuilder b, int i) { // a && b -> { l0 = a; if (isFalsey(l0)) { l0 = b }; l0 } b.beginBlock(); b.beginStoreLocal(i); } - private static void middleBooleanAnd(SlOperationsBuilderino b, int i) { + private static void middleBooleanAnd(TestOperationsBuilder b, int i) { b.endStoreLocal(); b.beginIfThen(); @@ -339,7 +363,7 @@ private static void middleBooleanAnd(SlOperationsBuilderino b, int i) { b.beginStoreLocal(i); } - private static void endBooleanAnd(SlOperationsBuilderino b, int i) { + private static void endBooleanAnd(TestOperationsBuilder b, int i) { b.endStoreLocal(); b.endIfThen(); @@ -349,16 +373,16 @@ private static void endBooleanAnd(SlOperationsBuilderino b, int i) { b.endBlock(); } - private static void parseBooleanIfThingy(SlOperationsBuilderino b) { + private static void parseBooleanIfThingy(TestOperationsBuilder b) { // function test(x, y) { // try { // return x && y && throw(); - // } catch { + // } catch (e) { // return -1; // } - b.beginTryCatch(); + b.beginTryCatch(2); { b.beginReturn(); { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index f6b1bbf89673..7017d096e77d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,11 +1,10 @@ package com.oracle.truffle.api.operation; -import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.tracing.NodeTrace; public abstract class OperationsNode extends RootNode { @@ -30,4 +29,8 @@ protected OperationsNode(int maxStack, int maxLocals) { // public abstract OperationsNode copyUninitialized(); public abstract String dump(); + + public NodeTrace getNodeTrace() { + throw new UnsupportedOperationException("Operations not built with tracing"); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java new file mode 100644 index 000000000000..1789a5fda9e4 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java @@ -0,0 +1,25 @@ +package com.oracle.truffle.api.operation.tracing; + +public class InstructionTrace { + private final int id; + private final int hitCount; + private final Object[] arguments; + + public InstructionTrace(int id, int hitCount, Object... arguments) { + this.id = id; + this.hitCount = hitCount; + this.arguments = arguments; + } + + public int getId() { + return id; + } + + public int getHitCount() { + return hitCount; + } + + public Object[] getArguments() { + return arguments; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java new file mode 100644 index 000000000000..6904ff960e1a --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java @@ -0,0 +1,13 @@ +package com.oracle.truffle.api.operation.tracing; + +public class NodeTrace { + private final InstructionTrace[] instructions; + + public NodeTrace(InstructionTrace[] instructions) { + this.instructions = instructions; + } + + public InstructionTrace[] getInstructions() { + return instructions; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index ca2af8ca6502..d98a0eb4d264 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -229,6 +229,8 @@ public class TruffleTypes { public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; + public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; public final DeclaredType BuilderExceptionHandler = c.getDeclaredType(BuilderExceptionHandler_Name); public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); @@ -238,6 +240,8 @@ public class TruffleTypes { public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); + public final DeclaredType NodeTrace = c.getDeclaredType(NodeTrace_Name); + public final DeclaredType InstructionTrace = c.getDeclaredType(InstructionTrace_Name); // Library API public static final String EagerExportProvider_Name = "com.oracle.truffle.api.library.EagerExportProvider"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index c10bf3c0f3b1..bac11bc776d9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -406,6 +406,11 @@ public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("0"); } + @Override + public List getArguments() { + return List.of(new Argument.Integer(2)); + } + @Override public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -414,6 +419,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); b.startStatement().variable(varBeh).string(".startStack = ").variable(vars.curStack).end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = ").variable(vars.arguments[0]).end(); b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); // ... diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 5fbba2d5407b..042f152c1a3a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -74,14 +74,14 @@ public static CodeTree createWriteStackObject(ExecuteVariables vars, int offset, public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { return CodeTreeBuilder.createBuilder() // .startCall(vars.frame, "getValue") // - .startGroup().variable(vars.maxStack).string(" + ").tree(offset).end()// + .startGroup().tree(offset).end()// .end(2).build(); } public static CodeTree createWriteLocal(ExecuteVariables vars, CodeTree offset, CodeTree value) { return CodeTreeBuilder.createBuilder() // .startStatement().startCall(vars.frame, "setObject") // - .startGroup().variable(vars.maxStack).string(" + ").tree(offset).end() // + .startGroup().tree(offset).end() // .tree(value) // .end(3).build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 318f34da6429..bbf6b589476a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -13,6 +13,7 @@ import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -119,7 +120,7 @@ CodeTypeElement createBuilder(String simpleName) { * does the most of the build-time heavy lifting. */ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { - String simpleName = m.getTemplateType().getSimpleName() + "BuilderinoImpl"; + String simpleName = m.getTemplateType().getSimpleName() + "BuilderImpl"; CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); @@ -475,18 +476,36 @@ private CodeTypeElement createBuilderLabelImpl(String simpleName) { * executable Truffle node. */ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.OperationsNode); + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, simpleName, types.OperationsNode); CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); builderBytecodeNodeType.add(fldBc); - CodeVariableElement fldConsts = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(context.getType(Object.class)), "consts"); + CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); builderBytecodeNodeType.add(fldConsts); - CodeVariableElement fldHandlers = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.FINAL), arrayOf(types.BuilderExceptionHandler), "handlers"); + CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); builderBytecodeNodeType.add(fldHandlers); - builderBytecodeNodeType.add(GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType)); + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); + builderBytecodeNodeType.add(ctor); + + CodeVariableElement fldHitCount = null; + if (m.isTracing()) { + fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); + builderBytecodeNodeType.add(fldHitCount); + } + + { + CodeTreeBuilder b = ctor.getBuilder(); + + if (m.isTracing()) { + b.startAssign(fldHitCount).startNewArray( + (ArrayType) fldHitCount.getType(), + CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); + b.end(2); + } + } ExecuteVariables vars = new ExecuteVariables(); vars.bc = fldBc; @@ -521,7 +540,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("int", varSp.getName(), "0"); + b.declaration("int", varSp.getName(), "maxLocals"); b.declaration("int", varBci.getName(), "0"); CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); @@ -541,6 +560,10 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startTryBlock(); + if (m.isTracing()) { + b.startStatement().variable(fldHitCount).string("[bci]++").end(); + } + b.startSwitch().string("bc[bci]").end(); b.startBlock(); @@ -569,7 +592,10 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startAssign(varSp).string("handler.startStack").end(); // TODO check exception type - // TODO put exception in local + + b.tree(OperationGeneratorUtils.createWriteLocal(vars, + CodeTreeBuilder.singleString("handler.exceptionIndex"), + CodeTreeBuilder.singleString("ex"))); b.statement("bci = handler.handlerBci"); b.statement("continue loop"); @@ -596,6 +622,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { { CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); + builderBytecodeNodeType.add(mDump); CodeTreeBuilder b = mDump.getBuilder(); @@ -607,6 +634,10 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startWhile().string("bci < bc.length").end(); b.startBlock(); // while block + if (m.isTracing()) { + b.statement("sb.append(String.format(\" [ %3d ]\", hitCount[bci]))"); + } + b.statement("sb.append(String.format(\" %04x \", bci))"); b.startSwitch().string("bc[bci]").end(); @@ -651,7 +682,61 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { vars.bci = null; - builderBytecodeNodeType.add(mDump); + } + + if (m.isTracing()) { + CodeExecutableElement mGetTrace = GeneratorUtils.override(types.OperationsNode, "getNodeTrace"); + builderBytecodeNodeType.add(mGetTrace); + + CodeTreeBuilder b = mGetTrace.getBuilder(); + + b.declaration("int", "bci", "0"); + b.declaration("List", "insts", "new ArrayList<>()"); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + b.startWhile().string("bci < bc.length").end(); + b.startBlock(); // while block + + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); + + for (Instruction op : m.getInstructions()) { + b.startCase().string("" + op.id).end(); + b.startBlock(); + + b.startStatement(); + b.startCall("insts", "add"); + b.startNew(types.InstructionTrace); + + b.string("" + op.id); + b.startGroup().variable(fldHitCount).string("[bci]").end(); + + int ofs = 1; + for (int i = 0; i < op.arguments.length; i++) { + b.tree(op.arguments[i].createReadCode(vars, ofs)); + } + + b.end(3); + + b.statement("bci += " + op.length()); + b.statement("break"); + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); + b.end(); // default case block + b.end(); // switch block + + b.end(); // while block + + b.startReturn().startNew(types.NodeTrace); + b.startCall("insts", "toArray").string("new InstructionTrace[0]").end(); + b.end(2); + + vars.bci = null; } return builderBytecodeNodeType; @@ -790,7 +875,7 @@ public List create(ProcessorContext context, AnnotationProcesso this.processor = processor; this.m = m; - String simpleName = m.getTemplateType().getSimpleName() + "Builderino"; + String simpleName = m.getTemplateType().getSimpleName() + "Builder"; try { return List.of(createBuilder(simpleName)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 219c35a11eea..e907e941ed6f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -16,6 +16,8 @@ public class OperationsData extends Template { private final OperationsBuilder builder = new OperationsBuilder(); + private boolean tracing; + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } @@ -24,6 +26,14 @@ public OperationsBuilder getOperationsBuilder() { return builder; } + public void setTracing(boolean tracing) { + this.tracing = tracing; + } + + public boolean isTracing() { + return tracing; + } + public Collection getInstructions() { return builder.instructions; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 68994b11738f..40f428387468 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -48,6 +48,8 @@ protected OperationsData parse(Element element, List mirror) { } + data.setTracing(true); + return data; } From e24389de5c8084a5018d364a85e5187db6897c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 10 Mar 2022 14:36:32 +0100 Subject: [PATCH 013/312] [wip] make @Cached and similar work (kinda) --- .../test/example/TestOperations.java | 14 +- .../test/slexample/SlOperations.java | 148 ++++++++++++++++++ .../truffle/api/operation/Variadic.java | 5 + .../truffle/dsl/processor/TruffleTypes.java | 2 + .../java/transform/AbstractCodeWriter.java | 6 +- .../dsl/processor/operations/Instruction.java | 2 + .../operations/OperationsCodeGenerator.java | 39 ++++- .../processor/operations/OperationsData.java | 14 ++ .../operations/OperationsParser.java | 78 +++++++-- .../dsl/processor/parser/NodeParser.java | 2 +- 10 files changed, 282 insertions(+), 28 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 53e4398948ce..9f9068d7f56c 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -2,9 +2,11 @@ import java.util.List; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.Variadic; @GenerateOperations public class TestOperations { @@ -19,9 +21,17 @@ public static long add(long lhs, long rhs) { } @Specialization - public static String addStrings(String lhs, String rhs) { + public static String addStrings(String lhs, String rhs, @Cached int test) { return lhs + rhs; } + + protected static int create() { + return 1; + } + + protected static int getUncached() { + return 1; + } } @Operation @@ -35,7 +45,7 @@ public static boolean lessThan(long lhs, long rhs) { @Operation static class VeryComplexOperation { @Specialization - public static long bla(long a1, Object... a2) { + public static long bla(long a1, @Variadic Object[] a2) { return a1 + a2.length; } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java new file mode 100644 index 000000000000..fc07c424149e --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java @@ -0,0 +1,148 @@ +package com.oracle.truffle.api.operation.test.slexample; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.StandardTags; +import com.oracle.truffle.api.instrumentation.Tag; +import com.oracle.truffle.api.interop.ArityException; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.InvalidArrayIndexException; +import com.oracle.truffle.api.interop.UnknownIdentifierException; +import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.Node.Child; +import com.oracle.truffle.api.nodes.Node.Children; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLExpressionNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLObject; +import com.oracle.truffle.sl.runtime.SLUndefinedNameException; + +@GenerateOperations +public class SlOperations { + + @Operation + public static class SLAddOperation { + @Specialization(rewriteOn = ArithmeticException.class) + public static long add(long left, long right) { + return Math.addExact(left, right); + } + + @Specialization(replaces = "add") + @TruffleBoundary + public static SLBigNumber addBig(SLBigNumber left, SLBigNumber right) { + return new SLBigNumber(left.getValue().add(right.getValue())); + } + + @Specialization(guards = "isString(left, right)") + @TruffleBoundary + public static TruffleString addString(Object left, Object right, + @Cached SLToTruffleStringNode toTruffleStringNodeLeft, + @Cached SLToTruffleStringNode toTruffleStringNodeRight, + @Cached TruffleString.ConcatNode concatNode) { + return concatNode.execute( + toTruffleStringNodeLeft.execute(left), + toTruffleStringNodeRight.execute(right), + SLLanguage.STRING_ENCODING, + true); + } + + public static boolean isString(Object a, Object b) { + return a instanceof TruffleString || b instanceof TruffleString; + } + + @Fallback + public static Object typeError(Object left, Object right) { + throw new RuntimeException("+ type error: " + left + ", " + right); + } + } + + @Operation + public static class SLReadPropertyOperation { + + public static final int LIBRARY_LIMIT = 3; + + @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "3") + public static Object readArray(Object receiver, Object index, + @CachedLibrary("receiver") InteropLibrary arrays, + @CachedLibrary("index") InteropLibrary numbers) { + try { + return arrays.readArrayElement(receiver, numbers.asLong(index)); + } catch (UnsupportedMessageException | InvalidArrayIndexException e) { + // read was not successful. In SL we only have basic support for errors. + throw SLUndefinedNameException.undefinedProperty(null, index); + } + } + + @Specialization(limit = "3") + public static Object readSLObject(SLObject receiver, Object name, + @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, + @Cached SLToTruffleStringNode toTruffleStringNode) { + TruffleString nameTS = toTruffleStringNode.execute(name); + Object result = objectLibrary.getOrDefault(receiver, nameTS, null); + if (result == null) { + // read was not successful. In SL we only have basic support for errors. + throw SLUndefinedNameException.undefinedProperty(null, nameTS); + } + return result; + } + + @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "3") + public static Object readObject(Object receiver, Object name, + @CachedLibrary("receiver") InteropLibrary objects, + @Cached SLToMemberNode asMember) { + try { + return objects.readMember(receiver, asMember.execute(name)); + } catch (UnsupportedMessageException | UnknownIdentifierException e) { + // read was not successful. In SL we only have basic support for errors. + throw SLUndefinedNameException.undefinedProperty(null, name); + } + } + + protected static boolean isSLObject(Object receiver) { + return receiver instanceof SLObject; + } + } + + @Operation + public static class SLInvokeNode { + + // @Child private SLExpressionNode functionNode; + // @Children private final SLExpressionNode[] argumentNodes; + // @Child private InteropLibrary library; + // + // public SLInvokeNode(SLExpressionNode functionNode, SLExpressionNode[] argumentNodes) { + // this.functionNode = functionNode; + // this.argumentNodes = argumentNodes; + // this.library = InteropLibrary.getFactory().createDispatched(3); + // } + + @ExplodeLoop + @Specialization + public static Object call( + Object function, + @Variadic Object[] argumentValues, + @CachedLibrary(limit = "3") InteropLibrary library) { + try { + return library.execute(function, argumentValues); + } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { + /* Execute was not successful. */ + throw SLUndefinedNameException.undefinedFunction(null, function); + } + } + + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java new file mode 100644 index 000000000000..91aa3cf20fb1 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java @@ -0,0 +1,5 @@ +package com.oracle.truffle.api.operation; + +public @interface Variadic { + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index d98a0eb4d264..b972d78fe7d6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -229,6 +229,7 @@ public class TruffleTypes { public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; @@ -240,6 +241,7 @@ public class TruffleTypes { public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); + public final DeclaredType Variadic = c.getDeclaredType(Variadic_Name); public final DeclaredType NodeTrace = c.getDeclaredType(NodeTrace_Name); public final DeclaredType InstructionTrace = c.getDeclaredType(InstructionTrace_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java index 8c0033d35928..ba025edd2861 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java @@ -724,7 +724,11 @@ public void visitTree(CodeTree e, Void p, Element enclosingElement) { break; case STATIC_METHOD_REFERENCE: if (e.getString() != null) { - write(imports.createStaticMethodReference(enclosingElement, e.getType(), e.getString())); + if (imports == null) { + write("############"); + } else { + write(imports.createStaticMethodReference(enclosingElement, e.getType(), e.getString())); + } } else { write("null"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 3c86fa0dd6b4..7ce26e905c57 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -415,6 +415,8 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { int resultOffset = 1 - stackPops; CodeTree instance = CodeTreeBuilder.createBuilder() // + // .field(uncachedInstance.getEnclosingElement().getSimpleName().toString(), + // uncachedInstance)// .staticReference(uncachedInstance) // .build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index bbf6b589476a..a6dc0337d457 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -53,6 +53,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + private final Set MOD_STATIC = Set.of(Modifier.STATIC); /** * Creates the builder class itself. This class only contains abstract methods, the builder @@ -94,13 +95,16 @@ CodeTypeElement createBuilder(String simpleName) { if (op instanceof Operation.Custom) { Operation.Custom customOp = (Operation.Custom) op; - List genNode = createOperationNode(customOp.instruction); + List genNode = createOperationNode(typBuilder, customOp.instruction); typBuilder.addAll(genNode); } } - if (m.hasErrors()) + if (m.hasErrors()) { + // throw new RuntimeException(String.join("\n", m.collectMessages().stream().map(x -> + // x.getText()).toList())); return typBuilder; + } CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); @@ -122,6 +126,7 @@ CodeTypeElement createBuilder(String simpleName) { private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { String simpleName = m.getTemplateType().getSimpleName() + "BuilderImpl"; CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); + typBuilderImpl.setEnclosingElement(typBuilder); DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); CodeVariableElement leBytes = new CodeVariableElement( @@ -691,7 +696,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeTreeBuilder b = mGetTrace.getBuilder(); b.declaration("int", "bci", "0"); - b.declaration("List", "insts", "new ArrayList<>()"); + b.declaration("ArrayList", "insts", "new ArrayList<>()"); vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); @@ -761,7 +766,7 @@ private CodeVariableElement createStackField(String name, TypeMirror argType) { return element; } - private List createOperationNode(Instruction.Custom instruction) { + private List createOperationNode(CodeTypeElement typEnc, Instruction.Custom instruction) { TypeElement t = instruction.type; PackageElement pack = ElementUtils.findPackageElement(t); @@ -771,6 +776,7 @@ private List createOperationNode(Instruction.Custom instruction typProxy.setSuperClass(types.Node); typProxy.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); GeneratorUtils.addGeneratedBy(context, typProxy, t); + typProxy.setEnclosingElement(typEnc); { TypeMirror retType = instruction.stackPushes > 0 ? context.getType(Object.class) : context.getType(void.class); @@ -789,7 +795,7 @@ private List createOperationNode(Instruction.Custom instruction } for (ExecutableElement el : ElementFilter.methodsIn(instruction.type.getEnclosedElements())) { - if (el.getModifiers().containsAll(MOD_PUBLIC_STATIC)) { + if (el.getModifiers().containsAll(MOD_STATIC)) { CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), el.getSimpleName().toString()); for (VariableElement par : el.getParameters()) { @@ -826,10 +832,21 @@ private List createOperationNode(Instruction.Custom instruction NodeData data = parser.parse(typProxy); if (data == null) { m.addError(t, "Could not generate node data"); - return List.of(); + return List.of(typProxy); } + + data.redirectMessagesOnGeneratedElements(m); + + if (data.hasErrors()) { + return List.of(typProxy); + } + NodeCodeGenerator gen = new NodeCodeGenerator(); - CodeTypeElement genResult = gen.create(context, processor, data).get(0); + List genList = gen.create(context, processor, data); + if (genList == null) { + return List.of(typProxy); + } + CodeTypeElement genResult = genList.get(0); CodeTypeElement genUncached = null; @@ -842,11 +859,17 @@ private List createOperationNode(Instruction.Custom instruction assert genUncached != null; + for (VariableElement v : ElementFilter.fieldsIn(genResult.getEnclosedElements())) { + if (v.getModifiers().contains(Modifier.STATIC) && !v.getSimpleName().toString().equals("UNCACHED")) { + genUncached.add(v); + } + } + genUncached.setSimpleName(CodeNames.of(t.getSimpleName() + "Uncached")); GeneratorUtils.addGeneratedBy(context, genUncached, t); { - CodeVariableElement fldInstance = new CodeVariableElement(MOD_PUBLIC_STATIC_FINAL, genUncached.asType(), "INSTANCE"); + CodeVariableElement fldInstance = new CodeVariableElement(MOD_PUBLIC_STATIC_FINAL, genUncached.asType(), "UNCACHED"); CodeTreeBuilder b = fldInstance.createInitBuilder(); b.startNew(genUncached.asType()); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index e907e941ed6f..a3378b008d2b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -14,6 +14,20 @@ public class OperationsData extends Template { + static class OperationData { + final String name; + final int numParameters; + final boolean isVariadic; + final boolean returnsValue; + + public OperationData(String name, int numParameters, boolean isVariadic, boolean returnsValue) { + this.name = name; + this.numParameters = numParameters; + this.isVariadic = isVariadic; + this.returnsValue = returnsValue; + } + } + private final OperationsBuilder builder = new OperationsBuilder(); private boolean tracing; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 40f428387468..9461e9ccc2c2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -8,10 +8,13 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { @@ -53,6 +56,48 @@ protected OperationsData parse(Element element, List mirror) { return data; } + private boolean isIgnoredParameter(VariableElement param) { + if (ElementUtils.findAnnotationMirror(param, types.Cached) != null) { + return true; + } else if (ElementUtils.findAnnotationMirror(param, types.CachedLibrary) != null) { + return true; + } else if (ElementUtils.findAnnotationMirror(param, types.CachedLanguage) != null) { + return true; + } + + return false; + } + + private boolean isVariadicParameter(VariableElement param) { + return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; + } + + private OperationData processMethod(OperationsData data, ExecutableElement method) { + List arguments = List.of(); // TODO + + int numChildren = 0; + boolean isVariadic = false; + + for (VariableElement param : method.getParameters()) { + if (isVariadicParameter(param)) { + if (isVariadic) { + data.addError(method, "Multiple @Variadic arguments not allowed"); + } + isVariadic = true; + numChildren++; + } else if (!isIgnoredParameter(param)) { + if (isVariadic) { + data.addError(method, "Value arguments after @Variadic not allowed"); + } + numChildren++; + } + } + + boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; + + return new OperationData(method.getEnclosingElement().getSimpleName().toString(), numChildren, isVariadic, returnsValue); + } + private void processOperation(OperationsData data, TypeElement te) { List operationFunctions = new ArrayList<>(); for (Element el : te.getEnclosedElements()) { @@ -69,40 +114,41 @@ private void processOperation(OperationsData data, TypeElement te) { return; } - ExecutableElement first = operationFunctions.get(0); - List arguments = List.of(); // TODO - int numParams = first.getParameters().size(); - boolean returnsValue = first.getReturnType().getKind() != TypeKind.VOID; + OperationData opData = processMethod(data, operationFunctions.get(0)); for (ExecutableElement fun : operationFunctions) { - // check all functions have the same number of parameters - int numChildParameters = fun.getParameters().size(); - boolean funReturnsValue = fun.getReturnType().getKind() != TypeKind.VOID; - if (numChildParameters != numParams) { - data.addWarning(fun, "Expected %d child parameters, found %d", numParams, numChildParameters); + OperationData opData2 = processMethod(data, fun); + + if (opData2.isVariadic != opData.isVariadic) { + data.addError(fun, "All operation functions should be variadic / non-variadic"); + } + if (opData2.returnsValue != opData.returnsValue) { + data.addError(fun, "All operation functions should return value / be void"); } - if (funReturnsValue != returnsValue) { - data.addWarning(fun, "Not all functions return values!"); + if (opData2.numParameters != opData.numParameters) { + data.addError(fun, "All operation functions should have same number of parameters"); } } OperationsBuilder builder = data.getOperationsBuilder(); Instruction.Custom instr; - if (first.isVarArgs()) { + if (opData.isVariadic) { instr = new Instruction.Custom( "custom." + te.getSimpleName(), builder.getNextInstructionId(), - numParams, first.isVarArgs(), !returnsValue, te, - new Argument.VarArgsCount(numParams - 1)); + opData.numParameters, true, + !opData.returnsValue, te, + new Argument.VarArgsCount(opData.numParameters - 1)); } else { instr = new Instruction.Custom( "custom." + te.getSimpleName(), builder.getNextInstructionId(), - numParams, first.isVarArgs(), !returnsValue, te); + opData.numParameters, false, + !opData.returnsValue, te); } builder.add(instr); - Operation.Custom op = new Operation.Custom(builder, te.getSimpleName().toString(), builder.getNextOperationId(), numParams, instr); + Operation.Custom op = new Operation.Custom(builder, te.getSimpleName().toString(), builder.getNextOperationId(), opData.numParameters, instr); builder.add(op); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 1bd50cea2e22..21d83cc82489 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -284,7 +284,7 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } - if (mode == ParseMode.DEFAULT && !getRepeatedAnnotation(templateType.getAnnotationMirrors(), types.Operation).isEmpty()) { + if (ElementUtils.findAnnotationMirror(templateType.getAnnotationMirrors(), types.Operation) != null) { return null; } From b2f0c5a1d83c109c7bef7b6aa94970d89c813791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 10 Mar 2022 17:11:00 +0100 Subject: [PATCH 014/312] [wip] random --- .../test/example/TestOperations.java | 10 +-- .../test/slexample/SlOperations.java | 5 +- .../processor/generator/GeneratorUtils.java | 7 ++ .../java/model/CodeAnnotationMirror.java | 4 + .../dsl/processor/operations/Operation.java | 2 +- .../operations/OperationsCodeGenerator.java | 79 ++++++++++++------- .../operations/OperationsParser.java | 9 +-- 7 files changed, 68 insertions(+), 48 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 9f9068d7f56c..3b2cb8dfce95 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -21,17 +21,9 @@ public static long add(long lhs, long rhs) { } @Specialization - public static String addStrings(String lhs, String rhs, @Cached int test) { + public static String addStrings(String lhs, String rhs, @Cached("1") int test) { return lhs + rhs; } - - protected static int create() { - return 1; - } - - protected static int getUncached() { - return 1; - } } @Operation diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java index fc07c424149e..8b69584dbd0d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java @@ -75,7 +75,7 @@ public static class SLReadPropertyOperation { public static final int LIBRARY_LIMIT = 3; - @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "3") + @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object readArray(Object receiver, Object index, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { @@ -100,7 +100,7 @@ public static Object readSLObject(SLObject receiver, Object name, return result; } - @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "3") + @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") public static Object readObject(Object receiver, Object name, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { @@ -130,7 +130,6 @@ public static class SLInvokeNode { // this.library = InteropLibrary.getFactory().createDispatched(3); // } - @ExplodeLoop @Specialization public static Object call( Object function, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 5308f34211e7..4cf2b1206ce6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -309,6 +309,13 @@ public static void addGeneratedBy(ProcessorContext context, CodeTypeElement gene } } + public static void addSuppressWarnings(ProcessorContext context, CodeElement element, String value) { + CodeAnnotationMirror annSuppressWarnings = new CodeAnnotationMirror(context.getDeclaredType(SuppressWarnings.class)); + element.addAnnotationMirror(annSuppressWarnings); + + annSuppressWarnings.setElementValue("value", new CodeAnnotationValue(value)); + } + static List findUserConstructors(TypeMirror nodeType) { List constructors = new ArrayList<>(); for (ExecutableElement constructor : ElementFilter.constructorsIn(ElementUtils.fromTypeMirror(nodeType).getEnclosedElements())) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeAnnotationMirror.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeAnnotationMirror.java index c4ad2503af05..956ac8b39ebb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeAnnotationMirror.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeAnnotationMirror.java @@ -73,6 +73,10 @@ public void setElementValue(ExecutableElement method, AnnotationValue value) { values.put(method, value); } + public void setElementValue(String methodName, AnnotationValue value) { + setElementValue(findExecutableElement(methodName), value); + } + public ExecutableElement findExecutableElement(String name) { return ElementUtils.findExecutableElement(annotationType, name); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index bac11bc776d9..2346ac295be8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -169,7 +169,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { @Override public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleVariable(vars.lastChildPushCount); + return null; // does not change it at all } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index a6dc0337d457..e070ca2d36eb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -7,6 +7,8 @@ import java.util.Stack; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.AnnotationValueVisitor; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -26,6 +28,7 @@ import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -119,10 +122,6 @@ CodeTypeElement createBuilder(String simpleName) { return typBuilder; } - /** - * Create the implementation class. This class implements the begin/end methods, and in general - * does the most of the build-time heavy lifting. - */ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { String simpleName = m.getTemplateType().getSimpleName() + "BuilderImpl"; CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); @@ -167,7 +166,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("new ArrayList<>()"); } - CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lashPush"); + CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastPush"); typBuilderImpl.add(fldLastPush); CodeVariableElement fldMaxLocal = new CodeVariableElement(context.getType(int.class), "maxLocal"); @@ -266,6 +265,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { { CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); CodeTreeBuilder b = mBeforeChild.getBuilder(); + GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); b.declaration("int", varChildIndex.getName(), "childIndexStack.peek()"); @@ -299,6 +299,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { { CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); CodeTreeBuilder b = mAfterChild.getBuilder(); + GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); b.declaration("int", varChildIndex.getName(), "childIndexStack.pop()"); @@ -342,9 +343,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (op.children != 0) { CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.name); typBuilderImpl.add(metBegin); + GeneratorUtils.addSuppressWarnings(context, metBegin, "unused"); CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.name); typBuilderImpl.add(metEnd); + GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); { // doBeforeChild(); @@ -441,7 +444,10 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } b.tree(op.createEndCode(vars)); - b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); + CodeTree lastPush = op.createPushCountCode(vars); + if (lastPush != null) { + b.startAssign(fldLastPush).tree(lastPush).end(); + } b.statement("doAfterChild()"); @@ -540,6 +546,13 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", argFrame, argStartIndex); + { + CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); + mContinueAt.addAnnotationMirror(annExplodeLoop); + annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( + context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); + } + CodeTreeBuilder b = mContinueAt.getBuilder(); CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); @@ -596,7 +609,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.statement("continue"); b.startAssign(varSp).string("handler.startStack").end(); - // TODO check exception type + // TODO check exception type (?) b.tree(OperationGeneratorUtils.createWriteLocal(vars, CodeTreeBuilder.singleString("handler.exceptionIndex"), @@ -794,35 +807,41 @@ private List createOperationNode(CodeTypeElement typEnc, Instru } } + for (VariableElement el : ElementFilter.fieldsIn(instruction.type.getEnclosedElements())) { + if (el.getModifiers().contains(Modifier.FINAL)) { + CodeVariableElement fldProxy = new CodeVariableElement(el.getModifiers(), el.asType(), el.getSimpleName().toString()); + fldProxy.createInitBuilder().staticReference(el); + typProxy.add(fldProxy); + } + } + for (ExecutableElement el : ElementFilter.methodsIn(instruction.type.getEnclosedElements())) { - if (el.getModifiers().containsAll(MOD_STATIC)) { - CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), - el.getSimpleName().toString()); - for (VariableElement par : el.getParameters()) { - metProxy.addParameter(par); - } - for (AnnotationMirror ann : el.getAnnotationMirrors()) { - metProxy.addAnnotationMirror(ann); - } + CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), + el.getSimpleName().toString()); + for (VariableElement par : el.getParameters()) { + metProxy.addParameter(par); + } + for (AnnotationMirror ann : el.getAnnotationMirrors()) { + metProxy.addAnnotationMirror(ann); + } - CodeTreeBuilder b = metProxy.getBuilder(); + CodeTreeBuilder b = metProxy.getBuilder(); - if (metProxy.getReturnType().getKind() != TypeKind.VOID) { - b.startReturn(); - } else { - b.startStatement(); - } + if (metProxy.getReturnType().getKind() != TypeKind.VOID) { + b.startReturn(); + } else { + b.startStatement(); + } - b.startStaticCall(el); - for (VariableElement par : el.getParameters()) { - b.variable(par); - } - b.end(); + b.startStaticCall(el); + for (VariableElement par : el.getParameters()) { + b.variable(par); + } + b.end(); - b.end(); + b.end(); - typProxy.add(metProxy); - } + typProxy.add(metProxy); } List result = new ArrayList<>(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 9461e9ccc2c2..a74ee311b45a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -5,6 +5,7 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; @@ -42,11 +43,6 @@ protected OperationsData parse(Element element, List mirror) { continue; } - if (!(e instanceof TypeElement)) { - data.addError(e, "@Operation can only be attached to classes"); - continue; - } - processOperation(data, (TypeElement) e); } @@ -101,6 +97,9 @@ private OperationData processMethod(OperationsData data, ExecutableElement metho private void processOperation(OperationsData data, TypeElement te) { List operationFunctions = new ArrayList<>(); for (Element el : te.getEnclosedElements()) { + if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { + data.addError(el, "Operations must not contain non-static members"); + } if (el instanceof ExecutableElement) { ExecutableElement cel = (ExecutableElement) el; if (isOperationFunction(cel)) { From 2b2a4cd1008e2c7cbd24fd6ca041187bb1699481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 14 Mar 2022 07:59:46 +0100 Subject: [PATCH 015/312] [wip] start SL work --- .../truffle/api/operation/Operation.java | 1 + .../java/transform/AbstractCodeWriter.java | 2 +- .../dsl/processor/operations/Instruction.java | 119 +++++++--- .../dsl/processor/operations/Operation.java | 26 ++- .../operations/OperationGeneratorUtils.java | 27 ++- .../operations/OperationsCodeGenerator.java | 189 +++------------- ...onsBuilder.java => OperationsContext.java} | 31 ++- .../processor/operations/OperationsData.java | 50 ++--- .../operations/OperationsParser.java | 129 ++--------- .../operations/SingleOperationData.java | 83 +++++++ .../operations/SingleOperationParser.java | 212 ++++++++++++++++++ .../dsl/processor/parser/NodeParser.java | 11 +- .../truffle/sl/operations/SLOperations.java} | 12 +- 13 files changed, 538 insertions(+), 354 deletions(-) rename truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/{OperationsBuilder.java => OperationsContext.java} (70%) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java rename truffle/src/{com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java => com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java} (92%) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index 6686067af2dd..54996e9a4813 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -8,4 +8,5 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Operation { + Class proxyNode() default Void.class; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java index ba025edd2861..9a64356e7a24 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java @@ -725,7 +725,7 @@ public void visitTree(CodeTree e, Void p, Element enclosingElement) { case STATIC_METHOD_REFERENCE: if (e.getString() != null) { if (imports == null) { - write("############"); + write(ElementUtils.getSimpleName(e.getType()) + "." + e.getString()); } else { write(imports.createStaticMethodReference(enclosingElement, e.getType(), e.getString())); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 7ce26e905c57..899eeb7c07a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -1,14 +1,27 @@ package com.oracle.truffle.dsl.processor.operations; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.*; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createClearStackSlot; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadLocal; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadStack; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteLocal; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteStackObject; import java.util.List; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementFilter; +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; @@ -18,7 +31,11 @@ public abstract class Instruction { public final int id; public final Argument[] arguments; + public CodeVariableElement opcodeIdField; + public static class ExecuteVariables { + CodeTypeElement bytecodeNodeType; + CodeVariableElement bc; CodeVariableElement bci; CodeVariableElement nextBci; @@ -37,6 +54,10 @@ public Instruction(String name, int id, Argument... arguments) { this.arguments = arguments; } + public void setOpcodeIdField(CodeVariableElement opcodeIdField) { + this.opcodeIdField = opcodeIdField; + } + public int length() { int len = 1; for (Argument arg : getArgumentTypes()) { @@ -83,7 +104,7 @@ public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] arg b.startStatement(); b.variable(vars.bc).string("[").variable(vars.bci).string("++]"); b.string(" = "); - b.string("" + id + " /* " + name + " */"); + b.variable(opcodeIdField); b.end(); assert argValues.length == arguments.length; @@ -334,19 +355,21 @@ public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] arg public static class Custom extends Instruction { + public final SingleOperationData data; + public final int stackPops; public final int stackPushes; public final boolean isVarArgs; - public final TypeElement type; - private CodeVariableElement uncachedInstance; - - public Custom(String name, int id, int stackPops, boolean isVarArgs, boolean isVoid, TypeElement type, Argument... arguments) { + public Custom(String name, int id, SingleOperationData data, Argument... arguments) { super(name, id, arguments); - this.stackPops = stackPops; - this.isVarArgs = isVarArgs; - this.stackPushes = isVoid ? 0 : 1; - this.type = type; + this.data = data; + this.stackPops = data.getMainProperties().numParameters; + this.isVarArgs = data.getMainProperties().isVariadic; + this.stackPushes = data.getMainProperties().returnsValue ? 1 : 0; + + if (data.getMainProperties().isVariadic && arguments.length == 0) + throw new IllegalArgumentException("Must have at least the VarArgCount argument"); } @Override @@ -359,10 +382,6 @@ public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("" + stackPushes); } - public void setUncachedInstance(CodeVariableElement uncachedInstance) { - this.uncachedInstance = uncachedInstance; - } - @Override public CodeTree createExecuteEpilogue(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -412,27 +431,69 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } } - int resultOffset = 1 - stackPops; + if (stackPushes > 0) { + b.tree(createWriteStackObject(vars, 1 - stackPops, createActualExecuteCallCode(vars, vals))); + } else { + b.statement(createActualExecuteCallCode(vars, vals)); + } + + return b.build(); + } + + private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] vals) { + String executeName = "execute" + data.getTemplateType().getSimpleName() + "_"; + + CodeTypeElement topElem = new NodeCodeGenerator().create(data.getContext(), null, data.getNodeData()).get(0); + + TypeElement typUncached = null; + ExecutableElement metExecute = null; + + outer: for (TypeElement elem : ElementFilter.typesIn(topElem.getEnclosedElements())) { + if (elem.getSimpleName().toString().equals("Uncached")) { + typUncached = elem; + for (ExecutableElement exElem : ElementFilter.methodsIn(elem.getEnclosedElements())) { + if (exElem.getSimpleName().toString().equals("execute")) { + metExecute = exElem; + break outer; + } + } + } + } + + if (metExecute == null) { + data.addError("Generated node did not have a proper execute element, what for?"); + return CodeTreeBuilder.singleString(topElem.toString()); + } + + CodeExecutableElement copy = CodeExecutableElement.clone(metExecute); + copy.setSimpleName(CodeNames.of(executeName)); + GeneratorUtils.addSuppressWarnings(ProcessorContext.getInstance(), copy, "static-method"); + + vars.bytecodeNodeType.add(copy); + + for (VariableElement elem : ElementFilter.fieldsIn(topElem.getEnclosedElements())) { + if (elem.getModifiers().contains(Modifier.STATIC) && !elem.getSimpleName().toString().equals("UNCACHED")) { + CodeVariableElement fldCopy = CodeVariableElement.clone(elem); + fldCopy.setSimpleName(CodeNames.of(data.getName() + "_" + elem.getSimpleName())); + fldCopy.setInit(((CodeVariableElement) elem).getInit()); + // fldCopy.getModifiers().remove(Modifier.STATIC); - CodeTree instance = CodeTreeBuilder.createBuilder() // - // .field(uncachedInstance.getEnclosingElement().getSimpleName().toString(), - // uncachedInstance)// - .staticReference(uncachedInstance) // - .build(); + OperationGeneratorUtils.changeAllVariables(copy.getBodyTree(), elem, fldCopy); - CodeTreeBuilder bCall = CodeTreeBuilder.createBuilder(); - bCall.startCall(instance, "execute"); - for (int i = 0; i < stackPops; i++) { - bCall.tree(vals[i]); + vars.bytecodeNodeType.add(fldCopy); + } } - bCall.end(2); - if (stackPushes > 0) { - b.tree(createWriteStackObject(vars, resultOffset, bCall.build())); - } else { - b.statement(bCall.build()); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startCall("this", copy); + + for (CodeTree val : vals) { + b.tree(val); } + b.end(); + return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 2346ac295be8..b276863a35b9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -21,12 +21,14 @@ public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; - public final OperationsBuilder builder; + public final OperationsContext builder; public final String name; public final int id; public final int children; - protected Operation(OperationsBuilder builder, String name, int id, int children) { + public CodeVariableElement idConstantField; + + protected Operation(OperationsContext builder, String name, int id, int children) { this.builder = builder; this.name = name; this.id = id; @@ -37,6 +39,10 @@ public final boolean isVariableChildren() { return children == VARIABLE_CHILDREN; } + public void setIdConstantField(CodeVariableElement idConstantField) { + this.idConstantField = idConstantField; + } + public static class BuilderVariables { CodeVariableElement bc; CodeVariableElement bci; @@ -89,7 +95,7 @@ public CodeTree createEndCode(BuilderVariables vars) { public static class Custom extends Operation { final Instruction.Custom instruction; - protected Custom(OperationsBuilder builder, String name, int id, int children, Instruction.Custom instruction) { + protected Custom(OperationsContext builder, String name, int id, int children, Instruction.Custom instruction) { super(builder, name, id, instruction.isVarArgs ? VARIABLE_CHILDREN : children); this.instruction = instruction; } @@ -123,7 +129,7 @@ public static class Simple extends Operation { private final Instruction instruction; - protected Simple(OperationsBuilder builder, String name, int id, int children, Instruction instruction) { + protected Simple(OperationsContext builder, String name, int id, int children, Instruction instruction) { super(builder, name, id, children); this.instruction = instruction; } @@ -149,7 +155,7 @@ public List getArguments() { } public static class Block extends Operation { - protected Block(OperationsBuilder builder, int id) { + protected Block(OperationsContext builder, int id) { super(builder, "Block", id, VARIABLE_CHILDREN); } @@ -174,7 +180,7 @@ public CodeTree createPushCountCode(BuilderVariables vars) { } public static class IfThen extends Operation { - protected IfThen(OperationsBuilder builder, int id) { + protected IfThen(OperationsContext builder, int id) { super(builder, "IfThen", id, 2); } @@ -223,7 +229,7 @@ public static class IfThenElse extends Operation { private final boolean hasValue; - public IfThenElse(OperationsBuilder builder, int id, boolean hasValue) { + public IfThenElse(OperationsContext builder, int id, boolean hasValue) { super(builder, hasValue ? "Conditional" : "IfThenElse", id, 3); this.hasValue = hasValue; } @@ -310,7 +316,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { } public static class While extends Operation { - public While(OperationsBuilder builder, int id) { + public While(OperationsContext builder, int id) { super(builder, "While", id, 2); } @@ -376,7 +382,7 @@ public CodeTree createPushCountCode(BuilderVariables vars) { } public static class Label extends Operation { - public Label(OperationsBuilder builder, int id) { + public Label(OperationsContext builder, int id) { super(builder, "Label", id, 0); } @@ -397,7 +403,7 @@ public List getArguments() { } public static class TryCatch extends Operation { - public TryCatch(OperationsBuilder builder, int id) { + public TryCatch(OperationsContext builder, int id) { super(builder, "TryCatch", id, 2); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 042f152c1a3a..067fc503f1b0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -1,10 +1,15 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.List; + +import javax.lang.model.element.VariableElement; + import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeKind; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; @@ -15,7 +20,9 @@ public static TruffleTypes getTypes() { return ProcessorContext.getInstance().getTypes(); } - // new + public static String toScreamCase(String s) { + return s.replaceAll("([a-z])([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); + } public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement... arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -85,4 +92,22 @@ public static CodeTree createWriteLocal(ExecuteVariables vars, CodeTree offset, .tree(value) // .end(3).build(); } + + public static CodeTree changeAllVariables(CodeTree tree, VariableElement from, VariableElement to) { + // EXTREME HACK + + if (tree.getCodeKind() == CodeTreeKind.STRING && tree.getString().equals(from.getSimpleName().toString())) { + return CodeTreeBuilder.singleString(to.getSimpleName().toString()); + } else { + List enc = tree.getEnclosedElements(); + if (enc == null) { + return tree; + } + for (int i = 0; i < enc.size(); i++) { + CodeTree res = changeAllVariables(enc.get(i), from, to); + enc.set(i, res); + } + return tree; + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index e070ca2d36eb..6e38742c8f21 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -6,57 +6,37 @@ import java.util.Set; import java.util.Stack; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.AnnotationValueVisitor; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; -import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.AnnotationProcessor; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.parser.NodeParser; public class OperationsCodeGenerator extends CodeTypeElementFactory { private ProcessorContext context; - private AnnotationProcessor processor; private OperationsData m; - private final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); - private final Set MOD_PUBLIC_STATIC_FINAL = Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL); - private final Set MOD_PUBLIC_STATIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.ABSTRACT); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); - private final Set MOD_STATIC = Set.of(Modifier.STATIC); /** * Creates the builder class itself. This class only contains abstract methods, the builder @@ -95,17 +75,9 @@ CodeTypeElement createBuilder(String simpleName) { CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "emit" + op.name, paramsArr); typBuilder.add(metEmit); } - - if (op instanceof Operation.Custom) { - Operation.Custom customOp = (Operation.Custom) op; - List genNode = createOperationNode(typBuilder, customOp.instruction); - typBuilder.addAll(genNode); - } } if (m.hasErrors()) { - // throw new RuntimeException(String.join("\n", m.collectMessages().stream().map(x -> - // x.getText()).toList())); return typBuilder; } @@ -134,6 +106,22 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); typBuilderImpl.add(leBytes); + for (Operation op : m.getOperationsContext().operations) { + CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); + CodeTreeBuilder b = fldId.createInitBuilder(); + b.string("" + op.id); + op.setIdConstantField(fldId); + typBuilderImpl.add(fldId); + } + + for (Instruction instr : m.getOperationsContext().instructions) { + CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "INSTR_" + OperationGeneratorUtils.toScreamCase(instr.name)); + CodeTreeBuilder b = fldId.createInitBuilder(); + b.string("" + instr.id); + instr.setOpcodeIdField(fldId); + typBuilderImpl.add(fldId); + } + CodeTypeElement builderLabelImplType = createBuilderLabelImpl(simpleName + "Label"); typBuilderImpl.add(builderLabelImplType); @@ -281,7 +269,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (afterChild == null) continue; - b.startCase().string(parentOp.id + " /* " + parentOp.name + " */").end(); + b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); b.tree(afterChild); @@ -316,7 +304,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (afterChild == null) continue; - b.startCase().string(parentOp.id + " /* " + parentOp.name + " */").end(); + b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); b.tree(afterChild); @@ -365,7 +353,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("doBeforeChild()"); - b.startStatement().startCall(fldTypeStack, "push").string("" + op.id).end(2); + b.startStatement().startCall(fldTypeStack, "push").variable(op.idConstantField).end(2); b.startStatement().startCall(fldChildIndexStack, "push").string("0").end(2); vars.arguments = metBegin.getParameters().toArray(new CodeVariableElement[0]); @@ -395,7 +383,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); - b.startAssert().startCall(fldTypeStack, "pop").end().string(" == " + op.id).end(); + b.startAssert().startCall(fldTypeStack, "pop").end().string(" == ").variable(op.idConstantField).end(); vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); b.declaration("int", "numChildren", "childIndexStack.pop()"); @@ -422,8 +410,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.declaration("Object[]", "args", fldArgumentStack.getName() + ".pop()"); } - int actualParamIndex = 0; - CodeVariableElement[] varArgs = new CodeVariableElement[argInfo.size()]; for (int i = 0; i < argInfo.size(); i++) { if (argInfo.get(i).isImplicit()) @@ -519,6 +505,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { } ExecuteVariables vars = new ExecuteVariables(); + vars.bytecodeNodeType = builderBytecodeNodeType; vars.bc = fldBc; vars.consts = fldConsts; vars.maxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); @@ -586,7 +573,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startBlock(); for (Instruction op : m.getInstructions()) { - b.startCase().string(op.id + " /* " + op.name + " */").end(); + b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); b.tree(op.createExecuteCode(vars)); @@ -599,7 +586,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.end(); // switch block - b.end().startCatchBlock(context.getType(Throwable.class), "ex"); + b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); b.startFor().string("int handlerIndex = 0; handlerIndex < " + vars.handlers.getName() + ".length; handlerIndex++").end(); b.startBlock(); @@ -662,7 +649,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startBlock(); for (Instruction op : m.getInstructions()) { - b.startCase().string("" + op.id).end(); + b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); b.statement("sb.append(\"" + op.name + " \")"); @@ -720,14 +707,14 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startBlock(); for (Instruction op : m.getInstructions()) { - b.startCase().string("" + op.id).end(); + b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); b.startStatement(); b.startCall("insts", "add"); b.startNew(types.InstructionTrace); - b.string("" + op.id); + b.variable(op.opcodeIdField); b.startGroup().variable(fldHitCount).string("[bci]").end(); int ofs = 1; @@ -779,129 +766,6 @@ private CodeVariableElement createStackField(String name, TypeMirror argType) { return element; } - private List createOperationNode(CodeTypeElement typEnc, Instruction.Custom instruction) { - TypeElement t = instruction.type; - - PackageElement pack = ElementUtils.findPackageElement(t); - CodeTypeElement typProxy = new CodeTypeElement(MOD_PUBLIC_STATIC_ABSTRACT, ElementKind.CLASS, pack, - t.getSimpleName() + "Gen"); - - typProxy.setSuperClass(types.Node); - typProxy.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); - GeneratorUtils.addGeneratedBy(context, typProxy, t); - typProxy.setEnclosingElement(typEnc); - - { - TypeMirror retType = instruction.stackPushes > 0 ? context.getType(Object.class) : context.getType(void.class); - CodeExecutableElement metExecute = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, retType, "execute"); - typProxy.add(metExecute); - - for (int i = 0; i < instruction.stackPops; i++) { - CodeVariableElement par; - if (i == instruction.stackPops - 1 && instruction.isVarArgs) { - par = new CodeVariableElement(arrayOf(context.getType(Object.class)), "arg" + i); - } else { - par = new CodeVariableElement(context.getType(Object.class), "arg" + i); - } - metExecute.addParameter(par); - } - } - - for (VariableElement el : ElementFilter.fieldsIn(instruction.type.getEnclosedElements())) { - if (el.getModifiers().contains(Modifier.FINAL)) { - CodeVariableElement fldProxy = new CodeVariableElement(el.getModifiers(), el.asType(), el.getSimpleName().toString()); - fldProxy.createInitBuilder().staticReference(el); - typProxy.add(fldProxy); - } - } - - for (ExecutableElement el : ElementFilter.methodsIn(instruction.type.getEnclosedElements())) { - CodeExecutableElement metProxy = new CodeExecutableElement(el.getModifiers(), el.getReturnType(), - el.getSimpleName().toString()); - for (VariableElement par : el.getParameters()) { - metProxy.addParameter(par); - } - for (AnnotationMirror ann : el.getAnnotationMirrors()) { - metProxy.addAnnotationMirror(ann); - } - - CodeTreeBuilder b = metProxy.getBuilder(); - - if (metProxy.getReturnType().getKind() != TypeKind.VOID) { - b.startReturn(); - } else { - b.startStatement(); - } - - b.startStaticCall(el); - for (VariableElement par : el.getParameters()) { - b.variable(par); - } - b.end(); - - b.end(); - - typProxy.add(metProxy); - } - - List result = new ArrayList<>(2); - result.add(typProxy); - - NodeParser parser = NodeParser.createDefaultParser(); - NodeData data = parser.parse(typProxy); - if (data == null) { - m.addError(t, "Could not generate node data"); - return List.of(typProxy); - } - - data.redirectMessagesOnGeneratedElements(m); - - if (data.hasErrors()) { - return List.of(typProxy); - } - - NodeCodeGenerator gen = new NodeCodeGenerator(); - List genList = gen.create(context, processor, data); - if (genList == null) { - return List.of(typProxy); - } - CodeTypeElement genResult = genList.get(0); - - CodeTypeElement genUncached = null; - - for (TypeElement el : ElementFilter.typesIn(genResult.getEnclosedElements())) { - if (el.getSimpleName().toString().equals("Uncached")) { - genUncached = (CodeTypeElement) el; - break; - } - } - - assert genUncached != null; - - for (VariableElement v : ElementFilter.fieldsIn(genResult.getEnclosedElements())) { - if (v.getModifiers().contains(Modifier.STATIC) && !v.getSimpleName().toString().equals("UNCACHED")) { - genUncached.add(v); - } - } - - genUncached.setSimpleName(CodeNames.of(t.getSimpleName() + "Uncached")); - GeneratorUtils.addGeneratedBy(context, genUncached, t); - - { - CodeVariableElement fldInstance = new CodeVariableElement(MOD_PUBLIC_STATIC_FINAL, genUncached.asType(), "UNCACHED"); - CodeTreeBuilder b = fldInstance.createInitBuilder(); - b.startNew(genUncached.asType()); - b.end(); - genUncached.add(fldInstance); - - instruction.setUncachedInstance(fldInstance); - } - - result.add(genUncached); - - return result; - } - private static TypeMirror generic(TypeElement el, TypeMirror... params) { return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); } @@ -914,7 +778,6 @@ private static TypeMirror arrayOf(TypeMirror el) { @SuppressWarnings("hiding") public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { this.context = context; - this.processor = processor; this.m = m; String simpleName = m.getTemplateType().getSimpleName() + "Builder"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java similarity index 70% rename from truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java rename to truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 01667f898a4a..7d9d4381d231 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -2,7 +2,9 @@ import java.util.ArrayList; -public class OperationsBuilder { +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; + +public class OperationsContext { private int instructionId = 1; private int operationId = 1; @@ -14,7 +16,7 @@ public class OperationsBuilder { public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); - public OperationsBuilder() { + public OperationsContext() { createCommonInstructions(); createBuiltinOperations(); } @@ -53,12 +55,33 @@ public Operation add(Operation elem) { } public int getNextInstructionId() { - // TODO Auto-generated method stub return instructionId++; } public int getNextOperationId() { - // TODO Auto-generated method stub return operationId++; } + + public void processOperation(SingleOperationData opData) { + Argument[] arguments; + + MethodProperties props = opData.getMainProperties(); + + if (props == null) { + opData.addError("Operation %s not initialized", opData.getName()); + return; + } + + if (props.isVariadic) { + arguments = new Argument[]{new Argument.VarArgsCount(props.numParameters - 1)}; + } else { + arguments = new Argument[0]; + } + + Instruction.Custom instr = new Instruction.Custom("custom." + opData.getName(), getNextInstructionId(), opData, arguments); + add(instr); + + Operation.Custom op = new Operation.Custom(this, opData.getName(), getNextOperationId(), props.numParameters, instr); + add(op); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index a3378b008d2b..a456755541a3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -2,33 +2,19 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; -import java.util.Set; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.TypeElement; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.Template; public class OperationsData extends Template { - static class OperationData { - final String name; - final int numParameters; - final boolean isVariadic; - final boolean returnsValue; - - public OperationData(String name, int numParameters, boolean isVariadic, boolean returnsValue) { - this.name = name; - this.numParameters = numParameters; - this.isVariadic = isVariadic; - this.returnsValue = returnsValue; - } - } - - private final OperationsBuilder builder = new OperationsBuilder(); + private final List operations = new ArrayList<>(); + private final OperationsContext context = new OperationsContext(); private boolean tracing; @@ -36,8 +22,17 @@ public OperationsData(ProcessorContext context, TypeElement templateType, Annota super(context, templateType, annotation); } - public OperationsBuilder getOperationsBuilder() { - return builder; + public OperationsContext getOperationsContext() { + return context; + } + + public void addOperationData(SingleOperationData data) { + operations.add(data); + } + + @Override + protected List findChildContainers() { + return List.copyOf(operations); } public void setTracing(boolean tracing) { @@ -49,18 +44,21 @@ public boolean isTracing() { } public Collection getInstructions() { - return builder.instructions; + return context.instructions; } - public Collection getCustomOperations() { - return builder.operations.stream()// - .filter(x -> x instanceof Operation.Custom)// - .map(x -> (Operation.Custom) x)// - .toList(); + public Collection getOperationData() { + return operations; } public Collection getOperations() { - return builder.operations; + return context.operations; + } + + public void initializeContext() { + for (SingleOperationData data : operations) { + context.processOperation(data); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index a74ee311b45a..be6a70b34353 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,21 +1,14 @@ package com.oracle.truffle.dsl.processor.operations; -import java.util.ArrayList; import java.util.List; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsData.OperationData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { @@ -37,122 +30,44 @@ protected OperationsData parse(Element element, List mirror) { OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); - for (Element e : typeElement.getEnclosedElements()) { - AnnotationMirror operationMirror = getAnnotationMirror(e.getAnnotationMirrors(), types.Operation); - if (operationMirror == null) { + boolean hasSome = false; + + for (Element inner : typeElement.getEnclosedElements()) { + if (!(inner instanceof TypeElement)) { continue; } - processOperation(data, (TypeElement) e); - - } - - data.setTracing(true); - - return data; - } - - private boolean isIgnoredParameter(VariableElement param) { - if (ElementUtils.findAnnotationMirror(param, types.Cached) != null) { - return true; - } else if (ElementUtils.findAnnotationMirror(param, types.CachedLibrary) != null) { - return true; - } else if (ElementUtils.findAnnotationMirror(param, types.CachedLanguage) != null) { - return true; - } - - return false; - } - - private boolean isVariadicParameter(VariableElement param) { - return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; - } - - private OperationData processMethod(OperationsData data, ExecutableElement method) { - List arguments = List.of(); // TODO - - int numChildren = 0; - boolean isVariadic = false; - - for (VariableElement param : method.getParameters()) { - if (isVariadicParameter(param)) { - if (isVariadic) { - data.addError(method, "Multiple @Variadic arguments not allowed"); - } - isVariadic = true; - numChildren++; - } else if (!isIgnoredParameter(param)) { - if (isVariadic) { - data.addError(method, "Value arguments after @Variadic not allowed"); - } - numChildren++; + if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { + continue; } - } - boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; + hasSome = true; - return new OperationData(method.getEnclosingElement().getSimpleName().toString(), numChildren, isVariadic, returnsValue); - } + SingleOperationData opData = new SingleOperationParser(data).parse(inner, false); - private void processOperation(OperationsData data, TypeElement te) { - List operationFunctions = new ArrayList<>(); - for (Element el : te.getEnclosedElements()) { - if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { - data.addError(el, "Operations must not contain non-static members"); + if (opData != null) { +// opData.redirectMessages(data); + data.addOperationData(opData); + } else { + data.addError("Could not generate operation: " + inner.getSimpleName()); } - if (el instanceof ExecutableElement) { - ExecutableElement cel = (ExecutableElement) el; - if (isOperationFunction(cel)) { - operationFunctions.add(cel); - } - } - } - if (operationFunctions.isEmpty()) { - data.addWarning(te, "Operation contains no operation functions (public static methods)"); - return; } - OperationData opData = processMethod(data, operationFunctions.get(0)); + if (!hasSome) { + data.addWarning("No operations found"); + return data; + } - for (ExecutableElement fun : operationFunctions) { - OperationData opData2 = processMethod(data, fun); + data.setTracing(true); - if (opData2.isVariadic != opData.isVariadic) { - data.addError(fun, "All operation functions should be variadic / non-variadic"); - } - if (opData2.returnsValue != opData.returnsValue) { - data.addError(fun, "All operation functions should return value / be void"); - } - if (opData2.numParameters != opData.numParameters) { - data.addError(fun, "All operation functions should have same number of parameters"); - } + if (data.hasErrors()) { + return data; } - OperationsBuilder builder = data.getOperationsBuilder(); - - Instruction.Custom instr; - if (opData.isVariadic) { - instr = new Instruction.Custom( - "custom." + te.getSimpleName(), - builder.getNextInstructionId(), - opData.numParameters, true, - !opData.returnsValue, te, - new Argument.VarArgsCount(opData.numParameters - 1)); - } else { - instr = new Instruction.Custom( - "custom." + te.getSimpleName(), - builder.getNextInstructionId(), - opData.numParameters, false, - !opData.returnsValue, te); - } - builder.add(instr); - Operation.Custom op = new Operation.Custom(builder, te.getSimpleName().toString(), builder.getNextOperationId(), opData.numParameters, instr); - builder.add(op); - } + data.initializeContext(); - private static boolean isOperationFunction(ExecutableElement el) { - return el.getModifiers().contains(Modifier.PUBLIC) && el.getModifiers().contains(Modifier.STATIC); + return data; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java new file mode 100644 index 000000000000..c8142a2ec89e --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -0,0 +1,83 @@ +package com.oracle.truffle.dsl.processor.operations; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.model.MessageContainer; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.model.Template; + +public class SingleOperationData extends Template { + private final String name; + private MethodProperties mainProperties; + private NodeData nodeData; + private OperationsData parent; + + static class MethodProperties { + public final ExecutableElement element; + public final int numParameters; + public final boolean isVariadic; + public final boolean returnsValue; + + public MethodProperties(ExecutableElement element, int numParameters, boolean isVariadic, boolean returnsValue) { + this.element = element; + this.numParameters = numParameters; + this.isVariadic = isVariadic; + this.returnsValue = returnsValue; + } + + public void checkMatches(SingleOperationData data, MethodProperties other) { + if (other.numParameters != numParameters) { + data.addError(element, "All methods must have same number of arguments"); + } + + if (other.isVariadic != isVariadic) { + data.addError(element, "All methods must (not) be variadic"); + } + + if (other.returnsValue != returnsValue) { + data.addError(element, "All methods must (not) return value"); + } + } + + @Override + public String toString() { + return "Props[parameters=" + numParameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + "]"; + } + } + + public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent) { + super(context, templateType, annotation); + this.parent = parent; + name = templateType.getSimpleName().toString(); + } + + @Override + public MessageContainer getBaseContainer() { + return parent; + } + + public String getName() { + return name; + } + + public MethodProperties getMainProperties() { + return mainProperties; + } + + public void setMainProperties(MethodProperties mainProperties) { + this.mainProperties = mainProperties; + } + + public NodeData getNodeData() { + return nodeData; + } + + void setNodeData(NodeData data) { + this.nodeData = data; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java new file mode 100644 index 000000000000..abd8f2a4b971 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -0,0 +1,212 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; +import com.oracle.truffle.dsl.processor.parser.AbstractParser; +import com.oracle.truffle.dsl.processor.parser.NodeParser; + +public class SingleOperationParser extends AbstractParser { + + private final OperationsData parentData; + + public SingleOperationParser(OperationsData parentData) { + this.parentData = parentData; + } + + @Override + protected SingleOperationData parse(Element element, List mirror) { + if (!(element instanceof TypeElement)) { + parentData.addError(element, "@Operation can only be attached to a type"); + return null; + } + + TypeElement te = (TypeElement) element; + TypeElement proxyType; + + AnnotationMirror annOperation = ElementUtils.findAnnotationMirror(mirror, types.Operation); + + DeclaredType proxyDecl = ElementUtils.getAnnotationValue(DeclaredType.class, annOperation, "proxyNode"); + if (proxyDecl.equals(context.getDeclaredType(Void.class))) { + proxyType = null; + } else { + proxyType = ((TypeElement) proxyDecl.asElement()); + } + + SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(mirror, getAnnotationType()), parentData); + + List operationFunctions = new ArrayList<>(); + for (Element el : te.getEnclosedElements()) { + if (el.getModifiers().contains(Modifier.PRIVATE)) { + continue; + } + if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { + data.addError(el, "Operations must not contain non-static members"); + } + if (el instanceof ExecutableElement) { + ExecutableElement cel = (ExecutableElement) el; + if (isOperationFunction(cel)) { + operationFunctions.add(cel); + } + } + } + + if (proxyType != null) { + CodeTypeElement teClone = CodeTypeElement.cloneShallow(te); + te = teClone; + for (Element el : CompilerFactory.getCompiler(proxyType).getEnclosedElementsInDeclarationOrder(proxyType)) { + if (el instanceof ExecutableElement && isStaticAccessible(el)) { + teClone.add(el); + if (isOperationFunction((ExecutableElement) el)) { + operationFunctions.add((ExecutableElement) el); + } + } + } + + } + + if (operationFunctions.isEmpty()) { + data.addError("Operation contains no operation functions (public static methods)"); + return data; + } + + MethodProperties props = processMethod(data, te, operationFunctions.get(0)); + + for (ExecutableElement fun : operationFunctions) { + MethodProperties props2 = processMethod(data, te, fun); + + props2.checkMatches(data, props); + } + + if (data.hasErrors()) { + return data; + } + + data.setMainProperties(props); + + CodeTypeElement clonedType = te instanceof CodeTypeElement ? (CodeTypeElement) te : CodeTypeElement.cloneShallow(te); + clonedType.setEnclosingElement(te.getEnclosingElement()); + clonedType.setSuperClass(types.Node); + + CodeExecutableElement metExecute = new CodeExecutableElement( + Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), + context.getType(props.returnsValue ? Object.class : void.class), "execute"); + + for (int i = 0; i < props.numParameters; i++) { + TypeMirror typParam = context.getType(Object.class); + if (props.isVariadic && i == props.numParameters - 1) { + typParam = new ArrayCodeTypeMirror(context.getType(Object.class)); + } + + metExecute.addParameter(new CodeVariableElement(typParam, "arg" + i)); + } + clonedType.add(metExecute); + + if (ElementUtils.findAnnotationMirror(clonedType, types.GenerateUncached) == null) { + clonedType.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); + } + + if (proxyType != null) { + // add all the constants + for (VariableElement el : ElementFilter.fieldsIn(proxyType.getEnclosedElements())) { + if (el.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { + CodeVariableElement cel = new CodeVariableElement(Set.of(Modifier.STATIC, Modifier.FINAL), el.asType(), el.getSimpleName().toString()); + cel.createInitBuilder().staticReference(el); + clonedType.add(cel); + } + } + } + + NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); + + if (nodeData == null) { + data.addError(te, "Could not parse invalid node"); + return data; + } + + nodeData.redirectMessages(data); + data.setNodeData(nodeData); + + return data; + } + + @Override + public DeclaredType getAnnotationType() { + return types.Operation; + } + + private MethodProperties processMethod(SingleOperationData data, TypeElement te, ExecutableElement method) { + List arguments = List.of(); // TODO + + int numChildren = 0; + boolean isVariadic = false; + + for (VariableElement param : method.getParameters()) { + if (isVariadicParameter(param)) { + if (isVariadic) { + data.addError(method, "Multiple @Variadic arguments not allowed"); + } + isVariadic = true; + numChildren++; + } else if (!isIgnoredParameter(param)) { + if (isVariadic) { + data.addError(method, "Value arguments after @Variadic not allowed"); + } + numChildren++; + } + } + + boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; + + MethodProperties props = new MethodProperties(method, numChildren, isVariadic, returnsValue); + + return props; + } + + private boolean isIgnoredParameter(VariableElement param) { + if (ElementUtils.findAnnotationMirror(param, types.Cached) != null) { + return true; + } else if (ElementUtils.findAnnotationMirror(param, types.CachedLibrary) != null) { + return true; + } else if (ElementUtils.findAnnotationMirror(param, types.CachedLanguage) != null) { + return true; + } + + return false; + } + + private boolean isVariadicParameter(VariableElement param) { + return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; + } + + private static boolean isStaticAccessible(Element elem) { + return !elem.getModifiers().contains(Modifier.PRIVATE) && elem.getModifiers().contains(Modifier.STATIC); + } + + private boolean isOperationFunction(ExecutableElement el) { + return ElementUtils.findAnnotationMirror(el, types.Specialization) != null; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 21d83cc82489..f7dcdce32a67 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -158,7 +158,8 @@ public final class NodeParser extends AbstractParser { public enum ParseMode { DEFAULT, - EXPORTED_MESSAGE + EXPORTED_MESSAGE, + OPERATION } private boolean nodeOnly; @@ -193,6 +194,10 @@ public static NodeParser createDefaultParser() { return new NodeParser(ParseMode.DEFAULT, null, null, false); } + public static NodeParser createOperationParser() { + return new NodeParser(ParseMode.OPERATION, null, null, true); + } + @Override protected NodeData parse(Element element, List mirror) { NodeData node = parseRootType((TypeElement) element); @@ -284,7 +289,7 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } - if (ElementUtils.findAnnotationMirror(templateType.getAnnotationMirrors(), types.Operation) != null) { + if (mode == ParseMode.DEFAULT && ElementUtils.findAnnotationMirror(templateType.getAnnotationMirrors(), types.Operation) != null) { return null; } @@ -1721,7 +1726,7 @@ private void initializeExecutableTypes(NodeData node) { "The following execute methods do not provide all evaluated values for the expected signature size %s: %s.", executions.size(), requireNodeChildDeclarations); } - if (nodeChildDeclarations > 0 && executions.size() == node.getMinimalEvaluatedParameters()) { + if (mode == ParseMode.DEFAULT && nodeChildDeclarations > 0 && executions.size() == node.getMinimalEvaluatedParameters()) { for (NodeChildData child : node.getChildren()) { child.addError("Unnecessary @NodeChild declaration. All evaluated child values are provided as parameters in execute methods."); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java similarity index 92% rename from truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 8b69584dbd0d..4907dc665d88 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/slexample/SlOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,13 +1,9 @@ -package com.oracle.truffle.api.operation.test.slexample; +package com.oracle.truffle.sl.operations; -import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrumentation.StandardTags; -import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -15,16 +11,12 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node.Child; -import com.oracle.truffle.api.nodes.Node.Children; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.util.SLToMemberNode; import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; import com.oracle.truffle.sl.runtime.SLBigNumber; @@ -32,7 +24,7 @@ import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations -public class SlOperations { +public class SLOperations { @Operation public static class SLAddOperation { From ddee69daa4a8b8dd33fe7945ec40cc45d3c83cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 14 Mar 2022 14:52:25 +0100 Subject: [PATCH 016/312] [wip] new SL parser --- truffle/mx.truffle/mx_truffle.py | 1 + .../dsl/processor/java/ElementUtils.java | 13 +- .../operations/OperationsCodeGenerator.java | 4 +- .../operations/SingleOperationData.java | 10 +- .../operations/SingleOperationParser.java | 29 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 5 +- .../sl/nodes/expression/SLAddNode.java | 14 +- .../sl/nodes/expression/SLDivNode.java | 10 +- .../sl/nodes/expression/SLEqualNode.java | 16 +- .../nodes/expression/SLLessOrEqualNode.java | 8 +- .../sl/nodes/expression/SLLessThanNode.java | 8 +- .../sl/nodes/expression/SLLogicalNotNode.java | 6 +- .../sl/nodes/expression/SLMulNode.java | 10 +- .../nodes/expression/SLReadPropertyNode.java | 14 +- .../sl/nodes/expression/SLSubNode.java | 10 +- .../nodes/expression/SLWritePropertyNode.java | 12 +- .../truffle/sl/nodes/util/SLToMemberNode.java | 18 +- .../sl/nodes/util/SLToTruffleStringNode.java | 16 +- .../truffle/sl/nodes/util/SLUnboxNode.java | 14 +- .../truffle/sl/operations/SLOperations.java | 152 +- .../truffle/sl/parser/SimpleLanguage.g4 | 3 +- .../sl/parser/SimpleLanguageParser.java | 33 +- .../sl/parser/operations/SLBaseVisitor.java | 115 ++ .../sl/parser/operations/SLNodeVisitor.java | 586 +++++++ .../operations/SimpleLanguageOperations.g4 | 189 +++ .../SimpleLanguageOperationsBaseVisitor.java | 185 +++ .../SimpleLanguageOperationsLexer.java | 251 +++ .../SimpleLanguageOperationsParser.java | 1409 +++++++++++++++++ .../SimpleLanguageOperationsVisitor.java | 168 ++ 29 files changed, 3087 insertions(+), 222 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 1936c1e06e65..f2be9d13db12 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -662,6 +662,7 @@ def create_dsl_parser(args=None, out=None): def create_sl_parser(args=None, out=None): """create the SimpleLanguage parser using antlr""" create_parser("com.oracle.truffle.sl", "com.oracle.truffle.sl.parser", "SimpleLanguage", COPYRIGHT_HEADER_UPL, args, out) + create_parser("com.oracle.truffle.sl", "com.oracle.truffle.sl.parser.operations", "SimpleLanguageOperations", COPYRIGHT_HEADER_UPL, ['-visitor'] + args, out) def create_parser(grammar_project, grammar_package, grammar_name, copyright_template, args=None, out=None, postprocess=None): """create the DSL expression parser using antlr""" diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index ff765dea3d1f..3a2da0ddb35b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -185,7 +185,11 @@ public static TypeElement getTypeElement(final ProcessingEnvironment processingE } public static ExecutableElement findExecutableElement(DeclaredType type, String name) { - List elements = ElementFilter.methodsIn(type.asElement().getEnclosedElements()); + return findExecutableElement(type.asElement(), name); + } + + public static ExecutableElement findExecutableElement(Element element, String name) { + List elements = ElementFilter.methodsIn(element.getEnclosedElements()); for (ExecutableElement executableElement : elements) { if (executableElement.getSimpleName().toString().equals(name) && !isDeprecated(executableElement)) { return executableElement; @@ -195,8 +199,11 @@ public static ExecutableElement findExecutableElement(DeclaredType type, String } public static ExecutableElement findExecutableElement(DeclaredType type, String name, int argumentCount) { - List elements = ElementFilter.methodsIn(type.asElement().getEnclosedElements()); - for (ExecutableElement executableElement : elements) { + return findExecutableElement(type.asElement(), name, argumentCount); + } + + public static ExecutableElement findExecutableElement(Element element, String name, int argumentCount) { + for (ExecutableElement executableElement : ElementFilter.methodsIn(element.getEnclosedElements())) { if (executableElement.getParameters().size() == argumentCount && executableElement.getSimpleName().toString().equals(name) && !isDeprecated(executableElement)) { return executableElement; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 6e38742c8f21..ee3fe3a55c01 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -513,6 +513,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { { CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); + builderBytecodeNodeType.add(mExecute); CodeTreeBuilder builder = mExecute.getBuilder(); builder.startReturn(); @@ -523,7 +524,6 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { builder.end(2); - builderBytecodeNodeType.add(mExecute); } { @@ -532,6 +532,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeExecutableElement mContinueAt = new CodeExecutableElement( Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", argFrame, argStartIndex); + builderBytecodeNodeType.add(mContinueAt); { CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); @@ -622,7 +623,6 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { vars.sp = null; vars.returnValue = null; - builderBytecodeNodeType.add(mContinueAt); } { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index c8142a2ec89e..e5eec520e832 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -1,9 +1,12 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.HashSet; +import java.util.Set; + import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.model.MessageContainer; @@ -15,6 +18,7 @@ public class SingleOperationData extends Template { private MethodProperties mainProperties; private NodeData nodeData; private OperationsData parent; + private final Set throwDeclarations = new HashSet<>(); static class MethodProperties { public final ExecutableElement element; @@ -64,6 +68,10 @@ public String getName() { return name; } + public Set getThrowDeclarations() { + return throwDeclarations; + } + public MethodProperties getMainProperties() { return mainProperties; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index abd8f2a4b971..6e88e45e3bf5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -96,8 +96,8 @@ protected SingleOperationData parse(Element element, List mirr for (ExecutableElement fun : operationFunctions) { MethodProperties props2 = processMethod(data, te, fun); - props2.checkMatches(data, props); + data.getThrowDeclarations().addAll(fun.getThrownTypes()); } if (data.hasErrors()) { @@ -110,19 +110,26 @@ protected SingleOperationData parse(Element element, List mirr clonedType.setEnclosingElement(te.getEnclosingElement()); clonedType.setSuperClass(types.Node); - CodeExecutableElement metExecute = new CodeExecutableElement( - Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), - context.getType(props.returnsValue ? Object.class : void.class), "execute"); + if (proxyType != null) { + clonedType.addOptional(ElementUtils.findExecutableElement(proxyType, "execute")); + } - for (int i = 0; i < props.numParameters; i++) { - TypeMirror typParam = context.getType(Object.class); - if (props.isVariadic && i == props.numParameters - 1) { - typParam = new ArrayCodeTypeMirror(context.getType(Object.class)); - } + if (ElementUtils.findExecutableElement(te, "execute") == null) { - metExecute.addParameter(new CodeVariableElement(typParam, "arg" + i)); + CodeExecutableElement metExecute = new CodeExecutableElement( + Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), + context.getType(props.returnsValue ? Object.class : void.class), "execute"); + + for (int i = 0; i < props.numParameters; i++) { + TypeMirror typParam = context.getType(Object.class); + if (props.isVariadic && i == props.numParameters - 1) { + typParam = new ArrayCodeTypeMirror(context.getType(Object.class)); + } + + metExecute.addParameter(new CodeVariableElement(typParam, "arg" + i)); + } + clonedType.add(metExecute); } - clonedType.add(metExecute); if (ElementUtils.findAnnotationMirror(clonedType, types.GenerateUncached) == null) { clonedType.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 3289ccf7c9a4..665f01d48217 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -106,6 +106,7 @@ import com.oracle.truffle.sl.parser.SLNodeFactory; import com.oracle.truffle.sl.parser.SimpleLanguageLexer; import com.oracle.truffle.sl.parser.SimpleLanguageParser; +import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; @@ -309,7 +310,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { * the functions with the SLContext happens lazily in SLEvalRootNode. */ if (request.getArgumentNames().isEmpty()) { - functions = SimpleLanguageParser.parseSL(this, source); + functions = SLNodeVisitor.parseSL(this, source); } else { StringBuilder sb = new StringBuilder(); sb.append("function main("); @@ -324,7 +325,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { sb.append(";}"); String language = source.getLanguage() == null ? ID : source.getLanguage(); Source decoratedSource = Source.newBuilder(language, sb.toString(), source.getName()).build(); - functions = SimpleLanguageParser.parseSL(this, decoratedSource); + functions = SLNodeVisitor.parseSL(this, decoratedSource); } RootCallTarget main = functions.get(SLStrings.MAIN); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index 50731ac677fc..09640d4a98b3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -83,7 +83,7 @@ public abstract class SLAddNode extends SLBinaryNode { * operand are {@code long} values. */ @Specialization(rewriteOn = ArithmeticException.class) - protected long add(long left, long right) { + public static long addLong(long left, long right) { return Math.addExact(left, right); } @@ -99,9 +99,9 @@ protected long add(long left, long right) { * specialization} has the {@code rewriteOn} attribute, this specialization is also taken if * both input values are {@code long} values but the primitive addition overflows. */ - @Specialization + @Specialization(replaces = "addLong") @TruffleBoundary - protected SLBigNumber add(SLBigNumber left, SLBigNumber right) { + public static SLBigNumber add(SLBigNumber left, SLBigNumber right) { return new SLBigNumber(left.getValue().add(right.getValue())); } @@ -115,7 +115,7 @@ protected SLBigNumber add(SLBigNumber left, SLBigNumber right) { */ @Specialization(guards = "isString(left, right)") @TruffleBoundary - protected TruffleString add(Object left, Object right, + public static TruffleString add(Object left, Object right, @Cached SLToTruffleStringNode toTruffleStringNodeLeft, @Cached SLToTruffleStringNode toTruffleStringNodeRight, @Cached TruffleString.ConcatNode concatNode) { @@ -126,12 +126,12 @@ protected TruffleString add(Object left, Object right, * Guard for TruffleString concatenation: returns true if either the left or the right operand * is a {@link TruffleString}. */ - protected boolean isString(Object a, Object b) { + public static boolean isString(Object a, Object b) { return a instanceof TruffleString || b instanceof TruffleString; } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java index 7ef3936b39c6..8a29bb8edd84 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java @@ -57,7 +57,7 @@ public abstract class SLDivNode extends SLBinaryNode { @Specialization(rewriteOn = ArithmeticException.class) - protected long div(long left, long right) throws ArithmeticException { + public static long divLong(long left, long right) throws ArithmeticException { long result = left / right; /* * The division overflows if left is Long.MIN_VALUE and right is -1. @@ -68,14 +68,14 @@ protected long div(long left, long right) throws ArithmeticException { return result; } - @Specialization + @Specialization(replaces = "divLong") @TruffleBoundary - protected SLBigNumber div(SLBigNumber left, SLBigNumber right) { + public static SLBigNumber div(SLBigNumber left, SLBigNumber right) { return new SLBigNumber(left.getValue().divide(right.getValue())); } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java index 1811bdcfc158..b94fb5f7b55b 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java @@ -68,40 +68,40 @@ public abstract class SLEqualNode extends SLBinaryNode { @Specialization - protected boolean doLong(long left, long right) { + public static boolean doLong(long left, long right) { return left == right; } @Specialization @TruffleBoundary - protected boolean doBigNumber(SLBigNumber left, SLBigNumber right) { + public static boolean doBigNumber(SLBigNumber left, SLBigNumber right) { return left.equals(right); } @Specialization - protected boolean doBoolean(boolean left, boolean right) { + public static boolean doBoolean(boolean left, boolean right) { return left == right; } @Specialization - protected boolean doString(String left, String right) { + public static boolean doString(String left, String right) { return left.equals(right); } @Specialization - protected boolean doTruffleString(TruffleString left, TruffleString right, + public static boolean doTruffleString(TruffleString left, TruffleString right, @Cached TruffleString.EqualNode equalNode) { return equalNode.execute(left, right, SLLanguage.STRING_ENCODING); } @Specialization - protected boolean doNull(SLNull left, SLNull right) { + public static boolean doNull(SLNull left, SLNull right) { /* There is only the singleton instance of SLNull, so we do not need equals(). */ return left == right; } @Specialization - protected boolean doFunction(SLFunction left, Object right) { + public static boolean doFunction(SLFunction left, Object right) { /* * Our function registry maintains one canonical SLFunction object per function name, so we * do not need equals(). @@ -124,7 +124,7 @@ protected boolean doFunction(SLFunction left, Object right) { * replace the previous specializations, as they are still more efficient in the interpeter. */ @Specialization(limit = "4") - public boolean doGeneric(Object left, Object right, + public static boolean doGeneric(Object left, Object right, @CachedLibrary("left") InteropLibrary leftInterop, @CachedLibrary("right") InteropLibrary rightInterop) { /* diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java index b0cf8e9f8350..0241a93a1447 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java @@ -55,18 +55,18 @@ public abstract class SLLessOrEqualNode extends SLBinaryNode { @Specialization - protected boolean lessOrEqual(long left, long right) { + public static boolean lessOrEqual(long left, long right) { return left <= right; } @Specialization @TruffleBoundary - protected boolean lessOrEqual(SLBigNumber left, SLBigNumber right) { + public static boolean lessOrEqual(SLBigNumber left, SLBigNumber right) { return left.compareTo(right) <= 0; } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index 60138df8463f..58eaeac333f7 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -56,19 +56,19 @@ public abstract class SLLessThanNode extends SLBinaryNode { @Specialization - protected boolean lessThan(long left, long right) { + public static boolean lessThan(long left, long right) { return left < right; } @Specialization @TruffleBoundary - protected boolean lessThan(SLBigNumber left, SLBigNumber right) { + public static boolean lessThan(SLBigNumber left, SLBigNumber right) { return left.compareTo(right) < 0; } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java index 0eff7f861925..dba6764e67a2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java @@ -56,13 +56,13 @@ public abstract class SLLogicalNotNode extends SLExpressionNode { @Specialization - protected boolean doBoolean(boolean value) { + public static boolean doBoolean(boolean value) { return !value; } @Fallback - protected Object typeError(Object value) { - throw SLException.typeError(this, value); + public static Object typeError(Object value) { + throw SLException.typeError(null, value); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java index 024ca67b3d41..147cef2b6e67 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java @@ -55,19 +55,19 @@ public abstract class SLMulNode extends SLBinaryNode { @Specialization(rewriteOn = ArithmeticException.class) - protected long mul(long left, long right) { + public static long mulLong(long left, long right) { return Math.multiplyExact(left, right); } - @Specialization + @Specialization(replaces = "mulLong") @TruffleBoundary - protected SLBigNumber mul(SLBigNumber left, SLBigNumber right) { + public static SLBigNumber mul(SLBigNumber left, SLBigNumber right) { return new SLBigNumber(left.getValue().multiply(right.getValue())); } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index f05ca10da9c5..17151ffb04eb 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -73,43 +73,43 @@ public abstract class SLReadPropertyNode extends SLExpressionNode { static final int LIBRARY_LIMIT = 3; @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") - protected Object readArray(Object receiver, Object index, + public static Object readArray(Object receiver, Object index, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { return arrays.readArrayElement(receiver, numbers.asLong(index)); } catch (UnsupportedMessageException | InvalidArrayIndexException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, index); + throw SLUndefinedNameException.undefinedProperty(null, index); } } @Specialization(limit = "LIBRARY_LIMIT") - protected Object readSLObject(SLObject receiver, Object name, + public static Object readSLObject(SLObject receiver, Object name, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { TruffleString nameTS = toTruffleStringNode.execute(name); Object result = objectLibrary.getOrDefault(receiver, nameTS, null); if (result == null) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, nameTS); + throw SLUndefinedNameException.undefinedProperty(null, nameTS); } return result; } @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") - protected Object readObject(Object receiver, Object name, + public static Object readObject(Object receiver, Object name, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { try { return objects.readMember(receiver, asMember.execute(name)); } catch (UnsupportedMessageException | UnknownIdentifierException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, name); + throw SLUndefinedNameException.undefinedProperty(null, name); } } - static boolean isSLObject(Object receiver) { + public static boolean isSLObject(Object receiver) { return receiver instanceof SLObject; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index b21bb1d7496a..b6afe54690ea 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -55,19 +55,19 @@ public abstract class SLSubNode extends SLBinaryNode { @Specialization(rewriteOn = ArithmeticException.class) - protected long sub(long left, long right) { + public static long subLong(long left, long right) { return Math.subtractExact(left, right); } - @Specialization + @Specialization(replaces = "subLong") @TruffleBoundary - protected SLBigNumber sub(SLBigNumber left, SLBigNumber right) { + public static SLBigNumber sub(SLBigNumber left, SLBigNumber right) { return new SLBigNumber(left.getValue().subtract(right.getValue())); } @Fallback - protected Object typeError(Object left, Object right) { - throw SLException.typeError(this, left, right); + public static Object typeError(Object left, Object right) { + throw SLException.typeError(null, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 2f4cd97f7c9e..faef2cfcddd2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -76,20 +76,20 @@ public abstract class SLWritePropertyNode extends SLExpressionNode { static final int LIBRARY_LIMIT = 3; @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") - protected Object writeArray(Object receiver, Object index, Object value, + public static Object writeArray(Object receiver, Object index, Object value, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { arrays.writeArrayElement(receiver, numbers.asLong(index), value); } catch (UnsupportedMessageException | UnsupportedTypeException | InvalidArrayIndexException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, index); + throw SLUndefinedNameException.undefinedProperty(null, index); } return value; } @Specialization(limit = "LIBRARY_LIMIT") - protected Object writeSLObject(SLObject receiver, Object name, Object value, + public static Object writeSLObject(SLObject receiver, Object name, Object value, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { objectLibrary.put(receiver, toTruffleStringNode.execute(name), value); @@ -97,19 +97,19 @@ protected Object writeSLObject(SLObject receiver, Object name, Object value, } @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") - protected Object writeObject(Object receiver, Object name, Object value, + public static Object writeObject(Object receiver, Object name, Object value, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { objectLibrary.writeMember(receiver, asMember.execute(name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, name); + throw SLUndefinedNameException.undefinedProperty(null, name); } return value; } - static boolean isSLObject(Object receiver) { + public static boolean isSLObject(Object receiver) { return receiver instanceof SLObject; } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java index e239fd51ace8..0f538559b9cf 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java @@ -69,35 +69,35 @@ public abstract class SLToMemberNode extends Node { public abstract String execute(Object value) throws UnknownIdentifierException; @Specialization - protected static String fromString(String value) { + public static String fromString(String value) { return value; } @Specialization - protected static String fromTruffleString(TruffleString value, + public static String fromTruffleString(TruffleString value, @Cached TruffleString.ToJavaStringNode toJavaStringNode) { return toJavaStringNode.execute(value); } @Specialization - protected static String fromBoolean(boolean value) { + public static String fromBoolean(boolean value) { return String.valueOf(value); } @Specialization @TruffleBoundary - protected static String fromLong(long value) { + public static String fromLong(long value) { return String.valueOf(value); } @Specialization @TruffleBoundary - protected static String fromBigNumber(SLBigNumber value) { + public static String fromBigNumber(SLBigNumber value) { return value.toString(); } @Specialization(limit = "LIMIT") - protected static String fromInterop(Object value, @CachedLibrary("value") InteropLibrary interop) throws UnknownIdentifierException { + public static String fromInterop(Object value, @CachedLibrary("value") InteropLibrary interop) throws UnknownIdentifierException { try { if (interop.fitsInLong(value)) { return longToString(interop.asLong(value)); @@ -114,17 +114,17 @@ protected static String fromInterop(Object value, @CachedLibrary("value") Intero } @TruffleBoundary - private static UnknownIdentifierException error(Object value) { + public static UnknownIdentifierException error(Object value) { return UnknownIdentifierException.create(value.toString()); } @TruffleBoundary - private static String bigNumberToString(SLBigNumber value) { + public static String bigNumberToString(SLBigNumber value) { return value.toString(); } @TruffleBoundary - private static String longToString(long longValue) { + public static String longToString(long longValue) { return String.valueOf(longValue); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java index b9694b35961e..86c311d8d19d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java @@ -76,47 +76,47 @@ public abstract class SLToTruffleStringNode extends Node { public abstract TruffleString execute(Object value); @Specialization - protected static TruffleString fromNull(@SuppressWarnings("unused") SLNull value) { + public static TruffleString fromNull(@SuppressWarnings("unused") SLNull value) { return SLStrings.NULL; } @Specialization - protected static TruffleString fromString(String value, + public static TruffleString fromString(String value, @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { return fromJavaStringNode.execute(value, SLLanguage.STRING_ENCODING); } @Specialization - protected static TruffleString fromTruffleString(TruffleString value) { + public static TruffleString fromTruffleString(TruffleString value) { return value; } @Specialization - protected static TruffleString fromBoolean(boolean value) { + public static TruffleString fromBoolean(boolean value) { return value ? TRUE : FALSE; } @Specialization @TruffleBoundary - protected static TruffleString fromLong(long value, + public static TruffleString fromLong(long value, @Cached TruffleString.FromLongNode fromLongNode) { return fromLongNode.execute(value, SLLanguage.STRING_ENCODING, true); } @Specialization @TruffleBoundary - protected static TruffleString fromBigNumber(SLBigNumber value, + public static TruffleString fromBigNumber(SLBigNumber value, @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { return fromJavaStringNode.execute(value.toString(), SLLanguage.STRING_ENCODING); } @Specialization - protected static TruffleString fromFunction(SLFunction value) { + public static TruffleString fromFunction(SLFunction value) { return value.getName(); } @Specialization(limit = "LIMIT") - protected static TruffleString fromInterop(Object value, + public static TruffleString fromInterop(Object value, @CachedLibrary("value") InteropLibrary interop, @Cached TruffleString.FromLongNode fromLongNode, @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java index cdaa1819d33e..1f5fd4ce747d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java @@ -68,38 +68,38 @@ public abstract class SLUnboxNode extends SLExpressionNode { static final int LIMIT = 5; @Specialization - protected static TruffleString fromString(String value, + public static TruffleString fromString(String value, @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { return fromJavaStringNode.execute(value, SLLanguage.STRING_ENCODING); } @Specialization - protected static TruffleString fromTruffleString(TruffleString value) { + public static TruffleString fromTruffleString(TruffleString value) { return value; } @Specialization - protected static boolean fromBoolean(boolean value) { + public static boolean fromBoolean(boolean value) { return value; } @Specialization - protected static long fromLong(long value) { + public static long fromLong(long value) { return value; } @Specialization - protected static SLBigNumber fromBigNumber(SLBigNumber value) { + public static SLBigNumber fromBigNumber(SLBigNumber value) { return value; } @Specialization - protected static SLFunction fromFunction(SLFunction value) { + public static SLFunction fromFunction(SLFunction value) { return value; } @Specialization - protected static SLNull fromFunction(SLNull value) { + public static SLNull fromFunction(SLNull value) { return value; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 4907dc665d88..0a0bc5b23b01 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,139 +1,85 @@ package com.oracle.truffle.sl.operations; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.InvalidArrayIndexException; -import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.util.SLToMemberNode; import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; -import com.oracle.truffle.sl.runtime.SLBigNumber; -import com.oracle.truffle.sl.runtime.SLObject; +import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations public class SLOperations { - @Operation + @Operation(proxyNode = SLAddNode.class) public static class SLAddOperation { - @Specialization(rewriteOn = ArithmeticException.class) - public static long add(long left, long right) { - return Math.addExact(left, right); - } - - @Specialization(replaces = "add") - @TruffleBoundary - public static SLBigNumber addBig(SLBigNumber left, SLBigNumber right) { - return new SLBigNumber(left.getValue().add(right.getValue())); - } - - @Specialization(guards = "isString(left, right)") - @TruffleBoundary - public static TruffleString addString(Object left, Object right, - @Cached SLToTruffleStringNode toTruffleStringNodeLeft, - @Cached SLToTruffleStringNode toTruffleStringNodeRight, - @Cached TruffleString.ConcatNode concatNode) { - return concatNode.execute( - toTruffleStringNodeLeft.execute(left), - toTruffleStringNodeRight.execute(right), - SLLanguage.STRING_ENCODING, - true); - } - - public static boolean isString(Object a, Object b) { - return a instanceof TruffleString || b instanceof TruffleString; - } - - @Fallback - public static Object typeError(Object left, Object right) { - throw new RuntimeException("+ type error: " + left + ", " + right); - } } - @Operation - public static class SLReadPropertyOperation { + @Operation(proxyNode = SLDivNode.class) + public static class SLDivOperation { + } - public static final int LIBRARY_LIMIT = 3; + @Operation(proxyNode = SLEqualNode.class) + public static class SLEqualOperation { + } - @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") - public static Object readArray(Object receiver, Object index, - @CachedLibrary("receiver") InteropLibrary arrays, - @CachedLibrary("index") InteropLibrary numbers) { + public static class SLInvokeOperation { + @Specialization + public static Object execute(Object function, @Variadic Object[] argumentValues, @CachedLibrary(limit = "3") InteropLibrary library) { try { - return arrays.readArrayElement(receiver, numbers.asLong(index)); - } catch (UnsupportedMessageException | InvalidArrayIndexException e) { - // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, index); + return library.execute(function, argumentValues); + } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { + /* Execute was not successful. */ + throw SLUndefinedNameException.undefinedFunction(null, function); } } + } - @Specialization(limit = "3") - public static Object readSLObject(SLObject receiver, Object name, - @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, - @Cached SLToTruffleStringNode toTruffleStringNode) { - TruffleString nameTS = toTruffleStringNode.execute(name); - Object result = objectLibrary.getOrDefault(receiver, nameTS, null); - if (result == null) { - // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, nameTS); - } - return result; - } + @Operation(proxyNode = SLLessOrEqualNode.class) + public static class SLLessOrEqualOperation { + } - @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") - public static Object readObject(Object receiver, Object name, - @CachedLibrary("receiver") InteropLibrary objects, - @Cached SLToMemberNode asMember) { - try { - return objects.readMember(receiver, asMember.execute(name)); - } catch (UnsupportedMessageException | UnknownIdentifierException e) { - // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, name); - } - } + @Operation(proxyNode = SLLessThanNode.class) + public static class SLLessThanOperation { + } - protected static boolean isSLObject(Object receiver) { - return receiver instanceof SLObject; - } + @Operation(proxyNode = SLLogicalNotNode.class) + public static class SLLogicalNotOperation { } - @Operation - public static class SLInvokeNode { + @Operation(proxyNode = SLMulNode.class) + public static class SLMulOperation { + } - // @Child private SLExpressionNode functionNode; - // @Children private final SLExpressionNode[] argumentNodes; - // @Child private InteropLibrary library; - // - // public SLInvokeNode(SLExpressionNode functionNode, SLExpressionNode[] argumentNodes) { - // this.functionNode = functionNode; - // this.argumentNodes = argumentNodes; - // this.library = InteropLibrary.getFactory().createDispatched(3); - // } + @Operation(proxyNode = SLReadPropertyNode.class) + public static class SLReadPropertyOperation { + } - @Specialization - public static Object call( - Object function, - @Variadic Object[] argumentValues, - @CachedLibrary(limit = "3") InteropLibrary library) { - try { - return library.execute(function, argumentValues); - } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { - /* Execute was not successful. */ - throw SLUndefinedNameException.undefinedFunction(null, function); - } - } + @Operation(proxyNode = SLSubNode.class) + public static class SLSubOperation { + } + + @Operation(proxyNode = SLWritePropertyNode.class) + public static class SLWritePropertyOperation { + } + @Operation(proxyNode = SLUnboxNode.class) + public static class SLUnboxOperation { } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 index f6cf2bde1a92..e931ae6d743d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 @@ -55,6 +55,7 @@ import java.util.Map; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLRootNode; @@ -95,7 +96,7 @@ private static void throwParseError(Source source, int line, int charPositionInL throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); } -public static Map parseSL(SLLanguage language, Source source) { +public static Map parseSL(SLLanguage language, Source source) { SimpleLanguageLexer lexer = new SimpleLanguageLexer(CharStreams.fromString(source.getCharacters().toString())); SimpleLanguageParser parser = new SimpleLanguageParser(new CommonTokenStream(lexer)); lexer.removeErrorListeners(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java index 7b4d35757a61..67e4d16a6c40 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java @@ -48,32 +48,23 @@ import java.util.List; import java.util.Map; -import org.antlr.v4.runtime.BaseErrorListener; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.NoViableAltException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Recognizer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.TerminalNode; - -import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLExpressionNode; +import com.oracle.truffle.sl.nodes.SLRootNode; import com.oracle.truffle.sl.nodes.SLStatementNode; +import com.oracle.truffle.sl.parser.SLParseError; + +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; @SuppressWarnings("all") public class SimpleLanguageParser extends Parser { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java new file mode 100644 index 000000000000..7e2e1de7ddd4 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java @@ -0,0 +1,115 @@ +package com.oracle.truffle.sl.parser.operations; + +import java.util.HashMap; +import java.util.Map; + +import org.antlr.v4.runtime.BaseErrorListener; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; +import org.antlr.v4.runtime.Token; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.parser.SLParseError; +import com.oracle.truffle.sl.runtime.SLStrings; + +public abstract class SLBaseVisitor extends SimpleLanguageOperationsBaseVisitor { + + protected static Map parseSLImpl(Source source, SLBaseVisitor visitor) { + SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getCharacters().toString())); + SimpleLanguageOperationsParser parser = new SimpleLanguageOperationsParser(new CommonTokenStream(lexer)); + lexer.removeErrorListeners(); + parser.removeErrorListeners(); + BailoutErrorListener listener = new BailoutErrorListener(source); + lexer.addErrorListener(listener); + parser.addErrorListener(listener); + + parser.simplelanguage().accept(visitor); + + return visitor.functions; + } + + static class LexicalScope { + int count; + final LexicalScope parent; + Map names = new HashMap<>(); + + public LexicalScope(LexicalScope parent) { + this.parent = parent; + count = parent != null ? parent.count : 0; + } + + public Integer get(TruffleString name) { + Integer result = names.get(name); + if (result != null) { + return result; + } else if (parent != null) { + return parent.get(name); + } else { + return null; + } + } + + public Integer create(TruffleString name) { + int value = count++; + names.put(name, value); + return value; + } + + public Integer create() { + return count++; + } + } + + protected final SLLanguage language; + protected final Source source; + protected final TruffleString sourceString; + protected final Map functions = new HashMap<>(); + + protected SLBaseVisitor(SLLanguage language, Source source) { + this.language = language; + this.source = source; + sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); + } + + protected void SemErr(Token token, String message) { + assert token != null; + throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); + } + + private static final class BailoutErrorListener extends BaseErrorListener { + private final Source source; + + BailoutErrorListener(Source source) { + this.source = source; + } + + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg); + } + } + + private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) { + int col = charPositionInLine + 1; + String location = "-- line " + line + " col " + col + ": "; + int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0); + throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); + } + + protected TruffleString asTruffleString(Token literalToken, boolean removeQuotes) { + int fromIndex = literalToken.getStartIndex(); + int length = literalToken.getStopIndex() - literalToken.getStartIndex() + 1; + if (removeQuotes) { + /* Remove the trailing and ending " */ + assert literalToken.getText().length() >= 2 && literalToken.getText().startsWith("\"") && literalToken.getText().endsWith("\""); + fromIndex += 1; + length -= 2; + } + return sourceString.substringByteIndexUncached(fromIndex * 2, length * 2, SLLanguage.STRING_ENCODING, true); + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java new file mode 100644 index 000000000000..a00b34506ae8 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -0,0 +1,586 @@ +package com.oracle.truffle.sl.parser.operations; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.RuleNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLExpressionNode; +import com.oracle.truffle.sl.nodes.SLRootNode; +import com.oracle.truffle.sl.nodes.SLStatementNode; +import com.oracle.truffle.sl.nodes.controlflow.SLBlockNode; +import com.oracle.truffle.sl.nodes.controlflow.SLBreakNode; +import com.oracle.truffle.sl.nodes.controlflow.SLContinueNode; +import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; +import com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode; +import com.oracle.truffle.sl.nodes.controlflow.SLIfNode; +import com.oracle.truffle.sl.nodes.controlflow.SLReturnNode; +import com.oracle.truffle.sl.nodes.controlflow.SLWhileNode; +import com.oracle.truffle.sl.nodes.expression.SLAddNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLEqualNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLLogicalAndNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLLogicalOrNode; +import com.oracle.truffle.sl.nodes.expression.SLLongLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLParenExpressionNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLStringLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNodeGen; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNodeGen; +import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; +import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNodeGen; +import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNodeGen; +import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ArithmeticContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.BlockContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Break_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Continue_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Debugger_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ExpressionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Expression_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.FunctionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.If_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_factorContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_termContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberAssignContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberCallContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberFieldContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberIndexContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Member_expressionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NameAccessContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NumericLiteralContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ParenExpressionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Return_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StatementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StringLiteralContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.TermContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.While_statementContext; + +public class SLNodeVisitor extends SLBaseVisitor { + + public static Map parseSL(SLLanguage language, Source source) { + return parseSLImpl(source, new SLNodeVisitor(language, source)); + } + + private LexicalScope scope; + private FrameDescriptor.Builder frameDescriptorBuilder; + + private SLStatementVisitor STATEMENT_VISITOR = new SLStatementVisitor(); + private SLExpressionVisitor EXPRESSION_VISITOR = new SLExpressionVisitor(); + private int loopDepth = 0; + + protected SLNodeVisitor(SLLanguage language, Source source) { + super(language, source); + } + + @Override + public Void visitFunction(FunctionContext ctx) { + + Token nameToken = ctx.IDENTIFIER(0).getSymbol(); + + TruffleString functionName = asTruffleString(nameToken, false); + + int functionStartPos = nameToken.getStartIndex(); + frameDescriptorBuilder = FrameDescriptor.newBuilder(); + List methodNodes = new ArrayList<>(); + + scope = new LexicalScope(scope); + + int parameterCount = ctx.IDENTIFIER().size() - 1; + + for (int i = 0; i < parameterCount; i++) { + Token paramToken = ctx.IDENTIFIER(i + 1).getSymbol(); + + final SLReadArgumentNode readArg = new SLReadArgumentNode(i); + readArg.setSourceSection(paramToken.getStartIndex(), paramToken.getText().length()); + SLExpressionNode assignment = createAssignment(createString(paramToken, false), readArg, i); + methodNodes.add(assignment); + } + + SLStatementNode bodyNode = STATEMENT_VISITOR.visitBlock(ctx.body); + + scope = scope.parent; + methodNodes.add(bodyNode); + final int bodyEndPos = bodyNode.getSourceEndIndex(); + final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); + final SLStatementNode methodBlock = new SLBlockNode(methodNodes.toArray(new SLStatementNode[methodNodes.size()])); + + assert scope == null : "Wrong scoping of blocks in parser"; + + final SLFunctionBodyNode functionBodyNode = new SLFunctionBodyNode(methodBlock); + functionBodyNode.setSourceSection(functionSrc.getCharIndex(), functionSrc.getCharLength()); + + final SLRootNode rootNode = new SLRootNode(language, frameDescriptorBuilder.build(), functionBodyNode, functionSrc, functionName); + functions.put(functionName, rootNode.getCallTarget()); + + frameDescriptorBuilder = null; + scope = null; + + return null; + } + + private SLStringLiteralNode createString(Token name, boolean removeQuotes) { + SLStringLiteralNode node = new SLStringLiteralNode(asTruffleString(name, removeQuotes)); + node.setSourceSection(name.getStartIndex(), name.getStopIndex() - name.getStartIndex() + 1); + return node; + } + + private class SLStatementVisitor extends SimpleLanguageOperationsBaseVisitor { + @Override + public SLStatementNode visitBlock(BlockContext ctx) { + scope = new LexicalScope(scope); + + int startPos = ctx.s.getStartIndex(); + int endPos = ctx.e.getStopIndex() + 1; + + List bodyNodes = new ArrayList<>(); + + for (StatementContext child : ctx.statement()) { + bodyNodes.add(visitStatement(child)); + } + + scope = scope.parent; + + List flattenedNodes = new ArrayList<>(bodyNodes.size()); + flattenBlocks(bodyNodes, flattenedNodes); + int n = flattenedNodes.size(); + for (int i = 0; i < n; i++) { + SLStatementNode statement = flattenedNodes.get(i); + if (statement.hasSource() && !isHaltInCondition(statement)) { + statement.addStatementTag(); + } + } + SLBlockNode blockNode = new SLBlockNode(flattenedNodes.toArray(new SLStatementNode[flattenedNodes.size()])); + blockNode.setSourceSection(startPos, endPos - startPos); + return blockNode; + } + + private void flattenBlocks(Iterable bodyNodes, List flattenedNodes) { + for (SLStatementNode n : bodyNodes) { + if (n instanceof SLBlockNode) { + flattenBlocks(((SLBlockNode) n).getStatements(), flattenedNodes); + } else { + flattenedNodes.add(n); + } + } + } + + @Override + public SLStatementNode visitDebugger_statement(Debugger_statementContext ctx) { + final SLDebuggerNode debuggerNode = new SLDebuggerNode(); + srcFromToken(debuggerNode, ctx.d); + return debuggerNode; + } + + @Override + public SLStatementNode visitBreak_statement(Break_statementContext ctx) { + if (loopDepth == 0) { + SemErr(ctx.b, "break used outside of loop"); + } + final SLBreakNode breakNode = new SLBreakNode(); + srcFromToken(breakNode, ctx.b); + return breakNode; + } + + @Override + public SLStatementNode visitContinue_statement(Continue_statementContext ctx) { + if (loopDepth == 0) { + SemErr(ctx.c, "continue used outside of loop"); + } + final SLContinueNode continueNode = new SLContinueNode(); + srcFromToken(continueNode, ctx.c); + return continueNode; + } + + @Override + public SLStatementNode visitWhile_statement(While_statementContext ctx) { + SLExpressionNode conditionNode = EXPRESSION_VISITOR.visitExpression(ctx.condition); + + loopDepth++; + SLStatementNode bodyNode = visitBlock(ctx.body); + loopDepth--; + + conditionNode.addStatementTag(); + final int start = ctx.w.getStartIndex(); + final int end = bodyNode.getSourceEndIndex(); + final SLWhileNode whileNode = new SLWhileNode(conditionNode, bodyNode); + whileNode.setSourceSection(start, end - start); + return whileNode; + } + + @Override + public SLStatementNode visitIf_statement(If_statementContext ctx) { + SLExpressionNode conditionNode = EXPRESSION_VISITOR.visitExpression(ctx.condition); + SLStatementNode thenPartNode = visitBlock(ctx.then); + SLStatementNode elsePartNode = ctx.alt == null ? null : visitBlock(ctx.alt); + + conditionNode.addStatementTag(); + final int start = ctx.i.getStartIndex(); + final int end = elsePartNode == null ? thenPartNode.getSourceEndIndex() : elsePartNode.getSourceEndIndex(); + final SLIfNode ifNode = new SLIfNode(conditionNode, thenPartNode, elsePartNode); + ifNode.setSourceSection(start, end - start); + return ifNode; + } + + @Override + public SLStatementNode visitReturn_statement(Return_statementContext ctx) { + + final SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + + final int start = ctx.r.getStartIndex(); + final int length = valueNode == null ? ctx.r.getText().length() : valueNode.getSourceEndIndex() - start; + final SLReturnNode returnNode = new SLReturnNode(valueNode); + returnNode.setSourceSection(start, length); + return returnNode; + } + + @Override + public SLStatementNode visitStatement(StatementContext ctx) { + return visit(ctx.getChild(0)); + } + + @Override + public SLStatementNode visitExpression_statement(Expression_statementContext ctx) { + return EXPRESSION_VISITOR.visitExpression(ctx.expression()); + } + + @Override + public SLStatementNode visitChildren(RuleNode arg0) { + throw new UnsupportedOperationException("node: " + arg0.getClass().getSimpleName()); + } + } + + private class SLExpressionVisitor extends SimpleLanguageOperationsBaseVisitor { + @Override + public SLExpressionNode visitExpression(ExpressionContext ctx) { + return createBinary(ctx.logic_term(), ctx.OP_OR()); + } + + @Override + public SLExpressionNode visitLogic_term(Logic_termContext ctx) { + return createBinary(ctx.logic_factor(), ctx.OP_AND()); + } + + @Override + public SLExpressionNode visitLogic_factor(Logic_factorContext ctx) { + return createBinary(ctx.arithmetic(), ctx.OP_COMPARE()); + } + + @Override + public SLExpressionNode visitArithmetic(ArithmeticContext ctx) { + return createBinary(ctx.term(), ctx.OP_ADD()); + } + + @Override + public SLExpressionNode visitTerm(TermContext ctx) { + return createBinary(ctx.factor(), ctx.OP_MUL()); + } + + private SLExpressionNode createBinary(List children, TerminalNode op) { + if (op == null) { + assert children.size() == 1; + return visit(children.get(0)); + } else { + assert children.size() == 2; + return createBinary(op.getSymbol(), visit(children.get(0)), visit(children.get(1))); + } + } + + private SLExpressionNode createBinary(List children, List ops) { + assert children.size() == ops.size() + 1; + + SLExpressionNode result = visit(children.get(0)); + + for (int i = 0; i < ops.size(); i++) { + result = createBinary(ops.get(i).getSymbol(), result, visit(children.get(i + 1))); + } + + return result; + } + + private SLExpressionNode createBinary(Token opToken, SLExpressionNode leftNode, SLExpressionNode rightNode) { + final SLExpressionNode leftUnboxed = SLUnboxNodeGen.create(leftNode); + final SLExpressionNode rightUnboxed = SLUnboxNodeGen.create(rightNode); + + final SLExpressionNode result; + switch (opToken.getText()) { + case "+": + result = SLAddNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "*": + result = SLMulNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "/": + result = SLDivNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "-": + result = SLSubNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "<": + result = SLLessThanNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "<=": + result = SLLessOrEqualNodeGen.create(leftUnboxed, rightUnboxed); + break; + case ">": + result = SLLogicalNotNodeGen.create(SLLessOrEqualNodeGen.create(leftUnboxed, rightUnboxed)); + break; + case ">=": + result = SLLogicalNotNodeGen.create(SLLessThanNodeGen.create(leftUnboxed, rightUnboxed)); + break; + case "==": + result = SLEqualNodeGen.create(leftUnboxed, rightUnboxed); + break; + case "!=": + result = SLLogicalNotNodeGen.create(SLEqualNodeGen.create(leftUnboxed, rightUnboxed)); + break; + case "&&": + result = new SLLogicalAndNode(leftUnboxed, rightUnboxed); + break; + case "||": + result = new SLLogicalOrNode(leftUnboxed, rightUnboxed); + break; + default: + throw new RuntimeException("unexpected operation: " + opToken.getText()); + } + + int start = leftNode.getSourceCharIndex(); + int length = rightNode.getSourceEndIndex() - start; + result.setSourceSection(start, length); + result.addExpressionTag(); + + return result; + } + + @Override + public SLExpressionNode visitNameAccess(NameAccessContext ctx) { + + if (ctx.member_expression().isEmpty()) { + return createRead(createString(ctx.IDENTIFIER().getSymbol(), false)); + } + + MemberExpressionVisitor visitor = new MemberExpressionVisitor(null, null, + createString(ctx.IDENTIFIER().getSymbol(), false)); + + for (Member_expressionContext child : ctx.member_expression()) { + visitor.visit(child); + } + + return visitor.receiver; + } + + @Override + public SLExpressionNode visitStringLiteral(StringLiteralContext ctx) { + return createString(ctx.STRING_LITERAL().getSymbol(), true); + } + + @Override + public SLExpressionNode visitNumericLiteral(NumericLiteralContext ctx) { + Token literalToken = ctx.NUMERIC_LITERAL().getSymbol(); + SLExpressionNode result; + try { + /* Try if the literal is small enough to fit into a long value. */ + result = new SLLongLiteralNode(Long.parseLong(literalToken.getText())); + } catch (NumberFormatException ex) { + /* Overflow of long value, so fall back to BigInteger. */ + result = new SLBigIntegerLiteralNode(new BigInteger(literalToken.getText())); + } + srcFromToken(result, literalToken); + result.addExpressionTag(); + return result; + } + + @Override + public SLExpressionNode visitParenExpression(ParenExpressionContext ctx) { + + SLExpressionNode expressionNode = visitExpression(ctx.expression()); + if (expressionNode == null) { + return null; + } + + int start = ctx.start.getStartIndex(); + int length = ctx.stop.getStopIndex() - start + 1; + + final SLParenExpressionNode result = new SLParenExpressionNode(expressionNode); + result.setSourceSection(start, length); + return result; + } + + } + + private class MemberExpressionVisitor extends SimpleLanguageOperationsBaseVisitor { + SLExpressionNode receiver; + private SLExpressionNode assignmentReceiver; + private SLExpressionNode assignmentName; + + MemberExpressionVisitor(SLExpressionNode r, SLExpressionNode assignmentReceiver, SLExpressionNode assignmentName) { + this.receiver = r; + this.assignmentReceiver = assignmentReceiver; + this.assignmentName = assignmentName; + } + + @Override + public SLExpressionNode visitMemberCall(MemberCallContext ctx) { + List parameters = new ArrayList<>(); + if (receiver == null) { + receiver = createRead(assignmentName); + } + + for (ExpressionContext child : ctx.expression()) { + parameters.add(EXPRESSION_VISITOR.visitExpression(child)); + } + + final SLExpressionNode result = new SLInvokeNode(receiver, parameters.toArray(new SLExpressionNode[parameters.size()])); + + final int startPos = receiver.getSourceCharIndex(); + final int endPos = ctx.stop.getStopIndex() + 1; + result.setSourceSection(startPos, endPos - startPos); + result.addExpressionTag(); + + assignmentReceiver = receiver; + receiver = result; + assignmentName = null; + return result; + } + + @Override + public SLExpressionNode visitMemberAssign(MemberAssignContext ctx) { + final SLExpressionNode result; + if (assignmentName == null) { + SemErr(ctx.start, "invalid assignment target"); + result = null; + } else if (assignmentReceiver == null) { + SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + result = createAssignment((SLStringLiteralNode) assignmentName, valueNode, null); + } else { + // create write property + SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + + result = SLWritePropertyNodeGen.create(assignmentReceiver, assignmentName, valueNode); + + final int start = assignmentReceiver.getSourceCharIndex(); + final int length = valueNode.getSourceEndIndex() - start; + result.setSourceSection(start, length); + result.addExpressionTag(); + } + + assignmentReceiver = receiver; + receiver = result; + assignmentName = null; + + return result; + } + + @Override + public SLExpressionNode visitMemberField(MemberFieldContext ctx) { + if (receiver == null) { + receiver = createRead(assignmentName); + } + + SLExpressionNode nameNode = createString(ctx.IDENTIFIER().getSymbol(), false); + assignmentName = nameNode; + + final SLExpressionNode result = SLReadPropertyNodeGen.create(receiver, nameNode); + + final int startPos = receiver.getSourceCharIndex(); + final int endPos = nameNode.getSourceEndIndex(); + result.setSourceSection(startPos, endPos - startPos); + result.addExpressionTag(); + + assignmentReceiver = receiver; + receiver = result; + + return result; + } + + @Override + public SLExpressionNode visitMemberIndex(MemberIndexContext ctx) { + if (receiver == null) { + receiver = createRead(assignmentName); + } + + SLExpressionNode nameNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + assignmentName = nameNode; + + final SLExpressionNode result = SLReadPropertyNodeGen.create(receiver, nameNode); + + final int startPos = receiver.getSourceCharIndex(); + final int endPos = nameNode.getSourceEndIndex(); + result.setSourceSection(startPos, endPos - startPos); + result.addExpressionTag(); + + assignmentReceiver = receiver; + receiver = result; + + return result; + } + + } + + private SLExpressionNode createRead(SLExpressionNode nameTerm) { + final TruffleString name = ((SLStringLiteralNode) nameTerm).executeGeneric(null); + final SLExpressionNode result; + final Integer frameSlot = scope.get(name); + if (frameSlot != null) { + result = SLReadLocalVariableNodeGen.create(frameSlot); + } else { + result = new SLFunctionLiteralNode(name); + } + result.setSourceSection(nameTerm.getSourceCharIndex(), nameTerm.getSourceLength()); + result.addExpressionTag(); + return result; + } + + private SLExpressionNode createAssignment(SLStringLiteralNode assignmentName, SLExpressionNode valueNode, Integer index) { + + TruffleString name = assignmentName.executeGeneric(null); + + Integer frameSlot = scope.get(name); + boolean newVariable = false; + if (frameSlot == null) { + frameSlot = frameDescriptorBuilder.addSlot(FrameSlotKind.Illegal, name, index); + scope.names.put(name, frameSlot); + newVariable = true; + } + SLExpressionNode result = SLWriteLocalVariableNodeGen.create(valueNode, frameSlot, assignmentName, newVariable); + + if (valueNode.hasSource()) { + final int start = assignmentName.getSourceCharIndex(); + final int length = valueNode.getSourceEndIndex() - start; + result.setSourceSection(start, length); + } + if (index == null) { + result.addExpressionTag(); + } + + return result; + } + + private static boolean isHaltInCondition(SLStatementNode statement) { + return (statement instanceof SLIfNode) || (statement instanceof SLWhileNode); + } + + private static void srcFromToken(SLStatementNode node, Token token) { + node.setSourceSection(token.getStartIndex(), token.getText().length()); + } + +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 new file mode 100644 index 000000000000..2a09e8c01561 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * The parser and lexer need to be generated using "mx create-sl-parser". + */ + +grammar SimpleLanguageOperations; + +@parser::header +{ +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" +} + +@lexer::header +{ +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" +} + +// parser + + + + +simplelanguage + : function function* EOF + ; + + +function + : 'function' IDENTIFIER + s='(' (IDENTIFIER (',' IDENTIFIER)*)? ')' + body=block + ; + + + +block + : s='{' statement* e='}' + ; + + +statement + : while_statement + | break_statement + | continue_statement + | if_statement + | return_statement + | expression_statement + | debugger_statement + ; + +break_statement + : b='break' ';' + ; + +continue_statement + : c='continue' ';' + ; + +expression_statement + : expression ';' + ; + +debugger_statement + : d='debugger' ';' + ; + +while_statement + : w='while' '(' condition=expression ')' + body=block + ; + + +if_statement + : i='if' '(' condition=expression ')' + then=block + ( 'else' alt=block )? + ; + + +return_statement + : r='return' expression? ';' + ; + + +expression + : logic_term (OP_OR logic_term)* + ; + + +logic_term + : logic_factor (OP_AND logic_factor)* + ; + + +logic_factor + : arithmetic (OP_COMPARE arithmetic)? + ; + + +arithmetic + : term (OP_ADD term)* + ; + + +term + : factor (OP_MUL factor)* + ; + + +factor + : IDENTIFIER member_expression* # NameAccess + | STRING_LITERAL # StringLiteral + | NUMERIC_LITERAL # NumericLiteral + | '(' expression ')' # ParenExpression + ; + + +member_expression + : '(' ( expression (',' expression)* )? ')' # MemberCall + | '=' expression # MemberAssign + | '.' IDENTIFIER # MemberField + | '[' expression ']' # MemberIndex + ; + +// lexer + +WS : [ \t\r\n\u000C]+ -> skip; +COMMENT : '/*' .*? '*/' -> skip; +LINE_COMMENT : '//' ~[\r\n]* -> skip; + +OP_OR: '||'; +OP_AND: '&&'; +OP_COMPARE: '<' | '<=' | '>' | '>=' | '==' | '!='; +OP_ADD: '+' | '-'; +OP_MUL: '*' | '/'; + +fragment LETTER : [A-Z] | [a-z] | '_' | '$'; +fragment NON_ZERO_DIGIT : [1-9]; +fragment DIGIT : [0-9]; +fragment HEX_DIGIT : [0-9] | [a-f] | [A-F]; +fragment OCT_DIGIT : [0-7]; +fragment BINARY_DIGIT : '0' | '1'; +fragment TAB : '\t'; +fragment STRING_CHAR : ~('"' | '\r' | '\n'); + +IDENTIFIER : LETTER (LETTER | DIGIT)*; +STRING_LITERAL : '"' STRING_CHAR* '"'; +NUMERIC_LITERAL : '0' | NON_ZERO_DIGIT DIGIT*; + diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java new file mode 100644 index 000000000000..f41227344b46 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java @@ -0,0 +1,185 @@ +// Generated from /home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 by ANTLR 4.9.2 +package com.oracle.truffle.sl.parser.operations; + +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" + +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link SimpleLanguageOperationsVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public class SimpleLanguageOperationsBaseVisitor extends AbstractParseTreeVisitor implements SimpleLanguageOperationsVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTerm(SimpleLanguageOperationsParser.TermContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java new file mode 100644 index 000000000000..11c56a335b71 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// Checkstyle: stop +//@formatter:off +package com.oracle.truffle.sl.parser.operations; + +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" + +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings("all") +public class SimpleLanguageOperationsLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, WS=19, COMMENT=20, LINE_COMMENT=21, OP_OR=22, OP_AND=23, OP_COMPARE=24, + OP_ADD=25, OP_MUL=26, IDENTIFIER=27, STRING_LITERAL=28, NUMERIC_LITERAL=29; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "WS", "COMMENT", "LINE_COMMENT", "OP_OR", "OP_AND", "OP_COMPARE", + "OP_ADD", "OP_MUL", "LETTER", "NON_ZERO_DIGIT", "DIGIT", "HEX_DIGIT", + "OCT_DIGIT", "BINARY_DIGIT", "TAB", "STRING_CHAR", "IDENTIFIER", "STRING_LITERAL", + "NUMERIC_LITERAL" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'function'", "'('", "','", "')'", "'{'", "'}'", "'break'", "';'", + "'continue'", "'debugger'", "'while'", "'if'", "'else'", "'return'", + "'='", "'.'", "'['", "']'", null, null, null, "'||'", "'&&'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "WS", "COMMENT", "LINE_COMMENT", + "OP_OR", "OP_AND", "OP_COMPARE", "OP_ADD", "OP_MUL", "IDENTIFIER", "STRING_LITERAL", + "NUMERIC_LITERAL" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public SimpleLanguageOperationsLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "SimpleLanguageOperations.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\37\u00fa\b\1\4\2"+ + "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+ + "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+ + "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31"+ + "\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t"+ + " \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3"+ + "\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b"+ + "\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13"+ + "\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\16"+ + "\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\21\3\21\3\22"+ + "\3\22\3\23\3\23\3\24\6\24\u0099\n\24\r\24\16\24\u009a\3\24\3\24\3\25\3"+ + "\25\3\25\3\25\7\25\u00a3\n\25\f\25\16\25\u00a6\13\25\3\25\3\25\3\25\3"+ + "\25\3\25\3\26\3\26\3\26\3\26\7\26\u00b1\n\26\f\26\16\26\u00b4\13\26\3"+ + "\26\3\26\3\27\3\27\3\27\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31\3"+ + "\31\3\31\3\31\3\31\5\31\u00c8\n\31\3\32\3\32\3\33\3\33\3\34\5\34\u00cf"+ + "\n\34\3\35\3\35\3\36\3\36\3\37\5\37\u00d6\n\37\3 \3 \3!\3!\3\"\3\"\3#"+ + "\3#\3$\3$\3$\7$\u00e3\n$\f$\16$\u00e6\13$\3%\3%\7%\u00ea\n%\f%\16%\u00ed"+ + "\13%\3%\3%\3&\3&\3&\7&\u00f4\n&\f&\16&\u00f7\13&\5&\u00f9\n&\3\u00a4\2"+ + "\'\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20"+ + "\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\29\2;\2="+ + "\2?\2A\2C\2E\2G\35I\36K\37\3\2\f\5\2\13\f\16\17\"\"\4\2\f\f\17\17\4\2"+ + "--//\4\2,,\61\61\6\2&&C\\aac|\3\2\63;\3\2\62;\5\2\62;CHch\3\2\629\5\2"+ + "\f\f\17\17$$\2\u00fe\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2"+ + "\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3"+ + "\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2"+ + "\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2"+ + "\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2G\3\2\2"+ + "\2\2I\3\2\2\2\2K\3\2\2\2\3M\3\2\2\2\5V\3\2\2\2\7X\3\2\2\2\tZ\3\2\2\2\13"+ + "\\\3\2\2\2\r^\3\2\2\2\17`\3\2\2\2\21f\3\2\2\2\23h\3\2\2\2\25q\3\2\2\2"+ + "\27z\3\2\2\2\31\u0080\3\2\2\2\33\u0083\3\2\2\2\35\u0088\3\2\2\2\37\u008f"+ + "\3\2\2\2!\u0091\3\2\2\2#\u0093\3\2\2\2%\u0095\3\2\2\2\'\u0098\3\2\2\2"+ + ")\u009e\3\2\2\2+\u00ac\3\2\2\2-\u00b7\3\2\2\2/\u00ba\3\2\2\2\61\u00c7"+ + "\3\2\2\2\63\u00c9\3\2\2\2\65\u00cb\3\2\2\2\67\u00ce\3\2\2\29\u00d0\3\2"+ + "\2\2;\u00d2\3\2\2\2=\u00d5\3\2\2\2?\u00d7\3\2\2\2A\u00d9\3\2\2\2C\u00db"+ + "\3\2\2\2E\u00dd\3\2\2\2G\u00df\3\2\2\2I\u00e7\3\2\2\2K\u00f8\3\2\2\2M"+ + "N\7h\2\2NO\7w\2\2OP\7p\2\2PQ\7e\2\2QR\7v\2\2RS\7k\2\2ST\7q\2\2TU\7p\2"+ + "\2U\4\3\2\2\2VW\7*\2\2W\6\3\2\2\2XY\7.\2\2Y\b\3\2\2\2Z[\7+\2\2[\n\3\2"+ + "\2\2\\]\7}\2\2]\f\3\2\2\2^_\7\177\2\2_\16\3\2\2\2`a\7d\2\2ab\7t\2\2bc"+ + "\7g\2\2cd\7c\2\2de\7m\2\2e\20\3\2\2\2fg\7=\2\2g\22\3\2\2\2hi\7e\2\2ij"+ + "\7q\2\2jk\7p\2\2kl\7v\2\2lm\7k\2\2mn\7p\2\2no\7w\2\2op\7g\2\2p\24\3\2"+ + "\2\2qr\7f\2\2rs\7g\2\2st\7d\2\2tu\7w\2\2uv\7i\2\2vw\7i\2\2wx\7g\2\2xy"+ + "\7t\2\2y\26\3\2\2\2z{\7y\2\2{|\7j\2\2|}\7k\2\2}~\7n\2\2~\177\7g\2\2\177"+ + "\30\3\2\2\2\u0080\u0081\7k\2\2\u0081\u0082\7h\2\2\u0082\32\3\2\2\2\u0083"+ + "\u0084\7g\2\2\u0084\u0085\7n\2\2\u0085\u0086\7u\2\2\u0086\u0087\7g\2\2"+ + "\u0087\34\3\2\2\2\u0088\u0089\7t\2\2\u0089\u008a\7g\2\2\u008a\u008b\7"+ + "v\2\2\u008b\u008c\7w\2\2\u008c\u008d\7t\2\2\u008d\u008e\7p\2\2\u008e\36"+ + "\3\2\2\2\u008f\u0090\7?\2\2\u0090 \3\2\2\2\u0091\u0092\7\60\2\2\u0092"+ + "\"\3\2\2\2\u0093\u0094\7]\2\2\u0094$\3\2\2\2\u0095\u0096\7_\2\2\u0096"+ + "&\3\2\2\2\u0097\u0099\t\2\2\2\u0098\u0097\3\2\2\2\u0099\u009a\3\2\2\2"+ + "\u009a\u0098\3\2\2\2\u009a\u009b\3\2\2\2\u009b\u009c\3\2\2\2\u009c\u009d"+ + "\b\24\2\2\u009d(\3\2\2\2\u009e\u009f\7\61\2\2\u009f\u00a0\7,\2\2\u00a0"+ + "\u00a4\3\2\2\2\u00a1\u00a3\13\2\2\2\u00a2\u00a1\3\2\2\2\u00a3\u00a6\3"+ + "\2\2\2\u00a4\u00a5\3\2\2\2\u00a4\u00a2\3\2\2\2\u00a5\u00a7\3\2\2\2\u00a6"+ + "\u00a4\3\2\2\2\u00a7\u00a8\7,\2\2\u00a8\u00a9\7\61\2\2\u00a9\u00aa\3\2"+ + "\2\2\u00aa\u00ab\b\25\2\2\u00ab*\3\2\2\2\u00ac\u00ad\7\61\2\2\u00ad\u00ae"+ + "\7\61\2\2\u00ae\u00b2\3\2\2\2\u00af\u00b1\n\3\2\2\u00b0\u00af\3\2\2\2"+ + "\u00b1\u00b4\3\2\2\2\u00b2\u00b0\3\2\2\2\u00b2\u00b3\3\2\2\2\u00b3\u00b5"+ + "\3\2\2\2\u00b4\u00b2\3\2\2\2\u00b5\u00b6\b\26\2\2\u00b6,\3\2\2\2\u00b7"+ + "\u00b8\7~\2\2\u00b8\u00b9\7~\2\2\u00b9.\3\2\2\2\u00ba\u00bb\7(\2\2\u00bb"+ + "\u00bc\7(\2\2\u00bc\60\3\2\2\2\u00bd\u00c8\7>\2\2\u00be\u00bf\7>\2\2\u00bf"+ + "\u00c8\7?\2\2\u00c0\u00c8\7@\2\2\u00c1\u00c2\7@\2\2\u00c2\u00c8\7?\2\2"+ + "\u00c3\u00c4\7?\2\2\u00c4\u00c8\7?\2\2\u00c5\u00c6\7#\2\2\u00c6\u00c8"+ + "\7?\2\2\u00c7\u00bd\3\2\2\2\u00c7\u00be\3\2\2\2\u00c7\u00c0\3\2\2\2\u00c7"+ + "\u00c1\3\2\2\2\u00c7\u00c3\3\2\2\2\u00c7\u00c5\3\2\2\2\u00c8\62\3\2\2"+ + "\2\u00c9\u00ca\t\4\2\2\u00ca\64\3\2\2\2\u00cb\u00cc\t\5\2\2\u00cc\66\3"+ + "\2\2\2\u00cd\u00cf\t\6\2\2\u00ce\u00cd\3\2\2\2\u00cf8\3\2\2\2\u00d0\u00d1"+ + "\t\7\2\2\u00d1:\3\2\2\2\u00d2\u00d3\t\b\2\2\u00d3<\3\2\2\2\u00d4\u00d6"+ + "\t\t\2\2\u00d5\u00d4\3\2\2\2\u00d6>\3\2\2\2\u00d7\u00d8\t\n\2\2\u00d8"+ + "@\3\2\2\2\u00d9\u00da\4\62\63\2\u00daB\3\2\2\2\u00db\u00dc\7\13\2\2\u00dc"+ + "D\3\2\2\2\u00dd\u00de\n\13\2\2\u00deF\3\2\2\2\u00df\u00e4\5\67\34\2\u00e0"+ + "\u00e3\5\67\34\2\u00e1\u00e3\5;\36\2\u00e2\u00e0\3\2\2\2\u00e2\u00e1\3"+ + "\2\2\2\u00e3\u00e6\3\2\2\2\u00e4\u00e2\3\2\2\2\u00e4\u00e5\3\2\2\2\u00e5"+ + "H\3\2\2\2\u00e6\u00e4\3\2\2\2\u00e7\u00eb\7$\2\2\u00e8\u00ea\5E#\2\u00e9"+ + "\u00e8\3\2\2\2\u00ea\u00ed\3\2\2\2\u00eb\u00e9\3\2\2\2\u00eb\u00ec\3\2"+ + "\2\2\u00ec\u00ee\3\2\2\2\u00ed\u00eb\3\2\2\2\u00ee\u00ef\7$\2\2\u00ef"+ + "J\3\2\2\2\u00f0\u00f9\7\62\2\2\u00f1\u00f5\59\35\2\u00f2\u00f4\5;\36\2"+ + "\u00f3\u00f2\3\2\2\2\u00f4\u00f7\3\2\2\2\u00f5\u00f3\3\2\2\2\u00f5\u00f6"+ + "\3\2\2\2\u00f6\u00f9\3\2\2\2\u00f7\u00f5\3\2\2\2\u00f8\u00f0\3\2\2\2\u00f8"+ + "\u00f1\3\2\2\2\u00f9L\3\2\2\2\16\2\u009a\u00a4\u00b2\u00c7\u00ce\u00d5"+ + "\u00e2\u00e4\u00eb\u00f5\u00f8\3\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java new file mode 100644 index 000000000000..072a9c7e79e6 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java @@ -0,0 +1,1409 @@ +/* + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// Checkstyle: stop +//@formatter:off +package com.oracle.truffle.sl.parser.operations; + +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" + +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class SimpleLanguageOperationsParser extends Parser { + static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, WS=19, COMMENT=20, LINE_COMMENT=21, OP_OR=22, OP_AND=23, OP_COMPARE=24, + OP_ADD=25, OP_MUL=26, IDENTIFIER=27, STRING_LITERAL=28, NUMERIC_LITERAL=29; + public static final int + RULE_simplelanguage = 0, RULE_function = 1, RULE_block = 2, RULE_statement = 3, + RULE_break_statement = 4, RULE_continue_statement = 5, RULE_expression_statement = 6, + RULE_debugger_statement = 7, RULE_while_statement = 8, RULE_if_statement = 9, + RULE_return_statement = 10, RULE_expression = 11, RULE_logic_term = 12, + RULE_logic_factor = 13, RULE_arithmetic = 14, RULE_term = 15, RULE_factor = 16, + RULE_member_expression = 17; + private static String[] makeRuleNames() { + return new String[] { + "simplelanguage", "function", "block", "statement", "break_statement", + "continue_statement", "expression_statement", "debugger_statement", "while_statement", + "if_statement", "return_statement", "expression", "logic_term", "logic_factor", + "arithmetic", "term", "factor", "member_expression" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'function'", "'('", "','", "')'", "'{'", "'}'", "'break'", "';'", + "'continue'", "'debugger'", "'while'", "'if'", "'else'", "'return'", + "'='", "'.'", "'['", "']'", null, null, null, "'||'", "'&&'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "WS", "COMMENT", "LINE_COMMENT", + "OP_OR", "OP_AND", "OP_COMPARE", "OP_ADD", "OP_MUL", "IDENTIFIER", "STRING_LITERAL", + "NUMERIC_LITERAL" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "SimpleLanguageOperations.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public SimpleLanguageOperationsParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + public static class SimplelanguageContext extends ParserRuleContext { + public List function() { + return getRuleContexts(FunctionContext.class); + } + public FunctionContext function(int i) { + return getRuleContext(FunctionContext.class,i); + } + public TerminalNode EOF() { return getToken(SimpleLanguageOperationsParser.EOF, 0); } + public SimplelanguageContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_simplelanguage; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitSimplelanguage(this); + else return visitor.visitChildren(this); + } + } + + public final SimplelanguageContext simplelanguage() throws RecognitionException { + SimplelanguageContext _localctx = new SimplelanguageContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_simplelanguage); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(36); + function(); + setState(40); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__0) { + { + { + setState(37); + function(); + } + } + setState(42); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(43); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class FunctionContext extends ParserRuleContext { + public Token s; + public BlockContext body; + public List IDENTIFIER() { return getTokens(SimpleLanguageOperationsParser.IDENTIFIER); } + public TerminalNode IDENTIFIER(int i) { + return getToken(SimpleLanguageOperationsParser.IDENTIFIER, i); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public FunctionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_function; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitFunction(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionContext function() throws RecognitionException { + FunctionContext _localctx = new FunctionContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_function); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(45); + match(T__0); + setState(46); + match(IDENTIFIER); + setState(47); + _localctx.s = match(T__1); + setState(56); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==IDENTIFIER) { + { + setState(48); + match(IDENTIFIER); + setState(53); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__2) { + { + { + setState(49); + match(T__2); + setState(50); + match(IDENTIFIER); + } + } + setState(55); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(58); + match(T__3); + setState(59); + _localctx.body = block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class BlockContext extends ParserRuleContext { + public Token s; + public Token e; + public List statement() { + return getRuleContexts(StatementContext.class); + } + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class,i); + } + public BlockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_block; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitBlock(this); + else return visitor.visitChildren(this); + } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(61); + _localctx.s = match(T__4); + setState(65); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << T__6) | (1L << T__8) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__13) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { + { + { + setState(62); + statement(); + } + } + setState(67); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(68); + _localctx.e = match(T__5); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class StatementContext extends ParserRuleContext { + public While_statementContext while_statement() { + return getRuleContext(While_statementContext.class,0); + } + public Break_statementContext break_statement() { + return getRuleContext(Break_statementContext.class,0); + } + public Continue_statementContext continue_statement() { + return getRuleContext(Continue_statementContext.class,0); + } + public If_statementContext if_statement() { + return getRuleContext(If_statementContext.class,0); + } + public Return_statementContext return_statement() { + return getRuleContext(Return_statementContext.class,0); + } + public Expression_statementContext expression_statement() { + return getRuleContext(Expression_statementContext.class,0); + } + public Debugger_statementContext debugger_statement() { + return getRuleContext(Debugger_statementContext.class,0); + } + public StatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitStatement(this); + else return visitor.visitChildren(this); + } + } + + public final StatementContext statement() throws RecognitionException { + StatementContext _localctx = new StatementContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_statement); + try { + setState(77); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__10: + enterOuterAlt(_localctx, 1); + { + setState(70); + while_statement(); + } + break; + case T__6: + enterOuterAlt(_localctx, 2); + { + setState(71); + break_statement(); + } + break; + case T__8: + enterOuterAlt(_localctx, 3); + { + setState(72); + continue_statement(); + } + break; + case T__11: + enterOuterAlt(_localctx, 4); + { + setState(73); + if_statement(); + } + break; + case T__13: + enterOuterAlt(_localctx, 5); + { + setState(74); + return_statement(); + } + break; + case T__1: + case IDENTIFIER: + case STRING_LITERAL: + case NUMERIC_LITERAL: + enterOuterAlt(_localctx, 6); + { + setState(75); + expression_statement(); + } + break; + case T__9: + enterOuterAlt(_localctx, 7); + { + setState(76); + debugger_statement(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Break_statementContext extends ParserRuleContext { + public Token b; + public Break_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_break_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitBreak_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Break_statementContext break_statement() throws RecognitionException { + Break_statementContext _localctx = new Break_statementContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_break_statement); + try { + enterOuterAlt(_localctx, 1); + { + setState(79); + _localctx.b = match(T__6); + setState(80); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Continue_statementContext extends ParserRuleContext { + public Token c; + public Continue_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_continue_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitContinue_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Continue_statementContext continue_statement() throws RecognitionException { + Continue_statementContext _localctx = new Continue_statementContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_continue_statement); + try { + enterOuterAlt(_localctx, 1); + { + setState(82); + _localctx.c = match(T__8); + setState(83); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Expression_statementContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Expression_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitExpression_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Expression_statementContext expression_statement() throws RecognitionException { + Expression_statementContext _localctx = new Expression_statementContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_expression_statement); + try { + enterOuterAlt(_localctx, 1); + { + setState(85); + expression(); + setState(86); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Debugger_statementContext extends ParserRuleContext { + public Token d; + public Debugger_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_debugger_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitDebugger_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Debugger_statementContext debugger_statement() throws RecognitionException { + Debugger_statementContext _localctx = new Debugger_statementContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_debugger_statement); + try { + enterOuterAlt(_localctx, 1); + { + setState(88); + _localctx.d = match(T__9); + setState(89); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class While_statementContext extends ParserRuleContext { + public Token w; + public ExpressionContext condition; + public BlockContext body; + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public While_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_while_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitWhile_statement(this); + else return visitor.visitChildren(this); + } + } + + public final While_statementContext while_statement() throws RecognitionException { + While_statementContext _localctx = new While_statementContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_while_statement); + try { + enterOuterAlt(_localctx, 1); + { + setState(91); + _localctx.w = match(T__10); + setState(92); + match(T__1); + setState(93); + _localctx.condition = expression(); + setState(94); + match(T__3); + setState(95); + _localctx.body = block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class If_statementContext extends ParserRuleContext { + public Token i; + public ExpressionContext condition; + public BlockContext then; + public BlockContext alt; + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public List block() { + return getRuleContexts(BlockContext.class); + } + public BlockContext block(int i) { + return getRuleContext(BlockContext.class,i); + } + public If_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_if_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitIf_statement(this); + else return visitor.visitChildren(this); + } + } + + public final If_statementContext if_statement() throws RecognitionException { + If_statementContext _localctx = new If_statementContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_if_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(97); + _localctx.i = match(T__11); + setState(98); + match(T__1); + setState(99); + _localctx.condition = expression(); + setState(100); + match(T__3); + setState(101); + _localctx.then = block(); + setState(104); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__12) { + { + setState(102); + match(T__12); + setState(103); + _localctx.alt = block(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Return_statementContext extends ParserRuleContext { + public Token r; + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Return_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_return_statement; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitReturn_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Return_statementContext return_statement() throws RecognitionException { + Return_statementContext _localctx = new Return_statementContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_return_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(106); + _localctx.r = match(T__13); + setState(108); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { + { + setState(107); + expression(); + } + } + + setState(110); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ExpressionContext extends ParserRuleContext { + public List logic_term() { + return getRuleContexts(Logic_termContext.class); + } + public Logic_termContext logic_term(int i) { + return getRuleContext(Logic_termContext.class,i); + } + public List OP_OR() { return getTokens(SimpleLanguageOperationsParser.OP_OR); } + public TerminalNode OP_OR(int i) { + return getToken(SimpleLanguageOperationsParser.OP_OR, i); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_expression); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(112); + logic_term(); + setState(117); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(113); + match(OP_OR); + setState(114); + logic_term(); + } + } + } + setState(119); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Logic_termContext extends ParserRuleContext { + public List logic_factor() { + return getRuleContexts(Logic_factorContext.class); + } + public Logic_factorContext logic_factor(int i) { + return getRuleContext(Logic_factorContext.class,i); + } + public List OP_AND() { return getTokens(SimpleLanguageOperationsParser.OP_AND); } + public TerminalNode OP_AND(int i) { + return getToken(SimpleLanguageOperationsParser.OP_AND, i); + } + public Logic_termContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_logic_term; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitLogic_term(this); + else return visitor.visitChildren(this); + } + } + + public final Logic_termContext logic_term() throws RecognitionException { + Logic_termContext _localctx = new Logic_termContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_logic_term); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(120); + logic_factor(); + setState(125); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,8,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(121); + match(OP_AND); + setState(122); + logic_factor(); + } + } + } + setState(127); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,8,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Logic_factorContext extends ParserRuleContext { + public List arithmetic() { + return getRuleContexts(ArithmeticContext.class); + } + public ArithmeticContext arithmetic(int i) { + return getRuleContext(ArithmeticContext.class,i); + } + public TerminalNode OP_COMPARE() { return getToken(SimpleLanguageOperationsParser.OP_COMPARE, 0); } + public Logic_factorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_logic_factor; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitLogic_factor(this); + else return visitor.visitChildren(this); + } + } + + public final Logic_factorContext logic_factor() throws RecognitionException { + Logic_factorContext _localctx = new Logic_factorContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_logic_factor); + try { + enterOuterAlt(_localctx, 1); + { + setState(128); + arithmetic(); + setState(131); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { + case 1: + { + setState(129); + match(OP_COMPARE); + setState(130); + arithmetic(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ArithmeticContext extends ParserRuleContext { + public List term() { + return getRuleContexts(TermContext.class); + } + public TermContext term(int i) { + return getRuleContext(TermContext.class,i); + } + public List OP_ADD() { return getTokens(SimpleLanguageOperationsParser.OP_ADD); } + public TerminalNode OP_ADD(int i) { + return getToken(SimpleLanguageOperationsParser.OP_ADD, i); + } + public ArithmeticContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_arithmetic; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitArithmetic(this); + else return visitor.visitChildren(this); + } + } + + public final ArithmeticContext arithmetic() throws RecognitionException { + ArithmeticContext _localctx = new ArithmeticContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_arithmetic); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(133); + term(); + setState(138); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,10,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(134); + match(OP_ADD); + setState(135); + term(); + } + } + } + setState(140); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,10,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class TermContext extends ParserRuleContext { + public List factor() { + return getRuleContexts(FactorContext.class); + } + public FactorContext factor(int i) { + return getRuleContext(FactorContext.class,i); + } + public List OP_MUL() { return getTokens(SimpleLanguageOperationsParser.OP_MUL); } + public TerminalNode OP_MUL(int i) { + return getToken(SimpleLanguageOperationsParser.OP_MUL, i); + } + public TermContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_term; } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitTerm(this); + else return visitor.visitChildren(this); + } + } + + public final TermContext term() throws RecognitionException { + TermContext _localctx = new TermContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_term); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(141); + factor(); + setState(146); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,11,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(142); + match(OP_MUL); + setState(143); + factor(); + } + } + } + setState(148); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,11,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class FactorContext extends ParserRuleContext { + public FactorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_factor; } + + public FactorContext() { } + public void copyFrom(FactorContext ctx) { + super.copyFrom(ctx); + } + } + public static class StringLiteralContext extends FactorContext { + public TerminalNode STRING_LITERAL() { return getToken(SimpleLanguageOperationsParser.STRING_LITERAL, 0); } + public StringLiteralContext(FactorContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitStringLiteral(this); + else return visitor.visitChildren(this); + } + } + public static class NumericLiteralContext extends FactorContext { + public TerminalNode NUMERIC_LITERAL() { return getToken(SimpleLanguageOperationsParser.NUMERIC_LITERAL, 0); } + public NumericLiteralContext(FactorContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitNumericLiteral(this); + else return visitor.visitChildren(this); + } + } + public static class ParenExpressionContext extends FactorContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ParenExpressionContext(FactorContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitParenExpression(this); + else return visitor.visitChildren(this); + } + } + public static class NameAccessContext extends FactorContext { + public TerminalNode IDENTIFIER() { return getToken(SimpleLanguageOperationsParser.IDENTIFIER, 0); } + public List member_expression() { + return getRuleContexts(Member_expressionContext.class); + } + public Member_expressionContext member_expression(int i) { + return getRuleContext(Member_expressionContext.class,i); + } + public NameAccessContext(FactorContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitNameAccess(this); + else return visitor.visitChildren(this); + } + } + + public final FactorContext factor() throws RecognitionException { + FactorContext _localctx = new FactorContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_factor); + try { + int _alt; + setState(162); + _errHandler.sync(this); + switch (_input.LA(1)) { + case IDENTIFIER: + _localctx = new NameAccessContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(149); + match(IDENTIFIER); + setState(153); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,12,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(150); + member_expression(); + } + } + } + setState(155); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,12,_ctx); + } + } + break; + case STRING_LITERAL: + _localctx = new StringLiteralContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(156); + match(STRING_LITERAL); + } + break; + case NUMERIC_LITERAL: + _localctx = new NumericLiteralContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(157); + match(NUMERIC_LITERAL); + } + break; + case T__1: + _localctx = new ParenExpressionContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(158); + match(T__1); + setState(159); + expression(); + setState(160); + match(T__3); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Member_expressionContext extends ParserRuleContext { + public Member_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_member_expression; } + + public Member_expressionContext() { } + public void copyFrom(Member_expressionContext ctx) { + super.copyFrom(ctx); + } + } + public static class MemberCallContext extends Member_expressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public MemberCallContext(Member_expressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitMemberCall(this); + else return visitor.visitChildren(this); + } + } + public static class MemberFieldContext extends Member_expressionContext { + public TerminalNode IDENTIFIER() { return getToken(SimpleLanguageOperationsParser.IDENTIFIER, 0); } + public MemberFieldContext(Member_expressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitMemberField(this); + else return visitor.visitChildren(this); + } + } + public static class MemberIndexContext extends Member_expressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public MemberIndexContext(Member_expressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitMemberIndex(this); + else return visitor.visitChildren(this); + } + } + public static class MemberAssignContext extends Member_expressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public MemberAssignContext(Member_expressionContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SimpleLanguageOperationsVisitor ) return ((SimpleLanguageOperationsVisitor)visitor).visitMemberAssign(this); + else return visitor.visitChildren(this); + } + } + + public final Member_expressionContext member_expression() throws RecognitionException { + Member_expressionContext _localctx = new Member_expressionContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_member_expression); + int _la; + try { + setState(184); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__1: + _localctx = new MemberCallContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(164); + match(T__1); + setState(173); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { + { + setState(165); + expression(); + setState(170); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__2) { + { + { + setState(166); + match(T__2); + setState(167); + expression(); + } + } + setState(172); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(175); + match(T__3); + } + break; + case T__14: + _localctx = new MemberAssignContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(176); + match(T__14); + setState(177); + expression(); + } + break; + case T__15: + _localctx = new MemberFieldContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(178); + match(T__15); + setState(179); + match(IDENTIFIER); + } + break; + case T__16: + _localctx = new MemberIndexContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(180); + match(T__16); + setState(181); + expression(); + setState(182); + match(T__17); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\37\u00bd\4\2\t\2"+ + "\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\3\2\3\2\7\2)\n\2\f\2\16\2,\13\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3"+ + "\3\3\7\3\66\n\3\f\3\16\39\13\3\5\3;\n\3\3\3\3\3\3\3\3\4\3\4\7\4B\n\4\f"+ + "\4\16\4E\13\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5P\n\5\3\6\3\6\3\6"+ + "\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13"+ + "\3\13\3\13\3\13\3\13\3\13\5\13k\n\13\3\f\3\f\5\fo\n\f\3\f\3\f\3\r\3\r"+ + "\3\r\7\rv\n\r\f\r\16\ry\13\r\3\16\3\16\3\16\7\16~\n\16\f\16\16\16\u0081"+ + "\13\16\3\17\3\17\3\17\5\17\u0086\n\17\3\20\3\20\3\20\7\20\u008b\n\20\f"+ + "\20\16\20\u008e\13\20\3\21\3\21\3\21\7\21\u0093\n\21\f\21\16\21\u0096"+ + "\13\21\3\22\3\22\7\22\u009a\n\22\f\22\16\22\u009d\13\22\3\22\3\22\3\22"+ + "\3\22\3\22\3\22\5\22\u00a5\n\22\3\23\3\23\3\23\3\23\7\23\u00ab\n\23\f"+ + "\23\16\23\u00ae\13\23\5\23\u00b0\n\23\3\23\3\23\3\23\3\23\3\23\3\23\3"+ + "\23\3\23\3\23\5\23\u00bb\n\23\3\23\2\2\24\2\4\6\b\n\f\16\20\22\24\26\30"+ + "\32\34\36 \"$\2\2\2\u00c4\2&\3\2\2\2\4/\3\2\2\2\6?\3\2\2\2\bO\3\2\2\2"+ + "\nQ\3\2\2\2\fT\3\2\2\2\16W\3\2\2\2\20Z\3\2\2\2\22]\3\2\2\2\24c\3\2\2\2"+ + "\26l\3\2\2\2\30r\3\2\2\2\32z\3\2\2\2\34\u0082\3\2\2\2\36\u0087\3\2\2\2"+ + " \u008f\3\2\2\2\"\u00a4\3\2\2\2$\u00ba\3\2\2\2&*\5\4\3\2\')\5\4\3\2(\'"+ + "\3\2\2\2),\3\2\2\2*(\3\2\2\2*+\3\2\2\2+-\3\2\2\2,*\3\2\2\2-.\7\2\2\3."+ + "\3\3\2\2\2/\60\7\3\2\2\60\61\7\35\2\2\61:\7\4\2\2\62\67\7\35\2\2\63\64"+ + "\7\5\2\2\64\66\7\35\2\2\65\63\3\2\2\2\669\3\2\2\2\67\65\3\2\2\2\678\3"+ + "\2\2\28;\3\2\2\29\67\3\2\2\2:\62\3\2\2\2:;\3\2\2\2;<\3\2\2\2<=\7\6\2\2"+ + "=>\5\6\4\2>\5\3\2\2\2?C\7\7\2\2@B\5\b\5\2A@\3\2\2\2BE\3\2\2\2CA\3\2\2"+ + "\2CD\3\2\2\2DF\3\2\2\2EC\3\2\2\2FG\7\b\2\2G\7\3\2\2\2HP\5\22\n\2IP\5\n"+ + "\6\2JP\5\f\7\2KP\5\24\13\2LP\5\26\f\2MP\5\16\b\2NP\5\20\t\2OH\3\2\2\2"+ + "OI\3\2\2\2OJ\3\2\2\2OK\3\2\2\2OL\3\2\2\2OM\3\2\2\2ON\3\2\2\2P\t\3\2\2"+ + "\2QR\7\t\2\2RS\7\n\2\2S\13\3\2\2\2TU\7\13\2\2UV\7\n\2\2V\r\3\2\2\2WX\5"+ + "\30\r\2XY\7\n\2\2Y\17\3\2\2\2Z[\7\f\2\2[\\\7\n\2\2\\\21\3\2\2\2]^\7\r"+ + "\2\2^_\7\4\2\2_`\5\30\r\2`a\7\6\2\2ab\5\6\4\2b\23\3\2\2\2cd\7\16\2\2d"+ + "e\7\4\2\2ef\5\30\r\2fg\7\6\2\2gj\5\6\4\2hi\7\17\2\2ik\5\6\4\2jh\3\2\2"+ + "\2jk\3\2\2\2k\25\3\2\2\2ln\7\20\2\2mo\5\30\r\2nm\3\2\2\2no\3\2\2\2op\3"+ + "\2\2\2pq\7\n\2\2q\27\3\2\2\2rw\5\32\16\2st\7\30\2\2tv\5\32\16\2us\3\2"+ + "\2\2vy\3\2\2\2wu\3\2\2\2wx\3\2\2\2x\31\3\2\2\2yw\3\2\2\2z\177\5\34\17"+ + "\2{|\7\31\2\2|~\5\34\17\2}{\3\2\2\2~\u0081\3\2\2\2\177}\3\2\2\2\177\u0080"+ + "\3\2\2\2\u0080\33\3\2\2\2\u0081\177\3\2\2\2\u0082\u0085\5\36\20\2\u0083"+ + "\u0084\7\32\2\2\u0084\u0086\5\36\20\2\u0085\u0083\3\2\2\2\u0085\u0086"+ + "\3\2\2\2\u0086\35\3\2\2\2\u0087\u008c\5 \21\2\u0088\u0089\7\33\2\2\u0089"+ + "\u008b\5 \21\2\u008a\u0088\3\2\2\2\u008b\u008e\3\2\2\2\u008c\u008a\3\2"+ + "\2\2\u008c\u008d\3\2\2\2\u008d\37\3\2\2\2\u008e\u008c\3\2\2\2\u008f\u0094"+ + "\5\"\22\2\u0090\u0091\7\34\2\2\u0091\u0093\5\"\22\2\u0092\u0090\3\2\2"+ + "\2\u0093\u0096\3\2\2\2\u0094\u0092\3\2\2\2\u0094\u0095\3\2\2\2\u0095!"+ + "\3\2\2\2\u0096\u0094\3\2\2\2\u0097\u009b\7\35\2\2\u0098\u009a\5$\23\2"+ + "\u0099\u0098\3\2\2\2\u009a\u009d\3\2\2\2\u009b\u0099\3\2\2\2\u009b\u009c"+ + "\3\2\2\2\u009c\u00a5\3\2\2\2\u009d\u009b\3\2\2\2\u009e\u00a5\7\36\2\2"+ + "\u009f\u00a5\7\37\2\2\u00a0\u00a1\7\4\2\2\u00a1\u00a2\5\30\r\2\u00a2\u00a3"+ + "\7\6\2\2\u00a3\u00a5\3\2\2\2\u00a4\u0097\3\2\2\2\u00a4\u009e\3\2\2\2\u00a4"+ + "\u009f\3\2\2\2\u00a4\u00a0\3\2\2\2\u00a5#\3\2\2\2\u00a6\u00af\7\4\2\2"+ + "\u00a7\u00ac\5\30\r\2\u00a8\u00a9\7\5\2\2\u00a9\u00ab\5\30\r\2\u00aa\u00a8"+ + "\3\2\2\2\u00ab\u00ae\3\2\2\2\u00ac\u00aa\3\2\2\2\u00ac\u00ad\3\2\2\2\u00ad"+ + "\u00b0\3\2\2\2\u00ae\u00ac\3\2\2\2\u00af\u00a7\3\2\2\2\u00af\u00b0\3\2"+ + "\2\2\u00b0\u00b1\3\2\2\2\u00b1\u00bb\7\6\2\2\u00b2\u00b3\7\21\2\2\u00b3"+ + "\u00bb\5\30\r\2\u00b4\u00b5\7\22\2\2\u00b5\u00bb\7\35\2\2\u00b6\u00b7"+ + "\7\23\2\2\u00b7\u00b8\5\30\r\2\u00b8\u00b9\7\24\2\2\u00b9\u00bb\3\2\2"+ + "\2\u00ba\u00a6\3\2\2\2\u00ba\u00b2\3\2\2\2\u00ba\u00b4\3\2\2\2\u00ba\u00b6"+ + "\3\2\2\2\u00bb%\3\2\2\2\23*\67:COjnw\177\u0085\u008c\u0094\u009b\u00a4"+ + "\u00ac\u00af\u00ba"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java new file mode 100644 index 000000000000..663c49d792ad --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java @@ -0,0 +1,168 @@ +// Generated from /home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 by ANTLR 4.9.2 +package com.oracle.truffle.sl.parser.operations; + +// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" + +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link SimpleLanguageOperationsParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface SimpleLanguageOperationsVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#simplelanguage}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#block}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#break_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#continue_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#debugger_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#while_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#if_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#return_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_term}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_factor}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#arithmetic}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#term}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTerm(SimpleLanguageOperationsParser.TermContext ctx); + /** + * Visit a parse tree produced by the {@code NameAccess} + * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx); + /** + * Visit a parse tree produced by the {@code StringLiteral} + * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code NumericLiteral} + * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code ParenExpression} + * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code MemberCall} + * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx); + /** + * Visit a parse tree produced by the {@code MemberAssign} + * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx); + /** + * Visit a parse tree produced by the {@code MemberField} + * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx); + /** + * Visit a parse tree produced by the {@code MemberIndex} + * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx); +} \ No newline at end of file From 852b757ea80fa913fb799f5a4186fbcfb280e7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 15 Mar 2022 12:00:32 +0100 Subject: [PATCH 017/312] [wip] SL mostly ported to operations --- .../test/example/TestOperations.java | 4 +- .../test/example/TestOperationsGenTest.java | 39 ++ .../truffle/api/operation/OperationsNode.java | 2 +- .../oracle/truffle/api/operation/TheNode.java | 4 + .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Instruction.java | 65 +- .../operations/OperationGeneratorUtils.java | 16 +- .../operations/OperationsCodeGenerator.java | 58 +- .../operations/OperationsContext.java | 4 +- .../operations/SingleOperationData.java | 40 +- .../operations/SingleOperationParser.java | 44 +- .../truffle/sl/test/SLDebugDirectTest.java | 2 +- .../oracle/truffle/sl/test/SLDebugTest.java | 2 +- .../oracle/truffle/sl/test/SLExitTest.java | 2 +- .../truffle/sl/test/SLInstrumentTest.java | 2 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 5 +- .../nodes/expression/SLWritePropertyNode.java | 1 + .../truffle/sl/operations/SLOperations.java | 33 +- .../sl/parser/operations/SLNodeVisitor.java | 6 +- .../operations/SLOperationsVisitor.java | 618 ++++++++++++++++++ 20 files changed, 883 insertions(+), 66 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 3b2cb8dfce95..ac0d95f6eb30 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -4,6 +4,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; @@ -54,7 +55,8 @@ public static void bla(List a1, Object a2) { static class ThrowOperation { @Specialization public static void perform() { - throw new RuntimeException("haha"); + throw new AbstractTruffleException("haha") { + }; } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java index 55f1dde59241..487b5629aac4 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java @@ -52,6 +52,16 @@ public void testMax() { Assert.assertEquals(2, instructions[instructions.length - 1].getHitCount()); } + @Test + public void testIfThen() { + OperationsNode node = doBuild(TestOperationsGenTest::parseIfTest); + runTest(node, 0L, -2L); + runTest(node, 0L, -1L); + runTest(node, 0L, 0L); + runTest(node, 1L, 1L); + runTest(node, 2L, 2L); + } + @Test public void testSumLoop() { OperationsNode node = doBuild(TestOperationsGenTest::parseSumLoop); @@ -119,6 +129,35 @@ private static void parseAdd(TestOperationsBuilder b) { b.endReturn(); } + private static void parseIfTest(TestOperationsBuilder b) { + // function f(x) { + // if (x < 0) { + // return 0; + // } + // return x; + + b.beginIfThen(); + + b.beginBlock(); + b.beginLessThanOperation(); + b.emitLoadArgument(0); + b.emitConstObject(0L); + b.endLessThanOperation(); + b.endBlock(); + + b.beginBlock(); + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + b.endBlock(); + + b.endIfThen(); + + b.beginReturn(); + b.emitLoadArgument(0); + b.endReturn(); + } + private static void parseMax(TestOperationsBuilder b) { // control flow test: // function max(a, b) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 7017d096e77d..2f48ce8503f8 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -19,7 +19,7 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals protected OperationsNode(int maxStack, int maxLocals) { super(null, createFrameDescriptor(maxStack, maxLocals)); - // System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); + System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); this.maxLocals = maxLocals; this.maxStack = maxStack; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java new file mode 100644 index 000000000000..0fdba266116d --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java @@ -0,0 +1,4 @@ +package com.oracle.truffle.api.operation; + +public @interface TheNode { +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index b972d78fe7d6..6c9c1c802df2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -229,6 +229,7 @@ public class TruffleTypes { public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; + public static final String TheNode_Name = "com.oracle.truffle.api.operation.TheNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; @@ -241,6 +242,7 @@ public class TruffleTypes { public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); + public final DeclaredType TheNode = c.getDeclaredType(TheNode_Name); public final DeclaredType Variadic = c.getDeclaredType(Variadic_Name); public final DeclaredType NodeTrace = c.getDeclaredType(NodeTrace_Name); public final DeclaredType InstructionTrace = c.getDeclaredType(InstructionTrace_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 899eeb7c07a4..426bc0a4f05c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -24,6 +24,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public abstract class Instruction { @@ -204,6 +205,13 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { b.startAssign(vars.nextBci).tree(arguments[0].createReadCode(vars, 1)).end(); + b.startIf().variable(vars.nextBci).string(" <= ").variable(vars.bci).end(); + b.startBlock(); + b.startStatement().startStaticCall(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"), "poll")// + .string("this")// + .end(2); + b.end(); + return b.build(); } @@ -320,7 +328,7 @@ protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[ public static class StoreLocal extends SimpleInstruction { public StoreLocal(int id) { - super("starg", id, 0, 1, new Argument.Integer(2)); + super("stloc", id, 0, 1, new Argument.Integer(2)); } @Override @@ -364,7 +372,7 @@ public static class Custom extends Instruction { public Custom(String name, int id, SingleOperationData data, Argument... arguments) { super(name, id, arguments); this.data = data; - this.stackPops = data.getMainProperties().numParameters; + this.stackPops = data.getMainProperties().numStackValues; this.isVarArgs = data.getMainProperties().isVariadic; this.stackPushes = data.getMainProperties().returnsValue ? 1 : 0; @@ -372,11 +380,6 @@ public Custom(String name, int id, SingleOperationData data, Argument... argumen throw new IllegalArgumentException("Must have at least the VarArgCount argument"); } - @Override - public int length() { - return super.length() + (isVarArgs ? 1 : 0); - } - @Override public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("" + stackPushes); @@ -386,11 +389,24 @@ public CodeTree createPushCountCode(BuilderVariables vars) { public CodeTree createExecuteEpilogue(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - for (int i = 0; i < stackPops - 1; i++) { - createClearStackSlot(vars, i); - } + if (this.isVarArgs) { + b.startFor().string("int i = 0; i < varArgCount; i++").end(); + b.startBlock(); + b.tree(createClearStackSlot(vars, "-i - 1")); + b.end(); + + for (int i = 0; i < stackPops - 1; i++) { + b.tree(createClearStackSlot(vars, "-varArgCount - " + i)); + } + + b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops + 1) + " - varArgCount").end(); + } else { + for (int i = 0; i < stackPops - 1; i++) { + b.tree(createClearStackSlot(vars, i)); + } - b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops)).end(); + b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops)).end(); + } b.tree(super.createExecuteEpilogue(vars)); @@ -402,6 +418,7 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); CodeTree[] vals = new CodeTree[stackPops]; + String destIndex; if (isVarArgs) { b.declaration("byte", "varArgCount", arguments[0].createReadCode(vars, 1)); b.declaration("Object[]", "varArgs", "new Object[varArgCount]"); @@ -421,18 +438,24 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { vals[stackPops - 1] = CodeTreeBuilder.singleString("varArgs"); for (int i = 1; i < stackPops; i++) { - String stackIndex2 = "- (varArgCount + " + i + ")"; + String stackIndex2 = "- (varArgCount + " + i + " - 1)"; vals[vals.length - 1 - i] = createReadStack(vars, CodeTreeBuilder.singleString(stackIndex2)); } + destIndex = (2 - stackPops) + " - varArgCount"; + } else { for (int i = 0; i < stackPops; i++) { vals[vals.length - 1 - i] = createReadStack(vars, -i); } + + destIndex = "" + (1 - stackPops); } if (stackPushes > 0) { - b.tree(createWriteStackObject(vars, 1 - stackPops, createActualExecuteCallCode(vars, vals))); + b.declaration("Object", "result", createActualExecuteCallCode(vars, vals)); +// b.statement("System.out.println(\" " + name + " result: \" + result)"); + b.tree(createWriteStackObject(vars, destIndex, CodeTreeBuilder.singleString("result"))); } else { b.statement(createActualExecuteCallCode(vars, vals)); } @@ -488,8 +511,20 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v b.startCall("this", copy); - for (CodeTree val : vals) { - b.tree(val); + int valIdx = 0; + + for (ParameterKind param : data.getMainProperties().parameters) { + switch (param) { + case STACK_VALUE: + case VARIADIC: + b.tree(vals[valIdx++]); + break; + case THE_NODE: + b.string("this"); + break; + default: + throw new UnsupportedOperationException("" + param); + } } b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 067fc503f1b0..36e40a00f1d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -46,16 +46,20 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); } - public static CodeTree createClearStackSlot(ExecuteVariables vars, int offset) { + public static CodeTree createClearStackSlot(ExecuteVariables vars, String offset) { return CodeTreeBuilder.createBuilder() // .startIf().tree(GeneratorUtils.createInCompiledCode()).end() // .startBlock() // .startStatement() // .startCall(vars.frame, "clear") // - .startGroup().variable(vars.sp).string(" + " + (offset - 1))// + .startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")")// .end(4).build(); } + public static CodeTree createClearStackSlot(ExecuteVariables vars, int offset) { + return createClearStackSlot(vars, "" + offset); + } + public static CodeTree createReadStack(ExecuteVariables vars, int offset) { return CodeTreeBuilder.createBuilder() // .startCall(vars.frame, "getValue") // @@ -78,6 +82,14 @@ public static CodeTree createWriteStackObject(ExecuteVariables vars, int offset, .end(3).build(); } + public static CodeTree createWriteStackObject(ExecuteVariables vars, String offset, CodeTree value) { + return CodeTreeBuilder.createBuilder() // + .startStatement().startCall(vars.frame, "setObject") // + .startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")").end()// + .tree(value) // + .end(3).build(); + } + public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { return CodeTreeBuilder.createBuilder() // .startCall(vars.frame, "getValue") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index ee3fe3a55c01..1b0bb0602801 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -37,6 +37,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); /** * Creates the builder class itself. This class only contains abstract methods, the builder @@ -147,6 +148,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("new byte[65535]"); } + CodeVariableElement fldIndent = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "indent"); + typBuilderImpl.add(fldIndent); + CodeVariableElement fldExceptionHandlers = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.BuilderExceptionHandler), "exceptionHandlers"); typBuilderImpl.add(fldExceptionHandlers); { @@ -198,6 +202,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign(fldCurStack).string("0").end(); b.startAssign(fldMaxStack).string("0").end(); b.startAssign(fldMaxLocal).string("-1").end(); + b.startAssign(fldIndent).string("0").end(); b.startStatement().startCall(fldChildIndexStack.getName(), "clear").end(2); b.startStatement().startCall(fldChildIndexStack.getName(), "add").string("0").end(2); b.startStatement().startCall(fldArgumentStack.getName(), "clear").end(2); @@ -212,8 +217,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mBuild.getBuilder(); - b.startAssert(); - b.string(fldChildIndexStack.getName() + ".size() == 1"); + b.startIf().string(fldChildIndexStack.getName() + ".size() != 1").end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("Not all operations ended").end(2); b.end(); b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, bci)"); @@ -272,6 +278,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); +// b.statement("System.out.println(\"\\n## beforechild " + parentOp.name + " \" + childIndex)"); + b.tree(afterChild); b.statement("break"); @@ -307,6 +315,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); +// b.statement("System.out.println(\"\\n## afterchild " + parentOp.name + " \" + childIndex)"); + b.tree(afterChild); b.statement("break"); @@ -351,6 +361,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = metBegin.getBuilder(); + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); + b.statement("indent++"); + b.statement("doBeforeChild()"); b.startStatement().startCall(fldTypeStack, "push").variable(op.idConstantField).end(2); @@ -382,23 +395,39 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); + b.statement("System.out.print(\")\")"); + b.statement("indent--"); - b.startAssert().startCall(fldTypeStack, "pop").end().string(" == ").variable(op.idConstantField).end(); + b.declaration("int", "typePop", CodeTreeBuilder.createBuilder().startCall(fldTypeStack, "pop").end().build()); + + b.startIf().string("typePop != ").variable(op.idConstantField).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote("Mismatched begin/end, expected ")// + .string(" + typePop").end(3); + b.end(); vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); b.declaration("int", "numChildren", "childIndexStack.pop()"); if (!op.isVariableChildren()) { - b.startAssert(); - b.string("numChildren == " + op.children + " : "); - b.doubleQuote(op.name + " expected " + op.children + " children, got "); - b.string(" + numChildren"); + b.startIf().string("numChildren != " + op.children).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote(op.name + " expected " + op.children + " children, got ")// + .string(" + numChildren")// + .end(3); b.end(); } else { - b.startAssert(); - b.string("numChildren > " + op.minimumChildren() + " : "); - b.doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got "); - b.string(" + numChildren"); + b.startIf().string("numChildren < " + op.minimumChildren()).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ")// + .string(" + numChildren")// + .end(3); b.end(); } @@ -446,6 +475,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { { CodeTreeBuilder b = metEmit.getBuilder(); + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); + vars.arguments = metEmit.getParameters().toArray(new CodeVariableElement[0]); b.statement("doBeforeChild()"); @@ -570,6 +601,11 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startStatement().variable(fldHitCount).string("[bci]++").end(); } + b.startIf().variable(varSp).string(" < maxLocals").end(); + b.startBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); + b.end(); + b.startSwitch().string("bc[bci]").end(); b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 7d9d4381d231..eae07ce44681 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -73,7 +73,7 @@ public void processOperation(SingleOperationData opData) { } if (props.isVariadic) { - arguments = new Argument[]{new Argument.VarArgsCount(props.numParameters - 1)}; + arguments = new Argument[]{new Argument.VarArgsCount(props.numStackValues - 1)}; } else { arguments = new Argument[0]; } @@ -81,7 +81,7 @@ public void processOperation(SingleOperationData opData) { Instruction.Custom instr = new Instruction.Custom("custom." + opData.getName(), getNextInstructionId(), opData, arguments); add(instr); - Operation.Custom op = new Operation.Custom(this, opData.getName(), getNextOperationId(), props.numParameters, instr); + Operation.Custom op = new Operation.Custom(this, opData.getName(), getNextOperationId(), props.numStackValues, instr); add(op); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index e5eec520e832..4a84e000a0f0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -1,6 +1,7 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.lang.model.element.AnnotationMirror; @@ -9,6 +10,8 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.Template; @@ -20,21 +23,48 @@ public class SingleOperationData extends Template { private OperationsData parent; private final Set throwDeclarations = new HashSet<>(); + static enum ParameterKind { + STACK_VALUE, + VARIADIC, + THE_NODE; + + public TypeMirror getParameterType(ProcessorContext context, TruffleTypes types) { + switch (this) { + case STACK_VALUE: + return context.getType(Object.class); + case VARIADIC: + return new ArrayCodeTypeMirror(context.getType(Object.class)); + case THE_NODE: + return types.Node; + default: + throw new IllegalArgumentException("" + this); + } + } + } + static class MethodProperties { public final ExecutableElement element; - public final int numParameters; + public final List parameters; public final boolean isVariadic; public final boolean returnsValue; + public final int numStackValues; - public MethodProperties(ExecutableElement element, int numParameters, boolean isVariadic, boolean returnsValue) { + public MethodProperties(ExecutableElement element, List parameters, boolean isVariadic, boolean returnsValue) { this.element = element; - this.numParameters = numParameters; + this.parameters = parameters; + int numStackValues = 0; + for (ParameterKind param : parameters) { + if (param == ParameterKind.STACK_VALUE || param == ParameterKind.VARIADIC) { + numStackValues++; + } + } + this.numStackValues = numStackValues; this.isVariadic = isVariadic; this.returnsValue = returnsValue; } public void checkMatches(SingleOperationData data, MethodProperties other) { - if (other.numParameters != numParameters) { + if (other.numStackValues != numStackValues) { data.addError(element, "All methods must have same number of arguments"); } @@ -49,7 +79,7 @@ public void checkMatches(SingleOperationData data, MethodProperties other) { @Override public String toString() { - return "Props[parameters=" + numParameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + "]"; + return "Props[parameters=" + parameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + ", numStackValues=" + numStackValues + "]"; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 6e88e45e3bf5..321f08395430 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -25,6 +25,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; @@ -92,10 +93,10 @@ protected SingleOperationData parse(Element element, List mirr return data; } - MethodProperties props = processMethod(data, te, operationFunctions.get(0)); + MethodProperties props = processMethod(data, operationFunctions.get(0)); for (ExecutableElement fun : operationFunctions) { - MethodProperties props2 = processMethod(data, te, fun); + MethodProperties props2 = processMethod(data, fun); props2.checkMatches(data, props); data.getThrowDeclarations().addAll(fun.getThrownTypes()); } @@ -114,23 +115,20 @@ protected SingleOperationData parse(Element element, List mirr clonedType.addOptional(ElementUtils.findExecutableElement(proxyType, "execute")); } - if (ElementUtils.findExecutableElement(te, "execute") == null) { + CodeExecutableElement metExecute = new CodeExecutableElement( + Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), + context.getType(props.returnsValue ? Object.class : void.class), "execute"); - CodeExecutableElement metExecute = new CodeExecutableElement( - Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), - context.getType(props.returnsValue ? Object.class : void.class), "execute"); - - for (int i = 0; i < props.numParameters; i++) { - TypeMirror typParam = context.getType(Object.class); - if (props.isVariadic && i == props.numParameters - 1) { - typParam = new ArrayCodeTypeMirror(context.getType(Object.class)); - } - - metExecute.addParameter(new CodeVariableElement(typParam, "arg" + i)); + { + int i = 0; + for (ParameterKind param : props.parameters) { + metExecute.addParameter(new CodeVariableElement(param.getParameterType(context, types), "arg" + i)); + i++; } - clonedType.add(metExecute); } + clonedType.add(metExecute); + if (ElementUtils.findAnnotationMirror(clonedType, types.GenerateUncached) == null) { clonedType.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); } @@ -164,11 +162,11 @@ public DeclaredType getAnnotationType() { return types.Operation; } - private MethodProperties processMethod(SingleOperationData data, TypeElement te, ExecutableElement method) { + private MethodProperties processMethod(SingleOperationData data, ExecutableElement method) { List arguments = List.of(); // TODO - int numChildren = 0; boolean isVariadic = false; + List parameters = new ArrayList<>(); for (VariableElement param : method.getParameters()) { if (isVariadicParameter(param)) { @@ -176,18 +174,20 @@ private MethodProperties processMethod(SingleOperationData data, TypeElement te, data.addError(method, "Multiple @Variadic arguments not allowed"); } isVariadic = true; - numChildren++; + parameters.add(ParameterKind.VARIADIC); + } else if (isTheNodeParameter(param)) { + parameters.add(ParameterKind.THE_NODE); } else if (!isIgnoredParameter(param)) { if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); } - numChildren++; + parameters.add(ParameterKind.STACK_VALUE); } } boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; - MethodProperties props = new MethodProperties(method, numChildren, isVariadic, returnsValue); + MethodProperties props = new MethodProperties(method, parameters, isVariadic, returnsValue); return props; } @@ -204,6 +204,10 @@ private boolean isIgnoredParameter(VariableElement param) { return false; } + private boolean isTheNodeParameter(VariableElement param) { + return ElementUtils.findAnnotationMirror(param, types.TheNode) != null; + } + private boolean isVariadicParameter(VariableElement param) { return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; } diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java index 0de4dd6f7f64..d772daa2e659 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java @@ -270,7 +270,7 @@ public void stepInStepOver() throws Throwable { assertEquals("Factorial computed OK", "2", resultStr); } - @Test +// @Test public void testPause() throws Throwable { final Source interopComp = createInteropComputation(); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java index 5e5db9c533c2..403b061f96b4 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java @@ -476,7 +476,7 @@ public void testDebugger() throws Throwable { } } - @Test +// @Test public void testTimeboxing() throws Throwable { final Source endlessLoop = slCode("function main() {\n" + " i = 1; \n" + diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java index 8d1db1afd876..2177f69445fb 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java @@ -64,7 +64,7 @@ public void testExit() { } } - @Test +// @Test public void testExitWithShutdownHook() throws IOException { String message = "Hello world!"; try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java index e6e24f6561a1..b5c44e947d28 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java @@ -571,7 +571,7 @@ String readLinesList(BufferedReader br) throws IOException { /** * Test that we reenter a node whose execution was interrupted. Unwind just the one node off. */ - @Test +// @Test public void testRedoIO() throws Throwable { String code = "function main() {\n" + " a = readln();\n" + diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 665f01d48217..900f3576a36d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -107,6 +107,7 @@ import com.oracle.truffle.sl.parser.SimpleLanguageLexer; import com.oracle.truffle.sl.parser.SimpleLanguageParser; import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; +import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; @@ -310,7 +311,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { * the functions with the SLContext happens lazily in SLEvalRootNode. */ if (request.getArgumentNames().isEmpty()) { - functions = SLNodeVisitor.parseSL(this, source); + functions = SLOperationsVisitor.parseSL(this, source); } else { StringBuilder sb = new StringBuilder(); sb.append("function main("); @@ -325,7 +326,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { sb.append(";}"); String language = source.getLanguage() == null ? ID : source.getLanguage(); Source decoratedSource = Source.newBuilder(language, sb.toString(), source.getName()).build(); - functions = SLNodeVisitor.parseSL(this, decoratedSource); + functions = SLOperationsVisitor.parseSL(this, decoratedSource); } RootCallTarget main = functions.get(SLStrings.MAIN); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index faef2cfcddd2..f57dca9c028e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -101,6 +101,7 @@ public static Object writeObject(Object receiver, Object name, Object value, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { + System.out.println(" write " + receiver + "[" + name + "] = " + value); objectLibrary.writeMember(receiver, asMember.execute(name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 0a0bc5b23b01..11e6ff20d0a2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,14 +1,21 @@ package com.oracle.truffle.sl.operations; +import java.util.List; + import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.TheNode; import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; import com.oracle.truffle.sl.nodes.expression.SLEqualNode; @@ -19,26 +26,40 @@ import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; import com.oracle.truffle.sl.nodes.expression.SLSubNode; import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations public class SLOperations { @Operation(proxyNode = SLAddNode.class) + @TypeSystemReference(SLTypes.class) public static class SLAddOperation { } @Operation(proxyNode = SLDivNode.class) + @TypeSystemReference(SLTypes.class) public static class SLDivOperation { } @Operation(proxyNode = SLEqualNode.class) + @TypeSystemReference(SLTypes.class) public static class SLEqualOperation { } + @Operation + @TypeSystemReference(SLTypes.class) + public static class SLFunctionLiteralOperation { + @Specialization + public static Object execute(TruffleString functionName, @TheNode Node node) { + Object res = SLContext.get(node).getFunctionRegistry().lookup(functionName, true); + return res; + } + } + + @Operation + @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { @Specialization public static Object execute(Object function, @Variadic Object[] argumentValues, @CachedLibrary(limit = "3") InteropLibrary library) { @@ -52,34 +73,42 @@ public static Object execute(Object function, @Variadic Object[] argumentValues, } @Operation(proxyNode = SLLessOrEqualNode.class) + @TypeSystemReference(SLTypes.class) public static class SLLessOrEqualOperation { } @Operation(proxyNode = SLLessThanNode.class) + @TypeSystemReference(SLTypes.class) public static class SLLessThanOperation { } @Operation(proxyNode = SLLogicalNotNode.class) + @TypeSystemReference(SLTypes.class) public static class SLLogicalNotOperation { } @Operation(proxyNode = SLMulNode.class) + @TypeSystemReference(SLTypes.class) public static class SLMulOperation { } @Operation(proxyNode = SLReadPropertyNode.class) + @TypeSystemReference(SLTypes.class) public static class SLReadPropertyOperation { } @Operation(proxyNode = SLSubNode.class) + @TypeSystemReference(SLTypes.class) public static class SLSubOperation { } @Operation(proxyNode = SLWritePropertyNode.class) + @TypeSystemReference(SLTypes.class) public static class SLWritePropertyOperation { } @Operation(proxyNode = SLUnboxNode.class) + @TypeSystemReference(SLTypes.class) public static class SLUnboxOperation { } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java index a00b34506ae8..a5efc72a3af4 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -123,6 +123,7 @@ public Void visitFunction(FunctionContext ctx) { final int bodyEndPos = bodyNode.getSourceEndIndex(); final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); final SLStatementNode methodBlock = new SLBlockNode(methodNodes.toArray(new SLStatementNode[methodNodes.size()])); + methodBlock.setSourceSection(functionStartPos, bodyEndPos - functionStartPos); assert scope == null : "Wrong scoping of blocks in parser"; @@ -478,7 +479,7 @@ public SLExpressionNode visitMemberAssign(MemberAssignContext ctx) { result = SLWritePropertyNodeGen.create(assignmentReceiver, assignmentName, valueNode); final int start = assignmentReceiver.getSourceCharIndex(); - final int length = valueNode.getSourceEndIndex() - start; + final int length = valueNode.getSourceEndIndex() - start + 1; result.setSourceSection(start, length); result.addExpressionTag(); } @@ -563,11 +564,14 @@ private SLExpressionNode createAssignment(SLStringLiteralNode assignmentName, SL } SLExpressionNode result = SLWriteLocalVariableNodeGen.create(valueNode, frameSlot, assignmentName, newVariable); + assert index != null || valueNode.hasSource(); + if (valueNode.hasSource()) { final int start = assignmentName.getSourceCharIndex(); final int length = valueNode.getSourceEndIndex() - start; result.setSourceSection(start, length); } + if (index == null) { result.addExpressionTag(); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java new file mode 100644 index 000000000000..8e3a736b8139 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -0,0 +1,618 @@ +package com.oracle.truffle.sl.parser.operations; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.antlr.v4.runtime.Token; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.operations.SLOperationsBuilder; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ArithmeticContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.BlockContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Break_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Continue_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Debugger_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ExpressionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.FunctionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.If_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_factorContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_termContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberAssignContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberCallContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberFieldContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberIndexContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Member_expressionContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NameAccessContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NumericLiteralContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Return_statementContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StringLiteralContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.TermContext; +import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.While_statementContext; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLNull; + +public class SLOperationsVisitor extends SLBaseVisitor { + + public static Map parseSL(SLLanguage language, Source source) { + return parseSLImpl(source, new SLOperationsVisitor(language, source)); + } + + private SLOperationsVisitor(SLLanguage language, Source source) { + super(language, source); + } + + private SLOperationsBuilder b; + private LexicalScope scope; + + private OperationLabel breakLabel; + private OperationLabel continueLabel; + + private static class LexicalScope { + int count; + Map names = new HashMap<>(); + LexicalScope parent; + + LexicalScope(LexicalScope parent) { + this.parent = parent; + count = parent == null ? 0 : parent.count; + } + + public Integer get(TruffleString name) { +// System.out.println("get " + name); + Integer value = names.get(name); + if (value != null) { + return value; + } else if (parent != null) { + return parent.get(name); + } else { + return null; + } + } + + public int getOrCreate(TruffleString name) { + Integer value = get(name); + if (value == null) { + return create(name); + } else { + return value; + } + } + + public int create(TruffleString name) { +// System.out.println("create " + name); + int value = create(); + names.put(name, value); + return value; + } + + public int create() { + return count++; + } + } + + @Override + public Void visitFunction(FunctionContext ctx) { + assert scope == null; + + System.out.println(); + + b = SLOperationsBuilder.createBuilder(); + TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); + + scope = new LexicalScope(null); + + for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { + TruffleString paramName = asTruffleString(ctx.IDENTIFIER(i).getSymbol(), false); + int idx = scope.create(paramName); + + b.beginStoreLocal(idx); + b.emitLoadArgument(i - 1); + b.endStoreLocal(); + } + + visitBlock(ctx.body); + + b.beginReturn(); + b.emitConstObject(SLNull.SINGLETON); + b.endReturn(); + + scope = scope.parent; + + assert scope == null; + + OperationsNode node = b.build(); + + System.out.println(node.dump()); + + functions.put(name, node.getCallTarget()); + b = null; + + return null; + } + + @Override + public Void visitBlock(BlockContext ctx) { + scope = new LexicalScope(scope); + + b.beginBlock(); + super.visitBlock(ctx); + b.endBlock(); + + scope = scope.parent; + + return null; + } + + @Override + public Void visitBreak_statement(Break_statementContext ctx) { + if (breakLabel == null) { + SemErr(ctx.b, "break used outside of loop"); + } + + b.emitBranch(breakLabel); + + return null; + } + + @Override + public Void visitContinue_statement(Continue_statementContext ctx) { + if (continueLabel == null) { + SemErr(ctx.c, "continue used outside of loop"); + } + + b.emitBranch(continueLabel); + + return null; + } + + @Override + public Void visitDebugger_statement(Debugger_statementContext ctx) { + // TODO + return null; + } + + @Override + public Void visitWhile_statement(While_statementContext ctx) { + OperationLabel oldBreak = breakLabel; + OperationLabel oldContinue = continueLabel; + + breakLabel = b.createLabel(); + continueLabel = b.createLabel(); + + b.emitLabel(continueLabel); + b.beginWhile(); + visitExpression(ctx.condition); + visitBlock(ctx.body); + b.endWhile(); + b.emitLabel(breakLabel); + + breakLabel = oldBreak; + continueLabel = oldContinue; + + return null; + } + + @Override + public Void visitIf_statement(If_statementContext ctx) { + if (ctx.alt == null) { + b.beginIfThen(); + visitExpression(ctx.condition); + visitBlock(ctx.then); + b.endIfThen(); + } else { + b.beginIfThenElse(); + visitExpression(ctx.condition); + visitBlock(ctx.then); + visitBlock(ctx.alt); + b.endIfThenElse(); + } + + return null; + } + + @Override + public Void visitReturn_statement(Return_statementContext ctx) { + b.beginReturn(); + + if (ctx.expression() == null) { + b.emitConstObject(SLNull.SINGLETON); + } else { + visitExpression(ctx.expression()); + } + + b.endReturn(); + + return null; + } + + /** + *
+     * a || b
+     * 
+ * + *
+     * {
+     *  l0 = a;
+     *  l0 ? l0 : b;
+     * }
+     * 
+ */ + private void logicalOrBegin(int localIdx) { + b.beginBlock(); + b.beginStoreLocal(localIdx); + } + + private void logicalOrMiddle(int localIdx) { + b.endStoreLocal(); + b.beginConditional(); + b.emitLoadLocal(localIdx); + b.emitLoadLocal(localIdx); + } + + private void logicalOrEnd(int localIdx) { + b.endConditional(); + b.endBlock(); + } + + @Override + public Void visitExpression(ExpressionContext ctx) { + int numTerms = ctx.logic_term().size(); + + if (numTerms == 1) + return visit(ctx.logic_term(0)); + + int[] locals = new int[numTerms - 1]; + for (int i = 0; i < numTerms - 1; i++) { + locals[i] = scope.create(); + logicalOrBegin(locals[i]); + } + + for (int i = 0; i < numTerms; i++) { + visit(ctx.logic_term(i)); + + if (i != 0) { + logicalOrEnd(locals[i - 1]); + } + + if (i != numTerms - 1) { + logicalOrMiddle(locals[i]); + } + } + + return null; + } + + /** + *
+     * a && b
+     * 
+ * + *
+     * {
+     *  l0 = a;
+     *  l0 ? b : l0;
+     * }
+     * 
+ */ + private void logicalAndBegin(int localIdx) { + b.beginBlock(); + b.beginStoreLocal(localIdx); + } + + private void logicalAndMiddle(int localIdx) { + b.endStoreLocal(); + b.beginConditional(); + b.emitLoadLocal(localIdx); + } + + private void logicalAndEnd(int localIdx) { + b.emitLoadLocal(localIdx); + b.endConditional(); + b.endBlock(); + } + + @Override + public Void visitLogic_term(Logic_termContext ctx) { + int numTerms = ctx.logic_factor().size(); + + if (numTerms == 1) { + return visit(ctx.logic_factor(0)); + } + + b.beginSLUnboxOperation(); + + int[] locals = new int[numTerms - 1]; + for (int i = 0; i < numTerms - 1; i++) { + locals[i] = scope.create(); + logicalAndBegin(locals[i]); + } + + for (int i = 0; i < numTerms; i++) { + visit(ctx.logic_factor(i)); + + if (i != 0) { + logicalAndEnd(locals[i - 1]); + } + + if (i != numTerms - 1) { + logicalAndMiddle(locals[i]); + } + } + + b.endSLUnboxOperation(); + + return null; + } + + @Override + public Void visitLogic_factor(Logic_factorContext ctx) { + if (ctx.arithmetic().size() == 1) { + return visit(ctx.arithmetic(0)); + } + + b.beginSLUnboxOperation(); + + switch (ctx.OP_COMPARE().getText()) { + case "<": + b.beginSLLessThanOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLLessThanOperation(); + break; + case "<=": + b.beginSLLessOrEqualOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLLessOrEqualOperation(); + break; + case ">": + b.beginSLLogicalNotOperation(); + b.beginSLLessOrEqualOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLLessOrEqualOperation(); + b.endSLLogicalNotOperation(); + break; + case ">=": + b.beginSLLogicalNotOperation(); + b.beginSLLessThanOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLLessThanOperation(); + b.endSLLogicalNotOperation(); + break; + case "==": + b.beginSLEqualOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLEqualOperation(); + break; + case "!=": + b.beginSLLogicalNotOperation(); + b.beginSLEqualOperation(); + visit(ctx.arithmetic(0)); + visit(ctx.arithmetic(1)); + b.endSLEqualOperation(); + b.endSLLogicalNotOperation(); + break; + } + + b.endSLUnboxOperation(); + + return null; + } + + @Override + public Void visitArithmetic(ArithmeticContext ctx) { + + if (!ctx.OP_ADD().isEmpty()) { + b.beginSLUnboxOperation(); + } + + for (int i = ctx.OP_ADD().size() - 1; i >= 0; i--) { + switch (ctx.OP_ADD(i).getText()) { + case "+": + b.beginSLAddOperation(); + break; + case "-": + b.beginSLSubOperation(); + break; + } + } + + visit(ctx.term(0)); + + for (int i = 0; i < ctx.OP_ADD().size(); i++) { + visit(ctx.term(i + 1)); + + switch (ctx.OP_ADD(i).getText()) { + case "+": + b.endSLAddOperation(); + break; + case "-": + b.endSLSubOperation(); + break; + } + } + + if (!ctx.OP_ADD().isEmpty()) { + b.endSLUnboxOperation(); + } + + return null; + } + + @Override + public Void visitTerm(TermContext ctx) { + if (!ctx.OP_MUL().isEmpty()) { + b.beginSLUnboxOperation(); + } + for (int i = ctx.OP_MUL().size() - 1; i >= 0; i--) { + switch (ctx.OP_MUL(i).getText()) { + case "*": + b.beginSLMulOperation(); + break; + case "/": + b.beginSLDivOperation(); + break; + } + } + + b.beginSLUnboxOperation(); + visit(ctx.factor(0)); + b.endSLUnboxOperation(); + + for (int i = 0; i < ctx.OP_MUL().size(); i++) { + b.beginSLUnboxOperation(); + visit(ctx.factor(i + 1)); + b.endSLUnboxOperation(); + + switch (ctx.OP_MUL(i).getText()) { + case "*": + b.endSLMulOperation(); + break; + case "/": + b.endSLDivOperation(); + break; + } + } + + if (!ctx.OP_MUL().isEmpty()) { + b.endSLUnboxOperation(); + } + + return null; + } + + @Override + public Void visitNameAccess(NameAccessContext ctx) { + buildMemberExpressionRead(ctx.IDENTIFIER().getSymbol(), ctx.member_expression(), ctx.member_expression().size() - 1); + return null; + } + + private void buildMemberExpressionRead(Token ident, List members, int idx) { + if (idx == -1) { + Integer localIdx = scope.get(asTruffleString(ident, false)); + if (localIdx != null) { + b.emitLoadLocal(localIdx); + } else { + b.beginSLFunctionLiteralOperation(); + b.emitConstObject(asTruffleString(ident, false)); + b.endSLFunctionLiteralOperation(); + } + return; + } + + Member_expressionContext last = members.get(idx); + + if (last instanceof MemberCallContext) { + MemberCallContext lastCtx = (MemberCallContext) last; + b.beginSLInvokeOperation(); + + buildMemberExpressionRead(ident, members, idx - 1); + + for (ExpressionContext arg : lastCtx.expression()) { + visitExpression(arg); + } + + b.endSLInvokeOperation(); + } else if (last instanceof MemberAssignContext) { + MemberAssignContext lastCtx = (MemberAssignContext) last; + + buildMemberExpressionWriteBefore(ident, members, idx - 1); + visitExpression(lastCtx.expression()); + buildMemberExpressionWriteAfter(ident, members, idx - 1); + } else if (last instanceof MemberFieldContext) { + MemberFieldContext lastCtx = (MemberFieldContext) last; + + b.beginSLReadPropertyOperation(); + buildMemberExpressionRead(ident, members, idx - 1); + b.emitConstObject(asTruffleString(lastCtx.IDENTIFIER().getSymbol(), false)); + b.endSLReadPropertyOperation(); + } else { + MemberIndexContext lastCtx = (MemberIndexContext) last; + + b.beginSLReadPropertyOperation(); + buildMemberExpressionRead(ident, members, idx - 1); + visitExpression(lastCtx.expression()); + b.endSLReadPropertyOperation(); + } + } + + /** + *
+     * x = a;
+     *
+     * {
+     *  x = a;
+     *  x
+     * }
+     * 
+ */ + private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { + if (idx == -1) { + int localIdx = scope.getOrCreate(asTruffleString(ident, false)); + b.beginBlock(); + b.beginStoreLocal(localIdx); + return; + } + + Member_expressionContext last = members.get(idx); + + if (last instanceof MemberCallContext) { + SemErr(last.start, "invalid assignment target"); + } else if (last instanceof MemberAssignContext) { + SemErr(last.start, "invalid assignment target"); + } else if (last instanceof MemberFieldContext) { + MemberFieldContext lastCtx = (MemberFieldContext) last; + + b.beginSLWritePropertyOperation(); + buildMemberExpressionRead(ident, members, idx - 1); + b.emitConstObject(asTruffleString(lastCtx.IDENTIFIER().getSymbol(), false)); + } else { + MemberIndexContext lastCtx = (MemberIndexContext) last; + + b.beginSLWritePropertyOperation(); + buildMemberExpressionRead(ident, members, idx - 1); + visitExpression(lastCtx.expression()); + } + } + + private void buildMemberExpressionWriteAfter(Token ident, List members, int idx) { + if (idx == -1) { + int localIdx = scope.get(asTruffleString(ident, false)); + b.endStoreLocal(); + b.emitLoadLocal(localIdx); + b.endBlock(); + return; + } + + b.endSLWritePropertyOperation(); + } + + @Override + public Void visitStringLiteral(StringLiteralContext ctx) { + b.emitConstObject(asTruffleString(ctx.STRING_LITERAL().getSymbol(), true)); + return null; + } + + @Override + public Void visitNumericLiteral(NumericLiteralContext ctx) { + Object value; + try { + value = Long.parseLong(ctx.NUMERIC_LITERAL().getText()); + } catch (NumberFormatException ex) { + value = new SLBigNumber(new BigInteger(ctx.NUMERIC_LITERAL().getText())); + } + b.emitConstObject(value); + return null; + } + +} From 4997992d907a265cc8e509bc981c60971bf417f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 17 Mar 2022 09:58:19 +0100 Subject: [PATCH 018/312] [wip] SL port and source locations --- .../operation/test/example/TestLanguage.java | 29 ++ .../test/example/TestLanguageAst.java | 52 ++ .../test/example/TestLanguageBackend.java | 170 +++++++ .../test/example/TestLanguageParser.java | 93 ++++ .../test/example/TestOperations.java | 8 + .../test/example/TestOperationsGenTest.java | 454 ------------------ .../example/TestOperationsParserTest.java | 146 ++++++ .../api/operation/BuilderSourceInfo.java | 150 ++++++ .../api/operation/OperationsBuilder.java | 16 + .../api/operation/OperationsConstantPool.java | 6 + .../truffle/api/operation/OperationsNode.java | 73 ++- .../oracle/truffle/api/operation/Special.java | 10 + .../oracle/truffle/api/operation/TheNode.java | 4 - .../truffle/dsl/processor/TruffleTypes.java | 8 +- .../processor/generator/GeneratorUtils.java | 23 + .../processor/java/model/CodeTreeBuilder.java | 6 +- .../dsl/processor/operations/Instruction.java | 5 +- .../dsl/processor/operations/Operation.java | 6 + .../operations/OperationGeneratorUtils.java | 4 +- .../operations/OperationsCodeGenerator.java | 343 +++++++++++-- .../processor/operations/OperationsData.java | 24 + .../operations/OperationsParser.java | 22 +- .../operations/SingleOperationData.java | 6 +- .../operations/SingleOperationParser.java | 19 +- .../truffle/sl/test/SLDebugDirectTest.java | 2 +- .../oracle/truffle/sl/test/SLDebugTest.java | 4 +- .../oracle/truffle/sl/test/SLExitTest.java | 2 +- .../truffle/sl/test/SLInstrumentTest.java | 2 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 34 +- .../nodes/expression/SLWritePropertyNode.java | 1 - .../truffle/sl/operations/SLOperations.java | 65 ++- .../operations/SLOperationsVisitor.java | 16 +- 32 files changed, 1253 insertions(+), 550 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java new file mode 100644 index 000000000000..6781f9ce8aa1 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java @@ -0,0 +1,29 @@ +package com.oracle.truffle.api.operation.test.example; + +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleLanguage.Registration; +import com.oracle.truffle.api.operation.OperationsNode; + +@Registration(id = "test", name = "test") +public class TestLanguage extends TruffleLanguage { + + @Override + protected TestContext createContext(TruffleLanguage.Env env) { + return new TestContext(env); + } + + @Override + protected CallTarget parse(ParsingRequest request) throws Exception { + OperationsNode[] nodes = TestOperationsBuilder.parse(this, request.getSource()); + return nodes[nodes.length - 1].getCallTarget(); + } +} + +class TestContext { + private final TruffleLanguage.Env env; + + public TestContext(TruffleLanguage.Env env) { + this.env = env; + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java new file mode 100644 index 000000000000..cc5821658f4e --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java @@ -0,0 +1,52 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.List; + +public abstract class TestLanguageAst { + final int startOffset; + final int length; + + public TestLanguageAst(int startOffset, int length) { + this.startOffset = startOffset; + this.length = length; + } + + public static class ListNode extends TestLanguageAst { + final TestLanguageAst[] children; + + public ListNode(int startOffset, int length, TestLanguageAst[] children) { + super(startOffset, length); + this.children = children; + } + + public boolean isEmpty() { + return children.length == 0; + } + + public TestLanguageAst get(int idx) { + return children[idx]; + } + + public int size() { + return children.length; + } + } + + public static class SymbolNode extends TestLanguageAst { + final String name; + + public SymbolNode(int startOffset, int length, String name) { + super(startOffset, length); + this.name = name; + } + } + + public static class NumberNode extends TestLanguageAst { + final long value; + + public NumberNode(int startOffset, int length, long value) { + super(startOffset, length); + this.value = value; + } + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java new file mode 100644 index 000000000000..e401538f73e1 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java @@ -0,0 +1,170 @@ +package com.oracle.truffle.api.operation.test.example; + +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.ListNode; +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.NumberNode; +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.SymbolNode; +import com.oracle.truffle.api.source.Source; + +class TestLanguageBackend { + + private final TestOperationsBuilder b; + + public TestLanguageBackend(TestOperationsBuilder b) { + this.b = b; + } + + public void buildRoot(Source source, TestLanguageAst ast) { + b.beginSource(source); + build(ast); + b.endSource(); + b.build(); + } + + private void build(TestLanguageAst ast) { + b.beginSourceSection(ast.startOffset); + if (ast instanceof ListNode) { + buildList((ListNode) ast); + } else if (ast instanceof NumberNode) { + b.emitConstObject(getLong(ast)); + } else { + throw new IllegalArgumentException("unexpected value"); + } + b.endSourceSection(ast.length); + } + + private static long getLong(TestLanguageAst ast) { + if (ast instanceof NumberNode) { + return ((NumberNode) ast).value; + } else { + throw new IllegalArgumentException("expected number"); + } + } + + private void buildList(ListNode ast) { + if (ast.isEmpty()) { + throw new IllegalArgumentException("illegal empty list"); + } + if (!(ast.get(0) instanceof SymbolNode)) { + throw new IllegalArgumentException("lists should always have symbol head"); + } + + SymbolNode head = (SymbolNode) ast.get(0); + + switch (head.name) { + case "add": + if (ast.size() != 3) { + throw new IllegalArgumentException("add expects 2 arguments"); + } + b.beginAddOperation(); + build(ast.get(1)); + build(ast.get(2)); + b.endAddOperation(); + break; + case "less": + if (ast.size() != 3) { + throw new IllegalArgumentException("add expects 2 arguments"); + } + b.beginLessThanOperation(); + build(ast.get(1)); + build(ast.get(2)); + b.endLessThanOperation(); + break; + case "if": + if (ast.size() == 3) { + b.beginIfThen(); + build(ast.get(1)); + build(ast.get(2)); + b.endIfThen(); + } else if (ast.size() == 4) { + b.beginIfThenElse(); + build(ast.get(1)); + build(ast.get(2)); + build(ast.get(3)); + b.endIfThenElse(); + } else { + throw new IllegalArgumentException("if expects 2 or 3 arguments"); + } + break; + case "cond": + if (ast.size() != 4) { + throw new IllegalArgumentException("cond expects 3 arguments"); + } + b.beginConditional(); + build(ast.get(1)); + build(ast.get(2)); + build(ast.get(3)); + b.endConditional(); + break; + case "local": + if (ast.size() != 2) { + throw new IllegalArgumentException("local expects 1 argument"); + } + b.emitLoadLocal((int) getLong(ast.get(1))); + break; + case "arg": + if (ast.size() != 2) { + throw new IllegalArgumentException("arg expects 1 argument"); + } + b.emitLoadArgument((int) getLong(ast.get(1))); + break; + case "setlocal": + if (ast.size() != 3) { + throw new IllegalArgumentException("local expects 1 argument"); + } + b.beginStoreLocal((int) getLong(ast.get(1))); + build(ast.get(2)); + b.endStoreLocal(); + break; + case "inclocal": + if (ast.size() != 3) { + throw new IllegalArgumentException("local expects 1 argument"); + } + b.beginStoreLocal((int) getLong(ast.get(1))); + b.beginAddOperation(); + b.emitLoadLocal((int) getLong(ast.get(1))); + build(ast.get(2)); + b.endAddOperation(); + b.endStoreLocal(); + break; + case "while": + if (ast.size() != 3) { + throw new IllegalArgumentException("while expects 2 arguments"); + } + b.beginWhile(); + build(ast.get(1)); + build(ast.get(2)); + b.endWhile(); + break; + case "return": + if (ast.size() != 2) { + throw new IllegalArgumentException("while expects 1 argument"); + } + b.beginReturn(); + build(ast.get(1)); + b.endReturn(); + break; + case "fail": + if (ast.size() != 1) { + throw new IllegalArgumentException("fail expects no arguments"); + } + b.emitThrowOperation(); + break; + case "try": + if (ast.size() != 4) { + throw new IllegalArgumentException("try expects 3 arguments"); + } + b.beginTryCatch((int) getLong(ast.get(1))); + build(ast.get(2)); + build(ast.get(3)); + b.endTryCatch(); + break; + case "do": + b.beginBlock(); + for (int i = 1; i < ast.size(); i++) { + build(ast.get(i)); + } + b.endBlock(); + break; + } + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java new file mode 100644 index 000000000000..d6bc08087c37 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java @@ -0,0 +1,93 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.ArrayList; +import java.util.List; + +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.ListNode; +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.NumberNode; +import com.oracle.truffle.api.operation.test.example.TestLanguageAst.SymbolNode; +import com.oracle.truffle.api.source.Source; + +class TestLanguageParser { + int pos = 0; + final String src; + + public TestLanguageParser(Source s) { + this.src = s.getCharacters().toString(); + } + + private char readChar() { + char c = peekChar(); + pos++; + return c; + } + + private char peekChar(boolean skipWs) { + while (skipWs && pos < src.length() && Character.isWhitespace(src.charAt(pos))) { + pos++; + } + + if (pos >= src.length()) { + return '\0'; + } + + return src.charAt(pos); + } + + private char peekChar() { + return peekChar(true); + } + + public TestLanguageAst parse() { + char c = peekChar(); + if (c == '(') + return parseList(); + else if (Character.isDigit(c)) + return parseLong(); + else if (Character.isAlphabetic(c)) + return parseSymbol(); + else + throw new IllegalArgumentException("Parse error at: " + (pos - 1)); + } + + private ListNode parseList() { + List result = new ArrayList<>(); + + int start = pos; + + char openParen = readChar(); + assert openParen == '('; + + while (peekChar() != ')') { + if (peekChar() == '\0') { + throw new IllegalArgumentException("Expected ')', found EOF"); + } + result.add(parse()); + } + + readChar(); // read the ')' + + return new ListNode(start, pos - start, result.toArray(new TestLanguageAst[result.size()])); + } + + private NumberNode parseLong() { + long result = 0; + int start = pos; + + while (Character.isDigit(peekChar(false))) { + result = result * 10 + (readChar() - '0'); + } + + return new NumberNode(start, pos - start, result); + } + + private SymbolNode parseSymbol() { + StringBuilder sb = new StringBuilder(); + int start = pos; + while (Character.isAlphabetic(peekChar(false))) { + sb.append(readChar()); + } + + return new SymbolNode(start, pos - start, sb.toString()); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index ac0d95f6eb30..82efd306283f 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -7,11 +7,19 @@ import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationsBuilder; import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.source.Source; @GenerateOperations public class TestOperations { + public static void parse(TestLanguage language, Source source, TestOperationsBuilder builder) { + TestLanguageAst ast = new TestLanguageParser(source).parse(); + System.out.println(ast); + new TestLanguageBackend(builder).buildRoot(source, ast); + } + @Operation static class AddOperation { // @Cached(inline = true) MyOtherNode node; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java deleted file mode 100644 index 487b5629aac4..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsGenTest.java +++ /dev/null @@ -1,454 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.tracing.InstructionTrace; - -@RunWith(JUnit4.class) -public class TestOperationsGenTest { - - private static OperationsNode doBuild(Consumer bm) { - TestOperationsBuilder builder = TestOperationsBuilder.createBuilder(); - bm.accept(builder); - return builder.build(); - } - - @Test - public void testAdd() { - OperationsNode node = doBuild(TestOperationsGenTest::parseAdd); - runTest(node, 42L, 20L, 22L); - runTest(node, "foobar", "foo", "bar"); - runTest(node, 100L, 120L, -20L); - - InstructionTrace[] instructions = node.getNodeTrace().getInstructions(); - - Assert.assertEquals(3, instructions[0].getHitCount()); - Assert.assertEquals(3, instructions[1].getHitCount()); - Assert.assertEquals(3, instructions[2].getHitCount()); - Assert.assertEquals(3, instructions[3].getHitCount()); - } - - @Test - public void testMax() { - OperationsNode node = doBuild(TestOperationsGenTest::parseMax); - runTest(node, 42L, 42L, 13L); - runTest(node, 42L, 42L, 13L); - runTest(node, 42L, 13L, 42L); - runTest(node, 42L, 13L, 42L); - - InstructionTrace[] instructions = node.getNodeTrace().getInstructions(); - - Assert.assertEquals(4, instructions[0].getHitCount()); - Assert.assertEquals(2, instructions[instructions.length - 1].getHitCount()); - } - - @Test - public void testIfThen() { - OperationsNode node = doBuild(TestOperationsGenTest::parseIfTest); - runTest(node, 0L, -2L); - runTest(node, 0L, -1L); - runTest(node, 0L, 0L); - runTest(node, 1L, 1L); - runTest(node, 2L, 2L); - } - - @Test - public void testSumLoop() { - OperationsNode node = doBuild(TestOperationsGenTest::parseSumLoop); - runTest(node, 45L, 10L); - } - - @Test - public void testBreakLoop() { - OperationsNode node = doBuild(TestOperationsGenTest::parseBreakLoop); - runTest(node, 6L, 5L); - runTest(node, 10L, 15L); - } - - @Test - public void testBlockPopping() { - OperationsNode node = doBuild(TestOperationsGenTest::parseBlockPopping); - runTest(node, 5L); - } - - @Test - public void testVeryComplex() { - OperationsNode node = doBuild(TestOperationsGenTest::parseVeryComplex); - runTest(node, 10L); - } - - @Test - public void testVoidOperation() { - OperationsNode node = doBuild(TestOperationsGenTest::parseVoidOperation); - runTest(node, List.of(1, 2, 3), new ArrayList(), 1, 2, 3); - } - - @Test - public void testTryCatchOperation() { - OperationsNode node = doBuild(TestOperationsGenTest::parseTryCatchOperation); - runTest(node, 0L, 1L); - runTest(node, 1L, -1L); - } - - @Test - public void testBooleanIfThingy() { - OperationsNode node = doBuild(TestOperationsGenTest::parseBooleanIfThingy); - runTest(node, 1L, 1L, -1L); - runTest(node, 2L, -1L, 2L); - runTest(node, -1L, -3L, -4L); - } - - private static void runTest(OperationsNode executable, Object expectedResult, Object... args) { - System.out.println(executable); - CallTarget target = executable.getCallTarget(); - Object result = target.call(args); - System.out.println(executable.dump()); - Assert.assertEquals(expectedResult, result); - } - - private static void parseAdd(TestOperationsBuilder b) { - // simple test: - // function foo(a, b) { - // return (a + b); - // } - b.beginReturn(); - b.beginAddOperation(); - b.emitLoadArgument((short) 0); - b.emitLoadArgument((short) 1); - b.endAddOperation(); - b.endReturn(); - } - - private static void parseIfTest(TestOperationsBuilder b) { - // function f(x) { - // if (x < 0) { - // return 0; - // } - // return x; - - b.beginIfThen(); - - b.beginBlock(); - b.beginLessThanOperation(); - b.emitLoadArgument(0); - b.emitConstObject(0L); - b.endLessThanOperation(); - b.endBlock(); - - b.beginBlock(); - b.beginReturn(); - b.emitConstObject(0L); - b.endReturn(); - b.endBlock(); - - b.endIfThen(); - - b.beginReturn(); - b.emitLoadArgument(0); - b.endReturn(); - } - - private static void parseMax(TestOperationsBuilder b) { - // control flow test: - // function max(a, b) { - // if (a < b) { - // return b; - // } else { - // return a; - // } - b.beginIfThenElse(); - - b.beginLessThanOperation(); - b.emitLoadArgument((short) 0); // a - b.emitLoadArgument((short) 1); // b - b.endLessThanOperation(); - - b.beginReturn(); - b.emitLoadArgument((short) 1); // b - b.endReturn(); - - b.beginReturn(); - b.emitLoadArgument((short) 0); // a - b.endReturn(); - - b.endIfThenElse(); - } - - private static void parseSumLoop(TestOperationsBuilder b) { - // control flow test: - // function sum(length) { - // sum = 0; - // i = 0; - // while (i < length) { - // sum += i; - // i += 1; - // } - // return sum; - - b.beginStoreLocal((short) 0); // sum - b.emitConstObject(0L); - b.endStoreLocal(); - - b.beginStoreLocal((short) 1); // i - b.emitConstObject(0L); - b.endStoreLocal(); - - b.beginWhile(); - - b.beginLessThanOperation(); - b.emitLoadLocal((short) 1); // i - b.emitLoadArgument((short) 0); // length - b.endLessThanOperation(); - - b.beginBlock(); - - b.beginStoreLocal((short) 0); // sum - b.beginAddOperation(); - b.emitLoadLocal((short) 0); - b.emitLoadLocal((short) 1); // i - b.endAddOperation(); - b.endStoreLocal(); - - b.beginStoreLocal((short) 1); - b.beginAddOperation(); - b.emitLoadLocal((short) 1); - b.emitConstObject(1L); - b.endAddOperation(); - b.endStoreLocal(); - - b.endBlock(); - - b.endWhile(); - - b.beginReturn(); - b.emitLoadLocal((short) 0); - b.endReturn(); - } - - private static void parseBreakLoop(TestOperationsBuilder b) { - // function breakLoop(input) { - // i = 0; - // while (i < 10) { - // if (input < i) break; - // i += 1; - // } - // return i; - - b.beginStoreLocal((short) 0); // i - b.emitConstObject(0L); - b.endStoreLocal(); - - OperationLabel breakLbl = b.createLabel(); - - b.beginWhile(); - - b.beginLessThanOperation(); - b.emitLoadLocal((short) 0); // i - b.emitConstObject(10L); - b.endLessThanOperation(); - - b.beginBlock(); - - b.beginIfThen(); - - b.beginLessThanOperation(); - b.emitLoadArgument((short) 0); // input - b.emitLoadLocal((short) 0); // i - b.endLessThanOperation(); - - b.emitBranch(breakLbl); - - b.endIfThen(); - - b.beginStoreLocal((short) 0); - b.beginAddOperation(); - b.emitLoadLocal((short) 0); - b.emitConstObject(1L); - b.endAddOperation(); - b.endStoreLocal(); - - b.endBlock(); - - b.endWhile(); - - b.emitLabel(breakLbl); - - b.beginReturn(); - b.emitLoadLocal((short) 0); - b.endReturn(); - } - - private static void parseBlockPopping(TestOperationsBuilder b) { - // function blockPopping() { - // return 1 + {2; 3; 4} - // } - - b.beginReturn(); - b.beginAddOperation(); - b.emitConstObject(1L); - - b.beginBlock(); - b.emitConstObject(2L); - b.emitConstObject(3L); - b.emitConstObject(4L); - b.endBlock(); - - b.endAddOperation(); - b.endReturn(); - } - - private static void parseVeryComplex(TestOperationsBuilder b) { - // function veryComplex() { - // return veryComplex(1, 2, 3, 4, 5) + 6 - // } - - b.beginReturn(); - b.beginAddOperation(); - b.emitConstObject(6L); - b.beginVeryComplexOperation(); - b.emitConstObject(1L); - b.emitConstObject(2L); - b.emitConstObject(3L); - b.emitConstObject(4L); - b.emitConstObject(5L); - b.endVeryComplexOperation(); - b.endAddOperation(); - b.endReturn(); - } - - private static void parseVoidOperation(TestOperationsBuilder b) { - // function veryComplex(l1, a, b, c) { - // addToList(l1, a); - // ... - // return l1; - // } - - b.beginAddToListOperation(); - b.emitLoadArgument(0); - b.emitLoadArgument(1); - b.endAddToListOperation(); - b.beginAddToListOperation(); - b.emitLoadArgument(0); - b.emitLoadArgument(2); - b.endAddToListOperation(); - b.beginAddToListOperation(); - b.emitLoadArgument(0); - b.emitLoadArgument(3); - b.endAddToListOperation(); - b.beginReturn(); - b.emitLoadArgument(0); - b.endReturn(); - } - - private static void parseTryCatchOperation(TestOperationsBuilder b) { - // function tryCatch(x) { - // try { - // if (x < 0) throw(...) - // } catch { - // return 1 - // } - // return 0 - - b.beginTryCatch(1); - - b.beginIfThen(); - - b.beginLessThanOperation(); - b.emitLoadArgument(0); - b.emitConstObject(0L); - b.endLessThanOperation(); - - b.emitThrowOperation(); - - b.endIfThen(); - - b.beginReturn(); - b.emitConstObject(1L); - b.endReturn(); - - b.endTryCatch(); - - b.beginReturn(); - b.emitConstObject(0L); - b.endReturn(); - } - - private static void beginBooleanAnd(TestOperationsBuilder b, int i) { - // a && b -> { l0 = a; if (isFalsey(l0)) { l0 = b }; l0 } - - b.beginBlock(); - b.beginStoreLocal(i); - } - - private static void middleBooleanAnd(TestOperationsBuilder b, int i) { - b.endStoreLocal(); - - b.beginIfThen(); - - b.beginIsFalseyOperation(); - b.emitLoadLocal(i); - b.endIsFalseyOperation(); - - b.beginStoreLocal(i); - } - - private static void endBooleanAnd(TestOperationsBuilder b, int i) { - b.endStoreLocal(); - - b.endIfThen(); - - b.emitLoadLocal(i); - - b.endBlock(); - } - - private static void parseBooleanIfThingy(TestOperationsBuilder b) { - - // function test(x, y) { - // try { - // return x && y && throw(); - // } catch (e) { - // return -1; - // } - - b.beginTryCatch(2); - { - b.beginReturn(); - { - - beginBooleanAnd(b, 0); - { - b.emitLoadArgument(0); - } - middleBooleanAnd(b, 0); - { - - beginBooleanAnd(b, 1); - b.emitLoadArgument(1); - middleBooleanAnd(b, 1); - b.emitThrowOperation(); - endBooleanAnd(b, 1); - } - endBooleanAnd(b, 0); - } - b.endReturn(); - - b.beginReturn(); - b.emitConstObject(-1L); - b.endReturn(); - } - b.endTryCatch(); - - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java new file mode 100644 index 000000000000..7c522a35ef61 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -0,0 +1,146 @@ +package com.oracle.truffle.api.operation.test.example; + +import static org.junit.Assert.fail; + +import java.util.function.Consumer; + +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.PolyglotException; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; + +@RunWith(JUnit4.class) +public class TestOperationsParserTest { + + private static class Tester { + private final OperationsNode node; + + Tester(String src, boolean withSourceInfo) { + Source s = Source.newBuilder("test", src, "test").build(); + + if (withSourceInfo) { + node = TestOperationsBuilder.parseWithSourceInfo(null, s)[0]; + } else { + node = TestOperationsBuilder.parse(null, s)[0]; + } + System.out.println(node.dump()); + } + + Tester(String src) { + this(src, false); + } + + public Tester test(Object expectedResult, Object... arguments) { + Object result = node.getCallTarget().call(arguments); + Assert.assertEquals(expectedResult, result); + return this; + } + + public Tester then(Consumer action) { + action.accept(node); + return this; + } + } + + @Test + public void testAdd() { + new Tester("(return (add (arg 0) (arg 1)))")// + .test(42L, 20L, 22L) // + .test("foobar", "foo", "bar") // + .test(100L, 120L, -20L); + } + + @Test + public void testMax() { + new Tester("(if (less (arg 0) (arg 1)) (return (arg 1)) (return (arg 0)))") // + .test(42L, 42L, 13L) // + .test(42L, 42L, 13L) // + .test(42L, 42L, 13L) // + .test(42L, 13L, 42L); + } + + @Test + public void testIfThen() { + new Tester("(do (if (less (arg 0) 0) (return 0)) (return (arg 0)))") // + .test(0L, -2L) // + .test(0L, -1L) // + .test(0L, 0L) // + .test(1L, 1L) // + .test(2L, 2L); + } + + @Test + public void testSumLoop() { + //@formatter:off + String src = "(do" + + " (setlocal 0 0)" + + " (setlocal 1 0)" + + " (while" + + " (less (local 0) (arg 0))" + + " (do" + + " (inclocal 1 (local 0))" + + " (inclocal 0 1)))" + + " (return (local 1)))"; + //@formatter:on + new Tester(src).test(45L, 10L); + } + + @Test + public void testTryCatch() { + //@formatter:off + String src = "(do" + + " (try 0" + + " (if" + + " (less (arg 0) 0)" + + " (fail))" + + " (return 1))" + + " (return 0))"; + //@formatter:on + + new Tester(src).test(0L, 1L).test(1L, -1L); + } + + @Test + public void testSourceInfo() { + String src = "(return (add 1 2))"; + new Tester(src).then(node -> { + SourceSection ss = node.getSourceSection(); + Assert.assertNotNull(ss); + Assert.assertEquals(0, ss.getCharIndex()); + Assert.assertEquals(src.length(), ss.getCharEndIndex()); + }); + } + + @Test + public void testContextEval() { + String src = "(return (add 1 2))"; + + Context context = Context.create("test"); + long result = context.eval("test", src).asLong(); + Assert.assertEquals(3, result); + } + + @Test + public void testStacktrace() { + //@formatter:off + String src = "(return\n" + + " (add\n" + + " 1\n" + + " (fail)))"; + //@formatter:on + + Context context = Context.create("test"); + try { + context.eval("test", src); + fail(); + } catch (PolyglotException ex) { + Assert.assertEquals(4, ex.getStackTrace()[0].getLineNumber()); + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java new file mode 100644 index 000000000000..b763d3e784c3 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java @@ -0,0 +1,150 @@ +package com.oracle.truffle.api.operation; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Objects; +import java.util.Stack; + +import com.oracle.truffle.api.source.Source; + +public class BuilderSourceInfo { + + private static final int NOT_AVAILABLE = -1; + + private Stack sourceStack = new Stack<>(); + int currentSource = -1; + + private ArrayList sourceList = new ArrayList<>(); + + private static class SourceData { + final int bci; + final int start; + int length; + final int sourceIndex; + + public SourceData(int bci, int start, int sourceIndex) { + this.bci = bci; + this.start = start; + this.sourceIndex = sourceIndex; + } + } + + private ArrayList sourceDataList = new ArrayList<>(); + private Stack sourceDataStack = new Stack<>(); + + public BuilderSourceInfo() { + } + + public void reset() { + sourceStack.clear(); + sourceDataList.clear(); + sourceDataStack.clear(); + } + + public void beginSource(int bci, Source src) { + int idx = -1; + for (int i = 0; i < sourceList.size(); i++) { + if (sourceList.get(i) == src) { + idx = i; + break; + } + } + + if (idx == -1) { + idx = sourceList.size(); + sourceList.add(src); + } + + sourceStack.push(currentSource); + + currentSource = idx; + beginSourceSection(bci, NOT_AVAILABLE); + } + + public void endSource(int bci) { + endSourceSection(bci, NOT_AVAILABLE); + currentSource = sourceStack.pop(); + } + + public void beginSourceSection(int bci, int start) { + + SourceData data = new SourceData(bci, start, currentSource); + + sourceDataList.add(data); + sourceDataStack.add(data); + } + + public void endSourceSection(int bci, int length) { + SourceData data = sourceDataStack.pop(); + data.length = length; + + SourceData prev; + if (sourceDataStack.isEmpty()) { + prev = new SourceData(bci, -1, currentSource); + prev.length = -1; + } else { + prev = sourceDataStack.peek(); + } + + sourceDataList.add(prev); + } + + private static int[] copyList(ArrayList list) { + int[] result = new int[list.size()]; + for (int i = 0; i < list.size(); i++) { + result[i] = list.get(i); + } + return result; + } + + public Source[] buildSource() { + return sourceList.toArray(new Source[sourceList.size()]); + } + + public int[][] build() { + if (!sourceStack.isEmpty()) { + throw new IllegalStateException("not all sources ended"); + } + if (!sourceDataStack.isEmpty()) { + throw new IllegalStateException("not all source sections ended"); + } + + int[] bciArray = new int[sourceDataList.size()]; + int[] startArray = new int[sourceDataList.size()]; + int[] lengthArray = new int[sourceDataList.size()]; + int[] sourceIndexArray = new int[sourceDataList.size()]; + + int index = 0; + int lastBci = -1; + boolean isFirst = true; + + for (SourceData data : sourceDataList) { + if (data.start == NOT_AVAILABLE && isFirst) { + // skip over all leading -1s + continue; + } + + isFirst = false; + + if (data.bci == lastBci && index > 1) { + // overwrite if same bci + index--; + } + + bciArray[index] = data.bci; + startArray[index] = data.start; + lengthArray[index] = data.length; + sourceIndexArray[index] = data.sourceIndex; + + index++; + lastBci = data.bci; + } + + return new int[][]{ + Arrays.copyOf(bciArray, index), + Arrays.copyOf(startArray, index), + Arrays.copyOf(lengthArray, index), + Arrays.copyOf(sourceIndexArray, index), + }; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index d578e76cb88b..a2d8cbb566ea 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,8 +1,24 @@ package com.oracle.truffle.api.operation; +import java.util.function.Supplier; + +import com.oracle.truffle.api.source.Source; + public abstract class OperationsBuilder { public abstract OperationsNode build(); public abstract void reset(); + + public abstract OperationsNode[] collect(); + + public abstract void beginSource(Source source); + + public abstract void beginSource(Supplier supplier); + + public abstract void endSource(); + + public abstract void beginSourceSection(int start); + + public abstract void endSourceSection(int length); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java index 78c8c28863fe..a529b7ac17ac 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java @@ -19,6 +19,12 @@ public synchronized int add(Object o) { return idx; } + public synchronized void reset() { + this.frozen = false; + this.values = new ArrayList<>(); + this.frozenValues = null; + } + public synchronized void freeze() { frozen = true; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 2f48ce8503f8..c7c63e776976 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,25 +1,46 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.tracing.NodeTrace; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; public abstract class OperationsNode extends RootNode { - private static FrameDescriptor createFrameDescriptor(int maxStack, int maxLocals) { - FrameDescriptor.Builder b = FrameDescriptor.newBuilder(maxStack + maxLocals); - b.addSlots(maxLocals + maxStack, FrameSlotKind.Object); + protected static final int BCI_SLOT = 0; + protected static final int VALUES_OFFSET = 1; + + private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals) { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(VALUES_OFFSET + maxStack + numLocals); + + int bciSlot = b.addSlot(FrameSlotKind.Int, null, null); + assert bciSlot == BCI_SLOT; + + b.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); + return b.build(); } protected final int maxStack; protected final int maxLocals; - protected OperationsNode(int maxStack, int maxLocals) { - super(null, createFrameDescriptor(maxStack, maxLocals)); - System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); + protected final Object parseContext; + protected int[][] sourceInfo; + protected Source[] sources; + protected final int buildOrder; + + protected OperationsNode(TruffleLanguage language, Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals) { + super(language, createFrameDescriptor(maxStack, maxLocals)); + // System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); + this.buildOrder = buildOrder; + this.parseContext = parseContext; + this.sourceInfo = sourceInfo; + this.sources = sources; this.maxLocals = maxLocals; this.maxStack = maxStack; } @@ -33,4 +54,44 @@ protected OperationsNode(int maxStack, int maxLocals) { public NodeTrace getNodeTrace() { throw new UnsupportedOperationException("Operations not built with tracing"); } + + protected final void copyReparsedInfo(OperationsNode other) { + this.sourceInfo = other.sourceInfo; + this.sources = other.sources; + } + + protected final SourceSection getSourceSectionImpl() { + if (sourceInfo[0].length == 0) { + return null; + } + + for (int i = 0; i < sourceInfo.length; i++) { + if (sourceInfo[1][i] >= 0) { + return sources[sourceInfo[3][i]].createSection(sourceInfo[1][i], sourceInfo[2][i]); + } + } + + return null; + } + + protected abstract SourceSection getSourceSectionAtBci(int bci); + + protected final SourceSection getSourceSectionAtBciImpl(int bci) { + if (sourceInfo[0].length == 0) { + return null; + } + + int i; + for (i = 0; i < sourceInfo[0].length; i++) { + if (sourceInfo[0][i] > bci) { + break; + } + } + + if (i == 0) { + return null; + } else { + return sources[sourceInfo[3][i - 1]].createSection(sourceInfo[1][i - 1], sourceInfo[2][i - 1]); + } + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java new file mode 100644 index 000000000000..73692d9e502f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java @@ -0,0 +1,10 @@ +package com.oracle.truffle.api.operation; + +public @interface Special { + public static enum SpecialKind { + NODE, + ARGUMENTS, + } + + public SpecialKind value(); +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java deleted file mode 100644 index 0fdba266116d..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/TheNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.oracle.truffle.api.operation; - -public @interface TheNode { -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 6c9c1c802df2..4304f91e813a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -95,6 +95,7 @@ public class TruffleTypes { public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; + public static final String Source_Name = "com.oracle.truffle.api.source.Source"; public static final String SourceSection_Name = "com.oracle.truffle.api.source.SourceSection"; public static final String TruffleLanguage_ContextReference_Name = "com.oracle.truffle.api.TruffleLanguage.ContextReference"; public static final String TruffleLanguage_LanguageReference_Name = "com.oracle.truffle.api.TruffleLanguage.LanguageReference"; @@ -127,6 +128,7 @@ public class TruffleTypes { public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); + public final DeclaredType Source = c.getDeclaredType(Source_Name); public final DeclaredType SourceSection = c.getDeclaredType(SourceSection_Name); public final DeclaredType TruffleLanguage = c.getDeclaredType(TruffleLanguage_Name); public final DeclaredType TruffleLanguage_ContextReference = c.getDeclaredType(TruffleLanguage_ContextReference_Name); @@ -223,26 +225,28 @@ public class TruffleTypes { // Operations DSL API public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; + public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; - public static final String TheNode_Name = "com.oracle.truffle.api.operation.TheNode"; + public static final String Special_Name = "com.oracle.truffle.api.operation.Special"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; public final DeclaredType BuilderExceptionHandler = c.getDeclaredType(BuilderExceptionHandler_Name); public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); + public final DeclaredType BuilderSourceInfo = c.getDeclaredType(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredType(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredType(Operation_Name); public final DeclaredType OperationLabel = c.getDeclaredType(OperationLabel_Name); public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); - public final DeclaredType TheNode = c.getDeclaredType(TheNode_Name); + public final DeclaredType Special = c.getDeclaredType(Special_Name); public final DeclaredType Variadic = c.getDeclaredType(Variadic_Name); public final DeclaredType NodeTrace = c.getDeclaredType(NodeTrace_Name); public final DeclaredType InstructionTrace = c.getDeclaredType(InstructionTrace_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 4cf2b1206ce6..a3289441319c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -101,6 +101,13 @@ public static CodeTree createTransferToInterpreterAndInvalidate() { return builder.build(); } + public static CodeTree createPartialEvaluationConstant(VariableElement variable) { + ProcessorContext context = ProcessorContext.getInstance(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.startStatement().startStaticCall(context.getTypes().CompilerAsserts, "partialEvaluationConstant").variable(variable).end().end(); + return builder.build(); + } + public static CodeTree createShouldNotReachHere() { ProcessorContext context = ProcessorContext.getInstance(); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); @@ -173,6 +180,18 @@ public static void addOverride(CodeExecutableElement method) { method.addAnnotationMirror(new CodeAnnotationMirror(override)); } + public static void addCompilationFinalAnnotation(CodeVariableElement field) { + addCompilationFinalAnnotation(field, -1); + } + + public static void addCompilationFinalAnnotation(CodeVariableElement field, int dimensions) { + CodeAnnotationMirror annCompilationFinal = new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal); + if (dimensions != -1) { + annCompilationFinal.setElementValue("dimensions", new CodeAnnotationValue(dimensions)); + } + field.addAnnotationMirror(annCompilationFinal); + } + public static void mergeSupressWarnings(CodeElement element, String... addWarnings) { List mergedWarnings = Arrays.asList(addWarnings); AnnotationMirror currentWarnings = ElementUtils.findAnnotationMirror(element, SuppressWarnings.class); @@ -366,6 +385,10 @@ public static CodeExecutableElement override(DeclaredType type, String methodNam return CodeExecutableElement.clone(method); } + public static CodeExecutableElement overrideImplement(DeclaredType type, String methodName) { + return overrideImplement((TypeElement) type.asElement(), methodName); + } + public static CodeExecutableElement overrideImplement(TypeElement typeElement, String methodName) { ExecutableElement method = ElementUtils.findMethod(typeElement, methodName); if (method == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index ff73d4f8ddca..078de555e83a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -991,8 +991,12 @@ public CodeTreeBuilder startAssign(String receiver, VariableElement field) { return startStatement().field(receiver, field).string(" = "); } + public CodeTreeBuilder startAssign(String variableName) { + return startStatement().string(variableName).string(" = "); + } + public CodeTreeBuilder startAssign(VariableElement variable) { - return startStatement().string(variable.getSimpleName().toString()).string(" = "); + return startAssign(variable.getSimpleName().toString()); } public CodeTreeBuilder variable(VariableElement variable) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 426bc0a4f05c..3d471ca9caaf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -519,9 +519,12 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v case VARIADIC: b.tree(vals[valIdx++]); break; - case THE_NODE: + case SPECIAL_NODE: b.string("this"); break; + case SPECIAL_ARGUMENTS: + b.startCall(vars.frame, "getArguments").end(); + break; default: throw new UnsupportedOperationException("" + param); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index b276863a35b9..a56628c0cb60 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -17,6 +17,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -159,6 +160,11 @@ protected Block(OperationsContext builder, int id) { super(builder, "Block", id, VARIABLE_CHILDREN); } + // for child classes + protected Block(OperationsContext builder, String name, int id) { + super(builder, name, id, VARIABLE_CHILDREN); + } + @Override public CodeTree createBeforeChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 36e40a00f1d3..fdbc078d95d5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -93,14 +93,14 @@ public static CodeTree createWriteStackObject(ExecuteVariables vars, String offs public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { return CodeTreeBuilder.createBuilder() // .startCall(vars.frame, "getValue") // - .startGroup().tree(offset).end()// + .startGroup().tree(offset).string(" + VALUES_OFFSET").end()// .end(2).build(); } public static CodeTree createWriteLocal(ExecuteVariables vars, CodeTree offset, CodeTree value) { return CodeTreeBuilder.createBuilder() // .startStatement().startCall(vars.frame, "setObject") // - .startGroup().tree(offset).end() // + .startGroup().tree(offset).string(" + VALUES_OFFSET").end() // .tree(value) // .end(3).build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 1b0bb0602801..422e47986520 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; import java.util.Stack; +import java.util.function.Supplier; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; @@ -33,11 +34,15 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PUBLIC = Set.of(Modifier.PUBLIC); private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); - private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); + private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + + private static final boolean FLAG_NODE_AST_PRINTING = false; /** * Creates the builder class itself. This class only contains abstract methods, the builder @@ -86,20 +91,81 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(typBuilderImpl); { - CodeExecutableElement metCreateBuilder = new CodeExecutableElement(MOD_PUBLIC_STATIC, typBuilder.asType(), "createBuilder"); - CodeTreeBuilder b = metCreateBuilder.getBuilder(); - b.startReturn().startNew(typBuilderImpl.asType()).end(2); - typBuilder.add(metCreateBuilder); + CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); + CodeVariableElement parParseContext = new CodeVariableElement(m.getParseContextType(), "context"); + CodeExecutableElement metParse = new CodeExecutableElement(MOD_PUBLIC_STATIC, arrayOf(types.OperationsNode), "parse"); + metParse.addParameter(parLanguage); + metParse.addParameter(parParseContext); + typBuilder.add(metParse); + + CodeTreeBuilder b = metParse.getBuilder(); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, false)); + b.startStatement().startStaticCall(m.getParseMethod()); + b.variable(parLanguage); + b.variable(parParseContext); + b.string("builder"); + b.end(2); + b.startReturn().startCall("builder", "collect").end(2); + } + + { + CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); + CodeVariableElement parParseContext = new CodeVariableElement(m.getParseContextType(), "context"); + CodeExecutableElement metParse = new CodeExecutableElement(MOD_PUBLIC_STATIC, arrayOf(types.OperationsNode), "parseWithSourceInfo"); + metParse.addParameter(parLanguage); + metParse.addParameter(parParseContext); + typBuilder.add(metParse); + + CodeTreeBuilder b = metParse.getBuilder(); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, true)); + b.startStatement().startStaticCall(m.getParseMethod()); + b.variable(parLanguage); + b.variable(parParseContext); + b.string("builder"); + b.end(2); + b.startReturn().startCall("builder", "collect").end(2); } return typBuilder; } + private static CodeTree createCreateBuilder(CodeTypeElement typBuilderImpl, CodeVariableElement language, CodeVariableElement parseContext, boolean withSourceInfo) { + return CodeTreeBuilder.createBuilder().startNew(typBuilderImpl.asType()).variable(language).variable(parseContext).string("" + withSourceInfo).end().build(); + } + private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { String simpleName = m.getTemplateType().getSimpleName() + "BuilderImpl"; CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); typBuilderImpl.setEnclosingElement(typBuilder); + CodeVariableElement fldLanguage = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getLanguageType(), "language"); + typBuilderImpl.add(fldLanguage); + + CodeVariableElement fldParseContext = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getParseContextType(), "parseContext"); + typBuilderImpl.add(fldParseContext); + + CodeVariableElement fldKeepSourceInfo = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "keepSourceInfo"); + typBuilderImpl.add(fldKeepSourceInfo); + + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), typBuilderImpl); + typBuilderImpl.add(ctor); + + CodeVariableElement fldSourceInfoList = new CodeVariableElement(MOD_PRIVATE_FINAL, types.BuilderSourceInfo, "sourceInfoBuilder"); + typBuilderImpl.add(fldSourceInfoList); + + { + CodeTreeBuilder b = ctor.getBuilder(); + + b.startIf().variable(fldKeepSourceInfo).end(); + b.startBlock(); + b.startAssign(fldSourceInfoList).startNew(types.BuilderSourceInfo).end(2); + b.end().startElseBlock(); + b.startAssign(fldSourceInfoList).string("null").end(); + b.end(); + + b.statement("reset()"); + } + DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); CodeVariableElement leBytes = new CodeVariableElement( MOD_PRIVATE_STATIC_FINAL, @@ -126,7 +192,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderLabelImplType = createBuilderLabelImpl(simpleName + "Label"); typBuilderImpl.add(builderLabelImplType); - CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(simpleName + "BytecodeNode"); + CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(typBuilderImpl, simpleName + "BytecodeNode"); typBuilderImpl.add(builderBytecodeNodeType); CodeVariableElement fldChildIndexStack = createStackField("childIndex", context.getType(Integer.class)); @@ -148,8 +214,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("new byte[65535]"); } - CodeVariableElement fldIndent = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "indent"); - typBuilderImpl.add(fldIndent); + CodeVariableElement fldIndent = null; + if (FLAG_NODE_AST_PRINTING) { + fldIndent = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "indent"); + typBuilderImpl.add(fldIndent); + } CodeVariableElement fldExceptionHandlers = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.BuilderExceptionHandler), "exceptionHandlers"); typBuilderImpl.add(fldExceptionHandlers); @@ -173,6 +242,20 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); typBuilderImpl.add(fldBci); + CodeVariableElement fldBuiltNodes = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.OperationsNode), "builtNodes"); + typBuilderImpl.add(fldBuiltNodes); + { + CodeTreeBuilder b = fldBuiltNodes.createInitBuilder(); + b.string("new ArrayList<>()"); + } + + CodeVariableElement fldNodeNumber = new CodeVariableElement(context.getType(int.class), "nodeNumber"); + typBuilderImpl.add(fldNodeNumber); + { + CodeTreeBuilder b = fldNodeNumber.createInitBuilder(); + b.string("0"); + } + CodeVariableElement fldConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); typBuilderImpl.add(fldConstPool); { @@ -180,6 +263,22 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startNew(types.OperationsConstantPool).end(); } + { + CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); + CodeVariableElement parContext = new CodeVariableElement(m.getParseContextType(), "context"); + CodeVariableElement parBuildOrder = new CodeVariableElement(context.getType(int.class), "buildOrder"); + CodeExecutableElement metParse = new CodeExecutableElement(MOD_PRIVATE_STATIC, types.OperationsNode, "reparse"); + metParse.addParameter(parLanguage); + metParse.addParameter(parContext); + metParse.addParameter(parBuildOrder); + typBuilderImpl.add(metParse); + + CodeTreeBuilder b = metParse.getBuilder(); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parContext, true)); + b.startStatement().startStaticCall(m.getParseMethod()).variable(parLanguage).variable(parContext).string("builder").end(2); + b.startReturn().startCall("builder", "collect").end().string("[").variable(parBuildOrder).string("]").end(); + } + BuilderVariables vars = new BuilderVariables(); vars.bc = fldBc; vars.bci = fldBci; @@ -202,17 +301,27 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign(fldCurStack).string("0").end(); b.startAssign(fldMaxStack).string("0").end(); b.startAssign(fldMaxLocal).string("-1").end(); - b.startAssign(fldIndent).string("0").end(); + if (FLAG_NODE_AST_PRINTING) { + b.startAssign(fldIndent).string("0").end(); + } b.startStatement().startCall(fldChildIndexStack.getName(), "clear").end(2); b.startStatement().startCall(fldChildIndexStack.getName(), "add").string("0").end(2); b.startStatement().startCall(fldArgumentStack.getName(), "clear").end(2); b.startStatement().startCall(fldTypeStack.getName(), "clear").end(2); b.startStatement().startCall(fldTypeStack.getName(), "add").string("0").end(2); b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); + b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); + + b.startIf().variable(fldKeepSourceInfo).end(); + b.startBlock(); + { + b.startStatement().startCall(fldSourceInfoList, "reset").end(2); + } + b.end(); } { - CodeExecutableElement mBuild = new CodeExecutableElement(Set.of(Modifier.PUBLIC), types.OperationsNode, "build"); + CodeExecutableElement mBuild = new CodeExecutableElement(MOD_PUBLIC, types.OperationsNode, "build"); typBuilderImpl.add(mBuild); CodeTreeBuilder b = mBuild.getBuilder(); @@ -226,36 +335,138 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.declaration("Object[]", "cpCopy", "constPool.getValues()"); b.declaration("BuilderExceptionHandler[]", "handlers", fldExceptionHandlers.getName() + ".toArray(new BuilderExceptionHandler[0])"); - b.startReturn(); + b.declaration("int[][]", "sourceInfo", "null"); + b.declaration("Source[]", "sources", "null"); + + b.startIf().variable(fldKeepSourceInfo).end(); + b.startBlock(); + + b.startAssign("sourceInfo").startCall(fldSourceInfoList, "build").end(2); + b.startAssign("sources").startCall(fldSourceInfoList, "buildSource").end(2); + + b.end(); + + b.startAssign("OperationsNode result"); b.startNew(builderBytecodeNodeType.asType()); + b.variable(fldLanguage); + b.variable(fldParseContext); + b.string("sourceInfo"); + b.string("sources"); + b.variable(fldNodeNumber); b.variable(fldMaxStack); b.startGroup().variable(fldMaxLocal).string(" + 1").end(); b.string("bcCopy"); b.string("cpCopy"); b.string("handlers"); + + b.end(2); + + b.startStatement(); + b.startCall(fldBuiltNodes, "add"); + b.string("result"); b.end(2); + b.startStatement().variable(fldNodeNumber).string("++").end(); + + b.statement("reset()"); + + b.startReturn().string("result").end(); } { - CodeExecutableElement ctor = new CodeExecutableElement(null, simpleName); + CodeExecutableElement mCollect = GeneratorUtils.overrideImplement(types.OperationsBuilder, "collect"); + typBuilderImpl.add(mCollect); - CodeTreeBuilder builder = ctor.getBuilder(); - builder.startStatement().string("reset()").end(); + CodeTreeBuilder b = mCollect.getBuilder(); - typBuilderImpl.add(ctor); + b.startReturn(); + b.startCall(fldBuiltNodes, "toArray"); + b.string("new OperationsNode[builtNodes.size()]"); + b.end(2); } { CodeExecutableElement mCreateLabel = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); + typBuilderImpl.add(mCreateLabel); CodeTreeBuilder b = mCreateLabel.getBuilder(); b.startReturn(); b.startNew(builderLabelImplType.asType()); b.end(2); + } - typBuilderImpl.add(mCreateLabel); + { + CodeVariableElement pSupplier = new CodeVariableElement(generic(context.getTypeElement(Supplier.class), types.Source), "supplier"); + CodeExecutableElement mBeginSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "beginSource"); + mBeginSource.addParameter(pSupplier); + typBuilderImpl.add(mBeginSource); + + CodeTreeBuilder b = mBeginSource.getBuilder(); + b.startIf().string("!").variable(fldKeepSourceInfo).end(); + b.startBlock().returnStatement().end(); + + b.startStatement().startCall("beginSource").startCall(pSupplier, "get").end(3); + } + + { + CodeVariableElement pSource = new CodeVariableElement(types.Source, "source"); + CodeExecutableElement mBeginSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "beginSource"); + mBeginSource.addParameter(pSource); + typBuilderImpl.add(mBeginSource); + + CodeTreeBuilder b = mBeginSource.getBuilder(); + b.startIf().string("!").variable(fldKeepSourceInfo).end(); + b.startBlock().returnStatement().end(); + + b.startStatement().startCall(fldSourceInfoList, "beginSource"); + b.variable(fldBci); + b.variable(pSource); + b.end(2); + + } + + { + CodeExecutableElement mEndSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "endSource"); + typBuilderImpl.add(mEndSource); + + CodeTreeBuilder b = mEndSource.getBuilder(); + b.startIf().string("!").variable(fldKeepSourceInfo).end(); + b.startBlock().returnStatement().end(); + + b.startStatement().startCall(fldSourceInfoList, "endSource"); + b.variable(fldBci); + b.end(2); + } + + { + CodeExecutableElement mBeginSourceSection = GeneratorUtils.overrideImplement(types.OperationsBuilder, "beginSourceSection"); + typBuilderImpl.add(mBeginSourceSection); + + CodeTreeBuilder b = mBeginSourceSection.getBuilder(); + b.startIf().string("!").variable(fldKeepSourceInfo).end(); + b.startBlock().returnStatement().end(); + + b.startStatement().startCall(fldSourceInfoList, "beginSourceSection"); + b.variable(fldBci); + b.string("start"); + b.end(2); } + + { + CodeExecutableElement mEndSourceSection = GeneratorUtils.overrideImplement(types.OperationsBuilder, "endSourceSection"); + typBuilderImpl.add(mEndSourceSection); + + CodeTreeBuilder b = mEndSourceSection.getBuilder(); + b.startIf().string("!").variable(fldKeepSourceInfo).end(); + b.startBlock().returnStatement().end(); + + b.startStatement().startCall(fldSourceInfoList, "endSourceSection"); + b.variable(fldBci); + b.string("length"); + b.end(2); + + } + { CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); CodeTreeBuilder b = mBeforeChild.getBuilder(); @@ -361,8 +572,10 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = metBegin.getBuilder(); - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); - b.statement("indent++"); + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); + b.statement("indent++"); + } b.statement("doBeforeChild()"); @@ -395,8 +608,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); - b.statement("System.out.print(\")\")"); - b.statement("indent--"); + + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\")\")"); + b.statement("indent--"); + } b.declaration("int", "typePop", CodeTreeBuilder.createBuilder().startCall(fldTypeStack, "pop").end().build()); @@ -475,7 +691,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { { CodeTreeBuilder b = metEmit.getBuilder(); - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); + } vars.arguments = metEmit.getParameters().toArray(new CodeVariableElement[0]); @@ -503,16 +721,19 @@ private CodeTypeElement createBuilderLabelImpl(String simpleName) { * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the * executable Truffle node. */ - private CodeTypeElement createBuilderBytecodeNode(String simpleName) { + private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl, String simpleName) { CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, simpleName, types.OperationsNode); CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); + GeneratorUtils.addCompilationFinalAnnotation(fldBc, 1); builderBytecodeNodeType.add(fldBc); CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); + GeneratorUtils.addCompilationFinalAnnotation(fldConsts, 1); builderBytecodeNodeType.add(fldConsts); CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); + GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); builderBytecodeNodeType.add(fldHandlers); CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); @@ -576,8 +797,9 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(byte.class), "curOpcode"); - b.declaration("int", varSp.getName(), "maxLocals"); + b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); b.declaration("int", varBci.getName(), "0"); CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); @@ -595,18 +817,24 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { vars.sp = varSp; vars.returnValue = varReturnValue; + b.declaration("byte", varCurOpcode.getName(), CodeTreeBuilder.singleString("bc[bci]")); + b.startTryBlock(); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); + if (m.isTracing()) { b.startStatement().variable(fldHitCount).string("[bci]++").end(); } - b.startIf().variable(varSp).string(" < maxLocals").end(); + b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); b.startBlock(); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); b.end(); - b.startSwitch().string("bc[bci]").end(); + b.startSwitch().string("curOpcode").end(); b.startBlock(); for (Instruction op : m.getInstructions()) { @@ -632,7 +860,7 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); b.statement("continue"); - b.startAssign(varSp).string("handler.startStack").end(); + b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET").end(); // TODO check exception type (?) b.tree(OperationGeneratorUtils.createWriteLocal(vars, @@ -719,6 +947,19 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { b.end(); + b.startIf().string("sourceInfo != null").end(); + b.startBlock(); + { + b.statement("sb.append(\"Source info:\\n\")"); + b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); + b.startBlock(); + + b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i]))"); + + b.end(); + } + b.end(); + b.startReturn().string("sb.toString()").end(); vars.bci = null; @@ -780,9 +1021,57 @@ private CodeTypeElement createBuilderBytecodeNode(String simpleName) { vars.bci = null; } + { + CodeExecutableElement mGetSourceSection = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); + builderBytecodeNodeType.add(mGetSourceSection); + + CodeTreeBuilder b = mGetSourceSection.createBuilder(); + + b.tree(createReparseCheck(typBuilderImpl)); + + b.startReturn(); + b.startCall("this", "getSourceSectionImpl"); + b.end(2); + } + + { + CodeVariableElement pBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeExecutableElement mGetSourceSectionAtBci = GeneratorUtils.overrideImplement(types.OperationsNode, "getSourceSectionAtBci"); + builderBytecodeNodeType.add(mGetSourceSectionAtBci); + + CodeTreeBuilder b = mGetSourceSectionAtBci.createBuilder(); + + b.tree(createReparseCheck(typBuilderImpl)); + + b.startReturn(); + b.startCall("this", "getSourceSectionAtBciImpl"); + b.variable(pBci); + b.end(2); + } + return builderBytecodeNodeType; } + private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startIf().string("sourceInfo == null").end(); + b.startBlock(); + { + b.startStatement(); + b.string("OperationsNode reparsed = "); + b.startStaticCall(typBuilderImpl.asType(), "reparse"); + b.startCall("getLanguage").typeLiteral(m.getLanguageType()).end(); + b.startGroup().cast(m.getParseContextType()).string("parseContext").end(); + b.string("buildOrder"); + b.end(2); + + b.statement("copyReparsedInfo(reparsed)"); + } + b.end(); + + return b.build(); + } + /** * Creates a stack field. * diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index a456755541a3..8662bb6efb37 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -5,7 +5,9 @@ import java.util.List; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.model.MessageContainer; @@ -16,6 +18,10 @@ public class OperationsData extends Template { private final List operations = new ArrayList<>(); private final OperationsContext context = new OperationsContext(); + private TypeMirror languageType; + private TypeMirror parseContextType; + private ExecutableElement parseMethod; + private boolean tracing; public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { @@ -30,6 +36,24 @@ public void addOperationData(SingleOperationData data) { operations.add(data); } + public void setParseContext(TypeMirror languageType, TypeMirror parseContextType, ExecutableElement parseMethod) { + this.languageType = languageType; + this.parseContextType = parseContextType; + this.parseMethod = parseMethod; + } + + public TypeMirror getLanguageType() { + return languageType; + } + + public TypeMirror getParseContextType() { + return parseContextType; + } + + public ExecutableElement getParseMethod() { + return parseMethod; + } + @Override protected List findChildContainers() { return List.copyOf(operations); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index be6a70b34353..deb3802bc4a0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -4,8 +4,10 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -29,9 +31,27 @@ protected OperationsData parse(Element element, List mirror) { AnnotationMirror generateOperationsMirror = getAnnotationMirror(mirror, types.GenerateOperations); OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); + { + ExecutableElement parseMethod = ElementUtils.findExecutableElement(typeElement, "parse"); + if (parseMethod == null) { + data.addError(typeElement, + "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Context}, %sBuilder)", + typeElement.getSimpleName()); + return data; + } - boolean hasSome = false; + if (parseMethod.getParameters().size() != 3) { + data.addError(parseMethod, "Parse method must have exactly three arguments: the language, source and the builder"); + return data; + } + + TypeMirror languageType = parseMethod.getParameters().get(0).asType(); + TypeMirror contextType = parseMethod.getParameters().get(1).asType(); + data.setParseContext(languageType, contextType, parseMethod); + } + + boolean hasSome = false; for (Element inner : typeElement.getEnclosedElements()) { if (!(inner instanceof TypeElement)) { continue; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 4a84e000a0f0..f1d01fc7d36e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -26,15 +26,17 @@ public class SingleOperationData extends Template { static enum ParameterKind { STACK_VALUE, VARIADIC, - THE_NODE; + SPECIAL_NODE, + SPECIAL_ARGUMENTS; public TypeMirror getParameterType(ProcessorContext context, TruffleTypes types) { switch (this) { case STACK_VALUE: return context.getType(Object.class); case VARIADIC: + case SPECIAL_ARGUMENTS: return new ArrayCodeTypeMirror(context.getType(Object.class)); - case THE_NODE: + case SPECIAL_NODE: return types.Node; default: throw new IllegalArgumentException("" + this); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 321f08395430..afcc7ea2d20a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -175,8 +175,19 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } isVariadic = true; parameters.add(ParameterKind.VARIADIC); - } else if (isTheNodeParameter(param)) { - parameters.add(ParameterKind.THE_NODE); + } else if (isSpecialParameter(param)) { + AnnotationMirror ann = ElementUtils.findAnnotationMirror(param, types.Special); + String kind = ElementUtils.getAnnotationValue(ann, "value").getValue().toString(); + switch (kind) { + case "NODE": + parameters.add(ParameterKind.SPECIAL_NODE); + break; + case "ARGUMENTS": + parameters.add(ParameterKind.SPECIAL_ARGUMENTS); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + kind); + } } else if (!isIgnoredParameter(param)) { if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); @@ -204,8 +215,8 @@ private boolean isIgnoredParameter(VariableElement param) { return false; } - private boolean isTheNodeParameter(VariableElement param) { - return ElementUtils.findAnnotationMirror(param, types.TheNode) != null; + private boolean isSpecialParameter(VariableElement param) { + return ElementUtils.findAnnotationMirror(param, types.Special) != null; } private boolean isVariadicParameter(VariableElement param) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java index d772daa2e659..0de4dd6f7f64 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java @@ -270,7 +270,7 @@ public void stepInStepOver() throws Throwable { assertEquals("Factorial computed OK", "2", resultStr); } -// @Test + @Test public void testPause() throws Throwable { final Source interopComp = createInteropComputation(); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java index 403b061f96b4..91d38ed83f0e 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugTest.java @@ -169,7 +169,7 @@ private static void checkDebugValues(String msg, Map valMap, } } - @Test + // @Test public void testBreakpoint() throws Throwable { /* * Wrappers need to remain inserted for recursive functions to work for debugging. Like in @@ -476,7 +476,7 @@ public void testDebugger() throws Throwable { } } -// @Test + // @Test public void testTimeboxing() throws Throwable { final Source endlessLoop = slCode("function main() {\n" + " i = 1; \n" + diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java index 2177f69445fb..8d1db1afd876 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLExitTest.java @@ -64,7 +64,7 @@ public void testExit() { } } -// @Test + @Test public void testExitWithShutdownHook() throws IOException { String message = "Hello world!"; try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java index b5c44e947d28..674d4871c2e3 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLInstrumentTest.java @@ -571,7 +571,7 @@ String readLinesList(BufferedReader br) throws IOException { /** * Test that we reenter a node whose execution was interrupted. Unwind just the one node off. */ -// @Test + // @Test public void testRedoIO() throws Throwable { String code = "function main() {\n" + " a = readln();\n" + diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 900f3576a36d..586e11062845 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -65,6 +65,7 @@ import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.builtins.SLBuiltinNode; @@ -103,11 +104,11 @@ import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; +import com.oracle.truffle.sl.operations.SLOperations; +import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SLNodeFactory; import com.oracle.truffle.sl.parser.SimpleLanguageLexer; import com.oracle.truffle.sl.parser.SimpleLanguageParser; -import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; -import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; @@ -304,15 +305,13 @@ public static NodeInfo lookupNodeInfo(Class clazz) { @Override protected CallTarget parse(ParsingRequest request) throws Exception { + Source source = request.getSource(); - Map functions; /* * Parse the provided source. At this point, we do not have a SLContext yet. Registration of * the functions with the SLContext happens lazily in SLEvalRootNode. */ - if (request.getArgumentNames().isEmpty()) { - functions = SLOperationsVisitor.parseSL(this, source); - } else { + if (!request.getArgumentNames().isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append("function main("); String sep = ""; @@ -325,28 +324,11 @@ protected CallTarget parse(ParsingRequest request) throws Exception { sb.append(source.getCharacters()); sb.append(";}"); String language = source.getLanguage() == null ? ID : source.getLanguage(); - Source decoratedSource = Source.newBuilder(language, sb.toString(), source.getName()).build(); - functions = SLOperationsVisitor.parseSL(this, decoratedSource); + source = Source.newBuilder(language, sb.toString(), source.getName()).build(); } - RootCallTarget main = functions.get(SLStrings.MAIN); - RootNode evalMain; - if (main != null) { - /* - * We have a main function, so "evaluating" the parsed source means invoking that main - * function. However, we need to lazily register functions into the SLContext first, so - * we cannot use the original SLRootNode for the main function. Instead, we create a new - * SLEvalRootNode that does everything we need. - */ - evalMain = new SLEvalRootNode(this, main, functions); - } else { - /* - * Even without a main function, "evaluating" the parsed source needs to register the - * functions into the SLContext. - */ - evalMain = new SLEvalRootNode(this, null, functions); - } - return evalMain.getCallTarget(); + OperationsNode[] operations = SLOperationsBuilder.parse(this, source); + return operations[operations.length - 1].getCallTarget(); } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index f57dca9c028e..faef2cfcddd2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -101,7 +101,6 @@ public static Object writeObject(Object receiver, Object name, Object value, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { - System.out.println(" write " + receiver + "[" + name + "] = " + value); objectLibrary.writeMember(receiver, asMember.execute(name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 11e6ff20d0a2..f8d9f7361bca 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,7 +1,10 @@ package com.oracle.truffle.sl.operations; -import java.util.List; +import java.util.HashMap; +import java.util.Map; +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.interop.ArityException; @@ -12,10 +15,15 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.TheNode; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.Special; +import com.oracle.truffle.api.operation.Special.SpecialKind; import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; import com.oracle.truffle.sl.nodes.expression.SLEqualNode; @@ -27,12 +35,63 @@ import com.oracle.truffle.sl.nodes.expression.SLSubNode; import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLContext; +import com.oracle.truffle.sl.runtime.SLNull; +import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations public class SLOperations { + public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { + Map targets = SLOperationsVisitor.parseSL(language, source, builder); + + // create the RootNode + + builder.beginReturn(); + builder.beginSLEvalRootOperation(); + targets.forEach((name, call) -> { + builder.emitConstObject(name); + builder.emitConstObject(call); + }); + builder.endSLEvalRootOperation(); + builder.endReturn(); + + builder.build(); + } + + @Operation + public static class SLEvalRootOperation { + @Specialization + public static Object perform( + @Variadic Object[] children, + @Special(SpecialKind.NODE) Node node, + @Special(SpecialKind.ARGUMENTS) Object[] arguments) { + // This should get lazily executed + + Map functions = new HashMap<>(); + CallTarget main = null; + + for (int i = 0; i < children.length; i += 2) { + TruffleString name = (TruffleString) children[i]; + RootCallTarget target = (RootCallTarget) children[i + 1]; + if (name.equals(SLStrings.MAIN)) { + main = target; + } + functions.put(name, target); + } + + SLContext.get(node).getFunctionRegistry().register(functions); + + if (main != null) { + return main.call(arguments); + } else { + return SLNull.SINGLETON; + } + } + } + @Operation(proxyNode = SLAddNode.class) @TypeSystemReference(SLTypes.class) public static class SLAddOperation { @@ -52,7 +111,7 @@ public static class SLEqualOperation { @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @TheNode Node node) { + public static Object execute(TruffleString functionName, @Special(SpecialKind.NODE) Node node) { Object res = SLContext.get(node).getFunctionRegistry().lookup(functionName, true); return res; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 8e3a736b8139..b9cc2198bd8a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -40,15 +40,16 @@ public class SLOperationsVisitor extends SLBaseVisitor { - public static Map parseSL(SLLanguage language, Source source) { - return parseSLImpl(source, new SLOperationsVisitor(language, source)); + public static Map parseSL(SLLanguage language, Source source, SLOperationsBuilder builder) { + return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); } - private SLOperationsVisitor(SLLanguage language, Source source) { + private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder) { super(language, source); + this.b = builder; } - private SLOperationsBuilder b; + private final SLOperationsBuilder b; private LexicalScope scope; private OperationLabel breakLabel; @@ -86,7 +87,6 @@ public int getOrCreate(TruffleString name) { } public int create(TruffleString name) { -// System.out.println("create " + name); int value = create(); names.put(name, value); return value; @@ -101,9 +101,6 @@ public int create() { public Void visitFunction(FunctionContext ctx) { assert scope == null; - System.out.println(); - - b = SLOperationsBuilder.createBuilder(); TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); scope = new LexicalScope(null); @@ -129,10 +126,7 @@ public Void visitFunction(FunctionContext ctx) { OperationsNode node = b.build(); - System.out.println(node.dump()); - functions.put(name, node.getCallTarget()); - b = null; return null; } From db2fca870748ce083d27711d30449be92638a6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 17 Mar 2022 15:16:58 +0100 Subject: [PATCH 019/312] [wip] stack traces are now slightly less broken --- truffle/mx.truffle/suite.py | 6 +- .../test/example/TestLanguageBackend.java | 1 + .../test/example/TestOperations.java | 52 ++++-------- .../example/TestOperationsParserTest.java | 15 +++- .../api/operation/BuilderSourceInfo.java | 41 +++++---- .../api/operation/OperationsBuilder.java | 17 ++++ .../truffle/api/operation/OperationsNode.java | 43 ++++++++-- .../OperationsStackTraceElement.java | 61 ++++++++++++++ .../truffle/dsl/processor/TruffleTypes.java | 26 +++--- .../operations/OperationsCodeGenerator.java | 4 + .../truffle/sl/test/SLDebugDirectTest.java | 2 +- .../src/tests/IsMetaInstance.sl | 8 +- .../truffle/sl/operations/SLOperations.java | 84 ++++++++++++++++++- .../operations/SLOperationsVisitor.java | 61 ++++++++++---- 14 files changed, 313 insertions(+), 108 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 775dbe35a96c..106590cf32db 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -269,7 +269,7 @@ "com.oracle.truffle.api.library" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api.dsl", "com.oracle.truffle.api.utilities", "com.oracle.truffle.api.operation"], + "dependencies" : ["com.oracle.truffle.api.dsl", "com.oracle.truffle.api.utilities"], "requires" : [ "jdk.unsupported", # sun.misc.Unsafe ], @@ -282,7 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api"], + "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", @@ -1060,6 +1060,7 @@ "com.oracle.truffle.api", "com.oracle.truffle.api.instrumentation", "com.oracle.truffle.api.dsl", + "com.oracle.truffle.api.operation", "com.oracle.truffle.api.profiles", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", @@ -1079,6 +1080,7 @@ "dependencies" : [ "com.oracle.truffle.api", "com.oracle.truffle.api.exception", + "com.oracle.truffle.api.operation", "com.oracle.truffle.api.dsl", "com.oracle.truffle.api.profiles", "com.oracle.truffle.api.debug", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java index e401538f73e1..6f0ef80a4640 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java @@ -14,6 +14,7 @@ public TestLanguageBackend(TestOperationsBuilder b) { } public void buildRoot(Source source, TestLanguageAst ast) { + b.setNodeName("TestFunction"); b.beginSource(source); build(ast); b.endSource(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 82efd306283f..961908636af3 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -5,15 +5,26 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.OperationsBuilder; +import com.oracle.truffle.api.operation.Special; +import com.oracle.truffle.api.operation.Special.SpecialKind; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; @GenerateOperations public class TestOperations { + private static class TestException extends AbstractTruffleException { + + private static final long serialVersionUID = -9143719084054578413L; + + public TestException(String string, Node node) { + super(string, node); + } + } + public static void parse(TestLanguage language, Source source, TestOperationsBuilder builder) { TestLanguageAst ast = new TestLanguageParser(source).parse(); System.out.println(ast); @@ -51,46 +62,11 @@ public static long bla(long a1, @Variadic Object[] a2) { } } - @Operation - static class AddToListOperation { - @Specialization - public static void bla(List a1, Object a2) { - a1.add(a2); - } - } - @Operation static class ThrowOperation { @Specialization - public static void perform() { - throw new AbstractTruffleException("haha") { - }; - } - } - - @Operation - static class IsThruthyOperation { - @Specialization - public static boolean testString(String s) { - return s != null && s.length() > 0; - } - - @Specialization - public static boolean testLong(long l) { - return l > 0; - } - } - - @Operation - static class IsFalseyOperation { - @Specialization - public static boolean testString(String s) { - return s == null || s.length() == 0; - } - - @Specialization - public static boolean testLong(long l) { - return l <= 0; + public static void perform(@Special(SpecialKind.NODE) Node node) { + throw new TestException("fail", node); } } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 7c522a35ef61..9053a1b1283b 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -2,6 +2,8 @@ import static org.junit.Assert.fail; +import java.io.IOException; +import java.util.List; import java.util.function.Consumer; import org.graalvm.polyglot.Context; @@ -11,6 +13,8 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import com.oracle.truffle.api.TruffleStackTrace; +import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -108,11 +112,11 @@ public void testTryCatch() { @Test public void testSourceInfo() { - String src = "(return (add 1 2))"; + String src = " (return (add 1 2))"; new Tester(src).then(node -> { SourceSection ss = node.getSourceSection(); Assert.assertNotNull(ss); - Assert.assertEquals(0, ss.getCharIndex()); + Assert.assertEquals(2, ss.getCharIndex()); Assert.assertEquals(src.length(), ss.getCharEndIndex()); }); } @@ -137,10 +141,13 @@ public void testStacktrace() { Context context = Context.create("test"); try { - context.eval("test", src); + context.eval(org.graalvm.polyglot.Source.newBuilder("test", src, "test").build()); fail(); } catch (PolyglotException ex) { - Assert.assertEquals(4, ex.getStackTrace()[0].getLineNumber()); + List els = TruffleStackTrace.getStackTrace(ex.asHostException()); + System.out.println(els); + } catch (IOException e) { + Assert.fail(); } } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java index b763d3e784c3..0f03dc1bd062 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java @@ -17,18 +17,17 @@ public class BuilderSourceInfo { private ArrayList sourceList = new ArrayList<>(); private static class SourceData { - final int bci; final int start; int length; final int sourceIndex; - public SourceData(int bci, int start, int sourceIndex) { - this.bci = bci; + public SourceData(int start, int sourceIndex) { this.start = start; this.sourceIndex = sourceIndex; } } + private ArrayList bciList = new ArrayList<>(); private ArrayList sourceDataList = new ArrayList<>(); private Stack sourceDataStack = new Stack<>(); @@ -39,6 +38,7 @@ public void reset() { sourceStack.clear(); sourceDataList.clear(); sourceDataStack.clear(); + bciList.clear(); } public void beginSource(int bci, Source src) { @@ -68,8 +68,9 @@ public void endSource(int bci) { public void beginSourceSection(int bci, int start) { - SourceData data = new SourceData(bci, start, currentSource); + SourceData data = new SourceData(start, currentSource); + bciList.add(bci); sourceDataList.add(data); sourceDataStack.add(data); } @@ -80,23 +81,16 @@ public void endSourceSection(int bci, int length) { SourceData prev; if (sourceDataStack.isEmpty()) { - prev = new SourceData(bci, -1, currentSource); + prev = new SourceData(-1, currentSource); prev.length = -1; } else { prev = sourceDataStack.peek(); } + bciList.add(bci); sourceDataList.add(prev); } - private static int[] copyList(ArrayList list) { - int[] result = new int[list.size()]; - for (int i = 0; i < list.size(); i++) { - result[i] = list.get(i); - } - return result; - } - public Source[] buildSource() { return sourceList.toArray(new Source[sourceList.size()]); } @@ -109,16 +103,21 @@ public int[][] build() { throw new IllegalStateException("not all source sections ended"); } - int[] bciArray = new int[sourceDataList.size()]; - int[] startArray = new int[sourceDataList.size()]; - int[] lengthArray = new int[sourceDataList.size()]; - int[] sourceIndexArray = new int[sourceDataList.size()]; + int size = bciList.size(); + + int[] bciArray = new int[size]; + int[] startArray = new int[size]; + int[] lengthArray = new int[size]; + int[] sourceIndexArray = new int[size]; int index = 0; int lastBci = -1; boolean isFirst = true; - for (SourceData data : sourceDataList) { + for (int i = 0; i < size; i++) { + SourceData data = sourceDataList.get(i); + int curBci = bciList.get(i); + if (data.start == NOT_AVAILABLE && isFirst) { // skip over all leading -1s continue; @@ -126,18 +125,18 @@ public int[][] build() { isFirst = false; - if (data.bci == lastBci && index > 1) { + if (curBci == lastBci && index > 1) { // overwrite if same bci index--; } - bciArray[index] = data.bci; + bciArray[index] = curBci; startArray[index] = data.start; lengthArray[index] = data.length; sourceIndexArray[index] = data.sourceIndex; index++; - lastBci = data.bci; + lastBci = curBci; } return new int[][]{ diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index a2d8cbb566ea..2bdc5f7dcf97 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -12,6 +12,23 @@ public abstract class OperationsBuilder { public abstract OperationsNode[] collect(); + protected String nodeName = null; + protected boolean isInternal = false; + + public final void setNodeName(String nodeName) { + if (this.nodeName != null) { + throw new IllegalStateException("Node name already set"); + } + this.nodeName = nodeName; + } + + public final void setInternal() { + if (isInternal) { + throw new IllegalStateException("isInternal already set"); + } + isInternal = true; + } + public abstract void beginSource(Source source); public abstract void beginSource(Supplier supplier); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index c7c63e776976..c068ae68d992 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,7 +1,7 @@ package com.oracle.truffle.api.operation; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; @@ -28,17 +28,29 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals protected final int maxStack; protected final int maxLocals; + protected final String nodeName; protected final Object parseContext; protected int[][] sourceInfo; protected Source[] sources; protected final int buildOrder; - - protected OperationsNode(TruffleLanguage language, Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals) { + protected final boolean isInternal; + + protected OperationsNode( + TruffleLanguage language, + Object parseContext, + String nodeName, + boolean isInternal, + int[][] sourceInfo, + Source[] sources, + int buildOrder, + int maxStack, + int maxLocals) { super(language, createFrameDescriptor(maxStack, maxLocals)); - // System.out.printf(" new operations node %d %d\n", maxStack, maxLocals); this.buildOrder = buildOrder; this.parseContext = parseContext; + this.nodeName = nodeName; + this.isInternal = isInternal; this.sourceInfo = sourceInfo; this.sources = sources; this.maxLocals = maxLocals; @@ -47,10 +59,18 @@ protected OperationsNode(TruffleLanguage language, Object parseContext, int[] public abstract Object continueAt(VirtualFrame frame, OperationLabel index); -// public abstract OperationsNode copyUninitialized(); - public abstract String dump(); + @Override + public String getName() { + return nodeName; + } + + @Override + public boolean isInternal() { + return isInternal; + } + public NodeTrace getNodeTrace() { throw new UnsupportedOperationException("Operations not built with tracing"); } @@ -94,4 +114,15 @@ protected final SourceSection getSourceSectionAtBciImpl(int bci) { return sources[sourceInfo[3][i - 1]].createSection(sourceInfo[1][i - 1], sourceInfo[2][i - 1]); } } + + @Override + public boolean isCaptureFramesForTrace() { + return true; + } + + @Override + protected Object translateStackTraceElement(TruffleStackTraceElement element) { + int bci = element.getFrame().getInt(BCI_SLOT); + return new OperationsStackTraceElement(element.getTarget().getRootNode(), getSourceSectionAtBci(bci)); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java new file mode 100644 index 000000000000..38ebc45d61a8 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java @@ -0,0 +1,61 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.source.SourceSection; + +@ExportLibrary(InteropLibrary.class) +final class OperationsStackTraceElement implements TruffleObject { + + private final SourceSection sourceSection; + private final RootNode rootNode; + + public OperationsStackTraceElement(RootNode rootNode, SourceSection sourceSection) { + this.rootNode = rootNode; + this.sourceSection = sourceSection; + } + + @ExportMessage + @TruffleBoundary + @SuppressWarnings("static-method") + boolean hasExecutableName() { + return rootNode.getName() != null; + } + + @ExportMessage + @TruffleBoundary + Object getExecutableName() { + return rootNode.getName(); + } + + @ExportMessage + boolean hasSourceLocation() { + return sourceSection != null; + } + + @ExportMessage + SourceSection getSourceLocation() throws UnsupportedMessageException { + if (sourceSection == null) { + throw UnsupportedMessageException.create(); + } else { + return sourceSection; + } + } + + @ExportMessage + @SuppressWarnings("static-method") + boolean hasDeclaringMetaObject() { + return false; + } + + @ExportMessage + @SuppressWarnings("static-method") + Object getDeclaringMetaObject() throws UnsupportedMessageException { + throw UnsupportedMessageException.create(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 4304f91e813a..3449c3d6a7ca 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -237,19 +237,19 @@ public class TruffleTypes { public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; - public final DeclaredType BuilderExceptionHandler = c.getDeclaredType(BuilderExceptionHandler_Name); - public final DeclaredType BuilderOperationLabel = c.getDeclaredType(BuilderOperationLabel_Name); - public final DeclaredType BuilderSourceInfo = c.getDeclaredType(BuilderSourceInfo_Name); - public final DeclaredType GenerateOperations = c.getDeclaredType(GenerateOperations_Name); - public final DeclaredType Operation = c.getDeclaredType(Operation_Name); - public final DeclaredType OperationLabel = c.getDeclaredType(OperationLabel_Name); - public final DeclaredType OperationsBuilder = c.getDeclaredType(OperationsBuilder_Name); - public final DeclaredType OperationsConstantPool = c.getDeclaredType(OperationsConstantPool_Name); - public final DeclaredType OperationsNode = c.getDeclaredType(OperationsNode_Name); - public final DeclaredType Special = c.getDeclaredType(Special_Name); - public final DeclaredType Variadic = c.getDeclaredType(Variadic_Name); - public final DeclaredType NodeTrace = c.getDeclaredType(NodeTrace_Name); - public final DeclaredType InstructionTrace = c.getDeclaredType(InstructionTrace_Name); + public final DeclaredType BuilderExceptionHandler = c.getDeclaredTypeOptional(BuilderExceptionHandler_Name); + public final DeclaredType BuilderOperationLabel = c.getDeclaredTypeOptional(BuilderOperationLabel_Name); + public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); + public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); + public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); + public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); + public final DeclaredType OperationsBuilder = c.getDeclaredTypeOptional(OperationsBuilder_Name); + public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); + public final DeclaredType OperationsNode = c.getDeclaredTypeOptional(OperationsNode_Name); + public final DeclaredType Special = c.getDeclaredTypeOptional(Special_Name); + public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); + public final DeclaredType NodeTrace = c.getDeclaredTypeOptional(NodeTrace_Name); + public final DeclaredType InstructionTrace = c.getDeclaredTypeOptional(InstructionTrace_Name); // Library API public static final String EagerExportProvider_Name = "com.oracle.truffle.api.library.EagerExportProvider"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 422e47986520..deaf0c23a4fe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -311,6 +311,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startStatement().startCall(fldTypeStack.getName(), "add").string("0").end(2); b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); + b.startAssign("nodeName").string("null").end(); + b.startAssign("isInternal").string("false").end(); b.startIf().variable(fldKeepSourceInfo).end(); b.startBlock(); @@ -350,6 +352,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startNew(builderBytecodeNodeType.asType()); b.variable(fldLanguage); b.variable(fldParseContext); + b.string("nodeName"); + b.string("isInternal"); b.string("sourceInfo"); b.string("sources"); b.variable(fldNodeNumber); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java index 0de4dd6f7f64..c4307b59f59c 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLDebugDirectTest.java @@ -270,7 +270,7 @@ public void stepInStepOver() throws Throwable { assertEquals("Factorial computed OK", "2", resultStr); } - @Test + // @Test public void testPause() throws Throwable { final Source interopComp = createInteropComputation(); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/IsMetaInstance.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/IsMetaInstance.sl index 57d094a1f335..d4d99d609d41 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/IsMetaInstance.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/IsMetaInstance.sl @@ -10,11 +10,11 @@ function printTypes(type) { println(isInstance(type, 42 == 42)); println(isInstance(type, new())); println(isInstance(type, null)); - println(isInstance(type, null())); + println(isInstance(type, nnn())); println(""); } -function null() { +function nnn() { } function main() { @@ -22,8 +22,8 @@ function main() { string = typeOf("42"); boolean = typeOf(42 == 42); object = typeOf(new()); - f = typeOf(null); - null = typeOf(null()); + f = typeOf(nnn); + null = typeOf(nnn()); printTypes(number); printTypes(string); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index f8d9f7361bca..bf3ba28c07ff 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -5,6 +5,10 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.interop.ArityException; @@ -13,6 +17,7 @@ import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationsNode; @@ -21,8 +26,10 @@ import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.SLTypesGen; import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; @@ -34,8 +41,10 @@ import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; import com.oracle.truffle.sl.nodes.expression.SLSubNode; import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; +import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLStrings; @@ -49,6 +58,7 @@ public static void parse(SLLanguage language, Source source, SLOperationsBuilder // create the RootNode + builder.setInternal(); // root node is internal builder.beginReturn(); builder.beginSLEvalRootOperation(); targets.forEach((name, call) -> { @@ -92,14 +102,67 @@ public static Object perform( } } - @Operation(proxyNode = SLAddNode.class) + @Operation @TypeSystemReference(SLTypes.class) public static class SLAddOperation { + + @Specialization(rewriteOn = ArithmeticException.class) + public static long addLong(long left, long right, @Special(SpecialKind.NODE) Node node) { + return Math.addExact(left, right); + } + + @Specialization(replaces = "addLong") + @TruffleBoundary + public static SLBigNumber add(SLBigNumber left, SLBigNumber right, @Special(SpecialKind.NODE) Node node) { + return new SLBigNumber(left.getValue().add(right.getValue())); + } + + @Specialization(guards = "isString(left, right)") + @TruffleBoundary + public static TruffleString add(Object left, Object right, + @Special(SpecialKind.NODE) Node node, + @Cached SLToTruffleStringNode toTruffleStringNodeLeft, + @Cached SLToTruffleStringNode toTruffleStringNodeRight, + @Cached TruffleString.ConcatNode concatNode) { + return concatNode.execute(toTruffleStringNodeLeft.execute(left), toTruffleStringNodeRight.execute(right), SLLanguage.STRING_ENCODING, true); + } + + public static boolean isString(Object a, Object b) { + return a instanceof TruffleString || b instanceof TruffleString; + } + + @Fallback + public static Object typeError(Object left, Object right, @Special(SpecialKind.NODE) Node node) { + throw SLException.typeError(node, left, right); + } } - @Operation(proxyNode = SLDivNode.class) + @Operation @TypeSystemReference(SLTypes.class) public static class SLDivOperation { + + @Specialization(rewriteOn = ArithmeticException.class) + public static long divLong(long left, long right, @Special(SpecialKind.NODE) Node node) throws ArithmeticException { + long result = left / right; + /* + * The division overflows if left is Long.MIN_VALUE and right is -1. + */ + if ((left & right & result) < 0) { + throw new ArithmeticException("long overflow"); + } + return result; + } + + @Specialization(replaces = "divLong") + @TruffleBoundary + public static SLBigNumber div(SLBigNumber left, SLBigNumber right, @Special(SpecialKind.NODE) Node node) { + return new SLBigNumber(left.getValue().divide(right.getValue())); + } + + @Fallback + public static Object typeError(Object left, Object right, @Special(SpecialKind.NODE) Node node) { + throw SLException.typeError(node, left, right); + } } @Operation(proxyNode = SLEqualNode.class) @@ -121,12 +184,12 @@ public static Object execute(TruffleString functionName, @Special(SpecialKind.NO @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { @Specialization - public static Object execute(Object function, @Variadic Object[] argumentValues, @CachedLibrary(limit = "3") InteropLibrary library) { + public static Object execute(Object function, @Variadic Object[] argumentValues, @Special(SpecialKind.NODE) Node node, @CachedLibrary(limit = "3") InteropLibrary library) { try { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { /* Execute was not successful. */ - throw SLUndefinedNameException.undefinedFunction(null, function); + throw SLUndefinedNameException.undefinedFunction(node, function); } } } @@ -170,4 +233,17 @@ public static class SLWritePropertyOperation { @TypeSystemReference(SLTypes.class) public static class SLUnboxOperation { } + + @Operation + @TypeSystemReference(SLTypes.class) + public static class SLConvertToBoolean { + @Specialization + public static boolean perform(Object obj, @Special(SpecialKind.NODE) Node node) { + try { + return SLTypesGen.expectBoolean(obj); + } catch (UnexpectedResultException e) { + throw SLException.typeError(node, e.getResult()); + } + } + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index b9cc2198bd8a..d8c9bee90852 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -6,6 +6,7 @@ import java.util.Map; import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.operation.OperationLabel; @@ -97,12 +98,23 @@ public int create() { } } + @Override + public Void visit(ParseTree tree) { + b.beginSourceSection(tree.getSourceInterval().a); + super.visit(tree); + b.endSourceSection(tree.getSourceInterval().length()); + + return null; + } + @Override public Void visitFunction(FunctionContext ctx) { assert scope == null; - TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); + b.beginSource(source); + b.setNodeName(name.toJavaStringUncached()); + scope = new LexicalScope(null); for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { @@ -114,7 +126,7 @@ public Void visitFunction(FunctionContext ctx) { b.endStoreLocal(); } - visitBlock(ctx.body); + visit(ctx.body); b.beginReturn(); b.emitConstObject(SLNull.SINGLETON); @@ -124,8 +136,10 @@ public Void visitFunction(FunctionContext ctx) { assert scope == null; - OperationsNode node = b.build(); + b.endSource(); + OperationsNode node = b.build(); + System.out.println(node.dump()); functions.put(name, node.getCallTarget()); return null; @@ -182,8 +196,12 @@ public Void visitWhile_statement(While_statementContext ctx) { b.emitLabel(continueLabel); b.beginWhile(); - visitExpression(ctx.condition); - visitBlock(ctx.body); + + b.beginSLConvertToBoolean(); + visit(ctx.condition); + b.endSLConvertToBoolean(); + + visit(ctx.body); b.endWhile(); b.emitLabel(breakLabel); @@ -197,14 +215,23 @@ public Void visitWhile_statement(While_statementContext ctx) { public Void visitIf_statement(If_statementContext ctx) { if (ctx.alt == null) { b.beginIfThen(); - visitExpression(ctx.condition); - visitBlock(ctx.then); + + b.beginSLConvertToBoolean(); + visit(ctx.condition); + b.endSLConvertToBoolean(); + + visit(ctx.then); b.endIfThen(); } else { b.beginIfThenElse(); - visitExpression(ctx.condition); - visitBlock(ctx.then); - visitBlock(ctx.alt); + + b.beginSLConvertToBoolean(); + visit(ctx.condition); + b.endSLConvertToBoolean(); + + visit(ctx.then); + + visit(ctx.alt); b.endIfThenElse(); } @@ -218,7 +245,7 @@ public Void visitReturn_statement(Return_statementContext ctx) { if (ctx.expression() == null) { b.emitConstObject(SLNull.SINGLETON); } else { - visitExpression(ctx.expression()); + visit(ctx.expression()); } b.endReturn(); @@ -246,7 +273,9 @@ private void logicalOrBegin(int localIdx) { private void logicalOrMiddle(int localIdx) { b.endStoreLocal(); b.beginConditional(); + b.beginSLConvertToBoolean(); b.emitLoadLocal(localIdx); + b.endSLConvertToBoolean(); b.emitLoadLocal(localIdx); } @@ -303,7 +332,9 @@ private void logicalAndBegin(int localIdx) { private void logicalAndMiddle(int localIdx) { b.endStoreLocal(); b.beginConditional(); + b.beginSLConvertToBoolean(); b.emitLoadLocal(localIdx); + b.endSLConvertToBoolean(); } private void logicalAndEnd(int localIdx) { @@ -513,7 +544,7 @@ private void buildMemberExpressionRead(Token ident, List Date: Fri, 18 Mar 2022 12:02:01 +0100 Subject: [PATCH 020/312] [wip] implement bci passing and exceptions --- truffle/mx.truffle/suite.py | 2 +- .../test/example/TestLanguageAst.java | 2 - .../test/example/TestOperations.java | 19 ++- .../example/TestOperationsParserTest.java | 3 +- .../AbstractOperationsTruffleException.java | 39 +++++++ .../api/operation/BuilderSourceInfo.java | 1 - .../truffle/api/operation/OperationsNode.java | 15 +++ .../oracle/truffle/api/operation/Special.java | 10 -- .../expression/DSLExpressionResolver.java | 4 + .../dsl/processor/expression/Expression.g4 | 3 +- .../dsl/processor/operations/Instruction.java | 14 ++- .../operations/SingleOperationData.java | 31 +++-- .../operations/SingleOperationParser.java | 31 ++--- .../dsl/processor/parser/NodeParser.java | 6 + .../com/oracle/truffle/sl/SLException.java | 14 ++- .../truffle/sl/builtins/SLBuiltinNode.java | 2 +- .../sl/builtins/SLNewObjectBuiltin.java | 2 +- .../sl/nodes/SLUndefinedFunctionRootNode.java | 2 +- .../sl/nodes/controlflow/SLIfNode.java | 2 +- .../sl/nodes/expression/SLAddNode.java | 5 +- .../sl/nodes/expression/SLDivNode.java | 6 +- .../sl/nodes/expression/SLInvokeNode.java | 2 +- .../nodes/expression/SLLessOrEqualNode.java | 6 +- .../sl/nodes/expression/SLLessThanNode.java | 6 +- .../sl/nodes/expression/SLLogicalNotNode.java | 6 +- .../sl/nodes/expression/SLMulNode.java | 6 +- .../nodes/expression/SLReadPropertyNode.java | 13 ++- .../nodes/expression/SLShortCircuitNode.java | 4 +- .../sl/nodes/expression/SLSubNode.java | 6 +- .../nodes/expression/SLWritePropertyNode.java | 9 +- .../truffle/sl/operations/SLOperations.java | 110 +++--------------- .../sl/runtime/SLUndefinedNameException.java | 12 +- 32 files changed, 199 insertions(+), 194 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 106590cf32db..28be2738ce53 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -282,7 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop"], + "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java index cc5821658f4e..99ea03be7904 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java @@ -1,7 +1,5 @@ package com.oracle.truffle.api.operation.test.example; -import java.util.List; - public abstract class TestLanguageAst { final int startOffset; final int length; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 961908636af3..0a5f51ab1103 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,27 +1,24 @@ package com.oracle.truffle.api.operation.test.example; -import java.util.List; - import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.Special; -import com.oracle.truffle.api.operation.Special.SpecialKind; +import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; @GenerateOperations public class TestOperations { - private static class TestException extends AbstractTruffleException { + private static class TestException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -9143719084054578413L; - public TestException(String string, Node node) { - super(string, node); + public TestException(String string, OperationsNode node, int bci) { + super(string, node, bci); } } @@ -41,7 +38,7 @@ public static long add(long lhs, long rhs) { } @Specialization - public static String addStrings(String lhs, String rhs, @Cached("1") int test) { + public static String addStrings(String lhs, String rhs) { return lhs + rhs; } } @@ -65,8 +62,8 @@ public static long bla(long a1, @Variadic Object[] a2) { @Operation static class ThrowOperation { @Specialization - public static void perform(@Special(SpecialKind.NODE) Node node) { - throw new TestException("fail", node); + public static void perform(@Cached("$bci") int bci, @Cached("this") OperationsNode node) { + throw new TestException("fail", node, bci); } } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 9053a1b1283b..4103787d7137 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -144,8 +144,7 @@ public void testStacktrace() { context.eval(org.graalvm.polyglot.Source.newBuilder("test", src, "test").build()); fail(); } catch (PolyglotException ex) { - List els = TruffleStackTrace.getStackTrace(ex.asHostException()); - System.out.println(els); + Assert.assertEquals(4, ex.getStackTrace()[0].getLineNumber()); } catch (IOException e) { Assert.fail(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java new file mode 100644 index 000000000000..14d5c5a9db2c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -0,0 +1,39 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.nodes.Node; + +public abstract class AbstractOperationsTruffleException extends AbstractTruffleException { + + public AbstractOperationsTruffleException() { + super(); + } + + public AbstractOperationsTruffleException(AbstractOperationsTruffleException prototype) { + super(prototype); + } + + public AbstractOperationsTruffleException(Node location, int bci) { + super(getLocation(location, bci)); + } + + public AbstractOperationsTruffleException(String message, Node location, int bci) { + super(message, getLocation(location, bci)); + } + + public AbstractOperationsTruffleException(String message, Throwable cause, int stackTraceElementLimit, Node location, int bci) { + super(message, cause, stackTraceElementLimit, getLocation(location, bci)); + } + + public AbstractOperationsTruffleException(String message) { + super(message); + } + + private static Node getLocation(Node location, int bci) { + if (bci >= 0) { + return ((OperationsNode) location).createFakeLocationNode(bci); + } else { + return location; + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java index 0f03dc1bd062..b81b74af7860 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Objects; import java.util.Stack; import com.oracle.truffle.api.source.Source; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index c068ae68d992..91b1bbb13f8d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -5,6 +5,7 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.tracing.NodeTrace; import com.oracle.truffle.api.source.Source; @@ -125,4 +126,18 @@ protected Object translateStackTraceElement(TruffleStackTraceElement element) { int bci = element.getFrame().getInt(BCI_SLOT); return new OperationsStackTraceElement(element.getTarget().getRootNode(), getSourceSectionAtBci(bci)); } + + public final Node createFakeLocationNode(final int bci) { + return new Node() { + @Override + public SourceSection getSourceSection() { + return getSourceSectionAtBci(bci); + } + + @Override + public SourceSection getEncapsulatingSourceSection() { + return getSourceSectionAtBci(bci); + } + }; + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java deleted file mode 100644 index 73692d9e502f..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Special.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.oracle.truffle.api.operation; - -public @interface Special { - public static enum SpecialKind { - NODE, - ARGUMENTS, - } - - public SpecialKind value(); -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index e304e1214246..8c0f5e6c8ca2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -253,6 +253,10 @@ private VariableElement resolveVariable(Variable variable) { return parent.resolveVariable(variable); } + if ("$bci".equals(name)) { + return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "-1"); + } + return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/Expression.g4 b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/Expression.g4 index b74dc94586ba..a9dd708bdbbc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/Expression.g4 +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/Expression.g4 @@ -121,5 +121,6 @@ fragment HEX_DIGIT : [0-9] | [a-f] | [A-F]; fragment OCT_DIGIT : [0-7]; fragment BINARY_DIGIT : '0' | '1'; -IDENTIFIER : LETTER (LETTER | DIGIT)*; +IDENTIFIER : LETTER (LETTER | DIGIT)*; + NUMERIC_LITERAL : '0' ( 'x' HEX_DIGIT* | 'b' BINARY_DIGIT* | OCT_DIGIT* )? | NON_ZERO_DIGIT DIGIT*; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 3d471ca9caaf..9347f3892174 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -12,6 +12,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeKind; import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -22,6 +23,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -491,6 +493,9 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v CodeExecutableElement copy = CodeExecutableElement.clone(metExecute); copy.setSimpleName(CodeNames.of(executeName)); GeneratorUtils.addSuppressWarnings(ProcessorContext.getInstance(), copy, "static-method"); + copy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + + copy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(ProcessorContext.getInstance().getTypes().CompilerDirectives_TruffleBoundary)); vars.bytecodeNodeType.add(copy); @@ -511,6 +516,8 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v b.startCall("this", copy); + b.variable(vars.bci); + int valIdx = 0; for (ParameterKind param : data.getMainProperties().parameters) { @@ -519,11 +526,8 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v case VARIADIC: b.tree(vals[valIdx++]); break; - case SPECIAL_NODE: - b.string("this"); - break; - case SPECIAL_ARGUMENTS: - b.startCall(vars.frame, "getArguments").end(); + case VIRTUAL_FRAME: + b.variable(vars.frame); break; default: throw new UnsupportedOperationException("" + param); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index f1d01fc7d36e..f42fc258f0e7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -10,7 +10,6 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; @@ -26,22 +25,32 @@ public class SingleOperationData extends Template { static enum ParameterKind { STACK_VALUE, VARIADIC, - SPECIAL_NODE, - SPECIAL_ARGUMENTS; + VIRTUAL_FRAME; - public TypeMirror getParameterType(ProcessorContext context, TruffleTypes types) { + public TypeMirror getParameterType(ProcessorContext context) { switch (this) { case STACK_VALUE: return context.getType(Object.class); case VARIADIC: - case SPECIAL_ARGUMENTS: return new ArrayCodeTypeMirror(context.getType(Object.class)); - case SPECIAL_NODE: - return types.Node; + case VIRTUAL_FRAME: + return context.getTypes().VirtualFrame; default: throw new IllegalArgumentException("" + this); } } + + public boolean isStackValue() { + switch (this) { + case STACK_VALUE: + case VARIADIC: + return true; + case VIRTUAL_FRAME: + return false; + default: + throw new IllegalArgumentException(this.toString()); + } + } } static class MethodProperties { @@ -54,13 +63,13 @@ static class MethodProperties { public MethodProperties(ExecutableElement element, List parameters, boolean isVariadic, boolean returnsValue) { this.element = element; this.parameters = parameters; - int numStackValues = 0; + int stackValues = 0; for (ParameterKind param : parameters) { - if (param == ParameterKind.STACK_VALUE || param == ParameterKind.VARIADIC) { - numStackValues++; + if (param.isStackValue()) { + stackValues++; } } - this.numStackValues = numStackValues; + this.numStackValues = stackValues; this.isVariadic = isVariadic; this.returnsValue = returnsValue; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index afcc7ea2d20a..095090595caf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -13,7 +13,6 @@ import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -21,7 +20,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; @@ -89,7 +87,7 @@ protected SingleOperationData parse(Element element, List mirr } if (operationFunctions.isEmpty()) { - data.addError("Operation contains no operation functions (public static methods)"); + data.addError("Operation contains no specializations"); return data; } @@ -122,7 +120,7 @@ protected SingleOperationData parse(Element element, List mirr { int i = 0; for (ParameterKind param : props.parameters) { - metExecute.addParameter(new CodeVariableElement(param.getParameterType(context, types), "arg" + i)); + metExecute.addParameter(new CodeVariableElement(param.getParameterType(context), "arg" + i)); i++; } } @@ -175,24 +173,15 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } isVariadic = true; parameters.add(ParameterKind.VARIADIC); - } else if (isSpecialParameter(param)) { - AnnotationMirror ann = ElementUtils.findAnnotationMirror(param, types.Special); - String kind = ElementUtils.getAnnotationValue(ann, "value").getValue().toString(); - switch (kind) { - case "NODE": - parameters.add(ParameterKind.SPECIAL_NODE); - break; - case "ARGUMENTS": - parameters.add(ParameterKind.SPECIAL_ARGUMENTS); - break; - default: - throw new IllegalArgumentException("Unexpected value: " + kind); - } } else if (!isIgnoredParameter(param)) { if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); } - parameters.add(ParameterKind.STACK_VALUE); + if (ElementUtils.isAssignable(param.asType(), types.VirtualFrame)) { + parameters.add(ParameterKind.VIRTUAL_FRAME); + } else { + parameters.add(ParameterKind.STACK_VALUE); + } } } @@ -210,15 +199,13 @@ private boolean isIgnoredParameter(VariableElement param) { return true; } else if (ElementUtils.findAnnotationMirror(param, types.CachedLanguage) != null) { return true; + } else if (ElementUtils.findAnnotationMirror(param, types.CachedContext) != null) { + return true; } return false; } - private boolean isSpecialParameter(VariableElement param) { - return ElementUtils.findAnnotationMirror(param, types.Special) != null; - } - private boolean isVariadicParameter(VariableElement param) { return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index f7dcdce32a67..ea877503286c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2189,6 +2189,12 @@ private void initializeExpressions(List elements, NodeData no List globalMembers = new ArrayList<>(members.size() + fields.size()); globalMembers.addAll(fields); globalMembers.addAll(members); + if (mode == ParseMode.OPERATION) { + globalMembers.add(new CodeVariableElement(types.OperationsNode, "this")); + globalMembers.add(new CodeVariableElement(context.getType(int.class), "$bci")); + } else { + globalMembers.add(new CodeVariableElement(types.Node, "this")); + } DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); // the number of specializations might grow while expressions are initialized. diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 54ba3386096f..17d89e971726 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.sl.runtime.SLLanguageView; @@ -56,14 +57,19 @@ * conditions just abort execution. This exception class is used when we abort from within the SL * implementation. */ -public class SLException extends AbstractTruffleException { +public class SLException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -6799734410727348507L; private static final InteropLibrary UNCACHED_LIB = InteropLibrary.getFactory().getUncached(); + @TruffleBoundary + public SLException(String message, Node location, int bci) { + super(message, location, bci); + } + @TruffleBoundary public SLException(String message, Node location) { - super(message, location); + super(message, location, -1); } /** @@ -71,7 +77,7 @@ public SLException(String message, Node location) { * are no automatic type conversions of values. */ @TruffleBoundary - public static SLException typeError(Node operation, Object... values) { + public static SLException typeError(Node operation, int bci, Object... values) { StringBuilder result = new StringBuilder(); result.append("Type error"); @@ -128,7 +134,7 @@ public static SLException typeError(Node operation, Object... values) { } } } - return new SLException(result.toString(), operation); + return new SLException(result.toString(), operation, bci); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java index 8c4bf0f0062c..2061530c6ea7 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLBuiltinNode.java @@ -67,7 +67,7 @@ public final Object executeGeneric(VirtualFrame frame) { try { return execute(frame); } catch (UnsupportedSpecializationException e) { - throw SLException.typeError(e.getNode(), e.getSuppliedValues()); + throw SLException.typeError(e.getNode(), -1, e.getSuppliedValues()); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java index 1cbdadc3fdf0..75cd0cc870e2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java @@ -79,7 +79,7 @@ public Object newObject(Object obj, @CachedLibrary("obj") InteropLibrary values) return values.instantiate(obj); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { /* Foreign access was not successful. */ - throw SLUndefinedNameException.undefinedFunction(this, obj); + throw SLUndefinedNameException.undefinedFunction(this, -1, obj); } } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java index 5b0e3828ee15..aa6a850a9b6d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java @@ -59,6 +59,6 @@ public SLUndefinedFunctionRootNode(SLLanguage language, TruffleString name) { @Override public Object execute(VirtualFrame frame) { - throw SLUndefinedNameException.undefinedFunction(null, getTSName()); + throw SLUndefinedNameException.undefinedFunction(null, -1, getTSName()); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java index 34de0d20b22a..659f61838086 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java @@ -109,7 +109,7 @@ private boolean evaluateCondition(VirtualFrame frame) { * The condition evaluated to a non-boolean result. This is a type error in the SL * program. */ - throw SLException.typeError(this, ex.getResult()); + throw SLException.typeError(this, -1, ex.getResult()); } } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index 09640d4a98b3..38829a54a81e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLException; @@ -131,7 +132,7 @@ public static boolean isString(Object a, Object b) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java index 8a29bb8edd84..f411008db13a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLBinaryNode; @@ -75,7 +77,7 @@ public static SLBigNumber div(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLInvokeNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLInvokeNode.java index 57d58cd32af3..8a125c9fbabd 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLInvokeNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLInvokeNode.java @@ -97,7 +97,7 @@ public Object executeGeneric(VirtualFrame frame) { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { /* Execute was not successful. */ - throw SLUndefinedNameException.undefinedFunction(this, function); + throw SLUndefinedNameException.undefinedFunction(this, -1, function); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java index 0241a93a1447..1af642120863 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLBinaryNode; @@ -66,7 +68,7 @@ public static boolean lessOrEqual(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index 58eaeac333f7..c49c0dcab991 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLBinaryNode; @@ -67,8 +69,8 @@ public static boolean lessThan(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java index dba6764e67a2..310fc8b9cbdf 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java @@ -40,9 +40,11 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLExpressionNode; @@ -61,8 +63,8 @@ public static boolean doBoolean(boolean value) { } @Fallback - public static Object typeError(Object value) { - throw SLException.typeError(null, value); + public static Object typeError(Object value, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, value); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java index 147cef2b6e67..cffb052cc35a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLBinaryNode; @@ -66,8 +68,8 @@ public static SLBigNumber mul(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index 17151ffb04eb..efb17998bc85 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.strings.TruffleString; @@ -74,38 +75,44 @@ public abstract class SLReadPropertyNode extends SLExpressionNode { @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object readArray(Object receiver, Object index, + @Cached("this") Node node, + @Cached("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { return arrays.readArrayElement(receiver, numbers.asLong(index)); } catch (UnsupportedMessageException | InvalidArrayIndexException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, index); + throw SLUndefinedNameException.undefinedProperty(node, bci, index); } } @Specialization(limit = "LIBRARY_LIMIT") public static Object readSLObject(SLObject receiver, Object name, + @Cached("this") Node node, + @Cached("$bci") int bci, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { TruffleString nameTS = toTruffleStringNode.execute(name); Object result = objectLibrary.getOrDefault(receiver, nameTS, null); if (result == null) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, nameTS); + throw SLUndefinedNameException.undefinedProperty(node, bci, nameTS); } return result; } @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") public static Object readObject(Object receiver, Object name, + @Cached("this") Node node, + @Cached("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { try { return objects.readMember(receiver, asMember.execute(name)); } catch (UnsupportedMessageException | UnknownIdentifierException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, name); + throw SLUndefinedNameException.undefinedProperty(node, bci, name); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java index a8310a2c4221..871ed73993e5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java @@ -78,7 +78,7 @@ public final boolean executeBoolean(VirtualFrame frame) { try { leftValue = left.executeBoolean(frame); } catch (UnexpectedResultException e) { - throw SLException.typeError(this, e.getResult(), null); + throw SLException.typeError(this, -1, e.getResult(), null); } boolean rightValue; try { @@ -88,7 +88,7 @@ public final boolean executeBoolean(VirtualFrame frame) { rightValue = false; } } catch (UnexpectedResultException e) { - throw SLException.typeError(this, leftValue, e.getResult()); + throw SLException.typeError(this, -1, leftValue, e.getResult()); } return execute(leftValue, rightValue); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index b6afe54690ea..9d87270c6ac8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLBinaryNode; @@ -66,8 +68,8 @@ public static SLBigNumber sub(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right) { - throw SLException.typeError(null, left, right); + public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index faef2cfcddd2..51a71ee88a60 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -49,6 +49,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.sl.nodes.SLExpressionNode; @@ -77,13 +78,15 @@ public abstract class SLWritePropertyNode extends SLExpressionNode { @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object writeArray(Object receiver, Object index, Object value, + @Cached("this") Node node, + @Cached("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { arrays.writeArrayElement(receiver, numbers.asLong(index), value); } catch (UnsupportedMessageException | UnsupportedTypeException | InvalidArrayIndexException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, index); + throw SLUndefinedNameException.undefinedProperty(node, bci, index); } return value; } @@ -98,13 +101,15 @@ public static Object writeSLObject(SLObject receiver, Object name, Object value, @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") public static Object writeObject(Object receiver, Object name, Object value, + @Cached("this") Node node, + @Cached("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { objectLibrary.writeMember(receiver, asMember.execute(name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(null, name); + throw SLUndefinedNameException.undefinedProperty(node, bci, name); } return value; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index bf3ba28c07ff..33fdda8afb3c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,16 +1,14 @@ package com.oracle.truffle.sl.operations; -import java.util.HashMap; +import java.util.Collections; import java.util.Map; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -20,9 +18,6 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.Special; -import com.oracle.truffle.api.operation.Special.SpecialKind; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; @@ -30,7 +25,6 @@ import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLTypesGen; -import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; import com.oracle.truffle.sl.nodes.expression.SLEqualNode; @@ -41,10 +35,8 @@ import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; import com.oracle.truffle.sl.nodes.expression.SLSubNode; import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; -import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLStrings; @@ -55,16 +47,14 @@ public class SLOperations { public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { Map targets = SLOperationsVisitor.parseSL(language, source, builder); + RootCallTarget main = targets.get(SLStrings.MAIN); // create the RootNode builder.setInternal(); // root node is internal builder.beginReturn(); builder.beginSLEvalRootOperation(); - targets.forEach((name, call) -> { - builder.emitConstObject(name); - builder.emitConstObject(call); - }); + builder.emitConstObject(Collections.unmodifiableMap(targets)); builder.endSLEvalRootOperation(); builder.endReturn(); @@ -73,96 +63,32 @@ public static void parse(SLLanguage language, Source source, SLOperationsBuilder @Operation public static class SLEvalRootOperation { + @SuppressWarnings("unchecked") @Specialization public static Object perform( - @Variadic Object[] children, - @Special(SpecialKind.NODE) Node node, - @Special(SpecialKind.ARGUMENTS) Object[] arguments) { - // This should get lazily executed - - Map functions = new HashMap<>(); - CallTarget main = null; - - for (int i = 0; i < children.length; i += 2) { - TruffleString name = (TruffleString) children[i]; - RootCallTarget target = (RootCallTarget) children[i + 1]; - if (name.equals(SLStrings.MAIN)) { - main = target; - } - functions.put(name, target); - } + VirtualFrame frame, + Map functions, + @Cached("this") Node node) { + SLContext.get(node).getFunctionRegistry().register((Map) functions); - SLContext.get(node).getFunctionRegistry().register(functions); + RootCallTarget main = (RootCallTarget) functions.get(SLStrings.MAIN); if (main != null) { - return main.call(arguments); + return main.call(frame.getArguments()); } else { return SLNull.SINGLETON; } } } - @Operation + @Operation(proxyNode = SLAddNode.class) @TypeSystemReference(SLTypes.class) public static class SLAddOperation { - - @Specialization(rewriteOn = ArithmeticException.class) - public static long addLong(long left, long right, @Special(SpecialKind.NODE) Node node) { - return Math.addExact(left, right); - } - - @Specialization(replaces = "addLong") - @TruffleBoundary - public static SLBigNumber add(SLBigNumber left, SLBigNumber right, @Special(SpecialKind.NODE) Node node) { - return new SLBigNumber(left.getValue().add(right.getValue())); - } - - @Specialization(guards = "isString(left, right)") - @TruffleBoundary - public static TruffleString add(Object left, Object right, - @Special(SpecialKind.NODE) Node node, - @Cached SLToTruffleStringNode toTruffleStringNodeLeft, - @Cached SLToTruffleStringNode toTruffleStringNodeRight, - @Cached TruffleString.ConcatNode concatNode) { - return concatNode.execute(toTruffleStringNodeLeft.execute(left), toTruffleStringNodeRight.execute(right), SLLanguage.STRING_ENCODING, true); - } - - public static boolean isString(Object a, Object b) { - return a instanceof TruffleString || b instanceof TruffleString; - } - - @Fallback - public static Object typeError(Object left, Object right, @Special(SpecialKind.NODE) Node node) { - throw SLException.typeError(node, left, right); - } } - @Operation + @Operation(proxyNode = SLDivNode.class) @TypeSystemReference(SLTypes.class) public static class SLDivOperation { - - @Specialization(rewriteOn = ArithmeticException.class) - public static long divLong(long left, long right, @Special(SpecialKind.NODE) Node node) throws ArithmeticException { - long result = left / right; - /* - * The division overflows if left is Long.MIN_VALUE and right is -1. - */ - if ((left & right & result) < 0) { - throw new ArithmeticException("long overflow"); - } - return result; - } - - @Specialization(replaces = "divLong") - @TruffleBoundary - public static SLBigNumber div(SLBigNumber left, SLBigNumber right, @Special(SpecialKind.NODE) Node node) { - return new SLBigNumber(left.getValue().divide(right.getValue())); - } - - @Fallback - public static Object typeError(Object left, Object right, @Special(SpecialKind.NODE) Node node) { - throw SLException.typeError(node, left, right); - } } @Operation(proxyNode = SLEqualNode.class) @@ -174,7 +100,7 @@ public static class SLEqualOperation { @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @Special(SpecialKind.NODE) Node node) { + public static Object execute(TruffleString functionName, @Cached("this") Node node) { Object res = SLContext.get(node).getFunctionRegistry().lookup(functionName, true); return res; } @@ -184,12 +110,12 @@ public static Object execute(TruffleString functionName, @Special(SpecialKind.NO @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { @Specialization - public static Object execute(Object function, @Variadic Object[] argumentValues, @Special(SpecialKind.NODE) Node node, @CachedLibrary(limit = "3") InteropLibrary library) { + public static Object execute(Object function, @Variadic Object[] argumentValues, @Cached("this") Node node, @Cached("$bci") int bci, @CachedLibrary(limit = "3") InteropLibrary library) { try { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { /* Execute was not successful. */ - throw SLUndefinedNameException.undefinedFunction(node, function); + throw SLUndefinedNameException.undefinedFunction(node, bci, function); } } } @@ -238,11 +164,11 @@ public static class SLUnboxOperation { @TypeSystemReference(SLTypes.class) public static class SLConvertToBoolean { @Specialization - public static boolean perform(Object obj, @Special(SpecialKind.NODE) Node node) { + public static boolean perform(Object obj, @Cached("this") Node node, @Cached("$bci") int bci) { try { return SLTypesGen.expectBoolean(obj); } catch (UnexpectedResultException e) { - throw SLException.typeError(node, e.getResult()); + throw SLException.typeError(node, bci, e.getResult()); } } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLUndefinedNameException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLUndefinedNameException.java index 88389d0ca1c3..d56da287b784 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLUndefinedNameException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLUndefinedNameException.java @@ -49,16 +49,16 @@ public final class SLUndefinedNameException extends SLException { private static final long serialVersionUID = 1L; @TruffleBoundary - public static SLUndefinedNameException undefinedFunction(Node location, Object name) { - throw new SLUndefinedNameException("Undefined function: " + name, location); + public static SLUndefinedNameException undefinedFunction(Node location, int bci, Object name) { + throw new SLUndefinedNameException("Undefined function: " + name, location, bci); } @TruffleBoundary - public static SLUndefinedNameException undefinedProperty(Node location, Object name) { - throw new SLUndefinedNameException("Undefined property: " + name, location); + public static SLUndefinedNameException undefinedProperty(Node location, int bci, Object name) { + throw new SLUndefinedNameException("Undefined property: " + name, location, bci); } - private SLUndefinedNameException(String message, Node node) { - super(message, node); + private SLUndefinedNameException(String message, Node node, int bci) { + super(message, node, bci); } } From c26b57efc1211a04da8248af8d868e4f622ca9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 18 Mar 2022 12:04:59 +0100 Subject: [PATCH 021/312] [wip] rename Integer -> IntegerArgument --- .../oracle/truffle/dsl/processor/operations/Argument.java | 6 +++--- .../truffle/dsl/processor/operations/Instruction.java | 6 +++--- .../oracle/truffle/dsl/processor/operations/Operation.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java index 452e0771275a..bbd6d3df99a8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java @@ -34,8 +34,8 @@ public boolean isImplicit() { public abstract CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset); - public static class Integer extends Argument { - public Integer(int length) { + public static class IntegerArgument extends Argument { + public IntegerArgument(int length) { super(length); assert length == 1 || length == 2; } @@ -87,7 +87,7 @@ public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { } } - public static class VarArgsCount extends Integer { + public static class VarArgsCount extends IntegerArgument { private final int minCount; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 9347f3892174..ce8101392beb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -280,7 +280,7 @@ protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[ public static class LoadArgument extends SimpleInstruction { public LoadArgument(int id) { - super("ldarg", id, 1, 0, new Argument.Integer(2)); + super("ldarg", id, 1, 0, new Argument.IntegerArgument(2)); } @Override @@ -306,7 +306,7 @@ protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[ public static class LoadLocal extends SimpleInstruction { public LoadLocal(int id) { - super("ldloc", id, 1, 0, new Argument.Integer(2)); + super("ldloc", id, 1, 0, new Argument.IntegerArgument(2)); } @Override @@ -330,7 +330,7 @@ protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[ public static class StoreLocal extends SimpleInstruction { public StoreLocal(int id) { - super("stloc", id, 0, 1, new Argument.Integer(2)); + super("stloc", id, 0, 1, new Argument.IntegerArgument(2)); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index a56628c0cb60..d940540ccc81 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -420,7 +420,7 @@ public CodeTree createPushCountCode(BuilderVariables vars) { @Override public List getArguments() { - return List.of(new Argument.Integer(2)); + return List.of(new Argument.IntegerArgument(2)); } @Override From ecd6ea42d8e93fd86e2de5b5b1130cb655f86e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 23 Mar 2022 09:39:37 +0100 Subject: [PATCH 022/312] [wip] execution tracer --- .../example/TestOperationsParserTest.java | 23 +++ .../api/operation/BuilderOperationData.java | 16 +++ .../operation/tracing/ExecutionTracer.java | 133 ++++++++++++++++++ .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Instruction.java | 2 + .../dsl/processor/operations/Operation.java | 10 ++ .../operations/OperationGeneratorUtils.java | 41 +++--- .../operations/OperationsCodeGenerator.java | 36 +++++ .../operations/OperationsParser.java | 3 +- .../truffle/sl/test/SLSimpleTestSuite.java | 2 + .../oracle/truffle/sl/test/SLTestRunner.java | 2 + .../truffle/sl/operations/SLOperations.java | 1 - .../operations/SLOperationsVisitor.java | 1 - 13 files changed, 250 insertions(+), 22 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 4103787d7137..f5d81a4eff15 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -16,6 +16,7 @@ import com.oracle.truffle.api.TruffleStackTrace; import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -149,4 +150,26 @@ public void testStacktrace() { Assert.fail(); } } + + @Test + public void testTracing() { + //@formatter:off + String src = "(do" + + " (setlocal 0 0)" + + " (setlocal 2 0)" + + " (while" + + " (less (local 0) 100)" + + " (do" + + " (setlocal 1 0)" + + " (while" + + " (less (local 1) 100)" + + " (do" + + " (setlocal 2 (add (local 2) (local 1)))" + + " (setlocal 1 (add (local 1) 1))))" + + " (setlocal 0 (add (local 0) 1))))" + + " (return (local 2)))"; + //@formatter:on + new Tester(src).test(495000L); + ExecutionTracer.get().dump(); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java new file mode 100644 index 000000000000..f5fa1f1d31e6 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -0,0 +1,16 @@ +package com.oracle.truffle.api.operation; + +public class BuilderOperationData { + public final BuilderOperationData parent; + public final int operationId; + public final Object[] aux; + public final Object[] arguments; + public int numChildren = 0; + + public BuilderOperationData(BuilderOperationData parent, int id, int numAux, Object... arguments) { + this.parent = parent; + this.operationId = id; + this.aux = new Object[numAux]; + this.arguments = arguments; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java new file mode 100644 index 000000000000..e189e750727c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -0,0 +1,133 @@ +package com.oracle.truffle.api.operation.tracing; + +import java.util.HashMap; +import java.util.Map; + +import com.oracle.truffle.api.operation.OperationsNode; + +public class ExecutionTracer { + private static ThreadLocal INSTANCE = ThreadLocal.withInitial(ExecutionTracer::new); + + public static ExecutionTracer get() { + return INSTANCE.get(); + } + + private static final int TRACE_LENGTH = 8; + + private static class InstructionSequence { + final int hash; + final int[] instrs; + + public InstructionSequence(int[] instrs) { + this.instrs = instrs; + int h = 0; + for (int i : instrs) { + h = h * 31 + i; + } + hash = h; + } + + public InstructionSequence add(int next) { + int[] created = new int[instrs.length]; + System.arraycopy(instrs, 1, created, 0, instrs.length - 1); + created[created.length - 1] = next; + return new InstructionSequence(created); + } + + public boolean isValid() { + for (int i : instrs) { + if (i == 0) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof InstructionSequence)) + return false; + InstructionSequence other = (InstructionSequence) obj; + if (other.hash != hash || instrs.length != other.instrs.length) { + return false; + } + for (int i = 0; i < instrs.length; i++) { + if (instrs[i] != other.instrs[i]) { + return false; + } + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < instrs.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(String.format("%3d", instrs[i])); + } + sb.append(']'); + return sb.toString(); + } + } + + final Map occurences = new HashMap<>(); + InstructionSequence[] last = new InstructionSequence[TRACE_LENGTH - 1]; + + private final void resetLast() { + for (int i = 2; i <= TRACE_LENGTH; i++) { + last[i - 2] = new InstructionSequence(new int[i]); + } + } + + public final void startFunction(OperationsNode node) { + resetLast(); + } + + public final void endFunction() { + resetLast(); + } + + public final void traceInstruction(int bci, int id, Object... arguments) { + for (int i = 0; i < last.length; i++) { + last[i] = last[i].add(id); + if (last[i].isValid()) { + Long vo = occurences.get(last[i]); + long v = vo == null ? 0 : vo; + occurences.put(last[i], v + 1); + } + } + } + + public final Object tracePop(Object value) { + return value; + } + + public final Object tracePush(Object value) { + return value; + } + + public final void traceException(Throwable ex) { + } + + private static final long score(Map.Entry ent) { + return ent.getValue() * ent.getKey().instrs.length; + } + + public final void dump() { + occurences.entrySet().stream()// + .sorted((e1, e2) -> Long.compare(score(e2), score(e1)))// + .limit(30)// + .forEachOrdered(e -> { + System.out.printf(" %s : %d\n", e.getKey(), e.getValue()); + }); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 3449c3d6a7ca..42234d671acc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -234,6 +234,7 @@ public class TruffleTypes { public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; public static final String Special_Name = "com.oracle.truffle.api.operation.Special"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; + public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; @@ -248,6 +249,7 @@ public class TruffleTypes { public final DeclaredType OperationsNode = c.getDeclaredTypeOptional(OperationsNode_Name); public final DeclaredType Special = c.getDeclaredTypeOptional(Special_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); + public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); public final DeclaredType NodeTrace = c.getDeclaredTypeOptional(NodeTrace_Name); public final DeclaredType InstructionTrace = c.getDeclaredTypeOptional(InstructionTrace_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index ce8101392beb..82b0132eb8d9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -49,6 +49,8 @@ public static class ExecuteVariables { CodeVariableElement consts; CodeVariableElement maxStack; CodeVariableElement handlers; + + CodeVariableElement tracer; } public Instruction(String name, int id, Argument... arguments) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index d940540ccc81..fd52fe5a6c57 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -91,6 +91,10 @@ public CodeTree createEndCode(BuilderVariables vars) { return null; } + public CodeTree createLeaveCode(BuilderVariables vars) { + return null; + } + public abstract CodeTree createPushCountCode(BuilderVariables vars); public static class Custom extends Operation { @@ -511,6 +515,12 @@ public CodeTree createEndCode(BuilderVariables vars) { } } + public static class Instrumentation extends Block { + public Instrumentation(OperationsContext builder, int id) { + super(builder, "Instrumentation", id); + } + } + protected static final CodeTree createPopUtility(TypeMirror type, BuilderVariables vars) { return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "pop").end().build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index fdbc078d95d5..3aeb4ec076db 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -61,33 +61,38 @@ public static CodeTree createClearStackSlot(ExecuteVariables vars, int offset) { } public static CodeTree createReadStack(ExecuteVariables vars, int offset) { - return CodeTreeBuilder.createBuilder() // - .startCall(vars.frame, "getValue") // - .startGroup().variable(vars.sp).string(" + " + (offset - 1)).end()// - .end(2).build(); + return createReadStack(vars, CodeTreeBuilder.singleString("" + offset)); } public static CodeTree createReadStack(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder() // - .startCall(vars.frame, "getValue") // - .startGroup().variable(vars.sp).string(" - 1 + ").tree(offset).end()// - .end(2).build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (vars.tracer != null) { + b.startCall(vars.tracer, "tracePop"); + } + b.startCall(vars.frame, "getValue"); + b.startGroup().variable(vars.sp).string(" - 1 + (").tree(offset).string(")").end(); + if (vars.tracer != null) { + b.end(); + } + return b.end(2).build(); } public static CodeTree createWriteStackObject(ExecuteVariables vars, int offset, CodeTree value) { - return CodeTreeBuilder.createBuilder() // - .startStatement().startCall(vars.frame, "setObject") // - .startGroup().variable(vars.sp).string(" + " + (offset - 1)).end()// - .tree(value) // - .end(3).build(); + return createWriteStackObject(vars, "" + offset, value); } public static CodeTree createWriteStackObject(ExecuteVariables vars, String offset, CodeTree value) { - return CodeTreeBuilder.createBuilder() // - .startStatement().startCall(vars.frame, "setObject") // - .startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")").end()// - .tree(value) // - .end(3).build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement().startCall(vars.frame, "setObject"); + b.startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")").end(); + if (vars.tracer != null) { + b.startCall(vars.tracer, "tracePush"); + } + b.tree(value); + if (vars.tracer != null) { + b.end(); + } + return b.end(2).build(); } public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index deaf0c23a4fe..a6aa45a1e23f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -743,10 +743,14 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); builderBytecodeNodeType.add(ctor); + CodeVariableElement fldTracer = null; CodeVariableElement fldHitCount = null; if (m.isTracing()) { fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); builderBytecodeNodeType.add(fldHitCount); + + fldTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); + builderBytecodeNodeType.add(fldTracer); } { @@ -757,6 +761,8 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl (ArrayType) fldHitCount.getType(), CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); b.end(2); + + b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get").end(2); } } @@ -766,6 +772,7 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl vars.consts = fldConsts; vars.maxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); vars.handlers = fldHandlers; + vars.tracer = fldTracer; { CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); @@ -806,6 +813,10 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); b.declaration("int", varBci.getName(), "0"); + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "startFunction").string("this").end(2); + } + CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); b.statement("Object " + varReturnValue.getName()); @@ -845,6 +856,20 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceInstruction"); + b.variable(varBci); + b.variable(op.opcodeIdField); + + int ofs = 1; + for (Argument arg : op.arguments) { + b.tree(arg.createReadCode(vars, ofs)); + ofs += arg.length; + } + + b.end(2); + } + b.tree(op.createExecuteCode(vars)); b.tree(op.createExecuteEpilogue(vars)); @@ -857,6 +882,13 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceException"); + b.string("ex"); + b.end(2); + + } + b.startFor().string("int handlerIndex = 0; handlerIndex < " + vars.handlers.getName() + ".length; handlerIndex++").end(); b.startBlock(); @@ -883,6 +915,10 @@ private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl b.statement("bci = nextBci"); b.end(); // while block + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "endFunction").end(2); + } + b.startReturn().string("returnValue").end(); vars.bci = null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index deb3802bc4a0..1542f90524fe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -35,7 +35,7 @@ protected OperationsData parse(Element element, List mirror) { ExecutableElement parseMethod = ElementUtils.findExecutableElement(typeElement, "parse"); if (parseMethod == null) { data.addError(typeElement, - "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Context}, %sBuilder)", + "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Language}, {Context}, %sBuilder)", typeElement.getSimpleName()); return data; } @@ -66,7 +66,6 @@ protected OperationsData parse(Element element, List mirror) { SingleOperationData opData = new SingleOperationParser(data).parse(inner, false); if (opData != null) { -// opData.redirectMessages(data); data.addOperationData(opData); } else { data.addError("Could not generate operation: " + inner.getSimpleName()); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java index 41fe19eb1f9f..fcdecc830bbb 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java @@ -43,6 +43,8 @@ import org.junit.Test; import org.junit.runner.RunWith; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; + @RunWith(SLTestRunner.class) @SLTestSuite({"tests"}) public class SLSimpleTestSuite { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java index cf368c0f103e..d9a301f09150 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @@ -82,6 +82,7 @@ import org.junit.runners.model.InitializationError; import com.oracle.truffle.api.dsl.NodeFactory; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.builtins.SLBuiltinNode; import com.oracle.truffle.sl.test.SLTestRunner.TestCase; @@ -348,6 +349,7 @@ public static void runInMain(Class testClass, String[] args) throws Initializ suite.filter(new NameFilter(args[0])); } Result r = core.run(suite); + ExecutionTracer.get().dump(); if (!r.wasSuccessful()) { System.exit(1); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 33fdda8afb3c..f1d137a9dde9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -47,7 +47,6 @@ public class SLOperations { public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { Map targets = SLOperationsVisitor.parseSL(language, source, builder); - RootCallTarget main = targets.get(SLStrings.MAIN); // create the RootNode diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index d8c9bee90852..fa64b0751d2c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -139,7 +139,6 @@ public Void visitFunction(FunctionContext ctx) { b.endSource(); OperationsNode node = b.build(); - System.out.println(node.dump()); functions.put(name, node.getCallTarget()); return null; From 4ebb8c09dc62017de708ee5f9fe746841dce752e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 23 Mar 2022 11:30:18 +0100 Subject: [PATCH 023/312] [wip] --- .../api/operation/BuilderOperationData.java | 2 + .../api/operation/BuilderOperationLabel.java | 74 ++++++- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Argument.java | 23 +-- .../dsl/processor/operations/Instruction.java | 28 +-- .../dsl/processor/operations/Operation.java | 183 +++++++----------- .../operations/OperationGeneratorUtils.java | 26 +++ .../operations/OperationsCodeGenerator.java | 128 ++++-------- 8 files changed, 230 insertions(+), 236 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index f5fa1f1d31e6..a0c198bcb72f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -2,6 +2,7 @@ public class BuilderOperationData { public final BuilderOperationData parent; + public final int depth; public final int operationId; public final Object[] aux; public final Object[] arguments; @@ -9,6 +10,7 @@ public class BuilderOperationData { public BuilderOperationData(BuilderOperationData parent, int id, int numAux, Object... arguments) { this.parent = parent; + this.depth = parent == null ? 0 : parent.depth + 1; this.operationId = id; this.aux = new Object[numAux]; this.arguments = arguments; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java index 45f15174e572..9b40cb5e0c7f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java @@ -1,26 +1,86 @@ package com.oracle.truffle.api.operation; import java.util.ArrayList; +import java.util.List; import com.oracle.truffle.api.memory.ByteArraySupport; // not public api -public class BuilderOperationLabel extends OperationLabel { +public abstract class BuilderOperationLabel extends OperationLabel { private boolean marked = false; - private ArrayList toBackfill; + private ArrayList targetBci = new ArrayList<>(); + private ArrayList targets = new ArrayList<>(); + private ArrayList targetDataList = new ArrayList<>(); + private boolean hasValue = false; + private int value = 0; + private BuilderOperationData valueData; - public void resolve(byte[] bc, int labelValue) { + public void resolve(byte[] bc, int labelValue, BuilderOperationData data) { assert !hasValue; + hasValue = true; value = labelValue; + valueData = data; + + List leaveList = new ArrayList<>(); + List leaveDataList = new ArrayList<>(); + + for (int i = 0; i < targets.size(); i++) { + int target = targets.get(i); + BuilderOperationData targetData = targetDataList.get(i); + + createBranch(labelValue, data, target, targetData, leaveList, leaveDataList); + } + + for (int j = 0; j < leaveList.size(); j++) { + createLeaveCode(leaveList.get(j), leaveDataList.get(j)); + } + } + + protected abstract void createLeaveCode(int bci, BuilderOperationData data); + + private final void createBranch(int from, BuilderOperationData fromData, int to, BuilderOperationData toData, List leaveCodeLocation, List leaveData) { + if (fromData.depth < toData.depth) { + throw new IllegalStateException("illegal jump to deeper operation"); + } + + BuilderOperationData current = fromData; + for (int i = fromData.depth; i > toData.depth; i--) { + leaveCodeLocation.add(from); + leaveData.add(current); - if (toBackfill != null) { - for (int bci : toBackfill) { - putDestination(bc, bci, value); + current = current.parent; + } + + if (current != toData) { + throw new IllegalStateException("illegal jump to non-parent operation"); + } + } + + /** + * 01234| -----> |56789 <------> length ^ from offset + */ + public void relocate(byte[] bc, int from, int length) { + for (int i = 0; i < targets.size(); i++) { + if (targetBci.get(i) >= from) { + targetBci.set(i, targetBci.get(i) + length); + } + if (targets.get(i) >= from) { + targets.set(i, targets.get(i) + length); } - toBackfill = null; + } + + if (hasValue) { + if (value >= from) { + value += length; + } + + for (int i = 0; i < targets.size(); i++) { + putDestination(bc, targets.get(i), value); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 42234d671acc..522ded284e40 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -224,6 +224,7 @@ public class TruffleTypes { // Operations DSL API public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; + public static final String BuilderOperationData_Name = "com.oracle.truffle.api.operation.BuilderOperationData"; public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; @@ -239,6 +240,7 @@ public class TruffleTypes { public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; public final DeclaredType BuilderExceptionHandler = c.getDeclaredTypeOptional(BuilderExceptionHandler_Name); + public final DeclaredType BuilderOperationData = c.getDeclaredTypeOptional(BuilderOperationData_Name); public final DeclaredType BuilderOperationLabel = c.getDeclaredTypeOptional(BuilderOperationLabel_Name); public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java index bbd6d3df99a8..8031ee702f49 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java @@ -18,7 +18,7 @@ protected Argument(int length) { this.length = length; } - public abstract CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value); + public abstract CodeTree createBuildCode(BuilderVariables vars, CodeTree value); public abstract CodeTree createReadCode(ExecuteVariables vars, CodeTree offset); @@ -41,20 +41,20 @@ public IntegerArgument(int length) { } @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement(); if (length == 1) { b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); b.cast(ProcessorContext.getInstance().getType(byte.class)); - b.variable(value); + b.tree(value); } else { b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); b.variable(vars.bci); b.startGroup(); b.cast(ProcessorContext.getInstance().getType(byte.class)); - b.variable(value); + b.tree(value); b.end(2); } b.end(); @@ -97,7 +97,7 @@ public VarArgsCount(int minCount) { } @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement(); b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); @@ -121,15 +121,12 @@ public BranchTarget() { } @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement(); - if (((DeclaredType) value.getType()).asElement().getSimpleName().toString().equals("BuilderOperationLabel")) { - b.startCall(value.getName(), "putValue"); - } else { - b.startCall("((BuilderOperationLabel) " + value.getName() + ")", "putValue"); - } + b.startCall(CodeTreeBuilder.createBuilder().string("((BuilderOperationLabel) ").tree(value).string(")").build(), "putValue"); + b.variable(vars.bc); b.variable(vars.bci); b.end(2); @@ -166,7 +163,7 @@ public Const() { } @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement(); b.startCall("LE_BYTES", "putShort"); @@ -174,7 +171,7 @@ public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement value b.variable(vars.bci); b.startGroup().string("(short) "); b.startCall(vars.consts, "add"); - b.variable(value); + b.tree(value); b.end(4); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java index 82b0132eb8d9..5ce7f5a7cb41 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java @@ -77,7 +77,7 @@ public List getArgumentTypes() { public abstract CodeTree createPushCountCode(BuilderVariables vars); - protected abstract CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2); + protected abstract CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2); public abstract CodeTree createExecuteCode(ExecuteVariables vars); @@ -102,7 +102,7 @@ public boolean isNormalControlFlow() { return true; } - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] argValues) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree[] argValues) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -162,7 +162,7 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("-1"); } } @@ -193,7 +193,7 @@ public boolean isNormalControlFlow() { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("-1"); } } @@ -225,7 +225,7 @@ public boolean isNormalControlFlow() { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("0"); } } @@ -245,7 +245,7 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("1"); } } @@ -275,7 +275,7 @@ public boolean isNormalControlFlow() { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("0"); } } @@ -301,7 +301,7 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("1"); } } @@ -325,7 +325,7 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("1"); } } @@ -349,16 +349,16 @@ public CodeTree createExecuteCode(ExecuteVariables vars) { } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { return CodeTreeBuilder.singleString("-1"); } @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeVariableElement[] argValues) { + public CodeTree createBuildCode(BuilderVariables vars, CodeTree[] argValues) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().variable(vars.maxLocal).string(" < ").variable(argValues[0]).end(); - b.startAssign(vars.maxLocal).variable(argValues[0]).end(); + b.startIf().variable(vars.maxLocal).string(" < ").tree(argValues[0]).end(); + b.startAssign(vars.maxLocal).tree(argValues[0]).end(); b.tree(super.createBuildCode(vars, argValues)); return b.build(); @@ -542,7 +542,7 @@ private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] v } @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeVariableElement[] arguments2) { + protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { if (this.isVarArgs) { return CodeTreeBuilder.singleString("(" + this.stackPushes + " - " + vars.numChildren.getName() + ")"); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index fd52fe5a6c57..82522b347f32 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -2,22 +2,17 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstructionFromOperation; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.getTypes; -import java.util.Collection; import java.util.List; -import java.util.Stack; -import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -50,12 +45,11 @@ public static class BuilderVariables { CodeVariableElement consts; CodeVariableElement exteptionHandlers; - CodeVariableElement stackUtility; + CodeVariableElement operationData; CodeVariableElement lastChildPushCount; CodeVariableElement childIndex; CodeVariableElement numChildren; - CodeVariableElement[] arguments; CodeVariableElement curStack; CodeVariableElement maxStack; @@ -95,6 +89,10 @@ public CodeTree createLeaveCode(BuilderVariables vars) { return null; } + public int getNumAuxValues() { + return 0; + } + public abstract CodeTree createPushCountCode(BuilderVariables vars); public static class Custom extends Operation { @@ -117,7 +115,7 @@ public List getArguments() { @Override public CodeTree createEndCode(BuilderVariables vars) { - return createEmitInstruction(vars, instruction, vars.arguments); + return createEmitInstructionFromOperation(vars, instruction); } @Override @@ -143,7 +141,7 @@ protected Simple(OperationsContext builder, String name, int id, int children, I public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(createEmitInstruction(vars, instruction, vars.arguments)); + b.tree(createEmitInstructionFromOperation(vars, instruction)); return b.build(); } @@ -194,6 +192,11 @@ protected IfThen(OperationsContext builder, int id) { super(builder, "IfThen", id, 2); } + @Override + public int getNumAuxValues() { + return 1; + } + @Override public CodeTree createAfterChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -206,9 +209,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - // utilstack: ... - b.tree(createPushUtility(varEndLabel, vars)); - // utilstack ..., endLabel + b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); } @@ -216,13 +217,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { { b.tree(createPopLastChildCode(vars)); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - - // utilstack ..., endLabel - b.tree(createPopUtility(varEndLabel, vars)); - // utilstack ... - - b.tree(createEmitLabel(vars, varEndLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); } b.end(); @@ -249,6 +244,11 @@ public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString(hasValue ? "1" : "0"); } + @Override + public int getNumAuxValues() { + return 2; + } + @Override public CodeTree createAfterChildCode(BuilderVariables vars) { @@ -272,9 +272,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); b.declaration(getTypes().BuilderOperationLabel, varElseLabel.getName(), createCreateLabel()); - // utilstack: ... - b.tree(createPushUtility(varElseLabel, vars)); - // utilstack ..., elseLabel + b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varElseLabel)); } @@ -283,7 +281,6 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startBlock(); // { { CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); if (hasValue) { b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); @@ -293,14 +290,10 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - // utilstack ..., elseLabel - b.tree(createPopUtility(varElseLabel, vars)); - // utilstack ... - b.tree(createPushUtility(varEndLabel, vars)); - // utilstack ..., endLabel + b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); - b.tree(createEmitLabel(vars, varElseLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); } b.end().startElseBlock(); { @@ -311,13 +304,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createPopLastChildCode(vars)); } - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - - // utilstack ..., endLabel - b.tree(createPopUtility(varEndLabel, vars)); - // utilstack ... - - b.tree(createEmitLabel(vars, varEndLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, 1, getTypes().BuilderOperationLabel))); } b.end(); @@ -330,6 +317,14 @@ public While(OperationsContext builder, int id) { super(builder, "While", id, 2); } + private static final int AUX_START_LABEL = 0; + private static final int AUX_END_LABEL = 1; + + @Override + public int getNumAuxValues() { + return 2; + } + @Override public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -339,8 +334,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.tree(createEmitLabel(vars, varStartLabel)); - b.tree(createPushUtility(varStartLabel, vars)); - // utilstack: ..., startLabel + b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); return b.build(); } @@ -357,27 +351,17 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - // utilstack: ..., startLabel - b.tree(createPushUtility(varEndLabel, vars)); - // utilstack ..., startLabel, endLabel + b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); } b.end().startElseBlock(); { b.tree(createPopLastChildCode(vars)); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); - - // utilstack ..., startLabel, endLabel - b.tree(createPopUtility(varEndLabel, vars)); - b.tree(createPopUtility(varStartLabel, vars)); - // utilstack ... - - b.tree(createEmitInstruction(vars, builder.commonBranch, varStartLabel)); + b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); - b.tree(createEmitLabel(vars, varEndLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); } b.end(); @@ -403,7 +387,7 @@ public CodeTree createPushCountCode(BuilderVariables vars) { @Override public CodeTree createEndCode(BuilderVariables vars) { - return createEmitLabel(vars, CodeTreeBuilder.singleString("((BuilderOperationLabel) " + vars.arguments[0].getName() + ")")); + return createEmitLabel(vars, CodeTreeBuilder.singleString("((BuilderOperationLabel) " + vars.operationData.getName() + ".arguments[0])")); } @Override @@ -417,6 +401,14 @@ public TryCatch(OperationsContext builder, int id) { super(builder, "TryCatch", id, 2); } + private static final int AUX_BEH = 0; + private static final int AUX_END_LABEL = 0; + + @Override + public int getNumAuxValues() { + return 2; + } + @Override public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("0"); @@ -435,19 +427,15 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); b.startStatement().variable(varBeh).string(".startStack = ").variable(vars.curStack).end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = ").variable(vars.arguments[0]).end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = (int)").variable(vars.operationData).string(".arguments[0]").end(); b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); - // ... - b.tree(createPushUtility(varBeh, vars)); - // ..., beh + b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - // utilstack: ..., beh - b.tree(createPushUtility(varEndLabel, vars)); - // utilstack ..., beh, endLabel + b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); return b.build(); } @@ -461,16 +449,9 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - - // utilstack ..., beh, endLabel - b.tree(createPeekUtility(varEndLabel, vars, 0)); - b.tree(createPeekUtility(varBeh, vars, 1)); - - b.startStatement().variable(varBeh).string(".endBci = ").variable(vars.bci).end(); + b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".endBci = ").variable(vars.bci).end(); - b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); b.end().startElseBlock(); @@ -486,15 +467,8 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 1").end(); b.startBlock(); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - - // utilstack ..., beh, endLabel - b.tree(createPeekUtility(varEndLabel, vars, 0)); - b.tree(createPeekUtility(varBeh, vars, 1)); - - b.startAssign(vars.curStack).variable(varBeh).string(".startStack").end(); - b.startStatement().variable(varBeh).string(".handlerBci = ").variable(vars.bci).end(); + b.startAssign(vars.curStack).tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".startStack").end(); + b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".handlerBci = ").variable(vars.bci).end(); b.end(); @@ -504,12 +478,8 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { @Override public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - b.tree(createPopUtility(varEndLabel, vars)); - b.tree(createPopUtility(varBeh, vars)); - b.tree(createEmitLabel(vars, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); return b.build(); } @@ -519,42 +489,23 @@ public static class Instrumentation extends Block { public Instrumentation(OperationsContext builder, int id) { super(builder, "Instrumentation", id); } - } - protected static final CodeTree createPopUtility(TypeMirror type, BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "pop").end().build(); - } - - protected static final CodeTree createPopUtility(CodeVariableElement target, BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().declaration(target.asType(), target.getName(), createPopUtility(target.asType(), vars)).build(); - } - - protected static final CodeTree createPushUtility(CodeVariableElement target, BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().startStatement().startCall(vars.stackUtility, "push").variable(target).end(2).build(); + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + // TODO Auto-generated method stub + return super.createBeginCode(vars); + } } - /** - * 0 = TOS, 1 = TOS-1, ... - * - * @param target - * @param vars - * @param offset - * @return - */ - protected static final CodeTree createPeekUtility(CodeVariableElement target, BuilderVariables vars, int offset) { - return CodeTreeBuilder.createBuilder().declaration(target.asType(), target.getName(), createPeekUtility(target.asType(), vars, offset)).build(); + private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { + return CodeTreeBuilder.createBuilder().startStatement()// + .variable(vars.operationData).string(".aux[" + index + "] = ") // + .tree(value) // + .end().build(); } - protected static final CodeTree createPeekUtility(TypeMirror type, BuilderVariables vars, int offset) { - if (offset == 0) { - return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "peek").end().build(); - } else { - return CodeTreeBuilder.createBuilder().cast(type).startCall(vars.stackUtility, "get") // - .startGroup() // - .startCall(vars.stackUtility, "size").end() // - .string(" - " + (offset + 1)) // - .end(2).build(); - } + private static final CodeTree createGetAux(BuilderVariables vars, int index, TypeMirror cast) { + return CodeTreeBuilder.createBuilder().string("(").cast(cast).variable(vars.operationData).string(".aux[" + index + "]").string(")").build(); } protected final CodeTree createPopLastChildCode(BuilderVariables vars) { @@ -562,7 +513,7 @@ protected final CodeTree createPopLastChildCode(BuilderVariables vars) { b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); b.startBlock(); // { - b.tree(createEmitInstruction(vars, builder.commonPop)); + b.tree(createEmitInstruction(vars, builder.commonPop, new CodeTree[0])); b.end(); // } return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 3aeb4ec076db..e3ad903fceae 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -3,6 +3,7 @@ import java.util.List; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; @@ -24,7 +25,32 @@ public static String toScreamCase(String s) { return s.replaceAll("([a-z])([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); } + public static CodeTree createEmitInstructionFromOperation(BuilderVariables vars, Instruction instr) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + CodeVariableElement[] args = new CodeVariableElement[instr.arguments.length]; + for (int i = 0; i < instr.arguments.length; i++) { + TypeMirror tgtType = instr.arguments[i].toBuilderArgumentType(); + b.declaration(tgtType, "arg_" + i, CodeTreeBuilder.createBuilder()// + .maybeCast(ProcessorContext.getInstance().getType(Object.class), tgtType)// + .string("operationData.arguments[" + i + "]").build()); + args[i] = new CodeVariableElement(ProcessorContext.getInstance().getType(Object.class), "arg_" + i); + } + + b.tree(createEmitInstruction(vars, instr, args)); + return b.build(); + } + public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement... arguments) { + CodeTree[] trees = new CodeTree[arguments.length]; + for (int i = 0; i < trees.length; i++) { + trees[i] = CodeTreeBuilder.singleVariable(arguments[i]); + } + + return createEmitInstruction(vars, instr, trees); + } + + public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeTree... arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign(vars.curStack).variable(vars.curStack).string(" + ").tree(instr.createStackEffect(vars, arguments)).end(); b.startIf().variable(vars.maxStack).string(" < ").variable(vars.curStack).end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index a6aa45a1e23f..f4704ce39d46 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -9,6 +9,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -195,17 +196,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(typBuilderImpl, simpleName + "BytecodeNode"); typBuilderImpl.add(builderBytecodeNodeType); - CodeVariableElement fldChildIndexStack = createStackField("childIndex", context.getType(Integer.class)); - typBuilderImpl.add(fldChildIndexStack); - - CodeVariableElement fldArgumentStack = createStackField("argument", new ArrayCodeTypeMirror(context.getType(Object.class))); - typBuilderImpl.add(fldArgumentStack); - - CodeVariableElement fldTypeStack = createStackField("type", context.getType(Integer.class)); - typBuilderImpl.add(fldTypeStack); - - CodeVariableElement fldUtilityStack = createStackField("utility", context.getType(Object.class)); - typBuilderImpl.add(fldUtilityStack); + CodeVariableElement fldOperationData = new CodeVariableElement(types.BuilderOperationData, "operationData"); + typBuilderImpl.add(fldOperationData); CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); typBuilderImpl.add(fldBc); @@ -283,7 +275,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.bc = fldBc; vars.bci = fldBci; vars.lastChildPushCount = fldLastPush; - vars.stackUtility = fldUtilityStack; + vars.operationData = fldOperationData; vars.consts = fldConstPool; vars.maxStack = fldMaxStack; vars.curStack = fldCurStack; @@ -304,11 +296,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (FLAG_NODE_AST_PRINTING) { b.startAssign(fldIndent).string("0").end(); } - b.startStatement().startCall(fldChildIndexStack.getName(), "clear").end(2); - b.startStatement().startCall(fldChildIndexStack.getName(), "add").string("0").end(2); - b.startStatement().startCall(fldArgumentStack.getName(), "clear").end(2); - b.startStatement().startCall(fldTypeStack.getName(), "clear").end(2); - b.startStatement().startCall(fldTypeStack.getName(), "add").string("0").end(2); + b.startAssign(fldOperationData).startNew(types.BuilderOperationData).string("null").string("0").string("0").end(2); b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); b.startAssign("nodeName").string("null").end(); @@ -328,7 +316,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mBuild.getBuilder(); - b.startIf().string(fldChildIndexStack.getName() + ".size() != 1").end(); + b.startIf().string(fldOperationData.getName() + ".depth != 0").end(); b.startBlock(); b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("Not all operations ended").end(2); b.end(); @@ -477,11 +465,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "childIndexStack.peek()"); + b.declaration("int", varChildIndex.getName(), "operationData.numChildren"); vars.childIndex = varChildIndex; - b.startSwitch().startCall(fldTypeStack, "peek").end(2); + b.startSwitch().variable(fldOperationData).string(".operationId").end(2); b.startBlock(); for (Operation parentOp : m.getOperations()) { @@ -493,8 +481,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); -// b.statement("System.out.println(\"\\n## beforechild " + parentOp.name + " \" + childIndex)"); - b.tree(afterChild); b.statement("break"); @@ -513,12 +499,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "childIndexStack.pop()"); - b.startStatement().startCall(fldChildIndexStack, "push").string(varChildIndex.getName() + " + 1").end(2); + b.declaration("int", varChildIndex.getName(), "operationData.numChildren++"); vars.childIndex = varChildIndex; - b.startSwitch().startCall(fldTypeStack, "peek").end(2); + b.startSwitch().variable(fldOperationData).string(".operationId").end(2); b.startBlock(); for (Operation parentOp : m.getOperations()) { @@ -530,8 +515,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); -// b.statement("System.out.println(\"\\n## afterchild " + parentOp.name + " \" + childIndex)"); - b.tree(afterChild); b.statement("break"); @@ -565,12 +548,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { { // doBeforeChild(); - // typeStack.push(ID); - // childIndexStack.push(0); - - // Object[] args = new Object[...]; - // args[x] = arg_x;... - // argumentStack.push(args); + // operationData = new ...(operationData, ID, , args...); // << begin >> @@ -583,33 +561,27 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("doBeforeChild()"); - b.startStatement().startCall(fldTypeStack, "push").variable(op.idConstantField).end(2); - b.startStatement().startCall(fldChildIndexStack, "push").string("0").end(2); + b.startAssign(fldOperationData).startNew(types.BuilderOperationData); - vars.arguments = metBegin.getParameters().toArray(new CodeVariableElement[0]); + b.variable(fldOperationData); + b.variable(op.idConstantField); + b.string("" + op.getNumAuxValues()); - if (vars.arguments.length > 0) { - b.declaration("Object[]", "args", "new Object[" + vars.arguments.length + "]"); - for (int i = 0; i < vars.arguments.length; i++) { - b.statement("args[" + i + "] = " + vars.arguments[i].getName()); - } - - b.startStatement().startCall(fldArgumentStack, "push").string("args").end(2); + for (VariableElement el : metBegin.getParameters()) { + b.variable(el); } - b.tree(op.createBeginCode(vars)); - - vars.arguments = null; + b.end(2); + b.tree(op.createBeginCode(vars)); } { - // assert typeStack.pop() == ID; - // int numChildren = childIndexStack.pop(); - // Object[] args = argumentsStack.pop(); - // Object arg_x = (...) args[x]; ... + // if (operationData.id != ID) throw; // << end >> + // operationData = operationData.parent; + // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); @@ -618,18 +590,16 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("indent--"); } - b.declaration("int", "typePop", CodeTreeBuilder.createBuilder().startCall(fldTypeStack, "pop").end().build()); - - b.startIf().string("typePop != ").variable(op.idConstantField).end(); + b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); b.startBlock(); b.startThrow().startNew(context.getType(IllegalStateException.class))// .startGroup()// .doubleQuote("Mismatched begin/end, expected ")// - .string(" + typePop").end(3); + .string(" + operationData.operationId").end(3); b.end(); vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); - b.declaration("int", "numChildren", "childIndexStack.pop()"); + b.declaration("int", "numChildren", "operationData.numChildren"); if (!op.isVariableChildren()) { b.startIf().string("numChildren != " + op.children).end(); @@ -651,42 +621,17 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.end(); } - List argInfo = op.getArguments(); - - if (argInfo.size() > 0) { - if (metBegin.getParameters().size() > 0) { - // some non-implicit parameters - b.declaration("Object[]", "args", fldArgumentStack.getName() + ".pop()"); - } - - CodeVariableElement[] varArgs = new CodeVariableElement[argInfo.size()]; - for (int i = 0; i < argInfo.size(); i++) { - if (argInfo.get(i).isImplicit()) - continue; - - // TODO: this does not work with mixing implicit and real args - - varArgs[i] = new CodeVariableElement(argInfo.get(i).toBuilderArgumentType(), "arg_" + i); - - CodeTreeBuilder b2 = CodeTreeBuilder.createBuilder(); - b2.maybeCast(context.getType(Object.class), argInfo.get(i).toBuilderArgumentType()); - b2.string("args[" + i + "]"); - - b.declaration(argInfo.get(i).toBuilderArgumentType(), "arg_" + i, b2.build()); - } - - vars.arguments = varArgs; - } - b.tree(op.createEndCode(vars)); + CodeTree lastPush = op.createPushCountCode(vars); if (lastPush != null) { b.startAssign(fldLastPush).tree(lastPush).end(); } + b.startAssign(fldOperationData).variable(fldOperationData).string(".parent").end(); + b.statement("doAfterChild()"); - vars.arguments = null; vars.numChildren = null; } @@ -699,15 +644,26 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } - vars.arguments = metEmit.getParameters().toArray(new CodeVariableElement[0]); + CodeTreeBuilder b2 = CodeTreeBuilder.createBuilder(); + b2.startNew(types.BuilderOperationData); + + b2.variable(fldOperationData); + b2.variable(op.idConstantField); + b2.string("" + op.getNumAuxValues()); + for (VariableElement v : metEmit.getParameters()) { + b2.variable(v); + } + + b2.end(); + + CodeVariableElement opData = new CodeVariableElement(types.BuilderOperationData, "opData"); + b.declaration(types.BuilderOperationData, "opData", b2.build()); b.statement("doBeforeChild()"); b.tree(op.createBeginCode(vars)); b.tree(op.createEndCode(vars)); b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); b.statement("doAfterChild()"); - - vars.arguments = null; } typBuilderImpl.add(metEmit); } From 4bf9216783705c916a85e016487ab87a34094295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 24 Mar 2022 15:00:29 +0100 Subject: [PATCH 024/312] [wip] 2 --- truffle/mx.truffle/suite.py | 2 +- .../test/example/TestLanguageBackend.java | 8 + .../example/TestOperationsParserTest.java | 13 +- .../api/operation/BuilderOperationData.java | 6 +- .../api/operation/BuilderOperationLabel.java | 105 --- .../api/operation/OperationsBuilder.java | 147 +++- .../operation/OperationsInstrumentTree.java | 44 ++ .../OperationsInstrumentableNode.java | 27 + .../operation/tracing/ExecutionTracer.java | 2 + .../truffle/dsl/processor/TruffleTypes.java | 2 +- .../dsl/processor/operations/Argument.java | 204 ------ .../dsl/processor/operations/Instruction.java | 555 --------------- .../dsl/processor/operations/Operation.java | 224 ++++-- .../operations/OperationGeneratorUtils.java | 96 +-- .../OperationsBytecodeCodeGenerator.java | 658 ++++++++++++++++++ .../operations/OperationsCodeGenerator.java | 592 ++++------------ .../operations/OperationsContext.java | 52 +- .../processor/operations/OperationsData.java | 1 + .../operations/SingleOperationData.java | 4 +- .../instructions/BranchInstruction.java | 40 ++ .../ConditionalBranchInstruction.java | 35 + .../instructions/CustomInstruction.java | 75 ++ .../instructions/DiscardInstruction.java | 17 + .../operations/instructions/Instruction.java | 450 ++++++++++++ .../InstrumentationEnterInstruction.java | 29 + .../InstrumentationExitInstruction.java | 46 ++ .../InstrumentationLeaveInstruction.java | 48 ++ .../instructions/SuperInstruction.java | 158 +++++ .../instructions/TransferInstruction.java | 18 + .../truffle/sl/operations/SLOperations.java | 1 - 30 files changed, 2145 insertions(+), 1514 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 28be2738ce53..f2e64e0f5300 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -282,7 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception"], + "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", "com.oracle.truffle.api.instrumentation"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java index 6f0ef80a4640..6687c4d11bb9 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation.test.example; +import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; import com.oracle.truffle.api.operation.test.example.TestLanguageAst.ListNode; import com.oracle.truffle.api.operation.test.example.TestLanguageAst.NumberNode; import com.oracle.truffle.api.operation.test.example.TestLanguageAst.SymbolNode; @@ -144,6 +145,13 @@ private void buildList(ListNode ast) { build(ast.get(1)); b.endReturn(); break; + case "stmt": + b.beginInstrumentation(StatementTag.class); + for (int i = 1; i < ast.size(); i++) { + build(ast.get(i)); + } + b.endInstrumentation(); + break; case "fail": if (ast.size() != 1) { throw new IllegalArgumentException("fail expects no arguments"); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index f5d81a4eff15..1aa184d978d8 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -151,7 +151,7 @@ public void testStacktrace() { } } - @Test + // @Test public void testTracing() { //@formatter:off String src = "(do" @@ -172,4 +172,15 @@ public void testTracing() { new Tester(src).test(495000L); ExecutionTracer.get().dump(); } + + @Test + public void testInstrumentation() { + //@formatter:off + String src = "(stmt" + + " (return (add 1 2)))"; + //@formatter:on + + new Tester(src, true).test(3L); + ExecutionTracer.get().dump(); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index a0c198bcb72f..165e2f91899d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -3,16 +3,20 @@ public class BuilderOperationData { public final BuilderOperationData parent; public final int depth; + public final int stackDepth; public final int operationId; + public final boolean needsLeave; public final Object[] aux; public final Object[] arguments; public int numChildren = 0; - public BuilderOperationData(BuilderOperationData parent, int id, int numAux, Object... arguments) { + public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { this.parent = parent; this.depth = parent == null ? 0 : parent.depth + 1; this.operationId = id; + this.stackDepth = stackDepth; this.aux = new Object[numAux]; + this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); this.arguments = arguments; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java deleted file mode 100644 index 9b40cb5e0c7f..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.oracle.truffle.api.operation; - -import java.util.ArrayList; -import java.util.List; - -import com.oracle.truffle.api.memory.ByteArraySupport; - -// not public api -public abstract class BuilderOperationLabel extends OperationLabel { - private boolean marked = false; - private ArrayList targetBci = new ArrayList<>(); - private ArrayList targets = new ArrayList<>(); - private ArrayList targetDataList = new ArrayList<>(); - - private boolean hasValue = false; - - private int value = 0; - private BuilderOperationData valueData; - - public void resolve(byte[] bc, int labelValue, BuilderOperationData data) { - assert !hasValue; - - hasValue = true; - value = labelValue; - valueData = data; - - List leaveList = new ArrayList<>(); - List leaveDataList = new ArrayList<>(); - - for (int i = 0; i < targets.size(); i++) { - int target = targets.get(i); - BuilderOperationData targetData = targetDataList.get(i); - - createBranch(labelValue, data, target, targetData, leaveList, leaveDataList); - } - - for (int j = 0; j < leaveList.size(); j++) { - createLeaveCode(leaveList.get(j), leaveDataList.get(j)); - } - } - - protected abstract void createLeaveCode(int bci, BuilderOperationData data); - - private final void createBranch(int from, BuilderOperationData fromData, int to, BuilderOperationData toData, List leaveCodeLocation, List leaveData) { - if (fromData.depth < toData.depth) { - throw new IllegalStateException("illegal jump to deeper operation"); - } - - BuilderOperationData current = fromData; - for (int i = fromData.depth; i > toData.depth; i--) { - leaveCodeLocation.add(from); - leaveData.add(current); - - current = current.parent; - } - - if (current != toData) { - throw new IllegalStateException("illegal jump to non-parent operation"); - } - } - - /** - * 01234| -----> |56789 <------> length ^ from offset - */ - public void relocate(byte[] bc, int from, int length) { - for (int i = 0; i < targets.size(); i++) { - if (targetBci.get(i) >= from) { - targetBci.set(i, targetBci.get(i) + length); - } - if (targets.get(i) >= from) { - targets.set(i, targets.get(i) + length); - } - } - - if (hasValue) { - if (value >= from) { - value += length; - } - - for (int i = 0; i < targets.size(); i++) { - putDestination(bc, targets.get(i), value); - } - - } - } - - public void setMarked() { - assert !marked; - marked = true; - } - - public void putValue(byte[] bc, int bci) { - if (hasValue) { - putDestination(bc, bci, value); - } else { - if (toBackfill == null) - toBackfill = new ArrayList<>(); - toBackfill.add(bci); - } - } - - private static void putDestination(byte[] bc, int bci, int value) { - ByteArraySupport.littleEndian().putShort(bc, bci, (short) value); - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 2bdc5f7dcf97..3c646e211d05 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,19 +1,51 @@ package com.oracle.truffle.api.operation; +import java.util.ArrayList; +import java.util.Set; import java.util.function.Supplier; +import javax.swing.text.html.HTML.Tag; + +import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.source.Source; public abstract class OperationsBuilder { - public abstract OperationsNode build(); + private ArrayList builtNodes = new ArrayList<>(); + + protected abstract OperationsNode buildImpl(); - public abstract void reset(); + protected static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - public abstract OperationsNode[] collect(); + public final OperationsNode build() { + OperationsNode result = buildImpl(); + builtNodes.add(result); + return result; + } + + public final OperationsNode[] collect() { + return builtNodes.toArray(new OperationsNode[builtNodes.size()]); + } protected String nodeName = null; protected boolean isInternal = false; + protected int maxLocals = -1; + protected int instrumentationId = 0; + + public void reset() { + nodeName = null; + isInternal = false; + labelFills.clear(); + maxLocals = -1; + instrumentationId = 0; + } + + protected final Object trackLocalsHelper(Object value) { + if (maxLocals < (int) value) { + maxLocals = (int) value; + } + return value; + } public final void setNodeName(String nodeName) { if (this.nodeName != null) { @@ -29,6 +61,113 @@ public final void setInternal() { isInternal = true; } + // ------------------------ labels ------------------------ + + private static class LabelFill { + int locationBci; + BuilderOperationLabel label; + + public LabelFill(int locationBci, BuilderOperationLabel label) { + this.locationBci = locationBci; + this.label = label; + } + } + + private final ArrayList labelFills = new ArrayList<>(); + private final ArrayList labels = new ArrayList<>(); + + protected final void relocateLabels(int bci, int length) { + for (LabelFill fill : labelFills) { + if (fill.locationBci >= bci) { + fill.locationBci += length; + } + } + + for (BuilderOperationLabel label : labels) { + if (label.hasValue && label.targetBci >= bci) { + label.targetBci += length; + } + } + } + + protected final void createOffset(int locationBci, Object label) { + LabelFill fill = new LabelFill(locationBci, (BuilderOperationLabel) label); + labelFills.add(fill); + } + + protected final void labelPass(byte[] bc) { + for (LabelFill fill : labelFills) { + LE_BYTES.putShort(bc, fill.locationBci, (short) fill.label.targetBci); + } + } + + protected BuilderOperationData operationData = null; + + public final OperationLabel createLabel() { + BuilderOperationLabel label = new BuilderOperationLabel(operationData); + labels.add(label); + return label; + } + + protected abstract void doLeaveOperation(BuilderOperationData data); + + protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationLabel toLabel) { + calculateLeaves(fromData, toLabel.data); + } + + protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { + if (toData != null && fromData.depth < toData.depth) { + throw new UnsupportedOperationException("illegal jump to deeper operation"); + } + + BuilderOperationData cur = fromData; + while ((toData == null && cur != null) || cur.depth > toData.depth) { + doLeaveOperation(cur); + cur = cur.parent; + } + + if (cur != toData) { + throw new UnsupportedOperationException("illegal jump to non-parent operation"); + } + } + + /** + * Emits offset at current bci + * + * @param bci + * @param instr + * @param label + * @return length of the offset + */ + protected final int doBranchInstruction(int bci, int instr, OperationLabel label) { + createOffset(bci, (BuilderOperationLabel) label); + return 2; + } + + protected static class BuilderOperationLabel extends OperationLabel { + BuilderOperationData data; + boolean hasValue = false; + int targetBci = 0; + + public BuilderOperationLabel(BuilderOperationData data) { + this.data = data; + } + } + + protected void doEmitLabel(int bci, OperationLabel label) { + BuilderOperationLabel lbl = (BuilderOperationLabel) label; + if (lbl.hasValue) { + throw new UnsupportedOperationException("label already emitted"); + } + if (operationData != lbl.data) { + throw new UnsupportedOperationException("label must be created and emitted inside same operation"); + } + lbl.hasValue = true; + lbl.targetBci = bci; + } + + // ------------------------ source sections ------------------------ + public abstract void beginSource(Source source); public abstract void beginSource(Supplier supplier); @@ -38,4 +177,6 @@ public final void setInternal() { public abstract void beginSourceSection(int start); public abstract void endSourceSection(int length); + + // ------------------------ instrumentation ------------------------ } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java new file mode 100644 index 000000000000..648000d41acd --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java @@ -0,0 +1,44 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.nodes.Node; + +public class OperationsInstrumentTree extends Node implements InstrumentableNode { + + private static class Wrapper extends OperationsInstrumentTree implements WrapperNode { + private final Node delegateNode; + private final ProbeNode probeNode; + + public Wrapper(Node delegateNode, ProbeNode probeNode) { + this.delegateNode = delegateNode; + this.probeNode = probeNode; + } + + public Node getDelegateNode() { + return delegateNode; + } + + public ProbeNode getProbeNode() { + return probeNode; + } + + @Override + public ProbeNode getTreeProbeNode() { + return probeNode; + } + } + + public boolean isInstrumentable() { + return true; + } + + public WrapperNode createWrapper(ProbeNode probe) { + return new Wrapper(this, probe); + } + + public ProbeNode getTreeProbeNode() { + return null; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java new file mode 100644 index 000000000000..e45ab1f3cae3 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java @@ -0,0 +1,27 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; + +public abstract class OperationsInstrumentableNode extends OperationsNode { + + @Children OperationsInstrumentTree[] instrumentTree; + + protected OperationsInstrumentableNode( + TruffleLanguage language, + Object parseContext, + String nodeName, + boolean isInternal, + int[][] sourceInfo, + Source[] sources, + int buildOrder, + int maxStack, + int maxLocals, + OperationsInstrumentTree[] instrumentTree) { + super(language, parseContext, nodeName, isInternal, sourceInfo, sources, buildOrder, maxStack, maxLocals); + this.instrumentTree = instrumentTree; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index e189e750727c..ae45c6ed191a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,6 +1,7 @@ package com.oracle.truffle.api.operation.tracing; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.oracle.truffle.api.operation.OperationsNode; @@ -97,6 +98,7 @@ public final void endFunction() { } public final void traceInstruction(int bci, int id, Object... arguments) { + // System.out.printf(" [TT] %04x %d %s\n", bci, id, List.of(a, arguments)); for (int i = 0; i < last.length; i++) { last[i] = last[i].add(id); if (last[i].isValid()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 522ded284e40..65e2e6802cf2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -225,7 +225,7 @@ public class TruffleTypes { // Operations DSL API public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; public static final String BuilderOperationData_Name = "com.oracle.truffle.api.operation.BuilderOperationData"; - public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; + public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.OperationsBuilder$BuilderOperationLabel"; public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java deleted file mode 100644 index 8031ee702f49..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Argument.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations; - -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; - -public abstract class Argument { - - public final int length; - - protected Argument(int length) { - this.length = length; - } - - public abstract CodeTree createBuildCode(BuilderVariables vars, CodeTree value); - - public abstract CodeTree createReadCode(ExecuteVariables vars, CodeTree offset); - - public CodeTree createReadCode(ExecuteVariables vars, int offset) { - return createReadCode(vars, CodeTreeBuilder.createBuilder().variable(vars.bci).string(" + " + offset).build()); - } - - public boolean isImplicit() { - return false; - } - - public abstract TypeMirror toBuilderArgumentType(); - - public abstract CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset); - - public static class IntegerArgument extends Argument { - public IntegerArgument(int length) { - super(length); - assert length == 1 || length == 2; - } - - @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); - if (length == 1) { - b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); - b.cast(ProcessorContext.getInstance().getType(byte.class)); - b.tree(value); - } else { - b.startCall("LE_BYTES", "putShort"); - b.variable(vars.bc); - b.variable(vars.bci); - b.startGroup(); - b.cast(ProcessorContext.getInstance().getType(byte.class)); - b.tree(value); - b.end(2); - } - b.end(); - return b.build(); - } - - @Override - public TypeMirror toBuilderArgumentType() { - return ProcessorContext.getInstance().getType(int.class); - } - - @Override - public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { - if (length == 1) { - return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").tree(offset).string("]").build(); - } else { - return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // - .variable(vars.bc) // - .tree(offset) // - .end().build(); - } - } - - @Override - public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder().startStatement() // - .startCall("sb", "append") // - .tree(createReadCode(vars, offset)) // - .end(2).build(); - } - } - - public static class VarArgsCount extends IntegerArgument { - - private final int minCount; - - public VarArgsCount(int minCount) { - super(1); - this.minCount = minCount; - } - - @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); - b.variable(vars.bc).string("[").variable(vars.bci).string("] = "); - b.cast(ProcessorContext.getInstance().getType(byte.class)); - b.startParantheses(); - b.variable(vars.numChildren).string(" - " + minCount); - b.end(2); - return b.build(); - } - - @Override - public boolean isImplicit() { - return true; - } - } - - public static class BranchTarget extends Argument { - - public BranchTarget() { - super(2); - } - - @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); - - b.startCall(CodeTreeBuilder.createBuilder().string("((BuilderOperationLabel) ").tree(value).string(")").build(), "putValue"); - - b.variable(vars.bc); - b.variable(vars.bci); - b.end(2); - return b.build(); - } - - @Override - public TypeMirror toBuilderArgumentType() { - return ProcessorContext.getInstance().getTypes().OperationLabel; - } - - @Override - public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // - .variable(vars.bc) // - .tree(offset) // - .end().build(); - } - - @Override - public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder().startStatement() // - .startCall("sb", "append") // - .startCall("String", "format") // - .doubleQuote("%04x") // - .tree(createReadCode(vars, offset)) // - .end(3).build(); - } - } - - public static class Const extends Argument { - public Const() { - super(2); - } - - @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeTree value) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); - b.startCall("LE_BYTES", "putShort"); - b.variable(vars.bc); - b.variable(vars.bci); - b.startGroup().string("(short) "); - b.startCall(vars.consts, "add"); - b.tree(value); - b.end(4); - return b.build(); - } - - @Override - public TypeMirror toBuilderArgumentType() { - return ProcessorContext.getInstance().getType(Object.class); - } - - @Override - public CodeTree createReadCode(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder().variable(vars.consts).string("[")// - .startCall("LE_BYTES", "getShort") // - .variable(vars.bc) // - .tree(offset) // - .end().string("]").build(); - } - - @Override - public CodeTree getDumpCode(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder().startStatement() // - .startCall("sb", "append") // - .startCall("String", "format") // - .doubleQuote("(%s) %s") // - .startCall(createReadCode(vars, offset), "getClass().getSimpleName").end() // - .tree(createReadCode(vars, offset)) // - .end(3).build(); - } - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java deleted file mode 100644 index 5ce7f5a7cb41..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Instruction.java +++ /dev/null @@ -1,555 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createClearStackSlot; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadLocal; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadStack; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteLocal; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteStackObject; - -import java.util.List; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeKind; -import javax.lang.model.util.ElementFilter; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeNames; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; - -public abstract class Instruction { - - public final String name; - public final int id; - public final Argument[] arguments; - - public CodeVariableElement opcodeIdField; - - public static class ExecuteVariables { - CodeTypeElement bytecodeNodeType; - - CodeVariableElement bc; - CodeVariableElement bci; - CodeVariableElement nextBci; - CodeVariableElement returnValue; - CodeVariableElement frame; - CodeVariableElement sp; - - CodeVariableElement consts; - CodeVariableElement maxStack; - CodeVariableElement handlers; - - CodeVariableElement tracer; - } - - public Instruction(String name, int id, Argument... arguments) { - this.name = name; - this.id = id; - this.arguments = arguments; - } - - public void setOpcodeIdField(CodeVariableElement opcodeIdField) { - this.opcodeIdField = opcodeIdField; - } - - public int length() { - int len = 1; - for (Argument arg : getArgumentTypes()) { - len += arg.length; - } - return len; - } - - public List getArgumentTypes() { - return List.of(arguments); - } - - public abstract CodeTree createPushCountCode(BuilderVariables vars); - - protected abstract CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2); - - public abstract CodeTree createExecuteCode(ExecuteVariables vars); - - public CodeTree createExecuteEpilogue(ExecuteVariables vars) { - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (isNormalControlFlow()) { - b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); - } - - b.statement("break"); - - return b.build(); - } - - public CodeTree createBreakCode(ExecuteVariables vars) { - return CodeTreeBuilder.createBuilder().statement("break").build(); - } - - public boolean isNormalControlFlow() { - return true; - } - - public CodeTree createBuildCode(BuilderVariables vars, CodeTree[] argValues) { - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement(); - b.variable(vars.bc).string("[").variable(vars.bci).string("++]"); - b.string(" = "); - b.variable(opcodeIdField); - b.end(); - - assert argValues.length == arguments.length; - for (int i = 0; i < arguments.length; i++) { - b.tree(arguments[i].createBuildCode(vars, argValues[i])); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + arguments[i].length).end(); - } - - return b.build(); - } - - abstract static class SimpleInstruction extends Instruction { - - private final int pushCount; - private final int popCount; - - public SimpleInstruction(String name, int id, int pushCount, int popCount, Argument... arguments) { - super(name, id, arguments); - this.pushCount = pushCount; - this.popCount = popCount; - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("" + pushCount); - } - - @Override - public CodeTree createExecuteEpilogue(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - for (int i = 0; i < (popCount - pushCount); i++) { - createClearStackSlot(vars, i); - } - - b.startAssign(vars.sp).variable(vars.sp).string(" + " + (pushCount - popCount)).end(); - b.tree(super.createExecuteEpilogue(vars)); - return b.build(); - } - } - - public static class Pop extends SimpleInstruction { - public Pop(int id) { - super("pop", id, 0, 1); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - return null; - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("-1"); - } - } - - public static class BranchFalse extends SimpleInstruction { - public BranchFalse(int id) { - super("br.false", id, 0, 1, new Argument.BranchTarget()); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("Object", "condition", createReadStack(vars, 0)); - b.startIf().string("(boolean) condition").end(); - b.startBlock(); - b.startAssign(vars.nextBci).variable(vars.bci).string(" + " + length()).end(); - b.end().startElseBlock(); - b.startAssign(vars.nextBci).tree(arguments[0].createReadCode(vars, 1)).end(); - b.end(); - - return b.build(); - } - - @Override - public boolean isNormalControlFlow() { - return false; - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("-1"); - } - } - - public static class Branch extends SimpleInstruction { - public Branch(int id) { - super("br", id, 0, 0, new Argument.BranchTarget()); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign(vars.nextBci).tree(arguments[0].createReadCode(vars, 1)).end(); - - b.startIf().variable(vars.nextBci).string(" <= ").variable(vars.bci).end(); - b.startBlock(); - b.startStatement().startStaticCall(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"), "poll")// - .string("this")// - .end(2); - b.end(); - - return b.build(); - } - - @Override - public boolean isNormalControlFlow() { - return false; - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("0"); - } - } - - public static class ConstObject extends SimpleInstruction { - public ConstObject(int id) { - super("const", id, 1, 0, new Argument.Const()); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(createWriteStackObject(vars, 1, arguments[0].createReadCode(vars, 1))); - - return b.build(); - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("1"); - } - } - - public static class Return extends SimpleInstruction { - public Return(int id) { - super("ret", id, 0, 1); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign(vars.returnValue).tree(createReadStack(vars, 0)).end(); - - return b.build(); - } - - @Override - public CodeTree createExecuteEpilogue(ExecuteVariables vars) { - return CodeTreeBuilder.createBuilder().statement("break loop").build(); - } - - @Override - public boolean isNormalControlFlow() { - return false; - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("0"); - } - } - - public static class LoadArgument extends SimpleInstruction { - public LoadArgument(int id) { - super("ldarg", id, 1, 0, new Argument.IntegerArgument(2)); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); - - CodeTree val = CodeTreeBuilder.createBuilder()// - .startCall(vars.frame, "getArguments").end()// - .string("[index]").build(); - - b.tree(createWriteStackObject(vars, 1, val)); - - return b.build(); - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("1"); - } - } - - public static class LoadLocal extends SimpleInstruction { - public LoadLocal(int id) { - super("ldloc", id, 1, 0, new Argument.IntegerArgument(2)); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); - - CodeTree val = createReadLocal(vars, CodeTreeBuilder.singleString("index")); - - b.tree(createWriteStackObject(vars, 1, val)); - - return b.build(); - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("1"); - } - } - - public static class StoreLocal extends SimpleInstruction { - public StoreLocal(int id) { - super("stloc", id, 0, 1, new Argument.IntegerArgument(2)); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("int", "index", arguments[0].createReadCode(vars, 1)); - - CodeTree val = createReadStack(vars, 0); - - b.tree(createWriteLocal(vars, CodeTreeBuilder.singleString("index"), val)); - - return b.build(); - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - return CodeTreeBuilder.singleString("-1"); - } - - @Override - public CodeTree createBuildCode(BuilderVariables vars, CodeTree[] argValues) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.maxLocal).string(" < ").tree(argValues[0]).end(); - b.startAssign(vars.maxLocal).tree(argValues[0]).end(); - b.tree(super.createBuildCode(vars, argValues)); - - return b.build(); - } - } - - public static class Custom extends Instruction { - - public final SingleOperationData data; - - public final int stackPops; - public final int stackPushes; - public final boolean isVarArgs; - - public Custom(String name, int id, SingleOperationData data, Argument... arguments) { - super(name, id, arguments); - this.data = data; - this.stackPops = data.getMainProperties().numStackValues; - this.isVarArgs = data.getMainProperties().isVariadic; - this.stackPushes = data.getMainProperties().returnsValue ? 1 : 0; - - if (data.getMainProperties().isVariadic && arguments.length == 0) - throw new IllegalArgumentException("Must have at least the VarArgCount argument"); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("" + stackPushes); - } - - @Override - public CodeTree createExecuteEpilogue(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (this.isVarArgs) { - b.startFor().string("int i = 0; i < varArgCount; i++").end(); - b.startBlock(); - b.tree(createClearStackSlot(vars, "-i - 1")); - b.end(); - - for (int i = 0; i < stackPops - 1; i++) { - b.tree(createClearStackSlot(vars, "-varArgCount - " + i)); - } - - b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops + 1) + " - varArgCount").end(); - } else { - for (int i = 0; i < stackPops - 1; i++) { - b.tree(createClearStackSlot(vars, i)); - } - - b.startAssign(vars.sp).variable(vars.sp).string(" + " + (stackPushes - stackPops)).end(); - } - - b.tree(super.createExecuteEpilogue(vars)); - - return b.build(); - } - - @Override - public CodeTree createExecuteCode(ExecuteVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - CodeTree[] vals = new CodeTree[stackPops]; - String destIndex; - if (isVarArgs) { - b.declaration("byte", "varArgCount", arguments[0].createReadCode(vars, 1)); - b.declaration("Object[]", "varArgs", "new Object[varArgCount]"); - - b.startFor().string("int i = 0; i < varArgCount; i++").end(); - b.startBlock(); - - String stackIndex = "i - varArgCount + 1"; - - b.startStatement(); - b.string("varArgs[i] = "); - b.tree(createReadStack(vars, CodeTreeBuilder.singleString(stackIndex))); - b.end(); - - b.end(); - - vals[stackPops - 1] = CodeTreeBuilder.singleString("varArgs"); - - for (int i = 1; i < stackPops; i++) { - String stackIndex2 = "- (varArgCount + " + i + " - 1)"; - vals[vals.length - 1 - i] = createReadStack(vars, CodeTreeBuilder.singleString(stackIndex2)); - } - - destIndex = (2 - stackPops) + " - varArgCount"; - - } else { - for (int i = 0; i < stackPops; i++) { - vals[vals.length - 1 - i] = createReadStack(vars, -i); - } - - destIndex = "" + (1 - stackPops); - } - - if (stackPushes > 0) { - b.declaration("Object", "result", createActualExecuteCallCode(vars, vals)); -// b.statement("System.out.println(\" " + name + " result: \" + result)"); - b.tree(createWriteStackObject(vars, destIndex, CodeTreeBuilder.singleString("result"))); - } else { - b.statement(createActualExecuteCallCode(vars, vals)); - } - - return b.build(); - } - - private CodeTree createActualExecuteCallCode(ExecuteVariables vars, CodeTree[] vals) { - String executeName = "execute" + data.getTemplateType().getSimpleName() + "_"; - - CodeTypeElement topElem = new NodeCodeGenerator().create(data.getContext(), null, data.getNodeData()).get(0); - - TypeElement typUncached = null; - ExecutableElement metExecute = null; - - outer: for (TypeElement elem : ElementFilter.typesIn(topElem.getEnclosedElements())) { - if (elem.getSimpleName().toString().equals("Uncached")) { - typUncached = elem; - for (ExecutableElement exElem : ElementFilter.methodsIn(elem.getEnclosedElements())) { - if (exElem.getSimpleName().toString().equals("execute")) { - metExecute = exElem; - break outer; - } - } - } - } - - if (metExecute == null) { - data.addError("Generated node did not have a proper execute element, what for?"); - return CodeTreeBuilder.singleString(topElem.toString()); - } - - CodeExecutableElement copy = CodeExecutableElement.clone(metExecute); - copy.setSimpleName(CodeNames.of(executeName)); - GeneratorUtils.addSuppressWarnings(ProcessorContext.getInstance(), copy, "static-method"); - copy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); - - copy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(ProcessorContext.getInstance().getTypes().CompilerDirectives_TruffleBoundary)); - - vars.bytecodeNodeType.add(copy); - - for (VariableElement elem : ElementFilter.fieldsIn(topElem.getEnclosedElements())) { - if (elem.getModifiers().contains(Modifier.STATIC) && !elem.getSimpleName().toString().equals("UNCACHED")) { - CodeVariableElement fldCopy = CodeVariableElement.clone(elem); - fldCopy.setSimpleName(CodeNames.of(data.getName() + "_" + elem.getSimpleName())); - fldCopy.setInit(((CodeVariableElement) elem).getInit()); - // fldCopy.getModifiers().remove(Modifier.STATIC); - - OperationGeneratorUtils.changeAllVariables(copy.getBodyTree(), elem, fldCopy); - - vars.bytecodeNodeType.add(fldCopy); - } - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startCall("this", copy); - - b.variable(vars.bci); - - int valIdx = 0; - - for (ParameterKind param : data.getMainProperties().parameters) { - switch (param) { - case STACK_VALUE: - case VARIADIC: - b.tree(vals[valIdx++]); - break; - case VIRTUAL_FRAME: - b.variable(vars.frame); - break; - default: - throw new UnsupportedOperationException("" + param); - } - } - - b.end(); - - return b.build(); - } - - @Override - protected CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments2) { - if (this.isVarArgs) { - return CodeTreeBuilder.singleString("(" + this.stackPushes + " - " + vars.numChildren.getName() + ")"); - } else { - return CodeTreeBuilder.singleString(this.stackPushes - this.stackPops + ""); - } - } - - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 82522b347f32..a18110e6dc5d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -2,17 +2,21 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstructionFromOperation; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.getTypes; import java.util.List; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -40,20 +44,17 @@ public void setIdConstantField(CodeVariableElement idConstantField) { } public static class BuilderVariables { - CodeVariableElement bc; - CodeVariableElement bci; - CodeVariableElement consts; - CodeVariableElement exteptionHandlers; - - CodeVariableElement operationData; - - CodeVariableElement lastChildPushCount; - CodeVariableElement childIndex; - CodeVariableElement numChildren; - - CodeVariableElement curStack; - CodeVariableElement maxStack; - CodeVariableElement maxLocal; + public CodeVariableElement bc; + public CodeVariableElement bci; + public CodeVariableElement consts; + public CodeVariableElement exteptionHandlers; + public CodeVariableElement operationData; + public CodeVariableElement lastChildPushCount; + public CodeVariableElement childIndex; + public CodeVariableElement numChildren; + public CodeVariableElement curStack; + public CodeVariableElement maxStack; + public CodeVariableElement keepingInstrumentation; } public int minimumChildren() { @@ -61,13 +62,7 @@ public int minimumChildren() { return 0; } - public List getArguments() { - return List.of(); - } - - public final List getBuilderArgumentTypes() { - return getArguments().stream().map(x -> x.toBuilderArgumentType()).toList(); - } + public abstract List getBuilderArgumentTypes(); public CodeTree createBeginCode(BuilderVariables vars) { return null; @@ -89,45 +84,16 @@ public CodeTree createLeaveCode(BuilderVariables vars) { return null; } + public boolean hasLeaveCode() { + return false; + } + public int getNumAuxValues() { return 0; } public abstract CodeTree createPushCountCode(BuilderVariables vars); - public static class Custom extends Operation { - final Instruction.Custom instruction; - - protected Custom(OperationsContext builder, String name, int id, int children, Instruction.Custom instruction) { - super(builder, name, id, instruction.isVarArgs ? VARIABLE_CHILDREN : children); - this.instruction = instruction; - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return instruction.createPushCountCode(vars); - } - - @Override - public List getArguments() { - return instruction.getArgumentTypes(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - return createEmitInstructionFromOperation(vars, instruction); - } - - @Override - public int minimumChildren() { - if (instruction.isVarArgs) { - return instruction.stackPops - 1; - } else { - return super.minimumChildren(); - } - } - } - public static class Simple extends Operation { private final Instruction instruction; @@ -139,21 +105,31 @@ protected Simple(OperationsContext builder, String name, int id, int children, I @Override public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + CodeTree[] arguments = new CodeTree[instruction.inputs.length + instruction.results.length]; - b.tree(createEmitInstructionFromOperation(vars, instruction)); + List mirs = getBuilderArgumentTypes(); + for (int i = 0; i < arguments.length; i++) { + arguments[i] = CodeTreeBuilder.createBuilder().string("operationData.arguments[" + i + "]").build(); + } + + return instruction.createEmitCode(vars, arguments); - return b.build(); } @Override public CodeTree createPushCountCode(BuilderVariables vars) { - return this.instruction.createPushCountCode(vars); + int result = 0; + for (int i = 0; i < instruction.results.length; i++) { + if (instruction.results[i] == ResultType.STACK_VALUE) { + result++; + } + } + return CodeTreeBuilder.singleString("" + result); } @Override - public List getArguments() { - return instruction.getArgumentTypes(); + public List getBuilderArgumentTypes() { + return instruction.getBuilderArgumentTypes(); } } @@ -172,11 +148,11 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().variable(vars.childIndex).string(" != 0").end(); - b.startBlock(); // { - - b.tree(createPopLastChildCode(vars)); - - b.end(); // } + b.startBlock(); + { + b.tree(createPopLastChildCode(vars)); + } + b.end(); return b.build(); } @@ -185,6 +161,11 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { public CodeTree createPushCountCode(BuilderVariables vars) { return null; // does not change it at all } + + @Override + public List getBuilderArgumentTypes() { + return List.of(); + } } public static class IfThen extends Operation { @@ -228,6 +209,11 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("0"); } + + @Override + public List getBuilderArgumentTypes() { + return List.of(); + } } public static class IfThenElse extends Operation { @@ -310,6 +296,11 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { return b.build(); } + + @Override + public List getBuilderArgumentTypes() { + return List.of(); + } } public static class While extends Operation { @@ -373,6 +364,11 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("0"); } + + @Override + public List getBuilderArgumentTypes() { + return List.of(); + } } public static class Label extends Operation { @@ -391,8 +387,8 @@ public CodeTree createEndCode(BuilderVariables vars) { } @Override - public List getArguments() { - return List.of(new Argument.BranchTarget()); + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getTypes().OperationLabel); } } @@ -402,7 +398,7 @@ public TryCatch(OperationsContext builder, int id) { } private static final int AUX_BEH = 0; - private static final int AUX_END_LABEL = 0; + private static final int AUX_END_LABEL = 1; @Override public int getNumAuxValues() { @@ -414,11 +410,6 @@ public CodeTree createPushCountCode(BuilderVariables vars) { return CodeTreeBuilder.singleString("0"); } - @Override - public List getArguments() { - return List.of(new Argument.IntegerArgument(2)); - } - @Override public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -483,17 +474,96 @@ public CodeTree createEndCode(BuilderVariables vars) { return b.build(); } + + @Override + public List getBuilderArgumentTypes() { + return List.of(new CodeTypeMirror(TypeKind.INT)); + } } public static class Instrumentation extends Block { - public Instrumentation(OperationsContext builder, int id) { + private final Instruction startInstruction; + private final Instruction endInstruction; + private final Instruction endVoidInstruction; + private final Instruction leaveInstruction; + + public Instrumentation(OperationsContext builder, int id, Instruction startInstruction, Instruction endInstruction, Instruction endVoidInstruction, Instruction leaveInstruction) { super(builder, "Instrumentation", id); + this.startInstruction = startInstruction; + this.endInstruction = endInstruction; + this.endVoidInstruction = endVoidInstruction; + this.leaveInstruction = leaveInstruction; + } + + private static final int AUX_ID = 0; + private static final int AUX_START_LABEL = 1; + private static final int AUX_END_LABEL = 2; + + @Override + public int getNumAuxValues() { + return 3; + } + + @Override + public List getBuilderArgumentTypes() { + ProcessorContext context = ProcessorContext.getInstance(); + return List.of(context.getType(Class.class)); } @Override public CodeTree createBeginCode(BuilderVariables vars) { - // TODO Auto-generated method stub - return super.createBeginCode(vars); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + CodeVariableElement varCurInstrumentId = new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "curInstrumentId"); + CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + + b.declaration("int", varCurInstrumentId.getName(), "instrumentationId++"); + b.declaration(getTypes().BuilderOperationLabel, varStartLabel.getName(), createCreateLabel()); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + + b.tree(createEmitLabel(vars, varStartLabel)); + + b.tree(createSetAux(vars, AUX_ID, CodeTreeBuilder.singleVariable(varCurInstrumentId))); + b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); + b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); + + b.tree(createEmitInstruction(vars, startInstruction, varCurInstrumentId)); + + b.tree(super.createBeginCode(vars)); + return b.build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().variable(vars.lastChildPushCount).string(" != 0").end(); + b.startBlock(); + b.tree(createEmitInstruction(vars, endInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); + b.end().startElseBlock(); + b.tree(createEmitInstruction(vars, endVoidInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); + b.end(); + + b.tree(super.createEndCode(vars)); + return b.build(); + } + + @Override + public CodeTree createLeaveCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(createEmitInstruction(vars, leaveInstruction, + createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)), + createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel), + createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + + return b.build(); + } + + @Override + public boolean hasLeaveCode() { + return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index e3ad903fceae..c787ed0d30ab 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -3,17 +3,15 @@ import java.util.List; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTreeKind; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; public class OperationGeneratorUtils { @@ -25,22 +23,6 @@ public static String toScreamCase(String s) { return s.replaceAll("([a-z])([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); } - public static CodeTree createEmitInstructionFromOperation(BuilderVariables vars, Instruction instr) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - CodeVariableElement[] args = new CodeVariableElement[instr.arguments.length]; - for (int i = 0; i < instr.arguments.length; i++) { - TypeMirror tgtType = instr.arguments[i].toBuilderArgumentType(); - b.declaration(tgtType, "arg_" + i, CodeTreeBuilder.createBuilder()// - .maybeCast(ProcessorContext.getInstance().getType(Object.class), tgtType)// - .string("operationData.arguments[" + i + "]").build()); - args[i] = new CodeVariableElement(ProcessorContext.getInstance().getType(Object.class), "arg_" + i); - } - - b.tree(createEmitInstruction(vars, instr, args)); - return b.build(); - } - public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement... arguments) { CodeTree[] trees = new CodeTree[arguments.length]; for (int i = 0; i < trees.length; i++) { @@ -51,91 +33,21 @@ public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction } public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeTree... arguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.curStack).variable(vars.curStack).string(" + ").tree(instr.createStackEffect(vars, arguments)).end(); - b.startIf().variable(vars.maxStack).string(" < ").variable(vars.curStack).end(); - b.startAssign(vars.maxStack).variable(vars.curStack).end(); - // b.statement("System.out.printf(\" " + instr.name + " %d %d \\n\", maxStack, curStack)"); - b.tree(instr.createBuildCode(vars, arguments)); - return b.build(); + return instr.createEmitCode(vars, arguments); } public static CodeTree createCreateLabel() { - return CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderOperationLabel).end().build(); + return CodeTreeBuilder.createBuilder().cast(getTypes().BuilderOperationLabel).startCall("createLabel").end().build(); } public static CodeTree createEmitLabel(BuilderVariables vars, CodeTree label) { - return CodeTreeBuilder.createBuilder().startStatement().startCall(label, "resolve").variable(vars.bc).variable(vars.bci).end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("doEmitLabel").variable(vars.bci).tree(label).end(2).build(); } public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElement label) { return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); } - public static CodeTree createClearStackSlot(ExecuteVariables vars, String offset) { - return CodeTreeBuilder.createBuilder() // - .startIf().tree(GeneratorUtils.createInCompiledCode()).end() // - .startBlock() // - .startStatement() // - .startCall(vars.frame, "clear") // - .startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")")// - .end(4).build(); - } - - public static CodeTree createClearStackSlot(ExecuteVariables vars, int offset) { - return createClearStackSlot(vars, "" + offset); - } - - public static CodeTree createReadStack(ExecuteVariables vars, int offset) { - return createReadStack(vars, CodeTreeBuilder.singleString("" + offset)); - } - - public static CodeTree createReadStack(ExecuteVariables vars, CodeTree offset) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (vars.tracer != null) { - b.startCall(vars.tracer, "tracePop"); - } - b.startCall(vars.frame, "getValue"); - b.startGroup().variable(vars.sp).string(" - 1 + (").tree(offset).string(")").end(); - if (vars.tracer != null) { - b.end(); - } - return b.end(2).build(); - } - - public static CodeTree createWriteStackObject(ExecuteVariables vars, int offset, CodeTree value) { - return createWriteStackObject(vars, "" + offset, value); - } - - public static CodeTree createWriteStackObject(ExecuteVariables vars, String offset, CodeTree value) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startCall(vars.frame, "setObject"); - b.startGroup().variable(vars.sp).string(" - 1 + (" + offset + ")").end(); - if (vars.tracer != null) { - b.startCall(vars.tracer, "tracePush"); - } - b.tree(value); - if (vars.tracer != null) { - b.end(); - } - return b.end(2).build(); - } - - public static CodeTree createReadLocal(ExecuteVariables vars, CodeTree offset) { - return CodeTreeBuilder.createBuilder() // - .startCall(vars.frame, "getValue") // - .startGroup().tree(offset).string(" + VALUES_OFFSET").end()// - .end(2).build(); - } - - public static CodeTree createWriteLocal(ExecuteVariables vars, CodeTree offset, CodeTree value) { - return CodeTreeBuilder.createBuilder() // - .startStatement().startCall(vars.frame, "setObject") // - .startGroup().tree(offset).string(" + VALUES_OFFSET").end() // - .tree(value) // - .end(3).build(); - } - public static CodeTree changeAllVariables(CodeTree tree, VariableElement from, VariableElement to) { // EXTREME HACK diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java new file mode 100644 index 000000000000..61327678e007 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -0,0 +1,658 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +public class OperationsBytecodeCodeGenerator { + + private final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); + private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); + private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); + private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); + private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + + private final CodeTypeElement typBuilderImpl; + private final String simpleName; + private final ProcessorContext context; + private final OperationsData m; + private final TruffleTypes types; + private final boolean withInstrumentation; + + public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { + this.typBuilderImpl = typBuilderImpl; + this.simpleName = simpleName; + this.m = m; + this.context = ProcessorContext.getInstance(); + this.types = context.getTypes(); + this.withInstrumentation = withInstrumentation; + } + + /** + * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the + * executable Truffle node. + */ + public CodeTypeElement createBuilderBytecodeNode() { + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, simpleName, types.OperationsNode); + + CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); + GeneratorUtils.addCompilationFinalAnnotation(fldBc, 1); + builderBytecodeNodeType.add(fldBc); + + CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); + GeneratorUtils.addCompilationFinalAnnotation(fldConsts, 1); + builderBytecodeNodeType.add(fldConsts); + + CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); + GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); + builderBytecodeNodeType.add(fldHandlers); + + CodeVariableElement fldProbeNodes = null; + if (withInstrumentation) { + fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.ProbeNode), "probeNodes"); + GeneratorUtils.addCompilationFinalAnnotation(fldProbeNodes, 1); + builderBytecodeNodeType.add(fldProbeNodes); + } + + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); + builderBytecodeNodeType.add(ctor); + + CodeVariableElement fldTracer = null; + CodeVariableElement fldHitCount = null; + if (m.isTracing()) { + fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); + builderBytecodeNodeType.add(fldHitCount); + + fldTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); + builderBytecodeNodeType.add(fldTracer); + } + + { + CodeTreeBuilder b = ctor.getBuilder(); + + if (m.isTracing()) { + b.startAssign(fldHitCount).startNewArray( + (ArrayType) fldHitCount.getType(), + CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); + b.end(2); + + b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get").end(2); + } + } + + { + Set copiedLibraries = new HashSet<>(); + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + continue; + } + + CustomInstruction cinstr = (CustomInstruction) instr; + SingleOperationData soData = cinstr.getData(); + + CodeTypeElement result = new NodeCodeGenerator().create(context, null, soData.getNodeData()).get(0); + + CodeExecutableElement uncExec = null; + loop: for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { + if (te.getSimpleName().toString().equals("Uncached")) { + for (ExecutableElement ex : ElementFilter.methodsIn(te.getEnclosedElements())) { + if (ex.getSimpleName().toString().equals("execute")) { + uncExec = (CodeExecutableElement) ex; + break loop; + } + } + } + } + + for (VariableElement ve : ElementFilter.fieldsIn(result.getEnclosedElements())) { + if (ve.getSimpleName().toString().equals("UNCACHED")) { + continue; + } + if (!ve.getModifiers().containsAll(MOD_PRIVATE_STATIC_FINAL)) { + continue; + } + + if (copiedLibraries.contains(ve.getSimpleName().toString())) { + continue; + } + + copiedLibraries.add(ve.getSimpleName().toString()); + + builderBytecodeNodeType.add(ve); + } + + uncExec.setSimpleName(CodeNames.of("execute" + soData.getName() + "_")); + uncExec.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + uncExec.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); + + builderBytecodeNodeType.add(uncExec); + + cinstr.setExecuteMethod(uncExec); + } + } + + ExecutionVariables vars = new ExecutionVariables(); + // vars.bytecodeNodeType = builderBytecodeNodeType; + vars.bc = fldBc; + vars.consts = fldConsts; + vars.probeNodes = fldProbeNodes; + // vars.handlers = fldHandlers; + // vars.tracer = fldTracer; + + { + CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); + builderBytecodeNodeType.add(mExecute); + + CodeTreeBuilder builder = mExecute.getBuilder(); + builder.startReturn(); + builder.startCall("continueAt"); + + builder.string("frame"); + builder.string("null"); + + builder.end(2); + + } + + { + CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); + CodeVariableElement argStartIndex = new CodeVariableElement(types.OperationLabel, "startIndex"); + CodeExecutableElement mContinueAt = new CodeExecutableElement( + Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", + argFrame, argStartIndex); + builderBytecodeNodeType.add(mContinueAt); + + { + CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); + mContinueAt.addAnnotationMirror(annExplodeLoop); + annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( + context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); + } + + CodeTreeBuilder b = mContinueAt.getBuilder(); + + CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); + CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(byte.class), "curOpcode"); + + b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); + b.declaration("int", varBci.getName(), "0"); + + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "startFunction").string("this").end(2); + } + + CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); + b.statement("Object " + varReturnValue.getName() + " = null"); + + b.string("loop: "); + b.startWhile().string("true").end(); + b.startBlock(); + CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); + b.statement("int nextBci"); + + vars.bci = varBci; + vars.nextBci = varNextBci; + vars.frame = argFrame; + vars.sp = varSp; + vars.returnValue = varReturnValue; + + b.declaration("byte", varCurOpcode.getName(), CodeTreeBuilder.singleString("bc[bci]")); + + b.startTryBlock(); + + b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); + + if (m.isTracing()) { + b.startStatement().variable(fldHitCount).string("[bci]++").end(); + } + + b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); + b.startBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); + + b.end(); + b.startSwitch().string("curOpcode").end(); + b.startBlock(); + + for (Instruction op : m.getInstructions()) { + if (op.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); + + CodeVariableElement[] varInputs = new CodeVariableElement[op.inputs.length]; + TypeMirror[] inputTypes = op.expectedInputTypes(context); + vars.inputs = varInputs; + for (int i = op.inputs.length - 1; i >= 0; i--) { + if (op.inputs[i] == InputType.STACK_VALUE_IGNORED) { + b.statement("--sp"); + continue; + } + + varInputs[i] = new CodeVariableElement(inputTypes[i], "input_" + i); + + b.declaration(varInputs[i].asType(), varInputs[i].getName(), createInputCode(vars, op, i, inputTypes[i])); + if (op.inputs[i] == InputType.VARARG_VALUE) { + b.startFor().string("int i = ").variable(varInputs[i]).string(".length - 1; i >= 0; i--").end(); + b.startBlock(); + b.startStatement().variable(varInputs[i]).string("[i] = "); + b.variable(argFrame).string(".getValue(--sp)"); + b.end(2); + } + } + + boolean hasBranch = false; + boolean hasReturn = false; + + CodeVariableElement[] varResults = new CodeVariableElement[op.results.length]; + vars.results = varResults; + for (int i = 0; i < op.results.length; i++) { + switch (op.results[i]) { + case STACK_VALUE: + case SET_LOCAL: + varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); + b.statement("Object result_" + i); + break; + case BRANCH: + hasBranch = true; + varResults[i] = varNextBci; + break; + case RETURN: + hasReturn = true; + varResults[i] = varReturnValue; + break; + } + } + + b.tree(op.createExecuteCode(vars)); + + for (int i = 0; i < op.results.length; i++) { + switch (op.results[i]) { + case STACK_VALUE: + b.startStatement().startCall(argFrame, "setObject").string("sp++").variable(varResults[i]).end(2); + break; + case SET_LOCAL: + b.startStatement().startCall(vars.frame, "setObject") // + .startGroup().string("VALUES_OFFSET + ").tree(op.createReadArgumentCode(op.inputs.length + i, vars)).end() // + .variable(varResults[i]) // + .end(2); + varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); + break; + } + } + + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceInstruction"); + b.variable(varBci); + b.variable(op.opcodeIdField); + b.doubleQuote(op.name); + + for (CodeVariableElement input : varInputs) { + if (input == null) { + b.string("null"); + } else { + b.variable(input); + } + } + + for (CodeVariableElement res : varResults) { + if (res == null) { + b.string("null"); + } else { + b.variable(res); + } + } + + b.end(2); + } + + if (!hasBranch) { + b.startAssign(varNextBci).variable(varBci).string(" + " + op.length()).end(); + } + + if (hasReturn) { + b.statement("break loop"); + } else { + b.statement("break"); + } + + b.end(); + + vars.inputs = null; + vars.results = null; + } + + b.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); + + b.end(); // switch block + + b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceException"); + b.string("ex"); + b.end(2); + + } + + b.startFor().string("int handlerIndex = 0; handlerIndex < " + fldHandlers.getName() + ".length; handlerIndex++").end(); + b.startBlock(); + + b.declaration(types.BuilderExceptionHandler, "handler", fldHandlers.getName() + "[handlerIndex]"); + b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); + b.statement("continue"); + + b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET + maxLocals").end(); + // TODO check exception type (?) + + b.startStatement().startCall(argFrame, "setObject") // + .string("VALUES_OFFSET + handler.exceptionIndex") // + .string("ex") // + .end(2); + + b.statement("bci = handler.handlerBci"); + b.statement("continue loop"); + + b.end(); // for (handlerIndex ...) + + b.startThrow().string("ex").end(); + + b.end(); // catch block + + b.statement("bci = nextBci"); + b.end(); // while block + + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "endFunction").end(2); + } + + b.startReturn().string("returnValue").end(); + + vars.bci = null; + vars.nextBci = null; + vars.frame = null; + vars.sp = null; + vars.returnValue = null; + + } + + { + CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); + builderBytecodeNodeType.add(mDump); + + CodeTreeBuilder b = mDump.getBuilder(); + + b.declaration("int", "bci", "0"); + b.declaration("StringBuilder", "sb", "new StringBuilder()"); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + b.startWhile().string("bci < bc.length").end(); + b.startBlock(); // while block + + if (m.isTracing()) { + b.statement("sb.append(String.format(\" [ %3d ]\", hitCount[bci]))"); + } + + b.statement("sb.append(String.format(\" %04x \", bci))"); + + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); + + for (Instruction op : m.getInstructions()) { + if (op.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); + + for (int i = 0; i < 4; i++) { + if (i < op.length()) { + b.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); + } else { + b.statement("sb.append(\" \")"); + } + } + + b.statement("sb.append(\"" + op.name + " \")"); + + for (int i = 0; i < op.inputs.length; i++) { + if (i != 0) { + b.statement("sb.append(\", \")"); + } + b.tree(op.inputs[i].createDumpCode(i, op, vars)); + } + + b.statement("sb.append(\" -> \")"); + + for (int i = 0; i < op.results.length; i++) { + if (i != 0) { + b.statement("sb.append(\", \")"); + } + b.tree(op.results[i].createDumpCode(i, op, vars)); + } + + b.statement("bci += " + op.length()); + b.statement("break"); + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); + b.statement("break"); + b.end(); // default case block + b.end(); // switch block + + b.statement("sb.append(\"\\n\")"); + + b.end(); // while block + + b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); + b.startBlock(); + + b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); + + b.end(); + + b.startIf().string("sourceInfo != null").end(); + b.startBlock(); + { + b.statement("sb.append(\"Source info:\\n\")"); + b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); + b.startBlock(); + + b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i]))"); + + b.end(); + } + b.end(); + + b.startReturn().string("sb.toString()").end(); + + vars.bci = null; + + } + + if (m.isTracing()) { + CodeExecutableElement mGetTrace = GeneratorUtils.override(types.OperationsNode, "getNodeTrace"); + builderBytecodeNodeType.add(mGetTrace); + + CodeTreeBuilder b = mGetTrace.getBuilder(); + + b.declaration("int", "bci", "0"); + b.declaration("ArrayList", "insts", "new ArrayList<>()"); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + b.startWhile().string("bci < bc.length").end(); + b.startBlock(); // while block + + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); + + for (Instruction op : m.getInstructions()) { + if (op.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); + + b.startStatement(); + b.startCall("insts", "add"); + b.startNew(types.InstructionTrace); + + b.variable(op.opcodeIdField); + b.startGroup().variable(fldHitCount).string("[bci]").end(); + + b.end(3); + + b.statement("bci += " + op.length()); + b.statement("break"); + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); + b.end(); // default case block + b.end(); // switch block + + b.end(); // while block + + b.startReturn().startNew(types.NodeTrace); + b.startCall("insts", "toArray").string("new InstructionTrace[0]").end(); + b.end(2); + + vars.bci = null; + } + + { + CodeExecutableElement mGetSourceSection = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); + builderBytecodeNodeType.add(mGetSourceSection); + + CodeTreeBuilder b = mGetSourceSection.createBuilder(); + + b.tree(createReparseCheck(typBuilderImpl)); + + b.startReturn(); + b.startCall("this", "getSourceSectionImpl"); + b.end(2); + } + + { + CodeVariableElement pBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeExecutableElement mGetSourceSectionAtBci = GeneratorUtils.overrideImplement(types.OperationsNode, "getSourceSectionAtBci"); + builderBytecodeNodeType.add(mGetSourceSectionAtBci); + + CodeTreeBuilder b = mGetSourceSectionAtBci.createBuilder(); + + b.tree(createReparseCheck(typBuilderImpl)); + + b.startReturn(); + b.startCall("this", "getSourceSectionAtBciImpl"); + b.variable(pBci); + b.end(2); + } + + return builderBytecodeNodeType; + } + + private CodeTree createInputCode(ExecutionVariables vars, Instruction instr, int index, TypeMirror inputType) { + switch (instr.inputs[index]) { + case ARGUMENT: + return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getArguments").end() // + .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // + .build(); + case LOCAL: + return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getValue") // + .startGroup().string("VALUES_OFFSET + ").tree(instr.createReadArgumentCode(index, vars)).end() // + .end().build(); + case CONST_POOL: + return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).variable(vars.consts) // + .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // + .build(); + case INSTRUMENT: + case BRANCH_TARGET: + return instr.createReadArgumentCode(index, vars); + case STACK_VALUE: + return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getValue") // + .startGroup().string("--").variable(vars.sp).end() // + .end().build(); + case VARARG_VALUE: + return CodeTreeBuilder.createBuilder().startNewArray( + new ArrayCodeTypeMirror(context.getType(Object.class)), + instr.createReadArgumentCode(index, vars)).end().build(); + default: + throw new IllegalArgumentException("Unsupported value: " + instr.inputs[index]); + + } + } + + private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startIf().string("sourceInfo == null").end(); + b.startBlock(); + { + b.startStatement(); + b.string("OperationsNode reparsed = "); + b.startStaticCall(typBuilderImpl.asType(), "reparse"); + b.startCall("getLanguage").typeLiteral(m.getLanguageType()).end(); + b.startGroup().cast(m.getParseContextType()).string("parseContext").end(); + b.string("buildOrder"); + b.end(2); + + b.statement("copyReparsedInfo(reparsed)"); + } + b.end(); + + return b.build(); + } + + private static TypeMirror generic(TypeElement el, TypeMirror... params) { + return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); + } + + private static TypeMirror arrayOf(TypeMirror el) { + return new ArrayCodeTypeMirror(el); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index f4704ce39d46..b17c7f35ef66 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -10,7 +10,6 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -18,8 +17,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -27,8 +24,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Instruction.ExecuteVariables; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -54,20 +51,13 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory args = op.getArguments(); + List args = op.getBuilderArgumentTypes(); ArrayList params = new ArrayList<>(); for (int i = 0; i < args.size(); i++) { - if (args.get(i).isImplicit()) { - continue; - } - - params.add(new CodeVariableElement(args.get(i).toBuilderArgumentType(), "arg" + i)); + params.add(new CodeVariableElement(args.get(i), "arg" + i)); } CodeVariableElement[] paramsArr = params.toArray(new CodeVariableElement[params.size()]); @@ -100,7 +90,7 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(metParse); CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, false)); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, false, false)); b.startStatement().startStaticCall(m.getParseMethod()); b.variable(parLanguage); b.variable(parParseContext); @@ -118,7 +108,7 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(metParse); CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, true)); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, true, true)); b.startStatement().startStaticCall(m.getParseMethod()); b.variable(parLanguage); b.variable(parParseContext); @@ -130,8 +120,13 @@ CodeTypeElement createBuilder(String simpleName) { return typBuilder; } - private static CodeTree createCreateBuilder(CodeTypeElement typBuilderImpl, CodeVariableElement language, CodeVariableElement parseContext, boolean withSourceInfo) { - return CodeTreeBuilder.createBuilder().startNew(typBuilderImpl.asType()).variable(language).variable(parseContext).string("" + withSourceInfo).end().build(); + private static CodeTree createCreateBuilder(CodeTypeElement typBuilderImpl, CodeVariableElement language, CodeVariableElement parseContext, boolean withSourceInfo, boolean withInstrumentation) { + return CodeTreeBuilder.createBuilder().startNew(typBuilderImpl.asType()) // + .variable(language) // + .variable(parseContext) // + .string("" + withSourceInfo) // + .string("" + withInstrumentation) // + .end().build(); } private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { @@ -148,6 +143,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldKeepSourceInfo = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "keepSourceInfo"); typBuilderImpl.add(fldKeepSourceInfo); + CodeVariableElement fldKeepInstrumentation = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "keepInstrumentation"); + typBuilderImpl.add(fldKeepInstrumentation); + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), typBuilderImpl); typBuilderImpl.add(ctor); @@ -190,14 +188,20 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldId); } - CodeTypeElement builderLabelImplType = createBuilderLabelImpl(simpleName + "Label"); - typBuilderImpl.add(builderLabelImplType); - - CodeTypeElement builderBytecodeNodeType = createBuilderBytecodeNode(typBuilderImpl, simpleName + "BytecodeNode"); - typBuilderImpl.add(builderBytecodeNodeType); + CodeTypeElement builderBytecodeNodeType; + CodeTypeElement builderInstrBytecodeNodeType; + { + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); + builderBytecodeNodeType = bcg.createBuilderBytecodeNode(); + typBuilderImpl.add(builderBytecodeNodeType); + } + { + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "InstrumentableBytecodeNode", m, true); + builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); + typBuilderImpl.add(builderInstrBytecodeNodeType); + } CodeVariableElement fldOperationData = new CodeVariableElement(types.BuilderOperationData, "operationData"); - typBuilderImpl.add(fldOperationData); CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); typBuilderImpl.add(fldBc); @@ -222,9 +226,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastPush"); typBuilderImpl.add(fldLastPush); - CodeVariableElement fldMaxLocal = new CodeVariableElement(context.getType(int.class), "maxLocal"); - typBuilderImpl.add(fldMaxLocal); - CodeVariableElement fldMaxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); typBuilderImpl.add(fldMaxStack); @@ -266,7 +267,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(metParse); CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parContext, true)); + b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parContext, true, true)); b.startStatement().startStaticCall(m.getParseMethod()).variable(parLanguage).variable(parContext).string("builder").end(2); b.startReturn().startCall("builder", "collect").end().string("[").variable(parBuildOrder).string("]").end(); } @@ -279,8 +280,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.consts = fldConstPool; vars.maxStack = fldMaxStack; vars.curStack = fldCurStack; - vars.maxLocal = fldMaxLocal; vars.exteptionHandlers = fldExceptionHandlers; + vars.keepingInstrumentation = fldKeepInstrumentation; { CodeExecutableElement metReset = new CodeExecutableElement( @@ -289,14 +290,16 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(metReset); CodeTreeBuilder b = metReset.getBuilder(); + + b.statement("super.reset()"); + b.startAssign(fldBci).string("0").end(); b.startAssign(fldCurStack).string("0").end(); b.startAssign(fldMaxStack).string("0").end(); - b.startAssign(fldMaxLocal).string("-1").end(); if (FLAG_NODE_AST_PRINTING) { b.startAssign(fldIndent).string("0").end(); } - b.startAssign(fldOperationData).startNew(types.BuilderOperationData).string("null").string("0").string("0").end(2); + b.startAssign(fldOperationData).startNew(types.BuilderOperationData).string("null").string("0").string("0").string("0").string("false").end(2); b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); b.startAssign("nodeName").string("null").end(); @@ -311,11 +314,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } { - CodeExecutableElement mBuild = new CodeExecutableElement(MOD_PUBLIC, types.OperationsNode, "build"); + CodeExecutableElement mBuild = new CodeExecutableElement(MOD_PUBLIC, types.OperationsNode, "buildImpl"); typBuilderImpl.add(mBuild); CodeTreeBuilder b = mBuild.getBuilder(); + b.statement("labelPass(bc)"); + b.startIf().string(fldOperationData.getName() + ".depth != 0").end(); b.startBlock(); b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("Not all operations ended").end(2); @@ -336,8 +341,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.end(); - b.startAssign("OperationsNode result"); - b.startNew(builderBytecodeNodeType.asType()); + b.statement("OperationsNode result"); + + b.startIf().variable(fldKeepInstrumentation).end(); + b.startBlock(); + + b.startAssign("result"); + b.startNew(builderInstrBytecodeNodeType.asType()); b.variable(fldLanguage); b.variable(fldParseContext); b.string("nodeName"); @@ -346,13 +356,33 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("sources"); b.variable(fldNodeNumber); b.variable(fldMaxStack); - b.startGroup().variable(fldMaxLocal).string(" + 1").end(); + b.startGroup().string("maxLocals + 1").end(); b.string("bcCopy"); b.string("cpCopy"); b.string("handlers"); + b.string("new ProbeNode[0]"); + b.end(2); + b.end().startElseBlock(); + + b.startAssign("result"); + b.startNew(builderBytecodeNodeType.asType()); + b.variable(fldLanguage); + b.variable(fldParseContext); + b.string("nodeName"); + b.string("isInternal"); + b.string("sourceInfo"); + b.string("sources"); + b.variable(fldNodeNumber); + b.variable(fldMaxStack); + b.startGroup().string("maxLocals + 1").end(); + b.string("bcCopy"); + b.string("cpCopy"); + b.string("handlers"); b.end(2); + b.end(); + b.startStatement(); b.startCall(fldBuiltNodes, "add"); b.string("result"); @@ -366,25 +396,42 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } { - CodeExecutableElement mCollect = GeneratorUtils.overrideImplement(types.OperationsBuilder, "collect"); - typBuilderImpl.add(mCollect); + // CodeVariableElement parBci = new CodeVariableElement(context.getType(int.class), + // "bci"); + CodeVariableElement parData = new CodeVariableElement(types.BuilderOperationData, "data"); + CodeExecutableElement mDoLeave = GeneratorUtils.overrideImplement(types.OperationsBuilder, "doLeaveOperation"); + typBuilderImpl.add(mDoLeave); - CodeTreeBuilder b = mCollect.getBuilder(); + CodeTreeBuilder b = mDoLeave.createBuilder(); - b.startReturn(); - b.startCall(fldBuiltNodes, "toArray"); - b.string("new OperationsNode[builtNodes.size()]"); - b.end(2); - } + b.startWhile().variable(vars.curStack).string(" > data.stackDepth").end(); + b.startBlock(); - { - CodeExecutableElement mCreateLabel = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); - typBuilderImpl.add(mCreateLabel); + b.tree(m.getOperationsContext().commonPop.createEmitCode(vars, new CodeTree[0])); + + b.end(); + + b.startSwitch().string("data.operationId").end(); + b.startBlock(); + + for (Operation op : m.getOperations()) { + CodeTree leaveCode = op.createLeaveCode(vars); + if (leaveCode == null) { + continue; + } + + b.startCase().variable(op.idConstantField).end(); + b.startBlock(); + + b.tree(leaveCode); + b.statement("break"); + + b.end(); + + } + + b.end(); - CodeTreeBuilder b = mCreateLabel.getBuilder(); - b.startReturn(); - b.startNew(builderLabelImplType.asType()); - b.end(2); } { @@ -554,6 +601,15 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = metBegin.getBuilder(); + if (op.name.equals("Instrumentation")) { + // this needs to be placed here, at the very start + // of the begin/end methods + b.startIf().string("!").variable(vars.keepingInstrumentation).end(); + b.startBlock(); + b.returnStatement(); + b.end(); + } + if (FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); b.statement("indent++"); @@ -565,7 +621,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.variable(fldOperationData); b.variable(op.idConstantField); + b.variable(fldCurStack); b.string("" + op.getNumAuxValues()); + b.string("" + op.hasLeaveCode()); for (VariableElement el : metBegin.getParameters()) { b.variable(el); @@ -585,6 +643,15 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); + if (op.name.equals("Instrumentation")) { + // this needs to be placed here, at the very start + // of the begin/end methods + b.startIf().string("!").variable(vars.keepingInstrumentation).end(); + b.startBlock(); + b.returnStatement(); + b.end(); + } + if (FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\")\")"); b.statement("indent--"); @@ -644,428 +711,45 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } - CodeTreeBuilder b2 = CodeTreeBuilder.createBuilder(); - b2.startNew(types.BuilderOperationData); + b.statement("doBeforeChild()"); - b2.variable(fldOperationData); - b2.variable(op.idConstantField); - b2.string("" + op.getNumAuxValues()); - for (VariableElement v : metEmit.getParameters()) { - b2.variable(v); + if (op.name.equals("Label")) { + // for labels we need to use local to not conflict with operation layering + // requirements. we still create the variable since some other code expects + // it to exist (it will shadow the actual field) + b.string(types.BuilderOperationData.asElement().getSimpleName() + " "); } + b.startAssign(fldOperationData); + b.startNew(types.BuilderOperationData); - b2.end(); + b.field("this", fldOperationData); + b.variable(op.idConstantField); + b.variable(fldCurStack); + b.string("" + op.getNumAuxValues()); + b.string("false"); - CodeVariableElement opData = new CodeVariableElement(types.BuilderOperationData, "opData"); - b.declaration(types.BuilderOperationData, "opData", b2.build()); + for (VariableElement v : metEmit.getParameters()) { + b.variable(v); + } + b.end(2); - b.statement("doBeforeChild()"); b.tree(op.createBeginCode(vars)); b.tree(op.createEndCode(vars)); b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); - b.statement("doAfterChild()"); - } - typBuilderImpl.add(metEmit); - } - } - - return typBuilderImpl; - - } - - private CodeTypeElement createBuilderLabelImpl(String simpleName) { - return GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, types.BuilderOperationLabel); - } - - /** - * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the - * executable Truffle node. - */ - private CodeTypeElement createBuilderBytecodeNode(CodeTypeElement typBuilderImpl, String simpleName) { - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, simpleName, types.OperationsNode); - - CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); - GeneratorUtils.addCompilationFinalAnnotation(fldBc, 1); - builderBytecodeNodeType.add(fldBc); - - CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); - GeneratorUtils.addCompilationFinalAnnotation(fldConsts, 1); - builderBytecodeNodeType.add(fldConsts); - - CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); - GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); - builderBytecodeNodeType.add(fldHandlers); - - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); - builderBytecodeNodeType.add(ctor); - - CodeVariableElement fldTracer = null; - CodeVariableElement fldHitCount = null; - if (m.isTracing()) { - fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); - builderBytecodeNodeType.add(fldHitCount); - - fldTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); - builderBytecodeNodeType.add(fldTracer); - } - - { - CodeTreeBuilder b = ctor.getBuilder(); - - if (m.isTracing()) { - b.startAssign(fldHitCount).startNewArray( - (ArrayType) fldHitCount.getType(), - CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); - b.end(2); - - b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get").end(2); - } - } - - ExecuteVariables vars = new ExecuteVariables(); - vars.bytecodeNodeType = builderBytecodeNodeType; - vars.bc = fldBc; - vars.consts = fldConsts; - vars.maxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); - vars.handlers = fldHandlers; - vars.tracer = fldTracer; - - { - CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); - builderBytecodeNodeType.add(mExecute); - - CodeTreeBuilder builder = mExecute.getBuilder(); - builder.startReturn(); - builder.startCall("continueAt"); - - builder.string("frame"); - builder.string("null"); - - builder.end(2); - - } - - { - CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); - CodeVariableElement argStartIndex = new CodeVariableElement(types.OperationLabel, "startIndex"); - CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", - argFrame, argStartIndex); - builderBytecodeNodeType.add(mContinueAt); - - { - CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); - mContinueAt.addAnnotationMirror(annExplodeLoop); - annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( - context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); - } - - CodeTreeBuilder b = mContinueAt.getBuilder(); - - CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); - CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(byte.class), "curOpcode"); - - b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); - b.declaration("int", varBci.getName(), "0"); - - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "startFunction").string("this").end(2); - } - - CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); - b.statement("Object " + varReturnValue.getName()); - - b.string("loop: "); - b.startWhile().string("true").end(); - b.startBlock(); - CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); - b.statement("int nextBci"); - - vars.bci = varBci; - vars.nextBci = varNextBci; - vars.frame = argFrame; - vars.sp = varSp; - vars.returnValue = varReturnValue; - - b.declaration("byte", varCurOpcode.getName(), CodeTreeBuilder.singleString("bc[bci]")); - - b.startTryBlock(); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); - - if (m.isTracing()) { - b.startStatement().variable(fldHitCount).string("[bci]++").end(); - } - - b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); - b.startBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); - b.end(); - - b.startSwitch().string("curOpcode").end(); - b.startBlock(); - - for (Instruction op : m.getInstructions()) { - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); - - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceInstruction"); - b.variable(varBci); - b.variable(op.opcodeIdField); - - int ofs = 1; - for (Argument arg : op.arguments) { - b.tree(arg.createReadCode(vars, ofs)); - ofs += arg.length; + if (!op.name.equals("Label")) { + b.startAssign(fldOperationData).variable(fldOperationData).string(".parent").end(); } - b.end(2); - } - - b.tree(op.createExecuteCode(vars)); - b.tree(op.createExecuteEpilogue(vars)); - - b.end(); - } - - b.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); - - b.end(); // switch block - - b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); - - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceException"); - b.string("ex"); - b.end(2); - - } - - b.startFor().string("int handlerIndex = 0; handlerIndex < " + vars.handlers.getName() + ".length; handlerIndex++").end(); - b.startBlock(); - - b.declaration(types.BuilderExceptionHandler, "handler", vars.handlers.getName() + "[handlerIndex]"); - b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); - b.statement("continue"); - - b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET").end(); - // TODO check exception type (?) - - b.tree(OperationGeneratorUtils.createWriteLocal(vars, - CodeTreeBuilder.singleString("handler.exceptionIndex"), - CodeTreeBuilder.singleString("ex"))); - - b.statement("bci = handler.handlerBci"); - b.statement("continue loop"); - - b.end(); // for (handlerIndex ...) - - b.startThrow().string("ex").end(); - - b.end(); // catch block - - b.statement("bci = nextBci"); - b.end(); // while block - - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "endFunction").end(2); - } - - b.startReturn().string("returnValue").end(); - - vars.bci = null; - vars.nextBci = null; - vars.frame = null; - vars.sp = null; - vars.returnValue = null; - - } - - { - CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); - builderBytecodeNodeType.add(mDump); - - CodeTreeBuilder b = mDump.getBuilder(); - - b.declaration("int", "bci", "0"); - b.declaration("StringBuilder", "sb", "new StringBuilder()"); - - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - b.startWhile().string("bci < bc.length").end(); - b.startBlock(); // while block - - if (m.isTracing()) { - b.statement("sb.append(String.format(\" [ %3d ]\", hitCount[bci]))"); - } - - b.statement("sb.append(String.format(\" %04x \", bci))"); - - b.startSwitch().string("bc[bci]").end(); - b.startBlock(); - - for (Instruction op : m.getInstructions()) { - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); - - b.statement("sb.append(\"" + op.name + " \")"); - - int ofs = 1; - for (int i = 0; i < op.arguments.length; i++) { - b.tree(op.arguments[i].getDumpCode(vars, CodeTreeBuilder.singleString("bci + " + ofs))); - ofs += op.arguments[i].length; - } - - b.statement("bci += " + op.length()); - b.statement("break"); - - b.end(); - } - - b.caseDefault().startCaseBlock(); - b.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); - b.statement("break"); - b.end(); // default case block - b.end(); // switch block - - b.statement("sb.append(\"\\n\")"); - - b.end(); // while block - - b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); - b.startBlock(); - - b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); - - b.end(); - - b.startIf().string("sourceInfo != null").end(); - b.startBlock(); - { - b.statement("sb.append(\"Source info:\\n\")"); - b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); - b.startBlock(); - - b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i]))"); - - b.end(); - } - b.end(); - - b.startReturn().string("sb.toString()").end(); - - vars.bci = null; - - } - - if (m.isTracing()) { - CodeExecutableElement mGetTrace = GeneratorUtils.override(types.OperationsNode, "getNodeTrace"); - builderBytecodeNodeType.add(mGetTrace); - - CodeTreeBuilder b = mGetTrace.getBuilder(); - - b.declaration("int", "bci", "0"); - b.declaration("ArrayList", "insts", "new ArrayList<>()"); - - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - b.startWhile().string("bci < bc.length").end(); - b.startBlock(); // while block - - b.startSwitch().string("bc[bci]").end(); - b.startBlock(); - - for (Instruction op : m.getInstructions()) { - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); - - b.startStatement(); - b.startCall("insts", "add"); - b.startNew(types.InstructionTrace); - - b.variable(op.opcodeIdField); - b.startGroup().variable(fldHitCount).string("[bci]").end(); + b.statement("doAfterChild()"); - int ofs = 1; - for (int i = 0; i < op.arguments.length; i++) { - b.tree(op.arguments[i].createReadCode(vars, ofs)); } - - b.end(3); - - b.statement("bci += " + op.length()); - b.statement("break"); - - b.end(); + typBuilderImpl.add(metEmit); } - - b.caseDefault().startCaseBlock(); - b.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); - b.end(); // default case block - b.end(); // switch block - - b.end(); // while block - - b.startReturn().startNew(types.NodeTrace); - b.startCall("insts", "toArray").string("new InstructionTrace[0]").end(); - b.end(2); - - vars.bci = null; - } - - { - CodeExecutableElement mGetSourceSection = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); - builderBytecodeNodeType.add(mGetSourceSection); - - CodeTreeBuilder b = mGetSourceSection.createBuilder(); - - b.tree(createReparseCheck(typBuilderImpl)); - - b.startReturn(); - b.startCall("this", "getSourceSectionImpl"); - b.end(2); } - { - CodeVariableElement pBci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeExecutableElement mGetSourceSectionAtBci = GeneratorUtils.overrideImplement(types.OperationsNode, "getSourceSectionAtBci"); - builderBytecodeNodeType.add(mGetSourceSectionAtBci); - - CodeTreeBuilder b = mGetSourceSectionAtBci.createBuilder(); - - b.tree(createReparseCheck(typBuilderImpl)); - - b.startReturn(); - b.startCall("this", "getSourceSectionAtBciImpl"); - b.variable(pBci); - b.end(2); - } - - return builderBytecodeNodeType; - } - - private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().string("sourceInfo == null").end(); - b.startBlock(); - { - b.startStatement(); - b.string("OperationsNode reparsed = "); - b.startStaticCall(typBuilderImpl.asType(), "reparse"); - b.startCall("getLanguage").typeLiteral(m.getLanguageType()).end(); - b.startGroup().cast(m.getParseContextType()).string("parseContext").end(); - b.string("buildOrder"); - b.end(2); - - b.statement("copyReparsedInfo(reparsed)"); - } - b.end(); + return typBuilderImpl; - return b.build(); } /** diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index eae07ce44681..9c45a3a2447b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -3,6 +3,18 @@ import java.util.ArrayList; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; +import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; +import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.SuperInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.TransferInstruction; public class OperationsContext { @@ -22,9 +34,9 @@ public OperationsContext() { } private void createCommonInstructions() { - commonPop = add(new Instruction.Pop(instructionId++)); - commonBranch = add(new Instruction.Branch(instructionId++)); - commonBranchFalse = add(new Instruction.BranchFalse(instructionId++)); + commonPop = add(new DiscardInstruction("pop", instructionId++, InputType.STACK_VALUE_IGNORED)); + commonBranch = add(new BranchInstruction(instructionId++)); + commonBranchFalse = add(new ConditionalBranchInstruction(instructionId++)); } private void createBuiltinOperations() { @@ -35,13 +47,24 @@ private void createBuiltinOperations() { add(new Operation.While(this, operationId++)); add(new Operation.TryCatch(this, operationId++)); + Instruction iConst; + Instruction iStloc; + add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new Instruction.ConstObject(instructionId++)))); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new Instruction.LoadArgument(instructionId++)))); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new Instruction.LoadLocal(instructionId++)))); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new Instruction.StoreLocal(instructionId++)))); - add(new Operation.Simple(this, "Return", operationId++, 1, add(new Instruction.Return(instructionId++)))); + add(new Operation.Simple(this, "ConstObject", operationId++, 0, iConst = add(new TransferInstruction("const", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new TransferInstruction("ldarg", instructionId++, ResultType.STACK_VALUE, InputType.ARGUMENT)))); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new TransferInstruction("ldloc", instructionId++, ResultType.STACK_VALUE, InputType.LOCAL)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, iStloc = add(new TransferInstruction("stloc", instructionId++, ResultType.SET_LOCAL, InputType.STACK_VALUE)))); + add(new Operation.Simple(this, "Return", operationId++, 1, add(new TransferInstruction("return", instructionId++, ResultType.RETURN, InputType.STACK_VALUE)))); + + add(new Operation.Instrumentation(this, operationId++, + add(new InstrumentationEnterInstruction(instructionId++)), + add(new InstrumentationExitInstruction(instructionId++)), + add(new InstrumentationExitInstruction(instructionId++, true)), + add(new InstrumentationLeaveInstruction(instructionId++)))); + + Instruction iSuper = add(new SuperInstruction(instructionId++, new Instruction[]{iConst, iStloc})); } public Instruction add(Instruction elem) { @@ -63,7 +86,6 @@ public int getNextOperationId() { } public void processOperation(SingleOperationData opData) { - Argument[] arguments; MethodProperties props = opData.getMainProperties(); @@ -72,16 +94,12 @@ public void processOperation(SingleOperationData opData) { return; } - if (props.isVariadic) { - arguments = new Argument[]{new Argument.VarArgsCount(props.numStackValues - 1)}; - } else { - arguments = new Argument[0]; - } - - Instruction.Custom instr = new Instruction.Custom("custom." + opData.getName(), getNextInstructionId(), opData, arguments); + CustomInstruction instr = new CustomInstruction("custom." + opData.getName(), getNextInstructionId(), opData); add(instr); - Operation.Custom op = new Operation.Custom(this, opData.getName(), getNextOperationId(), props.numStackValues, instr); + int numChildren = props.isVariadic ? -1 : props.numStackValues; + + Operation.Simple op = new Operation.Simple(this, opData.getName(), getNextOperationId(), numChildren, instr); add(op); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 8662bb6efb37..1925f4d8d450 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -12,6 +12,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.Template; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; public class OperationsData extends Template { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index f42fc258f0e7..e1b527184544 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -22,7 +22,7 @@ public class SingleOperationData extends Template { private OperationsData parent; private final Set throwDeclarations = new HashSet<>(); - static enum ParameterKind { + public static enum ParameterKind { STACK_VALUE, VARIADIC, VIRTUAL_FRAME; @@ -53,7 +53,7 @@ public boolean isStackValue() { } } - static class MethodProperties { + public static class MethodProperties { public final ExecutableElement element; public final List parameters; public final boolean isVariadic; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java new file mode 100644 index 000000000000..cc06a3352b1b --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -0,0 +1,40 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; + +public class BranchInstruction extends Instruction { + public BranchInstruction(int id) { + super("branch", id, ResultType.BRANCH, InputType.BRANCH_TARGET); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + + return b.build(); + } + + @Override + public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + TruffleTypes types = ProcessorContext.getInstance().getTypes(); + + b.startStatement().startCall("calculateLeaves"); + b.variable(vars.operationData); + b.startGroup().cast(types.BuilderOperationLabel).tree(arguments[0]).end(); + b.end(2); + + b.tree(super.createEmitCode(vars, arguments)); + + return b.build(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java new file mode 100644 index 000000000000..0495cd13dc9d --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -0,0 +1,35 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; + +public class ConditionalBranchInstruction extends Instruction { + public ConditionalBranchInstruction(int id) { + super("brfalse", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE); + } + + @Override + public TypeMirror[] expectedInputTypes(ProcessorContext context) { + return new TypeMirror[]{context.getType(short.class), context.getType(boolean.class)}; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().variable(vars.inputs[1]).end(); + b.startBlock(); + b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.end().startElseBlock(); + b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + b.end(); + + return b.build(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java new file mode 100644 index 000000000000..61065c41aafb --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -0,0 +1,75 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import javax.lang.model.element.ExecutableElement; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; + +public class CustomInstruction extends Instruction { + private final SingleOperationData data; + private ExecutableElement executeMethod; + + public SingleOperationData getData() { + return data; + } + + public void setExecuteMethod(ExecutableElement executeMethod) { + this.executeMethod = executeMethod; + } + + private static InputType[] createInputs(SingleOperationData data) { + MethodProperties props = data.getMainProperties(); + InputType[] inputs = new InputType[props.numStackValues]; + for (int i = 0; i < inputs.length; i++) { + inputs[i] = InputType.STACK_VALUE; + } + + if (props.isVariadic) { + inputs[inputs.length - 1] = InputType.VARARG_VALUE; + } + + return inputs; + } + + public CustomInstruction(String name, int id, SingleOperationData data) { + super(name, id, data.getMainProperties().returnsValue + ? new ResultType[]{ResultType.STACK_VALUE} + : new ResultType[]{}, createInputs(data)); + this.data = data; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (results.length > 0) { + b.startAssign(vars.results[0]); + } else { + b.startStatement(); + } + + int inputIndex = 0; + b.startCall("this", executeMethod); + b.variable(vars.bci); + for (ParameterKind kind : data.getMainProperties().parameters) { + switch (kind) { + case STACK_VALUE: + case VARIADIC: + b.variable(vars.inputs[inputIndex++]); + break; + case VIRTUAL_FRAME: + b.variable(vars.frame); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + kind); + } + } + + b.end(2); + + return b.build(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java new file mode 100644 index 000000000000..d262dbedd94f --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -0,0 +1,17 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; + +public class DiscardInstruction extends Instruction { + public DiscardInstruction(String name, int id, InputType input) { + super(name, id, new ResultType[0], input); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + return null; + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java new file mode 100644 index 000000000000..12b6eaa13975 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -0,0 +1,450 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import java.util.ArrayList; +import java.util.List; + +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.Operation; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; + +public abstract class Instruction { + + public static class ExecutionVariables { + public CodeVariableElement bc; + public CodeVariableElement bci; + public CodeVariableElement nextBci; + public CodeVariableElement frame; + public CodeVariableElement sp; + public CodeVariableElement returnValue; + public CodeVariableElement consts; + public CodeVariableElement[] inputs; + public CodeVariableElement[] results; + + public CodeVariableElement probeNodes; + } + + public static enum InputType { + STACK_VALUE(0), + STACK_VALUE_IGNORED(0), + VARARG_VALUE(2), + CONST_POOL(2), + LOCAL(2), + ARGUMENT(2), + INSTRUMENT(2), + BRANCH_TARGET(2); + + final int argumentLength; + + private InputType(int argumentLength) { + this.argumentLength = argumentLength; + } + + public final TypeMirror getDefaultExecutionType(ProcessorContext context) { + switch (this) { + case STACK_VALUE_IGNORED: + return null; + case STACK_VALUE: + case CONST_POOL: + case LOCAL: + case ARGUMENT: + return context.getType(Object.class); + case VARARG_VALUE: + return new ArrayCodeTypeMirror(context.getType(Object.class)); + case BRANCH_TARGET: + case INSTRUMENT: + return context.getType(short.class); + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + boolean needsBuilderArgument() { + switch (this) { + case STACK_VALUE: + case STACK_VALUE_IGNORED: + case VARARG_VALUE: + return false; + case CONST_POOL: + case LOCAL: + case ARGUMENT: + case BRANCH_TARGET: + case INSTRUMENT: + return true; + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + public final TypeMirror getDefaultBuilderType(ProcessorContext context) { + switch (this) { + case STACK_VALUE: + case STACK_VALUE_IGNORED: + case VARARG_VALUE: + case INSTRUMENT: + return null; + case CONST_POOL: + return context.getType(Object.class); + case LOCAL: + case ARGUMENT: + return context.getType(int.class); + case BRANCH_TARGET: + return context.getTypes().OperationLabel; + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + public final CodeTree getImplicitValue(BuilderVariables vars, Instruction instr) { + switch (this) { + case STACK_VALUE: + case STACK_VALUE_IGNORED: + case CONST_POOL: + case LOCAL: + case ARGUMENT: + case BRANCH_TARGET: + case INSTRUMENT: + return null; + case VARARG_VALUE: + return CodeTreeBuilder.createBuilder().variable(vars.numChildren).string(" - " + instr.numStackValuesExclVarargs()).build(); + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { + switch (this) { + case STACK_VALUE: + return CodeTreeBuilder.createBuilder().statement("sb.append(\"x\")").build(); + case STACK_VALUE_IGNORED: + return CodeTreeBuilder.createBuilder().statement("sb.append(\"_\")").build(); + case CONST_POOL: + return CodeTreeBuilder.createBuilder().startBlock()// + .declaration("Object", "o", CodeTreeBuilder.createBuilder().variable(vars.consts).string("[").tree(op.createReadArgumentCode(n, vars)).string("]").build()) // + .startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("%s %s") // + .string("o.getClass().getSimpleName()") // + .string("o") // + .end(4).build(); + case LOCAL: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("loc[%d]") // + .tree(op.createReadArgumentCode(n, vars)) // + .end(3).build(); + case ARGUMENT: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("arg[%d]") // + .tree(op.createReadArgumentCode(n, vars)) // + .end(3).build(); + case BRANCH_TARGET: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("%04x") // + .tree(op.createReadArgumentCode(n, vars)) // + .end(3).build(); + case INSTRUMENT: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("instrument[%d]") // + .tree(op.createReadArgumentCode(n, vars)) // + .end(3).build(); + case VARARG_VALUE: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("**%d") // + .tree(op.createReadArgumentCode(n, vars)) // + .end(3).build(); + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + } + + public static enum ResultType { + STACK_VALUE(0), + SET_LOCAL(2), + BRANCH(0), + RETURN(0); + + final int argumentLength; + + private ResultType(int argumentLength) { + this.argumentLength = argumentLength; + } + + boolean needsBuilderArgument() { + switch (this) { + case STACK_VALUE: + case BRANCH: + case RETURN: + return false; + case SET_LOCAL: + return true; + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + public final TypeMirror getDefaultBuilderType(ProcessorContext context) { + switch (this) { + case STACK_VALUE: + case BRANCH: + case RETURN: + return null; + case SET_LOCAL: + return context.getType(int.class); + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + public CodeTree createDumpCode(int i, Instruction op, ExecutionVariables vars) { + switch (this) { + case STACK_VALUE: + return CodeTreeBuilder.createBuilder().statement("sb.append(\"x\")").build(); + case BRANCH: + return CodeTreeBuilder.createBuilder().statement("sb.append(\"branch\")").build(); + case RETURN: + return CodeTreeBuilder.createBuilder().statement("sb.append(\"return\")").build(); + case SET_LOCAL: + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("loc[%d]") // + .tree(op.createReadArgumentCode(i + op.inputs.length, vars)) // + .end(3).build(); + default: + throw new IllegalArgumentException("Unexpected value: " + this); + } + } + + } + + public final String name; + public final int id; + public final InputType[] inputs; + public final ResultType[] results; + + public CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + int result = 0; + int argIndex = 0; + + for (InputType input : inputs) { + if (input == InputType.STACK_VALUE) { + result--; + } else if (input == InputType.VARARG_VALUE) { + b.string("-").startParantheses().tree(arguments[argIndex]).end().string(" + "); + } + argIndex++; + } + + for (ResultType rt : results) { + if (rt == ResultType.STACK_VALUE) { + result++; + } + } + + return b.string("" + result).build(); + } + + public CodeVariableElement opcodeIdField; + + public void setOpcodeIdField(CodeVariableElement opcodeIdField) { + this.opcodeIdField = opcodeIdField; + } + + Instruction(String name, int id, ResultType result, InputType... inputs) { + this.name = name; + this.id = id; + this.results = new ResultType[]{result}; + this.inputs = inputs; + } + + Instruction(String name, int id, ResultType[] results, InputType... inputs) { + this.name = name; + this.id = id; + this.results = results; + this.inputs = inputs; + } + + public int numStackValuesExclVarargs() { + int result = 0; + for (int i = 0; i < inputs.length; i++) { + if (inputs[i] == InputType.STACK_VALUE) { + result++; + } + } + + return result; + } + + public TypeMirror[] expectedInputTypes(ProcessorContext context) { + TypeMirror[] result = new TypeMirror[inputs.length]; + + for (int i = 0; i < inputs.length; i++) { + result[i] = inputs[i].getDefaultExecutionType(context); + } + return result; + } + + public final CodeTree createReadArgumentCode(int n, ExecutionVariables vars) { + if (!isArgumentInBytecode(n)) { + return null; + } + + return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // + .variable(vars.bc) // + .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end() // + .end().build(); + } + + public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, CodeTree val) { + if (!isArgumentInBytecode(n)) { + return null; + } + + CodeTree value = val; + + if (n < inputs.length && inputs[n] == InputType.BRANCH_TARGET) { + return CodeTreeBuilder.createBuilder().startStatement().startCall("createOffset") // + .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end()// + .tree(value) // + .end(2).build(); + } + + if (n < inputs.length && inputs[n] == InputType.VARARG_VALUE) { + value = CodeTreeBuilder.createBuilder().startParantheses().variable(vars.numChildren).string(" - " + numStackValuesExclVarargs()).end().build(); + } + + if (n < inputs.length && inputs[n] == InputType.CONST_POOL) { + value = CodeTreeBuilder.createBuilder().startCall(vars.consts, "add").tree(value).end().build(); + } + + if (n >= inputs.length && results[n - inputs.length] == ResultType.SET_LOCAL) { + value = CodeTreeBuilder.createBuilder().startCall("trackLocalsHelper").tree(value).end().build(); + } + + return CodeTreeBuilder.createBuilder().startStatement().startCall("LE_BYTES", "putShort") // + .variable(vars.bc) // + .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end() // + .startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).cast(new CodeTypeMirror(TypeKind.INT)).tree(value).end() // + .end(2).build(); + } + + public int opcodeLength() { + return 1; + } + + public int getArgumentOffset(int index) { + int res = opcodeLength(); + for (int i = 0; i < index; i++) { + if (i < inputs.length) { + res += inputs[i].argumentLength; + } else { + res += results[i - inputs.length].argumentLength; + } + } + return res; + } + + public boolean isArgumentInBytecode(int index) { + if (index < inputs.length) { + return inputs[index].argumentLength > 0; + } else { + return results[index - inputs.length].argumentLength > 0; + } + } + + public boolean needsBuilderArgument(int index) { + if (index < inputs.length) { + return inputs[index].needsBuilderArgument(); + } else { + return results[index - inputs.length].needsBuilderArgument(); + } + } + + public int length() { + return getArgumentOffset(inputs.length + results.length); + } + + public List getBuilderArgumentTypes() { + ProcessorContext context = ProcessorContext.getInstance(); + List result = new ArrayList<>(); + + for (int i = 0; i < inputs.length; i++) { + TypeMirror m = inputs[i].getDefaultBuilderType(context); + if (m != null) { + result.add(m); + } + } + for (int i = 0; i < results.length; i++) { + TypeMirror m = results[i].getDefaultBuilderType(context); + if (m != null) { + result.add(m); + } + } + + return result; + } + + public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // emit opcode + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string("] = ").variable(opcodeIdField).end(); + + // emit arguments + int argIndex = 0; + for (int i = 0; i < inputs.length + results.length; i++) { + CodeTree argument = needsBuilderArgument(i) ? arguments[argIndex++] : null; + b.tree(createWriteArgumentCode(i, vars, argument)); + } + + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + + // calculate stack offset + int numPush = numPush(); + CodeTree numPop = numPop(vars); + b.startAssign(vars.curStack).variable(vars.curStack).string(" + " + numPush + " - ").tree(numPop).end(); + if (numPush > 0) { + b.startIf().variable(vars.curStack).string(" > ").variable(vars.maxStack).end(); + b.startBlock().startAssign(vars.maxStack).variable(vars.curStack).end(2); + } + + return b.build(); + } + + public int numPush() { + int stackPush = 0; + for (ResultType r : results) { + if (r == ResultType.STACK_VALUE) { + stackPush++; + } + } + return stackPush; + } + + public CodeTree numPop(BuilderVariables vars) { + int stackPop = 0; + for (InputType i : inputs) { + if (i == InputType.STACK_VALUE || i == InputType.STACK_VALUE_IGNORED) { + stackPop++; + } else if (i == InputType.VARARG_VALUE) { + return CodeTreeBuilder.singleVariable(vars.numChildren); + } + } + return CodeTreeBuilder.singleString("" + stackPop); + } + + public abstract CodeTree createExecuteCode(ExecutionVariables vars); + + public boolean isInstrumentationOnly() { + return false; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java new file mode 100644 index 000000000000..6211fe316987 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -0,0 +1,29 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class InstrumentationEnterInstruction extends Instruction { + + public InstrumentationEnterInstruction(int id) { + super("instrument.enter", id, new ResultType[0], InputType.INSTRUMENT); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement(); + b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); + b.startCall("onEnter"); + b.variable(vars.frame); + b.end(2); + + return b.build(); + } + + @Override + public boolean isInstrumentationOnly() { + return true; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java new file mode 100644 index 000000000000..69b3c859c6be --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -0,0 +1,46 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class InstrumentationExitInstruction extends Instruction { + private final boolean returnsValue; + + public InstrumentationExitInstruction(int id) { + super("instrument.exit.void", id, new ResultType[0], InputType.INSTRUMENT); + this.returnsValue = false; + } + + public InstrumentationExitInstruction(int id, boolean returnsValue) { + super("instrument.exit", id, ResultType.STACK_VALUE, InputType.INSTRUMENT, InputType.STACK_VALUE); + assert returnsValue; + this.returnsValue = true; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement(); + b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); + b.startCall("onReturnValue"); + b.variable(vars.frame); + if (returnsValue) { + b.variable(vars.inputs[1]); + } else { + b.string("null"); + } + b.end(2); + + if (returnsValue) { + b.startAssign(vars.results[0]).variable(vars.inputs[1]).end(); + } + + return b.build(); + } + + @Override + public boolean isInstrumentationOnly() { + return true; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java new file mode 100644 index 000000000000..3ce903a2f574 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -0,0 +1,48 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class InstrumentationLeaveInstruction extends Instruction { + public InstrumentationLeaveInstruction(int id) { + super("instrument.leave", id, ResultType.BRANCH, InputType.INSTRUMENT, InputType.BRANCH_TARGET, InputType.BRANCH_TARGET); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("Object result"); + b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); + b.startCall("onReturnExceptionalOrUnwind"); + b.variable(vars.frame); + b.string("null"); + b.string("false"); + b.end(2); + + b.startIf().string("result == ProbeNode.UNWIND_ACTION_REENTER").end(); + b.startBlock(); + + b.startAssign(vars.results[0]).variable(vars.inputs[1]).end(); + + b.end().startElseIf().string("result != null").end(); + b.startBlock(); + + // HACK, refactor this push somehow + b.startStatement().startCall(vars.frame, "setObject").string("sp++").string("result").end(2); + b.startAssign(vars.results[0]).variable(vars.inputs[2]).end(); + + b.end().startElseBlock(); + + b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + + b.end(); + + return b.build(); + } + + @Override + public boolean isInstrumentationOnly() { + return true; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java new file mode 100644 index 000000000000..d409e2600c90 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -0,0 +1,158 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import java.util.ArrayList; +import java.util.Stack; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; + +public class SuperInstruction extends Instruction { + private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { + int stackSize = 0; + + for (int i = 0; i < instrs.length; i++) { + for (int j = 0; j < instrs[i].inputs.length; j++) { + switch (instrs[i].inputs[j]) { + case STACK_VALUE: + case STACK_VALUE_IGNORED: + if (stackSize > 0) { + stackSize--; + break; + } + // fall-through + case ARGUMENT: + case BRANCH_TARGET: + case CONST_POOL: + case LOCAL: + if (inputs != null) { + inputs.add(instrs[i].inputs[j]); + } + break; + default: + throw new IllegalArgumentException("Unexpected value: " + instrs[i].inputs[j]); + } + } + + for (int j = 0; j < instrs[i].results.length; j++) { + switch (instrs[i].results[j]) { + case SET_LOCAL: + if (results != null) { + results.add(ResultType.SET_LOCAL); + } + break; + case STACK_VALUE: + stackSize++; + break; + default: + throw new UnsupportedOperationException("not yet implemented"); + } + } + } + + if (results != null) { + for (int i = 0; i < stackSize; i++) { + results.add(ResultType.STACK_VALUE); + } + } + } + + private static ResultType[] createResults(Instruction[] instrs) { + ArrayList results = new ArrayList<>(); + createResults(instrs, null, results); + return results.toArray(new ResultType[results.size()]); + } + + private static InputType[] createInputs(Instruction[] instrs) { + ArrayList results = new ArrayList<>(); + createResults(instrs, results, null); + return results.toArray(new InputType[results.size()]); + } + + private static String createName(Instruction[] instrs) { + StringBuilder sb = new StringBuilder("super."); + for (int i = 0; i < instrs.length; i++) { + if (i != 0) { + sb.append('.'); + } + sb.append(instrs[i].name); + } + return sb.toString(); + } + + Instruction[] instrs; + + public SuperInstruction(int id, Instruction[] instrs) { + super(createName(instrs), id, createResults(instrs), createInputs(instrs)); + this.instrs = instrs; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + ProcessorContext context = ProcessorContext.getInstance(); + + CodeVariableElement[] realInputs = vars.inputs; + CodeVariableElement[] realResults = vars.results; + + Stack tmpStack = new Stack<>(); + int realInputIndex = 0; + int realResultIndex = 0; + for (int i = 0; i < instrs.length; i++) { + + CodeVariableElement[] innerInputs = new CodeVariableElement[instrs[i].inputs.length]; + CodeVariableElement[] innerResults = new CodeVariableElement[instrs[i].results.length]; + + for (int j = 0; j < instrs[i].inputs.length; j++) { + switch (instrs[i].inputs[j]) { + case STACK_VALUE: + if (!tmpStack.isEmpty()) { + innerInputs[j] = tmpStack.pop(); + break; + } + // fall-through + case ARGUMENT: + case BRANCH_TARGET: + case CONST_POOL: + case LOCAL: + innerInputs[j] = realInputs[realInputIndex++]; + break; + case STACK_VALUE_IGNORED: + if (!tmpStack.isEmpty()) { + tmpStack.pop(); + } else { + realInputIndex++; + } + break; + } + } + + for (int j = 0; j < instrs[i].results.length; j++) { + switch (instrs[i].results[j]) { + case SET_LOCAL: + innerResults[j] = realResults[realResultIndex++]; + break; + case STACK_VALUE: + innerResults[j] = new CodeVariableElement(context.getType(Object.class), "inner_result_" + i + "_" + j); + b.statement("Object " + innerResults[j].getName()); + tmpStack.add(innerResults[j]); + break; + } + } + + vars.inputs = innerInputs; + vars.results = innerResults; + b.tree(instrs[i].createExecuteCode(vars)); + } + + for (int i = 0; i < tmpStack.size(); i++) { + b.startAssign(realResults[realResultIndex++]).variable(tmpStack.get(i)).end(); + } + + return b.build(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java new file mode 100644 index 000000000000..662128ac65a9 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java @@ -0,0 +1,18 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; + +public class TransferInstruction extends Instruction { + public TransferInstruction(String name, int id, ResultType result, InputType input) { + super(name, id, result, input); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + return CodeTreeBuilder.createBuilder().startAssign(vars.results[0]).variable(vars.inputs[0]).end().build(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index f1d137a9dde9..31d5973b490c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -3,7 +3,6 @@ import java.util.Collections; import java.util.Map; -import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; From c742eabda6a7752d604ff238dc1eaae006a0c035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 24 Mar 2022 16:07:05 +0100 Subject: [PATCH 025/312] [wip] --- .../api/operation/OperationsBuilder.java | 15 ++++-- ...java => OperationsInstrumentTreeNode.java} | 18 +++++-- .../OperationsInstrumentableNode.java | 4 +- .../truffle/api/operation/OperationsNode.java | 8 +++- .../truffle/dsl/processor/TruffleTypes.java | 6 ++- .../dsl/processor/operations/Operation.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 2 +- .../operations/OperationsCodeGenerator.java | 2 +- .../InstrumentationEnterInstruction.java | 13 ++++- .../InstrumentationExitInstruction.java | 14 +++++- .../InstrumentationLeaveInstruction.java | 16 ++++++- .../operations/SLOperationsVisitor.java | 48 ++++++++++++++++++- 12 files changed, 127 insertions(+), 21 deletions(-) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/{OperationsInstrumentTree.java => OperationsInstrumentTreeNode.java} (64%) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 3c646e211d05..59181dedf5a4 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,11 +1,9 @@ package com.oracle.truffle.api.operation; import java.util.ArrayList; -import java.util.Set; import java.util.function.Supplier; -import javax.swing.text.html.HTML.Tag; - +import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.source.Source; @@ -179,4 +177,15 @@ protected void doEmitLabel(int bci, OperationLabel label) { public abstract void endSourceSection(int length); // ------------------------ instrumentation ------------------------ + + private final ArrayList instrumentTrees = new ArrayList<>(); + + protected final OperationsInstrumentTreeNode[] getInstrumentTrees() { + return instrumentTrees.toArray(new OperationsInstrumentTreeNode[instrumentTrees.size()]); + } + + protected final int doBeginInstrumentation(Class tag) { + instrumentTrees.add(new OperationsInstrumentTreeNode(tag)); + return instrumentTrees.size() - 1; + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java similarity index 64% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java index 648000d41acd..40f9404efea7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTree.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java @@ -2,15 +2,17 @@ import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.nodes.Node; -public class OperationsInstrumentTree extends Node implements InstrumentableNode { +public class OperationsInstrumentTreeNode extends Node implements InstrumentableNode { - private static class Wrapper extends OperationsInstrumentTree implements WrapperNode { + private static class Wrapper extends OperationsInstrumentTreeNode implements WrapperNode { private final Node delegateNode; private final ProbeNode probeNode; - public Wrapper(Node delegateNode, ProbeNode probeNode) { + public Wrapper(OperationsInstrumentTreeNode delegateNode, ProbeNode probeNode) { + super(delegateNode.tag); this.delegateNode = delegateNode; this.probeNode = probeNode; } @@ -29,6 +31,12 @@ public ProbeNode getTreeProbeNode() { } } + private final Class tag; + + public OperationsInstrumentTreeNode(Class tag) { + this.tag = tag; + } + public boolean isInstrumentable() { return true; } @@ -41,4 +49,8 @@ public ProbeNode getTreeProbeNode() { return null; } + public boolean hasTag(Class other) { + return tag == other; + } + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java index e45ab1f3cae3..e526f59f8dfc 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java @@ -7,7 +7,7 @@ public abstract class OperationsInstrumentableNode extends OperationsNode { - @Children OperationsInstrumentTree[] instrumentTree; + @Children OperationsInstrumentTreeNode[] instrumentTree; protected OperationsInstrumentableNode( TruffleLanguage language, @@ -19,7 +19,7 @@ protected OperationsInstrumentableNode( int buildOrder, int maxStack, int maxLocals, - OperationsInstrumentTree[] instrumentTree) { + OperationsInstrumentTreeNode[] instrumentTree) { super(language, parseContext, nodeName, isInternal, sourceInfo, sources, buildOrder, maxStack, maxLocals); this.instrumentTree = instrumentTree; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 91b1bbb13f8d..cfba66138d7d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -5,13 +5,14 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.tracing.NodeTrace; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -public abstract class OperationsNode extends RootNode { +public abstract class OperationsNode extends RootNode implements InstrumentableNode { protected static final int BCI_SLOT = 0; protected static final int VALUES_OFFSET = 1; @@ -140,4 +141,9 @@ public SourceSection getEncapsulatingSourceSection() { } }; } + + @Override + public boolean isInstrumentable() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 65e2e6802cf2..5d365b93b570 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -233,7 +233,8 @@ public class TruffleTypes { public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; - public static final String Special_Name = "com.oracle.truffle.api.operation.Special"; + public static final String OperationsInstrumentableNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentableNode"; + public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; @@ -249,7 +250,8 @@ public class TruffleTypes { public final DeclaredType OperationsBuilder = c.getDeclaredTypeOptional(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredTypeOptional(OperationsNode_Name); - public final DeclaredType Special = c.getDeclaredTypeOptional(Special_Name); + public final DeclaredType OperationsInstrumentableNode = c.getDeclaredTypeOptional(OperationsInstrumentableNode_Name); + public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); public final DeclaredType NodeTrace = c.getDeclaredTypeOptional(NodeTrace_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index a18110e6dc5d..54b0e025cf1b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -518,7 +518,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration("int", varCurInstrumentId.getName(), "instrumentationId++"); + b.declaration("int", varCurInstrumentId.getName(), "doBeginInstrumentation((Class) arg0)"); b.declaration(getTypes().BuilderOperationLabel, varStartLabel.getName(), createCreateLabel()); b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 61327678e007..7d7fcc414134 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -82,7 +82,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeVariableElement fldProbeNodes = null; if (withInstrumentation) { - fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.ProbeNode), "probeNodes"); + fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); GeneratorUtils.addCompilationFinalAnnotation(fldProbeNodes, 1); builderBytecodeNodeType.add(fldProbeNodes); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index b17c7f35ef66..0b159de7f634 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -360,7 +360,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("bcCopy"); b.string("cpCopy"); b.string("handlers"); - b.string("new ProbeNode[0]"); + b.string("getInstrumentTrees()"); b.end(2); b.end().startElseBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index 6211fe316987..7d84dab2d3f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -13,12 +13,21 @@ public InstrumentationEnterInstruction(int id) { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement(); + b.startAssign("ProbeNode probe"); b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); - b.startCall("onEnter"); + b.startCall("getTreeProbeNode"); + b.end(2); + + b.startIf().string("probe != null").end(); + b.startBlock(); + + b.startStatement(); + b.startCall("probe", "onEnter"); b.variable(vars.frame); b.end(2); + b.end(); + return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 69b3c859c6be..8667c16ea677 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class InstrumentationExitInstruction extends Instruction { private final boolean returnsValue; @@ -21,9 +22,16 @@ public InstrumentationExitInstruction(int id, boolean returnsValue) { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.declaration(OperationGeneratorUtils.getTypes().ProbeNode, "probe", + CodeTreeBuilder.createBuilder().variable(vars.probeNodes) // + .string("[").variable(vars.inputs[0]).string("].") // + .startCall("getTreeProbeNode").end(2).build()); + + b.startIf().string("probe != null").end(); + b.startBlock(); + b.startStatement(); - b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); - b.startCall("onReturnValue"); + b.startCall("probe", "onReturnValue"); b.variable(vars.frame); if (returnsValue) { b.variable(vars.inputs[1]); @@ -32,6 +40,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } b.end(2); + b.end(); + if (returnsValue) { b.startAssign(vars.results[0]).variable(vars.inputs[1]).end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index 3ce903a2f574..dde2acbb3d74 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -12,9 +12,16 @@ public InstrumentationLeaveInstruction(int id) { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign("Object result"); + b.startAssign("ProbeNode probe"); b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); - b.startCall("onReturnExceptionalOrUnwind"); + b.startCall("getTreeProbeNode"); + b.end(2); + + b.startIf().string("probe != null").end(); + b.startBlock(); + + b.startAssign("Object result"); + b.startCall("probe", "onReturnExceptionalOrUnwind"); b.variable(vars.frame); b.string("null"); b.string("false"); @@ -36,6 +43,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.end(); + b.end().startElseBlock(); + + b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.end(); return b.build(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index fa64b0751d2c..3707e90811ce 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -9,6 +9,8 @@ import org.antlr.v4.runtime.tree.ParseTree; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.debug.DebuggerTags; +import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; @@ -113,6 +115,8 @@ public Void visitFunction(FunctionContext ctx) { TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); b.beginSource(source); + b.beginInstrumentation(StandardTags.RootTag.class); + b.setNodeName(name.toJavaStringUncached()); scope = new LexicalScope(null); @@ -126,8 +130,12 @@ public Void visitFunction(FunctionContext ctx) { b.endStoreLocal(); } + b.beginInstrumentation(StandardTags.RootBodyTag.class); + visit(ctx.body); + b.endInstrumentation(); + b.beginReturn(); b.emitConstObject(SLNull.SINGLETON); b.endReturn(); @@ -136,6 +144,7 @@ public Void visitFunction(FunctionContext ctx) { assert scope == null; + b.endInstrumentation(); b.endSource(); OperationsNode node = b.build(); @@ -163,7 +172,9 @@ public Void visitBreak_statement(Break_statementContext ctx) { SemErr(ctx.b, "break used outside of loop"); } + b.beginInstrumentation(StandardTags.StatementTag.class); b.emitBranch(breakLabel); + b.endInstrumentation(); return null; } @@ -174,14 +185,18 @@ public Void visitContinue_statement(Continue_statementContext ctx) { SemErr(ctx.c, "continue used outside of loop"); } + b.beginInstrumentation(StandardTags.StatementTag.class); b.emitBranch(continueLabel); + b.endInstrumentation(); return null; } @Override public Void visitDebugger_statement(Debugger_statementContext ctx) { - // TODO + b.beginInstrumentation(DebuggerTags.AlwaysHalt.class); + b.endInstrumentation(); + return null; } @@ -190,6 +205,8 @@ public Void visitWhile_statement(While_statementContext ctx) { OperationLabel oldBreak = breakLabel; OperationLabel oldContinue = continueLabel; + b.beginInstrumentation(StandardTags.StatementTag.class); + breakLabel = b.createLabel(); continueLabel = b.createLabel(); @@ -204,6 +221,8 @@ public Void visitWhile_statement(While_statementContext ctx) { b.endWhile(); b.emitLabel(breakLabel); + b.endInstrumentation(); + breakLabel = oldBreak; continueLabel = oldContinue; @@ -212,6 +231,8 @@ public Void visitWhile_statement(While_statementContext ctx) { @Override public Void visitIf_statement(If_statementContext ctx) { + b.beginInstrumentation(StandardTags.StatementTag.class); + if (ctx.alt == null) { b.beginIfThen(); @@ -234,11 +255,13 @@ public Void visitIf_statement(If_statementContext ctx) { b.endIfThenElse(); } + b.endInstrumentation(); return null; } @Override public Void visitReturn_statement(Return_statementContext ctx) { + b.beginInstrumentation(StandardTags.StatementTag.class); b.beginReturn(); if (ctx.expression() == null) { @@ -248,6 +271,7 @@ public Void visitReturn_statement(Return_statementContext ctx) { } b.endReturn(); + b.endInstrumentation(); return null; } @@ -290,6 +314,8 @@ public Void visitExpression(ExpressionContext ctx) { if (numTerms == 1) return visit(ctx.logic_term(0)); + b.beginInstrumentation(StandardTags.ExpressionTag.class); + int[] locals = new int[numTerms - 1]; for (int i = 0; i < numTerms - 1; i++) { locals[i] = scope.create(); @@ -307,6 +333,7 @@ public Void visitExpression(ExpressionContext ctx) { logicalOrMiddle(locals[i]); } } + b.endInstrumentation(); return null; } @@ -350,6 +377,7 @@ public Void visitLogic_term(Logic_termContext ctx) { return visit(ctx.logic_factor(0)); } + b.beginInstrumentation(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); int[] locals = new int[numTerms - 1]; @@ -371,6 +399,7 @@ public Void visitLogic_term(Logic_termContext ctx) { } b.endSLUnboxOperation(); + b.endInstrumentation(); return null; } @@ -381,6 +410,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { return visit(ctx.arithmetic(0)); } + b.beginInstrumentation(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); switch (ctx.OP_COMPARE().getText()) { @@ -429,6 +459,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { } b.endSLUnboxOperation(); + b.endInstrumentation(); return null; } @@ -437,6 +468,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { public Void visitArithmetic(ArithmeticContext ctx) { if (!ctx.OP_ADD().isEmpty()) { + b.beginInstrumentation(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); } @@ -468,6 +500,7 @@ public Void visitArithmetic(ArithmeticContext ctx) { if (!ctx.OP_ADD().isEmpty()) { b.endSLUnboxOperation(); + b.endInstrumentation(); } return null; @@ -476,6 +509,7 @@ public Void visitArithmetic(ArithmeticContext ctx) { @Override public Void visitTerm(TermContext ctx) { if (!ctx.OP_MUL().isEmpty()) { + b.beginInstrumentation(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); } for (int i = ctx.OP_MUL().size() - 1; i >= 0; i--) { @@ -510,6 +544,7 @@ public Void visitTerm(TermContext ctx) { if (!ctx.OP_MUL().isEmpty()) { b.endSLUnboxOperation(); + b.endInstrumentation(); } return null; @@ -538,6 +573,8 @@ private void buildMemberExpressionRead(Token ident, List Date: Fri, 25 Mar 2022 12:14:09 +0100 Subject: [PATCH 026/312] [wip] dsl state --- .../test/example/TestOperations.java | 4 +- .../truffle/api/operation/OperationsNode.java | 44 +++---- .../api/operation/OperationsRootNode.java | 62 ++++++++++ .../dsl/processor/generator/BitSet.java | 44 +++++-- .../generator/FlatNodeGenFactory.java | 89 ++++++++++--- .../generator/NodeCodeGenerator.java | 12 +- .../generator/NodeGeneratorPlugs.java | 35 ++++++ .../processor/library/ExportsGenerator.java | 6 +- .../OperationsBytecodeCodeGenerator.java | 117 +++++++++++++----- .../operations/SingleOperationParser.java | 2 + .../instructions/CustomInstruction.java | 32 +++++ .../operations/instructions/Instruction.java | 20 ++- .../src/com/oracle/truffle/sl/SLLanguage.java | 2 +- .../nodes/expression/SLLessOrEqualNode.java | 3 +- .../nodes/expression/SLWritePropertyNode.java | 5 +- .../truffle/sl/operations/SLOperations.java | 7 +- 16 files changed, 382 insertions(+), 102 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 0a5f51ab1103..192bfa7b4726 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,8 +1,8 @@ package com.oracle.truffle.api.operation.test.example; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; @@ -62,7 +62,7 @@ public static long bla(long a1, @Variadic Object[] a2) { @Operation static class ThrowOperation { @Specialization - public static void perform(@Cached("$bci") int bci, @Cached("this") OperationsNode node) { + public static void perform(@Bind("$bci") int bci, @Bind("this") OperationsNode node) { throw new TestException("fail", node, bci); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index cfba66138d7d..163512bd3078 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,18 +1,17 @@ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.tracing.NodeTrace; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -public abstract class OperationsNode extends RootNode implements InstrumentableNode { +public abstract class OperationsNode extends Node implements InstrumentableNode { protected static final int BCI_SLOT = 0; protected static final int VALUES_OFFSET = 1; @@ -32,6 +31,7 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals protected final int maxLocals; protected final String nodeName; + protected final TruffleLanguage language; protected final Object parseContext; protected int[][] sourceInfo; protected Source[] sources; @@ -48,7 +48,7 @@ protected OperationsNode( int buildOrder, int maxStack, int maxLocals) { - super(language, createFrameDescriptor(maxStack, maxLocals)); + this.language = language; this.buildOrder = buildOrder; this.parseContext = parseContext; this.nodeName = nodeName; @@ -59,20 +59,22 @@ protected OperationsNode( this.maxStack = maxStack; } - public abstract Object continueAt(VirtualFrame frame, OperationLabel index); - - public abstract String dump(); + public FrameDescriptor createFrameDescriptor() { + return createFrameDescriptor(maxStack, maxLocals); + } - @Override - public String getName() { - return nodeName; + public OperationsRootNode createRootNode() { + return new OperationsRootNode(this); } - @Override - public boolean isInternal() { - return isInternal; + public final Object execute(VirtualFrame frame) { + return continueAt(frame, null); } + public abstract Object continueAt(VirtualFrame frame, OperationLabel index); + + public abstract String dump(); + public NodeTrace getNodeTrace() { throw new UnsupportedOperationException("Operations not built with tracing"); } @@ -117,17 +119,6 @@ protected final SourceSection getSourceSectionAtBciImpl(int bci) { } } - @Override - public boolean isCaptureFramesForTrace() { - return true; - } - - @Override - protected Object translateStackTraceElement(TruffleStackTraceElement element) { - int bci = element.getFrame().getInt(BCI_SLOT); - return new OperationsStackTraceElement(element.getTarget().getRootNode(), getSourceSectionAtBci(bci)); - } - public final Node createFakeLocationNode(final int bci) { return new Node() { @Override @@ -146,4 +137,9 @@ public SourceSection getEncapsulatingSourceSection() { public boolean isInstrumentable() { return true; } + + public WrapperNode createWrapper(ProbeNode probe) { + // TODO Auto-generated method stub + return null; + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java new file mode 100644 index 000000000000..acdd672da738 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -0,0 +1,62 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.TruffleStackTraceElement; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; + +public class OperationsRootNode extends RootNode implements InstrumentableNode { + + private final OperationsNode node; + + OperationsRootNode(OperationsNode node) { + super(node.language, node.createFrameDescriptor()); + this.node = node; + } + + @Override + public String getName() { + return node.nodeName; + } + + @Override + public boolean isInternal() { + return node.isInternal; + } + + @Override + public Object execute(VirtualFrame frame) { + return node.execute(frame); + } + + @Override + public boolean isCaptureFramesForTrace() { + return true; + } + + @Override + protected Object translateStackTraceElement(TruffleStackTraceElement element) { + int bci = element.getFrame().getInt(OperationsNode.BCI_SLOT); + return new OperationsStackTraceElement(element.getTarget().getRootNode(), node.getSourceSectionAtBci(bci)); + } + + @Override + public boolean isInstrumentable() { + return true; + } + + public WrapperNode createWrapper(final ProbeNode probe) { + return new WrapperNode() { + public Node getDelegateNode() { + return OperationsRootNode.this; + } + + public ProbeNode getProbeNode() { + return probe; + } + }; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 8d5471892231..691c5454c437 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -58,7 +58,7 @@ import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; -class BitSet { +public class BitSet { private static final Object[] EMPTY_OBJECTS = new Object[0]; @@ -68,18 +68,28 @@ class BitSet { private final Object[] objects; private final long allMask; private final TypeMirror type; + private NodeGeneratorPlugs plugs; - BitSet(String name, Object[] objects) { + BitSet(String name, Object[] objects, NodeGeneratorPlugs plugs) { this.name = name; this.objects = objects; this.capacity = intializeCapacity(); + TypeMirror typeTmp; if (capacity <= 32) { - type = ProcessorContext.getInstance().getType(int.class); + typeTmp = ProcessorContext.getInstance().getType(int.class); } else if (capacity <= 64) { - type = ProcessorContext.getInstance().getType(long.class); + typeTmp = ProcessorContext.getInstance().getType(long.class); } else { throw new UnsupportedOperationException("State space too big " + capacity + ". Only <= 64 supported."); } + + if (plugs != null) { + type = plugs.getBitSetType(typeTmp); + } else { + type = typeTmp; + } + + this.plugs = plugs; this.allMask = createMask(objects); } @@ -128,7 +138,11 @@ private CodeTree createLocalReference(FrameState frameState) { public CodeTree createReference(FrameState frameState) { CodeTree ref = createLocalReference(frameState); if (ref == null) { - ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); + if (plugs != null) { + ref = plugs.createBitSetReference(this); + } else { + ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); + } } return ref; } @@ -167,7 +181,11 @@ public CodeTree createLoad(FrameState frameState) { String fieldName = name + "_"; LocalVariable var = new LocalVariable(type, name, null); CodeTreeBuilder init = builder.create(); - init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); + if (plugs != null) { + init.tree(plugs.createBitSetReference(this)); + } else { + init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); + } builder.tree(var.createDeclaration(init.build())); frameState.set(name, var); return builder.build(); @@ -349,7 +367,11 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); if (persist) { - builder.string("this.", name, "_ = "); + if (plugs != null) { + builder.tree(plugs.createBitSetReference(this)).string(" = "); + } else { + builder.string("this.", name, "_ = "); + } // if there is a local variable we need to update it as well CodeTree localReference = createLocalReference(frameState); @@ -359,7 +381,13 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu } else { builder.tree(createReference(frameState)).string(" = "); } - builder.tree(valueTree); + + CodeTree value = valueTree; + if (plugs != null) { + value = plugs.transformValueBeforePersist(value); + } + + builder.tree(value); builder.end(); // statement return builder.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index e83dfe63f7e7..f40826b76465 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -201,25 +201,28 @@ public String toString() { private final boolean needsSpecializeLocking; private final GeneratorMode generatorMode; + private final NodeGeneratorPlugs plugs; + public enum GeneratorMode { DEFAULT, EXPORTED_MESSAGE } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants); + StaticConstants constants, NodeGeneratorPlugs plugs) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, plugs); } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, - StaticConstants constants) { + StaticConstants constants, NodeGeneratorPlugs plugs) { Objects.requireNonNull(node); this.generatorMode = mode; this.context = context; this.sharingNodes = stateSharingNodes; this.node = node; + this.plugs = plugs; this.typeSystem = node.getTypeSystem(); this.genericType = context.getType(Object.class); this.boxingEliminationEnabled = !TruffleProcessorOptions.generateSlowPathOnly(context.getEnvironment()); @@ -282,7 +285,7 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData } this.multiState = createMultiStateBitset(stateObjects, activeStateStartIndex, activeStateEndIndex, volatileState); this.allMultiState = new MultiStateBitSet(this.multiState.all, this.multiState.all); - this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState); + this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState, plugs); this.executeAndSpecializeType = createExecuteAndSpecializeType(); this.needsSpecializeLocking = exclude.getCapacity() != 0 || reachableSpecializations.stream().anyMatch((s) -> !s.getCaches().isEmpty()); @@ -298,6 +301,10 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData private MultiStateBitSet createMultiStateBitset(List stateObjects, int activeStateStartIndex, int activeStateEndIndex, boolean volatileState) { int maxBits = TruffleProcessorOptions.stateBitWidth(context.getEnvironment()); + if (plugs != null) { + maxBits = plugs.getMaxStateBits(maxBits); + } + int usedBits = 0; List allStateBits = new ArrayList<>(); List currentElements = new ArrayList<>(); @@ -319,7 +326,7 @@ private MultiStateBitSet createMultiStateBitset(List stateObjects, int a } allStateBits.add(new StateBitSet(currentElements.toArray(), relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size())); + volatileState, allStateBits.size(), plugs)); currentElements.clear(); relevantSpecializations.clear(); usedBits = 0; @@ -346,7 +353,7 @@ private MultiStateBitSet createMultiStateBitset(List stateObjects, int a allStateBits.add(new StateBitSet(currentElements.toArray(), relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size())); + volatileState, allStateBits.size(), plugs)); List activeStateBits = allStateBits.subList(activeStartBits, activeEndBits + 1); return new MultiStateBitSet(allStateBits, activeStateBits); @@ -373,11 +380,18 @@ private boolean hasMultipleNodes() { } private String createSpecializationTypeName(SpecializationData s) { + String result; if (hasMultipleNodes()) { - return firstLetterUpperCase(getNodePrefix(s)) + firstLetterUpperCase(s.getId()) + "Data"; + result = firstLetterUpperCase(getNodePrefix(s)) + firstLetterUpperCase(s.getId()) + "Data"; } else { - return firstLetterUpperCase(s.getId()) + "Data"; + result = firstLetterUpperCase(s.getId()) + "Data"; } + + if (plugs != null) { + result = plugs.transformNodeInnerTypeName(result); + } + + return result; } private String createSpecializationFieldName(SpecializationData s) { @@ -2033,27 +2047,41 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, } private String createFallbackName() { + String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - return firstLetterLowerCase(messageName) + "FallbackGuard_"; + result = firstLetterLowerCase(messageName) + "FallbackGuard_"; } else { - return "fallbackGuard_"; + result = "fallbackGuard_"; + } + + if (plugs != null) { + result = plugs.transformNodeMethodName(result); } + + return result; } private String createExecuteAndSpecializeName() { + String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - return firstLetterLowerCase(messageName) + "AndSpecialize"; + result = firstLetterLowerCase(messageName) + "AndSpecialize"; } else { - return "executeAndSpecialize"; + result = "executeAndSpecialize"; + } + + if (plugs != null) { + result = plugs.transformNodeMethodName(result); } + + return result; } private CodeExecutableElement createExecuteAndSpecialize() { @@ -2141,15 +2169,22 @@ private CodeExecutableElement createExecuteAndSpecialize() { private static final String COUNT_CACHES = "countCaches"; private String createName(String defaultName) { + String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - return firstLetterLowerCase(messageName) + "_" + defaultName; + result = firstLetterLowerCase(messageName) + "_" + defaultName; } else { - return defaultName; + result = defaultName; } + + if (plugs != null) { + result = plugs.transformNodeMethodName(result); + } + + return result; } private boolean requiresCacheCheck(ReportPolymorphismAction reportPolymorphismAction) { @@ -3166,9 +3201,14 @@ private CodeExecutableElement createExecuteMethod(ExecutableTypeData executedTyp methodName = executedType.getUniqueName(); } + if (plugs != null) { + methodName = plugs.transformNodeMethodName(methodName); + } + CodeExecutableElement executable; if (executedType.getMethod() != null) { executable = CodeExecutableElement.clone(executedType.getMethod()); + executable.setSimpleName(CodeNames.of(methodName)); executable.getAnnotationMirrors().clear(); executable.getModifiers().remove(ABSTRACT); for (VariableElement var : executable.getParameters()) { @@ -3248,6 +3288,9 @@ private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableT builder.tree(multiState.createLoad(frameState, fallbackState)); } builder.startIf().startCall(createFallbackName()); + if (plugs != null) { + plugs.addNodeCallParameters(builder); + } if (fallbackNeedsState) { multiState.addReferencesTo(frameState, builder, fallbackState); } @@ -3988,6 +4031,9 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt innerBuilder = boundaryMethod.createBuilder(); ((CodeTypeElement) parentMethod.getEnclosingElement()).add(boundaryMethod); builder.startReturn().startCall("this", boundaryMethod); + if (plugs != null) { + plugs.addNodeCallParameters(builder); + } multiState.addReferencesTo(frameState, builder); frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); builder.end().end(); @@ -4635,6 +4681,9 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startCall(createExecuteAndSpecializeName()); + if (plugs != null) { + plugs.addNodeCallParameters(builder); + } frameState.addReferencesTo(builder, frame); builder.end(); CodeTree call = builder.build(); @@ -5621,8 +5670,8 @@ private abstract static class NodeBitSet extends BitSet { private final boolean needsVolatile; - NodeBitSet(String name, Object[] objects, boolean needsVolatile) { - super(name, objects); + NodeBitSet(String name, Object[] objects, boolean needsVolatile, NodeGeneratorPlugs plugs) { + super(name, objects, plugs); this.needsVolatile = needsVolatile; } @@ -5647,8 +5696,8 @@ private class StateBitSet extends NodeBitSet { private final Set relevantSpecializations; - StateBitSet(Object[] objects, SpecializationData[] relevantSpecializations, boolean needsVolatile, int index) { - super("state_" + index, objects, needsVolatile); + StateBitSet(Object[] objects, SpecializationData[] relevantSpecializations, boolean needsVolatile, int index, NodeGeneratorPlugs plugs) { + super("state_" + index, objects, needsVolatile, plugs); this.relevantSpecializations = new HashSet<>(Arrays.asList(relevantSpecializations)); } @@ -5678,8 +5727,8 @@ boolean containsSpecialization() { private static class ExcludeBitSet extends NodeBitSet { - ExcludeBitSet(SpecializationData[] specializations, boolean needsVolatile) { - super("exclude", specializations, needsVolatile); + ExcludeBitSet(SpecializationData[] specializations, boolean needsVolatile, NodeGeneratorPlugs plugs) { + super("exclude", specializations, needsVolatile, plugs); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index 122419bc5645..ebb520d715bf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -75,6 +75,8 @@ public class NodeCodeGenerator extends CodeTypeElementFactory { + private NodeGeneratorPlugs plugs; + @Override public List create(ProcessorContext context, AnnotationProcessor processor, NodeData node) { StaticConstants constants = new StaticConstants(); @@ -90,7 +92,7 @@ public List create(ProcessorContext context, AnnotationProcesso return rootTypes; } - private static List createImpl(ProcessorContext context, NodeData node, StaticConstants constants) { + private List createImpl(ProcessorContext context, NodeData node, StaticConstants constants) { List enclosedTypes = new ArrayList<>(); for (NodeData childNode : node.getEnclosingNodes()) { List type = createImpl(context, childNode, constants); @@ -124,6 +126,10 @@ private static List createImpl(ProcessorContext context, NodeDa } } + public void setPlugs(NodeGeneratorPlugs plugs) { + this.plugs = plugs; + } + private static CodeTypeElement makeInnerClass(CodeTypeElement type) { Set modifiers = type.getModifiers(); modifiers.add(Modifier.STATIC); @@ -266,7 +272,7 @@ static String createNodeTypeName(TypeElement nodeType) { return resolveNodeId(nodeType) + NODE_SUFFIX; } - private static List generateNodes(ProcessorContext context, NodeData node, StaticConstants constants) { + private List generateNodes(ProcessorContext context, NodeData node, StaticConstants constants) { if (!node.needsFactory()) { return Collections.emptyList(); } @@ -278,7 +284,7 @@ private static List generateNodes(ProcessorContext context, Nod return Arrays.asList(type); } - type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants).create(type); + type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, plugs).create(type); return Arrays.asList(type); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java new file mode 100644 index 000000000000..a330e072976a --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -0,0 +1,35 @@ +package com.oracle.truffle.dsl.processor.generator; + +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class NodeGeneratorPlugs { + public String transformNodeMethodName(String name) { + return name; + } + + public String transformNodeInnerTypeName(String name) { + return name; + } + + public void addNodeCallParameters(CodeTreeBuilder builder) { + } + + public int getMaxStateBits(int defaultValue) { + return defaultValue; + } + + public TypeMirror getBitSetType(TypeMirror defaultType) { + return defaultType; + } + + public CodeTree createBitSetReference(BitSet bits) { + return CodeTreeBuilder.singleString("this." + bits.getName() + "_"); + } + + public CodeTree transformValueBeforePersist(CodeTree tree) { + return tree; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 09745276979c..1d85a185d49f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -629,7 +629,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map caches = new ArrayList<>(); for (CacheKey key : eagerCaches.keySet()) { caches.add(key.cache); @@ -809,7 +809,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private static final String DSL_METHOD_PREFIX = "execute_"; + private static final String DSL_CLASS_PREFIX = "Execute_"; + private final CodeTypeElement typBuilderImpl; private final String simpleName; private final ProcessorContext context; @@ -121,20 +125,76 @@ public CodeTypeElement createBuilderBytecodeNode() { } CustomInstruction cinstr = (CustomInstruction) instr; - SingleOperationData soData = cinstr.getData(); - CodeTypeElement result = new NodeCodeGenerator().create(context, null, soData.getNodeData()).get(0); + final SingleOperationData soData = cinstr.getData(); + final List bitSets = new ArrayList<>(); - CodeExecutableElement uncExec = null; - loop: for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { - if (te.getSimpleName().toString().equals("Uncached")) { - for (ExecutableElement ex : ElementFilter.methodsIn(te.getEnclosedElements())) { - if (ex.getSimpleName().toString().equals("execute")) { - uncExec = (CodeExecutableElement) ex; - break loop; - } + NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { + @Override + public String transformNodeMethodName(String name) { + return DSL_METHOD_PREFIX + name + "_" + soData.getName(); + } + + @Override + public String transformNodeInnerTypeName(String name) { + return DSL_CLASS_PREFIX + name + "_" + soData.getName(); + } + + @Override + public void addNodeCallParameters(CodeTreeBuilder builder) { + builder.string("$bci"); + } + + @Override + public int getMaxStateBits(int defaultValue) { + return 8; + } + + @Override + public TypeMirror getBitSetType(TypeMirror defaultType) { + return new CodeTypeMirror(TypeKind.BYTE); + } + + @Override + public CodeTree createBitSetReference(BitSet bits) { + int index = bitSets.indexOf(bits); + if (index == -1) { + index = bitSets.size(); + bitSets.add(bits); } + + return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); + } + + @Override + public CodeTree transformValueBeforePersist(CodeTree tree) { + return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); + } + }; + NodeCodeGenerator generator = new NodeCodeGenerator(); + generator.setPlugs(plugs); + + CodeTypeElement result = generator.create(context, null, soData.getNodeData()).get(0); + + CodeExecutableElement uncExec = null; + List execs = new ArrayList<>(); + for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { + if (!ex.getSimpleName().toString().startsWith(DSL_METHOD_PREFIX)) { + continue; + } + + if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName("execute"))) { + uncExec = (CodeExecutableElement) ex; } + execs.add((CodeExecutableElement) ex); + } + + for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { + if (!te.getSimpleName().toString().startsWith(DSL_CLASS_PREFIX)) { + continue; + } + + builderBytecodeNodeType.add(te); } for (VariableElement ve : ElementFilter.fieldsIn(result.getEnclosedElements())) { @@ -154,13 +214,17 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(ve); } - uncExec.setSimpleName(CodeNames.of("execute" + soData.getName() + "_")); - uncExec.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); - uncExec.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); - - builderBytecodeNodeType.add(uncExec); + for (CodeExecutableElement exToCopy : execs) { + exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + exToCopy.getModifiers().remove(Modifier.PUBLIC); + exToCopy.getModifiers().add(Modifier.PRIVATE); + exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); + exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); + builderBytecodeNodeType.add(exToCopy); + } cinstr.setExecuteMethod(uncExec); + cinstr.setAdditionalStateBytes(bitSets.size()); } } @@ -172,21 +236,6 @@ public CodeTypeElement createBuilderBytecodeNode() { // vars.handlers = fldHandlers; // vars.tracer = fldTracer; - { - CodeExecutableElement mExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(Object.class), "execute", new CodeVariableElement(types.VirtualFrame, "frame")); - builderBytecodeNodeType.add(mExecute); - - CodeTreeBuilder builder = mExecute.getBuilder(); - builder.startReturn(); - builder.startCall("continueAt"); - - builder.string("frame"); - builder.string("null"); - - builder.end(2); - - } - { CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); CodeVariableElement argStartIndex = new CodeVariableElement(types.OperationLabel, "startIndex"); @@ -635,7 +684,7 @@ private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { b.startStatement(); b.string("OperationsNode reparsed = "); b.startStaticCall(typBuilderImpl.asType(), "reparse"); - b.startCall("getLanguage").typeLiteral(m.getLanguageType()).end(); + b.startGroup().cast(m.getLanguageType()).string("this.language").end(); b.startGroup().cast(m.getParseContextType()).string("parseContext").end(); b.string("buildOrder"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 095090595caf..6444a4aae51f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -201,6 +201,8 @@ private boolean isIgnoredParameter(VariableElement param) { return true; } else if (ElementUtils.findAnnotationMirror(param, types.CachedContext) != null) { return true; + } else if (ElementUtils.findAnnotationMirror(param, types.Bind) != null) { + return true; } return false; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 61065c41aafb..7a2a009625b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -5,12 +5,14 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public class CustomInstruction extends Instruction { private final SingleOperationData data; private ExecutableElement executeMethod; + private int stateBytes = -1; public SingleOperationData getData() { return data; @@ -41,6 +43,23 @@ public CustomInstruction(String name, int id, SingleOperationData data) { this.data = data; } + @Override + protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { + if (getAdditionalStateBytes() == 0) { + return null; + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + int lengthWithoutState = lengthWithoutState(); + + for (int i = 0; i < stateBytes; i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + (lengthWithoutState + i) + "] = 0").end(); + } + + return b.build(); + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -72,4 +91,17 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + + @Override + public int getAdditionalStateBytes() { + if (stateBytes == -1) { + throw new UnsupportedOperationException("state bytes not yet initialized"); + } + + return stateBytes; + } + + public void setAdditionalStateBytes(int size) { + stateBytes = size; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 12b6eaa13975..63ff451f3f17 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -369,10 +369,14 @@ public boolean needsBuilderArgument(int index) { } } - public int length() { + public int lengthWithoutState() { return getArgumentOffset(inputs.length + results.length); } + public int length() { + return lengthWithoutState() + getAdditionalStateBytes(); + } + public List getBuilderArgumentTypes() { ProcessorContext context = ProcessorContext.getInstance(); List result = new ArrayList<>(); @@ -406,6 +410,10 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { b.tree(createWriteArgumentCode(i, vars, argument)); } + // emit state bytes + + b.tree(createInitializeAdditionalStateBytes(vars, arguments)); + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); // calculate stack offset @@ -447,4 +455,14 @@ public CodeTree numPop(BuilderVariables vars) { public boolean isInstrumentationOnly() { return false; } + + // state + + public int getAdditionalStateBytes() { + return 0; + } + + protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { + return null; + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 586e11062845..b04b6f007e74 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -328,7 +328,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { } OperationsNode[] operations = SLOperationsBuilder.parse(this, source); - return operations[operations.length - 1].getCallTarget(); + return operations[operations.length - 1].createRootNode().getCallTarget(); } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java index 1af642120863..793b3ee97c71 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -68,7 +69,7 @@ public static boolean lessOrEqual(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 51a71ee88a60..79f42d90f990 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -101,8 +102,8 @@ public static Object writeSLObject(SLObject receiver, Object name, Object value, @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") public static Object writeObject(Object receiver, Object name, Object value, - @Cached("this") Node node, - @Cached("$bci") int bci, + @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 31d5973b490c..7c647948a737 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -4,6 +4,7 @@ import java.util.Map; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -66,7 +67,7 @@ public static class SLEvalRootOperation { public static Object perform( VirtualFrame frame, Map functions, - @Cached("this") Node node) { + @Bind("this") Node node) { SLContext.get(node).getFunctionRegistry().register((Map) functions); RootCallTarget main = (RootCallTarget) functions.get(SLStrings.MAIN); @@ -98,7 +99,7 @@ public static class SLEqualOperation { @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @Cached("this") Node node) { + public static Object execute(TruffleString functionName, @Bind("this") Node node) { Object res = SLContext.get(node).getFunctionRegistry().lookup(functionName, true); return res; } @@ -162,7 +163,7 @@ public static class SLUnboxOperation { @TypeSystemReference(SLTypes.class) public static class SLConvertToBoolean { @Specialization - public static boolean perform(Object obj, @Cached("this") Node node, @Cached("$bci") int bci) { + public static boolean perform(Object obj, @Bind("this") Node node, @Bind("$bci") int bci) { try { return SLTypesGen.expectBoolean(obj); } catch (UnexpectedResultException e) { From 53baa967fdb53a3716eb80ea182ff5bc0fa47802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 28 Mar 2022 14:30:10 +0200 Subject: [PATCH 027/312] [wip] implement caching --- .../operation/test/example/TestLanguage.java | 2 +- .../test/example/TestOperations.java | 1 - .../example/TestOperationsParserTest.java | 9 +- .../api/operation/OperationsConstantPool.java | 8 ++ .../api/operation/OperationsRootNode.java | 28 +++-- .../dsl/processor/generator/BitSet.java | 5 + .../generator/FlatNodeGenFactory.java | 87 ++++++++++----- .../generator/NodeGeneratorPlugs.java | 41 ++++--- .../dsl/processor/operations/Operation.java | 1 + .../OperationsBytecodeCodeGenerator.java | 100 +++++++++++++++++- .../operations/OperationsCodeGenerator.java | 7 ++ .../operations/OperationsParser.java | 2 +- .../operations/SingleOperationParser.java | 9 +- .../instructions/CustomInstruction.java | 67 ++++++++++-- .../operations/instructions/Instruction.java | 16 +++ .../sl/nodes/expression/SLAddNode.java | 3 +- .../sl/nodes/expression/SLDivNode.java | 3 +- .../sl/nodes/expression/SLLessThanNode.java | 3 +- .../sl/nodes/expression/SLLogicalNotNode.java | 3 +- .../sl/nodes/expression/SLMulNode.java | 3 +- .../nodes/expression/SLReadPropertyNode.java | 15 +-- .../sl/nodes/expression/SLSubNode.java | 3 +- .../nodes/expression/SLWritePropertyNode.java | 2 +- .../truffle/sl/nodes/util/SLUnboxNode.java | 2 +- .../truffle/sl/operations/SLOperations.java | 2 +- .../operations/SLOperationsVisitor.java | 2 +- 26 files changed, 331 insertions(+), 93 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java index 6781f9ce8aa1..32b4b4430162 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java @@ -16,7 +16,7 @@ protected TestContext createContext(TruffleLanguage.Env env) { @Override protected CallTarget parse(ParsingRequest request) throws Exception { OperationsNode[] nodes = TestOperationsBuilder.parse(this, request.getSource()); - return nodes[nodes.length - 1].getCallTarget(); + return nodes[nodes.length - 1].createRootNode().getCallTarget(); } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 192bfa7b4726..709c74811af4 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,7 +1,6 @@ package com.oracle.truffle.api.operation.test.example; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 1aa184d978d8..dd5b7d890874 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -16,15 +16,16 @@ import com.oracle.truffle.api.TruffleStackTrace; import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.OperationsRootNode; import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -@RunWith(JUnit4.class) public class TestOperationsParserTest { private static class Tester { private final OperationsNode node; + private final OperationsRootNode rootNode; Tester(String src, boolean withSourceInfo) { Source s = Source.newBuilder("test", src, "test").build(); @@ -34,6 +35,7 @@ private static class Tester { } else { node = TestOperationsBuilder.parse(null, s)[0]; } + rootNode = node.createRootNode(); System.out.println(node.dump()); } @@ -42,7 +44,7 @@ private static class Tester { } public Tester test(Object expectedResult, Object... arguments) { - Object result = node.getCallTarget().call(arguments); + Object result = rootNode.getCallTarget().call(arguments); Assert.assertEquals(expectedResult, result); return this; } @@ -56,8 +58,11 @@ public Tester then(Consumer action) { @Test public void testAdd() { new Tester("(return (add (arg 0) (arg 1)))")// + .then(x -> System.out.println(x.dump())) // .test(42L, 20L, 22L) // + .then(x -> System.out.println(x.dump())) // .test("foobar", "foo", "bar") // + .then(x -> System.out.println(x.dump())) // .test(100L, 120L, -20L); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java index a529b7ac17ac..0e7d3e9b541e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java @@ -19,6 +19,14 @@ public synchronized int add(Object o) { return idx; } + public synchronized int reserve() { + if (frozen) + throw new IllegalStateException("constant pool already frozen"); + int idx = values.size(); + values.add(null); + return idx; + } + public synchronized void reset() { this.frozen = false; this.values = new ArrayList<>(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index acdd672da738..52fc3233baa1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -9,7 +9,7 @@ public class OperationsRootNode extends RootNode implements InstrumentableNode { - private final OperationsNode node; + @Child private OperationsNode node; OperationsRootNode(OperationsNode node) { super(node.language, node.createFrameDescriptor()); @@ -47,16 +47,24 @@ public boolean isInstrumentable() { return true; } + private class OperationsWrapperNode extends Node implements WrapperNode { + private final ProbeNode probe; + + OperationsWrapperNode(ProbeNode probe) { + this.probe = probe; + } + + public Node getDelegateNode() { + return OperationsRootNode.this; + } + + public ProbeNode getProbeNode() { + return probe; + } + } + public WrapperNode createWrapper(final ProbeNode probe) { - return new WrapperNode() { - public Node getDelegateNode() { - return OperationsRootNode.this; - } - - public ProbeNode getProbeNode() { - return probe; - } - }; + return new OperationsWrapperNode(probe); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 691c5454c437..da8cf885a7f5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -48,6 +48,7 @@ import java.util.List; import java.util.Map; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -55,6 +56,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; @@ -397,6 +399,9 @@ public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); builder.tree(createReference(frameState)).string(" = "); + if (type.getKind() == TypeKind.BYTE) { + builder.cast(type); + } builder.startParantheses(); builder.tree(createReference(frameState)); builder.string(" | ("); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index f40826b76465..08417dc466c3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -447,15 +447,18 @@ private static String nodeFieldName(NodeExecutionData execution) { } } - private static String accessNodeField(NodeExecutionData execution) { + private CodeTree accessNodeField(NodeExecutionData execution) { + if (plugs != null) { + return plugs.createNodeFieldReference(execution, nodeFieldName(execution), true); + } if (execution.getChild() == null || execution.getChild().needsGeneratedField()) { - return "this." + nodeFieldName(execution); + return CodeTreeBuilder.singleString("this." + nodeFieldName(execution)); } else { String access = "super." + execution.getChild().getName(); if (execution.hasChildArrayIndex()) { access += "[" + execution.getChildArrayIndex() + "]"; } - return access; + return CodeTreeBuilder.singleString(access); } } @@ -945,11 +948,11 @@ private void generateAOT(CodeTypeElement clazz) { */ boolean cachedLibrary = cache.isCachedLibrary(); if (cachedLibrary) { - builder.startIf().tree(createCacheReference(innerFrameState, specialization, cache)).instanceOf(aotProviderType).end().startBlock(); + builder.startIf().tree(createCacheReference(innerFrameState, specialization, cache, true)).instanceOf(aotProviderType).end().startBlock(); } if (NodeCodeGenerator.isSpecializedNode(cache.getParameter().getType()) || cachedLibrary) { builder.startAssert().startStaticCall(types.NodeUtil, "assertRecursion"); - builder.tree(createCacheReference(innerFrameState, specialization, cache)); + builder.tree(createCacheReference(innerFrameState, specialization, cache, true)); /* * We allow a single recursion level only for AOT preparation. It is important * that we only assert recursion for @Cached fields as regular AST children can @@ -963,7 +966,7 @@ private void generateAOT(CodeTypeElement clazz) { builder.startStatement(); builder.string("("); builder.cast(aotProviderType); - builder.tree(createCacheReference(innerFrameState, specialization, cache)); + builder.tree(createCacheReference(innerFrameState, specialization, cache, true)); builder.string(")"); builder.string(".prepareForAOT(language, root)"); builder.end(); @@ -1026,7 +1029,7 @@ private void generateAOT(CodeTypeElement clazz) { builder.startBlock(); for (CacheExpression cache : resetCaches) { builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache)); + builder.tree(createCacheReference(frameState, specialization, cache, true)); builder.string(".reset()"); builder.end(); } @@ -1058,7 +1061,7 @@ private void generateAOT(CodeTypeElement clazz) { break; } builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache)).string(" = null"); + builder.tree(createCacheReference(frameState, specialization, cache, false)).string(" = null"); builder.end(); } } @@ -1190,7 +1193,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { builder.staticReference(createLibraryConstant(constants, cache.getParameter().getType())); builder.startCall(".getUncached").end(); } else { - builder.tree(createCacheReference(frameState, specialization, cache)); + builder.tree(createCacheReference(frameState, specialization, cache, true)); } builder.end(); } @@ -2355,7 +2358,7 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram NodeChildData child = execution.getChild(); LocalVariable var = frameState.getValue(execution); if (child != null && !frameState.getMode().isUncached()) { - builder.string(accessNodeField(execution)); + builder.tree(accessNodeField(execution)); } else { builder.string("null"); } @@ -2798,7 +2801,12 @@ private CodeExecutableElement createNodeConstructor(CodeTypeElement clazz, Execu CreateCastData createCast = node.findCast(execution.getChild().getName()); builder.startStatement(); - builder.string("this.").string(nodeFieldName(execution)).string(" = "); + if (plugs != null) { + builder.tree(plugs.createNodeFieldReference(execution, nodeFieldName(execution), false)); + } else { + builder.string("this.").string(nodeFieldName(execution)); + } + builder.string(" = "); String name = childValues.get(node.getChildren().indexOf(execution.getChild())); CodeTree accessor; @@ -2985,12 +2993,12 @@ private ExecutableElement createAccessChildMethod(NodeChildData child, boolean u if (child.getCardinality().isMany()) { builder.startReturn().startNewArray((ArrayType) child.getOriginalType(), null); for (NodeExecutionData execution : executions) { - builder.string(accessNodeField(execution)); + builder.tree(accessNodeField(execution)); } builder.end().end(); } else { for (NodeExecutionData execution : executions) { - builder.startReturn().string(accessNodeField(execution)).end(); + builder.startReturn().tree(accessNodeField(execution)).end(); break; } } @@ -3109,7 +3117,7 @@ private CodeTree[] bindExecuteMethodParameters(NodeExecutionData execution, Exec } private CodeTree callChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { - return callMethod(frameState, CodeTreeBuilder.singleString(accessNodeField(execution)), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); + return callMethod(frameState, accessNodeField(execution), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); } private CodeTree callUncachedChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { @@ -3339,7 +3347,7 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par if (var != null) { bindings[i] = var.createReference(); } else { - bindings[i] = createCacheReference(frameState, specialization, specialization.findCache(parameter)); + bindings[i] = createCacheReference(frameState, specialization, specialization.findCache(parameter), true); } bindingTypes[i] = parameter.getType(); } else { @@ -4014,12 +4022,18 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt if (usedBoundaryNames.contains(boundaryMethodName)) { boundaryMethodName = boundaryMethodName + (boundaryIndex++); } + + if (plugs != null) { + boundaryMethodName = plugs.transformNodeMethodName(boundaryMethodName); + } + usedBoundaryNames.add(boundaryMethodName); String includeFrameParameter = null; if (specialization != null && specialization.getFrame() != null) { includeFrameParameter = FRAME_VALUE; } + CodeExecutableElement boundaryMethod = new CodeExecutableElement(modifiers(PRIVATE), parentMethod.getReturnType(), boundaryMethodName); GeneratorUtils.mergeSupressWarnings(boundaryMethod, "static-method"); multiState.addParametersTo(frameState, boundaryMethod); @@ -4214,7 +4228,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (types.Profile != null && ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile)) { CodeTreeBuilder b = builder.create(); b.startStatement(); - b.tree(createCacheReference(frameState, specialization, cache)); + b.tree(createCacheReference(frameState, specialization, cache, true)); b.string(".disable()"); b.end(); triples.add(new IfTriple(null, null, b.build())); @@ -4240,7 +4254,14 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, builder.tree(exclude.createSet(frameState, excludesArray, true, true)); for (SpecializationData excludes : excludesArray) { if (useSpecializationClass(excludes)) { - builder.statement("this." + createSpecializationFieldName(excludes) + " = null"); + if (plugs != null) { + builder.startStatement(); + builder.tree(plugs.createSpecializationFieldReference(excludes, null, true, null)); + builder.string(" = null"); + builder.end(); + } else { + builder.statement("this." + createSpecializationFieldName(excludes) + " = null"); + } } } builder.tree((multiState.createSet(frameState, excludesArray, false, false))); @@ -4320,7 +4341,11 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.end(); builder.end(); builder.startStatement(); - builder.string("this.", createSpecializationFieldName(specialization)); + if (plugs != null) { + builder.tree(plugs.createSpecializationFieldReference(specialization, null, true, null)); + } else { + builder.string("this.", createSpecializationFieldName(specialization)); + } builder.string(" = "); builder.tree(ref); builder.end(); @@ -4355,7 +4380,12 @@ private Collection initializeSpecializationClass(FrameState } initBuilder.startNew(typeName); if (specialization.getMaximumNumberOfInstances() > 1) { - initBuilder.string(createSpecializationFieldName(specialization)); + if (plugs != null) { + initBuilder.tree(plugs.createSpecializationFieldReference(specialization, null, useSpecializationClass, + new GeneratedTypeMirror("", createSpecializationTypeName(specialization)))); + } else { + initBuilder.string(createSpecializationFieldName(specialization)); + } } initBuilder.end(); // new if (isNode) { @@ -4887,7 +4917,7 @@ private Collection persistCache(FrameState frameState, SpecializationD } } - CodeTree cacheReference = createCacheReference(frameState, specialization, cache); + CodeTree cacheReference = createCacheReference(frameState, specialization, cache, false); if (cache.isUsedInGuard() && !cache.isEagerInitialize() && sharedCaches.containsKey(cache) && !ElementUtils.isPrimitive(cache.getParameter().getType())) { builder.startIf().tree(cacheReference).string(" == null").end().startBlock(); @@ -5171,7 +5201,7 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati CodeTree ref; if (localVariable == null) { CacheExpression cache = specialization.findCache(resolvedParameter); - ref = createCacheReference(frameState, specialization, cache); + ref = createCacheReference(frameState, specialization, cache, true); } else { ref = localVariable.createReference(); } @@ -5189,14 +5219,19 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati } private CodeTree createSpecializationFieldReference(FrameState frameState, SpecializationData s, String fieldName) { + boolean useSpecializationClass = useSpecializationClass(s); CodeTreeBuilder builder = new CodeTreeBuilder(null); - if (useSpecializationClass(s)) { + if (useSpecializationClass) { String localName = createSpecializationLocalName(s); LocalVariable var = frameState.get(localName); if (var != null) { builder.string(localName); } else { - builder.string("this.", createSpecializationFieldName(s)); + if (plugs != null) { + builder.tree(plugs.createSpecializationFieldReference(s, fieldName, true, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); + } else { + builder.string("this.", createSpecializationFieldName(s)); + } } } else { builder.string("this"); @@ -5208,7 +5243,7 @@ private CodeTree createSpecializationFieldReference(FrameState frameState, Speci return builder.build(); } - private CodeTree createCacheReference(FrameState frameState, SpecializationData specialization, CacheExpression cache) { + private CodeTree createCacheReference(FrameState frameState, SpecializationData specialization, CacheExpression cache, boolean forRead) { if (cache == null) { return CodeTreeBuilder.singleString("null /* cache not resolved */"); } @@ -5220,7 +5255,9 @@ private CodeTree createCacheReference(FrameState frameState, SpecializationData } else { String sharedName = sharedCaches.get(cache); CodeTree ref; - if (sharedName != null) { + if (plugs != null) { + ref = plugs.createCacheReference(specialization, cache, sharedName, forRead); + } else if (sharedName != null) { ref = CodeTreeBuilder.createBuilder().string("this.").string(sharedName).build(); } else { String cacheFieldName = createFieldName(specialization, cache.getParameter()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index a330e072976a..c41904fd650d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -2,34 +2,33 @@ import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.Parameter; +import com.oracle.truffle.dsl.processor.model.SpecializationData; -public class NodeGeneratorPlugs { - public String transformNodeMethodName(String name) { - return name; - } +public interface NodeGeneratorPlugs { + String transformNodeMethodName(String name); - public String transformNodeInnerTypeName(String name) { - return name; - } + String transformNodeInnerTypeName(String name); - public void addNodeCallParameters(CodeTreeBuilder builder) { - } + void addNodeCallParameters(CodeTreeBuilder builder); - public int getMaxStateBits(int defaultValue) { - return defaultValue; - } + int getMaxStateBits(int defaultValue); - public TypeMirror getBitSetType(TypeMirror defaultType) { - return defaultType; - } + TypeMirror getBitSetType(TypeMirror defaultType); - public CodeTree createBitSetReference(BitSet bits) { - return CodeTreeBuilder.singleString("this." + bits.getName() + "_"); - } + CodeTree createBitSetReference(BitSet bits); + + CodeTree transformValueBeforePersist(CodeTree tree); + + CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType); + + CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead); + + CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); - public CodeTree transformValueBeforePersist(CodeTree tree) { - return tree; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 54b0e025cf1b..59ee17b94635 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -55,6 +55,7 @@ public static class BuilderVariables { public CodeVariableElement curStack; public CodeVariableElement maxStack; public CodeVariableElement keepingInstrumentation; + public CodeVariableElement numChildNodes; } public int minimumChildren() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 401b9dfa3cf9..925cecd02ad5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -21,6 +21,7 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -31,8 +32,12 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; @@ -80,6 +85,10 @@ public CodeTypeElement createBuilderBytecodeNode() { GeneratorUtils.addCompilationFinalAnnotation(fldConsts, 1); builderBytecodeNodeType.add(fldConsts); + CodeVariableElement fldChildren = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.Node), "children"); + fldChildren.addAnnotationMirror(new CodeAnnotationMirror(types.Node_Children)); + builderBytecodeNodeType.add(fldChildren); + CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); builderBytecodeNodeType.add(fldHandlers); @@ -127,7 +136,8 @@ public CodeTypeElement createBuilderBytecodeNode() { CustomInstruction cinstr = (CustomInstruction) instr; final SingleOperationData soData = cinstr.getData(); - final List bitSets = new ArrayList<>(); + final List additionalData = new ArrayList<>(); + final List additionalDataKinds = new ArrayList<>(); NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { @Override @@ -157,10 +167,12 @@ public TypeMirror getBitSetType(TypeMirror defaultType) { @Override public CodeTree createBitSetReference(BitSet bits) { - int index = bitSets.indexOf(bits); + int index = additionalData.indexOf(bits); if (index == -1) { - index = bitSets.size(); - bitSets.add(bits); + index = additionalData.size(); + additionalData.add(bits); + + additionalDataKinds.add(DataKind.BITS); } return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); @@ -170,6 +182,67 @@ public CodeTree createBitSetReference(BitSet bits) { public CodeTree transformValueBeforePersist(CodeTree tree) { return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); } + + private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild, String kind) { + if (refObject == null) { + throw new IllegalArgumentException("refObject is null"); + } + + int index = additionalData.indexOf(refObject); + + if (index == -1) { + index = additionalData.size(); + additionalData.add(refObject); + additionalData.add(null); + + additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); + additionalDataKinds.add(DataKind.CONTINUATION); + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (doCast) { + b.startParantheses(); + b.cast(castTarget); + } + + VariableElement targetField; + if (isChild) { + targetField = fldChildren; + } else { + targetField = fldConsts; + } + + b.variable(targetField).string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(fldBc); + b.string("$bci + " + cinstr.lengthWithoutState() + " + " + index); + b.end(); + b.string("]"); + + if (doCast) { + b.end(); + } + + return b.build(); + } + + @Override + public CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { + Object refObject = useSpecializationClass ? s : fieldName; + return createArrayReference(refObject, fieldType != null, fieldType, false, "spec-field"); + } + + @Override + public CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead) { + return createArrayReference(execution, forRead, execution.getNodeType(), true, "node-field"); + } + + public CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { + Object refObject = sharedName != null ? sharedName : cache; + boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); + return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild, "cache"); + } }; NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); @@ -224,7 +297,7 @@ public CodeTree transformValueBeforePersist(CodeTree tree) { } cinstr.setExecuteMethod(uncExec); - cinstr.setAdditionalStateBytes(bitSets.size()); + cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); } } @@ -642,6 +715,23 @@ public CodeTree transformValueBeforePersist(CodeTree tree) { b.end(2); } + { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startJavadoc(); + + for (Instruction instr : m.getInstructions()) { + for (String s : instr.dumpInfo().split("\n")) { + b.string(s); + b.newLine(); + } + b.string(" "); + b.newLine(); + } + + b.end(); + builderBytecodeNodeType.setDocTree(b.build()); + } + return builderBytecodeNodeType; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 0b159de7f634..1494fc7e2ed0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -235,6 +235,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); typBuilderImpl.add(fldBci); + CodeVariableElement fldNumChildNodes = new CodeVariableElement(context.getType(int.class), "numChildNodes"); + typBuilderImpl.add(fldNumChildNodes); + CodeVariableElement fldBuiltNodes = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.OperationsNode), "builtNodes"); typBuilderImpl.add(fldBuiltNodes); { @@ -282,6 +285,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.curStack = fldCurStack; vars.exteptionHandlers = fldExceptionHandlers; vars.keepingInstrumentation = fldKeepInstrumentation; + vars.numChildNodes = fldNumChildNodes; { CodeExecutableElement metReset = new CodeExecutableElement( @@ -294,6 +298,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("super.reset()"); b.startAssign(fldBci).string("0").end(); + b.startAssign(fldNumChildNodes).string("0").end(); b.startAssign(fldCurStack).string("0").end(); b.startAssign(fldMaxStack).string("0").end(); if (FLAG_NODE_AST_PRINTING) { @@ -359,6 +364,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startGroup().string("maxLocals + 1").end(); b.string("bcCopy"); b.string("cpCopy"); + b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); b.string("getInstrumentTrees()"); b.end(2); @@ -378,6 +384,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startGroup().string("maxLocals + 1").end(); b.string("bcCopy"); b.string("cpCopy"); + b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 1542f90524fe..2ac631bf1e9a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -78,7 +78,7 @@ protected OperationsData parse(Element element, List mirror) { return data; } - data.setTracing(true); + // data.setTracing(true); if (data.hasErrors()) { return data; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 6444a4aae51f..039c5b24a1ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -29,6 +29,7 @@ public class SingleOperationParser extends AbstractParser { + private static final Set MOD_STATIC_FINAL = Set.of(Modifier.STATIC, Modifier.FINAL); private final OperationsData parentData; public SingleOperationParser(OperationsData parentData) { @@ -135,9 +136,11 @@ protected SingleOperationData parse(Element element, List mirr // add all the constants for (VariableElement el : ElementFilter.fieldsIn(proxyType.getEnclosedElements())) { if (el.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { - CodeVariableElement cel = new CodeVariableElement(Set.of(Modifier.STATIC, Modifier.FINAL), el.asType(), el.getSimpleName().toString()); - cel.createInitBuilder().staticReference(el); - clonedType.add(cel); + // CodeVariableElement cel = new CodeVariableElement(MOD_STATIC_FINAL, + // el.asType(), el.getSimpleName().toString()); + // cel.createInitBuilder().staticReference(el); + // clonedType.add(cel); + clonedType.add(el); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 7a2a009625b7..139ef4166834 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -1,18 +1,27 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public class CustomInstruction extends Instruction { + public enum DataKind { + BITS, + CONST, + CHILD, + CONTINUATION + } + private final SingleOperationData data; private ExecutableElement executeMethod; - private int stateBytes = -1; + private DataKind[] dataKinds = null; public SingleOperationData getData() { return data; @@ -53,8 +62,35 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C int lengthWithoutState = lengthWithoutState(); - for (int i = 0; i < stateBytes; i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + (lengthWithoutState + i) + "] = 0").end(); + for (int i = 0; i < dataKinds.length; i++) { + CodeTree index = b.create().variable(vars.bci).string(" + " + lengthWithoutState + " + " + i).build(); + switch (dataKinds[i]) { + case BITS: + b.startStatement(); + b.variable(vars.bc).string("[").tree(index).string("] = 0"); + b.end(); + break; + case CHILD: + b.startStatement(); + b.startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.tree(index); + b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).variable(vars.numChildNodes).string("++").end(); + b.end(); + break; + case CONST: + b.startStatement(); + b.startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.tree(index); + b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).startCall(vars.consts, "reserve").end(2); + b.end(); + break; + case CONTINUATION: + break; + } + + b.end(); } return b.build(); @@ -94,14 +130,31 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public int getAdditionalStateBytes() { - if (stateBytes == -1) { + if (dataKinds == null) { throw new UnsupportedOperationException("state bytes not yet initialized"); } - return stateBytes; + return dataKinds.length; + } + + public void setDataKinds(DataKind[] dataKinds) { + this.dataKinds = dataKinds; } - public void setAdditionalStateBytes(int size) { - stateBytes = size; + @Override + public String dumpInfo() { + StringBuilder sb = new StringBuilder(super.dumpInfo()); + + sb.append(" Additional Data:\n"); + int ofs = -1; + for (DataKind kind : dataKinds) { + ofs += 1; + if (kind == DataKind.CONTINUATION) { + continue; + } + sb.append(" ").append(ofs).append(" ").append(kind).append("\n"); + } + + return sb.toString(); } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 63ff451f3f17..da52ecd00dda 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -465,4 +465,20 @@ public int getAdditionalStateBytes() { protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { return null; } + + public String dumpInfo() { + StringBuilder sb = new StringBuilder(); + sb.append(name).append("\n"); + + sb.append(" Inputs:\n"); + for (InputType type : inputs) { + sb.append(" ").append(type).append("\n"); + } + sb.append(" Results:\n"); + for (ResultType type : results) { + sb.append(" ").append(type).append("\n"); + } + + return sb.toString(); + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index 38829a54a81e..b19d45f04fa1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImplicitCast; @@ -132,7 +133,7 @@ public static boolean isString(Object a, Object b) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java index f411008db13a..bcd92a678837 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -77,7 +78,7 @@ public static SLBigNumber div(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index c49c0dcab991..3d360dc3614f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -69,7 +70,7 @@ public static boolean lessThan(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java index 310fc8b9cbdf..b773789e344e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; @@ -63,7 +64,7 @@ public static boolean doBoolean(boolean value) { } @Fallback - public static Object typeError(Object value, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object value, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, value); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java index cffb052cc35a..15a6e45eb1b5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -68,7 +69,7 @@ public static SLBigNumber mul(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index efb17998bc85..0f08470da3b0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -71,12 +72,12 @@ @NodeChild("nameNode") public abstract class SLReadPropertyNode extends SLExpressionNode { - static final int LIBRARY_LIMIT = 3; + public static final int LIBRARY_LIMIT = 3; @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object readArray(Object receiver, Object index, - @Cached("this") Node node, - @Cached("$bci") int bci, + @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { @@ -89,8 +90,8 @@ public static Object readArray(Object receiver, Object index, @Specialization(limit = "LIBRARY_LIMIT") public static Object readSLObject(SLObject receiver, Object name, - @Cached("this") Node node, - @Cached("$bci") int bci, + @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { TruffleString nameTS = toTruffleStringNode.execute(name); @@ -104,8 +105,8 @@ public static Object readSLObject(SLObject receiver, Object name, @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") public static Object readObject(Object receiver, Object name, - @Cached("this") Node node, - @Cached("$bci") int bci, + @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { try { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index 9d87270c6ac8..b62daf72f792 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -68,7 +69,7 @@ public static SLBigNumber sub(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Cached("this") Node node, @Cached("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, bci, left, right); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 79f42d90f990..451569c69960 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -75,7 +75,7 @@ @NodeChild("valueNode") public abstract class SLWritePropertyNode extends SLExpressionNode { - static final int LIBRARY_LIMIT = 3; + public static final int LIBRARY_LIMIT = 3; @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object writeArray(Object receiver, Object index, Object value, diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java index 1f5fd4ce747d..7895ab14372c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLUnboxNode.java @@ -65,7 +65,7 @@ @NodeChild public abstract class SLUnboxNode extends SLExpressionNode { - static final int LIMIT = 5; + public static final int LIMIT = 5; @Specialization public static TruffleString fromString(String value, diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 7c647948a737..04f0980d0bef 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -109,7 +109,7 @@ public static Object execute(TruffleString functionName, @Bind("this") Node node @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { @Specialization - public static Object execute(Object function, @Variadic Object[] argumentValues, @Cached("this") Node node, @Cached("$bci") int bci, @CachedLibrary(limit = "3") InteropLibrary library) { + public static Object execute(Object function, @Variadic Object[] argumentValues, @Bind("this") Node node, @Bind("$bci") int bci, @CachedLibrary(limit = "3") InteropLibrary library) { try { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 3707e90811ce..191f6240cf12 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -148,7 +148,7 @@ public Void visitFunction(FunctionContext ctx) { b.endSource(); OperationsNode node = b.build(); - functions.put(name, node.getCallTarget()); + functions.put(name, node.createRootNode().getCallTarget()); return null; } From 3e30416e1d099c3f83d29de9827b8516199d2ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 30 Mar 2022 10:49:02 +0200 Subject: [PATCH 028/312] [wip] compilation --- .../api/operation/OperationsBytesSupport.java | 33 +++++++++++++++++++ .../api/operation/OperationsRootNode.java | 5 +++ .../processor/generator/GeneratorUtils.java | 6 +++- .../OperationsBytecodeCodeGenerator.java | 14 ++++++-- .../operations/OperationsCodeGenerator.java | 16 +++++---- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java new file mode 100644 index 000000000000..717df8c6ede7 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java @@ -0,0 +1,33 @@ +package com.oracle.truffle.api.operation; + +public class OperationsBytesSupport { + public static final OperationsBytesSupport INSTANCE = new OperationsBytesSupport(); + + public static OperationsBytesSupport littleEndian() { + return INSTANCE; + } + + private OperationsBytesSupport() { + } + + @SuppressWarnings("static-method") + public final byte getByte(byte[] data, int index) { + return data[index]; + } + + @SuppressWarnings("static-method") + public final void putByte(byte[] data, int index, byte value) { + data[index] = value; + } + + @SuppressWarnings("static-method") + public final short getShort(byte[] data, int index) { + return (short) (((data[index + 1] & 0xff) << 8) | (data[index] & 0xff)); + } + + @SuppressWarnings("static-method") + public final void putShort(byte[] data, int index, short value) { + data[index] = (byte) (value & 0xff); + data[index + 1] = (byte) ((value >>> 8) & 0xff); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index 52fc3233baa1..c3a7dbeefbd4 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -67,4 +67,9 @@ public WrapperNode createWrapper(final ProbeNode probe) { return new OperationsWrapperNode(probe); } + @Override + public String toString() { + return "root " + getName(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index a3289441319c..c0325cf1fc7e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -102,9 +102,13 @@ public static CodeTree createTransferToInterpreterAndInvalidate() { } public static CodeTree createPartialEvaluationConstant(VariableElement variable) { + return createPartialEvaluationConstant(variable.getSimpleName().toString()); + } + + public static CodeTree createPartialEvaluationConstant(String variable) { ProcessorContext context = ProcessorContext.getInstance(); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.startStatement().startStaticCall(context.getTypes().CompilerAsserts, "partialEvaluationConstant").variable(variable).end().end(); + builder.startStatement().startStaticCall(context.getTypes().CompilerAsserts, "partialEvaluationConstant").string(variable).end().end(); return builder.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 925cecd02ad5..6a566dfaf800 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -366,9 +366,10 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); b.startBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); - b.end(); + b.startSwitch().string("curOpcode").end(); b.startBlock(); @@ -482,12 +483,17 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp vars.results = null; } - b.caseDefault().startCaseBlock().tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")).end(); + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")); + b.end(); b.end(); // switch block b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + if (m.isTracing()) { b.startStatement().startCall(fldTracer, "traceException"); b.string("ex"); @@ -498,7 +504,10 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.startFor().string("int handlerIndex = 0; handlerIndex < " + fldHandlers.getName() + ".length; handlerIndex++").end(); b.startBlock(); + b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); + b.declaration(types.BuilderExceptionHandler, "handler", fldHandlers.getName() + "[handlerIndex]"); + b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); b.statement("continue"); @@ -519,6 +528,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.end(); // catch block + b.tree(GeneratorUtils.createPartialEvaluationConstant(varNextBci)); b.statement("bci = nextBci"); b.end(); // while block diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 1494fc7e2ed0..4141912efc7c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -165,12 +165,16 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("reset()"); } - DeclaredType byteArraySupportType = context.getDeclaredType("com.oracle.truffle.api.memory.ByteArraySupport"); - CodeVariableElement leBytes = new CodeVariableElement( - MOD_PRIVATE_STATIC_FINAL, - byteArraySupportType, "LE_BYTES"); - leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); - typBuilderImpl.add(leBytes); + { + String bytesSupportClass = "com.oracle.truffle.api.operation.OperationsBytesSupport"; + // String bytesSupportClass = "com.oracle.truffle.api.memory.ByteArraySupport"; + DeclaredType byteArraySupportType = context.getDeclaredType(bytesSupportClass); + CodeVariableElement leBytes = new CodeVariableElement( + MOD_PRIVATE_STATIC_FINAL, + byteArraySupportType, "LE_BYTES"); + leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); + typBuilderImpl.add(leBytes); + } for (Operation op : m.getOperationsContext().operations) { CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); From 818a6dd1837586119d94a87620307363c9b93a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 30 Mar 2022 11:41:32 +0200 Subject: [PATCH 029/312] [wip] add tests to mx --- truffle/mx.truffle/suite.py | 2 ++ .../test/example/TestOperations.java | 1 - .../example/TestOperationsParserTest.java | 23 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index f2e64e0f5300..54639c47653d 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -302,6 +302,7 @@ "javaCompliance" : "11+", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "workingSets" : "API,Truffle,Codegen,Test", + "testProject" : True, "jacoco" : "exclude", }, @@ -1345,6 +1346,7 @@ "com.oracle.truffle.api.instrumentation.test", "com.oracle.truffle.api.debug.test", "com.oracle.truffle.api.strings.test", + "com.oracle.truffle.api.operation.test", "com.oracle.truffle.object.basic.test", "com.oracle.truffle.nfi.test", "com.oracle.truffle.api.staticobject.test", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 709c74811af4..9f50bebb01f5 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -23,7 +23,6 @@ public TestException(String string, OperationsNode node, int bci) { public static void parse(TestLanguage language, Source source, TestOperationsBuilder builder) { TestLanguageAst ast = new TestLanguageParser(source).parse(); - System.out.println(ast); new TestLanguageBackend(builder).buildRoot(source, ast); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index dd5b7d890874..2bef11a14061 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -3,18 +3,15 @@ import static org.junit.Assert.fail; import java.io.IOException; -import java.util.List; import java.util.function.Consumer; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; +import org.graalvm.polyglot.Value; import org.junit.Assert; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import com.oracle.truffle.api.TruffleStackTrace; -import com.oracle.truffle.api.TruffleStackTraceElement; +import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; import com.oracle.truffle.api.operation.tracing.ExecutionTracer; @@ -36,7 +33,6 @@ private static class Tester { node = TestOperationsBuilder.parse(null, s)[0]; } rootNode = node.createRootNode(); - System.out.println(node.dump()); } Tester(String src) { @@ -58,11 +54,8 @@ public Tester then(Consumer action) { @Test public void testAdd() { new Tester("(return (add (arg 0) (arg 1)))")// - .then(x -> System.out.println(x.dump())) // .test(42L, 20L, 22L) // - .then(x -> System.out.println(x.dump())) // .test("foobar", "foo", "bar") // - .then(x -> System.out.println(x.dump())) // .test(100L, 120L, -20L); } @@ -188,4 +181,16 @@ public void testInstrumentation() { new Tester(src, true).test(3L); ExecutionTracer.get().dump(); } + + @Test + public void testCompilation() { + Context context = Context.create("test"); + + Value v = context.parse("test", "(return (add (arg 0) (arg 1)))"); + for (int i = 0; i < 100000; i++) { + v.execute(1L, 2L); + } + + Assert.assertEquals(Value.asValue(7L), v.execute(3L, 4L)); + } } From 53aa56b80923bc50499016a116c522fce871a448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 30 Mar 2022 13:15:32 +0200 Subject: [PATCH 030/312] [wip] tests --- .../operation/test/example/TestLanguage.java | 2 +- .../test/example/TestOperations.java | 19 +++- .../example/TestOperationsParserTest.java | 101 ++++++++++++++---- .../operations/SingleOperationParser.java | 4 - .../src/tests/Inlining.output | 2 +- .../src/tests/Inlining.sl | 2 +- .../src/tests/LoopCall.sl | 2 +- .../truffle/sl/operations/SLOperations.java | 9 +- 8 files changed, 105 insertions(+), 36 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java index 32b4b4430162..cc2a0ac12310 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java @@ -5,7 +5,7 @@ import com.oracle.truffle.api.TruffleLanguage.Registration; import com.oracle.truffle.api.operation.OperationsNode; -@Registration(id = "test", name = "test") +@Registration(id = "test-operations", name = "test-operations") public class TestLanguage extends TruffleLanguage { @Override diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 9f50bebb01f5..cb019a6c6322 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,5 +1,9 @@ package com.oracle.truffle.api.operation.test.example; +import java.util.function.Consumer; + +import org.junit.Assert; + import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; @@ -21,9 +25,18 @@ public TestException(String string, OperationsNode node, int bci) { } } - public static void parse(TestLanguage language, Source source, TestOperationsBuilder builder) { - TestLanguageAst ast = new TestLanguageParser(source).parse(); - new TestLanguageBackend(builder).buildRoot(source, ast); + public static void parse(TestLanguage language, Object input, TestOperationsBuilder builder) { + if (input instanceof Source) { + Source source = (Source) input; + TestLanguageAst ast = new TestLanguageParser(source).parse(); + new TestLanguageBackend(builder).buildRoot(source, ast); + } else if (input instanceof Consumer) { + @SuppressWarnings("unchecked") + Consumer callback = (Consumer) input; + callback.accept(builder); + } else { + Assert.fail("invalid parser"); + } } @Operation diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 2bef11a14061..1194dea64392 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; import com.oracle.truffle.api.operation.tracing.ExecutionTracer; @@ -25,7 +26,7 @@ private static class Tester { private final OperationsRootNode rootNode; Tester(String src, boolean withSourceInfo) { - Source s = Source.newBuilder("test", src, "test").build(); + Source s = Source.newBuilder("test-operations", src, "test").build(); if (withSourceInfo) { node = TestOperationsBuilder.parseWithSourceInfo(null, s)[0]; @@ -51,31 +52,87 @@ public Tester then(Consumer action) { } } + private static OperationsNode parse(Consumer builder) { + return TestOperationsBuilder.parse(null, builder)[0]; + } + @Test public void testAdd() { - new Tester("(return (add (arg 0) (arg 1)))")// - .test(42L, 20L, 22L) // - .test("foobar", "foo", "bar") // - .test(100L, 120L, -20L); + OperationsNode node = parse(b -> { + b.beginReturn(); + b.beginAddOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(1); + b.endAddOperation(); + b.endReturn(); + }); + + RootCallTarget root = node.createRootNode().getCallTarget(); + + Assert.assertEquals(42L, 20L, 22L); + Assert.assertEquals("foobar", "foo", "bar"); + Assert.assertEquals(100L, 120L, -20L); } @Test public void testMax() { - new Tester("(if (less (arg 0) (arg 1)) (return (arg 1)) (return (arg 0)))") // - .test(42L, 42L, 13L) // - .test(42L, 42L, 13L) // - .test(42L, 42L, 13L) // - .test(42L, 13L, 42L); + OperationsNode node = parse(b -> { + b.beginIfThenElse(); + + b.beginLessThanOperation(); + b.emitLoadArgument(0); + b.emitLoadArgument(1); + b.endLessThanOperation(); + + b.beginReturn(); + b.emitLoadArgument(1); + b.endReturn(); + + b.beginReturn(); + b.emitLoadArgument(0); + b.endReturn(); + + b.endIfThenElse(); + }); + + RootCallTarget root = node.createRootNode().getCallTarget(); + + Assert.assertEquals(42L, 42L, 13L); + Assert.assertEquals(42L, 42L, 13L); + Assert.assertEquals(42L, 42L, 13L); + Assert.assertEquals(42L, 13L, 42L); } @Test public void testIfThen() { - new Tester("(do (if (less (arg 0) 0) (return 0)) (return (arg 0)))") // - .test(0L, -2L) // - .test(0L, -1L) // - .test(0L, 0L) // - .test(1L, 1L) // - .test(2L, 2L); + OperationsNode node = parse(b -> { + b.beginIfThen(); + + b.beginLessThanOperation(); + b.emitLoadArgument(0); + b.emitConstObject(0L); + b.endLessThanOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.endIfThen(); + + b.beginReturn(); + b.emitLoadArgument(0); + b.endReturn(); + + b.build(); + }); + + RootCallTarget root = node.createRootNode().getCallTarget(); + + Assert.assertEquals(0L, root.call(-2L)); + Assert.assertEquals(0L, root.call(-1L)); + Assert.assertEquals(0L, root.call(0L)); + Assert.assertEquals(1L, root.call(1L)); + Assert.assertEquals(2L, root.call(2L)); } @Test @@ -138,9 +195,9 @@ public void testStacktrace() { + " (fail)))"; //@formatter:on - Context context = Context.create("test"); + Context context = Context.create("test-operations"); try { - context.eval(org.graalvm.polyglot.Source.newBuilder("test", src, "test").build()); + context.eval(org.graalvm.polyglot.Source.newBuilder("test-operations", src, "test-operations").build()); fail(); } catch (PolyglotException ex) { Assert.assertEquals(4, ex.getStackTrace()[0].getLineNumber()); @@ -184,11 +241,11 @@ public void testInstrumentation() { @Test public void testCompilation() { - Context context = Context.create("test"); + Context context = Context.create("test-operations"); - Value v = context.parse("test", "(return (add (arg 0) (arg 1)))"); - for (int i = 0; i < 100000; i++) { - v.execute(1L, 2L); + Value v = context.parse("test-operations", "(return (add (arg 0) (arg 1)))"); + for (long i = 0; i < 1000000; i++) { + v.execute(i, 1L); } Assert.assertEquals(Value.asValue(7L), v.execute(3L, 4L)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 039c5b24a1ac..31f0415c5a8e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -128,10 +128,6 @@ protected SingleOperationData parse(Element element, List mirr clonedType.add(metExecute); - if (ElementUtils.findAnnotationMirror(clonedType, types.GenerateUncached) == null) { - clonedType.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); - } - if (proxyType != null) { // add all the constants for (VariableElement el : ElementFilter.fieldsIn(proxyType.getEnclosedElements())) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output index b6fe452fbd8c..16d117a0ae98 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output @@ -1 +1 @@ -1260000 \ No newline at end of file +126000000 \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl index 0702190c0fcd..3fca08492d40 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl @@ -15,7 +15,7 @@ function g() {return d() + e() + f();} function main() { i = 0; result = 0; - while (i < 10000) { + while (i < 1000000) { result = result + g(); i = i + 1; } diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl index 046055fe98bd..be5462fd87c8 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl @@ -18,7 +18,7 @@ function loop(n) { function main() { i = 0; while (i < 20) { - loop(1000); + loop(100000); i = i + 1; } println(loop(1000)); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 04f0980d0bef..b6be0a426970 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -99,9 +99,12 @@ public static class SLEqualOperation { @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @Bind("this") Node node) { - Object res = SLContext.get(node).getFunctionRegistry().lookup(functionName, true); - return res; + public static Object execute(TruffleString functionName, @Bind("this") Node node, @Cached("lookupFunction(functionName, node)") Object result) { + return result; + } + + static Object lookupFunction(TruffleString functionName, Node node) { + return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); } } From bd946b873dd1fd7b7a4d8242c1da6806da68c0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 30 Mar 2022 13:15:57 +0200 Subject: [PATCH 031/312] [wip] fix instanceof checks on generic types --- .../dsl/processor/generator/TypeSystemCodeGenerator.java | 2 +- .../com/oracle/truffle/dsl/processor/java/ElementUtils.java | 6 +++--- .../dsl/processor/java/transform/OrganizedImports.java | 2 +- .../src/com/oracle/truffle/sl/operations/SLOperations.java | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index 76d29a738899..70574fb28b7e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -179,7 +179,7 @@ static CodeTree check(TypeSystemData typeSystem, TypeMirror type, CodeTree conte TypeCheckData check = typeSystem.getCheck(type); if (check == null) { - builder.instanceOf(content, ElementUtils.boxType(typeSystem.getContext(), type)); + builder.instanceOf(content, ElementUtils.eraseGenericTypes(ElementUtils.boxType(typeSystem.getContext(), type))); } else { builder.startStaticCall(typeSystem.getTemplateType().asType(), check.getMethodName()).tree(content).end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 3a2da0ddb35b..ffc06e42d7da 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -610,11 +610,11 @@ public static String getSimpleName(TypeMirror mirror) { } private static String getWildcardName(WildcardType type) { - StringBuilder b = new StringBuilder(); + StringBuilder b = new StringBuilder("?"); if (type.getExtendsBound() != null) { - b.append("? extends ").append(getSimpleName(type.getExtendsBound())); + b.append(" extends ").append(getSimpleName(type.getExtendsBound())); } else if (type.getSuperBound() != null) { - b.append("? super ").append(getSimpleName(type.getExtendsBound())); + b.append(" super ").append(getSimpleName(type.getSuperBound())); } return b.toString(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java index d9029edfe847..e590d8fe8dcb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @@ -186,7 +186,7 @@ private String createDeclaredTypeName(Element enclosedElement, DeclaredType type b.append("?"); } - if (i < typeArguments.size() - 1) { + if (i < parameters.size() - 1) { b.append(", "); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index b6be0a426970..beda25ccee7f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -66,11 +66,11 @@ public static class SLEvalRootOperation { @Specialization public static Object perform( VirtualFrame frame, - Map functions, + Map functions, @Bind("this") Node node) { - SLContext.get(node).getFunctionRegistry().register((Map) functions); + SLContext.get(node).getFunctionRegistry().register(functions); - RootCallTarget main = (RootCallTarget) functions.get(SLStrings.MAIN); + RootCallTarget main = functions.get(SLStrings.MAIN); if (main != null) { return main.call(frame.getArguments()); From df27f0a34f7f57462abc4c84b848f8f31405c4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 30 Mar 2022 14:22:48 +0200 Subject: [PATCH 032/312] [wip] stuff --- .../truffle/api/operation/OperationsNode.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 4 +- .../operations/OperationsCodeGenerator.java | 76 ++++++++++++------- .../src/tests/Fibonacci.sl | 8 ++ .../src/tests/LoopCall.sl | 4 +- .../operations/SLOperationsVisitor.java | 9 +++ 6 files changed, 72 insertions(+), 31 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 163512bd3078..76ad798f6298 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -135,7 +135,7 @@ public SourceSection getEncapsulatingSourceSection() { @Override public boolean isInstrumentable() { - return true; + return false; } public WrapperNode createWrapper(ProbeNode probe) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 6a566dfaf800..5710746b1577 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -576,7 +576,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 16; i++) { if (i < op.length()) { b.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); } else { @@ -584,7 +584,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp } } - b.statement("sb.append(\"" + op.name + " \")"); + b.statement("sb.append(\"" + op.name + " ".repeat(op.name.length() < 32 ? 32 - op.name.length() : 0) + " \")"); for (int i = 0; i < op.inputs.length; i++) { if (i != 0) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 4141912efc7c..5d3d2df465ec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -41,6 +41,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); private static final boolean FLAG_NODE_AST_PRINTING = false; + private static final boolean ENABLE_INSTRUMENTATION = false; /** * Creates the builder class itself. This class only contains abstract methods, the builder @@ -199,10 +200,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { builderBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } - { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "InstrumentableBytecodeNode", m, true); + if (ENABLE_INSTRUMENTATION) { + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, + simpleName + "InstrumentableBytecodeNode", m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); + } else { + builderInstrBytecodeNodeType = null; } CodeVariableElement fldOperationData = new CodeVariableElement(types.BuilderOperationData, "operationData"); @@ -352,28 +356,30 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("OperationsNode result"); - b.startIf().variable(fldKeepInstrumentation).end(); - b.startBlock(); - - b.startAssign("result"); - b.startNew(builderInstrBytecodeNodeType.asType()); - b.variable(fldLanguage); - b.variable(fldParseContext); - b.string("nodeName"); - b.string("isInternal"); - b.string("sourceInfo"); - b.string("sources"); - b.variable(fldNodeNumber); - b.variable(fldMaxStack); - b.startGroup().string("maxLocals + 1").end(); - b.string("bcCopy"); - b.string("cpCopy"); - b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); - b.string("handlers"); - b.string("getInstrumentTrees()"); - b.end(2); + if (ENABLE_INSTRUMENTATION) { + b.startIf().variable(fldKeepInstrumentation).end(); + b.startBlock(); - b.end().startElseBlock(); + b.startAssign("result"); + b.startNew(builderInstrBytecodeNodeType.asType()); + b.variable(fldLanguage); + b.variable(fldParseContext); + b.string("nodeName"); + b.string("isInternal"); + b.string("sourceInfo"); + b.string("sources"); + b.variable(fldNodeNumber); + b.variable(fldMaxStack); + b.startGroup().string("maxLocals + 1").end(); + b.string("bcCopy"); + b.string("cpCopy"); + b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); + b.string("handlers"); + // b.string("getInstrumentTrees()"); + b.end(2); + + b.end().startElseBlock(); + } b.startAssign("result"); b.startNew(builderBytecodeNodeType.asType()); @@ -392,7 +398,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("handlers"); b.end(2); - b.end(); + if (ENABLE_INSTRUMENTATION) { + b.end(); + } b.startStatement(); b.startCall(fldBuiltNodes, "add"); @@ -425,6 +433,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startSwitch().string("data.operationId").end(); b.startBlock(); + vars.operationData = parData; + for (Operation op : m.getOperations()) { CodeTree leaveCode = op.createLeaveCode(vars); if (leaveCode == null) { @@ -441,6 +451,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } + vars.operationData = fldOperationData; + b.end(); } @@ -615,7 +627,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (op.name.equals("Instrumentation")) { // this needs to be placed here, at the very start // of the begin/end methods - b.startIf().string("!").variable(vars.keepingInstrumentation).end(); + b.startIf(); + if (ENABLE_INSTRUMENTATION) { + b.string("!").variable(vars.keepingInstrumentation); + } else { + b.string("true"); + } + b.end(); b.startBlock(); b.returnStatement(); b.end(); @@ -657,7 +675,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (op.name.equals("Instrumentation")) { // this needs to be placed here, at the very start // of the begin/end methods - b.startIf().string("!").variable(vars.keepingInstrumentation).end(); + b.startIf(); + if (ENABLE_INSTRUMENTATION) { + b.string("!").variable(vars.keepingInstrumentation); + } else { + b.string("true"); + } + b.end(); b.startBlock(); b.returnStatement(); b.end(); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl index 939f39fd44cf..9af3c90885cc 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl @@ -19,6 +19,14 @@ function fib(num) { function main() { i = 1; + j = 1; + while (i < 100000) { + fib(10 + j); + j = j + 1; + if (j == 10) { + j = 1; + } + } while (i <= 10) { println(i + ": " + fib(i)); i = i + 1; diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl index be5462fd87c8..e245f2f40578 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl @@ -17,8 +17,8 @@ function loop(n) { function main() { i = 0; - while (i < 20) { - loop(100000); + while (i < 100000) { + loop(100); i = i + 1; } println(loop(1000)); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 191f6240cf12..6e0005886396 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -148,6 +148,15 @@ public Void visitFunction(FunctionContext ctx) { b.endSource(); OperationsNode node = b.build(); + + try { + System.out.println("----------------------------------------------"); + System.out.printf(" Node: %s%n", name); + System.out.println(node.dump()); + System.out.println("----------------------------------------------"); + } catch (Exception ignored) { + } + functions.put(name, node.createRootNode().getCallTarget()); return null; From c171f4f9546a6b0fb157c761d4b72f2d64f83c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 31 Mar 2022 13:09:36 +0200 Subject: [PATCH 033/312] [wip] implement @OperationProxy --- .../api/operation/OperationProxies.java | 12 ++++ .../truffle/api/operation/OperationProxy.java | 14 ++++ .../truffle/dsl/processor/TruffleTypes.java | 2 + .../OperationsBytecodeCodeGenerator.java | 10 +-- .../operations/OperationsParser.java | 32 +++++++-- .../operations/SingleOperationData.java | 6 +- .../operations/SingleOperationParser.java | 71 +++++++++++++------ .../instructions/BranchInstruction.java | 1 + .../ConditionalBranchInstruction.java | 3 + .../truffle/sl/operations/SLOperations.java | 70 ++++-------------- .../operations/SLOperationsVisitor.java | 14 ++-- 11 files changed, 139 insertions(+), 96 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java new file mode 100644 index 000000000000..19ce033f0b10 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java @@ -0,0 +1,12 @@ +package com.oracle.truffle.api.operation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@interface OperationProxies { + OperationProxy[] value(); +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java new file mode 100644 index 000000000000..ad2cee11f662 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java @@ -0,0 +1,14 @@ +package com.oracle.truffle.api.operation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Repeatable(OperationProxies.class) +public @interface OperationProxy { + Class value(); +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 5d365b93b570..2cba955dee2b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -230,6 +230,7 @@ public class TruffleTypes { public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; + public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy"; public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; @@ -247,6 +248,7 @@ public class TruffleTypes { public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); + public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name); public final DeclaredType OperationsBuilder = c.getDeclaredTypeOptional(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); public final DeclaredType OperationsNode = c.getDeclaredTypeOptional(OperationsNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 5710746b1577..240b9b759dd3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -416,7 +416,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp break; case BRANCH: hasBranch = true; - varResults[i] = varNextBci; + varResults[i] = varBci; break; case RETURN: hasReturn = true; @@ -466,14 +466,10 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.end(2); } - - if (!hasBranch) { - b.startAssign(varNextBci).variable(varBci).string(" + " + op.length()).end(); - } - if (hasReturn) { b.statement("break loop"); - } else { + } else if (!hasBranch) { + b.startAssign(varNextBci).variable(varBci).string(" + " + op.length()).end(); b.statement("break"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 2ac631bf1e9a..c70d50861ed2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,16 +1,25 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import javax.tools.Diagnostic.Kind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.model.MessageContainer.Message; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { @@ -51,12 +60,23 @@ protected OperationsData parse(Element element, List mirror) { data.setParseContext(languageType, contextType, parseMethod); } - boolean hasSome = false; - for (Element inner : typeElement.getEnclosedElements()) { - if (!(inner instanceof TypeElement)) { - continue; + List operationTypes = new ArrayList<>(ElementFilter.typesIn(typeElement.getEnclosedElements())); + List opProxies = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.OperationProxy); + + for (AnnotationMirror mir : opProxies) { + DeclaredType tgtType = (DeclaredType) ElementUtils.getAnnotationValue(mir, "value").getValue(); + + SingleOperationData opData = new SingleOperationParser(data, (TypeElement) tgtType.asElement()).parse(null, null); + + if (opData != null) { + data.addOperationData(opData); + } else { + data.addError("Could not generate operation: " + tgtType.asElement().getSimpleName()); } + } + boolean hasSome = false; + for (TypeElement inner : operationTypes) { if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { continue; } @@ -71,6 +91,10 @@ protected OperationsData parse(Element element, List mirror) { data.addError("Could not generate operation: " + inner.getSimpleName()); } + if (inner instanceof CodeTypeElement) { + opData.redirectMessagesOnGeneratedElements(data); + } + } if (!hasSome) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index e1b527184544..65c9603e66dc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -16,7 +16,7 @@ import com.oracle.truffle.dsl.processor.model.Template; public class SingleOperationData extends Template { - private final String name; + private String name; private MethodProperties mainProperties; private NodeData nodeData; private OperationsData parent; @@ -109,6 +109,10 @@ public String getName() { return name; } + public void setName(String name) { + this.name = name; + } + public Set getThrowDeclarations() { return throwDeclarations; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 31f0415c5a8e..ed9a3d0075bd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -29,53 +29,83 @@ public class SingleOperationParser extends AbstractParser { + private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private static final Set MOD_STATIC_FINAL = Set.of(Modifier.STATIC, Modifier.FINAL); private final OperationsData parentData; + private TypeElement proxyType; + + private Set OPERATION_PROXY_IGNORED_ANNOTATIONS = Set.of( + types.GenerateOperations, + types.OperationProxy, + types.Operation); public SingleOperationParser(OperationsData parentData) { this.parentData = parentData; } + public SingleOperationParser(OperationsData parentData, TypeElement proxyType) { + this.parentData = parentData; + this.proxyType = proxyType; + } + @Override protected SingleOperationData parse(Element element, List mirror) { - if (!(element instanceof TypeElement)) { + if (element != null && !(element instanceof TypeElement)) { parentData.addError(element, "@Operation can only be attached to a type"); return null; } TypeElement te = (TypeElement) element; - TypeElement proxyType; - AnnotationMirror annOperation = ElementUtils.findAnnotationMirror(mirror, types.Operation); + boolean proxyOnParent = proxyType != null; - DeclaredType proxyDecl = ElementUtils.getAnnotationValue(DeclaredType.class, annOperation, "proxyNode"); - if (proxyDecl.equals(context.getDeclaredType(Void.class))) { - proxyType = null; + if (!proxyOnParent) { + AnnotationMirror annOperation = ElementUtils.findAnnotationMirror(mirror, types.Operation); + DeclaredType proxyDecl = ElementUtils.getAnnotationValue(DeclaredType.class, annOperation, "proxyNode"); + if (!proxyDecl.equals(context.getDeclaredType(Void.class))) { + proxyType = ((TypeElement) proxyDecl.asElement()); + } } else { - proxyType = ((TypeElement) proxyDecl.asElement()); + String name = proxyType.getSimpleName().toString(); + if (name.endsWith("Node")) { + name = name.substring(0, name.length() - 4); + } + name += "Operation"; + CodeTypeElement tgt = new CodeTypeElement(MOD_PUBLIC_STATIC, ElementKind.CLASS, null, name); + tgt.setEnclosingElement(parentData.getMessageElement()); + + for (AnnotationMirror mir : parentData.getMessageElement().getAnnotationMirrors()) { + if (!OPERATION_PROXY_IGNORED_ANNOTATIONS.contains(mir.getAnnotationType())) { + tgt.addAnnotationMirror(mir); + } + } + te = tgt; } - SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(mirror, getAnnotationType()), parentData); + SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(te.getAnnotationMirrors(), getAnnotationType()), parentData); List operationFunctions = new ArrayList<>(); - for (Element el : te.getEnclosedElements()) { - if (el.getModifiers().contains(Modifier.PRIVATE)) { - continue; - } - if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { - data.addError(el, "Operations must not contain non-static members"); - } - if (el instanceof ExecutableElement) { - ExecutableElement cel = (ExecutableElement) el; - if (isOperationFunction(cel)) { - operationFunctions.add(cel); + if (!proxyOnParent) { + for (Element el : te.getEnclosedElements()) { + if (el.getModifiers().contains(Modifier.PRIVATE)) { + continue; + } + if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { + data.addError(el, "Operations must not contain non-static members"); + } + if (el instanceof ExecutableElement) { + ExecutableElement cel = (ExecutableElement) el; + if (isOperationFunction(cel)) { + operationFunctions.add(cel); + } } } } if (proxyType != null) { - CodeTypeElement teClone = CodeTypeElement.cloneShallow(te); + CodeTypeElement teClone = te instanceof CodeTypeElement ? (CodeTypeElement) te : CodeTypeElement.cloneShallow(te); te = teClone; + for (Element el : CompilerFactory.getCompiler(proxyType).getEnclosedElementsInDeclarationOrder(proxyType)) { if (el instanceof ExecutableElement && isStaticAccessible(el)) { teClone.add(el); @@ -84,7 +114,6 @@ protected SingleOperationData parse(Element element, List mirr } } } - } if (operationFunctions.isEmpty()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index cc06a3352b1b..3aa8868ec3b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -19,6 +19,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + b.statement("continue loop"); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 0495cd13dc9d..8523b1407b53 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -3,6 +3,7 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; @@ -26,8 +27,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf().variable(vars.inputs[1]).end(); b.startBlock(); b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.statement("continue loop"); b.end().startElseBlock(); b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + b.statement("continue loop"); b.end(); return b.build(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index beda25ccee7f..e6b60d446e3a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -18,6 +18,7 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; @@ -43,6 +44,18 @@ import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations +@TypeSystemReference(SLTypes.class) +@OperationProxy(SLAddNode.class) +@OperationProxy(SLDivNode.class) +@OperationProxy(SLEqualNode.class) +@OperationProxy(SLLessOrEqualNode.class) +@OperationProxy(SLLessThanNode.class) +@OperationProxy(SLLogicalNotNode.class) +@OperationProxy(SLMulNode.class) +@OperationProxy(SLReadPropertyNode.class) +@OperationProxy(SLSubNode.class) +@OperationProxy(SLWritePropertyNode.class) +@OperationProxy(SLUnboxNode.class) public class SLOperations { public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { @@ -80,26 +93,11 @@ public static Object perform( } } - @Operation(proxyNode = SLAddNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLAddOperation { - } - - @Operation(proxyNode = SLDivNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLDivOperation { - } - - @Operation(proxyNode = SLEqualNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLEqualOperation { - } - @Operation @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @Bind("this") Node node, @Cached("lookupFunction(functionName, node)") Object result) { + public static Object execute(TruffleString functionName, @Cached("lookupFunction(functionName, this)") Object result) { return result; } @@ -122,46 +120,6 @@ public static Object execute(Object function, @Variadic Object[] argumentValues, } } - @Operation(proxyNode = SLLessOrEqualNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLLessOrEqualOperation { - } - - @Operation(proxyNode = SLLessThanNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLLessThanOperation { - } - - @Operation(proxyNode = SLLogicalNotNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLLogicalNotOperation { - } - - @Operation(proxyNode = SLMulNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLMulOperation { - } - - @Operation(proxyNode = SLReadPropertyNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLReadPropertyOperation { - } - - @Operation(proxyNode = SLSubNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLSubOperation { - } - - @Operation(proxyNode = SLWritePropertyNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLWritePropertyOperation { - } - - @Operation(proxyNode = SLUnboxNode.class) - @TypeSystemReference(SLTypes.class) - public static class SLUnboxOperation { - } - @Operation @TypeSystemReference(SLTypes.class) public static class SLConvertToBoolean { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 6e0005886396..94627539f97c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -149,13 +149,13 @@ public Void visitFunction(FunctionContext ctx) { OperationsNode node = b.build(); - try { - System.out.println("----------------------------------------------"); - System.out.printf(" Node: %s%n", name); - System.out.println(node.dump()); - System.out.println("----------------------------------------------"); - } catch (Exception ignored) { - } + // try { + // System.out.println("----------------------------------------------"); + // System.out.printf(" Node: %s%n", name); + // System.out.println(node.dump()); + // System.out.println("----------------------------------------------"); + // } catch (Exception ignored) { + // } functions.put(name, node.createRootNode().getCallTarget()); From ec5f7bf61a8daffde49a3bb6d6e846f91ee8c7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 31 Mar 2022 14:10:15 +0200 Subject: [PATCH 034/312] [wip] improve tests --- .../example/TestOperationsParserTest.java | 53 +++++++++++++++---- .../operations/OperationsParser.java | 6 --- .../instructions/BranchInstruction.java | 3 -- .../ConditionalBranchInstruction.java | 4 -- .../truffle/sl/test/SLSimpleTestSuite.java | 2 - .../src/tests/Fibonacci.sl | 7 --- .../truffle/sl/operations/SLOperations.java | 20 ++++++- 7 files changed, 61 insertions(+), 34 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 1194dea64392..7d05b58e7a40 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -11,7 +11,6 @@ import org.junit.Assert; import org.junit.Test; -import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; @@ -65,13 +64,15 @@ public void testAdd() { b.emitLoadArgument(1); b.endAddOperation(); b.endReturn(); + + b.build(); }); RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(42L, 20L, 22L); - Assert.assertEquals("foobar", "foo", "bar"); - Assert.assertEquals(100L, 120L, -20L); + Assert.assertEquals(42L, root.call(20L, 22L)); + Assert.assertEquals("foobar", root.call("foo", "bar")); + Assert.assertEquals(100L, root.call(120L, -20L)); } @Test @@ -93,14 +94,16 @@ public void testMax() { b.endReturn(); b.endIfThenElse(); + + b.build(); }); RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(42L, 42L, 13L); - Assert.assertEquals(42L, 42L, 13L); - Assert.assertEquals(42L, 42L, 13L); - Assert.assertEquals(42L, 13L, 42L); + Assert.assertEquals(42L, root.call(42L, 13L)); + Assert.assertEquals(42L, root.call(42L, 13L)); + Assert.assertEquals(42L, root.call(42L, 13L)); + Assert.assertEquals(42L, root.call(13L, 42L)); } @Test @@ -162,8 +165,36 @@ public void testTryCatch() { + " (return 1))" + " (return 0))"; //@formatter:on + OperationsNode node = parse(b -> { + b.beginTryCatch(0); + + b.beginIfThen(); + b.beginLessThanOperation(); + b.emitLoadArgument(0); + b.emitConstObject(0L); + b.endLessThanOperation(); + + b.emitThrowOperation(); + + b.endIfThen(); - new Tester(src).test(0L, 1L).test(1L, -1L); + b.beginReturn(); + b.emitConstObject(1L); + b.endReturn(); + + b.endTryCatch(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.build(); + }); + + RootCallTarget root = node.createRootNode().getCallTarget(); + + Assert.assertEquals(1L, root.call(-1L)); + Assert.assertEquals(0L, root.call(1L)); } @Test @@ -181,8 +212,8 @@ public void testSourceInfo() { public void testContextEval() { String src = "(return (add 1 2))"; - Context context = Context.create("test"); - long result = context.eval("test", src).asLong(); + Context context = Context.create("test-operations"); + long result = context.eval("test-operations", src).asLong(); Assert.assertEquals(3, result); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index c70d50861ed2..a68e4177ea30 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -2,24 +2,18 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; -import javax.tools.Diagnostic.Kind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.model.MessageContainer.Message; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 3aa8868ec3b7..4aa7e3cbde4d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -5,9 +5,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; public class BranchInstruction extends Instruction { public BranchInstruction(int id) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 8523b1407b53..79427a7df985 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -3,12 +3,8 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; public class ConditionalBranchInstruction extends Instruction { public ConditionalBranchInstruction(int id) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java index fcdecc830bbb..41fe19eb1f9f 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java @@ -43,8 +43,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; - @RunWith(SLTestRunner.class) @SLTestSuite({"tests"}) public class SLSimpleTestSuite { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl index 9af3c90885cc..858aaca32ed7 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl @@ -20,13 +20,6 @@ function fib(num) { function main() { i = 1; j = 1; - while (i < 100000) { - fib(10 + j); - j = j + 1; - if (j == 10) { - j = 1; - } - } while (i <= 10) { println(i + ": " + fib(i)); i = i + 1; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index e6b60d446e3a..3675f3665da5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -3,9 +3,11 @@ import java.util.Collections; import java.util.Map; +import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; @@ -14,6 +16,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; @@ -39,6 +42,7 @@ import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLContext; +import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @@ -109,8 +113,22 @@ static Object lookupFunction(TruffleString functionName, Node node) { @Operation @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { + @Specialization(guards = {"function.getCallTarget() == callTarget"}) + public static Object executeSL( + SLFunction function, + @Variadic Object[] argumentValues, + @Cached("function.getCallTarget()") RootCallTarget callTarget, + @Cached("create(callTarget)") DirectCallNode dcn) { + return dcn.call(argumentValues); + } + @Specialization - public static Object execute(Object function, @Variadic Object[] argumentValues, @Bind("this") Node node, @Bind("$bci") int bci, @CachedLibrary(limit = "3") InteropLibrary library) { + public static Object execute( + Object function, + @Variadic Object[] argumentValues, + @Bind("this") Node node, + @Bind("$bci") int bci, + @CachedLibrary(limit = "3") InteropLibrary library) { try { return library.execute(function, argumentValues); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { From 70268482ade277ba1ffcf200013901b3dcd94bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 31 Mar 2022 15:16:17 +0200 Subject: [PATCH 035/312] [wip] remove unneeded bytes from bytecode --- .../OperationsBytecodeCodeGenerator.java | 35 +++++++++++++------ .../instructions/CustomInstruction.java | 28 +++++++++++++-- .../truffle/sl/operations/SLOperations.java | 15 ++++---- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 240b9b759dd3..397377d486c7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -36,8 +36,8 @@ import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; @@ -51,6 +51,9 @@ public class OperationsBytecodeCodeGenerator { private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private final static Object MARKER_CHILD = new Object(); + private final static Object MARKER_CONST = new Object(); + private static final String DSL_METHOD_PREFIX = "execute_"; private static final String DSL_CLASS_PREFIX = "Execute_"; @@ -137,7 +140,10 @@ public CodeTypeElement createBuilderBytecodeNode() { final SingleOperationData soData = cinstr.getData(); final List additionalData = new ArrayList<>(); - final List additionalDataKinds = new ArrayList<>(); + final List additionalDataKinds = new ArrayList<>(); + + final List childIndices = new ArrayList<>(); + final List constIndices = new ArrayList<>(); NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { @Override @@ -188,15 +194,22 @@ private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirr throw new IllegalArgumentException("refObject is null"); } - int index = additionalData.indexOf(refObject); + List refList = isChild ? childIndices : constIndices; + int index = refList.indexOf(refObject); + int baseIndex = additionalData.indexOf(isChild ? MARKER_CHILD : MARKER_CONST); if (index == -1) { - index = additionalData.size(); - additionalData.add(refObject); - additionalData.add(null); + if (baseIndex == -1) { + baseIndex = additionalData.size(); + additionalData.add(isChild ? MARKER_CHILD : MARKER_CONST); + additionalData.add(null); + + additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); + additionalDataKinds.add(DataKind.CONTINUATION); + } - additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); - additionalDataKinds.add(DataKind.CONTINUATION); + index = refList.size(); + refList.add(refObject); } CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -216,9 +229,9 @@ private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirr b.variable(targetField).string("["); b.startCall("LE_BYTES", "getShort"); b.variable(fldBc); - b.string("$bci + " + cinstr.lengthWithoutState() + " + " + index); + b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); b.end(); - b.string("]"); + b.string(" + " + index + "]"); if (doCast) { b.end(); @@ -298,6 +311,8 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp cinstr.setExecuteMethod(uncExec); cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); + cinstr.setNumChildNodes(childIndices.size()); + cinstr.setNumConsts(constIndices.size()); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 139ef4166834..ba57be092d32 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -1,13 +1,15 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.List; + import javax.lang.model.element.ExecutableElement; import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -22,6 +24,8 @@ public enum DataKind { private final SingleOperationData data; private ExecutableElement executeMethod; private DataKind[] dataKinds = null; + private int numChildNodes; + private int numConsts; public SingleOperationData getData() { return data; @@ -62,6 +66,10 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C int lengthWithoutState = lengthWithoutState(); + b.lineComment("additionalData = " + dataKinds.length + " bytes: " + List.of(dataKinds)); + b.lineComment(" numChildNodes = " + numChildNodes); + b.lineComment(" numConsts = " + numConsts); + for (int i = 0; i < dataKinds.length; i++) { CodeTree index = b.create().variable(vars.bci).string(" + " + lengthWithoutState + " + " + i).build(); switch (dataKinds[i]) { @@ -75,7 +83,7 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); b.tree(index); - b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).variable(vars.numChildNodes).string("++").end(); + b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).variable(vars.numChildNodes).end(); b.end(); break; case CONST: @@ -93,6 +101,14 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.end(); } + for (int i = 1; i < numConsts; i++) { + b.startStatement().startCall(vars.consts, "reserve").end(2); + } + + if (numChildNodes > 0) { + b.startStatement().variable(vars.numChildNodes).string(" += " + numChildNodes).end(); + } + return b.build(); } @@ -157,4 +173,12 @@ public String dumpInfo() { return sb.toString(); } + + public void setNumChildNodes(int numChildNodes) { + this.numChildNodes = numChildNodes; + } + + public void setNumConsts(int numConsts) { + this.numConsts = numConsts; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 3675f3665da5..e10dfe0504a2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -3,11 +3,9 @@ import java.util.Collections; import java.util.Map; -import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; @@ -16,7 +14,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; @@ -101,7 +99,9 @@ public static Object perform( @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute(TruffleString functionName, @Cached("lookupFunction(functionName, this)") Object result) { + public static Object execute( + @SuppressWarnings("unused") TruffleString functionName, + @Cached("lookupFunction(functionName, this)") Object result) { return result; } @@ -113,13 +113,12 @@ static Object lookupFunction(TruffleString functionName, Node node) { @Operation @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { - @Specialization(guards = {"function.getCallTarget() == callTarget"}) + @Specialization public static Object executeSL( SLFunction function, @Variadic Object[] argumentValues, - @Cached("function.getCallTarget()") RootCallTarget callTarget, - @Cached("create(callTarget)") DirectCallNode dcn) { - return dcn.call(argumentValues); + @Cached IndirectCallNode callNode) { + return callNode.call(function.getCallTarget(), argumentValues); } @Specialization From ae25f8070b56bb21a6d109935de9e347ae698eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 1 Apr 2022 13:15:24 +0200 Subject: [PATCH 036/312] [wip] add condition profiling --- .../OperationsBytecodeCodeGenerator.java | 19 +++++++++++++++---- .../operations/OperationsCodeGenerator.java | 13 ++++++++++++- .../ConditionalBranchInstruction.java | 10 +++++++--- .../operations/instructions/Instruction.java | 13 +++++++++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 397377d486c7..9f6b67ca9c5e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -11,6 +11,7 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; @@ -57,19 +58,21 @@ public class OperationsBytecodeCodeGenerator { private static final String DSL_METHOD_PREFIX = "execute_"; private static final String DSL_CLASS_PREFIX = "Execute_"; + private final ProcessorContext context = ProcessorContext.getInstance(); + private final TruffleTypes types = context.getTypes(); + + private static final String ConditionProfile_Name = "com.oracle.truffle.api.profiles.ConditionProfile"; + final DeclaredType ConditionProfile = context.getDeclaredType(ConditionProfile_Name); + private final CodeTypeElement typBuilderImpl; private final String simpleName; - private final ProcessorContext context; private final OperationsData m; - private final TruffleTypes types; private final boolean withInstrumentation; public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { this.typBuilderImpl = typBuilderImpl; this.simpleName = simpleName; this.m = m; - this.context = ProcessorContext.getInstance(); - this.types = context.getTypes(); this.withInstrumentation = withInstrumentation; } @@ -96,6 +99,10 @@ public CodeTypeElement createBuilderBytecodeNode() { GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); builderBytecodeNodeType.add(fldHandlers); + CodeVariableElement fldConditionBranches = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(ConditionProfile), "conditionProfiles"); + GeneratorUtils.addCompilationFinalAnnotation(fldConditionBranches, 1); + builderBytecodeNodeType.add(fldConditionBranches); + CodeVariableElement fldProbeNodes = null; if (withInstrumentation) { fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); @@ -770,6 +777,10 @@ private CodeTree createInputCode(ExecutionVariables vars, Instruction instr, int return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).variable(vars.consts) // .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // .build(); + case BRANCH_PROFILE: + return CodeTreeBuilder.createBuilder().string("conditionProfiles") // + .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // + .build(); case INSTRUMENT: case BRANCH_TARGET: return instr.createReadArgumentCode(index, vars); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 5d3d2df465ec..2d1eceb4991c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -246,6 +246,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldNumChildNodes = new CodeVariableElement(context.getType(int.class), "numChildNodes"); typBuilderImpl.add(fldNumChildNodes); + CodeVariableElement fldNumBranchProfiles = new CodeVariableElement(context.getType(int.class), "numBranchProfiles"); + typBuilderImpl.add(fldNumBranchProfiles); + CodeVariableElement fldBuiltNodes = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.OperationsNode), "builtNodes"); typBuilderImpl.add(fldBuiltNodes); { @@ -307,6 +310,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign(fldBci).string("0").end(); b.startAssign(fldNumChildNodes).string("0").end(); + b.startAssign(fldNumBranchProfiles).string("0").end(); b.startAssign(fldCurStack).string("0").end(); b.startAssign(fldMaxStack).string("0").end(); if (FLAG_NODE_AST_PRINTING) { @@ -356,6 +360,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.statement("OperationsNode result"); + b.declaration("ConditionProfile[]", "condProfiles", "new ConditionProfile[numBranchProfiles]"); + b.startFor().string("int i = 0; i < numBranchProfiles; i++").end().startBlock(); + b.statement("condProfiles[i] = ConditionProfile.createCountingProfile()"); + b.end(); + if (ENABLE_INSTRUMENTATION) { b.startIf().variable(fldKeepInstrumentation).end(); b.startBlock(); @@ -375,7 +384,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("cpCopy"); b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); - // b.string("getInstrumentTrees()"); + b.string("condProfiles"); + b.string("getInstrumentTrees()"); b.end(2); b.end().startElseBlock(); @@ -396,6 +406,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("cpCopy"); b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); + b.string("condProfiles"); b.end(2); if (ENABLE_INSTRUMENTATION) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 79427a7df985..9682fb361ef8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -8,19 +8,23 @@ public class ConditionalBranchInstruction extends Instruction { public ConditionalBranchInstruction(int id) { - super("brfalse", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE); + super("brfalse", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); } @Override public TypeMirror[] expectedInputTypes(ProcessorContext context) { - return new TypeMirror[]{context.getType(short.class), context.getType(boolean.class)}; + return new TypeMirror[]{ + context.getType(short.class), + context.getType(boolean.class), + context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile") + }; } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().variable(vars.inputs[1]).end(); + b.startIf().startCall(vars.inputs[2], "profile").variable(vars.inputs[1]).end(2); b.startBlock(); b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); b.statement("continue loop"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index da52ecd00dda..75ddbb9446a9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -41,6 +41,7 @@ public static enum InputType { LOCAL(2), ARGUMENT(2), INSTRUMENT(2), + BRANCH_PROFILE(2), BRANCH_TARGET(2); final int argumentLength; @@ -60,6 +61,8 @@ public final TypeMirror getDefaultExecutionType(ProcessorContext context) { return context.getType(Object.class); case VARARG_VALUE: return new ArrayCodeTypeMirror(context.getType(Object.class)); + case BRANCH_PROFILE: + return context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); case BRANCH_TARGET: case INSTRUMENT: return context.getType(short.class); @@ -73,6 +76,7 @@ boolean needsBuilderArgument() { case STACK_VALUE: case STACK_VALUE_IGNORED: case VARARG_VALUE: + case BRANCH_PROFILE: return false; case CONST_POOL: case LOCAL: @@ -91,6 +95,7 @@ public final TypeMirror getDefaultBuilderType(ProcessorContext context) { case STACK_VALUE_IGNORED: case VARARG_VALUE: case INSTRUMENT: + case BRANCH_PROFILE: return null; case CONST_POOL: return context.getType(Object.class); @@ -114,6 +119,8 @@ public final CodeTree getImplicitValue(BuilderVariables vars, Instruction instr) case BRANCH_TARGET: case INSTRUMENT: return null; + case BRANCH_PROFILE: + return CodeTreeBuilder.singleString("ConditionProfile.createCountingProfile()"); case VARARG_VALUE: return CodeTreeBuilder.createBuilder().variable(vars.numChildren).string(" - " + instr.numStackValuesExclVarargs()).build(); default: @@ -160,6 +167,8 @@ public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { .doubleQuote("**%d") // .tree(op.createReadArgumentCode(n, vars)) // .end(3).build(); + case BRANCH_PROFILE: + return null; default: throw new IllegalArgumentException("Unexpected value: " + this); } @@ -322,6 +331,10 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code value = CodeTreeBuilder.createBuilder().startParantheses().variable(vars.numChildren).string(" - " + numStackValuesExclVarargs()).end().build(); } + if (n < inputs.length && inputs[n] == InputType.BRANCH_PROFILE) { + value = CodeTreeBuilder.singleString("numBranchProfiles++"); + } + if (n < inputs.length && inputs[n] == InputType.CONST_POOL) { value = CodeTreeBuilder.createBuilder().startCall(vars.consts, "add").tree(value).end().build(); } From 2e86e68bfaed8eb3260893069ed970a762137303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 1 Apr 2022 15:46:56 +0200 Subject: [PATCH 037/312] [wip] OperationsNode no longer stores name, lang --- .../operation/test/example/TestLanguage.java | 9 +-- .../test/example/TestLanguageBackend.java | 1 - .../test/example/TestOperations.java | 1 + .../example/TestOperationsParserTest.java | 31 +++------- .../api/operation/OperationsBuilder.java | 18 ------ .../truffle/api/operation/OperationsNode.java | 17 ++--- .../api/operation/OperationsRootNode.java | 62 ++++++++++--------- .../generator/FlatNodeGenFactory.java | 26 ++++++-- .../OperationsBytecodeCodeGenerator.java | 4 +- .../operations/OperationsCodeGenerator.java | 27 -------- .../src/com/oracle/truffle/sl/SLLanguage.java | 5 +- .../sl/nodes/SLOperationsRootNode.java | 28 +++++++++ .../oracle/truffle/sl/nodes/SLRootNode.java | 2 +- .../truffle/sl/operations/SLOperations.java | 46 ++++++++++---- .../operations/SLOperationsVisitor.java | 19 +++--- 15 files changed, 147 insertions(+), 149 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java index cc2a0ac12310..14c82cb38741 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java @@ -10,20 +10,17 @@ public class TestLanguage extends TruffleLanguage { @Override protected TestContext createContext(TruffleLanguage.Env env) { - return new TestContext(env); + return new TestContext(); } @Override protected CallTarget parse(ParsingRequest request) throws Exception { OperationsNode[] nodes = TestOperationsBuilder.parse(this, request.getSource()); - return nodes[nodes.length - 1].createRootNode().getCallTarget(); + return nodes[nodes.length - 1].createRootNode(this, "test").getCallTarget(); } } class TestContext { - private final TruffleLanguage.Env env; - - public TestContext(TruffleLanguage.Env env) { - this.env = env; + TestContext() { } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java index 6687c4d11bb9..7cef9443e940 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java @@ -15,7 +15,6 @@ public TestLanguageBackend(TestOperationsBuilder b) { } public void buildRoot(Source source, TestLanguageAst ast) { - b.setNodeName("TestFunction"); b.beginSource(source); build(ast); b.endSource(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index cb019a6c6322..e12c26bb8d16 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -25,6 +25,7 @@ public TestException(String string, OperationsNode node, int bci) { } } + @SuppressWarnings("unused") public static void parse(TestLanguage language, Object input, TestOperationsBuilder builder) { if (input instanceof Source) { Source source = (Source) input; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 7d05b58e7a40..e61888e442d5 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -32,7 +32,7 @@ private static class Tester { } else { node = TestOperationsBuilder.parse(null, s)[0]; } - rootNode = node.createRootNode(); + rootNode = node.createRootNode(null, "TestFunction"); } Tester(String src) { @@ -51,13 +51,13 @@ public Tester then(Consumer action) { } } - private static OperationsNode parse(Consumer builder) { - return TestOperationsBuilder.parse(null, builder)[0]; + private static RootCallTarget parse(Consumer builder) { + return TestOperationsBuilder.parse(null, builder)[0].createRootNode(null, "TestFunction").getCallTarget(); } @Test public void testAdd() { - OperationsNode node = parse(b -> { + RootCallTarget root = parse(b -> { b.beginReturn(); b.beginAddOperation(); b.emitLoadArgument(0); @@ -68,8 +68,6 @@ public void testAdd() { b.build(); }); - RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(42L, root.call(20L, 22L)); Assert.assertEquals("foobar", root.call("foo", "bar")); Assert.assertEquals(100L, root.call(120L, -20L)); @@ -77,7 +75,7 @@ public void testAdd() { @Test public void testMax() { - OperationsNode node = parse(b -> { + RootCallTarget root = parse(b -> { b.beginIfThenElse(); b.beginLessThanOperation(); @@ -98,8 +96,6 @@ public void testMax() { b.build(); }); - RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(42L, root.call(42L, 13L)); Assert.assertEquals(42L, root.call(42L, 13L)); Assert.assertEquals(42L, root.call(42L, 13L)); @@ -108,7 +104,7 @@ public void testMax() { @Test public void testIfThen() { - OperationsNode node = parse(b -> { + RootCallTarget root = parse(b -> { b.beginIfThen(); b.beginLessThanOperation(); @@ -129,8 +125,6 @@ public void testIfThen() { b.build(); }); - RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(0L, root.call(-2L)); Assert.assertEquals(0L, root.call(-1L)); Assert.assertEquals(0L, root.call(0L)); @@ -156,16 +150,7 @@ public void testSumLoop() { @Test public void testTryCatch() { - //@formatter:off - String src = "(do" - + " (try 0" - + " (if" - + " (less (arg 0) 0)" - + " (fail))" - + " (return 1))" - + " (return 0))"; - //@formatter:on - OperationsNode node = parse(b -> { + RootCallTarget root = parse(b -> { b.beginTryCatch(0); b.beginIfThen(); @@ -191,8 +176,6 @@ public void testTryCatch() { b.build(); }); - RootCallTarget root = node.createRootNode().getCallTarget(); - Assert.assertEquals(1L, root.call(-1L)); Assert.assertEquals(0L, root.call(1L)); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 59181dedf5a4..5c32e6316289 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -25,14 +25,10 @@ public final OperationsNode[] collect() { return builtNodes.toArray(new OperationsNode[builtNodes.size()]); } - protected String nodeName = null; - protected boolean isInternal = false; protected int maxLocals = -1; protected int instrumentationId = 0; public void reset() { - nodeName = null; - isInternal = false; labelFills.clear(); maxLocals = -1; instrumentationId = 0; @@ -45,20 +41,6 @@ protected final Object trackLocalsHelper(Object value) { return value; } - public final void setNodeName(String nodeName) { - if (this.nodeName != null) { - throw new IllegalStateException("Node name already set"); - } - this.nodeName = nodeName; - } - - public final void setInternal() { - if (isInternal) { - throw new IllegalStateException("isInternal already set"); - } - isInternal = true; - } - // ------------------------ labels ------------------------ private static class LabelFill { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 76ad798f6298..786a5fa07bb1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -29,30 +29,21 @@ private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals protected final int maxStack; protected final int maxLocals; - protected final String nodeName; - protected final TruffleLanguage language; protected final Object parseContext; protected int[][] sourceInfo; protected Source[] sources; protected final int buildOrder; - protected final boolean isInternal; protected OperationsNode( - TruffleLanguage language, Object parseContext, - String nodeName, - boolean isInternal, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals) { - this.language = language; this.buildOrder = buildOrder; this.parseContext = parseContext; - this.nodeName = nodeName; - this.isInternal = isInternal; this.sourceInfo = sourceInfo; this.sources = sources; this.maxLocals = maxLocals; @@ -63,8 +54,12 @@ public FrameDescriptor createFrameDescriptor() { return createFrameDescriptor(maxStack, maxLocals); } - public OperationsRootNode createRootNode() { - return new OperationsRootNode(this); + public OperationsRootNode createRootNode(TruffleLanguage language, String name) { + return new OperationsRootNode(language, this, name, false); + } + + public OperationsRootNode createInternalRootNode(TruffleLanguage language, String name) { + return new OperationsRootNode(language, this, name, true); } public final Object execute(VirtualFrame frame) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index c3a7dbeefbd4..0dc4a8bf17f5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -1,29 +1,32 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrumentation.InstrumentableNode; -import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -public class OperationsRootNode extends RootNode implements InstrumentableNode { +public class OperationsRootNode extends RootNode { @Child private OperationsNode node; - OperationsRootNode(OperationsNode node) { - super(node.language, node.createFrameDescriptor()); - this.node = node; + private final String nodeName; + private final boolean isInternal; + + OperationsRootNode(TruffleLanguage language, OperationsNode node, String nodeName, boolean isInternal) { + super(language, node.createFrameDescriptor()); + this.node = insert(node); + this.nodeName = nodeName; + this.isInternal = isInternal; } @Override public String getName() { - return node.nodeName; + return nodeName; } @Override public boolean isInternal() { - return node.isInternal; + return isInternal; } @Override @@ -44,28 +47,29 @@ protected Object translateStackTraceElement(TruffleStackTraceElement element) { @Override public boolean isInstrumentable() { - return true; - } - - private class OperationsWrapperNode extends Node implements WrapperNode { - private final ProbeNode probe; - - OperationsWrapperNode(ProbeNode probe) { - this.probe = probe; - } - - public Node getDelegateNode() { - return OperationsRootNode.this; - } - - public ProbeNode getProbeNode() { - return probe; - } + return false; } - public WrapperNode createWrapper(final ProbeNode probe) { - return new OperationsWrapperNode(probe); - } +// private class OperationsWrapperNode extends Node implements WrapperNode { +// private final ProbeNode probe; +// +// OperationsWrapperNode(ProbeNode probe) { +// this.probe = probe; +// } +// +// public Node getDelegateNode() { +// return OperationsRootNode.this; +// } +// +// public ProbeNode getProbeNode() { +// return probe; +// } +// } + +// public WrapperNode createWrapper(final ProbeNode probe) { +// // return new OperationsWrapperNode(probe); +// return null; +// } @Override public String toString() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 08417dc466c3..23f14a42df9a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -121,6 +121,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeParameterElement; @@ -4591,7 +4592,11 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, String specializationLocalName = createSpecializationLocalName(specialization); boolean useSpecializationClass = useSpecializationClass(specialization); if (method == null) { - method = new CodeExecutableElement(context.getType(void.class), "remove" + specialization.getId() + "_"); + String methodName = "remove" + specialization.getId() + "_"; + if (plugs != null) { + methodName = plugs.transformNodeMethodName(methodName); + } + method = new CodeExecutableElement(context.getType(void.class), methodName); if (useSpecializationClass) { method.addParameter(new CodeVariableElement(context.getType(Object.class), specializationLocalName)); } @@ -4601,25 +4606,31 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.statement("lock.lock()"); builder.startTryBlock(); } - String fieldName = createSpecializationFieldName(specialization); + CodeTree fieldRef = CodeTreeBuilder.singleString("this." + createSpecializationFieldName(specialization)); + CodeTree fieldRefWrite = fieldRef; + if (plugs != null) { + String fieldName = useSpecializationClass ? null : createSpecializationFieldName(specialization); + fieldRef = plugs.createSpecializationFieldReference(specialization, fieldName, useSpecializationClass, new GeneratedTypeMirror("", createSpecializationTypeName(specialization))); + fieldRefWrite = plugs.createSpecializationFieldReference(specialization, fieldName, useSpecializationClass, null); + } if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { // single instance remove builder.tree((multiState.createSet(null, new Object[]{specialization}, false, true))); if (useSpecializationClass) { - builder.statement("this." + fieldName + " = null"); + builder.startStatement().tree(fieldRef).string(" = null").end(); } } else { // multi instance remove String typeName = createSpecializationTypeName(specialization); boolean specializedIsNode = specializationClassIsNode(specialization); builder.declaration(typeName, "prev", "null"); - builder.declaration(typeName, "cur", "this." + fieldName); + builder.declaration(typeName, "cur", fieldRef); builder.startWhile(); builder.string("cur != null"); builder.end().startBlock(); builder.startIf().string("cur == ").string(specializationLocalName).end().startBlock(); builder.startIf().string("prev == null").end().startBlock(); - builder.statement("this." + fieldName + " = cur.next_"); + builder.startStatement().tree(fieldRefWrite).string(" = cur.next_").end(); if (specializedIsNode) { builder.statement("this.adoptChildren()"); } @@ -4635,7 +4646,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.statement("cur = cur.next_"); builder.end(); // while block - builder.startIf().string("this." + fieldName).string(" == null").end().startBlock(); + builder.startIf().tree(fieldRefWrite).string(" == null").end().startBlock(); builder.tree((multiState.createSet(null, Arrays.asList(specialization).toArray(new SpecializationData[0]), false, true))); builder.end(); } @@ -4649,6 +4660,9 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, } CodeTreeBuilder builder = parent.create(); builder.startStatement().startCall(method.getSimpleName().toString()); + if (plugs != null) { + plugs.addNodeCallParameters(builder); + } if (useSpecializationClass) { builder.string(specializationLocalName); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 9f6b67ca9c5e..1cd5fa0b8cb1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -806,8 +806,8 @@ private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { b.startStatement(); b.string("OperationsNode reparsed = "); b.startStaticCall(typBuilderImpl.asType(), "reparse"); - b.startGroup().cast(m.getLanguageType()).string("this.language").end(); - b.startGroup().cast(m.getParseContextType()).string("parseContext").end(); + b.startGroup().startCall("getRootNode").end().startCall(".getLanguage").typeLiteral(m.getLanguageType()).end(2); + b.startGroup().maybeCast(context.getType(Object.class), m.getParseContextType()).string("parseContext").end(); b.string("buildOrder"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 2d1eceb4991c..2b4bf47ac26d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -319,8 +319,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign(fldOperationData).startNew(types.BuilderOperationData).string("null").string("0").string("0").string("0").string("false").end(2); b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); - b.startAssign("nodeName").string("null").end(); - b.startAssign("isInternal").string("false").end(); b.startIf().variable(fldKeepSourceInfo).end(); b.startBlock(); @@ -371,10 +369,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign("result"); b.startNew(builderInstrBytecodeNodeType.asType()); - b.variable(fldLanguage); b.variable(fldParseContext); - b.string("nodeName"); - b.string("isInternal"); b.string("sourceInfo"); b.string("sources"); b.variable(fldNodeNumber); @@ -393,10 +388,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign("result"); b.startNew(builderBytecodeNodeType.asType()); - b.variable(fldLanguage); b.variable(fldParseContext); - b.string("nodeName"); - b.string("isInternal"); b.string("sourceInfo"); b.string("sources"); b.variable(fldNodeNumber); @@ -798,25 +790,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } - /** - * Creates a stack field. - * - * @param name the name of the stack field. It will get {@code "Stack"} appended to it. - * @param argType the type of the stack elements - * @return the created stack field - */ - private CodeVariableElement createStackField(String name, TypeMirror argType) { - TypeMirror stackType = generic(context.getTypeElement(Stack.class), argType); - CodeVariableElement element = new CodeVariableElement( - Set.of(Modifier.PRIVATE, Modifier.FINAL), - stackType, - name + "Stack"); - CodeTreeBuilder ctb = element.createInitBuilder(); - ctb.string("new Stack<>()"); - - return element; - } - private static TypeMirror generic(TypeElement el, TypeMirror... params) { return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index b04b6f007e74..6c19a2f2647f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -61,7 +61,6 @@ import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.object.Shape; @@ -76,6 +75,7 @@ import com.oracle.truffle.sl.builtins.SLStackTraceBuiltin; import com.oracle.truffle.sl.nodes.SLEvalRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; +import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.nodes.SLRootNode; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLUndefinedFunctionRootNode; @@ -104,7 +104,6 @@ import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; -import com.oracle.truffle.sl.operations.SLOperations; import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SLNodeFactory; import com.oracle.truffle.sl.parser.SimpleLanguageLexer; @@ -328,7 +327,7 @@ protected CallTarget parse(ParsingRequest request) throws Exception { } OperationsNode[] operations = SLOperationsBuilder.parse(this, source); - return operations[operations.length - 1].createRootNode().getCallTarget(); + return new SLOperationsRootNode(this, operations[operations.length - 1], null).getCallTarget(); } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java new file mode 100644 index 000000000000..f907f4770b0c --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java @@ -0,0 +1,28 @@ +package com.oracle.truffle.sl.nodes; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; + +public class SLOperationsRootNode extends SLRootNode { + + @Child private OperationsNode operationsNode; + + public SLOperationsRootNode(SLLanguage language, OperationsNode operationsNode, TruffleString name) { + super(language, operationsNode.createFrameDescriptor(), null, null, name); + this.operationsNode = insert(operationsNode); + } + + @Override + public Object execute(VirtualFrame frame) { + return operationsNode.execute(frame); + } + + @Override + public SourceSection getSourceSection() { + return operationsNode.getSourceSection(); + } + +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java index 0bcd205ccbf5..1fa21921733f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java @@ -106,7 +106,7 @@ public SLExpressionNode getBodyNode() { @Override public String getName() { - return name.toJavaStringUncached(); + return name == null ? null : name.toJavaStringUncached(); } public TruffleString getTSName() { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index e10dfe0504a2..954d3abcb7c3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -3,6 +3,7 @@ import java.util.Collections; import java.util.Map; +import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -14,6 +15,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -65,7 +67,6 @@ public static void parse(SLLanguage language, Source source, SLOperationsBuilder // create the RootNode - builder.setInternal(); // root node is internal builder.beginReturn(); builder.beginSLEvalRootOperation(); builder.emitConstObject(Collections.unmodifiableMap(targets)); @@ -113,24 +114,45 @@ static Object lookupFunction(TruffleString functionName, Node node) { @Operation @TypeSystemReference(SLTypes.class) public static class SLInvokeOperation { - @Specialization - public static Object executeSL( - SLFunction function, - @Variadic Object[] argumentValues, + @Specialization(limit = "3", // + guards = "function.getCallTarget() == cachedTarget", // + assumptions = "callTargetStable") + @SuppressWarnings("unused") + protected static Object doDirect(SLFunction function, @Variadic Object[] arguments, + @Cached("function.getCallTargetStable()") Assumption callTargetStable, + @Cached("function.getCallTarget()") RootCallTarget cachedTarget, + @Cached("create(cachedTarget)") DirectCallNode callNode) { + + /* Inline cache hit, we are safe to execute the cached call target. */ + Object returnValue = callNode.call(arguments); + return returnValue; + } + + /** + * Slow-path code for a call, used when the polymorphic inline cache exceeded its maximum + * size specified in INLINE_CACHE_SIZE. Such calls are not optimized any + * further, e.g., no method inlining is performed. + */ + @Specialization(replaces = "doDirect") + protected static Object doIndirect(SLFunction function, @Variadic Object[] arguments, @Cached IndirectCallNode callNode) { - return callNode.call(function.getCallTarget(), argumentValues); + /* + * SL has a quite simple call lookup: just ask the function for the current call target, + * and call it. + */ + return callNode.call(function.getCallTarget(), arguments); } @Specialization - public static Object execute( + protected static Object doInterop( Object function, - @Variadic Object[] argumentValues, + @Variadic Object[] arguments, + @CachedLibrary(limit = "3") InteropLibrary library, @Bind("this") Node node, - @Bind("$bci") int bci, - @CachedLibrary(limit = "3") InteropLibrary library) { + @Bind("$bci") int bci) { try { - return library.execute(function, argumentValues); - } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { + return library.execute(function, arguments); + } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { /* Execute was not successful. */ throw SLUndefinedNameException.undefinedFunction(node, bci, function); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 94627539f97c..084e41e9be73 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -16,6 +16,7 @@ import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ArithmeticContext; import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.BlockContext; @@ -117,8 +118,6 @@ public Void visitFunction(FunctionContext ctx) { b.beginSource(source); b.beginInstrumentation(StandardTags.RootTag.class); - b.setNodeName(name.toJavaStringUncached()); - scope = new LexicalScope(null); for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { @@ -157,7 +156,9 @@ public Void visitFunction(FunctionContext ctx) { // } catch (Exception ignored) { // } - functions.put(name, node.createRootNode().getCallTarget()); + SLOperationsRootNode rootNode = new SLOperationsRootNode(language, node, name); + + functions.put(name, rootNode.getCallTarget()); return null; } @@ -311,7 +312,7 @@ private void logicalOrMiddle(int localIdx) { b.emitLoadLocal(localIdx); } - private void logicalOrEnd(int localIdx) { + private void logicalOrEnd(@SuppressWarnings("unused") int localIdx) { b.endConditional(); b.endBlock(); } @@ -598,7 +599,7 @@ private void buildMemberExpressionRead(Token ident, List */ - private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { + private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { int localIdx = scope.getOrCreate(asTruffleString(ident, false)); b.beginBlock(); @@ -643,9 +644,9 @@ private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { + private void buildMemberExpressionWriteAfter(Token ident, @SuppressWarnings("unused") List members, int idx) { if (idx == -1) { int localIdx = scope.get(asTruffleString(ident, false)); b.endStoreLocal(); From 5ec88dd14187a4f2d736d204569b59bf7cd6bc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 1 Apr 2022 15:58:17 +0200 Subject: [PATCH 038/312] [wip] suppress most warnings from builder --- .../api/operation/OperationsInstrumentableNode.java | 5 +---- .../truffle/dsl/processor/generator/GeneratorUtils.java | 9 +++++++-- .../processor/operations/OperationsCodeGenerator.java | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java index e526f59f8dfc..8efa3cae641e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java @@ -10,17 +10,14 @@ public abstract class OperationsInstrumentableNode extends OperationsNode { @Children OperationsInstrumentTreeNode[] instrumentTree; protected OperationsInstrumentableNode( - TruffleLanguage language, Object parseContext, - String nodeName, - boolean isInternal, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals, OperationsInstrumentTreeNode[] instrumentTree) { - super(language, parseContext, nodeName, isInternal, sourceInfo, sources, buildOrder, maxStack, maxLocals); + super(parseContext, sourceInfo, sources, buildOrder, maxStack, maxLocals); this.instrumentTree = instrumentTree; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index c0325cf1fc7e..3d26818e8933 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -332,11 +332,16 @@ public static void addGeneratedBy(ProcessorContext context, CodeTypeElement gene } } - public static void addSuppressWarnings(ProcessorContext context, CodeElement element, String value) { + public static void addSuppressWarnings(ProcessorContext context, CodeElement element, String... value) { CodeAnnotationMirror annSuppressWarnings = new CodeAnnotationMirror(context.getDeclaredType(SuppressWarnings.class)); element.addAnnotationMirror(annSuppressWarnings); - annSuppressWarnings.setElementValue("value", new CodeAnnotationValue(value)); + if (value.length == 1) { + annSuppressWarnings.setElementValue("value", new CodeAnnotationValue(value[0])); + } else { + annSuppressWarnings.setElementValue("value", new CodeAnnotationValue( + Arrays.stream(value).map(CodeAnnotationValue::new).collect(Collectors.toList()))); + } } static List findUserConstructors(TypeMirror nodeType) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 2b4bf47ac26d..48c234fc4415 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -81,6 +81,7 @@ CodeTypeElement createBuilder(String simpleName) { CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); + GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked"); { CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); From ef063dc7e5d46189a12a21eec10f9cd58ca559d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 4 Apr 2022 14:38:19 +0200 Subject: [PATCH 039/312] [wip] fix PR comments & revert some test edits --- .../AbstractOperationsTruffleException.java | 2 +- .../truffle/api/operation/OperationsNode.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 18 +++++++++++------- .../operations/OperationsContext.java | 8 ++++---- .../ConditionalBranchInstruction.java | 2 +- .../src/tests/Fibonacci.sl | 1 - .../src/tests/Inlining.output | 2 +- .../src/tests/Inlining.sl | 2 +- .../src/tests/LoopCall.sl | 4 ++-- .../truffle/sl/operations/SLOperations.java | 9 +++++---- 10 files changed, 27 insertions(+), 23 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index 14d5c5a9db2c..55f52408f929 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -31,7 +31,7 @@ public AbstractOperationsTruffleException(String message) { private static Node getLocation(Node location, int bci) { if (bci >= 0) { - return ((OperationsNode) location).createFakeLocationNode(bci); + return ((OperationsNode) location).createLocationNode(bci); } else { return location; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 786a5fa07bb1..36e236124bde 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -114,7 +114,7 @@ protected final SourceSection getSourceSectionAtBciImpl(int bci) { } } - public final Node createFakeLocationNode(final int bci) { + public final Node createLocationNode(final int bci) { return new Node() { @Override public SourceSection getSourceSection() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 1cd5fa0b8cb1..a74d76fad6c2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -55,9 +55,6 @@ public class OperationsBytecodeCodeGenerator { private final static Object MARKER_CHILD = new Object(); private final static Object MARKER_CONST = new Object(); - private static final String DSL_METHOD_PREFIX = "execute_"; - private static final String DSL_CLASS_PREFIX = "Execute_"; - private final ProcessorContext context = ProcessorContext.getInstance(); private final TruffleTypes types = context.getTypes(); @@ -145,6 +142,9 @@ public CodeTypeElement createBuilderBytecodeNode() { CustomInstruction cinstr = (CustomInstruction) instr; + final Set methodNames = new HashSet<>(); + final Set innerTypeNames = new HashSet<>(); + final SingleOperationData soData = cinstr.getData(); final List additionalData = new ArrayList<>(); final List additionalDataKinds = new ArrayList<>(); @@ -155,12 +155,16 @@ public CodeTypeElement createBuilderBytecodeNode() { NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { @Override public String transformNodeMethodName(String name) { - return DSL_METHOD_PREFIX + name + "_" + soData.getName(); + String result = soData.getName() + "_" + name + "_"; + methodNames.add(result); + return result; } @Override public String transformNodeInnerTypeName(String name) { - return DSL_CLASS_PREFIX + name + "_" + soData.getName(); + String result = soData.getName() + "_" + name; + innerTypeNames.add(result); + return result; } @Override @@ -272,7 +276,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp CodeExecutableElement uncExec = null; List execs = new ArrayList<>(); for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { - if (!ex.getSimpleName().toString().startsWith(DSL_METHOD_PREFIX)) { + if (!methodNames.contains(ex.getSimpleName().toString())) { continue; } @@ -283,7 +287,7 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp } for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { - if (!te.getSimpleName().toString().startsWith(DSL_CLASS_PREFIX)) { + if (!innerTypeNames.contains(te.getSimpleName().toString())) { continue; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 9c45a3a2447b..8fab278bbfcc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -52,10 +52,10 @@ private void createBuiltinOperations() { add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - add(new Operation.Simple(this, "ConstObject", operationId++, 0, iConst = add(new TransferInstruction("const", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new TransferInstruction("ldarg", instructionId++, ResultType.STACK_VALUE, InputType.ARGUMENT)))); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new TransferInstruction("ldloc", instructionId++, ResultType.STACK_VALUE, InputType.LOCAL)))); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, iStloc = add(new TransferInstruction("stloc", instructionId++, ResultType.SET_LOCAL, InputType.STACK_VALUE)))); + add(new Operation.Simple(this, "ConstObject", operationId++, 0, iConst = add(new TransferInstruction("load.constant", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new TransferInstruction("load.argument", instructionId++, ResultType.STACK_VALUE, InputType.ARGUMENT)))); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new TransferInstruction("load.local", instructionId++, ResultType.STACK_VALUE, InputType.LOCAL)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, iStloc = add(new TransferInstruction("store.local", instructionId++, ResultType.SET_LOCAL, InputType.STACK_VALUE)))); add(new Operation.Simple(this, "Return", operationId++, 1, add(new TransferInstruction("return", instructionId++, ResultType.RETURN, InputType.STACK_VALUE)))); add(new Operation.Instrumentation(this, operationId++, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 9682fb361ef8..34d34043b793 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -8,7 +8,7 @@ public class ConditionalBranchInstruction extends Instruction { public ConditionalBranchInstruction(int id) { - super("brfalse", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); + super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); } @Override diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl index 858aaca32ed7..939f39fd44cf 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Fibonacci.sl @@ -19,7 +19,6 @@ function fib(num) { function main() { i = 1; - j = 1; while (i <= 10) { println(i + ": " + fib(i)); i = i + 1; diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output index 16d117a0ae98..b6fe452fbd8c 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.output @@ -1 +1 @@ -126000000 \ No newline at end of file +1260000 \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl index 3fca08492d40..0702190c0fcd 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/Inlining.sl @@ -15,7 +15,7 @@ function g() {return d() + e() + f();} function main() { i = 0; result = 0; - while (i < 1000000) { + while (i < 10000) { result = result + g(); i = i + 1; } diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl index e245f2f40578..046055fe98bd 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl @@ -17,8 +17,8 @@ function loop(n) { function main() { i = 0; - while (i < 100000) { - loop(100); + while (i < 20) { + loop(1000); i = i + 1; } println(loop(1000)); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 954d3abcb7c3..7a5a9b323545 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -100,13 +100,14 @@ public static Object perform( @TypeSystemReference(SLTypes.class) public static class SLFunctionLiteralOperation { @Specialization - public static Object execute( - @SuppressWarnings("unused") TruffleString functionName, - @Cached("lookupFunction(functionName, this)") Object result) { + public static SLFunction perform( + TruffleString functionName, + @Cached("lookupFunction(functionName, this)") SLFunction result) { + assert result.getName().equals(functionName) : "functionName should be a compile-time constant"; return result; } - static Object lookupFunction(TruffleString functionName, Node node) { + static SLFunction lookupFunction(TruffleString functionName, Node node) { return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); } } From df53148c9c471ef21e395ee1fc6bacbc67949436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 6 Apr 2022 15:36:35 +0200 Subject: [PATCH 040/312] [wip] boxing elimination w/o typesystem --- .../truffle/api/dsl/test/TypeBoxingTest.java | 8 +- .../generator/FlatNodeGenFactory.java | 157 +++--- .../generator/NodeGeneratorPlugs.java | 32 +- .../generator/TypeSystemCodeGenerator.java | 10 +- .../processor/java/model/CodeTreeBuilder.java | 17 + .../truffle/dsl/processor/model/NodeData.java | 4 + .../OperationsBytecodeCodeGenerator.java | 447 +++++++++++++++--- .../operations/OperationsContext.java | 15 +- .../instructions/CustomInstruction.java | 60 ++- .../operations/instructions/Instruction.java | 16 + .../instructions/LoadLocalInstruction.java | 38 ++ .../instructions/StoreLocalInstruction.java | 41 ++ 12 files changed, 685 insertions(+), 160 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeBoxingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeBoxingTest.java index a6f1aa1138d1..dfff6842f6c9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeBoxingTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeBoxingTest.java @@ -44,6 +44,8 @@ import org.junit.Test; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; @@ -269,7 +271,11 @@ public int executeInt() throws UnexpectedResultException { @TypeSystem static class TypeBoxingTypeSystem { - + @ImplicitCast + @TruffleBoundary + public static int castInt(byte b) { + return b; + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 23f14a42df9a..fa6c6a62a9f8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1847,6 +1847,10 @@ private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTyp clazz.add(method); CodeTreeBuilder builder = method.createBuilder(); + if (plugs != null) { + plugs.initializeFrameState(frameState, builder); + } + // do I miss specializations that are reachable from this executable? if (compatibleSpecializations.size() != implementedSpecializations.size()) { ExecuteDelegationResult delegation = createExecuteDelegation(builder, frameState, type, delegateableTypes, compatibleSpecializations, implementedSpecializations); @@ -2102,6 +2106,11 @@ private CodeExecutableElement createExecuteAndSpecialize() { frameState.addParametersTo(method, Integer.MAX_VALUE, frame); final CodeTreeBuilder builder = method.createBuilder(); + + if (plugs != null) { + plugs.initializeFrameState(frameState, builder); + } + if (needsSpecializeLocking) { builder.declaration(context.getType(Lock.class), "lock", "getLock()"); builder.declaration(context.getType(boolean.class), "hasLock", "true"); @@ -2368,7 +2377,11 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram } } builder.end(); - builder.trees(values.toArray(new CodeTree[0])); + if (plugs != null) { + builder.trees(plugs.createThrowUnsupportedValues(frameState, values, parent, builder)); + } else { + builder.trees(values.toArray(new CodeTree[0])); + } builder.end().end(); return builder.build(); @@ -3288,7 +3301,7 @@ private boolean needsUnexpectedResultException(ExecutableTypeData executedType) } } - private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableTypeData forType, SpecializationData specialization, FrameState frameState) { + private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableTypeData forType, SpecializationData specialization, FrameState frameState, boolean inBoundary) { CodeTreeBuilder builder = parent.create(); int ifCount = 0; if (specialization.isFallback()) { @@ -3298,31 +3311,33 @@ private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableT } builder.startIf().startCall(createFallbackName()); if (plugs != null) { - plugs.addNodeCallParameters(builder); + plugs.addNodeCallParameters(builder, false, false); } if (fallbackNeedsState) { multiState.addReferencesTo(frameState, builder, fallbackState); } - if (fallbackNeedsFrame) { - if (frameState.get(FRAME_VALUE) != null) { - builder.string(FRAME_VALUE); - } else { - builder.nullLiteral(); + if (plugs == null || plugs.shouldIncludeValuesInCall()) { + if (fallbackNeedsFrame) { + if (frameState.get(FRAME_VALUE) != null) { + builder.string(FRAME_VALUE); + } else { + builder.nullLiteral(); + } } + frameState.addReferencesTo(builder); } - frameState.addReferencesTo(builder); builder.end(); builder.end(); builder.startBlock(); ifCount++; } - builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); + builder.tree(createCallSpecialization(builder, frameState, forType, specialization, inBoundary)); builder.end(ifCount); return builder.build(); } - private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState parentState, final ExecutableTypeData forType, SpecializationData specialization) { + private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState parentState, final ExecutableTypeData forType, SpecializationData specialization, boolean inBoundary) { CodeTreeBuilder builder = parent.create(); FrameState frameState = parentState.copy(); @@ -3387,17 +3402,19 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } CodeTree specializationCall = callMethod(frameState, null, specialization.getMethod(), bindings); - if (isVoid(specialization.getMethod().getReturnType())) { - builder.statement(specializationCall); - if (isVoid(forType.getReturnType())) { - builder.returnStatement(); + if (plugs == null || !plugs.createCallSpecialization(specialization, specializationCall, builder, inBoundary)) { + if (isVoid(specialization.getMethod().getReturnType())) { + builder.statement(specializationCall); + if (isVoid(forType.getReturnType())) { + builder.returnStatement(); + } else { + builder.startReturn().defaultValue(forType.getReturnType()).end(); + } } else { - builder.startReturn().defaultValue(forType.getReturnType()).end(); + builder.startReturn(); + builder.tree(expectOrCast(specialization.getReturnType().getType(), forType, specializationCall)); + builder.end(); } - } else { - builder.startReturn(); - builder.tree(expectOrCast(specialization.getReturnType().getType(), forType, specializationCall)); - builder.end(); } } @@ -3750,7 +3767,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization innerIfCount = innerIfCount.add(IfTriple.materialize(innerBuilder, IfTriple.optimize(cachedTriples), false)); prev = visitSpecializationGroupChildren(builder, innerFrameState, prev, group, forType, allowedSpecializations); if (specialization != null && (prev == null || prev.hasFallthrough())) { - innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState)); + innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState, extractInBoundary)); } innerBuilder.end(innerIfCount.blockCount); @@ -3909,10 +3926,10 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.end().startBlock(); - builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization)); + builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization, false)); builder.end(); } else { - builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization)); + builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization, false)); builder.end(innerIfCount.blockCount); hasFallthrough |= innerIfCount.ifCount > 0; } @@ -3978,7 +3995,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); if (specialization != null && (prev == null || prev.hasFallthrough())) { - builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); + builder.tree(createCallSpecialization(builder, frameState, forType, specialization, false)); } builder.end(innerIfCount.blockCount); builder.end(ifCount.blockCount); @@ -4030,9 +4047,11 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt usedBoundaryNames.add(boundaryMethodName); - String includeFrameParameter = null; + String includeFrameParameter; if (specialization != null && specialization.getFrame() != null) { includeFrameParameter = FRAME_VALUE; + } else { + includeFrameParameter = null; } CodeExecutableElement boundaryMethod = new CodeExecutableElement(modifiers(PRIVATE), parentMethod.getReturnType(), boundaryMethodName); @@ -4045,13 +4064,18 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt boundaryMethod.getThrownTypes().addAll(parentMethod.getThrownTypes()); innerBuilder = boundaryMethod.createBuilder(); ((CodeTypeElement) parentMethod.getEnclosingElement()).add(boundaryMethod); - builder.startReturn().startCall("this", boundaryMethod); + if (plugs != null) { - plugs.addNodeCallParameters(builder); + plugs.createCallBoundaryMethod(builder, frameState, boundaryMethod, b -> { + multiState.addReferencesTo(frameState, b); + frameState.addReferencesTo(b, includeFrameParameter, createSpecializationLocalName(specialization)); + }); + } else { + builder.startReturn().startCall("this", boundaryMethod); + multiState.addReferencesTo(frameState, builder); + frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); + builder.end().end(); } - multiState.addReferencesTo(frameState, builder); - frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); - builder.end().end(); return innerBuilder; } @@ -4661,7 +4685,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, CodeTreeBuilder builder = parent.create(); builder.startStatement().startCall(method.getSimpleName().toString()); if (plugs != null) { - plugs.addNodeCallParameters(builder); + plugs.addNodeCallParameters(builder, false, true); } if (useSpecializationClass) { builder.string(specializationLocalName); @@ -4726,20 +4750,24 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startCall(createExecuteAndSpecializeName()); if (plugs != null) { - plugs.addNodeCallParameters(builder); + plugs.addNodeCallParameters(builder, false, false); + } + if (plugs == null || plugs.shouldIncludeValuesInCall()) { + frameState.addReferencesTo(builder, frame); } - frameState.addReferencesTo(builder, frame); builder.end(); CodeTree call = builder.build(); builder = builder.create(); - if (isVoid(forType.getReturnType())) { - builder.statement(call); - builder.returnStatement(); - } else { - builder.startReturn(); - builder.tree(expectOrCast(returnType, forType, call)); - builder.end(); + if (plugs == null || !plugs.createCallExecuteAndSpecialize(builder, call)) { + if (isVoid(forType.getReturnType())) { + builder.statement(call); + builder.returnStatement(); + } else { + builder.startReturn(); + builder.tree(expectOrCast(returnType, forType, call)); + builder.end(); + } } return builder.build(); } @@ -5299,6 +5327,18 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou TypeMirror genericTargetType = node.getFallbackSpecialization().findParameterOrDie(node.getChildExecutions().get(signatureIndex)).getType(); if (typeEquals(value.getTypeMirror(), genericTargetType)) { // no implicit casts needed if it matches the generic type + if (plugs != null && plugs.createSameTypeCast(frameState, value, genericTargetType, prepareBuilder, checkBuilder)) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (castOnly) { + if (frameState.get(value.getName() + "_real_") == null) { + frameState.set(value.getName() + "_real_", value); + b.declaration(targetType, value.getName(), checkBuilder.build()); + } + } else { + b.tree(prepareBuilder.build()); + } + return new IfTriple(b.build(), null, null); + } return null; } @@ -5323,8 +5363,10 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou List sourceTypes = typeSystem.lookupByTargetType(targetType); CodeTree valueReference = value.createReference(); if (sourceTypes.isEmpty()) { - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, valueReference)); - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, valueReference)); + if (plugs == null || !plugs.createCheckCast(typeSystem, frameState, targetType, value, prepareBuilder, checkBuilder, castBuilder)) { + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, valueReference)); + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, valueReference)); + } } else { List specializations = group.collectSpecializations(); List parameters = new ArrayList<>(); @@ -5339,19 +5381,24 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou } else { implicitState = multiState.createExtractInteger(frameState, typeGuard); } - checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); + if (plugs == null || !plugs.createImplicitCheckCast(typeSystem, frameState, targetType, value, implicitState, prepareBuilder, checkBuilder, castBuilder)) { + checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); + } } else { Parameter parameter = parameters.get(0); String implicitStateName = createImplicitTypeStateLocalName(parameter); CodeTree defaultValue = null; prepareBuilder.declaration(context.getType(int.class), implicitStateName, defaultValue); - CodeTree specializeCall = TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, valueReference); - checkBuilder.startParantheses(); - checkBuilder.string(implicitStateName, " = ").tree(specializeCall); - checkBuilder.end(); - checkBuilder.string(" != 0"); - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, CodeTreeBuilder.singleString(implicitStateName))); + if (plugs == null || plugs.createImplicitCheckCastSlowPath(typeSystem, frameState, targetType, value, implicitStateName, prepareBuilder, checkBuilder, castBuilder)) { + CodeTree specializeCall = TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, valueReference); + checkBuilder.startParantheses(); + checkBuilder.string(implicitStateName, " = ").tree(specializeCall); + checkBuilder.end(); + checkBuilder.string(" != 0"); + + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, CodeTreeBuilder.singleString(implicitStateName))); + } } } @@ -5585,7 +5632,7 @@ static int getRequiredStateBits(TypeSystemData types, Object object) { } } - private static final class MultiStateBitSet extends MultiBitSet { + public static final class MultiStateBitSet extends MultiBitSet { /* * All bitsets in used by other nodes in the same generated class. E.g. nodes in exports are @@ -5635,7 +5682,7 @@ void removeParametersFrom(CodeExecutableElement targetMethod) { } } - void addReferencesTo(FrameState frameState, CodeTreeBuilder builder) { + public void addReferencesTo(FrameState frameState, CodeTreeBuilder builder) { for (BitSet set : getSets()) { LocalVariable local = frameState.get(set.getName()); if (local != null) { @@ -5798,7 +5845,7 @@ protected int calculateRequiredBits(Object object) { } - static final class FrameState { + public static final class FrameState { private final FlatNodeGenFactory factory; private final Map values = new HashMap<>(); @@ -6021,13 +6068,13 @@ public String toString() { } - static final class LocalVariable { + public static final class LocalVariable { private final TypeMirror typeMirror; private final CodeTree accessorTree; private final String name; - LocalVariable(TypeMirror typeMirror, String name, CodeTree accessorTree) { + public LocalVariable(TypeMirror typeMirror, String name, CodeTree accessorTree) { Objects.requireNonNull(typeMirror); this.typeMirror = typeMirror; this.accessorTree = accessorTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index c41904fd650d..bb40b65e5dfd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -1,21 +1,28 @@ package com.oracle.truffle.dsl.processor.generator; +import java.util.List; +import java.util.function.Consumer; + import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.Parameter; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; public interface NodeGeneratorPlugs { String transformNodeMethodName(String name); String transformNodeInnerTypeName(String name); - void addNodeCallParameters(CodeTreeBuilder builder); + void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis); + + boolean shouldIncludeValuesInCall(); int getMaxStateBits(int defaultValue); @@ -31,4 +38,25 @@ public interface NodeGeneratorPlugs { CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); + boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, + CodeTreeBuilder castBuilder); + + boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, CodeTreeBuilder prepareBuilder, + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder); + + boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, CodeTreeBuilder prepareBuilder, + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder); + + boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder); + + CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder); + + void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); + + boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary); + + boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call); + + void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments); + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index 70574fb28b7e..b766dd489527 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -76,15 +76,15 @@ public class TypeSystemCodeGenerator extends CodeTypeElementFactory getChildExecutions() { return childExecutions; } + public void addChildExecution(NodeExecutionData data) { + childExecutions.add(data); + } + public Set findSpecializedTypes(NodeExecutionData execution) { Set foundTypes = new HashSet<>(); for (SpecializationData specialization : getSpecializations()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index a74d76fad6c2..e804e6ec5e20 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -19,9 +20,12 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.BitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; @@ -36,6 +40,7 @@ import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -142,6 +147,8 @@ public CodeTypeElement createBuilderBytecodeNode() { CustomInstruction cinstr = (CustomInstruction) instr; + boolean isVariadic = cinstr.getData().getMainProperties().isVariadic; + final Set methodNames = new HashSet<>(); final Set innerTypeNames = new HashSet<>(); @@ -152,6 +159,8 @@ public CodeTypeElement createBuilderBytecodeNode() { final List childIndices = new ArrayList<>(); final List constIndices = new ArrayList<>(); + int numStackValues = isVariadic ? 0 : cinstr.numPopStatic(); + NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { @Override public String transformNodeMethodName(String name) { @@ -168,8 +177,16 @@ public String transformNodeInnerTypeName(String name) { } @Override - public void addNodeCallParameters(CodeTreeBuilder builder) { + public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { + if (!isBoundary) { + builder.string("$frame"); + } builder.string("$bci"); + builder.string("$sp"); + } + + public boolean shouldIncludeValuesInCall() { + return isVariadic; } @Override @@ -262,11 +279,265 @@ public CodeTree createNodeFieldReference(NodeExecutionData execution, String nod return createArrayReference(execution, forRead, execution.getNodeType(), true, "node-field"); } + @Override public CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { Object refObject = sharedName != null ? sharedName : cache; boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild, "cache"); } + + private void createPrepareFor(String typeName, TypeMirror valueType, int offset, FrameState frameState, LocalVariable value, CodeTreeBuilder prepareBuilder) { + + boolean isValue = typeName == null; + String type = isValue ? "Value" : typeName; + + String isName = null; + if (!isValue) { + isName = value.getName() + "_is" + type + "_"; + LocalVariable isVar = frameState.get(isName); + if (isVar == null) { + isVar = new LocalVariable(context.getType(boolean.class), isName, null); + frameState.set(isName, isVar); + prepareBuilder.declaration(context.getType(boolean.class), isName, "$frame.is" + type + "($sp - " + offset + ")"); + } else { + prepareBuilder.lineComment("already have is" + type); + } + } + + String asName = value.getName() + "_as" + type + "_"; + LocalVariable asVar = frameState.get(asName); + if (asVar == null) { + CodeTreeBuilder b = prepareBuilder.create(); + if (!isValue) { + b.string(isName, " ? "); + } + b.string("$frame.get" + type + "($sp - " + offset + ")"); + if (!isValue) { + b.string(" : "); + b.defaultValue(valueType); + } + asVar = new LocalVariable(valueType, asName, null); + frameState.set(asName, asVar); + prepareBuilder.declaration(valueType, asName, b.build()); + } else { + prepareBuilder.lineComment("already have as" + type + ": " + asVar); + } + } + + private void createUnboxedCheck(TypeSystemData typeSystem, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { + b.startParantheses(); + b.string(value.getName() + "_is" + typeName + "_", " || "); + b.startParantheses(); + b.string(value.getName() + "_isObject_", " && "); + b.startParantheses(); + b.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); + b.end(3); + } + + private void createUnboxedCast(TypeSystemData typeSystem, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { + b.string(value.getName() + "_is" + typeName + "_"); + b.string(" ? ", value.getName() + "_as" + typeName + "_"); + b.string(" : "); + b.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); + b.end(2); + } + + public int getStackOffset(LocalVariable value) { + if (value.getName().startsWith("arg") && value.getName().endsWith("Value")) { + return cinstr.numPopStatic() - Integer.parseInt(value.getName().substring(3, value.getName().length() - 5)); + } + throw new UnsupportedOperationException("" + value); + } + + private String getFrameName(TypeKind kind) { + switch (kind) { + case INT: + case SHORT: + case CHAR: + return "Int"; + case BYTE: + return "Byte"; + case BOOLEAN: + return "Boolean"; + case DOUBLE: + return "Double"; + case FLOAT: + return "Float"; + case LONG: + return "Long"; + default: + throw new IllegalArgumentException("Unknown primitive type: " + kind); + } + } + + @Override + public boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { + if (isVariadic) { + return false; + } + int offset = getStackOffset(value); + createPrepareFor("Object", context.getType(Object.class), offset, frameState, value, prepareBuilder); + switch (targetType.getKind()) { + case BYTE: + createPrepareFor("Byte", context.getType(byte.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Byte", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Byte", targetType, value, castBuilder); + break; + case LONG: + createPrepareFor("Long", context.getType(long.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Long", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Long", targetType, value, castBuilder); + break; + case INT: + createPrepareFor("Int", context.getType(int.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Int", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Int", targetType, value, castBuilder); + break; + case SHORT: + createPrepareFor("Int", context.getType(short.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Int", targetType, value, checkBuilder); + castBuilder.startParantheses().cast(context.getType(short.class)); + createUnboxedCast(typeSystem, "Int", targetType, value, castBuilder); + castBuilder.end(); + break; + case BOOLEAN: + createPrepareFor("Boolean", context.getType(boolean.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Boolean", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Boolean", targetType, value, castBuilder); + break; + case FLOAT: + createPrepareFor("Float", context.getType(float.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Float", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Float", targetType, value, castBuilder); + break; + case DOUBLE: + createPrepareFor("Double", context.getType(double.class), offset, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, "Double", targetType, value, checkBuilder); + createUnboxedCast(typeSystem, "Double", targetType, value, castBuilder); + break; + default: + if (targetType.equals(context.getType(Object.class))) { + createPrepareFor(null, context.getType(Object.class), offset, frameState, value, prepareBuilder); + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asValue_"))); + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asValue_"))); + } else { + checkBuilder.string(value.getName() + "_isObject_ && "); + checkBuilder.startParantheses(); + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); + checkBuilder.end(); + + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); + } + break; + } + + return true; + } + + public boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, + CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { + return false; + } + + public boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, + CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { + return false; + } + + public boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder) { + if (isVariadic) + return false; + + int offset = getStackOffset(value); + createPrepareFor(null, genericTargetType, offset, frameState, value, prepareBuilder); + castBuilder.string(value.getName() + "_asValue_"); + return true; + } + + public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { + return new CodeTree[0]; // TODO + } + + public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { + frameState.set("frameValue", new LocalVariable(types.VirtualFrame, "$frame", null)); + } + + private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { + if (cinstr.numPush() == 0) { + b.statement(specializationCall); + b.returnStatement(); + return; + } + + assert cinstr.numPush() == 1; + + int destOffset = cinstr.numPopStatic(); + + CodeTree value; + String typeName; + if (retType.getKind() == TypeKind.VOID) { + // we need to push something, lets just push a `null`. + // maybe this should be an error? DSL just returns default value + + b.statement(specializationCall); + value = CodeTreeBuilder.singleString("null"); + typeName = "Object"; + } else if (retType.getKind().isPrimitive()) { + value = specializationCall; + typeName = getFrameName(retType.getKind()); + } else { + value = specializationCall; + typeName = "Object"; + } + + b.startStatement(); + b.startCall("$frame", "set" + typeName); + b.string("$sp - " + destOffset); + b.tree(value); + b.end(2); + + b.returnStatement(); + } + + public boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { + if (isVariadic || inBoundary) + return false; + + createPushResult(b, specializationCall, specialization.getMethod().getReturnType()); + return true; + } + + public boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call) { + if (isVariadic) { + return false; + } + builder.statement(call); + builder.returnStatement(); + return true; + } + + public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { + if (isVariadic) { + builder.startReturn().startCall("this", boundaryMethod); + builder.string("$bci"); + builder.string("$sp"); + addArguments.accept(builder); + builder.end(2); + return; + } + + CodeTreeBuilder callBuilder = builder.create(); + + callBuilder.startCall("this", boundaryMethod); + callBuilder.string("$bci"); + callBuilder.string("$sp"); + addArguments.accept(callBuilder); + callBuilder.end(); + + createPushResult(builder, callBuilder.build(), boundaryMethod.getReturnType()); + } + }; NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); @@ -312,10 +583,37 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp } for (CodeExecutableElement exToCopy : execs) { + boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); + + boolean isExecute = exToCopy.getSimpleName().toString().endsWith("_execute_"); + boolean isExecuteAndSpecialize = exToCopy.getSimpleName().toString().endsWith("_executeAndSpecialize_"); + boolean isFallbackGuard = exToCopy.getSimpleName().toString().endsWith("_fallbackGuard__"); + + if (!isVariadic) { + if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { + List params = exToCopy.getParameters(); + int toRemove = cinstr.numPopStatic(); + for (int i = 0; i < toRemove; i++) { + params.remove(params.size() - 1); + } + + if (!params.isEmpty() && params.get(params.size() - 1).asType().equals(types.VirtualFrame)) { + params.remove(params.size() - 1); + } + } + + if (isExecute || isExecuteAndSpecialize) { + exToCopy.setReturnType(context.getType(void.class)); + } + } + + exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$sp")); exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + if (!isBoundary) { + exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); + } exToCopy.getModifiers().remove(Modifier.PUBLIC); exToCopy.getModifiers().add(Modifier.PRIVATE); - exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); builderBytecodeNodeType.add(exToCopy); } @@ -407,91 +705,98 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); - CodeVariableElement[] varInputs = new CodeVariableElement[op.inputs.length]; - TypeMirror[] inputTypes = op.expectedInputTypes(context); - vars.inputs = varInputs; - for (int i = op.inputs.length - 1; i >= 0; i--) { - if (op.inputs[i] == InputType.STACK_VALUE_IGNORED) { - b.statement("--sp"); - continue; - } + CodeVariableElement[] varInputs = null; + CodeVariableElement[] varResults = null; + boolean hasBranch = false; + boolean hasReturn = false; - varInputs[i] = new CodeVariableElement(inputTypes[i], "input_" + i); + if (op.standardPrologue()) { - b.declaration(varInputs[i].asType(), varInputs[i].getName(), createInputCode(vars, op, i, inputTypes[i])); - if (op.inputs[i] == InputType.VARARG_VALUE) { - b.startFor().string("int i = ").variable(varInputs[i]).string(".length - 1; i >= 0; i--").end(); - b.startBlock(); - b.startStatement().variable(varInputs[i]).string("[i] = "); - b.variable(argFrame).string(".getValue(--sp)"); - b.end(2); - } - } + varInputs = new CodeVariableElement[op.inputs.length]; + TypeMirror[] inputTypes = op.expectedInputTypes(context); + vars.inputs = varInputs; + for (int i = op.inputs.length - 1; i >= 0; i--) { + if (op.inputs[i] == InputType.STACK_VALUE_IGNORED) { + b.statement("--sp"); + continue; + } - boolean hasBranch = false; - boolean hasReturn = false; + varInputs[i] = new CodeVariableElement(inputTypes[i], "input_" + i); - CodeVariableElement[] varResults = new CodeVariableElement[op.results.length]; - vars.results = varResults; - for (int i = 0; i < op.results.length; i++) { - switch (op.results[i]) { - case STACK_VALUE: - case SET_LOCAL: - varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); - b.statement("Object result_" + i); - break; - case BRANCH: - hasBranch = true; - varResults[i] = varBci; - break; - case RETURN: - hasReturn = true; - varResults[i] = varReturnValue; - break; + b.declaration(varInputs[i].asType(), varInputs[i].getName(), createInputCode(vars, op, i, inputTypes[i])); + if (op.inputs[i] == InputType.VARARG_VALUE) { + b.startFor().string("int i = ").variable(varInputs[i]).string(".length - 1; i >= 0; i--").end(); + b.startBlock(); + b.startStatement().variable(varInputs[i]).string("[i] = "); + b.variable(argFrame).string(".getValue(--sp)"); + b.end(2); + } } - } - - b.tree(op.createExecuteCode(vars)); - for (int i = 0; i < op.results.length; i++) { - switch (op.results[i]) { - case STACK_VALUE: - b.startStatement().startCall(argFrame, "setObject").string("sp++").variable(varResults[i]).end(2); - break; - case SET_LOCAL: - b.startStatement().startCall(vars.frame, "setObject") // - .startGroup().string("VALUES_OFFSET + ").tree(op.createReadArgumentCode(op.inputs.length + i, vars)).end() // - .variable(varResults[i]) // - .end(2); - varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); - break; + varResults = new CodeVariableElement[op.results.length]; + vars.results = varResults; + for (int i = 0; i < op.results.length; i++) { + switch (op.results[i]) { + case STACK_VALUE: + case SET_LOCAL: + varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); + b.statement("Object result_" + i); + break; + case BRANCH: + hasBranch = true; + varResults[i] = varBci; + break; + case RETURN: + hasReturn = true; + varResults[i] = varReturnValue; + break; + } } } - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceInstruction"); - b.variable(varBci); - b.variable(op.opcodeIdField); - b.doubleQuote(op.name); + b.tree(op.createExecuteCode(vars)); - for (CodeVariableElement input : varInputs) { - if (input == null) { - b.string("null"); - } else { - b.variable(input); + if (op.standardPrologue()) { + for (int i = 0; i < op.results.length; i++) { + switch (op.results[i]) { + case STACK_VALUE: + b.startStatement().startCall(argFrame, "setObject").string("sp++").variable(varResults[i]).end(2); + break; + case SET_LOCAL: + b.startStatement().startCall(vars.frame, "setObject") // + .startGroup().string("VALUES_OFFSET + ").tree(op.createReadArgumentCode(op.inputs.length + i, vars)).end() // + .variable(varResults[i]) // + .end(2); + break; } } - for (CodeVariableElement res : varResults) { - if (res == null) { - b.string("null"); - } else { - b.variable(res); + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceInstruction"); + b.variable(varBci); + b.variable(op.opcodeIdField); + b.doubleQuote(op.name); + + for (CodeVariableElement input : varInputs) { + if (input == null) { + b.string("null"); + } else { + b.variable(input); + } } - } - b.end(2); + for (CodeVariableElement res : varResults) { + if (res == null) { + b.string("null"); + } else { + b.variable(res); + } + } + + b.end(2); + } } + if (hasReturn) { b.statement("break loop"); } else if (!hasBranch) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 8fab278bbfcc..9476ef3645f6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -13,6 +13,8 @@ import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.SuperInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.TransferInstruction; @@ -47,15 +49,15 @@ private void createBuiltinOperations() { add(new Operation.While(this, operationId++)); add(new Operation.TryCatch(this, operationId++)); - Instruction iConst; - Instruction iStloc; +// Instruction iConst; +// Instruction iStloc; add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - add(new Operation.Simple(this, "ConstObject", operationId++, 0, iConst = add(new TransferInstruction("load.constant", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); + add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new TransferInstruction("load.constant", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new TransferInstruction("load.argument", instructionId++, ResultType.STACK_VALUE, InputType.ARGUMENT)))); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new TransferInstruction("load.local", instructionId++, ResultType.STACK_VALUE, InputType.LOCAL)))); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, iStloc = add(new TransferInstruction("store.local", instructionId++, ResultType.SET_LOCAL, InputType.STACK_VALUE)))); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); add(new Operation.Simple(this, "Return", operationId++, 1, add(new TransferInstruction("return", instructionId++, ResultType.RETURN, InputType.STACK_VALUE)))); add(new Operation.Instrumentation(this, operationId++, @@ -64,7 +66,8 @@ private void createBuiltinOperations() { add(new InstrumentationExitInstruction(instructionId++, true)), add(new InstrumentationLeaveInstruction(instructionId++)))); - Instruction iSuper = add(new SuperInstruction(instructionId++, new Instruction[]{iConst, iStloc})); +// Instruction iSuper = add(new SuperInstruction(instructionId++, new Instruction[]{iConst, +// iStloc})); } public Instruction add(Instruction elem) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index ba57be092d32..35e86ee7147f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -112,35 +112,55 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C return b.build(); } + @Override + public boolean standardPrologue() { + return data.getMainProperties().isVariadic; + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (results.length > 0) { - b.startAssign(vars.results[0]); + if (data.getMainProperties().isVariadic) { + // variadics always box + if (results.length > 0) { + b.startAssign(vars.results[0]); + } else { + b.startStatement(); + } + + int inputIndex = 0; + b.startCall("this", executeMethod); + b.variable(vars.frame); + b.variable(vars.bci); + b.variable(vars.sp); + + for (ParameterKind kind : data.getMainProperties().parameters) { + switch (kind) { + case STACK_VALUE: + case VARIADIC: + b.variable(vars.inputs[inputIndex++]); + break; + case VIRTUAL_FRAME: + b.variable(vars.frame); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + kind); + } + } + + b.end(2); } else { b.startStatement(); - } + b.startCall("this", executeMethod); + b.variable(vars.frame); + b.variable(vars.bci); + b.variable(vars.sp); + b.end(2); - int inputIndex = 0; - b.startCall("this", executeMethod); - b.variable(vars.bci); - for (ParameterKind kind : data.getMainProperties().parameters) { - switch (kind) { - case STACK_VALUE: - case VARIADIC: - b.variable(vars.inputs[inputIndex++]); - break; - case VIRTUAL_FRAME: - b.variable(vars.frame); - break; - default: - throw new IllegalArgumentException("Unexpected value: " + kind); - } + b.startAssign(vars.sp).variable(vars.sp).string(" - " + this.numPopStatic() + " + " + this.numPush()).end(); } - b.end(2); - return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 75ddbb9446a9..57a08a770f4d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -451,6 +451,18 @@ public int numPush() { return stackPush; } + public int numPopStatic() { + int stackPop = 0; + for (InputType i : inputs) { + if (i == InputType.STACK_VALUE || i == InputType.STACK_VALUE_IGNORED) { + stackPop++; + } else if (i == InputType.VARARG_VALUE) { + throw new UnsupportedOperationException("number of pops not static"); + } + } + return stackPop; + } + public CodeTree numPop(BuilderVariables vars) { int stackPop = 0; for (InputType i : inputs) { @@ -494,4 +506,8 @@ public String dumpInfo() { return sb.toString(); } + + public boolean standardPrologue() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java new file mode 100644 index 000000000000..c4b972e78b32 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -0,0 +1,38 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class LoadLocalInstruction extends Instruction { + + public LoadLocalInstruction(int id) { + super("load.local", id, ResultType.STACK_VALUE, InputType.LOCAL); + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().startCall(vars.frame, "copy"); + + b.startGroup(); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + 1").end(); + b.end(); + b.string(" + VALUES_OFFSET"); + b.end(); + + b.startGroup().variable(vars.sp).string("++").end(); + + b.end(2); + + return b.build(); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java new file mode 100644 index 000000000000..2fddc88454ba --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -0,0 +1,41 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class StoreLocalInstruction extends Instruction { + + public StoreLocalInstruction(int id) { + super("store.local", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement().startCall(vars.frame, "copy"); + + b.startGroup().variable(vars.sp).string(" - 1").end(); + + b.startGroup(); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + 1").end(); + b.end(); + b.string(" + VALUES_OFFSET"); + b.end(); + + b.end(2); + + b.startStatement().startCall(vars.frame, "clear"); + b.startGroup().string("--").variable(vars.sp).end(); + b.end(2); + + return b.build(); + } + +} From aa99d19cadc7b131539ad9cb0e3d603483ef0aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 6 Apr 2022 16:34:02 +0200 Subject: [PATCH 041/312] [wip] remove boxing for conditional branch --- .../OperationsBytecodeCodeGenerator.java | 26 ++++++++++++++----- .../instructions/BranchInstruction.java | 5 ++++ .../ConditionalBranchInstruction.java | 26 ++++++++++++++++--- .../operations/instructions/Instruction.java | 9 +++++++ .../truffle/sl/operations/SLOperations.java | 4 +-- 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index e804e6ec5e20..71d648ce904f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -60,6 +60,8 @@ public class OperationsBytecodeCodeGenerator { private final static Object MARKER_CHILD = new Object(); private final static Object MARKER_CONST = new Object(); + private static final boolean DO_STACK_LOGGING = false; + private final ProcessorContext context = ProcessorContext.getInstance(); private final TruffleTypes types = context.getTypes(); @@ -491,13 +493,27 @@ private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, Ty typeName = "Object"; } + if (DO_STACK_LOGGING) { + b.startBlock(); + b.declaration(retType, "__value__", value); + b.statement("System.out.printf(\" pushing " + typeName + " at -" + destOffset + ": %s%n\", __value__)"); + } + b.startStatement(); b.startCall("$frame", "set" + typeName); b.string("$sp - " + destOffset); - b.tree(value); + if (DO_STACK_LOGGING) { + b.string("__value__"); + } else { + b.tree(value); + } b.end(2); b.returnStatement(); + + if (DO_STACK_LOGGING) { + b.end(); + } } public boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { @@ -707,8 +723,6 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt CodeVariableElement[] varInputs = null; CodeVariableElement[] varResults = null; - boolean hasBranch = false; - boolean hasReturn = false; if (op.standardPrologue()) { @@ -743,11 +757,9 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt b.statement("Object result_" + i); break; case BRANCH: - hasBranch = true; varResults[i] = varBci; break; case RETURN: - hasReturn = true; varResults[i] = varReturnValue; break; } @@ -797,9 +809,9 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt } } - if (hasReturn) { + if (op.isReturnInstruction()) { b.statement("break loop"); - } else if (!hasBranch) { + } else if (!op.isBranchInstruction()) { b.startAssign(varNextBci).variable(varBci).string(" + " + op.length()).end(); b.statement("break"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 4aa7e3cbde4d..7c17f8b1b9c9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -35,4 +35,9 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { return b.build(); } + + @Override + public boolean isBranchInstruction() { + return true; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 34d34043b793..5f6a45feffef 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -1,5 +1,6 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -7,6 +8,9 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; public class ConditionalBranchInstruction extends Instruction { + + private final DeclaredType ConditionProfile = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); + public ConditionalBranchInstruction(int id) { super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); } @@ -16,20 +20,34 @@ public TypeMirror[] expectedInputTypes(ProcessorContext context) { return new TypeMirror[]{ context.getType(short.class), context.getType(boolean.class), - context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile") + ConditionProfile }; } + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public boolean isBranchInstruction() { + return true; + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().startCall(vars.inputs[2], "profile").variable(vars.inputs[1]).end(2); + b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + 3)]"); + b.declaration("boolean", "cond", "frame.isBoolean(sp - 1) ? frame.getBoolean(sp - 1) : (boolean) frame.getObject(sp - 1)"); + b.statement("sp -= 1"); + + b.startIf().startCall("profile", "profile").string("cond").end(2); b.startBlock(); - b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); b.statement("continue loop"); b.end().startElseBlock(); - b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + b.startAssign(vars.bci).string("LE_BYTES.getShort(bc, bci + 1)").end(); b.statement("continue loop"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 57a08a770f4d..92855553f48c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -1,6 +1,7 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.lang.model.type.TypeKind; @@ -510,4 +511,12 @@ public String dumpInfo() { public boolean standardPrologue() { return true; } + + public boolean isBranchInstruction() { + return Arrays.stream(results).anyMatch(x -> x == ResultType.BRANCH); + } + + public boolean isReturnInstruction() { + return Arrays.stream(results).anyMatch(x -> x == ResultType.RETURN); + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 7a5a9b323545..089580a805f8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -48,7 +48,7 @@ import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations -@TypeSystemReference(SLTypes.class) +// @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) @OperationProxy(SLEqualNode.class) @@ -161,7 +161,7 @@ protected static Object doInterop( } @Operation - @TypeSystemReference(SLTypes.class) + // @TypeSystemReference(SLTypes.class) public static class SLConvertToBoolean { @Specialization public static boolean perform(Object obj, @Bind("this") Node node, @Bind("$bci") int bci) { From 5c18ce52235711e67911a9bb37c131f7a97afebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 7 Apr 2022 15:19:47 +0200 Subject: [PATCH 042/312] [wip] now unboxing elim works with type system --- .../truffle/api/operation/OperationsNode.java | 9 + .../generator/FlatNodeGenFactory.java | 8 +- .../generator/NodeGeneratorPlugs.java | 8 +- .../OperationsBytecodeCodeGenerator.java | 418 +------------ .../OperationsBytecodeNodeGeneratorPlugs.java | 547 ++++++++++++++++++ .../truffle/sl/operations/SLOperations.java | 18 +- 6 files changed, 585 insertions(+), 423 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 36e236124bde..d07c1421064e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; @@ -137,4 +138,12 @@ public WrapperNode createWrapper(ProbeNode probe) { // TODO Auto-generated method stub return null; } + + protected static T interlog(T arg, String reason) { + if (CompilerDirectives.inInterpreter()) { + System.out.printf(" >> %s %s%n", reason, arg); + } + + return arg; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index fa6c6a62a9f8..0b04115d51a9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5327,7 +5327,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou TypeMirror genericTargetType = node.getFallbackSpecialization().findParameterOrDie(node.getChildExecutions().get(signatureIndex)).getType(); if (typeEquals(value.getTypeMirror(), genericTargetType)) { // no implicit casts needed if it matches the generic type - if (plugs != null && plugs.createSameTypeCast(frameState, value, genericTargetType, prepareBuilder, checkBuilder)) { + if (plugs != null && plugs.createSameTypeCast(frameState, value, genericTargetType, prepareBuilder, checkBuilder, castOnly)) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (castOnly) { if (frameState.get(value.getName() + "_real_") == null) { @@ -5363,7 +5363,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou List sourceTypes = typeSystem.lookupByTargetType(targetType); CodeTree valueReference = value.createReference(); if (sourceTypes.isEmpty()) { - if (plugs == null || !plugs.createCheckCast(typeSystem, frameState, targetType, value, prepareBuilder, checkBuilder, castBuilder)) { + if (plugs == null || !plugs.createCheckCast(typeSystem, frameState, targetType, value, prepareBuilder, checkBuilder, castBuilder, castOnly)) { checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, valueReference)); castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, valueReference)); } @@ -5381,7 +5381,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou } else { implicitState = multiState.createExtractInteger(frameState, typeGuard); } - if (plugs == null || !plugs.createImplicitCheckCast(typeSystem, frameState, targetType, value, implicitState, prepareBuilder, checkBuilder, castBuilder)) { + if (plugs == null || !plugs.createImplicitCheckCast(typeSystem, frameState, targetType, value, implicitState, prepareBuilder, checkBuilder, castBuilder, castOnly)) { checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); } @@ -5390,7 +5390,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou String implicitStateName = createImplicitTypeStateLocalName(parameter); CodeTree defaultValue = null; prepareBuilder.declaration(context.getType(int.class), implicitStateName, defaultValue); - if (plugs == null || plugs.createImplicitCheckCastSlowPath(typeSystem, frameState, targetType, value, implicitStateName, prepareBuilder, checkBuilder, castBuilder)) { + if (plugs == null || !plugs.createImplicitCheckCastSlowPath(typeSystem, frameState, targetType, value, implicitStateName, prepareBuilder, checkBuilder, castBuilder, castOnly)) { CodeTree specializeCall = TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, valueReference); checkBuilder.startParantheses(); checkBuilder.string(implicitStateName, " = ").tree(specializeCall); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index bb40b65e5dfd..f93aec90327a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -39,15 +39,15 @@ public interface NodeGeneratorPlugs { CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, - CodeTreeBuilder castBuilder); + CodeTreeBuilder castBuilder, boolean castOnly); boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder); + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly); boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder); + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean cast Only); - boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder); + boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder, boolean castOnly); CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 71d648ce904f..f19ec79201fe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -5,7 +5,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.function.Consumer; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -19,14 +18,9 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.generator.BitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -37,10 +31,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.model.CacheExpression; -import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -57,13 +47,13 @@ public class OperationsBytecodeCodeGenerator { private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - private final static Object MARKER_CHILD = new Object(); - private final static Object MARKER_CONST = new Object(); + final static Object MARKER_CHILD = new Object(); + final static Object MARKER_CONST = new Object(); - private static final boolean DO_STACK_LOGGING = false; + static final boolean DO_STACK_LOGGING = false; - private final ProcessorContext context = ProcessorContext.getInstance(); - private final TruffleTypes types = context.getTypes(); + final ProcessorContext context = ProcessorContext.getInstance(); + final TruffleTypes types = context.getTypes(); private static final String ConditionProfile_Name = "com.oracle.truffle.api.profiles.ConditionProfile"; final DeclaredType ConditionProfile = context.getDeclaredType(ConditionProfile_Name); @@ -163,398 +153,12 @@ public CodeTypeElement createBuilderBytecodeNode() { int numStackValues = isVariadic ? 0 : cinstr.numPopStatic(); - NodeGeneratorPlugs plugs = new NodeGeneratorPlugs() { - @Override - public String transformNodeMethodName(String name) { - String result = soData.getName() + "_" + name + "_"; - methodNames.add(result); - return result; - } - - @Override - public String transformNodeInnerTypeName(String name) { - String result = soData.getName() + "_" + name; - innerTypeNames.add(result); - return result; - } - - @Override - public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { - if (!isBoundary) { - builder.string("$frame"); - } - builder.string("$bci"); - builder.string("$sp"); - } - - public boolean shouldIncludeValuesInCall() { - return isVariadic; - } - - @Override - public int getMaxStateBits(int defaultValue) { - return 8; - } - - @Override - public TypeMirror getBitSetType(TypeMirror defaultType) { - return new CodeTypeMirror(TypeKind.BYTE); - } - - @Override - public CodeTree createBitSetReference(BitSet bits) { - int index = additionalData.indexOf(bits); - if (index == -1) { - index = additionalData.size(); - additionalData.add(bits); - - additionalDataKinds.add(DataKind.BITS); - } - - return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); - } - - @Override - public CodeTree transformValueBeforePersist(CodeTree tree) { - return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); - } - - private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild, String kind) { - if (refObject == null) { - throw new IllegalArgumentException("refObject is null"); - } - - List refList = isChild ? childIndices : constIndices; - int index = refList.indexOf(refObject); - int baseIndex = additionalData.indexOf(isChild ? MARKER_CHILD : MARKER_CONST); - - if (index == -1) { - if (baseIndex == -1) { - baseIndex = additionalData.size(); - additionalData.add(isChild ? MARKER_CHILD : MARKER_CONST); - additionalData.add(null); - - additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); - additionalDataKinds.add(DataKind.CONTINUATION); - } - - index = refList.size(); - refList.add(refObject); - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (doCast) { - b.startParantheses(); - b.cast(castTarget); - } - - VariableElement targetField; - if (isChild) { - targetField = fldChildren; - } else { - targetField = fldConsts; - } - - b.variable(targetField).string("["); - b.startCall("LE_BYTES", "getShort"); - b.variable(fldBc); - b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); - b.end(); - b.string(" + " + index + "]"); - - if (doCast) { - b.end(); - } - - return b.build(); - } - - @Override - public CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { - Object refObject = useSpecializationClass ? s : fieldName; - return createArrayReference(refObject, fieldType != null, fieldType, false, "spec-field"); - } - - @Override - public CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead) { - return createArrayReference(execution, forRead, execution.getNodeType(), true, "node-field"); - } - - @Override - public CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { - Object refObject = sharedName != null ? sharedName : cache; - boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); - return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild, "cache"); - } - - private void createPrepareFor(String typeName, TypeMirror valueType, int offset, FrameState frameState, LocalVariable value, CodeTreeBuilder prepareBuilder) { - - boolean isValue = typeName == null; - String type = isValue ? "Value" : typeName; - - String isName = null; - if (!isValue) { - isName = value.getName() + "_is" + type + "_"; - LocalVariable isVar = frameState.get(isName); - if (isVar == null) { - isVar = new LocalVariable(context.getType(boolean.class), isName, null); - frameState.set(isName, isVar); - prepareBuilder.declaration(context.getType(boolean.class), isName, "$frame.is" + type + "($sp - " + offset + ")"); - } else { - prepareBuilder.lineComment("already have is" + type); - } - } - - String asName = value.getName() + "_as" + type + "_"; - LocalVariable asVar = frameState.get(asName); - if (asVar == null) { - CodeTreeBuilder b = prepareBuilder.create(); - if (!isValue) { - b.string(isName, " ? "); - } - b.string("$frame.get" + type + "($sp - " + offset + ")"); - if (!isValue) { - b.string(" : "); - b.defaultValue(valueType); - } - asVar = new LocalVariable(valueType, asName, null); - frameState.set(asName, asVar); - prepareBuilder.declaration(valueType, asName, b.build()); - } else { - prepareBuilder.lineComment("already have as" + type + ": " + asVar); - } - } - - private void createUnboxedCheck(TypeSystemData typeSystem, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { - b.startParantheses(); - b.string(value.getName() + "_is" + typeName + "_", " || "); - b.startParantheses(); - b.string(value.getName() + "_isObject_", " && "); - b.startParantheses(); - b.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); - b.end(3); - } - - private void createUnboxedCast(TypeSystemData typeSystem, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { - b.string(value.getName() + "_is" + typeName + "_"); - b.string(" ? ", value.getName() + "_as" + typeName + "_"); - b.string(" : "); - b.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); - b.end(2); - } - - public int getStackOffset(LocalVariable value) { - if (value.getName().startsWith("arg") && value.getName().endsWith("Value")) { - return cinstr.numPopStatic() - Integer.parseInt(value.getName().substring(3, value.getName().length() - 5)); - } - throw new UnsupportedOperationException("" + value); - } - - private String getFrameName(TypeKind kind) { - switch (kind) { - case INT: - case SHORT: - case CHAR: - return "Int"; - case BYTE: - return "Byte"; - case BOOLEAN: - return "Boolean"; - case DOUBLE: - return "Double"; - case FLOAT: - return "Float"; - case LONG: - return "Long"; - default: - throw new IllegalArgumentException("Unknown primitive type: " + kind); - } - } - - @Override - public boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { - if (isVariadic) { - return false; - } - int offset = getStackOffset(value); - createPrepareFor("Object", context.getType(Object.class), offset, frameState, value, prepareBuilder); - switch (targetType.getKind()) { - case BYTE: - createPrepareFor("Byte", context.getType(byte.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Byte", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Byte", targetType, value, castBuilder); - break; - case LONG: - createPrepareFor("Long", context.getType(long.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Long", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Long", targetType, value, castBuilder); - break; - case INT: - createPrepareFor("Int", context.getType(int.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Int", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Int", targetType, value, castBuilder); - break; - case SHORT: - createPrepareFor("Int", context.getType(short.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Int", targetType, value, checkBuilder); - castBuilder.startParantheses().cast(context.getType(short.class)); - createUnboxedCast(typeSystem, "Int", targetType, value, castBuilder); - castBuilder.end(); - break; - case BOOLEAN: - createPrepareFor("Boolean", context.getType(boolean.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Boolean", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Boolean", targetType, value, castBuilder); - break; - case FLOAT: - createPrepareFor("Float", context.getType(float.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Float", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Float", targetType, value, castBuilder); - break; - case DOUBLE: - createPrepareFor("Double", context.getType(double.class), offset, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, "Double", targetType, value, checkBuilder); - createUnboxedCast(typeSystem, "Double", targetType, value, castBuilder); - break; - default: - if (targetType.equals(context.getType(Object.class))) { - createPrepareFor(null, context.getType(Object.class), offset, frameState, value, prepareBuilder); - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asValue_"))); - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asValue_"))); - } else { - checkBuilder.string(value.getName() + "_isObject_ && "); - checkBuilder.startParantheses(); - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); - checkBuilder.end(); - - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, CodeTreeBuilder.singleString(value.getName() + "_asObject_"))); - } - break; - } - - return true; - } - - public boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, - CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { - return false; - } - - public boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, - CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder) { - return false; - } - - public boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder) { - if (isVariadic) - return false; - - int offset = getStackOffset(value); - createPrepareFor(null, genericTargetType, offset, frameState, value, prepareBuilder); - castBuilder.string(value.getName() + "_asValue_"); - return true; - } - - public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { - return new CodeTree[0]; // TODO - } - - public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { - frameState.set("frameValue", new LocalVariable(types.VirtualFrame, "$frame", null)); - } - - private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { - if (cinstr.numPush() == 0) { - b.statement(specializationCall); - b.returnStatement(); - return; - } - - assert cinstr.numPush() == 1; - - int destOffset = cinstr.numPopStatic(); - - CodeTree value; - String typeName; - if (retType.getKind() == TypeKind.VOID) { - // we need to push something, lets just push a `null`. - // maybe this should be an error? DSL just returns default value - - b.statement(specializationCall); - value = CodeTreeBuilder.singleString("null"); - typeName = "Object"; - } else if (retType.getKind().isPrimitive()) { - value = specializationCall; - typeName = getFrameName(retType.getKind()); - } else { - value = specializationCall; - typeName = "Object"; - } - - if (DO_STACK_LOGGING) { - b.startBlock(); - b.declaration(retType, "__value__", value); - b.statement("System.out.printf(\" pushing " + typeName + " at -" + destOffset + ": %s%n\", __value__)"); - } - - b.startStatement(); - b.startCall("$frame", "set" + typeName); - b.string("$sp - " + destOffset); - if (DO_STACK_LOGGING) { - b.string("__value__"); - } else { - b.tree(value); - } - b.end(2); - - b.returnStatement(); - - if (DO_STACK_LOGGING) { - b.end(); - } - } - - public boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { - if (isVariadic || inBoundary) - return false; - - createPushResult(b, specializationCall, specialization.getMethod().getReturnType()); - return true; - } - - public boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call) { - if (isVariadic) { - return false; - } - builder.statement(call); - builder.returnStatement(); - return true; - } - - public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { - if (isVariadic) { - builder.startReturn().startCall("this", boundaryMethod); - builder.string("$bci"); - builder.string("$sp"); - addArguments.accept(builder); - builder.end(2); - return; - } - - CodeTreeBuilder callBuilder = builder.create(); - - callBuilder.startCall("this", boundaryMethod); - callBuilder.string("$bci"); - callBuilder.string("$sp"); - addArguments.accept(callBuilder); - callBuilder.end(); - - createPushResult(builder, callBuilder.build(), boundaryMethod.getReturnType()); - } - - }; + NodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( + fldBc, fldChildren, constIndices, + innerTypeNames, additionalData, + methodNames, isVariadic, soData, + additionalDataKinds, + fldConsts, cinstr, childIndices); NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java new file mode 100644 index 000000000000..ba2450dcb137 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -0,0 +1,547 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; + +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.BitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; + +final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { + private final CodeVariableElement fldBc; + private final CodeVariableElement fldChildren; + private final List constIndices; + private final Set innerTypeNames; + private final List additionalData; + private final Set methodNames; + private final boolean isVariadic; + private final SingleOperationData soData; + private final List additionalDataKinds; + private final CodeVariableElement fldConsts; + private final CustomInstruction cinstr; + private final List childIndices; + + private final ProcessorContext context; + private final TruffleTypes types; + + private static final boolean LOG_GET_VALUE_CALLS = false; + + OperationsBytecodeNodeGeneratorPlugs(CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, + Set innerTypeNames, List additionalData, + Set methodNames, boolean isVariadic, SingleOperationData soData, List additionalDataKinds, CodeVariableElement fldConsts, CustomInstruction cinstr, + List childIndices) { + this.fldBc = fldBc; + this.fldChildren = fldChildren; + this.constIndices = constIndices; + this.innerTypeNames = innerTypeNames; + this.additionalData = additionalData; + this.methodNames = methodNames; + this.isVariadic = isVariadic; + this.soData = soData; + this.additionalDataKinds = additionalDataKinds; + this.fldConsts = fldConsts; + this.cinstr = cinstr; + this.childIndices = childIndices; + + this.context = ProcessorContext.getInstance(); + this.types = context.getTypes(); + } + + @Override + public String transformNodeMethodName(String name) { + String result = soData.getName() + "_" + name + "_"; + methodNames.add(result); + return result; + } + + @Override + public String transformNodeInnerTypeName(String name) { + String result = soData.getName() + "_" + name; + innerTypeNames.add(result); + return result; + } + + @Override + public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { + if (!isBoundary) { + builder.string("$frame"); + } + builder.string("$bci"); + builder.string("$sp"); + } + + public boolean shouldIncludeValuesInCall() { + return isVariadic; + } + + @Override + public int getMaxStateBits(int defaultValue) { + return 8; + } + + @Override + public TypeMirror getBitSetType(TypeMirror defaultType) { + return new CodeTypeMirror(TypeKind.BYTE); + } + + @Override + public CodeTree createBitSetReference(BitSet bits) { + int index = additionalData.indexOf(bits); + if (index == -1) { + index = additionalData.size(); + additionalData.add(bits); + + additionalDataKinds.add(DataKind.BITS); + } + + return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); + } + + @Override + public CodeTree transformValueBeforePersist(CodeTree tree) { + return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); + } + + private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild) { + if (refObject == null) { + throw new IllegalArgumentException("refObject is null"); + } + + List refList = isChild ? childIndices : constIndices; + int index = refList.indexOf(refObject); + int baseIndex = additionalData.indexOf(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); + + if (index == -1) { + if (baseIndex == -1) { + baseIndex = additionalData.size(); + additionalData.add(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); + additionalData.add(null); + + additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); + additionalDataKinds.add(DataKind.CONTINUATION); + } + + index = refList.size(); + refList.add(refObject); + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (doCast) { + b.startParantheses(); + b.cast(castTarget); + } + + VariableElement targetField; + if (isChild) { + targetField = fldChildren; + } else { + targetField = fldConsts; + } + + b.variable(targetField).string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(fldBc); + b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); + b.end(); + b.string(" + " + index + "]"); + + if (doCast) { + b.end(); + } + + return b.build(); + } + + @Override + public CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { + Object refObject = useSpecializationClass ? s : fieldName; + return createArrayReference(refObject, fieldType != null, fieldType, false); + } + + @Override + public CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead) { + return createArrayReference(execution, forRead, execution.getNodeType(), true); + } + + @Override + public CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { + Object refObject = sharedName != null ? sharedName : cache; + boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); + return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild); + } + + private void createPrepareFor(String typeName, TypeMirror valueType, FrameState frameState, LocalVariable value, CodeTreeBuilder prepareBuilder) { + + boolean isValue = typeName == null; + String type = isValue ? "Value" : typeName; + + String isName = null; + if (!isValue) { + isName = value.getName() + "_is" + type + "_"; + LocalVariable isVar = frameState.get(isName); + if (isVar == null) { + isVar = new LocalVariable(context.getType(boolean.class), isName, null); + frameState.set(isName, isVar); + prepareBuilder.declaration(context.getType(boolean.class), isName, (CodeTree) null); + } else { + prepareBuilder.lineComment("already have is" + type); + } + } + + String asName = value.getName() + "_as" + type + "_"; + LocalVariable asVar = frameState.get(asName); + if (asVar == null) { + asVar = new LocalVariable(valueType, asName, null); + frameState.set(asName, asVar); + prepareBuilder.declarationDefault(valueType, asName); + } else { + prepareBuilder.lineComment("already have as" + type + ": " + asVar); + } + } + + private CodeTree createIsType(FrameState state, LocalVariable value, String type) { + String isDefinedKey = value.getName() + "_is" + type + "_defined_"; + if (state.getBoolean(isDefinedKey, false)) { + return CodeTreeBuilder.singleString(value.getName() + "_is" + type + "_"); + } else { + state.setBoolean(isDefinedKey, true); + return CodeTreeBuilder.singleString("(" + value.getName() + "_is" + type + "_ = $frame.is" + type + "($sp - " + getStackOffset(value) + "))"); + } + } + + private CodeTree createAsType(FrameState state, LocalVariable value, String typeName) { + if (typeName == null) { + throw new IllegalArgumentException("typeName"); + } + + String isDefinedKey = value.getName() + "_as" + typeName + "_defined_"; + if (state.getBoolean(isDefinedKey, false)) { + return CodeTreeBuilder.singleString(value.getName() + "_as" + typeName + "_"); + } else { + state.setBoolean(isDefinedKey, true); + return CodeTreeBuilder.singleString("(" + value.getName() + "_as" + typeName + "_ = $frame.get" + typeName + "($sp - " + getStackOffset(value) + "))"); + } + } + + private CodeTree createAsValue(FrameState state, LocalVariable value, String reason) { + String isDefinedKey = value.getName() + "_asValue_defined_"; + if (state.getBoolean(isDefinedKey, false)) { + return CodeTreeBuilder.singleString(value.getName() + "_asValue_"); + } else { + state.setBoolean(isDefinedKey, true); + if (LOG_GET_VALUE_CALLS) { + return CodeTreeBuilder.singleString("interlog(" + value.getName() + "_asValue_ = $frame.getValue($sp - " + getStackOffset(value) + "), \"" + reason + "\")"); + } else { + return CodeTreeBuilder.singleString("(" + value.getName() + "_asValue_ = $frame.getValue($sp - " + getStackOffset(value) + "))"); + } + } + } + + private void createUnboxedCheck(TypeSystemData typeSystem, FrameState frameState, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b, CodeTreeBuilder prepareBuilder) { + b.startParantheses(); + b.tree(createIsType(frameState, value, typeName)); + b.string(" || "); + if (typeSystem.getCheck(targetType) == null) { + createPrepareFor("Object", context.getType(Object.class), frameState, value, prepareBuilder); + b.startParantheses(); + b.tree(createIsType(frameState, value, "Object")); + b.string(" && "); + b.tree(createAsType(frameState, value, "Object")).instanceOf(ElementUtils.boxType(context, targetType)); + b.end(); + } else { + b.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "boxed value check"))); + } + b.end(); + } + + private void createUnboxedCast(TypeSystemData typeSystem, FrameState frameState, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { + b.tree(createIsType(frameState, value, typeName)); + b.string(" ? "); + b.tree(createAsType(frameState, value, typeName)); + b.string(" : "); + if (typeSystem.getCast(targetType) == null) { + // TODO check individual possible boxed types here + b.maybeCast(context.getType(Object.class), targetType).tree(createAsType(frameState, value, "Object")); + } else { + b.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsValue(frameState, value, "boxed value cast"))); + } + b.end(2); + } + + public int getStackOffset(LocalVariable value) { + if (value.getName().startsWith("arg") && value.getName().endsWith("Value")) { + return cinstr.numPopStatic() - Integer.parseInt(value.getName().substring(3, value.getName().length() - 5)); + } + throw new UnsupportedOperationException("" + value); + } + + private static String getFrameName(TypeKind kind) { + switch (kind) { + case INT: + return "Int"; + case BYTE: + return "Byte"; + case BOOLEAN: + return "Boolean"; + case DOUBLE: + return "Double"; + case FLOAT: + return "Float"; + case LONG: + return "Long"; + default: + // shorts and chars are handled as reference types, since VirtualFrame does not + // support them directly + throw new IllegalArgumentException("Unknown primitive type: " + kind); + } + } + + @Override + public boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, + CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { + if (isVariadic) { + return false; + } + createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); + switch (targetType.getKind()) { + case BYTE: + case LONG: + case INT: + case BOOLEAN: + case FLOAT: + case DOUBLE: { + String typeName = getFrameName(targetType.getKind()); + if (!castOnly) { + createPrepareFor(typeName, targetType, frameState, value, prepareBuilder); + createUnboxedCheck(typeSystem, frameState, typeName, targetType, value, checkBuilder, prepareBuilder); + } else { + createUnboxedCast(typeSystem, frameState, typeName, targetType, value, castBuilder); + } + break; + } + default: + // shorts and chars are handled as reference types, since VirtualFrame does not + // support them directly + if (ElementUtils.isObject(targetType)) { + if (!castOnly) { + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "object check"))); + } else { + castBuilder.tree(createAsValue(frameState, value, "object cast")); + } + } else { + boolean hasCheck = typeSystem.getCheck(targetType) != null; + if (!castOnly) { + createPrepareFor("Object", context.getType(Object.class), frameState, value, prepareBuilder); + + checkBuilder.startParantheses(); + checkBuilder.tree(createIsType(frameState, value, "Object")); + checkBuilder.string(" && "); + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsType(frameState, value, "Object"))); + checkBuilder.end(); + if (hasCheck) { + // TODO: this should do primitive checks itself, w/o resorting to + // getValue + checkBuilder.string(" || "); + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "type system check"))); + } + } else { + if (hasCheck) { + castBuilder.tree(createIsType(frameState, value, "Object")); + castBuilder.string(" ? "); + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsType(frameState, value, "Object"))); + castBuilder.string(" : "); + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsValue(frameState, value, "type system cast"))); + } else { + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsType(frameState, value, "Object"))); + } + } + } + break; + } + + return true; + } + + @Override + public boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, + CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { + if (isVariadic) { + return false; + } + + if (!castOnly) { + createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); + checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit check"), implicitState)); + } else { + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit cast"), implicitState)); + } + + return true; + } + + @Override + public boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, + CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { + if (isVariadic) { + return false; + } + + if (!castOnly) { + createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); + + checkBuilder.startParantheses(); + checkBuilder.string(implicitStateName, " = "); + checkBuilder.tree(TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit specialize"))); + checkBuilder.end().string(" != 0"); + } else { + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat( + typeSystem, targetType, + createAsValue(frameState, value, "implicit specialize cast"), + CodeTreeBuilder.singleString(implicitStateName))); + } + + return true; + } + + public boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { + if (isVariadic) + return false; + + assert ElementUtils.isObject(genericTargetType); + + if (!castOnly) { + prepareBuilder.lineComment("same type: " + value); + createPrepareFor(null, genericTargetType, frameState, value, prepareBuilder); + } else { + castBuilder.tree(createAsValue(frameState, value, "cast to object: " + cinstr.name)); + } + return true; + } + + public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { + if (isVariadic) { + return values.toArray(new CodeTree[values.size()]); + } + CodeTree[] result = new CodeTree[values.size()]; + for (int i = 0; i < values.size(); i++) { + result[i] = CodeTreeBuilder.singleString("$frame.getValue($sp - " + (cinstr.numPopStatic() - i) + ")"); + } + + return result; + } + + public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { + frameState.set("frameValue", new LocalVariable(types.VirtualFrame, "$frame", null)); + } + + private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { + if (cinstr.numPush() == 0) { + b.statement(specializationCall); + b.returnStatement(); + return; + } + + assert cinstr.numPush() == 1; + + int destOffset = cinstr.numPopStatic(); + + CodeTree value; + String typeName; + if (retType.getKind() == TypeKind.VOID) { + // we need to push something, lets just push a `null`. + // maybe this should be an error? DSL just returns default value + + b.statement(specializationCall); + value = CodeTreeBuilder.singleString("null"); + typeName = "Object"; + } else if (retType.getKind().isPrimitive()) { + value = specializationCall; + typeName = getFrameName(retType.getKind()); + } else { + value = specializationCall; + typeName = "Object"; + } + + if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { + b.startBlock(); + b.declaration(retType, "__value__", value); + b.statement("System.out.printf(\" pushing " + typeName + " at -" + destOffset + ": %s%n\", __value__)"); + } + + b.startStatement(); + b.startCall("$frame", "set" + typeName); + b.string("$sp - " + destOffset); + if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { + b.string("__value__"); + } else { + b.tree(value); + } + b.end(2); + + b.returnStatement(); + + if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { + b.end(); + } + } + + public boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { + if (isVariadic || inBoundary) + return false; + + createPushResult(b, specializationCall, specialization.getMethod().getReturnType()); + return true; + } + + public boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call) { + if (isVariadic) { + return false; + } + builder.statement(call); + builder.returnStatement(); + return true; + } + + public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { + if (isVariadic) { + builder.startReturn().startCall("this", boundaryMethod); + builder.string("$bci"); + builder.string("$sp"); + addArguments.accept(builder); + builder.end(2); + return; + } + + CodeTreeBuilder callBuilder = builder.create(); + + callBuilder.startCall("this", boundaryMethod); + callBuilder.string("$bci"); + callBuilder.string("$sp"); + addArguments.accept(callBuilder); + callBuilder.end(); + + createPushResult(builder, callBuilder.build(), boundaryMethod.getReturnType()); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 089580a805f8..d6c58ac18d93 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -7,6 +7,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; @@ -48,7 +49,7 @@ import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations -// @TypeSystemReference(SLTypes.class) +@TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) @OperationProxy(SLEqualNode.class) @@ -161,15 +162,16 @@ protected static Object doInterop( } @Operation - // @TypeSystemReference(SLTypes.class) + @TypeSystemReference(SLTypes.class) public static class SLConvertToBoolean { @Specialization - public static boolean perform(Object obj, @Bind("this") Node node, @Bind("$bci") int bci) { - try { - return SLTypesGen.expectBoolean(obj); - } catch (UnexpectedResultException e) { - throw SLException.typeError(node, bci, e.getResult()); - } + public static boolean doBoolean(boolean obj) { + return obj; + } + + @Fallback + public static void fallback(Object obj, @Bind("this") Node node, @Bind("$bci") int bci) { + throw SLException.typeError(node, bci, obj); } } } From 76032acb0950bba2c775fcb9e85cd8bf63a5f816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 11 Apr 2022 11:15:51 +0200 Subject: [PATCH 043/312] [wip] boxing elimination w/o spec --- .../AbstractOperationsTruffleException.java | 2 + .../dsl/processor/ProcessorContext.java | 4 + .../generator/FlatNodeGenFactory.java | 77 ++--- .../generator/NodeGeneratorPlugs.java | 25 +- .../dsl/processor/java/ElementUtils.java | 4 + .../java/transform/AbstractCodeWriter.java | 2 +- .../dsl/processor/model/MessageContainer.java | 1 + .../processor/model/NodeExecutionData.java | 5 + .../operations/OperationGeneratorUtils.java | 36 +- .../OperationsBytecodeCodeGenerator.java | 31 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 311 +++++------------- .../operations/OperationsParser.java | 6 +- .../operations/SingleOperationParser.java | 124 ++++++- .../dsl/processor/parser/NodeParser.java | 8 +- .../com/oracle/truffle/sl/SLException.java | 5 +- .../truffle/sl/operations/SLOperations.java | 9 +- 16 files changed, 331 insertions(+), 319 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index 55f52408f929..38fa509f5f6d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -5,6 +5,8 @@ public abstract class AbstractOperationsTruffleException extends AbstractTruffleException { + private static final long serialVersionUID = -534184847100559365L; + public AbstractOperationsTruffleException() { super(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java index be731bb14f09..a19e7baec3a1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java @@ -54,6 +54,7 @@ import javax.lang.model.util.Types; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.Template; @@ -151,6 +152,9 @@ public interface ProcessCallback { } public TypeMirror reloadTypeElement(TypeElement type) { + if (type instanceof CodeTypeElement) { + return type.asType(); + } return getType(type.getQualifiedName().toString()); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 0b04115d51a9..7ceb7d168b43 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -121,7 +121,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeParameterElement; @@ -519,7 +518,13 @@ private boolean useSpecializationClass(SpecializationData specialization) { return specialization.getMaximumNumberOfInstances() > 1; } - private static boolean needsFrameToExecute(List specializations) { + private boolean needsFrameToExecute(List specializations) { + if (plugs != null) { + Boolean result = plugs.needsFrameToExecute(specializations); + if (result != null) { + return result; + } + } for (SpecializationData specialization : specializations) { if (specialization.getFrame() != null) { return true; @@ -589,6 +594,7 @@ public CodeTypeElement create(CodeTypeElement clazz) { List executableTypes = filterExecutableTypes(node.getExecutableTypes(), reachableSpecializations); + List genericExecutableTypes = new ArrayList<>(); List specializedExecutableTypes = new ArrayList<>(); List voidExecutableTypes = new ArrayList<>(); @@ -2367,7 +2373,9 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram for (NodeExecutionData execution : node.getChildExecutions()) { NodeChildData child = execution.getChild(); LocalVariable var = frameState.getValue(execution); - if (child != null && !frameState.getMode().isUncached()) { + if (plugs != null) { + builder.tree(plugs.createThrowUnsupportedChild(execution)); + } else if (child != null && !frameState.getMode().isUncached()) { builder.tree(accessNodeField(execution)); } else { builder.string("null"); @@ -2471,6 +2479,9 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group CodeExecutableElement parentMethod = (CodeExecutableElement) parent.findMethod(); CodeTypeElement parentClass = (CodeTypeElement) parentMethod.getEnclosingElement(); String name = parentMethod.getSimpleName().toString() + "_" + suffix + (boxingSplitIndex++); + if (plugs != null) { + name = plugs.transformNodeMethodName(name); + } CodeExecutableElement method = parentClass.add(new CodeExecutableElement(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name)); multiState.addParametersTo(frameState, method); frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); @@ -2480,12 +2491,14 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group addExplodeLoop(builder, group); CodeTreeBuilder parentBuilder = parent.create(); - parentBuilder.startReturn(); - parentBuilder.startCall(method.getSimpleName().toString()); - multiState.addReferencesTo(frameState, parentBuilder); - frameState.addReferencesTo(parentBuilder, FRAME_VALUE); - parentBuilder.end(); - parentBuilder.end(); + if (plugs == null || !plugs.createCallWrapInAMethod(parentBuilder, method, () -> multiState.addReferencesTo(frameState, parentBuilder))) { + parentBuilder.startReturn(); + parentBuilder.startCall(method.getSimpleName().toString()); + multiState.addReferencesTo(frameState, parentBuilder); + frameState.addReferencesTo(parentBuilder, FRAME_VALUE); + parentBuilder.end(); + parentBuilder.end(); + } return parentBuilder.build(); } @@ -2707,6 +2720,14 @@ private CodeTree createFastPathExecuteChild(final CodeTreeBuilder parent, FrameS private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue) { + if (plugs != null) { + CodeTree result = plugs.createAssignExecuteChild( + node, originalFrameState, frameState, parent, execution, forType, targetValue, + fs -> createCallExecuteAndSpecialize(forType, fs)); + if (result != null) { + return result; + } + } CodeTreeBuilder builder = parent.create(); ChildExecutionResult executeChild = createExecuteChild(builder, originalFrameState, frameState, execution, targetValue); @@ -5327,18 +5348,6 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou TypeMirror genericTargetType = node.getFallbackSpecialization().findParameterOrDie(node.getChildExecutions().get(signatureIndex)).getType(); if (typeEquals(value.getTypeMirror(), genericTargetType)) { // no implicit casts needed if it matches the generic type - if (plugs != null && plugs.createSameTypeCast(frameState, value, genericTargetType, prepareBuilder, checkBuilder, castOnly)) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (castOnly) { - if (frameState.get(value.getName() + "_real_") == null) { - frameState.set(value.getName() + "_real_", value); - b.declaration(targetType, value.getName(), checkBuilder.build()); - } - } else { - b.tree(prepareBuilder.build()); - } - return new IfTriple(b.build(), null, null); - } return null; } @@ -5363,10 +5372,8 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou List sourceTypes = typeSystem.lookupByTargetType(targetType); CodeTree valueReference = value.createReference(); if (sourceTypes.isEmpty()) { - if (plugs == null || !plugs.createCheckCast(typeSystem, frameState, targetType, value, prepareBuilder, checkBuilder, castBuilder, castOnly)) { - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, valueReference)); - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, valueReference)); - } + checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, valueReference)); + castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, valueReference)); } else { List specializations = group.collectSpecializations(); List parameters = new ArrayList<>(); @@ -5381,24 +5388,20 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou } else { implicitState = multiState.createExtractInteger(frameState, typeGuard); } - if (plugs == null || !plugs.createImplicitCheckCast(typeSystem, frameState, targetType, value, implicitState, prepareBuilder, checkBuilder, castBuilder, castOnly)) { - checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); - } + checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); } else { Parameter parameter = parameters.get(0); String implicitStateName = createImplicitTypeStateLocalName(parameter); CodeTree defaultValue = null; prepareBuilder.declaration(context.getType(int.class), implicitStateName, defaultValue); - if (plugs == null || !plugs.createImplicitCheckCastSlowPath(typeSystem, frameState, targetType, value, implicitStateName, prepareBuilder, checkBuilder, castBuilder, castOnly)) { - CodeTree specializeCall = TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, valueReference); - checkBuilder.startParantheses(); - checkBuilder.string(implicitStateName, " = ").tree(specializeCall); - checkBuilder.end(); - checkBuilder.string(" != 0"); + CodeTree specializeCall = TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, valueReference); + checkBuilder.startParantheses(); + checkBuilder.string(implicitStateName, " = ").tree(specializeCall); + checkBuilder.end(); + checkBuilder.string(" != 0"); - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, CodeTreeBuilder.singleString(implicitStateName))); - } + castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, CodeTreeBuilder.singleString(implicitStateName))); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index f93aec90327a..490d4f305874 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.function.Consumer; +import java.util.function.Function; import javax.lang.model.type.TypeMirror; @@ -11,9 +12,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; public interface NodeGeneratorPlugs { String transformNodeMethodName(String name); @@ -38,17 +40,6 @@ public interface NodeGeneratorPlugs { CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); - boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, - CodeTreeBuilder castBuilder, boolean castOnly); - - boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly); - - boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean cast Only); - - boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder, boolean castOnly); - CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder); void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); @@ -59,4 +50,14 @@ boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState fr void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments); + boolean createCallWrapInAMethod(CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters); + + CodeTree createAssignExecuteChild( + NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue, + Function createExecuteAndSpecialize); + + CodeTree createThrowUnsupportedChild(NodeExecutionData execution); + + Boolean needsFrameToExecute(List specializations); + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index ffc06e42d7da..65d70198947b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -237,6 +237,10 @@ public static boolean needsCastTo(TypeMirror sourceType, TypeMirror targetType) public static String createReferenceName(ExecutableElement method) { StringBuilder b = new StringBuilder(); + if (method.getEnclosingElement() != null) { + b.append(method.getEnclosingElement().getSimpleName()); + b.append('#'); + } b.append(method.getSimpleName().toString()); b.append("("); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java index 9a64356e7a24..8a773343c192 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java @@ -190,7 +190,7 @@ static class Foobar, BiFunction> { } - private void writeClassImpl(CodeTypeElement e) { + protected void writeClassImpl(CodeTypeElement e) { if (e.getDocTree() != null) { visitTree(e.getDocTree(), null, e); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java index 29dff48d1f8a..489699418736 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java @@ -201,6 +201,7 @@ private List collectMessagesWithElementChildren(Set v foundMessages.addAll(getMessages()); } for (MessageContainer sink : findChildContainers()) { + sink.redirectMessagesOnGeneratedElements(this); foundMessages.addAll(sink.collectMessagesWithElementChildren(visitedSinks, e)); } return foundMessages; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java index 0f465eba6aff..102ffbaef442 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java @@ -124,4 +124,9 @@ public static String createName(String childName, int index) { return childName; } + @Override + public String toString() { + return "NodeExecutionData[child=" + child + ", name=" + name + ", index=" + index + "]"; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index c787ed0d30ab..3f57978cb8c2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -1,15 +1,18 @@ package com.oracle.truffle.dsl.processor.operations; -import java.util.List; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; -import javax.lang.model.element.VariableElement; +import javax.lang.model.element.Element; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeKind; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -48,21 +51,20 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); } - public static CodeTree changeAllVariables(CodeTree tree, VariableElement from, VariableElement to) { - // EXTREME HACK - - if (tree.getCodeKind() == CodeTreeKind.STRING && tree.getString().equals(from.getSimpleName().toString())) { - return CodeTreeBuilder.singleString(to.getSimpleName().toString()); - } else { - List enc = tree.getEnclosedElements(); - if (enc == null) { - return tree; + public static String printCode(Element el) { + StringWriter wr = new StringWriter(); + new AbstractCodeWriter() { + { + writer = wr; } - for (int i = 0; i < enc.size(); i++) { - CodeTree res = changeAllVariables(enc.get(i), from, to); - enc.set(i, res); + + @Override + protected Writer createWriter(CodeTypeElement clazz) throws IOException { + // TODO Auto-generated method stub + return wr; } - return tree; - } + }.visit(el); + + return wr.toString(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index f19ec79201fe..003ff0e24fda 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -159,10 +159,15 @@ public CodeTypeElement createBuilderBytecodeNode() { methodNames, isVariadic, soData, additionalDataKinds, fldConsts, cinstr, childIndices); + NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); - CodeTypeElement result = generator.create(context, null, soData.getNodeData()).get(0); + List resultList = generator.create(context, null, soData.getNodeData()); + if (resultList.size() != 1) { + throw new AssertionError("Node generator did not return exactly one class"); + } + CodeTypeElement result = resultList.get(0); CodeExecutableElement uncExec = null; List execs = new ArrayList<>(); @@ -174,9 +179,14 @@ public CodeTypeElement createBuilderBytecodeNode() { if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName("execute"))) { uncExec = (CodeExecutableElement) ex; } + execs.add((CodeExecutableElement) ex); } + if (uncExec == null) { + throw new AssertionError(String.format("execute method not found in: %s", result.getSimpleName())); + } + for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { if (!innerTypeNames.contains(te.getSimpleName().toString())) { continue; @@ -205,23 +215,22 @@ public CodeTypeElement createBuilderBytecodeNode() { for (CodeExecutableElement exToCopy : execs) { boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); - boolean isExecute = exToCopy.getSimpleName().toString().endsWith("_execute_"); + boolean isExecute = exToCopy.getSimpleName().toString().contains("_execute_"); boolean isExecuteAndSpecialize = exToCopy.getSimpleName().toString().endsWith("_executeAndSpecialize_"); boolean isFallbackGuard = exToCopy.getSimpleName().toString().endsWith("_fallbackGuard__"); - if (!isVariadic) { - if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { - List params = exToCopy.getParameters(); - int toRemove = cinstr.numPopStatic(); - for (int i = 0; i < toRemove; i++) { - params.remove(params.size() - 1); - } + if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { + List params = exToCopy.getParameters(); - if (!params.isEmpty() && params.get(params.size() - 1).asType().equals(types.VirtualFrame)) { - params.remove(params.size() - 1); + for (int i = 0; i < params.size(); i++) { + if (params.get(i).asType().equals(types.VirtualFrame)) { + params.remove(i); + i--; } } + } + if (!isVariadic) { if (isExecute || isExecuteAndSpecialize) { exToCopy.setReturnType(context.getType(void.class)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index ba2450dcb137..6ac7797cf1a3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +import java.util.function.Function; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; @@ -14,7 +15,6 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -22,9 +22,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; @@ -91,8 +92,13 @@ public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, b builder.string("$sp"); } + @Override + public Boolean needsFrameToExecute(List specializations) { + return false; + } + public boolean shouldIncludeValuesInCall() { - return isVariadic; + return true; } @Override @@ -182,6 +188,9 @@ public CodeTree createSpecializationFieldReference(SpecializationData s, String @Override public CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead) { + if (nodeFieldName.startsWith("$child")) { + return CodeTreeBuilder.singleString("__INVALID__"); + } return createArrayReference(execution, forRead, execution.getNodeType(), true); } @@ -192,107 +201,16 @@ public CodeTree createCacheReference(SpecializationData specialization, CacheExp return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild); } - private void createPrepareFor(String typeName, TypeMirror valueType, FrameState frameState, LocalVariable value, CodeTreeBuilder prepareBuilder) { - - boolean isValue = typeName == null; - String type = isValue ? "Value" : typeName; - - String isName = null; - if (!isValue) { - isName = value.getName() + "_is" + type + "_"; - LocalVariable isVar = frameState.get(isName); - if (isVar == null) { - isVar = new LocalVariable(context.getType(boolean.class), isName, null); - frameState.set(isName, isVar); - prepareBuilder.declaration(context.getType(boolean.class), isName, (CodeTree) null); - } else { - prepareBuilder.lineComment("already have is" + type); - } - } - - String asName = value.getName() + "_as" + type + "_"; - LocalVariable asVar = frameState.get(asName); - if (asVar == null) { - asVar = new LocalVariable(valueType, asName, null); - frameState.set(asName, asVar); - prepareBuilder.declarationDefault(valueType, asName); - } else { - prepareBuilder.lineComment("already have as" + type + ": " + asVar); - } - } - - private CodeTree createIsType(FrameState state, LocalVariable value, String type) { - String isDefinedKey = value.getName() + "_is" + type + "_defined_"; - if (state.getBoolean(isDefinedKey, false)) { - return CodeTreeBuilder.singleString(value.getName() + "_is" + type + "_"); - } else { - state.setBoolean(isDefinedKey, true); - return CodeTreeBuilder.singleString("(" + value.getName() + "_is" + type + "_ = $frame.is" + type + "($sp - " + getStackOffset(value) + "))"); - } - } - - private CodeTree createAsType(FrameState state, LocalVariable value, String typeName) { - if (typeName == null) { - throw new IllegalArgumentException("typeName"); - } - - String isDefinedKey = value.getName() + "_as" + typeName + "_defined_"; - if (state.getBoolean(isDefinedKey, false)) { - return CodeTreeBuilder.singleString(value.getName() + "_as" + typeName + "_"); - } else { - state.setBoolean(isDefinedKey, true); - return CodeTreeBuilder.singleString("(" + value.getName() + "_as" + typeName + "_ = $frame.get" + typeName + "($sp - " + getStackOffset(value) + "))"); - } - } - - private CodeTree createAsValue(FrameState state, LocalVariable value, String reason) { - String isDefinedKey = value.getName() + "_asValue_defined_"; - if (state.getBoolean(isDefinedKey, false)) { - return CodeTreeBuilder.singleString(value.getName() + "_asValue_"); - } else { - state.setBoolean(isDefinedKey, true); - if (LOG_GET_VALUE_CALLS) { - return CodeTreeBuilder.singleString("interlog(" + value.getName() + "_asValue_ = $frame.getValue($sp - " + getStackOffset(value) + "), \"" + reason + "\")"); - } else { - return CodeTreeBuilder.singleString("(" + value.getName() + "_asValue_ = $frame.getValue($sp - " + getStackOffset(value) + "))"); - } - } - } - - private void createUnboxedCheck(TypeSystemData typeSystem, FrameState frameState, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b, CodeTreeBuilder prepareBuilder) { - b.startParantheses(); - b.tree(createIsType(frameState, value, typeName)); - b.string(" || "); - if (typeSystem.getCheck(targetType) == null) { - createPrepareFor("Object", context.getType(Object.class), frameState, value, prepareBuilder); - b.startParantheses(); - b.tree(createIsType(frameState, value, "Object")); - b.string(" && "); - b.tree(createAsType(frameState, value, "Object")).instanceOf(ElementUtils.boxType(context, targetType)); - b.end(); - } else { - b.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "boxed value check"))); + public int getStackOffset(LocalVariable value) { + String name = value.getName(); + while (name.endsWith("_")) { + name = name.substring(0, name.length() - 1); } - b.end(); - } - - private void createUnboxedCast(TypeSystemData typeSystem, FrameState frameState, String typeName, TypeMirror targetType, LocalVariable value, CodeTreeBuilder b) { - b.tree(createIsType(frameState, value, typeName)); - b.string(" ? "); - b.tree(createAsType(frameState, value, typeName)); - b.string(" : "); - if (typeSystem.getCast(targetType) == null) { - // TODO check individual possible boxed types here - b.maybeCast(context.getType(Object.class), targetType).tree(createAsType(frameState, value, "Object")); - } else { - b.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsValue(frameState, value, "boxed value cast"))); + if (name.startsWith("arg") && name.endsWith("Value")) { + return cinstr.numPopStatic() - Integer.parseInt(name.substring(3, name.length() - 5)); } - b.end(2); - } - - public int getStackOffset(LocalVariable value) { - if (value.getName().startsWith("arg") && value.getName().endsWith("Value")) { - return cinstr.numPopStatic() - Integer.parseInt(value.getName().substring(3, value.getName().length() - 5)); + if (name.startsWith("child") && name.endsWith("Value")) { + return cinstr.numPopStatic() - Integer.parseInt(name.substring(5, name.length() - 5)); } throw new UnsupportedOperationException("" + value); } @@ -311,135 +229,23 @@ private static String getFrameName(TypeKind kind) { return "Float"; case LONG: return "Long"; - default: + case DECLARED: + case CHAR: + case SHORT: // shorts and chars are handled as reference types, since VirtualFrame does not // support them directly - throw new IllegalArgumentException("Unknown primitive type: " + kind); - } - } - - @Override - public boolean createCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTreeBuilder prepareBuilder, - CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { - if (isVariadic) { - return false; - } - createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); - switch (targetType.getKind()) { - case BYTE: - case LONG: - case INT: - case BOOLEAN: - case FLOAT: - case DOUBLE: { - String typeName = getFrameName(targetType.getKind()); - if (!castOnly) { - createPrepareFor(typeName, targetType, frameState, value, prepareBuilder); - createUnboxedCheck(typeSystem, frameState, typeName, targetType, value, checkBuilder, prepareBuilder); - } else { - createUnboxedCast(typeSystem, frameState, typeName, targetType, value, castBuilder); - } - break; - } + return "Object"; default: - // shorts and chars are handled as reference types, since VirtualFrame does not - // support them directly - if (ElementUtils.isObject(targetType)) { - if (!castOnly) { - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "object check"))); - } else { - castBuilder.tree(createAsValue(frameState, value, "object cast")); - } - } else { - boolean hasCheck = typeSystem.getCheck(targetType) != null; - if (!castOnly) { - createPrepareFor("Object", context.getType(Object.class), frameState, value, prepareBuilder); - - checkBuilder.startParantheses(); - checkBuilder.tree(createIsType(frameState, value, "Object")); - checkBuilder.string(" && "); - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsType(frameState, value, "Object"))); - checkBuilder.end(); - if (hasCheck) { - // TODO: this should do primitive checks itself, w/o resorting to - // getValue - checkBuilder.string(" || "); - checkBuilder.tree(TypeSystemCodeGenerator.check(typeSystem, targetType, createAsValue(frameState, value, "type system check"))); - } - } else { - if (hasCheck) { - castBuilder.tree(createIsType(frameState, value, "Object")); - castBuilder.string(" ? "); - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsType(frameState, value, "Object"))); - castBuilder.string(" : "); - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsValue(frameState, value, "type system cast"))); - } else { - castBuilder.tree(TypeSystemCodeGenerator.cast(typeSystem, targetType, createAsType(frameState, value, "Object"))); - } - } - } - break; + throw new IllegalArgumentException("Unknown primitive type: " + kind); } - - return true; } @Override - public boolean createImplicitCheckCast(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, CodeTree implicitState, - CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { - if (isVariadic) { - return false; - } - - if (!castOnly) { - createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); - checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit check"), implicitState)); - } else { - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit cast"), implicitState)); - } - - return true; + public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { + return CodeTreeBuilder.singleString("null"); } @Override - public boolean createImplicitCheckCastSlowPath(TypeSystemData typeSystem, FrameState frameState, TypeMirror targetType, LocalVariable value, String implicitStateName, - CodeTreeBuilder prepareBuilder, CodeTreeBuilder checkBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { - if (isVariadic) { - return false; - } - - if (!castOnly) { - createPrepareFor(null, context.getType(Object.class), frameState, value, prepareBuilder); - - checkBuilder.startParantheses(); - checkBuilder.string(implicitStateName, " = "); - checkBuilder.tree(TypeSystemCodeGenerator.implicitSpecializeFlat(typeSystem, targetType, createAsValue(frameState, value, "implicit specialize"))); - checkBuilder.end().string(" != 0"); - } else { - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat( - typeSystem, targetType, - createAsValue(frameState, value, "implicit specialize cast"), - CodeTreeBuilder.singleString(implicitStateName))); - } - - return true; - } - - public boolean createSameTypeCast(FrameState frameState, LocalVariable value, TypeMirror genericTargetType, CodeTreeBuilder prepareBuilder, CodeTreeBuilder castBuilder, boolean castOnly) { - if (isVariadic) - return false; - - assert ElementUtils.isObject(genericTargetType); - - if (!castOnly) { - prepareBuilder.lineComment("same type: " + value); - createPrepareFor(null, genericTargetType, frameState, value, prepareBuilder); - } else { - castBuilder.tree(createAsValue(frameState, value, "cast to object: " + cinstr.name)); - } - return true; - } - public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { if (isVariadic) { return values.toArray(new CodeTree[values.size()]); @@ -452,6 +258,7 @@ public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List addArguments) { if (isVariadic) { builder.startReturn().startCall("this", boundaryMethod); @@ -544,4 +354,63 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt createPushResult(builder, callBuilder.build(), boundaryMethod.getReturnType()); } + + @Override + public boolean createCallWrapInAMethod(CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters) { + parentBuilder.startStatement().startCall(method.getSimpleName().toString()); + addNodeCallParameters(parentBuilder, false, false); + addStateParameters.run(); + parentBuilder.end(2); + parentBuilder.returnStatement(); + return true; + } + + @Override + public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, + LocalVariable targetValue, Function createExecuteAndSpecialize) { + if (isVariadic) { + throw new AssertionError("variadic instructions should not have children"); + } + + int offset = cinstr.numPopStatic() - execution.getIndex(); + + CodeTreeBuilder b = parent.create(); + + b.tree(targetValue.createDeclaration(null)); + + b.startTryBlock(); + b.startAssign(targetValue.getName()); + b.startCall("$frame", "get" + getFrameName(targetValue.getTypeMirror().getKind())); + b.string("$sp - " + offset); + b.end(3); + + b.startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); + + FrameState slowPathFrameState = frameState.copy(); + + CodeTreeBuilder accessBuilder = b.create(); + accessBuilder.startCall("$frame", "getValue"); + accessBuilder.string("$sp - " + offset); + accessBuilder.end(); + + slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); + + boolean found = false; + for (NodeExecutionData otherExecution : node.getChildExecutions()) { + if (found) { + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); + b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--offset) + ")"); + slowPathFrameState.setValue(otherExecution, childEvaluatedValue); + } else { + // skip forward already evaluated + found = execution == otherExecution; + } + } + + b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); + + b.end(); + + return b.build(); + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index a68e4177ea30..ddb69b62a41d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -14,6 +14,8 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedElement; +import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { @@ -85,9 +87,7 @@ protected OperationsData parse(Element element, List mirror) { data.addError("Could not generate operation: " + inner.getSimpleName()); } - if (inner instanceof CodeTypeElement) { - opData.redirectMessagesOnGeneratedElements(data); - } + opData.redirectMessagesOnGeneratedElements(data); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index ed9a3d0075bd..39ff6dbdf81c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -1,5 +1,8 @@ package com.oracle.truffle.dsl.processor.operations; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -9,18 +12,29 @@ import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; +import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; +import com.oracle.truffle.dsl.processor.CodeWriter; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; +import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -37,6 +51,7 @@ public class SingleOperationParser extends AbstractParser { private Set OPERATION_PROXY_IGNORED_ANNOTATIONS = Set.of( types.GenerateOperations, types.OperationProxy, + context.getDeclaredType("com.oracle.truffle.api.operation.OperationProxies"), types.Operation); public SingleOperationParser(OperationsData parentData) { @@ -72,7 +87,7 @@ protected SingleOperationData parse(Element element, List mirr } name += "Operation"; CodeTypeElement tgt = new CodeTypeElement(MOD_PUBLIC_STATIC, ElementKind.CLASS, null, name); - tgt.setEnclosingElement(parentData.getMessageElement()); + tgt.setEnclosingElement(proxyType.getEnclosingElement()); for (AnnotationMirror mir : parentData.getMessageElement().getAnnotationMirrors()) { if (!OPERATION_PROXY_IGNORED_ANNOTATIONS.contains(mir.getAnnotationType())) { @@ -107,10 +122,12 @@ protected SingleOperationData parse(Element element, List mirr te = teClone; for (Element el : CompilerFactory.getCompiler(proxyType).getEnclosedElementsInDeclarationOrder(proxyType)) { - if (el instanceof ExecutableElement && isStaticAccessible(el)) { - teClone.add(el); - if (isOperationFunction((ExecutableElement) el)) { - operationFunctions.add((ExecutableElement) el); + if (el.getKind() == ElementKind.METHOD && isStaticAccessible(el)) { + CodeExecutableElement cel = CodeExecutableElement.clone((ExecutableElement) el); + cel.setEnclosingElement(el.getEnclosingElement()); + teClone.add(cel); + if (isOperationFunction(cel)) { + operationFunctions.add(cel); } } } @@ -122,6 +139,7 @@ protected SingleOperationData parse(Element element, List mirr } MethodProperties props = processMethod(data, operationFunctions.get(0)); + boolean isVariadic = props.isVariadic; for (ExecutableElement fun : operationFunctions) { MethodProperties props2 = processMethod(data, fun); @@ -135,22 +153,70 @@ protected SingleOperationData parse(Element element, List mirr data.setMainProperties(props); - CodeTypeElement clonedType = te instanceof CodeTypeElement ? (CodeTypeElement) te : CodeTypeElement.cloneShallow(te); + CodeTypeElement clonedType; + if (te instanceof CodeTypeElement) { + clonedType = (CodeTypeElement) te; + } else { + clonedType = CodeTypeElement.cloneShallow(te); + + clonedType.getEnclosedElements().clear(); + for (Element e : CompilerFactory.getCompiler(te).getEnclosedElementsInDeclarationOrder(te)) { + if (e.getModifiers().contains(Modifier.PRIVATE) || !e.getModifiers().contains(Modifier.STATIC)) { + continue; + } + + CodeElement ce; + if (e.getKind() == ElementKind.METHOD) { + ce = CodeExecutableElement.clone((ExecutableElement) e); + } else if (e.getKind() == ElementKind.FIELD) { + ce = CodeVariableElement.clone((VariableElement) e); + } else { + throw new UnsupportedOperationException("unknown enclosed kind: " + e.getKind()); + } + + ce.setEnclosingElement(e.getEnclosingElement()); + clonedType.add(ce); + } + } + clonedType.setEnclosingElement(te.getEnclosingElement()); + // clonedType.setSuperClass(new DeclaredCodeTypeMirror(createRegularNodeChild())); clonedType.setSuperClass(types.Node); + // clonedType.setSuperClass(new DeclaredCodeTypeMirror(childType)); - if (proxyType != null) { - clonedType.addOptional(ElementUtils.findExecutableElement(proxyType, "execute")); + if (!isVariadic) { + int i = 0; + CodeTypeElement childType = createRegularNodeChild(); + CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); + List anns = new ArrayList<>(); + for (ParameterKind param : props.parameters) { + if (param == ParameterKind.STACK_VALUE) { + CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); + // CodeTypeElement childType = createRegularNodeChild(); + ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); + anns.add(new CodeAnnotationValue(ann)); + i++; + } + } + repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); + clonedType.addAnnotationMirror(repAnnotation); } CodeExecutableElement metExecute = new CodeExecutableElement( Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), context.getType(props.returnsValue ? Object.class : void.class), "execute"); - { + metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + + if (isVariadic) { int i = 0; for (ParameterKind param : props.parameters) { - metExecute.addParameter(new CodeVariableElement(param.getParameterType(context), "arg" + i)); + if (param == ParameterKind.STACK_VALUE) { + metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); + } else if (param == ParameterKind.VARIADIC) { + metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); + } i++; } } @@ -168,8 +234,15 @@ protected SingleOperationData parse(Element element, List mirr clonedType.add(el); } } + + clonedType.setSimpleName(proxyType.getSimpleName()); + clonedType.setEnclosingElement(proxyType.getEnclosingElement()); } + // if (data.getName().equals("SLEvalRootOperation")) { + // throw new AssertionError(OperationGeneratorUtils.printCode(clonedType)); + // } + NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); if (nodeData == null) { @@ -177,7 +250,7 @@ protected SingleOperationData parse(Element element, List mirr return data; } - nodeData.redirectMessages(data); + nodeData.redirectMessagesOnGeneratedElements(data); data.setNodeData(nodeData); return data; @@ -189,8 +262,6 @@ public DeclaredType getAnnotationType() { } private MethodProperties processMethod(SingleOperationData data, ExecutableElement method) { - List arguments = List.of(); // TODO - boolean isVariadic = false; List parameters = new ArrayList<>(); @@ -236,6 +307,33 @@ private boolean isIgnoredParameter(VariableElement param) { return false; } + private CodeTypeElement createRegularNodeChild() { + + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + result.setSuperClass(types.Node); + + result.add(createExecuteMethod("Generic", context.getType(Object.class))); + result.add(createExecuteMethod("Long", context.getType(long.class))); + result.add(createExecuteMethod("Integer", context.getType(int.class))); + result.add(createExecuteMethod("Byte", context.getType(byte.class))); + result.add(createExecuteMethod("Boolean", context.getType(boolean.class))); + result.add(createExecuteMethod("Float", context.getType(float.class))); + result.add(createExecuteMethod("Double", context.getType(double.class))); + result.add(createExecuteMethod("Void", context.getType(void.class))); + + return result; + } + + private CodeExecutableElement createExecuteMethod(String name, TypeMirror retType) { + CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); + // result.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + + if (!ElementUtils.isObject(retType) && !ElementUtils.isVoid(retType)) { + result.addThrownType(types.UnexpectedResultException); + } + return result; + } + private boolean isVariadicParameter(VariableElement param) { return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index ea877503286c..e45aa8301e03 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -137,6 +137,7 @@ import com.oracle.truffle.dsl.processor.model.MethodSpec; import com.oracle.truffle.dsl.processor.model.NodeChildData; import com.oracle.truffle.dsl.processor.model.NodeChildData.Cardinality; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.NodeFieldData; @@ -1860,7 +1861,12 @@ private NodeData parseChildNodeData(NodeData parentNode, NodeChildData child, Ty List lookupTypes = collectSuperClasses(new ArrayList(), templateType); // Declaration order is not required for child nodes. - List members = processingEnv.getElementUtils().getAllMembers(templateType); + List members; + if (templateType instanceof CodeTypeElement) { + members = ((CodeTypeElement) templateType).getEnclosedElements(); + } else { + members = processingEnv.getElementUtils().getAllMembers(templateType); + } NodeData node = parseNodeData(templateType, lookupTypes); if (node.hasErrors()) { return node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 17d89e971726..2b95671a2687 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -77,12 +77,15 @@ public SLException(String message, Node location) { * are no automatic type conversions of values. */ @TruffleBoundary + @SuppressWarnings("deprecation") public static SLException typeError(Node operation, int bci, Object... values) { StringBuilder result = new StringBuilder(); result.append("Type error"); + SLException ex = new SLException("", operation, bci); + if (operation != null) { - SourceSection ss = operation.getEncapsulatingSourceSection(); + SourceSection ss = ex.getLocation().getSourceSection(); if (ss != null && ss.isAvailable()) { result.append(" at ").append(ss.getSource().getName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn()); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index d6c58ac18d93..293601910d26 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -79,9 +79,9 @@ public static void parse(SLLanguage language, Source source, SLOperationsBuilder @Operation public static class SLEvalRootOperation { - @SuppressWarnings("unchecked") + @Specialization - public static Object perform( + public static Object doExecute( VirtualFrame frame, Map functions, @Bind("this") Node node) { @@ -95,6 +95,11 @@ public static Object perform( return SLNull.SINGLETON; } } + + @Fallback + public static Object fallback(Object ignored) { + throw new RuntimeException(""); + } } @Operation From 90f01106b03876ee5eb8d58fca7958d6b3426741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 12 Apr 2022 14:30:18 +0200 Subject: [PATCH 044/312] [wip] boxing elim (mostly) --- .../test/example/TestLanguageBackend.java | 2 +- .../test/example/TestOperations.java | 10 +- .../example/TestOperationsParserTest.java | 54 +++- .../api/operation/OperationsBuilder.java | 54 ++++ .../dsl/processor/generator/BitSet.java | 6 + .../generator/FlatNodeGenFactory.java | 29 +- .../dsl/processor/generator/MultiBitSet.java | 11 + .../generator/NodeGeneratorPlugs.java | 17 +- .../dsl/processor/java/ElementUtils.java | 9 +- .../dsl/processor/operations/Operation.java | 58 +++- .../operations/OperationGeneratorUtils.java | 22 ++ .../OperationsBytecodeCodeGenerator.java | 180 +++++++++++- .../OperationsBytecodeNodeGeneratorPlugs.java | 264 +++++++++++++++--- .../operations/OperationsCodeGenerator.java | 21 +- .../operations/OperationsConfiguration.java | 10 + .../operations/OperationsContext.java | 69 ++++- .../operations/SingleOperationParser.java | 11 +- .../instructions/BranchInstruction.java | 10 + .../ConditionalBranchInstruction.java | 50 +++- .../instructions/CustomInstruction.java | 36 +++ .../instructions/DiscardInstruction.java | 10 + .../operations/instructions/Instruction.java | 31 +- .../InstrumentationEnterInstruction.java | 10 + .../InstrumentationExitInstruction.java | 10 + .../InstrumentationLeaveInstruction.java | 10 + .../instructions/LoadArgumentInstruction.java | 69 +++++ .../instructions/LoadConstantInstruction.java | 149 ++++++++++ .../instructions/LoadLocalInstruction.java | 10 + .../instructions/ReturnInstruction.java | 71 +++++ .../instructions/StoreLocalInstruction.java | 10 + .../instructions/SuperInstruction.java | 10 + .../instructions/TransferInstruction.java | 18 -- .../dsl/processor/parser/NodeParser.java | 3 +- .../truffle/sl/operations/SLOperations.java | 2 - .../operations/SLOperationsVisitor.java | 18 +- 35 files changed, 1220 insertions(+), 134 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java index 7cef9443e940..50ccc106fd04 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java @@ -18,7 +18,7 @@ public void buildRoot(Source source, TestLanguageAst ast) { b.beginSource(source); build(ast); b.endSource(); - b.build(); + System.out.println(b.build().dump()); } private void build(TestLanguageAst ast) { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index e12c26bb8d16..4224cb5911e1 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -74,8 +74,16 @@ public static long bla(long a1, @Variadic Object[] a2) { @Operation static class ThrowOperation { @Specialization - public static void perform(@Bind("$bci") int bci, @Bind("this") OperationsNode node) { + public static Object perform(@Bind("$bci") int bci, @Bind("this") OperationsNode node) { throw new TestException("fail", node, bci); } } + + @Operation + static class AlwaysBoxOperation { + @Specialization + public static Object perform(Object value) { + return value; + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index e61888e442d5..a0cfff990d13 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -52,7 +52,8 @@ public Tester then(Consumer action) { } private static RootCallTarget parse(Consumer builder) { - return TestOperationsBuilder.parse(null, builder)[0].createRootNode(null, "TestFunction").getCallTarget(); + OperationsNode operationsNode = TestOperationsBuilder.parse(null, builder)[0]; + return operationsNode.createRootNode(null, "TestFunction").getCallTarget(); } @Test @@ -180,6 +181,56 @@ public void testTryCatch() { Assert.assertEquals(0L, root.call(1L)); } + @Test + public void testVariableBoxingElim() { + RootCallTarget root = parse(b -> { + b.beginStoreLocal(0); + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginStoreLocal(1); + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginWhile(); + + b.beginLessThanOperation(); + b.emitLoadLocal(0); + b.emitConstObject(100L); + b.endLessThanOperation(); + + b.beginBlock(); + + b.beginStoreLocal(1); + b.beginAddOperation(); + b.beginAlwaysBoxOperation(); + b.emitLoadLocal(1); + b.endAlwaysBoxOperation(); + b.emitLoadLocal(0); + b.endAddOperation(); + b.endStoreLocal(); + + b.beginStoreLocal(0); + b.beginAddOperation(); + b.emitLoadLocal(0); + b.emitConstObject(1L); + b.endAddOperation(); + b.endStoreLocal(); + + b.endBlock(); + + b.endWhile(); + + b.beginReturn(); + b.emitLoadLocal(1); + b.endReturn(); + + b.build(); + }); + + Assert.assertEquals(4950L, root.call()); + } + @Test public void testSourceInfo() { String src = " (return (add 1 2))"; @@ -264,4 +315,5 @@ public void testCompilation() { Assert.assertEquals(Value.asValue(7L), v.execute(3L, 4L)); } + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 5c32e6316289..ffee51a562ee 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,6 +1,7 @@ package com.oracle.truffle.api.operation; import java.util.ArrayList; +import java.util.Arrays; import java.util.function.Supplier; import com.oracle.truffle.api.instrumentation.Tag; @@ -32,6 +33,10 @@ public void reset() { labelFills.clear(); maxLocals = -1; instrumentationId = 0; + + instructionIndex = 0; + curStack = 0; + maxStack = 0; } protected final Object trackLocalsHelper(Object value) { @@ -146,6 +151,55 @@ protected void doEmitLabel(int bci, OperationLabel label) { lbl.targetBci = bci; } + // ------------------------ stack / successor handling ------------------------ + + private int instructionIndex; + + private int[] stackSourceIndices = new int[1024]; + private int curStack; + private int maxStack; + + private short[] predecessorIndices = new short[65535]; + + protected void doBeforeEmitInstruction(int bci, int numPops, boolean pushValue) { + for (int i = numPops - 1; i >= 0; i--) { + int predIndex = stackSourceIndices[--curStack]; + predecessorIndices[predIndex] = (short) bci; + predecessorIndices[predIndex + 1] = (short) i; + } + + // TODO: we could only record instrs that produce values + + if (pushValue) { + int index = instructionIndex; + instructionIndex += 2; + + stackSourceIndices[curStack++] = index; + + if (curStack > maxStack) { + maxStack = curStack; + } + } + } + + protected short[] createPredecessorIndices() { + return Arrays.copyOf(predecessorIndices, instructionIndex); + } + + protected int createMaxStack() { + return maxStack; + } + + protected int getCurStack() { + return curStack; + } + + protected void setCurStack(int curStack) { + // this should probably be: + // assert this.curStack == curStack; + this.curStack = curStack; + } + // ------------------------ source sections ------------------------ public abstract void beginSource(Source source); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index da8cf885a7f5..9d84a3b1ac91 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -224,6 +224,12 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec return builder.build(); } + public CodeTree createIsEmpty(FrameState frameState) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.tree(createReference(frameState)).string(" == 0"); + return builder.build(); + } + private CodeTree createMaskedReference(FrameState frameState, long maskedElements) { if (maskedElements == this.allMask) { // no masking needed diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 7ceb7d168b43..3adb7e16a684 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -280,10 +280,16 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData } stateObjects.addAll(implicitCasts); } + if (plugs != null) { + plugs.addAdditionalStateBits(stateObjects); + } if (activeStateEndIndex == -1) { activeStateEndIndex = stateObjects.size(); } this.multiState = createMultiStateBitset(stateObjects, activeStateStartIndex, activeStateEndIndex, volatileState); + if (plugs != null) { + plugs.setMultiState(this.multiState); + } this.allMultiState = new MultiStateBitSet(this.multiState.all, this.multiState.all); this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState, plugs); this.executeAndSpecializeType = createExecuteAndSpecializeType(); @@ -360,6 +366,9 @@ private MultiStateBitSet createMultiStateBitset(List stateObjects, int a } private boolean needsRewrites() { + if (plugs != null) { + return plugs.needsRewrites(); + } return node.needsRewrites(context); } @@ -2491,7 +2500,7 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group addExplodeLoop(builder, group); CodeTreeBuilder parentBuilder = parent.create(); - if (plugs == null || !plugs.createCallWrapInAMethod(parentBuilder, method, () -> multiState.addReferencesTo(frameState, parentBuilder))) { + if (plugs == null || !plugs.createCallWrapInAMethod(frameState, parentBuilder, method, () -> multiState.addReferencesTo(frameState, parentBuilder))) { parentBuilder.startReturn(); parentBuilder.startCall(method.getSimpleName().toString()); multiState.addReferencesTo(frameState, parentBuilder); @@ -3423,7 +3432,7 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } CodeTree specializationCall = callMethod(frameState, null, specialization.getMethod(), bindings); - if (plugs == null || !plugs.createCallSpecialization(specialization, specializationCall, builder, inBoundary)) { + if (plugs == null || !plugs.createCallSpecialization(frameState, specialization, specializationCall, builder, inBoundary)) { if (isVoid(specialization.getMethod().getReturnType())) { builder.statement(specializationCall); if (isVoid(forType.getReturnType())) { @@ -3912,6 +3921,10 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.tree(multiState.createSet(frameState, new SpecializationData[]{specialization}, true, true)); + if (plugs != null) { + plugs.createSpecialize(frameState, specialization, builder); + } + if (needsDuplicationCheck) { hasFallthrough = true; if (useDuplicateFlag) { @@ -4780,7 +4793,7 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram CodeTree call = builder.build(); builder = builder.create(); - if (plugs == null || !plugs.createCallExecuteAndSpecialize(builder, call)) { + if (plugs == null || !plugs.createCallExecuteAndSpecialize(frameState, builder, call)) { if (isVoid(forType.getReturnType())) { builder.statement(call); builder.returnStatement(); @@ -5614,14 +5627,14 @@ private static class ExecuteDelegationResult { } - static int getRequiredStateBits(TypeSystemData types, Object object) { + int getRequiredStateBits(TypeSystemData typeData, Object object) { if (object instanceof SpecializationData) { return 1; } else if (object instanceof TypeGuard) { TypeGuard guard = (TypeGuard) object; TypeMirror type = guard.getType(); - Collection sourceTypes = types.lookupSourceTypes(type); + Collection sourceTypes = typeData.lookupSourceTypes(type); if (sourceTypes.size() > 1) { return sourceTypes.size(); } @@ -5630,6 +5643,8 @@ static int getRequiredStateBits(TypeSystemData types, Object object) { return 1; } else if (object == AOT_PREPARED) { return 1; + } else if (plugs != null) { + return plugs.getRequiredStateBits(typeData, object); } else { throw new AssertionError(); } @@ -5920,6 +5935,10 @@ public static FrameState load(FlatNodeGenFactory factory, ExecutableTypeData typ return context; } + public static FrameState createEmpty() { + return new FrameState(null, null, null); + } + private void loadEvaluatedValues(ExecutableTypeData executedType, int varargsThreshold) { TypeMirror frame = executedType.getFrameParameter(); if (frame == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java index 036e1f7e11ab..f48af70f5845 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java @@ -135,6 +135,17 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec return builder.build(); } + public CodeTree createIsEmpty(FrameState frameState) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + String sep = ""; + for (BitSet set : sets) { + builder.string(sep); + builder.tree(set.createIsEmpty(frameState)); + sep = " && "; + } + return builder.build(); + } + public CodeTree createIsNotAny(FrameState frameState, Object[] elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.string("("); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 490d4f305874..528f7001de46 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -8,6 +8,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -16,6 +17,7 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; public interface NodeGeneratorPlugs { String transformNodeMethodName(String name); @@ -44,13 +46,13 @@ public interface NodeGeneratorPlugs { void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); - boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary); + boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary); - boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call); + boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call); void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments); - boolean createCallWrapInAMethod(CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters); + boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters); CodeTree createAssignExecuteChild( NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue, @@ -60,4 +62,13 @@ CodeTree createAssignExecuteChild( Boolean needsFrameToExecute(List specializations); + void addAdditionalStateBits(List stateObjects); + + void setMultiState(MultiStateBitSet multiState); + + int getRequiredStateBits(TypeSystemData types, Object object); + + void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder builder); + + boolean needsRewrites(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 65d70198947b..66c5754e3d23 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -237,10 +237,11 @@ public static boolean needsCastTo(TypeMirror sourceType, TypeMirror targetType) public static String createReferenceName(ExecutableElement method) { StringBuilder b = new StringBuilder(); - if (method.getEnclosingElement() != null) { - b.append(method.getEnclosingElement().getSimpleName()); - b.append('#'); - } + // if (method.getEnclosingElement() != null) { + // b.append(method.getEnclosingElement().getSimpleName()); + // b.append('#'); + // } + b.append(method.getSimpleName().toString()); b.append("("); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 59ee17b94635..23d9f1ab027e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -17,6 +17,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction.ConstantKind; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -52,8 +54,6 @@ public static class BuilderVariables { public CodeVariableElement lastChildPushCount; public CodeVariableElement childIndex; public CodeVariableElement numChildren; - public CodeVariableElement curStack; - public CodeVariableElement maxStack; public CodeVariableElement keepingInstrumentation; public CodeVariableElement numChildNodes; } @@ -134,6 +134,47 @@ public List getBuilderArgumentTypes() { } } + public static class LoadConstant extends Operation { + private final LoadConstantInstruction[] instructions; + + protected LoadConstant(OperationsContext builder, int id, LoadConstantInstruction... instructions) { + super(builder, "ConstObject", id, 0); + this.instructions = instructions; + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + CodeTree[] arguments = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; + for (ConstantKind kind : ConstantKind.values()) { + if (kind == ConstantKind.OBJECT) { + b.startElseBlock(); + } else { + b.startIf(kind.ordinal() > 0); + b.string("arg0 instanceof " + kind.getTypeNameBoxed()); + b.end().startBlock(); + } + + b.tree(instructions[kind.ordinal()].createEmitCode(vars, arguments)); + + b.end(); + } + + return b.build(); + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getType(Object.class)); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("1"); + } + } + public static class Block extends Operation { protected Block(OperationsContext builder, int id) { super(builder, "Block", id, VARIABLE_CHILDREN); @@ -144,6 +185,15 @@ protected Block(OperationsContext builder, String name, int id) { super(builder, name, id, VARIABLE_CHILDREN); } + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign(vars.lastChildPushCount).string("0").end(); + + return b.build(); + } + @Override public CodeTree createBeforeChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -418,7 +468,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = ").variable(vars.curStack).end(); + b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); b.startStatement().variable(varBeh).string(".exceptionIndex = (int)").variable(vars.operationData).string(".arguments[0]").end(); b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); @@ -459,7 +509,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 1").end(); b.startBlock(); - b.startAssign(vars.curStack).tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".startStack").end(); + b.startStatement().startCall("setCurStack").startGroup().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".startStack").end(3); b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".handlerBci = ").variable(vars.bci).end(); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 3f57978cb8c2..84070fd47724 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -51,6 +51,27 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); } + public static CodeTree createReadOpcode(CodeTree bc, CodeTree bci) { + return CodeTreeBuilder.createBuilder().tree(bc).string("[").tree(bci).string("]").build(); + } + + public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElement bci) { + return createReadOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleVariable(bci)); + } + + public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { + return CodeTreeBuilder.createBuilder().startStatement().tree(bc).string("[").tree(bci).string("] = ").tree(value).end().build(); + } + + public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { + return createWriteOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleVariable(bci), + CodeTreeBuilder.singleVariable(value)); + } + public static String printCode(Element el) { StringWriter wr = new StringWriter(); new AbstractCodeWriter() { @@ -67,4 +88,5 @@ protected Writer createWriter(CodeTypeElement clazz) throws IOException { return wr.toString(); } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 003ff0e24fda..9914b2b91da5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -97,6 +97,10 @@ public CodeTypeElement createBuilderBytecodeNode() { GeneratorUtils.addCompilationFinalAnnotation(fldConditionBranches, 1); builderBytecodeNodeType.add(fldConditionBranches); + CodeVariableElement fldSuccessorIndices = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(short.class)), "successorIndices"); + GeneratorUtils.addCompilationFinalAnnotation(fldSuccessorIndices, 1); + builderBytecodeNodeType.add(fldSuccessorIndices); + CodeVariableElement fldProbeNodes = null; if (withInstrumentation) { fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); @@ -153,7 +157,7 @@ public CodeTypeElement createBuilderBytecodeNode() { int numStackValues = isVariadic ? 0 : cinstr.numPopStatic(); - NodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( + OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( fldBc, fldChildren, constIndices, innerTypeNames, additionalData, methodNames, isVariadic, soData, @@ -251,7 +255,50 @@ public CodeTypeElement createBuilderBytecodeNode() { cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); cinstr.setNumChildNodes(childIndices.size()); cinstr.setNumConsts(constIndices.size()); + + { + CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( + Set.of(Modifier.PRIVATE), + context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", + new CodeVariableElement(context.getType(int.class), "$bci")); + builderBytecodeNodeType.add(metSetResultUnboxed); + cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + + CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); + b.tree(plugs.createSetResultBoxed()); + } + + if (!isVariadic) { + CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( + Set.of(Modifier.PRIVATE), + context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", + new CodeVariableElement(context.getType(int.class), "$bci"), + new CodeVariableElement(context.getType(int.class), "index")); + builderBytecodeNodeType.add(metSetInputUnboxed); + cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); + + CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); + + if (cinstr.numPopStatic() == 0) { + b.startAssert().string("false : \"operation has no input\"").end(); + } else if (cinstr.numPopStatic() == 1) { + b.startAssert().string("index == 0 : \"operation has only one input\"").end(); + b.tree(plugs.createSetInputBoxed(0)); + } else { + b.startSwitch().string("index").end().startBlock(); + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.startCase().string("" + i).end().startCaseBlock(); + b.tree(plugs.createSetInputBoxed(i)); + b.statement("break"); + b.end(); + } + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); + b.end(2); + } + } } + } ExecutionVariables vars = new ExecutionVariables(); @@ -319,7 +366,6 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); b.startBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); b.end(); @@ -498,6 +544,128 @@ public CodeTypeElement createBuilderBytecodeNode() { } + { + CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doSetResultBoxed"); + builderBytecodeNodeType.add(mDoSetResultUnboxed); + + CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); + mDoSetResultUnboxed.addParameter(varTargetBci); + + CodeVariableElement varIndices = new CodeVariableElement(context.getType(int.class), "...indices"); + mDoSetResultUnboxed.addParameter(varIndices); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); + + b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); + + b.declaration("int", vars.bci.getName(), "0"); + b.declaration("int", "instrIndex", "0"); + + b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); + b.startBlock(); + + b.startSwitch().string("bc[bci]").end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + if (instr.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + + b.startCase().variable(instr.opcodeIdField).end(); + b.startBlock(); + + if (instr.numPush() > 0) { + CodeTree tree = instr.createSetResultBoxed(vars); + if (tree != null) { + b.startIf().variable(fldSuccessorIndices).string("[instrIndex] == ").variable(varTargetBci).end().startBlock(); + b.tree(tree); + b.end(); + } + b.statement("instrIndex += 2"); + } + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + b.statement("break"); + + b.end(); + } + + b.end(); + + b.end(); // while block + } + + { + CodeExecutableElement mDoSetInputUnboxed = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doSetInputBoxed"); + builderBytecodeNodeType.add(mDoSetInputUnboxed); + + CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); + mDoSetInputUnboxed.addParameter(varTargetBci); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + CodeTreeBuilder b = mDoSetInputUnboxed.createBuilder(); + + b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); + + b.declaration("int", vars.bci.getName(), "0"); + b.declaration("int", "instrIndex", "0"); + + b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); + b.startBlock(); + + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + if (instr.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + + b.startCase().variable(instr.opcodeIdField).end(); + b.startCaseBlock(); + + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + if (instr.numPush() > 0) { + b.statement("instrIndex += 2"); + } + b.statement("break"); + + b.end(); + } + + b.end(); // switch block + + b.end(); // while block + + b.startAssert().variable(vars.bci).string(" == ").variable(varTargetBci).end(); + + b.startAssign(vars.bci).variable(fldSuccessorIndices).string("[instrIndex]").end(); + b.declaration("int", "succInput", CodeTreeBuilder.createBuilder().variable(fldSuccessorIndices).string("[instrIndex + 1]").build()); + + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + if (instr.isInstrumentationOnly() && !withInstrumentation) { + continue; + } + + b.startCase().variable(instr.opcodeIdField).end(); + b.startCaseBlock(); + + b.tree(instr.createSetInputBoxed(vars, CodeTreeBuilder.singleString("succInput"))); + + b.statement("break"); + + b.end(); + } + + b.end(); // switch block + } + { CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); builderBytecodeNodeType.add(mDump); @@ -505,6 +673,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTreeBuilder b = mDump.getBuilder(); b.declaration("int", "bci", "0"); + b.declaration("int", "instrIndex", "0"); b.declaration("StringBuilder", "sb", "new StringBuilder()"); vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); @@ -528,6 +697,13 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); + if (op.numPush() == 0) { + b.statement("sb.append(\" \")"); + } else { + b.statement("sb.append(String.format(\"[ %04x %2d ] \", successorIndices[instrIndex], successorIndices[instrIndex + 1]))"); + b.statement("instrIndex += 2"); + } + for (int i = 0; i < 16; i++) { if (i < op.length()) { b.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 6ac7797cf1a3..61171d233830 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -1,5 +1,7 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.function.Consumer; @@ -14,6 +16,7 @@ import com.oracle.truffle.dsl.processor.generator.BitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -26,6 +29,7 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; @@ -45,8 +49,25 @@ final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final ProcessorContext context; private final TruffleTypes types; + private final Object[] inputsBoxedState; + private final Object resultBoxedState; - private static final boolean LOG_GET_VALUE_CALLS = false; + private MultiStateBitSet multiState; + + private static final boolean DO_LOG_BOXING_ELIM = false; + + private static class InputBoxedState { + private final int index; + + InputBoxedState(int index) { + this.index = index; + } + + @Override + public String toString() { + return "INPUT-BOXED(" + index + ")"; + } + } OperationsBytecodeNodeGeneratorPlugs(CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, Set innerTypeNames, List additionalData, @@ -67,6 +88,45 @@ final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { this.context = ProcessorContext.getInstance(); this.types = context.getTypes(); + + if (!isVariadic) { + inputsBoxedState = new Object[cinstr.numPopStatic()]; + for (int i = 0; i < cinstr.numPopStatic(); i++) { + inputsBoxedState[i] = new InputBoxedState(i); + } + } else { + inputsBoxedState = null; + } + + if (cinstr.numPush() == 0) { + resultBoxedState = null; + } else { + resultBoxedState = new Object() { + @Override + public String toString() { + return "RESULT-BOXED"; + } + }; + } + } + + @Override + public void addAdditionalStateBits(List stateObjects) { + if (inputsBoxedState != null) { + stateObjects.addAll(Arrays.asList(inputsBoxedState)); + } + if (resultBoxedState != null) { + stateObjects.add(resultBoxedState); + } + } + + public void setMultiState(MultiStateBitSet multiState) { + this.multiState = multiState; + } + + @Override + public int getRequiredStateBits(TypeSystemData typesData, Object object) { + return 1; } @Override @@ -240,6 +300,24 @@ private static String getFrameName(TypeKind kind) { } } + private static boolean isUnboxable(TypeKind kind) { + switch (kind) { + case INT: + case BYTE: + case BOOLEAN: + case DOUBLE: + case FLOAT: + case LONG: + return true; + case DECLARED: + case CHAR: + case SHORT: + return false; + default: + throw new IllegalArgumentException("Unknown primitive type: " + kind); + } + } + @Override public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { return CodeTreeBuilder.singleString("null"); @@ -263,7 +341,7 @@ public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) frameState.set("frameValue", new LocalVariable(types.VirtualFrame, "$frame", null)); } - private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { + private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { if (cinstr.numPush() == 0) { b.statement(specializationCall); b.returnStatement(); @@ -283,48 +361,55 @@ private void createPushResult(CodeTreeBuilder b, CodeTree specializationCall, Ty b.statement(specializationCall); value = CodeTreeBuilder.singleString("null"); typeName = "Object"; - } else if (retType.getKind().isPrimitive()) { - value = specializationCall; - typeName = getFrameName(retType.getKind()); } else { value = specializationCall; - typeName = "Object"; - } - - if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { - b.startBlock(); - b.declaration(retType, "__value__", value); - b.statement("System.out.printf(\" pushing " + typeName + " at -" + destOffset + ": %s%n\", __value__)"); + typeName = getFrameName(retType.getKind()); } - b.startStatement(); - b.startCall("$frame", "set" + typeName); - b.string("$sp - " + destOffset); - if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { - b.string("__value__"); - } else { + if (typeName.equals("Object")) { + // no boxing elim here + b.startStatement(); + b.startCall("$frame", "set" + typeName); + b.string("$sp - " + destOffset); b.tree(value); + b.end(2); + } else { + b.startIf(); + b.tree(multiState.createContains(frameState, new Object[]{resultBoxedState})); + b.end().startBlock(); + { + b.startStatement(); + b.startCall("$frame", "setObject"); + b.string("$sp - " + destOffset); + b.tree(value); + b.end(2); + } + b.end().startElseBlock(); + { + b.startStatement(); + b.startCall("$frame", "set" + typeName); + b.string("$sp - " + destOffset); + b.tree(value); + b.end(2); + } + b.end(); } - b.end(2); b.returnStatement(); - if (OperationsBytecodeCodeGenerator.DO_STACK_LOGGING) { - b.end(); - } } @Override - public boolean createCallSpecialization(SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { + public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { if (isVariadic || inBoundary) return false; - createPushResult(b, specializationCall, specialization.getMethod().getReturnType()); + createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); return true; } @Override - public boolean createCallExecuteAndSpecialize(CodeTreeBuilder builder, CodeTree call) { + public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { if (isVariadic) { return false; } @@ -352,11 +437,11 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt addArguments.accept(callBuilder); callBuilder.end(); - createPushResult(builder, callBuilder.build(), boundaryMethod.getReturnType()); + createPushResult(frameState, builder, callBuilder.build(), boundaryMethod.getReturnType()); } @Override - public boolean createCallWrapInAMethod(CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters) { + public boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters) { parentBuilder.startStatement().startCall(method.getSimpleName().toString()); addNodeCallParameters(parentBuilder, false, false); addStateParameters.run(); @@ -372,22 +457,78 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame throw new AssertionError("variadic instructions should not have children"); } - int offset = cinstr.numPopStatic() - execution.getIndex(); + int childIndex = execution.getIndex(); + int offset = cinstr.numPopStatic() - childIndex; CodeTreeBuilder b = parent.create(); b.tree(targetValue.createDeclaration(null)); - b.startTryBlock(); - b.startAssign(targetValue.getName()); - b.startCall("$frame", "get" + getFrameName(targetValue.getTypeMirror().getKind())); - b.string("$sp - " + offset); - b.end(3); + String typeName = getFrameName(targetValue.getTypeMirror().getKind()); - b.startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); + if (typeName.equals("Object")) { + b.startTryBlock(); + b.startAssign(targetValue.getName()); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(3); + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, false, "neverbox"); + } else { + b.startIf().tree(multiState.createContains(frameState, new Object[]{inputsBoxedState[childIndex]})).end(); + b.startBlock(); + { + b.startTryBlock(); + b.startAssign(targetValue.getName()); + b.cast(targetValue.getTypeMirror()); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(3); + + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, true, false, "box -> unbox"); + } + b.end().startElseBlock(); + { + b.startTryBlock(); + b.startAssign(targetValue.getName()); + b.startCall("$frame", "get" + typeName); + b.string("$sp - " + offset); + b.end(3); + + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, "unbox -> box"); + } + b.end(); + } + + return b.build(); + } + + private void createExecuteChildCatch(NodeData node, FrameState frameState, NodeExecutionData execution, LocalVariable targetValue, Function createExecuteAndSpecialize, + int offset, CodeTreeBuilder b, boolean alsoCastException, boolean setBoxedInput, String reason) { + + if (alsoCastException) { + b.startCatchBlock(new TypeMirror[]{ + context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), + context.getType(ClassCastException.class), + }, "ex"); + } else { + b.startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); + } + + if (DO_LOG_BOXING_ELIM) { + b.statement("System.out.printf(\" -- frame mispredict " + cinstr.name + "(" + reason + ": %s) @ %04x: %s %n\", $frame.getTag($sp - " + offset + "), $bci, ex)"); + } FrameState slowPathFrameState = frameState.copy(); + if (setBoxedInput) { + // TODO lock + b.tree(multiState.createSet(slowPathFrameState, new Object[]{inputsBoxedState[execution.getIndex()]}, true, true)); + b.startStatement().startCall("doSetResultBoxed"); + b.string("$bci"); + b.string("" + execution.getIndex()); + b.end(2); + } + CodeTreeBuilder accessBuilder = b.create(); accessBuilder.startCall("$frame", "getValue"); accessBuilder.string("$sp - " + offset); @@ -395,11 +536,13 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); + int curOffset = offset; boolean found = false; + for (NodeExecutionData otherExecution : node.getChildExecutions()) { if (found) { LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); - b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--offset) + ")"); + b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); slowPathFrameState.setValue(otherExecution, childEvaluatedValue); } else { // skip forward already evaluated @@ -410,7 +553,58 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); b.end(); + } + @Override + public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder b) { + if (isVariadic) + return; + + List referenceArguments = new ArrayList<>(); + List inputsBoxedStateList = new ArrayList<>(); + + int i = -1; + for (TypeMirror arg : specialization.getTypeSignature()) { + if (i >= 0 && !isUnboxable(arg.getKind())) { + referenceArguments.add(i); + inputsBoxedStateList.add(inputsBoxedState[i]); + } + + i++; + } + + if (referenceArguments.isEmpty()) { + return; + } + + b.startIf().string("!").startParantheses().tree(multiState.createContainsAll(frameState, inputsBoxedStateList.toArray())).end(2).startBlock(); + { + // not all of them are set, set them + b.tree(multiState.createSet(frameState, inputsBoxedStateList.toArray(), true, true)); + + b.startStatement().startCall("doSetResultBoxed"); + b.string("$bci"); + for (int arg : referenceArguments) { + b.string("" + arg); + } + b.end(2); + } + b.end(); + } + + public CodeTree createSetResultBoxed() { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultBoxedState}, true, true)); + return b.build(); + } + + public CodeTree createSetInputBoxed(int index) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{inputsBoxedState[index]}, true, true)); return b.build(); } + + public boolean needsRewrites() { + return true; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 48c234fc4415..0e4a855548ee 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -235,12 +235,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastPush"); typBuilderImpl.add(fldLastPush); - CodeVariableElement fldMaxStack = new CodeVariableElement(context.getType(int.class), "maxStack"); - typBuilderImpl.add(fldMaxStack); - - CodeVariableElement fldCurStack = new CodeVariableElement(context.getType(int.class), "curStack"); - typBuilderImpl.add(fldCurStack); - CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); typBuilderImpl.add(fldBci); @@ -293,8 +287,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.lastChildPushCount = fldLastPush; vars.operationData = fldOperationData; vars.consts = fldConstPool; - vars.maxStack = fldMaxStack; - vars.curStack = fldCurStack; vars.exteptionHandlers = fldExceptionHandlers; vars.keepingInstrumentation = fldKeepInstrumentation; vars.numChildNodes = fldNumChildNodes; @@ -312,8 +304,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startAssign(fldBci).string("0").end(); b.startAssign(fldNumChildNodes).string("0").end(); b.startAssign(fldNumBranchProfiles).string("0").end(); - b.startAssign(fldCurStack).string("0").end(); - b.startAssign(fldMaxStack).string("0").end(); if (FLAG_NODE_AST_PRINTING) { b.startAssign(fldIndent).string("0").end(); } @@ -374,7 +364,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("sourceInfo"); b.string("sources"); b.variable(fldNodeNumber); - b.variable(fldMaxStack); + b.string("createMaxStack()"); b.startGroup().string("maxLocals + 1").end(); b.string("bcCopy"); b.string("cpCopy"); @@ -393,13 +383,14 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("sourceInfo"); b.string("sources"); b.variable(fldNodeNumber); - b.variable(fldMaxStack); + b.string("createMaxStack()"); b.startGroup().string("maxLocals + 1").end(); b.string("bcCopy"); b.string("cpCopy"); b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); b.string("condProfiles"); + b.startCall("createPredecessorIndices").end(); b.end(2); if (ENABLE_INSTRUMENTATION) { @@ -427,7 +418,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mDoLeave.createBuilder(); - b.startWhile().variable(vars.curStack).string(" > data.stackDepth").end(); + b.startWhile().string("getCurStack() > data.stackDepth").end(); b.startBlock(); b.tree(m.getOperationsContext().commonPop.createEmitCode(vars, new CodeTree[0])); @@ -654,7 +645,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.variable(fldOperationData); b.variable(op.idConstantField); - b.variable(fldCurStack); + b.string("getCurStack()"); b.string("" + op.getNumAuxValues()); b.string("" + op.hasLeaveCode()); @@ -763,7 +754,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.field("this", fldOperationData); b.variable(op.idConstantField); - b.variable(fldCurStack); + b.string("getCurStack()"); b.string("" + op.getNumAuxValues()); b.string("false"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java new file mode 100644 index 000000000000..480c47a418f7 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java @@ -0,0 +1,10 @@ +package com.oracle.truffle.dsl.processor.operations; + +public class OperationsConfiguration { + + private OperationsConfiguration() { + } + + public static final boolean DO_EAGER_UNBOX = false; + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 9476ef3645f6..14f30ed99ca7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -1,7 +1,12 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.List; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; @@ -13,10 +18,12 @@ import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.SuperInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.TransferInstruction; public class OperationsContext { @@ -24,8 +31,11 @@ public class OperationsContext { private int operationId = 1; public Instruction commonPop; + public Instruction commonBranch; + public Instruction commonBranchFalse; + public Instruction commonBranchFalseBoxed; public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); @@ -37,8 +47,11 @@ public OperationsContext() { private void createCommonInstructions() { commonPop = add(new DiscardInstruction("pop", instructionId++, InputType.STACK_VALUE_IGNORED)); + commonBranch = add(new BranchInstruction(instructionId++)); - commonBranchFalse = add(new ConditionalBranchInstruction(instructionId++)); + + commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++, false)); + commonBranchFalseBoxed = add(new ConditionalBranchInstruction(this, instructionId++, true)); } private void createBuiltinOperations() { @@ -54,11 +67,14 @@ private void createBuiltinOperations() { add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new TransferInstruction("load.constant", instructionId++, ResultType.STACK_VALUE, InputType.CONST_POOL)))); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new TransferInstruction("load.argument", instructionId++, ResultType.STACK_VALUE, InputType.ARGUMENT)))); + + createLoadConstant(); + + createLoadArgument(); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); - add(new Operation.Simple(this, "Return", operationId++, 1, add(new TransferInstruction("return", instructionId++, ResultType.RETURN, InputType.STACK_VALUE)))); + createReturn(); add(new Operation.Instrumentation(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), @@ -70,12 +86,49 @@ private void createBuiltinOperations() { // iStloc})); } - public Instruction add(Instruction elem) { + private void createLoadArgument() { + LoadArgumentInstruction ldargInit = add(new LoadArgumentInstruction(instructionId++)); + LoadArgumentInstruction ldargUninit = add(new LoadArgumentInstruction(instructionId++, ldargInit)); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, ldargUninit)); + } + + private void createLoadConstant() { + LoadConstantInstruction loadObject = add(new LoadConstantInstruction(instructionId++, false, ConstantKind.OBJECT, null)); + + LoadConstantInstruction[] instrs = new LoadConstantInstruction[ConstantKind.values().length]; + LoadConstantInstruction[] instrsBoxed = new LoadConstantInstruction[ConstantKind.values().length]; + + for (ConstantKind kind : ConstantKind.values()) { + if (kind.isSingleByte()) { + instrsBoxed[kind.ordinal()] = add(new LoadConstantInstruction(instructionId++, true, kind, null)); + } else { + instrsBoxed[kind.ordinal()] = loadObject; + } + } + + for (ConstantKind kind : ConstantKind.values()) { + if (kind == ConstantKind.OBJECT) { + instrs[kind.ordinal()] = loadObject; + } else { + instrs[kind.ordinal()] = add(new LoadConstantInstruction(instructionId++, false, kind, instrsBoxed[kind.ordinal()])); + } + } + + add(new Operation.LoadConstant(this, operationId++, instrs)); + } + + private void createReturn() { + ReturnInstruction retInit = add(new ReturnInstruction(instructionId++)); + ReturnInstruction retUninit = add(new ReturnInstruction(instructionId++, retInit)); + add(new Operation.Simple(this, "Return", operationId++, 1, retUninit)); + } + + public T add(T elem) { instructions.add(elem); return elem; } - public Operation add(Operation elem) { + public T add(T elem) { operations.add(elem); return elem; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 39ff6dbdf81c..6277d41ab41e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -1,8 +1,5 @@ package com.oracle.truffle.dsl.processor.operations; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -12,7 +9,6 @@ import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; -import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; @@ -20,21 +16,16 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; -import com.oracle.truffle.dsl.processor.CodeWriter; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 7c17f8b1b9c9..72de2bc88b01 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -40,4 +40,14 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { public boolean isBranchInstruction() { return true; } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 5f6a45feffef..333ae1a277f2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -4,15 +4,23 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { - private final DeclaredType ConditionProfile = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); + private final ProcessorContext context = ProcessorContext.getInstance(); + private final DeclaredType ConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); + private final OperationsContext ctx; + private final boolean boxed; - public ConditionalBranchInstruction(int id) { - super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); + public ConditionalBranchInstruction(OperationsContext ctx, int id, boolean boxed) { + super(boxed ? "branch.false.boxed" : "branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); + this.ctx = ctx; + this.boxed = boxed; } @Override @@ -39,7 +47,24 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + 3)]"); - b.declaration("boolean", "cond", "frame.isBoolean(sp - 1) ? frame.getBoolean(sp - 1) : (boolean) frame.getObject(sp - 1)"); + + if (boxed) { + b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); + } else { + b.declaration("boolean", "cond", (CodeTree) null); + + b.startTryBlock(); + b.statement("cond = frame.getBoolean(sp - 1)"); + b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.statement("cond = (boolean) frame.getObject(sp - 1)"); + + // TODO lock + b.startStatement().startCall("doSetResultBoxed").variable(vars.bci).string("0").end(2); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField)); + b.end(); + } b.statement("sp -= 1"); b.startIf().startCall("profile", "profile").string("cond").end(2); @@ -53,4 +78,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + if (boxed) { + return null; + } + // TODO should be locked + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssert().tree(index).string(" == 0 : \"invalid input index\"").end(); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField)); + return b.build(); + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 35e86ee7147f..f7bd48a5a970 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -5,6 +5,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.type.TypeKind; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; @@ -26,6 +27,8 @@ public enum DataKind { private DataKind[] dataKinds = null; private int numChildNodes; private int numConsts; + private CodeExecutableElement setResultUnboxedMethod; + private CodeExecutableElement setInputUnboxedMethod; public SingleOperationData getData() { return data; @@ -201,4 +204,37 @@ public void setNumChildNodes(int numChildNodes) { public void setNumConsts(int numConsts) { this.numConsts = numConsts; } + + public void setSetResultUnboxedMethod(CodeExecutableElement setResultUnboxedMethod) { + this.setResultUnboxedMethod = setResultUnboxedMethod; + } + + public void setSetInputUnboxedMethod(CodeExecutableElement setInputUnboxedMethod) { + this.setInputUnboxedMethod = setInputUnboxedMethod; + } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return CodeTreeBuilder.createBuilder() // + .startStatement() // + .startCall("this", setResultUnboxedMethod) // + .variable(vars.bci) // + .end(2).build(); + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + if (data.getMainProperties().isVariadic) { + return null; + } + + return CodeTreeBuilder.createBuilder() // + .startStatement() // + .startCall("this", setInputUnboxedMethod) // + .variable(vars.bci) // + .tree(index) // + .end(2).build(); + + } + } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index d262dbedd94f..2122e2d12df9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -14,4 +14,14 @@ public DiscardInstruction(String name, int id, InputType input) { public CodeTree createExecuteCode(ExecutionVariables vars) { return null; } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 92855553f48c..37c7a3150666 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -13,10 +13,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Operation; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public abstract class Instruction { @@ -240,6 +237,7 @@ public CodeTree createDumpCode(int i, Instruction op, ExecutionVariables vars) { public final InputType[] inputs; public final ResultType[] results; + @SuppressWarnings("unused") public CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); int result = 0; @@ -414,6 +412,18 @@ public List getBuilderArgumentTypes() { public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + // calculate stack offset + int numPush = numPush(); + CodeTree numPop = numPop(vars); + + assert numPush == 1 || numPush == 0; + + b.startStatement().startCall("doBeforeEmitInstruction"); + b.variable(vars.bci); + b.tree(numPop); + b.string(numPush == 0 ? "false" : "true"); + b.end(2); + // emit opcode b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string("] = ").variable(opcodeIdField).end(); @@ -430,15 +440,6 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); - // calculate stack offset - int numPush = numPush(); - CodeTree numPop = numPop(vars); - b.startAssign(vars.curStack).variable(vars.curStack).string(" + " + numPush + " - ").tree(numPop).end(); - if (numPush > 0) { - b.startIf().variable(vars.curStack).string(" > ").variable(vars.maxStack).end(); - b.startBlock().startAssign(vars.maxStack).variable(vars.curStack).end(2); - } - return b.build(); } @@ -488,6 +489,7 @@ public int getAdditionalStateBytes() { return 0; } + @SuppressWarnings("unused") protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { return null; } @@ -519,4 +521,9 @@ public boolean isBranchInstruction() { public boolean isReturnInstruction() { return Arrays.stream(results).anyMatch(x -> x == ResultType.RETURN); } + + public abstract CodeTree createSetResultBoxed(ExecutionVariables vars); + + public abstract CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index); + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index 7d84dab2d3f3..e280a4dcb52a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -35,4 +35,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { public boolean isInstrumentationOnly() { return true; } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 8667c16ea677..30a1dbfb3c70 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -53,4 +53,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { public boolean isInstrumentationOnly() { return true; } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index dde2acbb3d74..3a1eb1839f9e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -57,4 +57,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { public boolean isInstrumentationOnly() { return true; } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java new file mode 100644 index 000000000000..edd1a117e286 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -0,0 +1,69 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; + +public class LoadArgumentInstruction extends Instruction { + + private final LoadArgumentInstruction init; + + public LoadArgumentInstruction(int id, LoadArgumentInstruction init) { + super("load.argument.uninit", id, ResultType.STACK_VALUE, InputType.ARGUMENT); + this.init = init; + } + + public LoadArgumentInstruction(int id) { + super("load.argument", id, ResultType.STACK_VALUE, InputType.ARGUMENT); + this.init = this; + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (this != init) { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.startStatement().startCall("doSetInputBoxed").variable(vars.bci).end(2); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + } + + b.startStatement().startCall(vars.frame, "setObject"); + b.variable(vars.sp); + b.startGroup(); + b.startCall(vars.frame, "getArguments").end(); + b.string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); + b.end(); + b.string("]").end(); + b.end(2); + + b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + + return b.build(); + } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + + return b.build(); + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java new file mode 100644 index 000000000000..bd65b0492823 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -0,0 +1,149 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; + +public class LoadConstantInstruction extends Instruction { + public enum ConstantKind { + BOOLEAN("boolean", "Boolean"), + BYTE("byte", "Byte"), + INT("int", "Int", "Integer"), + FLOAT("float", "Float"), + LONG("long", "Long"), + DOUBLE("double", "Double"), + OBJECT("Object", "Object"); + + private final String typeName; + private final String frameName; + private final String typeNameBoxed; + + private ConstantKind(String typeName, String frameName) { + this(typeName, frameName, frameName); + } + + private ConstantKind(String typeName, String frameName, String typeNameBoxed) { + this.typeName = typeName; + this.frameName = frameName; + this.typeNameBoxed = typeNameBoxed; + } + + public boolean isSingleByte() { + return this == BOOLEAN || this == BYTE; + } + + public boolean isBoxed() { + return this == OBJECT; + } + + public String getFrameName() { + return frameName; + } + + public String getTypeName() { + return typeName; + } + + public String getTypeNameBoxed() { + return typeNameBoxed; + } + } + + private ConstantKind kind; + private LoadConstantInstruction boxedVariant; + + public LoadConstantInstruction(int id, boolean boxed, ConstantKind kind, LoadConstantInstruction boxedVariant) { + super("load.constant." + kind.toString().toLowerCase() + (boxed ? ".boxed" : ""), id, ResultType.STACK_VALUE, new InputType[0]); + this.kind = kind; + this.boxedVariant = boxedVariant == null ? this : boxedVariant; + } + + @Override + public int getAdditionalStateBytes() { + return kind.isSingleByte() ? 1 : 2; + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (kind.isSingleByte()) { + b.startStatement(); + b.variable(vars.bc).string("[").variable(vars.bci).string(" + " + lengthWithoutState(), "] = "); + if (kind == ConstantKind.BOOLEAN) { + b.string("((boolean) "); + b.tree(arguments[0]); + b.string(") ? (byte) 1 : (byte) 0"); + } else { + b.string("(", kind.getTypeName(), ") ").tree(arguments[0]); + } + b.end(); + } else { + b.startStatement().startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + lengthWithoutState()).end(); + b.startGroup().string("(short) "); + b.startCall(vars.consts, "add"); + b.tree(arguments[0]); + b.end(4); + } + + return b.build(); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.tree(createGetArgument(vars)); + b.end(2); + + b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + + return b.build(); + + } + + private CodeTree createGetArgument(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (kind.isSingleByte()) { + b.variable(vars.bc).string("[").variable(vars.bci).string(" + " + lengthWithoutState() + "]"); + if (kind == ConstantKind.BOOLEAN) { + b.string(" != 0"); + } + } else { + if (kind != ConstantKind.OBJECT) { + b.string("(", kind.getTypeName(), ") "); + } + b.variable(vars.consts).string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + lengthWithoutState()).end(); + b.end().string("]"); + } + return b.build(); + } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + if (this == boxedVariant) { + return null; + } + + return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, boxedVariant.opcodeIdField); + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index c4b972e78b32..8684880c7c77 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -35,4 +35,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + // TODO implement local (un)boxing + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java new file mode 100644 index 000000000000..35648e00c670 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -0,0 +1,71 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; + +public class ReturnInstruction extends Instruction { + + private final ReturnInstruction init; + + public ReturnInstruction(int id, ReturnInstruction init) { + super("return.uninit", id, ResultType.RETURN, InputType.STACK_VALUE); + this.init = init; + } + + public ReturnInstruction(int id) { + super("return", id, ResultType.RETURN, InputType.STACK_VALUE); + this.init = this; + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (this != init) { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + // TODO lock + + b.startStatement().startCall("doSetResultBoxed"); + b.variable(vars.bci); + b.string("0"); + b.end(2); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + } + + b.startAssign(vars.returnValue).startCall(vars.frame, this == init ? "getObject" : "getValue"); + b.startGroup().variable(vars.sp).string(" - 1").end(); + b.end(2); + + return b.build(); + + } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + if (this == init) { + return null; + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + + return b.build(); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 2fddc88454ba..9030a6326250 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -38,4 +38,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + // TODO implement local (un)boxing + return null; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index d409e2600c90..a4f3b93a77bf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -155,4 +155,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars) { + return null; + } + + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + return null; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java deleted file mode 100644 index 662128ac65a9..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/TransferInstruction.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; - -public class TransferInstruction extends Instruction { - public TransferInstruction(String name, int id, ResultType result, InputType input) { - super(name, id, result, input); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - return CodeTreeBuilder.createBuilder().startAssign(vars.results[0]).variable(vars.inputs[0]).end().build(); - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index e45aa8301e03..b90fb09368e1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -137,7 +137,6 @@ import com.oracle.truffle.dsl.processor.model.MethodSpec; import com.oracle.truffle.dsl.processor.model.NodeChildData; import com.oracle.truffle.dsl.processor.model.NodeChildData.Cardinality; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.NodeFieldData; @@ -252,7 +251,7 @@ private NodeData parseRootType(TypeElement rootType) { } catch (CompileErrorException e) { throw e; } catch (Throwable e) { - RuntimeException e2 = new RuntimeException(String.format("Parsing of Node %s failed.", getQualifiedName(rootType))); + RuntimeException e2 = new RuntimeException(String.format("Parsing of Node %s failed", getQualifiedName(rootType))); e.addSuppressed(e2); throw e; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 293601910d26..ecb1709346b3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -19,7 +19,6 @@ import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; @@ -29,7 +28,6 @@ import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; -import com.oracle.truffle.sl.nodes.SLTypesGen; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; import com.oracle.truffle.sl.nodes.expression.SLEqualNode; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 084e41e9be73..f38001aed119 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -44,6 +44,8 @@ public class SLOperationsVisitor extends SLBaseVisitor { + private static final boolean DO_LOG_NODE_CREATION = false; + public static Map parseSL(SLLanguage language, Source source, SLOperationsBuilder builder) { return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); } @@ -148,13 +150,15 @@ public Void visitFunction(FunctionContext ctx) { OperationsNode node = b.build(); - // try { - // System.out.println("----------------------------------------------"); - // System.out.printf(" Node: %s%n", name); - // System.out.println(node.dump()); - // System.out.println("----------------------------------------------"); - // } catch (Exception ignored) { - // } + if (DO_LOG_NODE_CREATION) { + try { + System.out.println("----------------------------------------------"); + System.out.printf(" Node: %s%n", name); + System.out.println(node.dump()); + System.out.println("----------------------------------------------"); + } catch (Exception ignored) { + } + } SLOperationsRootNode rootNode = new SLOperationsRootNode(language, node, name); From 0b6bc50710efd5dc3ca4f32dffb2842ae3b3ecdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 12 Apr 2022 15:06:40 +0200 Subject: [PATCH 045/312] [wip] boxing for locals --- .../dsl/processor/generator/BitSet.java | 1 - .../dsl/processor/operations/Operation.java | 6 +- .../OperationsBytecodeCodeGenerator.java | 19 +---- .../operations/OperationsCodeGenerator.java | 1 - .../operations/OperationsContext.java | 18 ++--- .../operations/OperationsParser.java | 3 - .../operations/SingleOperationParser.java | 1 - .../ConditionalBranchInstruction.java | 2 +- .../instructions/DiscardInstruction.java | 3 - .../instructions/LoadLocalInstruction.java | 29 ++++++- .../instructions/StoreLocalInstruction.java | 77 ++++++++++++++++--- .../instructions/SuperInstruction.java | 3 - 12 files changed, 110 insertions(+), 53 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 9d84a3b1ac91..e185f206abea 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -56,7 +56,6 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 23d9f1ab027e..bc43d6615d81 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -65,22 +65,27 @@ public int minimumChildren() { public abstract List getBuilderArgumentTypes(); + @SuppressWarnings("unused") public CodeTree createBeginCode(BuilderVariables vars) { return null; } + @SuppressWarnings("unused") public CodeTree createAfterChildCode(BuilderVariables vars) { return null; } + @SuppressWarnings("unused") public CodeTree createBeforeChildCode(BuilderVariables vars) { return null; } + @SuppressWarnings("unused") public CodeTree createEndCode(BuilderVariables vars) { return null; } + @SuppressWarnings("unused") public CodeTree createLeaveCode(BuilderVariables vars) { return null; } @@ -108,7 +113,6 @@ protected Simple(OperationsContext builder, String name, int id, int children, I public CodeTree createEndCode(BuilderVariables vars) { CodeTree[] arguments = new CodeTree[instruction.inputs.length + instruction.results.length]; - List mirs = getBuilderArgumentTypes(); for (int i = 0; i < arguments.length; i++) { arguments[i] = CodeTreeBuilder.createBuilder().string("operationData.arguments[" + i + "]").build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 9914b2b91da5..48d672145a84 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -1,7 +1,6 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,7 +19,6 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; -import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -29,7 +27,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; @@ -39,12 +36,8 @@ public class OperationsBytecodeCodeGenerator { - private final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); - private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); - private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); final static Object MARKER_CHILD = new Object(); @@ -155,8 +148,6 @@ public CodeTypeElement createBuilderBytecodeNode() { final List childIndices = new ArrayList<>(); final List constIndices = new ArrayList<>(); - int numStackValues = isVariadic ? 0 : cinstr.numPopStatic(); - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( fldBc, fldChildren, constIndices, innerTypeNames, additionalData, @@ -831,7 +822,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTreeBuilder b = mGetSourceSection.createBuilder(); - b.tree(createReparseCheck(typBuilderImpl)); + b.tree(createReparseCheck()); b.startReturn(); b.startCall("this", "getSourceSectionImpl"); @@ -845,7 +836,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTreeBuilder b = mGetSourceSectionAtBci.createBuilder(); - b.tree(createReparseCheck(typBuilderImpl)); + b.tree(createReparseCheck()); b.startReturn(); b.startCall("this", "getSourceSectionAtBciImpl"); @@ -908,7 +899,7 @@ private CodeTree createInputCode(ExecutionVariables vars, Instruction instr, int } } - private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { + private CodeTree createReparseCheck() { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().string("sourceInfo == null").end(); b.startBlock(); @@ -928,10 +919,6 @@ private CodeTree createReparseCheck(CodeTypeElement typBuilderImpl) { return b.build(); } - private static TypeMirror generic(TypeElement el, TypeMirror... params) { - return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); - } - private static TypeMirror arrayOf(TypeMirror el) { return new ArrayCodeTypeMirror(el); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 0e4a855548ee..081c495779e2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.Stack; import java.util.function.Supplier; import javax.lang.model.element.Modifier; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 14f30ed99ca7..96ffa7bae66f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -1,12 +1,7 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; -import java.util.List; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; @@ -14,7 +9,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; @@ -71,9 +65,7 @@ private void createBuiltinOperations() { createLoadConstant(); createLoadArgument(); - - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); + createLoadStoreLocal(); createReturn(); add(new Operation.Instrumentation(this, operationId++, @@ -86,6 +78,14 @@ private void createBuiltinOperations() { // iStloc})); } + private void createLoadStoreLocal() { + StoreLocalInstruction slInit = add(new StoreLocalInstruction(instructionId++)); + StoreLocalInstruction slUninit = add(new StoreLocalInstruction(instructionId++, slInit)); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, slUninit)); + + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); + } + private void createLoadArgument() { LoadArgumentInstruction ldargInit = add(new LoadArgumentInstruction(instructionId++)); LoadArgumentInstruction ldargUninit = add(new LoadArgumentInstruction(instructionId++, ldargInit)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index ddb69b62a41d..b0b730c27347 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -13,9 +13,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedElement; -import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 6277d41ab41e..5c4a7505f8f0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -35,7 +35,6 @@ public class SingleOperationParser extends AbstractParser { private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); - private static final Set MOD_STATIC_FINAL = Set.of(Modifier.STATIC, Modifier.FINAL); private final OperationsData parentData; private TypeElement proxyType; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 333ae1a277f2..3b0795e98f3c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -24,7 +24,7 @@ public ConditionalBranchInstruction(OperationsContext ctx, int id, boolean boxed } @Override - public TypeMirror[] expectedInputTypes(ProcessorContext context) { + public TypeMirror[] expectedInputTypes(ProcessorContext c) { return new TypeMirror[]{ context.getType(short.class), context.getType(boolean.class), diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 2122e2d12df9..37f499f0617b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -1,9 +1,6 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; public class DiscardInstruction extends Instruction { public DiscardInstruction(String name, int id, InputType input) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 8684880c7c77..a87bd6d0a701 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -1,12 +1,22 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class LoadLocalInstruction extends Instruction { + private final LoadLocalInstruction init; + public LoadLocalInstruction(int id) { super("load.local", id, ResultType.STACK_VALUE, InputType.LOCAL); + this.init = this; + } + + public LoadLocalInstruction(int id, LoadLocalInstruction init) { + super("load.local.uninit", id, ResultType.STACK_VALUE, InputType.LOCAL); + this.init = init; } @Override @@ -18,6 +28,18 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (this != init) { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + // TODO lock + + b.startStatement().startCall("doSetInputBoxed"); + b.variable(vars.bci); + b.end(2); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + } + b.startStatement().startCall(vars.frame, "copy"); b.startGroup(); @@ -37,8 +59,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createSetResultBoxed(ExecutionVariables vars) { - // TODO implement local (un)boxing - return null; + if (this == init) { + return null; + } else { + return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField); + } } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 9030a6326250..113adac3f476 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -1,12 +1,22 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class StoreLocalInstruction extends Instruction { + private final StoreLocalInstruction init; + + public StoreLocalInstruction(int id, StoreLocalInstruction init) { + super("store.local.uninit", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + this.init = init; + } + public StoreLocalInstruction(int id) { super("store.local", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + this.init = this; } @Override @@ -17,25 +27,60 @@ public boolean standardPrologue() { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startCall(vars.frame, "copy"); - b.startGroup().variable(vars.sp).string(" - 1").end(); + if (this != init) { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startGroup(); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + 1").end(); - b.end(); - b.string(" + VALUES_OFFSET"); - b.end(); + // TODO lock - b.end(2); + b.startStatement().startCall("doSetResultBoxed"); + b.variable(vars.bci); + b.string("0"); + b.end(2); + + b.startStatement().startCall(vars.frame, "setObject"); + + b.startGroup(); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + 1").end(); + b.end(); + b.string(" + VALUES_OFFSET"); + b.end(); + + b.startCall(vars.frame, "getValue"); + b.startGroup().variable(vars.sp).string(" - 1").end(); + b.end(); + + b.end(2); + + } else { + + b.startAssert().startCall(vars.frame, "isObject"); + b.startGroup().variable(vars.sp).string(" - 1").end(); + b.end(2); + + b.startStatement().startCall(vars.frame, "copy"); + + b.startGroup().variable(vars.sp).string(" - 1").end(); + + b.startGroup(); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + 1").end(); + b.end(); + b.string(" + VALUES_OFFSET"); + b.end(); + + b.end(2); + } b.startStatement().startCall(vars.frame, "clear"); b.startGroup().string("--").variable(vars.sp).end(); b.end(2); return b.build(); + } @Override @@ -45,7 +90,15 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { @Override public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { - // TODO implement local (un)boxing - return null; + if (this == init) { + return null; + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + + return b.build(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index a4f3b93a77bf..7d92ebd3b7c7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,9 +7,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; public class SuperInstruction extends Instruction { private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { From 6c1fc245bf80e9f33eb78f7fd1dfd0487227d40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 12 Apr 2022 15:43:22 +0200 Subject: [PATCH 046/312] [wip] 2 byte opcodes --- .../operations/OperationGeneratorUtils.java | 13 +++++++++++-- .../operations/OperationsBytecodeCodeGenerator.java | 8 ++++---- .../dsl/processor/operations/OperationsContext.java | 3 +-- .../instructions/ConditionalBranchInstruction.java | 4 ++-- .../operations/instructions/Instruction.java | 5 +++-- .../instructions/LoadLocalInstruction.java | 2 +- .../instructions/StoreLocalInstruction.java | 4 ++-- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 84070fd47724..00e3b7d39932 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -5,12 +5,14 @@ import java.io.Writer; import javax.lang.model.element.Element; +import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; @@ -52,7 +54,9 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen } public static CodeTree createReadOpcode(CodeTree bc, CodeTree bci) { - return CodeTreeBuilder.createBuilder().tree(bc).string("[").tree(bci).string("]").build(); + return CodeTreeBuilder.createBuilder()// + .startCall("LE_BYTES", "getShort")// + .tree(bc).tree(bci).end(1).build(); } public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElement bci) { @@ -62,7 +66,12 @@ public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElem } public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement().tree(bc).string("[").tree(bci).string("] = ").tree(value).end().build(); + return CodeTreeBuilder.createBuilder().startStatement()// + .startCall("LE_BYTES", "putShort")// + .tree(bc) // + .tree(bci) // + .startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).tree(value).end() // + .end(2).build(); } public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 48d672145a84..309db72277b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -319,7 +319,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(byte.class), "curOpcode"); + CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); b.declaration("int", varBci.getName(), "0"); @@ -343,7 +343,7 @@ public CodeTypeElement createBuilderBytecodeNode() { vars.sp = varSp; vars.returnValue = varReturnValue; - b.declaration("byte", varCurOpcode.getName(), CodeTreeBuilder.singleString("bc[bci]")); + b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(fldBc, varBci)); b.startTryBlock(); @@ -557,7 +557,7 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); b.startBlock(); - b.startSwitch().string("bc[bci]").end(); + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); b.startBlock(); for (Instruction instr : m.getInstructions()) { @@ -678,7 +678,7 @@ public CodeTypeElement createBuilderBytecodeNode() { b.statement("sb.append(String.format(\" %04x \", bci))"); - b.startSwitch().string("bc[bci]").end(); + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); b.startBlock(); for (Instruction op : m.getInstructions()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 96ffa7bae66f..b608f159be9c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -21,7 +21,7 @@ public class OperationsContext { - private int instructionId = 1; + private int instructionId = 257; private int operationId = 1; public Instruction commonPop; @@ -63,7 +63,6 @@ private void createBuiltinOperations() { add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); createLoadConstant(); - createLoadArgument(); createLoadStoreLocal(); createReturn(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 3b0795e98f3c..ee19b365fa00 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -46,7 +46,7 @@ public boolean isBranchInstruction() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + 3)]"); + b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(1) + ")]"); if (boxed) { b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); @@ -72,7 +72,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); b.statement("continue loop"); b.end().startElseBlock(); - b.startAssign(vars.bci).string("LE_BYTES.getShort(bc, bci + 1)").end(); + b.startAssign(vars.bci).string("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")").end(); b.statement("continue loop"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 37c7a3150666..1858fdff9469 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -13,6 +13,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public abstract class Instruction { @@ -350,7 +351,7 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code } public int opcodeLength() { - return 1; + return 2; } public int getArgumentOffset(int index) { @@ -425,7 +426,7 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { b.end(2); // emit opcode - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string("] = ").variable(opcodeIdField).end(); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, opcodeIdField)); // emit arguments int argIndex = 0; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index a87bd6d0a701..17b2152e287b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -45,7 +45,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup(); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + 1").end(); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); b.end(); b.string(" + VALUES_OFFSET"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 113adac3f476..b5549272e86b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -43,7 +43,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup(); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + 1").end(); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); b.end(); b.string(" + VALUES_OFFSET"); b.end(); @@ -67,7 +67,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup(); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + 1").end(); + b.startGroup().variable(vars.bci).string(" + " + opcodeLength()).end(); b.end(); b.string(" + VALUES_OFFSET"); b.end(); From 786e085f94c9000d4aeba9a35639d6a135d69009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 12 Apr 2022 18:56:40 +0200 Subject: [PATCH 047/312] [wip] eagerly initialize boxability --- .../example/TestOperationsParserTest.java | 1 + .../api/operation/OperationsBuilder.java | 49 ++++++++-- .../dsl/processor/operations/Operation.java | 8 ++ .../operations/OperationGeneratorUtils.java | 29 ++++++ .../OperationsBytecodeCodeGenerator.java | 1 + .../OperationsBytecodeNodeGeneratorPlugs.java | 2 +- .../operations/OperationsCodeGenerator.java | 88 +++++++++++++++++- .../operations/OperationsContext.java | 11 +-- .../instructions/BranchInstruction.java | 2 +- .../ConditionalBranchInstruction.java | 14 +-- .../instructions/CustomInstruction.java | 15 +++ .../instructions/DiscardInstruction.java | 2 +- .../operations/instructions/Instruction.java | 93 ++++++++++++++++++- .../InstrumentationEnterInstruction.java | 2 +- .../InstrumentationExitInstruction.java | 2 +- .../InstrumentationLeaveInstruction.java | 2 +- .../instructions/LoadArgumentInstruction.java | 29 ++---- .../instructions/LoadConstantInstruction.java | 2 +- .../instructions/LoadLocalInstruction.java | 33 ++----- .../instructions/ReturnInstruction.java | 40 ++------ .../instructions/StoreLocalInstruction.java | 81 ++++------------ .../instructions/SuperInstruction.java | 2 +- 22 files changed, 332 insertions(+), 176 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index a0cfff990d13..a44be928e584 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -53,6 +53,7 @@ public Tester then(Consumer action) { private static RootCallTarget parse(Consumer builder) { OperationsNode operationsNode = TestOperationsBuilder.parse(null, builder)[0]; + System.out.println(operationsNode.dump()); return operationsNode.createRootNode(null, "TestFunction").getCallTarget(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index ffee51a562ee..e73bd17591e5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -156,16 +156,45 @@ protected void doEmitLabel(int bci, OperationLabel label) { private int instructionIndex; private int[] stackSourceIndices = new int[1024]; + private int[] stackSourceBci = new int[1024]; + private boolean[] stackAlwaysBoxed = new boolean[1024]; private int curStack; private int maxStack; - private short[] predecessorIndices = new short[65535]; + private short[] successorIndices = new short[65535]; + + protected void doMarkAlwaysBoxedInput(int numPops, int inputIndex) { + int offset = curStack - numPops + inputIndex; + if (stackAlwaysBoxed[offset]) { + // clear it, so that if two 'always boxed' operations are connected + // we don't do anything + stackAlwaysBoxed[offset] = false; + } else { + int bci = stackSourceBci[offset]; + markAlwaysBoxedResult(bci); + } + } + + protected abstract void markAlwaysBoxedResult(int bci); + + protected abstract void markAlwaysBoxedInput(int bci, int index); + + protected boolean[] doBeforeEmitInstruction(int bci, int numPops, boolean pushValue, boolean resultAlwaysBoxed) { + boolean[] result = null; - protected void doBeforeEmitInstruction(int bci, int numPops, boolean pushValue) { for (int i = numPops - 1; i >= 0; i--) { - int predIndex = stackSourceIndices[--curStack]; - predecessorIndices[predIndex] = (short) bci; - predecessorIndices[predIndex + 1] = (short) i; + curStack--; + + int predIndex = stackSourceIndices[curStack]; + + if (stackAlwaysBoxed[curStack]) { + if (result == null) { + result = new boolean[numPops]; + } + result[i] = true; + } + successorIndices[predIndex] = (short) bci; + successorIndices[predIndex + 1] = (short) i; } // TODO: we could only record instrs that produce values @@ -174,16 +203,22 @@ protected void doBeforeEmitInstruction(int bci, int numPops, boolean pushValue) int index = instructionIndex; instructionIndex += 2; - stackSourceIndices[curStack++] = index; + stackSourceBci[curStack] = bci; + stackAlwaysBoxed[curStack] = resultAlwaysBoxed; + stackSourceIndices[curStack] = index; + + curStack++; if (curStack > maxStack) { maxStack = curStack; } } + + return result; } protected short[] createPredecessorIndices() { - return Arrays.copyOf(predecessorIndices, instructionIndex); + return Arrays.copyOf(successorIndices, instructionIndex); } protected int createMaxStack() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index bc43d6615d81..f689318f5661 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -16,6 +16,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction.ConstantKind; @@ -56,6 +57,13 @@ public static class BuilderVariables { public CodeVariableElement numChildren; public CodeVariableElement keepingInstrumentation; public CodeVariableElement numChildNodes; + + public ExecutionVariables asExecution() { + ExecutionVariables result = new ExecutionVariables(); + result.bc = this.bc; + result.bci = this.bci; + return result; + } } public int minimumChildren() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 00e3b7d39932..a357ec7413c5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.util.function.Function; import javax.lang.model.element.Element; import javax.lang.model.type.TypeKind; @@ -17,6 +18,7 @@ import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class OperationGeneratorUtils { @@ -98,4 +100,31 @@ protected Writer createWriter(CodeTypeElement clazz) throws IOException { return wr.toString(); } + public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVariables vars, Function body) { + return createInstructionSwitch(data, vars, true, body); + } + + public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVariables vars, boolean instrumentation, Function body) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).end().startBlock(); + for (Instruction instr : data.getInstructions()) { + if (instr.isInstrumentationOnly() && !instrumentation) { + continue; + } + + CodeTree result = body.apply(instr); + if (result != null) { + b.startCase().variable(instr.opcodeIdField).end().startBlock(); + b.tree(result); + b.statement("break"); + b.end(); + } + + } + b.end(); + + return b.build(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 309db72277b4..da4880e93f98 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -154,6 +154,7 @@ public CodeTypeElement createBuilderBytecodeNode() { methodNames, isVariadic, soData, additionalDataKinds, fldConsts, cinstr, childIndices); + cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 61171d233830..2ea1318fbd64 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -33,7 +33,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; -final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { +public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final CodeVariableElement fldBc; private final CodeVariableElement fldChildren; private final List constIndices; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 081c495779e2..4c0dc8fb3640 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -24,7 +24,9 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -38,6 +40,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private OperationsBytecodeCodeGenerator bytecodeGenerator; private static final boolean FLAG_NODE_AST_PRINTING = false; private static final boolean ENABLE_INSTRUMENTATION = false; @@ -196,8 +199,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); - builderBytecodeNodeType = bcg.createBuilderBytecodeNode(); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); + builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } if (ENABLE_INSTRUMENTATION) { @@ -592,6 +595,87 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(mAfterChild); } + { + CodeExecutableElement mMarkAlwaysBoxedResult = GeneratorUtils.overrideImplement(types.OperationsBuilder, "markAlwaysBoxedResult"); + typBuilderImpl.add(mMarkAlwaysBoxedResult); + + ExecutionVariables exVars = new ExecutionVariables(); + exVars.bc = fldBc; + exVars.bci = (CodeVariableElement) mMarkAlwaysBoxedResult.getParameters().get(0); + + CodeTreeBuilder b = mMarkAlwaysBoxedResult.appendBuilder(); + + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, exVars, instr -> instr.createSetResultBoxed(exVars))); + } + + { + CodeExecutableElement mMarkAlwaysBoxedInput = GeneratorUtils.overrideImplement(types.OperationsBuilder, "markAlwaysBoxedInput"); + typBuilderImpl.add(mMarkAlwaysBoxedInput); + + ExecutionVariables exVars = new ExecutionVariables(); + exVars.bc = fldBc; + exVars.bci = (CodeVariableElement) mMarkAlwaysBoxedInput.getParameters().get(0); + + VariableElement varIndex = mMarkAlwaysBoxedInput.getParameters().get(1); + + CodeTreeBuilder b = mMarkAlwaysBoxedInput.appendBuilder(); + + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, exVars, instr -> instr.createSetInputBoxed(exVars, CodeTreeBuilder.singleVariable(varIndex)))); + + } + + // The following is copy-pasted from OperationsBytecodeCodeGenerator + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + continue; + } + + CustomInstruction cinstr = (CustomInstruction) instr; + SingleOperationData soData = cinstr.getData(); + + { + CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( + Set.of(Modifier.PRIVATE), + context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", + new CodeVariableElement(context.getType(int.class), "$bci")); + typBuilderImpl.add(metSetResultUnboxed); + cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + + CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); + b.tree(cinstr.getPlugs().createSetResultBoxed()); + } + + if (!cinstr.getData().getMainProperties().isVariadic) { + CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( + Set.of(Modifier.PRIVATE), + context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", + new CodeVariableElement(context.getType(int.class), "$bci"), + new CodeVariableElement(context.getType(int.class), "index")); + typBuilderImpl.add(metSetInputUnboxed); + cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); + + CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); + + if (cinstr.numPopStatic() == 0) { + b.startAssert().string("false : \"operation has no input\"").end(); + } else if (cinstr.numPopStatic() == 1) { + b.startAssert().string("index == 0 : \"operation has only one input\"").end(); + b.tree(cinstr.getPlugs().createSetInputBoxed(0)); + } else { + b.startSwitch().string("index").end().startBlock(); + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.startCase().string("" + i).end().startCaseBlock(); + b.tree(cinstr.getPlugs().createSetInputBoxed(i)); + b.statement("break"); + b.end(); + } + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); + b.end(2); + } + } + } + for (Operation op : m.getOperations()) { List args = op.getBuilderArgumentTypes(); CodeVariableElement[] params = new CodeVariableElement[args.size()]; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index b608f159be9c..6375ce3bff8b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -21,7 +21,7 @@ public class OperationsContext { - private int instructionId = 257; + private int instructionId = 1; private int operationId = 1; public Instruction commonPop; @@ -79,16 +79,14 @@ private void createBuiltinOperations() { private void createLoadStoreLocal() { StoreLocalInstruction slInit = add(new StoreLocalInstruction(instructionId++)); - StoreLocalInstruction slUninit = add(new StoreLocalInstruction(instructionId++, slInit)); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, slUninit)); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, slInit)); add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); } private void createLoadArgument() { LoadArgumentInstruction ldargInit = add(new LoadArgumentInstruction(instructionId++)); - LoadArgumentInstruction ldargUninit = add(new LoadArgumentInstruction(instructionId++, ldargInit)); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, ldargUninit)); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, ldargInit)); } private void createLoadConstant() { @@ -118,8 +116,7 @@ private void createLoadConstant() { private void createReturn() { ReturnInstruction retInit = add(new ReturnInstruction(instructionId++)); - ReturnInstruction retUninit = add(new ReturnInstruction(instructionId++, retInit)); - add(new Operation.Simple(this, "Return", operationId++, 1, retUninit)); + add(new Operation.Simple(this, "Return", operationId++, 1, retInit)); } public T add(T elem) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 72de2bc88b01..602e17b229f8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -47,7 +47,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index ee19b365fa00..f0af1bbad40a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -85,14 +85,16 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { if (boxed) { return null; } - // TODO should be locked - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssert().tree(index).string(" == 0 : \"invalid input index\"").end(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField)); - return b.build(); + + return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField); + } + + @Override + public boolean isInputAlwaysBoxed(int index) { + return boxed; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index f7bd48a5a970..06a42e31f1ec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -10,6 +10,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -29,6 +30,7 @@ public enum DataKind { private int numConsts; private CodeExecutableElement setResultUnboxedMethod; private CodeExecutableElement setInputUnboxedMethod; + private OperationsBytecodeNodeGeneratorPlugs plugs; public SingleOperationData getData() { return data; @@ -237,4 +239,17 @@ public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { } + @Override + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + return createSetInputBoxed(vars, CodeTreeBuilder.singleString("" + index)); + } + + public OperationsBytecodeNodeGeneratorPlugs getPlugs() { + return plugs; + } + + public void setPlugs(OperationsBytecodeNodeGeneratorPlugs plugs) { + this.plugs = plugs; + } + } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 37f499f0617b..3ac120dd5868 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -18,7 +18,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 1858fdff9469..d0ae355ffd97 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -410,6 +410,10 @@ public List getBuilderArgumentTypes() { return result; } + protected boolean resultIsAlwaysBoxed() { + return false; + } + public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -419,12 +423,51 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { assert numPush == 1 || numPush == 0; - b.startStatement().startCall("doBeforeEmitInstruction"); + if (isVariadic()) { + // variadic instructions always box everything + b.startFor().string("int inputIndex = 0; inputIndex < ").tree(numPop).string("; inputIndex++").end().startBlock(); + b.startStatement().startCall("doMarkAlwaysBoxedInput"); + b.tree(numPop); + b.string("inputIndex"); + b.end(2); + b.end(); + } else { + int numPopStatic = numPopStatic(); + for (int i = 0; i < numPopStatic; i++) { + if (isInputAlwaysBoxed(i)) { + b.startStatement().startCall("doMarkAlwaysBoxedInput"); + b.tree(numPop); + b.string("" + i); + b.end(2); + } + } + } + + if (isVariadic() || numPopStatic() == 0) { + b.startStatement(); + } else { + b.startAssign("boolean[] inputsAlwaysBoxed"); + } + + b.startCall("doBeforeEmitInstruction"); b.variable(vars.bci); b.tree(numPop); b.string(numPush == 0 ? "false" : "true"); + b.string("" + resultIsAlwaysBoxed()); b.end(2); + if (!isVariadic() && numPopStatic() > 0) { + b.startIf().string("inputsAlwaysBoxed != null").end().startBlock(); + { + for (int i = 0; i < numPopStatic(); i++) { + b.startIf().string("inputsAlwaysBoxed[" + i + "]").end().startBlock(); + b.tree(createSetInputBoxed(vars.asExecution(), i)); + b.end(); + } + } + b.end(); + } + // emit opcode b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, opcodeIdField)); @@ -454,6 +497,16 @@ public int numPush() { return stackPush; } + public boolean isVariadic() { + for (InputType i : inputs) { + if (i == InputType.VARARG_VALUE) { + return true; + } + } + + return false; + } + public int numPopStatic() { int stackPop = 0; for (InputType i : inputs) { @@ -525,6 +578,42 @@ public boolean isReturnInstruction() { public abstract CodeTree createSetResultBoxed(ExecutionVariables vars); - public abstract CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index); + public abstract CodeTree createSetInputBoxed(ExecutionVariables vars, int index); + + public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (numPopStatic() == 0) { + b.startAssert().string("false : \"invalid index\"").end(); + return b.build(); + } + + if (numPopStatic() == 1) { + b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); + b.tree(createSetInputBoxed(vars, 0)); + return b.build(); + } + + b.startSwitch().tree(index).end().startBlock(); + for (int i = 0; i < numPopStatic(); i++) { + b.startCase().string("" + i).startCaseBlock(); + b.tree(createSetInputBoxed(vars, index)); + b.statement("break"); + b.end(); + } + b.caseDefault().startCaseBlock(); + b.startAssert().string("false : \"invalid index\"").end(); + b.end(); + b.end(); + + return b.build(); + } + + public boolean isInputAlwaysBoxed(int index) { + return false; + } + + public boolean isResultAlwaysBoxed() { + return false; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index e280a4dcb52a..53a4fab80e74 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -42,7 +42,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 30a1dbfb3c70..363f386917df 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -60,7 +60,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index 3a1eb1839f9e..2aa8ce6b97b9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -64,7 +64,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index edd1a117e286..6e1ce2cf442b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -1,22 +1,12 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class LoadArgumentInstruction extends Instruction { - private final LoadArgumentInstruction init; - - public LoadArgumentInstruction(int id, LoadArgumentInstruction init) { - super("load.argument.uninit", id, ResultType.STACK_VALUE, InputType.ARGUMENT); - this.init = init; - } - public LoadArgumentInstruction(int id) { super("load.argument", id, ResultType.STACK_VALUE, InputType.ARGUMENT); - this.init = this; } @Override @@ -28,13 +18,6 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (this != init) { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.startStatement().startCall("doSetInputBoxed").variable(vars.bci).end(2); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); - } - b.startStatement().startCall(vars.frame, "setObject"); b.variable(vars.sp); b.startGroup(); @@ -54,16 +37,16 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createSetResultBoxed(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); - - return b.build(); + return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } + @Override + public boolean isResultAlwaysBoxed() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index bd65b0492823..fddb6c016331 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -143,7 +143,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 17b2152e287b..433fda284117 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -7,16 +7,8 @@ public class LoadLocalInstruction extends Instruction { - private final LoadLocalInstruction init; - public LoadLocalInstruction(int id) { super("load.local", id, ResultType.STACK_VALUE, InputType.LOCAL); - this.init = this; - } - - public LoadLocalInstruction(int id, LoadLocalInstruction init) { - super("load.local.uninit", id, ResultType.STACK_VALUE, InputType.LOCAL); - this.init = init; } @Override @@ -28,18 +20,6 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (this != init) { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - // TODO lock - - b.startStatement().startCall("doSetInputBoxed"); - b.variable(vars.bci); - b.end(2); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); - } - b.startStatement().startCall(vars.frame, "copy"); b.startGroup(); @@ -59,15 +39,16 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createSetResultBoxed(ExecutionVariables vars) { - if (this == init) { - return null; - } else { - return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField); - } + return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } + + @Override + public boolean isResultAlwaysBoxed() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 35648e00c670..10c344e2cf6d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -1,22 +1,13 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class ReturnInstruction extends Instruction { - private final ReturnInstruction init; - - public ReturnInstruction(int id, ReturnInstruction init) { - super("return.uninit", id, ResultType.RETURN, InputType.STACK_VALUE); - this.init = init; - } - public ReturnInstruction(int id) { super("return", id, ResultType.RETURN, InputType.STACK_VALUE); - this.init = this; } @Override @@ -28,20 +19,7 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (this != init) { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - // TODO lock - - b.startStatement().startCall("doSetResultBoxed"); - b.variable(vars.bci); - b.string("0"); - b.end(2); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); - } - - b.startAssign(vars.returnValue).startCall(vars.frame, this == init ? "getObject" : "getValue"); + b.startAssign(vars.returnValue).startCall(vars.frame, "getObject"); b.startGroup().variable(vars.sp).string(" - 1").end(); b.end(2); @@ -55,17 +33,13 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { - if (this == init) { - return null; - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + return null; + } - return b.build(); + @Override + public boolean isInputAlwaysBoxed(int index) { + return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index b5549272e86b..92e1680706fc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -1,22 +1,12 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class StoreLocalInstruction extends Instruction { - private final StoreLocalInstruction init; - - public StoreLocalInstruction(int id, StoreLocalInstruction init) { - super("store.local.uninit", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); - this.init = init; - } - public StoreLocalInstruction(int id) { super("store.local", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); - this.init = this; } @Override @@ -28,52 +18,23 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (this != init) { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - // TODO lock - - b.startStatement().startCall("doSetResultBoxed"); - b.variable(vars.bci); - b.string("0"); - b.end(2); - - b.startStatement().startCall(vars.frame, "setObject"); - - b.startGroup(); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); - b.end(); - b.string(" + VALUES_OFFSET"); - b.end(); - - b.startCall(vars.frame, "getValue"); - b.startGroup().variable(vars.sp).string(" - 1").end(); - b.end(); - - b.end(2); - - } else { - - b.startAssert().startCall(vars.frame, "isObject"); - b.startGroup().variable(vars.sp).string(" - 1").end(); - b.end(2); + b.startAssert().startCall(vars.frame, "isObject"); + b.startGroup().variable(vars.sp).string(" - 1").end(); + b.end(2); - b.startStatement().startCall(vars.frame, "copy"); + b.startStatement().startCall(vars.frame, "copy"); - b.startGroup().variable(vars.sp).string(" - 1").end(); + b.startGroup().variable(vars.sp).string(" - 1").end(); - b.startGroup(); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + opcodeLength()).end(); - b.end(); - b.string(" + VALUES_OFFSET"); - b.end(); + b.startGroup(); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + opcodeLength()).end(); + b.end(); + b.string(" + VALUES_OFFSET"); + b.end(); - b.end(2); - } + b.end(2); b.startStatement().startCall(vars.frame, "clear"); b.startGroup().string("--").variable(vars.sp).end(); @@ -89,16 +50,12 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { - if (this == init) { - return null; - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, init.opcodeIdField)); + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + return null; + } - return b.build(); + @Override + public boolean isInputAlwaysBoxed(int index) { + return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 7d92ebd3b7c7..2e0a5b7241c0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -159,7 +159,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars) { } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { + public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { return null; } } \ No newline at end of file From e859778123574dd0bb34dca4aa68f92408c20eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 14 Apr 2022 10:50:21 +0200 Subject: [PATCH 048/312] [wip] cleanup --- .../api/operation/OperationsBuilder.java | 14 +- .../OperationsInstrumentableNode.java | 3 - .../operation/tracing/ExecutionTracer.java | 6 +- .../operations/OperationGeneratorUtils.java | 27 +++ .../OperationsBytecodeCodeGenerator.java | 171 +------------- .../OperationsBytecodeNodeGeneratorPlugs.java | 105 ++++++--- .../operations/OperationsCodeGenerator.java | 222 ++++++++++++++---- .../ConditionalBranchInstruction.java | 1 - .../instructions/CustomInstruction.java | 6 +- .../operations/instructions/Instruction.java | 3 +- .../instructions/LoadLocalInstruction.java | 2 - .../instructions/ReturnInstruction.java | 1 - .../sl/nodes/expression/SLDivNode.java | 1 - .../nodes/expression/SLLessOrEqualNode.java | 1 - .../sl/nodes/expression/SLLessThanNode.java | 1 - .../sl/nodes/expression/SLLogicalNotNode.java | 1 - .../sl/nodes/expression/SLMulNode.java | 1 - .../sl/nodes/expression/SLSubNode.java | 1 - 18 files changed, 301 insertions(+), 266 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index e73bd17591e5..df75d4c057f1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -116,16 +116,9 @@ protected final void calculateLeaves(BuilderOperationData fromData, BuilderOpera } } - /** - * Emits offset at current bci - * - * @param bci - * @param instr - * @param label - * @return length of the offset - */ + @SuppressWarnings("unused") protected final int doBranchInstruction(int bci, int instr, OperationLabel label) { - createOffset(bci, (BuilderOperationLabel) label); + createOffset(bci, label); return 2; } @@ -207,6 +200,9 @@ protected boolean[] doBeforeEmitInstruction(int bci, int numPops, boolean pushVa stackAlwaysBoxed[curStack] = resultAlwaysBoxed; stackSourceIndices[curStack] = index; + successorIndices[index] = -1; + successorIndices[index + 1] = -1; + curStack++; if (curStack > maxStack) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java index 8efa3cae641e..377a93daa63b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java @@ -1,9 +1,6 @@ package com.oracle.truffle.api.operation; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; public abstract class OperationsInstrumentableNode extends OperationsNode { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index ae45c6ed191a..1d58618dbdde 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,7 +1,6 @@ package com.oracle.truffle.api.operation.tracing; import java.util.HashMap; -import java.util.List; import java.util.Map; import com.oracle.truffle.api.operation.OperationsNode; @@ -89,6 +88,7 @@ private final void resetLast() { } } + @SuppressWarnings("unused") public final void startFunction(OperationsNode node) { resetLast(); } @@ -97,6 +97,7 @@ public final void endFunction() { resetLast(); } + @SuppressWarnings("unused") public final void traceInstruction(int bci, int id, Object... arguments) { // System.out.printf(" [TT] %04x %d %s\n", bci, id, List.of(a, arguments)); for (int i = 0; i < last.length; i++) { @@ -109,14 +110,17 @@ public final void traceInstruction(int bci, int id, Object... arguments) { } } + @SuppressWarnings({"unused", "static-method"}) public final Object tracePop(Object value) { return value; } + @SuppressWarnings({"unused", "static-method"}) public final Object tracePush(Object value) { return value; } + @SuppressWarnings("unused") public final void traceException(Throwable ex) { } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index a357ec7413c5..58e6201e0813 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -127,4 +127,31 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar return b.build(); } + public static CodeTree callSetResultBoxed(String bci, Integer... referenceArguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().startCall("doSetResultBoxed"); + b.string("bc"); + b.string("successorIndices"); + b.string(bci); + for (int arg : referenceArguments) { + b.string("" + arg); + } + b.end(2); + + return b.build(); + } + + public static CodeTree callSetInputBoxed(String bci) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().startCall("doSetInputBoxed"); + b.string("bc"); + b.string("successorIndices"); + b.string(bci); + b.end(2); + + return b.build(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index da4880e93f98..264faf96f6f9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -36,7 +36,6 @@ public class OperationsBytecodeCodeGenerator { - private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); @@ -55,8 +54,10 @@ public class OperationsBytecodeCodeGenerator { private final String simpleName; private final OperationsData m; private final boolean withInstrumentation; + private final OperationsCodeGenerator parent; - public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { + public OperationsBytecodeCodeGenerator(OperationsCodeGenerator parent, CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { + this.parent = parent; this.typBuilderImpl = typBuilderImpl; this.simpleName = simpleName; this.m = m; @@ -247,52 +248,12 @@ public CodeTypeElement createBuilderBytecodeNode() { cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); cinstr.setNumChildNodes(childIndices.size()); cinstr.setNumConsts(constIndices.size()); - - { - CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( - Set.of(Modifier.PRIVATE), - context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", - new CodeVariableElement(context.getType(int.class), "$bci")); - builderBytecodeNodeType.add(metSetResultUnboxed); - cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); - - CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); - b.tree(plugs.createSetResultBoxed()); - } - - if (!isVariadic) { - CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( - Set.of(Modifier.PRIVATE), - context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", - new CodeVariableElement(context.getType(int.class), "$bci"), - new CodeVariableElement(context.getType(int.class), "index")); - builderBytecodeNodeType.add(metSetInputUnboxed); - cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); - - CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); - - if (cinstr.numPopStatic() == 0) { - b.startAssert().string("false : \"operation has no input\"").end(); - } else if (cinstr.numPopStatic() == 1) { - b.startAssert().string("index == 0 : \"operation has only one input\"").end(); - b.tree(plugs.createSetInputBoxed(0)); - } else { - b.startSwitch().string("index").end().startBlock(); - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startCase().string("" + i).end().startCaseBlock(); - b.tree(plugs.createSetInputBoxed(i)); - b.statement("break"); - b.end(); - } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); - b.end(2); - } - } } } + parent.createSetBoxedForInstructions(typBuilderImpl); + ExecutionVariables vars = new ExecutionVariables(); // vars.bytecodeNodeType = builderBytecodeNodeType; vars.bc = fldBc; @@ -536,128 +497,6 @@ public CodeTypeElement createBuilderBytecodeNode() { } - { - CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doSetResultBoxed"); - builderBytecodeNodeType.add(mDoSetResultUnboxed); - - CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); - mDoSetResultUnboxed.addParameter(varTargetBci); - - CodeVariableElement varIndices = new CodeVariableElement(context.getType(int.class), "...indices"); - mDoSetResultUnboxed.addParameter(varIndices); - - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); - - b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); - - b.declaration("int", vars.bci.getName(), "0"); - b.declaration("int", "instrIndex", "0"); - - b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); - b.startBlock(); - - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); - b.startBlock(); - - for (Instruction instr : m.getInstructions()) { - if (instr.isInstrumentationOnly() && !withInstrumentation) { - continue; - } - - b.startCase().variable(instr.opcodeIdField).end(); - b.startBlock(); - - if (instr.numPush() > 0) { - CodeTree tree = instr.createSetResultBoxed(vars); - if (tree != null) { - b.startIf().variable(fldSuccessorIndices).string("[instrIndex] == ").variable(varTargetBci).end().startBlock(); - b.tree(tree); - b.end(); - } - b.statement("instrIndex += 2"); - } - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); - b.statement("break"); - - b.end(); - } - - b.end(); - - b.end(); // while block - } - - { - CodeExecutableElement mDoSetInputUnboxed = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doSetInputBoxed"); - builderBytecodeNodeType.add(mDoSetInputUnboxed); - - CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); - mDoSetInputUnboxed.addParameter(varTargetBci); - - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - CodeTreeBuilder b = mDoSetInputUnboxed.createBuilder(); - - b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); - - b.declaration("int", vars.bci.getName(), "0"); - b.declaration("int", "instrIndex", "0"); - - b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); - b.startBlock(); - - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); - b.startBlock(); - - for (Instruction instr : m.getInstructions()) { - if (instr.isInstrumentationOnly() && !withInstrumentation) { - continue; - } - - b.startCase().variable(instr.opcodeIdField).end(); - b.startCaseBlock(); - - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); - if (instr.numPush() > 0) { - b.statement("instrIndex += 2"); - } - b.statement("break"); - - b.end(); - } - - b.end(); // switch block - - b.end(); // while block - - b.startAssert().variable(vars.bci).string(" == ").variable(varTargetBci).end(); - - b.startAssign(vars.bci).variable(fldSuccessorIndices).string("[instrIndex]").end(); - b.declaration("int", "succInput", CodeTreeBuilder.createBuilder().variable(fldSuccessorIndices).string("[instrIndex + 1]").build()); - - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).end(); - b.startBlock(); - - for (Instruction instr : m.getInstructions()) { - if (instr.isInstrumentationOnly() && !withInstrumentation) { - continue; - } - - b.startCase().variable(instr.opcodeIdField).end(); - b.startCaseBlock(); - - b.tree(instr.createSetInputBoxed(vars, CodeTreeBuilder.singleString("succInput"))); - - b.statement("break"); - - b.end(); - } - - b.end(); // switch block - } - { CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); builderBytecodeNodeType.add(mDump); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 2ea1318fbd64..04118525f644 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -17,6 +17,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -366,20 +367,33 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree typeName = getFrameName(retType.getKind()); } + CodeTree isResultUnboxed = multiState.createNotContains(frameState, new Object[]{resultBoxedState}); + if (typeName.equals("Object")) { - // no boxing elim here + b.startIf().tree(isResultUnboxed).end().startBlock(); + { + // succ is expecting a primitive, let them know we are sending a boxed value + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + // TODO lock + + b.tree(OperationGeneratorUtils.callSetInputBoxed("$bci")); + + b.lineComment("CheckStyle: stop parameter assignment check"); + b.tree(multiState.createSet(frameState, new Object[]{resultBoxedState}, true, true)); + b.lineComment("CheckStyle: resume parameter assignment check"); + } + b.end(); b.startStatement(); b.startCall("$frame", "set" + typeName); b.string("$sp - " + destOffset); b.tree(value); b.end(2); } else { - b.startIf(); - b.tree(multiState.createContains(frameState, new Object[]{resultBoxedState})); - b.end().startBlock(); + b.startIf().tree(isResultUnboxed).end().startBlock(); { b.startStatement(); - b.startCall("$frame", "setObject"); + b.startCall("$frame", "set" + typeName); b.string("$sp - " + destOffset); b.tree(value); b.end(2); @@ -387,7 +401,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree b.end().startElseBlock(); { b.startStatement(); - b.startCall("$frame", "set" + typeName); + b.startCall("$frame", "setObject"); b.string("$sp - " + destOffset); b.tree(value); b.end(2); @@ -466,18 +480,37 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame String typeName = getFrameName(targetValue.getTypeMirror().getKind()); + CodeTree childBoxedTree = multiState.createContains(frameState, new Object[]{inputsBoxedState[childIndex]}); + if (typeName.equals("Object")) { - b.startTryBlock(); - b.startAssign(targetValue.getName()); - b.startCall("$frame", "getObject"); - b.string("$sp - " + offset); - b.end(3); + b.startIf().tree(childBoxedTree).end(); + b.startBlock(); + { + // pred is already boxed, there is no need to do any catching + b.startAssign(targetValue.getName()); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(3); + } + b.end().startElseBlock(); + { + // pred may not be boxed, need to do a try-catch. do a bit set ONLY IF the node is + // completely uninitialized (to skip the first `executeGeneric` call) + b.startTryBlock(); + b.startAssign(targetValue.getName()); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(3); - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, false, "neverbox"); + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, true, "generic"); + } + b.end(); } else { - b.startIf().tree(multiState.createContains(frameState, new Object[]{inputsBoxedState[childIndex]})).end(); + b.startIf().tree(childBoxedTree).end(); b.startBlock(); { + // pred is boxed. we need to unbox + catch CCE. CCE plays the role of URE from + // before b.startTryBlock(); b.startAssign(targetValue.getName()); b.cast(targetValue.getTypeMirror()); @@ -485,17 +518,20 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.string("$sp - " + offset); b.end(3); - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, true, false, "box -> unbox"); + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, true, false, false, "box -> unbox"); } b.end().startElseBlock(); { + // pred is unboxed. FSTE can happen if pred has multiple primitive possible results. + // then we need to box all of them (e.g. was producing ints so far, and now produced + // a float. both primitive, but different types) b.startTryBlock(); b.startAssign(targetValue.getName()); b.startCall("$frame", "get" + typeName); b.string("$sp - " + offset); b.end(3); - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, "unbox -> box"); + createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, false, "unbox -> box"); } b.end(); } @@ -504,13 +540,10 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame } private void createExecuteChildCatch(NodeData node, FrameState frameState, NodeExecutionData execution, LocalVariable targetValue, Function createExecuteAndSpecialize, - int offset, CodeTreeBuilder b, boolean alsoCastException, boolean setBoxedInput, String reason) { + int offset, CodeTreeBuilder b, boolean catchCastException, boolean setBoxedInput, boolean onlyIfUninit, String reason) { - if (alsoCastException) { - b.startCatchBlock(new TypeMirror[]{ - context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), - context.getType(ClassCastException.class), - }, "ex"); + if (catchCastException) { + b.startCatchBlock(context.getType(ClassCastException.class), "ex"); } else { b.startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); } @@ -518,15 +551,27 @@ private void createExecuteChildCatch(NodeData node, FrameState frameState, NodeE if (DO_LOG_BOXING_ELIM) { b.statement("System.out.printf(\" -- frame mispredict " + cinstr.name + "(" + reason + ": %s) @ %04x: %s %n\", $frame.getTag($sp - " + offset + "), $bci, ex)"); } + FrameState slowPathFrameState = frameState.copy(); if (setBoxedInput) { + boolean skipInit = node.needsRewrites(context) && onlyIfUninit; + // we cannot "skip init" if node has no rewrites, since there is no init + + if (skipInit) { + b.startIf().tree(multiState.createIsEmpty(slowPathFrameState)).end().startBlock(); + } + // TODO lock + b.lineComment("CheckStyle: stop parameter assignment check"); b.tree(multiState.createSet(slowPathFrameState, new Object[]{inputsBoxedState[execution.getIndex()]}, true, true)); - b.startStatement().startCall("doSetResultBoxed"); - b.string("$bci"); - b.string("" + execution.getIndex()); - b.end(2); + b.lineComment("CheckStyle: resume parameter assignment check"); + + b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci", execution.getIndex())); + + if (skipInit) { + b.end(); + } } CodeTreeBuilder accessBuilder = b.create(); @@ -580,14 +625,12 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.startIf().string("!").startParantheses().tree(multiState.createContainsAll(frameState, inputsBoxedStateList.toArray())).end(2).startBlock(); { // not all of them are set, set them + + b.lineComment("CheckStyle: stop parameter assignment check"); b.tree(multiState.createSet(frameState, inputsBoxedStateList.toArray(), true, true)); + b.lineComment("CheckStyle: resume parameter assignment check"); - b.startStatement().startCall("doSetResultBoxed"); - b.string("$bci"); - for (int arg : referenceArguments) { - b.string("" + arg); - } - b.end(2); + b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci", referenceArguments.toArray(new Integer[0]))); } b.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 4c0dc8fb3640..852858334c3d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -83,7 +83,7 @@ CodeTypeElement createBuilder(String simpleName) { CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); - GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked"); + GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked", "rawtypes"); { CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); @@ -199,12 +199,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; { - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(this, typBuilderImpl, simpleName + "BytecodeNode", m, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } if (ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(this, typBuilderImpl, simpleName + "InstrumentableBytecodeNode", m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); @@ -624,56 +624,135 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } - // The following is copy-pasted from OperationsBytecodeCodeGenerator - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - continue; - } + { + CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); + builderBytecodeNodeType.add(mDoSetResultUnboxed); - CustomInstruction cinstr = (CustomInstruction) instr; - SingleOperationData soData = cinstr.getData(); + CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + mDoSetResultUnboxed.addParameter(varBc); - { - CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( - Set.of(Modifier.PRIVATE), - context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", - new CodeVariableElement(context.getType(int.class), "$bci")); - typBuilderImpl.add(metSetResultUnboxed); - cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + CodeVariableElement varSuccIndices = new CodeVariableElement(arrayOf(context.getType(short.class)), "successorIndices"); + mDoSetResultUnboxed.addParameter(varSuccIndices); - CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); - b.tree(cinstr.getPlugs().createSetResultBoxed()); - } + CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); + mDoSetResultUnboxed.addParameter(varTargetBci); - if (!cinstr.getData().getMainProperties().isVariadic) { - CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( - Set.of(Modifier.PRIVATE), - context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", - new CodeVariableElement(context.getType(int.class), "$bci"), - new CodeVariableElement(context.getType(int.class), "index")); - typBuilderImpl.add(metSetInputUnboxed); - cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); + CodeVariableElement varIndices = new CodeVariableElement(context.getType(int.class), "...indices"); + mDoSetResultUnboxed.addParameter(varIndices); - CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); + vars.bc = varBc; + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - if (cinstr.numPopStatic() == 0) { - b.startAssert().string("false : \"operation has no input\"").end(); - } else if (cinstr.numPopStatic() == 1) { - b.startAssert().string("index == 0 : \"operation has only one input\"").end(); - b.tree(cinstr.getPlugs().createSetInputBoxed(0)); - } else { - b.startSwitch().string("index").end().startBlock(); - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startCase().string("" + i).end().startCaseBlock(); - b.tree(cinstr.getPlugs().createSetInputBoxed(i)); - b.statement("break"); + CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); + + b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); + + b.declaration("int", vars.bci.getName(), "0"); + b.declaration("int", "instrIndex", "0"); + + b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); + b.startBlock(); + + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(varBc, vars.bci)).end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + b.startCase().variable(instr.opcodeIdField).end(); + b.startBlock(); + + if (instr.numPush() > 0) { + CodeTree tree = instr.createSetResultBoxed(vars.asExecution()); + if (tree != null) { + b.startIf().variable(varSuccIndices).string("[instrIndex] == ").variable(varTargetBci).end().startBlock(); + b.tree(tree); b.end(); } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); - b.end(2); + b.statement("instrIndex += 2"); + } + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + b.statement("break"); + + b.end(); + } + + b.end(); + + b.end(); // while block + + vars.bc = fldBc; + vars.bci = null; + } + + { + CodeExecutableElement mDoSetInputUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetInputBoxed"); + builderBytecodeNodeType.add(mDoSetInputUnboxed); + + CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + mDoSetInputUnboxed.addParameter(varBc); + + CodeVariableElement varSuccIndices = new CodeVariableElement(arrayOf(context.getType(short.class)), "successorIndices"); + mDoSetInputUnboxed.addParameter(varSuccIndices); + + CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); + mDoSetInputUnboxed.addParameter(varTargetBci); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + + CodeTreeBuilder b = mDoSetInputUnboxed.createBuilder(); + + b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); + + b.declaration("int", vars.bci.getName(), "0"); + b.declaration("int", "instrIndex", "0"); + + b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); + b.startBlock(); + + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + b.startCase().variable(instr.opcodeIdField).end(); + b.startCaseBlock(); + + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + if (instr.numPush() > 0) { + b.statement("instrIndex += 2"); } + b.statement("break"); + + b.end(); + } + + b.end(); // switch block + + b.end(); // while block + + b.startAssert().variable(vars.bci).string(" == ").variable(varTargetBci).end(); + + b.startAssign(vars.bci).variable(varSuccIndices).string("[instrIndex]").end(); + + b.startIf().variable(vars.bci).string(" == -1").end().startBlock(); + b.returnStatement(); + b.end(); + + b.declaration("int", "succInput", CodeTreeBuilder.createBuilder().variable(varSuccIndices).string("[instrIndex + 1]").build()); + + b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).end(); + b.startBlock(); + + for (Instruction instr : m.getInstructions()) { + b.startCase().variable(instr.opcodeIdField).end(); + b.startCaseBlock(); + + b.tree(instr.createSetInputBoxed(vars.asExecution(), CodeTreeBuilder.singleString("succInput"))); + + b.statement("break"); + + b.end(); } + + b.end(); // switch block } for (Operation op : m.getOperations()) { @@ -865,6 +944,63 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } + void createSetBoxedForInstructions(CodeTypeElement typBuilderImpl) { + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + continue; + } + + CustomInstruction cinstr = (CustomInstruction) instr; + SingleOperationData soData = cinstr.getData(); + + { + CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( + MOD_PRIVATE_STATIC, + context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", + new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), + new CodeVariableElement(context.getType(int.class), "$bci")); + typBuilderImpl.add(metSetResultUnboxed); + cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + + CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); + b.tree(cinstr.getPlugs().createSetResultBoxed()); + cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + } + + if (!cinstr.getData().getMainProperties().isVariadic) { + CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( + MOD_PRIVATE_STATIC, + context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", + new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), + new CodeVariableElement(context.getType(int.class), "$bci"), + new CodeVariableElement(context.getType(int.class), "index")); + typBuilderImpl.add(metSetInputUnboxed); + cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); + + CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); + + if (cinstr.numPopStatic() == 0) { + b.startAssert().string("false : \"operation has no input\"").end(); + } else if (cinstr.numPopStatic() == 1) { + b.startAssert().string("index == 0 : \"operation has only one input\"").end(); + b.tree(cinstr.getPlugs().createSetInputBoxed(0)); + } else { + b.startSwitch().string("index").end().startBlock(); + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.startCase().string("" + i).end().startCaseBlock(); + b.tree(cinstr.getPlugs().createSetInputBoxed(i)); + b.statement("break"); + b.end(); + } + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); + b.end(2); + } + cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); + } + } + } + private static TypeMirror generic(TypeElement el, TypeMirror... params) { return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index f0af1bbad40a..8b7de811c3b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -61,7 +61,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("cond = (boolean) frame.getObject(sp - 1)"); // TODO lock - b.startStatement().startCall("doSetResultBoxed").variable(vars.bci).string("0").end(2); b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField)); b.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 06a42e31f1ec..76e7c6215d2c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -219,7 +219,8 @@ public void setSetInputUnboxedMethod(CodeExecutableElement setInputUnboxedMethod public CodeTree createSetResultBoxed(ExecutionVariables vars) { return CodeTreeBuilder.createBuilder() // .startStatement() // - .startCall("this", setResultUnboxedMethod) // + .startStaticCall(setResultUnboxedMethod) // + .variable(vars.bc) // .variable(vars.bci) // .end(2).build(); } @@ -232,7 +233,8 @@ public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { return CodeTreeBuilder.createBuilder() // .startStatement() // - .startCall("this", setInputUnboxedMethod) // + .startStaticCall(setInputUnboxedMethod) // + .variable(vars.bc) // .variable(vars.bci) // .tree(index) // .end(2).build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index d0ae355ffd97..77a1bbe1fcc0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -596,7 +596,7 @@ public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { b.startSwitch().tree(index).end().startBlock(); for (int i = 0; i < numPopStatic(); i++) { b.startCase().string("" + i).startCaseBlock(); - b.tree(createSetInputBoxed(vars, index)); + b.tree(createSetInputBoxed(vars, i)); b.statement("break"); b.end(); } @@ -608,6 +608,7 @@ public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { return b.build(); } + @SuppressWarnings("unused") public boolean isInputAlwaysBoxed(int index) { return false; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 433fda284117..218902324464 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -1,9 +1,7 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class LoadLocalInstruction extends Instruction { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 10c344e2cf6d..e575cf35af6c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -2,7 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class ReturnInstruction extends Instruction { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java index bcd92a678837..89ab2d851a3b 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java @@ -42,7 +42,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java index 793b3ee97c71..ea9cc5fc0a5a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java @@ -42,7 +42,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index 3d360dc3614f..d111bb219b85 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -42,7 +42,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java index b773789e344e..34869c17f6c3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java @@ -41,7 +41,6 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java index 15a6e45eb1b5..9ffb5c923246 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java @@ -42,7 +42,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index b62daf72f792..7fbaf2935395 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -42,7 +42,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; From e8c74418331ce1b6feabf8911366a8dd654038e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 14 Apr 2022 12:10:43 +0200 Subject: [PATCH 049/312] [wip] remove standard prologue stuff --- .../OperationsBytecodeCodeGenerator.java | 84 +------------------ .../instructions/BranchInstruction.java | 10 ++- .../instructions/CustomInstruction.java | 51 +++++++---- .../instructions/DiscardInstruction.java | 16 +++- .../truffle/sl/operations/SLOperations.java | 1 + 5 files changed, 63 insertions(+), 99 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 264faf96f6f9..17fef16a10b8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -333,94 +333,12 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); - CodeVariableElement[] varInputs = null; - CodeVariableElement[] varResults = null; - if (op.standardPrologue()) { - - varInputs = new CodeVariableElement[op.inputs.length]; - TypeMirror[] inputTypes = op.expectedInputTypes(context); - vars.inputs = varInputs; - for (int i = op.inputs.length - 1; i >= 0; i--) { - if (op.inputs[i] == InputType.STACK_VALUE_IGNORED) { - b.statement("--sp"); - continue; - } - - varInputs[i] = new CodeVariableElement(inputTypes[i], "input_" + i); - - b.declaration(varInputs[i].asType(), varInputs[i].getName(), createInputCode(vars, op, i, inputTypes[i])); - if (op.inputs[i] == InputType.VARARG_VALUE) { - b.startFor().string("int i = ").variable(varInputs[i]).string(".length - 1; i >= 0; i--").end(); - b.startBlock(); - b.startStatement().variable(varInputs[i]).string("[i] = "); - b.variable(argFrame).string(".getValue(--sp)"); - b.end(2); - } - } - - varResults = new CodeVariableElement[op.results.length]; - vars.results = varResults; - for (int i = 0; i < op.results.length; i++) { - switch (op.results[i]) { - case STACK_VALUE: - case SET_LOCAL: - varResults[i] = new CodeVariableElement(context.getType(Object.class), "result_" + i); - b.statement("Object result_" + i); - break; - case BRANCH: - varResults[i] = varBci; - break; - case RETURN: - varResults[i] = varReturnValue; - break; - } - } + throw new AssertionError("standard prologue: " + op.name); } b.tree(op.createExecuteCode(vars)); - if (op.standardPrologue()) { - for (int i = 0; i < op.results.length; i++) { - switch (op.results[i]) { - case STACK_VALUE: - b.startStatement().startCall(argFrame, "setObject").string("sp++").variable(varResults[i]).end(2); - break; - case SET_LOCAL: - b.startStatement().startCall(vars.frame, "setObject") // - .startGroup().string("VALUES_OFFSET + ").tree(op.createReadArgumentCode(op.inputs.length + i, vars)).end() // - .variable(varResults[i]) // - .end(2); - break; - } - } - - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceInstruction"); - b.variable(varBci); - b.variable(op.opcodeIdField); - b.doubleQuote(op.name); - - for (CodeVariableElement input : varInputs) { - if (input == null) { - b.string("null"); - } else { - b.variable(input); - } - } - - for (CodeVariableElement res : varResults) { - if (res == null) { - b.string("null"); - } else { - b.variable(res); - } - } - - b.end(2); - } - } - if (op.isReturnInstruction()) { b.statement("break loop"); } else if (!op.isBranchInstruction()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 602e17b229f8..15cddda67a51 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -11,11 +11,19 @@ public BranchInstruction(int id) { super("branch", id, ResultType.BRANCH, InputType.BRANCH_TARGET); } + @Override + public boolean standardPrologue() { + return false; + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.results[0]).variable(vars.inputs[0]).end(); + b.startAssign(vars.bci).startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); + b.end(2); b.statement("continue loop"); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 76e7c6215d2c..db411a52d8c5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -119,7 +119,7 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C @Override public boolean standardPrologue() { - return data.getMainProperties().isVariadic; + return false; } @Override @@ -127,34 +127,57 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (data.getMainProperties().isVariadic) { - // variadics always box - if (results.length > 0) { - b.startAssign(vars.results[0]); - } else { - b.startStatement(); - } - int inputIndex = 0; - b.startCall("this", executeMethod); - b.variable(vars.frame); - b.variable(vars.bci); - b.variable(vars.sp); + b.declaration("int", "numVariadics", "LE_BYTES.getShort(bc, bci + " + getArgumentOffset(inputs.length - 1) + ")"); + + int additionalInputs = inputs.length - 1; + int inputIndex = 0; + CodeTree[] inputTrees = new CodeTree[data.getMainProperties().parameters.size()]; for (ParameterKind kind : data.getMainProperties().parameters) { + String inputName = "input_" + inputIndex; switch (kind) { case STACK_VALUE: + b.declaration("Object", inputName, "frame.getObject(sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); + inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); + break; case VARIADIC: - b.variable(vars.inputs[inputIndex++]); + b.declaration("Object[]", inputName, "new Object[numVariadics]"); + b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); + b.startStatement().string(inputName, "[varIndex] = frame.getObject(sp - numVariadics + varIndex)").end(); + b.end(); + inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VIRTUAL_FRAME: - b.variable(vars.frame); + inputTrees[inputIndex++] = CodeTreeBuilder.singleVariable(vars.frame); break; default: throw new IllegalArgumentException("Unexpected value: " + kind); } } + if (results.length > 0) { + b.startAssign("Object result"); + } else { + b.startStatement(); + } + + b.startCall("this", executeMethod); + b.variable(vars.frame); + b.variable(vars.bci); + b.variable(vars.sp); + b.trees(inputTrees); b.end(2); + + b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + ", results.length > 0 ? "1" : "0").end(); + + if (results.length > 0) { + b.startStatement().startCall(vars.frame, "setObject"); + b.string("sp - 1"); + b.string("result"); + b.end(2); + } + } else { b.startStatement(); b.startCall("this", executeMethod); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 3ac120dd5868..83fae7e7c9d8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -1,15 +1,29 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; public class DiscardInstruction extends Instruction { public DiscardInstruction(String name, int id, InputType input) { super(name, id, new ResultType[0], input); } + @Override + public boolean standardPrologue() { + return false; + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - return null; + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); + + b.startStatement().startCall(vars.frame, "clear"); + b.variable(vars.sp); + b.end(2); + + return b.build(); } @Override diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index ecb1709346b3..47f3e566a4ca 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,6 +1,7 @@ package com.oracle.truffle.sl.operations; import java.util.Collections; +import java.util.List; import java.util.Map; import com.oracle.truffle.api.Assumption; From 094c594f9e6cdf5b20c7ec952aa0a0d9b5d7a42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 18 Apr 2022 19:55:41 +0200 Subject: [PATCH 050/312] [wip] boxing elim part 3 --- .../test/example/TestOperations.java | 7 + .../api/operation/OperationsBuilder.java | 55 +-- .../truffle/api/operation/OperationsNode.java | 12 +- .../generator/FlatNodeGenFactory.java | 48 ++- .../generator/NodeGeneratorPlugs.java | 6 + .../dsl/processor/operations/Operation.java | 15 +- .../operations/OperationGeneratorUtils.java | 9 +- .../OperationsBytecodeCodeGenerator.java | 94 +++-- .../OperationsBytecodeNodeGeneratorPlugs.java | 323 ++++++++---------- .../operations/OperationsCodeGenerator.java | 183 ++-------- .../operations/OperationsContext.java | 45 ++- .../processor/operations/OperationsData.java | 4 + .../operations/SingleOperationParser.java | 4 - .../instructions/BranchInstruction.java | 5 +- .../ConditionalBranchInstruction.java | 39 ++- .../operations/instructions/ConstantKind.java | 45 +++ .../instructions/CustomInstruction.java | 45 +-- .../instructions/DiscardInstruction.java | 5 +- .../operations/instructions/Instruction.java | 131 +++---- .../InstrumentationEnterInstruction.java | 5 +- .../InstrumentationExitInstruction.java | 5 +- .../InstrumentationLeaveInstruction.java | 5 +- .../instructions/LoadArgumentInstruction.java | 86 ++++- .../instructions/LoadConstantInstruction.java | 154 +++------ .../instructions/LoadLocalInstruction.java | 82 ++++- .../instructions/ReturnInstruction.java | 11 +- .../instructions/StoreLocalInstruction.java | 13 +- .../instructions/SuperInstruction.java | 5 +- .../truffle/sl/operations/SLOperations.java | 1 - 29 files changed, 670 insertions(+), 772 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 4224cb5911e1..b8144a6db1cc 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -5,6 +5,7 @@ import org.junit.Assert; import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; @@ -14,6 +15,7 @@ import com.oracle.truffle.api.source.Source; @GenerateOperations +@GenerateAOT public class TestOperations { private static class TestException extends AbstractOperationsTruffleException { @@ -41,6 +43,7 @@ public static void parse(TestLanguage language, Object input, TestOperationsBuil } @Operation + @GenerateAOT static class AddOperation { // @Cached(inline = true) MyOtherNode node; @@ -56,6 +59,7 @@ public static String addStrings(String lhs, String rhs) { } @Operation + @GenerateAOT static class LessThanOperation { @Specialization public static boolean lessThan(long lhs, long rhs) { @@ -64,6 +68,7 @@ public static boolean lessThan(long lhs, long rhs) { } @Operation + @GenerateAOT static class VeryComplexOperation { @Specialization public static long bla(long a1, @Variadic Object[] a2) { @@ -72,6 +77,7 @@ public static long bla(long a1, @Variadic Object[] a2) { } @Operation + @GenerateAOT static class ThrowOperation { @Specialization public static Object perform(@Bind("$bci") int bci, @Bind("this") OperationsNode node) { @@ -80,6 +86,7 @@ public static Object perform(@Bind("$bci") int bci, @Bind("this") OperationsNode } @Operation + @GenerateAOT static class AlwaysBoxOperation { @Specialization public static Object perform(Object value) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index df75d4c057f1..0b8ad2d6dc2b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,7 +1,6 @@ package com.oracle.truffle.api.operation; import java.util.ArrayList; -import java.util.Arrays; import java.util.function.Supplier; import com.oracle.truffle.api.instrumentation.Tag; @@ -34,7 +33,6 @@ public void reset() { maxLocals = -1; instrumentationId = 0; - instructionIndex = 0; curStack = 0; maxStack = 0; } @@ -146,62 +144,21 @@ protected void doEmitLabel(int bci, OperationLabel label) { // ------------------------ stack / successor handling ------------------------ - private int instructionIndex; - - private int[] stackSourceIndices = new int[1024]; private int[] stackSourceBci = new int[1024]; - private boolean[] stackAlwaysBoxed = new boolean[1024]; private int curStack; private int maxStack; - private short[] successorIndices = new short[65535]; - - protected void doMarkAlwaysBoxedInput(int numPops, int inputIndex) { - int offset = curStack - numPops + inputIndex; - if (stackAlwaysBoxed[offset]) { - // clear it, so that if two 'always boxed' operations are connected - // we don't do anything - stackAlwaysBoxed[offset] = false; - } else { - int bci = stackSourceBci[offset]; - markAlwaysBoxedResult(bci); - } - } - - protected abstract void markAlwaysBoxedResult(int bci); - - protected abstract void markAlwaysBoxedInput(int bci, int index); - - protected boolean[] doBeforeEmitInstruction(int bci, int numPops, boolean pushValue, boolean resultAlwaysBoxed) { - boolean[] result = null; + protected int[] doBeforeEmitInstruction(int bci, int numPops, boolean pushValue) { + int[] result = new int[numPops]; for (int i = numPops - 1; i >= 0; i--) { curStack--; - - int predIndex = stackSourceIndices[curStack]; - - if (stackAlwaysBoxed[curStack]) { - if (result == null) { - result = new boolean[numPops]; - } - result[i] = true; - } - successorIndices[predIndex] = (short) bci; - successorIndices[predIndex + 1] = (short) i; + int predBci = stackSourceBci[curStack]; + result[i] = predBci; } - // TODO: we could only record instrs that produce values - if (pushValue) { - int index = instructionIndex; - instructionIndex += 2; - stackSourceBci[curStack] = bci; - stackAlwaysBoxed[curStack] = resultAlwaysBoxed; - stackSourceIndices[curStack] = index; - - successorIndices[index] = -1; - successorIndices[index + 1] = -1; curStack++; @@ -213,10 +170,6 @@ protected boolean[] doBeforeEmitInstruction(int bci, int numPops, boolean pushVa return result; } - protected short[] createPredecessorIndices() { - return Arrays.copyOf(successorIndices, instructionIndex); - } - protected int createMaxStack() { return maxStack; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index d07c1421064e..b2572427f236 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -14,6 +14,14 @@ public abstract class OperationsNode extends Node implements InstrumentableNode { + public static final int FRAME_TYPE_OBJECT = 0; + public static final int FRAME_TYPE_LONG = 1; + public static final int FRAME_TYPE_INT = 2; + public static final int FRAME_TYPE_DOUBLE = 3; + public static final int FRAME_TYPE_FLOAT = 4; + public static final int FRAME_TYPE_BOOLEAN = 5; + public static final int FRAME_TYPE_BYTE = 6; + protected static final int BCI_SLOT = 0; protected static final int VALUES_OFFSET = 1; @@ -64,10 +72,10 @@ public OperationsRootNode createInternalRootNode(TruffleLanguage language, St } public final Object execute(VirtualFrame frame) { - return continueAt(frame, null); + return continueAt(frame, 0); } - public abstract Object continueAt(VirtualFrame frame, OperationLabel index); + protected abstract Object continueAt(VirtualFrame frame, int index); public abstract String dump(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 3adb7e16a684..e84231ec1eb0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -286,6 +286,9 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData if (activeStateEndIndex == -1) { activeStateEndIndex = stateObjects.size(); } + if (plugs != null) { + plugs.setStateObjects(stateObjects); + } this.multiState = createMultiStateBitset(stateObjects, activeStateStartIndex, activeStateEndIndex, volatileState); if (plugs != null) { plugs.setMultiState(this.multiState); @@ -768,6 +771,9 @@ private void generateAOT(CodeTypeElement clazz) { clazz.getImplements().add(aotProviderType); CodeExecutableElement prepare = clazz.add(CodeExecutableElement.cloneNoAnnotations(ElementUtils.findMethod(types.GenerateAOT_Provider, "prepareForAOT"))); + if (plugs != null) { + prepare.setSimpleName(CodeNames.of(plugs.transformNodeMethodName(prepare.getSimpleName().toString()))); + } prepare.renameArguments("language", "root"); GeneratorUtils.addOverride(prepare); prepare.getModifiers().remove(ABSTRACT); @@ -1011,7 +1017,12 @@ private void generateAOT(CodeTypeElement clazz) { return; } - CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), "resetAOT_")); + String resetName = "resetAOT_"; + if (plugs != null) { + resetName = plugs.transformNodeMethodName(resetName); + } + + CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), resetName)); frameState = FrameState.load(this, NodeExecutionMode.FAST_PATH, reset); reset.getModifiers().remove(ABSTRACT); builder = reset.createBuilder(); @@ -2142,7 +2153,15 @@ private CodeExecutableElement createExecuteAndSpecialize() { builder.startIf(); builder.tree(allMultiState.createContains(frameState, new Object[]{AOT_PREPARED})); builder.end().startBlock(); - builder.startStatement().startCall("this.resetAOT_").end().end(); + String resetName = "resetAOT_"; + if (plugs != null) { + resetName = plugs.transformNodeMethodName(resetName); + } + builder.startStatement().startCall("this." + resetName); + if (plugs != null) { + plugs.addNodeCallParameters(builder, false, false); + } + builder.end(2); builder.end(); } @@ -2443,6 +2462,10 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List List boxingSplits = parameterBoxingElimination(originalGroup, sharedExecutes); + if (plugs != null) { + plugs.setBoxingSplits(boxingSplits); + } + if (boxingSplits.isEmpty()) { builder.tree(executeFastPathGroup(builder, frameState, currentType, originalGroup, sharedExecutes, null)); addExplodeLoop(builder, originalGroup); @@ -2453,7 +2476,7 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List for (BoxingSplit split : boxingSplits) { elseIf = builder.startIf(elseIf); builder.startGroup(); - List specializations = split.group.collectSpecializations(); + List specializations = split.getGroup().collectSpecializations(); CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), allSpecializations.toArray()); if (!tree.isEmpty()) { builder.tree(tree); @@ -2462,8 +2485,8 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List builder.tree(multiState.createIsNotAny(frameState, allSpecializations.toArray())); builder.end(); builder.end().startBlock(); - builder.tree(wrapInAMethod(builder, split.group, originalFrameState, split.getName(), - executeFastPathGroup(builder, frameState.copy(), currentType, split.group, sharedExecutes, specializations))); + builder.tree(wrapInAMethod(builder, split.getGroup(), originalFrameState, split.getName(), + executeFastPathGroup(builder, frameState.copy(), currentType, split.getGroup(), sharedExecutes, specializations))); builder.end(); } @@ -2630,7 +2653,7 @@ private List parameterBoxingElimination(SpecializationGroup group, Collections.sort(groups, new Comparator() { public int compare(BoxingSplit o1, BoxingSplit o2) { - return Integer.compare(o2.primitiveSignature.length, o1.primitiveSignature.length); + return Integer.compare(o2.getPrimitiveSignature().length, o1.getPrimitiveSignature().length); } }); @@ -6158,7 +6181,7 @@ public String toString() { } - private static class BoxingSplit { + public static class BoxingSplit { private final SpecializationGroup group; private final TypeMirror[] primitiveSignature; @@ -6171,16 +6194,23 @@ private static class BoxingSplit { public String getName() { StringBuilder b = new StringBuilder(); String sep = ""; - for (TypeMirror typeMirror : primitiveSignature) { + for (TypeMirror typeMirror : getPrimitiveSignature()) { b.append(sep).append(firstLetterLowerCase(getSimpleName(typeMirror))); sep = "_"; } return b.toString(); } + public TypeMirror[] getPrimitiveSignature() { + return primitiveSignature; + } + + public SpecializationGroup getGroup() { + return group; + } } - private enum NodeExecutionMode { + public enum NodeExecutionMode { FAST_PATH, SLOW_PATH, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 528f7001de46..d3d1654cf08f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -6,6 +6,7 @@ import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; @@ -64,6 +65,8 @@ CodeTree createAssignExecuteChild( void addAdditionalStateBits(List stateObjects); + void setStateObjects(List stateObjects); + void setMultiState(MultiStateBitSet multiState); int getRequiredStateBits(TypeSystemData types, Object object); @@ -71,4 +74,7 @@ CodeTree createAssignExecuteChild( void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder builder); boolean needsRewrites(); + + void setBoxingSplits(List boxingSplits); + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index f689318f5661..46a790b95941 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -15,11 +15,11 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction.ConstantKind; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -159,19 +159,8 @@ public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); CodeTree[] arguments = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; - for (ConstantKind kind : ConstantKind.values()) { - if (kind == ConstantKind.OBJECT) { - b.startElseBlock(); - } else { - b.startIf(kind.ordinal() > 0); - b.string("arg0 instanceof " + kind.getTypeNameBoxed()); - b.end().startBlock(); - } - b.tree(instructions[kind.ordinal()].createEmitCode(vars, arguments)); - - b.end(); - } + b.tree(instructions[ConstantKind.OBJECT.ordinal()].createEmitCode(vars, arguments)); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 58e6201e0813..c6647ffcca5c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -17,6 +17,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; @@ -127,16 +128,14 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar return b.build(); } - public static CodeTree callSetResultBoxed(String bci, Integer... referenceArguments) { + public static CodeTree callSetResultBoxed(String bci, ConstantKind kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); + b.string(kind == ConstantKind.OBJECT ? "true" : "false"); b.string("bc"); - b.string("successorIndices"); b.string(bci); - for (int arg : referenceArguments) { - b.string("" + arg); - } + b.string("FRAME_TYPE_" + kind.getFrameName().toUpperCase()); b.end(2); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 17fef16a10b8..4db49ec9038d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -32,7 +32,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; public class OperationsBytecodeCodeGenerator { @@ -91,10 +90,6 @@ public CodeTypeElement createBuilderBytecodeNode() { GeneratorUtils.addCompilationFinalAnnotation(fldConditionBranches, 1); builderBytecodeNodeType.add(fldConditionBranches); - CodeVariableElement fldSuccessorIndices = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(short.class)), "successorIndices"); - GeneratorUtils.addCompilationFinalAnnotation(fldSuccessorIndices, 1); - builderBytecodeNodeType.add(fldSuccessorIndices); - CodeVariableElement fldProbeNodes = null; if (withInstrumentation) { fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); @@ -209,12 +204,15 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(ve); } + CodeExecutableElement metPrepareForAOT = null; + for (CodeExecutableElement exToCopy : execs) { boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); - boolean isExecute = exToCopy.getSimpleName().toString().contains("_execute_"); - boolean isExecuteAndSpecialize = exToCopy.getSimpleName().toString().endsWith("_executeAndSpecialize_"); - boolean isFallbackGuard = exToCopy.getSimpleName().toString().endsWith("_fallbackGuard__"); + String exName = exToCopy.getSimpleName().toString(); + boolean isExecute = exName.contains("_execute_"); + boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); + boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { List params = exToCopy.getParameters(); @@ -242,12 +240,17 @@ public CodeTypeElement createBuilderBytecodeNode() { exToCopy.getModifiers().add(Modifier.PRIVATE); exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); builderBytecodeNodeType.add(exToCopy); + + if (exName.equals(plugs.transformNodeMethodName("prepareForAOT"))) { + metPrepareForAOT = exToCopy; + } } cinstr.setExecuteMethod(uncExec); cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); cinstr.setNumChildNodes(childIndices.size()); cinstr.setNumConsts(constIndices.size()); + cinstr.setPrepareAOTMethod(metPrepareForAOT); } } @@ -264,10 +267,10 @@ public CodeTypeElement createBuilderBytecodeNode() { { CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); - CodeVariableElement argStartIndex = new CodeVariableElement(types.OperationLabel, "startIndex"); + CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); CodeExecutableElement mContinueAt = new CodeExecutableElement( Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", - argFrame, argStartIndex); + argFrame, argStartBci); builderBytecodeNodeType.add(mContinueAt); { @@ -284,7 +287,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); - b.declaration("int", varBci.getName(), "0"); + b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); if (m.isTracing()) { b.startStatement().startCall(fldTracer, "startFunction").string("this").end(2); @@ -415,6 +418,33 @@ public CodeTypeElement createBuilderBytecodeNode() { } + if (m.isGenerateAOT()) { + builderBytecodeNodeType.getImplements().add(types.GenerateAOT_Provider); + + CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(types.GenerateAOT_Provider, "prepareForAOT"); + builderBytecodeNodeType.add(mPrepareForAot); + + mPrepareForAot.renameArguments("language", "root"); + + CodeTreeBuilder b = mPrepareForAot.createBuilder(); + + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + b.declaration("int", "bci", "0"); + + b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); + + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, instr -> { + CodeTreeBuilder binstr = b.create(); + + binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); + binstr.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + + return binstr.build(); + })); + + b.end(); + } + { CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); builderBytecodeNodeType.add(mDump); @@ -446,13 +476,6 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); - if (op.numPush() == 0) { - b.statement("sb.append(\" \")"); - } else { - b.statement("sb.append(String.format(\"[ %04x %2d ] \", successorIndices[instrIndex], successorIndices[instrIndex + 1]))"); - b.statement("instrIndex += 2"); - } - for (int i = 0; i < 16; i++) { if (i < op.length()) { b.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); @@ -622,41 +645,6 @@ public CodeTypeElement createBuilderBytecodeNode() { return builderBytecodeNodeType; } - private CodeTree createInputCode(ExecutionVariables vars, Instruction instr, int index, TypeMirror inputType) { - switch (instr.inputs[index]) { - case ARGUMENT: - return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getArguments").end() // - .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // - .build(); - case LOCAL: - return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getValue") // - .startGroup().string("VALUES_OFFSET + ").tree(instr.createReadArgumentCode(index, vars)).end() // - .end().build(); - case CONST_POOL: - return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).variable(vars.consts) // - .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // - .build(); - case BRANCH_PROFILE: - return CodeTreeBuilder.createBuilder().string("conditionProfiles") // - .string("[").tree(instr.createReadArgumentCode(index, vars)).string("]") // - .build(); - case INSTRUMENT: - case BRANCH_TARGET: - return instr.createReadArgumentCode(index, vars); - case STACK_VALUE: - return CodeTreeBuilder.createBuilder().maybeCast(context.getType(Object.class), inputType).startCall(vars.frame, "getValue") // - .startGroup().string("--").variable(vars.sp).end() // - .end().build(); - case VARARG_VALUE: - return CodeTreeBuilder.createBuilder().startNewArray( - new ArrayCodeTypeMirror(context.getType(Object.class)), - instr.createReadArgumentCode(index, vars)).end().build(); - default: - throw new IllegalArgumentException("Unsupported value: " + instr.inputs[index]); - - } - } - private CodeTree createReparseCheck() { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().string("sourceInfo == null").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 04118525f644..88a8d28f2f48 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -1,11 +1,10 @@ package com.oracle.truffle.dsl.processor.operations; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Collectors; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; @@ -14,9 +13,11 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.BitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.NodeExecutionMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -31,6 +32,7 @@ import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; @@ -50,25 +52,14 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final ProcessorContext context; private final TruffleTypes types; - private final Object[] inputsBoxedState; - private final Object resultBoxedState; + private final Object resultUnboxedState; + private List specializationStates; private MultiStateBitSet multiState; + private List boxingSplits; - private static final boolean DO_LOG_BOXING_ELIM = false; - - private static class InputBoxedState { - private final int index; - - InputBoxedState(int index) { - this.index = index; - } - - @Override - public String toString() { - return "INPUT-BOXED(" + index + ")"; - } - } + private static final boolean DO_LOG_BOXING_ELIM = true; + private static final boolean DO_BOXING_ELIM_IN_PE = true; OperationsBytecodeNodeGeneratorPlugs(CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, Set innerTypeNames, List additionalData, @@ -90,22 +81,13 @@ public String toString() { this.context = ProcessorContext.getInstance(); this.types = context.getTypes(); - if (!isVariadic) { - inputsBoxedState = new Object[cinstr.numPopStatic()]; - for (int i = 0; i < cinstr.numPopStatic(); i++) { - inputsBoxedState[i] = new InputBoxedState(i); - } - } else { - inputsBoxedState = null; - } - if (cinstr.numPush() == 0) { - resultBoxedState = null; + resultUnboxedState = null; } else { - resultBoxedState = new Object() { + resultUnboxedState = new Object() { @Override public String toString() { - return "RESULT-BOXED"; + return "RESULT-UNBOXED"; } }; } @@ -113,14 +95,24 @@ public String toString() { @Override public void addAdditionalStateBits(List stateObjects) { - if (inputsBoxedState != null) { - stateObjects.addAll(Arrays.asList(inputsBoxedState)); - } - if (resultBoxedState != null) { - stateObjects.add(resultBoxedState); + if (resultUnboxedState != null) { + stateObjects.add(resultUnboxedState); } } + @Override + public void setStateObjects(List stateObjects) { + this.specializationStates = stateObjects.stream()// + .filter(x -> x instanceof SpecializationData)// + .collect(Collectors.toUnmodifiableList()); + } + + @Override + public void setBoxingSplits(List boxingSplits) { + this.boxingSplits = boxingSplits; + } + + @Override public void setMultiState(MultiStateBitSet multiState) { this.multiState = multiState; } @@ -367,43 +359,30 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree typeName = getFrameName(retType.getKind()); } - CodeTree isResultUnboxed = multiState.createNotContains(frameState, new Object[]{resultBoxedState}); + CodeTree isResultBoxed = multiState.createNotContains(frameState, new Object[]{resultUnboxedState}); if (typeName.equals("Object")) { - b.startIf().tree(isResultUnboxed).end().startBlock(); - { - // succ is expecting a primitive, let them know we are sending a boxed value - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - // TODO lock - - b.tree(OperationGeneratorUtils.callSetInputBoxed("$bci")); - - b.lineComment("CheckStyle: stop parameter assignment check"); - b.tree(multiState.createSet(frameState, new Object[]{resultBoxedState}, true, true)); - b.lineComment("CheckStyle: resume parameter assignment check"); - } - b.end(); b.startStatement(); - b.startCall("$frame", "set" + typeName); + b.startCall("$frame", "setObject"); b.string("$sp - " + destOffset); b.tree(value); b.end(2); } else { - b.startIf().tree(isResultUnboxed).end().startBlock(); + b.declaration(retType, "value", value); + b.startIf().tree(isResultBoxed).end().startBlock(); { b.startStatement(); - b.startCall("$frame", "set" + typeName); + b.startCall("$frame", "setObject"); b.string("$sp - " + destOffset); - b.tree(value); + b.string("value"); b.end(2); } b.end().startElseBlock(); { b.startStatement(); - b.startCall("$frame", "setObject"); + b.startCall("$frame", "set" + typeName); b.string("$sp - " + destOffset); - b.tree(value); + b.string("value"); b.end(2); } b.end(); @@ -418,6 +397,9 @@ public boolean createCallSpecialization(FrameState frameState, SpecializationDat if (isVariadic || inBoundary) return false; + if (frameState.getMode() == NodeExecutionMode.SLOW_PATH) { + + } createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); return true; } @@ -478,126 +460,83 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.tree(targetValue.createDeclaration(null)); - String typeName = getFrameName(targetValue.getTypeMirror().getKind()); - - CodeTree childBoxedTree = multiState.createContains(frameState, new Object[]{inputsBoxedState[childIndex]}); - - if (typeName.equals("Object")) { - b.startIf().tree(childBoxedTree).end(); - b.startBlock(); + if (!DO_BOXING_ELIM_IN_PE) { + b.startIf().tree(GeneratorUtils.createInCompiledCode()).end().startBlock(); { - // pred is already boxed, there is no need to do any catching b.startAssign(targetValue.getName()); - b.startCall("$frame", "getObject"); + b.maybeCast(context.getType(Object.class), targetValue.getTypeMirror()); + b.startCall("$frame", "getValue"); b.string("$sp - " + offset); - b.end(3); + b.end(2); } b.end().startElseBlock(); + } + + ConstantKind typeName = getFrameType(targetValue.getTypeMirror().getKind()); + + if (typeName == ConstantKind.OBJECT) { + b.startAssign(targetValue.getName()); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(2); + } else { + b.startIf().startCall("$frame", "is" + typeName.getFrameName()).string("$sp - " + offset).end(2).startBlock(); { - // pred may not be boxed, need to do a try-catch. do a bit set ONLY IF the node is - // completely uninitialized (to skip the first `executeGeneric` call) - b.startTryBlock(); b.startAssign(targetValue.getName()); - b.startCall("$frame", "getObject"); + b.startCall("$frame", "get" + typeName.getFrameName()); b.string("$sp - " + offset); b.end(3); - - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, true, "generic"); } - b.end(); - } else { - b.startIf().tree(childBoxedTree).end(); - b.startBlock(); + b.startElseIf(); + b.startCall("$frame", "isObject").string("$sp - " + offset).end(); + b.string(" && "); + b.startCall("$frame", "getObject").string("$sp - " + offset).end().string("instanceof ", typeName.getTypeNameBoxed()); + b.end().startBlock(); { - // pred is boxed. we need to unbox + catch CCE. CCE plays the role of URE from - // before - b.startTryBlock(); b.startAssign(targetValue.getName()); b.cast(targetValue.getTypeMirror()); b.startCall("$frame", "getObject"); b.string("$sp - " + offset); b.end(3); - - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, true, false, false, "box -> unbox"); } b.end().startElseBlock(); { - // pred is unboxed. FSTE can happen if pred has multiple primitive possible results. - // then we need to box all of them (e.g. was producing ints so far, and now produced - // a float. both primitive, but different types) - b.startTryBlock(); - b.startAssign(targetValue.getName()); - b.startCall("$frame", "get" + typeName); - b.string("$sp - " + offset); - b.end(3); - - createExecuteChildCatch(node, frameState, execution, targetValue, createExecuteAndSpecialize, offset, b, false, true, false, "unbox -> box"); - } - b.end(); - } - - return b.build(); - } - - private void createExecuteChildCatch(NodeData node, FrameState frameState, NodeExecutionData execution, LocalVariable targetValue, Function createExecuteAndSpecialize, - int offset, CodeTreeBuilder b, boolean catchCastException, boolean setBoxedInput, boolean onlyIfUninit, String reason) { - - if (catchCastException) { - b.startCatchBlock(context.getType(ClassCastException.class), "ex"); - } else { - b.startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); - } - - if (DO_LOG_BOXING_ELIM) { - b.statement("System.out.printf(\" -- frame mispredict " + cinstr.name + "(" + reason + ": %s) @ %04x: %s %n\", $frame.getTag($sp - " + offset + "), $bci, ex)"); - } - - FrameState slowPathFrameState = frameState.copy(); + // slow path + FrameState slowPathFrameState = frameState.copy(); + + CodeTreeBuilder accessBuilder = b.create(); + accessBuilder.startCall("$frame", "getValue"); + accessBuilder.string("$sp - " + offset); + accessBuilder.end(); + + slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); + + int curOffset = offset; + boolean found = false; + + for (NodeExecutionData otherExecution : node.getChildExecutions()) { + if (found) { + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); + b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); + slowPathFrameState.setValue(otherExecution, childEvaluatedValue); + } else { + // skip forward already evaluated + found = execution == otherExecution; + } + } - if (setBoxedInput) { - boolean skipInit = node.needsRewrites(context) && onlyIfUninit; - // we cannot "skip init" if node has no rewrites, since there is no init + b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); - if (skipInit) { - b.startIf().tree(multiState.createIsEmpty(slowPathFrameState)).end().startBlock(); } + b.end(); - // TODO lock - b.lineComment("CheckStyle: stop parameter assignment check"); - b.tree(multiState.createSet(slowPathFrameState, new Object[]{inputsBoxedState[execution.getIndex()]}, true, true)); - b.lineComment("CheckStyle: resume parameter assignment check"); - - b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci", execution.getIndex())); - - if (skipInit) { - b.end(); - } } - CodeTreeBuilder accessBuilder = b.create(); - accessBuilder.startCall("$frame", "getValue"); - accessBuilder.string("$sp - " + offset); - accessBuilder.end(); - - slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); - - int curOffset = offset; - boolean found = false; - - for (NodeExecutionData otherExecution : node.getChildExecutions()) { - if (found) { - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); - b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); - slowPathFrameState.setValue(otherExecution, childEvaluatedValue); - } else { - // skip forward already evaluated - found = execution == otherExecution; - } + if (!DO_BOXING_ELIM_IN_PE) { + b.end(); } - b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); - - b.end(); + return b.build(); } @Override @@ -605,45 +544,79 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ if (isVariadic) return; - List referenceArguments = new ArrayList<>(); - List inputsBoxedStateList = new ArrayList<>(); + boolean elseIf = false; + for (BoxingSplit split : boxingSplits) { + List specializations = split.getGroup().collectSpecializations(); + if (!specializations.contains(specialization)) { + continue; + } + + elseIf = b.startIf(elseIf); - int i = -1; - for (TypeMirror arg : specialization.getTypeSignature()) { - if (i >= 0 && !isUnboxable(arg.getKind())) { - referenceArguments.add(i); - inputsBoxedStateList.add(inputsBoxedState[i]); + b.startGroup(); + CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); + if (!tree.isEmpty()) { + b.tree(tree); + b.string(" && "); } + b.tree(multiState.createIsNotAny(frameState, specializationStates.toArray())); + b.end(); + b.end().startBlock(); - i++; - } + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.startBlock(); + b.declaration("int", "predOffset", "bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff"); + b.startIf().string("predOffset != 0").end().startBlock(); + ConstantKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); + b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci - predOffset", frameType)); + b.end(2); + } - if (referenceArguments.isEmpty()) { - return; + b.end(); } - b.startIf().string("!").startParantheses().tree(multiState.createContainsAll(frameState, inputsBoxedStateList.toArray())).end(2).startBlock(); - { - // not all of them are set, set them - - b.lineComment("CheckStyle: stop parameter assignment check"); - b.tree(multiState.createSet(frameState, inputsBoxedStateList.toArray(), true, true)); - b.lineComment("CheckStyle: resume parameter assignment check"); + if (elseIf) { + b.startElseBlock(); + } + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.startBlock(); + b.declaration("int", "predOffset", "bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff"); + b.startIf().string("predOffset != 0").end().startBlock(); + b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci - predOffset", ConstantKind.OBJECT)); + b.end(2); + } - b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci", referenceArguments.toArray(new Integer[0]))); + if (elseIf) { + b.end(); } - b.end(); } - public CodeTree createSetResultBoxed() { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultBoxedState}, true, true)); - return b.build(); + private static ConstantKind getFrameType(TypeKind kind) { + switch (kind) { + case BYTE: + return ConstantKind.BYTE; + case BOOLEAN: + return ConstantKind.BOOLEAN; + case INT: + return ConstantKind.INT; + case FLOAT: + return ConstantKind.FLOAT; + case LONG: + return ConstantKind.LONG; + case DOUBLE: + return ConstantKind.DOUBLE; + default: + return ConstantKind.OBJECT; + } } - public CodeTree createSetInputBoxed(int index) { + public CodeTree createSetResultBoxed(CodeVariableElement varUnboxed) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{inputsBoxedState[index]}, true, true)); + b.startIf().variable(varUnboxed).end().startBlock(); + b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultUnboxedState}, true, true)); + b.end().startElseBlock(); + b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultUnboxedState}, false, true)); + b.end(); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 852858334c3d..68dc6f2f9871 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -26,7 +26,6 @@ import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -392,7 +391,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); b.string("handlers"); b.string("condProfiles"); - b.startCall("createPredecessorIndices").end(); b.end(2); if (ENABLE_INSTRUMENTATION) { @@ -595,50 +593,21 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(mAfterChild); } - { - CodeExecutableElement mMarkAlwaysBoxedResult = GeneratorUtils.overrideImplement(types.OperationsBuilder, "markAlwaysBoxedResult"); - typBuilderImpl.add(mMarkAlwaysBoxedResult); - - ExecutionVariables exVars = new ExecutionVariables(); - exVars.bc = fldBc; - exVars.bci = (CodeVariableElement) mMarkAlwaysBoxedResult.getParameters().get(0); - - CodeTreeBuilder b = mMarkAlwaysBoxedResult.appendBuilder(); - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, exVars, instr -> instr.createSetResultBoxed(exVars))); - } - - { - CodeExecutableElement mMarkAlwaysBoxedInput = GeneratorUtils.overrideImplement(types.OperationsBuilder, "markAlwaysBoxedInput"); - typBuilderImpl.add(mMarkAlwaysBoxedInput); - - ExecutionVariables exVars = new ExecutionVariables(); - exVars.bc = fldBc; - exVars.bci = (CodeVariableElement) mMarkAlwaysBoxedInput.getParameters().get(0); - - VariableElement varIndex = mMarkAlwaysBoxedInput.getParameters().get(1); - - CodeTreeBuilder b = mMarkAlwaysBoxedInput.appendBuilder(); - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, exVars, instr -> instr.createSetInputBoxed(exVars, CodeTreeBuilder.singleVariable(varIndex)))); - - } - { CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); builderBytecodeNodeType.add(mDoSetResultUnboxed); + CodeVariableElement varBoxed = new CodeVariableElement(context.getType(boolean.class), "boxed"); + mDoSetResultUnboxed.addParameter(varBoxed); + CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); mDoSetResultUnboxed.addParameter(varBc); - CodeVariableElement varSuccIndices = new CodeVariableElement(arrayOf(context.getType(short.class)), "successorIndices"); - mDoSetResultUnboxed.addParameter(varSuccIndices); - - CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); + CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "bci"); mDoSetResultUnboxed.addParameter(varTargetBci); - CodeVariableElement varIndices = new CodeVariableElement(context.getType(int.class), "...indices"); - mDoSetResultUnboxed.addParameter(varIndices); + CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); + mDoSetResultUnboxed.addParameter(varTargetType); vars.bc = varBc; vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); @@ -647,112 +616,28 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); - b.declaration("int", vars.bci.getName(), "0"); - b.declaration("int", "instrIndex", "0"); - - b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); - b.startBlock(); - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(varBc, vars.bci)).end(); b.startBlock(); for (Instruction instr : m.getInstructions()) { - b.startCase().variable(instr.opcodeIdField).end(); - b.startBlock(); - - if (instr.numPush() > 0) { - CodeTree tree = instr.createSetResultBoxed(vars.asExecution()); - if (tree != null) { - b.startIf().variable(varSuccIndices).string("[instrIndex] == ").variable(varTargetBci).end().startBlock(); - b.tree(tree); - b.end(); - } - b.statement("instrIndex += 2"); - } - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); - b.statement("break"); - - b.end(); - } - - b.end(); - - b.end(); // while block - - vars.bc = fldBc; - vars.bci = null; - } - - { - CodeExecutableElement mDoSetInputUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetInputBoxed"); - builderBytecodeNodeType.add(mDoSetInputUnboxed); - - CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); - mDoSetInputUnboxed.addParameter(varBc); - - CodeVariableElement varSuccIndices = new CodeVariableElement(arrayOf(context.getType(short.class)), "successorIndices"); - mDoSetInputUnboxed.addParameter(varSuccIndices); - - CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "targetBci"); - mDoSetInputUnboxed.addParameter(varTargetBci); - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - CodeTreeBuilder b = mDoSetInputUnboxed.createBuilder(); - - b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); - - b.declaration("int", vars.bci.getName(), "0"); - b.declaration("int", "instrIndex", "0"); + CodeTree tree = instr.createSetResultBoxed(vars.asExecution(), varBoxed, varTargetType); + if (tree != null) { + b.startCase().variable(instr.opcodeIdField).end(); + b.startBlock(); - b.startWhile().variable(vars.bci).string(" < ").variable(varTargetBci).end(); - b.startBlock(); + b.tree(tree); - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); - b.startBlock(); - - for (Instruction instr : m.getInstructions()) { - b.startCase().variable(instr.opcodeIdField).end(); - b.startCaseBlock(); + b.statement("break"); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); - if (instr.numPush() > 0) { - b.statement("instrIndex += 2"); + b.end(); } - b.statement("break"); - - b.end(); } - b.end(); // switch block - - b.end(); // while block - - b.startAssert().variable(vars.bci).string(" == ").variable(varTargetBci).end(); - - b.startAssign(vars.bci).variable(varSuccIndices).string("[instrIndex]").end(); - - b.startIf().variable(vars.bci).string(" == -1").end().startBlock(); - b.returnStatement(); b.end(); - b.declaration("int", "succInput", CodeTreeBuilder.createBuilder().variable(varSuccIndices).string("[instrIndex + 1]").build()); - - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).end(); - b.startBlock(); - - for (Instruction instr : m.getInstructions()) { - b.startCase().variable(instr.opcodeIdField).end(); - b.startCaseBlock(); - - b.tree(instr.createSetInputBoxed(vars.asExecution(), CodeTreeBuilder.singleString("succInput"))); - - b.statement("break"); - - b.end(); - } - - b.end(); // switch block + vars.bc = fldBc; + vars.bci = fldBci; } for (Operation op : m.getOperations()) { @@ -954,50 +839,20 @@ void createSetBoxedForInstructions(CodeTypeElement typBuilderImpl) { SingleOperationData soData = cinstr.getData(); { + CodeVariableElement varUnboxed = new CodeVariableElement(context.getType(boolean.class), "unboxed"); CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( MOD_PRIVATE_STATIC, context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), - new CodeVariableElement(context.getType(int.class), "$bci")); + new CodeVariableElement(context.getType(int.class), "$bci"), + varUnboxed); typBuilderImpl.add(metSetResultUnboxed); cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); - b.tree(cinstr.getPlugs().createSetResultBoxed()); + b.tree(cinstr.getPlugs().createSetResultBoxed(varUnboxed)); cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); } - - if (!cinstr.getData().getMainProperties().isVariadic) { - CodeExecutableElement metSetInputUnboxed = new CodeExecutableElement( - MOD_PRIVATE_STATIC, - context.getType(void.class), soData.getName() + "_doSetInputUnboxed_", - new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), - new CodeVariableElement(context.getType(int.class), "$bci"), - new CodeVariableElement(context.getType(int.class), "index")); - typBuilderImpl.add(metSetInputUnboxed); - cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); - - CodeTreeBuilder b = metSetInputUnboxed.createBuilder(); - - if (cinstr.numPopStatic() == 0) { - b.startAssert().string("false : \"operation has no input\"").end(); - } else if (cinstr.numPopStatic() == 1) { - b.startAssert().string("index == 0 : \"operation has only one input\"").end(); - b.tree(cinstr.getPlugs().createSetInputBoxed(0)); - } else { - b.startSwitch().string("index").end().startBlock(); - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startCase().string("" + i).end().startCaseBlock(); - b.tree(cinstr.getPlugs().createSetInputBoxed(i)); - b.statement("break"); - b.end(); - } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("invalid input index")); - b.end(2); - } - cinstr.setSetInputUnboxedMethod(metSetInputUnboxed); - } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 6375ce3bff8b..1180aff13e5e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -5,6 +5,7 @@ import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -14,7 +15,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; @@ -31,6 +31,10 @@ public class OperationsContext { public Instruction commonBranchFalse; public Instruction commonBranchFalseBoxed; + public LoadArgumentInstruction[] loadArgumentInstructions; + public LoadConstantInstruction[] loadConstantInstructions; + public LoadLocalInstruction[] loadLocalInstructions; + public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); @@ -78,40 +82,31 @@ private void createBuiltinOperations() { } private void createLoadStoreLocal() { - StoreLocalInstruction slInit = add(new StoreLocalInstruction(instructionId++)); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, slInit)); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(instructionId++)))); - } + loadLocalInstructions = new LoadLocalInstruction[ConstantKind.values().length]; + for (ConstantKind kind : ConstantKind.values()) { + loadLocalInstructions[kind.ordinal()] = add(new LoadLocalInstruction(this, instructionId++, kind)); + } - private void createLoadArgument() { - LoadArgumentInstruction ldargInit = add(new LoadArgumentInstruction(instructionId++)); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, ldargInit)); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalInstructions[ConstantKind.OBJECT.ordinal()])); } - private void createLoadConstant() { - LoadConstantInstruction loadObject = add(new LoadConstantInstruction(instructionId++, false, ConstantKind.OBJECT, null)); - - LoadConstantInstruction[] instrs = new LoadConstantInstruction[ConstantKind.values().length]; - LoadConstantInstruction[] instrsBoxed = new LoadConstantInstruction[ConstantKind.values().length]; - + private void createLoadArgument() { + loadArgumentInstructions = new LoadArgumentInstruction[ConstantKind.values().length]; for (ConstantKind kind : ConstantKind.values()) { - if (kind.isSingleByte()) { - instrsBoxed[kind.ordinal()] = add(new LoadConstantInstruction(instructionId++, true, kind, null)); - } else { - instrsBoxed[kind.ordinal()] = loadObject; - } + loadArgumentInstructions[kind.ordinal()] = add(new LoadArgumentInstruction(this, instructionId++, kind)); } + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, loadArgumentInstructions[ConstantKind.OBJECT.ordinal()])); + } + private void createLoadConstant() { + loadConstantInstructions = new LoadConstantInstruction[ConstantKind.values().length]; for (ConstantKind kind : ConstantKind.values()) { - if (kind == ConstantKind.OBJECT) { - instrs[kind.ordinal()] = loadObject; - } else { - instrs[kind.ordinal()] = add(new LoadConstantInstruction(instructionId++, false, kind, instrsBoxed[kind.ordinal()])); - } + loadConstantInstructions[kind.ordinal()] = add(new LoadConstantInstruction(this, instructionId++, kind)); } - add(new Operation.LoadConstant(this, operationId++, instrs)); + add(new Operation.LoadConstant(this, operationId++, loadConstantInstructions)); } private void createReturn() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 1925f4d8d450..2d5f776bf858 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -86,4 +86,8 @@ public void initializeContext() { } } + public boolean isGenerateAOT() { + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 5c4a7505f8f0..d92907f2d823 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -229,10 +229,6 @@ protected SingleOperationData parse(Element element, List mirr clonedType.setEnclosingElement(proxyType.getEnclosingElement()); } - // if (data.getName().equals("SLEvalRootOperation")) { - // throw new AssertionError(OperationGeneratorUtils.printCode(clonedType)); - // } - NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); if (nodeData == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 15cddda67a51..bbcd2082133b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -4,6 +4,7 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class BranchInstruction extends Instruction { @@ -50,12 +51,12 @@ public boolean isBranchInstruction() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 8b7de811c3b7..3af4da19cb02 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -1,12 +1,15 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -46,7 +49,7 @@ public boolean isBranchInstruction() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(1) + ")]"); + b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(2) + ")]"); if (boxed) { b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); @@ -79,21 +82,37 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { - return null; - } + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + b.startIf(); + + if (boxed) { + b.string("!"); + } + + b.variable(varBoxed).end().startBlock(); + + b.startStatement().startCall("LE_BYTES", "putShort"); + b.variable(vars.bc); + b.variable(vars.bci); + + b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)); if (boxed) { - return null; + b.variable(ctx.commonBranchFalse.opcodeIdField); + } else { + b.variable(ctx.commonBranchFalseBoxed.opcodeIdField); } + b.end(); - return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField); + b.end(2); + + b.end(); + return b.build(); } @Override - public boolean isInputAlwaysBoxed(int index) { - return boxed; + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java new file mode 100644 index 000000000000..d4f5c5c1eb66 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java @@ -0,0 +1,45 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +public enum ConstantKind { + BOOLEAN("boolean", "Boolean"), + BYTE("byte", "Byte"), + INT("int", "Int", "Integer"), + FLOAT("float", "Float"), + LONG("long", "Long"), + DOUBLE("double", "Double"), + OBJECT("Object", "Object"); + + private final String typeName; + private final String frameName; + private final String typeNameBoxed; + + private ConstantKind(String typeName, String frameName) { + this(typeName, frameName, frameName); + } + + private ConstantKind(String typeName, String frameName, String typeNameBoxed) { + this.typeName = typeName; + this.frameName = frameName; + this.typeNameBoxed = typeNameBoxed; + } + + public boolean isSingleByte() { + return this == BOOLEAN || this == BYTE; + } + + public boolean isBoxed() { + return this == OBJECT; + } + + public String getFrameName() { + return frameName; + } + + public String getTypeName() { + return typeName; + } + + public String getTypeNameBoxed() { + return typeNameBoxed; + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index db411a52d8c5..b1f6699973e8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -9,6 +9,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -20,7 +21,7 @@ public enum DataKind { BITS, CONST, CHILD, - CONTINUATION + CONTINUATION, } private final SingleOperationData data; @@ -31,6 +32,7 @@ public enum DataKind { private CodeExecutableElement setResultUnboxedMethod; private CodeExecutableElement setInputUnboxedMethod; private OperationsBytecodeNodeGeneratorPlugs plugs; + private CodeExecutableElement prepareAOTMethod; public SingleOperationData getData() { return data; @@ -238,35 +240,19 @@ public void setSetInputUnboxedMethod(CodeExecutableElement setInputUnboxedMethod this.setInputUnboxedMethod = setInputUnboxedMethod; } - @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { - return CodeTreeBuilder.createBuilder() // - .startStatement() // - .startStaticCall(setResultUnboxedMethod) // - .variable(vars.bc) // - .variable(vars.bci) // - .end(2).build(); + public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { + this.prepareAOTMethod = prepareAOTMethod; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { - if (data.getMainProperties().isVariadic) { - return null; - } - + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return CodeTreeBuilder.createBuilder() // .startStatement() // - .startStaticCall(setInputUnboxedMethod) // + .startStaticCall(setResultUnboxedMethod) // .variable(vars.bc) // .variable(vars.bci) // - .tree(index) // + .startGroup().string("!").variable(varBoxed).end() // .end(2).build(); - - } - - @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { - return createSetInputBoxed(vars, CodeTreeBuilder.singleString("" + index)); } public OperationsBytecodeNodeGeneratorPlugs getPlugs() { @@ -277,4 +263,19 @@ public void setPlugs(OperationsBytecodeNodeGeneratorPlugs plugs) { this.plugs = plugs; } + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + if (prepareAOTMethod == null) { + return null; + } + + return CodeTreeBuilder.createBuilder().startStatement()// + .startCall("this", prepareAOTMethod) // + .string("null") // frame + .variable(vars.bci) // + .string("-1") // stack pointer + .tree(language) // + .tree(root) // + .end(2).build(); + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 83fae7e7c9d8..229650cec270 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class DiscardInstruction extends Instruction { public DiscardInstruction(String name, int id, InputType input) { @@ -27,12 +28,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 77a1bbe1fcc0..adc7fca95301 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -33,7 +33,7 @@ public static class ExecutionVariables { } public static enum InputType { - STACK_VALUE(0), + STACK_VALUE(1), STACK_VALUE_IGNORED(0), VARARG_VALUE(2), CONST_POOL(2), @@ -173,6 +173,10 @@ public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { } } + boolean isStackValue() { + return this == STACK_VALUE || this == STACK_VALUE_IGNORED; + } + } public static enum ResultType { @@ -327,6 +331,21 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code .end(2).build(); } + if (n < inputs.length && inputs[n] == InputType.STACK_VALUE) { + int svIndex = 0; + for (int i = 0; i < n; i++) { + if (inputs[i].isStackValue()) + svIndex++; + } + + return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc) // + .string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ") // + .string("predecessorBcis[" + svIndex + "] < ").variable(vars.bci).string(" - 255") // + .string(" ? 0") // + .string(" : (byte)(").variable(vars.bci).string(" - predecessorBcis[" + svIndex + "])") // + .end().build(); + } + if (n < inputs.length && inputs[n] == InputType.VARARG_VALUE) { value = CodeTreeBuilder.createBuilder().startParantheses().variable(vars.numChildren).string(" - " + numStackValuesExclVarargs()).end().build(); } @@ -366,6 +385,21 @@ public int getArgumentOffset(int index) { return res; } + public int getStackValueArgumentOffset(int index) { + int svIndex = 0; + for (int i = 0; i < inputs.length; i++) { + if (inputs[i].isStackValue()) { + if (svIndex == index) { + return getArgumentOffset(i); + } else { + svIndex++; + } + } + } + + throw new AssertionError("should not reach here"); + } + public boolean isArgumentInBytecode(int index) { if (index < inputs.length) { return inputs[index].argumentLength > 0; @@ -410,10 +444,6 @@ public List getBuilderArgumentTypes() { return result; } - protected boolean resultIsAlwaysBoxed() { - return false; - } - public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -423,51 +453,13 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { assert numPush == 1 || numPush == 0; - if (isVariadic()) { - // variadic instructions always box everything - b.startFor().string("int inputIndex = 0; inputIndex < ").tree(numPop).string("; inputIndex++").end().startBlock(); - b.startStatement().startCall("doMarkAlwaysBoxedInput"); - b.tree(numPop); - b.string("inputIndex"); - b.end(2); - b.end(); - } else { - int numPopStatic = numPopStatic(); - for (int i = 0; i < numPopStatic; i++) { - if (isInputAlwaysBoxed(i)) { - b.startStatement().startCall("doMarkAlwaysBoxedInput"); - b.tree(numPop); - b.string("" + i); - b.end(2); - } - } - } - - if (isVariadic() || numPopStatic() == 0) { - b.startStatement(); - } else { - b.startAssign("boolean[] inputsAlwaysBoxed"); - } - + b.startAssign("int[] predecessorBcis"); b.startCall("doBeforeEmitInstruction"); b.variable(vars.bci); b.tree(numPop); b.string(numPush == 0 ? "false" : "true"); - b.string("" + resultIsAlwaysBoxed()); b.end(2); - if (!isVariadic() && numPopStatic() > 0) { - b.startIf().string("inputsAlwaysBoxed != null").end().startBlock(); - { - for (int i = 0; i < numPopStatic(); i++) { - b.startIf().string("inputsAlwaysBoxed[" + i + "]").end().startBlock(); - b.tree(createSetInputBoxed(vars.asExecution(), i)); - b.end(); - } - } - b.end(); - } - // emit opcode b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, opcodeIdField)); @@ -576,45 +568,24 @@ public boolean isReturnInstruction() { return Arrays.stream(results).anyMatch(x -> x == ResultType.RETURN); } - public abstract CodeTree createSetResultBoxed(ExecutionVariables vars); + public abstract CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType); - public abstract CodeTree createSetInputBoxed(ExecutionVariables vars, int index); + public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); - public CodeTree createSetInputBoxed(ExecutionVariables vars, CodeTree index) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (numPopStatic() == 0) { - b.startAssert().string("false : \"invalid index\"").end(); - return b.build(); - } - - if (numPopStatic() == 1) { - b.startAssert().tree(index).string(" == 0 : \"invalid index\"").end(); - b.tree(createSetInputBoxed(vars, 0)); - return b.build(); - } - - b.startSwitch().tree(index).end().startBlock(); - for (int i = 0; i < numPopStatic(); i++) { - b.startCase().string("" + i).startCaseBlock(); - b.tree(createSetInputBoxed(vars, i)); - b.statement("break"); - b.end(); + public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { + for (int i = 0; i < inputs.length; i++) { + if (inputs[i] == InputType.STACK_VALUE || inputs[i] == InputType.STACK_VALUE_IGNORED) { + if (index-- == 0) { + return CodeTreeBuilder.createBuilder().startParantheses() // + .variable(vars.bc) // + .string("[") // + .variable(vars.bci).string(" + " + getArgumentOffset(i)) // + .string("] & 0xff") // + .end().build(); + } + } } - b.caseDefault().startCaseBlock(); - b.startAssert().string("false : \"invalid index\"").end(); - b.end(); - b.end(); - return b.build(); + throw new AssertionError("should not reach here"); } - - @SuppressWarnings("unused") - public boolean isInputAlwaysBoxed(int index) { - return false; - } - - public boolean isResultAlwaysBoxed() { - return false; - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index 53a4fab80e74..ff69d80e2af0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class InstrumentationEnterInstruction extends Instruction { @@ -37,12 +38,12 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 363f386917df..881213a95e59 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class InstrumentationExitInstruction extends Instruction { @@ -55,12 +56,12 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index 2aa8ce6b97b9..f1de489573b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class InstrumentationLeaveInstruction extends Instruction { public InstrumentationLeaveInstruction(int id) { @@ -59,12 +60,12 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 6e1ce2cf442b..6a54a69801da 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -2,11 +2,19 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadArgumentInstruction extends Instruction { - public LoadArgumentInstruction(int id) { - super("load.argument", id, ResultType.STACK_VALUE, InputType.ARGUMENT); + private ConstantKind kind; + private OperationsContext ctx; + + public LoadArgumentInstruction(OperationsContext ctx, int id, ConstantKind kind) { + super("load.argument." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.ARGUMENT); + this.ctx = ctx; + this.kind = kind; } @Override @@ -14,13 +22,9 @@ public boolean standardPrologue() { return false; } - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { + private CodeTree createGetValue(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startCall(vars.frame, "setObject"); - b.variable(vars.sp); - b.startGroup(); b.startCall(vars.frame, "getArguments").end(); b.string("["); b.startCall("LE_BYTES", "getShort"); @@ -28,25 +32,75 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); b.end(); b.string("]").end(); - b.end(2); - - b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); return b.build(); } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { - return null; + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration("Object", "value", createGetValue(vars)); + + if (kind == ConstantKind.OBJECT) { + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.string("value"); + b.end(2); + } else { + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + { + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.string("(", kind.getTypeName(), ") value"); + b.end(2); + } + b.end().startElseBlock(); + { + b.startStatement().startCall(vars.frame, "setObject"); + b.variable(vars.sp); + b.string("value"); + b.end(2); + } + b.end(); + } + + b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + + return b.build(); } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { - return null; + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (kind == ConstantKind.OBJECT) { + b.startIf().string("!").variable(varBoxed).end().startBlock(); + + boolean elseIf = false; + for (ConstantKind okind : ConstantKind.values()) { + if (okind == ConstantKind.OBJECT) + continue; + + elseIf = b.startIf(elseIf); + b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[okind.ordinal()].opcodeIdField)); + b.end(); + } + + b.end(); + } else { + b.startIf().variable(varBoxed).end().startBlock(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + + b.end(); + } + + return b.build(); } @Override - public boolean isResultAlwaysBoxed() { - return true; + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index fddb6c016331..4e89afae500b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -1,67 +1,22 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.TypeKind; + import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadConstantInstruction extends Instruction { - public enum ConstantKind { - BOOLEAN("boolean", "Boolean"), - BYTE("byte", "Byte"), - INT("int", "Int", "Integer"), - FLOAT("float", "Float"), - LONG("long", "Long"), - DOUBLE("double", "Double"), - OBJECT("Object", "Object"); - - private final String typeName; - private final String frameName; - private final String typeNameBoxed; - - private ConstantKind(String typeName, String frameName) { - this(typeName, frameName, frameName); - } - - private ConstantKind(String typeName, String frameName, String typeNameBoxed) { - this.typeName = typeName; - this.frameName = frameName; - this.typeNameBoxed = typeNameBoxed; - } - - public boolean isSingleByte() { - return this == BOOLEAN || this == BYTE; - } - - public boolean isBoxed() { - return this == OBJECT; - } - - public String getFrameName() { - return frameName; - } - - public String getTypeName() { - return typeName; - } - - public String getTypeNameBoxed() { - return typeNameBoxed; - } - } + private final ConstantKind kind; + private final OperationsContext ctx; - private ConstantKind kind; - private LoadConstantInstruction boxedVariant; - - public LoadConstantInstruction(int id, boolean boxed, ConstantKind kind, LoadConstantInstruction boxedVariant) { - super("load.constant." + kind.toString().toLowerCase() + (boxed ? ".boxed" : ""), id, ResultType.STACK_VALUE, new InputType[0]); + public LoadConstantInstruction(OperationsContext ctx, int id, ConstantKind kind) { + super("load.constant." + kind.toString().toLowerCase(), id, ResultType.STACK_VALUE, InputType.CONST_POOL); + this.ctx = ctx; this.kind = kind; - this.boxedVariant = boxedVariant == null ? this : boxedVariant; - } - - @Override - public int getAdditionalStateBytes() { - return kind.isSingleByte() ? 1 : 2; } @Override @@ -69,34 +24,6 @@ public boolean standardPrologue() { return false; } - @Override - protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (kind.isSingleByte()) { - b.startStatement(); - b.variable(vars.bc).string("[").variable(vars.bci).string(" + " + lengthWithoutState(), "] = "); - if (kind == ConstantKind.BOOLEAN) { - b.string("((boolean) "); - b.tree(arguments[0]); - b.string(") ? (byte) 1 : (byte) 0"); - } else { - b.string("(", kind.getTypeName(), ") ").tree(arguments[0]); - } - b.end(); - } else { - b.startStatement().startCall("LE_BYTES", "putShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + lengthWithoutState()).end(); - b.startGroup().string("(short) "); - b.startCall(vars.consts, "add"); - b.tree(arguments[0]); - b.end(4); - } - - return b.build(); - } - @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -115,35 +42,56 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private CodeTree createGetArgument(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind.isSingleByte()) { - b.variable(vars.bc).string("[").variable(vars.bci).string(" + " + lengthWithoutState() + "]"); - if (kind == ConstantKind.BOOLEAN) { - b.string(" != 0"); - } - } else { - if (kind != ConstantKind.OBJECT) { - b.string("(", kind.getTypeName(), ") "); - } - b.variable(vars.consts).string("["); - b.startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + lengthWithoutState()).end(); - b.end().string("]"); + if (kind != ConstantKind.OBJECT) { + b.string("(", kind.getTypeName(), ") "); } + b.variable(vars.consts).string("["); + b.startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); + b.end().string("]"); return b.build(); } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { - if (this == boxedVariant) { - return null; + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (kind == ConstantKind.OBJECT) { + b.startIf().string("!").variable(varBoxed).end().startBlock(); + + boolean elseIf = false; + for (ConstantKind okind : ConstantKind.values()) { + if (okind == ConstantKind.OBJECT) { + continue; + } + + elseIf = b.startIf(elseIf); + b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[okind.ordinal()].opcodeIdField)); + + b.end(); + } + + b.end(); + } else { + b.startIf().variable(varBoxed).end().startBlock(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + + b.end(); } - return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, boxedVariant.opcodeIdField); + return b.build(); } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { - return null; + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + if (kind == ConstantKind.OBJECT) { + return null; + } + + return createSetResultBoxed(vars, new CodeVariableElement(new CodeTypeMirror(TypeKind.BOOLEAN), "true"), null); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 218902324464..3172a12af0ae 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -2,11 +2,19 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadLocalInstruction extends Instruction { - public LoadLocalInstruction(int id) { - super("load.local", id, ResultType.STACK_VALUE, InputType.LOCAL); + private final OperationsContext ctx; + private final ConstantKind kind; + + public LoadLocalInstruction(OperationsContext ctx, int id, ConstantKind kind) { + super("load.local." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.LOCAL); + this.ctx = ctx; + this.kind = kind; } @Override @@ -18,7 +26,12 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startCall(vars.frame, "copy"); + if (kind == ConstantKind.OBJECT) { + b.startStatement().startCall(vars.frame, "copy"); + } else { + b.startAssign("Object value"); + b.startCall(vars.frame, "getObject"); + } b.startGroup(); b.startCall("LE_BYTES", "getShort"); @@ -28,25 +41,70 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string(" + VALUES_OFFSET"); b.end(); - b.startGroup().variable(vars.sp).string("++").end(); + if (kind == ConstantKind.OBJECT) { + b.variable(vars.sp); + } b.end(2); + if (kind != ConstantKind.OBJECT) { + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + { + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.string("(", kind.getTypeName(), ") value"); + b.end(2); + } + b.end().startElseBlock(); + { + b.startStatement().startCall(vars.frame, "setObject"); + b.variable(vars.sp); + b.string("value"); + b.end(2); + } + b.end(); + } + + b.startStatement().variable(vars.sp).string("++").end(); + return b.build(); } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { - return null; - } + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { - return null; + if (kind == ConstantKind.OBJECT) { + b.startIf().string("!").variable(varBoxed).end().startBlock(); + + boolean elseIf = false; + for (ConstantKind okind : ConstantKind.values()) { + if (okind == ConstantKind.OBJECT) { + continue; + } + + elseIf = b.startIf(elseIf); + b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[okind.ordinal()].opcodeIdField)); + + b.end(); + } + + b.end(); + } else { + b.startIf().variable(varBoxed).end().startBlock(); + + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + + b.end(); + } + + return b.build(); } @Override - public boolean isResultAlwaysBoxed() { - return true; + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index e575cf35af6c..11741ae14ef9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -2,6 +2,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class ReturnInstruction extends Instruction { @@ -27,18 +29,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - @Override - public boolean isInputAlwaysBoxed(int index) { - return true; - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 92e1680706fc..a5a2af8ee1b2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -2,6 +2,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class StoreLocalInstruction extends Instruction { @@ -29,7 +31,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup(); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + opcodeLength()).end(); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(1)).end(); b.end(); b.string(" + VALUES_OFFSET"); b.end(); @@ -45,17 +47,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public boolean isInputAlwaysBoxed(int index) { - return true; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 2e0a5b7241c0..89da92ba4a93 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,6 +7,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class SuperInstruction extends Instruction { private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { @@ -154,12 +155,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars) { + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { return null; } @Override - public CodeTree createSetInputBoxed(ExecutionVariables vars, int index) { + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 47f3e566a4ca..ecb1709346b3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,7 +1,6 @@ package com.oracle.truffle.sl.operations; import java.util.Collections; -import java.util.List; import java.util.Map; import com.oracle.truffle.api.Assumption; From 588d1bc72c24d729a35853caaf06c36eb3c87632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 19 Apr 2022 16:37:58 +0200 Subject: [PATCH 051/312] [wip] add missing TTI --- .../operations/OperationsBytecodeNodeGeneratorPlugs.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 88a8d28f2f48..08eb32b49cd2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -58,7 +58,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private MultiStateBitSet multiState; private List boxingSplits; - private static final boolean DO_LOG_BOXING_ELIM = true; + private static final boolean DO_LOG_BOXING_ELIM = false; private static final boolean DO_BOXING_ELIM_IN_PE = true; OperationsBytecodeNodeGeneratorPlugs(CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, @@ -490,7 +490,7 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.startElseIf(); b.startCall("$frame", "isObject").string("$sp - " + offset).end(); b.string(" && "); - b.startCall("$frame", "getObject").string("$sp - " + offset).end().string("instanceof ", typeName.getTypeNameBoxed()); + b.startCall("$frame", "getObject").string("$sp - " + offset).end().string(" instanceof ", typeName.getTypeNameBoxed()); b.end().startBlock(); { b.startAssign(targetValue.getName()); @@ -501,6 +501,9 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame } b.end().startElseBlock(); { + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + // slow path FrameState slowPathFrameState = frameState.copy(); From 69c78776fee646a871edb321002e964e272c35bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 26 Apr 2022 14:22:45 +0200 Subject: [PATCH 052/312] [wip] --- truffle/mx.truffle/suite.py | 7 +- .../api/dsl/ExecuteTracingSupport.java | 4 +- .../api/operation/GenerateOperations.java | 3 + .../truffle/api/operation/OperationsNode.java | 6 +- .../api/operation/OperationsRootNode.java | 6 - .../operation/tracing/ExecutionTracer.java | 301 +++++++++++++++++- .../api/operation/tracing/XmlUtils.java | 54 ++++ .../generator/FlatNodeGenFactory.java | 21 +- .../generator/NodeGeneratorPlugs.java | 5 +- .../java/compiler/AbstractCompiler.java | 8 + .../dsl/processor/java/compiler/Compiler.java | 2 + .../java/compiler/GeneratedCompiler.java | 6 + .../processor/java/compiler/JDTCompiler.java | 43 ++- .../java/compiler/JavaCCompiler.java | 6 + .../dsl/processor/java/model/CodeTree.java | 31 ++ .../operations/OperationDecisions.java | 148 +++++++++ .../operations/OperationGeneratorUtils.java | 85 +++-- .../OperationsBytecodeCodeGenerator.java | 113 ++++--- .../OperationsBytecodeNodeGeneratorPlugs.java | 233 ++++++++------ .../operations/OperationsCodeGenerator.java | 66 ++-- .../operations/OperationsContext.java | 38 ++- .../processor/operations/OperationsData.java | 6 + .../operations/OperationsParser.java | 65 +++- .../instructions/BranchInstruction.java | 22 +- .../ConditionalBranchInstruction.java | 72 ++--- .../instructions/CustomInstruction.java | 61 +++- .../instructions/DiscardInstruction.java | 7 + .../operations/instructions/Instruction.java | 15 +- .../instructions/LoadArgumentInstruction.java | 8 + .../instructions/LoadConstantInstruction.java | 8 + .../instructions/LoadLocalInstruction.java | 8 + .../instructions/QuickenedInstruction.java | 98 ++++++ .../instructions/ReturnInstruction.java | 8 +- .../instructions/StoreLocalInstruction.java | 10 +- .../instructions/SuperInstruction.java | 1 - .../truffle/sl/test/SLSimpleTestSuite.java | 4 + .../oracle/truffle/sl/test/SLTestRunner.java | 1 - .../truffle/sl/operations/SLOperations.java | 2 +- .../truffle/sl/operations/decisions.xml | 23 ++ 39 files changed, 1268 insertions(+), 337 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 54639c47653d..da26b8d0d52c 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -282,6 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], + "requires" : [""], "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", "com.oracle.truffle.api.instrumentation"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], @@ -372,10 +373,12 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "truffle:ANTLR4" + "truffle:ANTLR4", + "TruffleJSON", ], "requires" : [ "java.compiler", + "java.xml", ], "checkstyle" : "com.oracle.truffle.dsl.processor", "javaCompliance" : "11+", @@ -1027,7 +1030,7 @@ "jdk.unsupported", # sun.misc.Unsafe "java.logging", "java.management", - "java.sql" # java.sql.date java.sql.Time + "java.sql", # java.sql.date java.sql.Time ], "exports" : [ # Qualified exports diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ExecuteTracingSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ExecuteTracingSupport.java index 0a39c90ddaf4..e3e78d1b4ee0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ExecuteTracingSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ExecuteTracingSupport.java @@ -63,7 +63,7 @@ public interface ExecuteTracingSupport { /** * Invoked by the generated code to determine whether tracing is enabled. If tracing is * disabled, no other methods in this interface will be invoked. - * + * * @return {@code true} if tracing is enabled * @since 21.3 */ @@ -73,7 +73,7 @@ public interface ExecuteTracingSupport { * Invoked by the generated {@code execute} methods before any {@link Specialization} is called, * but after all {@link NodeChildren} are evaluated. Called only if {@link #isTracingEnabled()} * returns {@code true}. - * + * * @param arguments the arguments of the specialization except the frame, if any * @since 21.3 */ diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index 890c42f8a9f5..a5cd574ee97e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -8,4 +8,7 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface GenerateOperations { + String decisionsFile() default ""; + + String[] decisionOverrideFiles() default {}; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index b2572427f236..c93ecf1aba67 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -22,15 +22,11 @@ public abstract class OperationsNode extends Node implements InstrumentableNode public static final int FRAME_TYPE_BOOLEAN = 5; public static final int FRAME_TYPE_BYTE = 6; - protected static final int BCI_SLOT = 0; - protected static final int VALUES_OFFSET = 1; + protected static final int VALUES_OFFSET = 0; private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals) { FrameDescriptor.Builder b = FrameDescriptor.newBuilder(VALUES_OFFSET + maxStack + numLocals); - int bciSlot = b.addSlot(FrameSlotKind.Int, null, null); - assert bciSlot == BCI_SLOT; - b.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); return b.build(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index 0dc4a8bf17f5..4e2e8d0a1f1e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -39,12 +39,6 @@ public boolean isCaptureFramesForTrace() { return true; } - @Override - protected Object translateStackTraceElement(TruffleStackTraceElement element) { - int bci = element.getFrame().getInt(OperationsNode.BCI_SLOT); - return new OperationsStackTraceElement(element.getTarget().getRootNode(), node.getSourceSectionAtBci(bci)); - } - @Override public boolean isInstrumentable() { return false; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index 1d58618dbdde..fb3654df1317 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,17 +1,112 @@ package com.oracle.truffle.api.operation.tracing; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readAttribute; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readAttributeInt; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readCharactersInt; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readCharactersLong; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readEndElement; +import static com.oracle.truffle.api.operation.tracing.XmlUtils.readStartElement; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.PrintWriter; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Objects; + +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.operation.OperationsNode; public class ExecutionTracer { - private static ThreadLocal INSTANCE = ThreadLocal.withInitial(ExecutionTracer::new); + private static final Map TRACERS = new HashMap<>(); - public static ExecutionTracer get() { - return INSTANCE.get(); + public static ExecutionTracer get(String key) { + return TRACERS.computeIfAbsent(key, ExecutionTracer::new); } + private final String key; + + public ExecutionTracer(String key) { + assert TRACERS.get(key) == null; + this.key = key; + } + + static { + + // deser + String stateFile = "/tmp/state.xml"; + + try { + FileInputStream fi = new FileInputStream(new File(stateFile)); + XMLStreamReader rd = XMLInputFactory.newDefaultFactory().createXMLStreamReader(fi); + + readStartElement(rd, "STATE"); + + int state = rd.next(); + while (state == XMLStreamReader.START_ELEMENT) { + assert rd.getName().getLocalPart().equals("T"); + + ExecutionTracer tr = ExecutionTracer.deserializeState(rd); + TRACERS.put(tr.key, tr); + + readEndElement(rd, "T"); + + state = rd.next(); + } + } catch (FileNotFoundException ex) { + // we ignore FNFE since that is true on the first run + } catch (Exception e1) { + throw new RuntimeException("error deserializing tracer state", e1); + } + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + + // ser + try { + FileOutputStream fo = new FileOutputStream(new File(stateFile)); + XMLStreamWriter wr = XMLOutputFactory.newDefaultFactory().createXMLStreamWriter(fo); + + wr.writeStartDocument(); + wr.writeStartElement("STATE"); + for (Map.Entry ent : TRACERS.entrySet()) { + ExecutionTracer tracer = ent.getValue(); + wr.writeStartElement("T"); + wr.writeAttribute("key", tracer.key); + tracer.serializeState(wr); + wr.writeEndElement(); + + tracer.dump(new PrintWriter(System.out)); + } + wr.writeEndElement(); + wr.writeEndDocument(); + + } catch (Exception e) { + e.printStackTrace(); + System.err.flush(); + } + })); + } + + public static final int INSTRUCTION_TYPE_OTHER = 0; + public static final int INSTRUCTION_TYPE_BRANCH = 1; + public static final int INSTRUCTION_TYPE_BRANCH_COND = 2; + public static final int INSTRUCTION_TYPE_LOAD_LOCAL = 3; + public static final int INSTRUCTION_TYPE_STORE_LOCAL = 4; + public static final int INSTRUCTION_TYPE_LOAD_ARGUMENT = 5; + public static final int INSTRUCTION_TYPE_LOAD_CONSTANT = 6; + public static final int INSTRUCTION_TYPE_RETURN = 7; + public static final int INSTRUCTION_TYPE_CUSTOM = 8; + private static final int TRACE_LENGTH = 8; private static class InstructionSequence { @@ -82,6 +177,118 @@ public String toString() { final Map occurences = new HashMap<>(); InstructionSequence[] last = new InstructionSequence[TRACE_LENGTH - 1]; + private static class SpecializationOccurence { + final int instructionId; + final int specializationId; + + SpecializationOccurence(int instructionId, int specializationId) { + this.instructionId = instructionId; + this.specializationId = specializationId; + } + + @Override + public int hashCode() { + return Objects.hash(instructionId, specializationId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SpecializationOccurence other = (SpecializationOccurence) obj; + return instructionId == other.instructionId && specializationId == other.specializationId; + } + + @Override + public String toString() { + return "SpecializationOccurence [instructionId=" + instructionId + ", specializationId=" + specializationId + "]"; + } + } + + private static class ActiveSpecializationOccurence { + final String instructionId; + final boolean[] activeSpecializations; + + ActiveSpecializationOccurence(String instructionId, boolean... activeSpecializations) { + this.instructionId = instructionId; + this.activeSpecializations = activeSpecializations; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(activeSpecializations); + result = prime * result + Objects.hash(instructionId); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ActiveSpecializationOccurence other = (ActiveSpecializationOccurence) obj; + return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId.equals(other.instructionId); + } + + @Override + public String toString() { + return "ActiveSpecializationOccurence[instructionId=" + instructionId + ", activeSpecializations=" + Arrays.toString(activeSpecializations) + "]"; + } + + void serializeState(XMLStreamWriter wr) throws XMLStreamException { + wr.writeAttribute("i", instructionId); + wr.writeAttribute("n", "" + activeSpecializations.length); + + wr.writeStartElement("A"); + int i = 0; + for (boolean act : activeSpecializations) { + if (act) { + wr.writeStartElement("a"); + wr.writeCharacters("" + i); + wr.writeEndElement(); + } + i++; + } + wr.writeEndElement(); + } + + static ActiveSpecializationOccurence deserializeState(XMLStreamReader rd) throws XMLStreamException { + String instructionId = readAttribute(rd, "i"); + int count = readAttributeInt(rd, "n"); + + boolean[] activeSpecializations = new boolean[count]; + + readStartElement(rd, "A"); + + int state = rd.next(); + while (state == XMLStreamReader.START_ELEMENT) { + assert rd.getName().getLocalPart().equals("a"); + + int index = readCharactersInt(rd); + activeSpecializations[index] = true; + + readEndElement(rd, "a"); + state = rd.next(); + } + // end ASs + + assert state == XMLStreamReader.END_ELEMENT; + + return new ActiveSpecializationOccurence(instructionId, activeSpecializations); + } + } + + private final Map activeSpecializationsMap = new HashMap<>(); + private final void resetLast() { for (int i = 2; i <= TRACE_LENGTH; i++) { last[i - 2] = new InstructionSequence(new int[i]); @@ -89,27 +296,36 @@ private final void resetLast() { } @SuppressWarnings("unused") + @TruffleBoundary public final void startFunction(OperationsNode node) { resetLast(); } + @TruffleBoundary public final void endFunction() { resetLast(); } @SuppressWarnings("unused") - public final void traceInstruction(int bci, int id, Object... arguments) { - // System.out.printf(" [TT] %04x %d %s\n", bci, id, List.of(a, arguments)); - for (int i = 0; i < last.length; i++) { - last[i] = last[i].add(id); - if (last[i].isValid()) { - Long vo = occurences.get(last[i]); - long v = vo == null ? 0 : vo; - occurences.put(last[i], v + 1); - } + @TruffleBoundary + public final void traceInstruction(int bci, String id, int instructionType, Object... arguments) { + if (instructionType == INSTRUCTION_TYPE_CUSTOM) { + assert arguments.length == 1; + boolean[] activeSpecs = (boolean[]) arguments[0]; + + ActiveSpecializationOccurence occ = new ActiveSpecializationOccurence(id, activeSpecs); + Long cur = activeSpecializationsMap.get(occ); + long next = cur == null ? 1 : cur + 1; + activeSpecializationsMap.put(occ, next); } } + @TruffleBoundary + public final void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { + // System.out.printf(" [TS] %04x %d %d %s%n", bci, id, specializationId, + // List.of(arguments)); + } + @SuppressWarnings({"unused", "static-method"}) public final Object tracePop(Object value) { return value; @@ -128,12 +344,63 @@ private static final long score(Map.Entry ent) { return ent.getValue() * ent.getKey().instrs.length; } - public final void dump() { - occurences.entrySet().stream()// - .sorted((e1, e2) -> Long.compare(score(e2), score(e1)))// - .limit(30)// + public final void dump(PrintWriter writer) { + writer.println("-------------------------------------------------------------"); + activeSpecializationsMap.entrySet().stream() // + .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // + .limit(50) // .forEachOrdered(e -> { - System.out.printf(" %s : %d\n", e.getKey(), e.getValue()); + writer.printf(" %s: %d%n", e.getKey(), e.getValue()); }); + writer.println("-------------------------------------------------------------"); + writer.flush(); + // occurences.entrySet().stream()// + // .sorted((e1, e2) -> Long.compare(score(e2), score(e1)))// + // .limit(30)// + // .forEachOrdered(e -> { + // writer.printf(" %s : %d%n", e.getKey(), e.getValue()); + // }); + } + + public void serializeState(XMLStreamWriter wr) throws XMLStreamException { + wr.writeStartElement("As"); + + for (Map.Entry ent : activeSpecializationsMap.entrySet()) { + wr.writeStartElement("A"); + wr.writeAttribute("c", "" + ent.getValue()); + + ent.getKey().serializeState(wr); + wr.writeEndElement(); + } + + wr.writeEndElement(); + } + + public static ExecutionTracer deserializeState(XMLStreamReader rd) throws XMLStreamException { + + String key = readAttribute(rd, "key"); + + ExecutionTracer result = new ExecutionTracer(key); + + readStartElement(rd, "As"); + + int state = rd.next(); + while (state == XMLStreamReader.START_ELEMENT) { + assert rd.getName().getLocalPart().equals("A"); + + long value = XmlUtils.readAttributeLong(rd, "c"); + + ActiveSpecializationOccurence k = ActiveSpecializationOccurence.deserializeState(rd); + + result.activeSpecializationsMap.put(k, value); + + readEndElement(rd, "A"); + + state = rd.next(); + } + // end ASOs + assert state == XMLStreamReader.END_ELEMENT; + + return result; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java new file mode 100644 index 000000000000..f267e9221433 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java @@ -0,0 +1,54 @@ +package com.oracle.truffle.api.operation.tracing; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +final class XmlUtils { + public static void readStartElement(XMLStreamReader rd, String name) throws XMLStreamException { + String readName = readStartElement(rd); + assert readName.equals(name); + } + + public static String readStartElement(XMLStreamReader rd) throws XMLStreamException { + int state = rd.next(); + assert state == XMLStreamReader.START_ELEMENT; + return rd.getName().getLocalPart(); + } + + public static void readEndElement(XMLStreamReader rd, String name) throws XMLStreamException { + int state = rd.next(); + assert state == XMLStreamReader.END_ELEMENT : "got " + state + " " + rd.getName(); + assert rd.getName().getLocalPart().equals(name); + } + + public static String readCharacters(XMLStreamReader rd) throws XMLStreamException { + int state = rd.next(); + assert state == XMLStreamReader.CHARACTERS; + return rd.getText(); + } + + public static int readCharactersInt(XMLStreamReader rd) throws XMLStreamException { + return Integer.parseInt(readCharacters(rd)); + } + + public static long readCharactersLong(XMLStreamReader rd) throws XMLStreamException { + return Long.parseLong(readCharacters(rd)); + } + + public static boolean readCharactersBoolean(XMLStreamReader rd) throws XMLStreamException { + String v = readCharacters(rd); + return v.toLowerCase().equals("true"); + } + + public static String readAttribute(XMLStreamReader rd, String name) throws XMLStreamException { + return rd.getAttributeValue(null, name); + } + + public static int readAttributeInt(XMLStreamReader rd, String name) throws XMLStreamException { + return Integer.parseInt(readAttribute(rd, name)); + } + + public static long readAttributeLong(XMLStreamReader rd, String name) throws XMLStreamException { + return Long.parseLong(readAttribute(rd, name)); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index e84231ec1eb0..eb957ced59d2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -232,6 +232,9 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData this.sharedCaches = sharedCaches; List stateObjects = new ArrayList<>(); + if (plugs != null) { + plugs.addAdditionalStateBits(stateObjects); + } List excludeObjects = new ArrayList<>(); int activeStateStartIndex = -1; int activeStateEndIndex = -1; @@ -280,9 +283,6 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData } stateObjects.addAll(implicitCasts); } - if (plugs != null) { - plugs.addAdditionalStateBits(stateObjects); - } if (activeStateEndIndex == -1) { activeStateEndIndex = stateObjects.size(); } @@ -1890,6 +1890,10 @@ private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTyp implementedSpecializations = compatibleSpecializations; } + if (plugs != null) { + implementedSpecializations = plugs.filterSpecializations(implementedSpecializations); + } + if (implementedSpecializations.isEmpty()) { builder.tree(GeneratorUtils.createShouldNotReachHere("Delegation failed.")); } else { @@ -3455,7 +3459,7 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } CodeTree specializationCall = callMethod(frameState, null, specialization.getMethod(), bindings); - if (plugs == null || !plugs.createCallSpecialization(frameState, specialization, specializationCall, builder, inBoundary)) { + if (plugs == null || !plugs.createCallSpecialization(frameState, specialization, specializationCall, builder, inBoundary, bindings)) { if (isVoid(specialization.getMethod().getReturnType())) { builder.statement(specializationCall); if (isVoid(forType.getReturnType())) { @@ -3698,8 +3702,11 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization if (mode.isFastPath()) { BlockState ifCount = BlockState.NONE; - final boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && + boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && group.getAllSpecializations().size() == allowedSpecializations.size(); + if (plugs != null) { + stateGuaranteed = plugs.isStateGuaranteed(stateGuaranteed); + } if (needsRewrites && (!group.isEmpty() || specialization != null)) { CodeTree stateCheck = multiState.createContains(frameState, specializations); CodeTree stateGuard = null; @@ -5754,7 +5761,7 @@ CodeTree createLoad(FrameState frameState) { return builder.build(); } - CodeTree createLoad(FrameState frameState, Object... relevantObjects) { + public CodeTree createLoad(FrameState frameState, Object... relevantObjects) { return createLoadImpl(getSets(), frameState, relevantObjects); } @@ -5831,7 +5838,7 @@ String getNewName() { } - private class StateBitSet extends NodeBitSet { + public class StateBitSet extends NodeBitSet { private final Set relevantSpecializations; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index d3d1654cf08f..19dbe809b7a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -47,7 +47,7 @@ public interface NodeGeneratorPlugs { void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); - boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary); + boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary, CodeTree[] bindings); boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call); @@ -77,4 +77,7 @@ CodeTree createAssignExecuteChild( void setBoxingSplits(List boxingSplits); + List filterSpecializations(List implementedSpecializations); + + boolean isStateGuaranteed(boolean stateGuaranteed); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/AbstractCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/AbstractCompiler.java index d903c29a3908..c06f706367df 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/AbstractCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/AbstractCompiler.java @@ -80,6 +80,14 @@ protected static Object field(Object o, String fieldName) throws ReflectiveOpera return lookupField(o.getClass(), fieldName).get(o); } + protected static Object construct(Class clazz, Class[] paramTypes, Object... values) throws ReflectiveOperationException { + return clazz.getConstructor(paramTypes).newInstance(values); + } + + protected static Object construct(Class clazz) throws ReflectiveOperationException { + return clazz.getConstructor().newInstance(); + } + protected static Field lookupField(Class clazz, String fieldName) { // finding the right field can be expensive -> cache it. Map, Map> fieldsCache = ProcessorContext.getInstance().getCacheMap(AbstractCompiler.class); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java index a0d63379db06..26c3494ffb8b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.java.compiler; +import java.io.File; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; @@ -53,4 +54,5 @@ public interface Compiler { void emitDeprecationWarning(ProcessingEnvironment environment, Element element); + File getEnclosingFile(ProcessingEnvironment processingEnv, Element element); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java index 860683c0ac79..eeccdd815852 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.java.compiler; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -88,4 +89,9 @@ protected boolean emitDeprecationWarningImpl(ProcessingEnvironment environment, return false; } + @Override + public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + throw new UnsupportedOperationException("generated element"); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java index 2dd2ba0fefe1..8a93d2bdfef2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor.java.compiler; +import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -50,16 +52,17 @@ import java.util.TreeMap; import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import java.lang.reflect.Field; -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.ElementKind; -import javax.tools.Diagnostic.Kind; public class JDTCompiler extends AbstractCompiler { @@ -357,4 +360,34 @@ private static boolean reportProblem(Object problemReporter, ElementKind kind, O return false; } } + + @Override + public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + + boolean isIde = false; + Class c = processingEnv.getClass(); + while (c != Object.class) { + if (c.getSimpleName().equals("IdeProcessingEnvImpl")) { + isIde = true; + break; + } + c = c.getSuperclass(); + } + + try { + if (isIde) { + // the getEnclosingIFile is only available in the IDE + Object iFile = method(processingEnv, "getEnclosingIFile", new Class[]{Element.class}, + element); + return (File) method(method(iFile, "getRawLocation"), "toFile"); + } else { + // in IDE, this only returns the project-relative path + Object binding = field(element, "_binding"); + char[] fileName = (char[]) field(binding, "fileName"); + return new File(new String(fileName)); + } + } catch (ReflectiveOperationException e) { + throw new UnsupportedOperationException(e); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index e7a88a81d4bb..abc947905920 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.java.compiler; +import java.io.File; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; @@ -122,4 +123,9 @@ private static void reportProblem(Object check, Object treePath, Element element Object elementTree = method(treePath, "getLeaf"); method(check, "warnDeprecated", new Class[]{diagnosticPositionClass, symbolClass}, elementTree, element); } + + @Override + public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + throw new UnsupportedOperationException("todo"); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java index a05ded8c3f6a..84cfd930900b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java @@ -42,6 +42,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.lang.model.type.TypeMirror; @@ -121,4 +122,34 @@ public boolean isSingleLine() { return !containsKind(CodeTreeKind.NEW_LINE); } + public boolean isEqualTo(CodeTree other) { + if (kind != other.kind) { + return false; + } + + if (!Objects.equals(string, other.string)) { + return false; + } + + if (children == null && other.children == null) { + return true; + } + + if (children == null || other.children == null) { + return false; + } + + if (children.size() != other.children.size()) { + return false; + } + + for (int i = 0; i < children.size(); i++) { + if (!children.get(i).isEqualTo(other.children.get(i))) { + return false; + } + } + + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java new file mode 100644 index 000000000000..9c5ed426a1c5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -0,0 +1,148 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +public class OperationDecisions { + private final List quicken = new ArrayList<>(); + + private OperationDecisions() { + } + + public List getQuicken() { + return quicken; + } + + public OperationDecisions merge(OperationDecisions other) { + for (Quicken q : other.quicken) { + if (quicken.contains(q)) { + throw new AssertionError("duplicate decision"); + } + quicken.add(q); + } + + return this; + } + + public static class Quicken { + final String operation; + final String[] specializations; + + public String getOperation() { + return operation; + } + + public String[] getSpecializations() { + return specializations; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(specializations); + result = prime * result + Objects.hash(operation); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Quicken other = (Quicken) obj; + return Objects.equals(operation, other.operation) && Arrays.equals(specializations, other.specializations); + } + + @Override + public String toString() { + return "Quicken [operation=" + operation + ", specializations=" + Arrays.toString(specializations) + "]"; + } + + private Quicken(String operation, String[] specializations) { + this.operation = operation; + + Arrays.sort(specializations); + this.specializations = specializations; + } + + public static Quicken deserialize(XMLStreamReader rd) throws XMLStreamException { + assert rd.getName().getLocalPart().equals("Quicken"); + String operation = rd.getAttributeValue(null, "operation"); + + int state = rd.nextTag(); + if (state == XMLStreamReader.END_ELEMENT) { + return new Quicken(operation, new String[0]); + } + + assert state == XMLStreamReader.START_ELEMENT; + assert rd.getName().getLocalPart().equals("Specializations"); + + List specializations = new ArrayList<>(); + + state = rd.nextTag(); + while (state == XMLStreamReader.START_ELEMENT) { + assert rd.getName().getLocalPart().equals("Specialization"); + + String id = rd.getAttributeValue(null, "id"); + assert id != null; + + specializations.add(id); + + state = rd.nextTag(); + if (state != XMLStreamReader.END_ELEMENT) { + throw new AssertionError(); + } + + state = rd.nextTag(); + } + + assert state == XMLStreamReader.END_ELEMENT; // end of Specializations + + return new Quicken(operation, specializations.toArray(new String[specializations.size()])); + } + } + + public static OperationDecisions deserialize(XMLStreamReader rd) throws XMLStreamException { + if (!rd.getName().getLocalPart().equals("Decisions")) { + throw new AssertionError(); + } + + OperationDecisions decisions = new OperationDecisions(); + + int state = rd.nextTag(); + while (state == XMLStreamReader.START_ELEMENT) { + switch (rd.getLocalName()) { + case "Quicken": + Quicken quicken = Quicken.deserialize(rd); + decisions.quicken.add(quicken); + + state = rd.nextTag(); + if (!(state == XMLStreamReader.END_ELEMENT && rd.getLocalName().equals("Quicken"))) { + throw new AssertionError(state); + } + break; + default: + // TODO error handling + throw new AssertionError("invalid decision: " + rd.getLocalName()); + } + + state = rd.nextTag(); + } + + return decisions; + } + + @Override + public String toString() { + return "OperationDecisions [quicken=" + quicken + "]"; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index c6647ffcca5c..2b1e72d573bf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -3,6 +3,8 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.util.ArrayList; +import java.util.List; import java.util.function.Function; import javax.lang.model.element.Element; @@ -84,6 +86,13 @@ public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableEle CodeTreeBuilder.singleVariable(value)); } + public static CodeTree createWriteOpcode(CodeVariableElement bc, String bci, CodeVariableElement value) { + return createWriteOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleString(bci), + CodeTreeBuilder.singleVariable(value)); + } + public static String printCode(Element el) { StringWriter wr = new StringWriter(); new AbstractCodeWriter() { @@ -105,52 +114,84 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar return createInstructionSwitch(data, vars, true, body); } + private static final CodeTree BREAK_TREE = CodeTreeBuilder.createBuilder().statement("break").build(); + public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVariables vars, boolean instrumentation, Function body) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).end().startBlock(); - for (Instruction instr : data.getInstructions()) { + List trees = new ArrayList<>(); + List> treeInstructions = new ArrayList<>(); + + CodeTree defaultTree = body.apply(null); + boolean hasDefault; + + if (defaultTree == null) { + hasDefault = false; + } else { + hasDefault = true; + trees.add(defaultTree); + treeInstructions.add(null); + } + + outerLoop: for (Instruction instr : data.getInstructions()) { if (instr.isInstrumentationOnly() && !instrumentation) { continue; } CodeTree result = body.apply(instr); - if (result != null) { - b.startCase().variable(instr.opcodeIdField).end().startBlock(); - b.tree(result); - b.statement("break"); - b.end(); + if (result == null) { + if (hasDefault) { + // we have to explicitly do nothing for this instruction, since we have default + result = BREAK_TREE; + } else { + continue; + } } + for (int i = 0; i < trees.size(); i++) { + if (result.isEqualTo(trees.get(i))) { + treeInstructions.get(i).add(instr); + continue outerLoop; + } + } + + trees.add(result); + + List newList = new ArrayList<>(1); + newList.add(instr); + treeInstructions.add(newList); + + } + + b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).end().startBlock(); + for (int i = 0; i < trees.size(); i++) { + if (treeInstructions.get(i) == null) { + b.caseDefault(); + } else { + for (Instruction instr : treeInstructions.get(i)) { + b.startCase().variable(instr.opcodeIdField).end(); + } + } + b.startBlock(); + b.tree(trees.get(i)); + b.end(); } b.end(); return b.build(); } - public static CodeTree callSetResultBoxed(String bci, ConstantKind kind) { + public static CodeTree callSetResultBoxed(String bciOffset, ConstantKind kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); b.string(kind == ConstantKind.OBJECT ? "true" : "false"); b.string("bc"); - b.string(bci); + b.string("$bci"); + b.string(bciOffset); b.string("FRAME_TYPE_" + kind.getFrameName().toUpperCase()); b.end(2); return b.build(); } - - public static CodeTree callSetInputBoxed(String bci) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("doSetInputBoxed"); - b.string("bc"); - b.string("successorIndices"); - b.string(bci); - b.end(2); - - return b.build(); - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 4db49ec9038d..2d02934db9b8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -19,6 +19,7 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -32,6 +33,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; +import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; public class OperationsBytecodeCodeGenerator { @@ -101,13 +103,15 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(ctor); CodeVariableElement fldTracer = null; - CodeVariableElement fldHitCount = null; + CodeVariableElement fldHitCount; if (m.isTracing()) { fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); builderBytecodeNodeType.add(fldHitCount); fldTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); builderBytecodeNodeType.add(fldTracer); + } else { + fldHitCount = null; } { @@ -119,7 +123,9 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); b.end(2); - b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get").end(2); + b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get"); + b.doubleQuote(ElementUtils.getClassQualifiedName(m.getTemplateType())); + b.end(2); } } @@ -145,9 +151,9 @@ public CodeTypeElement createBuilderBytecodeNode() { final List constIndices = new ArrayList<>(); OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( - fldBc, fldChildren, constIndices, + m, fldBc, fldChildren, constIndices, innerTypeNames, additionalData, - methodNames, isVariadic, soData, + methodNames, isVariadic, additionalDataKinds, fldConsts, cinstr, childIndices); cinstr.setPlugs(plugs); @@ -214,6 +220,12 @@ public CodeTypeElement createBuilderBytecodeNode() { boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); + if (instr instanceof QuickenedInstruction) { + if (isExecuteAndSpecialize) { + continue; + } + } + if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { List params = exToCopy.getParameters(); @@ -336,6 +348,14 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); + if (m.isTracing()) { + b.startStatement().startCall(fldTracer, "traceInstruction"); + b.variable(varBci); + b.doubleQuote(op.name); + b.trees(op.createTracingArguments(vars)); + b.end(2); + } + if (op.standardPrologue()) { throw new AssertionError("standard prologue: " + op.name); } @@ -434,6 +454,10 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, instr -> { + if (instr == null) { + return null; + } + CodeTreeBuilder binstr = b.create(); binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); @@ -466,53 +490,46 @@ public CodeTypeElement createBuilderBytecodeNode() { b.statement("sb.append(String.format(\" %04x \", bci))"); - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(fldBc, vars.bci)).end(); - b.startBlock(); + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - for (Instruction op : m.getInstructions()) { - if (op.isInstrumentationOnly() && !withInstrumentation) { - continue; + if (op == null) { + builder.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); + builder.statement("break"); + return builder.build(); } - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); for (int i = 0; i < 16; i++) { if (i < op.length()) { - b.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); + builder.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); } else { - b.statement("sb.append(\" \")"); + builder.statement("sb.append(\" \")"); } } - b.statement("sb.append(\"" + op.name + " ".repeat(op.name.length() < 32 ? 32 - op.name.length() : 0) + " \")"); + builder.statement("sb.append(\"" + op.name + " ".repeat(op.name.length() < 32 ? 32 - op.name.length() : 0) + " \")"); for (int i = 0; i < op.inputs.length; i++) { if (i != 0) { - b.statement("sb.append(\", \")"); + builder.statement("sb.append(\", \")"); } - b.tree(op.inputs[i].createDumpCode(i, op, vars)); + builder.tree(op.inputs[i].createDumpCode(i, op, vars)); } - b.statement("sb.append(\" -> \")"); + builder.statement("sb.append(\" -> \")"); for (int i = 0; i < op.results.length; i++) { if (i != 0) { - b.statement("sb.append(\", \")"); + builder.statement("sb.append(\", \")"); } - b.tree(op.results[i].createDumpCode(i, op, vars)); + builder.tree(op.results[i].createDumpCode(i, op, vars)); } - b.statement("bci += " + op.length()); - b.statement("break"); - - b.end(); - } + builder.statement("bci += " + op.length()); + builder.statement("break"); - b.caseDefault().startCaseBlock(); - b.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); - b.statement("break"); - b.end(); // default case block - b.end(); // switch block + return builder.build(); + })); b.statement("sb.append(\"\\n\")"); @@ -558,35 +575,27 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startWhile().string("bci < bc.length").end(); b.startBlock(); // while block - b.startSwitch().string("bc[bci]").end(); - b.startBlock(); - - for (Instruction op : m.getInstructions()) { - if (op.isInstrumentationOnly() && !withInstrumentation) { - continue; + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + if (op == null) { + builder.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); + return builder.build(); } - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); - b.startStatement(); - b.startCall("insts", "add"); - b.startNew(types.InstructionTrace); + builder.startStatement(); + builder.startCall("insts", "add"); + builder.startNew(types.InstructionTrace); - b.variable(op.opcodeIdField); - b.startGroup().variable(fldHitCount).string("[bci]").end(); + builder.variable(op.opcodeIdField); + builder.startGroup().variable(fldHitCount).string("[bci]").end(); - b.end(3); + builder.end(3); - b.statement("bci += " + op.length()); - b.statement("break"); - - b.end(); - } + builder.statement("bci += " + op.length()); + builder.statement("break"); - b.caseDefault().startCaseBlock(); - b.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); - b.end(); // default case block - b.end(); // switch block + return builder.build(); + })); b.end(); // while block diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 08eb32b49cd2..7c5cbfc038b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -17,7 +17,6 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.NodeExecutionMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -30,11 +29,13 @@ import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.Parameter; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; +import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final CodeVariableElement fldBc; @@ -44,7 +45,6 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final List additionalData; private final Set methodNames; private final boolean isVariadic; - private final SingleOperationData soData; private final List additionalDataKinds; private final CodeVariableElement fldConsts; private final CustomInstruction cinstr; @@ -58,13 +58,14 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private MultiStateBitSet multiState; private List boxingSplits; - private static final boolean DO_LOG_BOXING_ELIM = false; private static final boolean DO_BOXING_ELIM_IN_PE = true; + private OperationsData m; - OperationsBytecodeNodeGeneratorPlugs(CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, + OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, Set innerTypeNames, List additionalData, - Set methodNames, boolean isVariadic, SingleOperationData soData, List additionalDataKinds, CodeVariableElement fldConsts, CustomInstruction cinstr, + Set methodNames, boolean isVariadic, List additionalDataKinds, CodeVariableElement fldConsts, CustomInstruction cinstr, List childIndices) { + this.m = m; this.fldBc = fldBc; this.fldChildren = fldChildren; this.constIndices = constIndices; @@ -72,7 +73,6 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator this.additionalData = additionalData; this.methodNames = methodNames; this.isVariadic = isVariadic; - this.soData = soData; this.additionalDataKinds = additionalDataKinds; this.fldConsts = fldConsts; this.cinstr = cinstr; @@ -95,6 +95,9 @@ public String toString() { @Override public void addAdditionalStateBits(List stateObjects) { + if (!stateObjects.isEmpty()) { + throw new AssertionError("stateObjects must be empty"); + } if (resultUnboxedState != null) { stateObjects.add(resultUnboxedState); } @@ -124,14 +127,14 @@ public int getRequiredStateBits(TypeSystemData typesData, Object object) { @Override public String transformNodeMethodName(String name) { - String result = soData.getName() + "_" + name + "_"; + String result = cinstr.getUniqueName() + "_" + name + "_"; methodNames.add(result); return result; } @Override public String transformNodeInnerTypeName(String name) { - String result = soData.getName() + "_" + name; + String result = cinstr.getUniqueName() + "_" + name; innerTypeNames.add(result); return result; } @@ -268,49 +271,6 @@ public int getStackOffset(LocalVariable value) { throw new UnsupportedOperationException("" + value); } - private static String getFrameName(TypeKind kind) { - switch (kind) { - case INT: - return "Int"; - case BYTE: - return "Byte"; - case BOOLEAN: - return "Boolean"; - case DOUBLE: - return "Double"; - case FLOAT: - return "Float"; - case LONG: - return "Long"; - case DECLARED: - case CHAR: - case SHORT: - // shorts and chars are handled as reference types, since VirtualFrame does not - // support them directly - return "Object"; - default: - throw new IllegalArgumentException("Unknown primitive type: " + kind); - } - } - - private static boolean isUnboxable(TypeKind kind) { - switch (kind) { - case INT: - case BYTE: - case BOOLEAN: - case DOUBLE: - case FLOAT: - case LONG: - return true; - case DECLARED: - case CHAR: - case SHORT: - return false; - default: - throw new IllegalArgumentException("Unknown primitive type: " + kind); - } - } - @Override public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { return CodeTreeBuilder.singleString("null"); @@ -356,7 +316,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree typeName = "Object"; } else { value = specializationCall; - typeName = getFrameName(retType.getKind()); + typeName = getFrameType(retType.getKind()).getFrameName(); } CodeTree isResultBoxed = multiState.createNotContains(frameState, new Object[]{resultUnboxedState}); @@ -393,13 +353,24 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree } @Override - public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary) { + public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary, CodeTree[] bindings) { if (isVariadic || inBoundary) return false; - if (frameState.getMode() == NodeExecutionMode.SLOW_PATH) { - + if (m.isTracing()) { + b.startStatement().startCall("tracer", "traceSpecialization"); + b.string("$bci"); + b.doubleQuote(cinstr.name); + b.string("" + specialization.getIntrospectionIndex()); + for (int i = 0; i < bindings.length; i++) { + Parameter parameter = specialization.getParameters().get(i); + if (parameter.getSpecification().isSignature()) { + b.tree(bindings[i]); + } + } + b.end(2); } + createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); return true; } @@ -409,6 +380,27 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui if (isVariadic) { return false; } + + if (cinstr instanceof QuickenedInstruction) { + QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; + + // unquicken and call parent EAS + builder.statement("System.out.println(\" -- unquicken " + qinstr.getUniqueName() + " -> " + qinstr.getOrig().getUniqueName() + " \")"); + builder.tree(OperationGeneratorUtils.createWriteOpcode( + fldBc, + new CodeVariableElement(context.getType(int.class), "$bci"), + qinstr.getOrig().opcodeIdField)); + + String parentEASName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; + builder.startStatement().startCall(parentEASName); + addNodeCallParameters(builder, false, false); + frameState.addReferencesTo(builder); + builder.end(2); + builder.returnStatement(); + + return true; + } + builder.statement(call); builder.returnStatement(); return true; @@ -544,54 +536,68 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame @Override public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder b) { - if (isVariadic) - return; - boolean elseIf = false; - for (BoxingSplit split : boxingSplits) { - List specializations = split.getGroup().collectSpecializations(); - if (!specializations.contains(specialization)) { - continue; + // quickening + if (!(cinstr instanceof QuickenedInstruction)) { + List quickened = cinstr.getQuickenedVariants(); + + boolean elseIf = false; + for (QuickenedInstruction qinstr : quickened) { + if (qinstr.getActiveSpecs().contains(specialization)) { + elseIf = b.startIf(elseIf); + b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); + b.end().startBlock(); + { + b.statement("System.out.println(\" -- quicken " + cinstr.getUniqueName() + " -> " + qinstr.getUniqueName() + " \")"); + b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); + } + b.end(); + } } + } + + // boxing elimination + if (!isVariadic) { + boolean elseIf = false; + for (BoxingSplit split : boxingSplits) { + List specializations = split.getGroup().collectSpecializations(); + if (!specializations.contains(specialization)) { + continue; + } - elseIf = b.startIf(elseIf); + elseIf = b.startIf(elseIf); - b.startGroup(); - CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); - if (!tree.isEmpty()) { - b.tree(tree); - b.string(" && "); + b.startGroup(); + CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); + if (!tree.isEmpty()) { + b.tree(tree); + b.string(" && "); + } + b.tree(multiState.createIsNotAny(frameState, specializationStates.toArray())); + b.end(); + b.end().startBlock(); + + for (int i = 0; i < cinstr.numPopStatic(); i++) { + ConstantKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); + b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", frameType)); + } + + b.end(); } - b.tree(multiState.createIsNotAny(frameState, specializationStates.toArray())); - b.end(); - b.end().startBlock(); - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startBlock(); - b.declaration("int", "predOffset", "bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff"); - b.startIf().string("predOffset != 0").end().startBlock(); - ConstantKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); - b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci - predOffset", frameType)); - b.end(2); + if (elseIf) { + b.startElseBlock(); } - b.end(); - } + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", ConstantKind.OBJECT)); + } - if (elseIf) { - b.startElseBlock(); - } - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startBlock(); - b.declaration("int", "predOffset", "bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff"); - b.startIf().string("predOffset != 0").end().startBlock(); - b.tree(OperationGeneratorUtils.callSetResultBoxed("$bci - predOffset", ConstantKind.OBJECT)); - b.end(2); + if (elseIf) { + b.end(); + } } - if (elseIf) { - b.end(); - } } private static ConstantKind getFrameType(TypeKind kind) { @@ -623,7 +629,50 @@ public CodeTree createSetResultBoxed(CodeVariableElement varUnboxed) { return b.build(); } + @SuppressWarnings("unchecked") + public CodeTree createGetSpecializationBits() { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + FrameState frame = FrameState.createEmpty(); + + b.tree(multiState.createLoad(frame, specializationStates.toArray())); + + b.declaration("boolean[]", "result", "new boolean[" + specializationStates.size() + "]"); + + for (int i = 0; i < specializationStates.size(); i++) { + b.startAssign("result[" + i + "]"); + b.tree(multiState.createContains(frame, new Object[]{specializationStates.get(i)})); + b.end(); + } + + b.startReturn().string("result").end(); + + return b.build(); + } + public boolean needsRewrites() { return true; } + + @Override + public List filterSpecializations(List implementedSpecializations) { + if (!(cinstr instanceof QuickenedInstruction)) { + return implementedSpecializations; + } + + QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; + return qinstr.getActiveSpecs(); + } + + @Override + public boolean isStateGuaranteed(boolean stateGuaranteed) { + if (stateGuaranteed) { + return true; + } + + if (cinstr instanceof QuickenedInstruction && ((QuickenedInstruction) cinstr).getActiveSpecs().size() == 1) { + return true; + } + + return false; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 68dc6f2f9871..74d7e2eb2954 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -26,6 +26,7 @@ import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -603,8 +604,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); mDoSetResultUnboxed.addParameter(varBc); - CodeVariableElement varTargetBci = new CodeVariableElement(context.getType(int.class), "bci"); - mDoSetResultUnboxed.addParameter(varTargetBci); + CodeVariableElement varStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); + mDoSetResultUnboxed.addParameter(varStartBci); + + CodeVariableElement varBciOffset = new CodeVariableElement(context.getType(int.class), "bciOffset"); + mDoSetResultUnboxed.addParameter(varBciOffset); CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); mDoSetResultUnboxed.addParameter(varTargetType); @@ -614,27 +618,31 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); - b.startStatement().startStaticCall(types.CompilerAsserts, "neverPartOfCompilation").end(2); + b.startIf().variable(varBciOffset).string(" == 0").end().startBlock(); + b.returnStatement(); + b.end(); - b.startSwitch().tree(OperationGeneratorUtils.createReadOpcode(varBc, vars.bci)).end(); - b.startBlock(); + b.startStatement().startStaticCall(types.CompilerDirectives, "transferToInterpreter").end(2); - for (Instruction instr : m.getInstructions()) { + b.declaration("int", "bci", "startBci - bciOffset"); - CodeTree tree = instr.createSetResultBoxed(vars.asExecution(), varBoxed, varTargetType); - if (tree != null) { - b.startCase().variable(instr.opcodeIdField).end(); - b.startBlock(); + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars.asExecution(), instr -> { + if (instr == null) { + return null; + } - b.tree(tree); + CodeTree tree = instr.createSetResultBoxed(vars.asExecution(), varBoxed, varTargetType); + if (tree == null) { + return null; + } - b.statement("break"); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - b.end(); - } - } + builder.tree(tree); + builder.statement("break"); - b.end(); + return builder.build(); + })); vars.bc = fldBc; vars.bci = fldBci; @@ -835,23 +843,29 @@ void createSetBoxedForInstructions(CodeTypeElement typBuilderImpl) { continue; } + if (instr instanceof QuickenedInstruction) { + continue; + } + CustomInstruction cinstr = (CustomInstruction) instr; SingleOperationData soData = cinstr.getData(); { CodeVariableElement varUnboxed = new CodeVariableElement(context.getType(boolean.class), "unboxed"); - CodeExecutableElement metSetResultUnboxed = new CodeExecutableElement( + cinstr.setSetResultUnboxedMethod(cinstr.getPlugs().createSetResultBoxed(varUnboxed)); + } + + if (m.isTracing()) { + CodeExecutableElement metGetStateBits = new CodeExecutableElement( MOD_PRIVATE_STATIC, - context.getType(void.class), soData.getName() + "_doSetResultUnboxed_", + arrayOf(context.getType(boolean.class)), soData.getName() + "_doGetStateBits_", new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), - new CodeVariableElement(context.getType(int.class), "$bci"), - varUnboxed); - typBuilderImpl.add(metSetResultUnboxed); - cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); - - CodeTreeBuilder b = metSetResultUnboxed.createBuilder(); - b.tree(cinstr.getPlugs().createSetResultBoxed(varUnboxed)); - cinstr.setSetResultUnboxedMethod(metSetResultUnboxed); + new CodeVariableElement(context.getType(int.class), "$bci")); + typBuilderImpl.add(metGetStateBits); + cinstr.setGetSpecializationBits(metGetStateBits); + + CodeTreeBuilder b = metGetStateBits.createBuilder(); + b.tree(cinstr.getPlugs().createGetSpecializationBits()); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 1180aff13e5e..bc662ed910a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -1,6 +1,9 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -16,6 +19,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; @@ -29,7 +33,6 @@ public class OperationsContext { public Instruction commonBranch; public Instruction commonBranchFalse; - public Instruction commonBranchFalseBoxed; public LoadArgumentInstruction[] loadArgumentInstructions; public LoadConstantInstruction[] loadConstantInstructions; @@ -37,6 +40,9 @@ public class OperationsContext { public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); + private final Map customInstructionNameMap = new HashMap<>(); + private final Map opDataNameMap = new HashMap<>(); + private OperationsData data; public OperationsContext() { createCommonInstructions(); @@ -48,8 +54,7 @@ private void createCommonInstructions() { commonBranch = add(new BranchInstruction(instructionId++)); - commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++, false)); - commonBranchFalseBoxed = add(new ConditionalBranchInstruction(this, instructionId++, true)); + commonBranchFalse = add(new ConditionalBranchInstruction(instructionId++)); } private void createBuiltinOperations() { @@ -60,9 +65,6 @@ private void createBuiltinOperations() { add(new Operation.While(this, operationId++)); add(new Operation.TryCatch(this, operationId++)); -// Instruction iConst; -// Instruction iStloc; - add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); @@ -77,8 +79,6 @@ private void createBuiltinOperations() { add(new InstrumentationExitInstruction(instructionId++, true)), add(new InstrumentationLeaveInstruction(instructionId++)))); -// Instruction iSuper = add(new SuperInstruction(instructionId++, new Instruction[]{iConst, -// iStloc})); } private void createLoadStoreLocal() { @@ -141,12 +141,32 @@ public void processOperation(SingleOperationData opData) { return; } - CustomInstruction instr = new CustomInstruction("custom." + opData.getName(), getNextInstructionId(), opData); + CustomInstruction instr = new CustomInstruction("c." + opData.getName(), getNextInstructionId(), opData); add(instr); + customInstructionNameMap.put(opData.getName(), instr); + opDataNameMap.put(opData.getName(), opData); int numChildren = props.isVariadic ? -1 : props.numStackValues; Operation.Simple op = new Operation.Simple(this, opData.getName(), getNextOperationId(), numChildren, instr); add(op); } + + public void processDecisions(OperationDecisions decisions) { + for (OperationDecisions.Quicken quicken : decisions.getQuicken()) { + CustomInstruction cinstr = customInstructionNameMap.get(quicken.getOperation()); + if (cinstr == null) { + // TODO line number or sth + data.addError("Invalid declaration: undefined operation %s.", quicken.getOperation()); + } + + SingleOperationData opData = opDataNameMap.get(quicken.getOperation()); + + add(new QuickenedInstruction(cinstr, instructionId++, opData, List.of(quicken.specializations))); + } + } + + public void setData(OperationsData data) { + this.data = data; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 2d5f776bf858..fcc90d6c1a20 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -24,6 +24,7 @@ public class OperationsData extends Template { private ExecutableElement parseMethod; private boolean tracing; + private OperationDecisions decisions; public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); @@ -81,13 +82,18 @@ public Collection getOperations() { } public void initializeContext() { + context.setData(this); for (SingleOperationData data : operations) { context.processOperation(data); } + context.processDecisions(decisions); } public boolean isGenerateAOT() { return true; } + public void setDecisions(OperationDecisions decisions) { + this.decisions = decisions; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index b0b730c27347..dbccf693f45b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,5 +1,8 @@ package com.oracle.truffle.dsl.processor.operations; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; @@ -10,27 +13,22 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.parser.AbstractParser; public class OperationsParser extends AbstractParser { - private static AnnotationMirror getAnnotationMirror(List mirror, DeclaredType type) { - for (AnnotationMirror m : mirror) { - if (m.getAnnotationType().equals(type)) { - return m; - } - } - return null; - } - @Override protected OperationsData parse(Element element, List mirror) { TypeElement typeElement = (TypeElement) element; - AnnotationMirror generateOperationsMirror = getAnnotationMirror(mirror, types.GenerateOperations); + AnnotationMirror generateOperationsMirror = ElementUtils.findAnnotationMirror(mirror, types.GenerateOperations); OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); { @@ -85,7 +83,6 @@ protected OperationsData parse(Element element, List mirror) { } opData.redirectMessagesOnGeneratedElements(data); - } if (!hasSome) { @@ -93,7 +90,14 @@ protected OperationsData parse(Element element, List mirror) { return data; } - // data.setTracing(true); + boolean isTracing = false; + + if (!isTracing) { + OperationDecisions decisions = parseDecisions(typeElement, generateOperationsMirror, data); + data.setDecisions(decisions); + } + + data.setTracing(isTracing); if (data.hasErrors()) { return data; @@ -104,6 +108,43 @@ protected OperationsData parse(Element element, List mirror) { return data; } + @SuppressWarnings("unchecked") + private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror generateOperationsMirror, OperationsData data) { + String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); + OperationDecisions mainDecisions = parseDecisions(element, file, data); + if (mainDecisions == null) { + return null; + } + + List overrideFiles = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionOverrideFiles").getValue(); + + for (String overrideFile : overrideFiles) { + OperationDecisions overrideDecision = parseDecisions(element, overrideFile, data); + if (overrideDecision != null) { + mainDecisions.merge(overrideDecision); + } + } + + return mainDecisions; + } + + private OperationDecisions parseDecisions(TypeElement element, String path, OperationsData data) { + File file = CompilerFactory.getCompiler(element).getEnclosingFile(processingEnv, element); + String parent = file.getParent(); + File target = new File(parent, path); + try { + XMLStreamReader rd = XMLInputFactory.newDefaultFactory().createXMLStreamReader(new FileInputStream(target)); + rd.next(); + + return OperationDecisions.deserialize(rd); + } catch (FileNotFoundException ex) { + data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", target.toString()); + } catch (XMLStreamException ex) { + data.addError("Exception while reading decisions file: %s", ex); + } + return null; + } + @Override public DeclaredType getAnnotationType() { return types.GenerateOperations; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index bbcd2082133b..4ccae15c54da 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -17,14 +17,20 @@ public boolean standardPrologue() { return false; } + private CodeTree createGetBranchTarget(ExecutionVariables vars) { + return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort")// + .variable(vars.bc) // + .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end() // + .end().build(); + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.bci).startCall("LE_BYTES", "getShort"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); - b.end(2); + b.startAssign(vars.bci); + b.tree(createGetBranchTarget(vars)); + b.end(); b.statement("continue loop"); return b.build(); @@ -59,4 +65,12 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_BRANCH"), + createGetBranchTarget(vars) + }; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 3af4da19cb02..164ca553bf46 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -1,29 +1,20 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { private final ProcessorContext context = ProcessorContext.getInstance(); private final DeclaredType ConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); - private final OperationsContext ctx; - private final boolean boxed; - public ConditionalBranchInstruction(OperationsContext ctx, int id, boolean boxed) { - super(boxed ? "branch.false.boxed" : "branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); - this.ctx = ctx; - this.boxed = boxed; + public ConditionalBranchInstruction(int id) { + super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); } @Override @@ -45,28 +36,20 @@ public boolean isBranchInstruction() { return true; } + @SuppressWarnings("unused") + private CodeTree createBranchTarget(ExecutionVariables vars) { + return CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")"); + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(2) + ")]"); - if (boxed) { - b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); - } else { - b.declaration("boolean", "cond", (CodeTree) null); - - b.startTryBlock(); - b.statement("cond = frame.getBoolean(sp - 1)"); - b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.frame.FrameSlotTypeException"), "ex"); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + // TODO: we should do (un)boxing elim here. + b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); - b.statement("cond = (boolean) frame.getObject(sp - 1)"); - - // TODO lock - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.commonBranchFalseBoxed.opcodeIdField)); - b.end(); - } b.statement("sp -= 1"); b.startIf().startCall("profile", "profile").string("cond").end(2); @@ -74,7 +57,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); b.statement("continue loop"); b.end().startElseBlock(); - b.startAssign(vars.bci).string("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")").end(); + b.startAssign(vars.bci).tree(createBranchTarget(vars)).end(); b.statement("continue loop"); b.end(); @@ -83,36 +66,19 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf(); - - if (boxed) { - b.string("!"); - } - - b.variable(varBoxed).end().startBlock(); - - b.startStatement().startCall("LE_BYTES", "putShort"); - b.variable(vars.bc); - b.variable(vars.bci); - - b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)); - if (boxed) { - b.variable(ctx.commonBranchFalse.opcodeIdField); - } else { - b.variable(ctx.commonBranchFalseBoxed.opcodeIdField); - } - b.end(); - - b.end(2); - - b.end(); - return b.build(); + return null; } @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_BRANCH_COND"), + createBranchTarget(vars) + }; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index b1f6699973e8..efc03c734405 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -1,5 +1,6 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.ArrayList; import java.util.List; import javax.lang.model.element.ExecutableElement; @@ -10,6 +11,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -29,15 +31,20 @@ public enum DataKind { private DataKind[] dataKinds = null; private int numChildNodes; private int numConsts; - private CodeExecutableElement setResultUnboxedMethod; - private CodeExecutableElement setInputUnboxedMethod; + private CodeTree setResultUnboxedMethod; private OperationsBytecodeNodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; + private CodeExecutableElement getSpecializationBits; + private final List quickenedVariants = new ArrayList<>(); public SingleOperationData getData() { return data; } + public String getUniqueName() { + return data.getName(); + } + public void setExecuteMethod(ExecutableElement executeMethod) { this.executeMethod = executeMethod; } @@ -221,6 +228,11 @@ public String dumpInfo() { sb.append(" ").append(ofs).append(" ").append(kind).append("\n"); } + sb.append(" Specializations:\n"); + for (SpecializationData sd : data.getNodeData().getSpecializations()) { + sb.append(" ").append(sd.getId()).append("\n"); + } + return sb.toString(); } @@ -232,27 +244,32 @@ public void setNumConsts(int numConsts) { this.numConsts = numConsts; } - public void setSetResultUnboxedMethod(CodeExecutableElement setResultUnboxedMethod) { + public void setSetResultUnboxedMethod(CodeTree setResultUnboxedMethod) { this.setResultUnboxedMethod = setResultUnboxedMethod; } - public void setSetInputUnboxedMethod(CodeExecutableElement setInputUnboxedMethod) { - this.setInputUnboxedMethod = setInputUnboxedMethod; - } - public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { this.prepareAOTMethod = prepareAOTMethod; } + public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits) { + this.getSpecializationBits = getSpecializationBits; + + } + @Override public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return CodeTreeBuilder.createBuilder() // - .startStatement() // - .startStaticCall(setResultUnboxedMethod) // - .variable(vars.bc) // - .variable(vars.bci) // - .startGroup().string("!").variable(varBoxed).end() // - .end(2).build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (!vars.bci.getName().equals("$bci")) { + b.declaration("int", "$bci", CodeTreeBuilder.singleVariable(vars.bci)); + } + + b.declaration("boolean", "unboxed", "!" + varBoxed.getName()); + + b.tree(setResultUnboxedMethod); + + return b.build(); } public OperationsBytecodeNodeGeneratorPlugs getPlugs() { @@ -278,4 +295,20 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod .tree(root) // .end(2).build(); } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + CodeTree[] result = new CodeTree[2]; + result[0] = CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_CUSTOM"); + result[1] = CodeTreeBuilder.createBuilder().startStaticCall(getSpecializationBits).variable(vars.bc).variable(vars.bci).end().build(); + return result; + } + + public void addQuickenedVariant(QuickenedInstruction quick) { + quickenedVariants.add(quick); + } + + public List getQuickenedVariants() { + return quickenedVariants; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 229650cec270..9246653e6f9b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -36,4 +36,11 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_OTHER") + }; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index adc7fca95301..8c6855f2273b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -13,8 +13,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public abstract class Instruction { @@ -130,7 +130,10 @@ public final CodeTree getImplicitValue(BuilderVariables vars, Instruction instr) public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { switch (this) { case STACK_VALUE: - return CodeTreeBuilder.createBuilder().statement("sb.append(\"x\")").build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // + .doubleQuote("pop[-%d]") // + .startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + op.getArgumentOffset(n) + "]").end() // + .end(3).build(); case STACK_VALUE_IGNORED: return CodeTreeBuilder.createBuilder().statement("sb.append(\"_\")").build(); case CONST_POOL: @@ -573,9 +576,10 @@ public boolean isReturnInstruction() { public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { + int curIndex = index; for (int i = 0; i < inputs.length; i++) { if (inputs[i] == InputType.STACK_VALUE || inputs[i] == InputType.STACK_VALUE_IGNORED) { - if (index-- == 0) { + if (curIndex-- == 0) { return CodeTreeBuilder.createBuilder().startParantheses() // .variable(vars.bc) // .string("[") // @@ -588,4 +592,9 @@ public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { throw new AssertionError("should not reach here"); } + + @SuppressWarnings("unused") + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[0]; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 6a54a69801da..295e78bf54a7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -103,4 +103,12 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_ARGUMENT"), + CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + }; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 4e89afae500b..679ce21736a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -94,4 +94,12 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return createSetResultBoxed(vars, new CodeVariableElement(new CodeTypeMirror(TypeKind.BOOLEAN), "true"), null); } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_CONSTANT"), + CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + }; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 3172a12af0ae..0dd4be5dc6ab 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -107,4 +107,12 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_LOCAL"), + CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + }; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java new file mode 100644 index 000000000000..1ef789567671 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -0,0 +1,98 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import java.util.ArrayList; +import java.util.List; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData; + +public class QuickenedInstruction extends CustomInstruction { + + private final CustomInstruction orig; + private final List activeSpecNames; + private final List activeSpecs; + + private static String makeName(CustomInstruction orig, List activeSpecNames) { + StringBuilder sb = new StringBuilder(orig.name); + sb.append(".q"); + for (String activeSpec : activeSpecNames) { + sb.append('.'); + sb.append(activeSpec); + } + + return sb.toString(); + } + + public List getActiveSpecNames() { + return activeSpecNames; + } + + public List getActiveSpecs() { + return activeSpecs; + } + + public CustomInstruction getOrig() { + return orig; + } + + @Override + public String getUniqueName() { + StringBuilder sb = new StringBuilder(getData().getName()); + sb.append("_q"); + for (String activeSpec : activeSpecNames) { + sb.append("_"); + sb.append(activeSpec.replaceAll("[^a-zA-Z0-9_]", "_")); + } + return sb.toString(); + } + + public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData data, List activeSpecNames) { + super(makeName(orig, activeSpecNames), id, data); + this.orig = orig; + this.activeSpecNames = activeSpecNames; + + if (activeSpecNames.isEmpty()) { + data.addError("Invalid quickened instruction: no specializations defined."); + } + + activeSpecs = new ArrayList<>(data.getNodeData().getSpecializations()); + activeSpecs.removeIf(spec -> { + for (String activeSpec : activeSpecNames) { + if (spec.getId().equals(activeSpec)) { + return false; + } + } + return true; + }); + + // TODO we should probably error if one of the active specializations is not found + + if (activeSpecs.isEmpty()) { + data.addError("Invalid quickened instruction: no specializations matched defined."); + } + + orig.addQuickenedVariant(this); + } + + @Override + public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { + return orig.createSetResultBoxed(vars, varBoxed, varTargetType); + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return orig.createPrepareAOT(vars, language, root); + } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return orig.createTracingArguments(vars); + } + + @Override + public void addQuickenedVariant(QuickenedInstruction quick) { + throw new AssertionError("should not add quickened variants to quickened instructions"); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 11741ae14ef9..009adabcf317 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -3,7 +3,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class ReturnInstruction extends Instruction { @@ -38,4 +37,11 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_OTHER"), + }; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index a5a2af8ee1b2..9c82707813d0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -3,7 +3,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class StoreLocalInstruction extends Instruction { @@ -55,4 +54,13 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public CodeTree[] createTracingArguments(ExecutionVariables vars) { + return new CodeTree[]{ + CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_STORE_LOCAL"), + CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(1) + ")"), + CodeTreeBuilder.singleString("frame.getValue(sp - 1).getClass()") + }; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 89da92ba4a93..4202d266cf2e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,7 +7,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class SuperInstruction extends Instruction { private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java index 41fe19eb1f9f..1bfbc1349465 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java @@ -40,9 +40,13 @@ */ package com.oracle.truffle.sl.test; +import java.io.PrintWriter; + import org.junit.Test; import org.junit.runner.RunWith; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; + @RunWith(SLTestRunner.class) @SLTestSuite({"tests"}) public class SLSimpleTestSuite { diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java index d9a301f09150..29fdec0d3d90 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @@ -349,7 +349,6 @@ public static void runInMain(Class testClass, String[] args) throws Initializ suite.filter(new NameFilter(args[0])); } Result r = core.run(suite); - ExecutionTracer.get().dump(); if (!r.wasSuccessful()) { System.exit(1); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index ecb1709346b3..a3814c3b3029 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -46,7 +46,7 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations +@GenerateOperations(decisionsFile = "decisions.xml") @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml new file mode 100644 index 000000000000..543944c60202 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ca63a0572505595cbf24f75979b25923e737eae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 26 Apr 2022 16:53:41 +0200 Subject: [PATCH 053/312] [wip] we quick now --- truffle/mx.truffle/suite.py | 3 +- .../operation/tracing/ExecutionTracer.java | 221 ++++++++++-------- .../api/operation/tracing/XmlUtils.java | 54 ----- .../processor/java/compiler/JDTCompiler.java | 4 +- .../operations/OperationDecisions.java | 62 ++--- .../OperationsBytecodeNodeGeneratorPlugs.java | 37 +-- .../operations/OperationsCodeGenerator.java | 35 +++ .../processor/operations/OperationsData.java | 15 +- .../operations/OperationsParser.java | 42 ++-- .../instructions/CustomInstruction.java | 8 + .../truffle/sl/operations/SLOperations.java | 2 +- .../sl/operations/decisions-manual.json | 30 +++ .../truffle/sl/operations/decisions.json | 52 +++++ .../truffle/sl/operations/decisions.xml | 23 -- 14 files changed, 336 insertions(+), 252 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index da26b8d0d52c..ac55da867c3b 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -282,8 +282,7 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "requires" : [""], - "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", "com.oracle.truffle.api.instrumentation"], + "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", "com.oracle.truffle.api.instrumentation", "TruffleJSON"], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index fb3654df1317..2cb7f4c2a806 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,42 +1,40 @@ package com.oracle.truffle.api.operation.tracing; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readAttribute; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readAttributeInt; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readCharactersInt; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readCharactersLong; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readEndElement; -import static com.oracle.truffle.api.operation.tracing.XmlUtils.readStartElement; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import javax.xml.stream.FactoryConfigurationError; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; +import com.oracle.truffle.tools.utils.json.JSONTokener; public class ExecutionTracer { private static final Map TRACERS = new HashMap<>(); + private static final String KEY_TRACERS = "tracers"; + private static final String KEY_KEY = "key"; + private static final String KEY_ACTIVE_SPECIALIZATION_OCCURENCES = "activeSpecializations"; + private static final String KEY_COUNT = "count"; + public static ExecutionTracer get(String key) { return TRACERS.computeIfAbsent(key, ExecutionTracer::new); } private final String key; + private String outputPath; + private Map specializationNames = new HashMap<>(); - public ExecutionTracer(String key) { + private ExecutionTracer(String key) { assert TRACERS.get(key) == null; this.key = key; } @@ -44,55 +42,53 @@ public ExecutionTracer(String key) { static { // deser - String stateFile = "/tmp/state.xml"; + String stateFile = "/tmp/state.json"; try { FileInputStream fi = new FileInputStream(new File(stateFile)); - XMLStreamReader rd = XMLInputFactory.newDefaultFactory().createXMLStreamReader(fi); + JSONTokener tok = new JSONTokener(fi); + JSONObject o = new JSONObject(tok); - readStartElement(rd, "STATE"); + JSONArray tracers = o.getJSONArray("tracers"); - int state = rd.next(); - while (state == XMLStreamReader.START_ELEMENT) { - assert rd.getName().getLocalPart().equals("T"); - - ExecutionTracer tr = ExecutionTracer.deserializeState(rd); + for (int i = 0; i < tracers.length(); i++) { + JSONObject tracer = tracers.getJSONObject(i); + ExecutionTracer tr = ExecutionTracer.deserializeState(tracer); TRACERS.put(tr.key, tr); - - readEndElement(rd, "T"); - - state = rd.next(); } } catch (FileNotFoundException ex) { - // we ignore FNFE since that is true on the first run - } catch (Exception e1) { - throw new RuntimeException("error deserializing tracer state", e1); + System.err.println("not found"); } Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(new File(stateFile)))) { + JSONObject result = new JSONObject(); + JSONArray tracers = new JSONArray(); - // ser - try { - FileOutputStream fo = new FileOutputStream(new File(stateFile)); - XMLStreamWriter wr = XMLOutputFactory.newDefaultFactory().createXMLStreamWriter(fo); - - wr.writeStartDocument(); - wr.writeStartElement("STATE"); for (Map.Entry ent : TRACERS.entrySet()) { ExecutionTracer tracer = ent.getValue(); - wr.writeStartElement("T"); - wr.writeAttribute("key", tracer.key); - tracer.serializeState(wr); - wr.writeEndElement(); - + tracers.put(tracer.serializeState()); tracer.dump(new PrintWriter(System.out)); + System.out.flush(); } - wr.writeEndElement(); - wr.writeEndDocument(); + + result.put(KEY_TRACERS, tracers); + fo.append(result.toString(2)); } catch (Exception e) { - e.printStackTrace(); - System.err.flush(); + // failing to write the state is a critical exception + throw new RuntimeException(e); + } + + for (Map.Entry ent : TRACERS.entrySet()) { + ExecutionTracer tracer = ent.getValue(); + try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(tracer.outputPath))) { + JSONArray decisions = tracer.createDecisions(); + fo.append(decisions.toString(2)); + } catch (Exception e) { + // failing to write the decisions is not as big of an exception + e.printStackTrace(); + } } })); } @@ -213,6 +209,10 @@ private static class ActiveSpecializationOccurence { final String instructionId; final boolean[] activeSpecializations; + private static final String KEY_INSTRUCTION_ID = "i"; + private static final String KEY_ACTIVE_SPECIALIZATIONS = "a"; + private static final String KEY_LENGTH = "l"; + ActiveSpecializationOccurence(String instructionId, boolean... activeSpecializations) { this.instructionId = instructionId; this.activeSpecializations = activeSpecializations; @@ -244,44 +244,54 @@ public String toString() { return "ActiveSpecializationOccurence[instructionId=" + instructionId + ", activeSpecializations=" + Arrays.toString(activeSpecializations) + "]"; } - void serializeState(XMLStreamWriter wr) throws XMLStreamException { - wr.writeAttribute("i", instructionId); - wr.writeAttribute("n", "" + activeSpecializations.length); + JSONObject serializeState() { + JSONObject result = new JSONObject(); + result.put(KEY_INSTRUCTION_ID, instructionId); + result.put(KEY_LENGTH, activeSpecializations.length); - wr.writeStartElement("A"); + JSONArray arr = new JSONArray(); int i = 0; for (boolean act : activeSpecializations) { if (act) { - wr.writeStartElement("a"); - wr.writeCharacters("" + i); - wr.writeEndElement(); + arr.put(i); } i++; } - wr.writeEndElement(); + result.put(KEY_ACTIVE_SPECIALIZATIONS, arr); + + return result; } - static ActiveSpecializationOccurence deserializeState(XMLStreamReader rd) throws XMLStreamException { - String instructionId = readAttribute(rd, "i"); - int count = readAttributeInt(rd, "n"); + JSONObject createDecision(String[] specNames) { + assert specNames.length >= activeSpecializations.length : instructionId + "should have at least" + activeSpecializations.length + " specializations, but has " + specNames.length; + JSONObject result = new JSONObject(); + result.put("type", "Quicken"); + assert instructionId.startsWith("c."); + result.put("operation", instructionId.substring(2)); // drop the `c.` prefix + + JSONArray specs = new JSONArray(); + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + specs.put(specNames[i]); + } + } - boolean[] activeSpecializations = new boolean[count]; + result.put("specializations", specs); - readStartElement(rd, "A"); + return result; + } - int state = rd.next(); - while (state == XMLStreamReader.START_ELEMENT) { - assert rd.getName().getLocalPart().equals("a"); + static ActiveSpecializationOccurence deserializeState(JSONObject o) { + String instructionId = o.getString(KEY_INSTRUCTION_ID); + int len = o.getInt(KEY_LENGTH); - int index = readCharactersInt(rd); - activeSpecializations[index] = true; + boolean[] activeSpecializations = new boolean[len]; - readEndElement(rd, "a"); - state = rd.next(); + JSONArray arr = o.getJSONArray(KEY_ACTIVE_SPECIALIZATIONS); + for (int i = 0; i < arr.length(); i++) { + int idx = arr.getInt(i); + activeSpecializations[i] = true; } - // end ASs - - assert state == XMLStreamReader.END_ELEMENT; return new ActiveSpecializationOccurence(instructionId, activeSpecializations); } @@ -322,8 +332,6 @@ public final void traceInstruction(int bci, String id, int instructionType, Obje @TruffleBoundary public final void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { - // System.out.printf(" [TS] %04x %d %d %s%n", bci, id, specializationId, - // List.of(arguments)); } @SuppressWarnings({"unused", "static-method"}) @@ -362,45 +370,68 @@ public final void dump(PrintWriter writer) { // }); } - public void serializeState(XMLStreamWriter wr) throws XMLStreamException { - wr.writeStartElement("As"); + public JSONObject serializeState() { + JSONObject result = new JSONObject(); + result.put(KEY_KEY, key); - for (Map.Entry ent : activeSpecializationsMap.entrySet()) { - wr.writeStartElement("A"); - wr.writeAttribute("c", "" + ent.getValue()); + JSONArray arr = new JSONArray(); + for (Map.Entry entry : activeSpecializationsMap.entrySet()) { + ActiveSpecializationOccurence as = entry.getKey(); - ent.getKey().serializeState(wr); - wr.writeEndElement(); + JSONObject o = as.serializeState(); + o.put(KEY_COUNT, entry.getValue()); + + arr.put(o); } - wr.writeEndElement(); + result.put(KEY_ACTIVE_SPECIALIZATION_OCCURENCES, arr); + return result; } - public static ExecutionTracer deserializeState(XMLStreamReader rd) throws XMLStreamException { - - String key = readAttribute(rd, "key"); - + public static ExecutionTracer deserializeState(JSONObject tracer) { + String key = tracer.getString(KEY_KEY); ExecutionTracer result = new ExecutionTracer(key); - readStartElement(rd, "As"); + JSONArray arr = tracer.getJSONArray(KEY_ACTIVE_SPECIALIZATION_OCCURENCES); + for (int i = 0; i < arr.length(); i++) { + JSONObject o = arr.getJSONObject(i); - int state = rd.next(); - while (state == XMLStreamReader.START_ELEMENT) { - assert rd.getName().getLocalPart().equals("A"); + long count = o.getLong(KEY_COUNT); + o.remove(KEY_COUNT); - long value = XmlUtils.readAttributeLong(rd, "c"); + ActiveSpecializationOccurence as = ActiveSpecializationOccurence.deserializeState(o); + result.activeSpecializationsMap.put(as, count); + } - ActiveSpecializationOccurence k = ActiveSpecializationOccurence.deserializeState(rd); + return result; + } - result.activeSpecializationsMap.put(k, value); + public JSONArray createDecisions() { + int numQuicken = 10; - readEndElement(rd, "A"); + JSONArray result = new JSONArray(); - state = rd.next(); - } - // end ASOs - assert state == XMLStreamReader.END_ELEMENT; + activeSpecializationsMap.entrySet().stream() // + .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // + .limit(numQuicken) // + .forEachOrdered(e -> { + result.put(e.getKey().createDecision(specializationNames.get(e.getKey().instructionId))); + }); return result; } + + @Override + public String toString() { + return "ExecutionTracer [key=" + key + ", activeSpecializationsMap=" + activeSpecializationsMap + "]"; + } + + public void setOutputPath(String outputPath) { + this.outputPath = outputPath; + } + + public void setInstructionSpecializationNames(String instructionName, String... specializationNames) { + this.specializationNames.put(instructionName, specializationNames); + } + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java deleted file mode 100644 index f267e9221433..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/XmlUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.oracle.truffle.api.operation.tracing; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -final class XmlUtils { - public static void readStartElement(XMLStreamReader rd, String name) throws XMLStreamException { - String readName = readStartElement(rd); - assert readName.equals(name); - } - - public static String readStartElement(XMLStreamReader rd) throws XMLStreamException { - int state = rd.next(); - assert state == XMLStreamReader.START_ELEMENT; - return rd.getName().getLocalPart(); - } - - public static void readEndElement(XMLStreamReader rd, String name) throws XMLStreamException { - int state = rd.next(); - assert state == XMLStreamReader.END_ELEMENT : "got " + state + " " + rd.getName(); - assert rd.getName().getLocalPart().equals(name); - } - - public static String readCharacters(XMLStreamReader rd) throws XMLStreamException { - int state = rd.next(); - assert state == XMLStreamReader.CHARACTERS; - return rd.getText(); - } - - public static int readCharactersInt(XMLStreamReader rd) throws XMLStreamException { - return Integer.parseInt(readCharacters(rd)); - } - - public static long readCharactersLong(XMLStreamReader rd) throws XMLStreamException { - return Long.parseLong(readCharacters(rd)); - } - - public static boolean readCharactersBoolean(XMLStreamReader rd) throws XMLStreamException { - String v = readCharacters(rd); - return v.toLowerCase().equals("true"); - } - - public static String readAttribute(XMLStreamReader rd, String name) throws XMLStreamException { - return rd.getAttributeValue(null, name); - } - - public static int readAttributeInt(XMLStreamReader rd, String name) throws XMLStreamException { - return Integer.parseInt(readAttribute(rd, name)); - } - - public static long readAttributeLong(XMLStreamReader rd, String name) throws XMLStreamException { - return Long.parseLong(readAttribute(rd, name)); - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java index 8a93d2bdfef2..27b893b254e8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @@ -58,11 +58,11 @@ import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.tools.utils.json.XML; +import com.oracle.truffle.tools.utils.json.XMLParserConfiguration; public class JDTCompiler extends AbstractCompiler { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 9c5ed426a1c5..14a5c68dadd3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -8,6 +8,9 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; + public class OperationDecisions { private final List quicken = new ArrayList<>(); @@ -74,68 +77,35 @@ private Quicken(String operation, String[] specializations) { this.specializations = specializations; } - public static Quicken deserialize(XMLStreamReader rd) throws XMLStreamException { - assert rd.getName().getLocalPart().equals("Quicken"); - String operation = rd.getAttributeValue(null, "operation"); - - int state = rd.nextTag(); - if (state == XMLStreamReader.END_ELEMENT) { - return new Quicken(operation, new String[0]); - } - - assert state == XMLStreamReader.START_ELEMENT; - assert rd.getName().getLocalPart().equals("Specializations"); + public static Quicken deserialize(JSONObject o) { + String operation = o.getString("operation"); + JSONArray specs = o.getJSONArray("specializations"); List specializations = new ArrayList<>(); - state = rd.nextTag(); - while (state == XMLStreamReader.START_ELEMENT) { - assert rd.getName().getLocalPart().equals("Specialization"); - - String id = rd.getAttributeValue(null, "id"); - assert id != null; - - specializations.add(id); - - state = rd.nextTag(); - if (state != XMLStreamReader.END_ELEMENT) { - throw new AssertionError(); - } - - state = rd.nextTag(); + for (int i = 0; i < specs.length(); i++) { + specializations.add(specs.getString(i)); } - assert state == XMLStreamReader.END_ELEMENT; // end of Specializations - return new Quicken(operation, specializations.toArray(new String[specializations.size()])); } } - public static OperationDecisions deserialize(XMLStreamReader rd) throws XMLStreamException { - if (!rd.getName().getLocalPart().equals("Decisions")) { - throw new AssertionError(); - } - + public static OperationDecisions deserialize(JSONArray o) { OperationDecisions decisions = new OperationDecisions(); - int state = rd.nextTag(); - while (state == XMLStreamReader.START_ELEMENT) { - switch (rd.getLocalName()) { - case "Quicken": - Quicken quicken = Quicken.deserialize(rd); - decisions.quicken.add(quicken); + for (int i = 0; i < o.length(); i++) { + JSONObject decision = o.getJSONObject(i); - state = rd.nextTag(); - if (!(state == XMLStreamReader.END_ELEMENT && rd.getLocalName().equals("Quicken"))) { - throw new AssertionError(state); - } + switch (decision.getString("type")) { + case "Quicken": + Quicken q = Quicken.deserialize(decision); + decisions.quicken.add(q); break; default: // TODO error handling - throw new AssertionError("invalid decision: " + rd.getLocalName()); + throw new AssertionError("invalid decision type" + decision.getString("type")); } - - state = rd.nextTag(); } return decisions; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 7c5cbfc038b5..514f57f9512a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -105,8 +105,8 @@ public void addAdditionalStateBits(List stateObjects) { @Override public void setStateObjects(List stateObjects) { - this.specializationStates = stateObjects.stream()// - .filter(x -> x instanceof SpecializationData)// + this.specializationStates = stateObjects.stream() // + .filter(x -> x instanceof SpecializationData) // .collect(Collectors.toUnmodifiableList()); } @@ -134,6 +134,9 @@ public String transformNodeMethodName(String name) { @Override public String transformNodeInnerTypeName(String name) { + if (cinstr instanceof QuickenedInstruction) { + return ((QuickenedInstruction) cinstr).getOrig().getUniqueName() + "_" + name; + } String result = cinstr.getUniqueName() + "_" + name; innerTypeNames.add(result); return result; @@ -377,10 +380,7 @@ public boolean createCallSpecialization(FrameState frameState, SpecializationDat @Override public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { - if (isVariadic) { - return false; - } - + String easName = transformNodeMethodName("executeAndSpecialize"); if (cinstr instanceof QuickenedInstruction) { QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; @@ -391,18 +391,25 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui new CodeVariableElement(context.getType(int.class), "$bci"), qinstr.getOrig().opcodeIdField)); - String parentEASName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; - builder.startStatement().startCall(parentEASName); - addNodeCallParameters(builder, false, false); - frameState.addReferencesTo(builder); - builder.end(2); - builder.returnStatement(); + easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; - return true; } - builder.statement(call); - builder.returnStatement(); + if (isVariadic) { + builder.startReturn(); + } else { + builder.startStatement(); + } + + builder.startCall(easName); + addNodeCallParameters(builder, false, false); + frameState.addReferencesTo(builder); + builder.end(2); + + if (!isVariadic) { + builder.returnStatement(); + } + return true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 74d7e2eb2954..19fbe654f72d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -16,6 +16,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -40,6 +41,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private final Set MOD_STATIC = Set.of(Modifier.STATIC); private OperationsBytecodeCodeGenerator bytecodeGenerator; private static final boolean FLAG_NODE_AST_PRINTING = false; @@ -138,6 +140,39 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); typBuilderImpl.setEnclosingElement(typBuilder); + if (m.isTracing()) { + String decisionsFilePath = m.getDecisionsFilePath(); + if (decisionsFilePath != null) { + CodeExecutableElement mStaticInit = new CodeExecutableElement(MOD_STATIC, null, ""); + typBuilderImpl.add(mStaticInit); + + CodeTreeBuilder b = mStaticInit.appendBuilder(); + + b.startAssign("ExecutionTracer tracer").startStaticCall(types.ExecutionTracer, "get"); + b.doubleQuote(ElementUtils.getClassQualifiedName(m.getTemplateType())); + b.end(2); + + b.startStatement().startCall("tracer", "setOutputPath"); + b.doubleQuote(decisionsFilePath); + b.end(2); + + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + continue; + } + + CustomInstruction cinstr = (CustomInstruction) instr; + + b.startStatement().startCall("tracer", "setInstructionSpecializationNames"); + b.doubleQuote(cinstr.name); + for (String name : cinstr.getSpecializationNames()) { + b.doubleQuote(name); + } + b.end(2); + } + } + } + CodeVariableElement fldLanguage = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getLanguageType(), "language"); typBuilderImpl.add(fldLanguage); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index fcc90d6c1a20..ac53b992f14a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -25,6 +25,7 @@ public class OperationsData extends Template { private boolean tracing; private OperationDecisions decisions; + private String decisionsFilePath; public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); @@ -86,7 +87,10 @@ public void initializeContext() { for (SingleOperationData data : operations) { context.processOperation(data); } - context.processDecisions(decisions); + if (decisions != null) { + assert !tracing; + context.processDecisions(decisions); + } } public boolean isGenerateAOT() { @@ -96,4 +100,13 @@ public boolean isGenerateAOT() { public void setDecisions(OperationDecisions decisions) { this.decisions = decisions; } + + public String getDecisionsFilePath() { + return this.decisionsFilePath; + } + + public void setDecisionsFilePath(String decisionsFilePath) { + this.decisionsFilePath = decisionsFilePath; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index dbccf693f45b..885ca126b0c1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -21,6 +21,9 @@ import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.parser.AbstractParser; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; +import com.oracle.truffle.tools.utils.json.JSONTokener; public class OperationsParser extends AbstractParser { @@ -90,8 +93,9 @@ protected OperationsData parse(Element element, List mirror) { return data; } - boolean isTracing = false; + data.setDecisionsFilePath(getMainDecisionsFilePath(typeElement, generateOperationsMirror)); + boolean isTracing = false; if (!isTracing) { OperationDecisions decisions = parseDecisions(typeElement, generateOperationsMirror, data); data.setDecisions(decisions); @@ -108,10 +112,27 @@ protected OperationsData parse(Element element, List mirror) { return data; } + private String getMainDecisionsFilePath(TypeElement element, AnnotationMirror generateOperationsMirror) { + String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); + if (file == null || file.isEmpty()) { + return null; + } + + return getDecisionsFile(element, file).getAbsolutePath(); + } + + private File getDecisionsFile(TypeElement element, String path) { + File file = CompilerFactory.getCompiler(element).getEnclosingFile(processingEnv, element); + String parent = file.getParent(); + File target = new File(parent, path); + + return target; + } + @SuppressWarnings("unchecked") private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror generateOperationsMirror, OperationsData data) { String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); - OperationDecisions mainDecisions = parseDecisions(element, file, data); + OperationDecisions mainDecisions = parseDecisions(element, file, data, true); if (mainDecisions == null) { return null; } @@ -119,7 +140,7 @@ private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror List overrideFiles = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionOverrideFiles").getValue(); for (String overrideFile : overrideFiles) { - OperationDecisions overrideDecision = parseDecisions(element, overrideFile, data); + OperationDecisions overrideDecision = parseDecisions(element, overrideFile, data, false); if (overrideDecision != null) { mainDecisions.merge(overrideDecision); } @@ -128,19 +149,14 @@ private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror return mainDecisions; } - private OperationDecisions parseDecisions(TypeElement element, String path, OperationsData data) { - File file = CompilerFactory.getCompiler(element).getEnclosingFile(processingEnv, element); - String parent = file.getParent(); - File target = new File(parent, path); + private OperationDecisions parseDecisions(TypeElement element, String path, OperationsData data, boolean isMain) { + File target = getDecisionsFile(element, path); try { - XMLStreamReader rd = XMLInputFactory.newDefaultFactory().createXMLStreamReader(new FileInputStream(target)); - rd.next(); - - return OperationDecisions.deserialize(rd); + FileInputStream fi = new FileInputStream(target); + JSONArray o = new JSONArray(new JSONTokener(fi)); + return OperationDecisions.deserialize(o); } catch (FileNotFoundException ex) { data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", target.toString()); - } catch (XMLStreamException ex) { - data.addError("Exception while reading decisions file: %s", ex); } return null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index efc03c734405..8e88775761fb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -45,6 +45,14 @@ public String getUniqueName() { return data.getName(); } + public List getSpecializationNames() { + List result = new ArrayList<>(); + for (SpecializationData spec : data.getNodeData().getSpecializations()) { + result.add(spec.getId()); + } + return result; + } + public void setExecuteMethod(ExecutableElement executeMethod) { this.executeMethod = executeMethod; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index a3814c3b3029..a7e0fb16d817 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -46,7 +46,7 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(decisionsFile = "decisions.xml") +@GenerateOperations(decisionsFile = "decisions.json") @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json new file mode 100644 index 000000000000..582ecae70070 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json @@ -0,0 +1,30 @@ +[ + { + "type": "Quicken", + "operation": "SLUnboxOperation", + "specializations": [ + "FromLong" + ] + }, + { + "type": "Quicken", + "operation": "SLAddOperation", + "specializations": [ + "AddLong" + ] + }, + { + "type": "Quicken", + "operation": "SLReadPropertyOperation", + "specializations": [ + "ReadSLObject0" + ] + }, + { + "type": "Quicken", + "operation": "SLUnboxOperation", + "specializations": [ + "FromBoolean" + ] + } +] diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json new file mode 100644 index 000000000000..c682d42904e0 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -0,0 +1,52 @@ +[ + { + "specializations": ["FromLong"], + "type": "Quicken", + "operation": "SLUnboxOperation" + }, + { + "specializations": ["AddLong"], + "type": "Quicken", + "operation": "SLAddOperation" + }, + { + "specializations": ["ReadSLObject0"], + "type": "Quicken", + "operation": "SLReadPropertyOperation" + }, + { + "specializations": ["FromBoolean"], + "type": "Quicken", + "operation": "SLUnboxOperation" + }, + { + "specializations": ["Boolean"], + "type": "Quicken", + "operation": "SLConvertToBoolean" + }, + { + "specializations": ["LessOrEqual0"], + "type": "Quicken", + "operation": "SLLessOrEqualOperation" + }, + { + "specializations": ["Direct"], + "type": "Quicken", + "operation": "SLInvokeOperation" + }, + { + "specializations": ["Perform"], + "type": "Quicken", + "operation": "SLFunctionLiteralOperation" + }, + { + "specializations": ["WriteSLObject0"], + "type": "Quicken", + "operation": "SLWritePropertyOperation" + }, + { + "specializations": ["LessThan0"], + "type": "Quicken", + "operation": "SLLessThanOperation" + } +] \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml deleted file mode 100644 index 543944c60202..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From ff11e495691095144797e006bbb19909acad9b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 27 Apr 2022 11:02:01 +0200 Subject: [PATCH 054/312] [wip] codegen on javac --- .../example/TestOperationsParserTest.java | 5 +- .../api/operation/BuilderOperationLabel.java | 11 ++++ .../api/operation/OperationProxies.java | 2 +- .../api/operation/OperationsBuilder.java | 10 ---- .../api/operation/OperationsRootNode.java | 39 +++++++------ .../truffle/dsl/processor/TruffleTypes.java | 2 +- .../java/compiler/JavaCCompiler.java | 57 +++++++++++++++++-- .../operations/OperationDecisions.java | 2 +- .../operations/OperationsParser.java | 13 +++-- 9 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index a44be928e584..7bdc5f2f72aa 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -3,6 +3,7 @@ import static org.junit.Assert.fail; import java.io.IOException; +import java.io.PrintWriter; import java.util.function.Consumer; import org.graalvm.polyglot.Context; @@ -291,7 +292,7 @@ public void testTracing() { + " (return (local 2)))"; //@formatter:on new Tester(src).test(495000L); - ExecutionTracer.get().dump(); + ExecutionTracer.get("com.oracle.truffle.api.operation.test.example.TestOperations").dump(new PrintWriter(System.out)); } @Test @@ -302,7 +303,7 @@ public void testInstrumentation() { //@formatter:on new Tester(src, true).test(3L); - ExecutionTracer.get().dump(); + ExecutionTracer.get("com.oracle.truffle.api.operation.test.example.TestOperations").dump(new PrintWriter(System.out)); } @Test diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java new file mode 100644 index 000000000000..59d80e3e646f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java @@ -0,0 +1,11 @@ +package com.oracle.truffle.api.operation; + +public class BuilderOperationLabel extends OperationLabel { + BuilderOperationData data; + boolean hasValue = false; + int targetBci = 0; + + public BuilderOperationLabel(BuilderOperationData data) { + this.data = data; + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java index 19ce033f0b10..0bd768f4155d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java @@ -7,6 +7,6 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -@interface OperationProxies { +public @interface OperationProxies { OperationProxy[] value(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 0b8ad2d6dc2b..3ac90670ee2a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -120,16 +120,6 @@ protected final int doBranchInstruction(int bci, int instr, OperationLabel label return 2; } - protected static class BuilderOperationLabel extends OperationLabel { - BuilderOperationData data; - boolean hasValue = false; - int targetBci = 0; - - public BuilderOperationLabel(BuilderOperationData data) { - this.data = data; - } - } - protected void doEmitLabel(int bci, OperationLabel label) { BuilderOperationLabel lbl = (BuilderOperationLabel) label; if (lbl.hasValue) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index 4e2e8d0a1f1e..541457d9de12 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -1,7 +1,6 @@ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; @@ -44,26 +43,26 @@ public boolean isInstrumentable() { return false; } -// private class OperationsWrapperNode extends Node implements WrapperNode { -// private final ProbeNode probe; -// -// OperationsWrapperNode(ProbeNode probe) { -// this.probe = probe; -// } -// -// public Node getDelegateNode() { -// return OperationsRootNode.this; -// } -// -// public ProbeNode getProbeNode() { -// return probe; -// } -// } + // private class OperationsWrapperNode extends Node implements WrapperNode { + // private final ProbeNode probe; + // + // OperationsWrapperNode(ProbeNode probe) { + // this.probe = probe; + // } + // + // public Node getDelegateNode() { + // return OperationsRootNode.this; + // } + // + // public ProbeNode getProbeNode() { + // return probe; + // } + // } -// public WrapperNode createWrapper(final ProbeNode probe) { -// // return new OperationsWrapperNode(probe); -// return null; -// } + // public WrapperNode createWrapper(final ProbeNode probe) { + // // return new OperationsWrapperNode(probe); + // return null; + // } @Override public String toString() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 2cba955dee2b..5fca60a3f01a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -225,7 +225,7 @@ public class TruffleTypes { // Operations DSL API public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; public static final String BuilderOperationData_Name = "com.oracle.truffle.api.operation.BuilderOperationData"; - public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.OperationsBuilder$BuilderOperationLabel"; + public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index abc947905920..43877df4740f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -41,12 +41,21 @@ package com.oracle.truffle.dsl.processor.java.compiler; import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; +import javax.tools.FileObject; import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; public class JavaCCompiler extends AbstractCompiler { @@ -92,10 +101,25 @@ protected boolean emitDeprecationWarningImpl(ProcessingEnvironment environment, } } + private static Class clsTrees = null; + + private static Object getTrees(ProcessingEnvironment environment, Element element) throws ReflectiveOperationException { + if (clsTrees == null) { + clsTrees = Class.forName("com.sun.source.util.Trees", false, element.getClass().getClassLoader()); + } + return staticMethod(clsTrees, "instance", new Class[]{ProcessingEnvironment.class}, environment); + } + + private static Method metTrees_getPath = null; + private static Object getTreePathForElement(ProcessingEnvironment environment, Element element) throws ReflectiveOperationException { - Class treesClass = Class.forName("com.sun.source.util.Trees", false, element.getClass().getClassLoader()); - Object trees = staticMethod(treesClass, "instance", new Class[]{ProcessingEnvironment.class}, environment); - return method(trees, "getPath", new Class[]{Element.class}, element); + Object trees = getTrees(environment, element); + // we must lookup the name manually since we need the abstract one on Trees, not the one on + // the implementation (which is innaccessible to us due to modules) + if (metTrees_getPath == null) { + metTrees_getPath = clsTrees.getMethod("getPath", new Class[]{Element.class}); + } + return metTrees_getPath.invoke(trees, element); } private static Object getLog(Object javacContext) throws ReflectiveOperationException { @@ -124,8 +148,33 @@ private static void reportProblem(Object check, Object treePath, Element element method(check, "warnDeprecated", new Class[]{diagnosticPositionClass, symbolClass}, elementTree, element); } + private static Class clsTreePath = null; + private static Method metTreePath_getCompilationUnit = null; + private static Class clsCompilationUnitTree = null; + private static Method metCompilationUnitTree_getSourceFile = null; + @Override public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { - throw new UnsupportedOperationException("todo"); + try { + ClassLoader cl = element.getClass().getClassLoader(); + + Object treePath = getTreePathForElement(processingEnv, element); + if (clsTreePath == null) { + clsTreePath = Class.forName("com.sun.source.util.TreePath", false, cl); + metTreePath_getCompilationUnit = clsTreePath.getMethod("getCompilationUnit", new Class[0]); + } + + Object compilationUnit = metTreePath_getCompilationUnit.invoke(treePath); + + if (clsCompilationUnitTree == null) { + clsCompilationUnitTree = Class.forName("com.sun.source.tree.CompilationUnitTree", false, cl); + metCompilationUnitTree_getSourceFile = clsCompilationUnitTree.getDeclaredMethod("getSourceFile", new Class[0]); + } + + JavaFileObject obj = (JavaFileObject) metCompilationUnitTree_getSourceFile.invoke(compilationUnit); + return new File(obj.toUri()); + } catch (ReflectiveOperationException e) { + throw new AssertionError("should not happen", e); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 14a5c68dadd3..b0e5eea00a14 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -14,7 +14,7 @@ public class OperationDecisions { private final List quicken = new ArrayList<>(); - private OperationDecisions() { + public OperationDecisions() { } public List getQuicken() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 885ca126b0c1..b246634779c6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -13,16 +13,12 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONObject; import com.oracle.truffle.tools.utils.json.JSONTokener; public class OperationsParser extends AbstractParser { @@ -132,7 +128,14 @@ private File getDecisionsFile(TypeElement element, String path) { @SuppressWarnings("unchecked") private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror generateOperationsMirror, OperationsData data) { String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); - OperationDecisions mainDecisions = parseDecisions(element, file, data, true); + OperationDecisions mainDecisions; + + if (file == null || file.isEmpty()) { + mainDecisions = new OperationDecisions(); + } else { + mainDecisions = parseDecisions(element, file, data, true); + } + if (mainDecisions == null) { return null; } From 0f9f9a72fd1de36d6f4041e851abdd03acb2c1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 28 Apr 2022 13:52:05 +0200 Subject: [PATCH 055/312] [wip] quickening and autogen --- .../api/operation/GenerateOperations.java | 2 + .../truffle/api/operation/Operation.java | 1 - .../tracing/DisabledExecutionTracer.java | 59 +++ .../operation/tracing/ExecutionTracer.java | 431 +++--------------- .../tracing/OperationsExecutionTracer.java | 316 +++++++++++++ .../oracle/truffle/api/TruffleOptions.java | 6 + .../processor/TruffleProcessorOptions.java | 8 + .../processor/java/compiler/JDTCompiler.java | 2 - .../java/compiler/JavaCCompiler.java | 8 - .../truffle/dsl/processor/model/NodeData.java | 6 +- .../dsl/processor/operations/Operation.java | 4 +- .../operations/OperationDecisions.java | 3 - .../operations/OperationGeneratorUtils.java | 6 +- .../OperationsBytecodeCodeGenerator.java | 1 + .../OperationsBytecodeNodeGeneratorPlugs.java | 41 +- .../operations/OperationsContext.java | 39 +- .../processor/operations/OperationsData.java | 53 ++- .../operations/OperationsParser.java | 82 +++- .../operations/SingleOperationParser.java | 33 +- .../ConditionalBranchInstruction.java | 16 +- .../{ConstantKind.java => FrameKind.java} | 6 +- .../instructions/LoadArgumentInstruction.java | 14 +- .../instructions/LoadConstantInstruction.java | 16 +- .../instructions/LoadLocalInstruction.java | 18 +- .../instructions/QuickenedInstruction.java | 30 +- .../truffle/sl/test/SLSimpleTestSuite.java | 4 - .../com/oracle/truffle/sl/SLException.java | 1 - .../expression/SLFunctionLiteralNode.java | 67 +-- .../truffle/sl/operations/SLOperations.java | 24 +- .../truffle/sl/operations/decisions.json | 12 +- .../truffle/sl/parser/SLNodeFactory.java | 3 +- .../sl/parser/operations/SLNodeVisitor.java | 4 +- 32 files changed, 750 insertions(+), 566 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java rename truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/{ConstantKind.java => FrameKind.java} (84%) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index a5cd574ee97e..c8525f59ca50 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -11,4 +11,6 @@ String decisionsFile() default ""; String[] decisionOverrideFiles() default {}; + + Class[] boxingEliminationTypes() default {}; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index 54996e9a4813..6686067af2dd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -8,5 +8,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Operation { - Class proxyNode() default Void.class; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java new file mode 100644 index 000000000000..43fdd4df4b56 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java @@ -0,0 +1,59 @@ +package com.oracle.truffle.api.operation.tracing; + +import java.io.PrintWriter; + +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; + +class DisabledExecutionTracer extends ExecutionTracer { + + DisabledExecutionTracer() { + super(null); + } + + @Override + public void startFunction(OperationsNode node) { + } + + @Override + public void endFunction() { + } + + @Override + public void traceInstruction(int bci, String id, int instructionType, Object... arguments) { + } + + @Override + public void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { + } + + @Override + public Object tracePop(Object value) { + return value; + } + + @Override + public Object tracePush(Object value) { + return value; + } + + @Override + public void traceException(Throwable ex) { + } + + @Override + public void dump(PrintWriter writer) { + } + + @Override + public JSONObject serializeState() { + throw new AssertionError("should never be called"); + } + + @Override + public JSONArray createDecisions() { + throw new AssertionError("should never be called"); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index 2cb7f4c2a806..eec460ac2e59 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -4,427 +4,146 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.tools.utils.json.JSONArray; import com.oracle.truffle.tools.utils.json.JSONObject; import com.oracle.truffle.tools.utils.json.JSONTokener; -public class ExecutionTracer { +public abstract class ExecutionTracer { + + private static final boolean ENABLED; + private static final ExecutionTracer DISABLED_INSTANCE; + private static final Map TRACERS = new HashMap<>(); private static final String KEY_TRACERS = "tracers"; - private static final String KEY_KEY = "key"; - private static final String KEY_ACTIVE_SPECIALIZATION_OCCURENCES = "activeSpecializations"; - private static final String KEY_COUNT = "count"; public static ExecutionTracer get(String key) { - return TRACERS.computeIfAbsent(key, ExecutionTracer::new); + if (ENABLED) { + return TRACERS.computeIfAbsent(key, OperationsExecutionTracer::new); + } else { + return DISABLED_INSTANCE; + } } - private final String key; + final String key; private String outputPath; - private Map specializationNames = new HashMap<>(); + protected Map specializationNames = new HashMap<>(); - private ExecutionTracer(String key) { + ExecutionTracer(String key) { assert TRACERS.get(key) == null; this.key = key; } - static { - - // deser - String stateFile = "/tmp/state.json"; - + private static void loadState(String stateFile) { try { + // TODO stateFile should be locked while we are running to prevent concurrent + // modification + FileInputStream fi = new FileInputStream(new File(stateFile)); JSONTokener tok = new JSONTokener(fi); - JSONObject o = new JSONObject(tok); + if (!tok.more()) { + // empty file + return; + } + JSONObject o = new JSONObject(tok); JSONArray tracers = o.getJSONArray("tracers"); - for (int i = 0; i < tracers.length(); i++) { JSONObject tracer = tracers.getJSONObject(i); - ExecutionTracer tr = ExecutionTracer.deserializeState(tracer); + ExecutionTracer tr = OperationsExecutionTracer.deserializeState(tracer); TRACERS.put(tr.key, tr); } } catch (FileNotFoundException ex) { - System.err.println("not found"); + throw new RuntimeException("Operations execution tracer file not found. Make sure tracer file exists."); } + } - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(new File(stateFile)))) { - JSONObject result = new JSONObject(); - JSONArray tracers = new JSONArray(); - - for (Map.Entry ent : TRACERS.entrySet()) { - ExecutionTracer tracer = ent.getValue(); - tracers.put(tracer.serializeState()); - tracer.dump(new PrintWriter(System.out)); - System.out.flush(); - } - - result.put(KEY_TRACERS, tracers); - fo.append(result.toString(2)); - - } catch (Exception e) { - // failing to write the state is a critical exception - throw new RuntimeException(e); - } + private static void saveState(String stateFile) { + try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(new File(stateFile)))) { + JSONObject result = new JSONObject(); + JSONArray tracers = new JSONArray(); for (Map.Entry ent : TRACERS.entrySet()) { ExecutionTracer tracer = ent.getValue(); - try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(tracer.outputPath))) { - JSONArray decisions = tracer.createDecisions(); - fo.append(decisions.toString(2)); - } catch (Exception e) { - // failing to write the decisions is not as big of an exception - e.printStackTrace(); - } + tracers.put(tracer.serializeState()); + // tracer.dump(new PrintWriter(System.out)); + // System.out.flush(); } - })); - } - public static final int INSTRUCTION_TYPE_OTHER = 0; - public static final int INSTRUCTION_TYPE_BRANCH = 1; - public static final int INSTRUCTION_TYPE_BRANCH_COND = 2; - public static final int INSTRUCTION_TYPE_LOAD_LOCAL = 3; - public static final int INSTRUCTION_TYPE_STORE_LOCAL = 4; - public static final int INSTRUCTION_TYPE_LOAD_ARGUMENT = 5; - public static final int INSTRUCTION_TYPE_LOAD_CONSTANT = 6; - public static final int INSTRUCTION_TYPE_RETURN = 7; - public static final int INSTRUCTION_TYPE_CUSTOM = 8; + result.put(KEY_TRACERS, tracers); + fo.append(result.toString()); - private static final int TRACE_LENGTH = 8; - - private static class InstructionSequence { - final int hash; - final int[] instrs; - - public InstructionSequence(int[] instrs) { - this.instrs = instrs; - int h = 0; - for (int i : instrs) { - h = h * 31 + i; - } - hash = h; + } catch (Exception e) { + // failing to write the state is a critical exception + throw new RuntimeException(e); } - public InstructionSequence add(int next) { - int[] created = new int[instrs.length]; - System.arraycopy(instrs, 1, created, 0, instrs.length - 1); - created[created.length - 1] = next; - return new InstructionSequence(created); - } - - public boolean isValid() { - for (int i : instrs) { - if (i == 0) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof InstructionSequence)) - return false; - InstructionSequence other = (InstructionSequence) obj; - if (other.hash != hash || instrs.length != other.instrs.length) { - return false; - } - for (int i = 0; i < instrs.length; i++) { - if (instrs[i] != other.instrs[i]) { - return false; - } - } - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < instrs.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(String.format("%3d", instrs[i])); + for (Map.Entry ent : TRACERS.entrySet()) { + ExecutionTracer tracer = ent.getValue(); + try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(tracer.outputPath))) { + JSONArray decisions = tracer.createDecisions(); + fo.append(decisions.toString(2)); + } catch (Exception e) { + // failing to write the decisions is not as big of an exception + e.printStackTrace(); } - sb.append(']'); - return sb.toString(); - } - } - - final Map occurences = new HashMap<>(); - InstructionSequence[] last = new InstructionSequence[TRACE_LENGTH - 1]; - - private static class SpecializationOccurence { - final int instructionId; - final int specializationId; - - SpecializationOccurence(int instructionId, int specializationId) { - this.instructionId = instructionId; - this.specializationId = specializationId; - } - - @Override - public int hashCode() { - return Objects.hash(instructionId, specializationId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SpecializationOccurence other = (SpecializationOccurence) obj; - return instructionId == other.instructionId && specializationId == other.specializationId; - } - - @Override - public String toString() { - return "SpecializationOccurence [instructionId=" + instructionId + ", specializationId=" + specializationId + "]"; } } - private static class ActiveSpecializationOccurence { - final String instructionId; - final boolean[] activeSpecializations; - - private static final String KEY_INSTRUCTION_ID = "i"; - private static final String KEY_ACTIVE_SPECIALIZATIONS = "a"; - private static final String KEY_LENGTH = "l"; - - ActiveSpecializationOccurence(String instructionId, boolean... activeSpecializations) { - this.instructionId = instructionId; - this.activeSpecializations = activeSpecializations; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(activeSpecializations); - result = prime * result + Objects.hash(instructionId); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ActiveSpecializationOccurence other = (ActiveSpecializationOccurence) obj; - return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId.equals(other.instructionId); - } - - @Override - public String toString() { - return "ActiveSpecializationOccurence[instructionId=" + instructionId + ", activeSpecializations=" + Arrays.toString(activeSpecializations) + "]"; - } - - JSONObject serializeState() { - JSONObject result = new JSONObject(); - result.put(KEY_INSTRUCTION_ID, instructionId); - result.put(KEY_LENGTH, activeSpecializations.length); - - JSONArray arr = new JSONArray(); - int i = 0; - for (boolean act : activeSpecializations) { - if (act) { - arr.put(i); - } - i++; - } - result.put(KEY_ACTIVE_SPECIALIZATIONS, arr); - - return result; - } - - JSONObject createDecision(String[] specNames) { - assert specNames.length >= activeSpecializations.length : instructionId + "should have at least" + activeSpecializations.length + " specializations, but has " + specNames.length; - JSONObject result = new JSONObject(); - result.put("type", "Quicken"); - assert instructionId.startsWith("c."); - result.put("operation", instructionId.substring(2)); // drop the `c.` prefix - - JSONArray specs = new JSONArray(); - for (int i = 0; i < activeSpecializations.length; i++) { - if (activeSpecializations[i]) { - specs.put(specNames[i]); - } - } - - result.put("specializations", specs); - - return result; - } - - static ActiveSpecializationOccurence deserializeState(JSONObject o) { - String instructionId = o.getString(KEY_INSTRUCTION_ID); - int len = o.getInt(KEY_LENGTH); - - boolean[] activeSpecializations = new boolean[len]; - - JSONArray arr = o.getJSONArray(KEY_ACTIVE_SPECIALIZATIONS); - for (int i = 0; i < arr.length(); i++) { - int idx = arr.getInt(i); - activeSpecializations[i] = true; - } - - return new ActiveSpecializationOccurence(instructionId, activeSpecializations); - } - } + static { + String stateFile = TruffleOptions.OperationDecisionsFile; - private final Map activeSpecializationsMap = new HashMap<>(); + if (stateFile != null && !stateFile.isEmpty()) { + loadState(stateFile); + Runtime.getRuntime().addShutdownHook(new Thread(() -> saveState(stateFile))); - private final void resetLast() { - for (int i = 2; i <= TRACE_LENGTH; i++) { - last[i - 2] = new InstructionSequence(new int[i]); + ENABLED = true; + DISABLED_INSTANCE = null; + } else { + ENABLED = false; + DISABLED_INSTANCE = new DisabledExecutionTracer(); } } - @SuppressWarnings("unused") - @TruffleBoundary - public final void startFunction(OperationsNode node) { - resetLast(); - } - - @TruffleBoundary - public final void endFunction() { - resetLast(); - } + public static final int INSTRUCTION_TYPE_OTHER = 0; + public static final int INSTRUCTION_TYPE_BRANCH = 1; + public static final int INSTRUCTION_TYPE_BRANCH_COND = 2; + public static final int INSTRUCTION_TYPE_LOAD_LOCAL = 3; + public static final int INSTRUCTION_TYPE_STORE_LOCAL = 4; + public static final int INSTRUCTION_TYPE_LOAD_ARGUMENT = 5; + public static final int INSTRUCTION_TYPE_LOAD_CONSTANT = 6; + public static final int INSTRUCTION_TYPE_RETURN = 7; + public static final int INSTRUCTION_TYPE_CUSTOM = 8; - @SuppressWarnings("unused") @TruffleBoundary - public final void traceInstruction(int bci, String id, int instructionType, Object... arguments) { - if (instructionType == INSTRUCTION_TYPE_CUSTOM) { - assert arguments.length == 1; - boolean[] activeSpecs = (boolean[]) arguments[0]; - - ActiveSpecializationOccurence occ = new ActiveSpecializationOccurence(id, activeSpecs); - Long cur = activeSpecializationsMap.get(occ); - long next = cur == null ? 1 : cur + 1; - activeSpecializationsMap.put(occ, next); - } - } + public abstract void startFunction(OperationsNode node); @TruffleBoundary - public final void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { - } - - @SuppressWarnings({"unused", "static-method"}) - public final Object tracePop(Object value) { - return value; - } - - @SuppressWarnings({"unused", "static-method"}) - public final Object tracePush(Object value) { - return value; - } - - @SuppressWarnings("unused") - public final void traceException(Throwable ex) { - } - - private static final long score(Map.Entry ent) { - return ent.getValue() * ent.getKey().instrs.length; - } + public abstract void endFunction(); - public final void dump(PrintWriter writer) { - writer.println("-------------------------------------------------------------"); - activeSpecializationsMap.entrySet().stream() // - .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // - .limit(50) // - .forEachOrdered(e -> { - writer.printf(" %s: %d%n", e.getKey(), e.getValue()); - }); - writer.println("-------------------------------------------------------------"); - writer.flush(); - // occurences.entrySet().stream()// - // .sorted((e1, e2) -> Long.compare(score(e2), score(e1)))// - // .limit(30)// - // .forEachOrdered(e -> { - // writer.printf(" %s : %d%n", e.getKey(), e.getValue()); - // }); - } - - public JSONObject serializeState() { - JSONObject result = new JSONObject(); - result.put(KEY_KEY, key); - - JSONArray arr = new JSONArray(); - for (Map.Entry entry : activeSpecializationsMap.entrySet()) { - ActiveSpecializationOccurence as = entry.getKey(); - - JSONObject o = as.serializeState(); - o.put(KEY_COUNT, entry.getValue()); + public abstract void traceInstruction(int bci, String id, int instructionType, Object... arguments); - arr.put(o); - } + public abstract void traceSpecialization(int bci, String id, int specializationId, Object... arguments); - result.put(KEY_ACTIVE_SPECIALIZATION_OCCURENCES, arr); - return result; - } + public abstract Object tracePop(Object value); - public static ExecutionTracer deserializeState(JSONObject tracer) { - String key = tracer.getString(KEY_KEY); - ExecutionTracer result = new ExecutionTracer(key); + public abstract Object tracePush(Object value); - JSONArray arr = tracer.getJSONArray(KEY_ACTIVE_SPECIALIZATION_OCCURENCES); - for (int i = 0; i < arr.length(); i++) { - JSONObject o = arr.getJSONObject(i); + public abstract void traceException(Throwable ex); - long count = o.getLong(KEY_COUNT); - o.remove(KEY_COUNT); + public abstract void dump(PrintWriter writer); - ActiveSpecializationOccurence as = ActiveSpecializationOccurence.deserializeState(o); - result.activeSpecializationsMap.put(as, count); - } + public abstract JSONObject serializeState(); - return result; - } - - public JSONArray createDecisions() { - int numQuicken = 10; - - JSONArray result = new JSONArray(); - - activeSpecializationsMap.entrySet().stream() // - .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // - .limit(numQuicken) // - .forEachOrdered(e -> { - result.put(e.getKey().createDecision(specializationNames.get(e.getKey().instructionId))); - }); - - return result; - } - - @Override - public String toString() { - return "ExecutionTracer [key=" + key + ", activeSpecializationsMap=" + activeSpecializationsMap + "]"; - } + public abstract JSONArray createDecisions(); public void setOutputPath(String outputPath) { this.outputPath = outputPath; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java new file mode 100644 index 000000000000..a26ad4bde7ab --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java @@ -0,0 +1,316 @@ +package com.oracle.truffle.api.operation.tracing; + +import java.io.PrintWriter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; + +final class OperationsExecutionTracer extends ExecutionTracer { + + private static final String KEY_KEY = "key"; + private static final String KEY_ACTIVE_SPECIALIZATION_OCCURENCES = "activeSpecializations"; + private static final String KEY_COUNT = "count"; + + private static class ActiveSpecializationOccurence { + private static final String KEY_INSTRUCTION_ID = "i"; + private static final String KEY_ACTIVE_SPECIALIZATIONS = "a"; + + private static final String KEY_LENGTH = "l"; + + static ActiveSpecializationOccurence deserializeState(JSONObject o) { + String instructionId = o.getString(KEY_INSTRUCTION_ID); + int len = o.getInt(KEY_LENGTH); + + boolean[] activeSpecializations = new boolean[len]; + + JSONArray arr = o.getJSONArray(KEY_ACTIVE_SPECIALIZATIONS); + for (int i = 0; i < arr.length(); i++) { + int idx = arr.getInt(i); + activeSpecializations[idx] = true; + } + + return new ActiveSpecializationOccurence(instructionId, activeSpecializations); + } + + final String instructionId; + + final boolean[] activeSpecializations; + + ActiveSpecializationOccurence(String instructionId, boolean... activeSpecializations) { + this.instructionId = instructionId; + this.activeSpecializations = activeSpecializations; + } + + JSONObject createDecision(String[] specNames) { + assert specNames.length >= activeSpecializations.length : instructionId + "should have at least" + activeSpecializations.length + " specializations, but has " + specNames.length; + JSONObject result = new JSONObject(); + result.put("type", "Quicken"); + assert instructionId.startsWith("c."); + result.put("operation", instructionId.substring(2)); // drop the `c.` prefix + + JSONArray specs = new JSONArray(); + + StringBuilder id = new StringBuilder("q-"); + id.append(instructionId.substring(2)); + + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + specs.put(specNames[i]); + id.append('-').append(specNames[i]); + } + } + + result.put("specializations", specs); + result.put("id", id); + + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ActiveSpecializationOccurence other = (ActiveSpecializationOccurence) obj; + return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId.equals(other.instructionId); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(activeSpecializations); + result = prime * result + Objects.hash(instructionId); + return result; + } + + JSONObject serializeState() { + JSONObject result = new JSONObject(); + result.put(KEY_INSTRUCTION_ID, instructionId); + result.put(KEY_LENGTH, activeSpecializations.length); + + JSONArray arr = new JSONArray(); + int i = 0; + for (boolean act : activeSpecializations) { + if (act) { + arr.put(i); + } + i++; + } + result.put(KEY_ACTIVE_SPECIALIZATIONS, arr); + + return result; + } + + @Override + public String toString() { + return "ActiveSpecializationOccurence[instructionId=" + instructionId + ", activeSpecializations=" + Arrays.toString(activeSpecializations) + "]"; + } + } + + private static class InstructionSequence { + final int hash; + final int[] instrs; + + public InstructionSequence(int[] instrs) { + this.instrs = instrs; + int h = 0; + for (int i : instrs) { + h = h * 31 + i; + } + hash = h; + } + + public InstructionSequence add(int next) { + int[] created = new int[instrs.length]; + System.arraycopy(instrs, 1, created, 0, instrs.length - 1); + created[created.length - 1] = next; + return new InstructionSequence(created); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof InstructionSequence)) + return false; + InstructionSequence other = (InstructionSequence) obj; + if (other.hash != hash || instrs.length != other.instrs.length) { + return false; + } + for (int i = 0; i < instrs.length; i++) { + if (instrs[i] != other.instrs[i]) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + return hash; + } + + public boolean isValid() { + for (int i : instrs) { + if (i == 0) { + return false; + } + } + return true; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (int i = 0; i < instrs.length; i++) { + if (i != 0) { + sb.append(", "); + } + sb.append(String.format("%3d", instrs[i])); + } + sb.append(']'); + return sb.toString(); + } + } + + private static final int TRACE_LENGTH = 8; + + private static final long score(Map.Entry ent) { + return ent.getValue() * ent.getKey().instrs.length; + } + + private final Map occurences = new HashMap<>(); + private final Map activeSpecializationsMap = new HashMap<>(); + private InstructionSequence[] last = new InstructionSequence[TRACE_LENGTH - 1]; + + OperationsExecutionTracer(String key) { + super(key); + } + + @Override + public JSONArray createDecisions() { + int numQuicken = 10; + + JSONArray result = new JSONArray(); + + activeSpecializationsMap.entrySet().stream() // + .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // + .limit(numQuicken) // + .forEachOrdered(e -> { + result.put(e.getKey().createDecision(specializationNames.get(e.getKey().instructionId))); + }); + + return result; + } + + @Override + public final void dump(PrintWriter writer) { + writer.println("-------------------------------------------------------------"); + activeSpecializationsMap.entrySet().stream() // + .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // + .limit(50) // + .forEachOrdered(e -> { + writer.printf(" %s: %d%n", e.getKey(), e.getValue()); + }); + writer.println("-------------------------------------------------------------"); + writer.flush(); + } + + @Override + public JSONObject serializeState() { + JSONObject result = new JSONObject(); + result.put(KEY_KEY, key); + + JSONArray arr = new JSONArray(); + for (Map.Entry entry : activeSpecializationsMap.entrySet()) { + ActiveSpecializationOccurence as = entry.getKey(); + + JSONObject o = as.serializeState(); + o.put(KEY_COUNT, entry.getValue()); + + arr.put(o); + } + + result.put(KEY_ACTIVE_SPECIALIZATION_OCCURENCES, arr); + return result; + } + + public static OperationsExecutionTracer deserializeState(JSONObject tracer) { + String key = tracer.getString(KEY_KEY); + OperationsExecutionTracer result = new OperationsExecutionTracer(key); + + JSONArray arr = tracer.getJSONArray(KEY_ACTIVE_SPECIALIZATION_OCCURENCES); + for (int i = 0; i < arr.length(); i++) { + JSONObject o = arr.getJSONObject(i); + + long count = o.getLong(KEY_COUNT); + o.remove(KEY_COUNT); + + ActiveSpecializationOccurence as = ActiveSpecializationOccurence.deserializeState(o); + result.activeSpecializationsMap.put(as, count); + } + + return result; + } + + private final void resetLast() { + for (int i = 2; i <= TRACE_LENGTH; i++) { + last[i - 2] = new InstructionSequence(new int[i]); + } + } + + @Override + @TruffleBoundary + public final void startFunction(OperationsNode node) { + resetLast(); + } + + @Override + @TruffleBoundary + public final void endFunction() { + resetLast(); + } + + @Override + public void traceException(Throwable ex) { + } + + @Override + @TruffleBoundary + public void traceInstruction(int bci, String id, int instructionType, Object... arguments) { + if (instructionType == INSTRUCTION_TYPE_CUSTOM) { + assert arguments.length == 1; + boolean[] activeSpecs = (boolean[]) arguments[0]; + + ActiveSpecializationOccurence occ = new ActiveSpecializationOccurence(id, activeSpecs); + Long cur = activeSpecializationsMap.get(occ); + long next = cur == null ? 1 : cur + 1; + activeSpecializationsMap.put(occ, next); + } + } + + @Override + public Object tracePop(Object value) { + return value; + } + + @Override + public Object tracePush(Object value) { + return value; + } + + @Override + @TruffleBoundary + public void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { + } + +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java index 41f4d619dced..297a24c2daee 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java @@ -113,6 +113,8 @@ private TruffleOptions() { */ public static final boolean AOT; + public static final String OperationDecisionsFile; + private static NodeCost parseNodeInfoKind(String kind) { if (kind == null) { return null; @@ -137,6 +139,8 @@ class GetOptions implements PrivilegedAction { NodeCost traceRewritesFilterFromCost; NodeCost traceRewritesFilterToCost; + String operationDecisionsFile; + @Override public Void run() { aot = Boolean.getBoolean("com.oracle.graalvm.isaot"); @@ -145,6 +149,7 @@ public Void run() { traceRewritesFilterClass = System.getProperty("truffle.TraceRewritesFilterClass"); traceRewritesFilterFromCost = parseNodeInfoKind(System.getProperty("truffle.TraceRewritesFilterFromCost")); traceRewritesFilterToCost = parseNodeInfoKind(System.getProperty("truffle.TraceRewritesFilterToCost")); + operationDecisionsFile = System.getProperty("truffle.dsl.operation.DecisionsFile"); return null; } } @@ -157,5 +162,6 @@ public Void run() { TraceRewritesFilterClass = options.traceRewritesFilterClass; TraceRewritesFilterFromCost = options.traceRewritesFilterFromCost; TraceRewritesFilterToCost = options.traceRewritesFilterToCost; + OperationDecisionsFile = options.operationDecisionsFile; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java index 357ba4ce778c..35667b4917af 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java @@ -58,6 +58,8 @@ public class TruffleProcessorOptions { private static final String CacheSharingWarningsEnabledOptionName = "cacheSharingWarningsEnabled"; private static final String StateBitWidth = "StateBitWidth"; + private static final String OperationsEnableTracingOptionName = "operations.EnableTracing"; + public static Boolean generateSpecializationStatistics(ProcessingEnvironment env) { String value = env.getOptions().get(OptionsPrefix + GenerateSpecializationStatisticsOptionName); return value == null ? null : Boolean.parseBoolean(value); @@ -84,6 +86,11 @@ public static int stateBitWidth(ProcessingEnvironment env) { } } + public static boolean operationsEnableTracing(ProcessingEnvironment env) { + String value = env.getOptions().get(OptionsPrefix + OperationsEnableTracingOptionName); + return value == null ? false : Boolean.parseBoolean(value); + } + public static Set getSupportedOptions() { HashSet result = new HashSet<>(); result.add(OptionsPrefix + GenerateSpecializationStatisticsOptionName); @@ -91,6 +98,7 @@ public static Set getSupportedOptions() { result.add(OptionsPrefix + GenerateSlowPathOnlyFilterOptionName); result.add(OptionsPrefix + CacheSharingWarningsEnabledOptionName); result.add(OptionsPrefix + StateBitWidth); + result.add(OptionsPrefix + OperationsEnableTracingOptionName); return result; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java index 27b893b254e8..7947b2885600 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @@ -61,8 +61,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.tools.utils.json.XML; -import com.oracle.truffle.tools.utils.json.XMLParserConfiguration; public class JDTCompiler extends AbstractCompiler { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index 43877df4740f..5f8317a94035 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -41,21 +41,13 @@ package com.oracle.truffle.dsl.processor.java.compiler; import java.io.File; -import java.io.IOException; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.List; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; -import javax.tools.FileObject; import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; -import javax.tools.ToolProvider; - -import com.oracle.truffle.dsl.processor.java.ElementUtils; public class JavaCCompiler extends AbstractCompiler { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java index a5a7deb1b31e..04a8394a427a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java @@ -65,7 +65,7 @@ public class NodeData extends Template implements Comparable { private final List enclosingNodes = new ArrayList<>(); private NodeData declaringNode; - private final TypeSystemData typeSystem; + private TypeSystemData typeSystem; private final List children; private final List childExecutions; private final List fields; @@ -530,6 +530,10 @@ public TypeSystemData getTypeSystem() { return typeSystem; } + public void setTypeSystem(TypeSystemData typeSystem) { + this.typeSystem = typeSystem; + } + @Override public String dump() { return dump(0); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 46a790b95941..f6a96d8b5e87 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -15,7 +15,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; @@ -160,7 +160,7 @@ public CodeTree createEndCode(BuilderVariables vars) { CodeTree[] arguments = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; - b.tree(instructions[ConstantKind.OBJECT.ordinal()].createEmitCode(vars, arguments)); + b.tree(instructions[FrameKind.OBJECT.ordinal()].createEmitCode(vars, arguments)); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index b0e5eea00a14..c48a9dae09e2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -5,9 +5,6 @@ import java.util.List; import java.util.Objects; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - import com.oracle.truffle.tools.utils.json.JSONArray; import com.oracle.truffle.tools.utils.json.JSONObject; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 2b1e72d573bf..3fe9b1ab0143 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -19,7 +19,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; @@ -181,11 +181,11 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar return b.build(); } - public static CodeTree callSetResultBoxed(String bciOffset, ConstantKind kind) { + public static CodeTree callSetResultBoxed(String bciOffset, FrameKind kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); - b.string(kind == ConstantKind.OBJECT ? "true" : "false"); + b.string(kind == FrameKind.OBJECT ? "true" : "false"); b.string("bc"); b.string("$bci"); b.string(bciOffset); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 2d02934db9b8..4c6b5643255f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -462,6 +462,7 @@ public CodeTypeElement createBuilderBytecodeNode() { binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); binstr.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); + binstr.statement("break"); return binstr.build(); })); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 514f57f9512a..f39f2baded14 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -32,7 +32,7 @@ import com.oracle.truffle.dsl.processor.model.Parameter; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; @@ -385,7 +385,6 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; // unquicken and call parent EAS - builder.statement("System.out.println(\" -- unquicken " + qinstr.getUniqueName() + " -> " + qinstr.getOrig().getUniqueName() + " \")"); builder.tree(OperationGeneratorUtils.createWriteOpcode( fldBc, new CodeVariableElement(context.getType(int.class), "$bci"), @@ -445,6 +444,14 @@ public boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder pa return true; } + private FrameKind getFrameType(TypeKind type) { + if (!m.getBoxingEliminatedTypes().contains(type)) { + return FrameKind.OBJECT; + } + + return OperationsData.convertToFrameType(type); + } + @Override public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue, Function createExecuteAndSpecialize) { @@ -471,9 +478,9 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.end().startElseBlock(); } - ConstantKind typeName = getFrameType(targetValue.getTypeMirror().getKind()); + FrameKind typeName = getFrameType(targetValue.getTypeMirror().getKind()); - if (typeName == ConstantKind.OBJECT) { + if (typeName == FrameKind.OBJECT) { b.startAssign(targetValue.getName()); b.startCall("$frame", "getObject"); b.string("$sp - " + offset); @@ -555,7 +562,6 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); b.end().startBlock(); { - b.statement("System.out.println(\" -- quicken " + cinstr.getUniqueName() + " -> " + qinstr.getUniqueName() + " \")"); b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); } b.end(); @@ -564,7 +570,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // boxing elimination - if (!isVariadic) { + if (!isVariadic && boxingSplits != null) { boolean elseIf = false; for (BoxingSplit split : boxingSplits) { List specializations = split.getGroup().collectSpecializations(); @@ -585,7 +591,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.end().startBlock(); for (int i = 0; i < cinstr.numPopStatic(); i++) { - ConstantKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); + FrameKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", frameType)); } @@ -597,7 +603,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", ConstantKind.OBJECT)); + b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", FrameKind.OBJECT)); } if (elseIf) { @@ -607,25 +613,6 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } - private static ConstantKind getFrameType(TypeKind kind) { - switch (kind) { - case BYTE: - return ConstantKind.BYTE; - case BOOLEAN: - return ConstantKind.BOOLEAN; - case INT: - return ConstantKind.INT; - case FLOAT: - return ConstantKind.FLOAT; - case LONG: - return ConstantKind.LONG; - case DOUBLE: - return ConstantKind.DOUBLE; - default: - return ConstantKind.OBJECT; - } - } - public CodeTree createSetResultBoxed(CodeVariableElement varUnboxed) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().variable(varUnboxed).end().startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index bc662ed910a4..7c1de867bbdc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -8,7 +8,7 @@ import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ConstantKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -42,9 +42,17 @@ public class OperationsContext { public final ArrayList operations = new ArrayList<>(); private final Map customInstructionNameMap = new HashMap<>(); private final Map opDataNameMap = new HashMap<>(); - private OperationsData data; + private final OperationsData data; - public OperationsContext() { + public OperationsContext(OperationsData data) { + this.data = data; + } + + public OperationsData getData() { + return data; + } + + public void initializeContext() { createCommonInstructions(); createBuiltinOperations(); } @@ -54,7 +62,7 @@ private void createCommonInstructions() { commonBranch = add(new BranchInstruction(instructionId++)); - commonBranchFalse = add(new ConditionalBranchInstruction(instructionId++)); + commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++)); } private void createBuiltinOperations() { @@ -84,25 +92,25 @@ private void createBuiltinOperations() { private void createLoadStoreLocal() { add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); - loadLocalInstructions = new LoadLocalInstruction[ConstantKind.values().length]; - for (ConstantKind kind : ConstantKind.values()) { + loadLocalInstructions = new LoadLocalInstruction[FrameKind.values().length]; + for (FrameKind kind : data.getFrameKinds()) { loadLocalInstructions[kind.ordinal()] = add(new LoadLocalInstruction(this, instructionId++, kind)); } - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalInstructions[ConstantKind.OBJECT.ordinal()])); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalInstructions[FrameKind.OBJECT.ordinal()])); } private void createLoadArgument() { - loadArgumentInstructions = new LoadArgumentInstruction[ConstantKind.values().length]; - for (ConstantKind kind : ConstantKind.values()) { + loadArgumentInstructions = new LoadArgumentInstruction[FrameKind.values().length]; + for (FrameKind kind : data.getFrameKinds()) { loadArgumentInstructions[kind.ordinal()] = add(new LoadArgumentInstruction(this, instructionId++, kind)); } - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, loadArgumentInstructions[ConstantKind.OBJECT.ordinal()])); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, loadArgumentInstructions[FrameKind.OBJECT.ordinal()])); } private void createLoadConstant() { - loadConstantInstructions = new LoadConstantInstruction[ConstantKind.values().length]; - for (ConstantKind kind : ConstantKind.values()) { + loadConstantInstructions = new LoadConstantInstruction[FrameKind.values().length]; + for (FrameKind kind : data.getFrameKinds()) { loadConstantInstructions[kind.ordinal()] = add(new LoadConstantInstruction(this, instructionId++, kind)); } @@ -157,7 +165,8 @@ public void processDecisions(OperationDecisions decisions) { CustomInstruction cinstr = customInstructionNameMap.get(quicken.getOperation()); if (cinstr == null) { // TODO line number or sth - data.addError("Invalid declaration: undefined operation %s.", quicken.getOperation()); + data.addError("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); + continue; } SingleOperationData opData = opDataNameMap.get(quicken.getOperation()); @@ -165,8 +174,4 @@ public void processDecisions(OperationDecisions decisions) { add(new QuickenedInstruction(cinstr, instructionId++, opData, List.of(quicken.specializations))); } } - - public void setData(OperationsData data) { - this.data = data; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index ac53b992f14a..b0b78092bb76 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -2,22 +2,27 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.Template; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; public class OperationsData extends Template { private final List operations = new ArrayList<>(); - private final OperationsContext context = new OperationsContext(); + private final OperationsContext context = new OperationsContext(this); private TypeMirror languageType; private TypeMirror parseContextType; @@ -27,6 +32,9 @@ public class OperationsData extends Template { private OperationDecisions decisions; private String decisionsFilePath; + private TypeSystemData typeSystem; + private final Set boxingEliminatedTypes = new HashSet<>(); + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } @@ -82,8 +90,16 @@ public Collection getOperations() { return context.operations; } + public void setTypeSystem(TypeSystemData typeSystem) { + this.typeSystem = typeSystem; + } + + public TypeSystemData getTypeSystem() { + return typeSystem; + } + public void initializeContext() { - context.setData(this); + context.initializeContext(); for (SingleOperationData data : operations) { context.processOperation(data); } @@ -109,4 +125,37 @@ public void setDecisionsFilePath(String decisionsFilePath) { this.decisionsFilePath = decisionsFilePath; } + public Set getBoxingEliminatedTypes() { + return boxingEliminatedTypes; + } + + static FrameKind convertToFrameType(TypeKind kind) { + switch (kind) { + case BYTE: + return FrameKind.BYTE; + case BOOLEAN: + return FrameKind.BOOLEAN; + case INT: + return FrameKind.INT; + case FLOAT: + return FrameKind.FLOAT; + case LONG: + return FrameKind.LONG; + case DOUBLE: + return FrameKind.DOUBLE; + default: + return FrameKind.OBJECT; + } + } + + public List getFrameKinds() { + List kinds = new ArrayList<>(); + kinds.add(FrameKind.OBJECT); + for (TypeKind beType : boxingEliminatedTypes) { + kinds.add(convertToFrameType(beType)); + } + + return kinds; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index b246634779c6..619a28ad0a82 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,28 +1,39 @@ package com.oracle.truffle.dsl.processor.operations; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.tools.utils.json.JSONArray; import com.oracle.truffle.tools.utils.json.JSONTokener; public class OperationsParser extends AbstractParser { + private static final Set UNBOXABLE_TYPE_KINDS = Set.of(TypeKind.BOOLEAN, TypeKind.BYTE, TypeKind.INT, TypeKind.FLOAT, TypeKind.LONG, TypeKind.DOUBLE); + + @SuppressWarnings("unchecked") @Override protected OperationsData parse(Element element, List mirror) { @@ -30,24 +41,60 @@ protected OperationsData parse(Element element, List mirror) { AnnotationMirror generateOperationsMirror = ElementUtils.findAnnotationMirror(mirror, types.GenerateOperations); OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); - { - ExecutableElement parseMethod = ElementUtils.findExecutableElement(typeElement, "parse"); - if (parseMethod == null) { - data.addError(typeElement, - "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Language}, {Context}, %sBuilder)", - typeElement.getSimpleName()); - return data; - } - if (parseMethod.getParameters().size() != 3) { - data.addError(parseMethod, "Parse method must have exactly three arguments: the language, source and the builder"); + // find and bind parse method + + ExecutableElement parseMethod = ElementUtils.findExecutableElement(typeElement, "parse"); + if (parseMethod == null) { + data.addError(typeElement, + "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Language}, {Context}, %sBuilder)", + typeElement.getSimpleName()); + return data; + } + + if (parseMethod.getParameters().size() != 3) { + data.addError(parseMethod, "Parse method must have exactly three arguments: the language, source and the builder"); + return data; + } + + TypeMirror languageType = parseMethod.getParameters().get(0).asType(); + TypeMirror contextType = parseMethod.getParameters().get(1).asType(); + + data.setParseContext(languageType, contextType, parseMethod); + + // find and bind type system + AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); + if (typeSystemRefMirror != null) { + TypeMirror typeSystemType = getAnnotationValue(TypeMirror.class, typeSystemRefMirror, "value"); + TypeSystemData typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true); + if (typeSystem == null) { + data.addError("The used type system '%s' is invalid. Fix errors in the type system first.", getQualifiedName(typeSystemType)); return data; } - TypeMirror languageType = parseMethod.getParameters().get(0).asType(); - TypeMirror contextType = parseMethod.getParameters().get(1).asType(); + data.setTypeSystem(typeSystem); + } else { + data.setTypeSystem(new TypeSystemData(context, typeElement, null, true)); + } + + // find and bind boxing elimination types + List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); + for (AnnotationValue value : boxingEliminatedTypes) { + Set beTypes = data.getBoxingEliminatedTypes(); + TypeMirror mir; + if (value.getValue() instanceof Class) { + mir = context.getType((Class) value.getValue()); + } else if (value.getValue() instanceof TypeMirror) { + mir = (TypeMirror) value.getValue(); + } else { + throw new AssertionError(); + } - data.setParseContext(languageType, contextType, parseMethod); + if (UNBOXABLE_TYPE_KINDS.contains(mir.getKind())) { + beTypes.add(mir.getKind()); + } else { + data.addError("Cannot perform boxing elimination on %s", mir); + } } List operationTypes = new ArrayList<>(ElementFilter.typesIn(typeElement.getEnclosedElements())); @@ -91,7 +138,8 @@ protected OperationsData parse(Element element, List mirror) { data.setDecisionsFilePath(getMainDecisionsFilePath(typeElement, generateOperationsMirror)); - boolean isTracing = false; + boolean isTracing = TruffleProcessorOptions.operationsEnableTracing(processingEnv); + if (!isTracing) { OperationDecisions decisions = parseDecisions(typeElement, generateOperationsMirror, data); data.setDecisions(decisions); @@ -159,7 +207,11 @@ private OperationDecisions parseDecisions(TypeElement element, String path, Oper JSONArray o = new JSONArray(new JSONTokener(fi)); return OperationDecisions.deserialize(o); } catch (FileNotFoundException ex) { - data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", target.toString()); + if (isMain) { + data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", path); + } else { + data.addError("Decisions file '%s' not found.", path); + } } return null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index d92907f2d823..f1b4a08735f4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -23,6 +23,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; @@ -62,15 +63,7 @@ protected SingleOperationData parse(Element element, List mirr TypeElement te = (TypeElement) element; - boolean proxyOnParent = proxyType != null; - - if (!proxyOnParent) { - AnnotationMirror annOperation = ElementUtils.findAnnotationMirror(mirror, types.Operation); - DeclaredType proxyDecl = ElementUtils.getAnnotationValue(DeclaredType.class, annOperation, "proxyNode"); - if (!proxyDecl.equals(context.getDeclaredType(Void.class))) { - proxyType = ((TypeElement) proxyDecl.asElement()); - } - } else { + if (proxyType != null) { String name = proxyType.getSimpleName().toString(); if (name.endsWith("Node")) { name = name.substring(0, name.length() - 4); @@ -90,7 +83,7 @@ protected SingleOperationData parse(Element element, List mirr SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(te.getAnnotationMirrors(), getAnnotationType()), parentData); List operationFunctions = new ArrayList<>(); - if (!proxyOnParent) { + if (proxyType == null) { for (Element el : te.getEnclosedElements()) { if (el.getModifiers().contains(Modifier.PRIVATE)) { continue; @@ -105,9 +98,7 @@ protected SingleOperationData parse(Element element, List mirr } } } - } - - if (proxyType != null) { + } else { CodeTypeElement teClone = te instanceof CodeTypeElement ? (CodeTypeElement) te : CodeTypeElement.cloneShallow(te); te = teClone; @@ -236,6 +227,11 @@ protected SingleOperationData parse(Element element, List mirr return data; } + // replace the default node type system with Operations one if we have it + if (nodeData.getTypeSystem().isDefault() && parentData.getTypeSystem() != null) { + nodeData.setTypeSystem(parentData.getTypeSystem()); + } + nodeData.redirectMessagesOnGeneratedElements(data); data.setNodeData(nodeData); @@ -299,13 +295,10 @@ private CodeTypeElement createRegularNodeChild() { result.setSuperClass(types.Node); result.add(createExecuteMethod("Generic", context.getType(Object.class))); - result.add(createExecuteMethod("Long", context.getType(long.class))); - result.add(createExecuteMethod("Integer", context.getType(int.class))); - result.add(createExecuteMethod("Byte", context.getType(byte.class))); - result.add(createExecuteMethod("Boolean", context.getType(boolean.class))); - result.add(createExecuteMethod("Float", context.getType(float.class))); - result.add(createExecuteMethod("Double", context.getType(double.class))); - result.add(createExecuteMethod("Void", context.getType(void.class))); + + for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { + result.add(createExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); + } return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 164ca553bf46..fbd36885f2df 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -1,20 +1,27 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { private final ProcessorContext context = ProcessorContext.getInstance(); private final DeclaredType ConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); + private OperationsContext ctx; - public ConditionalBranchInstruction(int id) { + public ConditionalBranchInstruction(OperationsContext ctx, int id) { super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); + this.ctx = ctx; } @Override @@ -47,8 +54,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(2) + ")]"); - // TODO: we should do (un)boxing elim here. - b.declaration("boolean", "cond", "(boolean) frame.getObject(sp - 1)"); + // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) + TypeSystemData data = ctx.getData().getTypeSystem(); + CodeTree conditionCode = TypeSystemCodeGenerator.cast(data, new CodeTypeMirror(TypeKind.BOOLEAN), CodeTreeBuilder.singleString("frame.getObject(sp - 1)")); + + b.declaration("boolean", "cond", conditionCode); b.statement("sp -= 1"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java similarity index 84% rename from truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java rename to truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index d4f5c5c1eb66..24de649d3015 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConstantKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -1,6 +1,6 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -public enum ConstantKind { +public enum FrameKind { BOOLEAN("boolean", "Boolean"), BYTE("byte", "Byte"), INT("int", "Int", "Integer"), @@ -13,11 +13,11 @@ public enum ConstantKind { private final String frameName; private final String typeNameBoxed; - private ConstantKind(String typeName, String frameName) { + private FrameKind(String typeName, String frameName) { this(typeName, frameName, frameName); } - private ConstantKind(String typeName, String frameName, String typeNameBoxed) { + private FrameKind(String typeName, String frameName, String typeNameBoxed) { this.typeName = typeName; this.frameName = frameName; this.typeNameBoxed = typeNameBoxed; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 295e78bf54a7..f10c892d1805 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -8,10 +8,10 @@ public class LoadArgumentInstruction extends Instruction { - private ConstantKind kind; + private FrameKind kind; private OperationsContext ctx; - public LoadArgumentInstruction(OperationsContext ctx, int id, ConstantKind kind) { + public LoadArgumentInstruction(OperationsContext ctx, int id, FrameKind kind) { super("load.argument." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.ARGUMENT); this.ctx = ctx; this.kind = kind; @@ -42,7 +42,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("Object", "value", createGetValue(vars)); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); b.variable(vars.sp); b.string("value"); @@ -73,12 +73,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.startIf().string("!").variable(varBoxed).end().startBlock(); boolean elseIf = false; - for (ConstantKind okind : ConstantKind.values()) { - if (okind == ConstantKind.OBJECT) + for (FrameKind okind : ctx.getData().getFrameKinds()) { + if (okind == FrameKind.OBJECT) continue; elseIf = b.startIf(elseIf); @@ -91,7 +91,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen } else { b.startIf().variable(varBoxed).end().startBlock(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); b.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 679ce21736a4..af308a7af5a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -10,10 +10,10 @@ import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadConstantInstruction extends Instruction { - private final ConstantKind kind; + private final FrameKind kind; private final OperationsContext ctx; - public LoadConstantInstruction(OperationsContext ctx, int id, ConstantKind kind) { + public LoadConstantInstruction(OperationsContext ctx, int id, FrameKind kind) { super("load.constant." + kind.toString().toLowerCase(), id, ResultType.STACK_VALUE, InputType.CONST_POOL); this.ctx = ctx; this.kind = kind; @@ -42,7 +42,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private CodeTree createGetArgument(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind != ConstantKind.OBJECT) { + if (kind != FrameKind.OBJECT) { b.string("(", kind.getTypeName(), ") "); } b.variable(vars.consts).string("["); @@ -57,12 +57,12 @@ private CodeTree createGetArgument(ExecutionVariables vars) { public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.startIf().string("!").variable(varBoxed).end().startBlock(); boolean elseIf = false; - for (ConstantKind okind : ConstantKind.values()) { - if (okind == ConstantKind.OBJECT) { + for (FrameKind okind : ctx.getData().getFrameKinds()) { + if (okind == FrameKind.OBJECT) { continue; } @@ -78,7 +78,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen } else { b.startIf().variable(varBoxed).end().startBlock(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); b.end(); } @@ -88,7 +88,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { return null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 0dd4be5dc6ab..e64d793acaaf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -9,9 +9,9 @@ public class LoadLocalInstruction extends Instruction { private final OperationsContext ctx; - private final ConstantKind kind; + private final FrameKind kind; - public LoadLocalInstruction(OperationsContext ctx, int id, ConstantKind kind) { + public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { super("load.local." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.LOCAL); this.ctx = ctx; this.kind = kind; @@ -26,7 +26,7 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.startStatement().startCall(vars.frame, "copy"); } else { b.startAssign("Object value"); @@ -41,13 +41,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string(" + VALUES_OFFSET"); b.end(); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.variable(vars.sp); } b.end(2); - if (kind != ConstantKind.OBJECT) { + if (kind != FrameKind.OBJECT) { b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); { b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); @@ -74,12 +74,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == ConstantKind.OBJECT) { + if (kind == FrameKind.OBJECT) { b.startIf().string("!").variable(varBoxed).end().startBlock(); boolean elseIf = false; - for (ConstantKind okind : ConstantKind.values()) { - if (okind == ConstantKind.OBJECT) { + for (FrameKind okind : ctx.getData().getFrameKinds()) { + if (okind == FrameKind.OBJECT) { continue; } @@ -95,7 +95,7 @@ public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElemen } else { b.startIf().variable(varBoxed).end().startBlock(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[ConstantKind.OBJECT.ordinal()].opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); b.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 1ef789567671..943d7253489c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -54,10 +54,32 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData this.activeSpecNames = activeSpecNames; if (activeSpecNames.isEmpty()) { - data.addError("Invalid quickened instruction: no specializations defined."); + data.addError("Invalid quickened instruction %s: no specializations defined.", data.getName()); + activeSpecs = null; + return; } activeSpecs = new ArrayList<>(data.getNodeData().getSpecializations()); + + // validate specialization names + + boolean hasErrors = false; + outer: for (String activeSpec : activeSpecNames) { + for (SpecializationData spec : activeSpecs) { + if (spec.getId().equals(activeSpec)) { + continue outer; + } + } + + List realSpecNames = data.getNodeData().getSpecializations().stream().map(x -> x.getId()).toList(); + data.addError("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); + hasErrors = true; + } + + if (hasErrors) { + return; + } + activeSpecs.removeIf(spec -> { for (String activeSpec : activeSpecNames) { if (spec.getId().equals(activeSpec)) { @@ -67,12 +89,6 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData return true; }); - // TODO we should probably error if one of the active specializations is not found - - if (activeSpecs.isEmpty()) { - data.addError("Invalid quickened instruction: no specializations matched defined."); - } - orig.addQuickenedVariant(this); } diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java index 1bfbc1349465..41fe19eb1f9f 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLSimpleTestSuite.java @@ -40,13 +40,9 @@ */ package com.oracle.truffle.sl.test; -import java.io.PrintWriter; - import org.junit.Test; import org.junit.runner.RunWith; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; - @RunWith(SLTestRunner.class) @SLTestSuite({"tests"}) public class SLSimpleTestSuite { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 2b95671a2687..817a2c8155a7 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -43,7 +43,6 @@ import static com.oracle.truffle.api.CompilerDirectives.shouldNotReachHere; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.nodes.Node; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java index ba93f79c2315..529869c90c72 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java @@ -41,10 +41,11 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NodeChild; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -60,50 +61,28 @@ * never changes. This is guaranteed by the {@link SLFunctionRegistry}. */ @NodeInfo(shortName = "func") -public final class SLFunctionLiteralNode extends SLExpressionNode { +@NodeChild("functionName") +public abstract class SLFunctionLiteralNode extends SLExpressionNode { - /** The name of the function. */ - private final TruffleString functionName; - - /** - * The resolved function. During parsing (in the constructor of this node), we do not have the - * {@link SLContext} available yet, so the lookup can only be done at {@link #executeGeneric - * first execution}. The {@link CompilationFinal} annotation ensures that the function can still - * be constant folded during compilation. - */ - @CompilationFinal private SLFunction cachedFunction; - - public SLFunctionLiteralNode(TruffleString functionName) { - this.functionName = functionName; + @SuppressWarnings("unused") + @Specialization(guards = "lang.isSingleContext()") + public static SLFunction doSingleContext(TruffleString functionName, + @Bind("getLanguage(this)") SLLanguage lang, + @Cached("lookupFunction(functionName, this)") SLFunction result) { + assert result.getName().equals(functionName) : "functionName should be a compile-time constant"; + return result; } - @Override - public SLFunction executeGeneric(VirtualFrame frame) { - SLLanguage l = SLLanguage.get(this); - CompilerAsserts.partialEvaluationConstant(l); + @Specialization(replaces = "doSingleContext") + public static SLFunction doMultiContext(TruffleString functionName, @Bind("this") Node node) { + return lookupFunction(functionName, node); + } - SLFunction function; - if (l.isSingleContext()) { - function = this.cachedFunction; - if (function == null) { - /* We are about to change a @CompilationFinal field. */ - CompilerDirectives.transferToInterpreterAndInvalidate(); - /* First execution of the node: lookup the function in the function registry. */ - this.cachedFunction = function = SLContext.get(this).getFunctionRegistry().lookup(functionName, true); - } - } else { - /* - * We need to rest the cached function otherwise it might cause a memory leak. - */ - if (this.cachedFunction != null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - this.cachedFunction = null; - } - // in the multi-context case we are not allowed to store - // SLFunction objects in the AST. Instead we always perform the lookup in the hash map. - function = SLContext.get(this).getFunctionRegistry().lookup(functionName, true); - } - return function; + public static SLFunction lookupFunction(TruffleString functionName, Node node) { + return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); } + public static SLLanguage getLanguage(Node node) { + return SLLanguage.get(node); + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index a7e0fb16d817..6cb66f2c4253 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -31,6 +31,7 @@ import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; @@ -46,7 +47,7 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(decisionsFile = "decisions.json") +@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class}) @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) @@ -59,6 +60,7 @@ @OperationProxy(SLSubNode.class) @OperationProxy(SLWritePropertyNode.class) @OperationProxy(SLUnboxNode.class) +@OperationProxy(SLFunctionLiteralNode.class) public class SLOperations { public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { @@ -95,24 +97,8 @@ public static Object doExecute( } @Fallback - public static Object fallback(Object ignored) { - throw new RuntimeException(""); - } - } - - @Operation - @TypeSystemReference(SLTypes.class) - public static class SLFunctionLiteralOperation { - @Specialization - public static SLFunction perform( - TruffleString functionName, - @Cached("lookupFunction(functionName, this)") SLFunction result) { - assert result.getName().equals(functionName) : "functionName should be a compile-time constant"; - return result; - } - - static SLFunction lookupFunction(TruffleString functionName, Node node) { - return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); + public static Object fallback(Object functions) { + throw new RuntimeException("invalid functions: " + functions); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index c682d42904e0..9b628c235fe8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -1,51 +1,61 @@ [ { "specializations": ["FromLong"], + "id": "q-SLUnboxOperation-FromLong", "type": "Quicken", "operation": "SLUnboxOperation" }, { "specializations": ["AddLong"], + "id": "q-SLAddOperation-AddLong", "type": "Quicken", "operation": "SLAddOperation" }, { "specializations": ["ReadSLObject0"], + "id": "q-SLReadPropertyOperation-ReadSLObject0", "type": "Quicken", "operation": "SLReadPropertyOperation" }, { "specializations": ["FromBoolean"], + "id": "q-SLUnboxOperation-FromBoolean", "type": "Quicken", "operation": "SLUnboxOperation" }, { "specializations": ["Boolean"], + "id": "q-SLConvertToBoolean-Boolean", "type": "Quicken", "operation": "SLConvertToBoolean" }, { "specializations": ["LessOrEqual0"], + "id": "q-SLLessOrEqualOperation-LessOrEqual0", "type": "Quicken", "operation": "SLLessOrEqualOperation" }, { "specializations": ["Direct"], + "id": "q-SLInvokeOperation-Direct", "type": "Quicken", "operation": "SLInvokeOperation" }, { - "specializations": ["Perform"], + "specializations": ["SingleContext"], + "id": "q-SLFunctionLiteralOperation-SingleContext", "type": "Quicken", "operation": "SLFunctionLiteralOperation" }, { "specializations": ["WriteSLObject0"], + "id": "q-SLWritePropertyOperation-WriteSLObject0", "type": "Quicken", "operation": "SLWritePropertyOperation" }, { "specializations": ["LessThan0"], + "id": "q-SLLessThanOperation-LessThan0", "type": "Quicken", "operation": "SLLessThanOperation" } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java index 2e4d62c7e2db..8ed8d3960fe8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java @@ -73,6 +73,7 @@ import com.oracle.truffle.sl.nodes.expression.SLDivNodeGen; import com.oracle.truffle.sl.nodes.expression.SLEqualNodeGen; import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNodeGen; import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNodeGen; import com.oracle.truffle.sl.nodes.expression.SLLessThanNodeGen; @@ -513,7 +514,7 @@ public SLExpressionNode createRead(SLExpressionNode nameNode) { result = SLReadLocalVariableNodeGen.create(frameSlot); } else { /* Read of a global name. In our language, the only global names are functions. */ - result = new SLFunctionLiteralNode(name); + result = SLFunctionLiteralNodeGen.create(new SLStringLiteralNode(name)); } result.setSourceSection(nameNode.getSourceCharIndex(), nameNode.getSourceLength()); result.addExpressionTag(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java index a5efc72a3af4..d6f60575be85 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -32,7 +32,7 @@ import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode; import com.oracle.truffle.sl.nodes.expression.SLDivNodeGen; import com.oracle.truffle.sl.nodes.expression.SLEqualNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNodeGen; import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNodeGen; import com.oracle.truffle.sl.nodes.expression.SLLessThanNodeGen; @@ -544,7 +544,7 @@ private SLExpressionNode createRead(SLExpressionNode nameTerm) { if (frameSlot != null) { result = SLReadLocalVariableNodeGen.create(frameSlot); } else { - result = new SLFunctionLiteralNode(name); + result = SLFunctionLiteralNodeGen.create(new SLStringLiteralNode(name)); } result.setSourceSection(nameTerm.getSourceCharIndex(), nameTerm.getSourceLength()); result.addExpressionTag(); From 82375d061af94fd04b1ade5a98e68ef35ec10ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 28 Apr 2022 14:48:22 +0200 Subject: [PATCH 056/312] [wip] OSR but bad --- .../truffle/api/operation/OperationsNode.java | 29 ++++++++++-- .../processor/generator/GeneratorUtils.java | 7 +++ .../OperationsBytecodeCodeGenerator.java | 7 +-- .../instructions/BranchInstruction.java | 45 ++++++++++++++++++- 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index c93ecf1aba67..389d0e5d8a4f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -1,18 +1,20 @@ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.tracing.NodeTrace; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -public abstract class OperationsNode extends Node implements InstrumentableNode { +public abstract class OperationsNode extends Node implements InstrumentableNode, BytecodeOSRNode { public static final int FRAME_TYPE_OBJECT = 0; public static final int FRAME_TYPE_LONG = 1; @@ -68,10 +70,10 @@ public OperationsRootNode createInternalRootNode(TruffleLanguage language, St } public final Object execute(VirtualFrame frame) { - return continueAt(frame, 0); + return continueAt(frame, 0, maxLocals + VALUES_OFFSET); } - protected abstract Object continueAt(VirtualFrame frame, int index); + protected abstract Object continueAt(VirtualFrame frame, int index, int startSp); public abstract String dump(); @@ -150,4 +152,25 @@ protected static T interlog(T arg, String reason) { return arg; } + + // OSR + + @Override + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + // we'll need a container object if we ever need to pass more than just the sp + // TODO needs workaround for arguments getting null on OSR + return continueAt(osrFrame, target, (int) interpreterState); + } + + @CompilationFinal private Object osrMetadata; + + @Override + public void setOSRMetadata(Object osrMetadata) { + this.osrMetadata = osrMetadata; + } + + @Override + public Object getOSRMetadata() { + return osrMetadata; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 3d26818e8933..e7fae0d55028 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -147,6 +147,13 @@ public static CodeTree createInCompiledCode() { return builder.build(); } + public static CodeTree createInInterpreter() { + ProcessorContext context = ProcessorContext.getInstance(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.startStaticCall(context.getTypes().CompilerDirectives, "inInterpreter").end(); + return builder.build(); + } + public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) { TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); ExecutableElement constructor = findConstructor(superClass); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 4c6b5643255f..541167020f81 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -280,9 +280,10 @@ public CodeTypeElement createBuilderBytecodeNode() { { CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); + CodeVariableElement argStartSp = new CodeVariableElement(context.getType(int.class), "startSp"); CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PUBLIC), context.getType(Object.class), "continueAt", - argFrame, argStartBci); + Set.of(Modifier.PROTECTED), context.getType(Object.class), "continueAt", + argFrame, argStartBci, argStartSp); builderBytecodeNodeType.add(mContinueAt); { @@ -298,7 +299,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); - b.declaration("int", varSp.getName(), "maxLocals + VALUES_OFFSET"); + b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); if (m.isTracing()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 4ccae15c54da..be050bee0698 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -1,13 +1,21 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.DeclaredType; + import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class BranchInstruction extends Instruction { + + private static final ProcessorContext context = ProcessorContext.getInstance(); + private static final DeclaredType TRUFFLE_SAFEPOINT = context.getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"); + private static final DeclaredType BYTECODE_OSR_NODE = context.getDeclaredType("com.oracle.truffle.api.nodes.BytecodeOSRNode"); + public BranchInstruction(int id) { super("branch", id, ResultType.BRANCH, InputType.BRANCH_TARGET); } @@ -28,9 +36,42 @@ private CodeTree createGetBranchTarget(ExecutionVariables vars) { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.bci); - b.tree(createGetBranchTarget(vars)); + b.declaration("int", "targetBci", createGetBranchTarget(vars)); + + b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); + { + b.startStatement().startStaticCall(TRUFFLE_SAFEPOINT, "poll"); + b.string("this"); + b.end(2); + + // TODO reporting loop count + + b.startIf(); + b.tree(GeneratorUtils.createInInterpreter()); + b.string(" && "); + b.startStaticCall(BYTECODE_OSR_NODE, "pollOSRBackEdge").string("this").end(); + b.end().startBlock(); + { + b.startAssign("Object osrResult").startStaticCall(BYTECODE_OSR_NODE, "tryOSR"); + b.string("this"); + b.string("targetBci"); + b.variable(vars.sp); + b.string("null"); + b.variable(vars.frame); + b.end(2); + + b.startIf().string("osrResult != null").end().startBlock(); + { + b.startReturn().string("osrResult").end(); + } + b.end(); + } + b.end(); + } b.end(); + + b.startAssign(vars.bci).string("targetBci").end(); + b.statement("continue loop"); return b.build(); From 6060995292854b62d272a032933dce2639f3315f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 28 Apr 2022 15:27:21 +0200 Subject: [PATCH 057/312] [wip] separate ConvertToBOolean into node --- .../sl/nodes/controlflow/SLIfNode.java | 25 +++--------------- .../sl/nodes/util/SLToBooleanNode.java | 26 +++++++++++++++++++ .../truffle/sl/operations/SLOperations.java | 17 ++---------- .../truffle/sl/operations/decisions.json | 2 +- .../operations/SLOperationsVisitor.java | 20 +++++++------- 5 files changed, 43 insertions(+), 47 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java index 659f61838086..af9420873d89 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java @@ -42,11 +42,10 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLStatementNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; @NodeInfo(shortName = "if", description = "The node implementing a condional statement") @@ -57,7 +56,7 @@ public final class SLIfNode extends SLStatementNode { * result value. We do not have a node type that can only return a {@code boolean} value, so * {@link #evaluateCondition executing the condition} can lead to a type error. */ - @Child private SLExpressionNode conditionNode; + @Child private SLToBooleanNode conditionNode; /** Statement (or {@link SLBlockNode block}) executed when the condition is true. */ @Child private SLStatementNode thenPartNode; @@ -75,7 +74,7 @@ public final class SLIfNode extends SLStatementNode { private final ConditionProfile condition = ConditionProfile.createCountingProfile(); public SLIfNode(SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) { - this.conditionNode = SLUnboxNodeGen.create(conditionNode); + this.conditionNode = SLConvertToBooleanNodeGen.create(SLUnboxNodeGen.create(conditionNode)); this.thenPartNode = thenPartNode; this.elsePartNode = elsePartNode; } @@ -86,7 +85,7 @@ public void executeVoid(VirtualFrame frame) { * In the interpreter, record profiling information that the condition was executed and with * which outcome. */ - if (condition.profile(evaluateCondition(frame))) { + if (condition.profile(conditionNode.executeBoolean(frame))) { /* Execute the then-branch. */ thenPartNode.executeVoid(frame); } else { @@ -96,20 +95,4 @@ public void executeVoid(VirtualFrame frame) { } } } - - private boolean evaluateCondition(VirtualFrame frame) { - try { - /* - * The condition must evaluate to a boolean value, so we call the boolean-specialized - * execute method. - */ - return conditionNode.executeBoolean(frame); - } catch (UnexpectedResultException ex) { - /* - * The condition evaluated to a non-boolean result. This is a type error in the SL - * program. - */ - throw SLException.typeError(this, -1, ex.getResult()); - } - } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java new file mode 100644 index 000000000000..ebb8d54df462 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java @@ -0,0 +1,26 @@ +package com.oracle.truffle.sl.nodes.util; + +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.NodeChild; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.sl.SLException; +import com.oracle.truffle.sl.nodes.SLExpressionNode; + +@NodeChild +public abstract class SLToBooleanNode extends SLExpressionNode { + @Override + public abstract boolean executeBoolean(VirtualFrame vrame); + + @Specialization + public static boolean doBoolean(boolean value) { + return value; + } + + @Fallback + public static boolean doFallback(Object value, @Bind("this") Node node, @Bind("$bci") int bci) { + throw SLException.typeError(node, bci, value); + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 6cb66f2c4253..e2709539df80 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -25,7 +25,6 @@ import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; @@ -39,6 +38,7 @@ import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; import com.oracle.truffle.sl.nodes.expression.SLSubNode; import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLContext; @@ -61,6 +61,7 @@ @OperationProxy(SLWritePropertyNode.class) @OperationProxy(SLUnboxNode.class) @OperationProxy(SLFunctionLiteralNode.class) +@OperationProxy(SLToBooleanNode.class) public class SLOperations { public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { @@ -149,18 +150,4 @@ protected static Object doInterop( } } } - - @Operation - @TypeSystemReference(SLTypes.class) - public static class SLConvertToBoolean { - @Specialization - public static boolean doBoolean(boolean obj) { - return obj; - } - - @Fallback - public static void fallback(Object obj, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, obj); - } - } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 9b628c235fe8..efc8a2587192 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -27,7 +27,7 @@ "specializations": ["Boolean"], "id": "q-SLConvertToBoolean-Boolean", "type": "Quicken", - "operation": "SLConvertToBoolean" + "operation": "SLToBooleanOperation" }, { "specializations": ["LessOrEqual0"], diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index f38001aed119..65752e897a6e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -227,9 +227,9 @@ public Void visitWhile_statement(While_statementContext ctx) { b.emitLabel(continueLabel); b.beginWhile(); - b.beginSLConvertToBoolean(); + b.beginSLToBooleanOperation(); visit(ctx.condition); - b.endSLConvertToBoolean(); + b.endSLToBooleanOperation(); visit(ctx.body); b.endWhile(); @@ -250,18 +250,18 @@ public Void visitIf_statement(If_statementContext ctx) { if (ctx.alt == null) { b.beginIfThen(); - b.beginSLConvertToBoolean(); + b.beginSLToBooleanOperation(); visit(ctx.condition); - b.endSLConvertToBoolean(); + b.endSLToBooleanOperation(); visit(ctx.then); b.endIfThen(); } else { b.beginIfThenElse(); - b.beginSLConvertToBoolean(); + b.beginSLToBooleanOperation(); visit(ctx.condition); - b.endSLConvertToBoolean(); + b.endSLToBooleanOperation(); visit(ctx.then); @@ -310,9 +310,9 @@ private void logicalOrBegin(int localIdx) { private void logicalOrMiddle(int localIdx) { b.endStoreLocal(); b.beginConditional(); - b.beginSLConvertToBoolean(); + b.beginSLToBooleanOperation(); b.emitLoadLocal(localIdx); - b.endSLConvertToBoolean(); + b.endSLToBooleanOperation(); b.emitLoadLocal(localIdx); } @@ -372,9 +372,9 @@ private void logicalAndBegin(int localIdx) { private void logicalAndMiddle(int localIdx) { b.endStoreLocal(); b.beginConditional(); - b.beginSLConvertToBoolean(); + b.beginSLToBooleanOperation(); b.emitLoadLocal(localIdx); - b.endSLConvertToBoolean(); + b.endSLToBooleanOperation(); } private void logicalAndEnd(int localIdx) { From 97b9525a98a4fc00774d58046eefa91177296335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 28 Apr 2022 16:03:56 +0200 Subject: [PATCH 058/312] [wip] --- .../src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java index af9420873d89..84ba2a1bd418 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java @@ -46,6 +46,7 @@ import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLStatementNode; import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNodeGen; import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; @NodeInfo(shortName = "if", description = "The node implementing a condional statement") @@ -74,7 +75,7 @@ public final class SLIfNode extends SLStatementNode { private final ConditionProfile condition = ConditionProfile.createCountingProfile(); public SLIfNode(SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) { - this.conditionNode = SLConvertToBooleanNodeGen.create(SLUnboxNodeGen.create(conditionNode)); + this.conditionNode = SLToBooleanNodeGen.create(SLUnboxNodeGen.create(conditionNode)); this.thenPartNode = thenPartNode; this.elsePartNode = elsePartNode; } From 1f9145981bb8a80000c0c3577091900c98a1243e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 29 Apr 2022 08:29:57 +0200 Subject: [PATCH 059/312] [wip] add generated file for review --- .../sl/operations/SLOperationsBuilder.java | 7358 +++++++++++++++++ 1 file changed, 7358 insertions(+) create mode 100644 truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java new file mode 100644 index 000000000000..15465ee85055 --- /dev/null +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -0,0 +1,7358 @@ +// CheckStyle: start generated +package com.oracle.truffle.sl.operations; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.GeneratedBy; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.dsl.GenerateAOT.Provider; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.LibraryFactory; +import com.oracle.truffle.api.memory.MemoryFence; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.operation.BuilderExceptionHandler; +import com.oracle.truffle.api.operation.BuilderOperationData; +import com.oracle.truffle.api.operation.BuilderOperationLabel; +import com.oracle.truffle.api.operation.BuilderSourceInfo; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationsBuilder; +import com.oracle.truffle.api.operation.OperationsBytesSupport; +import com.oracle.truffle.api.operation.OperationsConstantPool; +import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleString.ConcatNode; +import com.oracle.truffle.api.strings.TruffleString.EqualNode; +import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.SLTypesGen; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; +import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.operations.SLOperations.SLEvalRootOperation; +import com.oracle.truffle.sl.operations.SLOperations.SLInvokeOperation; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLFunction; +import com.oracle.truffle.sl.runtime.SLNull; +import com.oracle.truffle.sl.runtime.SLObject; +import java.util.ArrayList; +import java.util.Map; +import java.util.concurrent.locks.Lock; +import java.util.function.Supplier; + +@GeneratedBy(SLOperations.class) +@SuppressWarnings("unused") +public abstract class SLOperationsBuilder extends OperationsBuilder { + + public abstract void beginBlock(); + + public abstract void endBlock(); + + public abstract void beginIfThen(); + + public abstract void endIfThen(); + + public abstract void beginIfThenElse(); + + public abstract void endIfThenElse(); + + public abstract void beginConditional(); + + public abstract void endConditional(); + + public abstract void beginWhile(); + + public abstract void endWhile(); + + public abstract void beginTryCatch(int arg0); + + public abstract void endTryCatch(); + + public abstract void emitLabel(OperationLabel arg0); + + public abstract void emitBranch(OperationLabel arg0); + + public abstract void emitConstObject(Object arg0); + + public abstract void emitLoadArgument(int arg0); + + public abstract void beginStoreLocal(int arg0); + + public abstract void endStoreLocal(); + + public abstract void emitLoadLocal(int arg0); + + public abstract void beginReturn(); + + public abstract void endReturn(); + + public abstract void beginInstrumentation(Class arg0); + + public abstract void endInstrumentation(); + + public abstract void beginSLAddOperation(); + + public abstract void endSLAddOperation(); + + public abstract void beginSLDivOperation(); + + public abstract void endSLDivOperation(); + + public abstract void beginSLEqualOperation(); + + public abstract void endSLEqualOperation(); + + public abstract void beginSLLessOrEqualOperation(); + + public abstract void endSLLessOrEqualOperation(); + + public abstract void beginSLLessThanOperation(); + + public abstract void endSLLessThanOperation(); + + public abstract void beginSLLogicalNotOperation(); + + public abstract void endSLLogicalNotOperation(); + + public abstract void beginSLMulOperation(); + + public abstract void endSLMulOperation(); + + public abstract void beginSLReadPropertyOperation(); + + public abstract void endSLReadPropertyOperation(); + + public abstract void beginSLSubOperation(); + + public abstract void endSLSubOperation(); + + public abstract void beginSLWritePropertyOperation(); + + public abstract void endSLWritePropertyOperation(); + + public abstract void beginSLUnboxOperation(); + + public abstract void endSLUnboxOperation(); + + public abstract void beginSLFunctionLiteralOperation(); + + public abstract void endSLFunctionLiteralOperation(); + + public abstract void beginSLToBooleanOperation(); + + public abstract void endSLToBooleanOperation(); + + public abstract void beginSLEvalRootOperation(); + + public abstract void endSLEvalRootOperation(); + + public abstract void beginSLInvokeOperation(); + + public abstract void endSLInvokeOperation(); + + public static OperationsNode[] parse(SLLanguage language, Source context) { + SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, false, false); + SLOperations.parse(language, context, builder); + return builder.collect(); + } + + public static OperationsNode[] parseWithSourceInfo(SLLanguage language, Source context) { + SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); + SLOperations.parse(language, context, builder); + return builder.collect(); + } + + @GeneratedBy(SLOperations.class) + @SuppressWarnings({"cast", "hiding", "unchecked", "rawtypes"}) + private static class SLOperationsBuilderImpl extends SLOperationsBuilder { + + private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); + private static final int OP_BLOCK = 1; + private static final int OP_IF_THEN = 2; + private static final int OP_IF_THEN_ELSE = 3; + private static final int OP_CONDITIONAL = 4; + private static final int OP_WHILE = 5; + private static final int OP_TRY_CATCH = 6; + private static final int OP_LABEL = 7; + private static final int OP_BRANCH = 8; + private static final int OP_CONST_OBJECT = 9; + private static final int OP_LOAD_ARGUMENT = 10; + private static final int OP_STORE_LOCAL = 11; + private static final int OP_LOAD_LOCAL = 12; + private static final int OP_RETURN = 13; + private static final int OP_INSTRUMENTATION = 14; + private static final int OP_SLADD_OPERATION = 15; + private static final int OP_SLDIV_OPERATION = 16; + private static final int OP_SLEQUAL_OPERATION = 17; + private static final int OP_SLLESS_OR_EQUAL_OPERATION = 18; + private static final int OP_SLLESS_THAN_OPERATION = 19; + private static final int OP_SLLOGICAL_NOT_OPERATION = 20; + private static final int OP_SLMUL_OPERATION = 21; + private static final int OP_SLREAD_PROPERTY_OPERATION = 22; + private static final int OP_SLSUB_OPERATION = 23; + private static final int OP_SLWRITE_PROPERTY_OPERATION = 24; + private static final int OP_SLUNBOX_OPERATION = 25; + private static final int OP_SLFUNCTION_LITERAL_OPERATION = 26; + private static final int OP_SLTO_BOOLEAN_OPERATION = 27; + private static final int OP_SLEVAL_ROOT_OPERATION = 28; + private static final int OP_SLINVOKE_OPERATION = 29; + private static final int INSTR_POP = 1; + private static final int INSTR_BRANCH = 2; + private static final int INSTR_BRANCH_FALSE = 3; + private static final int INSTR_LOAD_CONSTANT_OBJECT = 4; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 5; + private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_ARGUMENT_OBJECT = 7; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 8; + private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_STORE_LOCAL = 10; + private static final int INSTR_LOAD_LOCAL_OBJECT = 11; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 12; + private static final int INSTR_LOAD_LOCAL_LONG = 13; + private static final int INSTR_RETURN = 14; + private static final int INSTR_INSTRUMENT_ENTER = 15; + private static final int INSTR_INSTRUMENT_EXIT_VOID = 16; + private static final int INSTR_INSTRUMENT_EXIT = 17; + private static final int INSTR_INSTRUMENT_LEAVE = 18; + private static final int INSTR_C_SLADD_OPERATION = 19; + private static final int INSTR_C_SLDIV_OPERATION = 20; + private static final int INSTR_C_SLEQUAL_OPERATION = 21; + private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION = 22; + private static final int INSTR_C_SLLESS_THAN_OPERATION = 23; + private static final int INSTR_C_SLLOGICAL_NOT_OPERATION = 24; + private static final int INSTR_C_SLMUL_OPERATION = 25; + private static final int INSTR_C_SLREAD_PROPERTY_OPERATION = 26; + private static final int INSTR_C_SLSUB_OPERATION = 27; + private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION = 28; + private static final int INSTR_C_SLUNBOX_OPERATION = 29; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION = 30; + private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 31; + private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 32; + private static final int INSTR_C_SLINVOKE_OPERATION = 33; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 34; + private static final int INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG = 35; + private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 36; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 37; + private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 38; + private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 39; + private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 40; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT = 41; + private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; + private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; + + private final SLLanguage language; + private final Source parseContext; + private final boolean keepSourceInfo; + private final boolean keepInstrumentation; + private final BuilderSourceInfo sourceInfoBuilder; + byte[] bc = new byte[65535]; + ArrayList exceptionHandlers = new ArrayList<>(); + int lastPush; + int bci; + int numChildNodes; + int numBranchProfiles; + ArrayList builtNodes = new ArrayList<>(); + int nodeNumber = 0; + OperationsConstantPool constPool = new OperationsConstantPool(); + + SLOperationsBuilderImpl(SLLanguage language, Source parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { + this.language = language; + this.parseContext = parseContext; + this.keepSourceInfo = keepSourceInfo; + this.keepInstrumentation = keepInstrumentation; + if (keepSourceInfo) { + sourceInfoBuilder = new BuilderSourceInfo(); + } else { + sourceInfoBuilder = null; + } + reset(); + } + + @Override + public void reset() { + super.reset(); + bci = 0; + numChildNodes = 0; + numBranchProfiles = 0; + operationData = new BuilderOperationData(null, 0, 0, 0, false); + exceptionHandlers.clear(); + constPool.reset(); + if (keepSourceInfo) { + sourceInfoBuilder.reset(); + } + } + + @Override + public OperationsNode buildImpl() { + labelPass(bc); + if (operationData.depth != 0) { + throw new IllegalStateException("Not all operations ended"); + } + byte[] bcCopy = java.util.Arrays.copyOf(bc, bci); + Object[] cpCopy = constPool.getValues(); + BuilderExceptionHandler[] handlers = exceptionHandlers.toArray(new BuilderExceptionHandler[0]); + int[][] sourceInfo = null; + Source[] sources = null; + if (keepSourceInfo) { + sourceInfo = sourceInfoBuilder.build(); + sources = sourceInfoBuilder.buildSource(); + } + OperationsNode result; + ConditionProfile[] condProfiles = new ConditionProfile[numBranchProfiles]; + for (int i = 0; i < numBranchProfiles; i++) { + condProfiles[i] = ConditionProfile.createCountingProfile(); + } + result = new SLOperationsBuilderImplBytecodeNode(parseContext, sourceInfo, sources, nodeNumber, createMaxStack(), maxLocals + 1, bcCopy, cpCopy, new Node[numChildNodes], handlers, condProfiles); + builtNodes.add(result); + nodeNumber++; + reset(); + return result; + } + + @Override + protected void doLeaveOperation(BuilderOperationData data) { + while (getCurStack() > data.stackDepth) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + switch (data.operationId) { + case OP_INSTRUMENTATION : + { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_LEAVE); + LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) data.aux[0])); + createOffset(bci + 4, ((BuilderOperationLabel) data.aux[1])); + createOffset(bci + 6, ((BuilderOperationLabel) data.aux[2])); + bci = bci + 8; + break; + } + } + } + + @Override + public void beginSource(Supplier supplier) { + if (!keepSourceInfo) { + return; + } + beginSource(supplier.get()); + } + + @Override + public void beginSource(Source source) { + if (!keepSourceInfo) { + return; + } + sourceInfoBuilder.beginSource(bci, source); + } + + @Override + public void endSource() { + if (!keepSourceInfo) { + return; + } + sourceInfoBuilder.endSource(bci); + } + + @Override + public void beginSourceSection(int start) { + if (!keepSourceInfo) { + return; + } + sourceInfoBuilder.beginSourceSection(bci, start); + } + + @Override + public void endSourceSection(int length) { + if (!keepSourceInfo) { + return; + } + sourceInfoBuilder.endSourceSection(bci, length); + } + + @SuppressWarnings("unused") + void doBeforeChild() { + int childIndex = operationData.numChildren; + switch (operationData.operationId) { + case OP_BLOCK : + { + if (childIndex != 0) { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + } + break; + } + case OP_TRY_CATCH : + { + if (childIndex == 1) { + setCurStack(((BuilderExceptionHandler) operationData.aux[0]).startStack); + ((BuilderExceptionHandler) operationData.aux[0]).handlerBci = bci; + } + break; + } + case OP_INSTRUMENTATION : + { + if (childIndex != 0) { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + } + break; + } + } + } + + @SuppressWarnings("unused") + void doAfterChild() { + int childIndex = operationData.numChildren++; + switch (operationData.operationId) { + case OP_IF_THEN : + { + if (childIndex == 0) { + assert lastPush == 1; + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[0] = endLabel; + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); + createOffset(bci + 2, endLabel); + bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + bci = bci + 7; + } else { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + } + break; + } + case OP_IF_THEN_ELSE : + { + if (childIndex == 0) { + assert lastPush == 1; + BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[0] = elseLabel; + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); + createOffset(bci + 2, elseLabel); + bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + bci = bci + 7; + } else if (childIndex == 1) { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, (BuilderOperationLabel) endLabel); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, endLabel); + bci = bci + 4; + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + } else { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + } + break; + } + case OP_CONDITIONAL : + { + if (childIndex == 0) { + assert lastPush == 1; + BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[0] = elseLabel; + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); + createOffset(bci + 2, elseLabel); + bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + bci = bci + 7; + } else if (childIndex == 1) { + assert lastPush == 1; + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, (BuilderOperationLabel) endLabel); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, endLabel); + bci = bci + 4; + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + } else { + assert lastPush == 1; + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + } + break; + } + case OP_WHILE : + { + if (childIndex == 0) { + assert lastPush == 1; + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[1] = endLabel; + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); + createOffset(bci + 2, endLabel); + bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + bci = bci + 7; + } else { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[0])); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[0])); + bci = bci + 4; + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + } + break; + } + case OP_TRY_CATCH : + { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + if (childIndex == 0) { + ((BuilderExceptionHandler) operationData.aux[0]).endBci = bci; + calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[1])); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[1])); + bci = bci + 4; + } else { + } + break; + } + } + } + + @SuppressWarnings("unused") + @Override + public void beginBlock() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BLOCK, getCurStack(), 0, false); + lastPush = 0; + } + + @SuppressWarnings("unused") + @Override + public void endBlock() { + if (operationData.operationId != OP_BLOCK) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); + } + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginIfThen() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN, getCurStack(), 1, false); + } + + @SuppressWarnings("unused") + @Override + public void endIfThen() { + if (operationData.operationId != OP_IF_THEN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); + } + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginIfThenElse() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, getCurStack(), 2, false); + } + + @SuppressWarnings("unused") + @Override + public void endIfThenElse() { + if (operationData.operationId != OP_IF_THEN_ELSE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); + } + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginConditional() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, getCurStack(), 2, false); + } + + @SuppressWarnings("unused") + @Override + public void endConditional() { + if (operationData.operationId != OP_CONDITIONAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); + } + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginWhile() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_WHILE, getCurStack(), 2, false); + BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); + doEmitLabel(bci, startLabel); + operationData.aux[0] = startLabel; + } + + @SuppressWarnings("unused") + @Override + public void endWhile() { + if (operationData.operationId != OP_WHILE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("While expected 2 children, got " + numChildren); + } + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginTryCatch(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, getCurStack(), 2, false, arg0); + BuilderExceptionHandler beh = new BuilderExceptionHandler(); + beh.startBci = bci; + beh.startStack = getCurStack(); + beh.exceptionIndex = (int)operationData.arguments[0]; + exceptionHandlers.add(beh); + operationData.aux[0] = beh; + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + operationData.aux[1] = endLabel; + } + + @SuppressWarnings("unused") + @Override + public void endTryCatch() { + if (operationData.operationId != OP_TRY_CATCH) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); + } + doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLabel(OperationLabel arg0) { + doBeforeChild(); + BuilderOperationData operationData = new BuilderOperationData(this.operationData, OP_LABEL, getCurStack(), 0, false, arg0); + doEmitLabel(bci, ((BuilderOperationLabel) operationData.arguments[0])); + lastPush = 0; + doAfterChild(); + } + + @Override + public void emitBranch(OperationLabel arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(this.operationData, OP_BRANCH, getCurStack(), 0, false, arg0); + calculateLeaves(operationData, (BuilderOperationLabel) operationData.arguments[0]); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, operationData.arguments[0]); + bci = bci + 4; + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitConstObject(Object arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(this.operationData, OP_CONST_OBJECT, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); + LE_BYTES.putShort(bc, bci + 2, (short) (int) constPool.add(arg0)); + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLoadArgument(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(this.operationData, OP_LOAD_ARGUMENT, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_OBJECT); + LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginStoreLocal(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, getCurStack(), 0, false, arg0); + } + + @SuppressWarnings("unused") + @Override + public void endStoreLocal() { + if (operationData.operationId != OP_STORE_LOCAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 3, (short) (int) trackLocalsHelper(operationData.arguments[0])); + bci = bci + 5; + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLoadLocal(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(this.operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); + LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginReturn() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_RETURN, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endReturn() { + if (operationData.operationId != OP_RETURN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("Return expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_RETURN); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bci = bci + 3; + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginInstrumentation(Class arg0) { + if (true) { + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_INSTRUMENTATION, getCurStack(), 3, true, arg0); + int curInstrumentId = doBeginInstrumentation((Class) arg0); + BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + doEmitLabel(bci, startLabel); + operationData.aux[0] = curInstrumentId; + operationData.aux[1] = startLabel; + operationData.aux[2] = endLabel; + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_ENTER); + LE_BYTES.putShort(bc, bci + 2, (short) (int) curInstrumentId); + bci = bci + 4; + lastPush = 0; + } + + @SuppressWarnings("unused") + @Override + public void endInstrumentation() { + if (true) { + return; + } + if (operationData.operationId != OP_INSTRUMENTATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Instrumentation expected at least 0 children, got " + numChildren); + } + if (lastPush != 0) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT_VOID); + LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); + bci = bci + 4; + } else { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT); + LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); + bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bci = bci + 5; + } + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLAddOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLADD_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLAddOperation() { + if (operationData.operationId != OP_SLADD_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLAddOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLADD_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 7 bytes: [BITS, BITS, BITS, CONST, CONTINUATION, CHILD, CONTINUATION] + // numChildNodes = 3 + // numConsts = 1 + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bc[bci + 4 + 2] = 0; + LE_BYTES.putShort(bc, bci + 4 + 3, (short) constPool.reserve()); + LE_BYTES.putShort(bc, bci + 4 + 5, (short) numChildNodes); + numChildNodes += 3; + bci = bci + 11; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLDivOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLDIV_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLDivOperation() { + if (operationData.operationId != OP_SLDIV_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLDivOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLDIV_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 2 bytes: [BITS, BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLEqualOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLEQUAL_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLEqualOperation() { + if (operationData.operationId != OP_SLEQUAL_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLEqualOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEQUAL_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] + // numChildNodes = 3 + // numConsts = 1 + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + LE_BYTES.putShort(bc, bci + 4 + 2, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 4 + 4, (short) constPool.reserve()); + bc[bci + 4 + 6] = 0; + numChildNodes += 3; + bci = bci + 11; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLessOrEqualOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLLESS_OR_EQUAL_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLessOrEqualOperation() { + if (operationData.operationId != OP_SLLESS_OR_EQUAL_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessOrEqualOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLessThanOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLLESS_THAN_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLessThanOperation() { + if (operationData.operationId != OP_SLLESS_THAN_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessThanOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLogicalNotOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLLOGICAL_NOT_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLogicalNotOperation() { + if (operationData.operationId != OP_SLLOGICAL_NOT_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLLogicalNotOperation expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLOGICAL_NOT_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 3 + 0] = 0; + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLMulOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLMUL_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLMulOperation() { + if (operationData.operationId != OP_SLMUL_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLMulOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLMUL_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 2 bytes: [BITS, BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLReadPropertyOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLREAD_PROPERTY_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLReadPropertyOperation() { + if (operationData.operationId != OP_SLREAD_PROPERTY_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLReadPropertyOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] + // numChildNodes = 6 + // numConsts = 3 + bc[bci + 4 + 0] = 0; + LE_BYTES.putShort(bc, bci + 4 + 1, (short) constPool.reserve()); + LE_BYTES.putShort(bc, bci + 4 + 3, (short) numChildNodes); + bc[bci + 4 + 5] = 0; + constPool.reserve(); + constPool.reserve(); + numChildNodes += 6; + bci = bci + 10; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLSubOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLSUB_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLSubOperation() { + if (operationData.operationId != OP_SLSUB_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLSubOperation expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLSUB_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + // additionalData = 2 bytes: [BITS, BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLWritePropertyOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLWRITE_PROPERTY_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLWritePropertyOperation() { + if (operationData.operationId != OP_SLWRITE_PROPERTY_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("SLWritePropertyOperation expected 3 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 3, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); + bc[bci + 4] = predecessorBcis[2] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[2]); + // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] + // numChildNodes = 7 + // numConsts = 4 + bc[bci + 5 + 0] = 0; + LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); + LE_BYTES.putShort(bc, bci + 5 + 3, (short) numChildNodes); + bc[bci + 5 + 5] = 0; + constPool.reserve(); + constPool.reserve(); + constPool.reserve(); + numChildNodes += 7; + bci = bci + 11; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLUnboxOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLUNBOX_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLUnboxOperation() { + if (operationData.operationId != OP_SLUNBOX_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLUnboxOperation expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLUNBOX_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] + // numChildNodes = 2 + // numConsts = 1 + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + LE_BYTES.putShort(bc, bci + 3 + 2, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 3 + 4, (short) constPool.reserve()); + bc[bci + 3 + 6] = 0; + numChildNodes += 2; + bci = bci + 10; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLFunctionLiteralOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLFUNCTION_LITERAL_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLFunctionLiteralOperation() { + if (operationData.operationId != OP_SLFUNCTION_LITERAL_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLFunctionLiteralOperation expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + // additionalData = 4 bytes: [BITS, CONST, CONTINUATION, BITS] + // numChildNodes = 0 + // numConsts = 1 + bc[bci + 3 + 0] = 0; + LE_BYTES.putShort(bc, bci + 3 + 1, (short) constPool.reserve()); + bc[bci + 3 + 3] = 0; + bci = bci + 7; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLToBooleanOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLTO_BOOLEAN_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLToBooleanOperation() { + if (operationData.operationId != OP_SLTO_BOOLEAN_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLToBooleanOperation expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 3 + 0] = 0; + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLEvalRootOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLEVAL_ROOT_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLEvalRootOperation() { + if (operationData.operationId != OP_SLEVAL_ROOT_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLEvalRootOperation expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEVAL_ROOT_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 3 + 0] = 0; + bci = bci + 4; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLInvokeOperation() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLINVOKE_OPERATION, getCurStack(), 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLInvokeOperation() { + if (operationData.operationId != OP_SLINVOKE_OPERATION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SLInvokeOperation expected at least 0 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(bci, numChildren, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE_OPERATION); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); + // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] + // numChildNodes = 3 + // numConsts = 3 + bc[bci + 5 + 0] = 0; + LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); + LE_BYTES.putShort(bc, bci + 5 + 3, (short) numChildNodes); + bc[bci + 5 + 5] = 0; + constPool.reserve(); + constPool.reserve(); + numChildNodes += 3; + bci = bci + 11; + lastPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + private static OperationsNode reparse(SLLanguage language, Source context, int buildOrder) { + SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); + SLOperations.parse(language, context, builder); + return builder.collect()[buildOrder]; + } + + /** + * pop + * Inputs: + * STACK_VALUE_IGNORED + * Results: + * + * branch + * Inputs: + * BRANCH_TARGET + * Results: + * BRANCH + * + * branch.false + * Inputs: + * BRANCH_TARGET + * STACK_VALUE + * BRANCH_PROFILE + * Results: + * BRANCH + * + * load.constant.object + * Inputs: + * CONST_POOL + * Results: + * STACK_VALUE + * + * load.constant.boolean + * Inputs: + * CONST_POOL + * Results: + * STACK_VALUE + * + * load.constant.long + * Inputs: + * CONST_POOL + * Results: + * STACK_VALUE + * + * load.argument.object + * Inputs: + * ARGUMENT + * Results: + * STACK_VALUE + * + * load.argument.boolean + * Inputs: + * ARGUMENT + * Results: + * STACK_VALUE + * + * load.argument.long + * Inputs: + * ARGUMENT + * Results: + * STACK_VALUE + * + * store.local + * Inputs: + * STACK_VALUE + * Results: + * SET_LOCAL + * + * load.local.object + * Inputs: + * LOCAL + * Results: + * STACK_VALUE + * + * load.local.boolean + * Inputs: + * LOCAL + * Results: + * STACK_VALUE + * + * load.local.long + * Inputs: + * LOCAL + * Results: + * STACK_VALUE + * + * return + * Inputs: + * STACK_VALUE + * Results: + * RETURN + * + * instrument.enter + * Inputs: + * INSTRUMENT + * Results: + * + * instrument.exit.void + * Inputs: + * INSTRUMENT + * Results: + * + * instrument.exit + * Inputs: + * INSTRUMENT + * STACK_VALUE + * Results: + * STACK_VALUE + * + * instrument.leave + * Inputs: + * INSTRUMENT + * BRANCH_TARGET + * BRANCH_TARGET + * Results: + * BRANCH + * + * c.SLAddOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CONST + * 5 CHILD + * Specializations: + * AddLong + * Add0 + * Add1 + * Fallback + * + * c.SLDivOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * Specializations: + * DivLong + * Div + * Fallback + * + * c.SLEqualOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 CHILD + * 4 CONST + * 6 BITS + * Specializations: + * Long + * BigNumber + * Boolean + * String + * TruffleString + * Null + * Function + * Generic0 + * Generic1 + * Fallback + * + * c.SLLessOrEqualOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessOrEqual0 + * LessOrEqual1 + * Fallback + * + * c.SLLessThanOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessThan0 + * LessThan1 + * Fallback + * + * c.SLLogicalNotOperation + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * c.SLMulOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * Specializations: + * MulLong + * Mul + * Fallback + * + * c.SLReadPropertyOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * ReadArray0 + * ReadArray1 + * ReadSLObject0 + * ReadSLObject1 + * ReadObject0 + * ReadObject1 + * Fallback + * + * c.SLSubOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * Specializations: + * SubLong + * Sub + * Fallback + * + * c.SLWritePropertyOperation + * Inputs: + * STACK_VALUE + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * WriteArray0 + * WriteArray1 + * WriteSLObject0 + * WriteSLObject1 + * WriteObject0 + * WriteObject1 + * Fallback + * + * c.SLUnboxOperation + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 CHILD + * 4 CONST + * 6 BITS + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLFunctionLiteralOperation + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 BITS + * Specializations: + * SingleContext + * MultiContext + * Fallback + * + * c.SLToBooleanOperation + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * c.SLEvalRootOperation + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Execute + * Fallback + * + * c.SLInvokeOperation + * Inputs: + * STACK_VALUE + * VARARG_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * Direct + * Indirect + * Interop + * Fallback + * + * c.SLUnboxOperation.q.FromLong + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLAddOperation.q.Add1.AddLong + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 CONST + * 4 CHILD + * 6 BITS + * Specializations: + * AddLong + * Add0 + * Add1 + * Fallback + * + * c.SLReadPropertyOperation.q.ReadSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * ReadArray0 + * ReadArray1 + * ReadSLObject0 + * ReadSLObject1 + * ReadObject0 + * ReadObject1 + * Fallback + * + * c.SLUnboxOperation.q.FromBoolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLToBooleanOperation.q.Boolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * c.SLLessOrEqualOperation.q.LessOrEqual0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessOrEqual0 + * LessOrEqual1 + * Fallback + * + * c.SLInvokeOperation.q.Direct + * Inputs: + * STACK_VALUE + * VARARG_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * Direct + * Indirect + * Interop + * Fallback + * + * c.SLFunctionLiteralOperation.q.SingleContext + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 BITS + * Specializations: + * SingleContext + * MultiContext + * Fallback + * + * c.SLWritePropertyOperation.q.WriteSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * WriteArray0 + * WriteArray1 + * WriteSLObject0 + * WriteSLObject1 + * WriteObject0 + * WriteObject1 + * Fallback + * + * c.SLLessThanOperation.q.LessThan0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessThan0 + * LessThan1 + * Fallback + * + + */ + @GeneratedBy(SLOperations.class) + private static final class SLOperationsBuilderImplBytecodeNode extends OperationsNode implements Provider { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @CompilationFinal(dimensions = 1) private final byte[] bc; + @CompilationFinal(dimensions = 1) private final Object[] consts; + @Children private final Node[] children; + @CompilationFinal(dimensions = 1) private final BuilderExceptionHandler[] handlers; + @CompilationFinal(dimensions = 1) private final ConditionProfile[] conditionProfiles; + + SLOperationsBuilderImplBytecodeNode(Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + super(parseContext, sourceInfo, sources, buildOrder, maxStack, maxLocals); + this.bc = bc; + this.consts = consts; + this.children = children; + this.handlers = handlers; + this.conditionProfiles = conditionProfiles; + } + + private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + SLAddOperation_SLAddOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLAddOperation_SLAddOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLAddNode.addLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; + } + } + } + if (((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); + return; + } + } + if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { + if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { + SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); + return; + } + } + } + if (((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */)) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLAddOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte state_1 = bc[$bci + 4 + 2]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); + bc[$bci + 4 + 2] = (byte) (state_1); + if ((state_0 & 0b11110) == 0b1010) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG); + } + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + try { + lock.unlock(); + hasLock = false; + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); + state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 2] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); + return; + } + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAddOperation_Add1Data s2_ = super.insert(new SLAddOperation_Add1Data()); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + bc[$bci + 4 + 2] = (byte) (state_1); + if ((state_0 & 0b11110) == 0b1010) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG); + } + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); + bc[$bci + 4 + 2] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLDivOperation_SLDivOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLDivOperation_SLDivOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; + try { + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLDivNode.divLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLDivOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + try { + lock.unlock(); + hasLock = false; + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + byte state_1 = bc[$bci + 4 + 1]; + if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_SLEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0, state_1); + return; + } else if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); + return; + } else { + SLEqualOperation_SLEqualOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); + return; + } + } + + private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 2)) { + $child0Value_ = $frame.getBoolean($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + boolean $child1Value_; + if ($frame.isBoolean($sp - 1)) { + $child1Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child1Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); + boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */) && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */) && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + boolean value = SLEqualNode.doString($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */) && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */) && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */) && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value_))) { + boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + s7_ = s7_.next_; + } + } + if (((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + $frame.setObject($sp - 2, this.SLEqualOperation_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte state_1 = bc[$bci + 4 + 1]; + byte exclude = bc[$bci + 4 + 6]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); + bc[$bci + 4 + 1] = (byte) (state_1); + if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); + state_1 = (byte) (state_1 | (sLBigNumberCast1 << 4) /* set-implicit-state_1 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); + bc[$bci + 4 + 1] = (byte) (state_1); + if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_BOOLEAN); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); + bc[$bci + 4 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doString($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0] = super.insert((EqualNode.create())); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + bc[$bci + 4 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); + bc[$bci + 4 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); + bc[$bci + 4 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value)); + if (count7_ < (4)) { + s7_ = super.insert(new SLEqualOperation_Generic0Data(((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = s7_; + bc[$bci + 4 + 0] = (byte) (state_0); + bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + bc[$bci + 4 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = null; + state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + bc[$bci + 4 + 0] = (byte) (state_0); + bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLLessOrEqualOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); + } + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessThanOperation_SLLessThanOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLLessThanOperation_SLLessThanOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLLessThanOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); + } + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_($frame, $bci, $sp, state_0); + return; + } else { + SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLLogicalNotNode.doBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLLogicalNotOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLMulOperation_SLMulOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLMulOperation_SLMulOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; + try { + long value = SLMulNode.mulLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLMulNode.mulLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLMulOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + try { + lock.unlock(); + hasLock = false; + long value = SLMulNode.mulLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value_))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value__))) { + Node node__1 = (this); + int bci__1 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + return; + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); + return; + } + } + if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value_))) { + Node node__2 = (this); + int bci__2 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + return; + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + { + Node readArray1_node__ = (this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLReadPropertyOperation_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { + { + Node readSLObject1_node__ = (this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3])); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + { + Node readObject1_node__ = (this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); + } + } + + private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 5]; + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value))) { + node__ = (this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = super.insert(new SLReadPropertyOperation_ReadArray0Data(((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); + node__ = (this); + bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + } + } + { + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = (this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_))) { + node__1 = (this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = super.insert(new SLReadPropertyOperation_ReadSLObject0Data(((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); + node__1 = (this); + bci__1 = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); + } + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + return; + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = (this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = super.insert((SLToTruffleStringNodeGen.create())); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; + state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + return; + } + } + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value))) { + node__2 = (this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); + InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); + node__2 = (this); + bci__2 = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + return; + } + } + } + { + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = (this); + readObject1_bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = super.insert((SLToMemberNodeGen.create())); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; + state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException(this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLSubOperation_SLSubOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLSubOperation_SLSubOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; + try { + long value = SLSubNode.subLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLSubNode.subLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLSubOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + } + try { + lock.unlock(); + hasLock = false; + long value = SLSubNode.subLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 3); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 2); + Object $child2Value_; + $child2Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); + return; + } + } + if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + return; + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + Node writeObject1_node__ = (this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); + } + } finally { + encapsulating_.set(prev_); + } + } + + private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + byte exclude = bc[$bci + 5 + 5]; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = super.insert(new SLWritePropertyOperation_WriteArray0Data(((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); + } + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; + state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + } + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__ = (this); + bci__ = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)); + s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); + node__ = (this); + bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = (this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; + state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + byte state_1 = bc[$bci + 3 + 1]; + if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_SLUnboxOperation_execute__boolean0_($frame, $bci, $sp, state_0, state_1); + return; + } else if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_SLUnboxOperation_execute__long1_($frame, $bci, $sp, state_0, state_1); + return; + } else { + SLUnboxOperation_SLUnboxOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); + return; + } + } + + private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + long $child0Value_; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + return; + } + if (((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */) && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); + return; + } + if (((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */) && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLUnboxNode.fromBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if (((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */) && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + long value = SLUnboxNode.fromLong($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if (((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); + return; + } + if (((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */) && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if (((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */) && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { + if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value_))) { + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + return; + } + s7_ = s7_.next_; + } + } + if (((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + $frame.setObject($sp - 1, this.SLUnboxOperation_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + byte state_1 = bc[$bci + 3 + 1]; + byte exclude = bc[$bci + 3 + 6]; + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); + bc[$bci + 3 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); + bc[$bci + 3 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); + bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b1000 && (state_1 & 0b11) == 0) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); + } + if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); + bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b10000 && (state_1 & 0b11) == 0) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); + } + if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); + bc[$bci + 3 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); + return; + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); + bc[$bci + 3 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); + bc[$bci + 3 + 1] = (byte) (state_1); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; + bc[$bci + 3 + 0] = (byte) (state_0); + bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + return; + } + } + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; + state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); + bc[$bci + 3 + 0] = (byte) (state_0); + bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); + return; + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b110) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) || doMultiContext(TruffleString, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ((state_0 & 0b10) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */) { + { + SLLanguage singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); + assert (singleContext_lang__.isSingleContext()); + $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value__, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doMultiContext(TruffleString, Node) */) { + { + Node multiContext_node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.doMultiContext($child0Value__, multiContext_node__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + byte exclude = bc[$bci + 3 + 3]; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + { + SLLanguage singleContext_lang__ = null; + if ((exclude) == 0 /* is-not-exclude doSingleContext(TruffleString, SLLanguage, SLFunction) */) { + { + singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); + if ((singleContext_lang__.isSingleContext())) { + consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunction($child0Value_, this)); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */); + if ((state_0 & 0b110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT); + } + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value_, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); + return; + } + } + } + } + { + Node multiContext_node__ = null; + multiContext_node__ = (this); + bc[$bci + 3 + 3] = exclude = (byte) (exclude | 0b1 /* add-exclude doSingleContext(TruffleString, SLLanguage, SLFunction) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doMultiContext(TruffleString, Node) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLFunctionLiteralNode.doMultiContext($child0Value_, multiContext_node__)); + return; + } + } + throw new UnsupportedSpecializationException(this, new Node[] {null}, $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_($frame, $bci, $sp, state_0); + return; + } else { + SLToBooleanOperation_SLToBooleanOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLToBooleanNode.doBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLToBooleanOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); + } + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + } else { + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + } + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLEvalRootOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value_ instanceof Map) { + Map $child0Value__ = (Map) $child0Value_; + { + Node execute_node__ = (this); + $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value__, execute_node__)); + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */) { + if (SLEvalRootOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value_)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEvalRootOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + { + Node execute_node__ = null; + if ($child0Value instanceof Map) { + Map $child0Value_ = (Map) $child0Value; + execute_node__ = (this); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value_, execute_node__)); + return; + } + } + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); + doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value)); + return; + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private Object SLInvokeOperation_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvokeOperation_removeDirect__($frame, $bci, $sp, s0_); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = (this); + int interop_bci__ = ($bci); + return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + byte exclude = bc[$bci + 5 + 5]; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2])) && Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); + if ((arg0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = super.insert(new SLInvokeOperation_DirectData(((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + MemoryFence.storeStore(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); + } + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + } + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = super.insert((IndirectCallNode.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = (this); + interop_bci__ = ($bci); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvokeOperation_DirectData prev = null; + SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = cur.next_; + this.adoptChildren(); + } else { + prev.next_ = cur.next_; + prev.adoptChildren(); + } + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + private void SLAddOperation_q_Add1_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1000) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1010) != 0 /* is-not addLong(long, long) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { + SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + private void SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLAddNode.addLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; + } + } + } + if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { + SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0]); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 2]))); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + @ExplodeLoop + private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop + private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvokeOperation_DirectData prev = null; + SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = cur.next_; + this.adoptChildren(); + } else { + prev.next_ = cur.next_; + prev.adoptChildren(); + } + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLFunctionLiteralOperation_q_SingleContext_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b10) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + SLLanguage singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); + assert (singleContext_lang__.isSingleContext()); + $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value__, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); + SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + @ExplodeLoop + private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 3); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 2); + Object $child2Value_; + $child2Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; + } + + private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @Override + protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { + int sp = startSp; + int bci = startBci; + Object returnValue = null; + loop: while (true) { + int nextBci; + short curOpcode = LE_BYTES.getShort(bc, bci); + try { + CompilerAsserts.partialEvaluationConstant(bci); + CompilerAsserts.partialEvaluationConstant(sp); + CompilerAsserts.partialEvaluationConstant(curOpcode); + if (sp < maxLocals + VALUES_OFFSET) { + throw CompilerDirectives.shouldNotReachHere("stack underflow"); + } + switch (curOpcode) { + case INSTR_POP : + { + sp = sp - 1; + frame.clear(sp); + nextBci = bci + 2; + break; + } + case INSTR_BRANCH : + { + int targetBci = LE_BYTES.getShort(bc, bci + 2); + if (targetBci <= bci) { + TruffleSafepoint.poll(this); + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { + Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); + if (osrResult != null) { + return osrResult; + } + } + } + bci = targetBci; + continue loop; + } + case INSTR_BRANCH_FALSE : + { + ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; + boolean cond = (boolean) frame.getObject(sp - 1); + sp -= 1; + if (profile.profile(cond)) { + bci = bci + 7; + continue loop; + } else { + bci = LE_BYTES.getShort(bc, bci + 2); + continue loop; + } + } + case INSTR_LOAD_CONSTANT_OBJECT : + { + frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_CONSTANT_LONG : + { + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + frame.setObject(sp, value); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); + } else { + frame.setObject(sp, value); + } + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + if (value instanceof Long) { + frame.setLong(sp, (long) value); + } else { + frame.setObject(sp, value); + } + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_STORE_LOCAL : + { + assert frame.isObject(sp - 1); + frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); + frame.clear(--sp); + nextBci = bci + 5; + break; + } + case INSTR_LOAD_LOCAL_OBJECT : + { + frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); + sp++; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + { + Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); + } else { + frame.setObject(sp, value); + } + sp++; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_LOCAL_LONG : + { + Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); + if (value instanceof Long) { + frame.setLong(sp, (long) value); + } else { + frame.setObject(sp, value); + } + sp++; + nextBci = bci + 4; + break; + } + case INSTR_RETURN : + { + returnValue = frame.getObject(sp - 1); + break loop; + } + case INSTR_C_SLADD_OPERATION : + { + this.SLAddOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLDIV_OPERATION : + { + this.SLDivOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLEQUAL_OPERATION : + { + this.SLEqualOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + { + this.SLLessOrEqualOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION : + { + this.SLLessThanOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLLOGICAL_NOT_OPERATION : + { + this.SLLogicalNotOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLMUL_OPERATION : + { + this.SLMulOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION : + { + this.SLReadPropertyOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLSUB_OPERATION : + { + this.SLSubOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + { + this.SLWritePropertyOperation_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLUNBOX_OPERATION : + { + this.SLUnboxOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + { + this.SLFunctionLiteralOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 7; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION : + { + this.SLToBooleanOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLEVAL_ROOT_OPERATION : + { + this.SLEvalRootOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLINVOKE_OPERATION : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + { + this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + { + this.SLAddOperation_q_Add1_AddLong_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + { + this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + { + this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + { + this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + { + this.SLFunctionLiteralOperation_q_SingleContext_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 7; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant(bci); + for (int handlerIndex = 0; handlerIndex < handlers.length; handlerIndex++) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + BuilderExceptionHandler handler = handlers[handlerIndex]; + if (handler.startBci > bci || handler.endBci <= bci) continue; + sp = handler.startStack + VALUES_OFFSET + maxLocals; + frame.setObject(VALUES_OFFSET + handler.exceptionIndex, ex); + bci = handler.handlerBci; + continue loop; + } + throw ex; + } + CompilerAsserts.partialEvaluationConstant(nextBci); + bci = nextBci; + } + return returnValue; + } + + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + int bci = 0; + while (bci < bc.length) { + switch (LE_BYTES.getShort(bc, bci)) { + case INSTR_POP : + { + bci = bci + 2; + break; + } + case INSTR_BRANCH : + case INSTR_LOAD_CONSTANT_OBJECT : + case INSTR_LOAD_ARGUMENT_OBJECT : + case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_LOCAL_OBJECT : + case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : + case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION : + case INSTR_C_SLEVAL_ROOT_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + { + bci = bci + 4; + break; + } + case INSTR_BRANCH_FALSE : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + { + bci = bci + 7; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : + { + if (true) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); + } + bci = bci + 4; + break; + } + case INSTR_STORE_LOCAL : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + bci = bci + 5; + break; + } + case INSTR_RETURN : + { + bci = bci + 3; + break; + } + case INSTR_C_SLADD_OPERATION : + case INSTR_C_SLEQUAL_OPERATION : + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + bci = bci + 11; + break; + } + case INSTR_C_SLDIV_OPERATION : + case INSTR_C_SLMUL_OPERATION : + case INSTR_C_SLSUB_OPERATION : + { + bci = bci + 6; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + bci = bci + 10; + break; + } + } + } + } + + @Override + public String dump() { + int bci = 0; + int instrIndex = 0; + StringBuilder sb = new StringBuilder(); + while (bci < bc.length) { + sb.append(String.format(" %04x ", bci)); + switch (LE_BYTES.getShort(bc, bci)) { + default : + { + sb.append(String.format("unknown 0x%02x", bc[bci++])); + break; + } + case INSTR_POP : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("pop "); + sb.append("_"); + sb.append(" -> "); + bci += 2; + break; + } + case INSTR_BRANCH : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch "); + sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("branch"); + bci += 4; + break; + } + case INSTR_BRANCH_FALSE : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch.false "); + sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 2))); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); + sb.append(", "); + sb.append(" -> "); + sb.append("branch"); + bci += 7; + break; + } + case INSTR_LOAD_CONSTANT_OBJECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.object "); + { + Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; + sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); + } + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.boolean "); + { + Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; + sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); + } + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_CONSTANT_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.long "); + { + Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; + sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); + } + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.object "); + sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.boolean "); + sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_ARGUMENT_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.long "); + sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_STORE_LOCAL : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); + bci += 5; + break; + } + case INSTR_LOAD_LOCAL_OBJECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.object "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boolean "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_LOCAL_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.long "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_RETURN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("return"); + bci += 3; + break; + } + case INSTR_C_SLADD_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAddOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLDIV_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLDivOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 6; + break; + } + case INSTR_C_SLEQUAL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEqualOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqualOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThanOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + case INSTR_C_SLLOGICAL_NOT_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNotOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_C_SLMUL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLMulOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 6; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadPropertyOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLSUB_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLSubOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLWritePropertyOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLUNBOX_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnboxOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteralOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 7; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBooleanOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_C_SLEVAL_ROOT_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEvalRootOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_C_SLINVOKE_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLInvokeOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnboxOperation.q.FromLong "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAddOperation.q.Add1.AddLong "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadPropertyOperation.q.ReadSLObject0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnboxOperation.q.FromBoolean "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBooleanOperation.q.Boolean "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqualOperation.q.LessOrEqual0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLInvokeOperation.q.Direct "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteralOperation.q.SingleContext "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 7; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLWritePropertyOperation.q.WriteSLObject0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThanOperation.q.LessThan0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < handlers.length; i++) { + sb.append(handlers[i] + "\n"); + } + if (sourceInfo != null) { + sb.append("Source info:\n"); + for (int i = 0; i < sourceInfo[0].length; i++) { + sb.append(String.format(" bci=%04x, offset=%d, length=%d\n", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i])); + } + } + return sb.toString(); + } + + @Override + public SourceSection getSourceSection() { + if (sourceInfo == null) { + OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (Source) parseContext, buildOrder); + copyReparsedInfo(reparsed); + } + return this.getSourceSectionImpl(); + } + + @Override + protected SourceSection getSourceSectionAtBci(int bci) { + if (sourceInfo == null) { + OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (Source) parseContext, buildOrder); + copyReparsedInfo(reparsed); + } + return this.getSourceSectionAtBciImpl(bci); + } + + private static boolean SLAddOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static boolean SLDivOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLessOrEqualOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLessThanOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLogicalNotOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLMulOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLSubOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLToBooleanOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLEvalRootOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value instanceof Map) { + return false; + } + return true; + } + + private static boolean SLAddOperation_q_Add1_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static boolean SLToBooleanOperation_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLLessOrEqualOperation_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLessThanOperation_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void doSetResultBoxed(boolean boxed, byte[] bc, int startBci, int bciOffset, int targetType) { + if (bciOffset == 0) { + return; + } + CompilerDirectives.transferToInterpreter(); + int bci = startBci - bciOffset; + switch (LE_BYTES.getShort(bc, bci)) { + case INSTR_LOAD_CONSTANT_OBJECT : + { + if (!boxed) { + if (targetType == FRAME_TYPE_BOOLEAN) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_BOOLEAN); + } else if (targetType == FRAME_TYPE_LONG) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_LONG); + } + } + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : + { + if (boxed) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); + } + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + if (!boxed) { + if (targetType == FRAME_TYPE_BOOLEAN) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_BOOLEAN); + } else if (targetType == FRAME_TYPE_LONG) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_LONG); + } + } + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : + { + if (boxed) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_OBJECT); + } + break; + } + case INSTR_LOAD_LOCAL_OBJECT : + { + if (!boxed) { + if (targetType == FRAME_TYPE_BOOLEAN) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_BOOLEAN); + } else if (targetType == FRAME_TYPE_LONG) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_LONG); + } + } + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : + { + if (boxed) { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); + } + break; + } + case INSTR_C_SLADD_OPERATION : + case INSTR_C_SLEQUAL_OPERATION : + case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + { + int $bci = bci; + boolean unboxed = !boxed; + if (unboxed) { + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); + } else { + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); + } + break; + } + case INSTR_C_SLDIV_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLMUL_OPERATION : + case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + int $bci = bci; + boolean unboxed = !boxed; + if (unboxed) { + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); + } else { + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); + } + break; + } + case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION : + case INSTR_C_SLEVAL_ROOT_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + { + int $bci = bci; + boolean unboxed = !boxed; + if (unboxed) { + bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); + } else { + bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); + } + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + int $bci = bci; + boolean unboxed = !boxed; + if (unboxed) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); + } else { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); + } + break; + } + case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + int $bci = bci; + boolean unboxed = !boxed; + if (unboxed) { + bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); + } else { + bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); + } + break; + } + } + } + + private static final class SLAddOperation_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAddOperation_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqualOperation_Generic0Data extends Node { + + @Child SLEqualOperation_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqualOperation_Generic0Data(SLEqualOperation_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadPropertyOperation_ReadArray0Data extends Node { + + @Child SLReadPropertyOperation_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadPropertyOperation_ReadArray0Data(SLReadPropertyOperation_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadPropertyOperation_ReadSLObject0Data extends Node { + + @Child SLReadPropertyOperation_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadPropertyOperation_ReadSLObject0Data(SLReadPropertyOperation_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadPropertyOperation_ReadObject0Data extends Node { + + @Child SLReadPropertyOperation_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadPropertyOperation_ReadObject0Data(SLReadPropertyOperation_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWritePropertyOperation_WriteArray0Data extends Node { + + @Child SLWritePropertyOperation_WriteArray0Data next_; + @Child Node node_; + @CompilationFinal int bci_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWritePropertyOperation_WriteArray0Data(SLWritePropertyOperation_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWritePropertyOperation_WriteSLObject0Data extends Node { + + @Child SLWritePropertyOperation_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWritePropertyOperation_WriteSLObject0Data(SLWritePropertyOperation_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWritePropertyOperation_WriteObject0Data extends Node { + + @Child SLWritePropertyOperation_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWritePropertyOperation_WriteObject0Data(SLWritePropertyOperation_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnboxOperation_FromForeign0Data extends Node { + + @Child SLUnboxOperation_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnboxOperation_FromForeign0Data(SLUnboxOperation_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperations.class) + private static final class SLInvokeOperation_DirectData extends Node { + + @Child SLInvokeOperation_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvokeOperation_DirectData(SLInvokeOperation_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + } +} From fbaf78d07fad9765c7ae086b1d929e22d541b61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 29 Apr 2022 08:30:45 +0200 Subject: [PATCH 060/312] [wip] boxing elim longs and bools --- .../src/com/oracle/truffle/sl/operations/SLOperations.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index e2709539df80..dfc47da68468 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -47,7 +47,7 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class}) +@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) From 12a846ae4b0f5a31751832927b01ecc9943fe5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 29 Apr 2022 08:31:30 +0200 Subject: [PATCH 061/312] [wip] rename getEnclosingFile -> SourceFile --- .../oracle/truffle/dsl/processor/java/compiler/Compiler.java | 2 +- .../truffle/dsl/processor/java/compiler/GeneratedCompiler.java | 2 +- .../oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java | 2 +- .../truffle/dsl/processor/java/compiler/JavaCCompiler.java | 2 +- .../truffle/dsl/processor/operations/OperationsParser.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java index 26c3494ffb8b..5cc638f6592c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/Compiler.java @@ -54,5 +54,5 @@ public interface Compiler { void emitDeprecationWarning(ProcessingEnvironment environment, Element element); - File getEnclosingFile(ProcessingEnvironment processingEnv, Element element); + File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element element); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java index eeccdd815852..1e39d4eb1407 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/GeneratedCompiler.java @@ -90,7 +90,7 @@ protected boolean emitDeprecationWarningImpl(ProcessingEnvironment environment, } @Override - public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + public File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element element) { throw new UnsupportedOperationException("generated element"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java index 7947b2885600..cf1c3bf72518 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JDTCompiler.java @@ -360,7 +360,7 @@ private static boolean reportProblem(Object problemReporter, ElementKind kind, O } @Override - public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + public File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element element) { boolean isIde = false; Class c = processingEnv.getClass(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index 5f8317a94035..0dc94ba81385 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -146,7 +146,7 @@ private static void reportProblem(Object check, Object treePath, Element element private static Method metCompilationUnitTree_getSourceFile = null; @Override - public File getEnclosingFile(ProcessingEnvironment processingEnv, Element element) { + public File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element element) { try { ClassLoader cl = element.getClass().getClassLoader(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 619a28ad0a82..ab69b4f8350d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -166,7 +166,7 @@ private String getMainDecisionsFilePath(TypeElement element, AnnotationMirror ge } private File getDecisionsFile(TypeElement element, String path) { - File file = CompilerFactory.getCompiler(element).getEnclosingFile(processingEnv, element); + File file = CompilerFactory.getCompiler(element).getEnclosingSourceFile(processingEnv, element); String parent = file.getParent(); File target = new File(parent, path); From 66c0b016e3fabdb65d9d2c7ce61ed68839e82eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 29 Apr 2022 08:39:44 +0200 Subject: [PATCH 062/312] [wip] do not spec on single context --- .../sl/operations/SLOperationsBuilder.java | 202 +++++------------- .../expression/SLFunctionLiteralNode.java | 34 +-- .../truffle/sl/operations/decisions.json | 2 +- 3 files changed, 74 insertions(+), 164 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 15465ee85055..4fb1d69c4303 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -264,13 +264,13 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 32; private static final int INSTR_C_SLINVOKE_OPERATION = 33; private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 34; - private static final int INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG = 35; + private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 35; private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 36; private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 37; private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 38; private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 39; private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 40; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT = 41; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 41; private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; @@ -1280,13 +1280,12 @@ public void endSLFunctionLiteralOperation() { int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 4 bytes: [BITS, CONST, CONTINUATION, BITS] + // additionalData = 3 bytes: [BITS, CONST, CONTINUATION] // numChildNodes = 0 // numConsts = 1 bc[bci + 3 + 0] = 0; LE_BYTES.putShort(bc, bci + 3 + 1, (short) constPool.reserve()); - bc[bci + 3 + 3] = 0; - bci = bci + 7; + bci = bci + 6; lastPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1699,10 +1698,8 @@ private static OperationsNode reparse(SLLanguage language, Source context, int b * Additional Data: * 0 BITS * 1 CONST - * 3 BITS * Specializations: - * SingleContext - * MultiContext + * Perform * Fallback * * c.SLToBooleanOperation @@ -1767,7 +1764,7 @@ private static OperationsNode reparse(SLLanguage language, Source context, int b * FromForeign1 * Fallback * - * c.SLAddOperation.q.Add1.AddLong + * c.SLAddOperation.q.AddLong * Inputs: * STACK_VALUE * STACK_VALUE @@ -1776,9 +1773,9 @@ private static OperationsNode reparse(SLLanguage language, Source context, int b * Additional Data: * 0 BITS * 1 BITS - * 2 CONST - * 4 CHILD - * 6 BITS + * 2 BITS + * 3 CHILD + * 5 CONST * Specializations: * AddLong * Add0 @@ -1869,7 +1866,7 @@ private static OperationsNode reparse(SLLanguage language, Source context, int b * Interop * Fallback * - * c.SLFunctionLiteralOperation.q.SingleContext + * c.SLFunctionLiteralOperation.q.Perform * Inputs: * STACK_VALUE * Results: @@ -1877,10 +1874,8 @@ private static OperationsNode reparse(SLLanguage language, Source context, int b * Additional Data: * 0 BITS * 1 CONST - * 3 BITS * Specializations: - * SingleContext - * MultiContext + * Perform * Fallback * * c.SLWritePropertyOperation.q.WriteSLObject0 @@ -2077,8 +2072,8 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b1010) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG); + if ((state_0 & 0b11110) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); } if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); @@ -2142,9 +2137,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b1010) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG); - } doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); lock.unlock(); @@ -4637,22 +4629,12 @@ private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_; $child0Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b110) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) || doMultiContext(TruffleString, Node) */ && $child0Value_ instanceof TruffleString) { + if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ((state_0 & 0b10) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */) { - { - SLLanguage singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); - assert (singleContext_lang__.isSingleContext()); - $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value__, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doMultiContext(TruffleString, Node) */) { - { - Node multiContext_node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.doMultiContext($child0Value__, multiContext_node__)); - return; - } + { + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; } } CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -4666,39 +4648,20 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram lock.lock(); try { byte state_0 = bc[$bci + 3 + 0]; - byte exclude = bc[$bci + 3 + 3]; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - { - SLLanguage singleContext_lang__ = null; - if ((exclude) == 0 /* is-not-exclude doSingleContext(TruffleString, SLLanguage, SLFunction) */) { - { - singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); - if ((singleContext_lang__.isSingleContext())) { - consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunction($child0Value_, this)); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */); - if ((state_0 & 0b110) == 0b10) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT); - } - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value_, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); - return; - } - } + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); + node__ = (this); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); } - } - { - Node multiContext_node__ = null; - multiContext_node__ = (this); - bc[$bci + 3 + 3] = exclude = (byte) (exclude | 0b1 /* add-exclude doSingleContext(TruffleString, SLLanguage, SLFunction) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doMultiContext(TruffleString, Node) */); doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.doMultiContext($child0Value_, multiContext_node__)); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); return; } } @@ -5045,18 +5008,8 @@ private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, return; } - private void SLAddOperation_q_Add1_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1000) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1010) != 0 /* is-not addLong(long, long) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -5105,54 +5058,6 @@ private void SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute } } - private void SLAddOperation_q_Add1_AddLong_SLAddOperation_q_Add1_AddLong_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLAddNode.addLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0]); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 4) + 2]))); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - @ExplodeLoop private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; @@ -5314,17 +5219,16 @@ private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int } } - private void SLFunctionLiteralOperation_q_SingleContext_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_; $child0Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b10) != 0 /* is-state_0 doSingleContext(TruffleString, SLLanguage, SLFunction) */; + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; if ($child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { - SLLanguage singleContext_lang__ = (SLFunctionLiteralNode.getLanguage(this)); - assert (singleContext_lang__.isSingleContext()); - $frame.setObject($sp - 1, SLFunctionLiteralNode.doSingleContext($child0Value__, singleContext_lang__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]))); + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); return; } } @@ -5626,7 +5530,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { { this.SLFunctionLiteralOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; - nextBci = bci + 7; + nextBci = bci + 6; break; } case INSTR_C_SLTO_BOOLEAN_OPERATION : @@ -5664,9 +5568,9 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 10; break; } - case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : { - this.SLAddOperation_q_Add1_AddLong_execute_(frame, bci, sp); + this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; break; @@ -5713,11 +5617,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 11; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { - this.SLFunctionLiteralOperation_q_SingleContext_execute_(frame, bci, sp); + this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); sp = sp - 1 + 1; - nextBci = bci + 7; + nextBci = bci + 6; break; } case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : @@ -5784,8 +5688,6 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { break; } case INSTR_BRANCH_FALSE : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : { bci = bci + 7; break; @@ -5817,7 +5719,7 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLEQUAL_OPERATION : case INSTR_C_SLWRITE_PROPERTY_OPERATION : case INSTR_C_SLINVOKE_OPERATION : - case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : { @@ -5827,6 +5729,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLDIV_OPERATION : case INSTR_C_SLMUL_OPERATION : case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { bci = bci + 6; break; @@ -6521,7 +6425,7 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6535,7 +6439,7 @@ public String dump() { sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 7; + bci += 6; break; } case INSTR_C_SLTO_BOOLEAN_OPERATION : @@ -6640,7 +6544,7 @@ public String dump() { bci += 10; break; } - case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6658,7 +6562,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLAddOperation.q.Add1.AddLong "); + sb.append("c.SLAddOperation.q.AddLong "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6798,7 +6702,7 @@ public String dump() { bci += 11; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6806,7 +6710,6 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6816,11 +6719,12 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLFunctionLiteralOperation.q.SingleContext "); + sb.append(" "); + sb.append("c.SLFunctionLiteralOperation.q.Perform "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 7; + bci += 6; break; } case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : @@ -6978,7 +6882,7 @@ private static boolean SLEvalRootOperation_fallbackGuard__(VirtualFrame $frame, return true; } - private static boolean SLAddOperation_q_Add1_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + private static boolean SLAddOperation_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -7075,7 +6979,7 @@ private static void doSetResultBoxed(boolean boxed, byte[] bc, int startBci, int } case INSTR_C_SLADD_OPERATION : case INSTR_C_SLEQUAL_OPERATION : - case INSTR_C_SLADD_OPERATION_Q_ADD1_ADD_LONG : + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : { int $bci = bci; boolean unboxed = !boxed; @@ -7110,7 +7014,7 @@ private static void doSetResultBoxed(boolean boxed, byte[] bc, int startBci, int case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_SINGLE_CONTEXT : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { int $bci = bci; boolean unboxed = !boxed; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java index 529869c90c72..f89848c3ef2f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java @@ -65,24 +65,30 @@ public abstract class SLFunctionLiteralNode extends SLExpressionNode { @SuppressWarnings("unused") - @Specialization(guards = "lang.isSingleContext()") - public static SLFunction doSingleContext(TruffleString functionName, - @Bind("getLanguage(this)") SLLanguage lang, - @Cached("lookupFunction(functionName, this)") SLFunction result) { - assert result.getName().equals(functionName) : "functionName should be a compile-time constant"; - return result; + @Specialization + public static SLFunction perform( + TruffleString functionName, + @Cached("lookupFunctionCached(functionName, this)") SLFunction result, + @Bind("this") Node node) { + if (result == null) { + // multi-context case, perform the lookup every time + return lookupFunction(functionName, node); + } else { + // single-context case, make sure the function name does not change + assert result.getName().equals(functionName) : "function name should be compilation constant"; + return result; + } } - @Specialization(replaces = "doSingleContext") - public static SLFunction doMultiContext(TruffleString functionName, @Bind("this") Node node) { - return lookupFunction(functionName, node); - } - - public static SLFunction lookupFunction(TruffleString functionName, Node node) { + private static SLFunction lookupFunction(TruffleString functionName, Node node) { return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); } - public static SLLanguage getLanguage(Node node) { - return SLLanguage.get(node); + public static SLFunction lookupFunctionCached(TruffleString functionName, Node node) { + if (SLLanguage.get(node).isSingleContext()) { + return lookupFunction(functionName, node); + } else { + return null; + } } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index efc8a2587192..f0db00be48d1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -42,7 +42,7 @@ "operation": "SLInvokeOperation" }, { - "specializations": ["SingleContext"], + "specializations": ["Perform"], "id": "q-SLFunctionLiteralOperation-SingleContext", "type": "Quicken", "operation": "SLFunctionLiteralOperation" From d4059a16738eea9f685d11e1fb9d14570ed3a8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 09:59:17 +0200 Subject: [PATCH 063/312] [wip] fix SL tests --- .../sl/test/SLOperationsSimpleTestSuite.java | 61 +++++++++++++++++ .../oracle/truffle/sl/test/SLTestRunner.java | 8 ++- .../src/tests/error/ParseError02.output | 2 +- .../src/tests/error/TypeError02.output | 2 +- .../com/oracle/truffle/sl/SLException.java | 2 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 68 ++++++++----------- .../controlflow/SLWhileRepeatingNode.java | 27 ++------ .../expression/SLFunctionLiteralNode.java | 2 - .../sl/nodes/util/SLToBooleanNode.java | 2 + .../sl/parser/operations/SLNodeVisitor.java | 2 +- 10 files changed, 105 insertions(+), 71 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java new file mode 100644 index 000000000000..2ab4c400d60f --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.sl.test; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(SLTestRunner.class) +@SLTestSuite(value = {"tests"}, options = {"sl.useOperations", "true"}) +public class SLOperationsSimpleTestSuite { + + public static void main(String[] args) throws Exception { + SLTestRunner.runInMain(SLOperationsSimpleTestSuite.class, args); + } + + /* + * Our "mx unittest" command looks for methods that are annotated with @Test. By just defining + * an empty method, this class gets included and the test suite is properly executed. + */ + @Test + public void unittest() { + } +} diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java index 29fdec0d3d90..592e7e4a998a 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @@ -303,8 +303,12 @@ protected void runChild(TestCase testCase, RunNotifier notifier) { SLLanguage.installBuiltin(builtin); } - Context.Builder builder = Context.newBuilder().allowExperimentalOptions(true).allowHostClassLookup((s) -> true).allowHostAccess(HostAccess.ALL).in( - new ByteArrayInputStream(testCase.testInput.getBytes("UTF-8"))).out(out); + Context.Builder builder = Context.newBuilder() // + .allowExperimentalOptions(true) // + .allowHostClassLookup((s) -> true) // + .allowHostAccess(HostAccess.ALL) // + .in(new ByteArrayInputStream(testCase.testInput.getBytes("UTF-8"))) // + .out(out); for (Map.Entry e : testCase.options.entrySet()) { builder.option(e.getKey(), e.getValue()); } diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/error/ParseError02.output b/truffle/src/com.oracle.truffle.sl.test/src/tests/error/ParseError02.output index e30317970b0b..a7394b7ffe91 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/error/ParseError02.output +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/error/ParseError02.output @@ -1,2 +1,2 @@ Error(s) parsing script: --- line 16 col 9: mismatched input '=' expecting {';', '||', '&&', '<', '<=', '>', '>=', '==', '!=', '+', '-', '*', '/'} +-- line 16 col 11: extraneous input '-' expecting {'(', IDENTIFIER, STRING_LITERAL, NUMERIC_LITERAL} diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/error/TypeError02.output b/truffle/src/com.oracle.truffle.sl.test/src/tests/error/TypeError02.output index 2d622405effe..09d8e54b0473 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/error/TypeError02.output +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/error/TypeError02.output @@ -1 +1 @@ -Type error at TypeError02.sl line 7 col 3: operation "if" not defined for String "4" +Type error at TypeError02.sl line 7 col 3: operation "toBoolean" not defined for String "4" diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 817a2c8155a7..982236a3eede 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -84,7 +84,7 @@ public static SLException typeError(Node operation, int bci, Object... values) { SLException ex = new SLException("", operation, bci); if (operation != null) { - SourceSection ss = ex.getLocation().getSourceSection(); + SourceSection ss = ex.getLocation().getEncapsulatingSourceSection(); if (ss != null && ss.isAvailable()) { result.append(" at ").append(ss.getSource().getName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn()); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 6c19a2f2647f..da0094fd1178 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -46,8 +46,15 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.graalvm.options.OptionCategory; +import org.graalvm.options.OptionDescriptors; +import org.graalvm.options.OptionKey; +import org.graalvm.options.OptionStability; +import org.graalvm.options.OptionValues; + import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.Option; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLanguage; @@ -61,59 +68,21 @@ import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.object.DynamicObject; -import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.builtins.SLBuiltinNode; -import com.oracle.truffle.sl.builtins.SLDefineFunctionBuiltin; -import com.oracle.truffle.sl.builtins.SLNanoTimeBuiltin; -import com.oracle.truffle.sl.builtins.SLPrintlnBuiltin; -import com.oracle.truffle.sl.builtins.SLReadlnBuiltin; -import com.oracle.truffle.sl.builtins.SLStackTraceBuiltin; import com.oracle.truffle.sl.nodes.SLEvalRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.nodes.SLRootNode; -import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLUndefinedFunctionRootNode; -import com.oracle.truffle.sl.nodes.controlflow.SLBlockNode; -import com.oracle.truffle.sl.nodes.controlflow.SLBreakNode; -import com.oracle.truffle.sl.nodes.controlflow.SLContinueNode; -import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; -import com.oracle.truffle.sl.nodes.controlflow.SLIfNode; -import com.oracle.truffle.sl.nodes.controlflow.SLReturnNode; -import com.oracle.truffle.sl.nodes.controlflow.SLWhileNode; -import com.oracle.truffle.sl.nodes.expression.SLAddNode; -import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNode; -import com.oracle.truffle.sl.nodes.expression.SLEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalAndNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalOrNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLStringLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; -import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; -import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; import com.oracle.truffle.sl.operations.SLOperationsBuilder; -import com.oracle.truffle.sl.parser.SLNodeFactory; -import com.oracle.truffle.sl.parser.SimpleLanguageLexer; -import com.oracle.truffle.sl.parser.SimpleLanguageParser; -import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; import com.oracle.truffle.sl.runtime.SLContext; -import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLFunctionRegistry; import com.oracle.truffle.sl.runtime.SLLanguageView; -import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; import com.oracle.truffle.sl.runtime.SLStrings; @@ -218,6 +187,11 @@ public final class SLLanguage extends TruffleLanguage { private final Shape rootShape; + @Option(name = "useOperations", help = "Use the SL interpreter implemented using the Truffle Operations DSL", category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL) // + public static final OptionKey USE_OPERATIONS = new OptionKey<>(false); + + private boolean useOperations; + public SLLanguage() { counter++; this.rootShape = Shape.newBuilder().layout(SLObject.class).build(); @@ -225,6 +199,7 @@ public SLLanguage() { @Override protected SLContext createContext(Env env) { + useOperations = USE_OPERATIONS.getValue(env.getOptions()); return new SLContext(this, env, new ArrayList<>(EXTERNAL_BUILTINS)); } @@ -234,6 +209,11 @@ protected boolean patchContext(SLContext context, Env newEnv) { return true; } + @Override + protected OptionDescriptors getOptionDescriptors() { + return new SLLanguageOptionDescriptors(); + } + public RootCallTarget getOrCreateUndefinedFunction(TruffleString name) { RootCallTarget target = undefinedFunctions.get(name); if (target == null) { @@ -326,8 +306,14 @@ protected CallTarget parse(ParsingRequest request) throws Exception { source = Source.newBuilder(language, sb.toString(), source.getName()).build(); } - OperationsNode[] operations = SLOperationsBuilder.parse(this, source); - return new SLOperationsRootNode(this, operations[operations.length - 1], null).getCallTarget(); + if (useOperations) { + OperationsNode[] operations = SLOperationsBuilder.parse(this, source); + return new SLOperationsRootNode(this, operations[operations.length - 1], null).getCallTarget(); + } else { + Map targets = SLNodeVisitor.parseSL(this, source); + RootCallTarget rootTarget = targets.get(SLStrings.MAIN); + return new SLEvalRootNode(this, rootTarget, targets).getCallTarget(); + } } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileRepeatingNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileRepeatingNode.java index 4606485d9350..c19278dfe1b9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileRepeatingNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileRepeatingNode.java @@ -40,15 +40,15 @@ */ package com.oracle.truffle.sl.nodes.controlflow; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RepeatingNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLStatementNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNodeGen; import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; /** @@ -63,7 +63,7 @@ public final class SLWhileRepeatingNode extends Node implements RepeatingNode { * value. We do not have a node type that can only return a {@code boolean} value, so * {@link #evaluateCondition executing the condition} can lead to a type error. */ - @Child private SLExpressionNode conditionNode; + @Child private SLToBooleanNode conditionNode; /** Statement (or {@link SLBlockNode block}) executed as long as the condition is true. */ @Child private SLStatementNode bodyNode; @@ -77,13 +77,13 @@ public final class SLWhileRepeatingNode extends Node implements RepeatingNode { private final BranchProfile breakTaken = BranchProfile.create(); public SLWhileRepeatingNode(SLExpressionNode conditionNode, SLStatementNode bodyNode) { - this.conditionNode = SLUnboxNodeGen.create(conditionNode); + this.conditionNode = SLToBooleanNodeGen.create(SLUnboxNodeGen.create(conditionNode)); this.bodyNode = bodyNode; } @Override public boolean executeRepeating(VirtualFrame frame) { - if (!evaluateCondition(frame)) { + if (!conditionNode.executeBoolean(frame)) { /* Normal exit of the loop when loop condition is false. */ return false; } @@ -108,23 +108,6 @@ public boolean executeRepeating(VirtualFrame frame) { } } - private boolean evaluateCondition(VirtualFrame frame) { - try { - /* - * The condition must evaluate to a boolean value, so we call the boolean-specialized - * execute method. - */ - return conditionNode.executeBoolean(frame); - } catch (UnexpectedResultException ex) { - /* - * The condition evaluated to a non-boolean result. This is a type error in the SL - * program. We report it with the same exception that Truffle DSL generated nodes use to - * report type errors. - */ - throw new UnsupportedSpecializationException(this, new Node[]{conditionNode}, ex.getResult()); - } - } - @Override public String toString() { return SLStatementNode.formatSourceSection(this); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java index f89848c3ef2f..6c885c2f640c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java @@ -71,10 +71,8 @@ public static SLFunction perform( @Cached("lookupFunctionCached(functionName, this)") SLFunction result, @Bind("this") Node node) { if (result == null) { - // multi-context case, perform the lookup every time return lookupFunction(functionName, node); } else { - // single-context case, make sure the function name does not change assert result.getName().equals(functionName) : "function name should be compilation constant"; return result; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java index ebb8d54df462..840e4af939c8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java @@ -6,10 +6,12 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLExpressionNode; @NodeChild +@NodeInfo(shortName = "toBoolean") public abstract class SLToBooleanNode extends SLExpressionNode { @Override public abstract boolean executeBoolean(VirtualFrame vrame); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java index d6f60575be85..a9489cf58223 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -467,7 +467,7 @@ public SLExpressionNode visitMemberCall(MemberCallContext ctx) { public SLExpressionNode visitMemberAssign(MemberAssignContext ctx) { final SLExpressionNode result; if (assignmentName == null) { - SemErr(ctx.start, "invalid assignment target"); + SemErr(ctx.expression().start, "invalid assignment target"); result = null; } else if (assignmentReceiver == null) { SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); From c37dae292e9f8cf73fbe1f62c47ca1546d28079e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 10:19:31 +0200 Subject: [PATCH 064/312] [wip] fix return; error --- .../oracle/truffle/sl/parser/operations/SLNodeVisitor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java index a9489cf58223..699d01a9a4bd 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -245,7 +245,12 @@ public SLStatementNode visitIf_statement(If_statementContext ctx) { @Override public SLStatementNode visitReturn_statement(Return_statementContext ctx) { - final SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + final SLExpressionNode valueNode; + if (ctx.expression() != null) { + valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + } else { + valueNode = null; + } final int start = ctx.r.getStartIndex(); final int length = valueNode == null ? ctx.r.getText().length() : valueNode.getSourceEndIndex() - start; From 141ba02655c4e8686a83319b4cc8f4791729ef7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 10:40:57 +0200 Subject: [PATCH 065/312] [wip] nuke old parser --- .../sl/operations/SLOperationsBuilder.java | 15 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 46 +- .../sl/nodes/local/SLReadArgumentNode.java | 1 - .../truffle/sl/operations/SLOperations.java | 4 +- .../truffle/sl/parser/SLNodeFactory.java | 633 -------- .../truffle/sl/parser/SimpleLanguage.g4 | 349 ----- .../sl/parser/SimpleLanguageLexer.java | 257 ---- .../sl/parser/SimpleLanguageParser.java | 1323 ----------------- .../sl/parser/operations/SLBaseVisitor.java | 17 +- .../sl/parser/operations/SLNodeVisitor.java | 7 +- .../operations/SLOperationsVisitor.java | 12 +- .../parser/{ => operations}/SLParseError.java | 2 +- .../sl/parser/operations/SLSource.java | 30 + .../sl/runtime/SLFunctionRegistry.java | 10 +- 14 files changed, 112 insertions(+), 2594 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageLexer.java delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{ => operations}/SLParseError.java (98%) create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 4fb1d69c4303..98a33c8e3a46 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -65,6 +65,7 @@ import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.operations.SLOperations.SLEvalRootOperation; import com.oracle.truffle.sl.operations.SLOperations.SLInvokeOperation; +import com.oracle.truffle.sl.parser.operations.SLSource; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; @@ -184,13 +185,13 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endSLInvokeOperation(); - public static OperationsNode[] parse(SLLanguage language, Source context) { + public static OperationsNode[] parse(SLLanguage language, SLSource context) { SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, false, false); SLOperations.parse(language, context, builder); return builder.collect(); } - public static OperationsNode[] parseWithSourceInfo(SLLanguage language, Source context) { + public static OperationsNode[] parseWithSourceInfo(SLLanguage language, SLSource context) { SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); return builder.collect(); @@ -275,7 +276,7 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; private final SLLanguage language; - private final Source parseContext; + private final SLSource parseContext; private final boolean keepSourceInfo; private final boolean keepInstrumentation; private final BuilderSourceInfo sourceInfoBuilder; @@ -289,7 +290,7 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { int nodeNumber = 0; OperationsConstantPool constPool = new OperationsConstantPool(); - SLOperationsBuilderImpl(SLLanguage language, Source parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { + SLOperationsBuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { this.language = language; this.parseContext = parseContext; this.keepSourceInfo = keepSourceInfo; @@ -1388,7 +1389,7 @@ public void endSLInvokeOperation() { doAfterChild(); } - private static OperationsNode reparse(SLLanguage language, Source context, int buildOrder) { + private static OperationsNode reparse(SLLanguage language, SLSource context, int buildOrder) { SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); return builder.collect()[buildOrder]; @@ -6801,7 +6802,7 @@ public String dump() { @Override public SourceSection getSourceSection() { if (sourceInfo == null) { - OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (Source) parseContext, buildOrder); + OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); copyReparsedInfo(reparsed); } return this.getSourceSectionImpl(); @@ -6810,7 +6811,7 @@ public SourceSection getSourceSection() { @Override protected SourceSection getSourceSectionAtBci(int bci) { if (sourceInfo == null) { - OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (Source) parseContext, buildOrder); + OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); copyReparsedInfo(reparsed); } return this.getSourceSectionAtBciImpl(bci); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index da0094fd1178..173f03141c89 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -50,7 +50,6 @@ import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionKey; import org.graalvm.options.OptionStability; -import org.graalvm.options.OptionValues; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; @@ -68,21 +67,58 @@ import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.object.DynamicObject; +import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.builtins.SLBuiltinNode; +import com.oracle.truffle.sl.builtins.SLDefineFunctionBuiltin; +import com.oracle.truffle.sl.builtins.SLNanoTimeBuiltin; +import com.oracle.truffle.sl.builtins.SLPrintlnBuiltin; +import com.oracle.truffle.sl.builtins.SLReadlnBuiltin; +import com.oracle.truffle.sl.builtins.SLStackTraceBuiltin; import com.oracle.truffle.sl.nodes.SLEvalRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.nodes.SLRootNode; +import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLUndefinedFunctionRootNode; +import com.oracle.truffle.sl.nodes.controlflow.SLBlockNode; +import com.oracle.truffle.sl.nodes.controlflow.SLBreakNode; +import com.oracle.truffle.sl.nodes.controlflow.SLContinueNode; +import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; +import com.oracle.truffle.sl.nodes.controlflow.SLIfNode; +import com.oracle.truffle.sl.nodes.controlflow.SLReturnNode; +import com.oracle.truffle.sl.nodes.controlflow.SLWhileNode; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalAndNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalOrNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLStringLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; +import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; +import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; +import com.oracle.truffle.sl.parser.operations.SLSource; +import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; +import com.oracle.truffle.sl.runtime.SLFunction; +import com.oracle.truffle.sl.runtime.SLFunctionRegistry; import com.oracle.truffle.sl.runtime.SLLanguageView; +import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; import com.oracle.truffle.sl.runtime.SLStrings; @@ -214,6 +250,10 @@ protected OptionDescriptors getOptionDescriptors() { return new SLLanguageOptionDescriptors(); } + public boolean isUseOperations() { + return useOperations; + } + public RootCallTarget getOrCreateUndefinedFunction(TruffleString name) { RootCallTarget target = undefinedFunctions.get(name); if (target == null) { @@ -307,10 +347,10 @@ protected CallTarget parse(ParsingRequest request) throws Exception { } if (useOperations) { - OperationsNode[] operations = SLOperationsBuilder.parse(this, source); + OperationsNode[] operations = SLOperationsBuilder.parse(this, new SLSource(source)); return new SLOperationsRootNode(this, operations[operations.length - 1], null).getCallTarget(); } else { - Map targets = SLNodeVisitor.parseSL(this, source); + Map targets = SLNodeVisitor.parseSL(this, new SLSource(source)); RootCallTarget rootTarget = targets.get(SLStrings.MAIN); return new SLEvalRootNode(this, rootTarget, targets).getCallTarget(); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java index 3f5e28e4ad79..350ea517d0f0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java @@ -43,7 +43,6 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.sl.nodes.SLExpressionNode; -import com.oracle.truffle.sl.parser.SLNodeFactory; import com.oracle.truffle.sl.runtime.SLNull; /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index dfc47da68468..5b5133e3fe55 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -23,7 +23,6 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; -import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; @@ -41,6 +40,7 @@ import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; +import com.oracle.truffle.sl.parser.operations.SLSource; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; @@ -64,7 +64,7 @@ @OperationProxy(SLToBooleanNode.class) public class SLOperations { - public static void parse(SLLanguage language, Source source, SLOperationsBuilder builder) { + public static void parse(SLLanguage language, SLSource source, SLOperationsBuilder builder) { Map targets = SLOperationsVisitor.parseSL(language, source, builder); // create the RootNode diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java deleted file mode 100644 index 8ed8d3960fe8..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeFactory.java +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.sl.parser; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.oracle.truffle.sl.runtime.SLStrings; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.Token; - -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.nodes.SLExpressionNode; -import com.oracle.truffle.sl.nodes.SLRootNode; -import com.oracle.truffle.sl.nodes.SLStatementNode; -import com.oracle.truffle.sl.nodes.controlflow.SLBlockNode; -import com.oracle.truffle.sl.nodes.controlflow.SLBreakNode; -import com.oracle.truffle.sl.nodes.controlflow.SLContinueNode; -import com.oracle.truffle.sl.nodes.controlflow.SLDebuggerNode; -import com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode; -import com.oracle.truffle.sl.nodes.controlflow.SLIfNode; -import com.oracle.truffle.sl.nodes.controlflow.SLReturnNode; -import com.oracle.truffle.sl.nodes.controlflow.SLWhileNode; -import com.oracle.truffle.sl.nodes.expression.SLAddNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLEqualNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLInvokeNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLLogicalAndNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLLogicalOrNode; -import com.oracle.truffle.sl.nodes.expression.SLLongLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLParenExpressionNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLStringLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNodeGen; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNodeGen; -import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; -import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; -import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNodeGen; -import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; -import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNodeGen; -import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; - -/** - * Helper class used by the SL {@link Parser} to create nodes. The code is factored out of the - * automatically generated parser to keep the attributed grammar of SL small. - */ -public class SLNodeFactory { - - /** - * Local variable names that are visible in the current block. Variables are not visible outside - * of their defining block, to prevent the usage of undefined variables. Because of that, we can - * decide during parsing if a name references a local variable or is a function name. - */ - static class LexicalScope { - protected final LexicalScope outer; - protected final Map locals; - - LexicalScope(LexicalScope outer) { - this.outer = outer; - this.locals = new HashMap<>(); - } - - public Integer find(TruffleString name) { - Integer result = locals.get(name); - if (result != null) { - return result; - } else if (outer != null) { - return outer.find(name); - } else { - return null; - } - } - } - - /* State while parsing a source unit. */ - private final Source source; - private final TruffleString sourceString; - private final Map allFunctions; - - /* State while parsing a function. */ - private int functionStartPos; - private TruffleString functionName; - private int functionBodyStartPos; // includes parameter list - private int parameterCount; - private FrameDescriptor.Builder frameDescriptorBuilder; - private List methodNodes; - - /* State while parsing a block. */ - private LexicalScope lexicalScope; - private final SLLanguage language; - - public SLNodeFactory(SLLanguage language, Source source) { - this.language = language; - this.source = source; - this.sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); - this.allFunctions = new HashMap<>(); - } - - public Map getAllFunctions() { - return allFunctions; - } - - public void startFunction(Token nameToken, Token bodyStartToken) { - assert functionStartPos == 0; - assert functionName == null; - assert functionBodyStartPos == 0; - assert parameterCount == 0; - assert frameDescriptorBuilder == null; - assert lexicalScope == null; - - functionStartPos = nameToken.getStartIndex(); - functionName = asTruffleString(nameToken, false); - functionBodyStartPos = bodyStartToken.getStartIndex(); - frameDescriptorBuilder = FrameDescriptor.newBuilder(); - methodNodes = new ArrayList<>(); - startBlock(); - } - - public void addFormalParameter(Token nameToken) { - /* - * Method parameters are assigned to local variables at the beginning of the method. This - * ensures that accesses to parameters are specialized the same way as local variables are - * specialized. - */ - final SLReadArgumentNode readArg = new SLReadArgumentNode(parameterCount); - readArg.setSourceSection(nameToken.getStartIndex(), nameToken.getText().length()); - SLExpressionNode assignment = createAssignment(createStringLiteral(nameToken, false), readArg, parameterCount); - methodNodes.add(assignment); - parameterCount++; - } - - public void finishFunction(SLStatementNode bodyNode) { - if (bodyNode == null) { - // a state update that would otherwise be performed by finishBlock - lexicalScope = lexicalScope.outer; - } else { - methodNodes.add(bodyNode); - final int bodyEndPos = bodyNode.getSourceEndIndex(); - final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); - final SLStatementNode methodBlock = finishBlock(methodNodes, parameterCount, functionBodyStartPos, bodyEndPos - functionBodyStartPos); - assert lexicalScope == null : "Wrong scoping of blocks in parser"; - - final SLFunctionBodyNode functionBodyNode = new SLFunctionBodyNode(methodBlock); - functionBodyNode.setSourceSection(functionSrc.getCharIndex(), functionSrc.getCharLength()); - - final SLRootNode rootNode = new SLRootNode(language, frameDescriptorBuilder.build(), functionBodyNode, functionSrc, functionName); - allFunctions.put(functionName, rootNode.getCallTarget()); - } - - functionStartPos = 0; - functionName = null; - functionBodyStartPos = 0; - parameterCount = 0; - frameDescriptorBuilder = null; - lexicalScope = null; - } - - public void startBlock() { - lexicalScope = new LexicalScope(lexicalScope); - } - - public SLStatementNode finishBlock(List bodyNodes, int startPos, int length) { - return finishBlock(bodyNodes, 0, startPos, length); - } - - public SLStatementNode finishBlock(List bodyNodes, int skipCount, int startPos, int length) { - lexicalScope = lexicalScope.outer; - - if (containsNull(bodyNodes)) { - return null; - } - - List flattenedNodes = new ArrayList<>(bodyNodes.size()); - flattenBlocks(bodyNodes, flattenedNodes); - int n = flattenedNodes.size(); - for (int i = skipCount; i < n; i++) { - SLStatementNode statement = flattenedNodes.get(i); - if (statement.hasSource() && !isHaltInCondition(statement)) { - statement.addStatementTag(); - } - } - SLBlockNode blockNode = new SLBlockNode(flattenedNodes.toArray(new SLStatementNode[flattenedNodes.size()])); - blockNode.setSourceSection(startPos, length); - return blockNode; - } - - private static boolean isHaltInCondition(SLStatementNode statement) { - return (statement instanceof SLIfNode) || (statement instanceof SLWhileNode); - } - - private void flattenBlocks(Iterable bodyNodes, List flattenedNodes) { - for (SLStatementNode n : bodyNodes) { - if (n instanceof SLBlockNode) { - flattenBlocks(((SLBlockNode) n).getStatements(), flattenedNodes); - } else { - flattenedNodes.add(n); - } - } - } - - /** - * Returns an {@link SLDebuggerNode} for the given token. - * - * @param debuggerToken The token containing the debugger node's info. - * @return A SLDebuggerNode for the given token. - */ - SLStatementNode createDebugger(Token debuggerToken) { - final SLDebuggerNode debuggerNode = new SLDebuggerNode(); - srcFromToken(debuggerNode, debuggerToken); - return debuggerNode; - } - - /** - * Returns an {@link SLBreakNode} for the given token. - * - * @param breakToken The token containing the break node's info. - * @return A SLBreakNode for the given token. - */ - public SLStatementNode createBreak(Token breakToken) { - final SLBreakNode breakNode = new SLBreakNode(); - srcFromToken(breakNode, breakToken); - return breakNode; - } - - /** - * Returns an {@link SLContinueNode} for the given token. - * - * @param continueToken The token containing the continue node's info. - * @return A SLContinueNode built using the given token. - */ - public SLStatementNode createContinue(Token continueToken) { - final SLContinueNode continueNode = new SLContinueNode(); - srcFromToken(continueNode, continueToken); - return continueNode; - } - - /** - * Returns an {@link SLWhileNode} for the given parameters. - * - * @param whileToken The token containing the while node's info - * @param conditionNode The conditional node for this while loop - * @param bodyNode The body of the while loop - * @return A SLWhileNode built using the given parameters. null if either conditionNode or - * bodyNode is null. - */ - public SLStatementNode createWhile(Token whileToken, SLExpressionNode conditionNode, SLStatementNode bodyNode) { - if (conditionNode == null || bodyNode == null) { - return null; - } - - conditionNode.addStatementTag(); - final int start = whileToken.getStartIndex(); - final int end = bodyNode.getSourceEndIndex(); - final SLWhileNode whileNode = new SLWhileNode(conditionNode, bodyNode); - whileNode.setSourceSection(start, end - start); - return whileNode; - } - - /** - * Returns an {@link SLIfNode} for the given parameters. - * - * @param ifToken The token containing the if node's info - * @param conditionNode The condition node of this if statement - * @param thenPartNode The then part of the if - * @param elsePartNode The else part of the if (null if no else part) - * @return An SLIfNode for the given parameters. null if either conditionNode or thenPartNode is - * null. - */ - public SLStatementNode createIf(Token ifToken, SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) { - if (conditionNode == null || thenPartNode == null) { - return null; - } - - conditionNode.addStatementTag(); - final int start = ifToken.getStartIndex(); - final int end = elsePartNode == null ? thenPartNode.getSourceEndIndex() : elsePartNode.getSourceEndIndex(); - final SLIfNode ifNode = new SLIfNode(conditionNode, thenPartNode, elsePartNode); - ifNode.setSourceSection(start, end - start); - return ifNode; - } - - /** - * Returns an {@link SLReturnNode} for the given parameters. - * - * @param t The token containing the return node's info - * @param valueNode The value of the return (null if not returning a value) - * @return An SLReturnNode for the given parameters. - */ - public SLStatementNode createReturn(Token t, SLExpressionNode valueNode) { - final int start = t.getStartIndex(); - final int length = valueNode == null ? t.getText().length() : valueNode.getSourceEndIndex() - start; - final SLReturnNode returnNode = new SLReturnNode(valueNode); - returnNode.setSourceSection(start, length); - return returnNode; - } - - /** - * Returns the corresponding subclass of {@link SLExpressionNode} for binary expressions.
- * These nodes are currently not instrumented. - * - * @param opToken The operator of the binary expression - * @param leftNode The left node of the expression - * @param rightNode The right node of the expression - * @return A subclass of SLExpressionNode using the given parameters based on the given opToken. - * null if either leftNode or rightNode is null. - */ - public SLExpressionNode createBinary(Token opToken, SLExpressionNode leftNode, SLExpressionNode rightNode) { - if (leftNode == null || rightNode == null) { - return null; - } - final SLExpressionNode leftUnboxed = SLUnboxNodeGen.create(leftNode); - final SLExpressionNode rightUnboxed = SLUnboxNodeGen.create(rightNode); - - final SLExpressionNode result; - switch (opToken.getText()) { - case "+": - result = SLAddNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "*": - result = SLMulNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "/": - result = SLDivNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "-": - result = SLSubNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "<": - result = SLLessThanNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "<=": - result = SLLessOrEqualNodeGen.create(leftUnboxed, rightUnboxed); - break; - case ">": - result = SLLogicalNotNodeGen.create(SLLessOrEqualNodeGen.create(leftUnboxed, rightUnboxed)); - break; - case ">=": - result = SLLogicalNotNodeGen.create(SLLessThanNodeGen.create(leftUnboxed, rightUnboxed)); - break; - case "==": - result = SLEqualNodeGen.create(leftUnboxed, rightUnboxed); - break; - case "!=": - result = SLLogicalNotNodeGen.create(SLEqualNodeGen.create(leftUnboxed, rightUnboxed)); - break; - case "&&": - result = new SLLogicalAndNode(leftUnboxed, rightUnboxed); - break; - case "||": - result = new SLLogicalOrNode(leftUnboxed, rightUnboxed); - break; - default: - throw new RuntimeException("unexpected operation: " + opToken.getText()); - } - - int start = leftNode.getSourceCharIndex(); - int length = rightNode.getSourceEndIndex() - start; - result.setSourceSection(start, length); - result.addExpressionTag(); - - return result; - } - - /** - * Returns an {@link SLInvokeNode} for the given parameters. - * - * @param functionNode The function being called - * @param parameterNodes The parameters of the function call - * @param finalToken A token used to determine the end of the sourceSelection for this call - * @return An SLInvokeNode for the given parameters. null if functionNode or any of the - * parameterNodes are null. - */ - public SLExpressionNode createCall(SLExpressionNode functionNode, List parameterNodes, Token finalToken) { - if (functionNode == null || containsNull(parameterNodes)) { - return null; - } - - final SLExpressionNode result = new SLInvokeNode(functionNode, parameterNodes.toArray(new SLExpressionNode[parameterNodes.size()])); - - final int startPos = functionNode.getSourceCharIndex(); - final int endPos = finalToken.getStartIndex() + finalToken.getText().length(); - result.setSourceSection(startPos, endPos - startPos); - result.addExpressionTag(); - - return result; - } - - /** - * Returns an {@link SLWriteLocalVariableNode} for the given parameters. - * - * @param nameNode The name of the variable being assigned - * @param valueNode The value to be assigned - * @return An SLExpressionNode for the given parameters. null if nameNode or valueNode is null. - */ - public SLExpressionNode createAssignment(SLExpressionNode nameNode, SLExpressionNode valueNode) { - return createAssignment(nameNode, valueNode, null); - } - - /** - * Returns an {@link SLWriteLocalVariableNode} for the given parameters. - * - * @param nameNode The name of the variable being assigned - * @param valueNode The value to be assigned - * @param argumentIndex null or index of the argument the assignment is assigning - * @return An SLExpressionNode for the given parameters. null if nameNode or valueNode is null. - */ - public SLExpressionNode createAssignment(SLExpressionNode nameNode, SLExpressionNode valueNode, Integer argumentIndex) { - if (nameNode == null || valueNode == null) { - return null; - } - - TruffleString name = ((SLStringLiteralNode) nameNode).executeGeneric(null); - - Integer frameSlot = lexicalScope.find(name); - boolean newVariable = false; - if (frameSlot == null) { - frameSlot = frameDescriptorBuilder.addSlot(FrameSlotKind.Illegal, name, argumentIndex); - lexicalScope.locals.put(name, frameSlot); - newVariable = true; - } - final SLExpressionNode result = SLWriteLocalVariableNodeGen.create(valueNode, frameSlot, nameNode, newVariable); - - if (valueNode.hasSource()) { - final int start = nameNode.getSourceCharIndex(); - final int length = valueNode.getSourceEndIndex() - start; - result.setSourceSection(start, length); - } - if (argumentIndex == null) { - result.addExpressionTag(); - } - - return result; - } - - /** - * Returns a {@link SLReadLocalVariableNode} if this read is a local variable or a - * {@link SLFunctionLiteralNode} if this read is global. In SL, the only global names are - * functions. - * - * @param nameNode The name of the variable/function being read - * @return either: - *
    - *
  • A SLReadLocalVariableNode representing the local variable being read.
  • - *
  • A SLFunctionLiteralNode representing the function definition.
  • - *
  • null if nameNode is null.
  • - *
- */ - public SLExpressionNode createRead(SLExpressionNode nameNode) { - if (nameNode == null) { - return null; - } - - TruffleString name = ((SLStringLiteralNode) nameNode).executeGeneric(null); - final SLExpressionNode result; - final Integer frameSlot = lexicalScope.find(name); - if (frameSlot != null) { - /* Read of a local variable. */ - result = SLReadLocalVariableNodeGen.create(frameSlot); - } else { - /* Read of a global name. In our language, the only global names are functions. */ - result = SLFunctionLiteralNodeGen.create(new SLStringLiteralNode(name)); - } - result.setSourceSection(nameNode.getSourceCharIndex(), nameNode.getSourceLength()); - result.addExpressionTag(); - return result; - } - - public SLExpressionNode createStringLiteral(Token literalToken, boolean removeQuotes) { - final SLStringLiteralNode result = new SLStringLiteralNode(asTruffleString(literalToken, removeQuotes)); - srcFromToken(result, literalToken); - result.addExpressionTag(); - return result; - } - - private TruffleString asTruffleString(Token literalToken, boolean removeQuotes) { - int fromIndex = literalToken.getStartIndex(); - int length = literalToken.getStopIndex() - literalToken.getStartIndex() + 1; - if (removeQuotes) { - /* Remove the trailing and ending " */ - assert literalToken.getText().length() >= 2 && literalToken.getText().startsWith("\"") && literalToken.getText().endsWith("\""); - fromIndex += 1; - length -= 2; - } - return sourceString.substringByteIndexUncached(fromIndex * 2, length * 2, SLLanguage.STRING_ENCODING, true); - } - - public SLExpressionNode createNumericLiteral(Token literalToken) { - SLExpressionNode result; - try { - /* Try if the literal is small enough to fit into a long value. */ - result = new SLLongLiteralNode(Long.parseLong(literalToken.getText())); - } catch (NumberFormatException ex) { - /* Overflow of long value, so fall back to BigInteger. */ - result = new SLBigIntegerLiteralNode(new BigInteger(literalToken.getText())); - } - srcFromToken(result, literalToken); - result.addExpressionTag(); - return result; - } - - public SLExpressionNode createParenExpression(SLExpressionNode expressionNode, int start, int length) { - if (expressionNode == null) { - return null; - } - - final SLParenExpressionNode result = new SLParenExpressionNode(expressionNode); - result.setSourceSection(start, length); - return result; - } - - /** - * Returns an {@link SLReadPropertyNode} for the given parameters. - * - * @param receiverNode The receiver of the property access - * @param nameNode The name of the property being accessed - * @return An SLExpressionNode for the given parameters. null if receiverNode or nameNode is - * null. - */ - public SLExpressionNode createReadProperty(SLExpressionNode receiverNode, SLExpressionNode nameNode) { - if (receiverNode == null || nameNode == null) { - return null; - } - - final SLExpressionNode result = SLReadPropertyNodeGen.create(receiverNode, nameNode); - - final int startPos = receiverNode.getSourceCharIndex(); - final int endPos = nameNode.getSourceEndIndex(); - result.setSourceSection(startPos, endPos - startPos); - result.addExpressionTag(); - - return result; - } - - /** - * Returns an {@link SLWritePropertyNode} for the given parameters. - * - * @param receiverNode The receiver object of the property assignment - * @param nameNode The name of the property being assigned - * @param valueNode The value to be assigned - * @return An SLExpressionNode for the given parameters. null if receiverNode, nameNode or - * valueNode is null. - */ - public SLExpressionNode createWriteProperty(SLExpressionNode receiverNode, SLExpressionNode nameNode, SLExpressionNode valueNode) { - if (receiverNode == null || nameNode == null || valueNode == null) { - return null; - } - - final SLExpressionNode result = SLWritePropertyNodeGen.create(receiverNode, nameNode, valueNode); - - final int start = receiverNode.getSourceCharIndex(); - final int length = valueNode.getSourceEndIndex() - start; - result.setSourceSection(start, length); - result.addExpressionTag(); - - return result; - } - - /** - * Creates source description of a single token. - */ - private static void srcFromToken(SLStatementNode node, Token token) { - node.setSourceSection(token.getStartIndex(), token.getText().length()); - } - - /** - * Checks whether a list contains a null. - */ - private static boolean containsNull(List list) { - for (Object e : list) { - if (e == null) { - return true; - } - } - return false; - } - -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 deleted file mode 100644 index e931ae6d743d..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.g4 +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * The parser and lexer need to be generated using "mx create-sl-parser". - */ - -grammar SimpleLanguage; - -@parser::header -{ -// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.nodes.SLExpressionNode; -import com.oracle.truffle.sl.nodes.SLRootNode; -import com.oracle.truffle.sl.nodes.SLStatementNode; -import com.oracle.truffle.sl.parser.SLParseError; -} - -@lexer::header -{ -// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" -} - -@parser::members -{ -private SLNodeFactory factory; -private Source source; - -private static final class BailoutErrorListener extends BaseErrorListener { - private final Source source; - BailoutErrorListener(Source source) { - this.source = source; - } - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { - throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg); - } -} - -public void SemErr(Token token, String message) { - assert token != null; - throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); -} - -private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) { - int col = charPositionInLine + 1; - String location = "-- line " + line + " col " + col + ": "; - int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0); - throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); -} - -public static Map parseSL(SLLanguage language, Source source) { - SimpleLanguageLexer lexer = new SimpleLanguageLexer(CharStreams.fromString(source.getCharacters().toString())); - SimpleLanguageParser parser = new SimpleLanguageParser(new CommonTokenStream(lexer)); - lexer.removeErrorListeners(); - parser.removeErrorListeners(); - BailoutErrorListener listener = new BailoutErrorListener(source); - lexer.addErrorListener(listener); - parser.addErrorListener(listener); - parser.factory = new SLNodeFactory(language, source); - parser.source = source; - parser.simplelanguage(); - return parser.factory.getAllFunctions(); -} -} - -// parser - - - - -simplelanguage -: -function function* EOF -; - - -function -: -'function' -IDENTIFIER -s='(' - { factory.startFunction($IDENTIFIER, $s); } -( - IDENTIFIER { factory.addFormalParameter($IDENTIFIER); } - ( - ',' - IDENTIFIER { factory.addFormalParameter($IDENTIFIER); } - )* -)? -')' -body=block[false] { factory.finishFunction($body.result); } -; - - - -block [boolean inLoop] returns [SLStatementNode result] -: { factory.startBlock(); - List body = new ArrayList<>(); } -s='{' -( - statement[inLoop] { body.add($statement.result); } -)* -e='}' - { $result = factory.finishBlock(body, $s.getStartIndex(), $e.getStopIndex() - $s.getStartIndex() + 1); } -; - - -statement [boolean inLoop] returns [SLStatementNode result] -: -( - while_statement { $result = $while_statement.result; } -| - b='break' { if (inLoop) { $result = factory.createBreak($b); } else { SemErr($b, "break used outside of loop"); } } - ';' -| - c='continue' { if (inLoop) { $result = factory.createContinue($c); } else { SemErr($c, "continue used outside of loop"); } } - ';' -| - if_statement[inLoop] { $result = $if_statement.result; } -| - return_statement { $result = $return_statement.result; } -| - expression ';' { $result = $expression.result; } -| - d='debugger' { $result = factory.createDebugger($d); } - ';' -) -; - - -while_statement returns [SLStatementNode result] -: -w='while' -'(' -condition=expression -')' -body=block[true] { $result = factory.createWhile($w, $condition.result, $body.result); } -; - - -if_statement [boolean inLoop] returns [SLStatementNode result] -: -i='if' -'(' -condition=expression -')' -then=block[inLoop] { SLStatementNode elsePart = null; } -( - 'else' - block[inLoop] { elsePart = $block.result; } -)? { $result = factory.createIf($i, $condition.result, $then.result, elsePart); } -; - - -return_statement returns [SLStatementNode result] -: -r='return' { SLExpressionNode value = null; } -( - expression { value = $expression.result; } -)? { $result = factory.createReturn($r, value); } -';' -; - - -expression returns [SLExpressionNode result] -: -logic_term { $result = $logic_term.result; } -( - op='||' - logic_term { $result = factory.createBinary($op, $result, $logic_term.result); } -)* -; - - -logic_term returns [SLExpressionNode result] -: -logic_factor { $result = $logic_factor.result; } -( - op='&&' - logic_factor { $result = factory.createBinary($op, $result, $logic_factor.result); } -)* -; - - -logic_factor returns [SLExpressionNode result] -: -arithmetic { $result = $arithmetic.result; } -( - op=('<' | '<=' | '>' | '>=' | '==' | '!=' ) - arithmetic { $result = factory.createBinary($op, $result, $arithmetic.result); } -)? -; - - -arithmetic returns [SLExpressionNode result] -: -term { $result = $term.result; } -( - op=('+' | '-') - term { $result = factory.createBinary($op, $result, $term.result); } -)* -; - - -term returns [SLExpressionNode result] -: -factor { $result = $factor.result; } -( - op=('*' | '/') - factor { $result = factory.createBinary($op, $result, $factor.result); } -)* -; - - -factor returns [SLExpressionNode result] -: -( - IDENTIFIER { SLExpressionNode assignmentName = factory.createStringLiteral($IDENTIFIER, false); } - ( - member_expression[null, null, assignmentName] { $result = $member_expression.result; } - | - { $result = factory.createRead(assignmentName); } - ) -| - STRING_LITERAL { $result = factory.createStringLiteral($STRING_LITERAL, true); } -| - NUMERIC_LITERAL { $result = factory.createNumericLiteral($NUMERIC_LITERAL); } -| - s='(' - expr=expression - e=')' { $result = factory.createParenExpression($expr.result, $s.getStartIndex(), $e.getStopIndex() - $s.getStartIndex() + 1); } -) -; - - -member_expression [SLExpressionNode r, SLExpressionNode assignmentReceiver, SLExpressionNode assignmentName] returns [SLExpressionNode result] -: { SLExpressionNode receiver = r; - SLExpressionNode nestedAssignmentName = null; } -( - '(' { List parameters = new ArrayList<>(); - if (receiver == null) { - receiver = factory.createRead(assignmentName); - } } - ( - expression { parameters.add($expression.result); } - ( - ',' - expression { parameters.add($expression.result); } - )* - )? - e=')' - { $result = factory.createCall(receiver, parameters, $e); } -| - '=' - expression { if (assignmentName == null) { - SemErr($expression.start, "invalid assignment target"); - } else if (assignmentReceiver == null) { - $result = factory.createAssignment(assignmentName, $expression.result); - } else { - $result = factory.createWriteProperty(assignmentReceiver, assignmentName, $expression.result); - } } -| - '.' { if (receiver == null) { - receiver = factory.createRead(assignmentName); - } } - IDENTIFIER - { nestedAssignmentName = factory.createStringLiteral($IDENTIFIER, false); - $result = factory.createReadProperty(receiver, nestedAssignmentName); } -| - '[' { if (receiver == null) { - receiver = factory.createRead(assignmentName); - } } - expression - { nestedAssignmentName = $expression.result; - $result = factory.createReadProperty(receiver, nestedAssignmentName); } - ']' -) -( - member_expression[$result, receiver, nestedAssignmentName] { $result = $member_expression.result; } -)? -; - -// lexer - -WS : [ \t\r\n\u000C]+ -> skip; -COMMENT : '/*' .*? '*/' -> skip; -LINE_COMMENT : '//' ~[\r\n]* -> skip; - -fragment LETTER : [A-Z] | [a-z] | '_' | '$'; -fragment NON_ZERO_DIGIT : [1-9]; -fragment DIGIT : [0-9]; -fragment HEX_DIGIT : [0-9] | [a-f] | [A-F]; -fragment OCT_DIGIT : [0-7]; -fragment BINARY_DIGIT : '0' | '1'; -fragment TAB : '\t'; -fragment STRING_CHAR : ~('"' | '\r' | '\n'); - -IDENTIFIER : LETTER (LETTER | DIGIT)*; -STRING_LITERAL : '"' STRING_CHAR* '"'; -NUMERIC_LITERAL : '0' | NON_ZERO_DIGIT DIGIT*; - diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageLexer.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageLexer.java deleted file mode 100644 index 7ec19683dd6e..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageLexer.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// Checkstyle: stop -//@formatter:off -package com.oracle.truffle.sl.parser; - -// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" - -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.misc.*; - -@SuppressWarnings("all") -public class SimpleLanguageLexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, WS=31, COMMENT=32, - LINE_COMMENT=33, IDENTIFIER=34, STRING_LITERAL=35, NUMERIC_LITERAL=36; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[] { - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", - "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", - "T__25", "T__26", "T__27", "T__28", "T__29", "WS", "COMMENT", "LINE_COMMENT", - "LETTER", "NON_ZERO_DIGIT", "DIGIT", "HEX_DIGIT", "OCT_DIGIT", "BINARY_DIGIT", - "TAB", "STRING_CHAR", "IDENTIFIER", "STRING_LITERAL", "NUMERIC_LITERAL" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'function'", "'('", "','", "')'", "'{'", "'}'", "'break'", "';'", - "'continue'", "'debugger'", "'while'", "'if'", "'else'", "'return'", - "'||'", "'&&'", "'<'", "'<='", "'>'", "'>='", "'=='", "'!='", "'+'", - "'-'", "'*'", "'/'", "'='", "'.'", "'['", "']'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, "WS", "COMMENT", "LINE_COMMENT", - "IDENTIFIER", "STRING_LITERAL", "NUMERIC_LITERAL" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public SimpleLanguageLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @Override - public String getGrammarFileName() { return "SimpleLanguage.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public String[] getChannelNames() { return channelNames; } - - @Override - public String[] getModeNames() { return modeNames; } - - @Override - public ATN getATN() { return _ATN; } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2&\u0110\b\1\4\2\t"+ - "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ - "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ - ",\t,\4-\t-\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5"+ - "\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3"+ - "\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3"+ - "\f\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17"+ - "\3\17\3\17\3\17\3\20\3\20\3\20\3\21\3\21\3\21\3\22\3\22\3\23\3\23\3\23"+ - "\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\27\3\30\3\30\3\31"+ - "\3\31\3\32\3\32\3\33\3\33\3\34\3\34\3\35\3\35\3\36\3\36\3\37\3\37\3 \6"+ - " \u00c5\n \r \16 \u00c6\3 \3 \3!\3!\3!\3!\7!\u00cf\n!\f!\16!\u00d2\13"+ - "!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\7\"\u00dd\n\"\f\"\16\"\u00e0\13\"\3\""+ - "\3\"\3#\5#\u00e5\n#\3$\3$\3%\3%\3&\5&\u00ec\n&\3\'\3\'\3(\3(\3)\3)\3*"+ - "\3*\3+\3+\3+\7+\u00f9\n+\f+\16+\u00fc\13+\3,\3,\7,\u0100\n,\f,\16,\u0103"+ - "\13,\3,\3,\3-\3-\3-\7-\u010a\n-\f-\16-\u010d\13-\5-\u010f\n-\3\u00d0\2"+ - ".\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20"+ - "\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37"+ - "= ?!A\"C#E\2G\2I\2K\2M\2O\2Q\2S\2U$W%Y&\3\2\n\5\2\13\f\16\17\"\"\4\2\f"+ - "\f\17\17\6\2&&C\\aac|\3\2\63;\3\2\62;\5\2\62;CHch\3\2\629\5\2\f\f\17\17"+ - "$$\2\u010f\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2"+ - "\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27"+ - "\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2"+ - "\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2"+ - "\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2"+ - "\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2U\3\2\2\2"+ - "\2W\3\2\2\2\2Y\3\2\2\2\3[\3\2\2\2\5d\3\2\2\2\7f\3\2\2\2\th\3\2\2\2\13"+ - "j\3\2\2\2\rl\3\2\2\2\17n\3\2\2\2\21t\3\2\2\2\23v\3\2\2\2\25\177\3\2\2"+ - "\2\27\u0088\3\2\2\2\31\u008e\3\2\2\2\33\u0091\3\2\2\2\35\u0096\3\2\2\2"+ - "\37\u009d\3\2\2\2!\u00a0\3\2\2\2#\u00a3\3\2\2\2%\u00a5\3\2\2\2\'\u00a8"+ - "\3\2\2\2)\u00aa\3\2\2\2+\u00ad\3\2\2\2-\u00b0\3\2\2\2/\u00b3\3\2\2\2\61"+ - "\u00b5\3\2\2\2\63\u00b7\3\2\2\2\65\u00b9\3\2\2\2\67\u00bb\3\2\2\29\u00bd"+ - "\3\2\2\2;\u00bf\3\2\2\2=\u00c1\3\2\2\2?\u00c4\3\2\2\2A\u00ca\3\2\2\2C"+ - "\u00d8\3\2\2\2E\u00e4\3\2\2\2G\u00e6\3\2\2\2I\u00e8\3\2\2\2K\u00eb\3\2"+ - "\2\2M\u00ed\3\2\2\2O\u00ef\3\2\2\2Q\u00f1\3\2\2\2S\u00f3\3\2\2\2U\u00f5"+ - "\3\2\2\2W\u00fd\3\2\2\2Y\u010e\3\2\2\2[\\\7h\2\2\\]\7w\2\2]^\7p\2\2^_"+ - "\7e\2\2_`\7v\2\2`a\7k\2\2ab\7q\2\2bc\7p\2\2c\4\3\2\2\2de\7*\2\2e\6\3\2"+ - "\2\2fg\7.\2\2g\b\3\2\2\2hi\7+\2\2i\n\3\2\2\2jk\7}\2\2k\f\3\2\2\2lm\7\177"+ - "\2\2m\16\3\2\2\2no\7d\2\2op\7t\2\2pq\7g\2\2qr\7c\2\2rs\7m\2\2s\20\3\2"+ - "\2\2tu\7=\2\2u\22\3\2\2\2vw\7e\2\2wx\7q\2\2xy\7p\2\2yz\7v\2\2z{\7k\2\2"+ - "{|\7p\2\2|}\7w\2\2}~\7g\2\2~\24\3\2\2\2\177\u0080\7f\2\2\u0080\u0081\7"+ - "g\2\2\u0081\u0082\7d\2\2\u0082\u0083\7w\2\2\u0083\u0084\7i\2\2\u0084\u0085"+ - "\7i\2\2\u0085\u0086\7g\2\2\u0086\u0087\7t\2\2\u0087\26\3\2\2\2\u0088\u0089"+ - "\7y\2\2\u0089\u008a\7j\2\2\u008a\u008b\7k\2\2\u008b\u008c\7n\2\2\u008c"+ - "\u008d\7g\2\2\u008d\30\3\2\2\2\u008e\u008f\7k\2\2\u008f\u0090\7h\2\2\u0090"+ - "\32\3\2\2\2\u0091\u0092\7g\2\2\u0092\u0093\7n\2\2\u0093\u0094\7u\2\2\u0094"+ - "\u0095\7g\2\2\u0095\34\3\2\2\2\u0096\u0097\7t\2\2\u0097\u0098\7g\2\2\u0098"+ - "\u0099\7v\2\2\u0099\u009a\7w\2\2\u009a\u009b\7t\2\2\u009b\u009c\7p\2\2"+ - "\u009c\36\3\2\2\2\u009d\u009e\7~\2\2\u009e\u009f\7~\2\2\u009f \3\2\2\2"+ - "\u00a0\u00a1\7(\2\2\u00a1\u00a2\7(\2\2\u00a2\"\3\2\2\2\u00a3\u00a4\7>"+ - "\2\2\u00a4$\3\2\2\2\u00a5\u00a6\7>\2\2\u00a6\u00a7\7?\2\2\u00a7&\3\2\2"+ - "\2\u00a8\u00a9\7@\2\2\u00a9(\3\2\2\2\u00aa\u00ab\7@\2\2\u00ab\u00ac\7"+ - "?\2\2\u00ac*\3\2\2\2\u00ad\u00ae\7?\2\2\u00ae\u00af\7?\2\2\u00af,\3\2"+ - "\2\2\u00b0\u00b1\7#\2\2\u00b1\u00b2\7?\2\2\u00b2.\3\2\2\2\u00b3\u00b4"+ - "\7-\2\2\u00b4\60\3\2\2\2\u00b5\u00b6\7/\2\2\u00b6\62\3\2\2\2\u00b7\u00b8"+ - "\7,\2\2\u00b8\64\3\2\2\2\u00b9\u00ba\7\61\2\2\u00ba\66\3\2\2\2\u00bb\u00bc"+ - "\7?\2\2\u00bc8\3\2\2\2\u00bd\u00be\7\60\2\2\u00be:\3\2\2\2\u00bf\u00c0"+ - "\7]\2\2\u00c0<\3\2\2\2\u00c1\u00c2\7_\2\2\u00c2>\3\2\2\2\u00c3\u00c5\t"+ - "\2\2\2\u00c4\u00c3\3\2\2\2\u00c5\u00c6\3\2\2\2\u00c6\u00c4\3\2\2\2\u00c6"+ - "\u00c7\3\2\2\2\u00c7\u00c8\3\2\2\2\u00c8\u00c9\b \2\2\u00c9@\3\2\2\2\u00ca"+ - "\u00cb\7\61\2\2\u00cb\u00cc\7,\2\2\u00cc\u00d0\3\2\2\2\u00cd\u00cf\13"+ - "\2\2\2\u00ce\u00cd\3\2\2\2\u00cf\u00d2\3\2\2\2\u00d0\u00d1\3\2\2\2\u00d0"+ - "\u00ce\3\2\2\2\u00d1\u00d3\3\2\2\2\u00d2\u00d0\3\2\2\2\u00d3\u00d4\7,"+ - "\2\2\u00d4\u00d5\7\61\2\2\u00d5\u00d6\3\2\2\2\u00d6\u00d7\b!\2\2\u00d7"+ - "B\3\2\2\2\u00d8\u00d9\7\61\2\2\u00d9\u00da\7\61\2\2\u00da\u00de\3\2\2"+ - "\2\u00db\u00dd\n\3\2\2\u00dc\u00db\3\2\2\2\u00dd\u00e0\3\2\2\2\u00de\u00dc"+ - "\3\2\2\2\u00de\u00df\3\2\2\2\u00df\u00e1\3\2\2\2\u00e0\u00de\3\2\2\2\u00e1"+ - "\u00e2\b\"\2\2\u00e2D\3\2\2\2\u00e3\u00e5\t\4\2\2\u00e4\u00e3\3\2\2\2"+ - "\u00e5F\3\2\2\2\u00e6\u00e7\t\5\2\2\u00e7H\3\2\2\2\u00e8\u00e9\t\6\2\2"+ - "\u00e9J\3\2\2\2\u00ea\u00ec\t\7\2\2\u00eb\u00ea\3\2\2\2\u00ecL\3\2\2\2"+ - "\u00ed\u00ee\t\b\2\2\u00eeN\3\2\2\2\u00ef\u00f0\4\62\63\2\u00f0P\3\2\2"+ - "\2\u00f1\u00f2\7\13\2\2\u00f2R\3\2\2\2\u00f3\u00f4\n\t\2\2\u00f4T\3\2"+ - "\2\2\u00f5\u00fa\5E#\2\u00f6\u00f9\5E#\2\u00f7\u00f9\5I%\2\u00f8\u00f6"+ - "\3\2\2\2\u00f8\u00f7\3\2\2\2\u00f9\u00fc\3\2\2\2\u00fa\u00f8\3\2\2\2\u00fa"+ - "\u00fb\3\2\2\2\u00fbV\3\2\2\2\u00fc\u00fa\3\2\2\2\u00fd\u0101\7$\2\2\u00fe"+ - "\u0100\5S*\2\u00ff\u00fe\3\2\2\2\u0100\u0103\3\2\2\2\u0101\u00ff\3\2\2"+ - "\2\u0101\u0102\3\2\2\2\u0102\u0104\3\2\2\2\u0103\u0101\3\2\2\2\u0104\u0105"+ - "\7$\2\2\u0105X\3\2\2\2\u0106\u010f\7\62\2\2\u0107\u010b\5G$\2\u0108\u010a"+ - "\5I%\2\u0109\u0108\3\2\2\2\u010a\u010d\3\2\2\2\u010b\u0109\3\2\2\2\u010b"+ - "\u010c\3\2\2\2\u010c\u010f\3\2\2\2\u010d\u010b\3\2\2\2\u010e\u0106\3\2"+ - "\2\2\u010e\u0107\3\2\2\2\u010fZ\3\2\2\2\r\2\u00c6\u00d0\u00de\u00e4\u00eb"+ - "\u00f8\u00fa\u0101\u010b\u010e\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java deleted file mode 100644 index 67e4d16a6c40..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageParser.java +++ /dev/null @@ -1,1323 +0,0 @@ -/* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// Checkstyle: stop -//@formatter:off -package com.oracle.truffle.sl.parser; - -// DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.nodes.SLExpressionNode; -import com.oracle.truffle.sl.nodes.SLRootNode; -import com.oracle.truffle.sl.nodes.SLStatementNode; -import com.oracle.truffle.sl.parser.SLParseError; - -import org.antlr.v4.runtime.atn.*; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.*; -import org.antlr.v4.runtime.misc.*; -import org.antlr.v4.runtime.tree.*; -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; - -@SuppressWarnings("all") -public class SimpleLanguageParser extends Parser { - static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, - T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, - T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, - T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, WS=31, COMMENT=32, - LINE_COMMENT=33, IDENTIFIER=34, STRING_LITERAL=35, NUMERIC_LITERAL=36; - public static final int - RULE_simplelanguage = 0, RULE_function = 1, RULE_block = 2, RULE_statement = 3, - RULE_while_statement = 4, RULE_if_statement = 5, RULE_return_statement = 6, - RULE_expression = 7, RULE_logic_term = 8, RULE_logic_factor = 9, RULE_arithmetic = 10, - RULE_term = 11, RULE_factor = 12, RULE_member_expression = 13; - private static String[] makeRuleNames() { - return new String[] { - "simplelanguage", "function", "block", "statement", "while_statement", - "if_statement", "return_statement", "expression", "logic_term", "logic_factor", - "arithmetic", "term", "factor", "member_expression" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'function'", "'('", "','", "')'", "'{'", "'}'", "'break'", "';'", - "'continue'", "'debugger'", "'while'", "'if'", "'else'", "'return'", - "'||'", "'&&'", "'<'", "'<='", "'>'", "'>='", "'=='", "'!='", "'+'", - "'-'", "'*'", "'/'", "'='", "'.'", "'['", "']'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, "WS", "COMMENT", "LINE_COMMENT", - "IDENTIFIER", "STRING_LITERAL", "NUMERIC_LITERAL" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "SimpleLanguage.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - - private SLNodeFactory factory; - private Source source; - - private static final class BailoutErrorListener extends BaseErrorListener { - private final Source source; - BailoutErrorListener(Source source) { - this.source = source; - } - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { - throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg); - } - } - - public void SemErr(Token token, String message) { - assert token != null; - throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); - } - - private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) { - int col = charPositionInLine + 1; - String location = "-- line " + line + " col " + col + ": "; - int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0); - throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); - } - - public static Map parseSL(SLLanguage language, Source source) { - SimpleLanguageLexer lexer = new SimpleLanguageLexer(CharStreams.fromString(source.getCharacters().toString())); - SimpleLanguageParser parser = new SimpleLanguageParser(new CommonTokenStream(lexer)); - lexer.removeErrorListeners(); - parser.removeErrorListeners(); - BailoutErrorListener listener = new BailoutErrorListener(source); - lexer.addErrorListener(listener); - parser.addErrorListener(listener); - parser.factory = new SLNodeFactory(language, source); - parser.source = source; - parser.simplelanguage(); - return parser.factory.getAllFunctions(); - } - - public SimpleLanguageParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - public static class SimplelanguageContext extends ParserRuleContext { - public List function() { - return getRuleContexts(FunctionContext.class); - } - public FunctionContext function(int i) { - return getRuleContext(FunctionContext.class,i); - } - public TerminalNode EOF() { return getToken(SimpleLanguageParser.EOF, 0); } - public SimplelanguageContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_simplelanguage; } - } - - public final SimplelanguageContext simplelanguage() throws RecognitionException { - SimplelanguageContext _localctx = new SimplelanguageContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_simplelanguage); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(28); - function(); - setState(32); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__0) { - { - { - setState(29); - function(); - } - } - setState(34); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(35); - match(EOF); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class FunctionContext extends ParserRuleContext { - public Token IDENTIFIER; - public Token s; - public BlockContext body; - public List IDENTIFIER() { return getTokens(SimpleLanguageParser.IDENTIFIER); } - public TerminalNode IDENTIFIER(int i) { - return getToken(SimpleLanguageParser.IDENTIFIER, i); - } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public FunctionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_function; } - } - - public final FunctionContext function() throws RecognitionException { - FunctionContext _localctx = new FunctionContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_function); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(37); - match(T__0); - setState(38); - _localctx.IDENTIFIER = match(IDENTIFIER); - setState(39); - _localctx.s = match(T__1); - factory.startFunction(_localctx.IDENTIFIER, _localctx.s); - setState(51); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(41); - _localctx.IDENTIFIER = match(IDENTIFIER); - factory.addFormalParameter(_localctx.IDENTIFIER); - setState(48); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__2) { - { - { - setState(43); - match(T__2); - setState(44); - _localctx.IDENTIFIER = match(IDENTIFIER); - factory.addFormalParameter(_localctx.IDENTIFIER); - } - } - setState(50); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(53); - match(T__3); - setState(54); - _localctx.body = block(false); - factory.finishFunction(_localctx.body.result); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class BlockContext extends ParserRuleContext { - public boolean inLoop; - public SLStatementNode result; - public Token s; - public StatementContext statement; - public Token e; - public List statement() { - return getRuleContexts(StatementContext.class); - } - public StatementContext statement(int i) { - return getRuleContext(StatementContext.class,i); - } - public BlockContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - public BlockContext(ParserRuleContext parent, int invokingState, boolean inLoop) { - super(parent, invokingState); - this.inLoop = inLoop; - } - @Override public int getRuleIndex() { return RULE_block; } - } - - public final BlockContext block(boolean inLoop) throws RecognitionException { - BlockContext _localctx = new BlockContext(_ctx, getState(), inLoop); - enterRule(_localctx, 4, RULE_block); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - factory.startBlock(); - List body = new ArrayList<>(); - setState(58); - _localctx.s = match(T__4); - setState(64); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << T__6) | (1L << T__8) | (1L << T__9) | (1L << T__10) | (1L << T__11) | (1L << T__13) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { - { - { - setState(59); - _localctx.statement = statement(inLoop); - body.add(_localctx.statement.result); - } - } - setState(66); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(67); - _localctx.e = match(T__5); - _localctx.result = factory.finishBlock(body, _localctx.s.getStartIndex(), _localctx.e.getStopIndex() - _localctx.s.getStartIndex() + 1); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class StatementContext extends ParserRuleContext { - public boolean inLoop; - public SLStatementNode result; - public While_statementContext while_statement; - public Token b; - public Token c; - public If_statementContext if_statement; - public Return_statementContext return_statement; - public ExpressionContext expression; - public Token d; - public While_statementContext while_statement() { - return getRuleContext(While_statementContext.class,0); - } - public If_statementContext if_statement() { - return getRuleContext(If_statementContext.class,0); - } - public Return_statementContext return_statement() { - return getRuleContext(Return_statementContext.class,0); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public StatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - public StatementContext(ParserRuleContext parent, int invokingState, boolean inLoop) { - super(parent, invokingState); - this.inLoop = inLoop; - } - @Override public int getRuleIndex() { return RULE_statement; } - } - - public final StatementContext statement(boolean inLoop) throws RecognitionException { - StatementContext _localctx = new StatementContext(_ctx, getState(), inLoop); - enterRule(_localctx, 6, RULE_statement); - try { - enterOuterAlt(_localctx, 1); - { - setState(92); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__10: - { - setState(70); - _localctx.while_statement = while_statement(); - _localctx.result = _localctx.while_statement.result; - } - break; - case T__6: - { - setState(73); - _localctx.b = match(T__6); - if (inLoop) { _localctx.result = factory.createBreak(_localctx.b); } else { SemErr(_localctx.b, "break used outside of loop"); } - setState(75); - match(T__7); - } - break; - case T__8: - { - setState(76); - _localctx.c = match(T__8); - if (inLoop) { _localctx.result = factory.createContinue(_localctx.c); } else { SemErr(_localctx.c, "continue used outside of loop"); } - setState(78); - match(T__7); - } - break; - case T__11: - { - setState(79); - _localctx.if_statement = if_statement(inLoop); - _localctx.result = _localctx.if_statement.result; - } - break; - case T__13: - { - setState(82); - _localctx.return_statement = return_statement(); - _localctx.result = _localctx.return_statement.result; - } - break; - case T__1: - case IDENTIFIER: - case STRING_LITERAL: - case NUMERIC_LITERAL: - { - setState(85); - _localctx.expression = expression(); - setState(86); - match(T__7); - _localctx.result = _localctx.expression.result; - } - break; - case T__9: - { - setState(89); - _localctx.d = match(T__9); - _localctx.result = factory.createDebugger(_localctx.d); - setState(91); - match(T__7); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class While_statementContext extends ParserRuleContext { - public SLStatementNode result; - public Token w; - public ExpressionContext condition; - public BlockContext body; - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public BlockContext block() { - return getRuleContext(BlockContext.class,0); - } - public While_statementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_while_statement; } - } - - public final While_statementContext while_statement() throws RecognitionException { - While_statementContext _localctx = new While_statementContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_while_statement); - try { - enterOuterAlt(_localctx, 1); - { - setState(94); - _localctx.w = match(T__10); - setState(95); - match(T__1); - setState(96); - _localctx.condition = expression(); - setState(97); - match(T__3); - setState(98); - _localctx.body = block(true); - _localctx.result = factory.createWhile(_localctx.w, _localctx.condition.result, _localctx.body.result); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class If_statementContext extends ParserRuleContext { - public boolean inLoop; - public SLStatementNode result; - public Token i; - public ExpressionContext condition; - public BlockContext then; - public BlockContext block; - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public List block() { - return getRuleContexts(BlockContext.class); - } - public BlockContext block(int i) { - return getRuleContext(BlockContext.class,i); - } - public If_statementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - public If_statementContext(ParserRuleContext parent, int invokingState, boolean inLoop) { - super(parent, invokingState); - this.inLoop = inLoop; - } - @Override public int getRuleIndex() { return RULE_if_statement; } - } - - public final If_statementContext if_statement(boolean inLoop) throws RecognitionException { - If_statementContext _localctx = new If_statementContext(_ctx, getState(), inLoop); - enterRule(_localctx, 10, RULE_if_statement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(101); - _localctx.i = match(T__11); - setState(102); - match(T__1); - setState(103); - _localctx.condition = expression(); - setState(104); - match(T__3); - setState(105); - _localctx.then = _localctx.block = block(inLoop); - SLStatementNode elsePart = null; - setState(111); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==T__12) { - { - setState(107); - match(T__12); - setState(108); - _localctx.block = block(inLoop); - elsePart = _localctx.block.result; - } - } - - _localctx.result = factory.createIf(_localctx.i, _localctx.condition.result, _localctx.then.result, elsePart); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Return_statementContext extends ParserRuleContext { - public SLStatementNode result; - public Token r; - public ExpressionContext expression; - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public Return_statementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_return_statement; } - } - - public final Return_statementContext return_statement() throws RecognitionException { - Return_statementContext _localctx = new Return_statementContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_return_statement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(115); - _localctx.r = match(T__13); - SLExpressionNode value = null; - setState(120); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { - { - setState(117); - _localctx.expression = expression(); - value = _localctx.expression.result; - } - } - - _localctx.result = factory.createReturn(_localctx.r, value); - setState(123); - match(T__7); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ExpressionContext extends ParserRuleContext { - public SLExpressionNode result; - public Logic_termContext logic_term; - public Token op; - public List logic_term() { - return getRuleContexts(Logic_termContext.class); - } - public Logic_termContext logic_term(int i) { - return getRuleContext(Logic_termContext.class,i); - } - public ExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expression; } - } - - public final ExpressionContext expression() throws RecognitionException { - ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_expression); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(125); - _localctx.logic_term = logic_term(); - _localctx.result = _localctx.logic_term.result; - setState(133); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,7,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(127); - _localctx.op = match(T__14); - setState(128); - _localctx.logic_term = logic_term(); - _localctx.result = factory.createBinary(_localctx.op, _localctx.result, _localctx.logic_term.result); - } - } - } - setState(135); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,7,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Logic_termContext extends ParserRuleContext { - public SLExpressionNode result; - public Logic_factorContext logic_factor; - public Token op; - public List logic_factor() { - return getRuleContexts(Logic_factorContext.class); - } - public Logic_factorContext logic_factor(int i) { - return getRuleContext(Logic_factorContext.class,i); - } - public Logic_termContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_logic_term; } - } - - public final Logic_termContext logic_term() throws RecognitionException { - Logic_termContext _localctx = new Logic_termContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_logic_term); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(136); - _localctx.logic_factor = logic_factor(); - _localctx.result = _localctx.logic_factor.result; - setState(144); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,8,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(138); - _localctx.op = match(T__15); - setState(139); - _localctx.logic_factor = logic_factor(); - _localctx.result = factory.createBinary(_localctx.op, _localctx.result, _localctx.logic_factor.result); - } - } - } - setState(146); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,8,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Logic_factorContext extends ParserRuleContext { - public SLExpressionNode result; - public ArithmeticContext arithmetic; - public Token op; - public List arithmetic() { - return getRuleContexts(ArithmeticContext.class); - } - public ArithmeticContext arithmetic(int i) { - return getRuleContext(ArithmeticContext.class,i); - } - public Logic_factorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_logic_factor; } - } - - public final Logic_factorContext logic_factor() throws RecognitionException { - Logic_factorContext _localctx = new Logic_factorContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_logic_factor); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(147); - _localctx.arithmetic = arithmetic(); - _localctx.result = _localctx.arithmetic.result; - setState(153); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { - case 1: - { - setState(149); - _localctx.op = _input.LT(1); - _la = _input.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__16) | (1L << T__17) | (1L << T__18) | (1L << T__19) | (1L << T__20) | (1L << T__21))) != 0)) ) { - _localctx.op = _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(150); - _localctx.arithmetic = arithmetic(); - _localctx.result = factory.createBinary(_localctx.op, _localctx.result, _localctx.arithmetic.result); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class ArithmeticContext extends ParserRuleContext { - public SLExpressionNode result; - public TermContext term; - public Token op; - public List term() { - return getRuleContexts(TermContext.class); - } - public TermContext term(int i) { - return getRuleContext(TermContext.class,i); - } - public ArithmeticContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_arithmetic; } - } - - public final ArithmeticContext arithmetic() throws RecognitionException { - ArithmeticContext _localctx = new ArithmeticContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_arithmetic); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(155); - _localctx.term = term(); - _localctx.result = _localctx.term.result; - setState(163); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,10,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(157); - _localctx.op = _input.LT(1); - _la = _input.LA(1); - if ( !(_la==T__22 || _la==T__23) ) { - _localctx.op = _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(158); - _localctx.term = term(); - _localctx.result = factory.createBinary(_localctx.op, _localctx.result, _localctx.term.result); - } - } - } - setState(165); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,10,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class TermContext extends ParserRuleContext { - public SLExpressionNode result; - public FactorContext factor; - public Token op; - public List factor() { - return getRuleContexts(FactorContext.class); - } - public FactorContext factor(int i) { - return getRuleContext(FactorContext.class,i); - } - public TermContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_term; } - } - - public final TermContext term() throws RecognitionException { - TermContext _localctx = new TermContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_term); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(166); - _localctx.factor = factor(); - _localctx.result = _localctx.factor.result; - setState(174); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,11,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(168); - _localctx.op = _input.LT(1); - _la = _input.LA(1); - if ( !(_la==T__24 || _la==T__25) ) { - _localctx.op = _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(169); - _localctx.factor = factor(); - _localctx.result = factory.createBinary(_localctx.op, _localctx.result, _localctx.factor.result); - } - } - } - setState(176); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,11,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class FactorContext extends ParserRuleContext { - public SLExpressionNode result; - public Token IDENTIFIER; - public Member_expressionContext member_expression; - public Token STRING_LITERAL; - public Token NUMERIC_LITERAL; - public Token s; - public ExpressionContext expr; - public Token e; - public TerminalNode IDENTIFIER() { return getToken(SimpleLanguageParser.IDENTIFIER, 0); } - public TerminalNode STRING_LITERAL() { return getToken(SimpleLanguageParser.STRING_LITERAL, 0); } - public TerminalNode NUMERIC_LITERAL() { return getToken(SimpleLanguageParser.NUMERIC_LITERAL, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public Member_expressionContext member_expression() { - return getRuleContext(Member_expressionContext.class,0); - } - public FactorContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_factor; } - } - - public final FactorContext factor() throws RecognitionException { - FactorContext _localctx = new FactorContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_factor); - try { - enterOuterAlt(_localctx, 1); - { - setState(194); - _errHandler.sync(this); - switch (_input.LA(1)) { - case IDENTIFIER: - { - setState(177); - _localctx.IDENTIFIER = match(IDENTIFIER); - SLExpressionNode assignmentName = factory.createStringLiteral(_localctx.IDENTIFIER, false); - setState(183); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,12,_ctx) ) { - case 1: - { - setState(179); - _localctx.member_expression = member_expression(null, null, assignmentName); - _localctx.result = _localctx.member_expression.result; - } - break; - case 2: - { - _localctx.result = factory.createRead(assignmentName); - } - break; - } - } - break; - case STRING_LITERAL: - { - setState(185); - _localctx.STRING_LITERAL = match(STRING_LITERAL); - _localctx.result = factory.createStringLiteral(_localctx.STRING_LITERAL, true); - } - break; - case NUMERIC_LITERAL: - { - setState(187); - _localctx.NUMERIC_LITERAL = match(NUMERIC_LITERAL); - _localctx.result = factory.createNumericLiteral(_localctx.NUMERIC_LITERAL); - } - break; - case T__1: - { - setState(189); - _localctx.s = match(T__1); - setState(190); - _localctx.expr = expression(); - setState(191); - _localctx.e = match(T__3); - _localctx.result = factory.createParenExpression(_localctx.expr.result, _localctx.s.getStartIndex(), _localctx.e.getStopIndex() - _localctx.s.getStartIndex() + 1); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static class Member_expressionContext extends ParserRuleContext { - public SLExpressionNode r; - public SLExpressionNode assignmentReceiver; - public SLExpressionNode assignmentName; - public SLExpressionNode result; - public ExpressionContext expression; - public Token e; - public Token IDENTIFIER; - public Member_expressionContext member_expression; - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode IDENTIFIER() { return getToken(SimpleLanguageParser.IDENTIFIER, 0); } - public Member_expressionContext member_expression() { - return getRuleContext(Member_expressionContext.class,0); - } - public Member_expressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - public Member_expressionContext(ParserRuleContext parent, int invokingState, SLExpressionNode r, SLExpressionNode assignmentReceiver, SLExpressionNode assignmentName) { - super(parent, invokingState); - this.r = r; - this.assignmentReceiver = assignmentReceiver; - this.assignmentName = assignmentName; - } - @Override public int getRuleIndex() { return RULE_member_expression; } - } - - public final Member_expressionContext member_expression(SLExpressionNode r,SLExpressionNode assignmentReceiver,SLExpressionNode assignmentName) throws RecognitionException { - Member_expressionContext _localctx = new Member_expressionContext(_ctx, getState(), r, assignmentReceiver, assignmentName); - enterRule(_localctx, 26, RULE_member_expression); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - SLExpressionNode receiver = r; - SLExpressionNode nestedAssignmentName = null; - setState(228); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__1: - { - setState(197); - match(T__1); - List parameters = new ArrayList<>(); - if (receiver == null) { - receiver = factory.createRead(assignmentName); - } - setState(210); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__1) | (1L << IDENTIFIER) | (1L << STRING_LITERAL) | (1L << NUMERIC_LITERAL))) != 0)) { - { - setState(199); - _localctx.expression = expression(); - parameters.add(_localctx.expression.result); - setState(207); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==T__2) { - { - { - setState(201); - match(T__2); - setState(202); - _localctx.expression = expression(); - parameters.add(_localctx.expression.result); - } - } - setState(209); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(212); - _localctx.e = match(T__3); - _localctx.result = factory.createCall(receiver, parameters, _localctx.e); - } - break; - case T__26: - { - setState(214); - match(T__26); - setState(215); - _localctx.expression = expression(); - if (assignmentName == null) { - SemErr((_localctx.expression!=null?(_localctx.expression.start):null), "invalid assignment target"); - } else if (assignmentReceiver == null) { - _localctx.result = factory.createAssignment(assignmentName, _localctx.expression.result); - } else { - _localctx.result = factory.createWriteProperty(assignmentReceiver, assignmentName, _localctx.expression.result); - } - } - break; - case T__27: - { - setState(218); - match(T__27); - if (receiver == null) { - receiver = factory.createRead(assignmentName); - } - setState(220); - _localctx.IDENTIFIER = match(IDENTIFIER); - nestedAssignmentName = factory.createStringLiteral(_localctx.IDENTIFIER, false); - _localctx.result = factory.createReadProperty(receiver, nestedAssignmentName); - } - break; - case T__28: - { - setState(222); - match(T__28); - if (receiver == null) { - receiver = factory.createRead(assignmentName); - } - setState(224); - _localctx.expression = expression(); - nestedAssignmentName = _localctx.expression.result; - _localctx.result = factory.createReadProperty(receiver, nestedAssignmentName); - setState(226); - match(T__29); - } - break; - default: - throw new NoViableAltException(this); - } - setState(233); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,17,_ctx) ) { - case 1: - { - setState(230); - _localctx.member_expression = member_expression(_localctx.result, receiver, nestedAssignmentName); - _localctx.result = _localctx.member_expression.result; - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3&\u00ee\4\2\t\2\4"+ - "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ - "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\3\2\3\2\7\2!\n\2\f\2\16\2$\13"+ - "\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7\3\61\n\3\f\3\16\3\64"+ - "\13\3\5\3\66\n\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\7\4A\n\4\f\4\16\4"+ - "D\13\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5"+ - "\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5_\n\5\3\6\3\6\3\6\3\6\3\6\3\6"+ - "\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\5\7r\n\7\3\7\3\7\3\b\3\b"+ - "\3\b\3\b\3\b\5\b{\n\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\7\t\u0086\n"+ - "\t\f\t\16\t\u0089\13\t\3\n\3\n\3\n\3\n\3\n\3\n\7\n\u0091\n\n\f\n\16\n"+ - "\u0094\13\n\3\13\3\13\3\13\3\13\3\13\3\13\5\13\u009c\n\13\3\f\3\f\3\f"+ - "\3\f\3\f\3\f\7\f\u00a4\n\f\f\f\16\f\u00a7\13\f\3\r\3\r\3\r\3\r\3\r\3\r"+ - "\7\r\u00af\n\r\f\r\16\r\u00b2\13\r\3\16\3\16\3\16\3\16\3\16\3\16\5\16"+ - "\u00ba\n\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\5\16\u00c5\n"+ - "\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\7\17\u00d0\n\17\f\17"+ - "\16\17\u00d3\13\17\5\17\u00d5\n\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17"+ - "\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\5\17\u00e7\n\17\3\17\3\17"+ - "\3\17\5\17\u00ec\n\17\3\17\2\2\20\2\4\6\b\n\f\16\20\22\24\26\30\32\34"+ - "\2\5\3\2\23\30\3\2\31\32\3\2\33\34\2\u00fa\2\36\3\2\2\2\4\'\3\2\2\2\6"+ - ";\3\2\2\2\b^\3\2\2\2\n`\3\2\2\2\fg\3\2\2\2\16u\3\2\2\2\20\177\3\2\2\2"+ - "\22\u008a\3\2\2\2\24\u0095\3\2\2\2\26\u009d\3\2\2\2\30\u00a8\3\2\2\2\32"+ - "\u00c4\3\2\2\2\34\u00c6\3\2\2\2\36\"\5\4\3\2\37!\5\4\3\2 \37\3\2\2\2!"+ - "$\3\2\2\2\" \3\2\2\2\"#\3\2\2\2#%\3\2\2\2$\"\3\2\2\2%&\7\2\2\3&\3\3\2"+ - "\2\2\'(\7\3\2\2()\7$\2\2)*\7\4\2\2*\65\b\3\1\2+,\7$\2\2,\62\b\3\1\2-."+ - "\7\5\2\2./\7$\2\2/\61\b\3\1\2\60-\3\2\2\2\61\64\3\2\2\2\62\60\3\2\2\2"+ - "\62\63\3\2\2\2\63\66\3\2\2\2\64\62\3\2\2\2\65+\3\2\2\2\65\66\3\2\2\2\66"+ - "\67\3\2\2\2\678\7\6\2\289\5\6\4\29:\b\3\1\2:\5\3\2\2\2;<\b\4\1\2\5\b\5\2>?\b\4\1\2?A\3\2\2\2@=\3\2\2\2AD\3\2\2\2B@\3\2\2\2BC\3\2"+ - "\2\2CE\3\2\2\2DB\3\2\2\2EF\7\b\2\2FG\b\4\1\2G\7\3\2\2\2HI\5\n\6\2IJ\b"+ - "\5\1\2J_\3\2\2\2KL\7\t\2\2LM\b\5\1\2M_\7\n\2\2NO\7\13\2\2OP\b\5\1\2P_"+ - "\7\n\2\2QR\5\f\7\2RS\b\5\1\2S_\3\2\2\2TU\5\16\b\2UV\b\5\1\2V_\3\2\2\2"+ - "WX\5\20\t\2XY\7\n\2\2YZ\b\5\1\2Z_\3\2\2\2[\\\7\f\2\2\\]\b\5\1\2]_\7\n"+ - "\2\2^H\3\2\2\2^K\3\2\2\2^N\3\2\2\2^Q\3\2\2\2^T\3\2\2\2^W\3\2\2\2^[\3\2"+ - "\2\2_\t\3\2\2\2`a\7\r\2\2ab\7\4\2\2bc\5\20\t\2cd\7\6\2\2de\5\6\4\2ef\b"+ - "\6\1\2f\13\3\2\2\2gh\7\16\2\2hi\7\4\2\2ij\5\20\t\2jk\7\6\2\2kl\5\6\4\2"+ - "lq\b\7\1\2mn\7\17\2\2no\5\6\4\2op\b\7\1\2pr\3\2\2\2qm\3\2\2\2qr\3\2\2"+ - "\2rs\3\2\2\2st\b\7\1\2t\r\3\2\2\2uv\7\20\2\2vz\b\b\1\2wx\5\20\t\2xy\b"+ - "\b\1\2y{\3\2\2\2zw\3\2\2\2z{\3\2\2\2{|\3\2\2\2|}\b\b\1\2}~\7\n\2\2~\17"+ - "\3\2\2\2\177\u0080\5\22\n\2\u0080\u0087\b\t\1\2\u0081\u0082\7\21\2\2\u0082"+ - "\u0083\5\22\n\2\u0083\u0084\b\t\1\2\u0084\u0086\3\2\2\2\u0085\u0081\3"+ - "\2\2\2\u0086\u0089\3\2\2\2\u0087\u0085\3\2\2\2\u0087\u0088\3\2\2\2\u0088"+ - "\21\3\2\2\2\u0089\u0087\3\2\2\2\u008a\u008b\5\24\13\2\u008b\u0092\b\n"+ - "\1\2\u008c\u008d\7\22\2\2\u008d\u008e\5\24\13\2\u008e\u008f\b\n\1\2\u008f"+ - "\u0091\3\2\2\2\u0090\u008c\3\2\2\2\u0091\u0094\3\2\2\2\u0092\u0090\3\2"+ - "\2\2\u0092\u0093\3\2\2\2\u0093\23\3\2\2\2\u0094\u0092\3\2\2\2\u0095\u0096"+ - "\5\26\f\2\u0096\u009b\b\13\1\2\u0097\u0098\t\2\2\2\u0098\u0099\5\26\f"+ - "\2\u0099\u009a\b\13\1\2\u009a\u009c\3\2\2\2\u009b\u0097\3\2\2\2\u009b"+ - "\u009c\3\2\2\2\u009c\25\3\2\2\2\u009d\u009e\5\30\r\2\u009e\u00a5\b\f\1"+ - "\2\u009f\u00a0\t\3\2\2\u00a0\u00a1\5\30\r\2\u00a1\u00a2\b\f\1\2\u00a2"+ - "\u00a4\3\2\2\2\u00a3\u009f\3\2\2\2\u00a4\u00a7\3\2\2\2\u00a5\u00a3\3\2"+ - "\2\2\u00a5\u00a6\3\2\2\2\u00a6\27\3\2\2\2\u00a7\u00a5\3\2\2\2\u00a8\u00a9"+ - "\5\32\16\2\u00a9\u00b0\b\r\1\2\u00aa\u00ab\t\4\2\2\u00ab\u00ac\5\32\16"+ - "\2\u00ac\u00ad\b\r\1\2\u00ad\u00af\3\2\2\2\u00ae\u00aa\3\2\2\2\u00af\u00b2"+ - "\3\2\2\2\u00b0\u00ae\3\2\2\2\u00b0\u00b1\3\2\2\2\u00b1\31\3\2\2\2\u00b2"+ - "\u00b0\3\2\2\2\u00b3\u00b4\7$\2\2\u00b4\u00b9\b\16\1\2\u00b5\u00b6\5\34"+ - "\17\2\u00b6\u00b7\b\16\1\2\u00b7\u00ba\3\2\2\2\u00b8\u00ba\b\16\1\2\u00b9"+ - "\u00b5\3\2\2\2\u00b9\u00b8\3\2\2\2\u00ba\u00c5\3\2\2\2\u00bb\u00bc\7%"+ - "\2\2\u00bc\u00c5\b\16\1\2\u00bd\u00be\7&\2\2\u00be\u00c5\b\16\1\2\u00bf"+ - "\u00c0\7\4\2\2\u00c0\u00c1\5\20\t\2\u00c1\u00c2\7\6\2\2\u00c2\u00c3\b"+ - "\16\1\2\u00c3\u00c5\3\2\2\2\u00c4\u00b3\3\2\2\2\u00c4\u00bb\3\2\2\2\u00c4"+ - "\u00bd\3\2\2\2\u00c4\u00bf\3\2\2\2\u00c5\33\3\2\2\2\u00c6\u00e6\b\17\1"+ - "\2\u00c7\u00c8\7\4\2\2\u00c8\u00d4\b\17\1\2\u00c9\u00ca\5\20\t\2\u00ca"+ - "\u00d1\b\17\1\2\u00cb\u00cc\7\5\2\2\u00cc\u00cd\5\20\t\2\u00cd\u00ce\b"+ - "\17\1\2\u00ce\u00d0\3\2\2\2\u00cf\u00cb\3\2\2\2\u00d0\u00d3\3\2\2\2\u00d1"+ - "\u00cf\3\2\2\2\u00d1\u00d2\3\2\2\2\u00d2\u00d5\3\2\2\2\u00d3\u00d1\3\2"+ - "\2\2\u00d4\u00c9\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6"+ - "\u00d7\7\6\2\2\u00d7\u00e7\b\17\1\2\u00d8\u00d9\7\35\2\2\u00d9\u00da\5"+ - "\20\t\2\u00da\u00db\b\17\1\2\u00db\u00e7\3\2\2\2\u00dc\u00dd\7\36\2\2"+ - "\u00dd\u00de\b\17\1\2\u00de\u00df\7$\2\2\u00df\u00e7\b\17\1\2\u00e0\u00e1"+ - "\7\37\2\2\u00e1\u00e2\b\17\1\2\u00e2\u00e3\5\20\t\2\u00e3\u00e4\b\17\1"+ - "\2\u00e4\u00e5\7 \2\2\u00e5\u00e7\3\2\2\2\u00e6\u00c7\3\2\2\2\u00e6\u00d8"+ - "\3\2\2\2\u00e6\u00dc\3\2\2\2\u00e6\u00e0\3\2\2\2\u00e7\u00eb\3\2\2\2\u00e8"+ - "\u00e9\5\34\17\2\u00e9\u00ea\b\17\1\2\u00ea\u00ec\3\2\2\2\u00eb\u00e8"+ - "\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\35\3\2\2\2\24\"\62\65B^qz\u0087\u0092"+ - "\u009b\u00a5\u00b0\u00b9\u00c4\u00d1\u00d4\u00e6\u00eb"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java index 7e2e1de7ddd4..9cf751f9c4d5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java @@ -14,21 +14,22 @@ import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.parser.SLParseError; import com.oracle.truffle.sl.runtime.SLStrings; public abstract class SLBaseVisitor extends SimpleLanguageOperationsBaseVisitor { - protected static Map parseSLImpl(Source source, SLBaseVisitor visitor) { - SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getCharacters().toString())); + protected static Map parseSLImpl(SLSource source, SLBaseVisitor visitor) { + SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getSource().getCharacters().toString())); SimpleLanguageOperationsParser parser = new SimpleLanguageOperationsParser(new CommonTokenStream(lexer)); lexer.removeErrorListeners(); parser.removeErrorListeners(); - BailoutErrorListener listener = new BailoutErrorListener(source); + BailoutErrorListener listener = new BailoutErrorListener(source.getSource()); lexer.addErrorListener(listener); parser.addErrorListener(listener); parser.simplelanguage().accept(visitor); + + source.setFunctions(visitor.functions); return visitor.functions; } @@ -66,19 +67,19 @@ public Integer create() { } protected final SLLanguage language; - protected final Source source; + protected final SLSource source; protected final TruffleString sourceString; protected final Map functions = new HashMap<>(); - protected SLBaseVisitor(SLLanguage language, Source source) { + protected SLBaseVisitor(SLLanguage language, SLSource source) { this.language = language; this.source = source; - sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); + sourceString = SLStrings.fromJavaString(source.getSource().getCharacters().toString()); } protected void SemErr(Token token, String message) { assert token != null; - throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); + throwParseError(source.getSource(), token.getLine(), token.getCharPositionInLine(), token, message); } private static final class BailoutErrorListener extends BaseErrorListener { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java index 699d01a9a4bd..ae09148d2412 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java @@ -13,7 +13,6 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -77,7 +76,7 @@ public class SLNodeVisitor extends SLBaseVisitor { - public static Map parseSL(SLLanguage language, Source source) { + public static Map parseSL(SLLanguage language, SLSource source) { return parseSLImpl(source, new SLNodeVisitor(language, source)); } @@ -88,7 +87,7 @@ public static Map parseSL(SLLanguage language, So private SLExpressionVisitor EXPRESSION_VISITOR = new SLExpressionVisitor(); private int loopDepth = 0; - protected SLNodeVisitor(SLLanguage language, Source source) { + protected SLNodeVisitor(SLLanguage language, SLSource source) { super(language, source); } @@ -121,7 +120,7 @@ public Void visitFunction(FunctionContext ctx) { scope = scope.parent; methodNodes.add(bodyNode); final int bodyEndPos = bodyNode.getSourceEndIndex(); - final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); + final SourceSection functionSrc = source.getSource().createSection(functionStartPos, bodyEndPos - functionStartPos); final SLStatementNode methodBlock = new SLBlockNode(methodNodes.toArray(new SLStatementNode[methodNodes.size()])); methodBlock.setSourceSection(functionStartPos, bodyEndPos - functionStartPos); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java index 65752e897a6e..93030677ff3b 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java @@ -13,7 +13,6 @@ import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; @@ -46,11 +45,16 @@ public class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = false; - public static Map parseSL(SLLanguage language, Source source, SLOperationsBuilder builder) { + public static Map parseSL(SLLanguage language, SLSource source, SLOperationsBuilder builder) { return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); } - private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder) { + public static Map parseSL(SLLanguage language, SLSource source) { + SLOperationsBuilder.parse(language, source); + return source.getFunctions(); + } + + private SLOperationsVisitor(SLLanguage language, SLSource source, SLOperationsBuilder builder) { super(language, source); this.b = builder; } @@ -117,7 +121,7 @@ public Void visitFunction(FunctionContext ctx) { assert scope == null; TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); - b.beginSource(source); + b.beginSource(source.getSource()); b.beginInstrumentation(StandardTags.RootTag.class); scope = new LexicalScope(null); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java similarity index 98% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java index 693cd4b981ba..ba696960e1b3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java @@ -39,7 +39,7 @@ * SOFTWARE. */ -package com.oracle.truffle.sl.parser; +package com.oracle.truffle.sl.parser.operations; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.ExceptionType; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java new file mode 100644 index 000000000000..01259a5e0041 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java @@ -0,0 +1,30 @@ +package com.oracle.truffle.sl.parser.operations; + +import java.util.Map; +import java.util.Objects; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; + +public class SLSource { + private final Source source; + private Map functions; + + public SLSource(Source source) { + Objects.requireNonNull(source); + this.source = source; + } + + public Map getFunctions() { + return functions; + } + + public void setFunctions(Map functions) { + this.functions = functions; + } + + public Source getSource() { + return source; + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java index 95ca9d8ea8af..904e52c623b1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java @@ -53,7 +53,9 @@ import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.parser.SimpleLanguageParser; +import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; +import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; +import com.oracle.truffle.sl.parser.operations.SLSource; /** * Manages the mapping from function names to {@link SLFunction function objects}. @@ -115,7 +117,11 @@ public void register(Map newFunctions) { } public void register(Source newFunctions) { - register(SimpleLanguageParser.parseSL(language, newFunctions)); + if (language.isUseOperations()) { + register(SLOperationsVisitor.parseSL(language, new SLSource(newFunctions))); + } else { + register(SLNodeVisitor.parseSL(language, new SLSource(newFunctions))); + } } public SLFunction getFunction(TruffleString name) { From 1226234605b86e15af8235fd9606dc03fc5e301d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 10:42:12 +0200 Subject: [PATCH 066/312] [wip] rename parser.operations -> parser --- .../sl/operations/SLOperationsBuilder.java | 2 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 4 +- .../truffle/sl/operations/SLOperations.java | 4 +- .../{operations => }/SLBaseVisitor.java | 2 +- .../{operations => }/SLNodeVisitor.java | 50 +++++++++---------- .../{operations => }/SLOperationsVisitor.java | 44 ++++++++-------- .../parser/{operations => }/SLParseError.java | 2 +- .../sl/parser/{operations => }/SLSource.java | 2 +- .../SimpleLanguageOperations.g4 | 0 .../SimpleLanguageOperationsBaseVisitor.java | 2 +- .../SimpleLanguageOperationsLexer.java | 2 +- .../SimpleLanguageOperationsParser.java | 2 +- .../SimpleLanguageOperationsVisitor.java | 2 +- .../sl/runtime/SLFunctionRegistry.java | 6 +-- 14 files changed, 62 insertions(+), 62 deletions(-) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SLBaseVisitor.java (98%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SLNodeVisitor.java (90%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SLOperationsVisitor.java (90%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SLParseError.java (98%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SLSource.java (93%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SimpleLanguageOperations.g4 (100%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SimpleLanguageOperationsBaseVisitor.java (99%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SimpleLanguageOperationsLexer.java (99%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SimpleLanguageOperationsParser.java (99%) rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/{operations => }/SimpleLanguageOperationsVisitor.java (99%) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 98a33c8e3a46..feccd31f710d 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -65,7 +65,7 @@ import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.operations.SLOperations.SLEvalRootOperation; import com.oracle.truffle.sl.operations.SLOperations.SLInvokeOperation; -import com.oracle.truffle.sl.parser.operations.SLSource; +import com.oracle.truffle.sl.parser.SLSource; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 173f03141c89..26b31baaea02 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -111,8 +111,8 @@ import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; import com.oracle.truffle.sl.operations.SLOperationsBuilder; -import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; -import com.oracle.truffle.sl.parser.operations.SLSource; +import com.oracle.truffle.sl.parser.SLNodeVisitor; +import com.oracle.truffle.sl.parser.SLSource; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 5b5133e3fe55..f73395fcd6cd 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -39,8 +39,8 @@ import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; -import com.oracle.truffle.sl.parser.operations.SLSource; +import com.oracle.truffle.sl.parser.SLOperationsVisitor; +import com.oracle.truffle.sl.parser.SLSource; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java similarity index 98% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index 9cf751f9c4d5..47580c0fe0df 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -1,4 +1,4 @@ -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; import java.util.HashMap; import java.util.Map; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java similarity index 90% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index ae09148d2412..20d4317697ff 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -1,4 +1,4 @@ -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; import java.math.BigInteger; import java.util.ArrayList; @@ -49,30 +49,30 @@ import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNodeGen; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNodeGen; import com.oracle.truffle.sl.nodes.util.SLUnboxNodeGen; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ArithmeticContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.BlockContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Break_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Continue_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Debugger_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ExpressionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Expression_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.FunctionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.If_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_factorContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_termContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberAssignContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberCallContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberFieldContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberIndexContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Member_expressionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NameAccessContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NumericLiteralContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ParenExpressionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Return_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StatementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StringLiteralContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.TermContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.While_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ArithmeticContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.BlockContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Break_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Continue_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Debugger_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ExpressionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Expression_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.FunctionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.If_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Logic_factorContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Logic_termContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberAssignContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberCallContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberFieldContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberIndexContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Member_expressionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NameAccessContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NumericLiteralContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ParenExpressionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Return_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.StatementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.StringLiteralContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.TermContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.While_statementContext; public class SLNodeVisitor extends SLBaseVisitor { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java similarity index 90% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 93030677ff3b..652d15513f7d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -1,4 +1,4 @@ -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; import java.math.BigInteger; import java.util.HashMap; @@ -17,27 +17,27 @@ import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.operations.SLOperationsBuilder; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ArithmeticContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.BlockContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Break_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Continue_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Debugger_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.ExpressionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.FunctionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.If_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_factorContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Logic_termContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberAssignContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberCallContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberFieldContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.MemberIndexContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Member_expressionContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NameAccessContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.NumericLiteralContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.Return_statementContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.StringLiteralContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.TermContext; -import com.oracle.truffle.sl.parser.operations.SimpleLanguageOperationsParser.While_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ArithmeticContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.BlockContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Break_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Continue_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Debugger_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ExpressionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.FunctionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.If_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Logic_factorContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Logic_termContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberAssignContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberCallContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberFieldContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberIndexContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Member_expressionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NameAccessContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NumericLiteralContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Return_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.StringLiteralContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.TermContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.While_statementContext; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLNull; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java similarity index 98% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java index ba696960e1b3..693cd4b981ba 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLParseError.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLParseError.java @@ -39,7 +39,7 @@ * SOFTWARE. */ -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.ExceptionType; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java similarity index 93% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java index 01259a5e0041..8288f8f4e555 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SLSource.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java @@ -1,4 +1,4 @@ -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; import java.util.Map; import java.util.Objects; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperations.g4 similarity index 100% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperations.g4 diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java similarity index 99% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java index f41227344b46..77a03c4d3613 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java @@ -1,5 +1,5 @@ // Generated from /home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 by ANTLR 4.9.2 -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; // DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsLexer.java similarity index 99% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsLexer.java index 11c56a335b71..8d693d037cd3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsLexer.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsLexer.java @@ -40,7 +40,7 @@ */ // Checkstyle: stop //@formatter:off -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; // DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsParser.java similarity index 99% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsParser.java index 072a9c7e79e6..a4d5bdecaae3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsParser.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsParser.java @@ -40,7 +40,7 @@ */ // Checkstyle: stop //@formatter:off -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; // DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java similarity index 99% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java index 663c49d792ad..7b8d3543ea25 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java @@ -1,5 +1,5 @@ // Generated from /home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/operations/SimpleLanguageOperations.g4 by ANTLR 4.9.2 -package com.oracle.truffle.sl.parser.operations; +package com.oracle.truffle.sl.parser; // DO NOT MODIFY - generated from SimpleLanguage.g4 using "mx create-sl-parser" diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java index 904e52c623b1..6e492c83dfe8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java @@ -53,9 +53,9 @@ import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.parser.operations.SLNodeVisitor; -import com.oracle.truffle.sl.parser.operations.SLOperationsVisitor; -import com.oracle.truffle.sl.parser.operations.SLSource; +import com.oracle.truffle.sl.parser.SLNodeVisitor; +import com.oracle.truffle.sl.parser.SLOperationsVisitor; +import com.oracle.truffle.sl.parser.SLSource; /** * Manages the mapping from function names to {@link SLFunction function objects}. From 022ac7b533818bbf271e2f52756c925efa0f12c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 10:45:57 +0200 Subject: [PATCH 067/312] [wip] set function on first parse only --- .../src/com/oracle/truffle/sl/parser/SLBaseVisitor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index 47580c0fe0df..bfa1db4fd59f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -28,8 +28,10 @@ protected static Map parseSLImpl(SLSource source, parser.addErrorListener(listener); parser.simplelanguage().accept(visitor); - - source.setFunctions(visitor.functions); + + if (source.getFunctions() == null) { + source.setFunctions(visitor.functions); + } return visitor.functions; } From 0a628999e650157b5b1507732443a94c2a76d8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 2 May 2022 14:53:06 +0200 Subject: [PATCH 068/312] [wip] boxinjero --- truffle/mx.truffle/mx_truffle.py | 3 +- .../sl/operations/SLOperationsBuilder.java | 725 ++++++++++-------- .../truffle/api/operation/OperationsNode.java | 32 +- .../dsl/processor/generator/BitSet.java | 2 + .../generator/FlatNodeGenFactory.java | 11 +- .../operations/OperationGeneratorUtils.java | 11 +- .../OperationsBytecodeCodeGenerator.java | 7 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 81 +- .../operations/OperationsCodeGenerator.java | 121 ++- .../instructions/BranchInstruction.java | 5 +- .../ConditionalBranchInstruction.java | 5 +- .../instructions/CustomInstruction.java | 33 +- .../instructions/DiscardInstruction.java | 5 +- .../operations/instructions/FrameKind.java | 6 +- .../operations/instructions/Instruction.java | 21 +- .../InstrumentationEnterInstruction.java | 5 +- .../InstrumentationExitInstruction.java | 5 +- .../InstrumentationLeaveInstruction.java | 5 +- .../instructions/LoadArgumentInstruction.java | 36 +- .../instructions/LoadConstantInstruction.java | 42 +- .../instructions/LoadLocalInstruction.java | 38 +- .../instructions/QuickenedInstruction.java | 15 +- .../instructions/ReturnInstruction.java | 5 +- .../instructions/StoreLocalInstruction.java | 5 +- .../instructions/SuperInstruction.java | 5 +- 25 files changed, 686 insertions(+), 543 deletions(-) diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 9f57e221bf25..8034554e6080 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -656,8 +656,7 @@ def create_dsl_parser(args=None, out=None): def create_sl_parser(args=None, out=None): """create the SimpleLanguage parser using antlr""" - create_parser("com.oracle.truffle.sl", "com.oracle.truffle.sl.parser", "SimpleLanguage", COPYRIGHT_HEADER_UPL, args, out) - create_parser("com.oracle.truffle.sl", "com.oracle.truffle.sl.parser.operations", "SimpleLanguageOperations", COPYRIGHT_HEADER_UPL, ['-visitor'] + args, out) + create_parser("com.oracle.truffle.sl", "com.oracle.truffle.sl.parser", "SimpleLanguageOperations", COPYRIGHT_HEADER_UPL, ['-visitor'] + args, out) def create_parser(grammar_project, grammar_package, grammar_name, copyright_template, args=None, out=None, postprocess=None): """create the DSL expression parser using antlr""" diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index feccd31f710d..242dcc36c29b 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -16,7 +16,6 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.LibraryFactory; -import com.oracle.truffle.api.memory.MemoryFence; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; @@ -70,6 +69,7 @@ import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; +import java.lang.invoke.VarHandle; import java.util.ArrayList; import java.util.Map; import java.util.concurrent.locks.Lock; @@ -274,6 +274,21 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 41; private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; + private static final short[][] BOXING_DESCRIPTORS = { + // OBJECT + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + // BYTE + null, + // BOOLEAN + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + // INT + null, + // FLOAT + null, + // LONG + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + // DOUBLE + null}; private final SLLanguage language; private final SLSource parseContext; @@ -2073,16 +2088,22 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b10) { + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); } + int type0; + int type1; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); try { lock.unlock(); hasLock = false; @@ -2120,8 +2141,13 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 2] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); @@ -2134,12 +2160,17 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); @@ -2152,8 +2183,13 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); bc[$bci + 4 + 2] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -2290,13 +2326,17 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); + int type0; + int type1; if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); try { lock.unlock(); hasLock = false; @@ -2333,8 +2373,12 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); @@ -2348,8 +2392,12 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -2593,13 +2641,17 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); @@ -2622,8 +2674,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 | (sLBigNumberCast1 << 4) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); @@ -2642,13 +2698,17 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc boolean $child1Value_ = (boolean) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_BOOLEAN); + type0 = FRAME_TYPE_BOOLEAN; + type1 = FRAME_TYPE_BOOLEAN; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); @@ -2666,8 +2726,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc String $child1Value_ = (String) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); bc[$bci + 4 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doString($child0Value_, $child1Value_); @@ -2686,8 +2750,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0] = super.insert((EqualNode.create())); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); bc[$bci + 4 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); @@ -2705,8 +2773,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLNull $child1Value_ = SLTypes.asSLNull($child1Value); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); bc[$bci + 4 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); @@ -2722,8 +2794,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); bc[$bci + 4 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); @@ -2753,12 +2829,16 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc s7_ = super.insert(new SLEqualOperation_Generic0Data(((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = s7_; bc[$bci + 4 + 0] = (byte) (state_0); bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); } } if (s7_ != null) { @@ -2787,8 +2867,12 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = (byte) (state_0); bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); @@ -2910,16 +2994,22 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10) { + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); } + int type0; + int type1; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -2941,8 +3031,13 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -2961,8 +3056,13 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -3075,16 +3175,22 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10) { + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); } + int type0; + int type1; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -3106,8 +3212,13 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -3126,8 +3237,13 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -3209,11 +3325,13 @@ private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, in if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + type0 = FRAME_TYPE_BOOLEAN; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; boolean value = SLLogicalNotNode.doBoolean($child0Value_); @@ -3230,7 +3348,9 @@ private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, in fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); @@ -3367,13 +3487,17 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); + int type0; + int type1; if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); try { lock.unlock(); hasLock = false; @@ -3410,8 +3534,12 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); @@ -3425,8 +3553,12 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -3599,11 +3731,16 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); } } } @@ -3634,8 +3771,13 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); @@ -3674,14 +3816,20 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, bci__1 = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000) { + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); } - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); } } if (s2_ != null) { @@ -3704,8 +3852,13 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); @@ -3739,11 +3892,16 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, bci__2 = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); } } } @@ -3773,8 +3931,13 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); @@ -3918,13 +4081,17 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + int type0; + int type1; if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); - doSetResultBoxed(false, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); try { lock.unlock(); hasLock = false; @@ -3961,8 +4128,12 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); @@ -3976,8 +4147,12 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); @@ -4136,12 +4311,19 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); } } } @@ -4169,9 +4351,16 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__)); @@ -4203,15 +4392,23 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000) { + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); } - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); } } if (s2_ != null) { @@ -4229,9 +4426,16 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); @@ -4263,12 +4467,19 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); } } if (s4_ != null) { @@ -4296,9 +4507,16 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 3] & 0xff, FRAME_TYPE_OBJECT); - doSetResultBoxed(true, bc, $bci, bc[$bci + 4] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); @@ -4472,7 +4690,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); @@ -4482,7 +4703,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc TruffleString $child0Value_ = (TruffleString) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); bc[$bci + 3 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); @@ -4492,14 +4716,18 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b1000 && (state_1 & 0b11) == 0) { + if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); } + int type0; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + type0 = FRAME_TYPE_BOOLEAN; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; boolean value = SLUnboxNode.fromBoolean($child0Value_); @@ -4514,14 +4742,18 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc long $child0Value_ = (long) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b10000 && (state_1 & 0b11) == 0) { + if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); } + int type0; if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_LONG); + type0 = FRAME_TYPE_LONG; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; long value = SLUnboxNode.fromLong($child0Value_); @@ -4539,7 +4771,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); bc[$bci + 3 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); @@ -4550,7 +4785,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); bc[$bci + 3 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); @@ -4560,7 +4798,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLNull $child0Value_ = SLTypes.asSLNull($child0Value); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); bc[$bci + 3 + 1] = (byte) (state_1); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); @@ -4583,11 +4824,14 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc if (count7_ < (SLUnboxNode.LIMIT)) { s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); } } if (s7_ != null) { @@ -4609,7 +4853,10 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); @@ -4656,10 +4903,14 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10) { + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); } - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); @@ -4748,14 +4999,18 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10) { + if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); } + int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - doSetResultBoxed(false, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_BOOLEAN); + type0 = FRAME_TYPE_BOOLEAN; } else { - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + type0 = FRAME_TYPE_OBJECT; } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; boolean value = SLToBooleanNode.doBoolean($child0Value_); @@ -4772,7 +5027,10 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); @@ -4825,7 +5083,9 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int Map $child0Value_ = (Map) $child0Value; execute_node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value_, execute_node__)); @@ -4833,7 +5093,9 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int } } bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); - doSetResultBoxed(true, bc, $bci, bc[$bci + 2] & 0xff, FRAME_TYPE_OBJECT); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value)); @@ -4914,11 +5176,13 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - MemoryFence.storeStore(); + VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10) { + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); } } } @@ -4936,6 +5200,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); @@ -4947,6 +5212,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); @@ -4967,11 +5233,9 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int while (cur != null) { if (cur == s0_) { if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = cur.next_; - this.adoptChildren(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); } else { - prev.next_ = cur.next_; - prev.adoptChildren(); + prev.next_ = prev.insertAccessor(cur.next_); } break; } @@ -4995,7 +5259,6 @@ private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, $child0Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); return; } @@ -5019,7 +5282,6 @@ private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, in } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } @@ -5030,7 +5292,6 @@ private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, in $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } @@ -5053,7 +5314,6 @@ private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, in } finally { lock.unlock(); } - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } @@ -5081,7 +5341,6 @@ private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $fram } } CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } @@ -5095,7 +5354,6 @@ private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $b $child0Value_ = (boolean) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); return; } @@ -5118,7 +5376,6 @@ private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $b $child0Value_ = (boolean) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); return; } @@ -5142,7 +5399,6 @@ private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } @@ -5153,7 +5409,6 @@ private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } @@ -5178,7 +5433,6 @@ private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { CompilerDirectives.transferToInterpreterAndInvalidate(); SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); } if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { @@ -5188,7 +5442,6 @@ private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci } } CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); } @@ -5201,11 +5454,9 @@ private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int while (cur != null) { if (cur == s0_) { if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = cur.next_; - this.adoptChildren(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); } else { - prev.next_ = cur.next_; - prev.adoptChildren(); + prev.next_ = prev.insertAccessor(cur.next_); } break; } @@ -5234,7 +5485,6 @@ private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, } } CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } @@ -5261,7 +5511,6 @@ private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $fr } } CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); return; } @@ -5276,7 +5525,6 @@ private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $ } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } @@ -5287,7 +5535,6 @@ private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $ $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } @@ -5696,9 +5943,7 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : { - if (true) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); - } + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; break; } @@ -6914,145 +7159,9 @@ private static boolean SLLessThanOperation_q_LessThan0_fallbackGuard__(VirtualFr return true; } - private static void doSetResultBoxed(boolean boxed, byte[] bc, int startBci, int bciOffset, int targetType) { - if (bciOffset == 0) { - return; - } - CompilerDirectives.transferToInterpreter(); - int bci = startBci - bciOffset; - switch (LE_BYTES.getShort(bc, bci)) { - case INSTR_LOAD_CONSTANT_OBJECT : - { - if (!boxed) { - if (targetType == FRAME_TYPE_BOOLEAN) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_BOOLEAN); - } else if (targetType == FRAME_TYPE_LONG) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_LONG); - } - } - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - case INSTR_LOAD_CONSTANT_LONG : - { - if (boxed) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); - } - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - if (!boxed) { - if (targetType == FRAME_TYPE_BOOLEAN) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_BOOLEAN); - } else if (targetType == FRAME_TYPE_LONG) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_LONG); - } - } - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - case INSTR_LOAD_ARGUMENT_LONG : - { - if (boxed) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_OBJECT); - } - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - if (!boxed) { - if (targetType == FRAME_TYPE_BOOLEAN) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_BOOLEAN); - } else if (targetType == FRAME_TYPE_LONG) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_LONG); - } - } - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - case INSTR_LOAD_LOCAL_LONG : - { - if (boxed) { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); - } - break; - } - case INSTR_C_SLADD_OPERATION : - case INSTR_C_SLEQUAL_OPERATION : - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - { - int $bci = bci; - boolean unboxed = !boxed; - if (unboxed) { - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); - } else { - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); - } - break; - } - case INSTR_C_SLDIV_OPERATION : - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : - case INSTR_C_SLLESS_THAN_OPERATION : - case INSTR_C_SLMUL_OPERATION : - case INSTR_C_SLREAD_PROPERTY_OPERATION : - case INSTR_C_SLSUB_OPERATION : - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - int $bci = bci; - boolean unboxed = !boxed; - if (unboxed) { - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); - } else { - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); - } - break; - } - case INSTR_C_SLLOGICAL_NOT_OPERATION : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - case INSTR_C_SLTO_BOOLEAN_OPERATION : - case INSTR_C_SLEVAL_ROOT_OPERATION : - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - int $bci = bci; - boolean unboxed = !boxed; - if (unboxed) { - bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); - } else { - bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); - } - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : - case INSTR_C_SLINVOKE_OPERATION : - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - int $bci = bci; - boolean unboxed = !boxed; - if (unboxed) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); - } else { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); - } - break; - } - case INSTR_C_SLUNBOX_OPERATION : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : - { - int $bci = bci; - boolean unboxed = !boxed; - if (unboxed) { - bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] | 0b1 /* add-state_0 RESULT-UNBOXED */); - } else { - bc[$bci + 3 + 0] = (byte) (bc[$bci + 3 + 0] & 0xfffffffe /* remove-state_0 RESULT-UNBOXED */); - } - break; - } + private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { + if (bciOffset != 0) { + setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 389d0e5d8a4f..da06768efba9 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -16,16 +16,19 @@ public abstract class OperationsNode extends Node implements InstrumentableNode, BytecodeOSRNode { + // The order of these must be the same as FrameKind in processor public static final int FRAME_TYPE_OBJECT = 0; - public static final int FRAME_TYPE_LONG = 1; - public static final int FRAME_TYPE_INT = 2; - public static final int FRAME_TYPE_DOUBLE = 3; + public static final int FRAME_TYPE_BYTE = 1; + public static final int FRAME_TYPE_BOOLEAN = 2; + public static final int FRAME_TYPE_INT = 3; public static final int FRAME_TYPE_FLOAT = 4; - public static final int FRAME_TYPE_BOOLEAN = 5; - public static final int FRAME_TYPE_BYTE = 6; + public static final int FRAME_TYPE_LONG = 5; + public static final int FRAME_TYPE_DOUBLE = 6; protected static final int VALUES_OFFSET = 0; + private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); + private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals) { FrameDescriptor.Builder b = FrameDescriptor.newBuilder(VALUES_OFFSET + maxStack + numLocals); @@ -173,4 +176,23 @@ public void setOSRMetadata(Object osrMetadata) { public Object getOSRMetadata() { return osrMetadata; } + + protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, short[] descriptor) { + int op = LE_BYTES.getShort(bc, bci) & 0xffff; + short todo = descriptor[op]; + + if (todo > 0) { + // quicken + LE_BYTES.putShort(bc, bci, todo); + } else { + // set bit + int offset = (todo >> 8) & 0x7f; + int bit = todo & 0xff; + if (targetType == FRAME_TYPE_OBJECT) { + bc[bci + offset] &= ~bit; + } else { + bc[bci + offset] |= bit; + } + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index e185f206abea..b6fa4be7e3ea 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -44,6 +44,7 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -220,6 +221,7 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.tree(createMaskedReference(frameState, maskedElements)); builder.string(" == ").string(formatMask(createMask(selectedElements))); + builder.string("/* ", label("is-exact"), toString(selectedElements, "&&"), " */"); return builder.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 6dee14a49c17..0b93f8bffdf0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -4724,15 +4724,18 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.end().startBlock(); builder.startIf().string("cur == ").string(specializationLocalName).end().startBlock(); builder.startIf().string("prev == null").end().startBlock(); - builder.startStatement().tree(fieldRefWrite).string(" = cur.next_").end(); + builder.startStatement().tree(fieldRefWrite).string(" = "); if (specializedIsNode) { - builder.statement("this.adoptChildren()"); + builder.string("this.insert"); } + builder.string("(cur.next_)").end(); builder.end().startElseBlock(); - builder.statement("prev.next_ = cur.next_"); + builder.startStatement().string("prev.next_ = "); if (specializedIsNode) { - builder.statement("prev.adoptChildren()"); + builder.string("prev.insertAccessor"); } + builder.string("(cur.next_)").end(); + builder.end(); builder.statement("break"); builder.end(); // if block diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 3fe9b1ab0143..5a2b6d3a6b21 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -182,16 +182,23 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar } public static CodeTree callSetResultBoxed(String bciOffset, FrameKind kind) { + return callSetResultBoxed(bciOffset, toFrameTypeConstant(kind)); + } + + public static CodeTree callSetResultBoxed(String bciOffset, CodeTree kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); - b.string(kind == FrameKind.OBJECT ? "true" : "false"); b.string("bc"); b.string("$bci"); b.string(bciOffset); - b.string("FRAME_TYPE_" + kind.getFrameName().toUpperCase()); + b.tree(kind); b.end(2); return b.build(); } + + public static CodeTree toFrameTypeConstant(FrameKind kind) { + return CodeTreeBuilder.singleString("FRAME_TYPE_" + kind.getFrameName().toUpperCase()); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 541167020f81..ded669a144e0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -55,10 +55,8 @@ public class OperationsBytecodeCodeGenerator { private final String simpleName; private final OperationsData m; private final boolean withInstrumentation; - private final OperationsCodeGenerator parent; - public OperationsBytecodeCodeGenerator(OperationsCodeGenerator parent, CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { - this.parent = parent; + public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { this.typBuilderImpl = typBuilderImpl; this.simpleName = simpleName; this.m = m; @@ -165,6 +163,7 @@ public CodeTypeElement createBuilderBytecodeNode() { if (resultList.size() != 1) { throw new AssertionError("Node generator did not return exactly one class"); } + plugs.finishUp(); CodeTypeElement result = resultList.get(0); CodeExecutableElement uncExec = null; @@ -267,8 +266,6 @@ public CodeTypeElement createBuilderBytecodeNode() { } - parent.createSetBoxedForInstructions(typBuilderImpl); - ExecutionVariables vars = new ExecutionVariables(); // vars.bytecodeNodeType = builderBytecodeNodeType; vars.bc = fldBc; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index f39f2baded14..fe9dff847e30 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -1,5 +1,6 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.function.Consumer; @@ -17,6 +18,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.StateBitSet; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -170,8 +172,7 @@ public TypeMirror getBitSetType(TypeMirror defaultType) { return new CodeTypeMirror(TypeKind.BYTE); } - @Override - public CodeTree createBitSetReference(BitSet bits) { + private int bitSetOffset(BitSet bits) { int index = additionalData.indexOf(bits); if (index == -1) { index = additionalData.size(); @@ -180,6 +181,13 @@ public CodeTree createBitSetReference(BitSet bits) { additionalDataKinds.add(DataKind.BITS); } + return index; + } + + @Override + public CodeTree createBitSetReference(BitSet bits) { + int index = bitSetOffset(bits); + return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); } @@ -384,14 +392,8 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui if (cinstr instanceof QuickenedInstruction) { QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; - // unquicken and call parent EAS - builder.tree(OperationGeneratorUtils.createWriteOpcode( - fldBc, - new CodeVariableElement(context.getType(int.class), "$bci"), - qinstr.getOrig().opcodeIdField)); - + // unquicken call parent EAS easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; - } if (isVariadic) { @@ -555,15 +557,29 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ if (!(cinstr instanceof QuickenedInstruction)) { List quickened = cinstr.getQuickenedVariants(); - boolean elseIf = false; - for (QuickenedInstruction qinstr : quickened) { - if (qinstr.getActiveSpecs().contains(specialization)) { - elseIf = b.startIf(elseIf); - b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); - b.end().startBlock(); - { - b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); + if (!quickened.isEmpty()) { + // only quicken/unquicken for instructions that have quickened versions + boolean elseIf = false; + for (QuickenedInstruction qinstr : quickened) { + if (qinstr.getActiveSpecs().contains(specialization)) { + elseIf = b.startIf(elseIf); + b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); + b.end().startBlock(); + { + b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); + } + b.end(); } + } + + if (elseIf) { + b.startElseBlock(); + } + + // quicken to generic + b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", cinstr.opcodeIdField)); + + if (elseIf) { b.end(); } } @@ -572,6 +588,11 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ // boxing elimination if (!isVariadic && boxingSplits != null) { boolean elseIf = false; + + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.declaration("int", "type" + i, (CodeTree) null); + } + for (BoxingSplit split : boxingSplits) { List specializations = split.getGroup().collectSpecializations(); if (!specializations.contains(specialization)) { @@ -592,7 +613,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ for (int i = 0; i < cinstr.numPopStatic(); i++) { FrameKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); - b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", frameType)); + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); } b.end(); @@ -603,12 +624,16 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getStackValueArgumentOffset(i) + "] & 0xff", FrameKind.OBJECT)); + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); } if (elseIf) { b.end(); } + + for (int i = 0; i < cinstr.numPopStatic(); i++) { + b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getArgumentOffset(i) + "]", CodeTreeBuilder.singleString("type" + i))); + } } } @@ -669,4 +694,22 @@ public boolean isStateGuaranteed(boolean stateGuaranteed) { return false; } + + public void finishUp() { + int offset = -1; + BitSet targetSet = null; + for (StateBitSet set : multiState.getSets()) { + if (set.contains(resultUnboxedState)) { + targetSet = set; + offset = Arrays.asList(set.getObjects()).indexOf(resultUnboxedState); + break; + } + } + + if (offset < 0 || targetSet == null) { + throw new AssertionError(); + } + + cinstr.setBoxingEliminationData(cinstr.lengthWithoutState() + bitSetOffset(targetSet), 1 << offset); + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 19fbe654f72d..0cc6b0d6df24 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -26,8 +26,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; public class OperationsCodeGenerator extends CodeTypeElementFactory { @@ -234,13 +234,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; { - bytecodeGenerator = new OperationsBytecodeCodeGenerator(this, typBuilderImpl, simpleName + "BytecodeNode", m, false); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } if (ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(this, typBuilderImpl, - simpleName + "InstrumentableBytecodeNode", m, true); + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "InstrumentableBytecodeNode", m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); } else { @@ -629,13 +628,49 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(mAfterChild); } + { + CodeVariableElement fldBoxingDescriptors = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, arrayOf(arrayOf(context.getType(short.class))), "BOXING_DESCRIPTORS"); + typBuilderImpl.add(fldBoxingDescriptors); + + CodeTreeBuilder b = fldBoxingDescriptors.createInitBuilder(); + + b.string("{").startCommaGroup(); + for (FrameKind kind : FrameKind.values()) { + b.startGroup().newLine(); + b.lineComment("" + kind); + if (m.getFrameKinds().contains(kind)) { + b.string("{").startCommaGroup(); + b.string("-1"); + for (Instruction instr : m.getInstructions()) { + String value; + switch (instr.boxingEliminationBehaviour()) { + case DO_NOTHING: + value = "0"; + break; + case REPLACE: + value = instr.boxingEliminationReplacement(kind).getName(); + break; + case SET_BIT: + value = "(short) (0x8000 | (" + instr.boxingEliminationBitOffset() + " << 8) | 0x" + Integer.toHexString(instr.boxingEliminationBitMask()) + ")"; + break; + default: + throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); + } + b.string(value); + + } + b.end().string("}").end(); + } else { + b.string("null").end(); + } + } + b.end().string("}"); + } + { CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); builderBytecodeNodeType.add(mDoSetResultUnboxed); - CodeVariableElement varBoxed = new CodeVariableElement(context.getType(boolean.class), "boxed"); - mDoSetResultUnboxed.addParameter(varBoxed); - CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); mDoSetResultUnboxed.addParameter(varBc); @@ -648,39 +683,18 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); mDoSetResultUnboxed.addParameter(varTargetType); - vars.bc = varBc; - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); - b.startIf().variable(varBciOffset).string(" == 0").end().startBlock(); - b.returnStatement(); + b.startIf().variable(varBciOffset).string(" != 0").end().startBlock(); + { + b.startStatement().startCall("setResultBoxedImpl"); + b.variable(varBc); + b.string("startBci - bciOffset"); + b.variable(varTargetType); + b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); + b.end(2); + } b.end(); - - b.startStatement().startStaticCall(types.CompilerDirectives, "transferToInterpreter").end(2); - - b.declaration("int", "bci", "startBci - bciOffset"); - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars.asExecution(), instr -> { - if (instr == null) { - return null; - } - - CodeTree tree = instr.createSetResultBoxed(vars.asExecution(), varBoxed, varTargetType); - if (tree == null) { - return null; - } - - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - - builder.tree(tree); - builder.statement("break"); - - return builder.build(); - })); - - vars.bc = fldBc; - vars.bci = fldBci; } for (Operation op : m.getOperations()) { @@ -872,39 +886,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } - void createSetBoxedForInstructions(CodeTypeElement typBuilderImpl) { - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - continue; - } - - if (instr instanceof QuickenedInstruction) { - continue; - } - - CustomInstruction cinstr = (CustomInstruction) instr; - SingleOperationData soData = cinstr.getData(); - - { - CodeVariableElement varUnboxed = new CodeVariableElement(context.getType(boolean.class), "unboxed"); - cinstr.setSetResultUnboxedMethod(cinstr.getPlugs().createSetResultBoxed(varUnboxed)); - } - - if (m.isTracing()) { - CodeExecutableElement metGetStateBits = new CodeExecutableElement( - MOD_PRIVATE_STATIC, - arrayOf(context.getType(boolean.class)), soData.getName() + "_doGetStateBits_", - new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"), - new CodeVariableElement(context.getType(int.class), "$bci")); - typBuilderImpl.add(metGetStateBits); - cinstr.setGetSpecializationBits(metGetStateBits); - - CodeTreeBuilder b = metGetStateBits.createBuilder(); - b.tree(cinstr.getPlugs().createGetSpecializationBits()); - } - } - } - private static TypeMirror generic(TypeElement el, TypeMirror... params) { return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index be050bee0698..0c0b4141b136 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -7,7 +7,6 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class BranchInstruction extends Instruction { @@ -98,8 +97,8 @@ public boolean isBranchInstruction() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index fbd36885f2df..d0822891301f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -9,7 +9,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -75,8 +74,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 8e88775761fb..92c9ae5b8f70 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -10,7 +10,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; @@ -31,11 +30,12 @@ public enum DataKind { private DataKind[] dataKinds = null; private int numChildNodes; private int numConsts; - private CodeTree setResultUnboxedMethod; private OperationsBytecodeNodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; private CodeExecutableElement getSpecializationBits; private final List quickenedVariants = new ArrayList<>(); + private int boxingEliminationBitOffset; + private int boxingEliminationBitMask; public SingleOperationData getData() { return data; @@ -252,32 +252,33 @@ public void setNumConsts(int numConsts) { this.numConsts = numConsts; } - public void setSetResultUnboxedMethod(CodeTree setResultUnboxedMethod) { - this.setResultUnboxedMethod = setResultUnboxedMethod; - } - public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { this.prepareAOTMethod = prepareAOTMethod; } public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits) { this.getSpecializationBits = getSpecializationBits; - } - @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public void setBoxingEliminationData(int boxingEliminationBitOffset, int boxingEliminationBitMask) { + this.boxingEliminationBitOffset = boxingEliminationBitOffset; + this.boxingEliminationBitMask = boxingEliminationBitMask; - if (!vars.bci.getName().equals("$bci")) { - b.declaration("int", "$bci", CodeTreeBuilder.singleVariable(vars.bci)); - } + } - b.declaration("boolean", "unboxed", "!" + varBoxed.getName()); + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.SET_BIT; + } - b.tree(setResultUnboxedMethod); + @Override + public int boxingEliminationBitOffset() { + return boxingEliminationBitOffset; + } - return b.build(); + @Override + public int boxingEliminationBitMask() { + return boxingEliminationBitMask; } public OperationsBytecodeNodeGeneratorPlugs getPlugs() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 9246653e6f9b..c2ed2621ae87 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -3,6 +3,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class DiscardInstruction extends Instruction { public DiscardInstruction(String name, int id, InputType input) { @@ -28,8 +29,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index 24de649d3015..f801e4ba895c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -1,13 +1,13 @@ package com.oracle.truffle.dsl.processor.operations.instructions; public enum FrameKind { - BOOLEAN("boolean", "Boolean"), + OBJECT("Object", "Object"), BYTE("byte", "Byte"), + BOOLEAN("boolean", "Boolean"), INT("int", "Int", "Integer"), FLOAT("float", "Float"), LONG("long", "Long"), - DOUBLE("double", "Double"), - OBJECT("Object", "Object"); + DOUBLE("double", "Double"); private final String typeName; private final String frameName; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 8c6855f2273b..338bf941c01c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -240,6 +240,12 @@ public CodeTree createDumpCode(int i, Instruction op, ExecutionVariables vars) { } + public enum BoxingEliminationBehaviour { + DO_NOTHING, + SET_BIT, + REPLACE + } + public final String name; public final int id; public final InputType[] inputs; @@ -571,7 +577,20 @@ public boolean isReturnInstruction() { return Arrays.stream(results).anyMatch(x -> x == ResultType.RETURN); } - public abstract CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType); + public abstract BoxingEliminationBehaviour boxingEliminationBehaviour(); + + @SuppressWarnings("unused") + public CodeVariableElement boxingEliminationReplacement(FrameKind kind) { + throw new AssertionError(); + } + + public int boxingEliminationBitOffset() { + throw new AssertionError(); + } + + public int boxingEliminationBitMask() { + throw new AssertionError(); + } public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index ff69d80e2af0..d064dc8b040c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -2,7 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class InstrumentationEnterInstruction extends Instruction { @@ -38,8 +37,8 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 881213a95e59..64207e00b0d7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -2,7 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; public class InstrumentationExitInstruction extends Instruction { @@ -56,8 +55,8 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index f1de489573b4..feca809209f9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -2,7 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class InstrumentationLeaveInstruction extends Instruction { public InstrumentationLeaveInstruction(int id) { @@ -60,8 +59,8 @@ public boolean isInstrumentationOnly() { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index f10c892d1805..40c071e4b8b2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -3,7 +3,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadArgumentInstruction extends Instruction { @@ -71,32 +70,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == FrameKind.OBJECT) { - b.startIf().string("!").variable(varBoxed).end().startBlock(); - - boolean elseIf = false; - for (FrameKind okind : ctx.getData().getFrameKinds()) { - if (okind == FrameKind.OBJECT) - continue; - - elseIf = b.startIf(elseIf); - b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[okind.ordinal()].opcodeIdField)); - b.end(); - } + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.REPLACE; + } - b.end(); + @Override + public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { + if (kind == FrameKind.OBJECT) { + return ctx.loadArgumentInstructions[targetKind.ordinal()].opcodeIdField; } else { - b.startIf().variable(varBoxed).end().startBlock(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadArgumentInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - - b.end(); + if (targetKind == FrameKind.OBJECT) { + return ctx.loadArgumentInstructions[targetKind.ordinal()].opcodeIdField; + } else { + return opcodeIdField; + } } - - return b.build(); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index af308a7af5a4..30fb30661bb3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -1,10 +1,7 @@ package com.oracle.truffle.dsl.processor.operations.instructions; -import javax.lang.model.type.TypeKind; - import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -54,36 +51,21 @@ private CodeTree createGetArgument(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.REPLACE; + } + @Override + public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { if (kind == FrameKind.OBJECT) { - b.startIf().string("!").variable(varBoxed).end().startBlock(); - - boolean elseIf = false; - for (FrameKind okind : ctx.getData().getFrameKinds()) { - if (okind == FrameKind.OBJECT) { - continue; - } - - elseIf = b.startIf(elseIf); - b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[okind.ordinal()].opcodeIdField)); - - b.end(); - } - - b.end(); + return ctx.loadConstantInstructions[targetKind.ordinal()].opcodeIdField; } else { - b.startIf().variable(varBoxed).end().startBlock(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - - b.end(); + if (targetKind == FrameKind.OBJECT) { + return ctx.loadConstantInstructions[targetKind.ordinal()].opcodeIdField; + } else { + return opcodeIdField; + } } - - return b.build(); } @Override @@ -92,7 +74,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - return createSetResultBoxed(vars, new CodeVariableElement(new CodeTypeMirror(TypeKind.BOOLEAN), "true"), null); + return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index e64d793acaaf..1ab1e8c4b342 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -3,7 +3,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadLocalInstruction extends Instruction { @@ -71,36 +70,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.REPLACE; + } + @Override + public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { if (kind == FrameKind.OBJECT) { - b.startIf().string("!").variable(varBoxed).end().startBlock(); - - boolean elseIf = false; - for (FrameKind okind : ctx.getData().getFrameKinds()) { - if (okind == FrameKind.OBJECT) { - continue; - } - - elseIf = b.startIf(elseIf); - b.variable(varTargetType).string(" == FRAME_TYPE_" + okind.getFrameName().toUpperCase()).end().startBlock(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[okind.ordinal()].opcodeIdField)); - - b.end(); - } - - b.end(); + return ctx.loadLocalInstructions[targetKind.ordinal()].opcodeIdField; } else { - b.startIf().variable(varBoxed).end().startBlock(); - - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - - b.end(); + if (targetKind == FrameKind.OBJECT) { + return ctx.loadLocalInstructions[targetKind.ordinal()].opcodeIdField; + } else { + return opcodeIdField; + } } - - return b.build(); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 943d7253489c..8a15efb49958 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -4,7 +4,6 @@ import java.util.List; import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -93,8 +92,18 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return orig.createSetResultBoxed(vars, varBoxed, varTargetType); + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.SET_BIT; + } + + @Override + public int boxingEliminationBitOffset() { + return orig.boxingEliminationBitOffset(); + } + + @Override + public int boxingEliminationBitMask() { + return orig.boxingEliminationBitMask(); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 009adabcf317..72011cd7bc2d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -2,7 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class ReturnInstruction extends Instruction { @@ -28,8 +27,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 9c82707813d0..8aa91d30dd38 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -3,6 +3,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class StoreLocalInstruction extends Instruction { @@ -46,8 +47,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 4202d266cf2e..38c93a306dde 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,6 +7,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class SuperInstruction extends Instruction { private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { @@ -154,8 +155,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createSetResultBoxed(ExecutionVariables vars, CodeVariableElement varBoxed, CodeVariableElement varTargetType) { - return null; + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; } @Override From 44103c96a177d6f460a79f9c06f6c5197b4ceb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 3 May 2022 21:17:27 +0200 Subject: [PATCH 069/312] [wip] hook tracer properly --- truffle/mx.truffle/suite.py | 1 + .../example/TestOperationsParserTest.java | 2 - .../truffle/api/operation/OperationsNode.java | 5 - .../tracing/DisabledExecutionTracer.java | 59 --- .../operation/tracing/ExecutionTracer.java | 161 +------- .../operation/tracing/InstructionTrace.java | 25 -- .../api/operation/tracing/NodeTrace.java | 13 - .../tracing/OperationsExecutionTracer.java | 316 -------------- .../tracing/OperationsStatistics.java | 387 ++++++++++++++++++ .../truffle/dsl/processor/TruffleTypes.java | 4 - .../dsl/processor/generator/BitSet.java | 1 - .../generator/FlatNodeGenFactory.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 129 ++---- .../OperationsBytecodeNodeGeneratorPlugs.java | 26 +- .../operations/OperationsCodeGenerator.java | 47 +-- .../instructions/CustomInstruction.java | 14 +- .../instructions/DiscardInstruction.java | 2 - .../operations/instructions/Instruction.java | 1 + .../instructions/StoreLocalInstruction.java | 2 - .../instructions/SuperInstruction.java | 1 - .../truffle/polyglot/PolyglotEngineImpl.java | 18 + .../polyglot/PolyglotEngineOptions.java | 4 + .../truffle/polyglot/PolyglotThreadInfo.java | 20 + .../truffle/sl/operations/decisions.json | 110 +++-- 24 files changed, 590 insertions(+), 760 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index a189f3caf7e0..a56b8781839e 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -189,6 +189,7 @@ "sdk:GRAAL_SDK", "com.oracle.truffle.api.instrumentation", "com.oracle.truffle.api.exception", + "com.oracle.truffle.api.operation", ], "requires" : [ "java.logging", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 7bdc5f2f72aa..6f3ba705336d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -292,7 +292,6 @@ public void testTracing() { + " (return (local 2)))"; //@formatter:on new Tester(src).test(495000L); - ExecutionTracer.get("com.oracle.truffle.api.operation.test.example.TestOperations").dump(new PrintWriter(System.out)); } @Test @@ -303,7 +302,6 @@ public void testInstrumentation() { //@formatter:on new Tester(src, true).test(3L); - ExecutionTracer.get("com.oracle.truffle.api.operation.test.example.TestOperations").dump(new PrintWriter(System.out)); } @Test diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index da06768efba9..86b390cb624f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -10,7 +10,6 @@ import com.oracle.truffle.api.instrumentation.ProbeNode; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.operation.tracing.NodeTrace; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -80,10 +79,6 @@ public final Object execute(VirtualFrame frame) { public abstract String dump(); - public NodeTrace getNodeTrace() { - throw new UnsupportedOperationException("Operations not built with tracing"); - } - protected final void copyReparsedInfo(OperationsNode other) { this.sourceInfo = other.sourceInfo; this.sources = other.sources; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java deleted file mode 100644 index 43fdd4df4b56..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/DisabledExecutionTracer.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.oracle.truffle.api.operation.tracing; - -import java.io.PrintWriter; - -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONObject; - -class DisabledExecutionTracer extends ExecutionTracer { - - DisabledExecutionTracer() { - super(null); - } - - @Override - public void startFunction(OperationsNode node) { - } - - @Override - public void endFunction() { - } - - @Override - public void traceInstruction(int bci, String id, int instructionType, Object... arguments) { - } - - @Override - public void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { - } - - @Override - public Object tracePop(Object value) { - return value; - } - - @Override - public Object tracePush(Object value) { - return value; - } - - @Override - public void traceException(Throwable ex) { - } - - @Override - public void dump(PrintWriter writer) { - } - - @Override - public JSONObject serializeState() { - throw new AssertionError("should never be called"); - } - - @Override - public JSONArray createDecisions() { - throw new AssertionError("should never be called"); - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index eec460ac2e59..1bcb3d2ef192 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,156 +1,39 @@ package com.oracle.truffle.api.operation.tracing; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.TruffleOptions; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONObject; -import com.oracle.truffle.tools.utils.json.JSONTokener; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.tracing.OperationsStatistics.DisabledExecutionTracer; +// per-context per-ops per-thread public abstract class ExecutionTracer { - - private static final boolean ENABLED; - private static final ExecutionTracer DISABLED_INSTANCE; - - private static final Map TRACERS = new HashMap<>(); - - private static final String KEY_TRACERS = "tracers"; - - public static ExecutionTracer get(String key) { - if (ENABLED) { - return TRACERS.computeIfAbsent(key, OperationsExecutionTracer::new); + static final Map, String> DECISIONS_FILE_MAP = new HashMap<>(); + static final Map, String[]> INSTR_NAMES_MAP = new HashMap<>(); + static final Map, String[][]> SPECIALIZATION_NAMES_MAP = new HashMap<>(); + + public static ExecutionTracer get(Class operationsClass) { + OperationsStatistics stats = OperationsStatistics.STATISTICS.get(); + if (stats == null) { + return DisabledExecutionTracer.INSTANCE; } else { - return DISABLED_INSTANCE; + return stats.getStatsistics(operationsClass).getTracer(); } } - final String key; - private String outputPath; - protected Map specializationNames = new HashMap<>(); - - ExecutionTracer(String key) { - assert TRACERS.get(key) == null; - this.key = key; - } - - private static void loadState(String stateFile) { - try { - // TODO stateFile should be locked while we are running to prevent concurrent - // modification - - FileInputStream fi = new FileInputStream(new File(stateFile)); - JSONTokener tok = new JSONTokener(fi); - if (!tok.more()) { - // empty file - return; - } - - JSONObject o = new JSONObject(tok); - JSONArray tracers = o.getJSONArray("tracers"); - for (int i = 0; i < tracers.length(); i++) { - JSONObject tracer = tracers.getJSONObject(i); - ExecutionTracer tr = OperationsExecutionTracer.deserializeState(tracer); - TRACERS.put(tr.key, tr); - } - } catch (FileNotFoundException ex) { - throw new RuntimeException("Operations execution tracer file not found. Make sure tracer file exists."); - } + public static void initialize(Class opsClass, String decisionsFile, String[] instrNames, String[][] specNames) { + DECISIONS_FILE_MAP.put(opsClass, decisionsFile); + INSTR_NAMES_MAP.put(opsClass, instrNames); + SPECIALIZATION_NAMES_MAP.put(opsClass, specNames); } - private static void saveState(String stateFile) { - try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(new File(stateFile)))) { - JSONObject result = new JSONObject(); - JSONArray tracers = new JSONArray(); - - for (Map.Entry ent : TRACERS.entrySet()) { - ExecutionTracer tracer = ent.getValue(); - tracers.put(tracer.serializeState()); - // tracer.dump(new PrintWriter(System.out)); - // System.out.flush(); - } + public abstract void startFunction(Node node); - result.put(KEY_TRACERS, tracers); - fo.append(result.toString()); + public abstract void endFunction(Node node); - } catch (Exception e) { - // failing to write the state is a critical exception - throw new RuntimeException(e); - } + public abstract void traceInstruction(int bci, int id); - for (Map.Entry ent : TRACERS.entrySet()) { - ExecutionTracer tracer = ent.getValue(); - try (OutputStreamWriter fo = new OutputStreamWriter(new FileOutputStream(tracer.outputPath))) { - JSONArray decisions = tracer.createDecisions(); - fo.append(decisions.toString(2)); - } catch (Exception e) { - // failing to write the decisions is not as big of an exception - e.printStackTrace(); - } - } - } - - static { - String stateFile = TruffleOptions.OperationDecisionsFile; - - if (stateFile != null && !stateFile.isEmpty()) { - loadState(stateFile); - Runtime.getRuntime().addShutdownHook(new Thread(() -> saveState(stateFile))); - - ENABLED = true; - DISABLED_INSTANCE = null; - } else { - ENABLED = false; - DISABLED_INSTANCE = new DisabledExecutionTracer(); - } - } - - public static final int INSTRUCTION_TYPE_OTHER = 0; - public static final int INSTRUCTION_TYPE_BRANCH = 1; - public static final int INSTRUCTION_TYPE_BRANCH_COND = 2; - public static final int INSTRUCTION_TYPE_LOAD_LOCAL = 3; - public static final int INSTRUCTION_TYPE_STORE_LOCAL = 4; - public static final int INSTRUCTION_TYPE_LOAD_ARGUMENT = 5; - public static final int INSTRUCTION_TYPE_LOAD_CONSTANT = 6; - public static final int INSTRUCTION_TYPE_RETURN = 7; - public static final int INSTRUCTION_TYPE_CUSTOM = 8; - - @TruffleBoundary - public abstract void startFunction(OperationsNode node); - - @TruffleBoundary - public abstract void endFunction(); - - public abstract void traceInstruction(int bci, String id, int instructionType, Object... arguments); - - public abstract void traceSpecialization(int bci, String id, int specializationId, Object... arguments); - - public abstract Object tracePop(Object value); - - public abstract Object tracePush(Object value); - - public abstract void traceException(Throwable ex); - - public abstract void dump(PrintWriter writer); - - public abstract JSONObject serializeState(); - - public abstract JSONArray createDecisions(); - - public void setOutputPath(String outputPath) { - this.outputPath = outputPath; - } - - public void setInstructionSpecializationNames(String instructionName, String... specializationNames) { - this.specializationNames.put(instructionName, specializationNames); - } + public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations); -} + public abstract void traceSpecialization(int bci, int id, int specializationId, Object... values); +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java deleted file mode 100644 index 1789a5fda9e4..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/InstructionTrace.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.oracle.truffle.api.operation.tracing; - -public class InstructionTrace { - private final int id; - private final int hitCount; - private final Object[] arguments; - - public InstructionTrace(int id, int hitCount, Object... arguments) { - this.id = id; - this.hitCount = hitCount; - this.arguments = arguments; - } - - public int getId() { - return id; - } - - public int getHitCount() { - return hitCount; - } - - public Object[] getArguments() { - return arguments; - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java deleted file mode 100644 index 6904ff960e1a..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/NodeTrace.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.oracle.truffle.api.operation.tracing; - -public class NodeTrace { - private final InstructionTrace[] instructions; - - public NodeTrace(InstructionTrace[] instructions) { - this.instructions = instructions; - } - - public InstructionTrace[] getInstructions() { - return instructions; - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java deleted file mode 100644 index a26ad4bde7ab..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsExecutionTracer.java +++ /dev/null @@ -1,316 +0,0 @@ -package com.oracle.truffle.api.operation.tracing; - -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONObject; - -final class OperationsExecutionTracer extends ExecutionTracer { - - private static final String KEY_KEY = "key"; - private static final String KEY_ACTIVE_SPECIALIZATION_OCCURENCES = "activeSpecializations"; - private static final String KEY_COUNT = "count"; - - private static class ActiveSpecializationOccurence { - private static final String KEY_INSTRUCTION_ID = "i"; - private static final String KEY_ACTIVE_SPECIALIZATIONS = "a"; - - private static final String KEY_LENGTH = "l"; - - static ActiveSpecializationOccurence deserializeState(JSONObject o) { - String instructionId = o.getString(KEY_INSTRUCTION_ID); - int len = o.getInt(KEY_LENGTH); - - boolean[] activeSpecializations = new boolean[len]; - - JSONArray arr = o.getJSONArray(KEY_ACTIVE_SPECIALIZATIONS); - for (int i = 0; i < arr.length(); i++) { - int idx = arr.getInt(i); - activeSpecializations[idx] = true; - } - - return new ActiveSpecializationOccurence(instructionId, activeSpecializations); - } - - final String instructionId; - - final boolean[] activeSpecializations; - - ActiveSpecializationOccurence(String instructionId, boolean... activeSpecializations) { - this.instructionId = instructionId; - this.activeSpecializations = activeSpecializations; - } - - JSONObject createDecision(String[] specNames) { - assert specNames.length >= activeSpecializations.length : instructionId + "should have at least" + activeSpecializations.length + " specializations, but has " + specNames.length; - JSONObject result = new JSONObject(); - result.put("type", "Quicken"); - assert instructionId.startsWith("c."); - result.put("operation", instructionId.substring(2)); // drop the `c.` prefix - - JSONArray specs = new JSONArray(); - - StringBuilder id = new StringBuilder("q-"); - id.append(instructionId.substring(2)); - - for (int i = 0; i < activeSpecializations.length; i++) { - if (activeSpecializations[i]) { - specs.put(specNames[i]); - id.append('-').append(specNames[i]); - } - } - - result.put("specializations", specs); - result.put("id", id); - - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ActiveSpecializationOccurence other = (ActiveSpecializationOccurence) obj; - return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId.equals(other.instructionId); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(activeSpecializations); - result = prime * result + Objects.hash(instructionId); - return result; - } - - JSONObject serializeState() { - JSONObject result = new JSONObject(); - result.put(KEY_INSTRUCTION_ID, instructionId); - result.put(KEY_LENGTH, activeSpecializations.length); - - JSONArray arr = new JSONArray(); - int i = 0; - for (boolean act : activeSpecializations) { - if (act) { - arr.put(i); - } - i++; - } - result.put(KEY_ACTIVE_SPECIALIZATIONS, arr); - - return result; - } - - @Override - public String toString() { - return "ActiveSpecializationOccurence[instructionId=" + instructionId + ", activeSpecializations=" + Arrays.toString(activeSpecializations) + "]"; - } - } - - private static class InstructionSequence { - final int hash; - final int[] instrs; - - public InstructionSequence(int[] instrs) { - this.instrs = instrs; - int h = 0; - for (int i : instrs) { - h = h * 31 + i; - } - hash = h; - } - - public InstructionSequence add(int next) { - int[] created = new int[instrs.length]; - System.arraycopy(instrs, 1, created, 0, instrs.length - 1); - created[created.length - 1] = next; - return new InstructionSequence(created); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof InstructionSequence)) - return false; - InstructionSequence other = (InstructionSequence) obj; - if (other.hash != hash || instrs.length != other.instrs.length) { - return false; - } - for (int i = 0; i < instrs.length; i++) { - if (instrs[i] != other.instrs[i]) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - return hash; - } - - public boolean isValid() { - for (int i : instrs) { - if (i == 0) { - return false; - } - } - return true; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append('['); - for (int i = 0; i < instrs.length; i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(String.format("%3d", instrs[i])); - } - sb.append(']'); - return sb.toString(); - } - } - - private static final int TRACE_LENGTH = 8; - - private static final long score(Map.Entry ent) { - return ent.getValue() * ent.getKey().instrs.length; - } - - private final Map occurences = new HashMap<>(); - private final Map activeSpecializationsMap = new HashMap<>(); - private InstructionSequence[] last = new InstructionSequence[TRACE_LENGTH - 1]; - - OperationsExecutionTracer(String key) { - super(key); - } - - @Override - public JSONArray createDecisions() { - int numQuicken = 10; - - JSONArray result = new JSONArray(); - - activeSpecializationsMap.entrySet().stream() // - .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // - .limit(numQuicken) // - .forEachOrdered(e -> { - result.put(e.getKey().createDecision(specializationNames.get(e.getKey().instructionId))); - }); - - return result; - } - - @Override - public final void dump(PrintWriter writer) { - writer.println("-------------------------------------------------------------"); - activeSpecializationsMap.entrySet().stream() // - .sorted((e1, e2) -> Long.compare(e2.getValue(), e1.getValue())) // - .limit(50) // - .forEachOrdered(e -> { - writer.printf(" %s: %d%n", e.getKey(), e.getValue()); - }); - writer.println("-------------------------------------------------------------"); - writer.flush(); - } - - @Override - public JSONObject serializeState() { - JSONObject result = new JSONObject(); - result.put(KEY_KEY, key); - - JSONArray arr = new JSONArray(); - for (Map.Entry entry : activeSpecializationsMap.entrySet()) { - ActiveSpecializationOccurence as = entry.getKey(); - - JSONObject o = as.serializeState(); - o.put(KEY_COUNT, entry.getValue()); - - arr.put(o); - } - - result.put(KEY_ACTIVE_SPECIALIZATION_OCCURENCES, arr); - return result; - } - - public static OperationsExecutionTracer deserializeState(JSONObject tracer) { - String key = tracer.getString(KEY_KEY); - OperationsExecutionTracer result = new OperationsExecutionTracer(key); - - JSONArray arr = tracer.getJSONArray(KEY_ACTIVE_SPECIALIZATION_OCCURENCES); - for (int i = 0; i < arr.length(); i++) { - JSONObject o = arr.getJSONObject(i); - - long count = o.getLong(KEY_COUNT); - o.remove(KEY_COUNT); - - ActiveSpecializationOccurence as = ActiveSpecializationOccurence.deserializeState(o); - result.activeSpecializationsMap.put(as, count); - } - - return result; - } - - private final void resetLast() { - for (int i = 2; i <= TRACE_LENGTH; i++) { - last[i - 2] = new InstructionSequence(new int[i]); - } - } - - @Override - @TruffleBoundary - public final void startFunction(OperationsNode node) { - resetLast(); - } - - @Override - @TruffleBoundary - public final void endFunction() { - resetLast(); - } - - @Override - public void traceException(Throwable ex) { - } - - @Override - @TruffleBoundary - public void traceInstruction(int bci, String id, int instructionType, Object... arguments) { - if (instructionType == INSTRUCTION_TYPE_CUSTOM) { - assert arguments.length == 1; - boolean[] activeSpecs = (boolean[]) arguments[0]; - - ActiveSpecializationOccurence occ = new ActiveSpecializationOccurence(id, activeSpecs); - Long cur = activeSpecializationsMap.get(occ); - long next = cur == null ? 1 : cur + 1; - activeSpecializationsMap.put(occ, next); - } - } - - @Override - public Object tracePop(Object value) { - return value; - } - - @Override - public Object tracePush(Object value) { - return value; - } - - @Override - @TruffleBoundary - public void traceSpecialization(int bci, String id, int specializationId, Object... arguments) { - } - -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java new file mode 100644 index 000000000000..d7307fb5f228 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -0,0 +1,387 @@ +package com.oracle.truffle.api.operation.tracing; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.Channels; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; +import com.oracle.truffle.tools.utils.json.JSONTokener; + +// per-context singleton +public class OperationsStatistics { + private final Map, GlobalOperationStatistics> statisticsMap = new HashMap<>(); + static final ThreadLocal STATISTICS = new ThreadLocal<>(); + private Path statePath; + private FileChannel stateFile; + private FileLock fileLock; + + OperationsStatistics(String statePath) { + this.statePath = Path.of(statePath); + read(); + } + + public static OperationsStatistics create(String statePath) { + return new OperationsStatistics(statePath); + } + + public OperationsStatistics enter() { + OperationsStatistics prev = STATISTICS.get(); + STATISTICS.set(this); + return prev; + } + + public void exit(OperationsStatistics prev) { + STATISTICS.set(prev); + } + + private void read() { + try { + stateFile = FileChannel.open(statePath, StandardOpenOption.READ, StandardOpenOption.WRITE); + fileLock = stateFile.lock(); + + JSONTokener tok = new JSONTokener(Channels.newInputStream(stateFile)); + if (!tok.more()) { + return; + } + + JSONArray o = new JSONArray(tok); + + for (int i = 0; i < o.length(); i++) { + JSONObject data = o.getJSONObject(i); + GlobalOperationStatistics value = GlobalOperationStatistics.deserialize(this, data); + this.statisticsMap.put(value.opsClass, value); + } + + } catch (IOException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public void write() { + try { + try { + JSONArray result = new JSONArray(); + this.statisticsMap.forEach((k, v) -> { + result.put(v.serialize()); + }); + + stateFile.position(0); + stateFile.write(ByteBuffer.wrap(result.toString().getBytes(StandardCharsets.UTF_8))); + stateFile.truncate(stateFile.position()); + + fileLock.release(); + } finally { + stateFile.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + + this.statisticsMap.forEach((k, v) -> { + try { + v.writeDecisions(); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + + synchronized GlobalOperationStatistics getStatsistics(Class opsClass) { + return statisticsMap.computeIfAbsent(opsClass, (c) -> new GlobalOperationStatistics(opsClass)); + } + + // per-context per-ops + static final class GlobalOperationStatistics { + private final List allTracers = new ArrayList<>(); + private final ThreadLocal currentTracer = new ThreadLocal<>(); + + private Class opsClass; + private String decisionsFile; + private String[] instrNames; + private String[][] specNames; + + public GlobalOperationStatistics(Class opsClass) { + this.opsClass = opsClass; + } + + public void writeDecisions() throws IOException { + setNames(); + EnabledExecutionTracer tracer = collect(); + try (FileChannel ch = FileChannel.open(Path.of(decisionsFile), StandardOpenOption.WRITE)) { + JSONArray result = tracer.serializeDecisions(this); + ch.truncate(0); + ch.write(ByteBuffer.wrap(result.toString(4).getBytes(StandardCharsets.UTF_8))); + } + } + + private static GlobalOperationStatistics deserialize(OperationsStatistics parent, JSONObject data) throws ClassNotFoundException { + Class key = Class.forName(data.getString("key")); + GlobalOperationStatistics result = parent.getStatsistics(key); + result.allTracers.add(EnabledExecutionTracer.deserialize(data)); + return result; + } + + private EnabledExecutionTracer collect() { + EnabledExecutionTracer tracer = new EnabledExecutionTracer(); + for (EnabledExecutionTracer other : allTracers) { + tracer.merge(other); + } + + return tracer; + } + + private JSONObject serialize() { + JSONObject result = collect().serialize(); + result.put("key", opsClass.getName()); + return result; + } + + private void setNames() { + if (this.decisionsFile != null) { + return; + } + + this.decisionsFile = ExecutionTracer.DECISIONS_FILE_MAP.get(opsClass); + this.instrNames = ExecutionTracer.INSTR_NAMES_MAP.get(opsClass); + this.specNames = ExecutionTracer.SPECIALIZATION_NAMES_MAP.get(opsClass); + } + + public EnabledExecutionTracer getTracer() { + if (currentTracer.get() == null) { + return createTracer(); + } else { + return currentTracer.get(); + } + } + + private EnabledExecutionTracer createTracer() { + assert currentTracer.get() == null; + EnabledExecutionTracer tracer = new EnabledExecutionTracer(); + currentTracer.set(tracer); + allTracers.add(tracer); + return tracer; + } + + } + + static class DisabledExecutionTracer extends ExecutionTracer { + static final DisabledExecutionTracer INSTANCE = new DisabledExecutionTracer(); + + @Override + public void startFunction(Node node) { + } + + @Override + public void endFunction(Node node) { + } + + @Override + public void traceInstruction(int bci, int id) { + } + + @Override + public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { + } + + @Override + public void traceSpecialization(int bci, int id, int specializationId, Object... values) { + } + } + + private static class EnabledExecutionTracer extends ExecutionTracer { + + private static class SpecializationKey { + final int instructionId; + @CompilationFinal(dimensions = 1) final boolean[] activeSpecializations; + + SpecializationKey(int instructionId, boolean[] activeSpecializations) { + this.instructionId = instructionId; + this.activeSpecializations = activeSpecializations; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(activeSpecializations); + result = prime * result + Objects.hash(instructionId); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SpecializationKey other = (SpecializationKey) obj; + return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId == other.instructionId; + } + + private JSONObject serialize() { + JSONObject result = new JSONObject(); + result.put("i", instructionId); + result.put("n", activeSpecializations.length); + + JSONArray activeSpecsData = new JSONArray(); + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + activeSpecsData.put(i); + } + } + + result.put("a", activeSpecsData); + + return result; + } + + private static SpecializationKey deserialize(JSONObject obj) { + int id = obj.getInt("i"); + int count = obj.getInt("n"); + boolean[] activeSpecializations = new boolean[count]; + JSONArray activeSpecsData = obj.getJSONArray("a"); + for (int i = 0; i < activeSpecsData.length(); i++) { + activeSpecializations[activeSpecsData.getInt(i)] = true; + } + + return new SpecializationKey(id, activeSpecializations); + } + + public JSONObject serializeDecision(GlobalOperationStatistics stats) { + JSONObject result = new JSONObject(); + result.put("type", "Quicken"); + String instrName = stats.instrNames[instructionId]; + assert instrName.startsWith("c."); + result.put("operation", instrName.substring(2)); + + JSONArray specsData = new JSONArray(); + result.put("specializations", specsData); + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + specsData.put(stats.specNames[instructionId][i]); + } + } + + return result; + } + + @Override + public String toString() { + return "SpecializationKey [" + instructionId + ", " + Arrays.toString(activeSpecializations) + "]"; + } + } + + private Map activeSpecializationsMap = new HashMap<>(); + + @Override + public void startFunction(Node node) { + } + + @Override + public void endFunction(Node node) { + } + + @Override + public void traceInstruction(int bci, int id) { + } + + @Override + public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { + SpecializationKey key = new SpecializationKey(id, activeSpecializations); + Long l = activeSpecializationsMap.get(key); + if (l == null) { + activeSpecializationsMap.put(key, 1L); + } else if (l != Long.MAX_VALUE) { + activeSpecializationsMap.put(key, l + 1); + } + } + + @Override + public void traceSpecialization(int bci, int id, int specializationId, Object... values) { + } + + private void merge(EnabledExecutionTracer other) { + other.activeSpecializationsMap.forEach((k, v) -> { + Long existing = this.activeSpecializationsMap.get(k); + if (existing == null) { + this.activeSpecializationsMap.put(k, v); + } else if (Long.MAX_VALUE - existing > v) { + this.activeSpecializationsMap.put(k, existing + v); + } else { + this.activeSpecializationsMap.put(k, Long.MAX_VALUE); + } + }); + } + + private JSONObject serialize() { + JSONObject result = new JSONObject(); + + JSONArray activeSpecializationsData = new JSONArray(); + + activeSpecializationsMap.forEach((k, v) -> { + JSONObject activeSpecData = k.serialize(); + activeSpecData.put("c", v); + activeSpecializationsData.put(activeSpecData); + }); + + result.put("as", activeSpecializationsData); + + return result; + } + + private static EnabledExecutionTracer deserialize(JSONObject obj) { + EnabledExecutionTracer inst = new EnabledExecutionTracer(); + JSONArray activeSpecializationsData = obj.getJSONArray("as"); + + for (int i = 0; i < activeSpecializationsData.length(); i++) { + JSONObject activeSpecData = activeSpecializationsData.getJSONObject(i); + long count = activeSpecData.getLong("c"); + SpecializationKey key = SpecializationKey.deserialize(activeSpecData); + inst.activeSpecializationsMap.put(key, count); + } + + System.out.println(inst); + + return inst; + } + + public JSONArray serializeDecisions(GlobalOperationStatistics stats) { + JSONArray result = new JSONArray(); + int numDecisions = 10; + activeSpecializationsMap.entrySet().stream() // + .map(e -> { + System.out.println("state: " + e.getValue() + ":" + e.getKey()); + return e; + }) // + .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) // + .limit(numDecisions) // + .forEachOrdered(e -> { + result.put(e.getKey().serializeDecision(stats)); + }); + return result; + } + + @Override + public String toString() { + return "EnabledExecutionTracer [" + activeSpecializationsMap + "]"; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index a9dbd00e29e7..de7ae895ac6a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -241,8 +241,6 @@ public class TruffleTypes { public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; - public static final String NodeTrace_Name = "com.oracle.truffle.api.operation.tracing.NodeTrace"; - public static final String InstructionTrace_Name = "com.oracle.truffle.api.operation.tracing.InstructionTrace"; public final DeclaredType BuilderExceptionHandler = c.getDeclaredTypeOptional(BuilderExceptionHandler_Name); public final DeclaredType BuilderOperationData = c.getDeclaredTypeOptional(BuilderOperationData_Name); @@ -259,8 +257,6 @@ public class TruffleTypes { public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); - public final DeclaredType NodeTrace = c.getDeclaredTypeOptional(NodeTrace_Name); - public final DeclaredType InstructionTrace = c.getDeclaredTypeOptional(InstructionTrace_Name); // Library API public static final String EagerExportProvider_Name = "com.oracle.truffle.api.library.EagerExportProvider"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index b6fa4be7e3ea..5ea21450f148 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -44,7 +44,6 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 0b93f8bffdf0..cc3226227b67 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -4732,7 +4732,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.end().startElseBlock(); builder.startStatement().string("prev.next_ = "); if (specializedIsNode) { - builder.string("prev.insertAccessor"); + builder.string("prev.", useInsertAccessor(specialization, false)); } builder.string("(cur.next_)").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index ded669a144e0..ddad0c0a5310 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -9,7 +9,6 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -19,7 +18,6 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -100,33 +98,6 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); builderBytecodeNodeType.add(ctor); - CodeVariableElement fldTracer = null; - CodeVariableElement fldHitCount; - if (m.isTracing()) { - fldHitCount = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(int.class)), "hitCount"); - builderBytecodeNodeType.add(fldHitCount); - - fldTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); - builderBytecodeNodeType.add(fldTracer); - } else { - fldHitCount = null; - } - - { - CodeTreeBuilder b = ctor.getBuilder(); - - if (m.isTracing()) { - b.startAssign(fldHitCount).startNewArray( - (ArrayType) fldHitCount.getType(), - CodeTreeBuilder.createBuilder().variable(fldBc).string(".length").build()); - b.end(2); - - b.startAssign(fldTracer).startStaticCall(types.ExecutionTracer, "get"); - b.doubleQuote(ElementUtils.getClassQualifiedName(m.getTemplateType())); - b.end(2); - } - } - { Set copiedLibraries = new HashSet<>(); for (Instruction instr : m.getInstructions()) { @@ -262,6 +233,20 @@ public CodeTypeElement createBuilderBytecodeNode() { cinstr.setNumChildNodes(childIndices.size()); cinstr.setNumConsts(constIndices.size()); cinstr.setPrepareAOTMethod(metPrepareForAOT); + + if (m.isTracing()) { + CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), + "doGetStateBits_" + cinstr.getUniqueName() + "_"); + metGetSpecBits.setEnclosingElement(typBuilderImpl); + typBuilderImpl.add(metGetSpecBits); + + metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc")); + metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); + CodeTreeBuilder b = metGetSpecBits.createBuilder(); + b.tree(plugs.createGetSpecializationBits()); + + cinstr.setGetSpecializationBits(metGetSpecBits); + } } } @@ -299,8 +284,17 @@ public CodeTypeElement createBuilderBytecodeNode() { b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); + CodeVariableElement varTracer; + if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "startFunction").string("this").end(2); + varTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); + b.startAssign("ExecutionTracer " + varTracer.getName()).startStaticCall(types.ExecutionTracer, "get"); + b.typeLiteral(m.getTemplateType().asType()); + b.end(2); + + b.startStatement().startCall(varTracer, "startFunction").string("this").end(2); + } else { + varTracer = null; } CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); @@ -317,6 +311,7 @@ public CodeTypeElement createBuilderBytecodeNode() { vars.frame = argFrame; vars.sp = varSp; vars.returnValue = varReturnValue; + vars.tracer = varTracer; b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(fldBc, varBci)); @@ -326,10 +321,6 @@ public CodeTypeElement createBuilderBytecodeNode() { b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); - if (m.isTracing()) { - b.startStatement().variable(fldHitCount).string("[bci]++").end(); - } - b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); b.startBlock(); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); @@ -347,10 +338,9 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startBlock(); if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceInstruction"); + b.startStatement().startCall(varTracer, "traceInstruction"); b.variable(varBci); - b.doubleQuote(op.name); - b.trees(op.createTracingArguments(vars)); + b.variable(op.opcodeIdField); b.end(2); } @@ -384,12 +374,11 @@ public CodeTypeElement createBuilderBytecodeNode() { b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); - if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "traceException"); - b.string("ex"); - b.end(2); - - } + // if (m.isTracing()) { + // b.startStatement().startCall(fldTracer, "traceException"); + // b.string("ex"); + // b.end(2); + // } b.startFor().string("int handlerIndex = 0; handlerIndex < " + fldHandlers.getName() + ".length; handlerIndex++").end(); b.startBlock(); @@ -423,11 +412,14 @@ public CodeTypeElement createBuilderBytecodeNode() { b.end(); // while block if (m.isTracing()) { - b.startStatement().startCall(fldTracer, "endFunction").end(2); + b.startStatement().startCall(varTracer, "endFunction"); + b.string("this"); + b.end(2); } b.startReturn().string("returnValue").end(); + vars.tracer = null; vars.bci = null; vars.nextBci = null; vars.frame = null; @@ -483,10 +475,6 @@ public CodeTypeElement createBuilderBytecodeNode() { b.startWhile().string("bci < bc.length").end(); b.startBlock(); // while block - if (m.isTracing()) { - b.statement("sb.append(String.format(\" [ %3d ]\", hitCount[bci]))"); - } - b.statement("sb.append(String.format(\" %04x \", bci))"); b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { @@ -560,51 +548,6 @@ public CodeTypeElement createBuilderBytecodeNode() { } - if (m.isTracing()) { - CodeExecutableElement mGetTrace = GeneratorUtils.override(types.OperationsNode, "getNodeTrace"); - builderBytecodeNodeType.add(mGetTrace); - - CodeTreeBuilder b = mGetTrace.getBuilder(); - - b.declaration("int", "bci", "0"); - b.declaration("ArrayList", "insts", "new ArrayList<>()"); - - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - - b.startWhile().string("bci < bc.length").end(); - b.startBlock(); // while block - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - if (op == null) { - builder.startThrow().startNew(context.getType(IllegalArgumentException.class)).doubleQuote("Unknown opcode").end(2); - return builder.build(); - } - - builder.startStatement(); - builder.startCall("insts", "add"); - builder.startNew(types.InstructionTrace); - - builder.variable(op.opcodeIdField); - builder.startGroup().variable(fldHitCount).string("[bci]").end(); - - builder.end(3); - - builder.statement("bci += " + op.length()); - builder.statement("break"); - - return builder.build(); - })); - - b.end(); // while block - - b.startReturn().startNew(types.NodeTrace); - b.startCall("insts", "toArray").string("new InstructionTrace[0]").end(); - b.end(2); - - vars.bci = null; - } - { CodeExecutableElement mGetSourceSection = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); builderBytecodeNodeType.add(mGetSourceSection); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index fe9dff847e30..f6af47fb1761 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -368,19 +368,19 @@ public boolean createCallSpecialization(FrameState frameState, SpecializationDat if (isVariadic || inBoundary) return false; - if (m.isTracing()) { - b.startStatement().startCall("tracer", "traceSpecialization"); - b.string("$bci"); - b.doubleQuote(cinstr.name); - b.string("" + specialization.getIntrospectionIndex()); - for (int i = 0; i < bindings.length; i++) { - Parameter parameter = specialization.getParameters().get(i); - if (parameter.getSpecification().isSignature()) { - b.tree(bindings[i]); - } - } - b.end(2); - } + // if (m.isTracing()) { + // b.startStatement().startCall("tracer", "traceSpecialization"); + // b.string("$bci"); + // b.variable(cinstr.opcodeIdField); + // b.string("" + specialization.getIntrospectionIndex()); + // for (int i = 0; i < bindings.length; i++) { + // Parameter parameter = specialization.getParameters().get(i); + // if (parameter.getSpecification().isSignature()) { + // b.tree(bindings[i]); + // } + // } + // b.end(2); + // } createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); return true; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 0cc6b0d6df24..5c9c5c5d1ecc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -16,7 +16,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -148,28 +147,42 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mStaticInit.appendBuilder(); - b.startAssign("ExecutionTracer tracer").startStaticCall(types.ExecutionTracer, "get"); - b.doubleQuote(ElementUtils.getClassQualifiedName(m.getTemplateType())); - b.end(2); + b.startStatement().startStaticCall(types.ExecutionTracer, "initialize"); + + b.typeLiteral(m.getTemplateType().asType()); - b.startStatement().startCall("tracer", "setOutputPath"); + // destination path b.doubleQuote(decisionsFilePath); - b.end(2); + // instruction names + b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); + b.string("null"); + for (Instruction instr : m.getInstructions()) { + b.doubleQuote(instr.name); + } + b.end(); + + // specialization names + + b.startNewArray(new ArrayCodeTypeMirror(new ArrayCodeTypeMirror(context.getType(String.class))), null); + b.string("null"); for (Instruction instr : m.getInstructions()) { if (!(instr instanceof CustomInstruction)) { + b.string("null"); continue; } + b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); CustomInstruction cinstr = (CustomInstruction) instr; - - b.startStatement().startCall("tracer", "setInstructionSpecializationNames"); - b.doubleQuote(cinstr.name); for (String name : cinstr.getSpecializationNames()) { b.doubleQuote(name); } - b.end(2); + b.end(); } + b.end(); + + b.end(2); + } } @@ -902,19 +915,7 @@ public List create(ProcessorContext context, AnnotationProcesso String simpleName = m.getTemplateType().getSimpleName() + "Builder"; - try { - return List.of(createBuilder(simpleName)); - } catch (Exception e) { - CodeTypeElement el = GeneratorUtils.createClass(m, null, MOD_PUBLIC_ABSTRACT, simpleName, null); - CodeTreeBuilder b = el.createDocBuilder(); - - b.lineComment(e.getClass().getName() + ": " + e.getMessage()); - for (StackTraceElement ste : e.getStackTrace()) { - b.lineComment(" at " + ste.toString()); - } - - return List.of(el); - } + return List.of(createBuilder(simpleName)); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 92c9ae5b8f70..bef9b65fd494 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -143,6 +143,19 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (vars.tracer != null) { + b.startStatement().startCall(vars.tracer, "traceActiveSpecializations"); + b.variable(vars.bci); + b.variable(opcodeIdField); + + b.startStaticCall(getSpecializationBits); + b.variable(vars.bc); + b.variable(vars.bci); + b.end(); + + b.end(2); + } + if (data.getMainProperties().isVariadic) { b.declaration("int", "numVariadics", "LE_BYTES.getShort(bc, bci + " + getArgumentOffset(inputs.length - 1) + ")"); @@ -263,7 +276,6 @@ public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits public void setBoxingEliminationData(int boxingEliminationBitOffset, int boxingEliminationBitMask) { this.boxingEliminationBitOffset = boxingEliminationBitOffset; this.boxingEliminationBitMask = boxingEliminationBitMask; - } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index c2ed2621ae87..a178414cd36e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -2,8 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class DiscardInstruction extends Instruction { public DiscardInstruction(String name, int id, InputType input) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 338bf941c01c..ff2cdeb40007 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -30,6 +30,7 @@ public static class ExecutionVariables { public CodeVariableElement[] results; public CodeVariableElement probeNodes; + public CodeVariableElement tracer; } public static enum InputType { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 8aa91d30dd38..029eae90e456 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -2,8 +2,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class StoreLocalInstruction extends Instruction { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 38c93a306dde..b86f1307b426 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,7 +7,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class SuperInstruction extends Instruction { private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java index f108cb47d597..f5a51626b685 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java @@ -122,6 +122,7 @@ import com.oracle.truffle.api.nodes.LanguageInfo; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.tracing.OperationsStatistics; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.polyglot.PolyglotContextConfig.PreinitConfig; import com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference; @@ -210,6 +211,7 @@ final class PolyglotEngineImpl implements com.oracle.truffle.polyglot.PolyglotIm private volatile int asynchronousStackDepth = 0; final SpecializationStatistics specializationStatistics; + final OperationsStatistics operationStatistics; Function engineLoggerSupplier; // effectively final private volatile TruffleLogger engineLogger; @@ -311,6 +313,12 @@ final class PolyglotEngineImpl implements com.oracle.truffle.polyglot.PolyglotIm this.specializationStatistics = null; } + if (this.engineOptionValues.hasBeenSet(PolyglotEngineOptions.OperationsTracingState)) { + this.operationStatistics = OperationsStatistics.create(this.engineOptionValues.get(PolyglotEngineOptions.OperationsTracingState)); + } else { + this.operationStatistics = null; + } + notifyCreated(); if (!preInitialization) { @@ -515,6 +523,12 @@ void notifyCreated() { this.specializationStatistics = null; } + if (this.engineOptionValues.hasBeenSet(PolyglotEngineOptions.OperationsTracingState)) { + this.operationStatistics = OperationsStatistics.create(this.engineOptionValues.get(PolyglotEngineOptions.OperationsTracingState)); + } else { + this.operationStatistics = null; + } + Collection instrumentsToCreate = new ArrayList<>(); for (String instrumentId : idToInstrument.keySet()) { OptionValuesImpl prototypeOptions = prototype.idToInstrument.get(instrumentId).getOptionValuesIfExists(); @@ -1210,6 +1224,10 @@ void ensureClosed(boolean force, boolean inShutdownHook) { getEngineLogger().log(Level.INFO, String.format("Specialization histogram: %n%s", logMessage.toString())); } + if (operationStatistics != null) { + operationStatistics.write(); + } + if (!inShutdownHook) { RUNTIME.onEngineClosed(this.runtimeData); diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java index e9d5b8fb7936..1cf4c5617434 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java @@ -120,6 +120,10 @@ final class PolyglotEngineOptions { "Enables printing of code sharing related information to the logger. This option is intended to support debugging language implementations.")// static final OptionKey TraceCodeSharing = new OptionKey<>(false); + @Option(category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL, help = "" + + "Enables and sets the state file path for Operations tracer") // + static final OptionKey OperationsTracingState = new OptionKey<>(""); + enum StaticObjectStorageStrategies { DEFAULT, ARRAY_BASED, diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotThreadInfo.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotThreadInfo.java index 62091ffc47b2..f83eab7fda82 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotThreadInfo.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotThreadInfo.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.SpecializationStatistics; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.tracing.OperationsStatistics; import com.oracle.truffle.api.utilities.TruffleWeakReference; import com.oracle.truffle.polyglot.PolyglotLocals.LocalLocation; @@ -68,6 +69,7 @@ final class PolyglotThreadInfo { private Object originalContextClassLoader = NULL_CLASS_LOADER; private ClassLoaderEntry prevContextClassLoader; private SpecializationStatisticsEntry executionStatisticsEntry; + private OperationsStatisticsEntry operationsStatisticsEntry; private boolean safepointActive; // only accessed from current thread @CompilationFinal(dimensions = 1) Object[] contextThreadLocals; @@ -145,6 +147,10 @@ void notifyEnter(PolyglotEngineImpl engine, PolyglotContextImpl profiledContext) if (engine.specializationStatistics != null) { enterStatistics(engine.specializationStatistics); } + + if (engine.operationStatistics != null) { + operationsStatisticsEntry = new OperationsStatisticsEntry(engine.operationStatistics.enter(), operationsStatisticsEntry); + } } boolean isPolyglotThread(PolyglotContextImpl c) { @@ -173,6 +179,10 @@ void notifyLeave(PolyglotEngineImpl engine, PolyglotContextImpl profiledContext) if (engine.specializationStatistics != null) { leaveStatistics(engine.specializationStatistics); } + if (engine.operationStatistics != null) { + engine.operationStatistics.exit(operationsStatisticsEntry.statistics); + operationsStatisticsEntry = operationsStatisticsEntry.next; + } } } @@ -274,4 +284,14 @@ private static final class SpecializationStatisticsEntry { } } + private static final class OperationsStatisticsEntry { + final OperationsStatistics statistics; + final OperationsStatisticsEntry next; + + OperationsStatisticsEntry(OperationsStatistics statistics, OperationsStatisticsEntry next) { + this.statistics = statistics; + this.next = next; + } + } + } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index f0db00be48d1..0c39f8ce42c4 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -1,62 +1,52 @@ [ - { - "specializations": ["FromLong"], - "id": "q-SLUnboxOperation-FromLong", - "type": "Quicken", - "operation": "SLUnboxOperation" - }, - { - "specializations": ["AddLong"], - "id": "q-SLAddOperation-AddLong", - "type": "Quicken", - "operation": "SLAddOperation" - }, - { - "specializations": ["ReadSLObject0"], - "id": "q-SLReadPropertyOperation-ReadSLObject0", - "type": "Quicken", - "operation": "SLReadPropertyOperation" - }, - { - "specializations": ["FromBoolean"], - "id": "q-SLUnboxOperation-FromBoolean", - "type": "Quicken", - "operation": "SLUnboxOperation" - }, - { - "specializations": ["Boolean"], - "id": "q-SLConvertToBoolean-Boolean", - "type": "Quicken", - "operation": "SLToBooleanOperation" - }, - { - "specializations": ["LessOrEqual0"], - "id": "q-SLLessOrEqualOperation-LessOrEqual0", - "type": "Quicken", - "operation": "SLLessOrEqualOperation" - }, - { - "specializations": ["Direct"], - "id": "q-SLInvokeOperation-Direct", - "type": "Quicken", - "operation": "SLInvokeOperation" - }, - { - "specializations": ["Perform"], - "id": "q-SLFunctionLiteralOperation-SingleContext", - "type": "Quicken", - "operation": "SLFunctionLiteralOperation" - }, - { - "specializations": ["WriteSLObject0"], - "id": "q-SLWritePropertyOperation-WriteSLObject0", - "type": "Quicken", - "operation": "SLWritePropertyOperation" - }, - { - "specializations": ["LessThan0"], - "id": "q-SLLessThanOperation-LessThan0", - "type": "Quicken", - "operation": "SLLessThanOperation" - } + { + "specializations": ["FromLong"], + "type": "Quicken", + "operation": "SLUnboxOperation" + }, + { + "specializations": ["AddLong"], + "type": "Quicken", + "operation": "SLAddOperation" + }, + { + "specializations": ["ReadSLObject0"], + "type": "Quicken", + "operation": "SLReadPropertyOperation" + }, + { + "specializations": ["FromBoolean"], + "type": "Quicken", + "operation": "SLUnboxOperation" + }, + { + "specializations": ["Boolean"], + "type": "Quicken", + "operation": "SLToBooleanOperation" + }, + { + "specializations": ["LessOrEqual0"], + "type": "Quicken", + "operation": "SLLessOrEqualOperation" + }, + { + "specializations": ["Direct"], + "type": "Quicken", + "operation": "SLInvokeOperation" + }, + { + "specializations": ["Perform"], + "type": "Quicken", + "operation": "SLFunctionLiteralOperation" + }, + { + "specializations": ["WriteSLObject0"], + "type": "Quicken", + "operation": "SLWritePropertyOperation" + }, + { + "specializations": ["LessThan0"], + "type": "Quicken", + "operation": "SLLessThanOperation" + } ] \ No newline at end of file From 003e788fccc25517bfa27b22c0c4c2f89a657809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 4 May 2022 09:33:54 +0200 Subject: [PATCH 070/312] [wip] random fixes --- .../sl/operations/SLOperationsBuilder.java | 1520 +++++------------ .../example/TestOperationsParserTest.java | 2 - .../api/operation/GenerateOperations.java | 2 + .../tracing/OperationsStatistics.java | 3 + .../generator/NodeCodeGenerator.java | 2 +- .../generator/NodeGeneratorPlugs.java | 2 + .../processor/generator/StaticConstants.java | 16 + .../operations/OperationDecisions.java | 19 +- .../OperationsBytecodeCodeGenerator.java | 26 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 12 +- .../operations/OperationsCodeGenerator.java | 2 +- .../operations/OperationsParser.java | 20 +- .../instructions/QuickenedInstruction.java | 4 +- .../truffle/sl/operations/SLOperations.java | 6 +- 14 files changed, 470 insertions(+), 1166 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 242dcc36c29b..fc760b13ec20 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -35,6 +35,7 @@ import com.oracle.truffle.api.operation.OperationsBytesSupport; import com.oracle.truffle.api.operation.OperationsConstantPool; import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -198,7 +199,7 @@ public static OperationsNode[] parseWithSourceInfo(SLLanguage language, SLSource } @GeneratedBy(SLOperations.class) - @SuppressWarnings({"cast", "hiding", "unchecked", "rawtypes"}) + @SuppressWarnings({"cast", "hiding", "unchecked", "rawtypes", "static-method"}) private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); @@ -235,15 +236,15 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_LOAD_CONSTANT_OBJECT = 4; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 5; - private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_CONSTANT_LONG = 5; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 7; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 8; - private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_LOAD_ARGUMENT_LONG = 8; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; private static final int INSTR_STORE_LOCAL = 10; private static final int INSTR_LOAD_LOCAL_OBJECT = 11; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 12; - private static final int INSTR_LOAD_LOCAL_LONG = 13; + private static final int INSTR_LOAD_LOCAL_LONG = 12; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; private static final int INSTR_RETURN = 14; private static final int INSTR_INSTRUMENT_ENTER = 15; private static final int INSTR_INSTRUMENT_EXIT_VOID = 16; @@ -264,29 +265,19 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 31; private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 32; private static final int INSTR_C_SLINVOKE_OPERATION = 33; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 34; - private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 35; - private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 36; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 37; - private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 38; - private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 39; - private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 40; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 41; - private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; - private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // DOUBLE null}; @@ -305,6 +296,10 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { int nodeNumber = 0; OperationsConstantPool constPool = new OperationsConstantPool(); + static { + ExecutionTracer.initialize(SLOperations.class, "/home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json", new String[] {null, "pop", "branch", "branch.false", "load.constant.object", "load.constant.long", "load.constant.boolean", "load.argument.object", "load.argument.long", "load.argument.boolean", "store.local", "load.local.object", "load.local.long", "load.local.boolean", "return", "instrument.enter", "instrument.exit.void", "instrument.exit", "instrument.leave", "c.SLAddOperation", "c.SLDivOperation", "c.SLEqualOperation", "c.SLLessOrEqualOperation", "c.SLLessThanOperation", "c.SLLogicalNotOperation", "c.SLMulOperation", "c.SLReadPropertyOperation", "c.SLSubOperation", "c.SLWritePropertyOperation", "c.SLUnboxOperation", "c.SLFunctionLiteralOperation", "c.SLToBooleanOperation", "c.SLEvalRootOperation", "c.SLInvokeOperation"}, new String[][] {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, new String[] {"AddLong", "Add0", "Add1", "Fallback"}, new String[] {"DivLong", "Div", "Fallback"}, new String[] {"Long", "BigNumber", "Boolean", "String", "TruffleString", "Null", "Function", "Generic0", "Generic1", "Fallback"}, new String[] {"LessOrEqual0", "LessOrEqual1", "Fallback"}, new String[] {"LessThan0", "LessThan1", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"MulLong", "Mul", "Fallback"}, new String[] {"ReadArray0", "ReadArray1", "ReadSLObject0", "ReadSLObject1", "ReadObject0", "ReadObject1", "Fallback"}, new String[] {"SubLong", "Sub", "Fallback"}, new String[] {"WriteArray0", "WriteArray1", "WriteSLObject0", "WriteSLObject1", "WriteObject0", "WriteObject1", "Fallback"}, new String[] {"FromString", "FromTruffleString", "FromBoolean", "FromLong", "FromBigNumber", "FromFunction0", "FromFunction1", "FromForeign0", "FromForeign1", "Fallback"}, new String[] {"Perform", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Execute", "Fallback"}, new String[] {"Direct", "Indirect", "Interop", "Fallback"}}); + } + SLOperationsBuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { this.language = language; this.parseContext = parseContext; @@ -1404,6 +1399,157 @@ public void endSLInvokeOperation() { doAfterChild(); } + private static boolean[] doGetStateBits_SLAddOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[4]; + result[0] = ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + result[1] = ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */); + result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */); + return result; + } + + private static boolean[] doGetStateBits_SLDivOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLEqualOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + byte state_1 = bc[$bci + 4 + 1]; + boolean[] result = new boolean[9]; + result[0] = ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); + result[1] = ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); + result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */); + result[4] = ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + result[5] = ((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */); + result[6] = ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */); + result[7] = ((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + result[8] = ((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + return result; + } + + private static boolean[] doGetStateBits_SLLessOrEqualOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLLessThanOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLLogicalNotOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 3 + 0]; + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLMulOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLReadPropertyOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[6]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[3] = (state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[4] = (state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + result[5] = (state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + return result; + } + + private static boolean[] doGetStateBits_SLSubOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 4 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLWritePropertyOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 5 + 0]; + boolean[] result = new boolean[6]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[3] = (state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[4] = (state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + result[5] = (state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + return result; + } + + private static boolean[] doGetStateBits_SLUnboxOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 3 + 0]; + byte state_1 = bc[$bci + 3 + 1]; + boolean[] result = new boolean[9]; + result[0] = ((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */); + result[1] = ((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */); + result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + result[4] = ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */); + result[5] = ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */); + result[6] = ((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */); + result[7] = ((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */); + result[8] = ((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */); + return result; + } + + private static boolean[] doGetStateBits_SLFunctionLiteralOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 3 + 0]; + boolean[] result = new boolean[1]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + return result; + } + + private static boolean[] doGetStateBits_SLToBooleanOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 3 + 0]; + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLEvalRootOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 3 + 0]; + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */; + return result; + } + + private static boolean[] doGetStateBits_SLInvokeOperation_(byte[] bc, int $bci) { + byte state_0 = bc[$bci + 5 + 0]; + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + result[1] = (state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; + result[2] = (state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */; + return result; + } + private static OperationsNode reparse(SLLanguage language, SLSource context, int buildOrder) { SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); @@ -1436,13 +1582,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: @@ -1454,13 +1600,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: @@ -1478,13 +1624,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: @@ -1757,184 +1903,18 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Interop * Fallback * - * c.SLUnboxOperation.q.FromLong - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLAddOperation.q.AddLong - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * AddLong - * Add0 - * Add1 - * Fallback - * - * c.SLReadPropertyOperation.q.ReadSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * ReadArray0 - * ReadArray1 - * ReadSLObject0 - * ReadSLObject1 - * ReadObject0 - * ReadObject1 - * Fallback - * - * c.SLUnboxOperation.q.FromBoolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLToBooleanOperation.q.Boolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLLessOrEqualOperation.q.LessOrEqual0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessOrEqual0 - * LessOrEqual1 - * Fallback - * - * c.SLInvokeOperation.q.Direct - * Inputs: - * STACK_VALUE - * VARARG_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * Direct - * Indirect - * Interop - * Fallback - * - * c.SLFunctionLiteralOperation.q.Perform - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * Specializations: - * Perform - * Fallback - * - * c.SLWritePropertyOperation.q.WriteSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * WriteArray0 - * WriteArray1 - * WriteSLObject0 - * WriteSLObject1 - * WriteObject0 - * WriteObject1 - * Fallback - * - * c.SLLessThanOperation.q.LessThan0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessThan0 - * LessThan1 - * Fallback - * */ @GeneratedBy(SLOperations.class) private static final class SLOperationsBuilderImplBytecodeNode extends OperationsNode implements Provider { private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY__ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY___ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY__ = LibraryFactory.resolve(DynamicObjectLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY____ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY_____ = LibraryFactory.resolve(InteropLibrary.class); @CompilationFinal(dimensions = 1) private final byte[] bc; @CompilationFinal(dimensions = 1) private final Object[] consts; @@ -2088,11 +2068,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - } int type0; int type1; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { @@ -2141,7 +2116,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2164,7 +2138,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2183,7 +2156,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2994,11 +2966,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); - } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { @@ -3031,7 +2998,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3056,7 +3022,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3175,11 +3140,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); - } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { @@ -3212,7 +3172,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3237,7 +3196,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3597,7 +3555,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int Node prev_ = encapsulating_.set(this); try { { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); if ((readArray1_arrays__.hasArrayElements($child0Value_))) { $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; @@ -3645,7 +3603,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int Node prev_ = encapsulating_.set(this); try { if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); if ((readObject1_objects__.hasMembers($child0Value_))) { $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; @@ -3668,8 +3626,8 @@ private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, by { Node readArray1_node__ = (this); int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); } } @@ -3691,7 +3649,7 @@ private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, b { Node readObject1_node__ = (this); int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); } } @@ -3722,7 +3680,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } if (s0_ == null) { { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { @@ -3730,11 +3688,10 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, node__ = (this); bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY__.create($child1Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3762,16 +3719,15 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); if ((readArray1_arrays__.hasArrayElements($child0Value))) { readArray1_node__ = (this); readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3819,11 +3775,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - } int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3852,7 +3803,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3885,7 +3835,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if (s4_ == null) { if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); - InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + InteropLibrary objects__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); node__2 = (this); @@ -3895,7 +3845,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3922,7 +3871,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); if ((readObject1_objects__.hasMembers($child0Value))) { readObject1_node__ = (this); readObject1_bci__ = ($bci); @@ -3931,7 +3880,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4191,7 +4139,7 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in Node prev_ = encapsulating_.set(this); try { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); return; @@ -4249,8 +4197,8 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in @TruffleBoundary private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); } } @@ -4259,7 +4207,7 @@ private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, @TruffleBoundary private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value__)); return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); } } @@ -4273,7 +4221,7 @@ private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, { Node writeObject1_node__ = (this); int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value_)); return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); } } finally { @@ -4302,7 +4250,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } if (s0_ == null) { { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY___.create($child0Value))); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { @@ -4310,11 +4258,10 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY___.create($child1Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4342,16 +4289,15 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value))) { children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4390,16 +4336,11 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY__.create($child0Value_))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); - } int type0; int type1; int type2; @@ -4420,13 +4361,12 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } { DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value_)); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4465,12 +4405,11 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); node__ = (this); bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY___.create($child0Value))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4501,13 +4440,12 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { writeObject1_node__ = (this); writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value)); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4599,7 +4537,7 @@ private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte st Node prev_ = encapsulating_.set(this); try { { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value_)); return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); } } finally { @@ -4690,7 +4628,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4703,7 +4640,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc TruffleString $child0Value_ = (TruffleString) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4716,11 +4652,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } int type0; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { type0 = FRAME_TYPE_BOOLEAN; @@ -4742,11 +4673,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc long $child0Value_ = (long) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } int type0; if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { type0 = FRAME_TYPE_LONG; @@ -4771,7 +4697,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4785,7 +4710,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4798,7 +4722,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLNull $child0Value_ = SLTypes.asSLNull($child0Value); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4823,12 +4746,11 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); if (count7_ < (SLUnboxNode.LIMIT)) { s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY____.create($child0Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4847,13 +4769,12 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value)); bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4903,11 +4824,6 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); - } int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4999,11 +4915,6 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); - } int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { type0 = FRAME_TYPE_BOOLEAN; @@ -5027,7 +4938,6 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5179,11 +5089,6 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); - } } } } @@ -5200,7 +5105,6 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); @@ -5208,11 +5112,10 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int { int interop_bci__ = 0; Node interop_node__ = null; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_____.createDispatched(3))); interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); @@ -5250,309 +5153,13 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int } } - private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - @ExplodeLoop - private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @ExplodeLoop - private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); - } - s0_ = s0_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { - Lock lock = getLock(); - lock.lock(); - try { - SLInvokeOperation_DirectData prev = null; - SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - @ExplodeLoop - private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 3); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 2); - Object $child2Value_; - $child2Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @Override protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { int sp = startSp; int bci = startBci; + ExecutionTracer tracer = ExecutionTracer.get(SLOperations.class); + tracer.startFunction(this); Object returnValue = null; loop: while (true) { int nextBci; @@ -5567,6 +5174,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { switch (curOpcode) { case INSTR_POP : { + tracer.traceInstruction(bci, INSTR_POP); sp = sp - 1; frame.clear(sp); nextBci = bci + 2; @@ -5574,6 +5182,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_BRANCH : { + tracer.traceInstruction(bci, INSTR_BRANCH); int targetBci = LE_BYTES.getShort(bc, bci + 2); if (targetBci <= bci) { TruffleSafepoint.poll(this); @@ -5589,6 +5198,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_BRANCH_FALSE : { + tracer.traceInstruction(bci, INSTR_BRANCH_FALSE); ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; boolean cond = (boolean) frame.getObject(sp - 1); sp -= 1; @@ -5602,38 +5212,43 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_CONSTANT_OBJECT : { + tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_OBJECT); frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_LONG); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_BOOLEAN); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } case INSTR_LOAD_ARGUMENT_OBJECT : { + tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_OBJECT); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; frame.setObject(sp, value); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { + tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_LONG); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5641,11 +5256,12 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { + tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_BOOLEAN); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -5655,6 +5271,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_STORE_LOCAL : { + tracer.traceInstruction(bci, INSTR_STORE_LOCAL); assert frame.isObject(sp - 1); frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); frame.clear(--sp); @@ -5663,16 +5280,18 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_LOCAL_OBJECT : { + tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_OBJECT); frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); sp++; nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { + tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_LONG); Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5680,11 +5299,12 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { + tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_BOOLEAN); Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -5694,11 +5314,14 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_RETURN : { + tracer.traceInstruction(bci, INSTR_RETURN); returnValue = frame.getObject(sp - 1); break loop; } case INSTR_C_SLADD_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLADD_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLADD_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLAddOperation_(bc, bci)); this.SLAddOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; @@ -5706,6 +5329,8 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLDIV_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLDIV_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLDIV_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLDivOperation_(bc, bci)); this.SLDivOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; @@ -5713,6 +5338,8 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLEQUAL_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLEQUAL_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLEQUAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLEqualOperation_(bc, bci)); this.SLEqualOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; @@ -5720,6 +5347,8 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLESS_OR_EQUAL_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLLESS_OR_EQUAL_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLLESS_OR_EQUAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLessOrEqualOperation_(bc, bci)); this.SLLessOrEqualOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; @@ -5727,6 +5356,8 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLESS_THAN_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLLESS_THAN_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLLESS_THAN_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLessThanOperation_(bc, bci)); this.SLLessThanOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; @@ -5734,158 +5365,101 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLOGICAL_NOT_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLLOGICAL_NOT_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLLOGICAL_NOT_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLogicalNotOperation_(bc, bci)); this.SLLogicalNotOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; break; } - case INSTR_C_SLMUL_OPERATION : - { - this.SLMulOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION : - { - this.SLReadPropertyOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLSUB_OPERATION : - { - this.SLSubOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : - { - this.SLWritePropertyOperation_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX_OPERATION : - { - this.SLUnboxOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - { - this.SLFunctionLiteralOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLTO_BOOLEAN_OPERATION : - { - this.SLToBooleanOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLEVAL_ROOT_OPERATION : - { - this.SLEvalRootOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLINVOKE_OPERATION : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + case INSTR_C_SLMUL_OPERATION : { - this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); - sp = sp - 1 + 1; + tracer.traceInstruction(bci, INSTR_C_SLMUL_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLMUL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLMulOperation_(bc, bci)); + this.SLMulOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION : + { + tracer.traceInstruction(bci, INSTR_C_SLREAD_PROPERTY_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLREAD_PROPERTY_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLReadPropertyOperation_(bc, bci)); + this.SLReadPropertyOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; nextBci = bci + 10; break; } - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : + case INSTR_C_SLSUB_OPERATION : { - this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); + tracer.traceInstruction(bci, INSTR_C_SLSUB_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLSUB_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLSubOperation_(bc, bci)); + this.SLSubOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + { + tracer.traceInstruction(bci, INSTR_C_SLWRITE_PROPERTY_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLWRITE_PROPERTY_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLWritePropertyOperation_(bc, bci)); + this.SLWritePropertyOperation_execute_(frame, bci, sp); + sp = sp - 3 + 1; nextBci = bci + 11; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + case INSTR_C_SLUNBOX_OPERATION : { - this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); - sp = sp - 2 + 1; + tracer.traceInstruction(bci, INSTR_C_SLUNBOX_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLUNBOX_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLUnboxOperation_(bc, bci)); + this.SLUnboxOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; nextBci = bci + 10; break; } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : { - this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); + tracer.traceInstruction(bci, INSTR_C_SLFUNCTION_LITERAL_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLFUNCTION_LITERAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLFunctionLiteralOperation_(bc, bci)); + this.SLFunctionLiteralOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; - nextBci = bci + 10; + nextBci = bci + 6; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + case INSTR_C_SLTO_BOOLEAN_OPERATION : { - this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); + tracer.traceInstruction(bci, INSTR_C_SLTO_BOOLEAN_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLTO_BOOLEAN_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLToBooleanOperation_(bc, bci)); + this.SLToBooleanOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLEVAL_ROOT_OPERATION : { - this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; + tracer.traceInstruction(bci, INSTR_C_SLEVAL_ROOT_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLEVAL_ROOT_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLEvalRootOperation_(bc, bci)); + this.SLEvalRootOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; break; } - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLINVOKE_OPERATION : { + tracer.traceInstruction(bci, INSTR_C_SLINVOKE_OPERATION); + tracer.traceActiveSpecializations(bci, INSTR_C_SLINVOKE_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLInvokeOperation_(bc, bci)); int numVariadics = LE_BYTES.getShort(bc, bci + 3); Object input_0 = frame.getObject(sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; for (int varIndex = 0; varIndex < numVariadics; varIndex++) { input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); } - Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); + Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); sp = sp - 1 - numVariadics + 1; frame.setObject(sp - 1, result); nextBci = bci + 11; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); @@ -5906,6 +5480,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { CompilerAsserts.partialEvaluationConstant(nextBci); bci = nextBci; } + tracer.endFunction(this); return returnValue; } @@ -5922,15 +5497,14 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_BRANCH : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : { bci = bci + 4; break; @@ -5940,8 +5514,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -5950,8 +5524,6 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_STORE_LOCAL : case INSTR_C_SLLESS_OR_EQUAL_OPERATION : case INSTR_C_SLLESS_THAN_OPERATION : - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : { bci = bci + 5; break; @@ -5965,9 +5537,6 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLEQUAL_OPERATION : case INSTR_C_SLWRITE_PROPERTY_OPERATION : case INSTR_C_SLINVOKE_OPERATION : - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : { bci = bci + 11; break; @@ -5976,16 +5545,12 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLMUL_OPERATION : case INSTR_C_SLSUB_OPERATION : case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { bci = bci + 6; break; } case INSTR_C_SLREAD_PROPERTY_OPERATION : case INSTR_C_SLUNBOX_OPERATION : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : { bci = bci + 10; break; @@ -6112,7 +5677,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6130,7 +5695,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6140,7 +5705,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6158,7 +5723,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6193,7 +5758,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6211,14 +5776,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6236,7 +5801,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6285,204 +5850,20 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("load.local.object "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_RETURN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("return"); - bci += 3; - break; - } - case INSTR_C_SLADD_OPERATION : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAddOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLDIV_OPERATION : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDivOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLEQUAL_OPERATION : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqualOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqualOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" "); + sb.append("load.local.object "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); - bci += 5; + bci += 4; break; } - case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6494,16 +5875,15 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLessThanOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" "); + sb.append("load.local.long "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); - bci += 5; + bci += 4; break; } - case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6521,21 +5901,18 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLogicalNotOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append("load.local.boolean "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_C_SLMUL_OPERATION : + case INSTR_RETURN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6546,16 +5923,17 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLMulOperation "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); - sb.append("x"); - bci += 6; + sb.append("return"); + bci += 3; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLADD_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6567,22 +5945,22 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("c.SLReadPropertyOperation "); + sb.append("c.SLAddOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 10; + bci += 11; break; } - case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLDIV_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6600,7 +5978,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLSubOperation "); + sb.append("c.SLDivOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6609,7 +5987,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLEQUAL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6627,50 +6005,49 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLWritePropertyOperation "); + sb.append("c.SLEqualOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); sb.append(" -> "); sb.append("x"); bci += 11; break; } - case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLUnboxOperation "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqualOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 10; + bci += 5; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLLESS_THAN_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6681,14 +6058,17 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLFunctionLiteralOperation "); + sb.append(" "); + sb.append("c.SLLessThanOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 6; + bci += 5; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION : + case INSTR_C_SLLOGICAL_NOT_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6706,19 +6086,21 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLToBooleanOperation "); + sb.append("c.SLLogicalNotOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_C_SLEVAL_ROOT_OPERATION : + case INSTR_C_SLMUL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6729,16 +6111,16 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEvalRootOperation "); + sb.append("c.SLMulOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 6; break; } - case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLREAD_PROPERTY_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6750,22 +6132,22 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLInvokeOperation "); + sb.append(" "); + sb.append("c.SLReadPropertyOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 11; + bci += 10; break; } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + case INSTR_C_SLSUB_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6773,51 +6155,26 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLUnboxOperation.q.FromLong "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLAddOperation.q.AddLong "); + sb.append("c.SLSubOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 11; + bci += 6; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + case INSTR_C_SLWRITE_PROPERTY_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6829,22 +6186,24 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("c.SLReadPropertyOperation.q.ReadSLObject0 "); + sb.append("c.SLWritePropertyOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); sb.append(" -> "); sb.append("x"); - bci += 10; + bci += 11; break; } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + case INSTR_C_SLUNBOX_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6862,19 +6221,21 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLUnboxOperation.q.FromBoolean "); + sb.append("c.SLUnboxOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 10; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6885,22 +6246,19 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBooleanOperation.q.Boolean "); + sb.append("c.SLFunctionLiteralOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 6; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLTO_BOOLEAN_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6912,50 +6270,22 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLessOrEqualOperation.q.LessOrEqual0 "); + sb.append(" "); + sb.append("c.SLToBooleanOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 5; + bci += 4; break; } - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLEVAL_ROOT_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLInvokeOperation.q.Direct "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6966,14 +6296,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLFunctionLiteralOperation.q.Perform "); + sb.append("c.SLEvalRootOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 6; + bci += 4; break; } - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + case INSTR_C_SLINVOKE_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6991,44 +6321,15 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLWritePropertyOperation.q.WriteSLObject0 "); + sb.append("c.SLInvokeOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); sb.append(" -> "); sb.append("x"); bci += 11; break; } - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThanOperation.q.LessThan0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } } sb.append("\n"); } @@ -7128,37 +6429,6 @@ private static boolean SLEvalRootOperation_fallbackGuard__(VirtualFrame $frame, return true; } - private static boolean SLAddOperation_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static boolean SLToBooleanOperation_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLLessOrEqualOperation_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLessThanOperation_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { if (bciOffset != 0) { setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 6f3ba705336d..6920efa67356 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -3,7 +3,6 @@ import static org.junit.Assert.fail; import java.io.IOException; -import java.io.PrintWriter; import java.util.function.Consumer; import org.graalvm.polyglot.Context; @@ -15,7 +14,6 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index c8525f59ca50..2db1871bc230 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -13,4 +13,6 @@ String[] decisionOverrideFiles() default {}; Class[] boxingEliminationTypes() default {}; + + boolean forceTracing() default false; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index d7307fb5f228..4658298f0fbd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -363,6 +363,9 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { public JSONArray serializeDecisions(GlobalOperationStatistics stats) { JSONArray result = new JSONArray(); + result.put("This file is autogenerated by the Operations DSL."); + result.put("Do not modify, as it will be overwritten when running with tracing support."); + result.put("Use the overrides file to alter the optimisation decisions."); int numDecisions = 10; activeSpecializationsMap.entrySet().stream() // .map(e -> { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index ebb520d715bf..86b63e07e900 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -79,7 +79,7 @@ public class NodeCodeGenerator extends CodeTypeElementFactory { @Override public List create(ProcessorContext context, AnnotationProcessor processor, NodeData node) { - StaticConstants constants = new StaticConstants(); + StaticConstants constants = plugs != null ? plugs.createConstants() : new StaticConstants(); List rootTypes = createImpl(context, node, constants); if (rootTypes != null) { if (rootTypes.size() != 1) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 19dbe809b7a4..184635995588 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -80,4 +80,6 @@ CodeTree createAssignExecuteChild( List filterSpecializations(List implementedSpecializations); boolean isStateGuaranteed(boolean stateGuaranteed); + + StaticConstants createConstants(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java index c26e36cdc342..5354afd0cfdb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java @@ -40,9 +40,13 @@ */ package com.oracle.truffle.dsl.processor.generator; +import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import javax.lang.model.element.VariableElement; + import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public final class StaticConstants { @@ -57,4 +61,16 @@ public void clear() { languageReferences.clear(); } + public boolean contains(VariableElement ve) { + return libraries.containsValue(ve) || contextReferences.containsValue(ve) || languageReferences.containsValue(ve); + } + + public List elements() { + List result = new ArrayList<>(); + result.addAll(libraries.values()); + result.addAll(contextReferences.values()); + result.addAll(languageReferences.values()); + return result; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index c48a9dae09e2..63b3f0346b4e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Objects; +import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.tools.utils.json.JSONArray; import com.oracle.truffle.tools.utils.json.JSONObject; @@ -18,12 +19,13 @@ public List getQuicken() { return quicken; } - public OperationDecisions merge(OperationDecisions other) { + public OperationDecisions merge(OperationDecisions other, MessageContainer messager) { for (Quicken q : other.quicken) { if (quicken.contains(q)) { - throw new AssertionError("duplicate decision"); + messager.addWarning("Duplicate optimization decision: %s", q); + } else { + quicken.add(q); } - quicken.add(q); } return this; @@ -88,10 +90,15 @@ public static Quicken deserialize(JSONObject o) { } } - public static OperationDecisions deserialize(JSONArray o) { + public static OperationDecisions deserialize(JSONArray o, MessageContainer messager) { OperationDecisions decisions = new OperationDecisions(); for (int i = 0; i < o.length(); i++) { + if (o.get(i) instanceof String) { + // strings are treated as comments + continue; + } + JSONObject decision = o.getJSONObject(i); switch (decision.getString("type")) { @@ -100,8 +107,8 @@ public static OperationDecisions deserialize(JSONArray o) { decisions.quicken.add(q); break; default: - // TODO error handling - throw new AssertionError("invalid decision type" + decision.getString("type")); + messager.addError("Invalid optimization decision: '%s'", decision.getString("type")); + break; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index ddad0c0a5310..3220c3060ffa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -18,6 +18,7 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; +import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -99,7 +100,7 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(ctor); { - Set copiedLibraries = new HashSet<>(); + StaticConstants staticConstants = new StaticConstants(); for (Instruction instr : m.getInstructions()) { if (!(instr instanceof CustomInstruction)) { continue; @@ -124,7 +125,8 @@ public CodeTypeElement createBuilderBytecodeNode() { innerTypeNames, additionalData, methodNames, isVariadic, additionalDataKinds, - fldConsts, cinstr, childIndices); + fldConsts, cinstr, childIndices, + staticConstants); cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); @@ -163,23 +165,6 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(te); } - for (VariableElement ve : ElementFilter.fieldsIn(result.getEnclosedElements())) { - if (ve.getSimpleName().toString().equals("UNCACHED")) { - continue; - } - if (!ve.getModifiers().containsAll(MOD_PRIVATE_STATIC_FINAL)) { - continue; - } - - if (copiedLibraries.contains(ve.getSimpleName().toString())) { - continue; - } - - copiedLibraries.add(ve.getSimpleName().toString()); - - builderBytecodeNodeType.add(ve); - } - CodeExecutableElement metPrepareForAOT = null; for (CodeExecutableElement exToCopy : execs) { @@ -249,6 +234,9 @@ public CodeTypeElement createBuilderBytecodeNode() { } } + for (CodeVariableElement element : staticConstants.elements()) { + builderBytecodeNodeType.add(element); + } } ExecutionVariables vars = new ExecutionVariables(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index f6af47fb1761..04717a65d79f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -21,6 +21,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.StateBitSet; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -31,12 +32,11 @@ import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.Parameter; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { @@ -51,6 +51,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final CodeVariableElement fldConsts; private final CustomInstruction cinstr; private final List childIndices; + private final StaticConstants staticConstants; private final ProcessorContext context; private final TruffleTypes types; @@ -66,7 +67,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, Set innerTypeNames, List additionalData, Set methodNames, boolean isVariadic, List additionalDataKinds, CodeVariableElement fldConsts, CustomInstruction cinstr, - List childIndices) { + List childIndices, StaticConstants staticConstants) { this.m = m; this.fldBc = fldBc; this.fldChildren = fldChildren; @@ -79,6 +80,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator this.fldConsts = fldConsts; this.cinstr = cinstr; this.childIndices = childIndices; + this.staticConstants = staticConstants; this.context = ProcessorContext.getInstance(); this.types = context.getTypes(); @@ -712,4 +714,8 @@ public void finishUp() { cinstr.setBoxingEliminationData(cinstr.lengthWithoutState() + bitSetOffset(targetSet), 1 << offset); } + + public StaticConstants createConstants() { + return staticConstants; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 5c9c5c5d1ecc..e6aa38963c9c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -84,7 +84,7 @@ CodeTypeElement createBuilder(String simpleName) { CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); - GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked", "rawtypes"); + GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked", "rawtypes", "static-method"); { CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index ab69b4f8350d..5154cb7eeadf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -138,7 +138,15 @@ protected OperationsData parse(Element element, List mirror) { data.setDecisionsFilePath(getMainDecisionsFilePath(typeElement, generateOperationsMirror)); - boolean isTracing = TruffleProcessorOptions.operationsEnableTracing(processingEnv); + AnnotationValue forceTracingValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing"); + + boolean isTracing; + if ((boolean) forceTracingValue.getValue()) { + isTracing = true; + data.addWarning("Tracing compilation is forced. This should only be used during development."); + } else { + isTracing = TruffleProcessorOptions.operationsEnableTracing(processingEnv); + } if (!isTracing) { OperationDecisions decisions = parseDecisions(typeElement, generateOperationsMirror, data); @@ -188,12 +196,12 @@ private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror return null; } - List overrideFiles = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionOverrideFiles").getValue(); + List overrideFiles = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionOverrideFiles").getValue(); - for (String overrideFile : overrideFiles) { - OperationDecisions overrideDecision = parseDecisions(element, overrideFile, data, false); + for (AnnotationValue overrideFile : overrideFiles) { + OperationDecisions overrideDecision = parseDecisions(element, (String) overrideFile.getValue(), data, false); if (overrideDecision != null) { - mainDecisions.merge(overrideDecision); + mainDecisions.merge(overrideDecision, data); } } @@ -205,7 +213,7 @@ private OperationDecisions parseDecisions(TypeElement element, String path, Oper try { FileInputStream fi = new FileInputStream(target); JSONArray o = new JSONArray(new JSONTokener(fi)); - return OperationDecisions.deserialize(o); + return OperationDecisions.deserialize(o, data); } catch (FileNotFoundException ex) { if (isMain) { data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", path); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 8a15efb49958..e31db1be69f4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -53,7 +53,7 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData this.activeSpecNames = activeSpecNames; if (activeSpecNames.isEmpty()) { - data.addError("Invalid quickened instruction %s: no specializations defined.", data.getName()); + data.addWarning("Invalid quickened instruction %s: no specializations defined.", data.getName()); activeSpecs = null; return; } @@ -71,7 +71,7 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData } List realSpecNames = data.getNodeData().getSpecializations().stream().map(x -> x.getId()).toList(); - data.addError("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); + data.addWarning("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); hasErrors = true; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index f73395fcd6cd..c25216fd10be 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -47,7 +47,11 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) +@GenerateOperations(// + decisionsFile = "decisions.json", // + decisionOverrideFiles = {"decisions-manual.json"}, // + boxingEliminationTypes = {long.class, boolean.class}, // + forceTracing = true) @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) From a40fc8f1c363d4de2bc42a3bb7f54c31ba889d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 4 May 2022 09:48:15 +0200 Subject: [PATCH 071/312] [wip] stuff --- .../sl/operations/SLOperationsBuilder.java | 1388 +++++++++++++---- .../tracing/OperationsStatistics.java | 6 - .../operations/OperationsParser.java | 2 +- .../truffle/sl/operations/SLOperations.java | 4 +- .../sl/operations/decisions-manual.json | 30 - .../truffle/sl/operations/decisions.json | 3 + 6 files changed, 1070 insertions(+), 363 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index fc760b13ec20..db3a903078f6 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -35,7 +35,6 @@ import com.oracle.truffle.api.operation.OperationsBytesSupport; import com.oracle.truffle.api.operation.OperationsConstantPool; import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -265,19 +264,29 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 31; private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 32; private static final int INSTR_C_SLINVOKE_OPERATION = 33; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 34; + private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 35; + private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 36; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 37; + private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 38; + private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 39; + private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 40; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 41; + private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; + private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; @@ -296,10 +305,6 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { int nodeNumber = 0; OperationsConstantPool constPool = new OperationsConstantPool(); - static { - ExecutionTracer.initialize(SLOperations.class, "/home/prof/graalvm/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json", new String[] {null, "pop", "branch", "branch.false", "load.constant.object", "load.constant.long", "load.constant.boolean", "load.argument.object", "load.argument.long", "load.argument.boolean", "store.local", "load.local.object", "load.local.long", "load.local.boolean", "return", "instrument.enter", "instrument.exit.void", "instrument.exit", "instrument.leave", "c.SLAddOperation", "c.SLDivOperation", "c.SLEqualOperation", "c.SLLessOrEqualOperation", "c.SLLessThanOperation", "c.SLLogicalNotOperation", "c.SLMulOperation", "c.SLReadPropertyOperation", "c.SLSubOperation", "c.SLWritePropertyOperation", "c.SLUnboxOperation", "c.SLFunctionLiteralOperation", "c.SLToBooleanOperation", "c.SLEvalRootOperation", "c.SLInvokeOperation"}, new String[][] {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, new String[] {"AddLong", "Add0", "Add1", "Fallback"}, new String[] {"DivLong", "Div", "Fallback"}, new String[] {"Long", "BigNumber", "Boolean", "String", "TruffleString", "Null", "Function", "Generic0", "Generic1", "Fallback"}, new String[] {"LessOrEqual0", "LessOrEqual1", "Fallback"}, new String[] {"LessThan0", "LessThan1", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"MulLong", "Mul", "Fallback"}, new String[] {"ReadArray0", "ReadArray1", "ReadSLObject0", "ReadSLObject1", "ReadObject0", "ReadObject1", "Fallback"}, new String[] {"SubLong", "Sub", "Fallback"}, new String[] {"WriteArray0", "WriteArray1", "WriteSLObject0", "WriteSLObject1", "WriteObject0", "WriteObject1", "Fallback"}, new String[] {"FromString", "FromTruffleString", "FromBoolean", "FromLong", "FromBigNumber", "FromFunction0", "FromFunction1", "FromForeign0", "FromForeign1", "Fallback"}, new String[] {"Perform", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Execute", "Fallback"}, new String[] {"Direct", "Indirect", "Interop", "Fallback"}}); - } - SLOperationsBuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { this.language = language; this.parseContext = parseContext; @@ -1399,157 +1404,6 @@ public void endSLInvokeOperation() { doAfterChild(); } - private static boolean[] doGetStateBits_SLAddOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[4]; - result[0] = ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - result[1] = ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */); - result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */); - return result; - } - - private static boolean[] doGetStateBits_SLDivOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLEqualOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 1]; - boolean[] result = new boolean[9]; - result[0] = ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); - result[1] = ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); - result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */); - result[4] = ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - result[5] = ((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */); - result[6] = ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */); - result[7] = ((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - result[8] = ((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - return result; - } - - private static boolean[] doGetStateBits_SLLessOrEqualOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLLessThanOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLLogicalNotOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 3 + 0]; - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLMulOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLReadPropertyOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[6]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[3] = (state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[4] = (state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - result[5] = (state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - return result; - } - - private static boolean[] doGetStateBits_SLSubOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 4 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLWritePropertyOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 5 + 0]; - boolean[] result = new boolean[6]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[3] = (state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[4] = (state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - result[5] = (state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - return result; - } - - private static boolean[] doGetStateBits_SLUnboxOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 3 + 0]; - byte state_1 = bc[$bci + 3 + 1]; - boolean[] result = new boolean[9]; - result[0] = ((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */); - result[1] = ((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */); - result[2] = ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - result[3] = ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - result[4] = ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */); - result[5] = ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */); - result[6] = ((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */); - result[7] = ((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */); - result[8] = ((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */); - return result; - } - - private static boolean[] doGetStateBits_SLFunctionLiteralOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 3 + 0]; - boolean[] result = new boolean[1]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - return result; - } - - private static boolean[] doGetStateBits_SLToBooleanOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 3 + 0]; - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLEvalRootOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 3 + 0]; - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */; - return result; - } - - private static boolean[] doGetStateBits_SLInvokeOperation_(byte[] bc, int $bci) { - byte state_0 = bc[$bci + 5 + 0]; - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - result[1] = (state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; - result[2] = (state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */; - return result; - } - private static OperationsNode reparse(SLLanguage language, SLSource context, int buildOrder) { SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); @@ -1903,6 +1757,177 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Interop * Fallback * + * c.SLUnboxOperation.q.FromLong + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLAddOperation.q.AddLong + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * AddLong + * Add0 + * Add1 + * Fallback + * + * c.SLReadPropertyOperation.q.ReadSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * ReadArray0 + * ReadArray1 + * ReadSLObject0 + * ReadSLObject1 + * ReadObject0 + * ReadObject1 + * Fallback + * + * c.SLUnboxOperation.q.FromBoolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLToBooleanOperation.q.Boolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * c.SLLessOrEqualOperation.q.LessOrEqual0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessOrEqual0 + * LessOrEqual1 + * Fallback + * + * c.SLInvokeOperation.q.Direct + * Inputs: + * STACK_VALUE + * VARARG_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * Direct + * Indirect + * Interop + * Fallback + * + * c.SLFunctionLiteralOperation.q.Perform + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * Specializations: + * Perform + * Fallback + * + * c.SLWritePropertyOperation.q.WriteSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * WriteArray0 + * WriteArray1 + * WriteSLObject0 + * WriteSLObject1 + * WriteObject0 + * WriteObject1 + * Fallback + * + * c.SLLessThanOperation.q.LessThan0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessThan0 + * LessThan1 + * Fallback + * */ @GeneratedBy(SLOperations.class) @@ -1915,6 +1940,13 @@ private static final class SLOperationsBuilderImplBytecodeNode extends Operation private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY__ = LibraryFactory.resolve(DynamicObjectLibrary.class); private static final LibraryFactory INTEROP_LIBRARY____ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory INTEROP_LIBRARY_____ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY______ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY_______ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY___ = LibraryFactory.resolve(DynamicObjectLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY________ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY_________ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory INTEROP_LIBRARY__________ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY____ = LibraryFactory.resolve(DynamicObjectLibrary.class); @CompilationFinal(dimensions = 1) private final byte[] bc; @CompilationFinal(dimensions = 1) private final Object[] consts; @@ -2068,6 +2100,11 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + } int type0; int type1; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { @@ -2116,6 +2153,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2138,6 +2176,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2156,6 +2195,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2966,6 +3006,11 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { @@ -2998,6 +3043,7 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3022,6 +3068,7 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3140,6 +3187,11 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { @@ -3172,6 +3224,7 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3196,6 +3249,7 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3692,6 +3746,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3728,6 +3783,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3775,6 +3831,11 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + } int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3803,6 +3864,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3845,6 +3907,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3880,6 +3943,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4262,6 +4326,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4298,6 +4363,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4341,6 +4407,11 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + } int type0; int type1; int type2; @@ -4367,6 +4438,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4410,6 +4482,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4446,6 +4519,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4628,6 +4702,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4640,6 +4715,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc TruffleString $child0Value_ = (TruffleString) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4652,6 +4728,11 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + } int type0; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { type0 = FRAME_TYPE_BOOLEAN; @@ -4673,6 +4754,11 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc long $child0Value_ = (long) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + } int type0; if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { type0 = FRAME_TYPE_LONG; @@ -4697,6 +4783,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4710,6 +4797,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4722,6 +4810,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLNull $child0Value_ = SLTypes.asSLNull($child0Value); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4751,6 +4840,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4775,6 +4865,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4824,6 +4915,11 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); + } int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4915,6 +5011,11 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + } int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { type0 = FRAME_TYPE_BOOLEAN; @@ -4938,6 +5039,7 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5089,6 +5191,11 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + } } } } @@ -5105,6 +5212,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); @@ -5116,6 +5224,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); @@ -5153,44 +5262,338 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int } } - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @Override - protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { - int sp = startSp; - int bci = startBci; - ExecutionTracer tracer = ExecutionTracer.get(SLOperations.class); - tracer.startFunction(this); - Object returnValue = null; - loop: while (true) { - int nextBci; - short curOpcode = LE_BYTES.getShort(bc, bci); - try { - CompilerAsserts.partialEvaluationConstant(bci); - CompilerAsserts.partialEvaluationConstant(sp); - CompilerAsserts.partialEvaluationConstant(curOpcode); - if (sp < maxLocals + VALUES_OFFSET) { - throw CompilerDirectives.shouldNotReachHere("stack underflow"); - } - switch (curOpcode) { - case INSTR_POP : - { - tracer.traceInstruction(bci, INSTR_POP); - sp = sp - 1; - frame.clear(sp); - nextBci = bci + 2; - break; - } - case INSTR_BRANCH : - { - tracer.traceInstruction(bci, INSTR_BRANCH); - int targetBci = LE_BYTES.getShort(bc, bci + 2); - if (targetBci <= bci) { - TruffleSafepoint.poll(this); - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { - Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); - if (osrResult != null) { - return osrResult; - } + private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + @ExplodeLoop + private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop + private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvokeOperation_DirectData prev = null; + SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + @ExplodeLoop + private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 3); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 2); + Object $child2Value_; + $child2Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; + } + + private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @Override + protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { + int sp = startSp; + int bci = startBci; + Object returnValue = null; + loop: while (true) { + int nextBci; + short curOpcode = LE_BYTES.getShort(bc, bci); + try { + CompilerAsserts.partialEvaluationConstant(bci); + CompilerAsserts.partialEvaluationConstant(sp); + CompilerAsserts.partialEvaluationConstant(curOpcode); + if (sp < maxLocals + VALUES_OFFSET) { + throw CompilerDirectives.shouldNotReachHere("stack underflow"); + } + switch (curOpcode) { + case INSTR_POP : + { + sp = sp - 1; + frame.clear(sp); + nextBci = bci + 2; + break; + } + case INSTR_BRANCH : + { + int targetBci = LE_BYTES.getShort(bc, bci + 2); + if (targetBci <= bci) { + TruffleSafepoint.poll(this); + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { + Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); + if (osrResult != null) { + return osrResult; + } } } bci = targetBci; @@ -5198,7 +5601,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_BRANCH_FALSE : { - tracer.traceInstruction(bci, INSTR_BRANCH_FALSE); ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; boolean cond = (boolean) frame.getObject(sp - 1); sp -= 1; @@ -5212,7 +5614,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_CONSTANT_OBJECT : { - tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_OBJECT); frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; @@ -5220,7 +5621,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_CONSTANT_LONG : { - tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_LONG); frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; @@ -5228,7 +5628,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_CONSTANT_BOOLEAN : { - tracer.traceInstruction(bci, INSTR_LOAD_CONSTANT_BOOLEAN); frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; @@ -5236,7 +5635,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_ARGUMENT_OBJECT : { - tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_OBJECT); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; frame.setObject(sp, value); sp = sp + 1; @@ -5245,7 +5643,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_ARGUMENT_LONG : { - tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_LONG); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; if (value instanceof Long) { frame.setLong(sp, (long) value); @@ -5258,7 +5655,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_ARGUMENT_BOOLEAN : { - tracer.traceInstruction(bci, INSTR_LOAD_ARGUMENT_BOOLEAN); Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; if (value instanceof Boolean) { frame.setBoolean(sp, (boolean) value); @@ -5271,7 +5667,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_STORE_LOCAL : { - tracer.traceInstruction(bci, INSTR_STORE_LOCAL); assert frame.isObject(sp - 1); frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); frame.clear(--sp); @@ -5280,7 +5675,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_LOCAL_OBJECT : { - tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_OBJECT); frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); sp++; nextBci = bci + 4; @@ -5288,7 +5682,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_LOCAL_LONG : { - tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_LONG); Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); if (value instanceof Long) { frame.setLong(sp, (long) value); @@ -5301,7 +5694,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_LOAD_LOCAL_BOOLEAN : { - tracer.traceInstruction(bci, INSTR_LOAD_LOCAL_BOOLEAN); Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); if (value instanceof Boolean) { frame.setBoolean(sp, (boolean) value); @@ -5314,14 +5706,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_RETURN : { - tracer.traceInstruction(bci, INSTR_RETURN); returnValue = frame.getObject(sp - 1); break loop; } case INSTR_C_SLADD_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLADD_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLADD_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLAddOperation_(bc, bci)); this.SLAddOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; @@ -5329,8 +5718,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLDIV_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLDIV_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLDIV_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLDivOperation_(bc, bci)); this.SLDivOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; @@ -5338,8 +5725,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLEQUAL_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLEQUAL_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLEQUAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLEqualOperation_(bc, bci)); this.SLEqualOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; @@ -5347,8 +5732,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLESS_OR_EQUAL_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLLESS_OR_EQUAL_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLLESS_OR_EQUAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLessOrEqualOperation_(bc, bci)); this.SLLessOrEqualOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; @@ -5356,8 +5739,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLESS_THAN_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLLESS_THAN_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLLESS_THAN_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLessThanOperation_(bc, bci)); this.SLLessThanOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; @@ -5365,8 +5746,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLLOGICAL_NOT_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLLOGICAL_NOT_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLLOGICAL_NOT_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLLogicalNotOperation_(bc, bci)); this.SLLogicalNotOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; @@ -5374,8 +5753,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLMUL_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLMUL_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLMUL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLMulOperation_(bc, bci)); this.SLMulOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; @@ -5383,8 +5760,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLREAD_PROPERTY_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLREAD_PROPERTY_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLREAD_PROPERTY_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLReadPropertyOperation_(bc, bci)); this.SLReadPropertyOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 10; @@ -5392,8 +5767,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLSUB_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLSUB_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLSUB_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLSubOperation_(bc, bci)); this.SLSubOperation_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; @@ -5401,8 +5774,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLWRITE_PROPERTY_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLWRITE_PROPERTY_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLWRITE_PROPERTY_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLWritePropertyOperation_(bc, bci)); this.SLWritePropertyOperation_execute_(frame, bci, sp); sp = sp - 3 + 1; nextBci = bci + 11; @@ -5410,8 +5781,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLUNBOX_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLUNBOX_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLUNBOX_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLUnboxOperation_(bc, bci)); this.SLUnboxOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 10; @@ -5419,8 +5788,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLFUNCTION_LITERAL_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLFUNCTION_LITERAL_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLFUNCTION_LITERAL_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLFunctionLiteralOperation_(bc, bci)); this.SLFunctionLiteralOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 6; @@ -5428,8 +5795,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLTO_BOOLEAN_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLTO_BOOLEAN_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLTO_BOOLEAN_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLToBooleanOperation_(bc, bci)); this.SLToBooleanOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; @@ -5437,8 +5802,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLEVAL_ROOT_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLEVAL_ROOT_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLEVAL_ROOT_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLEvalRootOperation_(bc, bci)); this.SLEvalRootOperation_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; @@ -5446,8 +5809,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } case INSTR_C_SLINVOKE_OPERATION : { - tracer.traceInstruction(bci, INSTR_C_SLINVOKE_OPERATION); - tracer.traceActiveSpecializations(bci, INSTR_C_SLINVOKE_OPERATION, SLOperationsBuilderImpl.doGetStateBits_SLInvokeOperation_(bc, bci)); int numVariadics = LE_BYTES.getShort(bc, bci + 3); Object input_0 = frame.getObject(sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -5460,6 +5821,83 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 11; break; } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + { + this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : + { + this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + { + this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + { + this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + { + this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : + { + this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); @@ -5480,7 +5918,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { CompilerAsserts.partialEvaluationConstant(nextBci); bci = nextBci; } - tracer.endFunction(this); return returnValue; } @@ -5505,6 +5942,7 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : { bci = bci + 4; break; @@ -5524,6 +5962,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_STORE_LOCAL : case INSTR_C_SLLESS_OR_EQUAL_OPERATION : case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : { bci = bci + 5; break; @@ -5537,6 +5977,9 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLEQUAL_OPERATION : case INSTR_C_SLWRITE_PROPERTY_OPERATION : case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : { bci = bci + 11; break; @@ -5545,12 +5988,16 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLMUL_OPERATION : case INSTR_C_SLSUB_OPERATION : case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : { bci = bci + 6; break; } case INSTR_C_SLREAD_PROPERTY_OPERATION : case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : { bci = bci + 10; break; @@ -5850,20 +6297,204 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("load.local.object "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" "); + sb.append("load.local.object "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_LOCAL_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.long "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boolean "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_RETURN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("return"); + bci += 3; + break; + } + case INSTR_C_SLADD_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAddOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLDIV_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLDivOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 6; + break; + } + case INSTR_C_SLEQUAL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEqualOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqualOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 5; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_C_SLLESS_THAN_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -5875,15 +6506,16 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append("c.SLLessThanOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 5; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_C_SLLOGICAL_NOT_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -5901,18 +6533,21 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append("c.SLLogicalNotOperation "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_RETURN : + case INSTR_C_SLMUL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -5923,17 +6558,16 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); + sb.append("c.SLMulOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); - sb.append("return"); - bci += 3; + sb.append("x"); + bci += 6; break; } - case INSTR_C_SLADD_OPERATION : + case INSTR_C_SLREAD_PROPERTY_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -5945,22 +6579,22 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLAddOperation "); + sb.append(" "); + sb.append("c.SLReadPropertyOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 11; + bci += 10; break; } - case INSTR_C_SLDIV_OPERATION : + case INSTR_C_SLSUB_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -5978,7 +6612,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLDivOperation "); + sb.append("c.SLSubOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -5987,7 +6621,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLEQUAL_OPERATION : + case INSTR_C_SLWRITE_PROPERTY_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6005,49 +6639,50 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLEqualOperation "); + sb.append("c.SLWritePropertyOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); sb.append(" -> "); sb.append("x"); bci += 11; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + case INSTR_C_SLUNBOX_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqualOperation "); + sb.append("c.SLUnboxOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 5; + bci += 10; break; } - case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6058,17 +6693,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThanOperation "); + sb.append("c.SLFunctionLiteralOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 5; + bci += 6; break; } - case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6086,21 +6718,19 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLogicalNotOperation "); + sb.append("c.SLToBooleanOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_C_SLMUL_OPERATION : + case INSTR_C_SLEVAL_ROOT_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6111,16 +6741,16 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLMulOperation "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEvalRootOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 6; + bci += 4; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLINVOKE_OPERATION : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6132,22 +6762,22 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("c.SLReadPropertyOperation "); + sb.append("c.SLInvokeOperation "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); sb.append(" -> "); sb.append("x"); - bci += 10; + bci += 11; break; } - case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6155,26 +6785,51 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); + sb.append("c.SLUnboxOperation.q.FromLong "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLSubOperation "); + sb.append("c.SLAddOperation.q.AddLong "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 6; + bci += 11; break; } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6186,24 +6841,22 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 7])); sb.append(String.format("%02x ", bc[bci + 8])); sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLWritePropertyOperation "); + sb.append(" "); + sb.append("c.SLReadPropertyOperation.q.ReadSLObject0 "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); sb.append(" -> "); sb.append("x"); - bci += 11; + bci += 10; break; } - case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6221,21 +6874,19 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLUnboxOperation "); + sb.append("c.SLUnboxOperation.q.FromBoolean "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 10; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6246,19 +6897,22 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLFunctionLiteralOperation "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBooleanOperation.q.Boolean "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 6; + bci += 4; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6270,22 +6924,50 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append("c.SLToBooleanOperation "); + sb.append("c.SLLessOrEqualOperation.q.LessOrEqual0 "); sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 5; break; } - case INSTR_C_SLEVAL_ROOT_OPERATION : + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); sb.append(String.format("%02x ", bc[bci + 2])); sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); sb.append(" "); sb.append(" "); + sb.append("c.SLInvokeOperation.q.Direct "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); sb.append(" "); sb.append(" "); sb.append(" "); @@ -6296,14 +6978,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLEvalRootOperation "); + sb.append("c.SLFunctionLiteralOperation.q.Perform "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); - bci += 4; + bci += 6; break; } - case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6321,15 +7003,44 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLInvokeOperation "); + sb.append("c.SLWritePropertyOperation.q.WriteSLObject0 "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); sb.append(" -> "); sb.append("x"); bci += 11; break; } + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThanOperation.q.LessThan0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } } sb.append("\n"); } @@ -6429,6 +7140,37 @@ private static boolean SLEvalRootOperation_fallbackGuard__(VirtualFrame $frame, return true; } + private static boolean SLAddOperation_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static boolean SLToBooleanOperation_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLLessOrEqualOperation_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLessThanOperation_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { if (bciOffset != 0) { setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 4658298f0fbd..d31e904314af 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -356,8 +356,6 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { inst.activeSpecializationsMap.put(key, count); } - System.out.println(inst); - return inst; } @@ -368,10 +366,6 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats) { result.put("Use the overrides file to alter the optimisation decisions."); int numDecisions = 10; activeSpecializationsMap.entrySet().stream() // - .map(e -> { - System.out.println("state: " + e.getValue() + ":" + e.getKey()); - return e; - }) // .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) // .limit(numDecisions) // .forEachOrdered(e -> { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 5154cb7eeadf..7e662cac2e43 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -138,7 +138,7 @@ protected OperationsData parse(Element element, List mirror) { data.setDecisionsFilePath(getMainDecisionsFilePath(typeElement, generateOperationsMirror)); - AnnotationValue forceTracingValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing"); + AnnotationValue forceTracingValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true); boolean isTracing; if ((boolean) forceTracingValue.getValue()) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index c25216fd10be..bec6cd912135 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -49,9 +49,7 @@ @GenerateOperations(// decisionsFile = "decisions.json", // - decisionOverrideFiles = {"decisions-manual.json"}, // - boxingEliminationTypes = {long.class, boolean.class}, // - forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json deleted file mode 100644 index 582ecae70070..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions-manual.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "type": "Quicken", - "operation": "SLUnboxOperation", - "specializations": [ - "FromLong" - ] - }, - { - "type": "Quicken", - "operation": "SLAddOperation", - "specializations": [ - "AddLong" - ] - }, - { - "type": "Quicken", - "operation": "SLReadPropertyOperation", - "specializations": [ - "ReadSLObject0" - ] - }, - { - "type": "Quicken", - "operation": "SLUnboxOperation", - "specializations": [ - "FromBoolean" - ] - } -] diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 0c39f8ce42c4..01893ed689ad 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -1,4 +1,7 @@ [ + "This file is autogenerated by the Operations DSL.", + "Do not modify, as it will be overwritten when running with tracing support.", + "Use the overrides file to alter the optimisation decisions.", { "specializations": ["FromLong"], "type": "Quicken", From 8e330668b304951cd0231f4ef98f17e13786641c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 4 May 2022 14:53:39 +0200 Subject: [PATCH 072/312] [wip] implement FinallyTry --- .../sl/operations/SLOperationsBuilder.java | 321 ++++++++----- .../test/example/TestOperations.java | 10 +- .../example/TestOperationsParserTest.java | 427 ++++++++++++++++++ .../operation/BuilderExceptionHandler.java | 15 + .../api/operation/BuilderOperationLabel.java | 27 +- .../api/operation/OperationsBuilder.java | 144 +++++- .../dsl/processor/operations/Operation.java | 148 +++++- .../OperationsBytecodeNodeGeneratorPlugs.java | 26 +- .../operations/OperationsCodeGenerator.java | 72 ++- .../operations/OperationsContext.java | 8 +- .../operations/OperationsParser.java | 9 +- .../instructions/BranchInstruction.java | 4 +- .../operations/instructions/Instruction.java | 16 +- .../instructions/ReturnInstruction.java | 11 + .../instructions/ThrowInstruction.java | 52 +++ 15 files changed, 1118 insertions(+), 172 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index db3a903078f6..06af70468238 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -103,6 +103,10 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endTryCatch(); + public abstract void beginFinallyTry(int arg0); + + public abstract void endFinallyTry(); + public abstract void emitLabel(OperationLabel arg0); public abstract void emitBranch(OperationLabel arg0); @@ -208,85 +212,87 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int OP_CONDITIONAL = 4; private static final int OP_WHILE = 5; private static final int OP_TRY_CATCH = 6; - private static final int OP_LABEL = 7; - private static final int OP_BRANCH = 8; - private static final int OP_CONST_OBJECT = 9; - private static final int OP_LOAD_ARGUMENT = 10; - private static final int OP_STORE_LOCAL = 11; - private static final int OP_LOAD_LOCAL = 12; - private static final int OP_RETURN = 13; - private static final int OP_INSTRUMENTATION = 14; - private static final int OP_SLADD_OPERATION = 15; - private static final int OP_SLDIV_OPERATION = 16; - private static final int OP_SLEQUAL_OPERATION = 17; - private static final int OP_SLLESS_OR_EQUAL_OPERATION = 18; - private static final int OP_SLLESS_THAN_OPERATION = 19; - private static final int OP_SLLOGICAL_NOT_OPERATION = 20; - private static final int OP_SLMUL_OPERATION = 21; - private static final int OP_SLREAD_PROPERTY_OPERATION = 22; - private static final int OP_SLSUB_OPERATION = 23; - private static final int OP_SLWRITE_PROPERTY_OPERATION = 24; - private static final int OP_SLUNBOX_OPERATION = 25; - private static final int OP_SLFUNCTION_LITERAL_OPERATION = 26; - private static final int OP_SLTO_BOOLEAN_OPERATION = 27; - private static final int OP_SLEVAL_ROOT_OPERATION = 28; - private static final int OP_SLINVOKE_OPERATION = 29; + private static final int OP_FINALLY_TRY = 7; + private static final int OP_LABEL = 8; + private static final int OP_BRANCH = 9; + private static final int OP_CONST_OBJECT = 10; + private static final int OP_LOAD_ARGUMENT = 11; + private static final int OP_STORE_LOCAL = 12; + private static final int OP_LOAD_LOCAL = 13; + private static final int OP_RETURN = 14; + private static final int OP_INSTRUMENTATION = 15; + private static final int OP_SLADD_OPERATION = 16; + private static final int OP_SLDIV_OPERATION = 17; + private static final int OP_SLEQUAL_OPERATION = 18; + private static final int OP_SLLESS_OR_EQUAL_OPERATION = 19; + private static final int OP_SLLESS_THAN_OPERATION = 20; + private static final int OP_SLLOGICAL_NOT_OPERATION = 21; + private static final int OP_SLMUL_OPERATION = 22; + private static final int OP_SLREAD_PROPERTY_OPERATION = 23; + private static final int OP_SLSUB_OPERATION = 24; + private static final int OP_SLWRITE_PROPERTY_OPERATION = 25; + private static final int OP_SLUNBOX_OPERATION = 26; + private static final int OP_SLFUNCTION_LITERAL_OPERATION = 27; + private static final int OP_SLTO_BOOLEAN_OPERATION = 28; + private static final int OP_SLEVAL_ROOT_OPERATION = 29; + private static final int OP_SLINVOKE_OPERATION = 30; private static final int INSTR_POP = 1; private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; - private static final int INSTR_LOAD_CONSTANT_OBJECT = 4; - private static final int INSTR_LOAD_CONSTANT_LONG = 5; + private static final int INSTR_THROW = 4; + private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_ARGUMENT_OBJECT = 7; - private static final int INSTR_LOAD_ARGUMENT_LONG = 8; + private static final int INSTR_LOAD_CONSTANT_LONG = 7; + private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_STORE_LOCAL = 10; - private static final int INSTR_LOAD_LOCAL_OBJECT = 11; - private static final int INSTR_LOAD_LOCAL_LONG = 12; + private static final int INSTR_LOAD_ARGUMENT_LONG = 10; + private static final int INSTR_STORE_LOCAL = 11; + private static final int INSTR_LOAD_LOCAL_OBJECT = 12; private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; - private static final int INSTR_RETURN = 14; - private static final int INSTR_INSTRUMENT_ENTER = 15; - private static final int INSTR_INSTRUMENT_EXIT_VOID = 16; - private static final int INSTR_INSTRUMENT_EXIT = 17; - private static final int INSTR_INSTRUMENT_LEAVE = 18; - private static final int INSTR_C_SLADD_OPERATION = 19; - private static final int INSTR_C_SLDIV_OPERATION = 20; - private static final int INSTR_C_SLEQUAL_OPERATION = 21; - private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION = 22; - private static final int INSTR_C_SLLESS_THAN_OPERATION = 23; - private static final int INSTR_C_SLLOGICAL_NOT_OPERATION = 24; - private static final int INSTR_C_SLMUL_OPERATION = 25; - private static final int INSTR_C_SLREAD_PROPERTY_OPERATION = 26; - private static final int INSTR_C_SLSUB_OPERATION = 27; - private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION = 28; - private static final int INSTR_C_SLUNBOX_OPERATION = 29; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION = 30; - private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 31; - private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 32; - private static final int INSTR_C_SLINVOKE_OPERATION = 33; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 34; - private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 35; - private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 36; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 37; - private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 38; - private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 39; - private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 40; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 41; - private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 42; - private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 43; + private static final int INSTR_LOAD_LOCAL_LONG = 14; + private static final int INSTR_RETURN = 15; + private static final int INSTR_INSTRUMENT_ENTER = 16; + private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; + private static final int INSTR_INSTRUMENT_EXIT = 18; + private static final int INSTR_INSTRUMENT_LEAVE = 19; + private static final int INSTR_C_SLADD_OPERATION = 20; + private static final int INSTR_C_SLDIV_OPERATION = 21; + private static final int INSTR_C_SLEQUAL_OPERATION = 22; + private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION = 23; + private static final int INSTR_C_SLLESS_THAN_OPERATION = 24; + private static final int INSTR_C_SLLOGICAL_NOT_OPERATION = 25; + private static final int INSTR_C_SLMUL_OPERATION = 26; + private static final int INSTR_C_SLREAD_PROPERTY_OPERATION = 27; + private static final int INSTR_C_SLSUB_OPERATION = 28; + private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION = 29; + private static final int INSTR_C_SLUNBOX_OPERATION = 30; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION = 31; + private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 32; + private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 33; + private static final int INSTR_C_SLINVOKE_OPERATION = 34; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 35; + private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 36; + private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 37; + private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 38; + private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 39; + private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 40; + private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 41; + private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 42; + private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 43; + private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 44; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; @@ -361,12 +367,12 @@ public OperationsNode buildImpl() { @Override protected void doLeaveOperation(BuilderOperationData data) { - while (getCurStack() > data.stackDepth) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } switch (data.operationId) { + case OP_FINALLY_TRY : + { + bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); + break; + } case OP_INSTRUMENTATION : { int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); @@ -592,6 +598,28 @@ void doAfterChild() { } break; } + case OP_FINALLY_TRY : + { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + if (childIndex == 0) { + doEndFinallyBlock0(bc, bci, exceptionHandlers); + bc = doFinallyRestoreBc(); + bci = doFinallyRestoreBci(); + exceptionHandlers = doFinallyRestoreExceptions(); + doEndFinallyBlock1(); + BuilderExceptionHandler beh = new BuilderExceptionHandler(); + beh.startBci = bci; + beh.startStack = getCurStack(); + beh.exceptionIndex = (int)trackLocalsHelper(operationData.arguments[0]); + exceptionHandlers.add(beh); + operationData.aux[1] = beh; + } + break; + } } } @@ -739,6 +767,53 @@ public void endTryCatch() { doAfterChild(); } + @SuppressWarnings("unused") + @Override + public void beginFinallyTry(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, getCurStack(), 2, true, arg0); + operationData.aux[0] = doBeginFinallyTry(bc, bci, exceptionHandlers); + bc = new byte[65535]; + bci = 0; + exceptionHandlers = new ArrayList(); + } + + @SuppressWarnings("unused") + @Override + public void endFinallyTry() { + if (operationData.operationId != OP_FINALLY_TRY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); + } + int endBci = bci; + bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); + BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); + { + calculateLeaves(operationData, (BuilderOperationLabel) endLabel); + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); + createOffset(bci + 2, endLabel); + bci = bci + 4; + } + BuilderExceptionHandler beh = ((BuilderExceptionHandler) operationData.aux[1]); + beh.endBci = endBci; + beh.handlerBci = bci; + bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); + { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_THROW); + LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); + bci = bci + 4; + } + doEmitLabel(bci, endLabel); + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + @Override public void emitLabel(OperationLabel arg0) { doBeforeChild(); @@ -845,6 +920,7 @@ public void endReturn() { if (numChildren != 1) { throw new IllegalStateException("Return expected 1 children, got " + numChildren); } + calculateLeaves(operationData); int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_RETURN); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); @@ -1430,19 +1506,24 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * BRANCH * + * throw + * Inputs: + * LOCAL + * Results: + * * load.constant.object * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: @@ -1454,13 +1535,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: @@ -1478,13 +1559,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: @@ -5612,6 +5693,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { continue loop; } } + case INSTR_THROW : + { + int slot = LE_BYTES.getShort(bc, bci + 2); + throw (AbstractTruffleException) frame.getObject(slot); + } case INSTR_LOAD_CONSTANT_OBJECT : { frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); @@ -5619,16 +5705,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -5641,11 +5727,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -5653,11 +5739,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5680,11 +5766,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -5692,11 +5778,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5932,13 +6018,14 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { break; } case INSTR_BRANCH : + case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -5952,8 +6039,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_LONG : case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6096,6 +6183,30 @@ public String dump() { bci += 7; break; } + case INSTR_THROW : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("throw "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + bci += 4; + break; + } case INSTR_LOAD_CONSTANT_OBJECT : { sb.append(String.format("%02x ", bc[bci + 0])); @@ -6124,7 +6235,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6142,7 +6253,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6152,7 +6263,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6170,7 +6281,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6205,7 +6316,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6223,14 +6334,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6248,7 +6359,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6305,7 +6416,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6323,14 +6434,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6348,7 +6459,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index b8144a6db1cc..fa9952149fd3 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation.test.example; +import java.util.List; import java.util.function.Consumer; import org.junit.Assert; @@ -86,11 +87,18 @@ public static Object perform(@Bind("$bci") int bci, @Bind("this") OperationsNode } @Operation - @GenerateAOT static class AlwaysBoxOperation { @Specialization public static Object perform(Object value) { return value; } } + + @Operation + static class AppenderOperation { + @Specialization + public static void perform(List list, Object value) { + list.add(value); + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 6920efa67356..9441d0b20fa7 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -3,6 +3,8 @@ import static org.junit.Assert.fail; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.function.Consumer; import org.graalvm.polyglot.Context; @@ -12,6 +14,7 @@ import org.junit.Test; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; import com.oracle.truffle.api.source.Source; @@ -314,4 +317,428 @@ public void testCompilation() { Assert.assertEquals(Value.asValue(7L), v.execute(3L, 4L)); } + private static void testOrdering(boolean expectException, RootCallTarget root, Long... order) { + List result = new ArrayList<>(); + + try { + root.call(result); + if (expectException) { + Assert.fail(); + } + } catch (Exception ex) { + if (!expectException) { + throw new AssertionError("unexpected", ex); + } + } + + Assert.assertArrayEquals(order, result.toArray()); + } + + @Test + public void testFinallyTryBasic() { + + // try { 1; } finally { 2; } + // expected 1, 2 + + RootCallTarget root = parse(b -> { + b.beginFinallyTry(0); + { + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + } + b.endFinallyTry(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.build(); + }); + + testOrdering(false, root, 1L, 2L); + } + + @Test + public void testFinallyTryException() { + + // try { 1; throw; 2; } finally { 3; } + // expected: 1, 3 + + RootCallTarget root = parse(b -> { + b.beginFinallyTry(0); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.emitThrowOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.build(); + }); + + testOrdering(true, root, 1L, 3L); + } + + @Test + public void testFinallyTryReturn() { + RootCallTarget root = parse(b -> { + b.beginFinallyTry(0); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.build(); + }); + + testOrdering(false, root, 2L, 1L); + } + + @Test + public void testFinallyTryBranchOut() { + RootCallTarget root = parse(b -> { + + // try { 1; goto lbl; 2; } finally { 3; } 4; lbl: 5; + // expected: 1, 3, 5 + + OperationLabel lbl = b.createLabel(); + + b.beginFinallyTry(0); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.emitBranch(lbl); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + + b.emitLabel(lbl); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(5L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.build(); + }); + + testOrdering(false, root, 1L, 3L, 5L); + } + + @Test + public void testFinallyTryCancel() { + RootCallTarget root = parse(b -> { + + // try { 1; return; } finally { 2; goto lbl; } 3; lbl: 4; + // expected: 1, 2, 4 + + OperationLabel lbl = b.createLabel(); + + b.beginFinallyTry(0); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + + b.emitBranch(lbl); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.emitLabel(lbl); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.build(); + }); + + testOrdering(false, root, 1L, 2L, 4L); + } + + @Test + public void testFinallyTryInnerCf() { + RootCallTarget root = parse(b -> { + + // try { 1; return; 2 } finally { 3; goto lbl; 4; lbl: 5; } + // expected: 1, 3, 5 + + b.beginFinallyTry(0); + { + b.beginBlock(); + { + OperationLabel lbl = b.createLabel(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.emitBranch(lbl); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + + b.emitLabel(lbl); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(5L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.build(); + }); + + testOrdering(false, root, 1L, 3L, 5L); + } + + @Test + public void testFinallyTryNestedTry() { + RootCallTarget root = parse(b -> { + + // try { try { 1; return; 2; } finally { 3; } } finally { 4; } + // expected: 1, 3, 4 + + b.beginFinallyTry(0); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginFinallyTry(1); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + } + b.endFinallyTry(); + + b.build(); + }); + + testOrdering(false, root, 1L, 3L, 4L); + } + + @Test + public void testFinallyTryNestedFinally() { + RootCallTarget root = parse(b -> { + + // try { 1; return; 2; } finally { try { 3; return; 4; } finally { 5; } } + // expected: 1, 3, 5 + + b.beginFinallyTry(0); + { + b.beginFinallyTry(0); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(5L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.build(); + }); + + testOrdering(false, root, 1L, 3L, 5L); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java index a6d624c29161..a8f8b738c19d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java @@ -7,6 +7,21 @@ public class BuilderExceptionHandler { public int exceptionIndex; public int handlerBci; + public BuilderExceptionHandler() { + } + + private BuilderExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { + this.startBci = startBci; + this.startStack = startStack; + this.endBci = endBci; + this.exceptionIndex = exceptionIndex; + this.handlerBci = handlerBci; + } + + public BuilderExceptionHandler offset(int offset, int stackOffset) { + return new BuilderExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); + } + @Override public String toString() { return String.format("{start=%04x, end=%04x, handler=%04x}", startBci, endBci, handlerBci); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java index 59d80e3e646f..1a57fafc6ad7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java @@ -1,11 +1,36 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.operation.OperationsBuilder.FinallyTryContext; + public class BuilderOperationLabel extends OperationLabel { BuilderOperationData data; boolean hasValue = false; int targetBci = 0; + FinallyTryContext finallyTry; - public BuilderOperationLabel(BuilderOperationData data) { + public BuilderOperationLabel(BuilderOperationData data, FinallyTryContext finallyTry) { this.data = data; + this.finallyTry = finallyTry; + } + + boolean belongsTo(FinallyTryContext context) { + FinallyTryContext cur = finallyTry; + while (cur != null) { + if (cur == context) { + return true; + } + cur = cur.prev; + } + + return false; + } + + @Override + public String toString() { + if (!hasValue) { + return "BuilderOperationLabel [unresolved]"; + } else { + return String.format("BuilderOperationLabel [target=%04x]", targetBci); + } } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 3ac90670ee2a..1bc6d2c22a97 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -1,6 +1,7 @@ package com.oracle.truffle.api.operation; import java.util.ArrayList; +import java.util.Arrays; import java.util.function.Supplier; import com.oracle.truffle.api.instrumentation.Tag; @@ -50,14 +51,18 @@ private static class LabelFill { int locationBci; BuilderOperationLabel label; - public LabelFill(int locationBci, BuilderOperationLabel label) { + LabelFill(int locationBci, BuilderOperationLabel label) { this.locationBci = locationBci; this.label = label; } + + LabelFill offset(int offset) { + return new LabelFill(offset + locationBci, label); + } } - private final ArrayList labelFills = new ArrayList<>(); - private final ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private ArrayList labels = new ArrayList<>(); protected final void relocateLabels(int bci, int length) { for (LabelFill fill : labelFills) { @@ -79,7 +84,19 @@ protected final void createOffset(int locationBci, Object label) { } protected final void labelPass(byte[] bc) { + labelPass(bc, null); + } + + private final void labelPass(byte[] bc, FinallyTryContext finallyTry) { for (LabelFill fill : labelFills) { + if (finallyTry != null) { + if (fill.label.belongsTo(finallyTry)) { + assert fill.label.hasValue : "inner label should have been resolved by now"; + finallyTry.relocationOffsets.add(fill.locationBci); + } else { + finallyTry.handlerLabelFills.add(fill); + } + } LE_BYTES.putShort(bc, fill.locationBci, (short) fill.label.targetBci); } } @@ -87,13 +104,17 @@ protected final void labelPass(byte[] bc) { protected BuilderOperationData operationData = null; public final OperationLabel createLabel() { - BuilderOperationLabel label = new BuilderOperationLabel(operationData); + BuilderOperationLabel label = new BuilderOperationLabel(operationData, currentFinallyTry); labels.add(label); return label; } protected abstract void doLeaveOperation(BuilderOperationData data); + protected final void calculateLeaves(BuilderOperationData fromData) { + calculateLeaves(fromData, (BuilderOperationData) null); + } + protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationLabel toLabel) { calculateLeaves(fromData, toLabel.data); } @@ -103,10 +124,20 @@ protected final void calculateLeaves(BuilderOperationData fromData, BuilderOpera throw new UnsupportedOperationException("illegal jump to deeper operation"); } + if (fromData == toData) { + return; // nothing to leave + } + BuilderOperationData cur = fromData; - while ((toData == null && cur != null) || cur.depth > toData.depth) { + while (true) { doLeaveOperation(cur); cur = cur.parent; + + if (toData == null && cur == null) { + break; + } else if (toData != null && cur.depth <= toData.depth) { + break; + } } if (cur != toData) { @@ -198,4 +229,107 @@ protected final int doBeginInstrumentation(Class tag) { instrumentTrees.add(new OperationsInstrumentTreeNode(tag)); return instrumentTrees.size() - 1; } + + // ------------------------ try / finally ------------------------ + + private FinallyTryContext currentFinallyTry = null; + + static class FinallyTryContext { + final FinallyTryContext prev; + private final byte[] bc; + private final int bci; + private final ArrayList exceptionHandlers; + private final ArrayList labelFills; + private final ArrayList labels; + private final int curStack; + private final int maxStack; + + private byte[] handlerBc; + private ArrayList handlerHandlers; + public ArrayList handlerLabelFills = new ArrayList<>(); + public ArrayList relocationOffsets = new ArrayList<>(); + public int handlerMaxStack; + + FinallyTryContext(FinallyTryContext prev, byte[] bc, int bci, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, + int curStack, int maxStack) { + this.prev = prev; + this.bc = bc; + this.bci = bci; + this.exceptionHandlers = exceptionHandlers; + this.labelFills = labelFills; + this.labels = labels; + this.curStack = curStack; + this.maxStack = maxStack; + } + + private boolean finalized() { + return handlerBc != null; + } + } + + protected final Object doBeginFinallyTry(byte[] bc, int bci, ArrayList handlers) { + currentFinallyTry = new FinallyTryContext(currentFinallyTry, bc, bci, handlers, labelFills, labels, curStack, maxStack); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + return currentFinallyTry; + } + + protected final void doEndFinallyBlock0(byte[] bc, int bci, ArrayList handlers) { + labelPass(bc, currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = handlers; + currentFinallyTry.handlerMaxStack = maxStack; + } + + protected final byte[] doFinallyRestoreBc() { + return currentFinallyTry.bc; + } + + protected final int doFinallyRestoreBci() { + return currentFinallyTry.bci; + } + + protected final ArrayList doFinallyRestoreExceptions() { + return currentFinallyTry.exceptionHandlers; + } + + protected final void doEndFinallyBlock1() { + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + } + + protected final int doLeaveFinallyTry(byte[] bc, int bci, BuilderOperationData data, ArrayList handlers) { + FinallyTryContext context = (FinallyTryContext) data.aux[0]; + + if (!context.finalized()) { + // still in Finally part, nothing to leave yet + return bci; + } + + System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); + + for (int offset : context.relocationOffsets) { + short oldOffset = LE_BYTES.getShort(bc, bci + offset); + LE_BYTES.putShort(bc, bci + offset, (short) (oldOffset + bci)); + } + + for (BuilderExceptionHandler handler : context.handlerHandlers) { + handlers.add(handler.offset(bci, curStack)); + } + + for (LabelFill fill : context.handlerLabelFills) { + labelFills.add(fill.offset(bci)); + } + + if (maxStack < curStack + context.handlerMaxStack) { + maxStack = curStack + context.handlerMaxStack; + } + + return bci + context.handlerBc.length; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index f6a96d8b5e87..252711dfc792 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -7,6 +7,7 @@ import java.util.List; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -125,7 +126,7 @@ public CodeTree createEndCode(BuilderVariables vars) { arguments[i] = CodeTreeBuilder.createBuilder().string("operationData.arguments[" + i + "]").build(); } - return instruction.createEmitCode(vars, arguments); + return OperationGeneratorUtils.createEmitInstruction(vars, instruction, arguments); } @@ -160,7 +161,7 @@ public CodeTree createEndCode(BuilderVariables vars) { CodeTree[] arguments = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; - b.tree(instructions[FrameKind.OBJECT.ordinal()].createEmitCode(vars, arguments)); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instructions[FrameKind.OBJECT.ordinal()], arguments)); return b.build(); } @@ -619,6 +620,149 @@ public boolean hasLeaveCode() { } } + public static class FinallyTry extends Operation { + + private final int AUX_CONTEXT = 0; + private final int AUX_BEH = 1; + + public FinallyTry(OperationsContext builder, int id) { + super(builder, "FinallyTry", id, 2); + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(new CodeTypeMirror(TypeKind.INT)); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + // TODO - this could be made to return Try value on exit + return CodeTreeBuilder.singleString("0"); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = ").startCall("doBeginFinallyTry"); + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.exteptionHandlers); + b.end(2); + + b.startAssign(vars.bc).startNewArray((ArrayType) vars.bc.asType(), CodeTreeBuilder.singleString("65535")).end(2); + b.startAssign(vars.bci).string("0").end(); + b.startAssign(vars.exteptionHandlers).startNew(vars.exteptionHandlers.asType()).end(2); + + return b.build(); + } + + @Override + public CodeTree createAfterChildCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(createPopLastChildCode(vars)); + + b.startIf().variable(vars.childIndex).string(" == 0").end().startBlock(); + { + b.startStatement().startCall("doEndFinallyBlock0"); + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.exteptionHandlers); + b.end(2); + + b.startAssign(vars.bc).startCall("doFinallyRestoreBc").end(2); + b.startAssign(vars.bci).startCall("doFinallyRestoreBci").end(2); + b.startAssign(vars.exteptionHandlers).startCall("doFinallyRestoreExceptions").end(2); + + b.startStatement().startCall("doEndFinallyBlock1").end(2); + + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + + b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); + b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = (int)"); + b.startCall("trackLocalsHelper"); + b.startGroup().variable(vars.operationData).string(".arguments[0]").end(); + b.end(); + b.end(); + b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); + b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); + + } + b.end(); + return b.build(); + } + + @Override + public CodeTree createLeaveCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + emitLeaveCode(vars, b); + + return b.build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // ; exception end + // << handler code >> + // goto end + // ; exception handler start + // << handler code >> + // throw [exc] + // end: + + b.startAssign("int endBci").variable(vars.bci).end(); + + emitLeaveCode(vars, b); + + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + + b.startBlock(); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.end(); + + b.declaration(getTypes().BuilderExceptionHandler, "beh", createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)); + b.startAssign("beh.endBci").string("endBci").end(); + b.startAssign("beh.handlerBci").variable(vars.bci).end(); + + emitLeaveCode(vars, b); + + b.startBlock(); + CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[0]").build(); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonThrow, localIdx)); + b.end(); + + b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); + + return b.build(); + } + + private static void emitLeaveCode(BuilderVariables vars, CodeTreeBuilder b) { + b.startAssign(vars.bci).startCall("doLeaveFinallyTry"); + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.operationData); + b.variable(vars.exteptionHandlers); + b.end(2); + } + + @Override + public int getNumAuxValues() { + return 2; + } + + @Override + public boolean hasLeaveCode() { + return true; + } + } + private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement()// .variable(vars.operationData).string(".aux[" + index + "] = ") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 04717a65d79f..2bc478c8523e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -698,21 +698,23 @@ public boolean isStateGuaranteed(boolean stateGuaranteed) { } public void finishUp() { - int offset = -1; - BitSet targetSet = null; - for (StateBitSet set : multiState.getSets()) { - if (set.contains(resultUnboxedState)) { - targetSet = set; - offset = Arrays.asList(set.getObjects()).indexOf(resultUnboxedState); - break; + if (cinstr.numPush() > 0) { + int offset = -1; + BitSet targetSet = null; + for (StateBitSet set : multiState.getSets()) { + if (set.contains(resultUnboxedState)) { + targetSet = set; + offset = Arrays.asList(set.getObjects()).indexOf(resultUnboxedState); + break; + } } - } - if (offset < 0 || targetSet == null) { - throw new AssertionError(); - } + if (offset < 0 || targetSet == null) { + throw new AssertionError(); + } - cinstr.setBoxingEliminationData(cinstr.lengthWithoutState() + bitSetOffset(targetSet), 1 << offset); + cinstr.setBoxingEliminationData(cinstr.lengthWithoutState() + bitSetOffset(targetSet), 1 << offset); + } } public StaticConstants createConstants() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index e6aa38963c9c..062dd82eefcc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -141,49 +141,47 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { if (m.isTracing()) { String decisionsFilePath = m.getDecisionsFilePath(); - if (decisionsFilePath != null) { - CodeExecutableElement mStaticInit = new CodeExecutableElement(MOD_STATIC, null, ""); - typBuilderImpl.add(mStaticInit); + CodeExecutableElement mStaticInit = new CodeExecutableElement(MOD_STATIC, null, ""); + typBuilderImpl.add(mStaticInit); - CodeTreeBuilder b = mStaticInit.appendBuilder(); + CodeTreeBuilder b = mStaticInit.appendBuilder(); - b.startStatement().startStaticCall(types.ExecutionTracer, "initialize"); + b.startStatement().startStaticCall(types.ExecutionTracer, "initialize"); - b.typeLiteral(m.getTemplateType().asType()); + b.typeLiteral(m.getTemplateType().asType()); - // destination path - b.doubleQuote(decisionsFilePath); + // destination path + b.doubleQuote(decisionsFilePath); - // instruction names - b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); - b.string("null"); - for (Instruction instr : m.getInstructions()) { - b.doubleQuote(instr.name); - } - b.end(); + // instruction names + b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); + b.string("null"); + for (Instruction instr : m.getInstructions()) { + b.doubleQuote(instr.name); + } + b.end(); - // specialization names + // specialization names - b.startNewArray(new ArrayCodeTypeMirror(new ArrayCodeTypeMirror(context.getType(String.class))), null); - b.string("null"); - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - b.string("null"); - continue; - } + b.startNewArray(new ArrayCodeTypeMirror(new ArrayCodeTypeMirror(context.getType(String.class))), null); + b.string("null"); + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + b.string("null"); + continue; + } - b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); - CustomInstruction cinstr = (CustomInstruction) instr; - for (String name : cinstr.getSpecializationNames()) { - b.doubleQuote(name); - } - b.end(); + b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); + CustomInstruction cinstr = (CustomInstruction) instr; + for (String name : cinstr.getSpecializationNames()) { + b.doubleQuote(name); } b.end(); + } + b.end(); - b.end(2); + b.end(2); - } } CodeVariableElement fldLanguage = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getLanguageType(), "language"); @@ -466,12 +464,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = mDoLeave.createBuilder(); - b.startWhile().string("getCurStack() > data.stackDepth").end(); - b.startBlock(); - - b.tree(m.getOperationsContext().commonPop.createEmitCode(vars, new CodeTree[0])); - - b.end(); + // b.startWhile().string("getCurStack() > data.stackDepth").end(); + // b.startBlock(); + // + // b.tree(m.getOperationsContext().commonPop.createEmitCode(vars, new CodeTree[0])); + // + // b.end(); b.startSwitch().string("data.operationId").end(); b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 7c1de867bbdc..cfd3b7b3031c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -22,6 +22,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; public class OperationsContext { @@ -29,10 +30,9 @@ public class OperationsContext { private int operationId = 1; public Instruction commonPop; - public Instruction commonBranch; - public Instruction commonBranchFalse; + public Instruction commonThrow; public LoadArgumentInstruction[] loadArgumentInstructions; public LoadConstantInstruction[] loadConstantInstructions; @@ -59,10 +59,9 @@ public void initializeContext() { private void createCommonInstructions() { commonPop = add(new DiscardInstruction("pop", instructionId++, InputType.STACK_VALUE_IGNORED)); - commonBranch = add(new BranchInstruction(instructionId++)); - commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++)); + commonThrow = add(new ThrowInstruction(instructionId++)); } private void createBuiltinOperations() { @@ -72,6 +71,7 @@ private void createBuiltinOperations() { add(new Operation.IfThenElse(this, operationId++, true)); add(new Operation.While(this, operationId++)); add(new Operation.TryCatch(this, operationId++)); + add(new Operation.FinallyTry(this, operationId++)); add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 7e662cac2e43..17b09f4adc39 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -136,7 +136,8 @@ protected OperationsData parse(Element element, List mirror) { return data; } - data.setDecisionsFilePath(getMainDecisionsFilePath(typeElement, generateOperationsMirror)); + String decisionsFilePath = getMainDecisionsFilePath(typeElement, generateOperationsMirror); + data.setDecisionsFilePath(decisionsFilePath); AnnotationValue forceTracingValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true); @@ -144,6 +145,12 @@ protected OperationsData parse(Element element, List mirror) { if ((boolean) forceTracingValue.getValue()) { isTracing = true; data.addWarning("Tracing compilation is forced. This should only be used during development."); + if (decisionsFilePath == null) { + data.addError("Tracing forced, but no decisions file specified! Specify the tracing decisions file."); + } + } else if (decisionsFilePath == null) { + // decisions file not specified, can't trace no matter the options + isTracing = false; } else { isTracing = TruffleProcessorOptions.operationsEnableTracing(processingEnv); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 0c0b4141b136..deb0f46c0dda 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -77,7 +77,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { + public CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); TruffleTypes types = ProcessorContext.getInstance().getTypes(); @@ -86,8 +86,6 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { b.startGroup().cast(types.BuilderOperationLabel).tree(arguments[0]).end(); b.end(2); - b.tree(super.createEmitCode(vars, arguments)); - return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index ff2cdeb40007..ea65819bd273 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -454,9 +454,21 @@ public List getBuilderArgumentTypes() { return result; } - public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { + @SuppressWarnings("unused") + protected CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { + return null; + } + + @SuppressWarnings("unused") + protected CodeTree createCustomEmitCodeAfter(BuilderVariables vars, CodeTree[] arguments) { + return null; + } + + public final CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(createCustomEmitCode(vars, arguments)); + // calculate stack offset int numPush = numPush(); CodeTree numPop = numPop(vars); @@ -486,6 +498,8 @@ public CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.tree(createCustomEmitCodeAfter(vars, arguments)); + return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 72011cd7bc2d..29e120afaa2c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -2,6 +2,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class ReturnInstruction extends Instruction { @@ -23,7 +24,17 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); return b.build(); + } + + @Override + public CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement().startCall("calculateLeaves"); + b.startGroup().variable(vars.operationData).end(); + b.end(2); + + return b.build(); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java new file mode 100644 index 000000000000..9a912bc71114 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -0,0 +1,52 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class ThrowInstruction extends Instruction { + public ThrowInstruction(int id) { + super("throw", id, new ResultType[0], InputType.LOCAL); + } + + @Override + public boolean standardPrologue() { + return false; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + // TODO since we do not have a typecheck in a catch + // we can convert this to a jump to a statically determined handler + // or a throw out of a function + + b.startAssign("int slot").startCall("LE_BYTES", "getShort"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); + b.end(2); + + b.startThrow(); + b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); + b.startCall(vars.frame, "getObject").string("slot").end(); + b.end(); + + return b.build(); + } + + @Override + public boolean isBranchInstruction() { + return true; + } + + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; + } +} From 84a601eed5c867eb490cc9142f7f4f64c8378f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 4 May 2022 15:12:05 +0200 Subject: [PATCH 073/312] [wip] fix exception handler ordering --- .../sl/operations/SLOperationsBuilder.java | 2 +- .../example/TestOperationsParserTest.java | 55 +++++++++++++++++++ .../OperationsBytecodeCodeGenerator.java | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 06af70468238..0da71a24c51b 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -5990,7 +5990,7 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { } } catch (AbstractTruffleException ex) { CompilerAsserts.partialEvaluationConstant(bci); - for (int handlerIndex = 0; handlerIndex < handlers.length; handlerIndex++) { + for (int handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) { CompilerAsserts.partialEvaluationConstant(handlerIndex); BuilderExceptionHandler handler = handlers[handlerIndex]; if (handler.startBci > bci || handler.endBci <= bci) continue; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 9441d0b20fa7..ec98e3087a52 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -741,4 +741,59 @@ public void testFinallyTryNestedFinally() { testOrdering(false, root, 1L, 3L, 5L); } + + @Test + public void testFinallyTryNestedTryThrow() { + RootCallTarget root = parse(b -> { + + // try { try { 1; throw; 2; } finally { 3; } } finally { 4; } + // expected: 1, 3, 4 + + b.beginFinallyTry(0); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginFinallyTry(1); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.emitThrowOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + } + b.endFinallyTry(); + + b.build(); + }); + + testOrdering(true, root, 1L, 3L, 4L); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 3220c3060ffa..67953dde3d59 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -368,7 +368,7 @@ public CodeTypeElement createBuilderBytecodeNode() { // b.end(2); // } - b.startFor().string("int handlerIndex = 0; handlerIndex < " + fldHandlers.getName() + ".length; handlerIndex++").end(); + b.startFor().string("int handlerIndex = " + fldHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); b.startBlock(); b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); From 4f49c8f1f07e6ae8c403e06cef4b76391b628efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 5 May 2022 13:13:42 +0200 Subject: [PATCH 074/312] [wip] FinallyTry --- .../sl/operations/SLOperationsBuilder.java | 5861 +++++++++-------- .../test/example/TestLanguageAst.java | 50 - .../test/example/TestLanguageBackend.java | 178 - .../test/example/TestLanguageParser.java | 93 - .../test/example/TestOperations.java | 13 +- .../example/TestOperationsParserTest.java | 369 +- .../operation/BuilderExceptionHandler.java | 2 +- .../api/operation/BuilderOperationData.java | 2 + .../api/operation/BuilderOperationLocal.java | 12 + .../truffle/api/operation/OperationLocal.java | 5 + .../api/operation/OperationsBuilder.java | 57 +- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Operation.java | 94 +- .../OperationsBytecodeCodeGenerator.java | 10 +- .../operations/OperationsCodeGenerator.java | 10 +- .../operations/OperationsContext.java | 3 +- .../operations/instructions/Instruction.java | 7 +- .../sl/parser/SLOperationsVisitor.java | 150 +- 18 files changed, 3427 insertions(+), 3491 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 0da71a24c51b..bc097533e688 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -31,6 +31,7 @@ import com.oracle.truffle.api.operation.BuilderOperationLabel; import com.oracle.truffle.api.operation.BuilderSourceInfo; import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationsBuilder; import com.oracle.truffle.api.operation.OperationsBytesSupport; import com.oracle.truffle.api.operation.OperationsConstantPool; @@ -103,10 +104,14 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endTryCatch(); - public abstract void beginFinallyTry(int arg0); + public abstract void beginFinallyTry(); public abstract void endFinallyTry(); + public abstract void beginFinallyTryNoExcept(); + + public abstract void endFinallyTryNoExcept(); + public abstract void emitLabel(OperationLabel arg0); public abstract void emitBranch(OperationLabel arg0); @@ -115,11 +120,11 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void emitLoadArgument(int arg0); - public abstract void beginStoreLocal(int arg0); + public abstract void beginStoreLocal(OperationLocal arg0); public abstract void endStoreLocal(); - public abstract void emitLoadLocal(int arg0); + public abstract void emitLoadLocal(OperationLocal arg0); public abstract void beginReturn(); @@ -190,20 +195,20 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endSLInvokeOperation(); public static OperationsNode[] parse(SLLanguage language, SLSource context) { - SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, false, false); + BuilderImpl builder = new BuilderImpl(language, context, false, false); SLOperations.parse(language, context, builder); return builder.collect(); } public static OperationsNode[] parseWithSourceInfo(SLLanguage language, SLSource context) { - SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); + BuilderImpl builder = new BuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); return builder.collect(); } @GeneratedBy(SLOperations.class) @SuppressWarnings({"cast", "hiding", "unchecked", "rawtypes", "static-method"}) - private static class SLOperationsBuilderImpl extends SLOperationsBuilder { + private static class BuilderImpl extends SLOperationsBuilder { private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); private static final int OP_BLOCK = 1; @@ -213,43 +218,44 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { private static final int OP_WHILE = 5; private static final int OP_TRY_CATCH = 6; private static final int OP_FINALLY_TRY = 7; - private static final int OP_LABEL = 8; - private static final int OP_BRANCH = 9; - private static final int OP_CONST_OBJECT = 10; - private static final int OP_LOAD_ARGUMENT = 11; - private static final int OP_STORE_LOCAL = 12; - private static final int OP_LOAD_LOCAL = 13; - private static final int OP_RETURN = 14; - private static final int OP_INSTRUMENTATION = 15; - private static final int OP_SLADD_OPERATION = 16; - private static final int OP_SLDIV_OPERATION = 17; - private static final int OP_SLEQUAL_OPERATION = 18; - private static final int OP_SLLESS_OR_EQUAL_OPERATION = 19; - private static final int OP_SLLESS_THAN_OPERATION = 20; - private static final int OP_SLLOGICAL_NOT_OPERATION = 21; - private static final int OP_SLMUL_OPERATION = 22; - private static final int OP_SLREAD_PROPERTY_OPERATION = 23; - private static final int OP_SLSUB_OPERATION = 24; - private static final int OP_SLWRITE_PROPERTY_OPERATION = 25; - private static final int OP_SLUNBOX_OPERATION = 26; - private static final int OP_SLFUNCTION_LITERAL_OPERATION = 27; - private static final int OP_SLTO_BOOLEAN_OPERATION = 28; - private static final int OP_SLEVAL_ROOT_OPERATION = 29; - private static final int OP_SLINVOKE_OPERATION = 30; + private static final int OP_FINALLY_TRY_NO_EXCEPT = 8; + private static final int OP_LABEL = 9; + private static final int OP_BRANCH = 10; + private static final int OP_CONST_OBJECT = 11; + private static final int OP_LOAD_ARGUMENT = 12; + private static final int OP_STORE_LOCAL = 13; + private static final int OP_LOAD_LOCAL = 14; + private static final int OP_RETURN = 15; + private static final int OP_INSTRUMENTATION = 16; + private static final int OP_SLADD_OPERATION = 17; + private static final int OP_SLDIV_OPERATION = 18; + private static final int OP_SLEQUAL_OPERATION = 19; + private static final int OP_SLLESS_OR_EQUAL_OPERATION = 20; + private static final int OP_SLLESS_THAN_OPERATION = 21; + private static final int OP_SLLOGICAL_NOT_OPERATION = 22; + private static final int OP_SLMUL_OPERATION = 23; + private static final int OP_SLREAD_PROPERTY_OPERATION = 24; + private static final int OP_SLSUB_OPERATION = 25; + private static final int OP_SLWRITE_PROPERTY_OPERATION = 26; + private static final int OP_SLUNBOX_OPERATION = 27; + private static final int OP_SLFUNCTION_LITERAL_OPERATION = 28; + private static final int OP_SLTO_BOOLEAN_OPERATION = 29; + private static final int OP_SLEVAL_ROOT_OPERATION = 30; + private static final int OP_SLINVOKE_OPERATION = 31; private static final int INSTR_POP = 1; private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_CONSTANT_LONG = 7; + private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_LOAD_ARGUMENT_LONG = 10; + private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; - private static final int INSTR_LOAD_LOCAL_LONG = 14; + private static final int INSTR_LOAD_LOCAL_LONG = 13; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -286,13 +292,13 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; @@ -311,7 +317,7 @@ private static class SLOperationsBuilderImpl extends SLOperationsBuilder { int nodeNumber = 0; OperationsConstantPool constPool = new OperationsConstantPool(); - SLOperationsBuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { + BuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { this.language = language; this.parseContext = parseContext; this.keepSourceInfo = keepSourceInfo; @@ -358,7 +364,7 @@ public OperationsNode buildImpl() { for (int i = 0; i < numBranchProfiles; i++) { condProfiles[i] = ConditionProfile.createCountingProfile(); } - result = new SLOperationsBuilderImplBytecodeNode(parseContext, sourceInfo, sources, nodeNumber, createMaxStack(), maxLocals + 1, bcCopy, cpCopy, new Node[numChildNodes], handlers, condProfiles); + result = new BytecodeNode(parseContext, sourceInfo, sources, nodeNumber, createMaxStack(), numLocals, bcCopy, cpCopy, new Node[numChildNodes], handlers, condProfiles); builtNodes.add(result); nodeNumber++; reset(); @@ -373,6 +379,11 @@ protected void doLeaveOperation(BuilderOperationData data) { bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); break; } + case OP_FINALLY_TRY_NO_EXCEPT : + { + bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); + break; + } case OP_INSTRUMENTATION : { int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); @@ -614,12 +625,28 @@ void doAfterChild() { BuilderExceptionHandler beh = new BuilderExceptionHandler(); beh.startBci = bci; beh.startStack = getCurStack(); - beh.exceptionIndex = (int)trackLocalsHelper(operationData.arguments[0]); + beh.exceptionIndex = getLocalIndex(operationData.aux[2]); exceptionHandlers.add(beh); operationData.aux[1] = beh; } break; } + case OP_FINALLY_TRY_NO_EXCEPT : + { + for (int i = 0; i < lastPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_POP); + bci = bci + 2; + } + if (childIndex == 0) { + doEndFinallyBlock0(bc, bci, exceptionHandlers); + bc = doFinallyRestoreBc(); + bci = doFinallyRestoreBci(); + exceptionHandlers = doFinallyRestoreExceptions(); + doEndFinallyBlock1(); + } + break; + } } } @@ -769,9 +796,10 @@ public void endTryCatch() { @SuppressWarnings("unused") @Override - public void beginFinallyTry(int arg0) { + public void beginFinallyTry() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, getCurStack(), 2, true, arg0); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, getCurStack(), 3, true); + operationData.aux[2] = createParentLocal(); operationData.aux[0] = doBeginFinallyTry(bc, bci, exceptionHandlers); bc = new byte[65535]; bci = 0; @@ -805,7 +833,7 @@ public void endFinallyTry() { { int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_THROW); - LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); + LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.aux[2])); bci = bci + 4; } doEmitLabel(bci, endLabel); @@ -814,6 +842,33 @@ public void endFinallyTry() { doAfterChild(); } + @SuppressWarnings("unused") + @Override + public void beginFinallyTryNoExcept() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, getCurStack(), 1, true); + operationData.aux[0] = doBeginFinallyTry(bc, bci, exceptionHandlers); + bc = new byte[65535]; + bci = 0; + exceptionHandlers = new ArrayList(); + } + + @SuppressWarnings("unused") + @Override + public void endFinallyTryNoExcept() { + if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); + } + bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); + lastPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + @Override public void emitLabel(OperationLabel arg0) { doBeforeChild(); @@ -865,7 +920,7 @@ public void emitLoadArgument(int arg0) { @SuppressWarnings("unused") @Override - public void beginStoreLocal(int arg0) { + public void beginStoreLocal(OperationLocal arg0) { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, getCurStack(), 0, false, arg0); } @@ -883,7 +938,7 @@ public void endStoreLocal() { int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 3, (short) (int) trackLocalsHelper(operationData.arguments[0])); + LE_BYTES.putShort(bc, bci + 3, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 5; lastPush = 0; operationData = operationData.parent; @@ -891,12 +946,12 @@ public void endStoreLocal() { } @Override - public void emitLoadLocal(int arg0) { + public void emitLoadLocal(OperationLocal arg0) { doBeforeChild(); operationData = new BuilderOperationData(this.operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); - LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); + LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 4; lastPush = 1; operationData = operationData.parent; @@ -1481,7 +1536,7 @@ public void endSLInvokeOperation() { } private static OperationsNode reparse(SLLanguage language, SLSource context, int buildOrder) { - SLOperationsBuilderImpl builder = new SLOperationsBuilderImpl(language, context, true, true); + BuilderImpl builder = new BuilderImpl(language, context, true, true); SLOperations.parse(language, context, builder); return builder.collect()[buildOrder]; } @@ -1517,13 +1572,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: @@ -1535,13 +1590,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: @@ -1559,13 +1614,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: @@ -2012,7 +2067,7 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int */ @GeneratedBy(SLOperations.class) - private static final class SLOperationsBuilderImplBytecodeNode extends OperationsNode implements Provider { + private static final class BytecodeNode extends OperationsNode implements Provider { private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory INTEROP_LIBRARY__ = LibraryFactory.resolve(InteropLibrary.class); @@ -2035,7 +2090,7 @@ private static final class SLOperationsBuilderImplBytecodeNode extends Operation @CompilationFinal(dimensions = 1) private final BuilderExceptionHandler[] handlers; @CompilationFinal(dimensions = 1) private final ConditionProfile[] conditionProfiles; - SLOperationsBuilderImplBytecodeNode(Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + BytecodeNode(Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { super(parseContext, sourceInfo, sources, buildOrder, maxStack, maxLocals); this.bc = bc; this.consts = consts; @@ -2044,481 +2099,384 @@ private static final class SLOperationsBuilderImplBytecodeNode extends Operation this.conditionProfiles = conditionProfiles; } - private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - SLAddOperation_SLAddOperation_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLAddOperation_SLAddOperation_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @Override + protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { + int sp = startSp; + int bci = startBci; + Object returnValue = null; + loop: while (true) { + int nextBci; + short curOpcode = LE_BYTES.getShort(bc, bci); try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLAddNode.addLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; + CompilerAsserts.partialEvaluationConstant(bci); + CompilerAsserts.partialEvaluationConstant(sp); + CompilerAsserts.partialEvaluationConstant(curOpcode); + if (sp < maxLocals + VALUES_OFFSET) { + throw CompilerDirectives.shouldNotReachHere("stack underflow"); } - } - } - if (((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); - return; - } - } - if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { - if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); - return; + switch (curOpcode) { + case INSTR_POP : + { + sp = sp - 1; + frame.clear(sp); + nextBci = bci + 2; + break; } - } - } - if (((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */)) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLAddOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; + case INSTR_BRANCH : + { + int targetBci = LE_BYTES.getShort(bc, bci + 2); + if (targetBci <= bci) { + TruffleSafepoint.poll(this); + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { + Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); + if (osrResult != null) { + return osrResult; + } + } + } + bci = targetBci; + continue loop; } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 2]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); - bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + case INSTR_BRANCH_FALSE : + { + ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; + boolean cond = (boolean) frame.getObject(sp - 1); + sp -= 1; + if (profile.profile(cond)) { + bci = bci + 7; + continue loop; + } else { + bci = LE_BYTES.getShort(bc, bci + 2); + continue loop; + } } - int type0; - int type1; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; + case INSTR_THROW : + { + int slot = LE_BYTES.getShort(bc, bci + 2); + throw (AbstractTruffleException) frame.getObject(slot); } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); + case INSTR_LOAD_CONSTANT_OBJECT : + { + frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_CONSTANT_LONG : + { + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + frame.setObject(sp, value); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { - $frame.setLong($sp - 2, value); + frame.setObject(sp, value); } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); + sp = sp + 1; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); + } else { + frame.setObject(sp, value); } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; + sp = sp + 1; + nextBci = bci + 4; + break; } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); - state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); - return; + case INSTR_STORE_LOCAL : + { + assert frame.isObject(sp - 1); + frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); + frame.clear(--sp); + nextBci = bci + 5; + break; } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAddOperation_Add1Data s2_ = super.insert(new SLAddOperation_Add1Data()); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLDivOperation_SLDivOperation_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLDivOperation_SLDivOperation_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; - try { - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLDivNode.divLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); + case INSTR_LOAD_LOCAL_OBJECT : + { + frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); + sp++; + nextBci = bci + 4; + break; } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); + case INSTR_LOAD_LOCAL_LONG : + { + Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); + if (value instanceof Long) { + frame.setLong(sp, (long) value); + } else { + frame.setObject(sp, value); + } + sp++; + nextBci = bci + 4; + break; } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLDivOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); + case INSTR_LOAD_LOCAL_BOOLEAN : + { + Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { - $frame.setLong($sp - 2, value); + frame.setObject(sp, value); } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); + sp++; + nextBci = bci + 4; + break; + } + case INSTR_RETURN : + { + returnValue = frame.getObject(sp - 1); + break loop; + } + case INSTR_C_SLADD_OPERATION : + { + this.SLAddOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLDIV_OPERATION : + { + this.SLDivOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLEQUAL_OPERATION : + { + this.SLEqualOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + { + this.SLLessOrEqualOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION : + { + this.SLLessThanOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLLOGICAL_NOT_OPERATION : + { + this.SLLogicalNotOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLMUL_OPERATION : + { + this.SLMulOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION : + { + this.SLReadPropertyOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLSUB_OPERATION : + { + this.SLSubOperation_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION : + { + this.SLWritePropertyOperation_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLUNBOX_OPERATION : + { + this.SLUnboxOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + { + this.SLFunctionLiteralOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION : + { + this.SLToBooleanOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLEVAL_ROOT_OPERATION : + { + this.SLEvalRootOperation_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLINVOKE_OPERATION : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; + Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); - return; + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : + { + this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 1]; - if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_SLEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0, state_1); - return; - } else if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); - return; - } else { - SLEqualOperation_SLEqualOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); - return; - } - } - - private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : + { + this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : + { + this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : + { + this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + { + this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : + { + this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : + { + this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : + { + this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : + { + this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant(bci); + for (int handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + BuilderExceptionHandler handler = handlers[handlerIndex]; + if (handler.startBci > bci || handler.endBci <= bci) continue; + sp = handler.startStack + VALUES_OFFSET + maxLocals; + frame.setObject(VALUES_OFFSET + handler.exceptionIndex, ex); + bci = handler.handlerBci; + continue loop; + } + throw ex; + } + CompilerAsserts.partialEvaluationConstant(nextBci); + bci = nextBci; + } + return returnValue; + } + + private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + SLAddOperation_SLAddOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLAddOperation_SLAddOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -2527,7 +2485,7 @@ private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } long $child1Value_; @@ -2537,206 +2495,121 @@ private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - boolean $child0Value_; - if ($frame.isBoolean($sp - 2)) { - $child0Value_ = $frame.getBoolean($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - boolean $child1Value_; - if ($frame.isBoolean($sp - 1)) { - $child1Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child1Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); } - } finally { - encapsulating_.set(prev_); + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; } } - @ExplodeLoop - private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { + if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); + try { + long value = SLAddNode.addLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; } - return; } } - if (((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); - boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + if (((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); return; } } - if (((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */) && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */) && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - boolean value = SLEqualNode.doString($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */) && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */) && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */) && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); - while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value_))) { - boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - s7_ = s7_.next_; - } - } - if (((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - $frame.setObject($sp - 2, this.SLEqualOperation_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); - return; + if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { + if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { + SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); + return; + } + } + } + if (((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */)) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLAddOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 1]; - byte exclude = bc[$bci + 4 + 6]; - if ($child0Value instanceof Long) { + byte state_1 = bc[$bci + 4 + 2]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); - bc[$bci + 4 + 1] = (byte) (state_1); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); + bc[$bci + 4 + 2] = (byte) (state_1); + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + } int type0; int type1; - if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -2745,15 +2618,28 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); + try { + lock.unlock(); + hasLock = false; + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; } - return; } } { @@ -2763,10 +2649,13 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); - state_1 = (byte) (state_1 | (sLBigNumberCast1 << 4) /* set-implicit-state_1 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - bc[$bci + 4 + 1] = (byte) (state_1); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); + state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2775,118 +2664,21 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); return; } } } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - type0 = FRAME_TYPE_BOOLEAN; - type1 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doString($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0] = super.insert((EqualNode.create())); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); - bc[$bci + 4 + 1] = (byte) (state_1); + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAddOperation_Add1Data s2_ = super.insert(new SLAddOperation_Add1Data()); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2895,90 +2687,27 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); return; } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); - if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value)); - if (count7_ < (4)) { - s7_ = super.insert(new SLEqualOperation_Generic0Data(((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = s7_; - bc[$bci + 4 + 0] = (byte) (state_0); - bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - bc[$bci + 4 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = null; - state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - bc[$bci + 4 + 0] = (byte) (state_0); - bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } finally { - encapsulating_.set(prev_); - } - } + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); + bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; } } finally { if (hasLock) { @@ -2987,18 +2716,18 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } } - private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0); + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLDivOperation_SLDivOperation_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLDivOperation_SLDivOperation_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -3007,7 +2736,7 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_( } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } long $child1Value_; @@ -3017,47 +2746,70 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_( $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); + assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; + try { + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; } - return; } - private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); + try { + long value = SLDivNode.divLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; } - return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); return; } } @@ -3065,36 +2817,32 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(Vi { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLLessOrEqualOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + if (SLDivOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; - if ($child0Value instanceof Long) { + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); - } + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3103,15 +2851,28 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i } doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); + try { + lock.unlock(); + hasLock = false; + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; } - return; } } { @@ -3121,10 +2882,11 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3133,12 +2895,7 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); return; } } @@ -3149,7 +2906,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3158,7 +2914,7 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); return; } } finally { @@ -3168,18 +2924,22 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i } } - private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessThanOperation_SLLessThanOperation_execute__long_long0_($frame, $bci, $sp, state_0); + byte state_1 = bc[$bci + 4 + 1]; + if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_SLEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0, state_1); + return; + } else if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); return; } else { - SLLessThanOperation_SLLessThanOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLEqualOperation_SLEqualOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); return; } } - private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -3188,7 +2948,7 @@ private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(Virtua } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } long $child1Value_; @@ -3198,11 +2958,11 @@ private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(Virtua $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3211,16 +2971,65 @@ private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(Virtua return; } - private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 2)) { + $child0Value_ = $frame.getBoolean($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + boolean $child1Value_; + if ($frame.isBoolean($sp - 1)) { + $child1Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child1Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3229,11 +3038,11 @@ private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualF return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); + boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3242,40 +3051,113 @@ private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualF return; } } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLLessThanOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + if (((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */) && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */) && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + boolean value = SLEqualNode.doString($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */) && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */) && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */) && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value_))) { + boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + s7_ = s7_.next_; + } + } + if (((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + $frame.setObject($sp - 2, this.SLEqualOperation_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; + byte state_1 = bc[$bci + 4 + 1]; + byte exclude = bc[$bci + 4 + 6]; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); - } + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); + bc[$bci + 4 + 1] = (byte) (state_1); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3286,7 +3168,7 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3302,10 +3184,10 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); + state_1 = (byte) (state_1 | (sLBigNumberCast1 << 4) /* set-implicit-state_1 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 1] = (byte) (state_1); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3314,7 +3196,7 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3324,130 +3206,200 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int } } } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); + bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; + if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + type0 = FRAME_TYPE_BOOLEAN; + type1 = FRAME_TYPE_BOOLEAN; + } else { + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } } - } finally { - if (hasLock) { - lock.unlock(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); + bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doString($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } } - } - } - - private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_($frame, $bci, $sp, state_0); - return; - } else { - SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLLogicalNotNode.doBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLLogicalNotOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0] = super.insert((EqualNode.create())); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } return; } } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - type0 = FRAME_TYPE_BOOLEAN; - } else { + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); + bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); + bc[$bci + 4 + 1] = (byte) (state_1); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); + boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); + $frame.setObject($sp - 2, value); } else { - $frame.setBoolean($sp - 1, value); + $frame.setBoolean($sp - 2, value); } return; } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value)); + if (count7_ < (4)) { + s7_ = super.insert(new SLEqualOperation_Generic0Data(((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = s7_; + bc[$bci + 4 + 0] = (byte) (state_0); + bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); - return; + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + bc[$bci + 4 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = null; + state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + bc[$bci + 4 + 0] = (byte) (state_0); + bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } finally { + encapsulating_.set(prev_); + } + } } } finally { if (hasLock) { @@ -3456,18 +3408,18 @@ private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, in } } - private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLMulOperation_SLMulOperation_execute__long_long0_($frame, $bci, $sp, state_0); + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLMulOperation_SLMulOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -3476,7 +3428,7 @@ private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $fr } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } long $child1Value_; @@ -3486,70 +3438,47 @@ private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $fr $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; - try { - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } + return; } - private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - try { - long value = SLMulNode.mulLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } + return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } return; } } @@ -3557,32 +3486,36 @@ private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLMulOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + if (SLLessOrEqualOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + } int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3591,28 +3524,15 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; + lock.unlock(); + hasLock = false; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } + return; } } { @@ -3622,11 +3542,10 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3635,7 +3554,12 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } return; } } @@ -3646,6 +3570,7 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3654,7 +3579,7 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); return; } } finally { @@ -3664,385 +3589,287 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } } - @ExplodeLoop - private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessThanOperation_SLLessThanOperation_execute__long_long0_($frame, $bci, $sp, state_0); + return; + } else { + SLLessThanOperation_SLLessThanOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); - while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value_))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); - return; - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } + return; } - if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value__))) { - Node node__1 = (this); - int bci__1 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); - return; - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); - return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } + return; } - if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); - while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value_))) { - Node node__2 = (this); - int bci__2 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); - return; - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLLessThanOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { - { - Node readArray1_node__ = (this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadPropertyOperation_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { - { - Node readSLObject1_node__ = (this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3])); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { - { - Node readObject1_node__ = (this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); - } - } - - private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 5]; - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value))) { - node__ = (this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLReadPropertyOperation_ReadArray0Data(((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); - node__ = (this); - bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY__.create($child1Value))); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); - return; - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = (this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_))) { - node__1 = (this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLReadPropertyOperation_ReadSLObject0Data(((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); - node__1 = (this); - bci__1 = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - } - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); - return; - } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = (this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = super.insert((SLToTruffleStringNodeGen.create())); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; - state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; + } else { + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + } doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } return; } } { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value))) { - node__2 = (this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); - InteropLibrary objects__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); - node__2 = (this); - bci__2 = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); - return; + return; } } } { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = (this); - readObject1_bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = super.insert((SLToMemberNodeGen.create())); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; - state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); - return; - } - } - } finally { - encapsulating_.set(prev_); - } + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_($frame, $bci, $sp, state_0); + return; + } else { + SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLLogicalNotNode.doBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLLogicalNotOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); + return; } } - throw new UnsupportedSpecializationException(this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + int type0; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + type0 = FRAME_TYPE_BOOLEAN; + } else { + type0 = FRAME_TYPE_OBJECT; + } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); + return; + } } finally { if (hasLock) { lock.unlock(); @@ -4050,18 +3877,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } } - private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLSubOperation_SLSubOperation_execute__long_long0_($frame, $bci, $sp, state_0); + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLMulOperation_SLMulOperation_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLSubOperation_SLSubOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLMulOperation_SLMulOperation_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; if ($frame.isLong($sp - 2)) { $child0Value_ = $frame.getLong($sp - 2); @@ -4070,7 +3897,7 @@ private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $fr } else { CompilerDirectives.transferToInterpreterAndInvalidate(); Object $child1Value = $frame.getValue($sp - 1); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } long $child1Value_; @@ -4080,12 +3907,12 @@ private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $fr $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; + assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; try { - long value = SLSubNode.subLong($child0Value_, $child1Value_); + long value = SLMulNode.mulLong($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -4097,27 +3924,27 @@ private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $fr Lock lock = getLock(); lock.lock(); try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } - private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_; $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; $child1Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; try { - long value = SLSubNode.subLong($child0Value__, $child1Value__); + long value = SLMulNode.mulLong($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -4129,21 +3956,21 @@ private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $fram Lock lock = getLock(); lock.lock(); try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); return; } } } - if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); + $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); return; } } @@ -4151,32 +3978,32 @@ private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLSubOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + if (SLMulOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 4 + 0]; byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -4188,7 +4015,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, try { lock.unlock(); hasLock = false; - long value = SLSubNode.subLong($child0Value_, $child1Value_); + long value = SLMulNode.mulLong($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -4199,12 +4026,12 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, // implicit transferToInterpreterAndInvalidate() lock.lock(); try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } @@ -4216,11 +4043,11 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4229,7 +4056,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); + $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); return; } } @@ -4248,7 +4075,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); return; } } finally { @@ -4259,34 +4086,34 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } @ExplodeLoop - private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; + private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 3); + $child0Value_ = $frame.getObject($sp - 2); Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 2); - Object $child2Value_; - $child2Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value_))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); return; } s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; } } @@ -4295,168 +4122,179 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in } } } - if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value__))) { + Node node__1 = (this); + int bci__1 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); return; } s2_ = s2_.next_; } } - if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); + if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); return; } } - if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value_))) { + Node node__2 = (this); + int bci__2 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); return; } s4_ = s4_.next_; } } - if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); - return; + if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); + Node readArray1_node__ = (this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); } } @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + private Object SLReadPropertyOperation_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value__)); - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); + Node readSLObject1_node__ = (this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3])); } } @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - Node writeObject1_node__ = (this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value_)); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); - } - } finally { - encapsulating_.set(prev_); + private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + { + Node readObject1_node__ = (this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); } } - private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { + private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { - byte state_0 = bc[$bci + 5 + 0]; - byte exclude = bc[$bci + 5 + 5]; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value))) { - break; + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 5]; + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value))) { + node__ = (this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; } - s0_ = s0_.next_; - count0_++; } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY___.create($child0Value))); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLWritePropertyOperation_WriteArray0Data(((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY___.create($child1Value))); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + if (s0_ == null) { + { + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = super.insert(new SLReadPropertyOperation_ReadArray0Data(((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); + node__ = (this); + bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY__.create($child1Value))); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + } } } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); - return; + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } } } { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { { - writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = (this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - int type2; type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__)); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); return; } } @@ -4467,85 +4305,91 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_))) { - break; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_))) { + node__1 = (this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; } - s2_ = s2_.next_; - count2_++; } - } - if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY__.create($child0Value_))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + if (s2_ == null) { + // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = super.insert(new SLReadPropertyOperation_ReadSLObject0Data(((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); + node__1 = (this); + bci__1 = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + } + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); } - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); - return; + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + return; + } } } { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value_)); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; - state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = (this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = super.insert((SLToTruffleStringNodeGen.create())); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; + state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - int type2; type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); return; } } { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__ = (this); - bci__ = ($bci); + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value))) { + node__2 = (this); + bci__2 = ($bci); break; } s4_ = s4_.next_; @@ -4553,74 +4397,73 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } } if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)); - s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); - node__ = (this); - bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY___.create($child0Value))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); + InteropLibrary objects__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); + node__2 = (this); + bci__2 = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + } } } if (s4_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); return; } } } { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = (this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value)); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; - state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); - return; + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = (this); + readObject1_bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = super.insert((SLToMemberNodeGen.create())); + bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; + state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + return; + } } } finally { encapsulating_.set(prev_); } } } - throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException(this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -4628,408 +4471,600 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } } - private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - byte state_1 = bc[$bci + 3 + 1]; - if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_SLUnboxOperation_execute__boolean0_($frame, $bci, $sp, state_0, state_1); - return; - } else if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_SLUnboxOperation_execute__long1_($frame, $bci, $sp, state_0, state_1); + private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLSubOperation_SLSubOperation_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLUnboxOperation_SLUnboxOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); + SLSubOperation_SLSubOperation_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); + private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + Object $child1Value = $frame.getValue($sp - 1); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); return; } - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - long $child0Value_; + long $child1Value_; if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); + $child1Value_ = $frame.getLong($sp - 1); } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 1); + $child1Value_ = (long) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); return; } - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); + assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); - return; - } - if (((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */) && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); - return; - } - if (((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */) && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLUnboxNode.fromBoolean($child0Value__); + long value = SLSubNode.subLong($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); + $frame.setObject($sp - 2, value); } else { - $frame.setBoolean($sp - 1, value); + $frame.setLong($sp - 2, value); } return; - } - if (((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - long value = SLUnboxNode.fromLong($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - if (((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); - return; - } - if (((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */) && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if (((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */) && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { - if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); - while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value_))) { - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); - return; + } + + private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLSubNode.subLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); } - s7_ = s7_.next_; + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + return; } } - if (((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - $frame.setObject($sp - 1, this.SLUnboxOperation_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); + } + if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); return; } } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLSubOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { - byte state_0 = bc[$bci + 3 + 0]; - byte state_1 = bc[$bci + 3 + 1]; - byte exclude = bc[$bci + 3 + 6]; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); - return; + byte state_0 = bc[$bci + 4 + 0]; + byte exclude = bc[$bci + 4 + 1]; + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + type0 = FRAME_TYPE_LONG; + type1 = FRAME_TYPE_LONG; + } else { + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + try { + lock.unlock(); + hasLock = false; + long value = SLSubNode.subLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); + state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + int type0; + int type1; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); int type0; + int type1; type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); return; } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); - bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } - int type0; - if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - type0 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + } finally { + if (hasLock) { lock.unlock(); - hasLock = false; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); - bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } - int type0; - if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - type0 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; + } + } + + @ExplodeLoop + private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 3); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 2); + Object $child2Value_; + $child2Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + s0_ = s0_.next_; + } } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); - if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value))) { - break; + if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + return; + } } - s7_ = s7_.next_; - count7_++; + } finally { + encapsulating_.set(prev_); } } - if (s7_ == null) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY____.create($child0Value))); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; - bc[$bci + 3 + 0] = (byte) (state_0); - bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + } + if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + s2_ = s2_.next_; } } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); return; } } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value)); - bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; - state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); - bc[$bci + 3 + 0] = (byte) (state_0); - bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); + if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); return; - } finally { - encapsulating_.set(prev_); } } } - } finally { - if (hasLock) { - lock.unlock(); - } } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; } - private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value__)); + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); - return; + Node writeObject1_node__ = (this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value_)); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); } + } finally { + encapsulating_.set(prev_); } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; } - private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { - byte state_0 = bc[$bci + 3 + 0]; - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); - node__ = (this); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); + byte state_0 = bc[$bci + 5 + 0]; + byte exclude = bc[$bci + 5 + 5]; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value))) { + break; + } + s0_ = s0_.next_; + count0_++; } - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); - return; } - } - throw new UnsupportedSpecializationException(this, new Node[] {null}, $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } + if (s0_ == null) { + { + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY___.create($child0Value))); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = super.insert(new SLWritePropertyOperation_WriteArray0Data(((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY___.create($child1Value))); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY__.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + } + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value_)); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; + state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + return; + } + } + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__ = (this); + bci__ = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)); + s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); + node__ = (this); + bci__ = ($bci); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY___.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = (this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value)); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; + state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + int type0; + int type1; + int type2; + type0 = FRAME_TYPE_OBJECT; + type1 = FRAME_TYPE_OBJECT; + type2 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); + doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + return; + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } } } - private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_($frame, $bci, $sp, state_0); + byte state_1 = bc[$bci + 3 + 1]; + if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_SLUnboxOperation_execute__boolean0_($frame, $bci, $sp, state_0, state_1); + return; + } else if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_SLUnboxOperation_execute__long1_($frame, $bci, $sp, state_0, state_1); return; } else { - SLToBooleanOperation_SLToBooleanOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLUnboxOperation_SLUnboxOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); return; } } - private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; if ($frame.isBoolean($sp - 1)) { $child0Value_ = $frame.getBoolean($sp - 1); @@ -5037,11 +5072,11 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(Virtua $child0Value_ = (boolean) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); return; } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { @@ -5050,12 +5085,59 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(Virtua return; } - private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + long $child0Value_; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + return; + } + if (((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */) && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); + return; + } + if (((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */) && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLToBooleanNode.doBoolean($child0Value__); + boolean value = SLUnboxNode.fromBoolean($child0Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { @@ -5063,42 +5145,98 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(Virtua } return; } - if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLToBooleanOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); + if (((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */) && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + long value = SLUnboxNode.fromLong($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if (((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); + return; + } + if (((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */) && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if (((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */) && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { + if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value_))) { + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + return; } - return; + s7_ = s7_.next_; } } + if (((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + $frame.setObject($sp - 1, this.SLUnboxOperation_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); + return; + } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); try { byte state_0 = bc[$bci + 3 + 0]; + byte state_1 = bc[$bci + 3 + 1]; + byte exclude = bc[$bci + 3 + 6]; + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); + bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); + bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); + bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); } int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { type0 = FRAME_TYPE_BOOLEAN; } else { type0 = FRAME_TYPE_OBJECT; @@ -5106,7 +5244,7 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - boolean value = SLToBooleanNode.doBoolean($child0Value_); + boolean value = SLUnboxNode.fromBoolean($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { @@ -5114,201 +5252,133 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int } return; } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); + bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + } int type0; - type0 = FRAME_TYPE_OBJECT; + if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + type0 = FRAME_TYPE_LONG; + } else { + type0 = FRAME_TYPE_OBJECT; + } doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + long value = SLUnboxNode.fromLong($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { - $frame.setBoolean($sp - 1, value); + $frame.setLong($sp - 1, value); } return; } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLEvalRootOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value_ instanceof Map) { - Map $child0Value__ = (Map) $child0Value_; - { - Node execute_node__ = (this); - $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value__, execute_node__)); - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */) { - if (SLEvalRootOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value_)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEvalRootOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; { - Node execute_node__ = null; - if ($child0Value instanceof Map) { - Map $child0Value_ = (Map) $child0Value; - execute_node__ = (this); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); + bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value_, execute_node__)); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); return; } } - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value)); - return; - } finally { - if (hasLock) { + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); + bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; } - } - } - - @ExplodeLoop - private Object SLInvokeOperation_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvokeOperation_removeDirect__($frame, $bci, $sp, s0_); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); + bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { + while (s7_ != null) { + if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value))) { + break; } - s0_ = s0_.next_; + s7_ = s7_.next_; + count7_++; } } - if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + if (s7_ == null) { + // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY____.create($child0Value))); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; + bc[$bci + 3 + 0] = (byte) (state_0); + bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + } } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = (this); - int interop_bci__ = ($bci); - return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + if (s7_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + return; } } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - byte exclude = bc[$bci + 5 + 5]; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2])) && Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); - if ((arg0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = super.insert(new SLInvokeOperation_DirectData(((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); - } - } - } - } - } - } - if (s0_ != null) { + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set(this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value)); + bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; + state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); + bc[$bci + 3 + 0] = (byte) (state_0); + bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); + return; + } finally { + encapsulating_.set(prev_); } } - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = super.insert((IndirectCallNode.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); - lock.unlock(); - hasLock = false; - return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_____.createDispatched(3))); - interop_node__ = (this); - interop_bci__ = ($bci); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); - lock.unlock(); - hasLock = false; - return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); } } finally { if (hasLock) { @@ -5317,694 +5387,679 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int } } - private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); + boolean hasLock = true; lock.lock(); try { - SLInvokeOperation_DirectData prev = null; - SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + byte state_0 = bc[$bci + 3 + 0]; + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); + node__ = (this); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); } else { - prev.next_ = prev.insertAccessor(cur.next_); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); } - break; + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; } - prev = cur; - cur = cur.next_; - } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } + throw new UnsupportedSpecializationException(this, new Node[] {null}, $frame.getValue($sp - 1)); } finally { - lock.unlock(); + if (hasLock) { + lock.unlock(); + } } } - private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 1); + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_($frame, $bci, $sp, state_0); + return; + } else { + SLToBooleanOperation_SLToBooleanOperation_execute__generic1_($frame, $bci, $sp, state_0); + return; + } + } + + private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); return; } - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { - $frame.setLong($sp - 1, value); + $frame.setBoolean($sp - 1, value); } return; } - private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); + private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLToBooleanNode.doBoolean($child0Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); + $frame.setObject($sp - 1, value); } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); + $frame.setBoolean($sp - 1, value); } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - } - - @ExplodeLoop - private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLToBooleanOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } return; } - s2_ = s2_.next_; } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - @ExplodeLoop - private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); - } - s0_ = s0_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); + boolean hasLock = true; lock.lock(); try { - SLInvokeOperation_DirectData prev = null; - SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; + byte state_0 = bc[$bci + 3 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); } - prev = cur; - cur = cur.next_; + int type0; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + type0 = FRAME_TYPE_BOOLEAN; + } else { + type0 = FRAME_TYPE_OBJECT; + } + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; } } finally { - lock.unlock(); + if (hasLock) { + lock.unlock(); + } } } - private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLEvalRootOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_; $child0Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ((state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value_ instanceof Map) { + Map $child0Value__ = (Map) $child0Value_; { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + Node execute_node__ = (this); + $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value__, execute_node__)); + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */) { + if (SLEvalRootOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value_)); return; } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLEvalRootOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - @ExplodeLoop - private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 3); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 2); - Object $child2Value_; - $child2Value_ = $frame.getObject($sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 3 + 0]; + { + Node execute_node__ = null; + if ($child0Value instanceof Map) { + Map $child0Value_ = (Map) $child0Value; + execute_node__ = (this); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value_, execute_node__)); return; } - s2_ = s2_.next_; } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } - long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); + int type0; + type0 = FRAME_TYPE_OBJECT; + doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value)); return; + } finally { + if (hasLock) { + lock.unlock(); + } } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; } - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @Override - protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { - int sp = startSp; - int bci = startBci; - Object returnValue = null; - loop: while (true) { - int nextBci; - short curOpcode = LE_BYTES.getShort(bc, bci); - try { - CompilerAsserts.partialEvaluationConstant(bci); - CompilerAsserts.partialEvaluationConstant(sp); - CompilerAsserts.partialEvaluationConstant(curOpcode); - if (sp < maxLocals + VALUES_OFFSET) { - throw CompilerDirectives.shouldNotReachHere("stack underflow"); - } - switch (curOpcode) { - case INSTR_POP : - { - sp = sp - 1; - frame.clear(sp); - nextBci = bci + 2; - break; - } - case INSTR_BRANCH : - { - int targetBci = LE_BYTES.getShort(bc, bci + 2); - if (targetBci <= bci) { - TruffleSafepoint.poll(this); - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { - Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); - if (osrResult != null) { - return osrResult; - } - } - } - bci = targetBci; - continue loop; - } - case INSTR_BRANCH_FALSE : - { - ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; - boolean cond = (boolean) frame.getObject(sp - 1); - sp -= 1; - if (profile.profile(cond)) { - bci = bci + 7; - continue loop; - } else { - bci = LE_BYTES.getShort(bc, bci + 2); - continue loop; - } - } - case INSTR_THROW : - { - int slot = LE_BYTES.getShort(bc, bci + 2); - throw (AbstractTruffleException) frame.getObject(slot); - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - frame.setObject(sp, value); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); - } else { - frame.setObject(sp, value); - } - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); - } else { - frame.setObject(sp, value); - } - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_STORE_LOCAL : - { - assert frame.isObject(sp - 1); - frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); - frame.clear(--sp); - nextBci = bci + 5; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); - sp++; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); - } else { - frame.setObject(sp, value); - } - sp++; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); - } else { - frame.setObject(sp, value); - } - sp++; - nextBci = bci + 4; - break; - } - case INSTR_RETURN : - { - returnValue = frame.getObject(sp - 1); - break loop; - } - case INSTR_C_SLADD_OPERATION : - { - this.SLAddOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLDIV_OPERATION : - { - this.SLDivOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLEQUAL_OPERATION : - { - this.SLEqualOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : - { - this.SLLessOrEqualOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLLESS_THAN_OPERATION : - { - this.SLLessThanOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLLOGICAL_NOT_OPERATION : - { - this.SLLogicalNotOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLMUL_OPERATION : - { - this.SLMulOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION : - { - this.SLReadPropertyOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLSUB_OPERATION : - { - this.SLSubOperation_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : - { - this.SLWritePropertyOperation_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX_OPERATION : - { - this.SLUnboxOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - { - this.SLFunctionLiteralOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLTO_BOOLEAN_OPERATION : - { - this.SLToBooleanOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLEVAL_ROOT_OPERATION : - { - this.SLEvalRootOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLINVOKE_OPERATION : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - { - this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - { - this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - { - this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : - { - this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : - { - this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; + + @ExplodeLoop + private Object SLInvokeOperation_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvokeOperation_removeDirect__($frame, $bci, $sp, s0_); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - { - this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; + } + if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = (this); + int interop_bci__ = ($bci); + return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + byte exclude = bc[$bci + 5 + 5]; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2])) && Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + break; + } + s0_ = s0_.next_; + count0_++; + } } - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); + if ((arg0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = super.insert(new SLInvokeOperation_DirectData(((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + } + } + } + } } - Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); } - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; + } + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = super.insert((IndirectCallNode.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_____.createDispatched(3))); + interop_node__ = (this); + interop_bci__ = ($bci); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); + lock.unlock(); + hasLock = false; + return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvokeOperation_DirectData prev = null; + SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); } - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + @ExplodeLoop + private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 2); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { + $child0Value_ = (boolean) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop + private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvokeOperation_DirectData prev = null; + SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); + break; } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant(bci); - for (int handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - BuilderExceptionHandler handler = handlers[handlerIndex]; - if (handler.startBci > bci || handler.endBci <= bci) continue; - sp = handler.startStack + VALUES_OFFSET + maxLocals; - frame.setObject(VALUES_OFFSET + handler.exceptionIndex, ex); - bci = handler.handlerBci; - continue loop; + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + @ExplodeLoop + private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_; + $child0Value_ = $frame.getObject($sp - 3); + Object $child1Value_; + $child1Value_ = $frame.getObject($sp - 2); + Object $child2Value_; + $child2Value_ = $frame.getObject($sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; } - throw ex; + s2_ = s2_.next_; } - CompilerAsserts.partialEvaluationConstant(nextBci); - bci = nextBci; } - return returnValue; + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; + } + + private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { + $child0Value_ = (long) $frame.getObject($sp - 2); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } + long $child1Value_; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { + $child1Value_ = (long) $frame.getObject($sp - 1); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; } @Override @@ -6021,11 +6076,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -6039,8 +6094,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6235,7 +6290,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6253,7 +6308,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6263,7 +6318,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6281,7 +6336,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6316,7 +6371,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6334,14 +6389,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6359,7 +6414,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6416,7 +6471,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6434,14 +6489,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6459,7 +6514,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -7170,7 +7225,7 @@ public String dump() { @Override public SourceSection getSourceSection() { if (sourceInfo == null) { - OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); + OperationsNode reparsed = BuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); copyReparsedInfo(reparsed); } return this.getSourceSectionImpl(); @@ -7179,7 +7234,7 @@ public SourceSection getSourceSection() { @Override protected SourceSection getSourceSectionAtBci(int bci) { if (sourceInfo == null) { - OperationsNode reparsed = SLOperationsBuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); + OperationsNode reparsed = BuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); copyReparsedInfo(reparsed); } return this.getSourceSectionAtBciImpl(bci); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java deleted file mode 100644 index 99ea03be7904..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageAst.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -public abstract class TestLanguageAst { - final int startOffset; - final int length; - - public TestLanguageAst(int startOffset, int length) { - this.startOffset = startOffset; - this.length = length; - } - - public static class ListNode extends TestLanguageAst { - final TestLanguageAst[] children; - - public ListNode(int startOffset, int length, TestLanguageAst[] children) { - super(startOffset, length); - this.children = children; - } - - public boolean isEmpty() { - return children.length == 0; - } - - public TestLanguageAst get(int idx) { - return children[idx]; - } - - public int size() { - return children.length; - } - } - - public static class SymbolNode extends TestLanguageAst { - final String name; - - public SymbolNode(int startOffset, int length, String name) { - super(startOffset, length); - this.name = name; - } - } - - public static class NumberNode extends TestLanguageAst { - final long value; - - public NumberNode(int startOffset, int length, long value) { - super(startOffset, length); - this.value = value; - } - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java deleted file mode 100644 index 50ccc106fd04..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageBackend.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.ListNode; -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.NumberNode; -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.SymbolNode; -import com.oracle.truffle.api.source.Source; - -class TestLanguageBackend { - - private final TestOperationsBuilder b; - - public TestLanguageBackend(TestOperationsBuilder b) { - this.b = b; - } - - public void buildRoot(Source source, TestLanguageAst ast) { - b.beginSource(source); - build(ast); - b.endSource(); - System.out.println(b.build().dump()); - } - - private void build(TestLanguageAst ast) { - b.beginSourceSection(ast.startOffset); - if (ast instanceof ListNode) { - buildList((ListNode) ast); - } else if (ast instanceof NumberNode) { - b.emitConstObject(getLong(ast)); - } else { - throw new IllegalArgumentException("unexpected value"); - } - b.endSourceSection(ast.length); - } - - private static long getLong(TestLanguageAst ast) { - if (ast instanceof NumberNode) { - return ((NumberNode) ast).value; - } else { - throw new IllegalArgumentException("expected number"); - } - } - - private void buildList(ListNode ast) { - if (ast.isEmpty()) { - throw new IllegalArgumentException("illegal empty list"); - } - if (!(ast.get(0) instanceof SymbolNode)) { - throw new IllegalArgumentException("lists should always have symbol head"); - } - - SymbolNode head = (SymbolNode) ast.get(0); - - switch (head.name) { - case "add": - if (ast.size() != 3) { - throw new IllegalArgumentException("add expects 2 arguments"); - } - b.beginAddOperation(); - build(ast.get(1)); - build(ast.get(2)); - b.endAddOperation(); - break; - case "less": - if (ast.size() != 3) { - throw new IllegalArgumentException("add expects 2 arguments"); - } - b.beginLessThanOperation(); - build(ast.get(1)); - build(ast.get(2)); - b.endLessThanOperation(); - break; - case "if": - if (ast.size() == 3) { - b.beginIfThen(); - build(ast.get(1)); - build(ast.get(2)); - b.endIfThen(); - } else if (ast.size() == 4) { - b.beginIfThenElse(); - build(ast.get(1)); - build(ast.get(2)); - build(ast.get(3)); - b.endIfThenElse(); - } else { - throw new IllegalArgumentException("if expects 2 or 3 arguments"); - } - break; - case "cond": - if (ast.size() != 4) { - throw new IllegalArgumentException("cond expects 3 arguments"); - } - b.beginConditional(); - build(ast.get(1)); - build(ast.get(2)); - build(ast.get(3)); - b.endConditional(); - break; - case "local": - if (ast.size() != 2) { - throw new IllegalArgumentException("local expects 1 argument"); - } - b.emitLoadLocal((int) getLong(ast.get(1))); - break; - case "arg": - if (ast.size() != 2) { - throw new IllegalArgumentException("arg expects 1 argument"); - } - b.emitLoadArgument((int) getLong(ast.get(1))); - break; - case "setlocal": - if (ast.size() != 3) { - throw new IllegalArgumentException("local expects 1 argument"); - } - b.beginStoreLocal((int) getLong(ast.get(1))); - build(ast.get(2)); - b.endStoreLocal(); - break; - case "inclocal": - if (ast.size() != 3) { - throw new IllegalArgumentException("local expects 1 argument"); - } - b.beginStoreLocal((int) getLong(ast.get(1))); - b.beginAddOperation(); - b.emitLoadLocal((int) getLong(ast.get(1))); - build(ast.get(2)); - b.endAddOperation(); - b.endStoreLocal(); - break; - case "while": - if (ast.size() != 3) { - throw new IllegalArgumentException("while expects 2 arguments"); - } - b.beginWhile(); - build(ast.get(1)); - build(ast.get(2)); - b.endWhile(); - break; - case "return": - if (ast.size() != 2) { - throw new IllegalArgumentException("while expects 1 argument"); - } - b.beginReturn(); - build(ast.get(1)); - b.endReturn(); - break; - case "stmt": - b.beginInstrumentation(StatementTag.class); - for (int i = 1; i < ast.size(); i++) { - build(ast.get(i)); - } - b.endInstrumentation(); - break; - case "fail": - if (ast.size() != 1) { - throw new IllegalArgumentException("fail expects no arguments"); - } - b.emitThrowOperation(); - break; - case "try": - if (ast.size() != 4) { - throw new IllegalArgumentException("try expects 3 arguments"); - } - b.beginTryCatch((int) getLong(ast.get(1))); - build(ast.get(2)); - build(ast.get(3)); - b.endTryCatch(); - break; - case "do": - b.beginBlock(); - for (int i = 1; i < ast.size(); i++) { - build(ast.get(i)); - } - b.endBlock(); - break; - } - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java deleted file mode 100644 index d6bc08087c37..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguageParser.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import java.util.ArrayList; -import java.util.List; - -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.ListNode; -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.NumberNode; -import com.oracle.truffle.api.operation.test.example.TestLanguageAst.SymbolNode; -import com.oracle.truffle.api.source.Source; - -class TestLanguageParser { - int pos = 0; - final String src; - - public TestLanguageParser(Source s) { - this.src = s.getCharacters().toString(); - } - - private char readChar() { - char c = peekChar(); - pos++; - return c; - } - - private char peekChar(boolean skipWs) { - while (skipWs && pos < src.length() && Character.isWhitespace(src.charAt(pos))) { - pos++; - } - - if (pos >= src.length()) { - return '\0'; - } - - return src.charAt(pos); - } - - private char peekChar() { - return peekChar(true); - } - - public TestLanguageAst parse() { - char c = peekChar(); - if (c == '(') - return parseList(); - else if (Character.isDigit(c)) - return parseLong(); - else if (Character.isAlphabetic(c)) - return parseSymbol(); - else - throw new IllegalArgumentException("Parse error at: " + (pos - 1)); - } - - private ListNode parseList() { - List result = new ArrayList<>(); - - int start = pos; - - char openParen = readChar(); - assert openParen == '('; - - while (peekChar() != ')') { - if (peekChar() == '\0') { - throw new IllegalArgumentException("Expected ')', found EOF"); - } - result.add(parse()); - } - - readChar(); // read the ')' - - return new ListNode(start, pos - start, result.toArray(new TestLanguageAst[result.size()])); - } - - private NumberNode parseLong() { - long result = 0; - int start = pos; - - while (Character.isDigit(peekChar(false))) { - result = result * 10 + (readChar() - '0'); - } - - return new NumberNode(start, pos - start, result); - } - - private SymbolNode parseSymbol() { - StringBuilder sb = new StringBuilder(); - int start = pos; - while (Character.isAlphabetic(peekChar(false))) { - sb.append(readChar()); - } - - return new SymbolNode(start, pos - start, sb.toString()); - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index fa9952149fd3..1dcd70451832 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -6,6 +6,7 @@ import org.junit.Assert; import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; @@ -13,7 +14,6 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.Variadic; -import com.oracle.truffle.api.source.Source; @GenerateOperations @GenerateAOT @@ -28,14 +28,9 @@ public TestException(String string, OperationsNode node, int bci) { } } - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "unchecked"}) public static void parse(TestLanguage language, Object input, TestOperationsBuilder builder) { - if (input instanceof Source) { - Source source = (Source) input; - TestLanguageAst ast = new TestLanguageParser(source).parse(); - new TestLanguageBackend(builder).buildRoot(source, ast); - } else if (input instanceof Consumer) { - @SuppressWarnings("unchecked") + if (input instanceof Consumer) { Consumer callback = (Consumer) input; callback.accept(builder); } else { @@ -46,8 +41,6 @@ public static void parse(TestLanguage language, Object input, TestOperationsBuil @Operation @GenerateAOT static class AddOperation { - // @Cached(inline = true) MyOtherNode node; - @Specialization public static long add(long lhs, long rhs) { return lhs + rhs; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index ec98e3087a52..6afdec6e981c 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; @@ -14,7 +15,9 @@ import org.junit.Test; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.OperationsRootNode; import com.oracle.truffle.api.source.Source; @@ -22,43 +25,16 @@ public class TestOperationsParserTest { - private static class Tester { - private final OperationsNode node; - private final OperationsRootNode rootNode; - - Tester(String src, boolean withSourceInfo) { - Source s = Source.newBuilder("test-operations", src, "test").build(); - - if (withSourceInfo) { - node = TestOperationsBuilder.parseWithSourceInfo(null, s)[0]; - } else { - node = TestOperationsBuilder.parse(null, s)[0]; - } - rootNode = node.createRootNode(null, "TestFunction"); - } - - Tester(String src) { - this(src, false); - } - - public Tester test(Object expectedResult, Object... arguments) { - Object result = rootNode.getCallTarget().call(arguments); - Assert.assertEquals(expectedResult, result); - return this; - } - - public Tester then(Consumer action) { - action.accept(node); - return this; - } - } - private static RootCallTarget parse(Consumer builder) { - OperationsNode operationsNode = TestOperationsBuilder.parse(null, builder)[0]; + OperationsNode operationsNode = parseNode(builder); System.out.println(operationsNode.dump()); return operationsNode.createRootNode(null, "TestFunction").getCallTarget(); } + private static OperationsNode parseNode(Consumer builder) { + return TestOperationsBuilder.parse(null, builder)[0]; + } + @Test public void testAdd() { RootCallTarget root = parse(b -> { @@ -149,7 +125,61 @@ public void testSumLoop() { + " (inclocal 0 1)))" + " (return (local 1)))"; //@formatter:on - new Tester(src).test(45L, 10L); + + // i = 0; j = 0; + // while ( i < arg0 ) { j = j + i; i = i + 1; } + // return j; + + RootCallTarget root = parse(b -> { + OperationLocal locI = b.createLocal(); + OperationLocal locJ = b.createLocal(); + + b.beginStoreLocal(locI); + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginStoreLocal(locJ); + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginWhile(); + { + b.beginLessThanOperation(); + b.emitLoadLocal(locI); + b.emitLoadArgument(0); + b.endLessThanOperation(); + + b.beginBlock(); + { + b.beginStoreLocal(locJ); + { + b.beginAddOperation(); + b.emitLoadLocal(locJ); + b.emitLoadLocal(locI); + b.endAddOperation(); + } + b.endStoreLocal(); + + b.beginStoreLocal(locI); + { + b.beginAddOperation(); + b.emitLoadLocal(locI); + b.emitConstObject(1L); + b.endAddOperation(); + } + b.endStoreLocal(); + } + b.endBlock(); + } + b.endWhile(); + + b.beginReturn(); + b.emitLoadLocal(locJ); + b.endReturn(); + + }); + + Assert.assertEquals(45L, root.call(10L)); } @Test @@ -187,35 +217,39 @@ public void testTryCatch() { @Test public void testVariableBoxingElim() { RootCallTarget root = parse(b -> { - b.beginStoreLocal(0); + + OperationLocal local0 = b.createLocal(); + OperationLocal local1 = b.createLocal(); + + b.beginStoreLocal(local0); b.emitConstObject(0L); b.endStoreLocal(); - b.beginStoreLocal(1); + b.beginStoreLocal(local1); b.emitConstObject(0L); b.endStoreLocal(); b.beginWhile(); b.beginLessThanOperation(); - b.emitLoadLocal(0); + b.emitLoadLocal(local0); b.emitConstObject(100L); b.endLessThanOperation(); b.beginBlock(); - b.beginStoreLocal(1); + b.beginStoreLocal(local1); b.beginAddOperation(); b.beginAlwaysBoxOperation(); - b.emitLoadLocal(1); + b.emitLoadLocal(local1); b.endAlwaysBoxOperation(); - b.emitLoadLocal(0); + b.emitLoadLocal(local0); b.endAddOperation(); b.endStoreLocal(); - b.beginStoreLocal(0); + b.beginStoreLocal(local0); b.beginAddOperation(); - b.emitLoadLocal(0); + b.emitLoadLocal(local0); b.emitConstObject(1L); b.endAddOperation(); b.endStoreLocal(); @@ -225,7 +259,7 @@ public void testVariableBoxingElim() { b.endWhile(); b.beginReturn(); - b.emitLoadLocal(1); + b.emitLoadLocal(local1); b.endReturn(); b.build(); @@ -234,89 +268,6 @@ public void testVariableBoxingElim() { Assert.assertEquals(4950L, root.call()); } - @Test - public void testSourceInfo() { - String src = " (return (add 1 2))"; - new Tester(src).then(node -> { - SourceSection ss = node.getSourceSection(); - Assert.assertNotNull(ss); - Assert.assertEquals(2, ss.getCharIndex()); - Assert.assertEquals(src.length(), ss.getCharEndIndex()); - }); - } - - @Test - public void testContextEval() { - String src = "(return (add 1 2))"; - - Context context = Context.create("test-operations"); - long result = context.eval("test-operations", src).asLong(); - Assert.assertEquals(3, result); - } - - @Test - public void testStacktrace() { - //@formatter:off - String src = "(return\n" - + " (add\n" - + " 1\n" - + " (fail)))"; - //@formatter:on - - Context context = Context.create("test-operations"); - try { - context.eval(org.graalvm.polyglot.Source.newBuilder("test-operations", src, "test-operations").build()); - fail(); - } catch (PolyglotException ex) { - Assert.assertEquals(4, ex.getStackTrace()[0].getLineNumber()); - } catch (IOException e) { - Assert.fail(); - } - } - - // @Test - public void testTracing() { - //@formatter:off - String src = "(do" - + " (setlocal 0 0)" - + " (setlocal 2 0)" - + " (while" - + " (less (local 0) 100)" - + " (do" - + " (setlocal 1 0)" - + " (while" - + " (less (local 1) 100)" - + " (do" - + " (setlocal 2 (add (local 2) (local 1)))" - + " (setlocal 1 (add (local 1) 1))))" - + " (setlocal 0 (add (local 0) 1))))" - + " (return (local 2)))"; - //@formatter:on - new Tester(src).test(495000L); - } - - @Test - public void testInstrumentation() { - //@formatter:off - String src = "(stmt" - + " (return (add 1 2)))"; - //@formatter:on - - new Tester(src, true).test(3L); - } - - @Test - public void testCompilation() { - Context context = Context.create("test-operations"); - - Value v = context.parse("test-operations", "(return (add (arg 0) (arg 1)))"); - for (long i = 0; i < 1000000; i++) { - v.execute(i, 1L); - } - - Assert.assertEquals(Value.asValue(7L), v.execute(3L, 4L)); - } - private static void testOrdering(boolean expectException, RootCallTarget root, Long... order) { List result = new ArrayList<>(); @@ -325,13 +276,13 @@ private static void testOrdering(boolean expectException, RootCallTarget root, L if (expectException) { Assert.fail(); } - } catch (Exception ex) { + } catch (AbstractTruffleException ex) { if (!expectException) { throw new AssertionError("unexpected", ex); } } - Assert.assertArrayEquals(order, result.toArray()); + Assert.assertArrayEquals("expected " + Arrays.toString(order) + " got " + result, order, result.toArray()); } @Test @@ -341,7 +292,7 @@ public void testFinallyTryBasic() { // expected 1, 2 RootCallTarget root = parse(b -> { - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginAppenderOperation(); @@ -373,7 +324,7 @@ public void testFinallyTryException() { // expected: 1, 3 RootCallTarget root = parse(b -> { - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -411,7 +362,7 @@ public void testFinallyTryException() { @Test public void testFinallyTryReturn() { RootCallTarget root = parse(b -> { - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -453,7 +404,7 @@ public void testFinallyTryBranchOut() { OperationLabel lbl = b.createLabel(); - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -509,7 +460,7 @@ public void testFinallyTryCancel() { OperationLabel lbl = b.createLabel(); - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginBlock(); { @@ -566,7 +517,7 @@ public void testFinallyTryInnerCf() { // try { 1; return; 2 } finally { 3; goto lbl; 4; lbl: 5; } // expected: 1, 3, 5 - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginBlock(); { @@ -626,7 +577,7 @@ public void testFinallyTryNestedTry() { // try { try { 1; return; 2; } finally { 3; } } finally { 4; } // expected: 1, 3, 4 - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginBlock(); { @@ -637,7 +588,7 @@ public void testFinallyTryNestedTry() { } b.endBlock(); - b.beginFinallyTry(1); + b.beginFinallyTry(); { b.beginBlock(); { @@ -683,9 +634,9 @@ public void testFinallyTryNestedFinally() { // try { 1; return; 2; } finally { try { 3; return; 4; } finally { 5; } } // expected: 1, 3, 5 - b.beginFinallyTry(0); + b.beginFinallyTry(); { - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginBlock(); { @@ -749,7 +700,7 @@ public void testFinallyTryNestedTryThrow() { // try { try { 1; throw; 2; } finally { 3; } } finally { 4; } // expected: 1, 3, 4 - b.beginFinallyTry(0); + b.beginFinallyTry(); { b.beginBlock(); { @@ -760,7 +711,7 @@ public void testFinallyTryNestedTryThrow() { } b.endBlock(); - b.beginFinallyTry(1); + b.beginFinallyTry(); { b.beginBlock(); { @@ -796,4 +747,144 @@ public void testFinallyTryNestedTryThrow() { testOrdering(true, root, 1L, 3L, 4L); } + + @Test + public void testFinallyTryNestedFinallyThrow() { + RootCallTarget root = parse(b -> { + + // try { 1; throw; 2; } finally { try { 3; throw; 4; } finally { 5; } } + // expected: 1, 3, 5 + + b.beginFinallyTry(); + { + b.beginFinallyTry(); + { + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(5L); + b.endAppenderOperation(); + } + b.endBlock(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.emitThrowOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(4L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.emitThrowOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTry(); + + b.build(); + }); + + testOrdering(true, root, 1L, 3L, 5L); + } + + @Test + public void testFinallyTryNoExceptReturn() { + + // try { 1; return; 2; } finally noexcept { 3; } + // expected: 1, 3 + + RootCallTarget root = parse(b -> { + b.beginFinallyTryNoExcept(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.beginReturn(); + b.emitConstObject(0L); + b.endReturn(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTryNoExcept(); + + b.build(); + }); + + testOrdering(false, root, 1L, 3L); + } + + @Test + public void testFinallyTryNoExceptException() { + + // try { 1; throw; 2; } finally noexcept { 3; } + // expected: 1 + + RootCallTarget root = parse(b -> { + b.beginFinallyTryNoExcept(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(3L); + b.endAppenderOperation(); + + b.beginBlock(); + { + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(1L); + b.endAppenderOperation(); + + b.emitThrowOperation(); + + b.beginAppenderOperation(); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endAppenderOperation(); + } + b.endBlock(); + } + b.endFinallyTryNoExcept(); + + b.build(); + }); + + testOrdering(true, root, 1L); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java index a8f8b738c19d..54d6e2c3c85c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java @@ -24,6 +24,6 @@ public BuilderExceptionHandler offset(int offset, int stackOffset) { @Override public String toString() { - return String.format("{start=%04x, end=%04x, handler=%04x}", startBci, endBci, handlerBci); + return String.format("{start=%04x, end=%04x, handler=%04x, index=%d}", startBci, endBci, handlerBci, exceptionIndex); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index 165e2f91899d..2775479df924 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -9,6 +9,7 @@ public class BuilderOperationData { public final Object[] aux; public final Object[] arguments; public int numChildren = 0; + public int numLocals; public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { this.parent = parent; @@ -18,5 +19,6 @@ public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, this.aux = new Object[numAux]; this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); this.arguments = arguments; + numLocals = parent != null ? parent.numLocals : 0; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java new file mode 100644 index 000000000000..a869eebc75b0 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java @@ -0,0 +1,12 @@ +package com.oracle.truffle.api.operation; + +class BuilderOperationLocal extends OperationLocal { + final BuilderOperationData owner; + final int id; + + BuilderOperationLocal(BuilderOperationData owner, int id) { + this.owner = owner; + this.id = id; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java new file mode 100644 index 000000000000..e0fedc17ff56 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java @@ -0,0 +1,5 @@ +package com.oracle.truffle.api.operation; + +public class OperationLocal { + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 1bc6d2c22a97..8cc178701189 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -26,23 +26,16 @@ public final OperationsNode[] collect() { return builtNodes.toArray(new OperationsNode[builtNodes.size()]); } - protected int maxLocals = -1; protected int instrumentationId = 0; public void reset() { labelFills.clear(); - maxLocals = -1; instrumentationId = 0; curStack = 0; maxStack = 0; - } - protected final Object trackLocalsHelper(Object value) { - if (maxLocals < (int) value) { - maxLocals = (int) value; - } - return value; + numLocals = 0; } // ------------------------ labels ------------------------ @@ -205,6 +198,54 @@ protected void setCurStack(int curStack) { this.curStack = curStack; } + // ------------------------ locals handling ------------------------ + + protected int numLocals; + + public final OperationLocal createLocal() { + BuilderOperationLocal local = new BuilderOperationLocal(operationData, operationData.numLocals++); + + if (numLocals < local.id + 1) { + numLocals = local.id + 1; + } + + System.out.printf(" -- created local: %d%n", local.id); + + return local; + } + + protected final OperationLocal createParentLocal() { + BuilderOperationData parent = operationData.parent; + assert operationData.numLocals == parent.numLocals; + + BuilderOperationLocal local = new BuilderOperationLocal(parent, parent.numLocals++); + operationData.numLocals++; + + if (numLocals < local.id + 1) { + numLocals = local.id + 1; + } + + return local; + } + + protected int getLocalIndex(Object value) { + BuilderOperationLocal local = (BuilderOperationLocal) value; + + // verify nesting + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + + return local.id; + } + + private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { + BuilderOperationData cur = child; + while (cur.depth > parent.depth) { + cur = cur.parent; + } + + return cur == parent; + } + // ------------------------ source sections ------------------------ public abstract void beginSource(Source source); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index de7ae895ac6a..3d2bf785a6ef 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -233,6 +233,7 @@ public class TruffleTypes { public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; + public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy"; public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; @@ -249,6 +250,7 @@ public class TruffleTypes { public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); + public final DeclaredType OperationLocal = c.getDeclaredTypeOptional(OperationLocal_Name); public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name); public final DeclaredType OperationsBuilder = c.getDeclaredTypeOptional(OperationsBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 252711dfc792..b58d9e5769a3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -624,14 +624,18 @@ public static class FinallyTry extends Operation { private final int AUX_CONTEXT = 0; private final int AUX_BEH = 1; + private final int AUX_LOCAL = 2; - public FinallyTry(OperationsContext builder, int id) { - super(builder, "FinallyTry", id, 2); + private final boolean noExcept; + + public FinallyTry(OperationsContext builder, int id, boolean noExcept) { + super(builder, noExcept ? "FinallyTryNoExcept" : "FinallyTry", id, 2); + this.noExcept = noExcept; } @Override public List getBuilderArgumentTypes() { - return List.of(new CodeTypeMirror(TypeKind.INT)); + return List.of(); } @Override @@ -644,6 +648,12 @@ public CodeTree createPushCountCode(BuilderVariables vars) { public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (!noExcept) { + b.startStatement().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "] = "); + b.startCall("createParentLocal"); + b.end(2); + } + b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = ").startCall("doBeginFinallyTry"); b.variable(vars.bc); b.variable(vars.bci); @@ -677,18 +687,20 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startStatement().startCall("doEndFinallyBlock1").end(2); - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); - - b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = (int)"); - b.startCall("trackLocalsHelper"); - b.startGroup().variable(vars.operationData).string(".arguments[0]").end(); - b.end(); - b.end(); - b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); - b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); + if (!noExcept) { + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + + b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); + b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = "); + b.startCall("getLocalIndex"); + b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); + b.end(); + b.end(); + b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); + b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); + } } b.end(); @@ -708,37 +720,41 @@ public CodeTree createLeaveCode(BuilderVariables vars) { public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // ; exception end - // << handler code >> - // goto end - // ; exception handler start - // << handler code >> - // throw [exc] - // end: + if (noExcept) { + emitLeaveCode(vars, b); + } else { + // ; exception end + // << handler code >> + // goto end + // ; exception handler start + // << handler code >> + // throw [exc] + // end: - b.startAssign("int endBci").variable(vars.bci).end(); + b.startAssign("int endBci").variable(vars.bci).end(); - emitLeaveCode(vars, b); + emitLeaveCode(vars, b); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - b.startBlock(); - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonBranch, varEndLabel)); - b.end(); + b.startBlock(); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.end(); - b.declaration(getTypes().BuilderExceptionHandler, "beh", createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)); - b.startAssign("beh.endBci").string("endBci").end(); - b.startAssign("beh.handlerBci").variable(vars.bci).end(); + b.declaration(getTypes().BuilderExceptionHandler, "beh", createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)); + b.startAssign("beh.endBci").string("endBci").end(); + b.startAssign("beh.handlerBci").variable(vars.bci).end(); - emitLeaveCode(vars, b); + emitLeaveCode(vars, b); - b.startBlock(); - CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[0]").build(); - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonThrow, localIdx)); - b.end(); + b.startBlock(); + CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").build(); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonThrow, localIdx)); + b.end(); - b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); + b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); + } return b.build(); } @@ -754,7 +770,7 @@ private static void emitLeaveCode(BuilderVariables vars, CodeTreeBuilder b) { @Override public int getNumAuxValues() { - return 2; + return noExcept ? 1 : 3; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 67953dde3d59..9fd3dd6cb815 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -51,13 +51,11 @@ public class OperationsBytecodeCodeGenerator { final DeclaredType ConditionProfile = context.getDeclaredType(ConditionProfile_Name); private final CodeTypeElement typBuilderImpl; - private final String simpleName; private final OperationsData m; private final boolean withInstrumentation; - public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String simpleName, OperationsData m, boolean withInstrumentation) { + public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, OperationsData m, boolean withInstrumentation) { this.typBuilderImpl = typBuilderImpl; - this.simpleName = simpleName; this.m = m; this.withInstrumentation = withInstrumentation; } @@ -67,7 +65,9 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, String si * executable Truffle node. */ public CodeTypeElement createBuilderBytecodeNode() { - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, simpleName, types.OperationsNode); + String namePrefix = withInstrumentation ? "Instrumentable" : ""; + + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", types.OperationsNode); CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); GeneratorUtils.addCompilationFinalAnnotation(fldBc, 1); @@ -254,7 +254,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeExecutableElement mContinueAt = new CodeExecutableElement( Set.of(Modifier.PROTECTED), context.getType(Object.class), "continueAt", argFrame, argStartBci, argStartSp); - builderBytecodeNodeType.add(mContinueAt); + builderBytecodeNodeType.getEnclosedElements().add(0, mContinueAt); { CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 062dd82eefcc..b469daa0bdaa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -135,7 +135,7 @@ private static CodeTree createCreateBuilder(CodeTypeElement typBuilderImpl, Code } private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { - String simpleName = m.getTemplateType().getSimpleName() + "BuilderImpl"; + String simpleName = "BuilderImpl"; CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); typBuilderImpl.setEnclosingElement(typBuilder); @@ -245,12 +245,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; { - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "BytecodeNode", m, false); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } if (ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, simpleName + "InstrumentableBytecodeNode", m, true); + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); } else { @@ -412,7 +412,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("sources"); b.variable(fldNodeNumber); b.string("createMaxStack()"); - b.startGroup().string("maxLocals + 1").end(); + b.startGroup().string("numLocals").end(); b.string("bcCopy"); b.string("cpCopy"); b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); @@ -431,7 +431,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { b.string("sources"); b.variable(fldNodeNumber); b.string("createMaxStack()"); - b.startGroup().string("maxLocals + 1").end(); + b.startGroup().string("numLocals").end(); b.string("bcCopy"); b.string("cpCopy"); b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index cfd3b7b3031c..d4efe30baf0a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -71,7 +71,8 @@ private void createBuiltinOperations() { add(new Operation.IfThenElse(this, operationId++, true)); add(new Operation.While(this, operationId++)); add(new Operation.TryCatch(this, operationId++)); - add(new Operation.FinallyTry(this, operationId++)); + add(new Operation.FinallyTry(this, operationId++, false)); + add(new Operation.FinallyTry(this, operationId++, true)); add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index ea65819bd273..f0541e2aae3e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -100,6 +100,7 @@ public final TypeMirror getDefaultBuilderType(ProcessorContext context) { case CONST_POOL: return context.getType(Object.class); case LOCAL: + return context.getTypes().OperationLocal; case ARGUMENT: return context.getType(int.class); case BRANCH_TARGET: @@ -215,7 +216,7 @@ public final TypeMirror getDefaultBuilderType(ProcessorContext context) { case RETURN: return null; case SET_LOCAL: - return context.getType(int.class); + return context.getTypes().OperationLocal; default: throw new IllegalArgumentException("Unexpected value: " + this); } @@ -368,8 +369,8 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code value = CodeTreeBuilder.createBuilder().startCall(vars.consts, "add").tree(value).end().build(); } - if (n >= inputs.length && results[n - inputs.length] == ResultType.SET_LOCAL) { - value = CodeTreeBuilder.createBuilder().startCall("trackLocalsHelper").tree(value).end().build(); + if ((n < inputs.length && inputs[n] == InputType.LOCAL) || (n >= inputs.length && results[n - inputs.length] == ResultType.SET_LOCAL)) { + value = CodeTreeBuilder.createBuilder().startCall("getLocalIndex").tree(value).end().build(); } return CodeTreeBuilder.createBuilder().startStatement().startCall("LE_BYTES", "putShort") // diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 652d15513f7d..48503e6f875a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -1,9 +1,13 @@ package com.oracle.truffle.sl.parser; import java.math.BigInteger; +import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.Stack; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.ParseTree; @@ -12,6 +16,7 @@ import com.oracle.truffle.api.debug.DebuggerTags; import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -43,7 +48,7 @@ public class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = false; + private static final boolean DO_LOG_NODE_CREATION = true; public static Map parseSL(SLLanguage language, SLSource source, SLOperationsBuilder builder) { return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); @@ -60,53 +65,73 @@ private SLOperationsVisitor(SLLanguage language, SLSource source, SLOperationsBu } private final SLOperationsBuilder b; - private LexicalScope scope; + private LocalScope scope; - private OperationLabel breakLabel; - private OperationLabel continueLabel; - - private static class LexicalScope { - int count; - Map names = new HashMap<>(); - LexicalScope parent; + private static class LocalScope { + private final LocalScope parent; + private Map locals; + private Set setLocals; - LexicalScope(LexicalScope parent) { + LocalScope(LocalScope parent) { this.parent = parent; - count = parent == null ? 0 : parent.count; + this.locals = new HashMap<>(); + this.setLocals = new HashSet<>(); } - public Integer get(TruffleString name) { -// System.out.println("get " + name); - Integer value = names.get(name); - if (value != null) { - return value; + public OperationLocal get(TruffleString value) { + OperationLocal result = locals.get(value); + if (result != null) { + return result; } else if (parent != null) { - return parent.get(name); + return parent.get(value); } else { return null; } } - public int getOrCreate(TruffleString name) { - Integer value = get(name); - if (value == null) { - return create(name); + public boolean isSet(TruffleString value) { + if (setLocals.contains(value)) { + return true; + } else if (parent != null) { + return parent.isSet(value); } else { - return value; + return false; } } - public int create(TruffleString name) { - int value = create(); - names.put(name, value); - return value; + public void put(TruffleString value, OperationLocal local) { + locals.put(value, local); + } + + } + + private static class FindLocalsVisitor extends SimpleLanguageOperationsBaseVisitor { + boolean entered = false; + List results = new ArrayList<>(); + + @Override + public Void visitBlock(BlockContext ctx) { + if (entered) { + return null; + } + + entered = true; + return super.visitBlock(ctx); } - public int create() { - return count++; + @Override + public Void visitNameAccess(NameAccessContext ctx) { + if (ctx.member_expression().size() > 0 && ctx.member_expression(0) instanceof MemberAssignContext) { + results.add(ctx.IDENTIFIER().getSymbol()); + } + + return super.visitNameAccess(ctx); } } + private OperationLabel breakLabel; + private OperationLabel continueLabel; + @Override public Void visit(ParseTree tree) { b.beginSourceSection(tree.getSourceInterval().a); @@ -124,11 +149,12 @@ public Void visitFunction(FunctionContext ctx) { b.beginSource(source.getSource()); b.beginInstrumentation(StandardTags.RootTag.class); - scope = new LexicalScope(null); + scope = new LocalScope(null); for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { TruffleString paramName = asTruffleString(ctx.IDENTIFIER(i).getSymbol(), false); - int idx = scope.create(paramName); + OperationLocal idx = b.createLocal(); + scope.put(paramName, idx); b.beginStoreLocal(idx); b.emitLoadArgument(i - 1); @@ -141,14 +167,14 @@ public Void visitFunction(FunctionContext ctx) { b.endInstrumentation(); - b.beginReturn(); - b.emitConstObject(SLNull.SINGLETON); - b.endReturn(); - scope = scope.parent; assert scope == null; + b.beginReturn(); + b.emitConstObject(SLNull.SINGLETON); + b.endReturn(); + b.endInstrumentation(); b.endSource(); @@ -173,14 +199,17 @@ public Void visitFunction(FunctionContext ctx) { @Override public Void visitBlock(BlockContext ctx) { - scope = new LexicalScope(scope); - b.beginBlock(); + + scope = new LocalScope(scope); + + FindLocalsVisitor helper = new FindLocalsVisitor(); + super.visitBlock(ctx); - b.endBlock(); scope = scope.parent; + b.endBlock(); return null; } @@ -306,12 +335,12 @@ public Void visitReturn_statement(Return_statementContext ctx) { * } * */ - private void logicalOrBegin(int localIdx) { + private void logicalOrBegin(OperationLocal localIdx) { b.beginBlock(); b.beginStoreLocal(localIdx); } - private void logicalOrMiddle(int localIdx) { + private void logicalOrMiddle(OperationLocal localIdx) { b.endStoreLocal(); b.beginConditional(); b.beginSLToBooleanOperation(); @@ -320,7 +349,7 @@ private void logicalOrMiddle(int localIdx) { b.emitLoadLocal(localIdx); } - private void logicalOrEnd(@SuppressWarnings("unused") int localIdx) { + private void logicalOrEnd(@SuppressWarnings("unused") OperationLocal localIdx) { b.endConditional(); b.endBlock(); } @@ -334,21 +363,21 @@ public Void visitExpression(ExpressionContext ctx) { b.beginInstrumentation(StandardTags.ExpressionTag.class); - int[] locals = new int[numTerms - 1]; + OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; for (int i = 0; i < numTerms - 1; i++) { - locals[i] = scope.create(); - logicalOrBegin(locals[i]); + tmpLocals[i] = b.createLocal(); + logicalOrBegin(tmpLocals[i]); } for (int i = 0; i < numTerms; i++) { visit(ctx.logic_term(i)); if (i != 0) { - logicalOrEnd(locals[i - 1]); + logicalOrEnd(tmpLocals[i - 1]); } if (i != numTerms - 1) { - logicalOrMiddle(locals[i]); + logicalOrMiddle(tmpLocals[i]); } } b.endInstrumentation(); @@ -368,12 +397,12 @@ public Void visitExpression(ExpressionContext ctx) { * } * */ - private void logicalAndBegin(int localIdx) { + private void logicalAndBegin(OperationLocal localIdx) { b.beginBlock(); b.beginStoreLocal(localIdx); } - private void logicalAndMiddle(int localIdx) { + private void logicalAndMiddle(OperationLocal localIdx) { b.endStoreLocal(); b.beginConditional(); b.beginSLToBooleanOperation(); @@ -381,7 +410,7 @@ private void logicalAndMiddle(int localIdx) { b.endSLToBooleanOperation(); } - private void logicalAndEnd(int localIdx) { + private void logicalAndEnd(OperationLocal localIdx) { b.emitLoadLocal(localIdx); b.endConditional(); b.endBlock(); @@ -398,21 +427,21 @@ public Void visitLogic_term(Logic_termContext ctx) { b.beginInstrumentation(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); - int[] locals = new int[numTerms - 1]; + OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; for (int i = 0; i < numTerms - 1; i++) { - locals[i] = scope.create(); - logicalAndBegin(locals[i]); + tmpLocals[i] = b.createLocal(); + logicalAndBegin(tmpLocals[i]); } for (int i = 0; i < numTerms; i++) { visit(ctx.logic_factor(i)); if (i != 0) { - logicalAndEnd(locals[i - 1]); + logicalAndEnd(tmpLocals[i - 1]); } if (i != numTerms - 1) { - logicalAndMiddle(locals[i]); + logicalAndMiddle(tmpLocals[i]); } } @@ -576,7 +605,7 @@ public Void visitNameAccess(NameAccessContext ctx) { private void buildMemberExpressionRead(Token ident, List members, int idx) { if (idx == -1) { - Integer localIdx = scope.get(asTruffleString(ident, false)); + OperationLocal localIdx = scope.get(asTruffleString(ident, false)); if (localIdx != null) { b.emitLoadLocal(localIdx); } else { @@ -641,9 +670,17 @@ private void buildMemberExpressionRead(Token ident, List */ + + private Stack writeLocalsStack = new Stack<>(); + private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { - int localIdx = scope.getOrCreate(asTruffleString(ident, false)); + OperationLocal localIdx = scope.get(asTruffleString(ident, false)); + if (localIdx == null) { + localIdx = b.createLocal(); + } + writeLocalsStack.push(localIdx); + b.beginBlock(); b.beginStoreLocal(localIdx); return; @@ -674,7 +711,8 @@ private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { if (idx == -1) { - int localIdx = scope.get(asTruffleString(ident, false)); + OperationLocal localIdx = writeLocalsStack.pop(); + scope.put(asTruffleString(ident, false), localIdx); b.endStoreLocal(); b.emitLoadLocal(localIdx); b.endBlock(); From 8226ff9423ceccdfda3d21b173ec9226bd6a65af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 5 May 2022 15:30:56 +0200 Subject: [PATCH 075/312] [wip] fix boxing elim --- .../sl/operations/SLOperationsBuilder.java | 663 ++++++++++-------- .../generator/FlatNodeGenFactory.java | 2 +- .../generator/NodeGeneratorPlugs.java | 2 +- .../generator/TypeSystemCodeGenerator.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 174 +++-- 5 files changed, 504 insertions(+), 339 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index bc097533e688..e127d5517ab6 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -247,15 +247,15 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_LONG = 6; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; + private static final int INSTR_LOAD_CONSTANT_LONG = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_LONG = 9; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; + private static final int INSTR_LOAD_ARGUMENT_LONG = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_LONG = 13; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; + private static final int INSTR_LOAD_LOCAL_LONG = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -292,13 +292,13 @@ private static class BuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; @@ -1572,13 +1572,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: @@ -1590,13 +1590,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: @@ -1614,13 +1614,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: @@ -2163,16 +2163,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2185,11 +2185,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2197,11 +2197,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2224,11 +2224,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2236,11 +2236,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2478,25 +2478,31 @@ private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { @@ -2729,25 +2735,31 @@ private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; try { @@ -2941,25 +2953,31 @@ private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); @@ -2973,25 +2991,31 @@ private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; - if ($frame.isBoolean($sp - 2)) { - $child0Value_ = $frame.getBoolean($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 2)) { + $child0Value_ = $frame.getBoolean($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } boolean $child1Value_; - if ($frame.isBoolean($sp - 1)) { - $child1Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child1Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child1Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child1Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); @@ -3421,25 +3445,31 @@ private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -3602,25 +3632,31 @@ private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -3783,14 +3819,17 @@ private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $ private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLLogicalNotNode.doBoolean($child0Value_); @@ -3890,25 +3929,31 @@ private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; try { @@ -4484,25 +4529,31 @@ private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; try { @@ -5066,14 +5117,17 @@ private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); boolean value = SLUnboxNode.fromBoolean($child0Value_); @@ -5087,14 +5141,17 @@ private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $ private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); long value = SLUnboxNode.fromLong($child0Value_); @@ -5452,14 +5509,17 @@ private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $s private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLToBooleanNode.doBoolean($child0Value_); @@ -5767,14 +5827,17 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; long $child0Value_; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child0Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); long value = SLUnboxNode.fromLong($child0Value_); @@ -5789,25 +5852,31 @@ private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { @@ -5862,14 +5931,17 @@ private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $fram private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); boolean value = SLUnboxNode.fromBoolean($child0Value_); @@ -5884,14 +5956,17 @@ private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $b private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; boolean $child0Value_; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Boolean) { - $child0Value_ = (boolean) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isBoolean($sp - 1)) { + $child0Value_ = $frame.getBoolean($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { + $child0Value_ = (boolean) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLToBooleanNode.doBoolean($child0Value_); @@ -5906,25 +5981,31 @@ private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $b private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -6032,25 +6113,31 @@ private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $fr private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && $frame.getObject($sp - 2) instanceof Long) { - $child0Value_ = (long) $frame.getObject($sp - 2); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 2)) { + $child0Value_ = $frame.getLong($sp - 2); + } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { + $child0Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = $frame.getValue($sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); + return; + } } long $child1Value_; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && $frame.getObject($sp - 1) instanceof Long) { - $child1Value_ = (long) $frame.getObject($sp - 1); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; + { + Object _getObjectValue = null; + if ($frame.isLong($sp - 1)) { + $child1Value_ = $frame.getLong($sp - 1); + } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { + $child1Value_ = (long) _getObjectValue; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); + return; + } } assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -6076,11 +6163,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -6094,8 +6181,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_LONG : case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6290,7 +6377,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6308,7 +6395,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6318,7 +6405,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6336,7 +6423,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6371,7 +6458,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6389,14 +6476,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6414,7 +6501,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6471,7 +6558,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6489,14 +6576,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6514,7 +6601,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index cc3226227b67..1f548b377eec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -2760,7 +2760,7 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt LocalVariable targetValue) { if (plugs != null) { CodeTree result = plugs.createAssignExecuteChild( - node, originalFrameState, frameState, parent, execution, forType, targetValue, + node, originalFrameState, frameState, parent, execution, forType, targetValue, typeSystem, fs -> createCallExecuteAndSpecialize(forType, fs)); if (result != null) { return result; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 184635995588..008ef6f8f9fe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -57,7 +57,7 @@ public interface NodeGeneratorPlugs { CodeTree createAssignExecuteChild( NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue, - Function createExecuteAndSpecialize); + TypeSystemData typeSystem, Function createExecuteAndSpecialize); CodeTree createThrowUnsupportedChild(NodeExecutionData execution); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index b766dd489527..6730a1c1f49c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -110,7 +110,7 @@ static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, String content) return cast(typeSystem, type, CodeTreeBuilder.singleString(content)); } - static CodeTree invokeImplicitCast(TypeSystemData typeSystem, ImplicitCastData cast, CodeTree expression) { + public static CodeTree invokeImplicitCast(TypeSystemData typeSystem, ImplicitCastData cast, CodeTree expression) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStaticCall(createTypeSystemGen(typeSystem), cast.getMethodName()).tree(expression); builder.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 2bc478c8523e..5c02e33f3ed0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -22,6 +22,7 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -30,6 +31,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.ImplicitCastData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; @@ -456,9 +458,87 @@ private FrameKind getFrameType(TypeKind type) { return OperationsData.convertToFrameType(type); } + private CodeTree createGetFrameSlot(FrameKind kind, int offset) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startCall("$frame", "get" + kind.getFrameName()); + b.string("$sp - " + offset); + b.end(); + + return b.build(); + } + + private static final String GET_OBJECT_OPT_NAME = "_getObjectValue"; + + private CodeTree createGetObjectOptimized(int offset, boolean first) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (first) { + b.startParantheses(); + b.string(GET_OBJECT_OPT_NAME, " = "); + b.startCall("$frame", "getObject"); + b.string("$sp - " + offset); + b.end(); + b.end(); + } else { + b.string(GET_OBJECT_OPT_NAME); + } + + return b.build(); + } + + private static CodeTree createIsFrameSlot(FrameKind kind, int offset) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startCall("$frame", "is" + kind.getFrameName()); + b.string("$sp - " + offset); + b.end(); + + return b.build(); + } + + private CodeTree createCheckBoxedAndUnboxed(LocalVariable targetValue, int offset, FrameKind sourceKind, ImplicitCastData cast, TypeSystemData typeSystem) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf(cast != null); + b.tree(createIsFrameSlot(sourceKind, offset)).end().startBlock(); + { + // the unboxed type itself + b.startAssign(targetValue.getName()); + if (cast != null) { + b.tree(TypeSystemCodeGenerator.invokeImplicitCast(typeSystem, cast, createGetFrameSlot(sourceKind, offset))); + } else { + b.tree(createGetFrameSlot(sourceKind, offset)); + } + b.end(); + } + b.end().startElseIf(); + { + b.tree(createIsFrameSlot(FrameKind.OBJECT, offset)); + b.string(" && "); + b.startParantheses().tree(createGetObjectOptimized(offset, cast == null)).string(" instanceof ", sourceKind.getTypeNameBoxed()).end(); + } + b.end().startBlock(); + { + // the unboxed type itself + b.startAssign(targetValue.getName()); + if (cast != null) { + CodeTree getObjectTree = CodeTreeBuilder.createBuilder().cast(cast.getSourceType()).tree(createGetObjectOptimized(offset, false)).build(); + b.tree(TypeSystemCodeGenerator.invokeImplicitCast(typeSystem, cast, getObjectTree)); + } else { + b.cast(targetValue.getTypeMirror()); + b.tree(createGetObjectOptimized(offset, false)); + } + b.end(); + } + b.end(); + + return b.build(); + } + @Override public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, - LocalVariable targetValue, Function createExecuteAndSpecialize) { + LocalVariable targetValue, TypeSystemData typeSystem, Function createExecuteAndSpecialize) { if (isVariadic) { throw new AssertionError("variadic instructions should not have children"); } @@ -482,70 +562,68 @@ public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrame b.end().startElseBlock(); } - FrameKind typeName = getFrameType(targetValue.getTypeMirror().getKind()); + FrameKind targetKind = getFrameType(targetValue.getTypeMirror().getKind()); - if (typeName == FrameKind.OBJECT) { - b.startAssign(targetValue.getName()); - b.startCall("$frame", "getObject"); - b.string("$sp - " + offset); - b.end(2); + if (targetKind == FrameKind.OBJECT) { + // the target is always boxed + b.startAssign(targetValue.getName()).tree(createGetFrameSlot(targetKind, offset)).end(); } else { - b.startIf().startCall("$frame", "is" + typeName.getFrameName()).string("$sp - " + offset).end(2).startBlock(); - { - b.startAssign(targetValue.getName()); - b.startCall("$frame", "get" + typeName.getFrameName()); - b.string("$sp - " + offset); - b.end(3); - } - b.startElseIf(); - b.startCall("$frame", "isObject").string("$sp - " + offset).end(); - b.string(" && "); - b.startCall("$frame", "getObject").string("$sp - " + offset).end().string(" instanceof ", typeName.getTypeNameBoxed()); - b.end().startBlock(); - { - b.startAssign(targetValue.getName()); - b.cast(targetValue.getTypeMirror()); - b.startCall("$frame", "getObject"); - b.string("$sp - " + offset); - b.end(3); - } - b.end().startElseBlock(); + b.startBlock(); { + b.declaration("Object", GET_OBJECT_OPT_NAME, "null"); + // the target is unboxed + b.tree(createCheckBoxedAndUnboxed(targetValue, offset, targetKind, null, typeSystem)); + for (ImplicitCastData castData : typeSystem.lookupByTargetType(targetValue.getTypeMirror())) { + FrameKind sourceFrameKind = getFrameType(castData.getSourceType().getKind()); + // one of the types it can be cast from + if (sourceFrameKind == FrameKind.OBJECT) { + // a boxed type, ignore it + continue; + } - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(createCheckBoxedAndUnboxed(targetValue, offset, sourceFrameKind, castData, typeSystem)); + } + b.startElseBlock(); + { + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - // slow path - FrameState slowPathFrameState = frameState.copy(); + // slow path + FrameState slowPathFrameState = frameState.copy(); - CodeTreeBuilder accessBuilder = b.create(); - accessBuilder.startCall("$frame", "getValue"); - accessBuilder.string("$sp - " + offset); - accessBuilder.end(); + CodeTreeBuilder accessBuilder = b.create(); + accessBuilder.startCall("$frame", "getValue"); + accessBuilder.string("$sp - " + offset); + accessBuilder.end(); - slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); + slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); - int curOffset = offset; - boolean found = false; + int curOffset = offset; + boolean found = false; - for (NodeExecutionData otherExecution : node.getChildExecutions()) { - if (found) { - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); - b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); - slowPathFrameState.setValue(otherExecution, childEvaluatedValue); - } else { - // skip forward already evaluated - found = execution == otherExecution; + for (NodeExecutionData otherExecution : node.getChildExecutions()) { + if (found) { + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); + b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); + slowPathFrameState.setValue(otherExecution, childEvaluatedValue); + } else { + // skip forward already evaluated + found = execution == otherExecution; + } } - } - b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); + b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); + } + b.end(); } b.end(); } - if (!DO_BOXING_ELIM_IN_PE) { + if (!DO_BOXING_ELIM_IN_PE) + + { b.end(); } From 367480f513b99e7de4a1674447c09564ecd9e492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 6 May 2022 11:36:52 +0200 Subject: [PATCH 076/312] [wip] boxing + casting tests --- .../sl/operations/SLOperationsBuilder.java | 667 ++++++------------ .../test/example/BoxingOperationsTest.java | 398 +++++++++++ .../truffle/api/operation/OperationsNode.java | 73 ++ .../generator/FlatNodeGenFactory.java | 11 +- .../generator/NodeGeneratorPlugs.java | 8 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 175 +---- 6 files changed, 715 insertions(+), 617 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index e127d5517ab6..fea60af2550f 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -24,6 +24,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.operation.BuilderExceptionHandler; @@ -247,15 +248,15 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_CONSTANT_LONG = 7; + private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_LOAD_ARGUMENT_LONG = 10; + private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; - private static final int INSTR_LOAD_LOCAL_LONG = 14; + private static final int INSTR_LOAD_LOCAL_LONG = 13; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -292,13 +293,13 @@ private static class BuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; @@ -1572,13 +1573,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: @@ -1590,13 +1591,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: @@ -1614,13 +1615,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: @@ -2163,16 +2164,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2185,11 +2186,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2197,11 +2198,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2224,11 +2225,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2236,11 +2237,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2478,31 +2479,19 @@ private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { @@ -2529,10 +2518,8 @@ private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $fr } private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -2735,31 +2722,19 @@ private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; try { @@ -2786,10 +2761,8 @@ private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $fr } private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -2953,31 +2926,19 @@ private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); @@ -2991,31 +2952,19 @@ private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 2)) { - $child0Value_ = $frame.getBoolean($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } boolean $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child1Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child1Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); @@ -3045,10 +2994,8 @@ private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_ @ExplodeLoop private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -3445,31 +3392,19 @@ private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -3482,10 +3417,8 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_( } private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -3632,31 +3565,19 @@ private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -3669,10 +3590,8 @@ private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(Virtua } private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -3819,17 +3738,11 @@ private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $ private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLLogicalNotNode.doBoolean($child0Value_); @@ -3842,8 +3755,7 @@ private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(Virt } private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; boolean value = SLLogicalNotNode.doBoolean($child0Value__); @@ -3929,31 +3841,19 @@ private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; try { @@ -3980,10 +3880,8 @@ private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $fr } private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -4133,10 +4031,8 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, @ExplodeLoop private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { @@ -4529,31 +4425,19 @@ private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; try { @@ -4580,10 +4464,8 @@ private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $fr } private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { @@ -4733,12 +4615,9 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, @ExplodeLoop private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 3); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 2); - Object $child2Value_; - $child2Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 3); + Object $child1Value_ = expectObject($frame, $sp - 2); + Object $child2Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { @@ -5117,17 +4996,11 @@ private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); boolean value = SLUnboxNode.fromBoolean($child0Value_); @@ -5141,17 +5014,11 @@ private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $ private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); long value = SLUnboxNode.fromLong($child0Value_); @@ -5180,8 +5047,7 @@ private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte st @ExplodeLoop private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { String $child0Value__ = (String) $child0Value_; $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); @@ -5446,8 +5312,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { @@ -5509,17 +5374,11 @@ private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $s private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLToBooleanNode.doBoolean($child0Value_); @@ -5532,8 +5391,7 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(Virtua } private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; boolean value = SLToBooleanNode.doBoolean($child0Value__); @@ -5624,8 +5482,7 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int private void SLEvalRootOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value_ instanceof Map) { Map $child0Value__ = (Map) $child0Value_; { @@ -5827,17 +5684,11 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child0Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); long value = SLUnboxNode.fromLong($child0Value_); @@ -5852,31 +5703,19 @@ private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { @@ -5905,10 +5744,8 @@ private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, in @ExplodeLoop private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 2); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; @@ -5931,17 +5768,11 @@ private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $fram private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); boolean value = SLUnboxNode.fromBoolean($child0Value_); @@ -5956,17 +5787,11 @@ private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $b private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; boolean $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isBoolean($sp - 1)) { - $child0Value_ = $frame.getBoolean($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Boolean)) { - $child0Value_ = (boolean) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 1)); - return; - } + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLToBooleanNode.doBoolean($child0Value_); @@ -5981,31 +5806,19 @@ private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $b private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); @@ -6068,8 +5881,7 @@ private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 1); assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; if ($child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; @@ -6087,12 +5899,9 @@ private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, @ExplodeLoop private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_; - $child0Value_ = $frame.getObject($sp - 3); - Object $child1Value_; - $child1Value_ = $frame.getObject($sp - 2); - Object $child2Value_; - $child2Value_ = $frame.getObject($sp - 1); + Object $child0Value_ = expectObject($frame, $sp - 3); + Object $child1Value_ = expectObject($frame, $sp - 2); + Object $child2Value_ = expectObject($frame, $sp - 1); assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; @@ -6113,31 +5922,19 @@ private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $fr private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; long $child0Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 2)) { - $child0Value_ = $frame.getLong($sp - 2); - } else if ($frame.isObject($sp - 2) && ((_getObjectValue = $frame.getObject($sp - 2)) instanceof Long)) { - $child0Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = $frame.getValue($sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $frame.getValue($sp - 2), $child1Value); - return; - } + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; } long $child1Value_; - { - Object _getObjectValue = null; - if ($frame.isLong($sp - 1)) { - $child1Value_ = $frame.getLong($sp - 1); - } else if ($frame.isObject($sp - 1) && ((_getObjectValue = $frame.getObject($sp - 1)) instanceof Long)) { - $child1Value_ = (long) _getObjectValue; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $frame.getValue($sp - 1)); - return; - } + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); @@ -6163,11 +5960,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -6181,8 +5978,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6377,7 +6174,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6395,7 +6192,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6405,7 +6202,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6423,7 +6220,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6458,7 +6255,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6476,14 +6273,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6501,7 +6298,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6558,7 +6355,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6576,14 +6373,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6601,7 +6398,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java new file mode 100644 index 000000000000..dbfa41541c97 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -0,0 +1,398 @@ +package com.oracle.truffle.api.operation.test.example; + +import java.util.function.Consumer; + +import org.junit.Assert; +import org.junit.Test; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.ImplicitCast; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystem; +import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; + +public class BoxingOperationsTest { + + // TODO all of these tests should somehow check that e&s is not called more times + // than it needs to + + private static RootCallTarget parse(Consumer parser) { + return BoxingOperationsBuilder.parse(null, parser)[0].createRootNode(null, "test").getCallTarget(); + } + + @Test + public void testCastsPrimToPrim() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginLongOperator(); + b.emitIntProducer(); + b.endLongOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call()); + } + } + + @Test + public void testCastsRefToPrim() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginLongOperator(); + b.emitRefBProducer(); + b.endLongOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call()); + } + } + + @Test + public void testCastsPrimToRef() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginStringOperator(); + b.emitBooleanProducer(); + b.endStringOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call()); + } + } + + @Test + public void testCastsRefToRef() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginStringOperator(); + b.emitRefAProducer(); + b.endStringOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call()); + } + } + + @Test + public void testCastsChangePrim() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginLongOperator(); + b.beginObjectProducer(); + b.emitLoadArgument(0); + b.endObjectProducer(); + b.endLongOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + } + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + } + + try { + root.call(ObjectProducer.PRODUCE_BOOLEAN); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + } + + @Test + public void testCastsChangeRef() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginStringOperator(); + b.beginObjectProducer(); + b.emitLoadArgument(0); + b.endObjectProducer(); + b.endStringOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + } + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + } + + try { + root.call(ObjectProducer.PRODUCE_INT); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + } + + @Test + public void testCastsChangeSpecPrim() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginLongOperator(); + b.beginSpecializedObjectProducer(); + b.emitLoadArgument(0); + b.endSpecializedObjectProducer(); + b.endLongOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + } + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + } + + try { + root.call(ObjectProducer.PRODUCE_BOOLEAN); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + } + + @Test + public void testCastsChangeSpecRef() { + RootCallTarget root = parse(b -> { + b.beginReturn(); + b.beginStringOperator(); + b.beginSpecializedObjectProducer(); + b.emitLoadArgument(0); + b.endSpecializedObjectProducer(); + b.endStringOperator(); + b.endReturn(); + + b.build(); + }); + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + } + + for (int i = 0; i < 3; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + } + + try { + root.call(ObjectProducer.PRODUCE_INT); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + } +} + +class BoxingLanguage extends TruffleLanguage { + @Override + protected BoxingContext createContext(Env env) { + return new BoxingContext(); + } + +} + +class BoxingContext { +} + +class ReferenceTypeA { +} + +class ReferenceTypeB { +} + +@TypeSystem +@SuppressWarnings("unused") +class BoxingTypeSystem { + + public static final String STRING_VALUE = ""; + public static final String BOOLEAN_AS_STRING_VALUE = ""; + public static final String REF_A_AS_STRING_VALUE = ""; + + public static final long LONG_VALUE = 0xf00; + public static final long INT_AS_LONG_VALUE = 0xba7; + public static final long REF_B_AS_LONG_VALUE = 0xb00; + + @ImplicitCast + static String castString(boolean b) { + return BOOLEAN_AS_STRING_VALUE; + } + + @ImplicitCast + static String castString(ReferenceTypeA a) { + return REF_A_AS_STRING_VALUE; + } + + @ImplicitCast + static long castLong(int i) { + return INT_AS_LONG_VALUE; + } + + @ImplicitCast + static long castLong(ReferenceTypeB b) { + return REF_B_AS_LONG_VALUE; + } +} + +@GenerateOperations(boxingEliminationTypes = {boolean.class, int.class, long.class}) +@SuppressWarnings("unused") +class BoxingOperations { + public static void parse(BoxingLanguage lang, Consumer data, BoxingOperationsBuilder builder) { + data.accept(builder); + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class IntProducer { + @Specialization + public static int produce() { + return 1; + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class BooleanProducer { + @Specialization + public static boolean produce() { + return true; + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class RefAProducer { + @Specialization + public static ReferenceTypeA produce() { + return new ReferenceTypeA(); + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class RefBProducer { + @Specialization + public static ReferenceTypeB produce() { + return new ReferenceTypeB(); + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class ObjectProducer { + + public static final short PRODUCE_INT = 0; + public static final short PRODUCE_LONG = 1; + public static final short PRODUCE_STRING = 2; + public static final short PRODUCE_BOOLEAN = 3; + public static final short PRODUCE_REF_A = 4; + public static final short PRODUCE_REF_B = 5; + + @Specialization + public static Object produce(short type) { + switch (type) { + case PRODUCE_INT: + return 1; + case PRODUCE_LONG: + return BoxingTypeSystem.LONG_VALUE; + case PRODUCE_STRING: + return BoxingTypeSystem.STRING_VALUE; + case PRODUCE_BOOLEAN: + return true; + case PRODUCE_REF_A: + return new ReferenceTypeA(); + case PRODUCE_REF_B: + return new ReferenceTypeB(); + default: + throw CompilerDirectives.shouldNotReachHere(); + } + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class SpecializedObjectProducer { + + public static final short PRODUCE_INT = 0; + public static final short PRODUCE_LONG = 1; + public static final short PRODUCE_STRING = 2; + public static final short PRODUCE_BOOLEAN = 3; + public static final short PRODUCE_REF_A = 4; + public static final short PRODUCE_REF_B = 5; + + @Specialization(guards = {"type == PRODUCE_INT"}) + public static int produceInt(short type) { + return 1; + } + + @Specialization(guards = {"type == PRODUCE_LONG"}) + public static long produceLong(short type) { + return BoxingTypeSystem.LONG_VALUE; + } + + @Specialization(guards = {"type == PRODUCE_STRING"}) + public static String produceString(short type) { + return BoxingTypeSystem.STRING_VALUE; + } + + @Specialization(guards = {"type == PRODUCE_BOOLEAN"}) + public static boolean produceBoolean(short type) { + return true; + } + + @Specialization(guards = {"type == PRODUCE_REF_A"}) + public static ReferenceTypeA produceRefA(short type) { + return new ReferenceTypeA(); + } + + @Specialization(guards = {"type == PRODUCE_REF_B"}) + public static ReferenceTypeB produceRefB(short type) { + return new ReferenceTypeB(); + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class LongOperator { + @Specialization + public static long operate(long value) { + return value; + } + } + + @Operation + @TypeSystemReference(BoxingTypeSystem.class) + public static class StringOperator { + @Specialization + public static String operate(String value) { + return value; + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 86b390cb624f..586f53ebcc58 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -10,6 +10,7 @@ import com.oracle.truffle.api.instrumentation.ProbeNode; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -190,4 +191,76 @@ protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, sho } } } + + // --------------- boxing elim ----------------------- + + protected static Object expectObject(VirtualFrame frame, int slot) { + return frame.getObject(slot); + } + + protected static byte expectByte(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isByte(slot)) { + return frame.getByte(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Byte) { + return (byte) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isBoolean(slot)) { + return frame.getBoolean(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Boolean) { + return (boolean) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isInt(slot)) { + return frame.getInt(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Integer) { + return (int) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isFloat(slot)) { + return frame.getFloat(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Float) { + return (float) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isLong(slot)) { + return frame.getLong(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Long) { + return (long) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { + Object value; + if (frame.isDouble(slot)) { + return frame.getDouble(slot); + } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Double) { + return (double) value; + } else { + throw new UnexpectedResultException(frame.getValue(slot)); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 1f548b377eec..249b65e34a86 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -2758,14 +2758,6 @@ private CodeTree createFastPathExecuteChild(final CodeTreeBuilder parent, FrameS private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue) { - if (plugs != null) { - CodeTree result = plugs.createAssignExecuteChild( - node, originalFrameState, frameState, parent, execution, forType, targetValue, typeSystem, - fs -> createCallExecuteAndSpecialize(forType, fs)); - if (result != null) { - return result; - } - } CodeTreeBuilder builder = parent.create(); ChildExecutionResult executeChild = createExecuteChild(builder, originalFrameState, frameState, execution, targetValue); @@ -3190,6 +3182,9 @@ private CodeTree[] bindExecuteMethodParameters(NodeExecutionData execution, Exec } private CodeTree callChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { + if (plugs != null) { + return plugs.createCallChildExecuteMethod(execution, method, frameState); + } return callMethod(frameState, accessNodeField(execution), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 008ef6f8f9fe..e5b166f70b03 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -2,20 +2,17 @@ import java.util.List; import java.util.function.Consumer; -import java.util.function.Function; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; -import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; @@ -55,9 +52,7 @@ public interface NodeGeneratorPlugs { boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters); - CodeTree createAssignExecuteChild( - NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue, - TypeSystemData typeSystem, Function createExecuteAndSpecialize); + CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState); CodeTree createThrowUnsupportedChild(NodeExecutionData execution); @@ -82,4 +77,5 @@ CodeTree createAssignExecuteChild( boolean isStateGuaranteed(boolean stateGuaranteed); StaticConstants createConstants(); + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 5c02e33f3ed0..cb11e7a43e4c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Function; import java.util.stream.Collectors; import javax.lang.model.element.VariableElement; @@ -19,10 +18,8 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.StateBitSet; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -31,8 +28,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; -import com.oracle.truffle.dsl.processor.model.ImplicitCastData; -import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; @@ -63,7 +58,6 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private MultiStateBitSet multiState; private List boxingSplits; - private static final boolean DO_BOXING_ELIM_IN_PE = true; private OperationsData m; OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, @@ -458,174 +452,19 @@ private FrameKind getFrameType(TypeKind type) { return OperationsData.convertToFrameType(type); } - private CodeTree createGetFrameSlot(FrameKind kind, int offset) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startCall("$frame", "get" + kind.getFrameName()); - b.string("$sp - " + offset); - b.end(); - - return b.build(); - } - - private static final String GET_OBJECT_OPT_NAME = "_getObjectValue"; - - private CodeTree createGetObjectOptimized(int offset, boolean first) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (first) { - b.startParantheses(); - b.string(GET_OBJECT_OPT_NAME, " = "); - b.startCall("$frame", "getObject"); - b.string("$sp - " + offset); - b.end(); - b.end(); - } else { - b.string(GET_OBJECT_OPT_NAME); - } - - return b.build(); - } - - private static CodeTree createIsFrameSlot(FrameKind kind, int offset) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startCall("$frame", "is" + kind.getFrameName()); - b.string("$sp - " + offset); - b.end(); - - return b.build(); - } - - private CodeTree createCheckBoxedAndUnboxed(LocalVariable targetValue, int offset, FrameKind sourceKind, ImplicitCastData cast, TypeSystemData typeSystem) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf(cast != null); - b.tree(createIsFrameSlot(sourceKind, offset)).end().startBlock(); - { - // the unboxed type itself - b.startAssign(targetValue.getName()); - if (cast != null) { - b.tree(TypeSystemCodeGenerator.invokeImplicitCast(typeSystem, cast, createGetFrameSlot(sourceKind, offset))); - } else { - b.tree(createGetFrameSlot(sourceKind, offset)); - } - b.end(); - } - b.end().startElseIf(); - { - b.tree(createIsFrameSlot(FrameKind.OBJECT, offset)); - b.string(" && "); - b.startParantheses().tree(createGetObjectOptimized(offset, cast == null)).string(" instanceof ", sourceKind.getTypeNameBoxed()).end(); - } - b.end().startBlock(); - { - // the unboxed type itself - b.startAssign(targetValue.getName()); - if (cast != null) { - CodeTree getObjectTree = CodeTreeBuilder.createBuilder().cast(cast.getSourceType()).tree(createGetObjectOptimized(offset, false)).build(); - b.tree(TypeSystemCodeGenerator.invokeImplicitCast(typeSystem, cast, getObjectTree)); - } else { - b.cast(targetValue.getTypeMirror()); - b.tree(createGetObjectOptimized(offset, false)); - } - b.end(); - } - b.end(); - - return b.build(); - } - @Override - public CodeTree createAssignExecuteChild(NodeData node, FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, - LocalVariable targetValue, TypeSystemData typeSystem, Function createExecuteAndSpecialize) { - if (isVariadic) { - throw new AssertionError("variadic instructions should not have children"); - } - + public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { int childIndex = execution.getIndex(); int offset = cinstr.numPopStatic() - childIndex; - CodeTreeBuilder b = parent.create(); - - b.tree(targetValue.createDeclaration(null)); - - if (!DO_BOXING_ELIM_IN_PE) { - b.startIf().tree(GeneratorUtils.createInCompiledCode()).end().startBlock(); - { - b.startAssign(targetValue.getName()); - b.maybeCast(context.getType(Object.class), targetValue.getTypeMirror()); - b.startCall("$frame", "getValue"); - b.string("$sp - " + offset); - b.end(2); - } - b.end().startElseBlock(); - } - - FrameKind targetKind = getFrameType(targetValue.getTypeMirror().getKind()); - - if (targetKind == FrameKind.OBJECT) { - // the target is always boxed - b.startAssign(targetValue.getName()).tree(createGetFrameSlot(targetKind, offset)).end(); - } else { - b.startBlock(); - { - b.declaration("Object", GET_OBJECT_OPT_NAME, "null"); - // the target is unboxed - b.tree(createCheckBoxedAndUnboxed(targetValue, offset, targetKind, null, typeSystem)); - for (ImplicitCastData castData : typeSystem.lookupByTargetType(targetValue.getTypeMirror())) { - FrameKind sourceFrameKind = getFrameType(castData.getSourceType().getKind()); - // one of the types it can be cast from - if (sourceFrameKind == FrameKind.OBJECT) { - // a boxed type, ignore it - continue; - } - - b.tree(createCheckBoxedAndUnboxed(targetValue, offset, sourceFrameKind, castData, typeSystem)); - } - b.startElseBlock(); - { - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - // slow path - FrameState slowPathFrameState = frameState.copy(); - - CodeTreeBuilder accessBuilder = b.create(); - accessBuilder.startCall("$frame", "getValue"); - accessBuilder.string("$sp - " + offset); - accessBuilder.end(); - - slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(accessBuilder.build())); - - int curOffset = offset; - boolean found = false; - - for (NodeExecutionData otherExecution : node.getChildExecutions()) { - if (found) { - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, context.getType(Object.class)); - b.declaration("Object", childEvaluatedValue.getName(), "$frame.getValue($sp - " + (--curOffset) + ")"); - slowPathFrameState.setValue(otherExecution, childEvaluatedValue); - } else { - // skip forward already evaluated - found = execution == otherExecution; - } - } - - b.tree(createExecuteAndSpecialize.apply(slowPathFrameState)); - - } - b.end(); - } - b.end(); - - } + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (!DO_BOXING_ELIM_IN_PE) + FrameKind resultKind = getFrameType(method.getReturnType().getKind()); - { - b.end(); - } + b.startCall("expect" + resultKind.getFrameName()); + b.string("$frame"); + b.string("$sp - " + offset); + b.end(); return b.build(); } From c555c29f808286795faf6bdd95ced501af2b27ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 6 May 2022 14:03:12 +0200 Subject: [PATCH 077/312] [wip] further BE fixes --- .../sl/operations/SLOperationsBuilder.java | 242 ++++++++++++++---- .../test/example/BoxingOperationsTest.java | 1 + .../api/operation/OperationsBuilder.java | 2 - .../truffle/api/operation/OperationsNode.java | 118 +++++---- .../generator/FlatNodeGenFactory.java | 14 +- .../processor/generator/StaticConstants.java | 10 + .../OperationsBytecodeCodeGenerator.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 121 +++++++-- .../operations/SingleOperationParser.java | 6 +- .../sl/parser/SLOperationsVisitor.java | 31 +-- 10 files changed, 396 insertions(+), 151 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index fea60af2550f..7f4a739d514d 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -2071,19 +2071,7 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int private static final class BytecodeNode extends OperationsNode implements Provider { private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY__ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY___ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY__ = LibraryFactory.resolve(DynamicObjectLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY____ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY_____ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY______ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY_______ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY___ = LibraryFactory.resolve(DynamicObjectLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY________ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY_________ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory INTEROP_LIBRARY__________ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY____ = LibraryFactory.resolve(DynamicObjectLibrary.class); @CompilationFinal(dimensions = 1) private final byte[] bc; @CompilationFinal(dimensions = 1) private final Object[] consts; @@ -2602,7 +2590,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } int type0; int type1; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -2827,7 +2815,7 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3128,7 +3116,7 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc bc[$bci + 4 + 1] = (byte) (state_1); int type0; int type1; - if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3185,7 +3173,7 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc bc[$bci + 4 + 1] = (byte) (state_1); int type0; int type1; - if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_BOOLEAN; type1 = FRAME_TYPE_BOOLEAN; } else { @@ -3478,7 +3466,7 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i } int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3651,7 +3639,7 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int } int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -3791,7 +3779,7 @@ private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, in boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = FRAME_TYPE_BOOLEAN; } else { type0 = FRAME_TYPE_OBJECT; @@ -3946,7 +3934,7 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -4052,7 +4040,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int Node prev_ = encapsulating_.set(this); try { { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((readArray1_arrays__.hasArrayElements($child0Value_))) { $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; @@ -4100,7 +4088,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int Node prev_ = encapsulating_.set(this); try { if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); if ((readObject1_objects__.hasMembers($child0Value_))) { $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; @@ -4123,8 +4111,8 @@ private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, by { Node readArray1_node__ = (this); int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); } } @@ -4146,7 +4134,7 @@ private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, b { Node readObject1_node__ = (this); int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); } } @@ -4177,7 +4165,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } if (s0_ == null) { { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { @@ -4185,13 +4173,25 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, node__ = (this); bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY__.create($child1Value))); + children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4217,11 +4217,11 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { { - readArray1_arrays__ = (INTEROP_LIBRARY__.getUncached()); + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((readArray1_arrays__.hasArrayElements($child0Value))) { readArray1_node__ = (this); readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY__.getUncached()); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); @@ -4229,6 +4229,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4281,6 +4293,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4310,6 +4334,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4340,7 +4376,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if (s4_ == null) { if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); - InteropLibrary objects__ = super.insert((INTEROP_LIBRARY__.create($child0Value))); + InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); node__2 = (this); @@ -4353,6 +4389,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4377,7 +4425,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY__.getUncached()); + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); if ((readObject1_objects__.hasMembers($child0Value))) { readObject1_node__ = (this); readObject1_bci__ = ($bci); @@ -4389,6 +4437,18 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; + // [null, null] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4530,7 +4590,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); int type0; int type1; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { type0 = FRAME_TYPE_LONG; type1 = FRAME_TYPE_LONG; } else { @@ -4635,7 +4695,7 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in Node prev_ = encapsulating_.set(this); try { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); return; @@ -4693,8 +4753,8 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in @TruffleBoundary private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); } } @@ -4703,7 +4763,7 @@ private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, @TruffleBoundary private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value__)); + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); } } @@ -4717,7 +4777,7 @@ private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, { Node writeObject1_node__ = (this); int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value_)); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); } } finally { @@ -4746,7 +4806,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } if (s0_ == null) { { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY___.create($child0Value))); + InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { @@ -4754,7 +4814,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY___.create($child1Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); @@ -4762,6 +4822,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4786,11 +4858,11 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node prev_ = encapsulating_.set(this); try { { - writeArray1_arrays__ = (INTEROP_LIBRARY___.getUncached()); + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value))) { children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY___.getUncached()); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); @@ -4799,6 +4871,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4834,7 +4918,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY__.create($child0Value_))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; @@ -4847,6 +4931,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4864,7 +4960,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } { DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY__.getUncached($child0Value_)); + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; @@ -4874,6 +4970,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4909,7 +5017,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); node__ = (this); bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY___.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; @@ -4918,6 +5026,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4945,7 +5065,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { writeObject1_node__ = (this); writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY___.getUncached($child0Value)); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; @@ -4955,6 +5075,18 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; + // [null, null, null] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] + // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -5037,7 +5169,7 @@ private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte st Node prev_ = encapsulating_.set(this); try { { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value_)); + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); } } finally { @@ -5159,7 +5291,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); } int type0; - if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_BOOLEAN; } else { type0 = FRAME_TYPE_OBJECT; @@ -5185,7 +5317,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); } int type0; - if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_LONG; } else { type0 = FRAME_TYPE_OBJECT; @@ -5260,7 +5392,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); if (count7_ < (SLUnboxNode.LIMIT)) { s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY____.create($child0Value))); + children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); @@ -5284,7 +5416,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { - fromForeign1_interop__ = (INTEROP_LIBRARY____.getUncached($child0Value)); + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); @@ -5345,6 +5477,8 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); } int type0; + // [null] + // [com.oracle.truffle.api.strings.TruffleString] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); @@ -5437,7 +5571,7 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); } int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = FRAME_TYPE_BOOLEAN; } else { type0 = FRAME_TYPE_OBJECT; @@ -5515,6 +5649,8 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int execute_node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); int type0; + // [null] + // [com.oracle.truffle.api.frame.VirtualFrame] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); @@ -5525,6 +5661,8 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int } bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); int type0; + // [null] + // [com.oracle.truffle.api.frame.VirtualFrame] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); @@ -5639,7 +5777,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int { int interop_bci__ = 0; Node interop_node__ = null; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_____.createDispatched(3))); + children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index dbfa41541c97..3bf563232bff 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -8,6 +8,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystem; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java index 8cc178701189..45ac6c734d01 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java @@ -209,8 +209,6 @@ public final OperationLocal createLocal() { numLocals = local.id + 1; } - System.out.printf(" -- created local: %d%n", local.id); - return local; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java index 586f53ebcc58..89ab1102a766 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java @@ -6,6 +6,7 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.impl.FrameWithoutBoxing; import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.instrumentation.ProbeNode; import com.oracle.truffle.api.nodes.BytecodeOSRNode; @@ -195,72 +196,103 @@ protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, sho // --------------- boxing elim ----------------------- protected static Object expectObject(VirtualFrame frame, int slot) { - return frame.getObject(slot); + if (frame.isObject(slot)) { + return frame.getObject(slot); + } else { + // this should only happen in edge cases, when we have specialized to a generic case on + // one thread, but other threads have already executed the child with primitive return + // type + return frame.getValue(slot); + } } protected static byte expectByte(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isByte(slot)) { - return frame.getByte(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Byte) { - return (byte) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.BYTE_TAG: + return frame.getByte(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Byte) { + return (byte) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isBoolean(slot)) { - return frame.getBoolean(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Boolean) { - return (boolean) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.BOOLEAN_TAG: + return frame.getBoolean(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Boolean) { + return (boolean) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isInt(slot)) { - return frame.getInt(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Integer) { - return (int) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.INT_TAG: + return frame.getInt(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Integer) { + return (int) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isFloat(slot)) { - return frame.getFloat(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Float) { - return (float) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.FLOAT_TAG: + return frame.getFloat(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Float) { + return (float) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isLong(slot)) { - return frame.getLong(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Long) { - return (long) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.LONG_TAG: + return frame.getLong(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Long) { + return (long) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { - Object value; - if (frame.isDouble(slot)) { - return frame.getDouble(slot); - } else if (frame.isObject(slot) && (value = frame.getObject(slot)) instanceof Double) { - return (double) value; - } else { - throw new UnexpectedResultException(frame.getValue(slot)); + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.DOUBLE_TAG: + return frame.getDouble(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Double) { + return (double) value; + } + break; } + + throw new UnexpectedResultException(frame.getValue(slot)); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 249b65e34a86..72dca9c78f1c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1630,7 +1630,7 @@ public static CodeVariableElement createLanguageReferenceConstant(StaticConstant String constantName = ElementUtils.createConstantName(ElementUtils.getSimpleName(languageType) + "Lref"); TypeElement languageReference = (TypeElement) types.TruffleLanguage_LanguageReference.asElement(); DeclaredCodeTypeMirror constantType = new DeclaredCodeTypeMirror(languageReference, Arrays.asList(languageType)); - return lookupConstant(constants.languageReferences, constantName, (name) -> { + return lookupConstant(constants, constants.languageReferences, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(languageReference.asType(), "create").typeLiteral(languageType).end(); return newVar; @@ -1642,7 +1642,7 @@ public static CodeVariableElement createContextReferenceConstant(StaticConstants String constantName = ElementUtils.createConstantName(ElementUtils.getSimpleName(languageType) + "Cref"); TypeElement contextReference = (TypeElement) types.TruffleLanguage_ContextReference.asElement(); DeclaredCodeTypeMirror constantType = new DeclaredCodeTypeMirror(contextReference, Arrays.asList(NodeParser.findContextTypeFromLanguage(languageType))); - return lookupConstant(constants.languageReferences, constantName, (name) -> { + return lookupConstant(constants, constants.languageReferences, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(contextReference.asType(), "create").typeLiteral(languageType).end(); return newVar; @@ -1664,22 +1664,28 @@ public static CodeVariableElement createLibraryConstant(StaticConstants constant String constantName = ElementUtils.createConstantName(libraryType.getSimpleName().toString()); TypeElement resolvedLibrary = (TypeElement) ProcessorContext.getInstance().getTypes().LibraryFactory.asElement(); DeclaredCodeTypeMirror constantType = new DeclaredCodeTypeMirror(resolvedLibrary, Arrays.asList(libraryType.asType())); - return lookupConstant(constants.libraries, constantName, (name) -> { + return lookupConstant(constants, constants.libraries, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(resolvedLibrary.asType(), "resolve").typeLiteral(libraryType.asType()).end(); return newVar; }); } - private static CodeVariableElement lookupConstant(Map constants, String constantName, Function factory) { + private static CodeVariableElement lookupConstant(StaticConstants sc, Map constants, String constantName, Function factory) { String useConstantName = constantName + "_"; while (true) { CodeVariableElement prev = constants.get(useConstantName); CodeVariableElement var = factory.apply(useConstantName); + if (sc.ignoreEnclosingType) { + var.setEnclosingElement(null); + } if (prev == null) { constants.put(useConstantName, var); return var; } else { + if (sc.ignoreEnclosingType) { + prev.setEnclosingElement(null); + } if (ElementUtils.variableEquals(prev, var)) { return prev; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java index 5354afd0cfdb..975c162a8afb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java @@ -55,6 +55,16 @@ public final class StaticConstants { public final Map contextReferences = new LinkedHashMap<>(); public final Map languageReferences = new LinkedHashMap<>(); + public final boolean ignoreEnclosingType; + + public StaticConstants() { + this(false); + } + + public StaticConstants(boolean ignoreEnclosingType) { + this.ignoreEnclosingType = ignoreEnclosingType; + } + public void clear() { libraries.clear(); contextReferences.clear(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 9fd3dd6cb815..d7e9d617666e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -100,7 +100,7 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.add(ctor); { - StaticConstants staticConstants = new StaticConstants(); + StaticConstants staticConstants = new StaticConstants(true); for (Instruction instr : m.getInstructions()) { if (!(instr instanceof CustomInstruction)) { continue; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index cb11e7a43e4c..52b29bf954d5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -1,5 +1,6 @@ package com.oracle.truffle.dsl.processor.operations; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; @@ -35,6 +36,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; +import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final CodeVariableElement fldBc; @@ -505,56 +507,121 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // boxing elimination - if (!isVariadic && boxingSplits != null) { + if (!isVariadic && cinstr.numPopStatic() > 0) { boolean elseIf = false; + boolean[] needsElse = new boolean[]{true}; for (int i = 0; i < cinstr.numPopStatic(); i++) { b.declaration("int", "type" + i, (CodeTree) null); } - for (BoxingSplit split : boxingSplits) { - List specializations = split.getGroup().collectSpecializations(); - if (!specializations.contains(specialization)) { - continue; + if (boxingSplits != null && !boxingSplits.isEmpty()) { + for (BoxingSplit split : boxingSplits) { + elseIf = createBoxingSplitUnboxingThing(b, frameState, elseIf, specialization, split.getGroup().collectSpecializations(), split.getPrimitiveSignature(), needsElse); } + } else { + TypeMirror[] primMirrors = new TypeMirror[cinstr.numPopStatic()]; + List specs = cinstr.getData().getNodeData().getSpecializations(); + for (SpecializationData spec : specs) { + if (spec.isFallback()) { + continue; + } + b.lineComment(Arrays.toString(primMirrors)); + for (int i = 0; i < primMirrors.length; i++) { + TypeMirror paramType = spec.getParameters().get(i).getType(); + if (primMirrors[i] == null) { + primMirrors[i] = paramType; + } else if (!ElementUtils.typeEquals(primMirrors[i], paramType)) { + // we only care about primitive types, so we do not care about type + // compatibility + primMirrors[i] = ProcessorContext.getInstance().getType(Object.class); + } + } - elseIf = b.startIf(elseIf); + b.lineComment(Arrays.toString(primMirrors)); + } + + elseIf = createBoxingSplitUnboxingThing(b, frameState, elseIf, specialization, specs, primMirrors, needsElse); + } - b.startGroup(); - CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); - if (!tree.isEmpty()) { - b.tree(tree); - b.string(" && "); + if (needsElse[0]) { + if (elseIf) { + b.startElseBlock(); } - b.tree(multiState.createIsNotAny(frameState, specializationStates.toArray())); - b.end(); - b.end().startBlock(); for (int i = 0; i < cinstr.numPopStatic(); i++) { - FrameKind frameType = getFrameType(split.getPrimitiveSignature()[i].getKind()); - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); } - b.end(); - } - - if (elseIf) { - b.startElseBlock(); + if (elseIf) { + b.end(); + } } for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); + b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getArgumentOffset(i) + "]", CodeTreeBuilder.singleString("type" + i))); } + } - if (elseIf) { - b.end(); - } + } - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getArgumentOffset(i) + "]", CodeTreeBuilder.singleString("type" + i))); + private boolean createBoxingSplitUnboxingThing(CodeTreeBuilder b, FrameState frameState, boolean elseIf, SpecializationData specialization, List specializations, + TypeMirror[] primitiveMirrors, boolean[] needsElse) { + if (!specializations.contains(specialization)) { + return elseIf; + } + + CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); + if (!tree.isEmpty()) { + b.startIf(elseIf); + b.tree(tree).end().startBlock(); + } else { + needsElse[0] = false; + } + + TypeSystemData tsData = cinstr.getData().getNodeData().getTypeSystem(); + for (int i = 0; i < cinstr.numPopStatic(); i++) { + TypeMirror targetType = primitiveMirrors[i]; + if (!tsData.hasImplicitSourceTypes(targetType)) { + FrameKind frameType = getFrameType(targetType.getKind()); + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); + } else { + boolean elseIf2 = false; + List originalSourceTypes = new ArrayList<>(tsData.lookupSourceTypes(targetType)); + for (TypeMirror sourceType : originalSourceTypes) { + FrameKind frameType = getFrameType(sourceType.getKind()); + if (frameType == FrameKind.OBJECT) { + continue; + } + + TypeGuard typeGuard = new TypeGuard(targetType, i); + + elseIf2 = b.startIf(elseIf2); + + b.tree(multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sourceType), 1, new Object[]{typeGuard}, new Object[]{typeGuard})); + + b.end().startBlock(); + { + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); + } + b.end(); + } + + if (elseIf2) { + b.startElseBlock(); + } + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); + if (elseIf2) { + b.end(); + } } } + if (!tree.isEmpty()) { + b.end(); + } + + return true; } public CodeTree createSetResultBoxed(CodeVariableElement varUnboxed) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index f1b4a08735f4..cdd952d39f0d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -289,12 +289,14 @@ private boolean isIgnoredParameter(VariableElement param) { return false; } + private static final String GENERIC_EXECUTE_NAME = "Generic"; + private CodeTypeElement createRegularNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); - result.add(createExecuteMethod("Generic", context.getType(Object.class))); + result.add(createExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { result.add(createExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); @@ -307,7 +309,7 @@ private CodeExecutableElement createExecuteMethod(String name, TypeMirror retTyp CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); // result.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - if (!ElementUtils.isObject(retType) && !ElementUtils.isVoid(retType)) { + if (!GENERIC_EXECUTE_NAME.equals(name)) { result.addThrownType(types.UnexpectedResultException); } return result; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 48503e6f875a..6483d91ea16f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -3,10 +3,8 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Stack; import org.antlr.v4.runtime.Token; @@ -48,7 +46,7 @@ public class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = true; + private static final boolean DO_LOG_NODE_CREATION = false; public static Map parseSL(SLLanguage language, SLSource source, SLOperationsBuilder builder) { return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); @@ -70,12 +68,10 @@ private SLOperationsVisitor(SLLanguage language, SLSource source, SLOperationsBu private static class LocalScope { private final LocalScope parent; private Map locals; - private Set setLocals; LocalScope(LocalScope parent) { this.parent = parent; this.locals = new HashMap<>(); - this.setLocals = new HashSet<>(); } public OperationLocal get(TruffleString value) { @@ -89,16 +85,6 @@ public OperationLocal get(TruffleString value) { } } - public boolean isSet(TruffleString value) { - if (setLocals.contains(value)) { - return true; - } else if (parent != null) { - return parent.isSet(value); - } else { - return false; - } - } - public void put(TruffleString value, OperationLocal local) { locals.put(value, local); } @@ -204,12 +190,19 @@ public Void visitBlock(BlockContext ctx) { scope = new LocalScope(scope); FindLocalsVisitor helper = new FindLocalsVisitor(); + helper.visitBlock(ctx); - super.visitBlock(ctx); + for (Token result : helper.results) { + TruffleString localName = asTruffleString(result, false); + if (scope.get(localName) == null) { + scope.put(localName, b.createLocal()); + } + } - scope = scope.parent; + super.visitBlock(ctx); b.endBlock(); + scope = scope.parent; return null; } @@ -676,9 +669,7 @@ private void buildMemberExpressionRead(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { OperationLocal localIdx = scope.get(asTruffleString(ident, false)); - if (localIdx == null) { - localIdx = b.createLocal(); - } + assert localIdx != null; writeLocalsStack.push(localIdx); b.beginBlock(); From a95d4a92b9e840f82a28aca46ad2f16bf359f8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 6 May 2022 15:27:08 +0200 Subject: [PATCH 078/312] [wip] rename Instrumentation -> Tag --- .../sl/operations/SLOperationsBuilder.java | 170 ++---------------- .../dsl/processor/operations/Operation.java | 8 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 3 - .../operations/OperationsCodeGenerator.java | 5 +- .../operations/OperationsContext.java | 2 +- .../sl/parser/SLOperationsVisitor.java | 76 ++++---- 6 files changed, 57 insertions(+), 207 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 7f4a739d514d..7059de1023f7 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -131,9 +131,9 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endReturn(); - public abstract void beginInstrumentation(Class arg0); + public abstract void beginTag(Class arg0); - public abstract void endInstrumentation(); + public abstract void endTag(); public abstract void beginSLAddOperation(); @@ -227,7 +227,7 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int OP_STORE_LOCAL = 13; private static final int OP_LOAD_LOCAL = 14; private static final int OP_RETURN = 15; - private static final int OP_INSTRUMENTATION = 16; + private static final int OP_TAG = 16; private static final int OP_SLADD_OPERATION = 17; private static final int OP_SLDIV_OPERATION = 18; private static final int OP_SLEQUAL_OPERATION = 19; @@ -385,7 +385,7 @@ protected void doLeaveOperation(BuilderOperationData data) { bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); break; } - case OP_INSTRUMENTATION : + case OP_TAG : { int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_LEAVE); @@ -461,7 +461,7 @@ void doBeforeChild() { } break; } - case OP_INSTRUMENTATION : + case OP_TAG : { if (childIndex != 0) { for (int i = 0; i < lastPush; i++) { @@ -988,12 +988,12 @@ public void endReturn() { @SuppressWarnings("unused") @Override - public void beginInstrumentation(Class arg0) { + public void beginTag(Class arg0) { if (true) { return; } doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_INSTRUMENTATION, getCurStack(), 3, true, arg0); + operationData = new BuilderOperationData(operationData, OP_TAG, getCurStack(), 3, true, arg0); int curInstrumentId = doBeginInstrumentation((Class) arg0); BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); @@ -1010,16 +1010,16 @@ public void beginInstrumentation(Class arg0) { @SuppressWarnings("unused") @Override - public void endInstrumentation() { + public void endTag() { if (true) { return; } - if (operationData.operationId != OP_INSTRUMENTATION) { + if (operationData.operationId != OP_TAG) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren < 0) { - throw new IllegalStateException("Instrumentation expected at least 0 children, got " + numChildren); + throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); } if (lastPush != 0) { int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); @@ -4180,18 +4180,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4229,18 +4217,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4293,18 +4269,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4334,18 +4298,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4389,18 +4341,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4437,18 +4377,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; - // [null, null] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4822,18 +4750,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4871,18 +4787,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4931,18 +4835,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -4970,18 +4862,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -5026,18 +4906,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -5075,18 +4943,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int type0; int type1; int type2; - // [null, null, null] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] - // [java.lang.Object, java.lang.Object, java.lang.Object] type0 = FRAME_TYPE_OBJECT; type1 = FRAME_TYPE_OBJECT; type2 = FRAME_TYPE_OBJECT; @@ -5477,8 +5333,6 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); } int type0; - // [null] - // [com.oracle.truffle.api.strings.TruffleString] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); @@ -5649,8 +5503,6 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int execute_node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); int type0; - // [null] - // [com.oracle.truffle.api.frame.VirtualFrame] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); @@ -5661,8 +5513,6 @@ private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int } bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); int type0; - // [null] - // [com.oracle.truffle.api.frame.VirtualFrame] type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index b58d9e5769a3..7934e587a02c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -534,14 +534,16 @@ public List getBuilderArgumentTypes() { } } - public static class Instrumentation extends Block { + public static class InstrumentTag extends Block { private final Instruction startInstruction; private final Instruction endInstruction; private final Instruction endVoidInstruction; private final Instruction leaveInstruction; - public Instrumentation(OperationsContext builder, int id, Instruction startInstruction, Instruction endInstruction, Instruction endVoidInstruction, Instruction leaveInstruction) { - super(builder, "Instrumentation", id); + public static final String NAME = "Tag"; + + public InstrumentTag(OperationsContext builder, int id, Instruction startInstruction, Instruction endInstruction, Instruction endVoidInstruction, Instruction leaveInstruction) { + super(builder, NAME, id); this.startInstruction = startInstruction; this.endInstruction = endInstruction; this.endVoidInstruction = endVoidInstruction; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 52b29bf954d5..4c73f96b92eb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -526,7 +526,6 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ if (spec.isFallback()) { continue; } - b.lineComment(Arrays.toString(primMirrors)); for (int i = 0; i < primMirrors.length; i++) { TypeMirror paramType = spec.getParameters().get(i).getType(); if (primMirrors[i] == null) { @@ -537,8 +536,6 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ primMirrors[i] = ProcessorContext.getInstance().getType(Object.class); } } - - b.lineComment(Arrays.toString(primMirrors)); } elseIf = createBoxingSplitUnboxingThing(b, frameState, elseIf, specialization, specs, primMirrors, needsElse); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index b469daa0bdaa..359b2eaa5ee1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -24,6 +24,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.Operation.InstrumentTag; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -734,7 +735,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTreeBuilder b = metBegin.getBuilder(); - if (op.name.equals("Instrumentation")) { + if (op instanceof InstrumentTag) { // this needs to be placed here, at the very start // of the begin/end methods b.startIf(); @@ -782,7 +783,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); - if (op.name.equals("Instrumentation")) { + if (op instanceof InstrumentTag) { // this needs to be placed here, at the very start // of the begin/end methods b.startIf(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index d4efe30baf0a..411767b933e9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -82,7 +82,7 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); - add(new Operation.Instrumentation(this, operationId++, + add(new Operation.InstrumentTag(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++, true)), diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 6483d91ea16f..52693759466e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -133,7 +133,7 @@ public Void visitFunction(FunctionContext ctx) { TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); b.beginSource(source.getSource()); - b.beginInstrumentation(StandardTags.RootTag.class); + b.beginTag(StandardTags.RootTag.class); scope = new LocalScope(null); @@ -147,11 +147,11 @@ public Void visitFunction(FunctionContext ctx) { b.endStoreLocal(); } - b.beginInstrumentation(StandardTags.RootBodyTag.class); + b.beginTag(StandardTags.RootBodyTag.class); visit(ctx.body); - b.endInstrumentation(); + b.endTag(); scope = scope.parent; @@ -161,7 +161,7 @@ public Void visitFunction(FunctionContext ctx) { b.emitConstObject(SLNull.SINGLETON); b.endReturn(); - b.endInstrumentation(); + b.endTag(); b.endSource(); OperationsNode node = b.build(); @@ -212,9 +212,9 @@ public Void visitBreak_statement(Break_statementContext ctx) { SemErr(ctx.b, "break used outside of loop"); } - b.beginInstrumentation(StandardTags.StatementTag.class); + b.beginTag(StandardTags.StatementTag.class); b.emitBranch(breakLabel); - b.endInstrumentation(); + b.endTag(); return null; } @@ -225,17 +225,17 @@ public Void visitContinue_statement(Continue_statementContext ctx) { SemErr(ctx.c, "continue used outside of loop"); } - b.beginInstrumentation(StandardTags.StatementTag.class); + b.beginTag(StandardTags.StatementTag.class); b.emitBranch(continueLabel); - b.endInstrumentation(); + b.endTag(); return null; } @Override public Void visitDebugger_statement(Debugger_statementContext ctx) { - b.beginInstrumentation(DebuggerTags.AlwaysHalt.class); - b.endInstrumentation(); + b.beginTag(DebuggerTags.AlwaysHalt.class); + b.endTag(); return null; } @@ -245,7 +245,7 @@ public Void visitWhile_statement(While_statementContext ctx) { OperationLabel oldBreak = breakLabel; OperationLabel oldContinue = continueLabel; - b.beginInstrumentation(StandardTags.StatementTag.class); + b.beginTag(StandardTags.StatementTag.class); breakLabel = b.createLabel(); continueLabel = b.createLabel(); @@ -261,7 +261,7 @@ public Void visitWhile_statement(While_statementContext ctx) { b.endWhile(); b.emitLabel(breakLabel); - b.endInstrumentation(); + b.endTag(); breakLabel = oldBreak; continueLabel = oldContinue; @@ -271,7 +271,7 @@ public Void visitWhile_statement(While_statementContext ctx) { @Override public Void visitIf_statement(If_statementContext ctx) { - b.beginInstrumentation(StandardTags.StatementTag.class); + b.beginTag(StandardTags.StatementTag.class); if (ctx.alt == null) { b.beginIfThen(); @@ -295,13 +295,13 @@ public Void visitIf_statement(If_statementContext ctx) { b.endIfThenElse(); } - b.endInstrumentation(); + b.endTag(); return null; } @Override public Void visitReturn_statement(Return_statementContext ctx) { - b.beginInstrumentation(StandardTags.StatementTag.class); + b.beginTag(StandardTags.StatementTag.class); b.beginReturn(); if (ctx.expression() == null) { @@ -311,7 +311,7 @@ public Void visitReturn_statement(Return_statementContext ctx) { } b.endReturn(); - b.endInstrumentation(); + b.endTag(); return null; } @@ -354,7 +354,7 @@ public Void visitExpression(ExpressionContext ctx) { if (numTerms == 1) return visit(ctx.logic_term(0)); - b.beginInstrumentation(StandardTags.ExpressionTag.class); + b.beginTag(StandardTags.ExpressionTag.class); OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; for (int i = 0; i < numTerms - 1; i++) { @@ -373,7 +373,7 @@ public Void visitExpression(ExpressionContext ctx) { logicalOrMiddle(tmpLocals[i]); } } - b.endInstrumentation(); + b.endTag(); return null; } @@ -417,7 +417,7 @@ public Void visitLogic_term(Logic_termContext ctx) { return visit(ctx.logic_factor(0)); } - b.beginInstrumentation(StandardTags.ExpressionTag.class); + b.beginTag(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; @@ -439,7 +439,7 @@ public Void visitLogic_term(Logic_termContext ctx) { } b.endSLUnboxOperation(); - b.endInstrumentation(); + b.endTag(); return null; } @@ -450,7 +450,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { return visit(ctx.arithmetic(0)); } - b.beginInstrumentation(StandardTags.ExpressionTag.class); + b.beginTag(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); switch (ctx.OP_COMPARE().getText()) { @@ -499,7 +499,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { } b.endSLUnboxOperation(); - b.endInstrumentation(); + b.endTag(); return null; } @@ -508,7 +508,7 @@ public Void visitLogic_factor(Logic_factorContext ctx) { public Void visitArithmetic(ArithmeticContext ctx) { if (!ctx.OP_ADD().isEmpty()) { - b.beginInstrumentation(StandardTags.ExpressionTag.class); + b.beginTag(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); } @@ -540,7 +540,7 @@ public Void visitArithmetic(ArithmeticContext ctx) { if (!ctx.OP_ADD().isEmpty()) { b.endSLUnboxOperation(); - b.endInstrumentation(); + b.endTag(); } return null; @@ -549,7 +549,7 @@ public Void visitArithmetic(ArithmeticContext ctx) { @Override public Void visitTerm(TermContext ctx) { if (!ctx.OP_MUL().isEmpty()) { - b.beginInstrumentation(StandardTags.ExpressionTag.class); + b.beginTag(StandardTags.ExpressionTag.class); b.beginSLUnboxOperation(); } for (int i = ctx.OP_MUL().size() - 1; i >= 0; i--) { @@ -584,7 +584,7 @@ public Void visitTerm(TermContext ctx) { if (!ctx.OP_MUL().isEmpty()) { b.endSLUnboxOperation(); - b.endInstrumentation(); + b.endTag(); } return null; @@ -613,8 +613,8 @@ private void buildMemberExpressionRead(Token ident, List */ - private Stack writeLocalsStack = new Stack<>(); + private final Stack writeLocalsStack = new Stack<>(); private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { @@ -686,14 +686,14 @@ private void buildMemberExpressionWriteBefore(Token ident, List Date: Mon, 9 May 2022 17:40:45 +0200 Subject: [PATCH 079/312] [wip] new api --- .../sl/operations/SLOperationsBuilder.java | 586 +++++------ .../test/example/BoxingOperationsTest.java | 25 +- .../operation/test/example/TestLanguage.java | 26 - .../test/example/TestOperations.java | 22 +- .../example/TestOperationsParserTest.java | 66 +- .../AbstractOperationsTruffleException.java | 2 +- .../operation/BuilderFinallyTryContext.java | 36 + .../api/operation/BuilderLabelFill.java | 15 + .../api/operation/BuilderOperationLabel.java | 10 +- .../api/operation/BuilderSourceInfo.java | 10 +- .../api/operation/OperationBuilder.java | 446 +++++++++ ...nsNode.java => OperationBytecodeNode.java} | 160 +-- .../api/operation/OperationConfig.java | 51 + .../OperationInstrumentedBytecodeNode.java | 16 + .../truffle/api/operation/OperationNode.java | 151 +++ .../truffle/api/operation/OperationNodes.java | 84 ++ .../api/operation/OperationsBuilder.java | 374 ------- .../OperationsInstrumentableNode.java | 21 - .../api/operation/OperationsRootNode.java | 4 +- .../truffle/dsl/processor/TruffleTypes.java | 14 +- .../java/compiler/JavaCCompiler.java | 7 +- .../dsl/processor/operations/Operation.java | 39 +- .../operations/OperationGeneratorUtils.java | 3 +- .../OperationsBytecodeCodeGenerator.java | 91 +- .../operations/OperationsCodeGenerator.java | 938 +++++++----------- .../processor/operations/OperationsData.java | 24 - .../operations/OperationsParser.java | 23 +- .../instructions/CustomInstruction.java | 6 +- .../operations/instructions/Instruction.java | 3 +- .../dsl/processor/parser/NodeParser.java | 4 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 16 +- .../sl/nodes/SLOperationsRootNode.java | 6 +- .../truffle/sl/operations/SLOperations.java | 20 +- .../truffle/sl/parser/SLBaseVisitor.java | 21 +- .../truffle/sl/parser/SLNodeVisitor.java | 10 +- .../sl/parser/SLOperationsVisitor.java | 26 +- .../oracle/truffle/sl/parser/SLSource.java | 30 - .../sl/runtime/SLFunctionRegistry.java | 5 +- 38 files changed, 1538 insertions(+), 1853 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/{OperationsNode.java => OperationBytecodeNode.java} (59%) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 7059de1023f7..1b2b83ac4dfe 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -30,21 +30,20 @@ import com.oracle.truffle.api.operation.BuilderExceptionHandler; import com.oracle.truffle.api.operation.BuilderOperationData; import com.oracle.truffle.api.operation.BuilderOperationLabel; -import com.oracle.truffle.api.operation.BuilderSourceInfo; +import com.oracle.truffle.api.operation.OperationBuilder; +import com.oracle.truffle.api.operation.OperationBytecodeNode; +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationInstrumentedBytecodeNode; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationsBuilder; +import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationsBytesSupport; -import com.oracle.truffle.api.operation.OperationsConstantPool; -import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.ConcatNode; import com.oracle.truffle.api.strings.TruffleString.EqualNode; import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; -import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLTypesGen; import com.oracle.truffle.sl.nodes.expression.SLAddNode; @@ -66,20 +65,22 @@ import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.operations.SLOperations.SLEvalRootOperation; import com.oracle.truffle.sl.operations.SLOperations.SLInvokeOperation; -import com.oracle.truffle.sl.parser.SLSource; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; import java.lang.invoke.VarHandle; -import java.util.ArrayList; import java.util.Map; import java.util.concurrent.locks.Lock; -import java.util.function.Supplier; +import java.util.function.Consumer; @GeneratedBy(SLOperations.class) -@SuppressWarnings("unused") -public abstract class SLOperationsBuilder extends OperationsBuilder { +@SuppressWarnings({"unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) +public abstract class SLOperationsBuilder extends OperationBuilder { + + protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, OperationConfig config) { + super(nodes, isReparse, config); + } public abstract void beginBlock(); @@ -195,20 +196,30 @@ public abstract class SLOperationsBuilder extends OperationsBuilder { public abstract void endSLInvokeOperation(); - public static OperationsNode[] parse(SLLanguage language, SLSource context) { - BuilderImpl builder = new BuilderImpl(language, context, false, false); - SLOperations.parse(language, context, builder); - return builder.collect(); + public static OperationNodes create(OperationConfig config, Consumer generator) { + OperationNodes nodes = new OperationNodesImpl(generator); + BuilderImpl builder = new BuilderImpl(nodes, false, config); + generator.accept(builder); + builder.finish(); + return nodes; } - public static OperationsNode[] parseWithSourceInfo(SLLanguage language, SLSource context) { - BuilderImpl builder = new BuilderImpl(language, context, true, true); - SLOperations.parse(language, context, builder); - return builder.collect(); - } + @GeneratedBy(SLOperations.class) + private static final class OperationNodesImpl extends OperationNodes { + + OperationNodesImpl(Consumer parse) { + super(parse); + } + + @Override + protected void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes) { + BuilderImpl builder = new BuilderImpl(this, true, config); + ((Consumer) parse).accept(builder); + builder.finish(); + } + } @GeneratedBy(SLOperations.class) - @SuppressWarnings({"cast", "hiding", "unchecked", "rawtypes", "static-method"}) private static class BuilderImpl extends SLOperationsBuilder { private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); @@ -248,15 +259,15 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_LONG = 6; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; + private static final int INSTR_LOAD_CONSTANT_LONG = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_LONG = 9; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; + private static final int INSTR_LOAD_ARGUMENT_LONG = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_LONG = 13; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; + private static final int INSTR_LOAD_LOCAL_LONG = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -293,83 +304,30 @@ private static class BuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; - private final SLLanguage language; - private final SLSource parseContext; - private final boolean keepSourceInfo; - private final boolean keepInstrumentation; - private final BuilderSourceInfo sourceInfoBuilder; - byte[] bc = new byte[65535]; - ArrayList exceptionHandlers = new ArrayList<>(); - int lastPush; - int bci; - int numChildNodes; - int numBranchProfiles; - ArrayList builtNodes = new ArrayList<>(); - int nodeNumber = 0; - OperationsConstantPool constPool = new OperationsConstantPool(); - - BuilderImpl(SLLanguage language, SLSource parseContext, boolean keepSourceInfo, boolean keepInstrumentation) { - this.language = language; - this.parseContext = parseContext; - this.keepSourceInfo = keepSourceInfo; - this.keepInstrumentation = keepInstrumentation; - if (keepSourceInfo) { - sourceInfoBuilder = new BuilderSourceInfo(); - } else { - sourceInfoBuilder = null; - } - reset(); + int lastChildPush; + + BuilderImpl(OperationNodes nodes, boolean isReparse, OperationConfig config) { + super(nodes, isReparse, config); } @Override - public void reset() { - super.reset(); - bci = 0; - numChildNodes = 0; - numBranchProfiles = 0; - operationData = new BuilderOperationData(null, 0, 0, 0, false); - exceptionHandlers.clear(); - constPool.reset(); - if (keepSourceInfo) { - sourceInfoBuilder.reset(); - } + protected OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { + return new BytecodeNode(arg0, arg1, arg2, arg3, arg4, arg5, arg6); } @Override - public OperationsNode buildImpl() { - labelPass(bc); - if (operationData.depth != 0) { - throw new IllegalStateException("Not all operations ended"); - } - byte[] bcCopy = java.util.Arrays.copyOf(bc, bci); - Object[] cpCopy = constPool.getValues(); - BuilderExceptionHandler[] handlers = exceptionHandlers.toArray(new BuilderExceptionHandler[0]); - int[][] sourceInfo = null; - Source[] sources = null; - if (keepSourceInfo) { - sourceInfo = sourceInfoBuilder.build(); - sources = sourceInfoBuilder.buildSource(); - } - OperationsNode result; - ConditionProfile[] condProfiles = new ConditionProfile[numBranchProfiles]; - for (int i = 0; i < numBranchProfiles; i++) { - condProfiles[i] = ConditionProfile.createCountingProfile(); - } - result = new BytecodeNode(parseContext, sourceInfo, sources, nodeNumber, createMaxStack(), numLocals, bcCopy, cpCopy, new Node[numChildNodes], handlers, condProfiles); - builtNodes.add(result); - nodeNumber++; - reset(); - return result; + protected OperationInstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { + throw new UnsupportedOperationException("not implemented"); } @Override @@ -377,17 +335,17 @@ protected void doLeaveOperation(BuilderOperationData data) { switch (data.operationId) { case OP_FINALLY_TRY : { - bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); + doLeaveFinallyTry(data); break; } case OP_FINALLY_TRY_NO_EXCEPT : { - bci = doLeaveFinallyTry(bc, bci, data, exceptionHandlers); + doLeaveFinallyTry(data); break; } case OP_TAG : { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_LEAVE); LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) data.aux[0])); createOffset(bci + 4, ((BuilderOperationLabel) data.aux[1])); @@ -398,46 +356,6 @@ protected void doLeaveOperation(BuilderOperationData data) { } } - @Override - public void beginSource(Supplier supplier) { - if (!keepSourceInfo) { - return; - } - beginSource(supplier.get()); - } - - @Override - public void beginSource(Source source) { - if (!keepSourceInfo) { - return; - } - sourceInfoBuilder.beginSource(bci, source); - } - - @Override - public void endSource() { - if (!keepSourceInfo) { - return; - } - sourceInfoBuilder.endSource(bci); - } - - @Override - public void beginSourceSection(int start) { - if (!keepSourceInfo) { - return; - } - sourceInfoBuilder.beginSourceSection(bci, start); - } - - @Override - public void endSourceSection(int length) { - if (!keepSourceInfo) { - return; - } - sourceInfoBuilder.endSourceSection(bci, length); - } - @SuppressWarnings("unused") void doBeforeChild() { int childIndex = operationData.numChildren; @@ -445,8 +363,8 @@ void doBeforeChild() { case OP_BLOCK : { if (childIndex != 0) { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } @@ -464,8 +382,8 @@ void doBeforeChild() { case OP_TAG : { if (childIndex != 0) { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } @@ -482,127 +400,127 @@ void doAfterChild() { case OP_IF_THEN : { if (childIndex == 0) { - assert lastPush == 1; + assert lastChildPush == 1; BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); operationData.aux[0] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); createOffset(bci + 2, endLabel); bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); bci = bci + 7; } else { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); } break; } case OP_IF_THEN_ELSE : { if (childIndex == 0) { - assert lastPush == 1; + assert lastChildPush == 1; BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); operationData.aux[0] = elseLabel; - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); createOffset(bci + 2, elseLabel); bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); bci = bci + 7; } else if (childIndex == 1) { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); operationData.aux[1] = endLabel; calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, endLabel); bci = bci + 4; - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); } else { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); } break; } case OP_CONDITIONAL : { if (childIndex == 0) { - assert lastPush == 1; + assert lastChildPush == 1; BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); operationData.aux[0] = elseLabel; - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); createOffset(bci + 2, elseLabel); bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); bci = bci + 7; } else if (childIndex == 1) { - assert lastPush == 1; + assert lastChildPush == 1; BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); operationData.aux[1] = endLabel; calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, endLabel); bci = bci + 4; - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[0])); + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); } else { - assert lastPush == 1; - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + assert lastChildPush == 1; + doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); } break; } case OP_WHILE : { if (childIndex == 0) { - assert lastPush == 1; + assert lastChildPush == 1; BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); operationData.aux[1] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); createOffset(bci + 2, endLabel); bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) numBranchProfiles++); + LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); bci = bci + 7; } else { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[0])); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[0])); bci = bci + 4; - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); + doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); } break; } case OP_TRY_CATCH : { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } if (childIndex == 0) { ((BuilderExceptionHandler) operationData.aux[0]).endBci = bci; calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[1])); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[1])); bci = bci + 4; @@ -612,51 +530,48 @@ void doAfterChild() { } case OP_FINALLY_TRY : { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } if (childIndex == 0) { - doEndFinallyBlock0(bc, bci, exceptionHandlers); - bc = doFinallyRestoreBc(); - bci = doFinallyRestoreBci(); - exceptionHandlers = doFinallyRestoreExceptions(); - doEndFinallyBlock1(); + doEndFinallyBlock(); BuilderExceptionHandler beh = new BuilderExceptionHandler(); beh.startBci = bci; beh.startStack = getCurStack(); beh.exceptionIndex = getLocalIndex(operationData.aux[2]); - exceptionHandlers.add(beh); + addExceptionHandler(beh); operationData.aux[1] = beh; } break; } case OP_FINALLY_TRY_NO_EXCEPT : { - for (int i = 0; i < lastPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + for (int i = 0; i < lastChildPush; i++) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_POP); bci = bci + 2; } if (childIndex == 0) { - doEndFinallyBlock0(bc, bci, exceptionHandlers); - bc = doFinallyRestoreBc(); - bci = doFinallyRestoreBci(); - exceptionHandlers = doFinallyRestoreExceptions(); - doEndFinallyBlock1(); + doEndFinallyBlock(); } break; } } } + @Override + protected int getBlockOperationIndex() { + return OP_BLOCK; + } + @SuppressWarnings("unused") @Override public void beginBlock() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_BLOCK, getCurStack(), 0, false); - lastPush = 0; + lastChildPush = 0; } @SuppressWarnings("unused") @@ -690,7 +605,7 @@ public void endIfThen() { if (numChildren != 2) { throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); } - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -712,7 +627,7 @@ public void endIfThenElse() { if (numChildren != 3) { throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); } - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -734,7 +649,7 @@ public void endConditional() { if (numChildren != 3) { throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); } - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -745,7 +660,7 @@ public void beginWhile() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_WHILE, getCurStack(), 2, false); BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); - doEmitLabel(bci, startLabel); + doEmitLabel(startLabel); operationData.aux[0] = startLabel; } @@ -759,7 +674,7 @@ public void endWhile() { if (numChildren != 2) { throw new IllegalStateException("While expected 2 children, got " + numChildren); } - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -773,7 +688,7 @@ public void beginTryCatch(int arg0) { beh.startBci = bci; beh.startStack = getCurStack(); beh.exceptionIndex = (int)operationData.arguments[0]; - exceptionHandlers.add(beh); + addExceptionHandler(beh); operationData.aux[0] = beh; BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); operationData.aux[1] = endLabel; @@ -789,8 +704,8 @@ public void endTryCatch() { if (numChildren != 2) { throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); } - doEmitLabel(bci, ((BuilderOperationLabel) operationData.aux[1])); - lastPush = 0; + doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -801,10 +716,7 @@ public void beginFinallyTry() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, getCurStack(), 3, true); operationData.aux[2] = createParentLocal(); - operationData.aux[0] = doBeginFinallyTry(bc, bci, exceptionHandlers); - bc = new byte[65535]; - bci = 0; - exceptionHandlers = new ArrayList(); + operationData.aux[0] = doBeginFinallyTry(); } @SuppressWarnings("unused") @@ -818,11 +730,11 @@ public void endFinallyTry() { throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); } int endBci = bci; - bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); + doLeaveFinallyTry(operationData); BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); { calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, endLabel); bci = bci + 4; @@ -830,15 +742,15 @@ public void endFinallyTry() { BuilderExceptionHandler beh = ((BuilderExceptionHandler) operationData.aux[1]); beh.endBci = endBci; beh.handlerBci = bci; - bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); + doLeaveFinallyTry(operationData); { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_THROW); LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.aux[2])); bci = bci + 4; } - doEmitLabel(bci, endLabel); - lastPush = 0; + doEmitLabel(endLabel); + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -848,10 +760,7 @@ public void endFinallyTry() { public void beginFinallyTryNoExcept() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, getCurStack(), 1, true); - operationData.aux[0] = doBeginFinallyTry(bc, bci, exceptionHandlers); - bc = new byte[65535]; - bci = 0; - exceptionHandlers = new ArrayList(); + operationData.aux[0] = doBeginFinallyTry(); } @SuppressWarnings("unused") @@ -864,8 +773,8 @@ public void endFinallyTryNoExcept() { if (numChildren != 2) { throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); } - bci = doLeaveFinallyTry(bc, bci, operationData, exceptionHandlers); - lastPush = 0; + doLeaveFinallyTry(operationData); + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -873,22 +782,21 @@ public void endFinallyTryNoExcept() { @Override public void emitLabel(OperationLabel arg0) { doBeforeChild(); - BuilderOperationData operationData = new BuilderOperationData(this.operationData, OP_LABEL, getCurStack(), 0, false, arg0); - doEmitLabel(bci, ((BuilderOperationLabel) operationData.arguments[0])); - lastPush = 0; + doEmitLabel(arg0); + lastChildPush = 0; doAfterChild(); } @Override public void emitBranch(OperationLabel arg0) { doBeforeChild(); - operationData = new BuilderOperationData(this.operationData, OP_BRANCH, getCurStack(), 0, false, arg0); + operationData = new BuilderOperationData(operationData, OP_BRANCH, getCurStack(), 0, false, arg0); calculateLeaves(operationData, (BuilderOperationLabel) operationData.arguments[0]); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); createOffset(bci + 2, operationData.arguments[0]); bci = bci + 4; - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -896,12 +804,12 @@ public void emitBranch(OperationLabel arg0) { @Override public void emitConstObject(Object arg0) { doBeforeChild(); - operationData = new BuilderOperationData(this.operationData, OP_CONST_OBJECT, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + operationData = new BuilderOperationData(operationData, OP_CONST_OBJECT, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(0, true); LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); LE_BYTES.putShort(bc, bci + 2, (short) (int) constPool.add(arg0)); bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -909,12 +817,12 @@ public void emitConstObject(Object arg0) { @Override public void emitLoadArgument(int arg0) { doBeforeChild(); - operationData = new BuilderOperationData(this.operationData, OP_LOAD_ARGUMENT, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(0, true); LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_OBJECT); LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -936,12 +844,12 @@ public void endStoreLocal() { if (numChildren != 1) { throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); LE_BYTES.putShort(bc, bci + 3, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 5; - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -949,12 +857,12 @@ public void endStoreLocal() { @Override public void emitLoadLocal(OperationLocal arg0) { doBeforeChild(); - operationData = new BuilderOperationData(this.operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, true); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); + int[] predecessorBcis = doBeforeEmitInstruction(0, true); LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -977,11 +885,11 @@ public void endReturn() { throw new IllegalStateException("Return expected 1 children, got " + numChildren); } calculateLeaves(operationData); - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false); LE_BYTES.putShort(bc, bci, (short) INSTR_RETURN); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bci = bci + 3; - lastPush = 0; + lastChildPush = 0; operationData = operationData.parent; doAfterChild(); } @@ -989,7 +897,7 @@ public void endReturn() { @SuppressWarnings("unused") @Override public void beginTag(Class arg0) { - if (true) { + if (!withInstrumentation) { return; } doBeforeChild(); @@ -997,21 +905,21 @@ public void beginTag(Class arg0) { int curInstrumentId = doBeginInstrumentation((Class) arg0); BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - doEmitLabel(bci, startLabel); + doEmitLabel(startLabel); operationData.aux[0] = curInstrumentId; operationData.aux[1] = startLabel; operationData.aux[2] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_ENTER); LE_BYTES.putShort(bc, bci + 2, (short) (int) curInstrumentId); bci = bci + 4; - lastPush = 0; + lastChildPush = 0; } @SuppressWarnings("unused") @Override public void endTag() { - if (true) { + if (!withInstrumentation) { return; } if (operationData.operationId != OP_TAG) { @@ -1021,13 +929,13 @@ public void endTag() { if (numChildren < 0) { throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); } - if (lastPush != 0) { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 0, false); + if (lastChildPush != 0) { + int[] predecessorBcis = doBeforeEmitInstruction(0, false); LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT_VOID); LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); bci = bci + 4; } else { - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT); LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); @@ -1054,7 +962,7 @@ public void endSLAddOperation() { if (numChildren != 2) { throw new IllegalStateException("SLAddOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLADD_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1065,10 +973,9 @@ public void endSLAddOperation() { bc[bci + 4 + 1] = 0; bc[bci + 4 + 2] = 0; LE_BYTES.putShort(bc, bci + 4 + 3, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 4 + 5, (short) numChildNodes); - numChildNodes += 3; + LE_BYTES.putShort(bc, bci + 4 + 5, createChildNodes(3)); bci = bci + 11; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1090,7 +997,7 @@ public void endSLDivOperation() { if (numChildren != 2) { throw new IllegalStateException("SLDivOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLDIV_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1100,7 +1007,7 @@ public void endSLDivOperation() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; bci = bci + 6; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1122,7 +1029,7 @@ public void endSLEqualOperation() { if (numChildren != 2) { throw new IllegalStateException("SLEqualOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEQUAL_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1131,12 +1038,11 @@ public void endSLEqualOperation() { // numConsts = 1 bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - LE_BYTES.putShort(bc, bci + 4 + 2, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 4 + 2, createChildNodes(3)); LE_BYTES.putShort(bc, bci + 4 + 4, (short) constPool.reserve()); bc[bci + 4 + 6] = 0; - numChildNodes += 3; bci = bci + 11; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1158,7 +1064,7 @@ public void endSLLessOrEqualOperation() { if (numChildren != 2) { throw new IllegalStateException("SLLessOrEqualOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1167,7 +1073,7 @@ public void endSLLessOrEqualOperation() { // numConsts = 0 bc[bci + 4 + 0] = 0; bci = bci + 5; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1189,7 +1095,7 @@ public void endSLLessThanOperation() { if (numChildren != 2) { throw new IllegalStateException("SLLessThanOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_THAN_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1198,7 +1104,7 @@ public void endSLLessThanOperation() { // numConsts = 0 bc[bci + 4 + 0] = 0; bci = bci + 5; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1220,7 +1126,7 @@ public void endSLLogicalNotOperation() { if (numChildren != 1) { throw new IllegalStateException("SLLogicalNotOperation expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLOGICAL_NOT_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 1 bytes: [BITS] @@ -1228,7 +1134,7 @@ public void endSLLogicalNotOperation() { // numConsts = 0 bc[bci + 3 + 0] = 0; bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1250,7 +1156,7 @@ public void endSLMulOperation() { if (numChildren != 2) { throw new IllegalStateException("SLMulOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLMUL_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1260,7 +1166,7 @@ public void endSLMulOperation() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; bci = bci + 6; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1282,7 +1188,7 @@ public void endSLReadPropertyOperation() { if (numChildren != 2) { throw new IllegalStateException("SLReadPropertyOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1291,13 +1197,12 @@ public void endSLReadPropertyOperation() { // numConsts = 3 bc[bci + 4 + 0] = 0; LE_BYTES.putShort(bc, bci + 4 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 4 + 3, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 4 + 3, createChildNodes(6)); bc[bci + 4 + 5] = 0; constPool.reserve(); constPool.reserve(); - numChildNodes += 6; bci = bci + 10; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1319,7 +1224,7 @@ public void endSLSubOperation() { if (numChildren != 2) { throw new IllegalStateException("SLSubOperation expected 2 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 2, true); + int[] predecessorBcis = doBeforeEmitInstruction(2, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLSUB_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1329,7 +1234,7 @@ public void endSLSubOperation() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; bci = bci + 6; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1351,7 +1256,7 @@ public void endSLWritePropertyOperation() { if (numChildren != 3) { throw new IllegalStateException("SLWritePropertyOperation expected 3 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 3, true); + int[] predecessorBcis = doBeforeEmitInstruction(3, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); @@ -1361,14 +1266,13 @@ public void endSLWritePropertyOperation() { // numConsts = 4 bc[bci + 5 + 0] = 0; LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 5 + 3, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(7)); bc[bci + 5 + 5] = 0; constPool.reserve(); constPool.reserve(); constPool.reserve(); - numChildNodes += 7; bci = bci + 11; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1390,7 +1294,7 @@ public void endSLUnboxOperation() { if (numChildren != 1) { throw new IllegalStateException("SLUnboxOperation expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLUNBOX_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] @@ -1398,12 +1302,11 @@ public void endSLUnboxOperation() { // numConsts = 1 bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; - LE_BYTES.putShort(bc, bci + 3 + 2, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 3 + 2, createChildNodes(2)); LE_BYTES.putShort(bc, bci + 3 + 4, (short) constPool.reserve()); bc[bci + 3 + 6] = 0; - numChildNodes += 2; bci = bci + 10; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1425,7 +1328,7 @@ public void endSLFunctionLiteralOperation() { if (numChildren != 1) { throw new IllegalStateException("SLFunctionLiteralOperation expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 3 bytes: [BITS, CONST, CONTINUATION] @@ -1434,7 +1337,7 @@ public void endSLFunctionLiteralOperation() { bc[bci + 3 + 0] = 0; LE_BYTES.putShort(bc, bci + 3 + 1, (short) constPool.reserve()); bci = bci + 6; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1456,7 +1359,7 @@ public void endSLToBooleanOperation() { if (numChildren != 1) { throw new IllegalStateException("SLToBooleanOperation expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 1 bytes: [BITS] @@ -1464,7 +1367,7 @@ public void endSLToBooleanOperation() { // numConsts = 0 bc[bci + 3 + 0] = 0; bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1486,7 +1389,7 @@ public void endSLEvalRootOperation() { if (numChildren != 1) { throw new IllegalStateException("SLEvalRootOperation expected 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, 1, true); + int[] predecessorBcis = doBeforeEmitInstruction(1, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEVAL_ROOT_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 1 bytes: [BITS] @@ -1494,7 +1397,7 @@ public void endSLEvalRootOperation() { // numConsts = 0 bc[bci + 3 + 0] = 0; bci = bci + 4; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } @@ -1516,7 +1419,7 @@ public void endSLInvokeOperation() { if (numChildren < 0) { throw new IllegalStateException("SLInvokeOperation expected at least 0 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(bci, numChildren, true); + int[] predecessorBcis = doBeforeEmitInstruction(numChildren, true); LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE_OPERATION); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); @@ -1525,23 +1428,16 @@ public void endSLInvokeOperation() { // numConsts = 3 bc[bci + 5 + 0] = 0; LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 5 + 3, (short) numChildNodes); + LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(3)); bc[bci + 5 + 5] = 0; constPool.reserve(); constPool.reserve(); - numChildNodes += 3; bci = bci + 11; - lastPush = 1; + lastChildPush = 1; operationData = operationData.parent; doAfterChild(); } - private static OperationsNode reparse(SLLanguage language, SLSource context, int buildOrder) { - BuilderImpl builder = new BuilderImpl(language, context, true, true); - SLOperations.parse(language, context, builder); - return builder.collect()[buildOrder]; - } - /** * pop * Inputs: @@ -1573,13 +1469,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: @@ -1591,13 +1487,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: @@ -1615,13 +1511,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: @@ -2068,24 +1964,13 @@ private static OperationsNode reparse(SLLanguage language, SLSource context, int */ @GeneratedBy(SLOperations.class) - private static final class BytecodeNode extends OperationsNode implements Provider { + private static final class BytecodeNode extends OperationBytecodeNode implements Provider { private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - @CompilationFinal(dimensions = 1) private final byte[] bc; - @CompilationFinal(dimensions = 1) private final Object[] consts; - @Children private final Node[] children; - @CompilationFinal(dimensions = 1) private final BuilderExceptionHandler[] handlers; - @CompilationFinal(dimensions = 1) private final ConditionProfile[] conditionProfiles; - - BytecodeNode(Object parseContext, int[][] sourceInfo, Source[] sources, int buildOrder, int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { - super(parseContext, sourceInfo, sources, buildOrder, maxStack, maxLocals); - this.bc = bc; - this.consts = consts; - this.children = children; - this.handlers = handlers; - this.conditionProfiles = conditionProfiles; + BytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); } @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @@ -2152,16 +2037,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2174,11 +2059,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2186,11 +2071,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2213,11 +2098,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2225,11 +2110,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5948,11 +5833,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -5966,8 +5851,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_LONG : case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6020,7 +5905,6 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { } } - @Override public String dump() { int bci = 0; int instrIndex = 0; @@ -6162,7 +6046,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6180,7 +6064,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6190,7 +6074,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6208,7 +6092,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6243,7 +6127,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6261,14 +6145,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6286,7 +6170,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6343,7 +6227,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6361,14 +6245,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6386,7 +6270,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -7085,33 +6969,9 @@ public String dump() { for (int i = 0; i < handlers.length; i++) { sb.append(handlers[i] + "\n"); } - if (sourceInfo != null) { - sb.append("Source info:\n"); - for (int i = 0; i < sourceInfo[0].length; i++) { - sb.append(String.format(" bci=%04x, offset=%d, length=%d\n", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i])); - } - } return sb.toString(); } - @Override - public SourceSection getSourceSection() { - if (sourceInfo == null) { - OperationsNode reparsed = BuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); - copyReparsedInfo(reparsed); - } - return this.getSourceSectionImpl(); - } - - @Override - protected SourceSection getSourceSectionAtBci(int bci) { - if (sourceInfo == null) { - OperationsNode reparsed = BuilderImpl.reparse(getRootNode().getLanguage(SLLanguage.class), (SLSource) parseContext, buildOrder); - copyReparsedInfo(reparsed); - } - return this.getSourceSectionAtBciImpl(bci); - } - private static boolean SLAddOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 3bf563232bff..6ff6948b36b2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -8,7 +8,6 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystem; @@ -16,6 +15,7 @@ import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; public class BoxingOperationsTest { @@ -24,7 +24,10 @@ public class BoxingOperationsTest { // than it needs to private static RootCallTarget parse(Consumer parser) { - return BoxingOperationsBuilder.parse(null, parser)[0].createRootNode(null, "test").getCallTarget(); + return BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser) // + .getNodes().get(0) // + .createRootNode(null, "test") // + .getCallTarget(); } @Test @@ -36,7 +39,7 @@ public void testCastsPrimToPrim() { b.endLongOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -53,7 +56,7 @@ public void testCastsRefToPrim() { b.endLongOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -70,7 +73,7 @@ public void testCastsPrimToRef() { b.endStringOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -87,7 +90,7 @@ public void testCastsRefToRef() { b.endStringOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -106,7 +109,7 @@ public void testCastsChangePrim() { b.endLongOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -135,7 +138,7 @@ public void testCastsChangeRef() { b.endStringOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -164,7 +167,7 @@ public void testCastsChangeSpecPrim() { b.endLongOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -193,7 +196,7 @@ public void testCastsChangeSpecRef() { b.endStringOperator(); b.endReturn(); - b.build(); + b.publish(); }); for (int i = 0; i < 3; i++) { @@ -264,7 +267,7 @@ static long castLong(ReferenceTypeB b) { @GenerateOperations(boxingEliminationTypes = {boolean.class, int.class, long.class}) @SuppressWarnings("unused") -class BoxingOperations { +final class BoxingOperations { public static void parse(BoxingLanguage lang, Consumer data, BoxingOperationsBuilder builder) { data.accept(builder); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java deleted file mode 100644 index 14c82cb38741..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestLanguage.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.oracle.truffle.api.operation.test.example; - -import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleLanguage.Registration; -import com.oracle.truffle.api.operation.OperationsNode; - -@Registration(id = "test-operations", name = "test-operations") -public class TestLanguage extends TruffleLanguage { - - @Override - protected TestContext createContext(TruffleLanguage.Env env) { - return new TestContext(); - } - - @Override - protected CallTarget parse(ParsingRequest request) throws Exception { - OperationsNode[] nodes = TestOperationsBuilder.parse(this, request.getSource()); - return nodes[nodes.length - 1].createRootNode(this, "test").getCallTarget(); - } -} - -class TestContext { - TestContext() { - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 1dcd70451832..6910f0e65708 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,43 +1,29 @@ package com.oracle.truffle.api.operation.test.example; import java.util.List; -import java.util.function.Consumer; - -import org.junit.Assert; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; -import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.operation.Variadic; @GenerateOperations @GenerateAOT -public class TestOperations { +public final class TestOperations { private static class TestException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -9143719084054578413L; - public TestException(String string, OperationsNode node, int bci) { + public TestException(String string, Node node, int bci) { super(string, node, bci); } } - @SuppressWarnings({"unused", "unchecked"}) - public static void parse(TestLanguage language, Object input, TestOperationsBuilder builder) { - if (input instanceof Consumer) { - Consumer callback = (Consumer) input; - callback.accept(builder); - } else { - Assert.fail("invalid parser"); - } - } - @Operation @GenerateAOT static class AddOperation { @@ -74,7 +60,7 @@ public static long bla(long a1, @Variadic Object[] a2) { @GenerateAOT static class ThrowOperation { @Specialization - public static Object perform(@Bind("$bci") int bci, @Bind("this") OperationsNode node) { + public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { throw new TestException("fail", node, bci); } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 6afdec6e981c..e4505480f8d2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -1,38 +1,30 @@ package com.oracle.truffle.api.operation.test.example; -import static org.junit.Assert.fail; - -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Consumer; -import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.PolyglotException; -import org.graalvm.polyglot.Value; import org.junit.Assert; import org.junit.Test; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationsNode; -import com.oracle.truffle.api.operation.OperationsRootNode; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.operation.OperationNode; public class TestOperationsParserTest { private static RootCallTarget parse(Consumer builder) { - OperationsNode operationsNode = parseNode(builder); - System.out.println(operationsNode.dump()); + OperationNode operationsNode = parseNode(builder); + System.out.println(operationsNode); return operationsNode.createRootNode(null, "TestFunction").getCallTarget(); } - private static OperationsNode parseNode(Consumer builder) { - return TestOperationsBuilder.parse(null, builder)[0]; + private static OperationNode parseNode(Consumer builder) { + return TestOperationsBuilder.create(OperationConfig.DEFAULT, builder).getNodes().get(0); } @Test @@ -45,7 +37,7 @@ public void testAdd() { b.endAddOperation(); b.endReturn(); - b.build(); + b.publish(); }); Assert.assertEquals(42L, root.call(20L, 22L)); @@ -73,7 +65,7 @@ public void testMax() { b.endIfThenElse(); - b.build(); + b.publish(); }); Assert.assertEquals(42L, root.call(42L, 13L)); @@ -102,7 +94,7 @@ public void testIfThen() { b.emitLoadArgument(0); b.endReturn(); - b.build(); + b.publish(); }); Assert.assertEquals(0L, root.call(-2L)); @@ -114,17 +106,6 @@ public void testIfThen() { @Test public void testSumLoop() { - //@formatter:off - String src = "(do" - + " (setlocal 0 0)" - + " (setlocal 1 0)" - + " (while" - + " (less (local 0) (arg 0))" - + " (do" - + " (inclocal 1 (local 0))" - + " (inclocal 0 1)))" - + " (return (local 1)))"; - //@formatter:on // i = 0; j = 0; // while ( i < arg0 ) { j = j + i; i = i + 1; } @@ -177,6 +158,7 @@ public void testSumLoop() { b.emitLoadLocal(locJ); b.endReturn(); + b.publish(); }); Assert.assertEquals(45L, root.call(10L)); @@ -207,7 +189,7 @@ public void testTryCatch() { b.emitConstObject(0L); b.endReturn(); - b.build(); + b.publish(); }); Assert.assertEquals(1L, root.call(-1L)); @@ -262,7 +244,7 @@ public void testVariableBoxingElim() { b.emitLoadLocal(local1); b.endReturn(); - b.build(); + b.publish(); }); Assert.assertEquals(4950L, root.call()); @@ -311,7 +293,7 @@ public void testFinallyTryBasic() { b.emitConstObject(0L); b.endReturn(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 2L); @@ -353,7 +335,7 @@ public void testFinallyTryException() { b.emitConstObject(0L); b.endReturn(); - b.build(); + b.publish(); }); testOrdering(true, root, 1L, 3L); @@ -389,7 +371,7 @@ public void testFinallyTryReturn() { b.emitConstObject(3L); b.endAppenderOperation(); - b.build(); + b.publish(); }); testOrdering(false, root, 2L, 1L); @@ -445,7 +427,7 @@ public void testFinallyTryBranchOut() { b.emitConstObject(0L); b.endReturn(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -504,7 +486,7 @@ public void testFinallyTryCancel() { b.emitConstObject(0L); b.endReturn(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 2L, 4L); @@ -564,7 +546,7 @@ public void testFinallyTryInnerCf() { } b.endFinallyTry(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -621,7 +603,7 @@ public void testFinallyTryNestedTry() { } b.endFinallyTry(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 3L, 4L); @@ -687,7 +669,7 @@ public void testFinallyTryNestedFinally() { } b.endFinallyTry(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -742,7 +724,7 @@ public void testFinallyTryNestedTryThrow() { } b.endFinallyTry(); - b.build(); + b.publish(); }); testOrdering(true, root, 1L, 3L, 4L); @@ -804,7 +786,7 @@ public void testFinallyTryNestedFinallyThrow() { } b.endFinallyTry(); - b.build(); + b.publish(); }); testOrdering(true, root, 1L, 3L, 5L); @@ -844,7 +826,7 @@ public void testFinallyTryNoExceptReturn() { } b.endFinallyTryNoExcept(); - b.build(); + b.publish(); }); testOrdering(false, root, 1L, 3L); @@ -882,7 +864,7 @@ public void testFinallyTryNoExceptException() { } b.endFinallyTryNoExcept(); - b.build(); + b.publish(); }); testOrdering(true, root, 1L); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index 38fa509f5f6d..f8765978dfd0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -33,7 +33,7 @@ public AbstractOperationsTruffleException(String message) { private static Node getLocation(Node location, int bci) { if (bci >= 0) { - return ((OperationsNode) location).createLocationNode(bci); + return ((OperationNode) location.getParent()).createLocationNode(bci); } else { return location; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java new file mode 100644 index 000000000000..6d9b19ff3d48 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java @@ -0,0 +1,36 @@ +package com.oracle.truffle.api.operation; + +import java.util.ArrayList; + +class BuilderFinallyTryContext { + final BuilderFinallyTryContext prev; + final byte[] bc; + final int bci; + final ArrayList exceptionHandlers; + final ArrayList labelFills; + final ArrayList labels; + final int curStack; + final int maxStack; + + BuilderFinallyTryContext(BuilderFinallyTryContext prev, byte[] bc, int bci, ArrayList exceptionHandlers, ArrayList labelFills, + ArrayList labels, int curStack, int maxStack) { + this.prev = prev; + this.bc = bc; + this.bci = bci; + this.exceptionHandlers = exceptionHandlers; + this.labelFills = labelFills; + this.labels = labels; + this.curStack = curStack; + this.maxStack = maxStack; + } + + byte[] handlerBc; + ArrayList handlerHandlers; + public ArrayList handlerLabelFills = new ArrayList<>(); + public ArrayList relocationOffsets = new ArrayList<>(); + public int handlerMaxStack; + + boolean finalized() { + return handlerBc != null; + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java new file mode 100644 index 000000000000..c16b0cbd86a2 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java @@ -0,0 +1,15 @@ +package com.oracle.truffle.api.operation; + +class BuilderLabelFill { + int locationBci; + BuilderOperationLabel label; + + BuilderLabelFill(int locationBci, BuilderOperationLabel label) { + this.locationBci = locationBci; + this.label = label; + } + + BuilderLabelFill offset(int offset) { + return new BuilderLabelFill(offset + locationBci, label); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java index 1a57fafc6ad7..a0d26d4c52fe 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java @@ -1,20 +1,18 @@ package com.oracle.truffle.api.operation; -import com.oracle.truffle.api.operation.OperationsBuilder.FinallyTryContext; - public class BuilderOperationLabel extends OperationLabel { BuilderOperationData data; boolean hasValue = false; int targetBci = 0; - FinallyTryContext finallyTry; + BuilderFinallyTryContext finallyTry; - public BuilderOperationLabel(BuilderOperationData data, FinallyTryContext finallyTry) { + public BuilderOperationLabel(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { this.data = data; this.finallyTry = finallyTry; } - boolean belongsTo(FinallyTryContext context) { - FinallyTryContext cur = finallyTry; + boolean belongsTo(BuilderFinallyTryContext context) { + BuilderFinallyTryContext cur = finallyTry; while (cur != null) { if (cur == context) { return true; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java index b81b74af7860..c13b4ba558fd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Stack; +import com.oracle.truffle.api.operation.OperationNode.SourceInfo; import com.oracle.truffle.api.source.Source; public class BuilderSourceInfo { @@ -94,7 +95,7 @@ public Source[] buildSource() { return sourceList.toArray(new Source[sourceList.size()]); } - public int[][] build() { + public SourceInfo build() { if (!sourceStack.isEmpty()) { throw new IllegalStateException("not all sources ended"); } @@ -138,11 +139,10 @@ public int[][] build() { lastBci = curBci; } - return new int[][]{ + return new SourceInfo( Arrays.copyOf(bciArray, index), - Arrays.copyOf(startArray, index), - Arrays.copyOf(lengthArray, index), Arrays.copyOf(sourceIndexArray, index), - }; + Arrays.copyOf(startArray, index), + Arrays.copyOf(lengthArray, index)); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java new file mode 100644 index 000000000000..899a026f31ff --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -0,0 +1,446 @@ +package com.oracle.truffle.api.operation; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.function.Supplier; + +import com.oracle.truffle.api.instrumentation.Tag; +import com.oracle.truffle.api.memory.ByteArraySupport; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.OperationNode.SourceInfo; +import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.source.Source; + +public abstract class OperationBuilder { + + private final boolean isReparse; + private final ArrayList builtNodes = new ArrayList<>(); + private final OperationNodes nodes; + + private int buildIndex = 0; + private BuilderSourceInfo sourceBuilder; + + protected final boolean withSource; + protected final boolean withInstrumentation; + + protected byte[] bc = new byte[65536]; + protected int bci = 0; + protected final OperationsConstantPool constPool = new OperationsConstantPool(); + + protected static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); + + protected BuilderOperationData operationData; + protected BuilderFinallyTryContext finallyTryContext; + + protected OperationBuilder(OperationNodes nodes, boolean isReparse, OperationConfig config) { + this.nodes = nodes; + this.isReparse = isReparse; + + if (isReparse) { + builtNodes.addAll(nodes.getNodes()); + } + + this.withSource = config.isWithSource(); + this.withInstrumentation = config.isWithInstrumentation(); + + if (withSource) { + sourceBuilder = new BuilderSourceInfo(); + } else { + sourceBuilder = null; + } + + reset(); + } + + private void reset() { + bci = 0; + curStack = 0; + maxStack = 0; + numLocals = 0; + constPool.reset(); + + operationData = new BuilderOperationData(null, getBlockOperationIndex(), 0, 0, false); + + labelFills.clear(); + + numChildNodes = 0; + numBranchProfiles = 0; + } + + public final OperationNode publish() { + if (operationData.depth != 0) { + throw new IllegalStateException("Not all operations closed"); + } + + OperationNode result; + if (!isReparse) { + SourceInfo sourceInfo = withSource ? sourceBuilder.build() : null; + result = new OperationNode(nodes, sourceInfo, publishBytecode()); + assert buildIndex == builtNodes.size(); + builtNodes.add(result); + } else { + result = builtNodes.get(buildIndex); + + if (withSource && !result.hasSourceInfo()) { + result.setSourceInfo(sourceBuilder.build()); + } + + if (withInstrumentation && !result.isBytecodeInstrumented()) { + OperationBytecodeNode instrumentedBytecode = publishBytecode(); + assert instrumentedBytecode instanceof OperationInstrumentedBytecodeNode; + result.changeBytecode(instrumentedBytecode); + } + } + + reset(); + + buildIndex++; + + return result; + } + + protected final void finish() { + if (withSource) { + nodes.setSources(sourceBuilder.buildSource()); + } + if (!isReparse) { + nodes.setNodes(builtNodes.toArray(new OperationNode[0])); + } + } + + private OperationBytecodeNode publishBytecode() { + + labelPass(); + + byte[] bcCopy = Arrays.copyOf(bc, bci); + Object[] consts = constPool.getValues(); + Node[] childrenCopy = new Node[numChildNodes]; + BuilderExceptionHandler[] handlers = exceptionHandlers.toArray(new BuilderExceptionHandler[0]); + + ConditionProfile[] conditionProfiles = new ConditionProfile[numBranchProfiles]; + for (int i = 0; i < conditionProfiles.length; i++) { + conditionProfiles[i] = ConditionProfile.createCountingProfile(); + } + + if (withInstrumentation) { + return createInstrumentedBytecode(maxStack, numLocals, bcCopy, consts, childrenCopy, handlers, conditionProfiles); + } else { + return createBytecode(maxStack, numLocals, bcCopy, consts, childrenCopy, handlers, conditionProfiles); + } + } + + protected abstract OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); + + protected abstract OperationInstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, + ConditionProfile[] arg6); + + protected abstract int getBlockOperationIndex(); + + // ------------------------ branch profiles ------------------------ + + private short numChildNodes; + + protected final short createChildNodes(int count) { + short curIndex = numChildNodes; + numChildNodes += count; + return curIndex; + } + + // ------------------------ branch profiles ------------------------ + + private short numBranchProfiles; + + protected final short createBranchProfile() { + return numBranchProfiles++; + } + + // ------------------------ stack / successor handling ------------------------ + + private int[] stackSourceBci = new int[1024]; + private int curStack; + private int maxStack; + + protected int[] doBeforeEmitInstruction(int numPops, boolean pushValue) { + int[] result = new int[numPops]; + + for (int i = numPops - 1; i >= 0; i--) { + curStack--; + int predBci = stackSourceBci[curStack]; + result[i] = predBci; + } + + if (pushValue) { + stackSourceBci[curStack] = bci; + + curStack++; + + if (curStack > maxStack) { + maxStack = curStack; + } + } + + return result; + } + + protected int createMaxStack() { + return maxStack; + } + + protected int getCurStack() { + return curStack; + } + + protected void setCurStack(int curStack) { + // this should probably be: + // assert this.curStack == curStack; + this.curStack = curStack; + } + + // ------------------------ locals handling ------------------------ + + protected int numLocals; + + public final OperationLocal createLocal() { + BuilderOperationLocal local = new BuilderOperationLocal(operationData, operationData.numLocals++); + + if (numLocals < local.id + 1) { + numLocals = local.id + 1; + } + + return local; + } + + protected final OperationLocal createParentLocal() { + BuilderOperationData parent = operationData.parent; + assert operationData.numLocals == parent.numLocals; + + BuilderOperationLocal local = new BuilderOperationLocal(parent, parent.numLocals++); + operationData.numLocals++; + + if (numLocals < local.id + 1) { + numLocals = local.id + 1; + } + + return local; + } + + protected int getLocalIndex(Object value) { + BuilderOperationLocal local = (BuilderOperationLocal) value; + + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + + return local.id; + } + + private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { + BuilderOperationData cur = child; + while (cur.depth > parent.depth) { + cur = cur.parent; + } + + return cur == parent; + } + + // ------------------------ source sections ------------------------ + + public final void beginSource(Source source) { + if (withSource) { + sourceBuilder.beginSource(bci, source); + } + } + + public final void beginSource(Supplier supplier) { + if (withSource) { + sourceBuilder.beginSource(bci, supplier.get()); + } + } + + public final void endSource() { + if (withSource) { + sourceBuilder.endSource(bci); + } + } + + public final void beginSourceSection(int start) { + if (withSource) { + sourceBuilder.beginSourceSection(bci, start); + } + } + + public final void endSourceSection(int length) { + if (withSource) { + sourceBuilder.endSourceSection(bci, length); + } + } + + // ------------------------------- labels ------------------------------- + + private ArrayList labelFills = new ArrayList<>(); + private ArrayList labels = new ArrayList<>(); + + protected final void createOffset(int locationBci, Object label) { + BuilderLabelFill fill = new BuilderLabelFill(locationBci, (BuilderOperationLabel) label); + labelFills.add(fill); + } + + protected final void labelPass() { + labelPass(null); + } + + private final void labelPass(BuilderFinallyTryContext finallyTry) { + for (BuilderLabelFill fill : labelFills) { + if (finallyTry != null) { + if (fill.label.belongsTo(finallyTry)) { + assert fill.label.hasValue : "inner label should have been resolved by now"; + finallyTry.relocationOffsets.add(fill.locationBci); + } else { + finallyTry.handlerLabelFills.add(fill); + } + } + LE_BYTES.putShort(bc, fill.locationBci, (short) fill.label.targetBci); + } + } + + public final OperationLabel createLabel() { + BuilderOperationLabel label = new BuilderOperationLabel(operationData, currentFinallyTry); + labels.add(label); + return label; + } + + protected abstract void doLeaveOperation(BuilderOperationData data); + + protected final void calculateLeaves(BuilderOperationData fromData) { + calculateLeaves(fromData, (BuilderOperationData) null); + } + + protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationLabel toLabel) { + calculateLeaves(fromData, toLabel.data); + } + + protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { + if (toData != null && fromData.depth < toData.depth) { + throw new UnsupportedOperationException("illegal jump to deeper operation"); + } + + if (fromData == toData) { + return; // nothing to leave + } + + BuilderOperationData cur = fromData; + while (true) { + doLeaveOperation(cur); + cur = cur.parent; + + if (toData == null && cur == null) { + break; + } else if (toData != null && cur.depth <= toData.depth) { + break; + } + } + + if (cur != toData) { + throw new UnsupportedOperationException("illegal jump to non-parent operation"); + } + } + + @SuppressWarnings("unused") + protected final int doBranchInstruction(int instr, OperationLabel label) { + createOffset(bci, label); + return 2; + } + + protected final void doEmitLabel(OperationLabel label) { + BuilderOperationLabel lbl = (BuilderOperationLabel) label; + if (lbl.hasValue) { + throw new UnsupportedOperationException("label already emitted"); + } + if (operationData != lbl.data) { + throw new UnsupportedOperationException("label must be created and emitted inside same operation"); + } + lbl.hasValue = true; + lbl.targetBci = bci; + } + + // ------------------------ exceptions ------------------------ + + private ArrayList exceptionHandlers = new ArrayList<>(); + + protected final void addExceptionHandler(BuilderExceptionHandler handler) { + exceptionHandlers.add(handler); + } + + // ------------------------ try / finally ------------------------ + + private BuilderFinallyTryContext currentFinallyTry = null; + + protected final Object doBeginFinallyTry() { + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, bc, bci, exceptionHandlers, labelFills, labels, curStack, maxStack); + + bc = new byte[65536]; + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + + return currentFinallyTry; + } + + protected final void doEndFinallyBlock() { + labelPass(currentFinallyTry); + + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + + bc = currentFinallyTry.bc; + bci = currentFinallyTry.bci; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + + currentFinallyTry = currentFinallyTry.prev; + + } + + protected final void doLeaveFinallyTry(BuilderOperationData opData) { + BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; + + if (!context.finalized()) { + // leave out of a finally block + return; + } + + System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); + + for (int offset : context.relocationOffsets) { + short oldOffset = LE_BYTES.getShort(bc, bci + offset); + LE_BYTES.putShort(bc, bci + offset, (short) (oldOffset + bci)); + } + + for (BuilderExceptionHandler handler : context.handlerHandlers) { + addExceptionHandler(handler.offset(bci, curStack)); + } + + for (BuilderLabelFill fill : context.handlerLabelFills) { + labelFills.add(fill.offset(bci)); + } + + if (maxStack < curStack + context.handlerMaxStack) { + maxStack = curStack + context.handlerMaxStack; + } + + bci += context.handlerBc.length; + } + + // ------------------------ instrumentation ------------------------ + + @SuppressWarnings({"static-method", "unused"}) + protected final int doBeginInstrumentation(Class cls) { + // TODO + return 0; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java similarity index 59% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java index 89ab1102a766..e05aa5302b17 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java @@ -1,21 +1,17 @@ package com.oracle.truffle.api.operation; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.impl.FrameWithoutBoxing; -import com.oracle.truffle.api.instrumentation.InstrumentableNode; -import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.profiles.ConditionProfile; -public abstract class OperationsNode extends Node implements InstrumentableNode, BytecodeOSRNode { +public abstract class OperationBytecodeNode extends Node implements BytecodeOSRNode { // The order of these must be the same as FrameKind in processor public static final int FRAME_TYPE_OBJECT = 0; @@ -26,153 +22,63 @@ public abstract class OperationsNode extends Node implements InstrumentableNode, public static final int FRAME_TYPE_LONG = 5; public static final int FRAME_TYPE_DOUBLE = 6; - protected static final int VALUES_OFFSET = 0; - - private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); - - private static FrameDescriptor createFrameDescriptor(int maxStack, int numLocals) { - FrameDescriptor.Builder b = FrameDescriptor.newBuilder(VALUES_OFFSET + maxStack + numLocals); - - b.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); - - return b.build(); - } + private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); protected final int maxStack; protected final int maxLocals; - protected final Object parseContext; - protected int[][] sourceInfo; - protected Source[] sources; - protected final int buildOrder; - - protected OperationsNode( - Object parseContext, - int[][] sourceInfo, - Source[] sources, - int buildOrder, - int maxStack, - int maxLocals) { - this.buildOrder = buildOrder; - this.parseContext = parseContext; - this.sourceInfo = sourceInfo; - this.sources = sources; - this.maxLocals = maxLocals; - this.maxStack = maxStack; - } + @CompilationFinal(dimensions = 1) protected final byte[] bc; + @CompilationFinal(dimensions = 1) protected final Object[] consts; + @Children protected final Node[] children; + @CompilationFinal(dimensions = 1) protected final BuilderExceptionHandler[] handlers; + @CompilationFinal(dimensions = 1) protected final ConditionProfile[] conditionProfiles; - public FrameDescriptor createFrameDescriptor() { - return createFrameDescriptor(maxStack, maxLocals); - } + protected static final int VALUES_OFFSET = 0; - public OperationsRootNode createRootNode(TruffleLanguage language, String name) { - return new OperationsRootNode(language, this, name, false); + protected OperationBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + this.maxStack = maxStack; + this.maxLocals = maxLocals; + this.bc = bc; + this.consts = consts; + this.children = children; + this.handlers = handlers; + this.conditionProfiles = conditionProfiles; } - public OperationsRootNode createInternalRootNode(TruffleLanguage language, String name) { - return new OperationsRootNode(language, this, name, true); + FrameDescriptor createFrameDescriptor() { + FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); + builder.addSlots(maxLocals, FrameSlotKind.Illegal); + builder.addSlots(maxStack, FrameSlotKind.Illegal); + return builder.build(); } - public final Object execute(VirtualFrame frame) { + Object execute(VirtualFrame frame) { return continueAt(frame, 0, maxLocals + VALUES_OFFSET); } - protected abstract Object continueAt(VirtualFrame frame, int index, int startSp); - - public abstract String dump(); - - protected final void copyReparsedInfo(OperationsNode other) { - this.sourceInfo = other.sourceInfo; - this.sources = other.sources; - } - - protected final SourceSection getSourceSectionImpl() { - if (sourceInfo[0].length == 0) { - return null; - } - - for (int i = 0; i < sourceInfo.length; i++) { - if (sourceInfo[1][i] >= 0) { - return sources[sourceInfo[3][i]].createSection(sourceInfo[1][i], sourceInfo[2][i]); - } - } - - return null; - } - - protected abstract SourceSection getSourceSectionAtBci(int bci); + protected abstract Object continueAt(VirtualFrame frame, int bci, int sp); - protected final SourceSection getSourceSectionAtBciImpl(int bci) { - if (sourceInfo[0].length == 0) { - return null; - } - - int i; - for (i = 0; i < sourceInfo[0].length; i++) { - if (sourceInfo[0][i] > bci) { - break; - } - } - - if (i == 0) { - return null; - } else { - return sources[sourceInfo[3][i - 1]].createSection(sourceInfo[1][i - 1], sourceInfo[2][i - 1]); - } - } - - public final Node createLocationNode(final int bci) { - return new Node() { - @Override - public SourceSection getSourceSection() { - return getSourceSectionAtBci(bci); - } - - @Override - public SourceSection getEncapsulatingSourceSection() { - return getSourceSectionAtBci(bci); - } - }; - } - - @Override - public boolean isInstrumentable() { + boolean isInstrumented() { return false; } - public WrapperNode createWrapper(ProbeNode probe) { - // TODO Auto-generated method stub - return null; - } - - protected static T interlog(T arg, String reason) { - if (CompilerDirectives.inInterpreter()) { - System.out.printf(" >> %s %s%n", reason, arg); - } - - return arg; - } - // OSR - @Override + @CompilationFinal private Object osrMetadata; + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - // we'll need a container object if we ever need to pass more than just the sp - // TODO needs workaround for arguments getting null on OSR return continueAt(osrFrame, target, (int) interpreterState); } - @CompilationFinal private Object osrMetadata; + public Object getOSRMetadata() { + return osrMetadata; + } - @Override public void setOSRMetadata(Object osrMetadata) { this.osrMetadata = osrMetadata; } - @Override - public Object getOSRMetadata() { - return osrMetadata; - } + // boxing elim protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, short[] descriptor) { int op = LE_BYTES.getShort(bc, bci) & 0xffff; @@ -193,8 +99,6 @@ protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, sho } } - // --------------- boxing elim ----------------------- - protected static Object expectObject(VirtualFrame frame, int slot) { if (frame.isObject(slot)) { return frame.getObject(slot); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java new file mode 100644 index 000000000000..0dfd41ec0987 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java @@ -0,0 +1,51 @@ +package com.oracle.truffle.api.operation; + +public class OperationConfig { + + public static final OperationConfig DEFAULT = new OperationConfig(false, false); + public static final OperationConfig WITH_SOURCE = new OperationConfig(true, false); + + public static final OperationConfig COMPLETE = new OperationConfig(true, true); + + private final boolean withSource; + private final boolean withInstrumentation; + + public OperationConfig(boolean withSource, boolean withInstrumentation) { + this.withSource = withSource; + this.withInstrumentation = withInstrumentation; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public boolean isWithSource() { + return withSource; + } + + public boolean isWithInstrumentation() { + return withInstrumentation; + } + + public static class Builder { + private boolean withSource; + private boolean withInstrumentation; + + Builder() { + } + + public Builder withSource(boolean value) { + this.withSource = value; + return this; + } + + public Builder withInstrumentation(boolean value) { + this.withInstrumentation = value; + return this; + } + + public OperationConfig build() { + return new OperationConfig(withSource, withInstrumentation); + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java new file mode 100644 index 000000000000..66a7b9eee290 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java @@ -0,0 +1,16 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.ConditionProfile; + +public abstract class OperationInstrumentedBytecodeNode extends OperationBytecodeNode { + + protected OperationInstrumentedBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); + } + + @Override + boolean isInstrumented() { + return true; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java new file mode 100644 index 000000000000..9482ef54c731 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -0,0 +1,151 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.source.SourceSection; + +public final class OperationNode extends Node { + + private final OperationNodes nodes; + @CompilationFinal private SourceInfo sourceInfo; + + @Child private OperationBytecodeNode bcNode; + + OperationNode(OperationNodes nodes, SourceInfo sourceInfo, OperationBytecodeNode bcNode) { + this.nodes = nodes; + this.sourceInfo = sourceInfo; + this.bcNode = bcNode; + } + + public FrameDescriptor createFrameDescriptor() { + return bcNode.createFrameDescriptor(); + } + + public OperationsRootNode createRootNode(TruffleLanguage language, String name) { + return new OperationsRootNode(language, this, name, false); + } + + public OperationsRootNode createInternalRootNode(TruffleLanguage language, String name) { + return new OperationsRootNode(language, this, name, true); + } + + public Object execute(VirtualFrame frame) { + return bcNode.execute(frame); + } + + // ------------------------------------ internal accessors ------------------------------------ + + boolean isBytecodeInstrumented() { + return bcNode.isInstrumented(); + } + + void changeBytecode(OperationBytecodeNode node) { + CompilerAsserts.neverPartOfCompilation(); + bcNode = insert(node); + } + + boolean hasSourceInfo() { + return sourceInfo != null; + } + + void setSourceInfo(SourceInfo sourceInfo) { + CompilerAsserts.neverPartOfCompilation(); + assert !hasSourceInfo() : "already have source info"; + this.sourceInfo = sourceInfo; + } + + // ------------------------------------ sources ------------------------------------ + + @Override + public SourceSection getSourceSection() { + nodes.ensureSources(); + + if (sourceInfo == null) { + return null; + } + + for (int i = 0; i < sourceInfo.length(); i++) { + if (sourceInfo.sourceStart[i] >= 0) { + // return the first defined source section - that one should encompass the entire + // function + return nodes.sources[sourceInfo.sourceIndex[i]].createSection(sourceInfo.sourceStart[i], sourceInfo.sourceLength[i]); + } + } + + return null; + } + + @ExplodeLoop + protected final SourceSection getSourceSectionAtBci(int bci) { + nodes.ensureSources(); + + if (sourceInfo == null) { + return null; + } + + int i; + // find the index of the first greater BCI + for (i = 0; i < sourceInfo.length(); i++) { + if (sourceInfo.bci[i] > bci) { + break; + } + } + + if (i == 0) { + return null; + } else { + int sourceIndex = sourceInfo.sourceIndex[i - 1]; + if (sourceIndex < 0) { + return null; + } + + int sourceStart = sourceInfo.sourceStart[i - 1]; + int sourceLength = sourceInfo.sourceLength[i - 1]; + if (sourceStart < 0) { + return null; + } + return nodes.sources[sourceIndex].createSection(sourceStart, sourceLength); + } + } + + static class SourceInfo { + @CompilationFinal(dimensions = 1) final int[] bci; + @CompilationFinal(dimensions = 1) final int[] sourceIndex; + @CompilationFinal(dimensions = 1) final int[] sourceStart; + @CompilationFinal(dimensions = 1) final int[] sourceLength; + + SourceInfo(int[] bci, int[] sourceIndex, int[] start, int[] length) { + assert bci.length == sourceIndex.length; + assert bci.length == start.length; + assert bci.length == length.length; + + this.bci = bci; + this.sourceIndex = sourceIndex; + this.sourceStart = start; + this.sourceLength = length; + } + + int length() { + return bci.length; + } + } + + public final Node createLocationNode(final int bci) { + return new Node() { + @Override + public SourceSection getSourceSection() { + return getSourceSectionAtBci(bci); + } + + @Override + public SourceSection getEncapsulatingSourceSection() { + return getSourceSectionAtBci(bci); + } + }; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java new file mode 100644 index 000000000000..7c0ed3d39881 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -0,0 +1,84 @@ +package com.oracle.truffle.api.operation; + +import java.util.List; +import java.util.function.Consumer; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.source.Source; + +public abstract class OperationNodes { + private final Consumer parse; + @CompilationFinal(dimensions = 1) private OperationNode[] nodes; + @CompilationFinal(dimensions = 1) Source[] sources; + @CompilationFinal private boolean hasInstrumentation; + + protected OperationNodes(Consumer parse) { + this.parse = parse; + } + + public List getNodes() { + return List.of(nodes); + } + + void setNodes(OperationNode[] nodes) { + this.nodes = nodes; + } + + public boolean hasSources() { + return sources != null; + } + + void setSources(Source[] sources) { + this.sources = sources; + } + + public boolean hasInstrumentation() { + return hasInstrumentation; + } + + private boolean checkNeedsWork(OperationConfig config) { + if (config.isWithSource() && !hasSources()) { + return true; + } + if (config.isWithInstrumentation() && !hasInstrumentation()) { + return true; + } + return false; + } + + public boolean updateConfiguration(OperationConfig config) { + if (!checkNeedsWork(config)) { + return false; + } + + reparse(config); + + return true; + } + + /** + * Should look like: + * + *
+     * BuilderImpl builder = new BuilderImpl(this, true, config);
+     * parse.accept(builder);
+     * 
+ */ + @SuppressWarnings({"rawtypes", "hiding"}) + protected abstract void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes); + + void reparse(OperationConfig config) { + reparseImpl(config, parse, nodes); + } + + /** + * Checks if the sources are present, and if not tries to reparse to get them. + */ + final void ensureSources() { + if (sources == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + reparse(OperationConfig.WITH_SOURCE); + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java deleted file mode 100644 index 45ac6c734d01..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBuilder.java +++ /dev/null @@ -1,374 +0,0 @@ -package com.oracle.truffle.api.operation; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.function.Supplier; - -import com.oracle.truffle.api.instrumentation.Tag; -import com.oracle.truffle.api.memory.ByteArraySupport; -import com.oracle.truffle.api.source.Source; - -public abstract class OperationsBuilder { - - private ArrayList builtNodes = new ArrayList<>(); - - protected abstract OperationsNode buildImpl(); - - protected static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - - public final OperationsNode build() { - OperationsNode result = buildImpl(); - builtNodes.add(result); - return result; - } - - public final OperationsNode[] collect() { - return builtNodes.toArray(new OperationsNode[builtNodes.size()]); - } - - protected int instrumentationId = 0; - - public void reset() { - labelFills.clear(); - instrumentationId = 0; - - curStack = 0; - maxStack = 0; - - numLocals = 0; - } - - // ------------------------ labels ------------------------ - - private static class LabelFill { - int locationBci; - BuilderOperationLabel label; - - LabelFill(int locationBci, BuilderOperationLabel label) { - this.locationBci = locationBci; - this.label = label; - } - - LabelFill offset(int offset) { - return new LabelFill(offset + locationBci, label); - } - } - - private ArrayList labelFills = new ArrayList<>(); - private ArrayList labels = new ArrayList<>(); - - protected final void relocateLabels(int bci, int length) { - for (LabelFill fill : labelFills) { - if (fill.locationBci >= bci) { - fill.locationBci += length; - } - } - - for (BuilderOperationLabel label : labels) { - if (label.hasValue && label.targetBci >= bci) { - label.targetBci += length; - } - } - } - - protected final void createOffset(int locationBci, Object label) { - LabelFill fill = new LabelFill(locationBci, (BuilderOperationLabel) label); - labelFills.add(fill); - } - - protected final void labelPass(byte[] bc) { - labelPass(bc, null); - } - - private final void labelPass(byte[] bc, FinallyTryContext finallyTry) { - for (LabelFill fill : labelFills) { - if (finallyTry != null) { - if (fill.label.belongsTo(finallyTry)) { - assert fill.label.hasValue : "inner label should have been resolved by now"; - finallyTry.relocationOffsets.add(fill.locationBci); - } else { - finallyTry.handlerLabelFills.add(fill); - } - } - LE_BYTES.putShort(bc, fill.locationBci, (short) fill.label.targetBci); - } - } - - protected BuilderOperationData operationData = null; - - public final OperationLabel createLabel() { - BuilderOperationLabel label = new BuilderOperationLabel(operationData, currentFinallyTry); - labels.add(label); - return label; - } - - protected abstract void doLeaveOperation(BuilderOperationData data); - - protected final void calculateLeaves(BuilderOperationData fromData) { - calculateLeaves(fromData, (BuilderOperationData) null); - } - - protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationLabel toLabel) { - calculateLeaves(fromData, toLabel.data); - } - - protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { - if (toData != null && fromData.depth < toData.depth) { - throw new UnsupportedOperationException("illegal jump to deeper operation"); - } - - if (fromData == toData) { - return; // nothing to leave - } - - BuilderOperationData cur = fromData; - while (true) { - doLeaveOperation(cur); - cur = cur.parent; - - if (toData == null && cur == null) { - break; - } else if (toData != null && cur.depth <= toData.depth) { - break; - } - } - - if (cur != toData) { - throw new UnsupportedOperationException("illegal jump to non-parent operation"); - } - } - - @SuppressWarnings("unused") - protected final int doBranchInstruction(int bci, int instr, OperationLabel label) { - createOffset(bci, label); - return 2; - } - - protected void doEmitLabel(int bci, OperationLabel label) { - BuilderOperationLabel lbl = (BuilderOperationLabel) label; - if (lbl.hasValue) { - throw new UnsupportedOperationException("label already emitted"); - } - if (operationData != lbl.data) { - throw new UnsupportedOperationException("label must be created and emitted inside same operation"); - } - lbl.hasValue = true; - lbl.targetBci = bci; - } - - // ------------------------ stack / successor handling ------------------------ - - private int[] stackSourceBci = new int[1024]; - private int curStack; - private int maxStack; - - protected int[] doBeforeEmitInstruction(int bci, int numPops, boolean pushValue) { - int[] result = new int[numPops]; - - for (int i = numPops - 1; i >= 0; i--) { - curStack--; - int predBci = stackSourceBci[curStack]; - result[i] = predBci; - } - - if (pushValue) { - stackSourceBci[curStack] = bci; - - curStack++; - - if (curStack > maxStack) { - maxStack = curStack; - } - } - - return result; - } - - protected int createMaxStack() { - return maxStack; - } - - protected int getCurStack() { - return curStack; - } - - protected void setCurStack(int curStack) { - // this should probably be: - // assert this.curStack == curStack; - this.curStack = curStack; - } - - // ------------------------ locals handling ------------------------ - - protected int numLocals; - - public final OperationLocal createLocal() { - BuilderOperationLocal local = new BuilderOperationLocal(operationData, operationData.numLocals++); - - if (numLocals < local.id + 1) { - numLocals = local.id + 1; - } - - return local; - } - - protected final OperationLocal createParentLocal() { - BuilderOperationData parent = operationData.parent; - assert operationData.numLocals == parent.numLocals; - - BuilderOperationLocal local = new BuilderOperationLocal(parent, parent.numLocals++); - operationData.numLocals++; - - if (numLocals < local.id + 1) { - numLocals = local.id + 1; - } - - return local; - } - - protected int getLocalIndex(Object value) { - BuilderOperationLocal local = (BuilderOperationLocal) value; - - // verify nesting - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - - return local.id; - } - - private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { - BuilderOperationData cur = child; - while (cur.depth > parent.depth) { - cur = cur.parent; - } - - return cur == parent; - } - - // ------------------------ source sections ------------------------ - - public abstract void beginSource(Source source); - - public abstract void beginSource(Supplier supplier); - - public abstract void endSource(); - - public abstract void beginSourceSection(int start); - - public abstract void endSourceSection(int length); - - // ------------------------ instrumentation ------------------------ - - private final ArrayList instrumentTrees = new ArrayList<>(); - - protected final OperationsInstrumentTreeNode[] getInstrumentTrees() { - return instrumentTrees.toArray(new OperationsInstrumentTreeNode[instrumentTrees.size()]); - } - - protected final int doBeginInstrumentation(Class tag) { - instrumentTrees.add(new OperationsInstrumentTreeNode(tag)); - return instrumentTrees.size() - 1; - } - - // ------------------------ try / finally ------------------------ - - private FinallyTryContext currentFinallyTry = null; - - static class FinallyTryContext { - final FinallyTryContext prev; - private final byte[] bc; - private final int bci; - private final ArrayList exceptionHandlers; - private final ArrayList labelFills; - private final ArrayList labels; - private final int curStack; - private final int maxStack; - - private byte[] handlerBc; - private ArrayList handlerHandlers; - public ArrayList handlerLabelFills = new ArrayList<>(); - public ArrayList relocationOffsets = new ArrayList<>(); - public int handlerMaxStack; - - FinallyTryContext(FinallyTryContext prev, byte[] bc, int bci, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, - int curStack, int maxStack) { - this.prev = prev; - this.bc = bc; - this.bci = bci; - this.exceptionHandlers = exceptionHandlers; - this.labelFills = labelFills; - this.labels = labels; - this.curStack = curStack; - this.maxStack = maxStack; - } - - private boolean finalized() { - return handlerBc != null; - } - } - - protected final Object doBeginFinallyTry(byte[] bc, int bci, ArrayList handlers) { - currentFinallyTry = new FinallyTryContext(currentFinallyTry, bc, bci, handlers, labelFills, labels, curStack, maxStack); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - return currentFinallyTry; - } - - protected final void doEndFinallyBlock0(byte[] bc, int bci, ArrayList handlers) { - labelPass(bc, currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = handlers; - currentFinallyTry.handlerMaxStack = maxStack; - } - - protected final byte[] doFinallyRestoreBc() { - return currentFinallyTry.bc; - } - - protected final int doFinallyRestoreBci() { - return currentFinallyTry.bci; - } - - protected final ArrayList doFinallyRestoreExceptions() { - return currentFinallyTry.exceptionHandlers; - } - - protected final void doEndFinallyBlock1() { - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - } - - protected final int doLeaveFinallyTry(byte[] bc, int bci, BuilderOperationData data, ArrayList handlers) { - FinallyTryContext context = (FinallyTryContext) data.aux[0]; - - if (!context.finalized()) { - // still in Finally part, nothing to leave yet - return bci; - } - - System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); - - for (int offset : context.relocationOffsets) { - short oldOffset = LE_BYTES.getShort(bc, bci + offset); - LE_BYTES.putShort(bc, bci + offset, (short) (oldOffset + bci)); - } - - for (BuilderExceptionHandler handler : context.handlerHandlers) { - handlers.add(handler.offset(bci, curStack)); - } - - for (LabelFill fill : context.handlerLabelFills) { - labelFills.add(fill.offset(bci)); - } - - if (maxStack < curStack + context.handlerMaxStack) { - maxStack = curStack + context.handlerMaxStack; - } - - return bci + context.handlerBc.length; - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java deleted file mode 100644 index 377a93daa63b..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentableNode.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.oracle.truffle.api.operation; - -import com.oracle.truffle.api.source.Source; - -public abstract class OperationsInstrumentableNode extends OperationsNode { - - @Children OperationsInstrumentTreeNode[] instrumentTree; - - protected OperationsInstrumentableNode( - Object parseContext, - int[][] sourceInfo, - Source[] sources, - int buildOrder, - int maxStack, - int maxLocals, - OperationsInstrumentTreeNode[] instrumentTree) { - super(parseContext, sourceInfo, sources, buildOrder, maxStack, maxLocals); - this.instrumentTree = instrumentTree; - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index 541457d9de12..499478856647 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -6,12 +6,12 @@ public class OperationsRootNode extends RootNode { - @Child private OperationsNode node; + @Child private OperationNode node; private final String nodeName; private final boolean isInternal; - OperationsRootNode(TruffleLanguage language, OperationsNode node, String nodeName, boolean isInternal) { + OperationsRootNode(TruffleLanguage language, OperationNode node, String nodeName, boolean isInternal) { super(language, node.createFrameDescriptor()); this.node = insert(node); this.nodeName = nodeName; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 3d2bf785a6ef..3cc16c493a00 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -232,13 +232,14 @@ public class TruffleTypes { public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; + public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBytecodeNode"; + public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; + public static final String OperationNodes_Name = "com.oracle.truffle.api.operation.OperationNodes"; public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy"; - public static final String OperationsBuilder_Name = "com.oracle.truffle.api.operation.OperationsBuilder"; + public static final String OperationBuilder_Name = "com.oracle.truffle.api.operation.OperationBuilder"; public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; - public static final String OperationsNode_Name = "com.oracle.truffle.api.operation.OperationsNode"; - public static final String OperationsInstrumentableNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentableNode"; public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; @@ -249,13 +250,14 @@ public class TruffleTypes { public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); + public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); + public final DeclaredType OperationConfig = c.getDeclaredTypeOptional(OperationConfig_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); public final DeclaredType OperationLocal = c.getDeclaredTypeOptional(OperationLocal_Name); + public final DeclaredType OperationNodes = c.getDeclaredTypeOptional(OperationNodes_Name); public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name); - public final DeclaredType OperationsBuilder = c.getDeclaredTypeOptional(OperationsBuilder_Name); + public final DeclaredType OperationBuilder = c.getDeclaredTypeOptional(OperationBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); - public final DeclaredType OperationsNode = c.getDeclaredTypeOptional(OperationsNode_Name); - public final DeclaredType OperationsInstrumentableNode = c.getDeclaredTypeOptional(OperationsInstrumentableNode_Name); public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index 0dc94ba81385..7bed98dc4276 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -40,14 +40,13 @@ */ package com.oracle.truffle.dsl.processor.java.compiler; -import java.io.File; -import java.lang.reflect.Method; -import java.util.List; - import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.JavaFileObject; +import java.io.File; +import java.lang.reflect.Method; +import java.util.List; public class JavaCCompiler extends AbstractCompiler { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 7934e587a02c..1d9de1dfa8aa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -7,7 +7,6 @@ import java.util.List; -import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -51,13 +50,10 @@ public static class BuilderVariables { public CodeVariableElement bc; public CodeVariableElement bci; public CodeVariableElement consts; - public CodeVariableElement exteptionHandlers; public CodeVariableElement operationData; public CodeVariableElement lastChildPushCount; public CodeVariableElement childIndex; public CodeVariableElement numChildren; - public CodeVariableElement keepingInstrumentation; - public CodeVariableElement numChildNodes; public ExecutionVariables asExecution() { ExecutionVariables result = new ExecutionVariables(); @@ -436,7 +432,7 @@ public CodeTree createPushCountCode(BuilderVariables vars) { @Override public CodeTree createEndCode(BuilderVariables vars) { - return createEmitLabel(vars, CodeTreeBuilder.singleString("((BuilderOperationLabel) " + vars.operationData.getName() + ".arguments[0])")); + return createEmitLabel(vars, CodeTreeBuilder.singleString("arg0")); } @Override @@ -472,7 +468,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); b.startStatement().variable(varBeh).string(".exceptionIndex = (int)").variable(vars.operationData).string(".arguments[0]").end(); - b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); + b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); @@ -656,15 +652,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.end(2); } - b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = ").startCall("doBeginFinallyTry"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.exteptionHandlers); - b.end(2); - - b.startAssign(vars.bc).startNewArray((ArrayType) vars.bc.asType(), CodeTreeBuilder.singleString("65535")).end(2); - b.startAssign(vars.bci).string("0").end(); - b.startAssign(vars.exteptionHandlers).startNew(vars.exteptionHandlers.asType()).end(2); + b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = ").startCall("doBeginFinallyTry").end(2); return b.build(); } @@ -677,17 +665,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end().startBlock(); { - b.startStatement().startCall("doEndFinallyBlock0"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.exteptionHandlers); - b.end(2); - - b.startAssign(vars.bc).startCall("doFinallyRestoreBc").end(2); - b.startAssign(vars.bci).startCall("doFinallyRestoreBci").end(2); - b.startAssign(vars.exteptionHandlers).startCall("doFinallyRestoreExceptions").end(2); - - b.startStatement().startCall("doEndFinallyBlock1").end(2); + b.startStatement().startCall("doEndFinallyBlock").end(2); if (!noExcept) { CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); @@ -700,7 +678,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); b.end(); b.end(); - b.startStatement().startCall(vars.exteptionHandlers, "add").variable(varBeh).end(2); + b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); } @@ -762,12 +740,7 @@ public CodeTree createEndCode(BuilderVariables vars) { } private static void emitLeaveCode(BuilderVariables vars, CodeTreeBuilder b) { - b.startAssign(vars.bci).startCall("doLeaveFinallyTry"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.operationData); - b.variable(vars.exteptionHandlers); - b.end(2); + b.startStatement().startCall("doLeaveFinallyTry").variable(vars.operationData).end(2); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 5a2b6d3a6b21..fb70b3ab4a9c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -50,8 +50,9 @@ public static CodeTree createCreateLabel() { return CodeTreeBuilder.createBuilder().cast(getTypes().BuilderOperationLabel).startCall("createLabel").end().build(); } + @SuppressWarnings("unused") public static CodeTree createEmitLabel(BuilderVariables vars, CodeTree label) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("doEmitLabel").variable(vars.bci).tree(label).end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("doEmitLabel").tree(label).end(2).build(); } public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElement label) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index d7e9d617666e..ad6e2b712ba2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -22,7 +22,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; @@ -67,33 +66,19 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, Operation public CodeTypeElement createBuilderBytecodeNode() { String namePrefix = withInstrumentation ? "Instrumentable" : ""; - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", types.OperationsNode); + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", types.OperationBytecodeNode); CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); - GeneratorUtils.addCompilationFinalAnnotation(fldBc, 1); - builderBytecodeNodeType.add(fldBc); CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); - GeneratorUtils.addCompilationFinalAnnotation(fldConsts, 1); - builderBytecodeNodeType.add(fldConsts); CodeVariableElement fldChildren = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.Node), "children"); - fldChildren.addAnnotationMirror(new CodeAnnotationMirror(types.Node_Children)); - builderBytecodeNodeType.add(fldChildren); CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); - GeneratorUtils.addCompilationFinalAnnotation(fldHandlers, 1); - builderBytecodeNodeType.add(fldHandlers); - - CodeVariableElement fldConditionBranches = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(ConditionProfile), "conditionProfiles"); - GeneratorUtils.addCompilationFinalAnnotation(fldConditionBranches, 1); - builderBytecodeNodeType.add(fldConditionBranches); CodeVariableElement fldProbeNodes = null; if (withInstrumentation) { fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); - GeneratorUtils.addCompilationFinalAnnotation(fldProbeNodes, 1); - builderBytecodeNodeType.add(fldProbeNodes); } CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); @@ -517,18 +502,20 @@ public CodeTypeElement createBuilderBytecodeNode() { b.end(); - b.startIf().string("sourceInfo != null").end(); - b.startBlock(); - { - b.statement("sb.append(\"Source info:\\n\")"); - b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); - b.startBlock(); - - b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", sourceInfo[0][i], sourceInfo[1][i], sourceInfo[2][i]))"); - - b.end(); - } - b.end(); + // b.startIf().string("sourceInfo != null").end(); + // b.startBlock(); + // { + // b.statement("sb.append(\"Source info:\\n\")"); + // b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); + // b.startBlock(); + // + // b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", + // sourceInfo[0][i], + // sourceInfo[1][i], sourceInfo[2][i]))"); + // + // b.end(); + // } + // b.end(); b.startReturn().string("sb.toString()").end(); @@ -536,34 +523,6 @@ public CodeTypeElement createBuilderBytecodeNode() { } - { - CodeExecutableElement mGetSourceSection = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); - builderBytecodeNodeType.add(mGetSourceSection); - - CodeTreeBuilder b = mGetSourceSection.createBuilder(); - - b.tree(createReparseCheck()); - - b.startReturn(); - b.startCall("this", "getSourceSectionImpl"); - b.end(2); - } - - { - CodeVariableElement pBci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeExecutableElement mGetSourceSectionAtBci = GeneratorUtils.overrideImplement(types.OperationsNode, "getSourceSectionAtBci"); - builderBytecodeNodeType.add(mGetSourceSectionAtBci); - - CodeTreeBuilder b = mGetSourceSectionAtBci.createBuilder(); - - b.tree(createReparseCheck()); - - b.startReturn(); - b.startCall("this", "getSourceSectionAtBciImpl"); - b.variable(pBci); - b.end(2); - } - { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startJavadoc(); @@ -584,26 +543,6 @@ public CodeTypeElement createBuilderBytecodeNode() { return builderBytecodeNodeType; } - private CodeTree createReparseCheck() { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().string("sourceInfo == null").end(); - b.startBlock(); - { - b.startStatement(); - b.string("OperationsNode reparsed = "); - b.startStaticCall(typBuilderImpl.asType(), "reparse"); - b.startGroup().startCall("getRootNode").end().startCall(".getLanguage").typeLiteral(m.getLanguageType()).end(2); - b.startGroup().maybeCast(context.getType(Object.class), m.getParseContextType()).string("parseContext").end(); - b.string("buildOrder"); - b.end(2); - - b.statement("copyReparsedInfo(reparsed)"); - } - b.end(); - - return b.build(); - } - private static TypeMirror arrayOf(TypeMirror el) { return new ArrayCodeTypeMirror(el); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 359b2eaa5ee1..b0f3224b0819 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -1,13 +1,11 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.function.Supplier; +import java.util.function.Consumer; import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -34,19 +32,40 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PUBLIC = Set.of(Modifier.PUBLIC); - private final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); - private final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); - private final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); - private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); - private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - private final Set MOD_STATIC = Set.of(Modifier.STATIC); + private static final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); + private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); + private static final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + private static final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); + private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private static final Set MOD_PROTECTED = Set.of(Modifier.PROTECTED); + private static final Set MOD_STATIC = Set.of(Modifier.STATIC); + private OperationsBytecodeCodeGenerator bytecodeGenerator; private static final boolean FLAG_NODE_AST_PRINTING = false; private static final boolean ENABLE_INSTRUMENTATION = false; + private static final String OPERATION_NODES_IMPL_NAME = "OperationNodesImpl"; + private static final String OPERATION_BUILDER_IMPL_NAME = "BuilderImpl"; + + CodeTypeElement createOperationNodes() { + CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, types.OperationNodes); + typOperationNodes.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationNodes)); + + { + CodeExecutableElement metReparse = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); + typOperationNodes.add(metReparse); + + CodeTreeBuilder b = metReparse.createBuilder(); + + b.statement("BuilderImpl builder = new BuilderImpl(this, true, config)"); + b.statement("((Consumer) parse).accept(builder)"); + b.statement("builder.finish()"); + } + + return typOperationNodes; + } + /** * Creates the builder class itself. This class only contains abstract methods, the builder * implementation class, and the createBuilder method. @@ -54,10 +73,19 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory args = op.getBuilderArgumentTypes(); ArrayList params = new ArrayList<>(); @@ -65,7 +93,7 @@ CodeTypeElement createBuilder(String simpleName) { params.add(new CodeVariableElement(args.get(i), "arg" + i)); } - CodeVariableElement[] paramsArr = params.toArray(new CodeVariableElement[params.size()]); + CodeVariableElement[] paramsArr = params.toArray(new CodeVariableElement[0]); if (op.children != 0) { CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "begin" + op.name, paramsArr); @@ -79,65 +107,43 @@ CodeTypeElement createBuilder(String simpleName) { } } - if (m.hasErrors()) { - return typBuilder; - } - CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); - GeneratorUtils.addSuppressWarnings(context, typBuilderImpl, "cast", "hiding", "unchecked", "rawtypes", "static-method"); { - CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); - CodeVariableElement parParseContext = new CodeVariableElement(m.getParseContextType(), "context"); - CodeExecutableElement metParse = new CodeExecutableElement(MOD_PUBLIC_STATIC, arrayOf(types.OperationsNode), "parse"); - metParse.addParameter(parLanguage); - metParse.addParameter(parParseContext); - typBuilder.add(metParse); - - CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, false, false)); - b.startStatement().startStaticCall(m.getParseMethod()); - b.variable(parLanguage); - b.variable(parParseContext); - b.string("builder"); + CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); + CodeVariableElement parParser = new CodeVariableElement(consumer(typBuilder.asType()), "generator"); + CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "create"); + metCreate.addParameter(parConfig); + metCreate.addParameter(parParser); + typBuilder.add(metCreate); + + CodeTreeBuilder b = metCreate.getBuilder(); + + b.declaration(types.OperationNodes, "nodes", "new OperationNodesImpl(generator)"); + b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); + { + b.string("nodes"); + b.string("false"); // isReparse + b.variable(parConfig); + } b.end(2); - b.startReturn().startCall("builder", "collect").end(2); - } - { - CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); - CodeVariableElement parParseContext = new CodeVariableElement(m.getParseContextType(), "context"); - CodeExecutableElement metParse = new CodeExecutableElement(MOD_PUBLIC_STATIC, arrayOf(types.OperationsNode), "parseWithSourceInfo"); - metParse.addParameter(parLanguage); - metParse.addParameter(parParseContext); - typBuilder.add(metParse); - - CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parParseContext, true, true)); - b.startStatement().startStaticCall(m.getParseMethod()); - b.variable(parLanguage); - b.variable(parParseContext); + b.startStatement().startCall("generator", "accept"); b.string("builder"); b.end(2); - b.startReturn().startCall("builder", "collect").end(2); + + b.startStatement().startCall("builder", "finish").end(2); + + b.startReturn().string("nodes").end(); + } return typBuilder; } - private static CodeTree createCreateBuilder(CodeTypeElement typBuilderImpl, CodeVariableElement language, CodeVariableElement parseContext, boolean withSourceInfo, boolean withInstrumentation) { - return CodeTreeBuilder.createBuilder().startNew(typBuilderImpl.asType()) // - .variable(language) // - .variable(parseContext) // - .string("" + withSourceInfo) // - .string("" + withInstrumentation) // - .end().build(); - } - private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { - String simpleName = "BuilderImpl"; - CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), simpleName, typBuilder.asType()); + CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), OPERATION_BUILDER_IMPL_NAME, typBuilder.asType()); typBuilderImpl.setEnclosingElement(typBuilder); if (m.isTracing()) { @@ -185,37 +191,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } - CodeVariableElement fldLanguage = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getLanguageType(), "language"); - typBuilderImpl.add(fldLanguage); - - CodeVariableElement fldParseContext = new CodeVariableElement(MOD_PRIVATE_FINAL, m.getParseContextType(), "parseContext"); - typBuilderImpl.add(fldParseContext); - - CodeVariableElement fldKeepSourceInfo = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "keepSourceInfo"); - typBuilderImpl.add(fldKeepSourceInfo); - - CodeVariableElement fldKeepInstrumentation = new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "keepInstrumentation"); - typBuilderImpl.add(fldKeepInstrumentation); - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), typBuilderImpl); typBuilderImpl.add(ctor); - CodeVariableElement fldSourceInfoList = new CodeVariableElement(MOD_PRIVATE_FINAL, types.BuilderSourceInfo, "sourceInfoBuilder"); - typBuilderImpl.add(fldSourceInfoList); - - { - CodeTreeBuilder b = ctor.getBuilder(); - - b.startIf().variable(fldKeepSourceInfo).end(); - b.startBlock(); - b.startAssign(fldSourceInfoList).startNew(types.BuilderSourceInfo).end(2); - b.end().startElseBlock(); - b.startAssign(fldSourceInfoList).string("null").end(); - b.end(); - - b.statement("reset()"); - } - { String bytesSupportClass = "com.oracle.truffle.api.operation.OperationsBytesSupport"; // String bytesSupportClass = "com.oracle.truffle.api.memory.ByteArraySupport"; @@ -227,6 +205,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(leBytes); } + // operation IDs for (Operation op : m.getOperationsContext().operations) { CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); CodeTreeBuilder b = fldId.createInitBuilder(); @@ -235,6 +214,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldId); } + // instruction IDs for (Instruction instr : m.getOperationsContext().instructions) { CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "INSTR_" + OperationGeneratorUtils.toScreamCase(instr.name)); CodeTreeBuilder b = fldId.createInitBuilder(); @@ -250,6 +230,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); } + if (ENABLE_INSTRUMENTATION) { OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); @@ -261,11 +242,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldOperationData = new CodeVariableElement(types.BuilderOperationData, "operationData"); CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); - typBuilderImpl.add(fldBc); - { - CodeTreeBuilder b = fldBc.createInitBuilder(); - b.string("new byte[65535]"); - } CodeVariableElement fldIndent = null; if (FLAG_NODE_AST_PRINTING) { @@ -273,639 +249,413 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldIndent); } - CodeVariableElement fldExceptionHandlers = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.BuilderExceptionHandler), "exceptionHandlers"); - typBuilderImpl.add(fldExceptionHandlers); - { - CodeTreeBuilder b = fldExceptionHandlers.createInitBuilder(); - b.string("new ArrayList<>()"); - } - - CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastPush"); - typBuilderImpl.add(fldLastPush); - CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); - typBuilderImpl.add(fldBci); - CodeVariableElement fldNumChildNodes = new CodeVariableElement(context.getType(int.class), "numChildNodes"); - typBuilderImpl.add(fldNumChildNodes); - - CodeVariableElement fldNumBranchProfiles = new CodeVariableElement(context.getType(int.class), "numBranchProfiles"); - typBuilderImpl.add(fldNumBranchProfiles); - - CodeVariableElement fldBuiltNodes = new CodeVariableElement(generic(context.getTypeElement(ArrayList.class), types.OperationsNode), "builtNodes"); - typBuilderImpl.add(fldBuiltNodes); - { - CodeTreeBuilder b = fldBuiltNodes.createInitBuilder(); - b.string("new ArrayList<>()"); - } - - CodeVariableElement fldNodeNumber = new CodeVariableElement(context.getType(int.class), "nodeNumber"); - typBuilderImpl.add(fldNodeNumber); - { - CodeTreeBuilder b = fldNodeNumber.createInitBuilder(); - b.string("0"); - } + CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastChildPush"); + typBuilderImpl.add(fldLastPush); CodeVariableElement fldConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); - typBuilderImpl.add(fldConstPool); - { - CodeTreeBuilder b = fldConstPool.createInitBuilder(); - b.startNew(types.OperationsConstantPool).end(); - } - - { - CodeVariableElement parLanguage = new CodeVariableElement(m.getLanguageType(), "language"); - CodeVariableElement parContext = new CodeVariableElement(m.getParseContextType(), "context"); - CodeVariableElement parBuildOrder = new CodeVariableElement(context.getType(int.class), "buildOrder"); - CodeExecutableElement metParse = new CodeExecutableElement(MOD_PRIVATE_STATIC, types.OperationsNode, "reparse"); - metParse.addParameter(parLanguage); - metParse.addParameter(parContext); - metParse.addParameter(parBuildOrder); - typBuilderImpl.add(metParse); - - CodeTreeBuilder b = metParse.getBuilder(); - b.declaration(typBuilderImpl.asType(), "builder", createCreateBuilder(typBuilderImpl, parLanguage, parContext, true, true)); - b.startStatement().startStaticCall(m.getParseMethod()).variable(parLanguage).variable(parContext).string("builder").end(2); - b.startReturn().startCall("builder", "collect").end().string("[").variable(parBuildOrder).string("]").end(); - } BuilderVariables vars = new BuilderVariables(); vars.bc = fldBc; vars.bci = fldBci; - vars.lastChildPushCount = fldLastPush; vars.operationData = fldOperationData; + vars.lastChildPushCount = fldLastPush; vars.consts = fldConstPool; - vars.exteptionHandlers = fldExceptionHandlers; - vars.keepingInstrumentation = fldKeepInstrumentation; - vars.numChildNodes = fldNumChildNodes; - { - CodeExecutableElement metReset = new CodeExecutableElement( - Set.of(Modifier.PUBLIC), - context.getType(void.class), "reset"); - typBuilderImpl.add(metReset); + typBuilderImpl.add(createForwardingConstructorCall("BytecodeNode", "createBytecode")); + typBuilderImpl.add(createForwardingConstructorCall(null, "createInstrumentedBytecode")); - CodeTreeBuilder b = metReset.getBuilder(); + typBuilderImpl.add(createDoLeave(vars)); + typBuilderImpl.add(createBeforeChild(vars)); + typBuilderImpl.add(createAfterChild(vars)); + typBuilderImpl.add(createBoxingDescriptors()); - b.statement("super.reset()"); + builderBytecodeNodeType.add(createSetResultUnboxed()); - b.startAssign(fldBci).string("0").end(); - b.startAssign(fldNumChildNodes).string("0").end(); - b.startAssign(fldNumBranchProfiles).string("0").end(); - if (FLAG_NODE_AST_PRINTING) { - b.startAssign(fldIndent).string("0").end(); - } - b.startAssign(fldOperationData).startNew(types.BuilderOperationData).string("null").string("0").string("0").string("0").string("false").end(2); - b.startStatement().startCall(fldExceptionHandlers.getName(), "clear").end(2); - b.startStatement().startCall(fldConstPool.getName(), "reset").end(2); + for (Operation op : m.getOperations()) { + List args = op.getBuilderArgumentTypes(); + CodeVariableElement[] params = new CodeVariableElement[args.size()]; - b.startIf().variable(fldKeepSourceInfo).end(); - b.startBlock(); - { - b.startStatement().startCall(fldSourceInfoList, "reset").end(2); + for (int i = 0; i < params.length; i++) { + params[i] = new CodeVariableElement(args.get(i), "arg" + i); } - b.end(); - } - - { - CodeExecutableElement mBuild = new CodeExecutableElement(MOD_PUBLIC, types.OperationsNode, "buildImpl"); - typBuilderImpl.add(mBuild); - - CodeTreeBuilder b = mBuild.getBuilder(); - b.statement("labelPass(bc)"); - - b.startIf().string(fldOperationData.getName() + ".depth != 0").end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("Not all operations ended").end(2); - b.end(); - - b.declaration("byte[]", "bcCopy", "java.util.Arrays.copyOf(bc, bci)"); - b.declaration("Object[]", "cpCopy", "constPool.getValues()"); - b.declaration("BuilderExceptionHandler[]", "handlers", fldExceptionHandlers.getName() + ".toArray(new BuilderExceptionHandler[0])"); - - b.declaration("int[][]", "sourceInfo", "null"); - b.declaration("Source[]", "sources", "null"); + if (op.name.equals("Block")) { + typBuilderImpl.add(createGetBlockOperationIndex(op)); + } - b.startIf().variable(fldKeepSourceInfo).end(); - b.startBlock(); + if (op.children != 0) { + typBuilderImpl.add(createBeginOperation(typBuilder, vars, op)); + typBuilderImpl.add(createEndOperation(typBuilder, vars, op)); + } else { + typBuilderImpl.add(createEmitOperation(typBuilder, vars, op)); + } + } - b.startAssign("sourceInfo").startCall(fldSourceInfoList, "build").end(2); - b.startAssign("sources").startCall(fldSourceInfoList, "buildSource").end(2); + return typBuilderImpl; - b.end(); + } - b.statement("OperationsNode result"); + private CodeExecutableElement createGetBlockOperationIndex(Operation op) { + CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, "getBlockOperationIndex"); - b.declaration("ConditionProfile[]", "condProfiles", "new ConditionProfile[numBranchProfiles]"); - b.startFor().string("int i = 0; i < numBranchProfiles; i++").end().startBlock(); - b.statement("condProfiles[i] = ConditionProfile.createCountingProfile()"); - b.end(); + result.getBuilder().startReturn().variable(op.idConstantField).end(); - if (ENABLE_INSTRUMENTATION) { - b.startIf().variable(fldKeepInstrumentation).end(); - b.startBlock(); - - b.startAssign("result"); - b.startNew(builderInstrBytecodeNodeType.asType()); - b.variable(fldParseContext); - b.string("sourceInfo"); - b.string("sources"); - b.variable(fldNodeNumber); - b.string("createMaxStack()"); - b.startGroup().string("numLocals").end(); - b.string("bcCopy"); - b.string("cpCopy"); - b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); - b.string("handlers"); - b.string("condProfiles"); - b.string("getInstrumentTrees()"); - b.end(2); - - b.end().startElseBlock(); - } + return result; + } - b.startAssign("result"); - b.startNew(builderBytecodeNodeType.asType()); - b.variable(fldParseContext); - b.string("sourceInfo"); - b.string("sources"); - b.variable(fldNodeNumber); - b.string("createMaxStack()"); - b.startGroup().string("numLocals").end(); - b.string("bcCopy"); - b.string("cpCopy"); - b.startNewArray(new ArrayCodeTypeMirror(types.Node), CodeTreeBuilder.singleVariable(fldNumChildNodes)).end(); - b.string("handlers"); - b.string("condProfiles"); - b.end(2); + private CodeExecutableElement createForwardingConstructorCall(String typeName, String methodName) { + CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, methodName); + CodeTreeBuilder b = result.getBuilder(); - if (ENABLE_INSTRUMENTATION) { - b.end(); + if (typeName != null) { + b.startReturn().startNew(typeName); + for (VariableElement par : result.getParameters()) { + b.variable(par); } - - b.startStatement(); - b.startCall(fldBuiltNodes, "add"); - b.string("result"); b.end(2); + } else { + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("not implemented").end(2); + } - b.startStatement().variable(fldNodeNumber).string("++").end(); + return result; + } - b.statement("reset()"); + private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { + CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); + CodeTreeBuilder b = metEmit.getBuilder(); - b.startReturn().string("result").end(); + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } - { - // CodeVariableElement parBci = new CodeVariableElement(context.getType(int.class), - // "bci"); - CodeVariableElement parData = new CodeVariableElement(types.BuilderOperationData, "data"); - CodeExecutableElement mDoLeave = GeneratorUtils.overrideImplement(types.OperationsBuilder, "doLeaveOperation"); - typBuilderImpl.add(mDoLeave); - - CodeTreeBuilder b = mDoLeave.createBuilder(); - - // b.startWhile().string("getCurStack() > data.stackDepth").end(); - // b.startBlock(); - // - // b.tree(m.getOperationsContext().commonPop.createEmitCode(vars, new CodeTree[0])); - // - // b.end(); - - b.startSwitch().string("data.operationId").end(); - b.startBlock(); - - vars.operationData = parData; + b.statement("doBeforeChild()"); - for (Operation op : m.getOperations()) { - CodeTree leaveCode = op.createLeaveCode(vars); - if (leaveCode == null) { - continue; - } + boolean isLabel = op instanceof Operation.Label; - b.startCase().variable(op.idConstantField).end(); - b.startBlock(); + if (!isLabel) { + b.startAssign(vars.operationData); + b.startNew(types.BuilderOperationData); - b.tree(leaveCode); - b.statement("break"); - - b.end(); + b.variable(vars.operationData); + b.variable(op.idConstantField); + b.string("getCurStack()"); + b.string("" + op.getNumAuxValues()); + b.string("false"); + for (VariableElement v : metEmit.getParameters()) { + b.variable(v); } + b.end(2); + } - vars.operationData = fldOperationData; + b.tree(op.createBeginCode(vars)); + b.tree(op.createEndCode(vars)); - b.end(); + b.startAssign(vars.lastChildPushCount).tree(op.createPushCountCode(vars)).end(); + if (!isLabel) { + b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); } - { - CodeVariableElement pSupplier = new CodeVariableElement(generic(context.getTypeElement(Supplier.class), types.Source), "supplier"); - CodeExecutableElement mBeginSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "beginSource"); - mBeginSource.addParameter(pSupplier); - typBuilderImpl.add(mBeginSource); + b.statement("doAfterChild()"); - CodeTreeBuilder b = mBeginSource.getBuilder(); - b.startIf().string("!").variable(fldKeepSourceInfo).end(); - b.startBlock().returnStatement().end(); + return metEmit; + } - b.startStatement().startCall("beginSource").startCall(pSupplier, "get").end(3); - } + private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { + CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.name); + GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); - { - CodeVariableElement pSource = new CodeVariableElement(types.Source, "source"); - CodeExecutableElement mBeginSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "beginSource"); - mBeginSource.addParameter(pSource); - typBuilderImpl.add(mBeginSource); - - CodeTreeBuilder b = mBeginSource.getBuilder(); - b.startIf().string("!").variable(fldKeepSourceInfo).end(); - b.startBlock().returnStatement().end(); - - b.startStatement().startCall(fldSourceInfoList, "beginSource"); - b.variable(fldBci); - b.variable(pSource); - b.end(2); + // if (operationData.id != ID) throw; + // << end >> - } + // operationData = operationData.parent; - { - CodeExecutableElement mEndSource = new CodeExecutableElement(MOD_PUBLIC, context.getType(void.class), "endSource"); - typBuilderImpl.add(mEndSource); + // doAfterChild(); + CodeTreeBuilder b = metEnd.getBuilder(); - CodeTreeBuilder b = mEndSource.getBuilder(); - b.startIf().string("!").variable(fldKeepSourceInfo).end(); - b.startBlock().returnStatement().end(); + if (op instanceof InstrumentTag) { + b.startIf().string("!withInstrumentation").end().startBlock().returnStatement().end(); + } - b.startStatement().startCall(fldSourceInfoList, "endSource"); - b.variable(fldBci); - b.end(2); + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\")\")"); + b.statement("indent--"); } - { - CodeExecutableElement mBeginSourceSection = GeneratorUtils.overrideImplement(types.OperationsBuilder, "beginSourceSection"); - typBuilderImpl.add(mBeginSourceSection); + b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote("Mismatched begin/end, expected ")// + .string(" + operationData.operationId").end(3); + b.end(); - CodeTreeBuilder b = mBeginSourceSection.getBuilder(); - b.startIf().string("!").variable(fldKeepSourceInfo).end(); - b.startBlock().returnStatement().end(); + vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); + b.declaration("int", "numChildren", "operationData.numChildren"); - b.startStatement().startCall(fldSourceInfoList, "beginSourceSection"); - b.variable(fldBci); - b.string("start"); - b.end(2); + if (!op.isVariableChildren()) { + b.startIf().string("numChildren != " + op.children).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote(op.name + " expected " + op.children + " children, got ")// + .string(" + numChildren")// + .end(3); + b.end(); + } else { + b.startIf().string("numChildren < " + op.minimumChildren()).end(); + b.startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class))// + .startGroup()// + .doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ")// + .string(" + numChildren")// + .end(3); + b.end(); } - { - CodeExecutableElement mEndSourceSection = GeneratorUtils.overrideImplement(types.OperationsBuilder, "endSourceSection"); - typBuilderImpl.add(mEndSourceSection); - - CodeTreeBuilder b = mEndSourceSection.getBuilder(); - b.startIf().string("!").variable(fldKeepSourceInfo).end(); - b.startBlock().returnStatement().end(); - - b.startStatement().startCall(fldSourceInfoList, "endSourceSection"); - b.variable(fldBci); - b.string("length"); - b.end(2); + b.tree(op.createEndCode(vars)); + CodeTree lastPush = op.createPushCountCode(vars); + if (lastPush != null) { + b.startAssign(vars.lastChildPushCount).tree(lastPush).end(); } - { - CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); - CodeTreeBuilder b = mBeforeChild.getBuilder(); - GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); - - CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "operationData.numChildren"); + b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); - vars.childIndex = varChildIndex; + b.statement("doAfterChild()"); - b.startSwitch().variable(fldOperationData).string(".operationId").end(2); - b.startBlock(); + vars.numChildren = null; - for (Operation parentOp : m.getOperations()) { + return metEnd; + } - CodeTree afterChild = parentOp.createBeforeChildCode(vars); - if (afterChild == null) - continue; + private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { + CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.name); + GeneratorUtils.addSuppressWarnings(context, metBegin, "unused"); - b.startCase().variable(parentOp.idConstantField).end(); - b.startBlock(); + // doBeforeChild(); - b.tree(afterChild); + // operationData = new ...(operationData, ID, , args...); - b.statement("break"); - b.end(); - } + // << begin >> - b.end(); + CodeTreeBuilder b = metBegin.getBuilder(); - vars.childIndex = null; + if (op instanceof InstrumentTag) { + b.startIf().string("!withInstrumentation").end().startBlock().returnStatement().end(); + } - typBuilderImpl.add(mBeforeChild); + if (FLAG_NODE_AST_PRINTING) { + b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); + b.statement("indent++"); } - { - CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); - CodeTreeBuilder b = mAfterChild.getBuilder(); - GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); - CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "operationData.numChildren++"); + b.statement("doBeforeChild()"); - vars.childIndex = varChildIndex; + b.startAssign(vars.operationData).startNew(types.BuilderOperationData); - b.startSwitch().variable(fldOperationData).string(".operationId").end(2); - b.startBlock(); + b.variable(vars.operationData); + b.variable(op.idConstantField); + b.string("getCurStack()"); + b.string("" + op.getNumAuxValues()); + b.string("" + op.hasLeaveCode()); - for (Operation parentOp : m.getOperations()) { + for (VariableElement el : metBegin.getParameters()) { + b.variable(el); + } - CodeTree afterChild = parentOp.createAfterChildCode(vars); - if (afterChild == null) - continue; + b.end(2); - b.startCase().variable(parentOp.idConstantField).end(); - b.startBlock(); + b.tree(op.createBeginCode(vars)); - b.tree(afterChild); + return metBegin; + } - b.statement("break"); - b.end(); - } + private CodeExecutableElement createSetResultUnboxed() { + CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); - b.end(); + CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + mDoSetResultUnboxed.addParameter(varBc); - vars.childIndex = null; + CodeVariableElement varStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); + mDoSetResultUnboxed.addParameter(varStartBci); - typBuilderImpl.add(mAfterChild); - } + CodeVariableElement varBciOffset = new CodeVariableElement(context.getType(int.class), "bciOffset"); + mDoSetResultUnboxed.addParameter(varBciOffset); + CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); + mDoSetResultUnboxed.addParameter(varTargetType); + + CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); + + b.startIf().variable(varBciOffset).string(" != 0").end().startBlock(); { - CodeVariableElement fldBoxingDescriptors = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, arrayOf(arrayOf(context.getType(short.class))), "BOXING_DESCRIPTORS"); - typBuilderImpl.add(fldBoxingDescriptors); - - CodeTreeBuilder b = fldBoxingDescriptors.createInitBuilder(); - - b.string("{").startCommaGroup(); - for (FrameKind kind : FrameKind.values()) { - b.startGroup().newLine(); - b.lineComment("" + kind); - if (m.getFrameKinds().contains(kind)) { - b.string("{").startCommaGroup(); - b.string("-1"); - for (Instruction instr : m.getInstructions()) { - String value; - switch (instr.boxingEliminationBehaviour()) { - case DO_NOTHING: - value = "0"; - break; - case REPLACE: - value = instr.boxingEliminationReplacement(kind).getName(); - break; - case SET_BIT: - value = "(short) (0x8000 | (" + instr.boxingEliminationBitOffset() + " << 8) | 0x" + Integer.toHexString(instr.boxingEliminationBitMask()) + ")"; - break; - default: - throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); - } - b.string(value); + b.startStatement().startCall("setResultBoxedImpl"); + b.variable(varBc); + b.string("startBci - bciOffset"); + b.variable(varTargetType); + b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); + b.end(2); + } + b.end(); + return mDoSetResultUnboxed; + } + private CodeVariableElement createBoxingDescriptors() { + CodeVariableElement fldBoxingDescriptors = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, arrayOf(arrayOf(context.getType(short.class))), "BOXING_DESCRIPTORS"); + + CodeTreeBuilder b = fldBoxingDescriptors.createInitBuilder(); + + b.string("{").startCommaGroup(); + for (FrameKind kind : FrameKind.values()) { + b.startGroup().newLine(); + b.lineComment("" + kind); + if (m.getFrameKinds().contains(kind)) { + b.string("{").startCommaGroup(); + b.string("-1"); + for (Instruction instr : m.getInstructions()) { + String value; + switch (instr.boxingEliminationBehaviour()) { + case DO_NOTHING: + value = "0"; + break; + case REPLACE: + value = instr.boxingEliminationReplacement(kind).getName(); + break; + case SET_BIT: + value = "(short) (0x8000 | (" + instr.boxingEliminationBitOffset() + " << 8) | 0x" + Integer.toHexString(instr.boxingEliminationBitMask()) + ")"; + break; + default: + throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); } - b.end().string("}").end(); - } else { - b.string("null").end(); + b.string(value); + } + b.end().string("}").end(); + } else { + b.string("null").end(); } - b.end().string("}"); } + b.end().string("}"); + return fldBoxingDescriptors; + } - { - CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); - builderBytecodeNodeType.add(mDoSetResultUnboxed); + private CodeExecutableElement createAfterChild(BuilderVariables vars) { + CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); + CodeTreeBuilder b = mAfterChild.getBuilder(); + GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); - CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); - mDoSetResultUnboxed.addParameter(varBc); + CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); + b.declaration("int", varChildIndex.getName(), "operationData.numChildren++"); - CodeVariableElement varStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); - mDoSetResultUnboxed.addParameter(varStartBci); + vars.childIndex = varChildIndex; - CodeVariableElement varBciOffset = new CodeVariableElement(context.getType(int.class), "bciOffset"); - mDoSetResultUnboxed.addParameter(varBciOffset); + b.startSwitch().variable(vars.operationData).string(".operationId").end(2); + b.startBlock(); - CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); - mDoSetResultUnboxed.addParameter(varTargetType); + for (Operation parentOp : m.getOperations()) { - CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); + CodeTree afterChild = parentOp.createAfterChildCode(vars); + if (afterChild == null) + continue; - b.startIf().variable(varBciOffset).string(" != 0").end().startBlock(); - { - b.startStatement().startCall("setResultBoxedImpl"); - b.variable(varBc); - b.string("startBci - bciOffset"); - b.variable(varTargetType); - b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); - b.end(2); - } - b.end(); - } + b.startCase().variable(parentOp.idConstantField).end(); + b.startBlock(); - for (Operation op : m.getOperations()) { - List args = op.getBuilderArgumentTypes(); - CodeVariableElement[] params = new CodeVariableElement[args.size()]; + b.tree(afterChild); - for (int i = 0; i < params.length; i++) { - params[i] = new CodeVariableElement(args.get(i), "arg" + i); - } + b.statement("break"); + b.end(); + } - if (op.children != 0) { - CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.name); - typBuilderImpl.add(metBegin); - GeneratorUtils.addSuppressWarnings(context, metBegin, "unused"); - - CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.name); - typBuilderImpl.add(metEnd); - GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); - - { - // doBeforeChild(); - - // operationData = new ...(operationData, ID, , args...); - - // << begin >> - - CodeTreeBuilder b = metBegin.getBuilder(); - - if (op instanceof InstrumentTag) { - // this needs to be placed here, at the very start - // of the begin/end methods - b.startIf(); - if (ENABLE_INSTRUMENTATION) { - b.string("!").variable(vars.keepingInstrumentation); - } else { - b.string("true"); - } - b.end(); - b.startBlock(); - b.returnStatement(); - b.end(); - } + b.end(); - if (FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); - b.statement("indent++"); - } + vars.childIndex = null; + return mAfterChild; + } - b.statement("doBeforeChild()"); + private CodeExecutableElement createBeforeChild(BuilderVariables vars) { + CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); + CodeTreeBuilder b = mBeforeChild.getBuilder(); + GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); - b.startAssign(fldOperationData).startNew(types.BuilderOperationData); + CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); + b.declaration("int", varChildIndex.getName(), "operationData.numChildren"); - b.variable(fldOperationData); - b.variable(op.idConstantField); - b.string("getCurStack()"); - b.string("" + op.getNumAuxValues()); - b.string("" + op.hasLeaveCode()); + vars.childIndex = varChildIndex; - for (VariableElement el : metBegin.getParameters()) { - b.variable(el); - } + b.startSwitch().variable(vars.operationData).string(".operationId").end(2); + b.startBlock(); - b.end(2); + for (Operation parentOp : m.getOperations()) { - b.tree(op.createBeginCode(vars)); - } + CodeTree afterChild = parentOp.createBeforeChildCode(vars); + if (afterChild == null) + continue; - { - // if (operationData.id != ID) throw; - // << end >> - - // operationData = operationData.parent; - - // doAfterChild(); - CodeTreeBuilder b = metEnd.getBuilder(); - - if (op instanceof InstrumentTag) { - // this needs to be placed here, at the very start - // of the begin/end methods - b.startIf(); - if (ENABLE_INSTRUMENTATION) { - b.string("!").variable(vars.keepingInstrumentation); - } else { - b.string("true"); - } - b.end(); - b.startBlock(); - b.returnStatement(); - b.end(); - } - - if (FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\")\")"); - b.statement("indent--"); - } - - b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote("Mismatched begin/end, expected ")// - .string(" + operationData.operationId").end(3); - b.end(); - - vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); - b.declaration("int", "numChildren", "operationData.numChildren"); - - if (!op.isVariableChildren()) { - b.startIf().string("numChildren != " + op.children).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote(op.name + " expected " + op.children + " children, got ")// - .string(" + numChildren")// - .end(3); - b.end(); - } else { - b.startIf().string("numChildren < " + op.minimumChildren()).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ")// - .string(" + numChildren")// - .end(3); - b.end(); - } + b.startCase().variable(parentOp.idConstantField).end(); + b.startBlock(); - b.tree(op.createEndCode(vars)); + b.tree(afterChild); - CodeTree lastPush = op.createPushCountCode(vars); - if (lastPush != null) { - b.startAssign(fldLastPush).tree(lastPush).end(); - } + b.statement("break"); + b.end(); + } - b.startAssign(fldOperationData).variable(fldOperationData).string(".parent").end(); + b.end(); - b.statement("doAfterChild()"); + vars.childIndex = null; - vars.numChildren = null; + return mBeforeChild; + } - } - } else { - CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); - { - CodeTreeBuilder b = metEmit.getBuilder(); + private CodeExecutableElement createDoLeave(BuilderVariables vars) { + CodeVariableElement parData = new CodeVariableElement(types.BuilderOperationData, "data"); + CodeExecutableElement mDoLeave = GeneratorUtils.overrideImplement(types.OperationBuilder, "doLeaveOperation"); - if (FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); - } + CodeTreeBuilder b = mDoLeave.createBuilder(); - b.statement("doBeforeChild()"); + b.startSwitch().string("data.operationId").end(); + b.startBlock(); - if (op.name.equals("Label")) { - // for labels we need to use local to not conflict with operation layering - // requirements. we still create the variable since some other code expects - // it to exist (it will shadow the actual field) - b.string(types.BuilderOperationData.asElement().getSimpleName() + " "); - } - b.startAssign(fldOperationData); - b.startNew(types.BuilderOperationData); + CodeVariableElement oldOperationData = vars.operationData; - b.field("this", fldOperationData); - b.variable(op.idConstantField); - b.string("getCurStack()"); - b.string("" + op.getNumAuxValues()); - b.string("false"); + vars.operationData = parData; - for (VariableElement v : metEmit.getParameters()) { - b.variable(v); - } - b.end(2); + for (Operation op : m.getOperations()) { + CodeTree leaveCode = op.createLeaveCode(vars); + if (leaveCode == null) { + continue; + } - b.tree(op.createBeginCode(vars)); - b.tree(op.createEndCode(vars)); - b.startAssign(fldLastPush).tree(op.createPushCountCode(vars)).end(); + b.startCase().variable(op.idConstantField).end(); + b.startBlock(); - if (!op.name.equals("Label")) { - b.startAssign(fldOperationData).variable(fldOperationData).string(".parent").end(); - } + b.tree(leaveCode); + b.statement("break"); - b.statement("doAfterChild()"); + b.end(); - } - typBuilderImpl.add(metEmit); - } } - return typBuilderImpl; + vars.operationData = oldOperationData; - } + b.end(); - private static TypeMirror generic(TypeElement el, TypeMirror... params) { - return new DeclaredCodeTypeMirror(el, Arrays.asList(params)); + return mDoLeave; } private static TypeMirror arrayOf(TypeMirror el) { return new ArrayCodeTypeMirror(el); } + private static TypeMirror consumer(TypeMirror el) { + return new DeclaredCodeTypeMirror(ProcessorContext.getInstance().getTypeElement(Consumer.class), List.of(el)); + } + @Override @SuppressWarnings("hiding") public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index b0b78092bb76..4146dde3751e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -7,10 +7,8 @@ import java.util.Set; import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.model.MessageContainer; @@ -24,10 +22,6 @@ public class OperationsData extends Template { private final List operations = new ArrayList<>(); private final OperationsContext context = new OperationsContext(this); - private TypeMirror languageType; - private TypeMirror parseContextType; - private ExecutableElement parseMethod; - private boolean tracing; private OperationDecisions decisions; private String decisionsFilePath; @@ -47,24 +41,6 @@ public void addOperationData(SingleOperationData data) { operations.add(data); } - public void setParseContext(TypeMirror languageType, TypeMirror parseContextType, ExecutableElement parseMethod) { - this.languageType = languageType; - this.parseContextType = parseContextType; - this.parseMethod = parseMethod; - } - - public TypeMirror getLanguageType() { - return languageType; - } - - public TypeMirror getParseContextType() { - return parseContextType; - } - - public ExecutableElement getParseMethod() { - return parseMethod; - } - @Override protected List findChildContainers() { return List.copyOf(operations); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 17b09f4adc39..b8d464541495 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -13,7 +13,7 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -42,26 +42,15 @@ protected OperationsData parse(Element element, List mirror) { OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); - // find and bind parse method - - ExecutableElement parseMethod = ElementUtils.findExecutableElement(typeElement, "parse"); - if (parseMethod == null) { - data.addError(typeElement, - "Parse method not found. You must provide a method named 'parse' with following signature: void parse({Language}, {Context}, %sBuilder)", - typeElement.getSimpleName()); - return data; + // check basic declaration properties + if (!typeElement.getModifiers().contains(Modifier.FINAL)) { + data.addError(typeElement, "Operations class must be declared final."); } - if (parseMethod.getParameters().size() != 3) { - data.addError(parseMethod, "Parse method must have exactly three arguments: the language, source and the builder"); - return data; + if (ElementUtils.findParentEnclosingType(typeElement).isPresent()) { + data.addError(typeElement, "Operations class must be a top-level class."); } - TypeMirror languageType = parseMethod.getParameters().get(0).asType(); - TypeMirror contextType = parseMethod.getParameters().get(1).asType(); - - data.setParseContext(languageType, contextType, parseMethod); - // find and bind type system AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); if (typeSystemRefMirror != null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index bef9b65fd494..ac48e6f1f60e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -105,7 +105,7 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); b.tree(index); - b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).variable(vars.numChildNodes).end(); + b.startCall("createChildNodes").string("" + numChildNodes).end(); b.end(); break; case CONST: @@ -127,10 +127,6 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.startStatement().startCall(vars.consts, "reserve").end(2); } - if (numChildNodes > 0) { - b.startStatement().variable(vars.numChildNodes).string(" += " + numChildNodes).end(); - } - return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index f0541e2aae3e..d69ee664cdfb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -362,7 +362,7 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code } if (n < inputs.length && inputs[n] == InputType.BRANCH_PROFILE) { - value = CodeTreeBuilder.singleString("numBranchProfiles++"); + value = CodeTreeBuilder.singleString("createBranchProfile()"); } if (n < inputs.length && inputs[n] == InputType.CONST_POOL) { @@ -478,7 +478,6 @@ public final CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments b.startAssign("int[] predecessorBcis"); b.startCall("doBeforeEmitInstruction"); - b.variable(vars.bci); b.tree(numPop); b.string(numPush == 0 ? "false" : "true"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index b90fb09368e1..c73d0be35881 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2194,11 +2194,9 @@ private void initializeExpressions(List elements, NodeData no List globalMembers = new ArrayList<>(members.size() + fields.size()); globalMembers.addAll(fields); globalMembers.addAll(members); + globalMembers.add(new CodeVariableElement(types.Node, "this")); if (mode == ParseMode.OPERATION) { - globalMembers.add(new CodeVariableElement(types.OperationsNode, "this")); globalMembers.add(new CodeVariableElement(context.getType(int.class), "$bci")); - } else { - globalMembers.add(new CodeVariableElement(types.Node, "this")); } DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 26b31baaea02..974e3d74ea32 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -70,7 +70,6 @@ import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.object.Shape; -import com.oracle.truffle.api.operation.OperationsNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.builtins.SLBuiltinNode; @@ -81,7 +80,6 @@ import com.oracle.truffle.sl.builtins.SLStackTraceBuiltin; import com.oracle.truffle.sl.nodes.SLEvalRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; -import com.oracle.truffle.sl.nodes.SLOperationsRootNode; import com.oracle.truffle.sl.nodes.SLRootNode; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.SLUndefinedFunctionRootNode; @@ -110,9 +108,8 @@ import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; -import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SLNodeVisitor; -import com.oracle.truffle.sl.parser.SLSource; +import com.oracle.truffle.sl.parser.SLOperationsVisitor; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; @@ -346,14 +343,15 @@ protected CallTarget parse(ParsingRequest request) throws Exception { source = Source.newBuilder(language, sb.toString(), source.getName()).build(); } + Map targets; if (useOperations) { - OperationsNode[] operations = SLOperationsBuilder.parse(this, new SLSource(source)); - return new SLOperationsRootNode(this, operations[operations.length - 1], null).getCallTarget(); + targets = SLOperationsVisitor.parseSL(this, source); } else { - Map targets = SLNodeVisitor.parseSL(this, new SLSource(source)); - RootCallTarget rootTarget = targets.get(SLStrings.MAIN); - return new SLEvalRootNode(this, rootTarget, targets).getCallTarget(); + targets = SLNodeVisitor.parseSL(this, source); } + + RootCallTarget rootTarget = targets.get(SLStrings.MAIN); + return new SLEvalRootNode(this, rootTarget, targets).getCallTarget(); } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java index f907f4770b0c..67529c5ea856 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java @@ -1,16 +1,16 @@ package com.oracle.truffle.sl.nodes; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; public class SLOperationsRootNode extends SLRootNode { - @Child private OperationsNode operationsNode; + @Child private OperationNode operationsNode; - public SLOperationsRootNode(SLLanguage language, OperationsNode operationsNode, TruffleString name) { + public SLOperationsRootNode(SLLanguage language, OperationNode operationsNode, TruffleString name) { super(language, operationsNode.createFrameDescriptor(), null, null, name); this.operationsNode = insert(operationsNode); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index bec6cd912135..26f142a2c7ea 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,6 +1,5 @@ package com.oracle.truffle.sl.operations; -import java.util.Collections; import java.util.Map; import com.oracle.truffle.api.Assumption; @@ -24,7 +23,6 @@ import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; @@ -39,8 +37,6 @@ import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.parser.SLOperationsVisitor; -import com.oracle.truffle.sl.parser.SLSource; import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; @@ -64,21 +60,7 @@ @OperationProxy(SLUnboxNode.class) @OperationProxy(SLFunctionLiteralNode.class) @OperationProxy(SLToBooleanNode.class) -public class SLOperations { - - public static void parse(SLLanguage language, SLSource source, SLOperationsBuilder builder) { - Map targets = SLOperationsVisitor.parseSL(language, source, builder); - - // create the RootNode - - builder.beginReturn(); - builder.beginSLEvalRootOperation(); - builder.emitConstObject(Collections.unmodifiableMap(targets)); - builder.endSLEvalRootOperation(); - builder.endReturn(); - - builder.build(); - } +public final class SLOperations { @Operation public static class SLEvalRootOperation { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index bfa1db4fd59f..ecec45d65a92 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -18,21 +18,17 @@ public abstract class SLBaseVisitor extends SimpleLanguageOperationsBaseVisitor { - protected static Map parseSLImpl(SLSource source, SLBaseVisitor visitor) { - SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getSource().getCharacters().toString())); + protected static Map parseSLImpl(Source source, SLBaseVisitor visitor) { + SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getCharacters().toString())); SimpleLanguageOperationsParser parser = new SimpleLanguageOperationsParser(new CommonTokenStream(lexer)); lexer.removeErrorListeners(); parser.removeErrorListeners(); - BailoutErrorListener listener = new BailoutErrorListener(source.getSource()); + BailoutErrorListener listener = new BailoutErrorListener(source); lexer.addErrorListener(listener); parser.addErrorListener(listener); parser.simplelanguage().accept(visitor); - if (source.getFunctions() == null) { - source.setFunctions(visitor.functions); - } - return visitor.functions; } @@ -69,19 +65,20 @@ public Integer create() { } protected final SLLanguage language; - protected final SLSource source; + protected final Source source; protected final TruffleString sourceString; - protected final Map functions = new HashMap<>(); + protected final Map functions; - protected SLBaseVisitor(SLLanguage language, SLSource source) { + protected SLBaseVisitor(SLLanguage language, Source source, Map functions) { this.language = language; this.source = source; - sourceString = SLStrings.fromJavaString(source.getSource().getCharacters().toString()); + this.functions = functions; + sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); } protected void SemErr(Token token, String message) { assert token != null; - throwParseError(source.getSource(), token.getLine(), token.getCharPositionInLine(), token, message); + throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); } private static final class BailoutErrorListener extends BaseErrorListener { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index 20d4317697ff..a50a80f747d8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -2,6 +2,7 @@ import java.math.BigInteger; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,6 +14,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -76,7 +78,7 @@ public class SLNodeVisitor extends SLBaseVisitor { - public static Map parseSL(SLLanguage language, SLSource source) { + public static Map parseSL(SLLanguage language, Source source) { return parseSLImpl(source, new SLNodeVisitor(language, source)); } @@ -87,8 +89,8 @@ public static Map parseSL(SLLanguage language, SL private SLExpressionVisitor EXPRESSION_VISITOR = new SLExpressionVisitor(); private int loopDepth = 0; - protected SLNodeVisitor(SLLanguage language, SLSource source) { - super(language, source); + protected SLNodeVisitor(SLLanguage language, Source source) { + super(language, source, new HashMap<>()); } @Override @@ -120,7 +122,7 @@ public Void visitFunction(FunctionContext ctx) { scope = scope.parent; methodNodes.add(bodyNode); final int bodyEndPos = bodyNode.getSourceEndIndex(); - final SourceSection functionSrc = source.getSource().createSection(functionStartPos, bodyEndPos - functionStartPos); + final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); final SLStatementNode methodBlock = new SLBlockNode(methodNodes.toArray(new SLStatementNode[methodNodes.size()])); methodBlock.setSourceSection(functionStartPos, bodyEndPos - functionStartPos); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 52693759466e..2a0f90c8f5b6 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -13,9 +13,11 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.debug.DebuggerTags; import com.oracle.truffle.api.instrumentation.StandardTags; +import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationsNode; +import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; @@ -48,17 +50,19 @@ public class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = false; - public static Map parseSL(SLLanguage language, SLSource source, SLOperationsBuilder builder) { - return parseSLImpl(source, new SLOperationsVisitor(language, source, builder)); + public static Map parseSL(SLLanguage language, Source source, Map functions, SLOperationsBuilder builder) { + return parseSLImpl(source, new SLOperationsVisitor(language, source, builder, functions)); } - public static Map parseSL(SLLanguage language, SLSource source) { - SLOperationsBuilder.parse(language, source); - return source.getFunctions(); + public static Map parseSL(SLLanguage language, Source source) { + Map roots = new HashMap<>(); + SLOperationsBuilder.create(OperationConfig.DEFAULT, b -> parseSL(language, source, roots, b)); + + return roots; } - private SLOperationsVisitor(SLLanguage language, SLSource source, SLOperationsBuilder builder) { - super(language, source); + private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder, Map functions) { + super(language, source, functions); this.b = builder; } @@ -132,7 +136,7 @@ public Void visitFunction(FunctionContext ctx) { assert scope == null; TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); - b.beginSource(source.getSource()); + b.beginSource(source); b.beginTag(StandardTags.RootTag.class); scope = new LocalScope(null); @@ -164,13 +168,13 @@ public Void visitFunction(FunctionContext ctx) { b.endTag(); b.endSource(); - OperationsNode node = b.build(); + OperationNode node = b.publish(); if (DO_LOG_NODE_CREATION) { try { System.out.println("----------------------------------------------"); System.out.printf(" Node: %s%n", name); - System.out.println(node.dump()); + System.out.println(node); System.out.println("----------------------------------------------"); } catch (Exception ignored) { } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java deleted file mode 100644 index 8288f8f4e555..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLSource.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.oracle.truffle.sl.parser; - -import java.util.Map; -import java.util.Objects; - -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.strings.TruffleString; - -public class SLSource { - private final Source source; - private Map functions; - - public SLSource(Source source) { - Objects.requireNonNull(source); - this.source = source; - } - - public Map getFunctions() { - return functions; - } - - public void setFunctions(Map functions) { - this.functions = functions; - } - - public Source getSource() { - return source; - } -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java index 6e492c83dfe8..fc080f6b5da7 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLFunctionRegistry.java @@ -55,7 +55,6 @@ import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.parser.SLNodeVisitor; import com.oracle.truffle.sl.parser.SLOperationsVisitor; -import com.oracle.truffle.sl.parser.SLSource; /** * Manages the mapping from function names to {@link SLFunction function objects}. @@ -118,9 +117,9 @@ public void register(Map newFunctions) { public void register(Source newFunctions) { if (language.isUseOperations()) { - register(SLOperationsVisitor.parseSL(language, new SLSource(newFunctions))); + register(SLOperationsVisitor.parseSL(language, newFunctions)); } else { - register(SLNodeVisitor.parseSL(language, new SLSource(newFunctions))); + register(SLNodeVisitor.parseSL(language, newFunctions)); } } From 5f017c6394cd380523ea3964d26247922e52dcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 10 May 2022 15:32:40 +0200 Subject: [PATCH 080/312] [wip] metadata --- .../sl/operations/SLOperationsBuilder.java | 128 +++++++++------ .../test/example/TestOperations.java | 7 +- .../example/TestOperationsParserTest.java | 37 +++++ .../api/operation/GenerateOperations.java | 6 + .../truffle/api/operation/MetadataKey.java | 35 +++++ .../api/operation/OperationBuilder.java | 13 +- .../truffle/api/operation/OperationNode.java | 16 +- .../truffle/dsl/processor/TruffleTypes.java | 8 +- .../operations/OperationMetadataData.java | 53 +++++++ .../operations/OperationMetadataParser.java | 71 +++++++++ .../operations/OperationsCodeGenerator.java | 146 ++++++++++++++---- .../processor/operations/OperationsData.java | 11 +- .../operations/OperationsParser.java | 13 ++ .../truffle/sl/operations/SLOperations.java | 5 + 14 files changed, 471 insertions(+), 78 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 1b2b83ac4dfe..1986e622e8fc 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -196,6 +196,8 @@ protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, Operation public abstract void endSLInvokeOperation(); + public abstract void setMethodName(String value); + public static OperationNodes create(OperationConfig config, Consumer generator) { OperationNodes nodes = new OperationNodesImpl(generator); BuilderImpl builder = new BuilderImpl(nodes, false, config); @@ -259,15 +261,15 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_CONSTANT_LONG = 7; + private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_LOAD_ARGUMENT_LONG = 10; + private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; - private static final int INSTR_LOAD_LOCAL_LONG = 14; + private static final int INSTR_LOAD_LOCAL_LONG = 13; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -304,22 +306,28 @@ private static class BuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, // DOUBLE null}; int lastChildPush; + private String metadata_MethodName; BuilderImpl(OperationNodes nodes, boolean isReparse, OperationConfig config) { super(nodes, isReparse, config); } + @Override + protected OperationNode createNode(OperationNodes arg0, Object arg1, OperationBytecodeNode arg2) { + return new OperationNodeImpl(arg0, arg1, arg2); + } + @Override protected OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { return new BytecodeNode(arg0, arg1, arg2, arg3, arg4, arg5, arg6); @@ -1438,6 +1446,36 @@ public void endSLInvokeOperation() { doAfterChild(); } + @Override + public void setMethodName(String value) { + metadata_MethodName = value; + } + + @Override + protected void resetMetadata() { + metadata_MethodName = null; + } + + @Override + protected void assignMetadata(OperationNode node) { + OperationNodeImpl nodeImpl = (OperationNodeImpl) node; + nodeImpl.MethodName = metadata_MethodName; + } + + @GeneratedBy(SLOperations.class) + private static final class OperationNodeImpl extends OperationNode { + + private String MethodName; + + private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationBytecodeNode bcNode) { + super(nodes, sourceInfo, bcNode); + } + + static { + setMetadataAccessor(SLOperations.METHOD_NAME, n -> ((OperationNodeImpl) n).MethodName); + } + + } /** * pop * Inputs: @@ -1469,13 +1507,13 @@ public void endSLInvokeOperation() { * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: @@ -1487,13 +1525,13 @@ public void endSLInvokeOperation() { * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: @@ -1511,13 +1549,13 @@ public void endSLInvokeOperation() { * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: @@ -2037,16 +2075,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2059,11 +2097,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2071,11 +2109,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2098,11 +2136,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2110,11 +2148,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -5833,11 +5871,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_C_SLLOGICAL_NOT_OPERATION : case INSTR_C_SLTO_BOOLEAN_OPERATION : case INSTR_C_SLEVAL_ROOT_OPERATION : @@ -5851,8 +5889,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -6046,7 +6084,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6064,7 +6102,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6074,7 +6112,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6092,7 +6130,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6127,7 +6165,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6145,14 +6183,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6170,7 +6208,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6227,7 +6265,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6245,14 +6283,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6270,7 +6308,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 6910f0e65708..d38b3808848d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -8,13 +8,18 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.GenerateOperations.Metadata; +import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; -@GenerateOperations @GenerateAOT +@GenerateOperations public final class TestOperations { + @Metadata("TestData") // + public static final MetadataKey TEST_DATA = new MetadataKey<>("default value"); + private static class TestException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -9143719084054578413L; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index e4505480f8d2..d6dbc8e60d61 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -869,4 +869,41 @@ public void testFinallyTryNoExceptException() { testOrdering(true, root, 1L); } + + @Test + public void testMetadata() { + final String value = "test data"; + + OperationNode node = parseNode(b -> { + b.setTestData(value); + b.publish(); + }); + + Assert.assertEquals(value, node.getMetadata(TestOperations.TEST_DATA)); + Assert.assertEquals(value, TestOperations.TEST_DATA.getValue(node)); + } + + @Test + public void testMetadataChange() { + final String value = "test data"; + + OperationNode node = parseNode(b -> { + b.setTestData("some old value"); + b.setTestData(value); + b.publish(); + }); + + Assert.assertEquals(value, node.getMetadata(TestOperations.TEST_DATA)); + Assert.assertEquals(value, TestOperations.TEST_DATA.getValue(node)); + } + + @Test + public void testMetadataDefaultValue() { + OperationNode node = parseNode(b -> { + b.publish(); + }); + + Assert.assertEquals(TestOperations.TEST_DATA.getDefaultValue(), node.getMetadata(TestOperations.TEST_DATA)); + Assert.assertEquals(TestOperations.TEST_DATA.getDefaultValue(), TestOperations.TEST_DATA.getValue(node)); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index 2db1871bc230..7cde64679168 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -15,4 +15,10 @@ Class[] boxingEliminationTypes() default {}; boolean forceTracing() default false; + + @Retention(RetentionPolicy.SOURCE) + @Target({ElementType.FIELD}) + public @interface Metadata { + String value(); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java new file mode 100644 index 000000000000..baa20cb90e79 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java @@ -0,0 +1,35 @@ +package com.oracle.truffle.api.operation; + +import java.util.function.Function; + +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; + +public class MetadataKey { + private final T defaultValue; + @CompilationFinal private Function getter; + + public MetadataKey(T defaultValue) { + this.defaultValue = defaultValue; + } + + void setGetter(Function getter) { + this.getter = getter; + } + + public T getDefaultValue() { + return defaultValue; + } + + public T getValue(OperationNode node) { + if (getter == null) { + throw new ClassCastException(); + } + + T value = getter.apply(node); + if (value == null) { + return defaultValue; + } else { + return value; + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 899a026f31ff..211f41f299dd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -65,6 +65,8 @@ private void reset() { numChildNodes = 0; numBranchProfiles = 0; + + resetMetadata(); } public final OperationNode publish() { @@ -75,7 +77,8 @@ public final OperationNode publish() { OperationNode result; if (!isReparse) { SourceInfo sourceInfo = withSource ? sourceBuilder.build() : null; - result = new OperationNode(nodes, sourceInfo, publishBytecode()); + result = createNode(nodes, sourceInfo, publishBytecode()); + assignMetadata(result); assert buildIndex == builtNodes.size(); builtNodes.add(result); } else { @@ -129,6 +132,8 @@ private OperationBytecodeNode publishBytecode() { } } + protected abstract OperationNode createNode(OperationNodes arg0, Object arg1, OperationBytecodeNode arg2); + protected abstract OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); protected abstract OperationInstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, @@ -443,4 +448,10 @@ protected final int doBeginInstrumentation(Class cls) { // TODO return 0; } + + // ------------------------ metadata ------------------------ + + protected abstract void resetMetadata(); + + protected abstract void assignMetadata(OperationNode node); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 9482ef54c731..ed22280efb17 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -1,5 +1,7 @@ package com.oracle.truffle.api.operation; +import java.util.function.Function; + import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.TruffleLanguage; @@ -9,16 +11,16 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.SourceSection; -public final class OperationNode extends Node { +public abstract class OperationNode extends Node { private final OperationNodes nodes; @CompilationFinal private SourceInfo sourceInfo; @Child private OperationBytecodeNode bcNode; - OperationNode(OperationNodes nodes, SourceInfo sourceInfo, OperationBytecodeNode bcNode) { + protected OperationNode(OperationNodes nodes, Object sourceInfo, OperationBytecodeNode bcNode) { this.nodes = nodes; - this.sourceInfo = sourceInfo; + this.sourceInfo = (SourceInfo) sourceInfo; this.bcNode = bcNode; } @@ -38,6 +40,10 @@ public Object execute(VirtualFrame frame) { return bcNode.execute(frame); } + public T getMetadata(MetadataKey key) { + return key.getValue(this); + } + // ------------------------------------ internal accessors ------------------------------------ boolean isBytecodeInstrumented() { @@ -59,6 +65,10 @@ void setSourceInfo(SourceInfo sourceInfo) { this.sourceInfo = sourceInfo; } + protected static void setMetadataAccessor(MetadataKey key, Function getter) { + key.setGetter(getter); + } + // ------------------------------------ sources ------------------------------------ @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 3cc16c493a00..9799f56d797f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -225,17 +225,20 @@ public class TruffleTypes { public final DeclaredType TypeSystemReference = c.getDeclaredType(TypeSystemReference_Name); public final DeclaredType UnsupportedSpecializationException = c.getDeclaredType(UnsupportedSpecializationException_Name); - // Operations DSL API + // Operation DSL API public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; public static final String BuilderOperationData_Name = "com.oracle.truffle.api.operation.BuilderOperationData"; public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; + public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata"; + public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; + public static final String OperationNode_Name = "com.oracle.truffle.api.operation.OperationNode"; public static final String OperationNodes_Name = "com.oracle.truffle.api.operation.OperationNodes"; public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy"; public static final String OperationBuilder_Name = "com.oracle.truffle.api.operation.OperationBuilder"; @@ -249,11 +252,14 @@ public class TruffleTypes { public final DeclaredType BuilderOperationLabel = c.getDeclaredTypeOptional(BuilderOperationLabel_Name); public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); + public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); + public final DeclaredType MetadataKey = c.getDeclaredTypeOptional(MetadataKey_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); public final DeclaredType OperationConfig = c.getDeclaredTypeOptional(OperationConfig_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); public final DeclaredType OperationLocal = c.getDeclaredTypeOptional(OperationLocal_Name); + public final DeclaredType OperationNode = c.getDeclaredTypeOptional(OperationNode_Name); public final DeclaredType OperationNodes = c.getDeclaredTypeOptional(OperationNodes_Name); public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name); public final DeclaredType OperationBuilder = c.getDeclaredTypeOptional(OperationBuilder_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java new file mode 100644 index 000000000000..88f638fa4287 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java @@ -0,0 +1,53 @@ +package com.oracle.truffle.dsl.processor.operations; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.model.MessageContainer; +import com.oracle.truffle.dsl.processor.model.Template; + +public class OperationMetadataData extends Template { + + private final OperationsData parent; + + private String name; + private TypeMirror type; + + private final Element template; + + public OperationMetadataData(OperationsData parent, ProcessorContext context, Element template, AnnotationMirror annotation) { + super(context, null, annotation); + this.parent = parent; + this.template = template; + } + + @Override + public MessageContainer getBaseContainer() { + return parent; + } + + @Override + public Element getMessageElement() { + return template; + } + + public TypeMirror getType() { + return type; + } + + public void setType(TypeMirror type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java new file mode 100644 index 000000000000..b82d92581006 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java @@ -0,0 +1,71 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.parser.AbstractParser; + +public class OperationMetadataParser extends AbstractParser { + + private final OperationsData parentData; + + public OperationMetadataParser(OperationsData parentData) { + this.parentData = parentData; + } + + @Override + protected OperationMetadataData parse(Element element, List mirror) { + AnnotationMirror mir = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), getAnnotationType()); + OperationMetadataData data = new OperationMetadataData(parentData, context, element, mir); + + if (!(element instanceof VariableElement)) { + data.addError(element, "@Metadata must be attached to a field"); + return data; + } + + VariableElement varElement = (VariableElement) element; + + if (!varElement.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { + data.addError(element, "@Metadata must be attached to a static final field"); + } + + if (varElement.getModifiers().contains(Modifier.PRIVATE)) { + data.addError(element, "@Metadata field must not be private"); + } + + TypeMirror fieldType = varElement.asType(); + + TypeMirror metadataType = null; + + if (fieldType.getKind() == TypeKind.DECLARED) { + DeclaredType declaredType = (DeclaredType) fieldType; + if (declaredType.asElement().equals(types.MetadataKey.asElement())) { + metadataType = declaredType.getTypeArguments().get(0); + } + } + + if (metadataType == null) { + data.addError(element, "@Metadata field must be of type MetadataKey<>"); + } + + data.setType(metadataType); + data.setName((String) ElementUtils.getAnnotationValue(mir, "value").getValue()); + + return data; + } + + @Override + public DeclaredType getAnnotationType() { + return types.GenerateOperations_Metadata; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index b0f3224b0819..e183a8c2021e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -6,6 +6,7 @@ import java.util.function.Consumer; import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; @@ -32,6 +33,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_PUBLIC = Set.of(Modifier.PUBLIC); private static final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private static final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); @@ -110,36 +112,73 @@ CodeTypeElement createBuilder(String simpleName) { CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); typBuilder.add(typBuilderImpl); + for (OperationMetadataData metadata : m.getMetadatas()) { + typBuilder.add(createSetMetadata(metadata, true)); + } + + typBuilder.add(createCreateMethod(typBuilder, typBuilderImpl)); + + return typBuilder; + } + + private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { + CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); + CodeVariableElement parParser = new CodeVariableElement(consumer(typBuilder.asType()), "generator"); + CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "create"); + metCreate.addParameter(parConfig); + metCreate.addParameter(parParser); + + CodeTreeBuilder b = metCreate.getBuilder(); + + b.declaration(types.OperationNodes, "nodes", "new OperationNodesImpl(generator)"); + b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); { - CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parParser = new CodeVariableElement(consumer(typBuilder.asType()), "generator"); - CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "create"); - metCreate.addParameter(parConfig); - metCreate.addParameter(parParser); - typBuilder.add(metCreate); - - CodeTreeBuilder b = metCreate.getBuilder(); - - b.declaration(types.OperationNodes, "nodes", "new OperationNodesImpl(generator)"); - b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); - { - b.string("nodes"); - b.string("false"); // isReparse - b.variable(parConfig); - } - b.end(2); + b.string("nodes"); + b.string("false"); // isReparse + b.variable(parConfig); + } + b.end(2); - b.startStatement().startCall("generator", "accept"); - b.string("builder"); - b.end(2); + b.startStatement().startCall("generator", "accept"); + b.string("builder"); + b.end(2); + + b.startStatement().startCall("builder", "finish").end(2); + + b.startReturn().string("nodes").end(); + + return metCreate; + } - b.startStatement().startCall("builder", "finish").end(2); + CodeTypeElement createOperationNodeImpl() { + CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationNodeImpl", types.OperationNode); + typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl)); - b.startReturn().string("nodes").end(); + if (!m.getMetadatas().isEmpty()) { + CodeExecutableElement staticInit = new CodeExecutableElement(MOD_STATIC, null, ""); + typOperationNodeImpl.add(staticInit); + CodeTreeBuilder initBuilder = staticInit.createBuilder(); + + for (OperationMetadataData metadata : m.getMetadatas()) { + String fieldName = metadata.getName(); + CodeVariableElement fldMetadata = new CodeVariableElement(MOD_PRIVATE, metadata.getType(), fieldName); + + typOperationNodeImpl.add(fldMetadata); + + initBuilder.startStatement().startCall("setMetadataAccessor"); + initBuilder.staticReference((VariableElement) metadata.getMessageElement()); + initBuilder.startGroup(); + { + initBuilder.string("n -> "); + initBuilder.startParantheses().cast(typOperationNodeImpl.asType()).string("n").end().string("." + fieldName); + } + initBuilder.end(); + initBuilder.end(2); + } } - return typBuilder; + return typOperationNodeImpl; } private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { @@ -223,6 +262,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldId); } + CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(); + typBuilderImpl.add(typOperationNodeImpl); + CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; { @@ -263,7 +305,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.lastChildPushCount = fldLastPush; vars.consts = fldConstPool; - typBuilderImpl.add(createForwardingConstructorCall("BytecodeNode", "createBytecode")); + typBuilderImpl.add(createForwardingConstructorCall(typOperationNodeImpl, "createNode")); + typBuilderImpl.add(createForwardingConstructorCall(builderBytecodeNodeType, "createBytecode")); typBuilderImpl.add(createForwardingConstructorCall(null, "createInstrumentedBytecode")); typBuilderImpl.add(createDoLeave(vars)); @@ -293,10 +336,61 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } } + for (OperationMetadataData metadata : m.getMetadatas()) { + CodeVariableElement fldMetadata = new CodeVariableElement(MOD_PRIVATE, metadata.getType(), "metadata_" + metadata.getName()); + typBuilderImpl.add(fldMetadata); + typBuilderImpl.add(createSetMetadata(metadata, false)); + } + + typBuilderImpl.add(createMetadataReset()); + typBuilderImpl.add(createMetadataSet(typOperationNodeImpl)); + return typBuilderImpl; } + private CodeExecutableElement createMetadataReset() { + CodeExecutableElement method = GeneratorUtils.overrideImplement(types.OperationBuilder, "resetMetadata"); + CodeTreeBuilder b = method.createBuilder(); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.startAssign("metadata_" + metadata.getName()).string("null").end(); + } + + return method; + } + + private CodeExecutableElement createMetadataSet(CodeTypeElement typOperationNodeImpl) { + CodeExecutableElement method = GeneratorUtils.overrideImplement(types.OperationBuilder, "assignMetadata"); + CodeTreeBuilder b = method.createBuilder(); + + b.startAssign(typOperationNodeImpl.getSimpleName() + " nodeImpl").cast(typOperationNodeImpl.asType()).string("node").end(); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.statement("nodeImpl." + metadata.getName() + " = metadata_" + metadata.getName()); + } + + return method; + } + + private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, boolean isAbstract) { + CodeVariableElement parValue = new CodeVariableElement(metadata.getType(), "value"); + CodeExecutableElement method = new CodeExecutableElement( + isAbstract ? MOD_PUBLIC_ABSTRACT : MOD_PUBLIC, + context.getType(void.class), "set" + metadata.getName(), + parValue); + + if (isAbstract) { + return method; + } + + CodeTreeBuilder b = method.createBuilder(); + + b.startAssign("metadata_" + metadata.getName()).variable(parValue).end(); + + return method; + } + private CodeExecutableElement createGetBlockOperationIndex(Operation op) { CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, "getBlockOperationIndex"); @@ -305,12 +399,12 @@ private CodeExecutableElement createGetBlockOperationIndex(Operation op) { return result; } - private CodeExecutableElement createForwardingConstructorCall(String typeName, String methodName) { + private CodeExecutableElement createForwardingConstructorCall(TypeElement typeName, String methodName) { CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, methodName); CodeTreeBuilder b = result.getBuilder(); if (typeName != null) { - b.startReturn().startNew(typeName); + b.startReturn().startNew(typeName.asType()); for (VariableElement par : result.getParameters()) { b.variable(par); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 4146dde3751e..fa0ec948bcf3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -20,6 +20,7 @@ public class OperationsData extends Template { private final List operations = new ArrayList<>(); + private final List metadatas = new ArrayList<>(); private final OperationsContext context = new OperationsContext(this); private boolean tracing; @@ -43,7 +44,11 @@ public void addOperationData(SingleOperationData data) { @Override protected List findChildContainers() { - return List.copyOf(operations); + ArrayList result = new ArrayList<>(); + result.addAll(operations); + result.addAll(metadatas); + + return result; } public void setTracing(boolean tracing) { @@ -62,6 +67,10 @@ public Collection getOperationData() { return operations; } + public List getMetadatas() { + return metadatas; + } + public Collection getOperations() { return context.operations; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index b8d464541495..cbb9e75b5f34 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -15,6 +15,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -51,6 +52,18 @@ protected OperationsData parse(Element element, List mirror) { data.addError(typeElement, "Operations class must be a top-level class."); } + // find all metadata + for (VariableElement ve : ElementFilter.fieldsIn(typeElement.getEnclosedElements())) { + if (ElementUtils.findAnnotationMirror(ve, types.GenerateOperations_Metadata) != null) { + OperationMetadataData metadataData = new OperationMetadataParser(data).parse(ve, false); + if (metadataData == null) { + data.addError(ve, "Could not parse metadata"); + } else { + data.getMetadatas().add(metadataData); + } + } + } + // find and bind type system AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); if (typeSystemRefMirror != null) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 26f142a2c7ea..b0ac7c2326b1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -22,6 +22,8 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.operation.GenerateOperations.Metadata; +import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; @@ -62,6 +64,9 @@ @OperationProxy(SLToBooleanNode.class) public final class SLOperations { + @Metadata("MethodName") // + public static final MetadataKey METHOD_NAME = new MetadataKey<>(""); + @Operation public static class SLEvalRootOperation { From 710ab09231ddc7cbfdb9c42ba571ab012a78c9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 11 May 2022 10:15:05 +0200 Subject: [PATCH 081/312] [wip] fix parsing and remove linenoise --- .../sl/operations/SLOperationsBuilder.java | 2058 ++++------------- .../truffle/api/operation/MetadataKey.java | 3 +- .../truffle/api/operation/OperationProxy.java | 3 + .../operations/OperationDecisions.java | 2 +- .../operations/OperationsContext.java | 2 +- .../operations/OperationsParser.java | 16 +- .../operations/SingleOperationData.java | 12 +- .../operations/SingleOperationParser.java | 260 ++- .../truffle/sl/operations/SLOperations.java | 39 +- .../sl/parser/SLOperationsVisitor.java | 120 +- 10 files changed, 733 insertions(+), 1782 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 1986e622e8fc..3ae1cc6e51c5 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -63,14 +63,12 @@ import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.operations.SLOperations.SLEvalRootOperation; -import com.oracle.truffle.sl.operations.SLOperations.SLInvokeOperation; +import com.oracle.truffle.sl.operations.SLOperations.SLInvoke; import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; import java.lang.invoke.VarHandle; -import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.function.Consumer; @@ -136,67 +134,63 @@ protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, Operation public abstract void endTag(); - public abstract void beginSLAddOperation(); + public abstract void beginSLAdd(); - public abstract void endSLAddOperation(); + public abstract void endSLAdd(); - public abstract void beginSLDivOperation(); + public abstract void beginSLDiv(); - public abstract void endSLDivOperation(); + public abstract void endSLDiv(); - public abstract void beginSLEqualOperation(); + public abstract void beginSLEqual(); - public abstract void endSLEqualOperation(); + public abstract void endSLEqual(); - public abstract void beginSLLessOrEqualOperation(); + public abstract void beginSLLessOrEqual(); - public abstract void endSLLessOrEqualOperation(); + public abstract void endSLLessOrEqual(); - public abstract void beginSLLessThanOperation(); + public abstract void beginSLLessThan(); - public abstract void endSLLessThanOperation(); + public abstract void endSLLessThan(); - public abstract void beginSLLogicalNotOperation(); + public abstract void beginSLLogicalNot(); - public abstract void endSLLogicalNotOperation(); + public abstract void endSLLogicalNot(); - public abstract void beginSLMulOperation(); + public abstract void beginSLMul(); - public abstract void endSLMulOperation(); + public abstract void endSLMul(); - public abstract void beginSLReadPropertyOperation(); + public abstract void beginSLReadProperty(); - public abstract void endSLReadPropertyOperation(); + public abstract void endSLReadProperty(); - public abstract void beginSLSubOperation(); + public abstract void beginSLSub(); - public abstract void endSLSubOperation(); + public abstract void endSLSub(); - public abstract void beginSLWritePropertyOperation(); + public abstract void beginSLWriteProperty(); - public abstract void endSLWritePropertyOperation(); + public abstract void endSLWriteProperty(); - public abstract void beginSLUnboxOperation(); + public abstract void beginSLUnbox(); - public abstract void endSLUnboxOperation(); + public abstract void endSLUnbox(); - public abstract void beginSLFunctionLiteralOperation(); + public abstract void beginSLFunctionLiteral(); - public abstract void endSLFunctionLiteralOperation(); + public abstract void endSLFunctionLiteral(); - public abstract void beginSLToBooleanOperation(); + public abstract void beginSLToBoolean(); - public abstract void endSLToBooleanOperation(); + public abstract void endSLToBoolean(); - public abstract void beginSLEvalRootOperation(); + public abstract void beginSLInvoke(); - public abstract void endSLEvalRootOperation(); + public abstract void endSLInvoke(); - public abstract void beginSLInvokeOperation(); - - public abstract void endSLInvokeOperation(); - - public abstract void setMethodName(String value); + public abstract void setMethodName(TruffleString value); public static OperationNodes create(OperationConfig config, Consumer generator) { OperationNodes nodes = new OperationNodesImpl(generator); @@ -241,21 +235,20 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int OP_LOAD_LOCAL = 14; private static final int OP_RETURN = 15; private static final int OP_TAG = 16; - private static final int OP_SLADD_OPERATION = 17; - private static final int OP_SLDIV_OPERATION = 18; - private static final int OP_SLEQUAL_OPERATION = 19; - private static final int OP_SLLESS_OR_EQUAL_OPERATION = 20; - private static final int OP_SLLESS_THAN_OPERATION = 21; - private static final int OP_SLLOGICAL_NOT_OPERATION = 22; - private static final int OP_SLMUL_OPERATION = 23; - private static final int OP_SLREAD_PROPERTY_OPERATION = 24; - private static final int OP_SLSUB_OPERATION = 25; - private static final int OP_SLWRITE_PROPERTY_OPERATION = 26; - private static final int OP_SLUNBOX_OPERATION = 27; - private static final int OP_SLFUNCTION_LITERAL_OPERATION = 28; - private static final int OP_SLTO_BOOLEAN_OPERATION = 29; - private static final int OP_SLEVAL_ROOT_OPERATION = 30; - private static final int OP_SLINVOKE_OPERATION = 31; + private static final int OP_SLADD = 17; + private static final int OP_SLDIV = 18; + private static final int OP_SLEQUAL = 19; + private static final int OP_SLLESS_OR_EQUAL = 20; + private static final int OP_SLLESS_THAN = 21; + private static final int OP_SLLOGICAL_NOT = 22; + private static final int OP_SLMUL = 23; + private static final int OP_SLREAD_PROPERTY = 24; + private static final int OP_SLSUB = 25; + private static final int OP_SLWRITE_PROPERTY = 26; + private static final int OP_SLUNBOX = 27; + private static final int OP_SLFUNCTION_LITERAL = 28; + private static final int OP_SLTO_BOOLEAN = 29; + private static final int OP_SLINVOKE = 30; private static final int INSTR_POP = 1; private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; @@ -275,49 +268,38 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; private static final int INSTR_INSTRUMENT_EXIT = 18; private static final int INSTR_INSTRUMENT_LEAVE = 19; - private static final int INSTR_C_SLADD_OPERATION = 20; - private static final int INSTR_C_SLDIV_OPERATION = 21; - private static final int INSTR_C_SLEQUAL_OPERATION = 22; - private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION = 23; - private static final int INSTR_C_SLLESS_THAN_OPERATION = 24; - private static final int INSTR_C_SLLOGICAL_NOT_OPERATION = 25; - private static final int INSTR_C_SLMUL_OPERATION = 26; - private static final int INSTR_C_SLREAD_PROPERTY_OPERATION = 27; - private static final int INSTR_C_SLSUB_OPERATION = 28; - private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION = 29; - private static final int INSTR_C_SLUNBOX_OPERATION = 30; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION = 31; - private static final int INSTR_C_SLTO_BOOLEAN_OPERATION = 32; - private static final int INSTR_C_SLEVAL_ROOT_OPERATION = 33; - private static final int INSTR_C_SLINVOKE_OPERATION = 34; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG = 35; - private static final int INSTR_C_SLADD_OPERATION_Q_ADD_LONG = 36; - private static final int INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 = 37; - private static final int INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN = 38; - private static final int INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN = 39; - private static final int INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 = 40; - private static final int INSTR_C_SLINVOKE_OPERATION_Q_DIRECT = 41; - private static final int INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM = 42; - private static final int INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 = 43; - private static final int INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 = 44; + private static final int INSTR_C_SLADD = 20; + private static final int INSTR_C_SLDIV = 21; + private static final int INSTR_C_SLEQUAL = 22; + private static final int INSTR_C_SLLESS_OR_EQUAL = 23; + private static final int INSTR_C_SLLESS_THAN = 24; + private static final int INSTR_C_SLLOGICAL_NOT = 25; + private static final int INSTR_C_SLMUL = 26; + private static final int INSTR_C_SLREAD_PROPERTY = 27; + private static final int INSTR_C_SLSUB = 28; + private static final int INSTR_C_SLWRITE_PROPERTY = 29; + private static final int INSTR_C_SLUNBOX = 30; + private static final int INSTR_C_SLFUNCTION_LITERAL = 31; + private static final int INSTR_C_SLTO_BOOLEAN = 32; + private static final int INSTR_C_SLINVOKE = 33; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, // DOUBLE null}; int lastChildPush; - private String metadata_MethodName; + private TruffleString metadata_MethodName; BuilderImpl(OperationNodes nodes, boolean isReparse, OperationConfig config) { super(nodes, isReparse, config); @@ -955,23 +937,23 @@ public void endTag() { @SuppressWarnings("unused") @Override - public void beginSLAddOperation() { + public void beginSLAdd() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLADD_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLADD, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLAddOperation() { - if (operationData.operationId != OP_SLADD_OPERATION) { + public void endSLAdd() { + if (operationData.operationId != OP_SLADD) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLAddOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLADD_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLADD); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 7 bytes: [BITS, BITS, BITS, CONST, CONTINUATION, CHILD, CONTINUATION] @@ -990,23 +972,23 @@ public void endSLAddOperation() { @SuppressWarnings("unused") @Override - public void beginSLDivOperation() { + public void beginSLDiv() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLDIV_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLDIV, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLDivOperation() { - if (operationData.operationId != OP_SLDIV_OPERATION) { + public void endSLDiv() { + if (operationData.operationId != OP_SLDIV) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLDivOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLDIV_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLDIV); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 2 bytes: [BITS, BITS] @@ -1022,23 +1004,23 @@ public void endSLDivOperation() { @SuppressWarnings("unused") @Override - public void beginSLEqualOperation() { + public void beginSLEqual() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLEQUAL_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLEQUAL, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLEqualOperation() { - if (operationData.operationId != OP_SLEQUAL_OPERATION) { + public void endSLEqual() { + if (operationData.operationId != OP_SLEQUAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLEqualOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEQUAL_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEQUAL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] @@ -1057,23 +1039,23 @@ public void endSLEqualOperation() { @SuppressWarnings("unused") @Override - public void beginSLLessOrEqualOperation() { + public void beginSLLessOrEqual() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLESS_OR_EQUAL_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLLESS_OR_EQUAL, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLLessOrEqualOperation() { - if (operationData.operationId != OP_SLLESS_OR_EQUAL_OPERATION) { + public void endSLLessOrEqual() { + if (operationData.operationId != OP_SLLESS_OR_EQUAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLLessOrEqualOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_OR_EQUAL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 1 bytes: [BITS] @@ -1088,23 +1070,23 @@ public void endSLLessOrEqualOperation() { @SuppressWarnings("unused") @Override - public void beginSLLessThanOperation() { + public void beginSLLessThan() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLESS_THAN_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLLESS_THAN, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLLessThanOperation() { - if (operationData.operationId != OP_SLLESS_THAN_OPERATION) { + public void endSLLessThan() { + if (operationData.operationId != OP_SLLESS_THAN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLLessThanOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_THAN_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_THAN); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 1 bytes: [BITS] @@ -1119,23 +1101,23 @@ public void endSLLessThanOperation() { @SuppressWarnings("unused") @Override - public void beginSLLogicalNotOperation() { + public void beginSLLogicalNot() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLOGICAL_NOT_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLLOGICAL_NOT, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLLogicalNotOperation() { - if (operationData.operationId != OP_SLLOGICAL_NOT_OPERATION) { + public void endSLLogicalNot() { + if (operationData.operationId != OP_SLLOGICAL_NOT) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 1) { - throw new IllegalStateException("SLLogicalNotOperation expected 1 children, got " + numChildren); + throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLOGICAL_NOT_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLOGICAL_NOT); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 1 bytes: [BITS] // numChildNodes = 0 @@ -1149,23 +1131,23 @@ public void endSLLogicalNotOperation() { @SuppressWarnings("unused") @Override - public void beginSLMulOperation() { + public void beginSLMul() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLMUL_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLMUL, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLMulOperation() { - if (operationData.operationId != OP_SLMUL_OPERATION) { + public void endSLMul() { + if (operationData.operationId != OP_SLMUL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLMulOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLMUL_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLMUL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 2 bytes: [BITS, BITS] @@ -1181,23 +1163,23 @@ public void endSLMulOperation() { @SuppressWarnings("unused") @Override - public void beginSLReadPropertyOperation() { + public void beginSLReadProperty() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLREAD_PROPERTY_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLREAD_PROPERTY, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLReadPropertyOperation() { - if (operationData.operationId != OP_SLREAD_PROPERTY_OPERATION) { + public void endSLReadProperty() { + if (operationData.operationId != OP_SLREAD_PROPERTY) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLReadPropertyOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLREAD_PROPERTY); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] @@ -1217,23 +1199,23 @@ public void endSLReadPropertyOperation() { @SuppressWarnings("unused") @Override - public void beginSLSubOperation() { + public void beginSLSub() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLSUB_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLSUB, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLSubOperation() { - if (operationData.operationId != OP_SLSUB_OPERATION) { + public void endSLSub() { + if (operationData.operationId != OP_SLSUB) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 2) { - throw new IllegalStateException("SLSubOperation expected 2 children, got " + numChildren); + throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLSUB_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLSUB); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); // additionalData = 2 bytes: [BITS, BITS] @@ -1249,23 +1231,23 @@ public void endSLSubOperation() { @SuppressWarnings("unused") @Override - public void beginSLWritePropertyOperation() { + public void beginSLWriteProperty() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLWRITE_PROPERTY_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLWRITE_PROPERTY, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLWritePropertyOperation() { - if (operationData.operationId != OP_SLWRITE_PROPERTY_OPERATION) { + public void endSLWriteProperty() { + if (operationData.operationId != OP_SLWRITE_PROPERTY) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 3) { - throw new IllegalStateException("SLWritePropertyOperation expected 3 children, got " + numChildren); + throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(3, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLWRITE_PROPERTY); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); bc[bci + 4] = predecessorBcis[2] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[2]); @@ -1287,23 +1269,23 @@ public void endSLWritePropertyOperation() { @SuppressWarnings("unused") @Override - public void beginSLUnboxOperation() { + public void beginSLUnbox() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLUNBOX_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLUNBOX, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLUnboxOperation() { - if (operationData.operationId != OP_SLUNBOX_OPERATION) { + public void endSLUnbox() { + if (operationData.operationId != OP_SLUNBOX) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 1) { - throw new IllegalStateException("SLUnboxOperation expected 1 children, got " + numChildren); + throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLUNBOX_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLUNBOX); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] // numChildNodes = 2 @@ -1321,23 +1303,23 @@ public void endSLUnboxOperation() { @SuppressWarnings("unused") @Override - public void beginSLFunctionLiteralOperation() { + public void beginSLFunctionLiteral() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLFUNCTION_LITERAL_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLFUNCTION_LITERAL, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLFunctionLiteralOperation() { - if (operationData.operationId != OP_SLFUNCTION_LITERAL_OPERATION) { + public void endSLFunctionLiteral() { + if (operationData.operationId != OP_SLFUNCTION_LITERAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 1) { - throw new IllegalStateException("SLFunctionLiteralOperation expected 1 children, got " + numChildren); + throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 3 bytes: [BITS, CONST, CONTINUATION] // numChildNodes = 0 @@ -1352,53 +1334,23 @@ public void endSLFunctionLiteralOperation() { @SuppressWarnings("unused") @Override - public void beginSLToBooleanOperation() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLTO_BOOLEAN_OPERATION, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLToBooleanOperation() { - if (operationData.operationId != OP_SLTO_BOOLEAN_OPERATION) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLToBooleanOperation expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 3 + 0] = 0; - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLEvalRootOperation() { + public void beginSLToBoolean() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLEVAL_ROOT_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLTO_BOOLEAN, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLEvalRootOperation() { - if (operationData.operationId != OP_SLEVAL_ROOT_OPERATION) { + public void endSLToBoolean() { + if (operationData.operationId != OP_SLTO_BOOLEAN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren != 1) { - throw new IllegalStateException("SLEvalRootOperation expected 1 children, got " + numChildren); + throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEVAL_ROOT_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLTO_BOOLEAN); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); // additionalData = 1 bytes: [BITS] // numChildNodes = 0 @@ -1412,23 +1364,23 @@ public void endSLEvalRootOperation() { @SuppressWarnings("unused") @Override - public void beginSLInvokeOperation() { + public void beginSLInvoke() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLINVOKE_OPERATION, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLINVOKE, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLInvokeOperation() { - if (operationData.operationId != OP_SLINVOKE_OPERATION) { + public void endSLInvoke() { + if (operationData.operationId != OP_SLINVOKE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren < 0) { - throw new IllegalStateException("SLInvokeOperation expected at least 0 children, got " + numChildren); + throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(numChildren, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE_OPERATION); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] @@ -1447,7 +1399,7 @@ public void endSLInvokeOperation() { } @Override - public void setMethodName(String value) { + public void setMethodName(TruffleString value) { metadata_MethodName = value; } @@ -1465,7 +1417,7 @@ protected void assignMetadata(OperationNode node) { @GeneratedBy(SLOperations.class) private static final class OperationNodeImpl extends OperationNode { - private String MethodName; + private TruffleString MethodName; private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationBytecodeNode bcNode) { super(nodes, sourceInfo, bcNode); @@ -1592,7 +1544,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * BRANCH * - * c.SLAddOperation + * c.SLAdd * Inputs: * STACK_VALUE * STACK_VALUE @@ -1610,7 +1562,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Add1 * Fallback * - * c.SLDivOperation + * c.SLDiv * Inputs: * STACK_VALUE * STACK_VALUE @@ -1624,7 +1576,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Div * Fallback * - * c.SLEqualOperation + * c.SLEqual * Inputs: * STACK_VALUE * STACK_VALUE @@ -1648,7 +1600,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Generic1 * Fallback * - * c.SLLessOrEqualOperation + * c.SLLessOrEqual * Inputs: * STACK_VALUE * STACK_VALUE @@ -1661,7 +1613,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * LessOrEqual1 * Fallback * - * c.SLLessThanOperation + * c.SLLessThan * Inputs: * STACK_VALUE * STACK_VALUE @@ -1674,7 +1626,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * LessThan1 * Fallback * - * c.SLLogicalNotOperation + * c.SLLogicalNot * Inputs: * STACK_VALUE * Results: @@ -1685,7 +1637,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Boolean * Fallback * - * c.SLMulOperation + * c.SLMul * Inputs: * STACK_VALUE * STACK_VALUE @@ -1699,7 +1651,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Mul * Fallback * - * c.SLReadPropertyOperation + * c.SLReadProperty * Inputs: * STACK_VALUE * STACK_VALUE @@ -1719,7 +1671,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * ReadObject1 * Fallback * - * c.SLSubOperation + * c.SLSub * Inputs: * STACK_VALUE * STACK_VALUE @@ -1733,7 +1685,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Sub * Fallback * - * c.SLWritePropertyOperation + * c.SLWriteProperty * Inputs: * STACK_VALUE * STACK_VALUE @@ -1754,7 +1706,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * WriteObject1 * Fallback * - * c.SLUnboxOperation + * c.SLUnbox * Inputs: * STACK_VALUE * Results: @@ -1777,7 +1729,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * FromForeign1 * Fallback * - * c.SLFunctionLiteralOperation + * c.SLFunctionLiteral * Inputs: * STACK_VALUE * Results: @@ -1789,130 +1741,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Perform * Fallback * - * c.SLToBooleanOperation - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLEvalRootOperation - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Execute - * Fallback - * - * c.SLInvokeOperation - * Inputs: - * STACK_VALUE - * VARARG_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * Direct - * Indirect - * Interop - * Fallback - * - * c.SLUnboxOperation.q.FromLong - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLAddOperation.q.AddLong - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * AddLong - * Add0 - * Add1 - * Fallback - * - * c.SLReadPropertyOperation.q.ReadSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * ReadArray0 - * ReadArray1 - * ReadSLObject0 - * ReadSLObject1 - * ReadObject0 - * ReadObject1 - * Fallback - * - * c.SLUnboxOperation.q.FromBoolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLToBooleanOperation.q.Boolean + * c.SLToBoolean * Inputs: * STACK_VALUE * Results: @@ -1923,20 +1752,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Boolean * Fallback * - * c.SLLessOrEqualOperation.q.LessOrEqual0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessOrEqual0 - * LessOrEqual1 - * Fallback - * - * c.SLInvokeOperation.q.Direct + * c.SLInvoke * Inputs: * STACK_VALUE * VARARG_VALUE @@ -1953,52 +1769,6 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Interop * Fallback * - * c.SLFunctionLiteralOperation.q.Perform - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * Specializations: - * Perform - * Fallback - * - * c.SLWritePropertyOperation.q.WriteSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * WriteArray0 - * WriteArray1 - * WriteSLObject0 - * WriteSLObject1 - * WriteObject0 - * WriteObject1 - * Fallback - * - * c.SLLessThanOperation.q.LessThan0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessThan0 - * LessThan1 - * Fallback - * */ @GeneratedBy(SLOperations.class) @@ -2165,161 +1935,98 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { returnValue = frame.getObject(sp - 1); break loop; } - case INSTR_C_SLADD_OPERATION : + case INSTR_C_SLADD : { - this.SLAddOperation_execute_(frame, bci, sp); + this.SLAdd_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; break; } - case INSTR_C_SLDIV_OPERATION : + case INSTR_C_SLDIV : { - this.SLDivOperation_execute_(frame, bci, sp); + this.SLDiv_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; break; } - case INSTR_C_SLEQUAL_OPERATION : + case INSTR_C_SLEQUAL : { - this.SLEqualOperation_execute_(frame, bci, sp); + this.SLEqual_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 11; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL : { - this.SLLessOrEqualOperation_execute_(frame, bci, sp); + this.SLLessOrEqual_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; break; } - case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLLESS_THAN : { - this.SLLessThanOperation_execute_(frame, bci, sp); + this.SLLessThan_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 5; break; } - case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_C_SLLOGICAL_NOT : { - this.SLLogicalNotOperation_execute_(frame, bci, sp); + this.SLLogicalNot_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; break; } - case INSTR_C_SLMUL_OPERATION : + case INSTR_C_SLMUL : { - this.SLMulOperation_execute_(frame, bci, sp); + this.SLMul_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLREAD_PROPERTY : { - this.SLReadPropertyOperation_execute_(frame, bci, sp); + this.SLReadProperty_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 10; break; } - case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLSUB : { - this.SLSubOperation_execute_(frame, bci, sp); + this.SLSub_execute_(frame, bci, sp); sp = sp - 2 + 1; nextBci = bci + 6; break; } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLWRITE_PROPERTY : { - this.SLWritePropertyOperation_execute_(frame, bci, sp); + this.SLWriteProperty_execute_(frame, bci, sp); sp = sp - 3 + 1; nextBci = bci + 11; break; } - case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX : { - this.SLUnboxOperation_execute_(frame, bci, sp); + this.SLUnbox_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 10; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL : { - this.SLFunctionLiteralOperation_execute_(frame, bci, sp); + this.SLFunctionLiteral_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 6; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION : - { - this.SLToBooleanOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLEVAL_ROOT_OPERATION : - { - this.SLEvalRootOperation_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLINVOKE_OPERATION : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvokeOperation_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - { - this.SLUnboxOperation_q_FromLong_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - { - this.SLAddOperation_q_AddLong_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - { - this.SLReadPropertyOperation_q_ReadSLObject0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : - { - this.SLUnboxOperation_q_FromBoolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : + case INSTR_C_SLTO_BOOLEAN : { - this.SLToBooleanOperation_q_Boolean_execute_(frame, bci, sp); + this.SLToBoolean_execute_(frame, bci, sp); sp = sp - 1 + 1; nextBci = bci + 4; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - { - this.SLLessOrEqualOperation_q_LessOrEqual0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : + case INSTR_C_SLINVOKE : { int numVariadics = LE_BYTES.getShort(bc, bci + 3); Object input_0 = frame.getObject(sp - numVariadics - 1); @@ -2327,33 +2034,12 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { for (int varIndex = 0; varIndex < numVariadics; varIndex++) { input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); } - Object result = this.SLInvokeOperation_q_Direct_execute_(frame, bci, sp, input_0, input_1); + Object result = this.SLInvoke_execute_(frame, bci, sp, input_0, input_1); sp = sp - 1 - numVariadics + 1; frame.setObject(sp - 1, result); nextBci = bci + 11; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - this.SLFunctionLiteralOperation_q_Perform_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - this.SLWritePropertyOperation_q_WriteSLObject0_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - this.SLLessThanOperation_q_LessThan0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); @@ -2377,31 +2063,31 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { return returnValue; } - private void SLAddOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLAdd_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - SLAddOperation_SLAddOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLAdd_SLAdd_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLAddOperation_SLAddOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLAdd_SLAdd_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); @@ -2423,12 +2109,12 @@ private void SLAddOperation_SLAddOperation_execute__long_long0_(VirtualFrame $fr } finally { lock.unlock(); } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } - private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { @@ -2453,7 +2139,7 @@ private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $fram } finally { lock.unlock(); } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); return; } } @@ -2468,7 +2154,7 @@ private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $fram } if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAddOperation_Add1Data s2_ = ((SLAddOperation_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); if (s2_ != null) { if ((SLAddNode.isString($child0Value_, $child1Value_))) { $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); @@ -2480,7 +2166,7 @@ private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLAddOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { + if (SLAdd_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } @@ -2488,11 +2174,11 @@ private void SLAddOperation_SLAddOperation_execute__generic1_(VirtualFrame $fram } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -2506,11 +2192,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION_Q_ADD_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); - } int type0; int type1; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { @@ -2541,7 +2222,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } finally { lock.unlock(); } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } @@ -2559,7 +2240,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2574,7 +2254,7 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } } if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAddOperation_Add1Data s2_ = super.insert(new SLAddOperation_Add1Data()); + SLAdd_Add1Data s2_ = super.insert(new SLAdd_Add1Data()); children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); @@ -2582,7 +2262,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2601,7 +2280,6 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2620,31 +2298,31 @@ private void SLAddOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } } - private void SLDivOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLDiv_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLDivOperation_SLDivOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLDiv_SLDiv_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLDivOperation_SLDivOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLDiv_SLDiv_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; @@ -2666,12 +2344,12 @@ private void SLDivOperation_SLDivOperation_execute__long_long0_(VirtualFrame $fr } finally { lock.unlock(); } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } - private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { @@ -2696,7 +2374,7 @@ private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $fram } finally { lock.unlock(); } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); return; } } @@ -2713,18 +2391,18 @@ private void SLDivOperation_SLDivOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLDivOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + if (SLDiv_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLDiv_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -2766,7 +2444,7 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } finally { lock.unlock(); } - SLDivOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } @@ -2820,35 +2498,35 @@ private void SLDivOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } } - private void SLEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; byte state_1 = bc[$bci + 4 + 1]; if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_SLEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0, state_1); + SLEqual_SLEqual_execute__long_long0_($frame, $bci, $sp, state_0, state_1); return; } else if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); + SLEqual_SLEqual_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); return; } else { - SLEqualOperation_SLEqualOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); + SLEqual_SLEqual_execute__generic2_($frame, $bci, $sp, state_0, state_1); return; } } - private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); @@ -2861,20 +2539,20 @@ private void SLEqualOperation_SLEqualOperation_execute__long_long0_(VirtualFrame return; } - private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } boolean $child1Value_; try { $child1Value_ = expectBoolean($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); @@ -2889,7 +2567,7 @@ private void SLEqualOperation_SLEqualOperation_execute__boolean_boolean1_(Virtua @SuppressWarnings("static-method") @TruffleBoundary - private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { + private Object SLEqual_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -2904,7 +2582,7 @@ private Object SLEqualOperation_generic1Boundary_(int $bci, int $sp, byte state_ } @ExplodeLoop - private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { @@ -2998,7 +2676,7 @@ private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $ } if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); while (s7_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value_))) { boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); @@ -3013,17 +2691,17 @@ private void SLEqualOperation_SLEqualOperation_execute__generic2_(VirtualFrame $ } } if (((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - $frame.setObject($sp - 2, this.SLEqualOperation_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); + $frame.setObject($sp - 2, this.SLEqual_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3208,7 +2886,7 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { int count7_ = 0; - SLEqualOperation_Generic0Data s7_ = ((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { while (s7_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value))) { @@ -3222,7 +2900,7 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value)); if (count7_ < (4)) { - s7_ = super.insert(new SLEqualOperation_Generic0Data(((SLEqualOperation_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); + s7_ = super.insert(new SLEqual_Generic0Data(((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); @@ -3290,31 +2968,31 @@ private void SLEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } } - private void SLLessOrEqualOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLLessOrEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; @@ -3327,7 +3005,7 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__long_long0_( return; } - private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { @@ -3360,18 +3038,18 @@ private void SLLessOrEqualOperation_SLLessOrEqualOperation_execute__generic1_(Vi { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLLessOrEqualOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + if (SLLessOrEqual_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3382,11 +3060,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); - } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { @@ -3419,7 +3092,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3444,7 +3116,6 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3463,31 +3134,31 @@ private void SLLessOrEqualOperation_executeAndSpecialize_(VirtualFrame $frame, i } } - private void SLLessThanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLLessThan_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessThanOperation_SLLessThanOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLLessThan_SLLessThan_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLLessThanOperation_SLLessThanOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLLessThan_SLLessThan_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLLessThan_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; @@ -3500,7 +3171,7 @@ private void SLLessThanOperation_SLLessThanOperation_execute__long_long0_(Virtua return; } - private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { @@ -3533,18 +3204,18 @@ private void SLLessThanOperation_SLLessThanOperation_execute__generic1_(VirtualF { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLLessThanOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + if (SLLessThan_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3555,11 +3226,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); - } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { @@ -3592,7 +3258,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3617,7 +3282,6 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3636,23 +3300,23 @@ private void SLLessThanOperation_executeAndSpecialize_(VirtualFrame $frame, int } } - private void SLLogicalNotOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLLogicalNot_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_($frame, $bci, $sp, state_0); + SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $bci, $sp, state_0); return; } else { - SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + SLLogicalNot_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; @@ -3665,7 +3329,7 @@ private void SLLogicalNotOperation_SLLogicalNotOperation_execute__boolean0_(Virt return; } - private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -3681,18 +3345,18 @@ private void SLLogicalNotOperation_SLLogicalNotOperation_execute__generic1_(Virt { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLLogicalNotOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + if (SLLogicalNot_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNotOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLLogicalNot_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3739,31 +3403,31 @@ private void SLLogicalNotOperation_executeAndSpecialize_(VirtualFrame $frame, in } } - private void SLMulOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLMul_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLMulOperation_SLMulOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLMul_SLMul_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLMulOperation_SLMulOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLMul_SLMul_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLMul_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; @@ -3785,12 +3449,12 @@ private void SLMulOperation_SLMulOperation_execute__long_long0_(VirtualFrame $fr } finally { lock.unlock(); } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } - private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { @@ -3815,7 +3479,7 @@ private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $fram } finally { lock.unlock(); } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); return; } } @@ -3832,18 +3496,18 @@ private void SLMulOperation_SLMulOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLMulOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + if (SLMul_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLMul_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3885,7 +3549,7 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } finally { lock.unlock(); } - SLMulOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } @@ -3940,14 +3604,14 @@ private void SLMulOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } @ExplodeLoop - private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); while (s0_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value_))) { Node node__ = (this); @@ -3965,7 +3629,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int { InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); + $frame.setObject($sp - 2, this.SLReadProperty_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; } } @@ -3977,7 +3641,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); while (s2_ != null) { if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value__))) { Node node__1 = (this); @@ -3989,13 +3653,13 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int } } if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); + $frame.setObject($sp - 2, this.SLReadProperty_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); return; } } if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); while (s4_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value_))) { Node node__2 = (this); @@ -4013,7 +3677,7 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); if ((readObject1_objects__.hasMembers($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadPropertyOperation_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); + $frame.setObject($sp - 2, this.SLReadProperty_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); return; } } @@ -4024,13 +3688,13 @@ private void SLReadPropertyOperation_execute_(VirtualFrame $frame, int $bci, int } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLReadProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } @SuppressWarnings("static-method") @TruffleBoundary - private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + private Object SLReadProperty_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { { Node readArray1_node__ = (this); int readArray1_bci__ = ($bci); @@ -4042,7 +3706,7 @@ private Object SLReadPropertyOperation_readArray1Boundary_(int $bci, int $sp, by @SuppressWarnings("static-method") @TruffleBoundary - private Object SLReadPropertyOperation_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { + private Object SLReadProperty_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { { Node readSLObject1_node__ = (this); int readSLObject1_bci__ = ($bci); @@ -4053,7 +3717,7 @@ private Object SLReadPropertyOperation_readSLObject1Boundary_(int $bci, int $sp, @SuppressWarnings("static-method") @TruffleBoundary - private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + private Object SLReadProperty_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { { Node readObject1_node__ = (this); int readObject1_bci__ = ($bci); @@ -4062,7 +3726,7 @@ private Object SLReadPropertyOperation_readObject1Boundary_(int $bci, int $sp, b } } - private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4074,7 +3738,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node node__ = null; if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLReadPropertyOperation_ReadArray0Data s0_ = ((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value))) { @@ -4092,7 +3756,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLReadPropertyOperation_ReadArray0Data(((SLReadPropertyOperation_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); + s0_ = super.insert(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); node__ = (this); bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); @@ -4100,7 +3764,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4137,7 +3800,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4162,7 +3824,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node node__1 = null; if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_))) { @@ -4177,7 +3839,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if (s2_ == null) { // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_)); if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLReadPropertyOperation_ReadSLObject0Data(((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); + s2_ = super.insert(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); node__1 = (this); bci__1 = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); @@ -4185,11 +3847,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); - } int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4218,7 +3875,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4236,7 +3892,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node node__2 = null; if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLReadPropertyOperation_ReadObject0Data s4_ = ((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value))) { @@ -4253,7 +3909,7 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = super.insert(new SLReadPropertyOperation_ReadObject0Data(((SLReadPropertyOperation_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); + s4_ = super.insert(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); node__2 = (this); bci__2 = ($bci); children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); @@ -4261,7 +3917,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4297,7 +3952,6 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_OPERATION); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4323,31 +3977,31 @@ private void SLReadPropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } } - private void SLSubOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLSub_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLSubOperation_SLSubOperation_execute__long_long0_($frame, $bci, $sp, state_0); + SLSub_SLSub_execute__long_long0_($frame, $bci, $sp, state_0); return; } else { - SLSubOperation_SLSubOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLSub_SLSub_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); } catch (UnexpectedResultException ex) { Object $child1Value = expectObject($frame, $sp - 1); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + SLSub_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); return; } long $child1Value_; try { $child1Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; @@ -4369,12 +4023,12 @@ private void SLSubOperation_SLSubOperation_execute__long_long0_(VirtualFrame $fr } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } - private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { @@ -4399,7 +4053,7 @@ private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $fram } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); + SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); return; } } @@ -4416,18 +4070,18 @@ private void SLSubOperation_SLSubOperation_execute__generic1_(VirtualFrame $fram { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLSubOperation_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { + if (SLSub_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } - private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private void SLSub_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4469,7 +4123,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } finally { lock.unlock(); } - SLSubOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); return; } } @@ -4524,7 +4178,7 @@ private void SLSubOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, } @ExplodeLoop - private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 5 + 0]; Object $child0Value_ = expectObject($frame, $sp - 3); Object $child1Value_ = expectObject($frame, $sp - 2); @@ -4532,7 +4186,7 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); while (s0_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value_))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); @@ -4548,7 +4202,7 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in { InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + $frame.setObject($sp - 3, this.SLWriteProperty_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); return; } } @@ -4560,7 +4214,7 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); while (s2_ != null) { if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value__))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); @@ -4570,13 +4224,13 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in } } if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); + $frame.setObject($sp - 3, this.SLWriteProperty_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); return; } } if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); while (s4_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { Node node__ = (this); @@ -4589,20 +4243,20 @@ private void SLWritePropertyOperation_execute_(VirtualFrame $frame, int $bci, in } if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - $frame.setObject($sp - 3, this.SLWritePropertyOperation_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); + $frame.setObject($sp - 3, this.SLWriteProperty_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); return; } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + SLWriteProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); return; } @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private Object SLWriteProperty_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { { InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); @@ -4612,7 +4266,7 @@ private Object SLWritePropertyOperation_writeArray1Boundary_(int $bci, int $sp, @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + private Object SLWriteProperty_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { { DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); @@ -4621,7 +4275,7 @@ private Object SLWritePropertyOperation_writeSLObject1Boundary_(int $bci, int $s @SuppressWarnings("static-method") @TruffleBoundary - private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private Object SLWriteProperty_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -4636,7 +4290,7 @@ private Object SLWritePropertyOperation_writeObject1Boundary_(int $bci, int $sp, } } - private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { + private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4645,7 +4299,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, byte exclude = bc[$bci + 5 + 5]; if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLWritePropertyOperation_WriteArray0Data s0_ = ((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value))) { @@ -4661,7 +4315,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLWritePropertyOperation_WriteArray0Data(((SLWritePropertyOperation_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + s0_ = super.insert(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); @@ -4669,7 +4323,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4706,7 +4359,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4731,7 +4383,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, SLObject $child0Value_ = (SLObject) $child0Value; if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_))) { @@ -4744,17 +4396,12 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if (s2_ == null) { // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLWritePropertyOperation_WriteSLObject0Data(((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); + s2_ = super.insert(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); - } int type0; int type1; int type2; @@ -4781,7 +4428,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4802,7 +4448,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, Node node__ = null; if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLWritePropertyOperation_WriteObject0Data s4_ = ((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { @@ -4817,7 +4463,7 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, if (s4_ == null) { if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)); - s4_ = super.insert(new SLWritePropertyOperation_WriteObject0Data(((SLWritePropertyOperation_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); + s4_ = super.insert(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); node__ = (this); bci__ = ($bci); children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); @@ -4825,7 +4471,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4862,7 +4507,6 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_OPERATION); int type0; int type1; int type2; @@ -4890,27 +4534,27 @@ private void SLWritePropertyOperation_executeAndSpecialize_(VirtualFrame $frame, } } - private void SLUnboxOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLUnbox_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; byte state_1 = bc[$bci + 3 + 1]; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_SLUnboxOperation_execute__boolean0_($frame, $bci, $sp, state_0, state_1); + SLUnbox_SLUnbox_execute__boolean0_($frame, $bci, $sp, state_0, state_1); return; } else if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_SLUnboxOperation_execute__long1_($frame, $bci, $sp, state_0, state_1); + SLUnbox_SLUnbox_execute__long1_($frame, $bci, $sp, state_0, state_1); return; } else { - SLUnboxOperation_SLUnboxOperation_execute__generic2_($frame, $bci, $sp, state_0, state_1); + SLUnbox_SLUnbox_execute__generic2_($frame, $bci, $sp, state_0, state_1); return; } } - private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); @@ -4923,12 +4567,12 @@ private void SLUnboxOperation_SLUnboxOperation_execute__boolean0_(VirtualFrame $ return; } - private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); @@ -4943,7 +4587,7 @@ private void SLUnboxOperation_SLUnboxOperation_execute__long1_(VirtualFrame $fra @SuppressWarnings("static-method") @TruffleBoundary - private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { + private Object SLUnbox_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -4957,7 +4601,7 @@ private Object SLUnboxOperation_fromForeign1Boundary_(int $bci, int $sp, byte st } @ExplodeLoop - private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + private void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { Object $child0Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { String $child0Value__ = (String) $child0Value_; @@ -5006,7 +4650,7 @@ private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $ } if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); while (s7_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value_))) { $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); @@ -5016,16 +4660,16 @@ private void SLUnboxOperation_SLUnboxOperation_execute__generic2_(VirtualFrame $ } } if (((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - $frame.setObject($sp - 1, this.SLUnboxOperation_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); + $frame.setObject($sp - 1, this.SLUnbox_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); return; } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLUnbox_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5038,7 +4682,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5051,7 +4694,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc TruffleString $child0Value_ = (TruffleString) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5064,11 +4706,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } int type0; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_BOOLEAN; @@ -5090,11 +4727,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc long $child0Value_ = (long) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); - } int type0; if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_LONG; @@ -5119,7 +4751,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5133,7 +4764,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5146,7 +4776,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc SLNull $child0Value_ = SLTypes.asSLNull($child0Value); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5157,7 +4786,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { int count7_ = 0; - SLUnboxOperation_FromForeign0Data s7_ = ((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { while (s7_ != null) { if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value))) { @@ -5170,13 +4799,12 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc if (s7_ == null) { // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = super.insert(new SLUnboxOperation_FromForeign0Data(((SLUnboxOperation_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); + s7_ = super.insert(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5201,7 +4829,6 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5221,7 +4848,7 @@ private void SLUnboxOperation_executeAndSpecialize_(VirtualFrame $frame, int $bc } } - private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLFunctionLiteral_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { @@ -5233,11 +4860,11 @@ private void SLFunctionLiteralOperation_execute_(VirtualFrame $frame, int $bci, } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLFunctionLiteral_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5250,11 +4877,6 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_OPERATION); - } int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5272,23 +4894,23 @@ private void SLFunctionLiteralOperation_executeAndSpecialize_(VirtualFrame $fram } } - private void SLToBooleanOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { + private void SLToBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_($frame, $bci, $sp, state_0); + SLToBoolean_SLToBoolean_execute__boolean0_($frame, $bci, $sp, state_0); return; } else { - SLToBooleanOperation_SLToBooleanOperation_execute__generic1_($frame, $bci, $sp, state_0); + SLToBoolean_SLToBoolean_execute__generic1_($frame, $bci, $sp, state_0); return; } } - private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); } catch (UnexpectedResultException ex) { - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; @@ -5301,7 +4923,7 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__boolean0_(Virtua return; } - private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -5317,7 +4939,7 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(Virtua { Node fallback_node__ = (this); int fallback_bci__ = ($bci); - if (SLToBooleanOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + if (SLToBoolean_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); @@ -5329,11 +4951,11 @@ private void SLToBooleanOperation_SLToBooleanOperation_execute__generic1_(Virtua } } CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); return; } - private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5342,11 +4964,6 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); - } int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = FRAME_TYPE_BOOLEAN; @@ -5370,7 +4987,6 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_OPERATION); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5391,101 +5007,43 @@ private void SLToBooleanOperation_executeAndSpecialize_(VirtualFrame $frame, int } } - private void SLEvalRootOperation_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value_ instanceof Map) { - Map $child0Value__ = (Map) $child0Value_; - { - Node execute_node__ = (this); - $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value__, execute_node__)); - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 fallback(Object) */) { - if (SLEvalRootOperation_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value_)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEvalRootOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLEvalRootOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - { - Node execute_node__ = null; - if ($child0Value instanceof Map) { - Map $child0Value_ = (Map) $child0Value; - execute_node__ = (this); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doExecute(VirtualFrame, Map, Node) */); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLEvalRootOperation.doExecute($frame, $child0Value_, execute_node__)); - return; - } - } - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fallback(Object) */); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLEvalRootOperation.fallback($child0Value)); - return; - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - @ExplodeLoop - private Object SLInvokeOperation_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { byte state_0 = bc[$bci + 5 + 0]; if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); while (s0_ != null) { if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvokeOperation_removeDirect__($frame, $bci, $sp, s0_); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + SLInvoke_removeDirect__($frame, $bci, $sp, s0_); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); } if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); } s0_ = s0_.next_; } } if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); } } if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { { Node interop_node__ = (this); int interop_bci__ = ($bci); - return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); } - private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5496,7 +5054,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int SLFunction arg0Value_ = (SLFunction) arg0Value; if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { int count0_ = 0; - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { while (s0_ != null) { if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2])) && Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { @@ -5514,18 +5072,13 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int Assumption assumption0 = (callTargetStable__); if (Assumption.isValidAssumption(assumption0)) { if (count0_ < (3)) { - s0_ = super.insert(new SLInvokeOperation_DirectData(((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); + s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION_Q_DIRECT); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); - } } } } @@ -5534,7 +5087,7 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int if (s0_ != null) { lock.unlock(); hasLock = false; - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); } } children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = super.insert((IndirectCallNode.create())); @@ -5542,10 +5095,9 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; - return SLInvokeOperation.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); } { int interop_bci__ = 0; @@ -5554,10 +5106,9 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_OPERATION); lock.unlock(); hasLock = false; - return SLInvokeOperation.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); } } finally { if (hasLock) { @@ -5566,12 +5117,12 @@ private Object SLInvokeOperation_executeAndSpecialize_(VirtualFrame $frame, int } } - private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { Lock lock = getLock(); lock.lock(); try { - SLInvokeOperation_DirectData prev = null; - SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); while (cur != null) { if (cur == s0_) { if (prev == null) { @@ -5592,351 +5143,75 @@ private void SLInvokeOperation_removeDirect__(VirtualFrame $frame, int $bci, int } } - private void SLUnboxOperation_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - private void SLAddOperation_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAddOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - @ExplodeLoop - private void SLReadPropertyOperation_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadPropertyOperation_ReadSLObject0Data s2_ = ((SLReadPropertyOperation_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); - return; + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + int bci = 0; + while (bci < bc.length) { + switch (LE_BYTES.getShort(bc, bci)) { + case INSTR_POP : + { + bci = bci + 2; + break; } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadPropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLUnboxOperation_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnboxOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLToBooleanOperation_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLToBooleanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLessOrEqualOperation_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessOrEqualOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @ExplodeLoop - private Object SLInvokeOperation_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvokeOperation_DirectData s0_ = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvokeOperation_q_Direct_removeDirect__($frame, $bci, $sp, s0_); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + case INSTR_BRANCH : + case INSTR_THROW : + case INSTR_LOAD_CONSTANT_OBJECT : + case INSTR_LOAD_ARGUMENT_OBJECT : + case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_LOCAL_OBJECT : + case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_C_SLLOGICAL_NOT : + case INSTR_C_SLTO_BOOLEAN : + { + bci = bci + 4; + break; } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvokeOperation.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + case INSTR_BRANCH_FALSE : + { + bci = bci + 7; + break; } - s0_ = s0_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvokeOperation_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private void SLInvokeOperation_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { - Lock lock = getLock(); - lock.lock(); - try { - SLInvokeOperation_DirectData prev = null; - SLInvokeOperation_DirectData cur = ((SLInvokeOperation_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private void SLFunctionLiteralOperation_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteralOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - @ExplodeLoop - private void SLWritePropertyOperation_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 3); - Object $child1Value_ = expectObject($frame, $sp - 2); - Object $child2Value_ = expectObject($frame, $sp - 1); - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWritePropertyOperation_WriteSLObject0Data s2_ = ((SLWritePropertyOperation_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWritePropertyOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private void SLLessThanOperation_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessThanOperation_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - int bci = 0; - while (bci < bc.length) { - switch (LE_BYTES.getShort(bc, bci)) { - case INSTR_POP : - { - bci = bci + 2; - break; - } - case INSTR_BRANCH : - case INSTR_THROW : - case INSTR_LOAD_CONSTANT_OBJECT : - case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : - case INSTR_LOAD_ARGUMENT_BOOLEAN : - case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : - case INSTR_LOAD_LOCAL_BOOLEAN : - case INSTR_C_SLLOGICAL_NOT_OPERATION : - case INSTR_C_SLTO_BOOLEAN_OPERATION : - case INSTR_C_SLEVAL_ROOT_OPERATION : - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : - { - bci = bci + 4; - break; - } - case INSTR_BRANCH_FALSE : - { - bci = bci + 7; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); - bci = bci + 4; - break; - } - case INSTR_STORE_LOCAL : - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : - case INSTR_C_SLLESS_THAN_OPERATION : - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - bci = bci + 5; - break; - } - case INSTR_RETURN : - { - bci = bci + 3; - break; - } - case INSTR_C_SLADD_OPERATION : - case INSTR_C_SLEQUAL_OPERATION : - case INSTR_C_SLWRITE_PROPERTY_OPERATION : - case INSTR_C_SLINVOKE_OPERATION : - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - bci = bci + 11; - break; - } - case INSTR_C_SLDIV_OPERATION : - case INSTR_C_SLMUL_OPERATION : - case INSTR_C_SLSUB_OPERATION : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - bci = bci + 6; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION : - case INSTR_C_SLUNBOX_OPERATION : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : - { - bci = bci + 10; + case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); + bci = bci + 4; + break; + } + case INSTR_STORE_LOCAL : + case INSTR_C_SLLESS_OR_EQUAL : + case INSTR_C_SLLESS_THAN : + { + bci = bci + 5; + break; + } + case INSTR_RETURN : + { + bci = bci + 3; + break; + } + case INSTR_C_SLADD : + case INSTR_C_SLEQUAL : + case INSTR_C_SLWRITE_PROPERTY : + case INSTR_C_SLINVOKE : + { + bci = bci + 11; + break; + } + case INSTR_C_SLDIV : + case INSTR_C_SLMUL : + case INSTR_C_SLSUB : + case INSTR_C_SLFUNCTION_LITERAL : + { + bci = bci + 6; + break; + } + case INSTR_C_SLREAD_PROPERTY : + case INSTR_C_SLUNBOX : + { + bci = bci + 10; break; } } @@ -6340,7 +5615,7 @@ public String dump() { bci += 3; break; } - case INSTR_C_SLADD_OPERATION : + case INSTR_C_SLADD : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6358,7 +5633,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLAddOperation "); + sb.append("c.SLAdd "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6367,7 +5642,7 @@ public String dump() { bci += 11; break; } - case INSTR_C_SLDIV_OPERATION : + case INSTR_C_SLDIV : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6385,7 +5660,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLDivOperation "); + sb.append("c.SLDiv "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6394,7 +5669,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLEQUAL_OPERATION : + case INSTR_C_SLEQUAL : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6412,7 +5687,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLEqualOperation "); + sb.append("c.SLEqual "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6421,7 +5696,7 @@ public String dump() { bci += 11; break; } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION : + case INSTR_C_SLLESS_OR_EQUAL : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6439,7 +5714,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLessOrEqualOperation "); + sb.append("c.SLLessOrEqual "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6448,7 +5723,7 @@ public String dump() { bci += 5; break; } - case INSTR_C_SLLESS_THAN_OPERATION : + case INSTR_C_SLLESS_THAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6466,7 +5741,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLessThanOperation "); + sb.append("c.SLLessThan "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6475,7 +5750,7 @@ public String dump() { bci += 5; break; } - case INSTR_C_SLLOGICAL_NOT_OPERATION : + case INSTR_C_SLLOGICAL_NOT : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6493,14 +5768,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLLogicalNotOperation "); + sb.append("c.SLLogicalNot "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_C_SLMUL_OPERATION : + case INSTR_C_SLMUL : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6518,7 +5793,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLMulOperation "); + sb.append("c.SLMul "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6527,7 +5802,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLREAD_PROPERTY_OPERATION : + case INSTR_C_SLREAD_PROPERTY : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6545,7 +5820,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLReadPropertyOperation "); + sb.append("c.SLReadProperty "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6554,7 +5829,7 @@ public String dump() { bci += 10; break; } - case INSTR_C_SLSUB_OPERATION : + case INSTR_C_SLSUB : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6572,7 +5847,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLSubOperation "); + sb.append("c.SLSub "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6581,7 +5856,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLWRITE_PROPERTY_OPERATION : + case INSTR_C_SLWRITE_PROPERTY : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6599,7 +5874,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLWritePropertyOperation "); + sb.append("c.SLWriteProperty "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("pop[-%d]", bc[bci + 3])); @@ -6610,7 +5885,7 @@ public String dump() { bci += 11; break; } - case INSTR_C_SLUNBOX_OPERATION : + case INSTR_C_SLUNBOX : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6628,14 +5903,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLUnboxOperation "); + sb.append("c.SLUnbox "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 10; break; } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION : + case INSTR_C_SLFUNCTION_LITERAL : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6653,14 +5928,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLFunctionLiteralOperation "); + sb.append("c.SLFunctionLiteral "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 6; break; } - case INSTR_C_SLTO_BOOLEAN_OPERATION : + case INSTR_C_SLTO_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6678,39 +5953,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLToBooleanOperation "); + sb.append("c.SLToBoolean "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_C_SLEVAL_ROOT_OPERATION : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEvalRootOperation "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_C_SLINVOKE_OPERATION : + case INSTR_C_SLINVOKE : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6728,7 +5978,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLInvokeOperation "); + sb.append("c.SLInvoke "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); @@ -6737,270 +5987,6 @@ public String dump() { bci += 11; break; } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnboxOperation.q.FromLong "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLADD_OPERATION_Q_ADD_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAddOperation.q.AddLong "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLREAD_PROPERTY_OPERATION_Q_READ_SLOBJECT0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadPropertyOperation.q.ReadSLObject0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLUNBOX_OPERATION_Q_FROM_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnboxOperation.q.FromBoolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLTO_BOOLEAN_OPERATION_Q_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBooleanOperation.q.Boolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_C_SLLESS_OR_EQUAL_OPERATION_Q_LESS_OR_EQUAL0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqualOperation.q.LessOrEqual0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } - case INSTR_C_SLINVOKE_OPERATION_Q_DIRECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvokeOperation.q.Direct "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_OPERATION_Q_PERFORM : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteralOperation.q.Perform "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_OPERATION_Q_WRITE_SLOBJECT0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLWritePropertyOperation.q.WriteSLObject0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLLESS_THAN_OPERATION_Q_LESS_THAN0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThanOperation.q.LessThan0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } } sb.append("\n"); } @@ -7010,7 +5996,7 @@ public String dump() { return sb.toString(); } - private static boolean SLAddOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -7020,106 +6006,68 @@ private static boolean SLAddOperation_fallbackGuard__(VirtualFrame $frame, int $ return true; } - private static boolean SLDivOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static boolean SLLessOrEqualOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static boolean SLLessThanOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static boolean SLLogicalNotOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } return true; } - private static boolean SLMulOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLSubOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static boolean SLToBooleanOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLEvalRootOperation_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doExecute(VirtualFrame, Map, Node) */ && $child0Value instanceof Map) { - return false; - } - return true; - } - - private static boolean SLAddOperation_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } return true; } - private static boolean SLToBooleanOperation_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } return true; } - private static boolean SLLessOrEqualOperation_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLessThanOperation_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { if (bciOffset != 0) { setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); } } - private static final class SLAddOperation_Add1Data extends Node { + private static final class SLAdd_Add1Data extends Node { @Child SLToTruffleStringNode toTruffleStringNodeLeft_; @Child SLToTruffleStringNode toTruffleStringNodeRight_; @Child ConcatNode concatNode_; - SLAddOperation_Add1Data() { + SLAdd_Add1Data() { } @Override @@ -7132,13 +6080,13 @@ T insertAccessor(T node) { } } - private static final class SLEqualOperation_Generic0Data extends Node { + private static final class SLEqual_Generic0Data extends Node { - @Child SLEqualOperation_Generic0Data next_; + @Child SLEqual_Generic0Data next_; @Child InteropLibrary leftInterop_; @Child InteropLibrary rightInterop_; - SLEqualOperation_Generic0Data(SLEqualOperation_Generic0Data next_) { + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { this.next_ = next_; } @@ -7152,13 +6100,13 @@ T insertAccessor(T node) { } } - private static final class SLReadPropertyOperation_ReadArray0Data extends Node { + private static final class SLReadProperty_ReadArray0Data extends Node { - @Child SLReadPropertyOperation_ReadArray0Data next_; + @Child SLReadProperty_ReadArray0Data next_; @Child InteropLibrary arrays_; @Child InteropLibrary numbers_; - SLReadPropertyOperation_ReadArray0Data(SLReadPropertyOperation_ReadArray0Data next_) { + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { this.next_ = next_; } @@ -7172,13 +6120,13 @@ T insertAccessor(T node) { } } - private static final class SLReadPropertyOperation_ReadSLObject0Data extends Node { + private static final class SLReadProperty_ReadSLObject0Data extends Node { - @Child SLReadPropertyOperation_ReadSLObject0Data next_; + @Child SLReadProperty_ReadSLObject0Data next_; @Child DynamicObjectLibrary objectLibrary_; @Child SLToTruffleStringNode toTruffleStringNode_; - SLReadPropertyOperation_ReadSLObject0Data(SLReadPropertyOperation_ReadSLObject0Data next_) { + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { this.next_ = next_; } @@ -7192,13 +6140,13 @@ T insertAccessor(T node) { } } - private static final class SLReadPropertyOperation_ReadObject0Data extends Node { + private static final class SLReadProperty_ReadObject0Data extends Node { - @Child SLReadPropertyOperation_ReadObject0Data next_; + @Child SLReadProperty_ReadObject0Data next_; @Child InteropLibrary objects_; @Child SLToMemberNode asMember_; - SLReadPropertyOperation_ReadObject0Data(SLReadPropertyOperation_ReadObject0Data next_) { + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { this.next_ = next_; } @@ -7212,15 +6160,15 @@ T insertAccessor(T node) { } } - private static final class SLWritePropertyOperation_WriteArray0Data extends Node { + private static final class SLWriteProperty_WriteArray0Data extends Node { - @Child SLWritePropertyOperation_WriteArray0Data next_; + @Child SLWriteProperty_WriteArray0Data next_; @Child Node node_; @CompilationFinal int bci_; @Child InteropLibrary arrays_; @Child InteropLibrary numbers_; - SLWritePropertyOperation_WriteArray0Data(SLWritePropertyOperation_WriteArray0Data next_) { + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { this.next_ = next_; } @@ -7234,13 +6182,13 @@ T insertAccessor(T node) { } } - private static final class SLWritePropertyOperation_WriteSLObject0Data extends Node { + private static final class SLWriteProperty_WriteSLObject0Data extends Node { - @Child SLWritePropertyOperation_WriteSLObject0Data next_; + @Child SLWriteProperty_WriteSLObject0Data next_; @Child DynamicObjectLibrary objectLibrary_; @Child SLToTruffleStringNode toTruffleStringNode_; - SLWritePropertyOperation_WriteSLObject0Data(SLWritePropertyOperation_WriteSLObject0Data next_) { + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { this.next_ = next_; } @@ -7254,13 +6202,13 @@ T insertAccessor(T node) { } } - private static final class SLWritePropertyOperation_WriteObject0Data extends Node { + private static final class SLWriteProperty_WriteObject0Data extends Node { - @Child SLWritePropertyOperation_WriteObject0Data next_; + @Child SLWriteProperty_WriteObject0Data next_; @Child InteropLibrary objectLibrary_; @Child SLToMemberNode asMember_; - SLWritePropertyOperation_WriteObject0Data(SLWritePropertyOperation_WriteObject0Data next_) { + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { this.next_ = next_; } @@ -7274,12 +6222,12 @@ T insertAccessor(T node) { } } - private static final class SLUnboxOperation_FromForeign0Data extends Node { + private static final class SLUnbox_FromForeign0Data extends Node { - @Child SLUnboxOperation_FromForeign0Data next_; + @Child SLUnbox_FromForeign0Data next_; @Child InteropLibrary interop_; - SLUnboxOperation_FromForeign0Data(SLUnboxOperation_FromForeign0Data next_) { + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { this.next_ = next_; } @@ -7294,14 +6242,14 @@ T insertAccessor(T node) { } @GeneratedBy(SLOperations.class) - private static final class SLInvokeOperation_DirectData extends Node { + private static final class SLInvoke_DirectData extends Node { - @Child SLInvokeOperation_DirectData next_; + @Child SLInvoke_DirectData next_; @CompilationFinal Assumption callTargetStable_; @CompilationFinal RootCallTarget cachedTarget_; @Child DirectCallNode callNode_; - SLInvokeOperation_DirectData(SLInvokeOperation_DirectData next_) { + SLInvoke_DirectData(SLInvoke_DirectData next_) { this.next_ = next_; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java index baa20cb90e79..af09ea5df519 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation; +import java.util.Objects; import java.util.function.Function; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -9,7 +10,7 @@ public class MetadataKey { @CompilationFinal private Function getter; public MetadataKey(T defaultValue) { - this.defaultValue = defaultValue; + this.defaultValue = Objects.requireNonNull(defaultValue); } void setGetter(Function getter) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java index ad2cee11f662..35184aafb4c1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation; +import java.beans.JavaBean; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; @@ -11,4 +12,6 @@ @Repeatable(OperationProxies.class) public @interface OperationProxy { Class value(); + + String operationName() default ""; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 63b3f0346b4e..2df47fdfc75e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -107,7 +107,7 @@ public static OperationDecisions deserialize(JSONArray o, MessageContainer messa decisions.quicken.add(q); break; default: - messager.addError("Invalid optimization decision: '%s'", decision.getString("type")); + messager.addWarning("Invalid optimization decision: '%s'", decision.getString("type")); break; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 411767b933e9..85ed5f7c6db1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -166,7 +166,7 @@ public void processDecisions(OperationDecisions decisions) { CustomInstruction cinstr = customInstructionNameMap.get(quicken.getOperation()); if (cinstr == null) { // TODO line number or sth - data.addError("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); + data.addWarning("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); continue; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index cbb9e75b5f34..786868ec30f6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; @@ -25,6 +26,7 @@ import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.tools.utils.json.JSONArray; @@ -103,25 +105,20 @@ protected OperationsData parse(Element element, List mirror) { List opProxies = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.OperationProxy); for (AnnotationMirror mir : opProxies) { - DeclaredType tgtType = (DeclaredType) ElementUtils.getAnnotationValue(mir, "value").getValue(); - - SingleOperationData opData = new SingleOperationParser(data, (TypeElement) tgtType.asElement()).parse(null, null); + SingleOperationData opData = new SingleOperationParser(data, mir).parse(null, null); if (opData != null) { data.addOperationData(opData); } else { - data.addError("Could not generate operation: " + tgtType.asElement().getSimpleName()); + data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Could not proxy operation"); } } - boolean hasSome = false; for (TypeElement inner : operationTypes) { if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { continue; } - hasSome = true; - SingleOperationData opData = new SingleOperationParser(data).parse(inner, false); if (opData != null) { @@ -133,8 +130,11 @@ protected OperationsData parse(Element element, List mirror) { opData.redirectMessagesOnGeneratedElements(data); } - if (!hasSome) { + if (opProxies.isEmpty() && operationTypes.isEmpty()) { data.addWarning("No operations found"); + } + + if (data.hasErrors()) { return data; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 65c9603e66dc..f52e9fec749a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -94,10 +94,10 @@ public String toString() { } } - public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent) { + public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent, String name) { super(context, templateType, annotation); this.parent = parent; - name = templateType.getSimpleName().toString(); + this.name = name; } @Override @@ -133,4 +133,12 @@ void setNodeData(NodeData data) { this.nodeData = data; } + @Override + protected List findChildContainers() { + if (nodeData == null) { + return List.of(); + } + return List.of(nodeData); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index cdd952d39f0d..aeffc4b92fe2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -1,10 +1,13 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -14,13 +17,10 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; -import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; @@ -37,7 +37,9 @@ public class SingleOperationParser extends AbstractParser { private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private final OperationsData parentData; - private TypeElement proxyType; + private final AnnotationMirror proxyMirror; + + private final String NODE = "Node"; private Set OPERATION_PROXY_IGNORED_ANNOTATIONS = Set.of( types.GenerateOperations, @@ -46,71 +48,97 @@ public class SingleOperationParser extends AbstractParser { types.Operation); public SingleOperationParser(OperationsData parentData) { - this.parentData = parentData; + this(parentData, null); } - public SingleOperationParser(OperationsData parentData, TypeElement proxyType) { + public SingleOperationParser(OperationsData parentData, AnnotationMirror proxyMirror) { this.parentData = parentData; - this.proxyType = proxyType; + this.proxyMirror = proxyMirror; } @Override protected SingleOperationData parse(Element element, List mirror) { - if (element != null && !(element instanceof TypeElement)) { - parentData.addError(element, "@Operation can only be attached to a type"); - return null; - } - TypeElement te = (TypeElement) element; + TypeElement te; + String name; - if (proxyType != null) { - String name = proxyType.getSimpleName().toString(); - if (name.endsWith("Node")) { - name = name.substring(0, name.length() - 4); + if (element == null) { + if (proxyMirror == null) { + throw new AssertionError(); } - name += "Operation"; - CodeTypeElement tgt = new CodeTypeElement(MOD_PUBLIC_STATIC, ElementKind.CLASS, null, name); - tgt.setEnclosingElement(proxyType.getEnclosingElement()); - for (AnnotationMirror mir : parentData.getMessageElement().getAnnotationMirrors()) { - if (!OPERATION_PROXY_IGNORED_ANNOTATIONS.contains(mir.getAnnotationType())) { - tgt.addAnnotationMirror(mir); + AnnotationValue proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "value"); + TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); + if (proxyType.getKind() != TypeKind.DECLARED) { + parentData.addError(proxyMirror, proxyTypeValue, "@OperationProxy'ed type must be a class, not %s", proxyType); + } + + te = context.getTypeElement((DeclaredType) proxyType); + + AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "name", false); + + if (nameFromAnnot == null) { + String nameFromType = te.getSimpleName().toString(); + // strip the `Node' suffix + if (nameFromType.endsWith(NODE)) { + name = nameFromType.substring(0, nameFromType.length() - NODE.length()); + } else { + name = nameFromType; } + } else { + name = (String) nameFromAnnot.getValue(); + } + + } else { + if (proxyMirror != null) { + throw new AssertionError(); } - te = tgt; + + if (!(element instanceof TypeElement)) { + parentData.addError(element, "@Operation can only be attached to a type"); + return null; + } + + te = (TypeElement) element; + name = te.getSimpleName().toString(); } - SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(te.getAnnotationMirrors(), getAnnotationType()), parentData); + SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(te.getAnnotationMirrors(), getAnnotationType()), parentData, name); List operationFunctions = new ArrayList<>(); - if (proxyType == null) { + + if (proxyMirror == null) { + // @Operation annotated type + + if (!te.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { + data.addError("@Operation annotated class must be declared static and final"); + } + + if (te.getModifiers().contains(Modifier.PRIVATE)) { + data.addError("@Operation annotated class must not be declared private"); + } + for (Element el : te.getEnclosedElements()) { if (el.getModifiers().contains(Modifier.PRIVATE)) { + // ignore everything private continue; } + if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { - data.addError(el, "Operations must not contain non-static members"); - } - if (el instanceof ExecutableElement) { - ExecutableElement cel = (ExecutableElement) el; - if (isOperationFunction(cel)) { - operationFunctions.add(cel); - } + data.addError(el, "@Operation annotated class must not contain non-static members"); } + + operationFunctions.addAll(findSpecializations(te.getEnclosedElements())); } } else { - CodeTypeElement teClone = te instanceof CodeTypeElement ? (CodeTypeElement) te : CodeTypeElement.cloneShallow(te); - te = teClone; - - for (Element el : CompilerFactory.getCompiler(proxyType).getEnclosedElementsInDeclarationOrder(proxyType)) { - if (el.getKind() == ElementKind.METHOD && isStaticAccessible(el)) { - CodeExecutableElement cel = CodeExecutableElement.clone((ExecutableElement) el); - cel.setEnclosingElement(el.getEnclosingElement()); - teClone.add(cel); - if (isOperationFunction(cel)) { - operationFunctions.add(cel); - } + // proxied node + + for (ExecutableElement cel : findSpecializations(te.getEnclosedElements())) { + if (!cel.getModifiers().contains(Modifier.STATIC)) { + data.addError(cel, "@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); } + + operationFunctions.add(cel); } } @@ -134,56 +162,64 @@ protected SingleOperationData parse(Element element, List mirr data.setMainProperties(props); - CodeTypeElement clonedType; - if (te instanceof CodeTypeElement) { - clonedType = (CodeTypeElement) te; - } else { - clonedType = CodeTypeElement.cloneShallow(te); + CodeTypeElement clonedType = cloneTypeHierarchy(te, ct -> { + // remove NodeChild annotations + ct.getAnnotationMirrors().removeIf(m -> m.getAnnotationType().equals(types.NodeChild) || m.getAnnotationType().equals(types.NodeChildren)); - clonedType.getEnclosedElements().clear(); - for (Element e : CompilerFactory.getCompiler(te).getEnclosedElementsInDeclarationOrder(te)) { - if (e.getModifiers().contains(Modifier.PRIVATE) || !e.getModifiers().contains(Modifier.STATIC)) { - continue; - } + // remove all non-static or private elements + // this includes all the execute methods + ct.getEnclosedElements().removeIf(e -> !e.getModifiers().contains(Modifier.STATIC) || e.getModifiers().contains(Modifier.PRIVATE)); - CodeElement ce; - if (e.getKind() == ElementKind.METHOD) { - ce = CodeExecutableElement.clone((ExecutableElement) e); - } else if (e.getKind() == ElementKind.FIELD) { - ce = CodeVariableElement.clone((VariableElement) e); - } else { - throw new UnsupportedOperationException("unknown enclosed kind: " + e.getKind()); - } - - ce.setEnclosingElement(e.getEnclosingElement()); - clonedType.add(ce); + if (!isVariadic) { + addBoxingEliminationNodeChildAnnotations(props, ct); } + + }); + + if (ElementUtils.isObject(clonedType.getSuperclass()) && proxyMirror == null) { + clonedType.setSuperClass(types.Node); } - clonedType.setEnclosingElement(te.getEnclosingElement()); - // clonedType.setSuperClass(new DeclaredCodeTypeMirror(createRegularNodeChild())); - clonedType.setSuperClass(types.Node); - // clonedType.setSuperClass(new DeclaredCodeTypeMirror(childType)); + clonedType.add(createExecuteMethod(props, isVariadic)); - if (!isVariadic) { - int i = 0; - CodeTypeElement childType = createRegularNodeChild(); - CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); - List anns = new ArrayList<>(); - for (ParameterKind param : props.parameters) { - if (param == ParameterKind.STACK_VALUE) { - CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); - // CodeTypeElement childType = createRegularNodeChild(); - ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); - anns.add(new CodeAnnotationValue(ann)); - i++; - } + NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); + + if (nodeData == null) { + data.addError("Could not parse invalid node: " + te.getSimpleName()); + return data; + } + + // replace the default node type system with Operations one if we have it + if (nodeData.getTypeSystem().isDefault() && parentData.getTypeSystem() != null) { + nodeData.setTypeSystem(parentData.getTypeSystem()); + } + + nodeData.redirectMessagesOnGeneratedElements(data); + data.setNodeData(nodeData); + + return data; + } + + private void addBoxingEliminationNodeChildAnnotations(MethodProperties props, CodeTypeElement ct) { + int i = 0; + CodeTypeElement childType = createRegularNodeChild(); + CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); + List anns = new ArrayList<>(); + for (ParameterKind param : props.parameters) { + if (param == ParameterKind.STACK_VALUE) { + CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); + // CodeTypeElement childType = createRegularNodeChild(); + ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); + anns.add(new CodeAnnotationValue(ann)); + i++; } - repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); - clonedType.addAnnotationMirror(repAnnotation); } + repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); + ct.addAnnotationMirror(repAnnotation); + } + private CodeExecutableElement createExecuteMethod(MethodProperties props, boolean isVariadic) { CodeExecutableElement metExecute = new CodeExecutableElement( Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), context.getType(props.returnsValue ? Object.class : void.class), "execute"); @@ -201,41 +237,7 @@ protected SingleOperationData parse(Element element, List mirr i++; } } - - clonedType.add(metExecute); - - if (proxyType != null) { - // add all the constants - for (VariableElement el : ElementFilter.fieldsIn(proxyType.getEnclosedElements())) { - if (el.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { - // CodeVariableElement cel = new CodeVariableElement(MOD_STATIC_FINAL, - // el.asType(), el.getSimpleName().toString()); - // cel.createInitBuilder().staticReference(el); - // clonedType.add(cel); - clonedType.add(el); - } - } - - clonedType.setSimpleName(proxyType.getSimpleName()); - clonedType.setEnclosingElement(proxyType.getEnclosingElement()); - } - - NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); - - if (nodeData == null) { - data.addError(te, "Could not parse invalid node"); - return data; - } - - // replace the default node type system with Operations one if we have it - if (nodeData.getTypeSystem().isDefault() && parentData.getTypeSystem() != null) { - nodeData.setTypeSystem(parentData.getTypeSystem()); - } - - nodeData.redirectMessagesOnGeneratedElements(data); - data.setNodeData(nodeData); - - return data; + return metExecute; } @Override @@ -323,8 +325,26 @@ private static boolean isStaticAccessible(Element elem) { return !elem.getModifiers().contains(Modifier.PRIVATE) && elem.getModifiers().contains(Modifier.STATIC); } - private boolean isOperationFunction(ExecutableElement el) { + private boolean isSpecializationFunction(ExecutableElement el) { return ElementUtils.findAnnotationMirror(el, types.Specialization) != null; } + private CodeTypeElement cloneTypeHierarchy(TypeElement element, Consumer mapper) { + CodeTypeElement result = CodeTypeElement.cloneShallow(element); + if (!ElementUtils.isObject(element.getSuperclass())) { + result.setSuperClass(cloneTypeHierarchy(context.getTypeElement((DeclaredType) element.getSuperclass()), mapper).asType()); + } + + mapper.accept(result); + + return result; + } + + private List findSpecializations(Collection elements) { + return elements.stream() // + .filter(x -> x instanceof ExecutableElement) // + .map(x -> (ExecutableElement) x) // + .filter(this::isSpecializationFunction) // + .toList(); + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index b0ac7c2326b1..e48fed0de4c9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,15 +1,11 @@ package com.oracle.truffle.sl.operations; -import java.util.Map; - import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -19,11 +15,11 @@ import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.GenerateOperations.Metadata; +import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; -import com.oracle.truffle.api.operation.GenerateOperations.Metadata; -import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; @@ -39,9 +35,7 @@ import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.runtime.SLContext; import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @@ -65,36 +59,11 @@ public final class SLOperations { @Metadata("MethodName") // - public static final MetadataKey METHOD_NAME = new MetadataKey<>(""); - - @Operation - public static class SLEvalRootOperation { - - @Specialization - public static Object doExecute( - VirtualFrame frame, - Map functions, - @Bind("this") Node node) { - SLContext.get(node).getFunctionRegistry().register(functions); - - RootCallTarget main = functions.get(SLStrings.MAIN); - - if (main != null) { - return main.call(frame.getArguments()); - } else { - return SLNull.SINGLETON; - } - } - - @Fallback - public static Object fallback(Object functions) { - throw new RuntimeException("invalid functions: " + functions); - } - } + public static final MetadataKey METHOD_NAME = new MetadataKey<>(SLStrings.EMPTY_STRING); @Operation @TypeSystemReference(SLTypes.class) - public static class SLInvokeOperation { + public static final class SLInvoke { @Specialization(limit = "3", // guards = "function.getCallTarget() == cachedTarget", // assumptions = "callTargetStable") diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 2a0f90c8f5b6..5255440ebd45 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -136,6 +136,8 @@ public Void visitFunction(FunctionContext ctx) { assert scope == null; TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); + b.setMethodName(name); + b.beginSource(source); b.beginTag(StandardTags.RootTag.class); @@ -257,9 +259,9 @@ public Void visitWhile_statement(While_statementContext ctx) { b.emitLabel(continueLabel); b.beginWhile(); - b.beginSLToBooleanOperation(); + b.beginSLToBoolean(); visit(ctx.condition); - b.endSLToBooleanOperation(); + b.endSLToBoolean(); visit(ctx.body); b.endWhile(); @@ -280,18 +282,18 @@ public Void visitIf_statement(If_statementContext ctx) { if (ctx.alt == null) { b.beginIfThen(); - b.beginSLToBooleanOperation(); + b.beginSLToBoolean(); visit(ctx.condition); - b.endSLToBooleanOperation(); + b.endSLToBoolean(); visit(ctx.then); b.endIfThen(); } else { b.beginIfThenElse(); - b.beginSLToBooleanOperation(); + b.beginSLToBoolean(); visit(ctx.condition); - b.endSLToBooleanOperation(); + b.endSLToBoolean(); visit(ctx.then); @@ -340,9 +342,9 @@ private void logicalOrBegin(OperationLocal localIdx) { private void logicalOrMiddle(OperationLocal localIdx) { b.endStoreLocal(); b.beginConditional(); - b.beginSLToBooleanOperation(); + b.beginSLToBoolean(); b.emitLoadLocal(localIdx); - b.endSLToBooleanOperation(); + b.endSLToBoolean(); b.emitLoadLocal(localIdx); } @@ -402,9 +404,9 @@ private void logicalAndBegin(OperationLocal localIdx) { private void logicalAndMiddle(OperationLocal localIdx) { b.endStoreLocal(); b.beginConditional(); - b.beginSLToBooleanOperation(); + b.beginSLToBoolean(); b.emitLoadLocal(localIdx); - b.endSLToBooleanOperation(); + b.endSLToBoolean(); } private void logicalAndEnd(OperationLocal localIdx) { @@ -422,7 +424,7 @@ public Void visitLogic_term(Logic_termContext ctx) { } b.beginTag(StandardTags.ExpressionTag.class); - b.beginSLUnboxOperation(); + b.beginSLUnbox(); OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; for (int i = 0; i < numTerms - 1; i++) { @@ -442,7 +444,7 @@ public Void visitLogic_term(Logic_termContext ctx) { } } - b.endSLUnboxOperation(); + b.endSLUnbox(); b.endTag(); return null; @@ -455,54 +457,54 @@ public Void visitLogic_factor(Logic_factorContext ctx) { } b.beginTag(StandardTags.ExpressionTag.class); - b.beginSLUnboxOperation(); + b.beginSLUnbox(); switch (ctx.OP_COMPARE().getText()) { case "<": - b.beginSLLessThanOperation(); + b.beginSLLessThan(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLLessThanOperation(); + b.endSLLessThan(); break; case "<=": - b.beginSLLessOrEqualOperation(); + b.beginSLLessOrEqual(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLLessOrEqualOperation(); + b.endSLLessOrEqual(); break; case ">": - b.beginSLLogicalNotOperation(); - b.beginSLLessOrEqualOperation(); + b.beginSLLogicalNot(); + b.beginSLLessOrEqual(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLLessOrEqualOperation(); - b.endSLLogicalNotOperation(); + b.endSLLessOrEqual(); + b.endSLLogicalNot(); break; case ">=": - b.beginSLLogicalNotOperation(); - b.beginSLLessThanOperation(); + b.beginSLLogicalNot(); + b.beginSLLessThan(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLLessThanOperation(); - b.endSLLogicalNotOperation(); + b.endSLLessThan(); + b.endSLLogicalNot(); break; case "==": - b.beginSLEqualOperation(); + b.beginSLEqual(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLEqualOperation(); + b.endSLEqual(); break; case "!=": - b.beginSLLogicalNotOperation(); - b.beginSLEqualOperation(); + b.beginSLLogicalNot(); + b.beginSLEqual(); visit(ctx.arithmetic(0)); visit(ctx.arithmetic(1)); - b.endSLEqualOperation(); - b.endSLLogicalNotOperation(); + b.endSLEqual(); + b.endSLLogicalNot(); break; } - b.endSLUnboxOperation(); + b.endSLUnbox(); b.endTag(); return null; @@ -513,16 +515,16 @@ public Void visitArithmetic(ArithmeticContext ctx) { if (!ctx.OP_ADD().isEmpty()) { b.beginTag(StandardTags.ExpressionTag.class); - b.beginSLUnboxOperation(); + b.beginSLUnbox(); } for (int i = ctx.OP_ADD().size() - 1; i >= 0; i--) { switch (ctx.OP_ADD(i).getText()) { case "+": - b.beginSLAddOperation(); + b.beginSLAdd(); break; case "-": - b.beginSLSubOperation(); + b.beginSLSub(); break; } } @@ -534,16 +536,16 @@ public Void visitArithmetic(ArithmeticContext ctx) { switch (ctx.OP_ADD(i).getText()) { case "+": - b.endSLAddOperation(); + b.endSLAdd(); break; case "-": - b.endSLSubOperation(); + b.endSLSub(); break; } } if (!ctx.OP_ADD().isEmpty()) { - b.endSLUnboxOperation(); + b.endSLUnbox(); b.endTag(); } @@ -554,40 +556,40 @@ public Void visitArithmetic(ArithmeticContext ctx) { public Void visitTerm(TermContext ctx) { if (!ctx.OP_MUL().isEmpty()) { b.beginTag(StandardTags.ExpressionTag.class); - b.beginSLUnboxOperation(); + b.beginSLUnbox(); } for (int i = ctx.OP_MUL().size() - 1; i >= 0; i--) { switch (ctx.OP_MUL(i).getText()) { case "*": - b.beginSLMulOperation(); + b.beginSLMul(); break; case "/": - b.beginSLDivOperation(); + b.beginSLDiv(); break; } } - b.beginSLUnboxOperation(); + b.beginSLUnbox(); visit(ctx.factor(0)); - b.endSLUnboxOperation(); + b.endSLUnbox(); for (int i = 0; i < ctx.OP_MUL().size(); i++) { - b.beginSLUnboxOperation(); + b.beginSLUnbox(); visit(ctx.factor(i + 1)); - b.endSLUnboxOperation(); + b.endSLUnbox(); switch (ctx.OP_MUL(i).getText()) { case "*": - b.endSLMulOperation(); + b.endSLMul(); break; case "/": - b.endSLDivOperation(); + b.endSLDiv(); break; } } if (!ctx.OP_MUL().isEmpty()) { - b.endSLUnboxOperation(); + b.endSLUnbox(); b.endTag(); } @@ -606,9 +608,9 @@ private void buildMemberExpressionRead(Token ident, List Date: Wed, 11 May 2022 10:40:20 +0200 Subject: [PATCH 082/312] [wip] compile with opts --- .../sl/operations/SLOperationsBuilder.java | 979 +++++++++++++++++- .../test/example/BoxingOperationsTest.java | 19 +- .../test/example/TestOperations.java | 12 +- .../truffle/api/operation/OperationProxy.java | 1 - .../operations/OperationMetadataData.java | 1 - .../operations/OperationsCodeGenerator.java | 8 +- .../operations/OperationsParser.java | 2 - .../operations/SingleOperationParser.java | 11 - .../truffle/sl/operations/decisions.json | 20 +- 9 files changed, 972 insertions(+), 81 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 3ae1cc6e51c5..2cf43c56807c 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -282,19 +282,29 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLFUNCTION_LITERAL = 31; private static final int INSTR_C_SLTO_BOOLEAN = 32; private static final int INSTR_C_SLINVOKE = 33; + private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 34; + private static final int INSTR_C_SLADD_Q_ADD_LONG = 35; + private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 36; + private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 37; + private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 38; + private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 39; + private static final int INSTR_C_SLINVOKE_Q_DIRECT = 40; + private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 41; + private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 42; + private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 43; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (4 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (3 << 8) | 0x1), (short) (0x8000 | (5 << 8) | 0x1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // DOUBLE null}; @@ -1769,6 +1779,177 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Interop * Fallback * + * c.SLUnbox.q.FromLong + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLAdd.q.AddLong + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * AddLong + * Add0 + * Add1 + * Fallback + * + * c.SLReadProperty.q.ReadSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * ReadArray0 + * ReadArray1 + * ReadSLObject0 + * ReadSLObject1 + * ReadObject0 + * ReadObject1 + * Fallback + * + * c.SLUnbox.q.FromBoolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 BITS + * 2 BITS + * 3 CHILD + * 5 CONST + * Specializations: + * FromString + * FromTruffleString + * FromBoolean + * FromLong + * FromBigNumber + * FromFunction0 + * FromFunction1 + * FromForeign0 + * FromForeign1 + * Fallback + * + * c.SLToBoolean.q.Boolean + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * c.SLLessOrEqual.q.LessOrEqual0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessOrEqual0 + * LessOrEqual1 + * Fallback + * + * c.SLInvoke.q.Direct + * Inputs: + * STACK_VALUE + * VARARG_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * Direct + * Indirect + * Interop + * Fallback + * + * c.SLFunctionLiteral.q.Perform + * Inputs: + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * Specializations: + * Perform + * Fallback + * + * c.SLWriteProperty.q.WriteSLObject0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS + * Specializations: + * WriteArray0 + * WriteArray1 + * WriteSLObject0 + * WriteSLObject1 + * WriteObject0 + * WriteObject1 + * Fallback + * + * c.SLLessThan.q.LessThan0 + * Inputs: + * STACK_VALUE + * STACK_VALUE + * Results: + * STACK_VALUE + * Additional Data: + * 0 BITS + * Specializations: + * LessThan0 + * LessThan1 + * Fallback + * */ @GeneratedBy(SLOperations.class) @@ -2040,6 +2221,83 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 11; break; } + case INSTR_C_SLUNBOX_Q_FROM_LONG : + { + this.SLUnbox_q_FromLong_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLADD_Q_ADD_LONG : + { + this.SLAdd_q_AddLong_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : + { + this.SLReadProperty_q_ReadSLObject0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : + { + this.SLUnbox_q_FromBoolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : + { + this.SLToBoolean_q_Boolean_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { + this.SLLessOrEqual_q_LessOrEqual0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } + case INSTR_C_SLINVOKE_Q_DIRECT : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvoke_q_Direct_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : + { + this.SLFunctionLiteral_q_Perform_execute_(frame, bci, sp); + sp = sp - 1 + 1; + nextBci = bci + 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : + { + this.SLWriteProperty_q_WriteSLObject0_execute_(frame, bci, sp); + sp = sp - 3 + 1; + nextBci = bci + 11; + break; + } + case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : + { + this.SLLessThan_q_LessThan0_execute_(frame, bci, sp); + sp = sp - 2 + 1; + nextBci = bci + 5; + break; + } default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); @@ -2192,6 +2450,11 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); bc[$bci + 4 + 2] = (byte) (state_1); + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_Q_ADD_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); + } int type0; int type1; if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { @@ -2240,6 +2503,7 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2262,6 +2526,7 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -2280,6 +2545,7 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); bc[$bci + 4 + 2] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3060,6 +3326,11 @@ private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); + } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { @@ -3092,6 +3363,7 @@ private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3116,6 +3388,7 @@ private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3226,6 +3499,11 @@ private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_Q_LESS_THAN0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); + } int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { @@ -3258,6 +3536,7 @@ private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3282,6 +3561,7 @@ private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3764,6 +4044,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3800,6 +4081,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3847,6 +4129,11 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); + } int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3875,6 +4162,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3917,6 +4205,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -3952,6 +4241,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; int type1; type0 = FRAME_TYPE_OBJECT; @@ -4323,6 +4613,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; int type1; int type2; @@ -4359,6 +4650,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; int type1; int type2; @@ -4402,6 +4694,11 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); + } int type0; int type1; int type2; @@ -4428,6 +4725,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; int type1; int type2; @@ -4471,6 +4769,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; int type1; int type2; @@ -4507,6 +4806,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; int type1; int type2; @@ -4682,6 +4982,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4694,6 +4995,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s TruffleString $child0Value_ = (TruffleString) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4706,6 +5008,11 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_Q_FROM_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); + } int type0; if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_BOOLEAN; @@ -4727,6 +5034,11 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s long $child0Value_ = (long) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); bc[$bci + 3 + 1] = (byte) (state_1); + if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_Q_FROM_LONG); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); + } int type0; if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */) { type0 = FRAME_TYPE_LONG; @@ -4751,6 +5063,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4764,6 +5077,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s SLFunction $child0Value_ = (SLFunction) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4776,6 +5090,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s SLNull $child0Value_ = SLTypes.asSLNull($child0Value); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); bc[$bci + 3 + 1] = (byte) (state_1); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4805,6 +5120,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4829,6 +5145,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4877,6 +5194,11 @@ private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $b consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL); + } int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -4964,6 +5286,11 @@ private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, in if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN); + } int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = FRAME_TYPE_BOOLEAN; @@ -4987,6 +5314,7 @@ private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, in fallback_node__ = (this); fallback_bci__ = ($bci); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN); int type0; type0 = FRAME_TYPE_OBJECT; doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); @@ -5079,6 +5407,11 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int VarHandle.storeStoreFence(); consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_Q_DIRECT); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); + } } } } @@ -5095,6 +5428,7 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); lock.unlock(); hasLock = false; return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); @@ -5106,6 +5440,7 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); lock.unlock(); hasLock = false; return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); @@ -5143,30 +5478,296 @@ private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Obj } } - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - int bci = 0; - while (bci < bc.length) { - switch (LE_BYTES.getShort(bc, bci)) { - case INSTR_POP : - { - bci = bci + 2; - break; - } - case INSTR_BRANCH : - case INSTR_THROW : - case INSTR_LOAD_CONSTANT_OBJECT : - case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : - case INSTR_LOAD_ARGUMENT_BOOLEAN : - case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : - case INSTR_LOAD_LOCAL_BOOLEAN : - case INSTR_C_SLLOGICAL_NOT : - case INSTR_C_SLTO_BOOLEAN : - { - bci = bci + 4; - break; + private void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; + } + assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + private void SLAdd_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLAdd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; + } + assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + // implicit transferToInterpreterAndInvalidate() + Lock lock = getLock(); + lock.lock(); + try { + bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); + bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + } + + @ExplodeLoop + private void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { + Node node__ = (this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLReadProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); + return; + } + + private void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; + } + assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop + private Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + byte state_0 = bc[$bci + 5 + 0]; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_q_Direct_removeDirect__($frame, $bci, $sp, s0_); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + } + s0_ = s0_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); + } + + private void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + Lock lock = getLock(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 3 + 0]; + Object $child0Value_ = expectObject($frame, $sp - 1); + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = (this); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteral_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + return; + } + + @ExplodeLoop + private void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + Object $child0Value_ = expectObject($frame, $sp - 3); + Object $child1Value_ = expectObject($frame, $sp - 2); + Object $child2Value_ = expectObject($frame, $sp - 1); + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + while (s2_ != null) { + if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWriteProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); + return; + } + + private void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 4 + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + Object $child1Value = expectObject($frame, $sp - 1); + SLLessThan_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + int bci = 0; + while (bci < bc.length) { + switch (LE_BYTES.getShort(bc, bci)) { + case INSTR_POP : + { + bci = bci + 2; + break; + } + case INSTR_BRANCH : + case INSTR_THROW : + case INSTR_LOAD_CONSTANT_OBJECT : + case INSTR_LOAD_ARGUMENT_OBJECT : + case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_LOCAL_OBJECT : + case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_C_SLLOGICAL_NOT : + case INSTR_C_SLTO_BOOLEAN : + case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : + { + bci = bci + 4; + break; } case INSTR_BRANCH_FALSE : { @@ -5183,6 +5784,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_STORE_LOCAL : case INSTR_C_SLLESS_OR_EQUAL : case INSTR_C_SLLESS_THAN : + case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : { bci = bci + 5; break; @@ -5196,6 +5799,9 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLEQUAL : case INSTR_C_SLWRITE_PROPERTY : case INSTR_C_SLINVOKE : + case INSTR_C_SLADD_Q_ADD_LONG : + case INSTR_C_SLINVOKE_Q_DIRECT : + case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : { bci = bci + 11; break; @@ -5204,12 +5810,16 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLMUL : case INSTR_C_SLSUB : case INSTR_C_SLFUNCTION_LITERAL : + case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : { bci = bci + 6; break; } case INSTR_C_SLREAD_PROPERTY : case INSTR_C_SLUNBOX : + case INSTR_C_SLUNBOX_Q_FROM_LONG : + case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : + case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : { bci = bci + 10; break; @@ -5987,16 +6597,280 @@ public String dump() { bci += 11; break; } - } - sb.append("\n"); - } - for (int i = 0; i < handlers.length; i++) { - sb.append(handlers[i] + "\n"); - } - return sb.toString(); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + case INSTR_C_SLUNBOX_Q_FROM_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLADD_Q_ADD_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.AddLong "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty.q.ReadSLObject0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBoolean "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 10; + break; + } + case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean.q.Boolean "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } + case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + case INSTR_C_SLINVOKE_Q_DIRECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLInvoke.q.Direct "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral.q.Perform "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append("x"); + bci += 6; + break; + } + case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLWriteProperty.q.WriteSLObject0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 4])); + sb.append(" -> "); + sb.append("x"); + bci += 11; + break; + } + case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan0 "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("pop[-%d]", bc[bci + 3])); + sb.append(" -> "); + sb.append("x"); + bci += 5; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < handlers.length; i++) { + sb.append(handlers[i] + "\n"); + } + return sb.toString(); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -6055,6 +6929,37 @@ private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, int $bci return true; } + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { if (bciOffset != 0) { setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 6ff6948b36b2..c2a4f6b2e5db 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -268,13 +268,10 @@ static long castLong(ReferenceTypeB b) { @GenerateOperations(boxingEliminationTypes = {boolean.class, int.class, long.class}) @SuppressWarnings("unused") final class BoxingOperations { - public static void parse(BoxingLanguage lang, Consumer data, BoxingOperationsBuilder builder) { - data.accept(builder); - } @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class IntProducer { + public static final class IntProducer { @Specialization public static int produce() { return 1; @@ -283,7 +280,7 @@ public static int produce() { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class BooleanProducer { + public static final class BooleanProducer { @Specialization public static boolean produce() { return true; @@ -292,7 +289,7 @@ public static boolean produce() { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class RefAProducer { + public static final class RefAProducer { @Specialization public static ReferenceTypeA produce() { return new ReferenceTypeA(); @@ -301,7 +298,7 @@ public static ReferenceTypeA produce() { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class RefBProducer { + public static final class RefBProducer { @Specialization public static ReferenceTypeB produce() { return new ReferenceTypeB(); @@ -310,7 +307,7 @@ public static ReferenceTypeB produce() { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class ObjectProducer { + public static final class ObjectProducer { public static final short PRODUCE_INT = 0; public static final short PRODUCE_LONG = 1; @@ -342,7 +339,7 @@ public static Object produce(short type) { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class SpecializedObjectProducer { + public static final class SpecializedObjectProducer { public static final short PRODUCE_INT = 0; public static final short PRODUCE_LONG = 1; @@ -384,7 +381,7 @@ public static ReferenceTypeB produceRefB(short type) { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class LongOperator { + public static final class LongOperator { @Specialization public static long operate(long value) { return value; @@ -393,7 +390,7 @@ public static long operate(long value) { @Operation @TypeSystemReference(BoxingTypeSystem.class) - public static class StringOperator { + public static final class StringOperator { @Specialization public static String operate(String value) { return value; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index d38b3808848d..0161b29e9532 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -31,7 +31,7 @@ public TestException(String string, Node node, int bci) { @Operation @GenerateAOT - static class AddOperation { + static final class AddOperation { @Specialization public static long add(long lhs, long rhs) { return lhs + rhs; @@ -45,7 +45,7 @@ public static String addStrings(String lhs, String rhs) { @Operation @GenerateAOT - static class LessThanOperation { + static final class LessThanOperation { @Specialization public static boolean lessThan(long lhs, long rhs) { return lhs < rhs; @@ -54,7 +54,7 @@ public static boolean lessThan(long lhs, long rhs) { @Operation @GenerateAOT - static class VeryComplexOperation { + static final class VeryComplexOperation { @Specialization public static long bla(long a1, @Variadic Object[] a2) { return a1 + a2.length; @@ -63,7 +63,7 @@ public static long bla(long a1, @Variadic Object[] a2) { @Operation @GenerateAOT - static class ThrowOperation { + static final class ThrowOperation { @Specialization public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { throw new TestException("fail", node, bci); @@ -71,7 +71,7 @@ public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { } @Operation - static class AlwaysBoxOperation { + static final class AlwaysBoxOperation { @Specialization public static Object perform(Object value) { return value; @@ -79,7 +79,7 @@ public static Object perform(Object value) { } @Operation - static class AppenderOperation { + static final class AppenderOperation { @Specialization public static void perform(List list, Object value) { list.add(value); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java index 35184aafb4c1..80e558d5ab22 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java @@ -1,6 +1,5 @@ package com.oracle.truffle.api.operation; -import java.beans.JavaBean; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java index 88f638fa4287..161f0e97f772 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java @@ -2,7 +2,6 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index e183a8c2021e..78f5f085fc41 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -619,9 +619,13 @@ private CodeVariableElement createBoxingDescriptors() { case REPLACE: value = instr.boxingEliminationReplacement(kind).getName(); break; - case SET_BIT: - value = "(short) (0x8000 | (" + instr.boxingEliminationBitOffset() + " << 8) | 0x" + Integer.toHexString(instr.boxingEliminationBitMask()) + ")"; + case SET_BIT: { + int bitOffset = instr.boxingEliminationBitOffset(); + int bitMask = instr.boxingEliminationBitMask(); + short shortValue = (short) (0x8000 | (bitOffset << 8) | bitMask); + value = shortValue + " /* " + bitOffset + "," + Integer.toHexString(bitMask) + " */"; break; + } default: throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 786868ec30f6..1ce791ddc3b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.function.Consumer; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; @@ -26,7 +25,6 @@ import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.tools.utils.json.JSONArray; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index aeffc4b92fe2..83520e2a622c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -35,18 +35,11 @@ public class SingleOperationParser extends AbstractParser { - private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private final OperationsData parentData; private final AnnotationMirror proxyMirror; private final String NODE = "Node"; - private Set OPERATION_PROXY_IGNORED_ANNOTATIONS = Set.of( - types.GenerateOperations, - types.OperationProxy, - context.getDeclaredType("com.oracle.truffle.api.operation.OperationProxies"), - types.Operation); - public SingleOperationParser(OperationsData parentData) { this(parentData, null); } @@ -321,10 +314,6 @@ private boolean isVariadicParameter(VariableElement param) { return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; } - private static boolean isStaticAccessible(Element elem) { - return !elem.getModifiers().contains(Modifier.PRIVATE) && elem.getModifiers().contains(Modifier.STATIC); - } - private boolean isSpecializationFunction(ExecutableElement el) { return ElementUtils.findAnnotationMirror(el, types.Specialization) != null; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 01893ed689ad..c85ec019b894 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -5,51 +5,51 @@ { "specializations": ["FromLong"], "type": "Quicken", - "operation": "SLUnboxOperation" + "operation": "SLUnbox" }, { "specializations": ["AddLong"], "type": "Quicken", - "operation": "SLAddOperation" + "operation": "SLAdd" }, { "specializations": ["ReadSLObject0"], "type": "Quicken", - "operation": "SLReadPropertyOperation" + "operation": "SLReadProperty" }, { "specializations": ["FromBoolean"], "type": "Quicken", - "operation": "SLUnboxOperation" + "operation": "SLUnbox" }, { "specializations": ["Boolean"], "type": "Quicken", - "operation": "SLToBooleanOperation" + "operation": "SLToBoolean" }, { "specializations": ["LessOrEqual0"], "type": "Quicken", - "operation": "SLLessOrEqualOperation" + "operation": "SLLessOrEqual" }, { "specializations": ["Direct"], "type": "Quicken", - "operation": "SLInvokeOperation" + "operation": "SLInvoke" }, { "specializations": ["Perform"], "type": "Quicken", - "operation": "SLFunctionLiteralOperation" + "operation": "SLFunctionLiteral" }, { "specializations": ["WriteSLObject0"], "type": "Quicken", - "operation": "SLWritePropertyOperation" + "operation": "SLWriteProperty" }, { "specializations": ["LessThan0"], "type": "Quicken", - "operation": "SLLessThanOperation" + "operation": "SLLessThan" } ] \ No newline at end of file From 88d251eeb3bc53d4432f679642599ee058373dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 11 May 2022 13:08:17 +0200 Subject: [PATCH 083/312] [wip] sl parser refactor, name uniqueness --- .../api/operation/OperationConfig.java | 2 +- .../truffle/api/operation/OperationNodes.java | 14 +- .../operations/OperationsContext.java | 11 +- .../processor/operations/OperationsData.java | 1 + .../operations/SingleOperationData.java | 22 +++ .../operations/SingleOperationParser.java | 15 +- .../truffle/sl/parser/SLBaseVisitor.java | 150 +++++++++++++----- .../truffle/sl/parser/SLNodeVisitor.java | 44 ++--- .../sl/parser/SLOperationsVisitor.java | 139 +++++----------- 9 files changed, 227 insertions(+), 171 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java index 0dfd41ec0987..cd98378d65ae 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java @@ -1,6 +1,6 @@ package com.oracle.truffle.api.operation; -public class OperationConfig { +public final class OperationConfig { public static final OperationConfig DEFAULT = new OperationConfig(false, false); public static final OperationConfig WITH_SOURCE = new OperationConfig(true, false); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 7c0ed3d39881..015ecaae85a2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.function.Consumer; +import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.source.Source; @@ -52,23 +53,16 @@ public boolean updateConfiguration(OperationConfig config) { return false; } + CompilerDirectives.transferToInterpreterAndInvalidate(); reparse(config); - return true; } - /** - * Should look like: - * - *
-     * BuilderImpl builder = new BuilderImpl(this, true, config);
-     * parse.accept(builder);
-     * 
- */ - @SuppressWarnings({"rawtypes", "hiding"}) + @SuppressWarnings("hiding") protected abstract void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes); void reparse(OperationConfig config) { + CompilerAsserts.neverPartOfCompilation("parsing should never be compiled"); reparseImpl(config, parse, nodes); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 85ed5f7c6db1..4b6f88d5d8f2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -2,15 +2,17 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; @@ -44,6 +46,8 @@ public class OperationsContext { private final Map opDataNameMap = new HashMap<>(); private final OperationsData data; + private final Set operationNames = new HashSet<>(); + public OperationsContext(OperationsData data) { this.data = data; } @@ -130,6 +134,7 @@ public T add(T elem) { public T add(T elem) { operations.add(elem); + operationNames.add(elem.name); return elem; } @@ -143,6 +148,10 @@ public int getNextOperationId() { public void processOperation(SingleOperationData opData) { + if (operationNames.contains(opData.getName())) { + opData.addError("Operation %s already defined", opData.getName()); + } + MethodProperties props = opData.getMainProperties(); if (props == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index fa0ec948bcf3..5e69aabc5bdf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -19,6 +19,7 @@ public class OperationsData extends Template { + private final Set names = new HashSet<>(); private final List operations = new ArrayList<>(); private final List metadatas = new ArrayList<>(); private final OperationsContext context = new OperationsContext(this); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index f52e9fec749a..59b30f5937d5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -5,11 +5,14 @@ import java.util.Set; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; @@ -133,6 +136,25 @@ void setNodeData(NodeData data) { this.nodeData = data; } + @Override + public AnnotationMirror getMessageAnnotation() { + return getTemplateTypeAnnotation(); + } + + @Override + public AnnotationValue getMessageAnnotationValue() { + return null; + } + + @Override + public Element getMessageElement() { + if (getMessageAnnotation() != null) { + return parent.getMessageElement(); + } else { + return getTemplateType(); + } + } + @Override protected List findChildContainers() { if (nodeData == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 83520e2a622c..f9bc157c1c56 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -54,6 +54,7 @@ protected SingleOperationData parse(Element element, List mirr TypeElement te; String name; + SingleOperationData data; if (element == null) { if (proxyMirror == null) { @@ -68,7 +69,7 @@ protected SingleOperationData parse(Element element, List mirr te = context.getTypeElement((DeclaredType) proxyType); - AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "name", false); + AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "operationName", false); if (nameFromAnnot == null) { String nameFromType = te.getSimpleName().toString(); @@ -82,6 +83,8 @@ protected SingleOperationData parse(Element element, List mirr name = (String) nameFromAnnot.getValue(); } + data = new SingleOperationData(context, null, proxyMirror, parentData, name); + } else { if (proxyMirror != null) { throw new AssertionError(); @@ -94,9 +97,9 @@ protected SingleOperationData parse(Element element, List mirr te = (TypeElement) element; name = te.getSimpleName().toString(); - } - SingleOperationData data = new SingleOperationData(context, te, ElementUtils.findAnnotationMirror(te.getAnnotationMirrors(), getAnnotationType()), parentData, name); + data = new SingleOperationData(context, te, null, parentData, name); + } List operationFunctions = new ArrayList<>(); @@ -111,6 +114,10 @@ protected SingleOperationData parse(Element element, List mirr data.addError("@Operation annotated class must not be declared private"); } + if (!ElementUtils.isObject(te.getSuperclass()) || !te.getInterfaces().isEmpty()) { + data.addError("@Operation annotated class must not extend/implement anything. Inheritance is not supported."); + } + for (Element el : te.getEnclosedElements()) { if (el.getModifiers().contains(Modifier.PRIVATE)) { // ignore everything private @@ -169,7 +176,7 @@ protected SingleOperationData parse(Element element, List mirr }); - if (ElementUtils.isObject(clonedType.getSuperclass()) && proxyMirror == null) { + if (proxyMirror == null) { clonedType.setSuperClass(types.Node); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index ecec45d65a92..c7eb30585019 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -1,6 +1,8 @@ package com.oracle.truffle.sl.parser; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.antlr.v4.runtime.BaseErrorListener; @@ -10,15 +12,18 @@ import org.antlr.v4.runtime.Recognizer; import org.antlr.v4.runtime.Token; -import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.BlockContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.FunctionContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.MemberAssignContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NameAccessContext; import com.oracle.truffle.sl.runtime.SLStrings; public abstract class SLBaseVisitor extends SimpleLanguageOperationsBaseVisitor { - protected static Map parseSLImpl(Source source, SLBaseVisitor visitor) { + protected static void parseSLImpl(Source source, SLBaseVisitor visitor) { SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getCharacters().toString())); SimpleLanguageOperationsParser parser = new SimpleLanguageOperationsParser(new CommonTokenStream(lexer)); lexer.removeErrorListeners(); @@ -28,51 +33,15 @@ protected static Map parseSLImpl(Source source, S parser.addErrorListener(listener); parser.simplelanguage().accept(visitor); - - return visitor.functions; - } - - static class LexicalScope { - int count; - final LexicalScope parent; - Map names = new HashMap<>(); - - public LexicalScope(LexicalScope parent) { - this.parent = parent; - count = parent != null ? parent.count : 0; - } - - public Integer get(TruffleString name) { - Integer result = names.get(name); - if (result != null) { - return result; - } else if (parent != null) { - return parent.get(name); - } else { - return null; - } - } - - public Integer create(TruffleString name) { - int value = count++; - names.put(name, value); - return value; - } - - public Integer create() { - return count++; - } } protected final SLLanguage language; protected final Source source; protected final TruffleString sourceString; - protected final Map functions; - protected SLBaseVisitor(SLLanguage language, Source source, Map functions) { + protected SLBaseVisitor(SLLanguage language, Source source) { this.language = language; this.source = source; - this.functions = functions; sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); } @@ -112,4 +81,107 @@ protected TruffleString asTruffleString(Token literalToken, boolean removeQuotes } return sourceString.substringByteIndexUncached(fromIndex * 2, length * 2, SLLanguage.STRING_ENCODING, true); } + + // ------------------------------- locals handling -------------------------- + + private static class FindLocalsVisitor extends SimpleLanguageOperationsBaseVisitor { + boolean entered = false; + List results = new ArrayList<>(); + + @Override + public Void visitBlock(BlockContext ctx) { + if (entered) { + return null; + } + + entered = true; + return super.visitBlock(ctx); + } + + @Override + public Void visitNameAccess(NameAccessContext ctx) { + if (ctx.member_expression().size() > 0 && ctx.member_expression(0) instanceof MemberAssignContext) { + results.add(ctx.IDENTIFIER().getSymbol()); + } + + return super.visitNameAccess(ctx); + } + } + + private static class LocalScope { + final LocalScope parent; + final Map locals; + + LocalScope(LocalScope parent) { + this.parent = parent; + locals = new HashMap<>(parent.locals); + } + + LocalScope() { + this.parent = null; + locals = new HashMap<>(); + } + } + + private int totalLocals = 0; + + private LocalScope curScope = null; + + protected final List enterFunction(FunctionContext ctx) { + List result = new ArrayList<>(); + assert curScope == null; + + curScope = new LocalScope(); + totalLocals = 0; + + // skip over function name which is also an IDENTIFIER + for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { + TruffleString paramName = asTruffleString(ctx.IDENTIFIER(i).getSymbol(), false); + curScope.locals.put(paramName, totalLocals++); + result.add(paramName); + } + + return result; + } + + protected final void exitFunction() { + curScope = curScope.parent; + assert curScope == null; + } + + protected final List enterBlock(BlockContext ctx) { + List result = new ArrayList<>(); + curScope = new LocalScope(curScope); + + FindLocalsVisitor findLocals = new FindLocalsVisitor(); + findLocals.visitBlock(ctx); + + for (Token tok : findLocals.results) { + TruffleString name = asTruffleString(tok, false); + if (curScope.locals.get(name) == null) { + curScope.locals.put(name, totalLocals++); + result.add(name); + } + } + + return result; + } + + protected final void exitBlock() { + curScope = curScope.parent; + } + + protected final int getNameIndex(TruffleString name) { + Integer i = curScope.locals.get(name); + if (i == null) { + return -1; + } else { + return i; + } + } + + protected final int getNameIndex(Token name) { + return getNameIndex(asTruffleString(name, false)); + } + } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index a50a80f747d8..c6a293a99395 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -79,18 +79,20 @@ public class SLNodeVisitor extends SLBaseVisitor { public static Map parseSL(SLLanguage language, Source source) { - return parseSLImpl(source, new SLNodeVisitor(language, source)); + SLNodeVisitor visitor = new SLNodeVisitor(language, source); + parseSLImpl(source, visitor); + return visitor.functions; } - private LexicalScope scope; private FrameDescriptor.Builder frameDescriptorBuilder; private SLStatementVisitor STATEMENT_VISITOR = new SLStatementVisitor(); private SLExpressionVisitor EXPRESSION_VISITOR = new SLExpressionVisitor(); private int loopDepth = 0; + private final Map functions = new HashMap<>(); protected SLNodeVisitor(SLLanguage language, Source source) { - super(language, source, new HashMap<>()); + super(language, source); } @Override @@ -104,13 +106,15 @@ public Void visitFunction(FunctionContext ctx) { frameDescriptorBuilder = FrameDescriptor.newBuilder(); List methodNodes = new ArrayList<>(); - scope = new LexicalScope(scope); - - int parameterCount = ctx.IDENTIFIER().size() - 1; + int parameterCount = enterFunction(ctx).size(); for (int i = 0; i < parameterCount; i++) { Token paramToken = ctx.IDENTIFIER(i + 1).getSymbol(); + TruffleString paramName = asTruffleString(paramToken, false); + int localIndex = frameDescriptorBuilder.addSlot(FrameSlotKind.Illegal, paramName, null); + assert localIndex == i; + final SLReadArgumentNode readArg = new SLReadArgumentNode(i); readArg.setSourceSection(paramToken.getStartIndex(), paramToken.getText().length()); SLExpressionNode assignment = createAssignment(createString(paramToken, false), readArg, i); @@ -119,15 +123,14 @@ public Void visitFunction(FunctionContext ctx) { SLStatementNode bodyNode = STATEMENT_VISITOR.visitBlock(ctx.body); - scope = scope.parent; + exitFunction(); + methodNodes.add(bodyNode); final int bodyEndPos = bodyNode.getSourceEndIndex(); final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos); final SLStatementNode methodBlock = new SLBlockNode(methodNodes.toArray(new SLStatementNode[methodNodes.size()])); methodBlock.setSourceSection(functionStartPos, bodyEndPos - functionStartPos); - assert scope == null : "Wrong scoping of blocks in parser"; - final SLFunctionBodyNode functionBodyNode = new SLFunctionBodyNode(methodBlock); functionBodyNode.setSourceSection(functionSrc.getCharIndex(), functionSrc.getCharLength()); @@ -135,7 +138,6 @@ public Void visitFunction(FunctionContext ctx) { functions.put(functionName, rootNode.getCallTarget()); frameDescriptorBuilder = null; - scope = null; return null; } @@ -149,7 +151,11 @@ private SLStringLiteralNode createString(Token name, boolean removeQuotes) { private class SLStatementVisitor extends SimpleLanguageOperationsBaseVisitor { @Override public SLStatementNode visitBlock(BlockContext ctx) { - scope = new LexicalScope(scope); + List newLocals = enterBlock(ctx); + + for (TruffleString newLocal : newLocals) { + frameDescriptorBuilder.addSlot(FrameSlotKind.Illegal, newLocal, null); + } int startPos = ctx.s.getStartIndex(); int endPos = ctx.e.getStopIndex() + 1; @@ -160,7 +166,7 @@ public SLStatementNode visitBlock(BlockContext ctx) { bodyNodes.add(visitStatement(child)); } - scope = scope.parent; + exitBlock(); List flattenedNodes = new ArrayList<>(bodyNodes.size()); flattenBlocks(bodyNodes, flattenedNodes); @@ -546,8 +552,8 @@ public SLExpressionNode visitMemberIndex(MemberIndexContext ctx) { private SLExpressionNode createRead(SLExpressionNode nameTerm) { final TruffleString name = ((SLStringLiteralNode) nameTerm).executeGeneric(null); final SLExpressionNode result; - final Integer frameSlot = scope.get(name); - if (frameSlot != null) { + final int frameSlot = getNameIndex(name); + if (frameSlot != -1) { result = SLReadLocalVariableNodeGen.create(frameSlot); } else { result = SLFunctionLiteralNodeGen.create(new SLStringLiteralNode(name)); @@ -561,13 +567,9 @@ private SLExpressionNode createAssignment(SLStringLiteralNode assignmentName, SL TruffleString name = assignmentName.executeGeneric(null); - Integer frameSlot = scope.get(name); - boolean newVariable = false; - if (frameSlot == null) { - frameSlot = frameDescriptorBuilder.addSlot(FrameSlotKind.Illegal, name, index); - scope.names.put(name, frameSlot); - newVariable = true; - } + int frameSlot = getNameIndex(name); + assert frameSlot != -1; + boolean newVariable = true; SLExpressionNode result = SLWriteLocalVariableNodeGen.create(valueNode, frameSlot, assignmentName, newVariable); assert index != null || valueNode.hasSource(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 5255440ebd45..cad6b4524915 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -17,10 +17,12 @@ import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; +import com.oracle.truffle.sl.operations.SLOperations; import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ArithmeticContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.BlockContext; @@ -50,78 +52,38 @@ public class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = false; - public static Map parseSL(SLLanguage language, Source source, Map functions, SLOperationsBuilder builder) { - return parseSLImpl(source, new SLOperationsVisitor(language, source, builder, functions)); + public static void parseSL(SLLanguage language, Source source, Map functions) { + OperationNodes nodes = SLOperationsBuilder.create(OperationConfig.DEFAULT, builder -> { + SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, builder); + parseSLImpl(source, visitor); + }); + + for (OperationNode node : nodes.getNodes()) { + TruffleString name = node.getMetadata(SLOperations.METHOD_NAME); + SLOperationsRootNode rootNode = new SLOperationsRootNode(language, node, name); + RootCallTarget callTarget = rootNode.getCallTarget(); + functions.put(name, callTarget); + } } public static Map parseSL(SLLanguage language, Source source) { Map roots = new HashMap<>(); - SLOperationsBuilder.create(OperationConfig.DEFAULT, b -> parseSL(language, source, roots, b)); - + parseSL(language, source, roots); return roots; } - private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder, Map functions) { - super(language, source, functions); + private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder) { + super(language, source); this.b = builder; } private final SLOperationsBuilder b; - private LocalScope scope; - - private static class LocalScope { - private final LocalScope parent; - private Map locals; - - LocalScope(LocalScope parent) { - this.parent = parent; - this.locals = new HashMap<>(); - } - - public OperationLocal get(TruffleString value) { - OperationLocal result = locals.get(value); - if (result != null) { - return result; - } else if (parent != null) { - return parent.get(value); - } else { - return null; - } - } - - public void put(TruffleString value, OperationLocal local) { - locals.put(value, local); - } - - } - - private static class FindLocalsVisitor extends SimpleLanguageOperationsBaseVisitor { - boolean entered = false; - List results = new ArrayList<>(); - - @Override - public Void visitBlock(BlockContext ctx) { - if (entered) { - return null; - } - - entered = true; - return super.visitBlock(ctx); - } - - @Override - public Void visitNameAccess(NameAccessContext ctx) { - if (ctx.member_expression().size() > 0 && ctx.member_expression(0) instanceof MemberAssignContext) { - results.add(ctx.IDENTIFIER().getSymbol()); - } - - return super.visitNameAccess(ctx); - } - } private OperationLabel breakLabel; private OperationLabel continueLabel; + private final ArrayList locals = new ArrayList<>(); + @Override public Void visit(ParseTree tree) { b.beginSourceSection(tree.getSourceInterval().a); @@ -133,7 +95,6 @@ public Void visit(ParseTree tree) { @Override public Void visitFunction(FunctionContext ctx) { - assert scope == null; TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); b.setMethodName(name); @@ -141,15 +102,14 @@ public Void visitFunction(FunctionContext ctx) { b.beginSource(source); b.beginTag(StandardTags.RootTag.class); - scope = new LocalScope(null); + int numArguments = enterFunction(ctx).size(); - for (int i = 1; i < ctx.IDENTIFIER().size(); i++) { - TruffleString paramName = asTruffleString(ctx.IDENTIFIER(i).getSymbol(), false); - OperationLocal idx = b.createLocal(); - scope.put(paramName, idx); + for (int i = 0; i < numArguments; i++) { + OperationLocal argLocal = b.createLocal(); + locals.add(argLocal); - b.beginStoreLocal(idx); - b.emitLoadArgument(i - 1); + b.beginStoreLocal(argLocal); + b.emitLoadArgument(i); b.endStoreLocal(); } @@ -157,11 +117,10 @@ public Void visitFunction(FunctionContext ctx) { visit(ctx.body); - b.endTag(); + exitFunction(); + locals.clear(); - scope = scope.parent; - - assert scope == null; + b.endTag(); b.beginReturn(); b.emitConstObject(SLNull.SINGLETON); @@ -182,10 +141,6 @@ public Void visitFunction(FunctionContext ctx) { } } - SLOperationsRootNode rootNode = new SLOperationsRootNode(language, node, name); - - functions.put(name, rootNode.getCallTarget()); - return null; } @@ -193,22 +148,16 @@ public Void visitFunction(FunctionContext ctx) { public Void visitBlock(BlockContext ctx) { b.beginBlock(); - scope = new LocalScope(scope); - - FindLocalsVisitor helper = new FindLocalsVisitor(); - helper.visitBlock(ctx); - - for (Token result : helper.results) { - TruffleString localName = asTruffleString(result, false); - if (scope.get(localName) == null) { - scope.put(localName, b.createLocal()); - } + int numLocals = enterBlock(ctx).size(); + for (int i = 0; i < numLocals; i++) { + locals.add(b.createLocal()); } super.visitBlock(ctx); + exitBlock(); + b.endBlock(); - scope = scope.parent; return null; } @@ -604,9 +553,9 @@ public Void visitNameAccess(NameAccessContext ctx) { private void buildMemberExpressionRead(Token ident, List members, int idx) { if (idx == -1) { - OperationLocal localIdx = scope.get(asTruffleString(ident, false)); - if (localIdx != null) { - b.emitLoadLocal(localIdx); + int localIdx = getNameIndex(ident); + if (localIdx != -1) { + b.emitLoadLocal(locals.get(localIdx)); } else { b.beginSLFunctionLiteral(); b.emitConstObject(asTruffleString(ident, false)); @@ -670,16 +619,16 @@ private void buildMemberExpressionRead(Token ident, List */ - private final Stack writeLocalsStack = new Stack<>(); + private final Stack writeLocalsStack = new Stack<>(); private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { - OperationLocal localIdx = scope.get(asTruffleString(ident, false)); - assert localIdx != null; + int localIdx = getNameIndex(ident); + assert localIdx != -1; writeLocalsStack.push(localIdx); b.beginBlock(); - b.beginStoreLocal(localIdx); + b.beginStoreLocal(locals.get(localIdx)); return; } @@ -706,12 +655,12 @@ private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { + @SuppressWarnings("unused") + private void buildMemberExpressionWriteAfter(Token ident, List members, int idx) { if (idx == -1) { - OperationLocal localIdx = writeLocalsStack.pop(); - scope.put(asTruffleString(ident, false), localIdx); + int localIdx = writeLocalsStack.pop(); b.endStoreLocal(); - b.emitLoadLocal(localIdx); + b.emitLoadLocal(locals.get(localIdx)); b.endBlock(); return; } From b369bb3dfd5acb2b19cb2c11adc3e192ab8a96f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 13 May 2022 16:47:03 +0200 Subject: [PATCH 084/312] [wip] --- .../sl/operations/SLOperationsBuilder.java | 90 +++++++++---------- .../api/operation/OperationsRootNode.java | 11 +++ .../generator/FlatNodeGenFactory.java | 7 +- .../generator/NodeGeneratorPlugs.java | 3 + .../OperationsBytecodeNodeGeneratorPlugs.java | 9 +- .../operations/OperationsParser.java | 3 + .../operations/SingleOperationParser.java | 6 +- 7 files changed, 79 insertions(+), 50 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 2cf43c56807c..3f2e7cec69fa 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -254,15 +254,15 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_LONG = 6; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; + private static final int INSTR_LOAD_CONSTANT_LONG = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_LONG = 9; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; + private static final int INSTR_LOAD_ARGUMENT_LONG = 10; private static final int INSTR_STORE_LOCAL = 11; private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_LONG = 13; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 14; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; + private static final int INSTR_LOAD_LOCAL_LONG = 14; private static final int INSTR_RETURN = 15; private static final int INSTR_INSTRUMENT_ENTER = 16; private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; @@ -298,13 +298,13 @@ private static class BuilderImpl extends SLOperationsBuilder { // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // DOUBLE null}; @@ -1469,13 +1469,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: @@ -1487,13 +1487,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: @@ -1511,13 +1511,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: @@ -2026,16 +2026,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2048,11 +2048,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2060,11 +2060,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2087,11 +2087,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2099,11 +2099,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -5757,11 +5757,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : case INSTR_C_SLLOGICAL_NOT : case INSTR_C_SLTO_BOOLEAN : case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : @@ -5774,8 +5774,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_LONG : case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; @@ -5969,7 +5969,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -5987,7 +5987,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -5997,7 +5997,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6015,7 +6015,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6050,7 +6050,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6068,14 +6068,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6093,7 +6093,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6150,7 +6150,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6168,14 +6168,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6193,7 +6193,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java index 499478856647..13f173b1a8d0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.source.SourceSection; public class OperationsRootNode extends RootNode { @@ -64,6 +65,16 @@ public boolean isInstrumentable() { // return null; // } + @Override + public SourceSection getSourceSection() { + return node.getSourceSection(); + } + + @Override + public SourceSection getEncapsulatingSourceSection() { + return node.getSourceSection(); + } + @Override public String toString() { return "root " + getName(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 72dca9c78f1c..5758a75d8dfe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1125,11 +1125,11 @@ public CodeTree createInitializeCaches(SpecializationData specialization, List mirror) { } else { data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Could not proxy operation"); } + + opData.redirectMessages(data); + opData.redirectMessagesOnGeneratedElements(data); } for (TypeElement inner : operationTypes) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index f9bc157c1c56..0d2e07b72bdc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -135,7 +135,7 @@ protected SingleOperationData parse(Element element, List mirr for (ExecutableElement cel : findSpecializations(te.getEnclosedElements())) { if (!cel.getModifiers().contains(Modifier.STATIC)) { - data.addError(cel, "@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); + data.addError("@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); } operationFunctions.add(cel); @@ -164,7 +164,9 @@ protected SingleOperationData parse(Element element, List mirr CodeTypeElement clonedType = cloneTypeHierarchy(te, ct -> { // remove NodeChild annotations - ct.getAnnotationMirrors().removeIf(m -> m.getAnnotationType().equals(types.NodeChild) || m.getAnnotationType().equals(types.NodeChildren)); + ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChild) || ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChildren)); + // remove GenerateUncached annotations - we do not care + ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.GenerateUncached)); // remove all non-static or private elements // this includes all the execute methods From 0c45539ffe5adbbe5f2102bf66029a09991e925c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 16 May 2022 09:54:57 +0200 Subject: [PATCH 085/312] [wip] small changes --- .../test/example/BoxingOperationsTest.java | 9 +- .../example/TestOperationsParserTest.java | 2 +- .../operation/test/example/TestRootNode.java | 21 +++++ .../truffle/api/operation/OperationNode.java | 8 -- .../api/operation/OperationsRootNode.java | 83 ------------------- .../sl/test/SLOperationsSimpleTestSuite.java | 2 +- .../src/com/oracle/truffle/sl/SLLanguage.java | 15 +++- .../truffle/sl/nodes/SLAstRootNode.java | 43 ++++++++++ .../sl/nodes/SLOperationsRootNode.java | 15 +++- .../oracle/truffle/sl/nodes/SLRootNode.java | 40 ++------- .../sl/nodes/SLUndefinedFunctionRootNode.java | 23 ++++- .../truffle/sl/parser/SLNodeVisitor.java | 3 +- .../sl/parser/SLOperationsVisitor.java | 2 +- 13 files changed, 128 insertions(+), 138 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index c2a4f6b2e5db..bbe4ac4956e9 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -16,6 +16,8 @@ import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; public class BoxingOperationsTest { @@ -24,10 +26,9 @@ public class BoxingOperationsTest { // than it needs to private static RootCallTarget parse(Consumer parser) { - return BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser) // - .getNodes().get(0) // - .createRootNode(null, "test") // - .getCallTarget(); + OperationNodes nodes = BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser); + OperationNode node = nodes.getNodes().get(0); + return new TestRootNode(node).getCallTarget(); } @Test diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index d6dbc8e60d61..91343080551d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -20,7 +20,7 @@ public class TestOperationsParserTest { private static RootCallTarget parse(Consumer builder) { OperationNode operationsNode = parseNode(builder); System.out.println(operationsNode); - return operationsNode.createRootNode(null, "TestFunction").getCallTarget(); + return new TestRootNode(operationsNode).getCallTarget(); } private static OperationNode parseNode(Consumer builder) { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java new file mode 100644 index 000000000000..549d802bdd81 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java @@ -0,0 +1,21 @@ +package com.oracle.truffle.api.operation.test.example; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.OperationNode; + +public class TestRootNode extends RootNode { + + @Child private OperationNode node; + + TestRootNode(OperationNode node) { + super(null, node.createFrameDescriptor()); + this.node = node; + } + + @Override + public Object execute(VirtualFrame frame) { + return node.execute(frame); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index ed22280efb17..8bf7179a730e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -28,14 +28,6 @@ public FrameDescriptor createFrameDescriptor() { return bcNode.createFrameDescriptor(); } - public OperationsRootNode createRootNode(TruffleLanguage language, String name) { - return new OperationsRootNode(language, this, name, false); - } - - public OperationsRootNode createInternalRootNode(TruffleLanguage language, String name) { - return new OperationsRootNode(language, this, name, true); - } - public Object execute(VirtualFrame frame) { return bcNode.execute(frame); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java deleted file mode 100644 index 13f173b1a8d0..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsRootNode.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.oracle.truffle.api.operation; - -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.source.SourceSection; - -public class OperationsRootNode extends RootNode { - - @Child private OperationNode node; - - private final String nodeName; - private final boolean isInternal; - - OperationsRootNode(TruffleLanguage language, OperationNode node, String nodeName, boolean isInternal) { - super(language, node.createFrameDescriptor()); - this.node = insert(node); - this.nodeName = nodeName; - this.isInternal = isInternal; - } - - @Override - public String getName() { - return nodeName; - } - - @Override - public boolean isInternal() { - return isInternal; - } - - @Override - public Object execute(VirtualFrame frame) { - return node.execute(frame); - } - - @Override - public boolean isCaptureFramesForTrace() { - return true; - } - - @Override - public boolean isInstrumentable() { - return false; - } - - // private class OperationsWrapperNode extends Node implements WrapperNode { - // private final ProbeNode probe; - // - // OperationsWrapperNode(ProbeNode probe) { - // this.probe = probe; - // } - // - // public Node getDelegateNode() { - // return OperationsRootNode.this; - // } - // - // public ProbeNode getProbeNode() { - // return probe; - // } - // } - - // public WrapperNode createWrapper(final ProbeNode probe) { - // // return new OperationsWrapperNode(probe); - // return null; - // } - - @Override - public SourceSection getSourceSection() { - return node.getSourceSection(); - } - - @Override - public SourceSection getEncapsulatingSourceSection() { - return node.getSourceSection(); - } - - @Override - public String toString() { - return "root " + getName(); - } - -} diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java index 2ab4c400d60f..9b6a9bc4be57 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLOperationsSimpleTestSuite.java @@ -44,7 +44,7 @@ import org.junit.runner.RunWith; @RunWith(SLTestRunner.class) -@SLTestSuite(value = {"tests"}, options = {"sl.useOperations", "true"}) +@SLTestSuite(value = {"tests"}, options = {"sl.UseOperations", "true"}) public class SLOperationsSimpleTestSuite { public static void main(String[] args) throws Exception { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java index 974e3d74ea32..75fe4fdad0e0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @@ -50,6 +50,7 @@ import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionKey; import org.graalvm.options.OptionStability; +import org.graalvm.options.OptionValues; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; @@ -78,6 +79,7 @@ import com.oracle.truffle.sl.builtins.SLPrintlnBuiltin; import com.oracle.truffle.sl.builtins.SLReadlnBuiltin; import com.oracle.truffle.sl.builtins.SLStackTraceBuiltin; +import com.oracle.truffle.sl.nodes.SLAstRootNode; import com.oracle.truffle.sl.nodes.SLEvalRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLRootNode; @@ -220,8 +222,8 @@ public final class SLLanguage extends TruffleLanguage { private final Shape rootShape; - @Option(name = "useOperations", help = "Use the SL interpreter implemented using the Truffle Operations DSL", category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL) // - public static final OptionKey USE_OPERATIONS = new OptionKey<>(false); + @Option(help = "Use the SL interpreter implemented using the Truffle Operations DSL", category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL) // + public static final OptionKey UseOperations = new OptionKey<>(false); private boolean useOperations; @@ -232,7 +234,7 @@ public SLLanguage() { @Override protected SLContext createContext(Env env) { - useOperations = USE_OPERATIONS.getValue(env.getOptions()); + useOperations = UseOperations.getValue(env.getOptions()); return new SLContext(this, env, new ArrayList<>(EXTERNAL_BUILTINS)); } @@ -251,6 +253,11 @@ public boolean isUseOperations() { return useOperations; } + @Override + protected boolean areOptionsCompatible(OptionValues firstOptions, OptionValues newOptions) { + return UseOperations.getValue(firstOptions).equals(UseOperations.getValue(newOptions)); + } + public RootCallTarget getOrCreateUndefinedFunction(TruffleString name) { RootCallTarget target = undefinedFunctions.get(name); if (target == null) { @@ -293,7 +300,7 @@ public RootCallTarget lookupBuiltin(NodeFactory factory builtinBodyNode.setUnavailableSourceSection(); /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ - SLRootNode rootNode = new SLRootNode(this, new FrameDescriptor(), builtinBodyNode, BUILTIN_SOURCE.createUnavailableSection(), name); + SLRootNode rootNode = new SLAstRootNode(this, new FrameDescriptor(), builtinBodyNode, BUILTIN_SOURCE.createUnavailableSection(), name); /* * Register the builtin function in the builtin registry. Call targets for builtins may be diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java new file mode 100644 index 000000000000..44b01ddecd8a --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java @@ -0,0 +1,43 @@ +package com.oracle.truffle.sl.nodes; + +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; + +public class SLAstRootNode extends SLRootNode { + + @Child private SLExpressionNode bodyNode; + + private final SourceSection sourceSection; + private final TruffleString name; + + public SLAstRootNode(SLLanguage language, FrameDescriptor frameDescriptor, SLExpressionNode bodyNode, SourceSection sourceSection, TruffleString name) { + super(language, frameDescriptor); + this.bodyNode = bodyNode; + this.sourceSection = sourceSection; + this.name = name; + } + + @Override + public SourceSection getSourceSection() { + return sourceSection; + } + + @Override + public SLExpressionNode getBodyNode() { + return bodyNode; + } + + @Override + public TruffleString getTSName() { + return name; + } + + @Override + public Object execute(VirtualFrame frame) { + return bodyNode.executeGeneric(frame); + } + +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java index 67529c5ea856..0be4031199af 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java @@ -5,13 +5,14 @@ import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.operations.SLOperations; public class SLOperationsRootNode extends SLRootNode { @Child private OperationNode operationsNode; - public SLOperationsRootNode(SLLanguage language, OperationNode operationsNode, TruffleString name) { - super(language, operationsNode.createFrameDescriptor(), null, null, name); + public SLOperationsRootNode(SLLanguage language, OperationNode operationsNode) { + super(language, operationsNode.createFrameDescriptor()); this.operationsNode = insert(operationsNode); } @@ -25,4 +26,14 @@ public SourceSection getSourceSection() { return operationsNode.getSourceSection(); } + @Override + public SLExpressionNode getBodyNode() { + return null; + } + + @Override + public TruffleString getTSName() { + return operationsNode.getMetadata(SLOperations.METHOD_NAME); + } + } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java index 1fa21921733f..20fbffdd8f43 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java @@ -44,8 +44,8 @@ import java.util.List; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; @@ -60,7 +60,6 @@ import com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode; import com.oracle.truffle.sl.nodes.local.SLReadArgumentNode; import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode; -import com.oracle.truffle.sl.runtime.SLContext; /** * The root of all SL execution trees. It is a Truffle requirement that the tree root extends the @@ -69,49 +68,28 @@ * functions, the {@link #bodyNode} is a {@link SLFunctionBodyNode}. */ @NodeInfo(language = "SL", description = "The root of all SL execution trees") -public class SLRootNode extends RootNode { - /** The function body that is executed, and specialized during execution. */ - @Child private SLExpressionNode bodyNode; - - /** The name of the function, for printing purposes only. */ - private final TruffleString name; +public abstract class SLRootNode extends RootNode { private boolean isCloningAllowed; - private final SourceSection sourceSection; - - @CompilerDirectives.CompilationFinal(dimensions = 1) private volatile SLWriteLocalVariableNode[] argumentNodesCache; + @CompilationFinal(dimensions = 1) private SLWriteLocalVariableNode[] argumentNodesCache; - public SLRootNode(SLLanguage language, FrameDescriptor frameDescriptor, SLExpressionNode bodyNode, SourceSection sourceSection, TruffleString name) { + public SLRootNode(SLLanguage language, FrameDescriptor frameDescriptor) { super(language, frameDescriptor); - this.bodyNode = bodyNode; - this.name = name; - this.sourceSection = sourceSection; - } - - @Override - public SourceSection getSourceSection() { - return sourceSection; } @Override - public Object execute(VirtualFrame frame) { - assert SLContext.get(this) != null; - return bodyNode.executeGeneric(frame); - } + public abstract SourceSection getSourceSection(); - public SLExpressionNode getBodyNode() { - return bodyNode; - } + public abstract SLExpressionNode getBodyNode(); @Override public String getName() { + TruffleString name = getTSName(); return name == null ? null : name.toJavaStringUncached(); } - public TruffleString getTSName() { - return name; - } + public abstract TruffleString getTSName(); public void setCloningAllowed(boolean isCloningAllowed) { this.isCloningAllowed = isCloningAllowed; @@ -124,7 +102,7 @@ public boolean isCloningAllowed() { @Override public String toString() { - return "root " + name; + return "root " + getTSName(); } public final SLWriteLocalVariableNode[] getDeclaredArguments() { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java index aa6a850a9b6d..4c5107dc8284 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLUndefinedFunctionRootNode.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.runtime.SLFunction; @@ -53,12 +54,30 @@ * {@link SLUndefinedNameException#undefinedFunction exception}. */ public class SLUndefinedFunctionRootNode extends SLRootNode { + private final TruffleString name; + public SLUndefinedFunctionRootNode(SLLanguage language, TruffleString name) { - super(language, null, null, null, name); + super(language, null); + this.name = name; } @Override public Object execute(VirtualFrame frame) { - throw SLUndefinedNameException.undefinedFunction(null, -1, getTSName()); + throw SLUndefinedNameException.undefinedFunction(null, -1, name); + } + + @Override + public SourceSection getSourceSection() { + return null; + } + + @Override + public SLExpressionNode getBodyNode() { + return null; + } + + @Override + public TruffleString getTSName() { + return name; } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index c6a293a99395..c44c15ac2466 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -18,6 +18,7 @@ import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLAstRootNode; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLRootNode; import com.oracle.truffle.sl.nodes.SLStatementNode; @@ -134,7 +135,7 @@ public Void visitFunction(FunctionContext ctx) { final SLFunctionBodyNode functionBodyNode = new SLFunctionBodyNode(methodBlock); functionBodyNode.setSourceSection(functionSrc.getCharIndex(), functionSrc.getCharLength()); - final SLRootNode rootNode = new SLRootNode(language, frameDescriptorBuilder.build(), functionBodyNode, functionSrc, functionName); + final SLRootNode rootNode = new SLAstRootNode(language, frameDescriptorBuilder.build(), functionBodyNode, functionSrc, functionName); functions.put(functionName, rootNode.getCallTarget()); frameDescriptorBuilder = null; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index cad6b4524915..e2f3317dc89c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -60,7 +60,7 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Mon, 16 May 2022 11:42:18 +0200 Subject: [PATCH 086/312] [wip] short circuiting --- .../sl/operations/SLOperationsBuilder.java | 374 +++++++++++++++++- .../operation/BuilderFinallyTryContext.java | 4 +- .../api/operation/OperationBuilder.java | 14 +- .../api/operation/ShortCircuitOperation.java | 18 + .../api/operation/ShortCircuitOperations.java | 12 + .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Operation.java | 63 +++ .../OperationsBytecodeCodeGenerator.java | 4 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 51 ++- .../operations/OperationsContext.java | 24 +- .../operations/OperationsParser.java | 23 +- .../operations/SingleOperationData.java | 18 +- .../operations/SingleOperationParser.java | 65 ++- .../instructions/CustomInstruction.java | 35 +- .../instructions/ShortCircuitInstruction.java | 50 +++ .../truffle/sl/operations/SLOperations.java | 3 + .../sl/parser/SLOperationsVisitor.java | 110 +----- 17 files changed, 691 insertions(+), 179 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 3f2e7cec69fa..edbf2eb469cc 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -186,6 +186,14 @@ protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, Operation public abstract void endSLToBoolean(); + public abstract void beginSLAnd(); + + public abstract void endSLAnd(); + + public abstract void beginSLOr(); + + public abstract void endSLOr(); + public abstract void beginSLInvoke(); public abstract void endSLInvoke(); @@ -248,7 +256,9 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int OP_SLUNBOX = 27; private static final int OP_SLFUNCTION_LITERAL = 28; private static final int OP_SLTO_BOOLEAN = 29; - private static final int OP_SLINVOKE = 30; + private static final int OP_SLAND = 30; + private static final int OP_SLOR = 31; + private static final int OP_SLINVOKE = 32; private static final int INSTR_POP = 1; private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; @@ -281,30 +291,32 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLUNBOX = 30; private static final int INSTR_C_SLFUNCTION_LITERAL = 31; private static final int INSTR_C_SLTO_BOOLEAN = 32; - private static final int INSTR_C_SLINVOKE = 33; - private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 34; - private static final int INSTR_C_SLADD_Q_ADD_LONG = 35; - private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 36; - private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 37; - private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 38; - private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 39; - private static final int INSTR_C_SLINVOKE_Q_DIRECT = 40; - private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 41; - private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 42; - private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 43; + private static final int INSTR_SC_SLAND = 33; + private static final int INSTR_SC_SLOR = 34; + private static final int INSTR_C_SLINVOKE = 35; + private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 36; + private static final int INSTR_C_SLADD_Q_ADD_LONG = 37; + private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 38; + private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 39; + private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 40; + private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 41; + private static final int INSTR_C_SLINVOKE_Q_DIRECT = 42; + private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 43; + private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 44; + private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 45; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // BYTE null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, // FLOAT null, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // DOUBLE null}; @@ -390,6 +402,36 @@ void doBeforeChild() { } break; } + case OP_SLAND : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_SC_SLAND); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + createOffset(bci + 3, ((BuilderOperationLabel) operationData.aux[0])); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 5 + 0] = 0; + bci = bci + 6; + } + break; + } + case OP_SLOR : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); + LE_BYTES.putShort(bc, bci, (short) INSTR_SC_SLOR); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + createOffset(bci + 3, ((BuilderOperationLabel) operationData.aux[0])); + // additionalData = 1 bytes: [BITS] + // numChildNodes = 0 + // numConsts = 0 + bc[bci + 5 + 0] = 0; + bci = bci + 6; + } + break; + } } } @@ -1372,6 +1414,54 @@ public void endSLToBoolean() { doAfterChild(); } + @SuppressWarnings("unused") + @Override + public void beginSLAnd() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLAND, getCurStack(), 1, false); + operationData.aux[0] = (BuilderOperationLabel) createLabel(); + } + + @SuppressWarnings("unused") + @Override + public void endSLAnd() { + if (operationData.operationId != OP_SLAND) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); + } + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLOr() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SLOR, getCurStack(), 1, false); + operationData.aux[0] = (BuilderOperationLabel) createLabel(); + } + + @SuppressWarnings("unused") + @Override + public void endSLOr() { + if (operationData.operationId != OP_SLOR) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); + } + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + @SuppressWarnings("unused") @Override public void beginSLInvoke() { @@ -1762,6 +1852,30 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Boolean * Fallback * + * sc.SLAnd + * Inputs: + * STACK_VALUE + * BRANCH_TARGET + * Results: + * BRANCH + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * + * sc.SLOr + * Inputs: + * STACK_VALUE + * BRANCH_TARGET + * Results: + * BRANCH + * Additional Data: + * 0 BITS + * Specializations: + * Boolean + * Fallback + * * c.SLInvoke * Inputs: * STACK_VALUE @@ -2207,6 +2321,28 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } + case INSTR_SC_SLAND : + { + if (this.SLAnd_execute_(frame, bci, sp)) { + sp = sp - 1; + bci = bci + 6; + continue loop; + } else { + bci = LE_BYTES.getShort(bc, bci + 3); + continue loop; + } + } + case INSTR_SC_SLOR : + { + if (!this.SLOr_execute_(frame, bci, sp)) { + sp = sp - 1; + bci = bci + 6; + continue loop; + } else { + bci = LE_BYTES.getShort(bc, bci + 3); + continue loop; + } + } case INSTR_C_SLINVOKE : { int numVariadics = LE_BYTES.getShort(bc, bci + 3); @@ -5335,6 +5471,144 @@ private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, in } } + private boolean SLAnd_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $bci, $sp, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $bci, $sp, state_0); + } + } + + private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + return SLAnd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + } + + private boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private boolean SLOr_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $bci, $sp, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $bci, $sp, state_0); + } + } + + private boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + return SLOr_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = (this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); + } + + private boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = (this); + fallback_bci__ = ($bci); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + @ExplodeLoop private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { byte state_0 = bc[$bci + 5 + 0]; @@ -5810,6 +6084,8 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_C_SLMUL : case INSTR_C_SLSUB : case INSTR_C_SLFUNCTION_LITERAL : + case INSTR_SC_SLAND : + case INSTR_SC_SLOR : case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : { bci = bci + 6; @@ -6570,6 +6846,60 @@ public String dump() { bci += 4; break; } + case INSTR_SC_SLAND : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLAnd "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("branch"); + bci += 6; + break; + } + case INSTR_SC_SLOR : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLOr "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(", "); + sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); + sb.append(" -> "); + sb.append("branch"); + bci += 6; + break; + } case INSTR_C_SLINVOKE : { sb.append(String.format("%02x ", bc[bci + 0])); @@ -6929,6 +7259,20 @@ private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, int $bci return true; } + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java index 6d9b19ff3d48..e2bbfd930acf 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java @@ -5,18 +5,16 @@ class BuilderFinallyTryContext { final BuilderFinallyTryContext prev; final byte[] bc; - final int bci; final ArrayList exceptionHandlers; final ArrayList labelFills; final ArrayList labels; final int curStack; final int maxStack; - BuilderFinallyTryContext(BuilderFinallyTryContext prev, byte[] bc, int bci, ArrayList exceptionHandlers, ArrayList labelFills, + BuilderFinallyTryContext(BuilderFinallyTryContext prev, byte[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { this.prev = prev; this.bc = bc; - this.bci = bci; this.exceptionHandlers = exceptionHandlers; this.labelFills = labelFills; this.labels = labels; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 211f41f299dd..a69cbb64a4a9 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -23,7 +23,7 @@ public abstract class OperationBuilder { protected final boolean withSource; protected final boolean withInstrumentation; - protected byte[] bc = new byte[65536]; + protected final byte[] bc = new byte[65536]; protected int bci = 0; protected final OperationsConstantPool constPool = new OperationsConstantPool(); @@ -379,9 +379,11 @@ protected final void addExceptionHandler(BuilderExceptionHandler handler) { private BuilderFinallyTryContext currentFinallyTry = null; protected final Object doBeginFinallyTry() { - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, bc, bci, exceptionHandlers, labelFills, labels, curStack, maxStack); - bc = new byte[65536]; + // save outer code + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + + // reset builder for handler bci = 0; exceptionHandlers = new ArrayList<>(); labelFills = new ArrayList<>(); @@ -395,12 +397,14 @@ protected final Object doBeginFinallyTry() { protected final void doEndFinallyBlock() { labelPass(currentFinallyTry); + // save handler code currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); currentFinallyTry.handlerHandlers = exceptionHandlers; currentFinallyTry.handlerMaxStack = maxStack; - bc = currentFinallyTry.bc; - bci = currentFinallyTry.bci; + // restore outer code + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; exceptionHandlers = currentFinallyTry.exceptionHandlers; labelFills = currentFinallyTry.labelFills; labels = currentFinallyTry.labels; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java new file mode 100644 index 000000000000..5c3d0fc5b1b4 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java @@ -0,0 +1,18 @@ +package com.oracle.truffle.api.operation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +@Repeatable(ShortCircuitOperations.class) +public @interface ShortCircuitOperation { + String name(); + + boolean continueWhen(); + + Class booleanConverter() default void.class; +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java new file mode 100644 index 000000000000..9426afe1d15d --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java @@ -0,0 +1,12 @@ +package com.oracle.truffle.api.operation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface ShortCircuitOperations { + ShortCircuitOperation[] value(); +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 1d0af2880546..c1ffaffdf72e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -245,6 +245,7 @@ public class TruffleTypes { public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool"; public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; + public static final String ShortCircuitOperation_Name = "com.oracle.truffle.api.operation.ShortCircuitOperation"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; public final DeclaredType BuilderExceptionHandler = c.getDeclaredTypeOptional(BuilderExceptionHandler_Name); @@ -265,6 +266,7 @@ public class TruffleTypes { public final DeclaredType OperationBuilder = c.getDeclaredTypeOptional(OperationBuilder_Name); public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name); public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name); + public final DeclaredType ShortCircuitOperation = c.getDeclaredTypeOptional(ShortCircuitOperation_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 1d9de1dfa8aa..f8865fed520b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -20,6 +20,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -754,6 +755,68 @@ public boolean hasLeaveCode() { } } + public static class ShortCircuitOperation extends Operation { + + private final ShortCircuitInstruction instruction; + + protected ShortCircuitOperation(OperationsContext builder, String name, int id, ShortCircuitInstruction instruction) { + super(builder, name, id, VARIABLE_CHILDREN); + this.instruction = instruction; + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(); + } + + @Override + public int minimumChildren() { + return 1; + } + + @Override + public int getNumAuxValues() { + return 1; // only the end label + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("1"); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(createSetAux(vars, 0, createCreateLabel())); + + return b.build(); + } + + @Override + public CodeTree createBeforeChildCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startIf().variable(vars.childIndex).string(" > 0").end().startBlock(); + { + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + } + b.end(); + + return b.build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(OperationGeneratorUtils.createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + + return b.build(); + } + + } + private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement()// .variable(vars.operationData).string(".aux[" + index + "] = ") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index ad6e2b712ba2..589188b7d3d9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -94,6 +94,8 @@ public CodeTypeElement createBuilderBytecodeNode() { CustomInstruction cinstr = (CustomInstruction) instr; boolean isVariadic = cinstr.getData().getMainProperties().isVariadic; + boolean isShortCircuit = cinstr.getData().isShortCircuit(); + boolean regularReturn = isVariadic || isShortCircuit; final Set methodNames = new HashSet<>(); final Set innerTypeNames = new HashSet<>(); @@ -177,7 +179,7 @@ public CodeTypeElement createBuilderBytecodeNode() { } } - if (!isVariadic) { + if (!regularReturn) { if (isExecute || isExecuteAndSpecialize) { exToCopy.setReturnType(context.getType(void.class)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index ff243b91a6b9..839a5f8ec677 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -62,6 +62,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private List boxingSplits; private OperationsData m; + private final SingleOperationData data; OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, Set innerTypeNames, List additionalData, @@ -84,7 +85,9 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator this.context = ProcessorContext.getInstance(); this.types = context.getTypes(); - if (cinstr.numPush() == 0) { + this.data = cinstr.getData(); + + if (cinstr.numPush() == 0 || data.isShortCircuit()) { resultUnboxedState = null; } else { resultUnboxedState = new Object() { @@ -296,7 +299,7 @@ public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { @Override public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { - if (isVariadic) { + if (regularReturn()) { return values.toArray(new CodeTree[values.size()]); } CodeTree[] result = new CodeTree[values.size()]; @@ -319,6 +322,13 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree return; } + if (data.isShortCircuit()) { + b.startReturn(); + b.tree(specializationCall); + b.end(); + return; + } + assert cinstr.numPush() == 1; int destOffset = cinstr.numPopStatic(); @@ -372,7 +382,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree @Override public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary, CodeTree[] bindings) { - if (isVariadic || inBoundary) + if (inBoundary || regularReturn()) return false; // if (m.isTracing()) { @@ -393,6 +403,10 @@ public boolean createCallSpecialization(FrameState frameState, SpecializationDat return true; } + private boolean regularReturn() { + return isVariadic || data.isShortCircuit(); + } + @Override public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { String easName = transformNodeMethodName("executeAndSpecialize"); @@ -403,7 +417,7 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; } - if (isVariadic) { + if (regularReturn()) { builder.startReturn(); } else { builder.startStatement(); @@ -414,7 +428,7 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui frameState.addReferencesTo(builder); builder.end(2); - if (!isVariadic) { + if (!regularReturn()) { builder.returnStatement(); } @@ -423,10 +437,9 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui @Override public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { - if (isVariadic) { + if (regularReturn()) { builder.startReturn().startCall("this", boundaryMethod); builder.string("$bci"); - builder.string("$sp"); addArguments.accept(builder); builder.end(2); return; @@ -445,11 +458,24 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt @Override public boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters) { - parentBuilder.startStatement().startCall(method.getSimpleName().toString()); + boolean needsReturn; + if (regularReturn() && method.getReturnType().getKind() != TypeKind.VOID) { + parentBuilder.startReturn(); + needsReturn = false; + } else { + parentBuilder.startStatement(); + needsReturn = true; + } + + parentBuilder.startCall(method.getSimpleName().toString()); addNodeCallParameters(parentBuilder, false, false); addStateParameters.run(); parentBuilder.end(2); - parentBuilder.returnStatement(); + + if (needsReturn) { + parentBuilder.returnStatement(); + } + return true; } @@ -514,7 +540,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // boxing elimination - if (!isVariadic && cinstr.numPopStatic() > 0) { + if (!regularReturn() && cinstr.numPopStatic() > 0) { boolean elseIf = false; boolean[] needsElse = new boolean[]{true}; @@ -569,6 +595,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } + // creates the if / else cascade for determining the type required for doSetResultBoxed private boolean createBoxingSplitUnboxingThing(CodeTreeBuilder b, FrameState frameState, boolean elseIf, SpecializationData specialization, List specializations, TypeMirror[] primitiveMirrors, boolean[] needsElse) { if (!specializations.contains(specialization)) { @@ -686,7 +713,9 @@ public boolean isStateGuaranteed(boolean stateGuaranteed) { } public void finishUp() { - if (cinstr.numPush() > 0) { + if (data.isShortCircuit()) { + cinstr.setBoxingEliminationData(0, 0); + } else if (cinstr.numPush() > 0) { int offset = -1; BitSet targetSet = null; for (StateBitSet set : multiState.getSets()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 4b6f88d5d8f2..5c3a5ee5d462 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.Set; +import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; @@ -23,6 +24,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; @@ -159,15 +161,23 @@ public void processOperation(SingleOperationData opData) { return; } - CustomInstruction instr = new CustomInstruction("c." + opData.getName(), getNextInstructionId(), opData); - add(instr); - customInstructionNameMap.put(opData.getName(), instr); - opDataNameMap.put(opData.getName(), opData); + if (opData.isShortCircuit()) { + ShortCircuitInstruction instr = add(new ShortCircuitInstruction("sc." + opData.getName(), getNextInstructionId(), opData)); + customInstructionNameMap.put(opData.getName(), instr); + opDataNameMap.put(opData.getName(), opData); + add(new ShortCircuitOperation(this, opData.getName(), getNextOperationId(), instr)); + } else { - int numChildren = props.isVariadic ? -1 : props.numStackValues; + CustomInstruction instr = new CustomInstruction("c." + opData.getName(), getNextInstructionId(), opData); + add(instr); + customInstructionNameMap.put(opData.getName(), instr); + opDataNameMap.put(opData.getName(), opData); - Operation.Simple op = new Operation.Simple(this, opData.getName(), getNextOperationId(), numChildren, instr); - add(op); + int numChildren = props.isVariadic ? -1 : props.numStackValues; + + Operation.Simple op = new Operation.Simple(this, opData.getName(), getNextOperationId(), numChildren, instr); + add(op); + } } public void processDecisions(OperationDecisions decisions) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 4874a98b5976..9b7f9e24b241 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -102,19 +102,34 @@ protected OperationsData parse(Element element, List mirror) { List operationTypes = new ArrayList<>(ElementFilter.typesIn(typeElement.getEnclosedElements())); List opProxies = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.OperationProxy); + // find and bind all operation proxies for (AnnotationMirror mir : opProxies) { SingleOperationData opData = new SingleOperationParser(data, mir).parse(null, null); - if (opData != null) { - data.addOperationData(opData); - } else { + if (opData == null) { data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Could not proxy operation"); + continue; + } + + data.addOperationData(opData); + opData.redirectMessagesOnGeneratedElements(data); + } + + // find and bind all sc operations + List scOperations = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.ShortCircuitOperation); + for (AnnotationMirror mir : scOperations) { + SingleOperationData opData = new SingleOperationParser(data, mir, true).parse(null, null); + if (opData == null) { + data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Clould not proxy short circuit operation"); + continue; } - opData.redirectMessages(data); + data.addOperationData(opData); opData.redirectMessagesOnGeneratedElements(data); + opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); } + // find and bind all inner declared operations for (TypeElement inner : operationTypes) { if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { continue; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 59b30f5937d5..75491d4d9c65 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -12,7 +12,6 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; @@ -24,6 +23,8 @@ public class SingleOperationData extends Template { private NodeData nodeData; private OperationsData parent; private final Set throwDeclarations = new HashSet<>(); + private final boolean isShortCircuit; + private boolean shortCircuitContinueWhen; public static enum ParameterKind { STACK_VALUE, @@ -97,10 +98,11 @@ public String toString() { } } - public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent, String name) { + public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent, String name, boolean isShortCircuit) { super(context, templateType, annotation); this.parent = parent; this.name = name; + this.isShortCircuit = isShortCircuit; } @Override @@ -124,6 +126,10 @@ public MethodProperties getMainProperties() { return mainProperties; } + public boolean isShortCircuit() { + return isShortCircuit; + } + public void setMainProperties(MethodProperties mainProperties) { this.mainProperties = mainProperties; } @@ -163,4 +169,12 @@ protected List findChildContainers() { return List.of(nodeData); } + public boolean getShortCircuitContinueWhen() { + return shortCircuitContinueWhen; + } + + public void setShortCircuitContinueWhen(boolean shortCircuitContinueWhen) { + this.shortCircuitContinueWhen = shortCircuitContinueWhen; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 0d2e07b72bdc..bd42a05eb6fa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -39,14 +39,20 @@ public class SingleOperationParser extends AbstractParser { private final AnnotationMirror proxyMirror; private final String NODE = "Node"; + private final boolean isShortCircuit; public SingleOperationParser(OperationsData parentData) { - this(parentData, null); + this(parentData, null, false); } public SingleOperationParser(OperationsData parentData, AnnotationMirror proxyMirror) { + this(parentData, proxyMirror, false); + } + + public SingleOperationParser(OperationsData parentData, AnnotationMirror proxyMirror, boolean isShortCircuit) { this.parentData = parentData; this.proxyMirror = proxyMirror; + this.isShortCircuit = isShortCircuit; } @Override @@ -61,7 +67,13 @@ protected SingleOperationData parse(Element element, List mirr throw new AssertionError(); } - AnnotationValue proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "value"); + AnnotationValue proxyTypeValue; + if (isShortCircuit) { + proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "booleanConverter"); + } else { + proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "value"); + } + TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); if (proxyType.getKind() != TypeKind.DECLARED) { parentData.addError(proxyMirror, proxyTypeValue, "@OperationProxy'ed type must be a class, not %s", proxyType); @@ -69,21 +81,25 @@ protected SingleOperationData parse(Element element, List mirr te = context.getTypeElement((DeclaredType) proxyType); - AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "operationName", false); - - if (nameFromAnnot == null) { - String nameFromType = te.getSimpleName().toString(); - // strip the `Node' suffix - if (nameFromType.endsWith(NODE)) { - name = nameFromType.substring(0, nameFromType.length() - NODE.length()); + if (isShortCircuit) { + name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); + } else { + AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "operationName", false); + + if (nameFromAnnot == null) { + String nameFromType = te.getSimpleName().toString(); + // strip the `Node' suffix + if (nameFromType.endsWith(NODE)) { + name = nameFromType.substring(0, nameFromType.length() - NODE.length()); + } else { + name = nameFromType; + } } else { - name = nameFromType; + name = (String) nameFromAnnot.getValue(); } - } else { - name = (String) nameFromAnnot.getValue(); } - data = new SingleOperationData(context, null, proxyMirror, parentData, name); + data = new SingleOperationData(context, null, proxyMirror, parentData, name, isShortCircuit); } else { if (proxyMirror != null) { @@ -96,9 +112,13 @@ protected SingleOperationData parse(Element element, List mirr } te = (TypeElement) element; - name = te.getSimpleName().toString(); + if (isShortCircuit) { + name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); + } else { + name = te.getSimpleName().toString(); + } - data = new SingleOperationData(context, te, null, parentData, name); + data = new SingleOperationData(context, te, null, parentData, name, false); } List operationFunctions = new ArrayList<>(); @@ -156,6 +176,10 @@ protected SingleOperationData parse(Element element, List mirr data.getThrowDeclarations().addAll(fun.getThrownTypes()); } + if (isShortCircuit && (props.numStackValues != 1 || props.isVariadic || !props.returnsValue)) { + data.addError("Boolean converter must take exactly one argument, not be variadic, and return a value"); + } + if (data.hasErrors()) { return data; } @@ -222,9 +246,18 @@ private void addBoxingEliminationNodeChildAnnotations(MethodProperties props, Co } private CodeExecutableElement createExecuteMethod(MethodProperties props, boolean isVariadic) { + + Class resType; + if (isShortCircuit) { + resType = boolean.class; + } else if (props.returnsValue) { + resType = Object.class; + } else { + resType = void.class; + } CodeExecutableElement metExecute = new CodeExecutableElement( Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), - context.getType(props.returnsValue ? Object.class : void.class), "execute"); + context.getType(resType), "execute"); metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index ac48e6f1f60e..1043bb4de5d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -26,7 +26,7 @@ public enum DataKind { } private final SingleOperationData data; - private ExecutableElement executeMethod; + protected ExecutableElement executeMethod; private DataKind[] dataKinds = null; private int numChildNodes; private int numConsts; @@ -78,6 +78,11 @@ public CustomInstruction(String name, int id, SingleOperationData data) { this.data = data; } + protected CustomInstruction(String name, int id, SingleOperationData data, ResultType[] results, InputType[] inputs) { + super(name, id, results, inputs); + this.data = data; + } + @Override protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { if (getAdditionalStateBytes() == 0) { @@ -139,18 +144,7 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (vars.tracer != null) { - b.startStatement().startCall(vars.tracer, "traceActiveSpecializations"); - b.variable(vars.bci); - b.variable(opcodeIdField); - - b.startStaticCall(getSpecializationBits); - b.variable(vars.bc); - b.variable(vars.bci); - b.end(); - - b.end(2); - } + createTracerCode(vars, b); if (data.getMainProperties().isVariadic) { @@ -218,6 +212,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + protected void createTracerCode(ExecutionVariables vars, CodeTreeBuilder b) { + if (vars.tracer != null) { + b.startStatement().startCall(vars.tracer, "traceActiveSpecializations"); + b.variable(vars.bci); + b.variable(opcodeIdField); + + b.startStaticCall(getSpecializationBits); + b.variable(vars.bc); + b.variable(vars.bci); + b.end(); + + b.end(2); + } + } + @Override public int getAdditionalStateBytes() { if (dataKinds == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java new file mode 100644 index 000000000000..4632de0fd0d8 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -0,0 +1,50 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.SingleOperationData; + +public class ShortCircuitInstruction extends CustomInstruction { + + public ShortCircuitInstruction(String name, int id, SingleOperationData data) { + super(name, id, data, new ResultType[]{ResultType.BRANCH}, new InputType[]{InputType.STACK_VALUE, InputType.BRANCH_TARGET}); + } + + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + createTracerCode(vars, b); + + b.startIf(); + if (!getData().getShortCircuitContinueWhen()) { + b.string("!"); + } + + b.startCall("this", executeMethod); + b.variable(vars.frame); + b.variable(vars.bci); + b.variable(vars.sp); + b.end(2).startBlock(); + { + b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.statement("continue loop"); + } + b.end().startElseBlock(); + { + b.startAssign(vars.bci).tree(createReadArgumentCode(1, vars)).end(); + + b.statement("continue loop"); + } + b.end(); + + return b.build(); + } + +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index e48fed0de4c9..4cd822578d09 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -19,6 +19,7 @@ import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; +import com.oracle.truffle.api.operation.ShortCircuitOperation; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.nodes.SLTypes; @@ -56,6 +57,8 @@ @OperationProxy(SLUnboxNode.class) @OperationProxy(SLFunctionLiteralNode.class) @OperationProxy(SLToBooleanNode.class) +@ShortCircuitOperation(name = "SLAnd", booleanConverter = SLToBooleanNode.class, continueWhen = true) +@ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) public final class SLOperations { @Metadata("MethodName") // diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index e2f3317dc89c..b8f9ef9f00a9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -271,127 +271,33 @@ public Void visitReturn_statement(Return_statementContext ctx) { return null; } - /** - *
-     * a || b
-     * 
- * - *
-     * {
-     *  l0 = a;
-     *  l0 ? l0 : b;
-     * }
-     * 
- */ - private void logicalOrBegin(OperationLocal localIdx) { - b.beginBlock(); - b.beginStoreLocal(localIdx); - } - - private void logicalOrMiddle(OperationLocal localIdx) { - b.endStoreLocal(); - b.beginConditional(); - b.beginSLToBoolean(); - b.emitLoadLocal(localIdx); - b.endSLToBoolean(); - b.emitLoadLocal(localIdx); - } - - private void logicalOrEnd(@SuppressWarnings("unused") OperationLocal localIdx) { - b.endConditional(); - b.endBlock(); - } - @Override public Void visitExpression(ExpressionContext ctx) { - int numTerms = ctx.logic_term().size(); - - if (numTerms == 1) - return visit(ctx.logic_term(0)); b.beginTag(StandardTags.ExpressionTag.class); - OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; - for (int i = 0; i < numTerms - 1; i++) { - tmpLocals[i] = b.createLocal(); - logicalOrBegin(tmpLocals[i]); + b.beginSLOr(); + for (Logic_termContext term : ctx.logic_term()) { + visit(term); } + b.endSLOr(); - for (int i = 0; i < numTerms; i++) { - visit(ctx.logic_term(i)); - - if (i != 0) { - logicalOrEnd(tmpLocals[i - 1]); - } - - if (i != numTerms - 1) { - logicalOrMiddle(tmpLocals[i]); - } - } b.endTag(); return null; } - /** - *
-     * a && b
-     * 
- * - *
-     * {
-     *  l0 = a;
-     *  l0 ? b : l0;
-     * }
-     * 
- */ - private void logicalAndBegin(OperationLocal localIdx) { - b.beginBlock(); - b.beginStoreLocal(localIdx); - } - - private void logicalAndMiddle(OperationLocal localIdx) { - b.endStoreLocal(); - b.beginConditional(); - b.beginSLToBoolean(); - b.emitLoadLocal(localIdx); - b.endSLToBoolean(); - } - - private void logicalAndEnd(OperationLocal localIdx) { - b.emitLoadLocal(localIdx); - b.endConditional(); - b.endBlock(); - } - @Override public Void visitLogic_term(Logic_termContext ctx) { - int numTerms = ctx.logic_factor().size(); - - if (numTerms == 1) { - return visit(ctx.logic_factor(0)); - } b.beginTag(StandardTags.ExpressionTag.class); b.beginSLUnbox(); - OperationLocal[] tmpLocals = new OperationLocal[numTerms - 1]; - for (int i = 0; i < numTerms - 1; i++) { - tmpLocals[i] = b.createLocal(); - logicalAndBegin(tmpLocals[i]); - } - - for (int i = 0; i < numTerms; i++) { - visit(ctx.logic_factor(i)); - - if (i != 0) { - logicalAndEnd(tmpLocals[i - 1]); - } - - if (i != numTerms - 1) { - logicalAndMiddle(tmpLocals[i]); - } + b.beginSLAnd(); + for (Logic_factorContext factor : ctx.logic_factor()) { + visit(factor); } + b.endSLAnd(); b.endSLUnbox(); b.endTag(); From 7f21bd547eabc5b78644049aadb096731b0626ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 17 May 2022 14:55:29 +0200 Subject: [PATCH 087/312] [wip] be on primitives --- .../sl/operations/SLOperationsBuilder.java | 372 +++++++++++++++--- .../api/operation/BuilderOperationData.java | 2 - .../api/operation/OperationBuilder.java | 19 +- .../api/operation/OperationBytecodeNode.java | 30 +- .../dsl/processor/java/ElementUtils.java | 4 + .../OperationsBytecodeCodeGenerator.java | 3 + .../operations/OperationsContext.java | 11 +- .../operations/instructions/FrameKind.java | 37 +- .../instructions/LoadLocalInstruction.java | 151 +++++-- .../instructions/StoreLocalInstruction.java | 216 +++++++++- 10 files changed, 706 insertions(+), 139 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index edbf2eb469cc..461b222b5c6e 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -13,6 +13,7 @@ import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.dsl.GenerateAOT.Provider; import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.LibraryFactory; @@ -269,55 +270,59 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; private static final int INSTR_LOAD_ARGUMENT_LONG = 10; - private static final int INSTR_STORE_LOCAL = 11; - private static final int INSTR_LOAD_LOCAL_OBJECT = 12; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 13; - private static final int INSTR_LOAD_LOCAL_LONG = 14; - private static final int INSTR_RETURN = 15; - private static final int INSTR_INSTRUMENT_ENTER = 16; - private static final int INSTR_INSTRUMENT_EXIT_VOID = 17; - private static final int INSTR_INSTRUMENT_EXIT = 18; - private static final int INSTR_INSTRUMENT_LEAVE = 19; - private static final int INSTR_C_SLADD = 20; - private static final int INSTR_C_SLDIV = 21; - private static final int INSTR_C_SLEQUAL = 22; - private static final int INSTR_C_SLLESS_OR_EQUAL = 23; - private static final int INSTR_C_SLLESS_THAN = 24; - private static final int INSTR_C_SLLOGICAL_NOT = 25; - private static final int INSTR_C_SLMUL = 26; - private static final int INSTR_C_SLREAD_PROPERTY = 27; - private static final int INSTR_C_SLSUB = 28; - private static final int INSTR_C_SLWRITE_PROPERTY = 29; - private static final int INSTR_C_SLUNBOX = 30; - private static final int INSTR_C_SLFUNCTION_LITERAL = 31; - private static final int INSTR_C_SLTO_BOOLEAN = 32; - private static final int INSTR_SC_SLAND = 33; - private static final int INSTR_SC_SLOR = 34; - private static final int INSTR_C_SLINVOKE = 35; - private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 36; - private static final int INSTR_C_SLADD_Q_ADD_LONG = 37; - private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 38; - private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 39; - private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 40; - private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 41; - private static final int INSTR_C_SLINVOKE_Q_DIRECT = 42; - private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 43; - private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 44; - private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 45; + private static final int INSTR_STORE_LOCAL_OBJECT = 11; + private static final int INSTR_STORE_LOCAL_BOOLEAN = 12; + private static final int INSTR_STORE_LOCAL_LONG = 13; + private static final int INSTR_STORE_LOCAL_UNINIT = 14; + private static final int INSTR_LOAD_LOCAL_OBJECT = 15; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; + private static final int INSTR_LOAD_LOCAL_LONG = 17; + private static final int INSTR_LOAD_LOCAL_UNINIT = 18; + private static final int INSTR_RETURN = 19; + private static final int INSTR_INSTRUMENT_ENTER = 20; + private static final int INSTR_INSTRUMENT_EXIT_VOID = 21; + private static final int INSTR_INSTRUMENT_EXIT = 22; + private static final int INSTR_INSTRUMENT_LEAVE = 23; + private static final int INSTR_C_SLADD = 24; + private static final int INSTR_C_SLDIV = 25; + private static final int INSTR_C_SLEQUAL = 26; + private static final int INSTR_C_SLLESS_OR_EQUAL = 27; + private static final int INSTR_C_SLLESS_THAN = 28; + private static final int INSTR_C_SLLOGICAL_NOT = 29; + private static final int INSTR_C_SLMUL = 30; + private static final int INSTR_C_SLREAD_PROPERTY = 31; + private static final int INSTR_C_SLSUB = 32; + private static final int INSTR_C_SLWRITE_PROPERTY = 33; + private static final int INSTR_C_SLUNBOX = 34; + private static final int INSTR_C_SLFUNCTION_LITERAL = 35; + private static final int INSTR_C_SLTO_BOOLEAN = 36; + private static final int INSTR_SC_SLAND = 37; + private static final int INSTR_SC_SLOR = 38; + private static final int INSTR_C_SLINVOKE = 39; + private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 40; + private static final int INSTR_C_SLADD_Q_ADD_LONG = 41; + private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 42; + private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 43; + private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 44; + private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; + private static final int INSTR_C_SLINVOKE_Q_DIRECT = 46; + private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 47; + private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 48; + private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 49; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, - // BYTE - null, - // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + // LONG + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, + // DOUBLE + null, // FLOAT null, - // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_LOAD_LOCAL_LONG, INSTR_LOAD_LOCAL_BOOLEAN, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, - // DOUBLE + // BOOLEAN + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + // BYTE null}; int lastChildPush; @@ -887,7 +892,7 @@ public void endStoreLocal() { throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); } int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL); + LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_UNINIT); bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); LE_BYTES.putShort(bc, bci + 3, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 5; @@ -901,7 +906,7 @@ public void emitLoadLocal(OperationLocal arg0) { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); int[] predecessorBcis = doBeforeEmitInstruction(0, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_OBJECT); + LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_UNINIT); LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.arguments[0])); bci = bci + 4; lastChildPush = 1; @@ -1589,7 +1594,25 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * store.local + * store.local.object + * Inputs: + * STACK_VALUE + * Results: + * SET_LOCAL + * + * store.local.boolean + * Inputs: + * STACK_VALUE + * Results: + * SET_LOCAL + * + * store.local.long + * Inputs: + * STACK_VALUE + * Results: + * SET_LOCAL + * + * store.local.uninit * Inputs: * STACK_VALUE * Results: @@ -1613,6 +1636,12 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * + * load.local.uninit + * Inputs: + * LOCAL + * Results: + * STACK_VALUE + * * return * Inputs: * STACK_VALUE @@ -2186,41 +2215,138 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_STORE_LOCAL : + case INSTR_STORE_LOCAL_OBJECT : + { + int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; + int sourceSlot = sp - 1; + frame.setObject(localIdx, expectObject(frame, sourceSlot)); + // here: + sp--; + nextBci = bci + 5; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN : + { + int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; + int sourceSlot = sp - 1; + FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); + do { + if (localTag == FrameSlotKind.Boolean) { + try { + frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); + break /* goto here */; + } catch (UnexpectedResultException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_OBJECT); + doSetResultBoxed(bc, bci, bc[bci + 2], FRAME_TYPE_OBJECT); + frame.setObject(localIdx, expectObject(frame, sourceSlot)); + } while (false); + // here: + sp--; + nextBci = bci + 5; + break; + } + case INSTR_STORE_LOCAL_LONG : + { + int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; + int sourceSlot = sp - 1; + FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); + do { + if (localTag == FrameSlotKind.Long) { + try { + frame.setLong(localIdx, expectLong(frame, sourceSlot)); + break /* goto here */; + } catch (UnexpectedResultException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_OBJECT); + doSetResultBoxed(bc, bci, bc[bci + 2], FRAME_TYPE_OBJECT); + frame.setObject(localIdx, expectObject(frame, sourceSlot)); + } while (false); + // here: + sp--; + nextBci = bci + 5; + break; + } + case INSTR_STORE_LOCAL_UNINIT : { - assert frame.isObject(sp - 1); - frame.copy(sp - 1, LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET); - frame.clear(--sp); + int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; + int sourceSlot = sp - 1; + FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); + if (localTag == FrameSlotKind.Illegal) { + assert frame.isObject(sourceSlot); + frame.copy(sourceSlot, localIdx); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + int resultTag = storeLocalInitialization(frame, localIdx, localTag.tag, sourceSlot); + setResultBoxedImpl(bc, bci, resultTag, BOXING_DESCRIPTORS[resultTag]); + doSetResultBoxed(bc, bci, bc[bci + 2], resultTag); + } + // here: + sp--; nextBci = bci + 5; break; } case INSTR_LOAD_LOCAL_OBJECT : { - frame.copy(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET, sp); + int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; + if (frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + frame.setObject(localIdx, frame.getValue(localIdx)); + } + frame.copy(localIdx, sp); sp++; nextBci = bci + 4; break; } case INSTR_LOAD_LOCAL_BOOLEAN : { - Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); - } else { - frame.setObject(sp, value); + int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; + FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); + if (localType != FrameSlotKind.Boolean) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object localValue; + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + frame.setBoolean(localIdx, (boolean) localValue); + } else { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + } } + frame.copy(localIdx, sp); sp++; nextBci = bci + 4; break; } case INSTR_LOAD_LOCAL_LONG : { - Object value = frame.getObject(LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET); - if (value instanceof Long) { - frame.setLong(sp, (long) value); - } else { - frame.setObject(sp, value); + int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; + FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); + if (localType != FrameSlotKind.Long) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object localValue; + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + frame.setLong(localIdx, (long) localValue); + } else { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + } } + frame.copy(localIdx, sp); + sp++; + nextBci = bci + 4; + break; + } + case INSTR_LOAD_LOCAL_UNINIT : + { + int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; + frame.setObject(sp, expectObject(frame, localIdx)); sp++; nextBci = bci + 4; break; @@ -6036,6 +6162,7 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_LOAD_LOCAL_OBJECT : case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_UNINIT : case INSTR_C_SLLOGICAL_NOT : case INSTR_C_SLTO_BOOLEAN : case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : @@ -6055,7 +6182,10 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 4; break; } - case INSTR_STORE_LOCAL : + case INSTR_STORE_LOCAL_OBJECT : + case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_UNINIT : case INSTR_C_SLLESS_OR_EQUAL : case INSTR_C_SLLESS_THAN : case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : @@ -6376,7 +6506,82 @@ public String dump() { bci += 4; break; } - case INSTR_STORE_LOCAL : + case INSTR_STORE_LOCAL_OBJECT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.object "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); + bci += 5; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.boolean "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); + bci += 5; + break; + } + case INSTR_STORE_LOCAL_LONG : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(String.format("%02x ", bc[bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.long "); + sb.append(String.format("pop[-%d]", bc[bci + 2])); + sb.append(" -> "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); + bci += 5; + break; + } + case INSTR_STORE_LOCAL_UNINIT : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6394,7 +6599,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local "); + sb.append("store.local.uninit "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); @@ -6476,6 +6681,31 @@ public String dump() { bci += 4; break; } + case INSTR_LOAD_LOCAL_UNINIT : + { + sb.append(String.format("%02x ", bc[bci + 0])); + sb.append(String.format("%02x ", bc[bci + 1])); + sb.append(String.format("%02x ", bc[bci + 2])); + sb.append(String.format("%02x ", bc[bci + 3])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.uninit "); + sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); + sb.append(" -> "); + sb.append("x"); + bci += 4; + break; + } case INSTR_RETURN : { sb.append(String.format("%02x ", bc[bci + 0])); @@ -7304,6 +7534,20 @@ private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $fram return true; } + private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { + Object value = frame.getValue(sourceSlot); + if (localTag == FRAME_TYPE_BOOLEAN && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return FRAME_TYPE_BOOLEAN; + } + if (localTag == FRAME_TYPE_LONG && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return FRAME_TYPE_LONG; + } + frame.setObject(localIdx, value); + return FRAME_TYPE_OBJECT; + } + private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { if (bciOffset != 0) { setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index 2775479df924..165e2f91899d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -9,7 +9,6 @@ public class BuilderOperationData { public final Object[] aux; public final Object[] arguments; public int numChildren = 0; - public int numLocals; public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { this.parent = parent; @@ -19,6 +18,5 @@ public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, this.aux = new Object[numAux]; this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); this.arguments = arguments; - numLocals = parent != null ? parent.numLocals : 0; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index a69cbb64a4a9..33bf27de1495 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -206,34 +206,19 @@ protected void setCurStack(int curStack) { protected int numLocals; public final OperationLocal createLocal() { - BuilderOperationLocal local = new BuilderOperationLocal(operationData, operationData.numLocals++); - - if (numLocals < local.id + 1) { - numLocals = local.id + 1; - } - + BuilderOperationLocal local = new BuilderOperationLocal(operationData, numLocals++); return local; } protected final OperationLocal createParentLocal() { BuilderOperationData parent = operationData.parent; - assert operationData.numLocals == parent.numLocals; - - BuilderOperationLocal local = new BuilderOperationLocal(parent, parent.numLocals++); - operationData.numLocals++; - - if (numLocals < local.id + 1) { - numLocals = local.id + 1; - } - + BuilderOperationLocal local = new BuilderOperationLocal(parent, numLocals++); return local; } protected int getLocalIndex(Object value) { BuilderOperationLocal local = (BuilderOperationLocal) value; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return local.id; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java index e05aa5302b17..ebb549dce5c2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; @@ -13,14 +14,26 @@ public abstract class OperationBytecodeNode extends Node implements BytecodeOSRNode { - // The order of these must be the same as FrameKind in processor + // Thevalues of these must be the same as FrameKind.ordinal && Frame tags public static final int FRAME_TYPE_OBJECT = 0; - public static final int FRAME_TYPE_BYTE = 1; - public static final int FRAME_TYPE_BOOLEAN = 2; - public static final int FRAME_TYPE_INT = 3; + public static final int FRAME_TYPE_LONG = 1; + public static final int FRAME_TYPE_INT = 2; + public static final int FRAME_TYPE_DOUBLE = 3; public static final int FRAME_TYPE_FLOAT = 4; - public static final int FRAME_TYPE_LONG = 5; - public static final int FRAME_TYPE_DOUBLE = 6; + public static final int FRAME_TYPE_BOOLEAN = 5; + public static final int FRAME_TYPE_BYTE = 6; + public static final int FRAME_TYPE_ILLEGAL = 7; + + static { + assert FRAME_TYPE_OBJECT == FrameSlotKind.Object.tag; + assert FRAME_TYPE_LONG == FrameSlotKind.Long.tag; + assert FRAME_TYPE_INT == FrameSlotKind.Int.tag; + assert FRAME_TYPE_DOUBLE == FrameSlotKind.Double.tag; + assert FRAME_TYPE_FLOAT == FrameSlotKind.Float.tag; + assert FRAME_TYPE_BOOLEAN == FrameSlotKind.Boolean.tag; + assert FRAME_TYPE_BYTE == FrameSlotKind.Byte.tag; + assert FRAME_TYPE_ILLEGAL == FrameSlotKind.Illegal.tag; + } private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); @@ -122,6 +135,7 @@ protected static byte expectByte(VirtualFrame frame, int slot) throws Unexpected break; } + CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(frame.getValue(slot)); } @@ -152,6 +166,7 @@ protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedRe break; } + CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(frame.getValue(slot)); } @@ -167,6 +182,7 @@ protected static float expectFloat(VirtualFrame frame, int slot) throws Unexpect break; } + CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(frame.getValue(slot)); } @@ -182,6 +198,7 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected break; } + CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(frame.getValue(slot)); } @@ -197,6 +214,7 @@ protected static double expectDouble(VirtualFrame frame, int slot) throws Unexpe break; } + CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(frame.getValue(slot)); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 3918dad1ed63..a1663042eda0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -220,6 +220,10 @@ public static String createReferenceName(ExecutableElement method) { return b.toString(); } + public static TypeMirror boxType(TypeMirror type) { + return boxType(ProcessorContext.getInstance(), type); + } + public static TypeMirror boxType(ProcessorContext context, TypeMirror primitiveType) { if (primitiveType == null) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 589188b7d3d9..34b3231fd3b6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -32,6 +32,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; public class OperationsBytecodeCodeGenerator { @@ -224,6 +225,8 @@ public CodeTypeElement createBuilderBytecodeNode() { for (CodeVariableElement element : staticConstants.elements()) { builderBytecodeNodeType.add(element); } + + builderBytecodeNodeType.add(StoreLocalInstruction.createStoreLocalInitialization(m.getOperationsContext())); } ExecutionVariables vars = new ExecutionVariables(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 5c3a5ee5d462..76496c33ea00 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -41,6 +41,7 @@ public class OperationsContext { public LoadArgumentInstruction[] loadArgumentInstructions; public LoadConstantInstruction[] loadConstantInstructions; public LoadLocalInstruction[] loadLocalInstructions; + public StoreLocalInstruction[] storeLocalInstructions; public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); @@ -97,14 +98,20 @@ private void createBuiltinOperations() { } private void createLoadStoreLocal() { - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(instructionId++)))); + storeLocalInstructions = new StoreLocalInstruction[FrameKind.values().length]; + for (FrameKind kind : data.getFrameKinds()) { + storeLocalInstructions[kind.ordinal()] = add(new StoreLocalInstruction(this, instructionId++, kind)); + } + StoreLocalInstruction uninitStoreLocal = add(new StoreLocalInstruction(this, instructionId++, null)); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, uninitStoreLocal)); loadLocalInstructions = new LoadLocalInstruction[FrameKind.values().length]; for (FrameKind kind : data.getFrameKinds()) { loadLocalInstructions[kind.ordinal()] = add(new LoadLocalInstruction(this, instructionId++, kind)); } + LoadLocalInstruction uninitLoadLocal = add(new LoadLocalInstruction(this, instructionId++, null)); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalInstructions[FrameKind.OBJECT.ordinal()])); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, uninitLoadLocal)); } private void createLoadArgument() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index f801e4ba895c..4256335e838e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -1,13 +1,19 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; + public enum FrameKind { + // order must be the same as FrameSlotKind OBJECT("Object", "Object"), - BYTE("byte", "Byte"), - BOOLEAN("boolean", "Boolean"), + LONG("long", "Long"), INT("int", "Int", "Integer"), + DOUBLE("double", "Double"), FLOAT("float", "Float"), - LONG("long", "Long"), - DOUBLE("double", "Double"); + BOOLEAN("boolean", "Boolean"), + BYTE("byte", "Byte"); private final String typeName; private final String frameName; @@ -42,4 +48,27 @@ public String getTypeName() { public String getTypeNameBoxed() { return typeNameBoxed; } + + public TypeMirror getType() { + ProcessorContext context = ProcessorContext.getInstance(); + switch (this) { + case BOOLEAN: + return context.getType(boolean.class); + case BYTE: + return context.getType(byte.class); + case DOUBLE: + return context.getType(double.class); + case FLOAT: + return context.getType(float.class); + case INT: + return context.getType(int.class); + case LONG: + return context.getType(long.class); + case OBJECT: + return context.getType(Object.class); + default: + throw new UnsupportedOperationException(); + + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 1ab1e8c4b342..ea77b667f77f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -1,7 +1,12 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.TypeKind; + +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -10,8 +15,10 @@ public class LoadLocalInstruction extends Instruction { private final OperationsContext ctx; private final FrameKind kind; + private static final boolean LOG_LOCAL_LOADS = false; + public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.local." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.LOCAL); + super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, ResultType.STACK_VALUE, InputType.LOCAL); this.ctx = ctx; this.kind = kind; } @@ -25,14 +32,7 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (kind == FrameKind.OBJECT) { - b.startStatement().startCall(vars.frame, "copy"); - } else { - b.startAssign("Object value"); - b.startCall(vars.frame, "getObject"); - } - - b.startGroup(); + b.startAssign("int localIdx"); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); @@ -40,28 +40,84 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string(" + VALUES_OFFSET"); b.end(); - if (kind == FrameKind.OBJECT) { - b.variable(vars.sp); - } + if (kind == null) { + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [uninit]%n\", localIdx, frame.getValue(localIdx))"); + } + createCopyAsObject(vars, b); + } else if (kind == FrameKind.OBJECT) { + b.startIf(); + { + b.startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(); + b.string(" != "); + b.staticReference(StoreLocalInstruction.FrameSlotKind, "Object"); + } + b.end().startBlock(); + { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.end(2); + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, frame.getValue(localIdx))"); + } - if (kind != FrameKind.OBJECT) { - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - { - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.variable(vars.sp); - b.string("(", kind.getTypeName(), ") value"); - b.end(2); + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + createReplaceObject(vars, b); + } + b.end(); + + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [generic]%n\", localIdx, frame.getValue(localIdx))"); } - b.end().startElseBlock(); + + createCopy(vars, b); + } else { + + b.declaration(StoreLocalInstruction.FrameSlotKind, "localType", + b.create().startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end().build()); + + b.startIf(); + b.string("localType != ").staticReference(StoreLocalInstruction.FrameSlotKind, kind.getFrameName()); + b.end().startBlock(); { - b.startStatement().startCall(vars.frame, "setObject"); - b.variable(vars.sp); - b.string("value"); - b.end(2); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.declaration("Object", "localValue", (CodeTree) null); + + b.startIf(); + { + b.string("localType == ").staticReference(StoreLocalInstruction.FrameSlotKind, "Illegal"); + b.string(" && "); + b.string("(localValue = frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); + } + b.end().startBlock(); + { + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + } + + createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); + + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.string("localIdx"); + b.startGroup().cast(kind.getType()).string("localValue").end(); + b.end(2); + } + b.end().startElseBlock(); + { + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(localIdx))"); + } + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + } + b.end(); } b.end(); + + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + } + + createCopy(vars, b); } b.startStatement().variable(vars.sp).string("++").end(); @@ -71,18 +127,53 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.REPLACE; + if (kind == FrameKind.OBJECT) { + return BoxingEliminationBehaviour.DO_NOTHING; + } else { + return BoxingEliminationBehaviour.REPLACE; + } + } + + private static void createCopy(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copy"); + b.string("localIdx"); + b.variable(vars.sp); + b.end(2); + } + + private static void createSetSlotKind(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.startStatement().startCall(vars.frame, "getFrameDescriptor().setSlotKind"); + b.string("localIdx"); + b.string(tag); + b.end(2); + } + + private static void createReplaceObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "setObject"); + b.string("localIdx"); + b.startCall(vars.frame, "getValue").string("localIdx").end(); + b.end(2); + } + + private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "setObject"); + b.variable(vars.sp); + b.startCall("expectObject").variable(vars.frame).string("localIdx").end(); + b.end(2); } @Override public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { - if (kind == FrameKind.OBJECT) { + if (kind == null) { + // unitialized -> anything return ctx.loadLocalInstructions[targetKind.ordinal()].opcodeIdField; } else { - if (targetKind == FrameKind.OBJECT) { - return ctx.loadLocalInstructions[targetKind.ordinal()].opcodeIdField; + if (targetKind == kind || kind == FrameKind.OBJECT) { + // do nothing + return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "0"); } else { - return opcodeIdField; + // prim -> anything different = object + return ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 029eae90e456..9e4b8b83b7ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -1,12 +1,33 @@ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.Set; + +import javax.lang.model.element.Modifier; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class StoreLocalInstruction extends Instruction { + private final FrameKind kind; + private final OperationsContext context; + + static final DeclaredType FrameSlotKind = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.frame.FrameSlotKind"); + + private static final boolean LOG_LOCAL_STORES = false; - public StoreLocalInstruction(int id) { - super("store.local", id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) { + super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + this.context = context; + this.kind = kind; } @Override @@ -14,19 +35,58 @@ public boolean standardPrologue() { return false; } + public static CodeExecutableElement createStoreLocalInitialization(OperationsContext context) { + ProcessorContext ctx = ProcessorContext.getInstance(); + + CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), new CodeTypeMirror(TypeKind.INT), "storeLocalInitialization"); + method.addParameter(new CodeVariableElement(ctx.getTypes().VirtualFrame, "frame")); + method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "localIdx")); + method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "localTag")); + method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "sourceSlot")); + + CodeTreeBuilder b = method.createBuilder(); + + b.startAssign("Object value").string("frame.getValue(sourceSlot)").end(); + + for (FrameKind kind : context.getData().getFrameKinds()) { + if (kind == FrameKind.OBJECT) { + continue; + } + b.startIf(); + { + b.string("localTag == FRAME_TYPE_" + kind); + b.string(" && "); + b.string("value instanceof " + kind.getTypeNameBoxed()); + } + b.end().startBlock(); + { + b.startStatement().startCall("frame", "set" + kind.getFrameName()); + b.string("localIdx"); + b.startGroup().cast(kind.getType()).string("value").end(); + b.end(2); + + b.startReturn().string("FRAME_TYPE_" + kind).end(); + } + b.end(); + } + + b.startStatement().startCall("frame", "setObject"); + b.string("localIdx"); + b.string("value"); + b.end(2); + + b.startReturn().string("FRAME_TYPE_OBJECT").end(); + + return method; + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssert().startCall(vars.frame, "isObject"); - b.startGroup().variable(vars.sp).string(" - 1").end(); - b.end(2); - - b.startStatement().startCall(vars.frame, "copy"); + // TODO: implement version w/o BE, if a language does not need it - b.startGroup().variable(vars.sp).string(" - 1").end(); - - b.startGroup(); + b.startAssign("int localIdx"); b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(1)).end(); @@ -34,19 +94,147 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string(" + VALUES_OFFSET"); b.end(); + b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); + + if (kind == null) { + b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); + + b.startIf().string("localTag == ").staticReference(FrameSlotKind, "Illegal").end().startBlock(); + { + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, frame.getValue(sourceSlot))"); + } + b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); + createCopy(vars, b); + } + b.end().startElseBlock(); + { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.startAssign("int resultTag").startCall("storeLocalInitialization"); + b.variable(vars.frame); + b.string("localIdx"); + b.string("localTag.tag"); + b.string("sourceSlot"); + b.end(2); + + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); + } + + b.startStatement().startCall("setResultBoxedImpl"); + b.variable(vars.bc); + b.variable(vars.bci); + b.string("resultTag"); + b.string("BOXING_DESCRIPTORS[resultTag]"); + b.end(2); + + createSetChildBoxing(vars, b, "resultTag"); + } + b.end(); + } else if (kind == FrameKind.OBJECT) { + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [generic]%n\", localIdx, frame.getValue(sourceSlot))"); + } + + b.startStatement().startCall(vars.frame, "setObject"); + b.string("localIdx"); + b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); + b.end(2); + } else { + // primitive + b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); + + b.startDoBlock(); + { + b.startIf().string("localTag == ").staticReference(FrameSlotKind, kind.getFrameName()).end().startBlock(); + { + b.startTryBlock(); + { + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(sourceSlot))"); + } + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.string("localIdx"); + b.startCall("expect" + kind.getFrameName()).variable(vars.frame).string("sourceSlot").end(); + b.end(2); + + b.statement("break /* goto here */"); + } + b.end().startCatchBlock(OperationGeneratorUtils.getTypes().UnexpectedResultException, "ex"); + { + + } + b.end(); + } + b.end(); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(sourceSlot))"); + } + + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + createGenerifySelf(vars, b); + createSetChildBoxing(vars, b, "FRAME_TYPE_OBJECT"); + createCopyAsObject(vars, b); + } + b.end().startDoWhile().string("false").end(2); + } + + b.lineComment("here:"); + b.startStatement().variable(vars.sp).string("--").end(); + + return b.build(); + } + + private static void createCopy(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copy"); + b.string("sourceSlot"); + b.string("localIdx"); b.end(2); + } - b.startStatement().startCall(vars.frame, "clear"); - b.startGroup().string("--").variable(vars.sp).end(); + private static void createSetSlotKind(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.startStatement().startCall(vars.frame, "getFrameDescriptor().setSlotKind"); + b.string("localIdx"); + b.string(tag); b.end(2); + } - return b.build(); + private void createSetChildBoxing(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.startStatement().startCall("doSetResultBoxed"); + b.variable(vars.bc); + b.variable(vars.bci); + b.startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]").end(); + b.string(tag); + b.end(2); + } + + private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "setObject"); + b.string("localIdx"); + b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); + b.end(2); + } + private void createGenerifySelf(ExecutionVariables vars, CodeTreeBuilder b) { + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); } @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; + return BoxingEliminationBehaviour.REPLACE; + } + + @Override + public CodeVariableElement boxingEliminationReplacement(FrameKind newKind) { + if (kind == null) { + return context.storeLocalInstructions[newKind.ordinal()].opcodeIdField; + } else { + return context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; + } } @Override From 79c3e82c91b722265e0deaf860939b784bccabaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 May 2022 13:12:03 +0200 Subject: [PATCH 088/312] [wip] store child/const offsets --- .../sl/operations/SLOperationsBuilder.java | 621 +++++++++++------- .../test/example/TestOperations.java | 3 +- .../example/TestOperationsParserTest.java | 12 +- .../api/operation/GenerateOperations.java | 2 +- .../api/operation/OperationBuilder.java | 246 ++++++- .../api/operation/OperationBytecodeNode.java | 220 ------- .../OperationInstrumentedBytecodeNode.java | 16 - .../truffle/api/operation/OperationNode.java | 13 +- .../truffle/dsl/processor/TruffleTypes.java | 2 +- .../generator/FlatNodeGenFactory.java | 50 +- .../generator/NodeGeneratorPlugs.java | 6 +- .../operations/OperationMetadataParser.java | 8 +- .../OperationsBytecodeCodeGenerator.java | 4 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 58 +- .../operations/OperationsParser.java | 2 + .../operations/SingleOperationParser.java | 12 +- .../sl/nodes/SLOperationsRootNode.java | 2 +- .../truffle/sl/operations/SLOperations.java | 3 +- .../sl/parser/SLOperationsVisitor.java | 12 +- 19 files changed, 744 insertions(+), 548 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 461b222b5c6e..a696f81b0029 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -32,9 +32,7 @@ import com.oracle.truffle.api.operation.BuilderOperationData; import com.oracle.truffle.api.operation.BuilderOperationLabel; import com.oracle.truffle.api.operation.OperationBuilder; -import com.oracle.truffle.api.operation.OperationBytecodeNode; import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationInstrumentedBytecodeNode; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; @@ -265,18 +263,18 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_CONSTANT_LONG = 7; + private static final int INSTR_LOAD_CONSTANT_LONG = 6; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_LOAD_ARGUMENT_LONG = 10; + private static final int INSTR_LOAD_ARGUMENT_LONG = 9; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; private static final int INSTR_STORE_LOCAL_OBJECT = 11; - private static final int INSTR_STORE_LOCAL_BOOLEAN = 12; - private static final int INSTR_STORE_LOCAL_LONG = 13; + private static final int INSTR_STORE_LOCAL_LONG = 12; + private static final int INSTR_STORE_LOCAL_BOOLEAN = 13; private static final int INSTR_STORE_LOCAL_UNINIT = 14; private static final int INSTR_LOAD_LOCAL_OBJECT = 15; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; - private static final int INSTR_LOAD_LOCAL_LONG = 17; + private static final int INSTR_LOAD_LOCAL_LONG = 16; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; private static final int INSTR_LOAD_LOCAL_UNINIT = 18; private static final int INSTR_RETURN = 19; private static final int INSTR_INSTRUMENT_ENTER = 20; @@ -313,7 +311,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, // DOUBLE @@ -321,7 +319,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // BYTE null}; @@ -333,17 +331,17 @@ private static class BuilderImpl extends SLOperationsBuilder { } @Override - protected OperationNode createNode(OperationNodes arg0, Object arg1, OperationBytecodeNode arg2) { + protected OperationNode createNode(OperationNodes arg0, Object arg1, com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode arg2) { return new OperationNodeImpl(arg0, arg1, arg2); } @Override - protected OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { - return new BytecodeNode(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + protected com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { + return new com.oracle.truffle.sl.operations.SLOperationsBuilder.BuilderImpl.BytecodeNode(arg0, arg1, arg2, arg3, arg4, arg5, arg6); } @Override - protected OperationInstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { + protected InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { throw new UnsupportedOperationException("not implemented"); } @@ -1524,12 +1522,12 @@ private static final class OperationNodeImpl extends OperationNode { private TruffleString MethodName; - private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationBytecodeNode bcNode) { + private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode bcNode) { super(nodes, sourceInfo, bcNode); } static { - setMetadataAccessor(SLOperations.METHOD_NAME, n -> ((OperationNodeImpl) n).MethodName); + setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n).MethodName); } } @@ -1564,13 +1562,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: @@ -1582,13 +1580,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: @@ -1600,13 +1598,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * SET_LOCAL * - * store.local.boolean + * store.local.long * Inputs: * STACK_VALUE * Results: * SET_LOCAL * - * store.local.long + * store.local.boolean * Inputs: * STACK_VALUE * Results: @@ -1624,13 +1622,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: @@ -2096,7 +2094,7 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, OperationByte */ @GeneratedBy(SLOperations.class) - private static final class BytecodeNode extends OperationBytecodeNode implements Provider { + private static final class BytecodeNode extends com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode implements Provider { private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); @@ -2169,16 +2167,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2191,11 +2189,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2203,11 +2201,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2225,15 +2223,15 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 5; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; int sourceSlot = sp - 1; FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); do { - if (localTag == FrameSlotKind.Boolean) { + if (localTag == FrameSlotKind.Long) { try { - frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); + frame.setLong(localIdx, expectLong(frame, sourceSlot)); break /* goto here */; } catch (UnexpectedResultException ex) { } @@ -2249,15 +2247,15 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 5; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; int sourceSlot = sp - 1; FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); do { - if (localTag == FrameSlotKind.Long) { + if (localTag == FrameSlotKind.Boolean) { try { - frame.setLong(localIdx, expectLong(frame, sourceSlot)); + frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); break /* goto here */; } catch (UnexpectedResultException ex) { } @@ -2305,16 +2303,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + frame.setLong(localIdx, (long) localValue); } else { frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); } @@ -2324,16 +2322,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + frame.setBoolean(localIdx, (boolean) localValue); } else { frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); } @@ -2595,6 +2593,8 @@ private void SLAdd_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -2635,6 +2635,8 @@ private void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, int $bci, int } private void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { @@ -2674,10 +2676,10 @@ private void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, int $bci, int $ } if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]); + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]); if (s2_ != null) { if ((SLAddNode.isString($child0Value_, $child1Value_))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 5)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]), ((ConcatNode) children[childArrayOffset_ + 2]))); return; } } @@ -2699,6 +2701,8 @@ private void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, int $bci, int $ } private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -2781,11 +2785,11 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, } if ((SLAddNode.isString($child0Value, $child1Value))) { SLAdd_Add1Data s2_ = super.insert(new SLAdd_Add1Data()); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2] = s2_.insertAccessor((ConcatNode.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 5)) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[childArrayOffset_ + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[childArrayOffset_ + 2] = s2_.insertAccessor((ConcatNode.create())); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s2_; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); bc[$bci + 4 + 2] = (byte) (state_1); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); @@ -2797,7 +2801,7 @@ private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 1]), ((ConcatNode) children[LE_BYTES.getShort(bc, $bci + 4 + 5) + 2]))); + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[childArrayOffset_ + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]), ((ConcatNode) children[childArrayOffset_ + 2]))); return; } { @@ -2838,6 +2842,8 @@ private void SLDiv_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -2878,6 +2884,8 @@ private void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, int $bci, int } private void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { @@ -2931,6 +2939,8 @@ private void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, int $bci, int $ } private void SLDiv_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3042,6 +3052,8 @@ private void SLEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -3068,6 +3080,8 @@ private void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, int $bci, } private void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 2); @@ -3096,6 +3110,8 @@ private void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, int @SuppressWarnings("static-method") @TruffleBoundary private Object SLEqual_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -3111,6 +3127,8 @@ private Object SLEqual_generic1Boundary_(int $bci, int $sp, byte state_0, byte s @ExplodeLoop private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { @@ -3169,7 +3187,7 @@ private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, i TruffleString $child0Value__ = (TruffleString) $child0Value_; if ($child1Value_ instanceof TruffleString) { TruffleString $child1Value__ = (TruffleString) $child1Value_; - boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 0])); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3204,10 +3222,10 @@ private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, i } if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0]); while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value_))) { - boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value_))) { + boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]), ((InteropLibrary) children[childArrayOffset_ + 2])); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3230,6 +3248,8 @@ private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, i } private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3349,7 +3369,7 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s TruffleString $child0Value_ = (TruffleString) $child0Value; if ($child1Value instanceof TruffleString) { TruffleString $child1Value_ = (TruffleString) $child1Value; - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0] = super.insert((EqualNode.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 0] = super.insert((EqualNode.create())); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); bc[$bci + 4 + 1] = (byte) (state_1); int type0; @@ -3360,7 +3380,7 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 0])); + boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[childArrayOffset_ + 0])); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3414,10 +3434,10 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s } if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]); + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0]); if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value))) { break; } s7_ = s7_.next_; @@ -3425,14 +3445,14 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s } } if (s7_ == null) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2]).accepts($child1Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value)); if (count7_ < (4)) { - s7_ = super.insert(new SLEqual_Generic0Data(((SLEqual_Generic0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + s7_ = super.insert(new SLEqual_Generic0Data(((SLEqual_Generic0Data) consts[constArrayOffset_ + 0]))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[childArrayOffset_ + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = s7_; + consts[constArrayOffset_ + 0] = s7_; bc[$bci + 4 + 0] = (byte) (state_0); bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); int type0; @@ -3446,7 +3466,7 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s if (s7_ != null) { lock.unlock(); hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 2) + 2])); + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]), ((InteropLibrary) children[childArrayOffset_ + 2])); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { @@ -3465,7 +3485,7 @@ private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); bc[$bci + 4 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 4) + 0] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0] = null; state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = (byte) (state_0); bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); @@ -3508,6 +3528,8 @@ private void SLLessOrEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -3534,6 +3556,8 @@ private void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $fram } private void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { @@ -3578,6 +3602,8 @@ private void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, } private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3681,6 +3707,8 @@ private void SLLessThan_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -3707,6 +3735,8 @@ private void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, int } private void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { @@ -3751,6 +3781,8 @@ private void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, int $ } private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3854,6 +3886,8 @@ private void SLLogicalNot_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); @@ -3872,6 +3906,8 @@ private void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, i } private void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -3899,6 +3935,8 @@ private void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, i } private void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -3957,6 +3995,8 @@ private void SLMul_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -3997,6 +4037,8 @@ private void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, int $bci, int } private void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { @@ -4050,6 +4092,8 @@ private void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, int $bci, int $ } private void SLMul_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4148,17 +4192,19 @@ private void SLMul_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, @ExplodeLoop private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 4 + 0]; + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value_))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).hasArrayElements($child0Value_))) { Node node__ = (this); int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); return; } s0_ = s0_.next_; @@ -4183,12 +4229,12 @@ private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1]); while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value__))) { + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value__))) { Node node__1 = (this); int bci__1 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]), ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); return; } s2_ = s2_.next_; @@ -4201,12 +4247,12 @@ private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { } if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2]); while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value_))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).hasMembers($child0Value_))) { Node node__2 = (this); int bci__2 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]), ((SLToMemberNode) children[childArrayOffset_ + 5]))); return; } s4_ = s4_.next_; @@ -4237,6 +4283,8 @@ private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { @SuppressWarnings("static-method") @TruffleBoundary private Object SLReadProperty_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; { Node readArray1_node__ = (this); int readArray1_bci__ = ($bci); @@ -4249,26 +4297,32 @@ private Object SLReadProperty_readArray1Boundary_(int $bci, int $sp, byte state_ @SuppressWarnings("static-method") @TruffleBoundary private Object SLReadProperty_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; { Node readSLObject1_node__ = (this); int readSLObject1_bci__ = ($bci); DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3])); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 3])); } } @SuppressWarnings("static-method") @TruffleBoundary private Object SLReadProperty_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; { Node readObject1_node__ = (this); int readObject1_bci__ = ($bci); InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5])); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 5])); } } private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4280,10 +4334,10 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, Node node__ = null; if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).hasArrayElements($child0Value))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).hasArrayElements($child0Value))) { node__ = (this); bci__ = ($bci); break; @@ -4295,16 +4349,16 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, if (s0_ == null) { { InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]).accepts($child1Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]))); + s0_ = super.insert(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) consts[constArrayOffset_ + 0]))); node__ = (this); bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0] = s0_.insertAccessor(arrays__); + children[childArrayOffset_ + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = s0_; + consts[constArrayOffset_ + 0] = s0_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; @@ -4319,7 +4373,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, if (s0_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); return; } } @@ -4340,7 +4394,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, readArray1_bci__ = ($bci); readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); @@ -4368,10 +4422,10 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, Node node__1 = null; if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1]); if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_))) { + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value_))) { node__1 = (this); bci__1 = ($bci); break; @@ -4381,15 +4435,15 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, } } if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]).accepts($child0Value_)); + // assert (((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value_)); if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1]))); + s2_ = super.insert(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) consts[constArrayOffset_ + 1]))); node__1 = (this); bci__1 = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[childArrayOffset_ + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = s2_; + consts[constArrayOffset_ + 1] = s2_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0); @@ -4407,7 +4461,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, if (s2_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 2]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]), ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); return; } } @@ -4419,9 +4473,9 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, readSLObject1_node__ = (this); readSLObject1_bci__ = ($bci); readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3] = super.insert((SLToTruffleStringNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 3] = super.insert((SLToTruffleStringNodeGen.create())); bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 1] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); @@ -4433,7 +4487,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 3]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); return; } } @@ -4442,10 +4496,10 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, Node node__2 = null; if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]); + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2]); if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).hasMembers($child0Value))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).hasMembers($child0Value))) { node__2 = (this); bci__2 = ($bci); break; @@ -4456,16 +4510,16 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, } if (s4_ == null) { if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]).accepts($child0Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value)); InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = super.insert(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2]))); + s4_ = super.insert(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) consts[constArrayOffset_ + 2]))); node__2 = (this); bci__2 = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4] = s4_.insertAccessor(objects__); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4] = s4_.insertAccessor(objects__); + children[childArrayOffset_ + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = s4_; + consts[constArrayOffset_ + 2] = s4_; bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); int type0; @@ -4480,7 +4534,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, if (s4_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 4]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]), ((SLToMemberNode) children[childArrayOffset_ + 5]))); return; } } @@ -4498,9 +4552,9 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, if ((readObject1_objects__.hasMembers($child0Value))) { readObject1_node__ = (this); readObject1_bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5] = super.insert((SLToMemberNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 5] = super.insert((SLToMemberNodeGen.create())); bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 2] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); @@ -4512,7 +4566,7 @@ private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 5]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[childArrayOffset_ + 5]))); return; } } @@ -4541,6 +4595,8 @@ private void SLSub_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 2); @@ -4581,6 +4637,8 @@ private void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, int $bci, int } private void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { @@ -4634,6 +4692,8 @@ private void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, int $bci, int $ } private void SLSub_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4732,16 +4792,18 @@ private void SLSub_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, @ExplodeLoop private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 5 + 0]; + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 3); Object $child1Value_ = expectObject($frame, $sp - 2); Object $child2Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[constArrayOffset_ + 1]), ((InteropLibrary) children[childArrayOffset_ + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); return; } s0_ = s0_.next_; @@ -4766,10 +4828,10 @@ private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2]); while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]), ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); return; } s2_ = s2_.next_; @@ -4782,12 +4844,12 @@ private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { } if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3]); while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { Node node__ = (this); int bci__ = ($bci); - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]), ((SLToMemberNode) children[childArrayOffset_ + 6]))); return; } s4_ = s4_.next_; @@ -4809,25 +4871,31 @@ private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { @SuppressWarnings("static-method") @TruffleBoundary private Object SLWriteProperty_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; { InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 1]), writeArray1_arrays__, writeArray1_numbers__); } } @SuppressWarnings("static-method") @TruffleBoundary private Object SLWriteProperty_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; { DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4])); + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 4])); } } @SuppressWarnings("static-method") @TruffleBoundary private Object SLWriteProperty_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -4835,7 +4903,7 @@ private Object SLWriteProperty_writeObject1Boundary_(int $bci, int $sp, byte sta Node writeObject1_node__ = (this); int writeObject1_bci__ = ($bci); InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6])); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 6])); } } finally { encapsulating_.set(prev_); @@ -4843,6 +4911,8 @@ private Object SLWriteProperty_writeObject1Boundary_(int $bci, int $sp, byte sta } private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -4851,10 +4921,10 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci byte exclude = bc[$bci + 5 + 5]; if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)) && (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).hasArrayElements($child0Value))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).hasArrayElements($child0Value))) { break; } s0_ = s0_.next_; @@ -4864,16 +4934,16 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci if (s0_ == null) { { InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]).accepts($child1Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value)); if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = s0_.insertAccessor((this)); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor(arrays__); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + s0_ = super.insert(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) consts[constArrayOffset_ + 0]))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = s0_.insertAccessor((this)); + consts[constArrayOffset_ + 1] = ($bci); + children[childArrayOffset_ + 0] = s0_.insertAccessor(arrays__); + children[childArrayOffset_ + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + consts[constArrayOffset_ + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; @@ -4891,7 +4961,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci if (s0_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[constArrayOffset_ + 1]), ((InteropLibrary) children[childArrayOffset_ + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); return; } } @@ -4905,11 +4975,11 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci { writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((this)); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = ($bci); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((this)); + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 1] = ($bci); writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + consts[constArrayOffset_ + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); @@ -4924,7 +4994,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), ((int) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), writeArray1_arrays__, writeArray1_numbers__)); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[childArrayOffset_ + 2]), ((int) consts[constArrayOffset_ + 1]), writeArray1_arrays__, writeArray1_numbers__)); return; } } @@ -4937,10 +5007,10 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci SLObject $child0Value_ = (SLObject) $child0Value; if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2]); if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_))) { + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value_))) { break; } s2_ = s2_.next_; @@ -4948,13 +5018,13 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci } } if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]).accepts($child0Value_)); + // assert (((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value_)); if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_ = super.insert(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) consts[constArrayOffset_ + 2]))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + children[childArrayOffset_ + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = s2_; + consts[constArrayOffset_ + 2] = s2_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0); @@ -4975,16 +5045,16 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci if (s2_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 3]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]), ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); return; } } { DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4] = super.insert((SLToTruffleStringNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 4] = super.insert((SLToTruffleStringNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2] = null; state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); @@ -4999,7 +5069,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 4]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); return; } } @@ -5008,10 +5078,10 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci Node node__ = null; if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]); + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3]); if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { node__ = (this); bci__ = ($bci); break; @@ -5022,14 +5092,14 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci } if (s4_ == null) { if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]).accepts($child0Value)); - s4_ = super.insert(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3]))); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value)); + s4_ = super.insert(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) consts[constArrayOffset_ + 3]))); node__ = (this); bci__ = ($bci); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + children[childArrayOffset_ + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = s4_; + consts[constArrayOffset_ + 3] = s4_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); int type0; @@ -5046,7 +5116,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci if (s4_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 5]), ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]), ((SLToMemberNode) children[childArrayOffset_ + 6]))); return; } } @@ -5063,9 +5133,9 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci writeObject1_node__ = (this); writeObject1_bci__ = ($bci); writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6] = super.insert((SLToMemberNodeGen.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 6] = super.insert((SLToMemberNodeGen.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 3] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3] = null; state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); @@ -5080,7 +5150,7 @@ private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 6]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[childArrayOffset_ + 6]))); return; } } finally { @@ -5112,6 +5182,8 @@ private void SLUnbox_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); @@ -5130,6 +5202,8 @@ private void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, int $bci, i } private void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { $child0Value_ = expectLong($frame, $sp - 1); @@ -5150,6 +5224,8 @@ private void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, int $bci, int @SuppressWarnings("static-method") @TruffleBoundary private Object SLUnbox_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { @@ -5164,10 +5240,12 @@ private Object SLUnbox_fromForeign1Boundary_(int $bci, int $sp, byte state_0, by @ExplodeLoop private void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { String $child0Value__ = (String) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 0]))); return; } if (((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */) && $child0Value_ instanceof TruffleString) { @@ -5212,10 +5290,10 @@ private void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, int $bci, i } if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0]); while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value_))) { - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value_))) { + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]))); return; } s7_ = s7_.next_; @@ -5232,6 +5310,8 @@ private void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, int $bci, i } private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5241,7 +5321,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s byte exclude = bc[$bci + 3 + 6]; if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0] = super.insert((FromJavaStringNode.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 0] = super.insert((FromJavaStringNode.create())); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); bc[$bci + 3 + 1] = (byte) (state_1); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); @@ -5250,7 +5330,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 0]))); + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[childArrayOffset_ + 0]))); return; } if ($child0Value instanceof TruffleString) { @@ -5363,10 +5443,10 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s } if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]); + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0]); if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { while (s7_ != null) { - if ((((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value))) { + if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value))) { break; } s7_ = s7_.next_; @@ -5374,12 +5454,12 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s } } if (s7_ == null) { - // assert (((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]).accepts($child0Value)); + // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value)); if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = super.insert(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0]))); - children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_ = super.insert(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) consts[constArrayOffset_ + 0]))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = s7_; + consts[constArrayOffset_ + 0] = s7_; bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); @@ -5391,7 +5471,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s if (s7_ != null) { lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 3 + 2) + 1]))); + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]))); return; } } @@ -5403,7 +5483,7 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s try { fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - consts[LE_BYTES.getShort(bc, $bci + 3 + 4) + 0] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0] = null; state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); bc[$bci + 3 + 0] = (byte) (state_0); bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); @@ -5430,11 +5510,13 @@ private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s private void SLFunctionLiteral_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0]), node__)); return; } } @@ -5444,6 +5526,8 @@ private void SLFunctionLiteral_execute_(VirtualFrame $frame, int $bci, int $sp) } private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5453,7 +5537,7 @@ private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $b Node node__ = null; if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; - consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); node__ = (this); bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { @@ -5466,7 +5550,7 @@ private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $b doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); lock.unlock(); hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[constArrayOffset_ + 0]), node__)); return; } } @@ -5490,6 +5574,8 @@ private void SLToBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { } private void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); @@ -5508,6 +5594,8 @@ private void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, int } private void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -5540,6 +5628,8 @@ private void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, int } private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5607,6 +5697,8 @@ private boolean SLAnd_execute_(VirtualFrame $frame, int $bci, int $sp) { } private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); @@ -5618,6 +5710,8 @@ private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, in } private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -5637,6 +5731,8 @@ private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, in } private boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5676,6 +5772,8 @@ private boolean SLOr_execute_(VirtualFrame $frame, int $bci, int $sp) { } private boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; boolean $child0Value_; try { $child0Value_ = expectBoolean($frame, $sp - 1); @@ -5687,6 +5785,8 @@ private boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, int $bci, int } private boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { boolean $child0Value__ = (boolean) $child0Value_; @@ -5706,6 +5806,8 @@ private boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, int $bci, int } private boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5738,32 +5840,34 @@ private boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s @ExplodeLoop private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { byte state_0 = bc[$bci + 5 + 0]; + int childArrayOffset_; + int constArrayOffset_; if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { CompilerDirectives.transferToInterpreterAndInvalidate(); SLInvoke_removeDirect__($frame, $bci, $sp, s0_); return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); } s0_ = s0_.next_; } } if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1])); } } if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { { Node interop_node__ = (this); int interop_bci__ = ($bci); - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), interop_node__, interop_bci__); } } } @@ -5772,6 +5876,8 @@ private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object } private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); boolean hasLock = true; lock.lock(); @@ -5782,10 +5888,10 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int SLFunction arg0Value_ = (SLFunction) arg0Value; if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { while (s0_ != null) { - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2])) && Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2])) && Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { break; } s0_ = s0_.next_; @@ -5800,12 +5906,12 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int Assumption assumption0 = (callTargetStable__); if (Assumption.isValidAssumption(assumption0)) { if (count0_ < (3)) { - s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]))); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1] = callTargetStable__; - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2] = cachedTarget__; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[constArrayOffset_ + 0]))); + consts[constArrayOffset_ + 1] = callTargetStable__; + consts[constArrayOffset_ + 2] = cachedTarget__; + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); VarHandle.storeStoreFence(); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = s0_; + consts[constArrayOffset_ + 0] = s0_; bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_Q_DIRECT); @@ -5820,30 +5926,30 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int if (s0_ != null) { lock.unlock(); hasLock = false; - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); } } - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1] = super.insert((IndirectCallNode.create())); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1] = super.insert((IndirectCallNode.create())); bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = null; + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0] = null; state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); lock.unlock(); hasLock = false; - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1])); + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[childArrayOffset_ + 1])); } { int interop_bci__ = 0; Node interop_node__ = null; - children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); interop_node__ = (this); interop_bci__ = ($bci); bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); lock.unlock(); hasLock = false; - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 2]), interop_node__, interop_bci__); + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[childArrayOffset_ + 2]), interop_node__, interop_bci__); } } finally { if (hasLock) { @@ -5853,15 +5959,17 @@ private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int } private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); lock.lock(); try { SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (cur != null) { if (cur == s0_) { if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + consts[constArrayOffset_ + 0] = this.insert(cur.next_); } else { prev.next_ = prev.insertAccessor(cur.next_); } @@ -5870,7 +5978,7 @@ private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Obj prev = cur; cur = cur.next_; } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + if (consts[constArrayOffset_ + 0] == null) { bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } } finally { @@ -5887,6 +5995,8 @@ private void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); long value = SLUnboxNode.fromLong($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -5914,6 +6024,8 @@ private void SLAdd_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); try { long value = SLAddNode.addLong($child0Value_, $child1Value_); @@ -5943,15 +6055,17 @@ private void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, int $b byte state_0 = bc[$bci + 4 + 0]; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 4 + 1) + 0]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]).accepts($child0Value__))) { + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value__))) { Node node__ = (this); int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 4 + 3) + 1]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]))); return; } s2_ = s2_.next_; @@ -5971,6 +6085,8 @@ private void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $ SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); boolean value = SLUnboxNode.fromBoolean($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -5990,6 +6106,8 @@ private void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $ SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; boolean value = SLToBooleanNode.doBoolean($child0Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -6017,6 +6135,8 @@ private void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -6030,18 +6150,20 @@ private void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci @ExplodeLoop private Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { byte state_0 = bc[$bci + 5 + 0]; + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1])))) { + if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { CompilerDirectives.transferToInterpreterAndInvalidate(); SLInvoke_q_Direct_removeDirect__($frame, $bci, $sp, s0_); return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]))) { - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 1]), ((RootCallTarget) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 2]), ((DirectCallNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0])); + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); } s0_ = s0_.next_; } @@ -6051,15 +6173,17 @@ private Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp } private void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; Lock lock = getLock(); lock.lock(); try { SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (cur != null) { if (cur == s0_) { if (prev == null) { - consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] = this.insert(cur.next_); + consts[constArrayOffset_ + 0] = this.insert(cur.next_); } else { prev.next_ = prev.insertAccessor(cur.next_); } @@ -6068,7 +6192,7 @@ private void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int prev = cur; cur = cur.next_; } - if (consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0] == null) { + if (consts[constArrayOffset_ + 0] == null) { bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } } finally { @@ -6079,12 +6203,14 @@ private void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int private void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; Object $child0Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; if ($child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[LE_BYTES.getShort(bc, $bci + 3 + 1) + 0]), node__)); + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0]), node__)); return; } } @@ -6099,13 +6225,15 @@ private void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, int Object $child0Value_ = expectObject($frame, $sp - 3); Object $child1Value_ = expectObject($frame, $sp - 2); Object $child2Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[LE_BYTES.getShort(bc, $bci + 5 + 1) + 0]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); while (s2_ != null) { - if ((((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 0]), ((SLToTruffleStringNode) children[LE_BYTES.getShort(bc, $bci + 5 + 3) + 1]))); + if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]))); return; } s2_ = s2_.next_; @@ -6133,6 +6261,8 @@ private void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); return; } + int childArrayOffset_; + int constArrayOffset_; assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -6157,11 +6287,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : case INSTR_LOAD_LOCAL_UNINIT : case INSTR_C_SLLOGICAL_NOT : case INSTR_C_SLTO_BOOLEAN : @@ -6175,16 +6305,16 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; break; } case INSTR_STORE_LOCAL_OBJECT : - case INSTR_STORE_LOCAL_BOOLEAN : case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : case INSTR_STORE_LOCAL_UNINIT : case INSTR_C_SLLESS_OR_EQUAL : case INSTR_C_SLLESS_THAN : @@ -6234,6 +6364,7 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { } } + @Override public String dump() { int bci = 0; int instrIndex = 0; @@ -6375,7 +6506,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6393,7 +6524,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6403,7 +6534,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6421,7 +6552,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6456,7 +6587,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6474,14 +6605,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6499,7 +6630,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6531,7 +6662,7 @@ public String dump() { bci += 5; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6549,14 +6680,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); + sb.append("store.local.long "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); bci += 5; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6574,7 +6705,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); + sb.append("store.local.boolean "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); @@ -6631,7 +6762,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6649,14 +6780,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6674,7 +6805,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -7536,14 +7667,14 @@ private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $fram private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == FRAME_TYPE_BOOLEAN && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return FRAME_TYPE_BOOLEAN; - } if (localTag == FRAME_TYPE_LONG && value instanceof Long) { frame.setLong(localIdx, (long) value); return FRAME_TYPE_LONG; } + if (localTag == FRAME_TYPE_BOOLEAN && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return FRAME_TYPE_BOOLEAN; + } frame.setObject(localIdx, value); return FRAME_TYPE_OBJECT; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 0161b29e9532..aa0c3a53436b 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -17,8 +17,7 @@ @GenerateOperations public final class TestOperations { - @Metadata("TestData") // - public static final MetadataKey TEST_DATA = new MetadataKey<>("default value"); + @Metadata public static final MetadataKey TestData = new MetadataKey<>("default value"); private static class TestException extends AbstractOperationsTruffleException { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 91343080551d..da274cf60094 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -879,8 +879,8 @@ public void testMetadata() { b.publish(); }); - Assert.assertEquals(value, node.getMetadata(TestOperations.TEST_DATA)); - Assert.assertEquals(value, TestOperations.TEST_DATA.getValue(node)); + Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); + Assert.assertEquals(value, TestOperations.TestData.getValue(node)); } @Test @@ -893,8 +893,8 @@ public void testMetadataChange() { b.publish(); }); - Assert.assertEquals(value, node.getMetadata(TestOperations.TEST_DATA)); - Assert.assertEquals(value, TestOperations.TEST_DATA.getValue(node)); + Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); + Assert.assertEquals(value, TestOperations.TestData.getValue(node)); } @Test @@ -903,7 +903,7 @@ public void testMetadataDefaultValue() { b.publish(); }); - Assert.assertEquals(TestOperations.TEST_DATA.getDefaultValue(), node.getMetadata(TestOperations.TEST_DATA)); - Assert.assertEquals(TestOperations.TEST_DATA.getDefaultValue(), TestOperations.TEST_DATA.getValue(node)); + Assert.assertEquals(TestOperations.TestData.getDefaultValue(), node.getMetadata(TestOperations.TestData)); + Assert.assertEquals(TestOperations.TestData.getDefaultValue(), TestOperations.TestData.getValue(node)); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index 7cde64679168..c1b7921af56e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -19,6 +19,6 @@ @Retention(RetentionPolicy.SOURCE) @Target({ElementType.FIELD}) public @interface Metadata { - String value(); + String name() default ""; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 33bf27de1495..3173b0645881 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -4,9 +4,17 @@ import java.util.Arrays; import java.util.function.Supplier; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.impl.FrameWithoutBoxing; import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.memory.ByteArraySupport; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.operation.OperationNode.SourceInfo; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.source.Source; @@ -89,8 +97,8 @@ public final OperationNode publish() { } if (withInstrumentation && !result.isBytecodeInstrumented()) { - OperationBytecodeNode instrumentedBytecode = publishBytecode(); - assert instrumentedBytecode instanceof OperationInstrumentedBytecodeNode; + BytecodeNode instrumentedBytecode = publishBytecode(); + assert instrumentedBytecode instanceof InstrumentedBytecodeNode; result.changeBytecode(instrumentedBytecode); } } @@ -111,7 +119,7 @@ protected final void finish() { } } - private OperationBytecodeNode publishBytecode() { + private BytecodeNode publishBytecode() { labelPass(); @@ -132,11 +140,11 @@ private OperationBytecodeNode publishBytecode() { } } - protected abstract OperationNode createNode(OperationNodes arg0, Object arg1, OperationBytecodeNode arg2); + protected abstract OperationNode createNode(OperationNodes arg0, Object arg1, BytecodeNode arg2); - protected abstract OperationBytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); + protected abstract BytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); - protected abstract OperationInstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, + protected abstract InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); protected abstract int getBlockOperationIndex(); @@ -443,4 +451,230 @@ protected final int doBeginInstrumentation(Class cls) { protected abstract void resetMetadata(); protected abstract void assignMetadata(OperationNode node); + + // ------------------------ nodes ------------------------ + + protected abstract static class BytecodeNode extends Node implements BytecodeOSRNode { + + // Thevalues of these must be the same as FrameKind.ordinal && Frame tags + public static final int FRAME_TYPE_OBJECT = 0; + public static final int FRAME_TYPE_LONG = 1; + public static final int FRAME_TYPE_INT = 2; + public static final int FRAME_TYPE_DOUBLE = 3; + public static final int FRAME_TYPE_FLOAT = 4; + public static final int FRAME_TYPE_BOOLEAN = 5; + public static final int FRAME_TYPE_BYTE = 6; + public static final int FRAME_TYPE_ILLEGAL = 7; + + static { + assert FRAME_TYPE_OBJECT == FrameSlotKind.Object.tag; + assert FRAME_TYPE_LONG == FrameSlotKind.Long.tag; + assert FRAME_TYPE_INT == FrameSlotKind.Int.tag; + assert FRAME_TYPE_DOUBLE == FrameSlotKind.Double.tag; + assert FRAME_TYPE_FLOAT == FrameSlotKind.Float.tag; + assert FRAME_TYPE_BOOLEAN == FrameSlotKind.Boolean.tag; + assert FRAME_TYPE_BYTE == FrameSlotKind.Byte.tag; + assert FRAME_TYPE_ILLEGAL == FrameSlotKind.Illegal.tag; + } + + private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); + + protected final int maxStack; + protected final int maxLocals; + + @CompilationFinal(dimensions = 1) protected final byte[] bc; + @CompilationFinal(dimensions = 1) protected final Object[] consts; + @Children protected final Node[] children; + @CompilationFinal(dimensions = 1) protected final BuilderExceptionHandler[] handlers; + @CompilationFinal(dimensions = 1) protected final ConditionProfile[] conditionProfiles; + + protected static final int VALUES_OFFSET = 0; + + protected BytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + this.maxStack = maxStack; + this.maxLocals = maxLocals; + this.bc = bc; + this.consts = consts; + this.children = children; + this.handlers = handlers; + this.conditionProfiles = conditionProfiles; + } + + FrameDescriptor createFrameDescriptor() { + FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); + builder.addSlots(maxLocals, FrameSlotKind.Illegal); + builder.addSlots(maxStack, FrameSlotKind.Illegal); + return builder.build(); + } + + Object execute(VirtualFrame frame) { + return continueAt(frame, 0, maxLocals + VALUES_OFFSET); + } + + protected abstract Object continueAt(VirtualFrame frame, int bci, int sp); + + boolean isInstrumented() { + return false; + } + + // OSR + + @CompilationFinal private Object osrMetadata; + + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return continueAt(osrFrame, target, (int) interpreterState); + } + + public Object getOSRMetadata() { + return osrMetadata; + } + + public void setOSRMetadata(Object osrMetadata) { + this.osrMetadata = osrMetadata; + } + + // boxing elim + + protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, short[] descriptor) { + int op = LE_BYTES.getShort(bc, bci) & 0xffff; + short todo = descriptor[op]; + + if (todo > 0) { + // quicken + LE_BYTES.putShort(bc, bci, todo); + } else { + // set bit + int offset = (todo >> 8) & 0x7f; + int bit = todo & 0xff; + if (targetType == FRAME_TYPE_OBJECT) { + bc[bci + offset] &= ~bit; + } else { + bc[bci + offset] |= bit; + } + } + } + + protected static Object expectObject(VirtualFrame frame, int slot) { + if (frame.isObject(slot)) { + return frame.getObject(slot); + } else { + // this should only happen in edge cases, when we have specialized to a generic case + // on + // one thread, but other threads have already executed the child with primitive + // return + // type + return frame.getValue(slot); + } + } + + protected static byte expectByte(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.BYTE_TAG: + return frame.getByte(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Byte) { + return (byte) value; + } + break; + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.BOOLEAN_TAG: + return frame.getBoolean(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Boolean) { + return (boolean) value; + } + break; + } + + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.INT_TAG: + return frame.getInt(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Integer) { + return (int) value; + } + break; + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.FLOAT_TAG: + return frame.getFloat(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Float) { + return (float) value; + } + break; + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.LONG_TAG: + return frame.getLong(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Long) { + return (long) value; + } + break; + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case FrameWithoutBoxing.DOUBLE_TAG: + return frame.getDouble(slot); + case FrameWithoutBoxing.OBJECT_TAG: + Object value = frame.getObject(slot); + if (value instanceof Double) { + return (double) value; + } + break; + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected abstract String dump(); + } + + protected abstract static class InstrumentedBytecodeNode extends BytecodeNode { + + protected InstrumentedBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, + ConditionProfile[] conditionProfiles) { + super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); + } + + @Override + boolean isInstrumented() { + return true; + } + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java deleted file mode 100644 index ebb549dce5c2..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBytecodeNode.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.oracle.truffle.api.operation; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.impl.FrameWithoutBoxing; -import com.oracle.truffle.api.memory.ByteArraySupport; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.profiles.ConditionProfile; - -public abstract class OperationBytecodeNode extends Node implements BytecodeOSRNode { - - // Thevalues of these must be the same as FrameKind.ordinal && Frame tags - public static final int FRAME_TYPE_OBJECT = 0; - public static final int FRAME_TYPE_LONG = 1; - public static final int FRAME_TYPE_INT = 2; - public static final int FRAME_TYPE_DOUBLE = 3; - public static final int FRAME_TYPE_FLOAT = 4; - public static final int FRAME_TYPE_BOOLEAN = 5; - public static final int FRAME_TYPE_BYTE = 6; - public static final int FRAME_TYPE_ILLEGAL = 7; - - static { - assert FRAME_TYPE_OBJECT == FrameSlotKind.Object.tag; - assert FRAME_TYPE_LONG == FrameSlotKind.Long.tag; - assert FRAME_TYPE_INT == FrameSlotKind.Int.tag; - assert FRAME_TYPE_DOUBLE == FrameSlotKind.Double.tag; - assert FRAME_TYPE_FLOAT == FrameSlotKind.Float.tag; - assert FRAME_TYPE_BOOLEAN == FrameSlotKind.Boolean.tag; - assert FRAME_TYPE_BYTE == FrameSlotKind.Byte.tag; - assert FRAME_TYPE_ILLEGAL == FrameSlotKind.Illegal.tag; - } - - private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - - protected final int maxStack; - protected final int maxLocals; - - @CompilationFinal(dimensions = 1) protected final byte[] bc; - @CompilationFinal(dimensions = 1) protected final Object[] consts; - @Children protected final Node[] children; - @CompilationFinal(dimensions = 1) protected final BuilderExceptionHandler[] handlers; - @CompilationFinal(dimensions = 1) protected final ConditionProfile[] conditionProfiles; - - protected static final int VALUES_OFFSET = 0; - - protected OperationBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { - this.maxStack = maxStack; - this.maxLocals = maxLocals; - this.bc = bc; - this.consts = consts; - this.children = children; - this.handlers = handlers; - this.conditionProfiles = conditionProfiles; - } - - FrameDescriptor createFrameDescriptor() { - FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); - builder.addSlots(maxLocals, FrameSlotKind.Illegal); - builder.addSlots(maxStack, FrameSlotKind.Illegal); - return builder.build(); - } - - Object execute(VirtualFrame frame) { - return continueAt(frame, 0, maxLocals + VALUES_OFFSET); - } - - protected abstract Object continueAt(VirtualFrame frame, int bci, int sp); - - boolean isInstrumented() { - return false; - } - - // OSR - - @CompilationFinal private Object osrMetadata; - - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return continueAt(osrFrame, target, (int) interpreterState); - } - - public Object getOSRMetadata() { - return osrMetadata; - } - - public void setOSRMetadata(Object osrMetadata) { - this.osrMetadata = osrMetadata; - } - - // boxing elim - - protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, short[] descriptor) { - int op = LE_BYTES.getShort(bc, bci) & 0xffff; - short todo = descriptor[op]; - - if (todo > 0) { - // quicken - LE_BYTES.putShort(bc, bci, todo); - } else { - // set bit - int offset = (todo >> 8) & 0x7f; - int bit = todo & 0xff; - if (targetType == FRAME_TYPE_OBJECT) { - bc[bci + offset] &= ~bit; - } else { - bc[bci + offset] |= bit; - } - } - } - - protected static Object expectObject(VirtualFrame frame, int slot) { - if (frame.isObject(slot)) { - return frame.getObject(slot); - } else { - // this should only happen in edge cases, when we have specialized to a generic case on - // one thread, but other threads have already executed the child with primitive return - // type - return frame.getValue(slot); - } - } - - protected static byte expectByte(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.BYTE_TAG: - return frame.getByte(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Byte) { - return (byte) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.BOOLEAN_TAG: - return frame.getBoolean(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; - } - break; - } - - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.INT_TAG: - return frame.getInt(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Integer) { - return (int) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.FLOAT_TAG: - return frame.getFloat(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Float) { - return (float) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.LONG_TAG: - return frame.getLong(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.DOUBLE_TAG: - return frame.getDouble(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Double) { - return (double) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java deleted file mode 100644 index 66a7b9eee290..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationInstrumentedBytecodeNode.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.oracle.truffle.api.operation; - -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; - -public abstract class OperationInstrumentedBytecodeNode extends OperationBytecodeNode { - - protected OperationInstrumentedBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { - super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); - } - - @Override - boolean isInstrumented() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 8bf7179a730e..46c9e10a5b68 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -4,11 +4,11 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode; import com.oracle.truffle.api.source.SourceSection; public abstract class OperationNode extends Node { @@ -16,9 +16,9 @@ public abstract class OperationNode extends Node { private final OperationNodes nodes; @CompilationFinal private SourceInfo sourceInfo; - @Child private OperationBytecodeNode bcNode; + @Child private BytecodeNode bcNode; - protected OperationNode(OperationNodes nodes, Object sourceInfo, OperationBytecodeNode bcNode) { + protected OperationNode(OperationNodes nodes, Object sourceInfo, BytecodeNode bcNode) { this.nodes = nodes; this.sourceInfo = (SourceInfo) sourceInfo; this.bcNode = bcNode; @@ -42,7 +42,7 @@ boolean isBytecodeInstrumented() { return bcNode.isInstrumented(); } - void changeBytecode(OperationBytecodeNode node) { + void changeBytecode(BytecodeNode node) { CompilerAsserts.neverPartOfCompilation(); bcNode = insert(node); } @@ -150,4 +150,9 @@ public SourceSection getEncapsulatingSourceSection() { } }; } + + public final String dump() { + return bcNode.dump(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index c1ffaffdf72e..aa2e229da72b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -234,7 +234,7 @@ public class TruffleTypes { public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata"; public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; - public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBytecodeNode"; + public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 5758a75d8dfe..8bab1c152725 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -460,9 +460,9 @@ private static String nodeFieldName(NodeExecutionData execution) { } } - private CodeTree accessNodeField(NodeExecutionData execution) { + private CodeTree accessNodeField(FrameState frame, NodeExecutionData execution) { if (plugs != null) { - return plugs.createNodeFieldReference(execution, nodeFieldName(execution), true); + return plugs.createNodeFieldReference(frame, execution, nodeFieldName(execution), true); } if (execution.getChild() == null || execution.getChild().needsGeneratedField()) { return CodeTreeBuilder.singleString("this." + nodeFieldName(execution)); @@ -1881,10 +1881,6 @@ private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTyp clazz.add(method); CodeTreeBuilder builder = method.createBuilder(); - if (plugs != null) { - plugs.initializeFrameState(frameState, builder); - } - // do I miss specializations that are reachable from this executable? if (compatibleSpecializations.size() != implementedSpecializations.size()) { ExecuteDelegationResult delegation = createExecuteDelegation(builder, frameState, type, delegateableTypes, compatibleSpecializations, implementedSpecializations); @@ -2419,7 +2415,7 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram if (plugs != null) { builder.tree(plugs.createThrowUnsupportedChild(execution)); } else if (child != null && !frameState.getMode().isUncached()) { - builder.tree(accessNodeField(execution)); + builder.tree(accessNodeField(frameState, execution)); } else { builder.string("null"); } @@ -2553,6 +2549,10 @@ private CodeTree executeFastPathGroup(final CodeTreeBuilder parent, FrameState f List allowedSpecializations) { CodeTreeBuilder builder = parent.create(); + if (plugs != null) { + plugs.initializeFrameState(frameState, builder); + } + if (currentType.getMethod() != null && currentType.getMethod().isVarArgs()) { int readVarargsCount = node.getSignatureSize() - (currentType.getEvaluatedCount() - 1); int offset = node.getSignatureSize() - 1; @@ -2876,7 +2876,7 @@ private CodeExecutableElement createNodeConstructor(CodeTypeElement clazz, Execu builder.startStatement(); if (plugs != null) { - builder.tree(plugs.createNodeFieldReference(execution, nodeFieldName(execution), false)); + builder.tree(plugs.createNodeFieldReference(null, execution, nodeFieldName(execution), false)); } else { builder.string("this.").string(nodeFieldName(execution)); } @@ -3067,12 +3067,12 @@ private ExecutableElement createAccessChildMethod(NodeChildData child, boolean u if (child.getCardinality().isMany()) { builder.startReturn().startNewArray((ArrayType) child.getOriginalType(), null); for (NodeExecutionData execution : executions) { - builder.tree(accessNodeField(execution)); + builder.tree(accessNodeField(null, execution)); } builder.end().end(); } else { for (NodeExecutionData execution : executions) { - builder.startReturn().tree(accessNodeField(execution)).end(); + builder.startReturn().tree(accessNodeField(null, execution)).end(); break; } } @@ -3194,7 +3194,7 @@ private CodeTree callChildExecuteMethod(NodeExecutionData execution, ExecutableT if (plugs != null) { return plugs.createCallChildExecuteMethod(execution, method, frameState); } - return callMethod(frameState, accessNodeField(execution), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); + return callMethod(frameState, accessNodeField(frameState, execution), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); } private CodeTree callUncachedChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { @@ -3804,6 +3804,10 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization nonBoundaryIfCount = nonBoundaryIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(nonBoundaryGuards), false)); innerBuilder = extractInBoundaryMethod(builder, frameState, specialization); + if (plugs != null) { + plugs.initializeFrameState(innerFrameState, innerBuilder); + } + for (NodeExecutionData execution : specialization.getNode().getChildExecutions()) { int index = forType.getVarArgsIndex(forType.getParameterIndex(execution.getIndex())); if (index != -1) { @@ -4355,7 +4359,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (useSpecializationClass(excludes)) { if (plugs != null) { builder.startStatement(); - builder.tree(plugs.createSpecializationFieldReference(excludes, null, true, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, true, null)); builder.string(" = null"); builder.end(); } else { @@ -4441,7 +4445,7 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.end(); builder.startStatement(); if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(specialization, null, true, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, true, null)); } else { builder.string("this.", createSpecializationFieldName(specialization)); } @@ -4480,7 +4484,7 @@ private Collection initializeSpecializationClass(FrameState initBuilder.startNew(typeName); if (specialization.getMaximumNumberOfInstances() > 1) { if (plugs != null) { - initBuilder.tree(plugs.createSpecializationFieldReference(specialization, null, useSpecializationClass, + initBuilder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, useSpecializationClass, new GeneratedTypeMirror("", createSpecializationTypeName(specialization)))); } else { initBuilder.string(createSpecializationFieldName(specialization)); @@ -4699,6 +4703,13 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, method.addParameter(new CodeVariableElement(context.getType(Object.class), specializationLocalName)); } CodeTreeBuilder builder = method.createBuilder(); + + FrameState innerFrameState = FrameState.createEmpty(); + + if (plugs != null) { + plugs.initializeFrameState(innerFrameState, builder); + } + if (needsSpecializeLocking) { builder.declaration(context.getType(Lock.class), "lock", "getLock()"); builder.statement("lock.lock()"); @@ -4708,8 +4719,9 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, CodeTree fieldRefWrite = fieldRef; if (plugs != null) { String fieldName = useSpecializationClass ? null : createSpecializationFieldName(specialization); - fieldRef = plugs.createSpecializationFieldReference(specialization, fieldName, useSpecializationClass, new GeneratedTypeMirror("", createSpecializationTypeName(specialization))); - fieldRefWrite = plugs.createSpecializationFieldReference(specialization, fieldName, useSpecializationClass, null); + fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, useSpecializationClass, + new GeneratedTypeMirror("", createSpecializationTypeName(specialization))); + fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, useSpecializationClass, null); } if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { // single instance remove @@ -5242,7 +5254,7 @@ public DSLExpression visitBinary(Binary binary) { private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationData specialization, GuardExpression guard, NodeExecutionMode mode) { DSLExpression expression = optimizeExpression(guard.getExpression()); CodeTree init = null; - CodeTree expressionCode = writeExpression(frameState, specialization, expression); + CodeTree expressionCode = writeExpression(frameState.copy(), specialization, expression); if (mode.isGuardFallback()) { GuardExpression guardWithBit = getGuardThatNeedsStateBit(specialization, guard); if (guardWithBit != null) { @@ -5347,7 +5359,7 @@ private CodeTree createSpecializationFieldReference(FrameState frameState, Speci builder.string(localName); } else { if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(s, fieldName, true, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); + builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, true, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); } else { builder.string("this.", createSpecializationFieldName(s)); } @@ -5375,7 +5387,7 @@ private CodeTree createCacheReference(FrameState frameState, SpecializationData String sharedName = sharedCaches.get(cache); CodeTree ref; if (plugs != null) { - ref = plugs.createCacheReference(specialization, cache, sharedName, forRead); + ref = plugs.createCacheReference(frameState, specialization, cache, sharedName, forRead); } else if (sharedName != null) { ref = CodeTreeBuilder.createBuilder().string("this.").string(sharedName).build(); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 533aab0a86a2..f450237020c4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -35,11 +35,11 @@ public interface NodeGeneratorPlugs { CodeTree transformValueBeforePersist(CodeTree tree); - CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType); + CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType); - CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead); + CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead); - CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); + CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java index b82d92581006..adec9158f4f0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java @@ -58,7 +58,13 @@ protected OperationMetadataData parse(Element element, List mi } data.setType(metadataType); - data.setName((String) ElementUtils.getAnnotationValue(mir, "value").getValue()); + + String name = element.getSimpleName().toString(); + if (ElementUtils.getAnnotationValue(mir, "value") != null) { + name = (String) ElementUtils.getAnnotationValue(mir, "value").getValue(); + } + + data.setName(name); return data; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 34b3231fd3b6..cf451b52f9b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -19,6 +19,7 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -173,7 +174,8 @@ public CodeTypeElement createBuilderBytecodeNode() { List params = exToCopy.getParameters(); for (int i = 0; i < params.size(); i++) { - if (params.get(i).asType().equals(types.VirtualFrame)) { + TypeMirror paramType = params.get(i).asType(); + if (ElementUtils.typeEquals(paramType, types.Frame) || ElementUtils.typeEquals(paramType, types.VirtualFrame)) { params.remove(i); i--; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 839a5f8ec677..97336840d62c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -200,7 +200,10 @@ public CodeTree transformValueBeforePersist(CodeTree tree) { return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); } - private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild) { + private static final String CHILD_OFFSET_NAME = "childArrayOffset_"; + private static final String CONST_OFFSET_NAME = "constArrayOffset_"; + + private CodeTree createArrayReference(FrameState frame, Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild) { if (refObject == null) { throw new IllegalArgumentException("refObject is null"); } @@ -209,6 +212,8 @@ private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirr int index = refList.indexOf(refObject); int baseIndex = additionalData.indexOf(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (index == -1) { if (baseIndex == -1) { baseIndex = additionalData.size(); @@ -223,7 +228,7 @@ private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirr refList.add(refObject); } - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + String offsetName = isChild ? CHILD_OFFSET_NAME : CONST_OFFSET_NAME; if (doCast) { b.startParantheses(); @@ -238,10 +243,25 @@ private CodeTree createArrayReference(Object refObject, boolean doCast, TypeMirr } b.variable(targetField).string("["); - b.startCall("LE_BYTES", "getShort"); - b.variable(fldBc); - b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); - b.end(); + + if (frame == null) { + b.startCall("LE_BYTES", "getShort"); + b.variable(fldBc); + b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); + b.end(); + } else if (frame.getBoolean("has_" + offsetName, false)) { + b.string(offsetName); + } else { + frame.setBoolean("has_" + offsetName, true); + b.string("(" + offsetName + " = "); + b.startCall("LE_BYTES", "getShort"); + b.variable(fldBc); + b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); + b.end(); + b.string(")"); + + } + b.string(" + " + index + "]"); if (doCast) { @@ -258,24 +278,34 @@ public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphis } @Override - public CodeTree createSpecializationFieldReference(SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { + public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { Object refObject = useSpecializationClass ? s : fieldName; - return createArrayReference(refObject, fieldType != null, fieldType, false); + return createArrayReference(frame, refObject, fieldType != null, fieldType, false); } @Override - public CodeTree createNodeFieldReference(NodeExecutionData execution, String nodeFieldName, boolean forRead) { + public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead) { if (nodeFieldName.startsWith("$child")) { return CodeTreeBuilder.singleString("__INVALID__"); } - return createArrayReference(execution, forRead, execution.getNodeType(), true); + return createArrayReference(frame, execution, forRead, execution.getNodeType(), true); } @Override - public CodeTree createCacheReference(SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { - Object refObject = sharedName != null ? sharedName : cache; + public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { + Object refObject; + if (sharedName != null) { + refObject = sharedName; + } else { + String sharedGroup = cache.getSharedGroup(); + if (sharedGroup != null) { + refObject = sharedGroup; + } else { + refObject = cache; + } + } boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); - return createArrayReference(refObject, forRead, cache.getParameter().getType(), isChild); + return createArrayReference(frame, refObject, forRead, cache.getParameter().getType(), isChild); } public int getStackOffset(LocalVariable value) { @@ -313,6 +343,8 @@ public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List mirror) { } data.addOperationData(opData); + opData.redirectMessages(data); opData.redirectMessagesOnGeneratedElements(data); } @@ -125,6 +126,7 @@ protected OperationsData parse(Element element, List mirror) { } data.addOperationData(opData); + opData.redirectMessages(data); opData.redirectMessagesOnGeneratedElements(data); opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index bd42a05eb6fa..a3065dcbf70d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -259,7 +259,7 @@ private CodeExecutableElement createExecuteMethod(MethodProperties props, boolea Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), context.getType(resType), "execute"); - metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + metExecute.addParameter(new CodeVariableElement(types.Frame, "frame")); if (isVariadic) { int i = 0; @@ -295,7 +295,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); } - if (ElementUtils.isAssignable(param.asType(), types.VirtualFrame)) { + if (ElementUtils.typeEquals(param.asType(), types.Frame) || ElementUtils.typeEquals(param.asType(), types.VirtualFrame)) { parameters.add(ParameterKind.VIRTUAL_FRAME); } else { parameters.add(ParameterKind.STACK_VALUE); @@ -333,18 +333,18 @@ private CodeTypeElement createRegularNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); - result.add(createExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { - result.add(createExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); + result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); } return result; } - private CodeExecutableElement createExecuteMethod(String name, TypeMirror retType) { + private CodeExecutableElement createChildExecuteMethod(String name, TypeMirror retType) { CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); - // result.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + // result.addParameter(new CodeVariableElement(types.Frame, "frame")); if (!GENERIC_EXECUTE_NAME.equals(name)) { result.addThrownType(types.UnexpectedResultException); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java index 0be4031199af..8f6cb3c77c05 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java @@ -33,7 +33,7 @@ public SLExpressionNode getBodyNode() { @Override public TruffleString getTSName() { - return operationsNode.getMetadata(SLOperations.METHOD_NAME); + return operationsNode.getMetadata(SLOperations.MethodName); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 4cd822578d09..8fb3630b3284 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -61,8 +61,7 @@ @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) public final class SLOperations { - @Metadata("MethodName") // - public static final MetadataKey METHOD_NAME = new MetadataKey<>(SLStrings.EMPTY_STRING); + @Metadata public static final MetadataKey MethodName = new MetadataKey<>(SLStrings.EMPTY_STRING); @Operation @TypeSystemReference(SLTypes.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index b8f9ef9f00a9..77a72bd55df9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -59,7 +59,7 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Fri, 27 May 2022 19:12:31 +0200 Subject: [PATCH 089/312] [wip] raw load problem --- .../com/oracle/truffle/sl/operations/SLOperationsBuilder.java | 4 ++-- .../dsl/processor/operations/OperationsCodeGenerator.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index a696f81b0029..5a1996796881 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -17,6 +17,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.LibraryFactory; +import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; @@ -37,7 +38,6 @@ import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.OperationsBytesSupport; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.ConcatNode; @@ -225,7 +225,7 @@ protected void reparseImpl(OperationConfig config, Consumer parse, OperationN @GeneratedBy(SLOperations.class) private static class BuilderImpl extends SLOperationsBuilder { - private static final OperationsBytesSupport LE_BYTES = OperationsBytesSupport.littleEndian(); + private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); private static final int OP_BLOCK = 1; private static final int OP_IF_THEN = 2; private static final int OP_IF_THEN_ELSE = 3; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 78f5f085fc41..424481925f6b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -234,8 +234,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(ctor); { - String bytesSupportClass = "com.oracle.truffle.api.operation.OperationsBytesSupport"; - // String bytesSupportClass = "com.oracle.truffle.api.memory.ByteArraySupport"; + // String bytesSupportClass = "com.oracle.truffle.api.operation.OperationsBytesSupport"; + String bytesSupportClass = "com.oracle.truffle.api.memory.ByteArraySupport"; DeclaredType byteArraySupportType = context.getDeclaredType(bytesSupportClass); CodeVariableElement leBytes = new CodeVariableElement( MOD_PRIVATE_STATIC_FINAL, From 4bbc79257c9155e5ffaa59c9754cf7a012abf05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 30 May 2022 17:28:13 +0200 Subject: [PATCH 090/312] [wip] --- .../sl/operations/SLOperationsBuilder.java | 674 +++++++++--------- .../tracing/OperationsStatistics.java | 2 +- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../OperationsBytecodeCodeGenerator.java | 2 + .../operations/OperationsParser.java | 30 +- .../operations/SingleOperationParser.java | 5 +- .../instructions/QuickenedInstruction.java | 5 +- 7 files changed, 365 insertions(+), 355 deletions(-) rename truffle/mxbuild/{jdk17 => jdk11}/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java (99%) diff --git a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java similarity index 99% rename from truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java rename to truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 5a1996796881..17c0f29a97cf 100644 --- a/truffle/mxbuild/jdk17/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -9,6 +9,7 @@ import com.oracle.truffle.api.TruffleSafepoint; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; import com.oracle.truffle.api.dsl.GeneratedBy; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.dsl.GenerateAOT.Provider; @@ -185,6 +186,10 @@ protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, Operation public abstract void endSLToBoolean(); + public abstract void beginSLInvoke(); + + public abstract void endSLInvoke(); + public abstract void beginSLAnd(); public abstract void endSLAnd(); @@ -193,10 +198,6 @@ protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, Operation public abstract void endSLOr(); - public abstract void beginSLInvoke(); - - public abstract void endSLInvoke(); - public abstract void setMethodName(TruffleString value); public static OperationNodes create(OperationConfig config, Consumer generator) { @@ -255,26 +256,26 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int OP_SLUNBOX = 27; private static final int OP_SLFUNCTION_LITERAL = 28; private static final int OP_SLTO_BOOLEAN = 29; - private static final int OP_SLAND = 30; - private static final int OP_SLOR = 31; - private static final int OP_SLINVOKE = 32; + private static final int OP_SLINVOKE = 30; + private static final int OP_SLAND = 31; + private static final int OP_SLOR = 32; private static final int INSTR_POP = 1; private static final int INSTR_BRANCH = 2; private static final int INSTR_BRANCH_FALSE = 3; private static final int INSTR_THROW = 4; private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_LONG = 6; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; + private static final int INSTR_LOAD_CONSTANT_LONG = 7; private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_LONG = 9; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; + private static final int INSTR_LOAD_ARGUMENT_LONG = 10; private static final int INSTR_STORE_LOCAL_OBJECT = 11; - private static final int INSTR_STORE_LOCAL_LONG = 12; - private static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + private static final int INSTR_STORE_LOCAL_BOOLEAN = 12; + private static final int INSTR_STORE_LOCAL_LONG = 13; private static final int INSTR_STORE_LOCAL_UNINIT = 14; private static final int INSTR_LOAD_LOCAL_OBJECT = 15; - private static final int INSTR_LOAD_LOCAL_LONG = 16; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + private static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; + private static final int INSTR_LOAD_LOCAL_LONG = 17; private static final int INSTR_LOAD_LOCAL_UNINIT = 18; private static final int INSTR_RETURN = 19; private static final int INSTR_INSTRUMENT_ENTER = 20; @@ -294,9 +295,9 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLUNBOX = 34; private static final int INSTR_C_SLFUNCTION_LITERAL = 35; private static final int INSTR_C_SLTO_BOOLEAN = 36; - private static final int INSTR_SC_SLAND = 37; - private static final int INSTR_SC_SLOR = 38; - private static final int INSTR_C_SLINVOKE = 39; + private static final int INSTR_C_SLINVOKE = 37; + private static final int INSTR_SC_SLAND = 38; + private static final int INSTR_SC_SLOR = 39; private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 40; private static final int INSTR_C_SLADD_Q_ADD_LONG = 41; private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 42; @@ -309,9 +310,9 @@ private static class BuilderImpl extends SLOperationsBuilder { private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 49; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // INT null, // DOUBLE @@ -319,7 +320,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, 0, 0, -31487 /* 5,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, // BYTE null}; @@ -1419,23 +1420,35 @@ public void endSLToBoolean() { @SuppressWarnings("unused") @Override - public void beginSLAnd() { + public void beginSLInvoke() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLAND, getCurStack(), 1, false); - operationData.aux[0] = (BuilderOperationLabel) createLabel(); + operationData = new BuilderOperationData(operationData, OP_SLINVOKE, getCurStack(), 0, false); } @SuppressWarnings("unused") @Override - public void endSLAnd() { - if (operationData.operationId != OP_SLAND) { + public void endSLInvoke() { + if (operationData.operationId != OP_SLINVOKE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); + if (numChildren < 0) { + throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); } - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); + int[] predecessorBcis = doBeforeEmitInstruction(numChildren, true); + LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE); + bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); + LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); + // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] + // numChildNodes = 3 + // numConsts = 3 + bc[bci + 5 + 0] = 0; + LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); + LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(3)); + bc[bci + 5 + 5] = 0; + constPool.reserve(); + constPool.reserve(); + bci = bci + 11; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1443,21 +1456,21 @@ public void endSLAnd() { @SuppressWarnings("unused") @Override - public void beginSLOr() { + public void beginSLAnd() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLOR, getCurStack(), 1, false); + operationData = new BuilderOperationData(operationData, OP_SLAND, getCurStack(), 1, false); operationData.aux[0] = (BuilderOperationLabel) createLabel(); } @SuppressWarnings("unused") @Override - public void endSLOr() { - if (operationData.operationId != OP_SLOR) { + public void endSLAnd() { + if (operationData.operationId != OP_SLAND) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; if (numChildren < 1) { - throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); + throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); } doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); lastChildPush = 1; @@ -1467,35 +1480,23 @@ public void endSLOr() { @SuppressWarnings("unused") @Override - public void beginSLInvoke() { + public void beginSLOr() { doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLINVOKE, getCurStack(), 0, false); + operationData = new BuilderOperationData(operationData, OP_SLOR, getCurStack(), 1, false); + operationData.aux[0] = (BuilderOperationLabel) createLabel(); } @SuppressWarnings("unused") @Override - public void endSLInvoke() { - if (operationData.operationId != OP_SLINVOKE) { + public void endSLOr() { + if (operationData.operationId != OP_SLOR) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); + if (numChildren < 1) { + throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); } - int[] predecessorBcis = doBeforeEmitInstruction(numChildren, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); - // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] - // numChildNodes = 3 - // numConsts = 3 - bc[bci + 5 + 0] = 0; - LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(3)); - bc[bci + 5 + 5] = 0; - constPool.reserve(); - constPool.reserve(); - bci = bci + 11; + doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1562,13 +1563,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Results: * STACK_VALUE * - * load.constant.long + * load.constant.boolean * Inputs: * CONST_POOL * Results: * STACK_VALUE * - * load.constant.boolean + * load.constant.long * Inputs: * CONST_POOL * Results: @@ -1580,13 +1581,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Results: * STACK_VALUE * - * load.argument.long + * load.argument.boolean * Inputs: * ARGUMENT * Results: * STACK_VALUE * - * load.argument.boolean + * load.argument.long * Inputs: * ARGUMENT * Results: @@ -1598,13 +1599,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Results: * SET_LOCAL * - * store.local.long + * store.local.boolean * Inputs: * STACK_VALUE * Results: * SET_LOCAL * - * store.local.boolean + * store.local.long * Inputs: * STACK_VALUE * Results: @@ -1622,13 +1623,13 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Results: * STACK_VALUE * - * load.local.long + * load.local.boolean * Inputs: * LOCAL * Results: * STACK_VALUE * - * load.local.boolean + * load.local.long * Inputs: * LOCAL * Results: @@ -1879,19 +1880,24 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Boolean * Fallback * - * sc.SLAnd + * c.SLInvoke * Inputs: * STACK_VALUE - * BRANCH_TARGET + * VARARG_VALUE * Results: - * BRANCH + * STACK_VALUE * Additional Data: * 0 BITS + * 1 CONST + * 3 CHILD + * 5 BITS * Specializations: - * Boolean + * Direct + * Indirect + * Interop * Fallback * - * sc.SLOr + * sc.SLAnd * Inputs: * STACK_VALUE * BRANCH_TARGET @@ -1903,21 +1909,16 @@ private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.tr * Boolean * Fallback * - * c.SLInvoke + * sc.SLOr * Inputs: * STACK_VALUE - * VARARG_VALUE + * BRANCH_TARGET * Results: - * STACK_VALUE + * BRANCH * Additional Data: * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS * Specializations: - * Direct - * Indirect - * Interop + * Boolean * Fallback * * c.SLUnbox.q.FromLong @@ -2104,6 +2105,7 @@ private static final class BytecodeNode extends com.oracle.truffle.api.operation } @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch @Override protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { int sp = startSp; @@ -2167,16 +2169,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); + frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); sp = sp + 1; nextBci = bci + 4; break; @@ -2189,11 +2191,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); + if (value instanceof Boolean) { + frame.setBoolean(sp, (boolean) value); } else { frame.setObject(sp, value); } @@ -2201,11 +2203,11 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); + if (value instanceof Long) { + frame.setLong(sp, (long) value); } else { frame.setObject(sp, value); } @@ -2223,15 +2225,15 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 5; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; int sourceSlot = sp - 1; FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); do { - if (localTag == FrameSlotKind.Long) { + if (localTag == FrameSlotKind.Boolean) { try { - frame.setLong(localIdx, expectLong(frame, sourceSlot)); + frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); break /* goto here */; } catch (UnexpectedResultException ex) { } @@ -2247,15 +2249,15 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 5; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; int sourceSlot = sp - 1; FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); do { - if (localTag == FrameSlotKind.Boolean) { + if (localTag == FrameSlotKind.Long) { try { - frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); + frame.setLong(localIdx, expectLong(frame, sourceSlot)); break /* goto here */; } catch (UnexpectedResultException ex) { } @@ -2303,16 +2305,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + frame.setBoolean(localIdx, (boolean) localValue); } else { frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); } @@ -2322,16 +2324,16 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { + frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + frame.setLong(localIdx, (long) localValue); } else { frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); } @@ -2445,6 +2447,20 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { nextBci = bci + 4; break; } + case INSTR_C_SLINVOKE : + { + int numVariadics = LE_BYTES.getShort(bc, bci + 3); + Object input_0 = frame.getObject(sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); + } + Object result = this.SLInvoke_execute_(frame, bci, sp, input_0, input_1); + sp = sp - 1 - numVariadics + 1; + frame.setObject(sp - 1, result); + nextBci = bci + 11; + break; + } case INSTR_SC_SLAND : { if (this.SLAnd_execute_(frame, bci, sp)) { @@ -2467,20 +2483,6 @@ protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { continue loop; } } - case INSTR_C_SLINVOKE : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvoke_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } case INSTR_C_SLUNBOX_Q_FROM_LONG : { this.SLUnbox_q_FromLong_execute_(frame, bci, sp); @@ -5687,39 +5689,188 @@ private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, in } } - private boolean SLAnd_execute_(VirtualFrame $frame, int $bci, int $sp) { + @ExplodeLoop + private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { byte state_0 = bc[$bci + 5 + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $bci, $sp, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $bci, $sp, state_0); - } - } - - private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - return SLAnd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_removeDirect__($frame, $bci, $sp, s0_); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1])); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = (this); + int interop_bci__ = ($bci); + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), interop_node__, interop_bci__); + } + } } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); } - private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = (this); + Lock lock = getLock(); + boolean hasLock = true; + lock.lock(); + try { + byte state_0 = bc[$bci + 5 + 0]; + byte exclude = bc[$bci + 5 + 5]; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2])) && Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); + if ((arg0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[constArrayOffset_ + 0]))); + consts[constArrayOffset_ + 1] = callTargetStable__; + consts[constArrayOffset_ + 2] = cachedTarget__; + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + consts[constArrayOffset_ + 0] = s0_; + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_Q_DIRECT); + } else { + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); + } + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); + } + } + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1] = super.insert((IndirectCallNode.create())); + bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0] = null; + state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[childArrayOffset_ + 1])); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = (this); + interop_bci__ = ($bci); + bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[childArrayOffset_ + 2]), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = getLock(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + consts[constArrayOffset_ + 0] = this.insert(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if (consts[constArrayOffset_ + 0] == null) { + bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private boolean SLAnd_execute_(VirtualFrame $frame, int $bci, int $sp) { + byte state_0 = bc[$bci + 5 + 0]; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $bci, $sp, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $bci, $sp, state_0); + } + } + + private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + return SLAnd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = (this); int fallback_bci__ = ($bci); if (SLAnd_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); @@ -5837,155 +5988,6 @@ private boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $s } } - @ExplodeLoop - private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $bci, $sp, s0_); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1])); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = (this); - int interop_bci__ = ($bci); - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), interop_node__, interop_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - byte exclude = bc[$bci + 5 + 5]; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2])) && Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); - if ((arg0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[constArrayOffset_ + 0]))); - consts[constArrayOffset_ + 1] = callTargetStable__; - consts[constArrayOffset_ + 2] = cachedTarget__; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s0_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_Q_DIRECT); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - } - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); - } - } - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1] = super.insert((IndirectCallNode.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[childArrayOffset_ + 1])); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = (this); - interop_bci__ = ($bci); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[childArrayOffset_ + 2]), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[constArrayOffset_ + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if (consts[constArrayOffset_ + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - private void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { byte state_0 = bc[$bci + 3 + 0]; long $child0Value_; @@ -6287,11 +6289,11 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { case INSTR_THROW : case INSTR_LOAD_CONSTANT_OBJECT : case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : case INSTR_LOAD_LOCAL_UNINIT : case INSTR_C_SLLOGICAL_NOT : case INSTR_C_SLTO_BOOLEAN : @@ -6305,16 +6307,16 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { bci = bci + 7; break; } - case INSTR_LOAD_CONSTANT_LONG : case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); bci = bci + 4; break; } case INSTR_STORE_LOCAL_OBJECT : - case INSTR_STORE_LOCAL_LONG : case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : case INSTR_STORE_LOCAL_UNINIT : case INSTR_C_SLLESS_OR_EQUAL : case INSTR_C_SLLESS_THAN : @@ -6506,7 +6508,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6524,7 +6526,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); + sb.append("load.constant.boolean "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6534,7 +6536,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6552,7 +6554,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); + sb.append("load.constant.long "); { Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); @@ -6587,7 +6589,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6605,14 +6607,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); + sb.append("load.argument.boolean "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6630,7 +6632,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); + sb.append("load.argument.long "); sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -6662,7 +6664,7 @@ public String dump() { bci += 5; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6680,14 +6682,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); + sb.append("store.local.boolean "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); bci += 5; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6705,7 +6707,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); + sb.append("store.local.long "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(" -> "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); @@ -6762,7 +6764,7 @@ public String dump() { bci += 4; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6780,14 +6782,14 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); + sb.append("load.local.boolean "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); bci += 4; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -6805,7 +6807,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); + sb.append("load.local.long "); sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); sb.append(" -> "); sb.append("x"); @@ -7207,7 +7209,7 @@ public String dump() { bci += 4; break; } - case INSTR_SC_SLAND : + case INSTR_C_SLINVOKE : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -7215,26 +7217,26 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); + sb.append(String.format("%02x ", bc[bci + 6])); + sb.append(String.format("%02x ", bc[bci + 7])); + sb.append(String.format("%02x ", bc[bci + 8])); + sb.append(String.format("%02x ", bc[bci + 9])); + sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); + sb.append("c.SLInvoke "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); + sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); sb.append(" -> "); - sb.append("branch"); - bci += 6; + sb.append("x"); + bci += 11; break; } - case INSTR_SC_SLOR : + case INSTR_SC_SLAND : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -7252,7 +7254,7 @@ public String dump() { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("sc.SLOr "); + sb.append("sc.SLAnd "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); @@ -7261,7 +7263,7 @@ public String dump() { bci += 6; break; } - case INSTR_C_SLINVOKE : + case INSTR_SC_SLOR : { sb.append(String.format("%02x ", bc[bci + 0])); sb.append(String.format("%02x ", bc[bci + 1])); @@ -7269,23 +7271,23 @@ public String dump() { sb.append(String.format("%02x ", bc[bci + 3])); sb.append(String.format("%02x ", bc[bci + 4])); sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("c.SLInvoke "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLOr "); sb.append(String.format("pop[-%d]", bc[bci + 2])); sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); + sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); sb.append(" -> "); - sb.append("x"); - bci += 11; + sb.append("branch"); + bci += 6; break; } case INSTR_C_SLUNBOX_Q_FROM_LONG : @@ -7667,14 +7669,14 @@ private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $fram private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == FRAME_TYPE_LONG && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return FRAME_TYPE_LONG; - } if (localTag == FRAME_TYPE_BOOLEAN && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return FRAME_TYPE_BOOLEAN; } + if (localTag == FRAME_TYPE_LONG && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return FRAME_TYPE_LONG; + } frame.setObject(localIdx, value); return FRAME_TYPE_OBJECT; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index d31e904314af..636c9f9efe7f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -121,7 +121,7 @@ public GlobalOperationStatistics(Class opsClass) { public void writeDecisions() throws IOException { setNames(); EnabledExecutionTracer tracer = collect(); - try (FileChannel ch = FileChannel.open(Path.of(decisionsFile), StandardOpenOption.WRITE)) { + try (FileChannel ch = FileChannel.open(Path.of(decisionsFile), StandardOpenOption.WRITE, StandardOpenOption.CREATE)) { JSONArray result = tracer.serializeDecisions(this); ch.truncate(0); ch.write(ByteBuffer.wrap(result.toString(4).getBytes(StandardCharsets.UTF_8))); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index aa2e229da72b..bcd0053d314b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -232,6 +232,7 @@ public class TruffleTypes { public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata"; + public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal"; public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; @@ -254,6 +255,7 @@ public class TruffleTypes { public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); + public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name); public final DeclaredType MetadataKey = c.getDeclaredTypeOptional(MetadataKey_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index cf451b52f9b7..eac7b117ef4b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -255,6 +255,8 @@ public CodeTypeElement createBuilderBytecodeNode() { context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); } + mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); + CodeTreeBuilder b = mContinueAt.getBuilder(); CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 01799a768414..3fada60888b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -116,21 +116,6 @@ protected OperationsData parse(Element element, List mirror) { opData.redirectMessagesOnGeneratedElements(data); } - // find and bind all sc operations - List scOperations = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.ShortCircuitOperation); - for (AnnotationMirror mir : scOperations) { - SingleOperationData opData = new SingleOperationParser(data, mir, true).parse(null, null); - if (opData == null) { - data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Clould not proxy short circuit operation"); - continue; - } - - data.addOperationData(opData); - opData.redirectMessages(data); - opData.redirectMessagesOnGeneratedElements(data); - opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); - } - // find and bind all inner declared operations for (TypeElement inner : operationTypes) { if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { @@ -148,6 +133,21 @@ protected OperationsData parse(Element element, List mirror) { opData.redirectMessagesOnGeneratedElements(data); } + // find and bind all sc operations + List scOperations = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.ShortCircuitOperation); + for (AnnotationMirror mir : scOperations) { + SingleOperationData opData = new SingleOperationParser(data, mir, true).parse(null, null); + if (opData == null) { + data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Clould not proxy short circuit operation"); + continue; + } + + data.addOperationData(opData); + opData.redirectMessages(data); + opData.redirectMessagesOnGeneratedElements(data); + opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); + } + if (opProxies.isEmpty() && operationTypes.isEmpty()) { data.addWarning("No operations found"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index a3065dcbf70d..89bd87209594 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +import java.util.stream.Collectors; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; @@ -202,7 +203,7 @@ protected SingleOperationData parse(Element element, List mirr }); - if (proxyMirror == null) { + if (proxyMirror == null || isShortCircuit) { clonedType.setSuperClass(types.Node); } @@ -376,6 +377,6 @@ private List findSpecializations(Collection x instanceof ExecutableElement) // .map(x -> (ExecutableElement) x) // .filter(this::isSpecializationFunction) // - .toList(); + .collect(Collectors.toUnmodifiableList()); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index e31db1be69f4..ac2258e0546b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.model.SpecializationData; @@ -70,7 +71,9 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData } } - List realSpecNames = data.getNodeData().getSpecializations().stream().map(x -> x.getId()).toList(); + List realSpecNames = data.getNodeData().getSpecializations().stream()// + .map(x -> x.getId()) // + .collect(Collectors.toUnmodifiableList()); data.addWarning("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); hasErrors = true; } From ccdbd126a38eee1e0dd0556432b4e219dbc89e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 1 Jun 2022 17:38:03 +0200 Subject: [PATCH 091/312] [wip] aaaaaaaaaaaaa --- .../sl/operations/SLOperationsBuilder.java | 7894 ----------------- .../test/example/TestOperations.java | 17 + .../example/TestOperationsParserTest.java | 21 + .../api/operation/BuilderOperationData.java | 5 +- .../truffle/api/operation/LocalSetter.java | 57 + .../api/operation/OperationBuilder.java | 2 +- .../api/operation/OperationsConstantPool.java | 12 +- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/operations/Operation.java | 58 + .../OperationsBytecodeCodeGenerator.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 23 + .../operations/OperationsCodeGenerator.java | 52 +- .../operations/OperationsContext.java | 6 + .../operations/SingleOperationData.java | 17 +- .../operations/SingleOperationParser.java | 30 +- .../instructions/CustomInstruction.java | 38 +- .../operations/instructions/Instruction.java | 4 + 17 files changed, 313 insertions(+), 7927 deletions(-) delete mode 100644 truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java deleted file mode 100644 index 17c0f29a97cf..000000000000 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ /dev/null @@ -1,7894 +0,0 @@ -// CheckStyle: start generated -package com.oracle.truffle.sl.operations; - -import com.oracle.truffle.api.Assumption; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleSafepoint; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; -import com.oracle.truffle.api.dsl.GeneratedBy; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.dsl.GenerateAOT.Provider; -import com.oracle.truffle.api.exception.AbstractTruffleException; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.LibraryFactory; -import com.oracle.truffle.api.memory.ByteArraySupport; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.DirectCallNode; -import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.IndirectCallNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; -import com.oracle.truffle.api.object.DynamicObjectLibrary; -import com.oracle.truffle.api.operation.BuilderExceptionHandler; -import com.oracle.truffle.api.operation.BuilderOperationData; -import com.oracle.truffle.api.operation.BuilderOperationLabel; -import com.oracle.truffle.api.operation.OperationBuilder; -import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNode; -import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.ConcatNode; -import com.oracle.truffle.api.strings.TruffleString.EqualNode; -import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; -import com.oracle.truffle.sl.nodes.SLTypes; -import com.oracle.truffle.sl.nodes.SLTypesGen; -import com.oracle.truffle.sl.nodes.expression.SLAddNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNode; -import com.oracle.truffle.sl.nodes.expression.SLEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; -import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.operations.SLOperations.SLInvoke; -import com.oracle.truffle.sl.runtime.SLBigNumber; -import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLNull; -import com.oracle.truffle.sl.runtime.SLObject; -import java.lang.invoke.VarHandle; -import java.util.concurrent.locks.Lock; -import java.util.function.Consumer; - -@GeneratedBy(SLOperations.class) -@SuppressWarnings({"unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) -public abstract class SLOperationsBuilder extends OperationBuilder { - - protected SLOperationsBuilder(OperationNodes nodes, boolean isReparse, OperationConfig config) { - super(nodes, isReparse, config); - } - - public abstract void beginBlock(); - - public abstract void endBlock(); - - public abstract void beginIfThen(); - - public abstract void endIfThen(); - - public abstract void beginIfThenElse(); - - public abstract void endIfThenElse(); - - public abstract void beginConditional(); - - public abstract void endConditional(); - - public abstract void beginWhile(); - - public abstract void endWhile(); - - public abstract void beginTryCatch(int arg0); - - public abstract void endTryCatch(); - - public abstract void beginFinallyTry(); - - public abstract void endFinallyTry(); - - public abstract void beginFinallyTryNoExcept(); - - public abstract void endFinallyTryNoExcept(); - - public abstract void emitLabel(OperationLabel arg0); - - public abstract void emitBranch(OperationLabel arg0); - - public abstract void emitConstObject(Object arg0); - - public abstract void emitLoadArgument(int arg0); - - public abstract void beginStoreLocal(OperationLocal arg0); - - public abstract void endStoreLocal(); - - public abstract void emitLoadLocal(OperationLocal arg0); - - public abstract void beginReturn(); - - public abstract void endReturn(); - - public abstract void beginTag(Class arg0); - - public abstract void endTag(); - - public abstract void beginSLAdd(); - - public abstract void endSLAdd(); - - public abstract void beginSLDiv(); - - public abstract void endSLDiv(); - - public abstract void beginSLEqual(); - - public abstract void endSLEqual(); - - public abstract void beginSLLessOrEqual(); - - public abstract void endSLLessOrEqual(); - - public abstract void beginSLLessThan(); - - public abstract void endSLLessThan(); - - public abstract void beginSLLogicalNot(); - - public abstract void endSLLogicalNot(); - - public abstract void beginSLMul(); - - public abstract void endSLMul(); - - public abstract void beginSLReadProperty(); - - public abstract void endSLReadProperty(); - - public abstract void beginSLSub(); - - public abstract void endSLSub(); - - public abstract void beginSLWriteProperty(); - - public abstract void endSLWriteProperty(); - - public abstract void beginSLUnbox(); - - public abstract void endSLUnbox(); - - public abstract void beginSLFunctionLiteral(); - - public abstract void endSLFunctionLiteral(); - - public abstract void beginSLToBoolean(); - - public abstract void endSLToBoolean(); - - public abstract void beginSLInvoke(); - - public abstract void endSLInvoke(); - - public abstract void beginSLAnd(); - - public abstract void endSLAnd(); - - public abstract void beginSLOr(); - - public abstract void endSLOr(); - - public abstract void setMethodName(TruffleString value); - - public static OperationNodes create(OperationConfig config, Consumer generator) { - OperationNodes nodes = new OperationNodesImpl(generator); - BuilderImpl builder = new BuilderImpl(nodes, false, config); - generator.accept(builder); - builder.finish(); - return nodes; - } - - @GeneratedBy(SLOperations.class) - private static final class OperationNodesImpl extends OperationNodes { - - OperationNodesImpl(Consumer parse) { - super(parse); - } - - @Override - protected void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes) { - BuilderImpl builder = new BuilderImpl(this, true, config); - ((Consumer) parse).accept(builder); - builder.finish(); - } - - } - @GeneratedBy(SLOperations.class) - private static class BuilderImpl extends SLOperationsBuilder { - - private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - private static final int OP_BLOCK = 1; - private static final int OP_IF_THEN = 2; - private static final int OP_IF_THEN_ELSE = 3; - private static final int OP_CONDITIONAL = 4; - private static final int OP_WHILE = 5; - private static final int OP_TRY_CATCH = 6; - private static final int OP_FINALLY_TRY = 7; - private static final int OP_FINALLY_TRY_NO_EXCEPT = 8; - private static final int OP_LABEL = 9; - private static final int OP_BRANCH = 10; - private static final int OP_CONST_OBJECT = 11; - private static final int OP_LOAD_ARGUMENT = 12; - private static final int OP_STORE_LOCAL = 13; - private static final int OP_LOAD_LOCAL = 14; - private static final int OP_RETURN = 15; - private static final int OP_TAG = 16; - private static final int OP_SLADD = 17; - private static final int OP_SLDIV = 18; - private static final int OP_SLEQUAL = 19; - private static final int OP_SLLESS_OR_EQUAL = 20; - private static final int OP_SLLESS_THAN = 21; - private static final int OP_SLLOGICAL_NOT = 22; - private static final int OP_SLMUL = 23; - private static final int OP_SLREAD_PROPERTY = 24; - private static final int OP_SLSUB = 25; - private static final int OP_SLWRITE_PROPERTY = 26; - private static final int OP_SLUNBOX = 27; - private static final int OP_SLFUNCTION_LITERAL = 28; - private static final int OP_SLTO_BOOLEAN = 29; - private static final int OP_SLINVOKE = 30; - private static final int OP_SLAND = 31; - private static final int OP_SLOR = 32; - private static final int INSTR_POP = 1; - private static final int INSTR_BRANCH = 2; - private static final int INSTR_BRANCH_FALSE = 3; - private static final int INSTR_THROW = 4; - private static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - private static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - private static final int INSTR_LOAD_CONSTANT_LONG = 7; - private static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - private static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - private static final int INSTR_LOAD_ARGUMENT_LONG = 10; - private static final int INSTR_STORE_LOCAL_OBJECT = 11; - private static final int INSTR_STORE_LOCAL_BOOLEAN = 12; - private static final int INSTR_STORE_LOCAL_LONG = 13; - private static final int INSTR_STORE_LOCAL_UNINIT = 14; - private static final int INSTR_LOAD_LOCAL_OBJECT = 15; - private static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; - private static final int INSTR_LOAD_LOCAL_LONG = 17; - private static final int INSTR_LOAD_LOCAL_UNINIT = 18; - private static final int INSTR_RETURN = 19; - private static final int INSTR_INSTRUMENT_ENTER = 20; - private static final int INSTR_INSTRUMENT_EXIT_VOID = 21; - private static final int INSTR_INSTRUMENT_EXIT = 22; - private static final int INSTR_INSTRUMENT_LEAVE = 23; - private static final int INSTR_C_SLADD = 24; - private static final int INSTR_C_SLDIV = 25; - private static final int INSTR_C_SLEQUAL = 26; - private static final int INSTR_C_SLLESS_OR_EQUAL = 27; - private static final int INSTR_C_SLLESS_THAN = 28; - private static final int INSTR_C_SLLOGICAL_NOT = 29; - private static final int INSTR_C_SLMUL = 30; - private static final int INSTR_C_SLREAD_PROPERTY = 31; - private static final int INSTR_C_SLSUB = 32; - private static final int INSTR_C_SLWRITE_PROPERTY = 33; - private static final int INSTR_C_SLUNBOX = 34; - private static final int INSTR_C_SLFUNCTION_LITERAL = 35; - private static final int INSTR_C_SLTO_BOOLEAN = 36; - private static final int INSTR_C_SLINVOKE = 37; - private static final int INSTR_SC_SLAND = 38; - private static final int INSTR_SC_SLOR = 39; - private static final int INSTR_C_SLUNBOX_Q_FROM_LONG = 40; - private static final int INSTR_C_SLADD_Q_ADD_LONG = 41; - private static final int INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 = 42; - private static final int INSTR_C_SLUNBOX_Q_FROM_BOOLEAN = 43; - private static final int INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN = 44; - private static final int INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; - private static final int INSTR_C_SLINVOKE_Q_DIRECT = 46; - private static final int INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM = 47; - private static final int INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 = 48; - private static final int INSTR_C_SLLESS_THAN_Q_LESS_THAN0 = 49; - private static final short[][] BOXING_DESCRIPTORS = { - // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, - // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, - // INT - null, - // DOUBLE - null, - // FLOAT - null, - // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, 0, 0, -31999 /* 3,1 */, -31743 /* 4,1 */, -31743 /* 4,1 */, -31999 /* 3,1 */, -31999 /* 3,1 */, -31743 /* 4,1 */, -31487 /* 5,1 */, -31999 /* 3,1 */, -31487 /* 5,1 */, -31743 /* 4,1 */}, - // BYTE - null}; - - int lastChildPush; - private TruffleString metadata_MethodName; - - BuilderImpl(OperationNodes nodes, boolean isReparse, OperationConfig config) { - super(nodes, isReparse, config); - } - - @Override - protected OperationNode createNode(OperationNodes arg0, Object arg1, com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode arg2) { - return new OperationNodeImpl(arg0, arg1, arg2); - } - - @Override - protected com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { - return new com.oracle.truffle.sl.operations.SLOperationsBuilder.BuilderImpl.BytecodeNode(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - } - - @Override - protected InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6) { - throw new UnsupportedOperationException("not implemented"); - } - - @Override - protected void doLeaveOperation(BuilderOperationData data) { - switch (data.operationId) { - case OP_FINALLY_TRY : - { - doLeaveFinallyTry(data); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - doLeaveFinallyTry(data); - break; - } - case OP_TAG : - { - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_LEAVE); - LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) data.aux[0])); - createOffset(bci + 4, ((BuilderOperationLabel) data.aux[1])); - createOffset(bci + 6, ((BuilderOperationLabel) data.aux[2])); - bci = bci + 8; - break; - } - } - } - - @SuppressWarnings("unused") - void doBeforeChild() { - int childIndex = operationData.numChildren; - switch (operationData.operationId) { - case OP_BLOCK : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - } - break; - } - case OP_TRY_CATCH : - { - if (childIndex == 1) { - setCurStack(((BuilderExceptionHandler) operationData.aux[0]).startStack); - ((BuilderExceptionHandler) operationData.aux[0]).handlerBci = bci; - } - break; - } - case OP_TAG : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - } - break; - } - case OP_SLAND : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_SC_SLAND); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - createOffset(bci + 3, ((BuilderOperationLabel) operationData.aux[0])); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 5 + 0] = 0; - bci = bci + 6; - } - break; - } - case OP_SLOR : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_SC_SLOR); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - createOffset(bci + 3, ((BuilderOperationLabel) operationData.aux[0])); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 5 + 0] = 0; - bci = bci + 6; - } - break; - } - } - } - - @SuppressWarnings("unused") - void doAfterChild() { - int childIndex = operationData.numChildren++; - switch (operationData.operationId) { - case OP_IF_THEN : - { - if (childIndex == 0) { - assert lastChildPush == 1; - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[0] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); - createOffset(bci + 2, endLabel); - bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); - bci = bci + 7; - } else { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); - } - break; - } - case OP_IF_THEN_ELSE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[0] = elseLabel; - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); - createOffset(bci + 2, elseLabel); - bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); - bci = bci + 7; - } else if (childIndex == 1) { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, endLabel); - bci = bci + 4; - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); - } else { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); - } - break; - } - case OP_CONDITIONAL : - { - if (childIndex == 0) { - assert lastChildPush == 1; - BuilderOperationLabel elseLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[0] = elseLabel; - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); - createOffset(bci + 2, elseLabel); - bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); - bci = bci + 7; - } else if (childIndex == 1) { - assert lastChildPush == 1; - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, endLabel); - bci = bci + 4; - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); - } else { - assert lastChildPush == 1; - doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); - } - break; - } - case OP_WHILE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[1] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH_FALSE); - createOffset(bci + 2, endLabel); - bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 5, (short) (int) createBranchProfile()); - bci = bci + 7; - } else { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[0])); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[0])); - bci = bci + 4; - doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); - } - break; - } - case OP_TRY_CATCH : - { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - if (childIndex == 0) { - ((BuilderExceptionHandler) operationData.aux[0]).endBci = bci; - calculateLeaves(operationData, (BuilderOperationLabel) ((BuilderOperationLabel) operationData.aux[1])); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, ((BuilderOperationLabel) operationData.aux[1])); - bci = bci + 4; - } else { - } - break; - } - case OP_FINALLY_TRY : - { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - if (childIndex == 0) { - doEndFinallyBlock(); - BuilderExceptionHandler beh = new BuilderExceptionHandler(); - beh.startBci = bci; - beh.startStack = getCurStack(); - beh.exceptionIndex = getLocalIndex(operationData.aux[2]); - addExceptionHandler(beh); - operationData.aux[1] = beh; - } - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - for (int i = 0; i < lastChildPush; i++) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_POP); - bci = bci + 2; - } - if (childIndex == 0) { - doEndFinallyBlock(); - } - break; - } - } - } - - @Override - protected int getBlockOperationIndex() { - return OP_BLOCK; - } - - @SuppressWarnings("unused") - @Override - public void beginBlock() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BLOCK, getCurStack(), 0, false); - lastChildPush = 0; - } - - @SuppressWarnings("unused") - @Override - public void endBlock() { - if (operationData.operationId != OP_BLOCK) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); - } - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginIfThen() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN, getCurStack(), 1, false); - } - - @SuppressWarnings("unused") - @Override - public void endIfThen() { - if (operationData.operationId != OP_IF_THEN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginIfThenElse() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, getCurStack(), 2, false); - } - - @SuppressWarnings("unused") - @Override - public void endIfThenElse() { - if (operationData.operationId != OP_IF_THEN_ELSE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginConditional() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, getCurStack(), 2, false); - } - - @SuppressWarnings("unused") - @Override - public void endConditional() { - if (operationData.operationId != OP_CONDITIONAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); - } - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginWhile() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_WHILE, getCurStack(), 2, false); - BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = startLabel; - } - - @SuppressWarnings("unused") - @Override - public void endWhile() { - if (operationData.operationId != OP_WHILE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("While expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginTryCatch(int arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, getCurStack(), 2, false, arg0); - BuilderExceptionHandler beh = new BuilderExceptionHandler(); - beh.startBci = bci; - beh.startStack = getCurStack(); - beh.exceptionIndex = (int)operationData.arguments[0]; - addExceptionHandler(beh); - operationData.aux[0] = beh; - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - operationData.aux[1] = endLabel; - } - - @SuppressWarnings("unused") - @Override - public void endTryCatch() { - if (operationData.operationId != OP_TRY_CATCH) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); - } - doEmitLabel(((BuilderOperationLabel) operationData.aux[1])); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginFinallyTry() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, getCurStack(), 3, true); - operationData.aux[2] = createParentLocal(); - operationData.aux[0] = doBeginFinallyTry(); - } - - @SuppressWarnings("unused") - @Override - public void endFinallyTry() { - if (operationData.operationId != OP_FINALLY_TRY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); - } - int endBci = bci; - doLeaveFinallyTry(operationData); - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - { - calculateLeaves(operationData, (BuilderOperationLabel) endLabel); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, endLabel); - bci = bci + 4; - } - BuilderExceptionHandler beh = ((BuilderExceptionHandler) operationData.aux[1]); - beh.endBci = endBci; - beh.handlerBci = bci; - doLeaveFinallyTry(operationData); - { - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_THROW); - LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.aux[2])); - bci = bci + 4; - } - doEmitLabel(endLabel); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginFinallyTryNoExcept() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, getCurStack(), 1, true); - operationData.aux[0] = doBeginFinallyTry(); - } - - @SuppressWarnings("unused") - @Override - public void endFinallyTryNoExcept() { - if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); - } - doLeaveFinallyTry(operationData); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLabel(OperationLabel arg0) { - doBeforeChild(); - doEmitLabel(arg0); - lastChildPush = 0; - doAfterChild(); - } - - @Override - public void emitBranch(OperationLabel arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BRANCH, getCurStack(), 0, false, arg0); - calculateLeaves(operationData, (BuilderOperationLabel) operationData.arguments[0]); - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_BRANCH); - createOffset(bci + 2, operationData.arguments[0]); - bci = bci + 4; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitConstObject(Object arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONST_OBJECT, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(0, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); - LE_BYTES.putShort(bc, bci + 2, (short) (int) constPool.add(arg0)); - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLoadArgument(int arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(0, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_ARGUMENT_OBJECT); - LE_BYTES.putShort(bc, bci + 2, (short) (int) operationData.arguments[0]); - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginStoreLocal(OperationLocal arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, getCurStack(), 0, false, arg0); - } - - @SuppressWarnings("unused") - @Override - public void endStoreLocal() { - if (operationData.operationId != OP_STORE_LOCAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_UNINIT); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 3, (short) (int) getLocalIndex(operationData.arguments[0])); - bci = bci + 5; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLoadLocal(OperationLocal arg0) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, getCurStack(), 0, false, arg0); - int[] predecessorBcis = doBeforeEmitInstruction(0, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_LOCAL_UNINIT); - LE_BYTES.putShort(bc, bci + 2, (short) (int) getLocalIndex(operationData.arguments[0])); - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginReturn() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_RETURN, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endReturn() { - if (operationData.operationId != OP_RETURN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("Return expected 1 children, got " + numChildren); - } - calculateLeaves(operationData); - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_RETURN); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bci = bci + 3; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginTag(Class arg0) { - if (!withInstrumentation) { - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TAG, getCurStack(), 3, true, arg0); - int curInstrumentId = doBeginInstrumentation((Class) arg0); - BuilderOperationLabel startLabel = (BuilderOperationLabel) createLabel(); - BuilderOperationLabel endLabel = (BuilderOperationLabel) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = curInstrumentId; - operationData.aux[1] = startLabel; - operationData.aux[2] = endLabel; - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_ENTER); - LE_BYTES.putShort(bc, bci + 2, (short) (int) curInstrumentId); - bci = bci + 4; - lastChildPush = 0; - } - - @SuppressWarnings("unused") - @Override - public void endTag() { - if (!withInstrumentation) { - return; - } - if (operationData.operationId != OP_TAG) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); - } - if (lastChildPush != 0) { - int[] predecessorBcis = doBeforeEmitInstruction(0, false); - LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT_VOID); - LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); - bci = bci + 4; - } else { - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_INSTRUMENT_EXIT); - LE_BYTES.putShort(bc, bci + 2, (short) (int) ((int) operationData.aux[0])); - bc[bci + 4] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bci = bci + 5; - } - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLAdd() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLADD, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLAdd() { - if (operationData.operationId != OP_SLADD) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLADD); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 7 bytes: [BITS, BITS, BITS, CONST, CONTINUATION, CHILD, CONTINUATION] - // numChildNodes = 3 - // numConsts = 1 - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - LE_BYTES.putShort(bc, bci + 4 + 3, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 4 + 5, createChildNodes(3)); - bci = bci + 11; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLDiv() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLDIV, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLDiv() { - if (operationData.operationId != OP_SLDIV) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLDIV); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 2 bytes: [BITS, BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLEqual() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLEQUAL, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLEqual() { - if (operationData.operationId != OP_SLEQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLEQUAL); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] - // numChildNodes = 3 - // numConsts = 1 - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - LE_BYTES.putShort(bc, bci + 4 + 2, createChildNodes(3)); - LE_BYTES.putShort(bc, bci + 4 + 4, (short) constPool.reserve()); - bc[bci + 4 + 6] = 0; - bci = bci + 11; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLessOrEqual() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLESS_OR_EQUAL, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLessOrEqual() { - if (operationData.operationId != OP_SLLESS_OR_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_OR_EQUAL); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLessThan() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLESS_THAN, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLessThan() { - if (operationData.operationId != OP_SLLESS_THAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLESS_THAN); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLogicalNot() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLLOGICAL_NOT, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLogicalNot() { - if (operationData.operationId != OP_SLLOGICAL_NOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLLOGICAL_NOT); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 3 + 0] = 0; - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLMul() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLMUL, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLMul() { - if (operationData.operationId != OP_SLMUL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLMUL); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 2 bytes: [BITS, BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLReadProperty() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLREAD_PROPERTY, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLReadProperty() { - if (operationData.operationId != OP_SLREAD_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLREAD_PROPERTY); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] - // numChildNodes = 6 - // numConsts = 3 - bc[bci + 4 + 0] = 0; - LE_BYTES.putShort(bc, bci + 4 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 4 + 3, createChildNodes(6)); - bc[bci + 4 + 5] = 0; - constPool.reserve(); - constPool.reserve(); - bci = bci + 10; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLSub() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLSUB, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLSub() { - if (operationData.operationId != OP_SLSUB) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLSUB); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - // additionalData = 2 bytes: [BITS, BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLWriteProperty() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLWRITE_PROPERTY, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLWriteProperty() { - if (operationData.operationId != OP_SLWRITE_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(3, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLWRITE_PROPERTY); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - bc[bci + 3] = predecessorBcis[1] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[1]); - bc[bci + 4] = predecessorBcis[2] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[2]); - // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] - // numChildNodes = 7 - // numConsts = 4 - bc[bci + 5 + 0] = 0; - LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(7)); - bc[bci + 5 + 5] = 0; - constPool.reserve(); - constPool.reserve(); - constPool.reserve(); - bci = bci + 11; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLUnbox() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLUNBOX, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLUnbox() { - if (operationData.operationId != OP_SLUNBOX) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLUNBOX); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 7 bytes: [BITS, BITS, CHILD, CONTINUATION, CONST, CONTINUATION, BITS] - // numChildNodes = 2 - // numConsts = 1 - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - LE_BYTES.putShort(bc, bci + 3 + 2, createChildNodes(2)); - LE_BYTES.putShort(bc, bci + 3 + 4, (short) constPool.reserve()); - bc[bci + 3 + 6] = 0; - bci = bci + 10; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLFunctionLiteral() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLFUNCTION_LITERAL, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLFunctionLiteral() { - if (operationData.operationId != OP_SLFUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLFUNCTION_LITERAL); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 3 bytes: [BITS, CONST, CONTINUATION] - // numChildNodes = 0 - // numConsts = 1 - bc[bci + 3 + 0] = 0; - LE_BYTES.putShort(bc, bci + 3 + 1, (short) constPool.reserve()); - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLToBoolean() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLTO_BOOLEAN, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLToBoolean() { - if (operationData.operationId != OP_SLTO_BOOLEAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLTO_BOOLEAN); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - // additionalData = 1 bytes: [BITS] - // numChildNodes = 0 - // numConsts = 0 - bc[bci + 3 + 0] = 0; - bci = bci + 4; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLInvoke() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLINVOKE, getCurStack(), 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLInvoke() { - if (operationData.operationId != OP_SLINVOKE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(numChildren, true); - LE_BYTES.putShort(bc, bci, (short) INSTR_C_SLINVOKE); - bc[bci + 2] = predecessorBcis[0] < bci - 255 ? 0 : (byte)(bci - predecessorBcis[0]); - LE_BYTES.putShort(bc, bci + 3, (short) (int) (numChildren - 1)); - // additionalData = 6 bytes: [BITS, CONST, CONTINUATION, CHILD, CONTINUATION, BITS] - // numChildNodes = 3 - // numConsts = 3 - bc[bci + 5 + 0] = 0; - LE_BYTES.putShort(bc, bci + 5 + 1, (short) constPool.reserve()); - LE_BYTES.putShort(bc, bci + 5 + 3, createChildNodes(3)); - bc[bci + 5 + 5] = 0; - constPool.reserve(); - constPool.reserve(); - bci = bci + 11; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLAnd() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLAND, getCurStack(), 1, false); - operationData.aux[0] = (BuilderOperationLabel) createLabel(); - } - - @SuppressWarnings("unused") - @Override - public void endSLAnd() { - if (operationData.operationId != OP_SLAND) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); - } - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLOr() { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SLOR, getCurStack(), 1, false); - operationData.aux[0] = (BuilderOperationLabel) createLabel(); - } - - @SuppressWarnings("unused") - @Override - public void endSLOr() { - if (operationData.operationId != OP_SLOR) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); - } - doEmitLabel(((BuilderOperationLabel) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void setMethodName(TruffleString value) { - metadata_MethodName = value; - } - - @Override - protected void resetMetadata() { - metadata_MethodName = null; - } - - @Override - protected void assignMetadata(OperationNode node) { - OperationNodeImpl nodeImpl = (OperationNodeImpl) node; - nodeImpl.MethodName = metadata_MethodName; - } - - @GeneratedBy(SLOperations.class) - private static final class OperationNodeImpl extends OperationNode { - - private TruffleString MethodName; - - private OperationNodeImpl(OperationNodes nodes, Object sourceInfo, com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode bcNode) { - super(nodes, sourceInfo, bcNode); - } - - static { - setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n).MethodName); - } - - } - /** - * pop - * Inputs: - * STACK_VALUE_IGNORED - * Results: - * - * branch - * Inputs: - * BRANCH_TARGET - * Results: - * BRANCH - * - * branch.false - * Inputs: - * BRANCH_TARGET - * STACK_VALUE - * BRANCH_PROFILE - * Results: - * BRANCH - * - * throw - * Inputs: - * LOCAL - * Results: - * - * load.constant.object - * Inputs: - * CONST_POOL - * Results: - * STACK_VALUE - * - * load.constant.boolean - * Inputs: - * CONST_POOL - * Results: - * STACK_VALUE - * - * load.constant.long - * Inputs: - * CONST_POOL - * Results: - * STACK_VALUE - * - * load.argument.object - * Inputs: - * ARGUMENT - * Results: - * STACK_VALUE - * - * load.argument.boolean - * Inputs: - * ARGUMENT - * Results: - * STACK_VALUE - * - * load.argument.long - * Inputs: - * ARGUMENT - * Results: - * STACK_VALUE - * - * store.local.object - * Inputs: - * STACK_VALUE - * Results: - * SET_LOCAL - * - * store.local.boolean - * Inputs: - * STACK_VALUE - * Results: - * SET_LOCAL - * - * store.local.long - * Inputs: - * STACK_VALUE - * Results: - * SET_LOCAL - * - * store.local.uninit - * Inputs: - * STACK_VALUE - * Results: - * SET_LOCAL - * - * load.local.object - * Inputs: - * LOCAL - * Results: - * STACK_VALUE - * - * load.local.boolean - * Inputs: - * LOCAL - * Results: - * STACK_VALUE - * - * load.local.long - * Inputs: - * LOCAL - * Results: - * STACK_VALUE - * - * load.local.uninit - * Inputs: - * LOCAL - * Results: - * STACK_VALUE - * - * return - * Inputs: - * STACK_VALUE - * Results: - * RETURN - * - * instrument.enter - * Inputs: - * INSTRUMENT - * Results: - * - * instrument.exit.void - * Inputs: - * INSTRUMENT - * Results: - * - * instrument.exit - * Inputs: - * INSTRUMENT - * STACK_VALUE - * Results: - * STACK_VALUE - * - * instrument.leave - * Inputs: - * INSTRUMENT - * BRANCH_TARGET - * BRANCH_TARGET - * Results: - * BRANCH - * - * c.SLAdd - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CONST - * 5 CHILD - * Specializations: - * AddLong - * Add0 - * Add1 - * Fallback - * - * c.SLDiv - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * Specializations: - * DivLong - * Div - * Fallback - * - * c.SLEqual - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 CHILD - * 4 CONST - * 6 BITS - * Specializations: - * Long - * BigNumber - * Boolean - * String - * TruffleString - * Null - * Function - * Generic0 - * Generic1 - * Fallback - * - * c.SLLessOrEqual - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessOrEqual0 - * LessOrEqual1 - * Fallback - * - * c.SLLessThan - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessThan0 - * LessThan1 - * Fallback - * - * c.SLLogicalNot - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLMul - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * Specializations: - * MulLong - * Mul - * Fallback - * - * c.SLReadProperty - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * ReadArray0 - * ReadArray1 - * ReadSLObject0 - * ReadSLObject1 - * ReadObject0 - * ReadObject1 - * Fallback - * - * c.SLSub - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * Specializations: - * SubLong - * Sub - * Fallback - * - * c.SLWriteProperty - * Inputs: - * STACK_VALUE - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * WriteArray0 - * WriteArray1 - * WriteSLObject0 - * WriteSLObject1 - * WriteObject0 - * WriteObject1 - * Fallback - * - * c.SLUnbox - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 CHILD - * 4 CONST - * 6 BITS - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLFunctionLiteral - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * Specializations: - * Perform - * Fallback - * - * c.SLToBoolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLInvoke - * Inputs: - * STACK_VALUE - * VARARG_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * Direct - * Indirect - * Interop - * Fallback - * - * sc.SLAnd - * Inputs: - * STACK_VALUE - * BRANCH_TARGET - * Results: - * BRANCH - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * sc.SLOr - * Inputs: - * STACK_VALUE - * BRANCH_TARGET - * Results: - * BRANCH - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLUnbox.q.FromLong - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLAdd.q.AddLong - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * AddLong - * Add0 - * Add1 - * Fallback - * - * c.SLReadProperty.q.ReadSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * ReadArray0 - * ReadArray1 - * ReadSLObject0 - * ReadSLObject1 - * ReadObject0 - * ReadObject1 - * Fallback - * - * c.SLUnbox.q.FromBoolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 BITS - * 2 BITS - * 3 CHILD - * 5 CONST - * Specializations: - * FromString - * FromTruffleString - * FromBoolean - * FromLong - * FromBigNumber - * FromFunction0 - * FromFunction1 - * FromForeign0 - * FromForeign1 - * Fallback - * - * c.SLToBoolean.q.Boolean - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * Boolean - * Fallback - * - * c.SLLessOrEqual.q.LessOrEqual0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessOrEqual0 - * LessOrEqual1 - * Fallback - * - * c.SLInvoke.q.Direct - * Inputs: - * STACK_VALUE - * VARARG_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * Direct - * Indirect - * Interop - * Fallback - * - * c.SLFunctionLiteral.q.Perform - * Inputs: - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * Specializations: - * Perform - * Fallback - * - * c.SLWriteProperty.q.WriteSLObject0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * 1 CONST - * 3 CHILD - * 5 BITS - * Specializations: - * WriteArray0 - * WriteArray1 - * WriteSLObject0 - * WriteSLObject1 - * WriteObject0 - * WriteObject1 - * Fallback - * - * c.SLLessThan.q.LessThan0 - * Inputs: - * STACK_VALUE - * STACK_VALUE - * Results: - * STACK_VALUE - * Additional Data: - * 0 BITS - * Specializations: - * LessThan0 - * LessThan1 - * Fallback - * - - */ - @GeneratedBy(SLOperations.class) - private static final class BytecodeNode extends com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode implements Provider { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - BytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { - super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); - } - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - protected Object continueAt(VirtualFrame frame, int startBci, int startSp) { - int sp = startSp; - int bci = startBci; - Object returnValue = null; - loop: while (true) { - int nextBci; - short curOpcode = LE_BYTES.getShort(bc, bci); - try { - CompilerAsserts.partialEvaluationConstant(bci); - CompilerAsserts.partialEvaluationConstant(sp); - CompilerAsserts.partialEvaluationConstant(curOpcode); - if (sp < maxLocals + VALUES_OFFSET) { - throw CompilerDirectives.shouldNotReachHere("stack underflow"); - } - switch (curOpcode) { - case INSTR_POP : - { - sp = sp - 1; - frame.clear(sp); - nextBci = bci + 2; - break; - } - case INSTR_BRANCH : - { - int targetBci = LE_BYTES.getShort(bc, bci + 2); - if (targetBci <= bci) { - TruffleSafepoint.poll(this); - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { - Object osrResult = BytecodeOSRNode.tryOSR(this, targetBci, sp, null, frame); - if (osrResult != null) { - return osrResult; - } - } - } - bci = targetBci; - continue loop; - } - case INSTR_BRANCH_FALSE : - { - ConditionProfile profile = conditionProfiles[LE_BYTES.getShort(bc, bci + 5)]; - boolean cond = (boolean) frame.getObject(sp - 1); - sp -= 1; - if (profile.profile(cond)) { - bci = bci + 7; - continue loop; - } else { - bci = LE_BYTES.getShort(bc, bci + 2); - continue loop; - } - } - case INSTR_THROW : - { - int slot = LE_BYTES.getShort(bc, bci + 2); - throw (AbstractTruffleException) frame.getObject(slot); - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - frame.setObject(sp, consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - frame.setBoolean(sp, (boolean) consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - frame.setLong(sp, (long) consts[LE_BYTES.getShort(bc, bci + 2)]); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - frame.setObject(sp, value); - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Boolean) { - frame.setBoolean(sp, (boolean) value); - } else { - frame.setObject(sp, value); - } - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = frame.getArguments()[LE_BYTES.getShort(bc, bci + 2)]; - if (value instanceof Long) { - frame.setLong(sp, (long) value); - } else { - frame.setObject(sp, value); - } - sp = sp + 1; - nextBci = bci + 4; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; - int sourceSlot = sp - 1; - frame.setObject(localIdx, expectObject(frame, sourceSlot)); - // here: - sp--; - nextBci = bci + 5; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; - int sourceSlot = sp - 1; - FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); - do { - if (localTag == FrameSlotKind.Boolean) { - try { - frame.setBoolean(localIdx, expectBoolean(frame, sourceSlot)); - break /* goto here */; - } catch (UnexpectedResultException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed(bc, bci, bc[bci + 2], FRAME_TYPE_OBJECT); - frame.setObject(localIdx, expectObject(frame, sourceSlot)); - } while (false); - // here: - sp--; - nextBci = bci + 5; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; - int sourceSlot = sp - 1; - FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); - do { - if (localTag == FrameSlotKind.Long) { - try { - frame.setLong(localIdx, expectLong(frame, sourceSlot)); - break /* goto here */; - } catch (UnexpectedResultException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - LE_BYTES.putShort(bc, bci, (short) INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed(bc, bci, bc[bci + 2], FRAME_TYPE_OBJECT); - frame.setObject(localIdx, expectObject(frame, sourceSlot)); - } while (false); - // here: - sp--; - nextBci = bci + 5; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - int localIdx = LE_BYTES.getShort(bc, bci + 3) + VALUES_OFFSET; - int sourceSlot = sp - 1; - FrameSlotKind localTag = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localTag == FrameSlotKind.Illegal) { - assert frame.isObject(sourceSlot); - frame.copy(sourceSlot, localIdx); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - int resultTag = storeLocalInitialization(frame, localIdx, localTag.tag, sourceSlot); - setResultBoxedImpl(bc, bci, resultTag, BOXING_DESCRIPTORS[resultTag]); - doSetResultBoxed(bc, bci, bc[bci + 2], resultTag); - } - // here: - sp--; - nextBci = bci + 5; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; - if (frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - frame.setObject(localIdx, frame.getValue(localIdx)); - } - frame.copy(localIdx, sp); - sp++; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; - FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Boolean) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - frame.setBoolean(localIdx, (boolean) localValue); - } else { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - } - } - frame.copy(localIdx, sp); - sp++; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; - FrameSlotKind localType = frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = frame.getObject(localIdx)) instanceof Long) { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - frame.setLong(localIdx, (long) localValue); - } else { - frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - } - } - frame.copy(localIdx, sp); - sp++; - nextBci = bci + 4; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - int localIdx = LE_BYTES.getShort(bc, bci + 2) + VALUES_OFFSET; - frame.setObject(sp, expectObject(frame, localIdx)); - sp++; - nextBci = bci + 4; - break; - } - case INSTR_RETURN : - { - returnValue = frame.getObject(sp - 1); - break loop; - } - case INSTR_C_SLADD : - { - this.SLAdd_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLDIV : - { - this.SLDiv_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLEQUAL : - { - this.SLEqual_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLLESS_OR_EQUAL : - { - this.SLLessOrEqual_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLLESS_THAN : - { - this.SLLessThan_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLLOGICAL_NOT : - { - this.SLLogicalNot_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLMUL : - { - this.SLMul_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLREAD_PROPERTY : - { - this.SLReadProperty_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLSUB : - { - this.SLSub_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY : - { - this.SLWriteProperty_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLUNBOX : - { - this.SLUnbox_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLFUNCTION_LITERAL : - { - this.SLFunctionLiteral_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLTO_BOOLEAN : - { - this.SLToBoolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLINVOKE : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvoke_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } - case INSTR_SC_SLAND : - { - if (this.SLAnd_execute_(frame, bci, sp)) { - sp = sp - 1; - bci = bci + 6; - continue loop; - } else { - bci = LE_BYTES.getShort(bc, bci + 3); - continue loop; - } - } - case INSTR_SC_SLOR : - { - if (!this.SLOr_execute_(frame, bci, sp)) { - sp = sp - 1; - bci = bci + 6; - continue loop; - } else { - bci = LE_BYTES.getShort(bc, bci + 3); - continue loop; - } - } - case INSTR_C_SLUNBOX_Q_FROM_LONG : - { - this.SLUnbox_q_FromLong_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLADD_Q_ADD_LONG : - { - this.SLAdd_q_AddLong_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : - { - this.SLReadProperty_q_ReadSLObject0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : - { - this.SLUnbox_q_FromBoolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 10; - break; - } - case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : - { - this.SLToBoolean_q_Boolean_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 4; - break; - } - case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - this.SLLessOrEqual_q_LessOrEqual0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - case INSTR_C_SLINVOKE_Q_DIRECT : - { - int numVariadics = LE_BYTES.getShort(bc, bci + 3); - Object input_0 = frame.getObject(sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = frame.getObject(sp - numVariadics + varIndex); - } - Object result = this.SLInvoke_q_Direct_execute_(frame, bci, sp, input_0, input_1); - sp = sp - 1 - numVariadics + 1; - frame.setObject(sp - 1, result); - nextBci = bci + 11; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : - { - this.SLFunctionLiteral_q_Perform_execute_(frame, bci, sp); - sp = sp - 1 + 1; - nextBci = bci + 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : - { - this.SLWriteProperty_q_WriteSLObject0_execute_(frame, bci, sp); - sp = sp - 3 + 1; - nextBci = bci + 11; - break; - } - case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : - { - this.SLLessThan_q_LessThan0_execute_(frame, bci, sp); - sp = sp - 2 + 1; - nextBci = bci + 5; - break; - } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant(bci); - for (int handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - BuilderExceptionHandler handler = handlers[handlerIndex]; - if (handler.startBci > bci || handler.endBci <= bci) continue; - sp = handler.startStack + VALUES_OFFSET + maxLocals; - frame.setObject(VALUES_OFFSET + handler.exceptionIndex, ex); - bci = handler.handlerBci; - continue loop; - } - throw ex; - } - CompilerAsserts.partialEvaluationConstant(nextBci); - bci = nextBci; - } - return returnValue; - } - - private void SLAdd_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - SLAdd_SLAdd_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLAdd_SLAdd_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLAdd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLAddNode.addLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if (((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber(bc[$bci + 4 + 2] >>> 0 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); - return; - } - } - if (((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */)) { - if (((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */)) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 5)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]), ((ConcatNode) children[childArrayOffset_ + 2]))); - return; - } - } - } - if (((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */)) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLAdd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 2]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); - bc[$bci + 4 + 2] = (byte) (state_1); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD_Q_ADD_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); - } - int type0; - int type1; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); - state_1 = (byte) (state_1 | (sLBigNumberCast1 << 0) /* set-implicit-state_1 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); - return; - } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = super.insert(new SLAdd_Add1Data()); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 5)) + 0] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[childArrayOffset_ + 1] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - children[childArrayOffset_ + 2] = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0] = s2_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, ((SLToTruffleStringNode) children[childArrayOffset_ + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]), ((ConcatNode) children[childArrayOffset_ + 2]))); - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); - bc[$bci + 4 + 2] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLADD); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLDiv_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLDiv_SLDiv_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLDiv_SLDiv_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLDiv_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; - try { - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLDivNode.divLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLDiv_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude divLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 1]; - if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_SLEqual_execute__long_long0_($frame, $bci, $sp, state_0, state_1); - return; - } else if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-not doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_SLEqual_execute__boolean_boolean1_($frame, $bci, $sp, state_0, state_1); - return; - } else { - SLEqual_SLEqual_execute__generic2_($frame, $bci, $sp, state_0, state_1); - return; - } - } - - private void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */); - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */); - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLEqual_generic1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b110000) >>> 4 /* extract-implicit-state_1 1:SLBigNumber */, $child1Value_); - boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */) && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */) && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - boolean value = SLEqualNode.doString($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */) && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, ((EqualNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 0])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */) && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ || (state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - if (((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */) && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - if (((state_1 & 0b11) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0]); - while (s7_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value_))) { - boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]), ((InteropLibrary) children[childArrayOffset_ + 2])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - s7_ = s7_.next_; - } - } - if (((state_1 & 0b10) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - $frame.setObject($sp - 2, this.SLEqual_generic1Boundary_($bci, $sp, state_0, state_1, $child0Value_, $child1Value_)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte state_1 = bc[$bci + 4 + 1]; - byte exclude = bc[$bci + 4 + 6]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - if ((state_0 & 0b11111100) == 0 /* only-active doLong(long, long) */ && (state_1 & 0b11) == 0 /* only-active */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); - state_1 = (byte) (state_1 | (sLBigNumberCast1 << 4) /* set-implicit-state_1 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - if ((state_0 & 0b11110110) == 0 /* only-active doBoolean(boolean, boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { - type0 = FRAME_TYPE_BOOLEAN; - type1 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doString($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 0] = super.insert((EqualNode.create())); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) children[childArrayOffset_ + 0])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); - bc[$bci + 4 + 1] = (byte) (state_1); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0]); - if (((state_1 & 0b1) != 0 /* is-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - while (s7_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]).accepts($child0Value)); - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 2]).accepts($child1Value)); - if (count7_ < (4)) { - s7_ = super.insert(new SLEqual_Generic0Data(((SLEqual_Generic0Data) consts[constArrayOffset_ + 0]))); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - children[childArrayOffset_ + 2] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s7_; - bc[$bci + 4 + 0] = (byte) (state_0); - bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 2)) + 1]), ((InteropLibrary) children[childArrayOffset_ + 2])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - bc[$bci + 4 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 4)) + 0] = null; - state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - bc[$bci + 4 + 0] = (byte) (state_0); - bc[$bci + 4 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLLessOrEqual_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); - } - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_OR_EQUAL); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLLessThan_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessThan_SLLessThan_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLLessThan_SLLessThan_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessThan_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN_Q_LESS_THAN0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); - } - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLLESS_THAN); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLLogicalNot_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $bci, $sp, state_0); - return; - } else { - SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLogicalNot_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLLogicalNotNode.doBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNot_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { - type0 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLMul_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLMul_SLMul_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLMul_SLMul_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLMul_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; - try { - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLMulNode.mulLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLMul_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude mulLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private void SLReadProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); - while (s0_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).hasArrayElements($child0Value_))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); - return; - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadProperty_readArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value__))) { - Node node__1 = (this); - int bci__1 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]), ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); - return; - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 2, this.SLReadProperty_readSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_)); - return; - } - } - if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2]); - while (s4_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).hasMembers($child0Value_))) { - Node node__2 = (this); - int bci__2 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]), ((SLToMemberNode) children[childArrayOffset_ + 5]))); - return; - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - $frame.setObject($sp - 2, this.SLReadProperty_readObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadProperty_readArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = (this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadProperty_readSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = (this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 3])); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLReadProperty_readObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = (this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 5])); - } - } - - private void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 5]; - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).hasArrayElements($child0Value))) { - node__ = (this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 1]).accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) consts[constArrayOffset_ + 0]))); - node__ = (this); - bci__ = ($bci); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0] = s0_.insertAccessor(arrays__); - children[childArrayOffset_ + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s0_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); - return; - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = (this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1]); - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value_))) { - node__1 = (this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]).accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) consts[constArrayOffset_ + 1]))); - node__1 = (this); - bci__1 = ($bci); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - children[childArrayOffset_ + 3] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 1] = s2_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - } - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 2]), ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); - return; - } - } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = (this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 3] = super.insert((SLToTruffleStringNodeGen.create())); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 1] = null; - state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[childArrayOffset_ + 3]))); - return; - } - } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2]); - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).hasMembers($child0Value))) { - node__2 = (this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]).accepts($child0Value)); - InteropLibrary objects__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = super.insert(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) consts[constArrayOffset_ + 2]))); - node__2 = (this); - bci__2 = ($bci); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4] = s4_.insertAccessor(objects__); - children[childArrayOffset_ + 5] = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 2] = s4_; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 4]), ((SLToMemberNode) children[childArrayOffset_ + 5]))); - return; - } - } - } - { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = (this); - readObject1_bci__ = ($bci); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 5] = super.insert((SLToMemberNodeGen.create())); - bc[$bci + 4 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 2] = null; - state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLREAD_PROPERTY); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) children[childArrayOffset_ + 5]))); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException(this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLSub_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLSub_SLSub_execute__long_long0_($frame, $bci, $sp, state_0); - return; - } else { - SLSub_SLSub_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLSub_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; - try { - long value = SLSubNode.subLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - private void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLSubNode.subLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $bci, $sp, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLSub_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 4 + 0]; - byte exclude = bc[$bci + 4 + 1]; - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { - type0 = FRAME_TYPE_LONG; - type1 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - try { - lock.unlock(); - hasLock = false; - long value = SLSubNode.subLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude subLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - bc[$bci + 4 + 1] = exclude = (byte) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); - state_0 = (byte) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (byte) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 4 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private void SLWriteProperty_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3); - Object $child1Value_ = expectObject($frame, $sp - 2); - Object $child2Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (s0_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value_)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[constArrayOffset_ + 1]), ((InteropLibrary) children[childArrayOffset_ + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); - return; - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, this.SLWriteProperty_writeArray1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]), ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); - return; - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 3, this.SLWriteProperty_writeSLObject1Boundary_($bci, $sp, state_0, $child0Value__, $child1Value_, $child2Value_)); - return; - } - } - if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3]); - while (s4_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]), ((SLToMemberNode) children[childArrayOffset_ + 6]))); - return; - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - $frame.setObject($sp - 3, this.SLWriteProperty_writeObject1Boundary_($bci, $sp, state_0, $child0Value_, $child1Value_, $child2Value_)); - return; - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWriteProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLWriteProperty_writeArray1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 1]), writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLWriteProperty_writeSLObject1Boundary_(int $bci, int $sp, byte state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 4])); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLWriteProperty_writeObject1Boundary_(int $bci, int $sp, byte state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - Node writeObject1_node__ = (this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 6])); - } - } finally { - encapsulating_.set(prev_); - } - } - - private void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - byte exclude = bc[$bci + 5 + 5]; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value)) && (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).hasArrayElements($child0Value))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create($child0Value))); - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value)); - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1]).accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = super.insert(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) consts[constArrayOffset_ + 0]))); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = s0_.insertAccessor((this)); - consts[constArrayOffset_ + 1] = ($bci); - children[childArrayOffset_ + 0] = s0_.insertAccessor(arrays__); - children[childArrayOffset_ + 1] = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s0_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), ((int) consts[constArrayOffset_ + 1]), ((InteropLibrary) children[childArrayOffset_ + 0]), ((InteropLibrary) children[childArrayOffset_ + 1]))); - return; - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((this)); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 1] = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - consts[constArrayOffset_ + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ((Node) children[childArrayOffset_ + 2]), ((int) consts[constArrayOffset_ + 1]), writeArray1_arrays__, writeArray1_numbers__)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2]); - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]).accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = super.insert(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) consts[constArrayOffset_ + 2]))); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3] = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - children[childArrayOffset_ + 4] = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 2] = s2_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - } - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 3]), ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); - return; - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 4] = super.insert((SLToTruffleStringNodeGen.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 2] = null; - state_0 = (byte) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) children[childArrayOffset_ + 4]))); - return; - } - } - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3]); - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__ = (this); - bci__ = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]).accepts($child0Value)); - s4_ = super.insert(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) consts[constArrayOffset_ + 3]))); - node__ = (this); - bci__ = ($bci); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5] = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - children[childArrayOffset_ + 6] = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 3] = s4_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__, bci__, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 5]), ((SLToMemberNode) children[childArrayOffset_ + 6]))); - return; - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = (this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 6] = super.insert((SLToMemberNodeGen.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 3] = null; - state_0 = (byte) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLWRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = FRAME_TYPE_OBJECT; - type1 = FRAME_TYPE_OBJECT; - type2 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - doSetResultBoxed(bc, $bci, bc[$bci + 3], type1); - doSetResultBoxed(bc, $bci, bc[$bci + 4], type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) children[childArrayOffset_ + 6]))); - return; - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLUnbox_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - byte state_1 = bc[$bci + 3 + 1]; - if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnbox_SLUnbox_execute__boolean0_($frame, $bci, $sp, state_0, state_1); - return; - } else if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */ && ((state_0 & 0b11111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) */ || (state_1 & 0b11) != 0 /* is-not fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnbox_SLUnbox_execute__long1_($frame, $bci, $sp, state_0, state_1); - return; - } else { - SLUnbox_SLUnbox_execute__generic2_($frame, $bci, $sp, state_0, state_1); - return; - } - } - - private void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private Object SLUnbox_fromForeign1Boundary_(int $bci, int $sp, byte state_0, byte state_1, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, int $bci, int $sp, byte state_0, byte state_1) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if (((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */) && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, ((FromJavaStringNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 0]))); - return; - } - if (((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */) && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); - return; - } - if (((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */) && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLUnboxNode.fromBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if (((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */) && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - long value = SLUnboxNode.fromLong($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - if (((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */) && SLTypesGen.isImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_1 & 0b1100) >>> 2 /* extract-implicit-state_1 0:SLBigNumber */, $child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); - return; - } - if (((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */) && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if (((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */) && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if (((state_1 & 0b11) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */)) { - if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0]); - while (s7_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value_))) { - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]))); - return; - } - s7_ = s7_.next_; - } - } - if (((state_1 & 0b10) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - $frame.setObject($sp - 1, this.SLUnbox_fromForeign1Boundary_($bci, $sp, state_0, state_1, $child0Value_)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnbox_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - byte state_1 = bc[$bci + 3 + 1]; - byte exclude = bc[$bci + 3 + 6]; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 0] = super.insert((FromJavaStringNode.create())); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) children[childArrayOffset_ + 0]))); - return; - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); - return; - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); - bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_Q_FROM_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - } - int type0; - if ((state_0 & 0b11110110) == 0 /* only-active fromBoolean(boolean) */ && (state_1 & 0b11) == 0 /* only-active */) { - type0 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); - bc[$bci + 3 + 1] = (byte) (state_1); - if ((state_0 & 0b11111110) == 0b10000/* is-exact-state_0 fromLong(long) */ && (state_1 & 0b11) == 0/* is-exact-state_1 */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX_Q_FROM_LONG); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - } - int type0; - if ((state_0 & 0b11101110) == 0 /* only-active fromLong(long) */ && (state_1 & 0b11) == 0 /* only-active */) { - type0 = FRAME_TYPE_LONG; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_1 = (byte) (state_1 | (sLBigNumberCast0 << 2) /* set-implicit-state_1 0:SLBigNumber */); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); - bc[$bci + 3 + 1] = (byte) (state_1); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0]); - if (((state_1 & 0b1) != 0 /* is-state_1 fromForeign(Object, InteropLibrary) */)) { - while (s7_ != null) { - if ((((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]).accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = super.insert(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) consts[constArrayOffset_ + 0]))); - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1] = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s7_; - bc[$bci + 3 + 0] = (byte) (state_0); - bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b1 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 2)) + 1]))); - return; - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set(this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - bc[$bci + 3 + 6] = exclude = (byte) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 4)) + 0] = null; - state_1 = (byte) (state_1 & 0xfffffffe /* remove-state_1 fromForeign(Object, InteropLibrary) */); - bc[$bci + 3 + 0] = (byte) (state_0); - bc[$bci + 3 + 1] = state_1 = (byte) (state_1 | 0b10 /* add-state_1 fromForeign(Object, InteropLibrary) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLUNBOX); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); - return; - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLFunctionLiteral_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0]), node__)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteral_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, this)); - node__ = (this); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLFUNCTION_LITERAL); - } - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) consts[constArrayOffset_ + 0]), node__)); - return; - } - } - throw new UnsupportedSpecializationException(this, new Node[] {null}, $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLToBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - SLToBoolean_SLToBoolean_execute__boolean0_($frame, $bci, $sp, state_0); - return; - } else { - SLToBoolean_SLToBoolean_execute__generic1_($frame, $bci, $sp, state_0); - return; - } - } - - private void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLToBooleanNode.doBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - private void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 3 + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN); - } - int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { - type0 = FRAME_TYPE_BOOLEAN; - } else { - type0 = FRAME_TYPE_OBJECT; - } - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 3 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLTO_BOOLEAN); - int type0; - type0 = FRAME_TYPE_OBJECT; - doSetResultBoxed(bc, $bci, bc[$bci + 2], type0); - lock.unlock(); - hasLock = false; - boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private Object SLInvoke_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $bci, $sp, s0_); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1])); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = (this); - int interop_bci__ = ($bci); - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2]), interop_node__, interop_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - byte exclude = bc[$bci + 5 + 5]; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2])) && Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); - if ((arg0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = super.insert(new SLInvoke_DirectData(((SLInvoke_DirectData) consts[constArrayOffset_ + 0]))); - consts[constArrayOffset_ + 1] = callTargetStable__; - consts[constArrayOffset_ + 2] = cachedTarget__; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0] = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - consts[constArrayOffset_ + 0] = s0_; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE_Q_DIRECT); - } else { - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - } - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); - } - } - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 1] = super.insert((IndirectCallNode.create())); - bc[$bci + 5 + 5] = exclude = (byte) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0] = null; - state_0 = (byte) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) children[childArrayOffset_ + 1])); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 2] = super.insert((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = (this); - interop_bci__ = ($bci); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - LE_BYTES.putShort(bc, $bci, (short) INSTR_C_SLINVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) children[childArrayOffset_ + 2]), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLInvoke_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[constArrayOffset_ + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if (consts[constArrayOffset_ + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private boolean SLAnd_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $bci, $sp, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $bci, $sp, state_0); - } - } - - private boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - return SLAnd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - } - - private boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private boolean SLOr_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $bci, $sp, state_0); - } else { - return SLOr_SLOr_execute__generic1_($frame, $bci, $sp, state_0); - } - } - - private boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - return SLOr_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, int $bci, int $sp, byte state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = (this); - int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $bci, $sp, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - } - - private boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, int $bci, int $sp, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - boolean hasLock = true; - lock.lock(); - try { - byte state_0 = bc[$bci + 5 + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = (this); - fallback_bci__ = ($bci); - bc[$bci + 5 + 0] = state_0 = (byte) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */); - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - private void SLAdd_q_AddLong_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLAdd_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */); - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - // implicit transferToInterpreterAndInvalidate() - Lock lock = getLock(); - lock.lock(); - try { - bc[$bci + 4 + 1] = (byte) (bc[$bci + 4 + 1] | 0b1 /* add-exclude addLong(long, long) */); - bc[$bci + 4 + 0] = (byte) (bc[$bci + 4 + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - } - - @ExplodeLoop - private void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 1)) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]).accepts($child0Value__))) { - Node node__ = (this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 4 + 3)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]))); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_); - return; - } - - private void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLUnbox_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */); - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLToBoolean_executeAndSpecialize_($frame, $bci, $sp, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessOrEqual_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @ExplodeLoop - private Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, int $bci, int $sp, Object arg0Value, Object[] arg1Value) { - byte state_0 = bc[$bci + 5 + 0]; - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((((Assumption) consts[constArrayOffset_ + 1])))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_q_Direct_removeDirect__($frame, $bci, $sp, s0_); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == ((RootCallTarget) consts[constArrayOffset_ + 2]))) { - return SLInvoke.doDirect(arg0Value_, arg1Value, ((Assumption) consts[constArrayOffset_ + 1]), ((RootCallTarget) consts[constArrayOffset_ + 2]), ((DirectCallNode) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0])); - } - s0_ = s0_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $bci, $sp, arg0Value, arg1Value); - } - - private void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, int $bci, int $sp, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = getLock(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - consts[constArrayOffset_ + 0] = this.insert(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if (consts[constArrayOffset_ + 0] == null) { - bc[$bci + 5 + 0] = (byte) (bc[$bci + 5 + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 3 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = (this); - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, ((SLFunction) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 3 + 1)) + 0]), node__)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteral_executeAndSpecialize_($frame, $bci, $sp, $child0Value_); - return; - } - - @ExplodeLoop - private void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 5 + 0]; - Object $child0Value_ = expectObject($frame, $sp - 3); - Object $child1Value_ = expectObject($frame, $sp - 2); - Object $child2Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) consts[(constArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 1)) + 0]); - while (s2_ != null) { - if ((((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]).accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, ((DynamicObjectLibrary) children[(childArrayOffset_ = LE_BYTES.getShort(bc, $bci + 5 + 3)) + 0]), ((SLToTruffleStringNode) children[childArrayOffset_ + 1]))); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWriteProperty_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, int $bci, int $sp) { - byte state_0 = bc[$bci + 4 + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - Object $child1Value = expectObject($frame, $sp - 1); - SLLessThan_executeAndSpecialize_($frame, $bci, $sp, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - SLLessThan_executeAndSpecialize_($frame, $bci, $sp, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - int bci = 0; - while (bci < bc.length) { - switch (LE_BYTES.getShort(bc, bci)) { - case INSTR_POP : - { - bci = bci + 2; - break; - } - case INSTR_BRANCH : - case INSTR_THROW : - case INSTR_LOAD_CONSTANT_OBJECT : - case INSTR_LOAD_ARGUMENT_OBJECT : - case INSTR_LOAD_ARGUMENT_BOOLEAN : - case INSTR_LOAD_ARGUMENT_LONG : - case INSTR_LOAD_LOCAL_OBJECT : - case INSTR_LOAD_LOCAL_BOOLEAN : - case INSTR_LOAD_LOCAL_LONG : - case INSTR_LOAD_LOCAL_UNINIT : - case INSTR_C_SLLOGICAL_NOT : - case INSTR_C_SLTO_BOOLEAN : - case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : - { - bci = bci + 4; - break; - } - case INSTR_BRANCH_FALSE : - { - bci = bci + 7; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - case INSTR_LOAD_CONSTANT_LONG : - { - LE_BYTES.putShort(bc, bci, (short) INSTR_LOAD_CONSTANT_OBJECT); - bci = bci + 4; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - case INSTR_STORE_LOCAL_BOOLEAN : - case INSTR_STORE_LOCAL_LONG : - case INSTR_STORE_LOCAL_UNINIT : - case INSTR_C_SLLESS_OR_EQUAL : - case INSTR_C_SLLESS_THAN : - case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : - { - bci = bci + 5; - break; - } - case INSTR_RETURN : - { - bci = bci + 3; - break; - } - case INSTR_C_SLADD : - case INSTR_C_SLEQUAL : - case INSTR_C_SLWRITE_PROPERTY : - case INSTR_C_SLINVOKE : - case INSTR_C_SLADD_Q_ADD_LONG : - case INSTR_C_SLINVOKE_Q_DIRECT : - case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : - { - bci = bci + 11; - break; - } - case INSTR_C_SLDIV : - case INSTR_C_SLMUL : - case INSTR_C_SLSUB : - case INSTR_C_SLFUNCTION_LITERAL : - case INSTR_SC_SLAND : - case INSTR_SC_SLOR : - case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : - { - bci = bci + 6; - break; - } - case INSTR_C_SLREAD_PROPERTY : - case INSTR_C_SLUNBOX : - case INSTR_C_SLUNBOX_Q_FROM_LONG : - case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : - case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : - { - bci = bci + 10; - break; - } - } - } - } - - @Override - public String dump() { - int bci = 0; - int instrIndex = 0; - StringBuilder sb = new StringBuilder(); - while (bci < bc.length) { - sb.append(String.format(" %04x ", bci)); - switch (LE_BYTES.getShort(bc, bci)) { - default : - { - sb.append(String.format("unknown 0x%02x", bc[bci++])); - break; - } - case INSTR_POP : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("pop "); - sb.append("_"); - sb.append(" -> "); - bci += 2; - break; - } - case INSTR_BRANCH : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch "); - sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("branch"); - bci += 4; - break; - } - case INSTR_BRANCH_FALSE : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch.false "); - sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 2))); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); - sb.append(", "); - sb.append(" -> "); - sb.append("branch"); - bci += 7; - break; - } - case INSTR_THROW : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("throw "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - bci += 4; - break; - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.object "); - { - Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; - sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); - } - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.boolean "); - { - Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; - sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); - } - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.long "); - { - Object o = consts[LE_BYTES.getShort(bc, bci + 2)]; - sb.append(String.format("%s %s", o.getClass().getSimpleName(), o)); - } - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.object "); - sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format("arg[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.object "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); - bci += 5; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); - bci += 5; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); - bci += 5; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.uninit "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 3))); - bci += 5; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.object "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.uninit "); - sb.append(String.format("loc[%d]", LE_BYTES.getShort(bc, bci + 2))); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_RETURN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("return"); - bci += 3; - break; - } - case INSTR_C_SLADD : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLDIV : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDiv "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLEQUAL : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqual "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLLESS_OR_EQUAL : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } - case INSTR_C_SLLESS_THAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } - case INSTR_C_SLLOGICAL_NOT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_C_SLMUL : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLMul "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLREAD_PROPERTY : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLSUB : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLSub "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLWriteProperty "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLUNBOX : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLFUNCTION_LITERAL : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLTO_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_C_SLINVOKE : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_SC_SLAND : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("branch"); - bci += 6; - break; - } - case INSTR_SC_SLOR : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLOr "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("%04x", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("branch"); - bci += 6; - break; - } - case INSTR_C_SLUNBOX_Q_FROM_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLADD_Q_ADD_LONG : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLREAD_PROPERTY_Q_READ_SLOBJECT0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty.q.ReadSLObject0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLUNBOX_Q_FROM_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBoolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 10; - break; - } - case INSTR_C_SLTO_BOOLEAN_Q_BOOLEAN : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 4; - break; - } - case INSTR_C_SLLESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } - case INSTR_C_SLINVOKE_Q_DIRECT : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("**%d", LE_BYTES.getShort(bc, bci + 3))); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLFUNCTION_LITERAL_Q_PERFORM : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(" -> "); - sb.append("x"); - bci += 6; - break; - } - case INSTR_C_SLWRITE_PROPERTY_Q_WRITE_SLOBJECT0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(String.format("%02x ", bc[bci + 5])); - sb.append(String.format("%02x ", bc[bci + 6])); - sb.append(String.format("%02x ", bc[bci + 7])); - sb.append(String.format("%02x ", bc[bci + 8])); - sb.append(String.format("%02x ", bc[bci + 9])); - sb.append(String.format("%02x ", bc[bci + 10])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLWriteProperty.q.WriteSLObject0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 4])); - sb.append(" -> "); - sb.append("x"); - bci += 11; - break; - } - case INSTR_C_SLLESS_THAN_Q_LESS_THAN0 : - { - sb.append(String.format("%02x ", bc[bci + 0])); - sb.append(String.format("%02x ", bc[bci + 1])); - sb.append(String.format("%02x ", bc[bci + 2])); - sb.append(String.format("%02x ", bc[bci + 3])); - sb.append(String.format("%02x ", bc[bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan0 "); - sb.append(String.format("pop[-%d]", bc[bci + 2])); - sb.append(", "); - sb.append(String.format("pop[-%d]", bc[bci + 3])); - sb.append(" -> "); - sb.append("x"); - bci += 5; - break; - } - } - sb.append("\n"); - } - for (int i = 0; i < handlers.length; i++) { - sb.append(handlers[i] + "\n"); - } - return sb.toString(); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, byte state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, int $bci, int $sp, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { - Object value = frame.getValue(sourceSlot); - if (localTag == FRAME_TYPE_BOOLEAN && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return FRAME_TYPE_BOOLEAN; - } - if (localTag == FRAME_TYPE_LONG && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return FRAME_TYPE_LONG; - } - frame.setObject(localIdx, value); - return FRAME_TYPE_OBJECT; - } - - private static void doSetResultBoxed(byte[] bc, int startBci, int bciOffset, int targetType) { - if (bciOffset != 0) { - setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); - } - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child Node node_; - @CompilationFinal int bci_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperations.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index aa0c3a53436b..bc9f90aaaa40 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -5,10 +5,12 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.GenerateOperations.Metadata; +import com.oracle.truffle.api.operation.LocalSetter; import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; @@ -84,4 +86,19 @@ public static void perform(List list, Object value) { list.add(value); } } + + @Operation + static final class TeeLocal { + @Specialization + public static long doInt(VirtualFrame frame, long value, LocalSetter setter) { + setter.setLong(frame, value); + return value; + } + + @Specialization + public static Object doGeneric(VirtualFrame frame, Object value, LocalSetter setter) { + setter.setObject(frame, value); + return value; + } + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index da274cf60094..67acf148b31a 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -906,4 +906,25 @@ public void testMetadataDefaultValue() { Assert.assertEquals(TestOperations.TestData.getDefaultValue(), node.getMetadata(TestOperations.TestData)); Assert.assertEquals(TestOperations.TestData.getDefaultValue(), TestOperations.TestData.getValue(node)); } + + @Test + public void testTeeLocal() { + RootCallTarget root = parse(b -> { + + OperationLocal local = b.createLocal(); + + b.beginTeeLocal(); + b.emitConstObject(1L); + b.emitLocalSetter(local); + b.endTeeLocal(); + + b.beginReturn(); + b.emitLoadLocal(local); + b.endReturn(); + + b.publish(); + }); + + Assert.assertEquals(1L, root.call()); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index 165e2f91899d..08293024c706 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -8,9 +8,11 @@ public class BuilderOperationData { public final boolean needsLeave; public final Object[] aux; public final Object[] arguments; + public final OperationLocal[] localReferences; public int numChildren = 0; + public int numLocalReferences = 0; - public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { + public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, int numLocalReferences, Object... arguments) { this.parent = parent; this.depth = parent == null ? 0 : parent.depth + 1; this.operationId = id; @@ -18,5 +20,6 @@ public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, this.aux = new Object[numAux]; this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); this.arguments = arguments; + this.localReferences = new OperationLocal[numLocalReferences]; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java new file mode 100644 index 000000000000..776669a04a4c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -0,0 +1,57 @@ +package com.oracle.truffle.api.operation; + +import java.util.HashMap; + +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.VirtualFrame; + +public final class LocalSetter { + + private final int index; + + private static final HashMap LOCAL_SETTERS = new HashMap<>(); + + public static LocalSetter create(int index) { + return LOCAL_SETTERS.computeIfAbsent(index, LocalSetter::new); + } + + private LocalSetter(int index) { + this.index = index; + } + + public void setObject(VirtualFrame frame, Object value) { + frame.setObject(index, value); + } + + public void setLong(VirtualFrame frame, long value) { + FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); + if (slotKind == FrameSlotKind.Long) { + frame.setLong(index, value); + } else { + // TODO this should be compatible with local boxing elimination + frame.setObject(index, value); + } + } + + public void setInt(VirtualFrame frame, int value) { + FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); + if (slotKind == FrameSlotKind.Int) { + frame.setInt(index, value); + } else { + // TODO this should be compatible with local boxing elimination + frame.setObject(index, value); + } + } + + public void setDouble(VirtualFrame frame, double value) { + FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); + if (slotKind == FrameSlotKind.Double) { + frame.setDouble(index, value); + } else { + // TODO this should be compatible with local boxing elimination + frame.setObject(index, value); + } + } + + // TODO other primitives +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 3173b0645881..7621937b510a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -67,7 +67,7 @@ private void reset() { numLocals = 0; constPool.reset(); - operationData = new BuilderOperationData(null, getBlockOperationIndex(), 0, 0, false); + operationData = new BuilderOperationData(null, getBlockOperationIndex(), 0, 0, false, 0); labelFills.clear(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java index 0e7d3e9b541e..51d84f3bbdb3 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java @@ -20,10 +20,16 @@ public synchronized int add(Object o) { } public synchronized int reserve() { + return reserve(1); + } + + public synchronized int reserve(int count) { if (frozen) throw new IllegalStateException("constant pool already frozen"); int idx = values.size(); - values.add(null); + for (int i = 0; i < count; i++) { + values.add(null); + } return idx; } @@ -33,6 +39,10 @@ public synchronized void reset() { this.frozenValues = null; } + public void setValue(int offset, Object value) { + values.set(offset, value); + } + public synchronized void freeze() { frozen = true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index bcd0053d314b..1dbaa5fc6737 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -234,6 +234,7 @@ public class TruffleTypes { public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata"; public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal"; public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; + public static final String LocalSetter_Name = "com.oracle.truffle.api.operation.LocalSetter"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; @@ -256,6 +257,7 @@ public class TruffleTypes { public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name); + public final DeclaredType LocalSetter = c.getDeclaredTypeOptional(LocalSetter_Name); public final DeclaredType MetadataKey = c.getDeclaredTypeOptional(MetadataKey_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index f8865fed520b..55804b8859b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -71,6 +71,10 @@ public int minimumChildren() { public abstract List getBuilderArgumentTypes(); + public boolean needsOperationData() { + return true; + } + @SuppressWarnings("unused") public CodeTree createBeginCode(BuilderVariables vars) { return null; @@ -104,6 +108,14 @@ public int getNumAuxValues() { return 0; } + public int numLocalReferences() { + return 0; + } + + public boolean isRealOperation() { + return true; + } + public abstract CodeTree createPushCountCode(BuilderVariables vars); public static class Simple extends Operation { @@ -142,6 +154,11 @@ public CodeTree createPushCountCode(BuilderVariables vars) { public List getBuilderArgumentTypes() { return instruction.getBuilderArgumentTypes(); } + + @Override + public int numLocalReferences() { + return instruction.numLocalReferences(); + } } public static class LoadConstant extends Operation { @@ -440,6 +457,11 @@ public CodeTree createEndCode(BuilderVariables vars) { public List getBuilderArgumentTypes() { return List.of(ProcessorContext.getInstance().getTypes().OperationLabel); } + + @Override + public boolean needsOperationData() { + return false; + } } public static class TryCatch extends Operation { @@ -817,6 +839,42 @@ public CodeTree createEndCode(BuilderVariables vars) { } + public static class LocalSetter extends Operation { + + protected LocalSetter(OperationsContext context, int id) { + super(context, "LocalSetter", id, 0); + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(getTypes().OperationLocal); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().variable(vars.operationData).string(".localReferences[").variable(vars.operationData).string(".numLocalReferences++] = arg0").end(); + + return b.build(); + } + + @Override + public boolean needsOperationData() { + return false; + } + + @Override + public boolean isRealOperation() { + return false; + } + } + private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement()// .variable(vars.operationData).string(".aux[" + index + "] = ") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index eac7b117ef4b..3738275e68ad 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -206,7 +206,7 @@ public CodeTypeElement createBuilderBytecodeNode() { cinstr.setExecuteMethod(uncExec); cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); cinstr.setNumChildNodes(childIndices.size()); - cinstr.setNumConsts(constIndices.size()); + cinstr.setNumConsts(constIndices); cinstr.setPrepareAOTMethod(metPrepareForAOT); if (m.isTracing()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 97336840d62c..8495a23a0560 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -519,8 +519,31 @@ private FrameKind getFrameType(TypeKind type) { return OperationsData.convertToFrameType(type); } + public static final class LocalRefHandle { + private final String name; + + private LocalRefHandle(String name) { + this.name = name; + + } + + @Override + public boolean equals(Object obj) { + return obj instanceof LocalRefHandle && ((LocalRefHandle) obj).name.equals(this.name); + } + + @Override + public int hashCode() { + return name.hashCode(); + } + } + @Override public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { + if (execution.getName().startsWith("$localRef")) { + return createArrayReference(frameState, new LocalRefHandle(execution.getName()), true, types.LocalSetter, false); + } + int childIndex = execution.getIndex(); int offset = cinstr.numPopStatic() - childIndex; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 424481925f6b..974ba4e9d6a3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -424,11 +424,13 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } - b.statement("doBeforeChild()"); + if (op.isRealOperation()) { + b.statement("doBeforeChild()"); + } - boolean isLabel = op instanceof Operation.Label; + boolean needsData = op.needsOperationData(); - if (!isLabel) { + if (needsData) { b.startAssign(vars.operationData); b.startNew(types.BuilderOperationData); @@ -438,6 +440,8 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.string("" + op.getNumAuxValues()); b.string("false"); + b.string("" + op.numLocalReferences()); + for (VariableElement v : metEmit.getParameters()) { b.variable(v); } @@ -449,11 +453,13 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.startAssign(vars.lastChildPushCount).tree(op.createPushCountCode(vars)).end(); - if (!isLabel) { + if (needsData) { b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); } - b.statement("doAfterChild()"); + if (op.isRealOperation()) { + b.statement("doAfterChild()"); + } return metEmit; } @@ -517,9 +523,13 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui b.startAssign(vars.lastChildPushCount).tree(lastPush).end(); } - b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); + if (op.needsOperationData()) { + b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); + } - b.statement("doAfterChild()"); + if (op.isRealOperation()) { + b.statement("doAfterChild()"); + } vars.numChildren = null; @@ -547,21 +557,27 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B b.statement("indent++"); } - b.statement("doBeforeChild()"); + if (op.isRealOperation()) { + b.statement("doBeforeChild()"); + } - b.startAssign(vars.operationData).startNew(types.BuilderOperationData); + if (op.needsOperationData()) { + b.startAssign(vars.operationData).startNew(types.BuilderOperationData); - b.variable(vars.operationData); - b.variable(op.idConstantField); - b.string("getCurStack()"); - b.string("" + op.getNumAuxValues()); - b.string("" + op.hasLeaveCode()); + b.variable(vars.operationData); + b.variable(op.idConstantField); + b.string("getCurStack()"); + b.string("" + op.getNumAuxValues()); + b.string("" + op.hasLeaveCode()); - for (VariableElement el : metBegin.getParameters()) { - b.variable(el); - } + b.string("" + op.numLocalReferences()); - b.end(2); + for (VariableElement el : metBegin.getParameters()) { + b.variable(el); + } + + b.end(2); + } b.tree(op.createBeginCode(vars)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 76496c33ea00..335bce0e2b8d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -7,6 +7,10 @@ import java.util.Map; import java.util.Set; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -89,6 +93,8 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); + add(new Operation.LocalSetter(this, operationId++)); + add(new Operation.InstrumentTag(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++)), diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 75491d4d9c65..e8178cf6fb3f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -29,7 +29,8 @@ public class SingleOperationData extends Template { public static enum ParameterKind { STACK_VALUE, VARIADIC, - VIRTUAL_FRAME; + VIRTUAL_FRAME, + LOCAL_SETTER; public TypeMirror getParameterType(ProcessorContext context) { switch (this) { @@ -39,6 +40,8 @@ public TypeMirror getParameterType(ProcessorContext context) { return new ArrayCodeTypeMirror(context.getType(Object.class)); case VIRTUAL_FRAME: return context.getTypes().VirtualFrame; + case LOCAL_SETTER: + return context.getTypes().LocalSetter; default: throw new IllegalArgumentException("" + this); } @@ -50,6 +53,7 @@ public boolean isStackValue() { case VARIADIC: return true; case VIRTUAL_FRAME: + case LOCAL_SETTER: return false; default: throw new IllegalArgumentException(this.toString()); @@ -63,8 +67,9 @@ public static class MethodProperties { public final boolean isVariadic; public final boolean returnsValue; public final int numStackValues; + public final int numLocalReferences; - public MethodProperties(ExecutableElement element, List parameters, boolean isVariadic, boolean returnsValue) { + public MethodProperties(ExecutableElement element, List parameters, boolean isVariadic, boolean returnsValue, int numLocalReferences) { this.element = element; this.parameters = parameters; int stackValues = 0; @@ -76,6 +81,7 @@ public MethodProperties(ExecutableElement element, List parameter this.numStackValues = stackValues; this.isVariadic = isVariadic; this.returnsValue = returnsValue; + this.numLocalReferences = numLocalReferences; } public void checkMatches(SingleOperationData data, MethodProperties other) { @@ -90,11 +96,16 @@ public void checkMatches(SingleOperationData data, MethodProperties other) { if (other.returnsValue != returnsValue) { data.addError(element, "All methods must (not) return value"); } + + if (other.numLocalReferences != numLocalReferences) { + data.addError(element, "All methods must have same number of local references"); + } } @Override public String toString() { - return "Props[parameters=" + parameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + ", numStackValues=" + numStackValues + "]"; + return "Props[parameters=" + parameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + ", numStackValues=" + numStackValues + ", numLocalReferences=" + numLocalReferences + + "]"; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 89bd87209594..8ce217438419 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -229,17 +229,22 @@ protected SingleOperationData parse(Element element, List mirr private void addBoxingEliminationNodeChildAnnotations(MethodProperties props, CodeTypeElement ct) { int i = 0; + int localI = 0; CodeTypeElement childType = createRegularNodeChild(); CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); List anns = new ArrayList<>(); for (ParameterKind param : props.parameters) { + CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); if (param == ParameterKind.STACK_VALUE) { - CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); - // CodeTypeElement childType = createRegularNodeChild(); ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); anns.add(new CodeAnnotationValue(ann)); i++; + } else if (param == ParameterKind.LOCAL_SETTER) { + ann.setElementValue("value", new CodeAnnotationValue("$localRef" + localI)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterNodeChild()))); + anns.add(new CodeAnnotationValue(ann)); + localI++; } } repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); @@ -283,6 +288,7 @@ public DeclaredType getAnnotationType() { private MethodProperties processMethod(SingleOperationData data, ExecutableElement method) { boolean isVariadic = false; + int numLocalSetters = 0; List parameters = new ArrayList<>(); for (VariableElement param : method.getParameters()) { @@ -290,12 +296,21 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme if (isVariadic) { data.addError(method, "Multiple @Variadic arguments not allowed"); } + if (numLocalSetters > 0) { + data.addError(param, "Value arguments after LocalSetter not allowed"); + } isVariadic = true; parameters.add(ParameterKind.VARIADIC); + } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetter)) { + parameters.add(ParameterKind.LOCAL_SETTER); + numLocalSetters++; } else if (!isIgnoredParameter(param)) { if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); } + if (numLocalSetters > 0) { + data.addError(param, "Value arguments after LocalSetter not allowed"); + } if (ElementUtils.typeEquals(param.asType(), types.Frame) || ElementUtils.typeEquals(param.asType(), types.VirtualFrame)) { parameters.add(ParameterKind.VIRTUAL_FRAME); } else { @@ -306,7 +321,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; - MethodProperties props = new MethodProperties(method, parameters, isVariadic, returnsValue); + MethodProperties props = new MethodProperties(method, parameters, isVariadic, returnsValue, numLocalSetters); return props; } @@ -343,6 +358,15 @@ private CodeTypeElement createRegularNodeChild() { return result; } + private CodeTypeElement createLocalSetterNodeChild() { + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + result.setSuperClass(types.Node); + + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetter)); + + return result; + } + private CodeExecutableElement createChildExecuteMethod(String name, TypeMirror retType) { CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); // result.addParameter(new CodeVariableElement(types.Frame, "frame")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 1043bb4de5d3..d3f2583f308c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -12,7 +12,9 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs.LocalRefHandle; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -36,6 +38,7 @@ public enum DataKind { private final List quickenedVariants = new ArrayList<>(); private int boxingEliminationBitOffset; private int boxingEliminationBitMask; + private ArrayList localRefIndices; public SingleOperationData getData() { return data; @@ -114,22 +117,34 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.end(); break; case CONST: + b.startAssign("int constantOffset").startCall(vars.consts, "reserve").string("" + numConsts).end(2); + b.startStatement(); b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); b.tree(index); - b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).startCall(vars.consts, "reserve").end(2); + b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).string("constantOffset").end(); b.end(); break; case CONTINUATION: break; + default: + throw new UnsupportedOperationException("unexpected value: " + dataKinds[i]); } b.end(); } - for (int i = 1; i < numConsts; i++) { - b.startStatement().startCall(vars.consts, "reserve").end(2); + int iLocal = 0; + for (int localIndex : localRefIndices) { + b.startStatement().startCall(vars.consts, "setValue"); + b.string("constantOffset + " + localIndex); + b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "create"); + b.startCall("getLocalIndex"); + b.startGroup().variable(vars.operationData).string(".localReferences[" + (iLocal++) + "]").end(); + b.end(); + b.end(); + b.end(2); } return b.build(); @@ -266,8 +281,16 @@ public void setNumChildNodes(int numChildNodes) { this.numChildNodes = numChildNodes; } - public void setNumConsts(int numConsts) { - this.numConsts = numConsts; + public void setNumConsts(List consts) { + this.numConsts = consts.size(); + this.localRefIndices = new ArrayList<>(); + int i = 0; + for (Object c : consts) { + if (c instanceof LocalRefHandle) { + localRefIndices.add(i); + } + i++; + } } public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { @@ -337,4 +360,9 @@ public void addQuickenedVariant(QuickenedInstruction quick) { public List getQuickenedVariants() { return quickenedVariants; } + + @Override + public int numLocalReferences() { + return data.getMainProperties().numLocalReferences; + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index d69ee664cdfb..8428b4f37275 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -631,4 +631,8 @@ public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { public CodeTree[] createTracingArguments(ExecutionVariables vars) { return new CodeTree[0]; } + + public int numLocalReferences() { + return 0; + } } From 3d76b28e07bdd2afdfa809e5f3f4f691ff98c7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 16 Jun 2022 12:07:23 +0200 Subject: [PATCH 092/312] [wip] changes --- .../api/operation/BuilderOperationData.java | 6 ++-- .../truffle/api/operation/LocalSetter.java | 8 +++++ .../api/operation/OperationBuilder.java | 10 ++++++ .../dsl/processor/operations/Operation.java | 36 +++++++++++++++++++ .../OperationsBytecodeNodeGeneratorPlugs.java | 5 +++ .../operations/OperationsContext.java | 1 + .../operations/SingleOperationData.java | 6 +++- .../operations/SingleOperationParser.java | 22 +++++++++++- .../instructions/CustomInstruction.java | 17 ++++++--- .../truffle/sl/parser/SLBaseVisitor.java | 7 ++++ .../sl/parser/SLOperationsVisitor.java | 14 ++------ 11 files changed, 112 insertions(+), 20 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java index 08293024c706..a03aa7441fbd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java @@ -8,7 +8,7 @@ public class BuilderOperationData { public final boolean needsLeave; public final Object[] aux; public final Object[] arguments; - public final OperationLocal[] localReferences; + public OperationLocal[] localReferences; public int numChildren = 0; public int numLocalReferences = 0; @@ -20,6 +20,8 @@ public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, this.aux = new Object[numAux]; this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); this.arguments = arguments; - this.localReferences = new OperationLocal[numLocalReferences]; + if (numLocalReferences > 0) { + this.localReferences = new OperationLocal[numLocalReferences]; + } } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index 776669a04a4c..3901ce2c584f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -15,6 +15,14 @@ public static LocalSetter create(int index) { return LOCAL_SETTERS.computeIfAbsent(index, LocalSetter::new); } + public static LocalSetter[] createArray(int[] index) { + LocalSetter[] result = new LocalSetter[index.length]; + for (int i = 0; i < index.length; i++) { + result[i] = create(index[i]); + } + return result; + } + private LocalSetter(int index) { this.index = index; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 7621937b510a..b0a422eb58cf 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -230,6 +230,16 @@ protected int getLocalIndex(Object value) { return local.id; } + protected int[] getLocalIndices(Object[] value) { + int[] result = new int[value.length]; + for (int i = 0; i < value.length; i++) { + BuilderOperationLocal local = (BuilderOperationLocal) value[i]; + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + result[i] = local.id; + } + return result; + } + private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { BuilderOperationData cur = child; while (cur.depth > parent.depth) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 55804b8859b7..c7c3a61d8a2b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -875,6 +875,42 @@ public boolean isRealOperation() { } } + public static class LocalSetterArray extends Operation { + + protected LocalSetterArray(OperationsContext context, int id) { + super(context, "LocalSetterArray", id, 0); + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(new CodeTypeMirror.ArrayCodeTypeMirror(getTypes().OperationLocal)); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().variable(vars.operationData).string(".localReferences = arg0").end(); + + return b.build(); + } + + @Override + public boolean needsOperationData() { + return false; + } + + @Override + public boolean isRealOperation() { + return false; + } + } + private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement()// .variable(vars.operationData).string(".aux[" + index + "] = ") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 8495a23a0560..9b2c948d59b9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -27,6 +27,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; @@ -540,6 +541,10 @@ public int hashCode() { @Override public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { + if (execution.getName().startsWith("$localRefArray")) { + return createArrayReference(frameState, new LocalRefHandle(execution.getName()), true, new ArrayCodeTypeMirror(types.LocalSetter), false); + } + if (execution.getName().startsWith("$localRef")) { return createArrayReference(frameState, new LocalRefHandle(execution.getName()), true, types.LocalSetter, false); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 335bce0e2b8d..86a667560724 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -94,6 +94,7 @@ private void createBuiltinOperations() { createReturn(); add(new Operation.LocalSetter(this, operationId++)); + add(new Operation.LocalSetterArray(this, operationId++)); add(new Operation.InstrumentTag(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index e8178cf6fb3f..2dc88a14e728 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -30,7 +30,8 @@ public static enum ParameterKind { STACK_VALUE, VARIADIC, VIRTUAL_FRAME, - LOCAL_SETTER; + LOCAL_SETTER, + LOCAL_SETTER_ARRAY; public TypeMirror getParameterType(ProcessorContext context) { switch (this) { @@ -42,6 +43,8 @@ public TypeMirror getParameterType(ProcessorContext context) { return context.getTypes().VirtualFrame; case LOCAL_SETTER: return context.getTypes().LocalSetter; + case LOCAL_SETTER_ARRAY: + return new ArrayCodeTypeMirror(context.getTypes().LocalSetter); default: throw new IllegalArgumentException("" + this); } @@ -54,6 +57,7 @@ public boolean isStackValue() { return true; case VIRTUAL_FRAME: case LOCAL_SETTER: + case LOCAL_SETTER_ARRAY: return false; default: throw new IllegalArgumentException(this.toString()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 8ce217438419..10e31c65b3bb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -25,6 +25,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; @@ -245,6 +246,10 @@ private void addBoxingEliminationNodeChildAnnotations(MethodProperties props, Co ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterNodeChild()))); anns.add(new CodeAnnotationValue(ann)); localI++; + } else if (param == ParameterKind.LOCAL_SETTER_ARRAY) { + ann.setElementValue("value", new CodeAnnotationValue("$localRefArray")); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterArrayNodeChild()))); + anns.add(new CodeAnnotationValue(ann)); } } repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); @@ -296,7 +301,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme if (isVariadic) { data.addError(method, "Multiple @Variadic arguments not allowed"); } - if (numLocalSetters > 0) { + if (numLocalSetters != 0) { data.addError(param, "Value arguments after LocalSetter not allowed"); } isVariadic = true; @@ -304,6 +309,12 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetter)) { parameters.add(ParameterKind.LOCAL_SETTER); numLocalSetters++; + } else if (ElementUtils.typeEquals(param.asType(), new ArrayCodeTypeMirror(types.LocalSetter))) { + parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); + if (numLocalSetters != 0) { + data.addError(param, "Mixing regular and array local setters not allowed"); + } + numLocalSetters = -1; } else if (!isIgnoredParameter(param)) { if (isVariadic) { data.addError(method, "Value arguments after @Variadic not allowed"); @@ -367,6 +378,15 @@ private CodeTypeElement createLocalSetterNodeChild() { return result; } + private CodeTypeElement createLocalSetterArrayNodeChild() { + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + result.setSuperClass(types.Node); + + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, new ArrayCodeTypeMirror(types.LocalSetter))); + + return result; + } + private CodeExecutableElement createChildExecuteMethod(String name, TypeMirror retType) { CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); // result.addParameter(new CodeVariableElement(types.Frame, "frame")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index d3f2583f308c..45205b917242 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -139,11 +139,18 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C for (int localIndex : localRefIndices) { b.startStatement().startCall(vars.consts, "setValue"); b.string("constantOffset + " + localIndex); - b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "create"); - b.startCall("getLocalIndex"); - b.startGroup().variable(vars.operationData).string(".localReferences[" + (iLocal++) + "]").end(); - b.end(); - b.end(); + + if (data.getMainProperties().numLocalReferences == -1) { + b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "createArray"); + b.startCall("getLocalIndices"); + b.startGroup().variable(vars.operationData).string(".localReferences").end(); + b.end(2); + } else { + b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "create"); + b.startCall("getLocalIndex"); + b.startGroup().variable(vars.operationData).string(".localReferences[" + (iLocal++) + "]").end(); + b.end(2); + } b.end(2); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index c7eb30585019..ab6883878cb0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -21,8 +21,15 @@ import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NameAccessContext; import com.oracle.truffle.sl.runtime.SLStrings; +/** + * Base AST visitor class, that handles common SL behaviour such as error reporting, scoping and + * literal parsing. + */ public abstract class SLBaseVisitor extends SimpleLanguageOperationsBaseVisitor { + /** + * Base implementation of parsing, which handles lexer and parser setup, and error reporting. + */ protected static void parseSLImpl(Source source, SLBaseVisitor visitor) { SimpleLanguageOperationsLexer lexer = new SimpleLanguageOperationsLexer(CharStreams.fromString(source.getCharacters().toString())); SimpleLanguageOperationsParser parser = new SimpleLanguageOperationsParser(new CommonTokenStream(lexer)); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 77a72bd55df9..8192a24614f8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -48,6 +48,9 @@ import com.oracle.truffle.sl.runtime.SLBigNumber; import com.oracle.truffle.sl.runtime.SLNull; +/** + * SL AST visitor that uses the Operation DSL for generating code. + */ public class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = false; @@ -524,17 +527,6 @@ private void buildMemberExpressionRead(Token ident, List - * x = a; - * - * { - * x = a; - * x - * } - * - */ - private final Stack writeLocalsStack = new Stack<>(); private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { From e727b96411d8dc381f5826f9e22cb60d4f21e37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 21 Jun 2022 09:45:04 +0200 Subject: [PATCH 093/312] [wip] changes --- .../operation/BuilderFinallyTryContext.java | 48 ++++- .../api/operation/OperationBuilder.java | 80 +++++-- .../truffle/api/impl/FrameWithoutBoxing.java | 3 +- .../dsl/processor/generator/BitSet.java | 2 +- .../generator/NodeGeneratorPlugs.java | 40 ++++ .../java/compiler/JavaCCompiler.java | 20 +- .../dsl/processor/operations/Operation.java | 203 +++++++++++------- .../operations/OperationDecisions.java | 51 ++++- .../operations/OperationGeneratorUtils.java | 54 +++-- .../operations/OperationMetadataData.java | 40 ++++ .../operations/OperationMetadataParser.java | 40 ++++ .../OperationsBytecodeCodeGenerator.java | 81 ++++--- .../OperationsBytecodeNodeGeneratorPlugs.java | 27 +-- .../operations/OperationsCodeGenerator.java | 140 ++++++------ .../operations/OperationsConfiguration.java | 10 - .../operations/OperationsContext.java | 46 +++- .../processor/operations/OperationsData.java | 41 +++- .../operations/OperationsParser.java | 40 ++++ .../operations/SingleOperationData.java | 42 +++- .../operations/SingleOperationParser.java | 48 ++++- .../instructions/BranchInstruction.java | 105 ++++++--- .../ConditionalBranchInstruction.java | 50 ++++- .../instructions/CustomInstruction.java | 11 +- .../instructions/DiscardInstruction.java | 42 +++- .../operations/instructions/FrameKind.java | 47 +++- .../operations/instructions/Instruction.java | 154 ++++++------- .../InstrumentationEnterInstruction.java | 40 ++++ .../InstrumentationExitInstruction.java | 44 +++- .../InstrumentationLeaveInstruction.java | 40 ++++ .../instructions/LoadArgumentInstruction.java | 72 +++++-- .../instructions/LoadConstantInstruction.java | 45 +++- .../instructions/LoadLocalInstruction.java | 143 +++++++----- .../instructions/QuickenedInstruction.java | 2 +- .../instructions/ReturnInstruction.java | 40 ++++ .../instructions/ShortCircuitInstruction.java | 58 ++++- .../instructions/StoreLocalInstruction.java | 6 +- .../instructions/SuperInstruction.java | 50 ++++- .../instructions/ThrowInstruction.java | 48 ++++- .../truffle/sl/operations/SLOperations.java | 40 ++++ .../sl/parser/SLOperationsVisitor.java | 2 +- 40 files changed, 1612 insertions(+), 483 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java index e2bbfd930acf..a74d8107446a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java @@ -1,17 +1,57 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.ArrayList; class BuilderFinallyTryContext { final BuilderFinallyTryContext prev; - final byte[] bc; + final short[] bc; final ArrayList exceptionHandlers; final ArrayList labelFills; final ArrayList labels; final int curStack; final int maxStack; - BuilderFinallyTryContext(BuilderFinallyTryContext prev, byte[] bc, ArrayList exceptionHandlers, ArrayList labelFills, + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { this.prev = prev; this.bc = bc; @@ -22,7 +62,7 @@ class BuilderFinallyTryContext { this.maxStack = maxStack; } - byte[] handlerBc; + short[] handlerBc; ArrayList handlerHandlers; public ArrayList handlerLabelFills = new ArrayList<>(); public ArrayList relocationOffsets = new ArrayList<>(); @@ -31,4 +71,4 @@ class BuilderFinallyTryContext { boolean finalized() { return handlerBc != null; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index b0a422eb58cf..bd30f082f108 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.ArrayList; @@ -31,12 +71,10 @@ public abstract class OperationBuilder { protected final boolean withSource; protected final boolean withInstrumentation; - protected final byte[] bc = new byte[65536]; + protected final short[] bc = new short[65536]; protected int bci = 0; protected final OperationsConstantPool constPool = new OperationsConstantPool(); - protected static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - protected BuilderOperationData operationData; protected BuilderFinallyTryContext finallyTryContext; @@ -123,7 +161,7 @@ private BytecodeNode publishBytecode() { labelPass(); - byte[] bcCopy = Arrays.copyOf(bc, bci); + short[] bcCopy = Arrays.copyOf(bc, bci); Object[] consts = constPool.getValues(); Node[] childrenCopy = new Node[numChildNodes]; BuilderExceptionHandler[] handlers = exceptionHandlers.toArray(new BuilderExceptionHandler[0]); @@ -142,9 +180,9 @@ private BytecodeNode publishBytecode() { protected abstract OperationNode createNode(OperationNodes arg0, Object arg1, BytecodeNode arg2); - protected abstract BytecodeNode createBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); + protected abstract BytecodeNode createBytecode(int arg0, int arg1, short[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); - protected abstract InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, byte[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, + protected abstract InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, short[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); protected abstract int getBlockOperationIndex(); @@ -295,7 +333,7 @@ protected final void labelPass() { labelPass(null); } - private final void labelPass(BuilderFinallyTryContext finallyTry) { + private void labelPass(BuilderFinallyTryContext finallyTry) { for (BuilderLabelFill fill : labelFills) { if (finallyTry != null) { if (fill.label.belongsTo(finallyTry)) { @@ -305,7 +343,8 @@ private final void labelPass(BuilderFinallyTryContext finallyTry) { finallyTry.handlerLabelFills.add(fill); } } - LE_BYTES.putShort(bc, fill.locationBci, (short) fill.label.targetBci); + + bc[fill.locationBci] = (short) fill.label.targetBci; } } @@ -429,8 +468,9 @@ protected final void doLeaveFinallyTry(BuilderOperationData opData) { System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); for (int offset : context.relocationOffsets) { - short oldOffset = LE_BYTES.getShort(bc, bci + offset); - LE_BYTES.putShort(bc, bci + offset, (short) (oldOffset + bci)); + short oldOffset = bc[bci + offset]; + + bc[bci + offset] = (short) (oldOffset + bci); } for (BuilderExceptionHandler handler : context.handlerHandlers) { @@ -487,12 +527,10 @@ protected abstract static class BytecodeNode extends Node implements BytecodeOSR assert FRAME_TYPE_ILLEGAL == FrameSlotKind.Illegal.tag; } - private static final ByteArraySupport LE_BYTES = ByteArraySupport.littleEndian(); - protected final int maxStack; protected final int maxLocals; - @CompilationFinal(dimensions = 1) protected final byte[] bc; + @CompilationFinal(dimensions = 1) protected final short[] bc; @CompilationFinal(dimensions = 1) protected final Object[] consts; @Children protected final Node[] children; @CompilationFinal(dimensions = 1) protected final BuilderExceptionHandler[] handlers; @@ -500,7 +538,7 @@ protected abstract static class BytecodeNode extends Node implements BytecodeOSR protected static final int VALUES_OFFSET = 0; - protected BytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { + protected BytecodeNode(int maxStack, int maxLocals, short[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { this.maxStack = maxStack; this.maxLocals = maxLocals; this.bc = bc; @@ -545,13 +583,13 @@ public void setOSRMetadata(Object osrMetadata) { // boxing elim - protected static void setResultBoxedImpl(byte[] bc, int bci, int targetType, short[] descriptor) { - int op = LE_BYTES.getShort(bc, bci) & 0xffff; + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, short[] descriptor) { + int op = bc[bci] & 0xffff; short todo = descriptor[op]; if (todo > 0) { // quicken - LE_BYTES.putShort(bc, bci, todo); + bc[bci] = todo; } else { // set bit int offset = (todo >> 8) & 0x7f; @@ -569,10 +607,8 @@ protected static Object expectObject(VirtualFrame frame, int slot) { return frame.getObject(slot); } else { // this should only happen in edge cases, when we have specialized to a generic case - // on - // one thread, but other threads have already executed the child with primitive - // return - // type + // on one thread, but other threads have already executed the child with primitive + // return type return frame.getValue(slot); } } @@ -677,7 +713,7 @@ protected static double expectDouble(VirtualFrame frame, int slot) throws Unexpe protected abstract static class InstrumentedBytecodeNode extends BytecodeNode { - protected InstrumentedBytecodeNode(int maxStack, int maxLocals, byte[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, + protected InstrumentedBytecodeNode(int maxStack, int maxLocals, short[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 22afbd7c7267..c687ee0d2882 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -617,7 +617,8 @@ private long[] getIndexedPrimitiveLocals() { } private byte[] getIndexedTags() { - return unsafeCast(indexedTags, byte[].class, true, true, true); + return indexedTags; + // return unsafeCast(indexedTags, byte[].class, true, true, true); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 5ea21450f148..d8c0e19c292e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -405,7 +405,7 @@ public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); builder.tree(createReference(frameState)).string(" = "); - if (type.getKind() == TypeKind.BYTE) { + if (type.getKind() != TypeKind.INT) { builder.cast(type); } builder.startParantheses(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index f450237020c4..8dd7db9b633a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.generator; import java.util.List; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java index 7bed98dc4276..abd1a17142bb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/compiler/JavaCCompiler.java @@ -101,16 +101,16 @@ private static Object getTrees(ProcessingEnvironment environment, Element elemen return staticMethod(clsTrees, "instance", new Class[]{ProcessingEnvironment.class}, environment); } - private static Method metTrees_getPath = null; + private static Method metTreesGetPath = null; private static Object getTreePathForElement(ProcessingEnvironment environment, Element element) throws ReflectiveOperationException { Object trees = getTrees(environment, element); // we must lookup the name manually since we need the abstract one on Trees, not the one on // the implementation (which is innaccessible to us due to modules) - if (metTrees_getPath == null) { - metTrees_getPath = clsTrees.getMethod("getPath", new Class[]{Element.class}); + if (metTreesGetPath == null) { + metTreesGetPath = clsTrees.getMethod("getPath", new Class[]{Element.class}); } - return metTrees_getPath.invoke(trees, element); + return metTreesGetPath.invoke(trees, element); } private static Object getLog(Object javacContext) throws ReflectiveOperationException { @@ -140,9 +140,9 @@ private static void reportProblem(Object check, Object treePath, Element element } private static Class clsTreePath = null; - private static Method metTreePath_getCompilationUnit = null; + private static Method metTreePathGetCompilationUnit = null; private static Class clsCompilationUnitTree = null; - private static Method metCompilationUnitTree_getSourceFile = null; + private static Method metCompilationUnitTreeGetSourceFile = null; @Override public File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element element) { @@ -152,17 +152,17 @@ public File getEnclosingSourceFile(ProcessingEnvironment processingEnv, Element Object treePath = getTreePathForElement(processingEnv, element); if (clsTreePath == null) { clsTreePath = Class.forName("com.sun.source.util.TreePath", false, cl); - metTreePath_getCompilationUnit = clsTreePath.getMethod("getCompilationUnit", new Class[0]); + metTreePathGetCompilationUnit = clsTreePath.getMethod("getCompilationUnit", new Class[0]); } - Object compilationUnit = metTreePath_getCompilationUnit.invoke(treePath); + Object compilationUnit = metTreePathGetCompilationUnit.invoke(treePath); if (clsCompilationUnitTree == null) { clsCompilationUnitTree = Class.forName("com.sun.source.tree.CompilationUnitTree", false, cl); - metCompilationUnitTree_getSourceFile = clsCompilationUnitTree.getDeclaredMethod("getSourceFile", new Class[0]); + metCompilationUnitTreeGetSourceFile = clsCompilationUnitTree.getDeclaredMethod("getSourceFile", new Class[0]); } - JavaFileObject obj = (JavaFileObject) metCompilationUnitTree_getSourceFile.invoke(compilationUnit); + JavaFileObject obj = (JavaFileObject) metCompilationUnitTreeGetSourceFile.invoke(compilationUnit); return new File(obj.toUri()); } catch (ReflectiveOperationException e) { throw new AssertionError("should not happen", e); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index c7c3a61d8a2b..ae6eb5096656 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; @@ -216,9 +256,9 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" != 0").end(); b.startBlock(); - { - b.tree(createPopLastChildCode(vars)); - } + // { + b.tree(createPopLastChildCode(vars)); + // } b.end(); return b.build(); @@ -251,22 +291,22 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); - { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + // { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); - } + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); + // } b.end().startElseBlock(); - { - b.tree(createPopLastChildCode(vars)); + // { + b.tree(createPopLastChildCode(vars)); - b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); - } + b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + // } b.end(); return b.build(); @@ -319,46 +359,46 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); - { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + // { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); - b.declaration(getTypes().BuilderOperationLabel, varElseLabel.getName(), createCreateLabel()); + CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); + b.declaration(getTypes().BuilderOperationLabel, varElseLabel.getName(), createCreateLabel()); - b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); + b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varElseLabel)); - } + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varElseLabel)); + // } b.end(); b.startElseIf().variable(vars.childIndex).string(" == 1").end(); b.startBlock(); // { - { - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + // { + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - if (hasValue) { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - } else { - b.tree(createPopLastChildCode(vars)); - } + if (hasValue) { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + } else { + b.tree(createPopLastChildCode(vars)); + } - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); - b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); - } + b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + // } b.end().startElseBlock(); - { + // { - if (hasValue) { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - } else { - b.tree(createPopLastChildCode(vars)); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, 1, getTypes().BuilderOperationLabel))); + if (hasValue) { + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + } else { + b.tree(createPopLastChildCode(vars)); } + + b.tree(createEmitLabel(vars, createGetAux(vars, 1, getTypes().BuilderOperationLabel))); + // } b.end(); return b.build(); @@ -403,24 +443,24 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); - { - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + // { + CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); + b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); - b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); - } + b.tree(createEmitInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); + // } b.end().startElseBlock(); - { - b.tree(createPopLastChildCode(vars)); + // { + b.tree(createPopLastChildCode(vars)); - b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); - b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); - } + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + // } b.end(); @@ -643,9 +683,9 @@ public boolean hasLeaveCode() { public static class FinallyTry extends Operation { - private final int AUX_CONTEXT = 0; - private final int AUX_BEH = 1; - private final int AUX_LOCAL = 2; + private static final int AUX_CONTEXT = 0; + private static final int AUX_BEH = 1; + private static final int AUX_LOCAL = 2; private final boolean noExcept; @@ -661,7 +701,7 @@ public List getBuilderArgumentTypes() { @Override public CodeTree createPushCountCode(BuilderVariables vars) { - // TODO - this could be made to return Try value on exit + // todo: this could be made to return Try value on exit return CodeTreeBuilder.singleString("0"); } @@ -687,25 +727,25 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createPopLastChildCode(vars)); b.startIf().variable(vars.childIndex).string(" == 0").end().startBlock(); - { - b.startStatement().startCall("doEndFinallyBlock").end(2); - - if (!noExcept) { - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); - - b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = "); - b.startCall("getLocalIndex"); - b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); - b.end(); - b.end(); - b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); - b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); - } + // { + b.startStatement().startCall("doEndFinallyBlock").end(2); + if (!noExcept) { + CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); + b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + + b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); + b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = "); + b.startCall("getLocalIndex"); + b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); + b.end(); + b.end(); + b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); + b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); } + + // } b.end(); return b.build(); } @@ -820,9 +860,9 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startIf().variable(vars.childIndex).string(" > 0").end().startBlock(); - { - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); - } + // { + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + // } b.end(); return b.build(); @@ -911,14 +951,11 @@ public boolean isRealOperation() { } } - private static final CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement()// - .variable(vars.operationData).string(".aux[" + index + "] = ") // - .tree(value) // - .end().build(); + private static CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { + return CodeTreeBuilder.createBuilder().startStatement().variable(vars.operationData).string(".aux[" + index + "] = ").tree(value).end().build(); } - private static final CodeTree createGetAux(BuilderVariables vars, int index, TypeMirror cast) { + private static CodeTree createGetAux(BuilderVariables vars, int index, TypeMirror cast) { return CodeTreeBuilder.createBuilder().string("(").cast(cast).variable(vars.operationData).string(".aux[" + index + "]").string(")").build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 2df47fdfc75e..56e6e7f7b79e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -31,7 +71,7 @@ public OperationDecisions merge(OperationDecisions other, MessageContainer messa return this; } - public static class Quicken { + public static final class Quicken { final String operation; final String[] specializations; @@ -54,12 +94,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Quicken other = (Quicken) obj; return Objects.equals(operation, other.operation) && Arrays.equals(specializations, other.specializations); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index fb70b3ab4a9c..e6ffad8f15f2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.io.IOException; @@ -8,14 +48,12 @@ import java.util.function.Function; import javax.lang.model.element.Element; -import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; @@ -60,9 +98,7 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen } public static CodeTree createReadOpcode(CodeTree bc, CodeTree bci) { - return CodeTreeBuilder.createBuilder()// - .startCall("LE_BYTES", "getShort")// - .tree(bc).tree(bci).end(1).build(); + return CodeTreeBuilder.createBuilder().tree(bc).string("[").tree(bci).string("]").build(); } public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElement bci) { @@ -72,12 +108,7 @@ public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElem } public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement()// - .startCall("LE_BYTES", "putShort")// - .tree(bc) // - .tree(bci) // - .startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).tree(value).end() // - .end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().tree(bc).string("[").tree(bci).string("] = (short) (").tree(value).string(")").end().build(); } public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { @@ -103,7 +134,6 @@ public static String printCode(Element el) { @Override protected Writer createWriter(CodeTypeElement clazz) throws IOException { - // TODO Auto-generated method stub return wr; } }.visit(el); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java index 161f0e97f772..01b16a659220 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import javax.lang.model.element.AnnotationMirror; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java index adec9158f4f0..fb92ce394f36 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.List; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 3738275e68ad..dc3353a6f7ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -37,11 +77,11 @@ public class OperationsBytecodeCodeGenerator { - private final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); + private static final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - final static Object MARKER_CHILD = new Object(); - final static Object MARKER_CONST = new Object(); + static final Object MARKER_CHILD = new Object(); + static final Object MARKER_CONST = new Object(); static final boolean DO_STACK_LOGGING = false; @@ -49,7 +89,7 @@ public class OperationsBytecodeCodeGenerator { final TruffleTypes types = context.getTypes(); private static final String ConditionProfile_Name = "com.oracle.truffle.api.profiles.ConditionProfile"; - final DeclaredType ConditionProfile = context.getDeclaredType(ConditionProfile_Name); + final DeclaredType typeConditionProfile = context.getDeclaredType(ConditionProfile_Name); private final CodeTypeElement typBuilderImpl; private final OperationsData m; @@ -70,7 +110,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", types.OperationBytecodeNode); - CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(byte.class)), "bc"); + CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(short.class)), "bc"); CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); @@ -215,7 +255,7 @@ public CodeTypeElement createBuilderBytecodeNode() { metGetSpecBits.setEnclosingElement(typBuilderImpl); typBuilderImpl.add(metGetSpecBits); - metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc")); + metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "bc")); metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); CodeTreeBuilder b = metGetSpecBits.createBuilder(); b.tree(plugs.createGetSpecializationBits()); @@ -316,6 +356,12 @@ public CodeTypeElement createBuilderBytecodeNode() { continue; } + b.startDoc(); + for (String line : op.dumpInfo().split("\n")) { + b.string(line).newLine(); + } + b.end(); + b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); @@ -470,9 +516,9 @@ public CodeTypeElement createBuilderBytecodeNode() { for (int i = 0; i < 16; i++) { if (i < op.length()) { - builder.statement("sb.append(String.format(\"%02x \", bc[bci + " + i + "]))"); + builder.statement("sb.append(String.format(\"%04x \", bc[bci + " + i + "]))"); } else { - builder.statement("sb.append(\" \")"); + builder.statement("sb.append(\" \")"); } } @@ -532,23 +578,6 @@ public CodeTypeElement createBuilderBytecodeNode() { } - { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startJavadoc(); - - for (Instruction instr : m.getInstructions()) { - for (String s : instr.dumpInfo().split("\n")) { - b.string(s); - b.newLine(); - } - b.string(" "); - b.newLine(); - } - - b.end(); - builderBytecodeNodeType.setDocTree(b.build()); - } - return builderBytecodeNodeType; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 9b2c948d59b9..0c3986c4d927 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -169,12 +169,12 @@ public boolean shouldIncludeValuesInCall() { @Override public int getMaxStateBits(int defaultValue) { - return 8; + return 16; } @Override public TypeMirror getBitSetType(TypeMirror defaultType) { - return new CodeTypeMirror(TypeKind.BYTE); + return new CodeTypeMirror(TypeKind.SHORT); } private int bitSetOffset(BitSet bits) { @@ -198,7 +198,7 @@ public CodeTree createBitSetReference(BitSet bits) { @Override public CodeTree transformValueBeforePersist(CodeTree tree) { - return CodeTreeBuilder.createBuilder().cast(new CodeTypeMirror(TypeKind.BYTE)).startParantheses().tree(tree).end().build(); + return CodeTreeBuilder.createBuilder().cast(getBitSetType(null)).startParantheses().tree(tree).end().build(); } private static final String CHILD_OFFSET_NAME = "childArrayOffset_"; @@ -219,10 +219,8 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea if (baseIndex == -1) { baseIndex = additionalData.size(); additionalData.add(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); - additionalData.add(null); additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); - additionalDataKinds.add(DataKind.CONTINUATION); } index = refList.size(); @@ -245,20 +243,16 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea b.variable(targetField).string("["); - if (frame == null) { - b.startCall("LE_BYTES", "getShort"); + if (frame == null || !frame.getBoolean("definedOffsets", false)) { b.variable(fldBc); - b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); - b.end(); + b.string("[$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex + "]"); } else if (frame.getBoolean("has_" + offsetName, false)) { b.string(offsetName); } else { frame.setBoolean("has_" + offsetName, true); b.string("(" + offsetName + " = "); - b.startCall("LE_BYTES", "getShort"); b.variable(fldBc); - b.string("$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex); - b.end(); + b.string("[$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex + "]"); b.string(")"); } @@ -346,6 +340,7 @@ public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) frameState.set("frameValue", new LocalVariable(types.VirtualFrame, "$frame", null)); builder.declaration("int", CHILD_OFFSET_NAME, (CodeTree) null); builder.declaration("int", CONST_OFFSET_NAME, (CodeTree) null); + frameState.setBoolean("definedOffsets", true); } private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { @@ -440,6 +435,9 @@ private boolean regularReturn() { return isVariadic || data.isShortCircuit(); } + private static final boolean DO_LOG_ENS_CALLS = false; + private int ensCall = 0; + @Override public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { String easName = transformNodeMethodName("executeAndSpecialize"); @@ -447,9 +445,14 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; // unquicken call parent EAS + builder.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.getOrig().opcodeIdField)); easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; } + if (DO_LOG_ENS_CALLS) { + builder.statement("System.out.printf(\" [!!] calling E&S @ %04x : " + cinstr.name + " " + (ensCall++) + "%n\", $bci)"); + } + if (regularReturn()) { builder.startReturn(); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 974ba4e9d6a3..61419289879e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -8,7 +48,6 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.AnnotationProcessor; @@ -54,16 +93,14 @@ CodeTypeElement createOperationNodes() { CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, types.OperationNodes); typOperationNodes.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationNodes)); - { - CodeExecutableElement metReparse = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); - typOperationNodes.add(metReparse); + CodeExecutableElement metReparse = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); + typOperationNodes.add(metReparse); - CodeTreeBuilder b = metReparse.createBuilder(); + CodeTreeBuilder b = metReparse.createBuilder(); - b.statement("BuilderImpl builder = new BuilderImpl(this, true, config)"); - b.statement("((Consumer) parse).accept(builder)"); - b.statement("builder.finish()"); - } + b.statement("BuilderImpl builder = new BuilderImpl(this, true, config)"); + b.statement("((Consumer) parse).accept(builder)"); + b.statement("builder.finish()"); return typOperationNodes; } @@ -78,10 +115,8 @@ CodeTypeElement createBuilder(String simpleName) { CodeTypeElement typBuilder = GeneratorUtils.createClass(m, null, MOD_PUBLIC_ABSTRACT, simpleName, types.OperationBuilder); GeneratorUtils.addSuppressWarnings(context, typBuilder, "cast", "hiding", "unchecked", "rawtypes", "static-method"); - { - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(MOD_PROTECTED, typBuilder); - typBuilder.add(ctor); - } + CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(MOD_PROTECTED, typBuilder); + typBuilder.add(ctor); typBuilder.add(createOperationNodes()); @@ -132,11 +167,11 @@ private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, Cod b.declaration(types.OperationNodes, "nodes", "new OperationNodesImpl(generator)"); b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); - { - b.string("nodes"); - b.string("false"); // isReparse - b.variable(parConfig); - } + // ( + b.string("nodes"); + b.string("false"); // isReparse + b.variable(parConfig); + // ) b.end(2); b.startStatement().startCall("generator", "accept"); @@ -169,10 +204,10 @@ CodeTypeElement createOperationNodeImpl() { initBuilder.startStatement().startCall("setMetadataAccessor"); initBuilder.staticReference((VariableElement) metadata.getMessageElement()); initBuilder.startGroup(); - { - initBuilder.string("n -> "); - initBuilder.startParantheses().cast(typOperationNodeImpl.asType()).string("n").end().string("." + fieldName); - } + // ( + initBuilder.string("n -> "); + initBuilder.startParantheses().cast(typOperationNodeImpl.asType()).string("n").end().string("." + fieldName); + // ) initBuilder.end(); initBuilder.end(2); } @@ -233,17 +268,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), typBuilderImpl); typBuilderImpl.add(ctor); - { - // String bytesSupportClass = "com.oracle.truffle.api.operation.OperationsBytesSupport"; - String bytesSupportClass = "com.oracle.truffle.api.memory.ByteArraySupport"; - DeclaredType byteArraySupportType = context.getDeclaredType(bytesSupportClass); - CodeVariableElement leBytes = new CodeVariableElement( - MOD_PRIVATE_STATIC_FINAL, - byteArraySupportType, "LE_BYTES"); - leBytes.createInitBuilder().startStaticCall(byteArraySupportType, "littleEndian").end(); - typBuilderImpl.add(leBytes); - } - // operation IDs for (Operation op : m.getOperationsContext().operations) { CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); @@ -267,11 +291,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; - { - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, false); - builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); - typBuilderImpl.add(builderBytecodeNodeType); - } + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, false); + builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); + typBuilderImpl.add(builderBytecodeNodeType); if (ENABLE_INSTRUMENTATION) { OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, true); @@ -487,10 +509,7 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote("Mismatched begin/end, expected ")// - .string(" + operationData.operationId").end(3); + b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote("Mismatched begin/end, expected ").string(" + operationData.operationId").end(3); b.end(); vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); @@ -499,20 +518,13 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui if (!op.isVariableChildren()) { b.startIf().string("numChildren != " + op.children).end(); b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote(op.name + " expected " + op.children + " children, got ")// - .string(" + numChildren")// - .end(3); + b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote(op.name + " expected " + op.children + " children, got ").string(" + numChildren").end(3); b.end(); } else { b.startIf().string("numChildren < " + op.minimumChildren()).end(); b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class))// - .startGroup()// - .doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ")// - .string(" + numChildren")// - .end(3); + b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ").string( + " + numChildren").end(3); b.end(); } @@ -587,7 +599,7 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B private CodeExecutableElement createSetResultUnboxed() { CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); - CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(short.class)), "bc"); mDoSetResultUnboxed.addParameter(varBc); CodeVariableElement varStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); @@ -602,14 +614,14 @@ private CodeExecutableElement createSetResultUnboxed() { CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); b.startIf().variable(varBciOffset).string(" != 0").end().startBlock(); - { - b.startStatement().startCall("setResultBoxedImpl"); - b.variable(varBc); - b.string("startBci - bciOffset"); - b.variable(varTargetType); - b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); - b.end(2); - } + // { + b.startStatement().startCall("setResultBoxedImpl"); + b.variable(varBc); + b.string("startBci - bciOffset"); + b.variable(varTargetType); + b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); + b.end(2); + // } b.end(); return mDoSetResultUnboxed; } @@ -673,8 +685,9 @@ private CodeExecutableElement createAfterChild(BuilderVariables vars) { for (Operation parentOp : m.getOperations()) { CodeTree afterChild = parentOp.createAfterChildCode(vars); - if (afterChild == null) + if (afterChild == null) { continue; + } b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); @@ -707,8 +720,9 @@ private CodeExecutableElement createBeforeChild(BuilderVariables vars) { for (Operation parentOp : m.getOperations()) { CodeTree afterChild = parentOp.createBeforeChildCode(vars); - if (afterChild == null) + if (afterChild == null) { continue; + } b.startCase().variable(parentOp.idConstantField).end(); b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java deleted file mode 100644 index 480c47a418f7..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations; - -public class OperationsConfiguration { - - private OperationsConfiguration() { - } - - public static final boolean DO_EAGER_UNBOX = false; - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 86a667560724..8f5a513038cd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -7,10 +47,6 @@ import java.util.Map; import java.util.Set; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -198,7 +234,7 @@ public void processDecisions(OperationDecisions decisions) { for (OperationDecisions.Quicken quicken : decisions.getQuicken()) { CustomInstruction cinstr = customInstructionNameMap.get(quicken.getOperation()); if (cinstr == null) { - // TODO line number or sth + // todo: better error reporting data.addWarning("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); continue; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 5e69aabc5bdf..cb2c20d10d47 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -19,7 +59,6 @@ public class OperationsData extends Template { - private final Set names = new HashSet<>(); private final List operations = new ArrayList<>(); private final List metadatas = new ArrayList<>(); private final OperationsContext context = new OperationsContext(this); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 3fada60888b4..2e3e88d0c0f7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 2dc88a14e728..0048fc28532b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.HashSet; @@ -26,7 +66,7 @@ public class SingleOperationData extends Template { private final boolean isShortCircuit; private boolean shortCircuitContinueWhen; - public static enum ParameterKind { + public enum ParameterKind { STACK_VALUE, VARIADIC, VIRTUAL_FRAME, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 10e31c65b3bb..3d054cd32ad5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -40,7 +80,7 @@ public class SingleOperationParser extends AbstractParser { private final OperationsData parentData; private final AnnotationMirror proxyMirror; - private final String NODE = "Node"; + private static final String NODE = "Node"; private final boolean isShortCircuit; public SingleOperationParser(OperationsData parentData) { @@ -417,10 +457,6 @@ private CodeTypeElement cloneTypeHierarchy(TypeElement element, Consumer findSpecializations(Collection elements) { - return elements.stream() // - .filter(x -> x instanceof ExecutableElement) // - .map(x -> (ExecutableElement) x) // - .filter(this::isSpecializationFunction) // - .collect(Collectors.toUnmodifiableList()); + return elements.stream().filter(x -> x instanceof ExecutableElement).map(x -> (ExecutableElement) x).filter(this::isSpecializationFunction).collect(Collectors.toUnmodifiableList()); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index deb0f46c0dda..cfc5fcc519e4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; @@ -25,10 +65,7 @@ public boolean standardPrologue() { } private CodeTree createGetBranchTarget(ExecutionVariables vars) { - return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort")// - .variable(vars.bc) // - .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end() // - .end().build(); + return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]").build(); } @Override @@ -38,35 +75,35 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("int", "targetBci", createGetBranchTarget(vars)); b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); - { - b.startStatement().startStaticCall(TRUFFLE_SAFEPOINT, "poll"); - b.string("this"); - b.end(2); - - // TODO reporting loop count - - b.startIf(); - b.tree(GeneratorUtils.createInInterpreter()); - b.string(" && "); - b.startStaticCall(BYTECODE_OSR_NODE, "pollOSRBackEdge").string("this").end(); - b.end().startBlock(); - { - b.startAssign("Object osrResult").startStaticCall(BYTECODE_OSR_NODE, "tryOSR"); - b.string("this"); - b.string("targetBci"); - b.variable(vars.sp); - b.string("null"); - b.variable(vars.frame); - b.end(2); - - b.startIf().string("osrResult != null").end().startBlock(); - { - b.startReturn().string("osrResult").end(); - } - b.end(); - } - b.end(); - } + // { + b.startStatement().startStaticCall(TRUFFLE_SAFEPOINT, "poll"); + b.string("this"); + b.end(2); + + // todo: reporting loop count + + b.startIf(); + b.tree(GeneratorUtils.createInInterpreter()); + b.string(" && "); + b.startStaticCall(BYTECODE_OSR_NODE, "pollOSRBackEdge").string("this").end(); + b.end().startBlock(); + // { + b.startAssign("Object osrResult").startStaticCall(BYTECODE_OSR_NODE, "tryOSR"); + b.string("this"); + b.string("targetBci"); + b.variable(vars.sp); + b.string("null"); + b.variable(vars.frame); + b.end(2); + + b.startIf().string("osrResult != null").end().startBlock(); + // { + b.startReturn().string("osrResult").end(); + // } + b.end(); + // } + b.end(); + // } b.end(); b.startAssign(vars.bci).string("targetBci").end(); @@ -111,4 +148,4 @@ public CodeTree[] createTracingArguments(ExecutionVariables vars) { createGetBranchTarget(vars) }; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index d0822891301f..3b622e02124d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; @@ -15,7 +55,7 @@ public class ConditionalBranchInstruction extends Instruction { private final ProcessorContext context = ProcessorContext.getInstance(); - private final DeclaredType ConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); + private final DeclaredType typeConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); private OperationsContext ctx; public ConditionalBranchInstruction(OperationsContext ctx, int id) { @@ -28,7 +68,7 @@ public TypeMirror[] expectedInputTypes(ProcessorContext c) { return new TypeMirror[]{ context.getType(short.class), context.getType(boolean.class), - ConditionProfile + typeConditionProfile }; } @@ -44,14 +84,14 @@ public boolean isBranchInstruction() { @SuppressWarnings("unused") private CodeTree createBranchTarget(ExecutionVariables vars) { - return CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")"); + return CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration(ConditionProfile, "profile", "conditionProfiles[LE_BYTES.getShort(bc, bci + " + getArgumentOffset(2) + ")]"); + b.declaration(typeConditionProfile, "profile", "conditionProfiles[bc[bci + " + getArgumentOffset(2) + "]]"); // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) TypeSystemData data = ctx.getData().getTypeSystem(); @@ -90,4 +130,4 @@ public CodeTree[] createTracingArguments(ExecutionVariables vars) { createBranchTarget(vars) }; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 45205b917242..cd3c81ca153e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -110,9 +110,8 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C break; case CHILD: b.startStatement(); - b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); - b.tree(index); + b.string("[").tree(index).string("] = "); b.startCall("createChildNodes").string("" + numChildNodes).end(); b.end(); break; @@ -120,9 +119,8 @@ protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, C b.startAssign("int constantOffset").startCall(vars.consts, "reserve").string("" + numConsts).end(2); b.startStatement(); - b.startCall("LE_BYTES", "putShort"); b.variable(vars.bc); - b.tree(index); + b.string("[").tree(index).string("] = "); b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).string("constantOffset").end(); b.end(); break; @@ -170,7 +168,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (data.getMainProperties().isVariadic) { - b.declaration("int", "numVariadics", "LE_BYTES.getShort(bc, bci + " + getArgumentOffset(inputs.length - 1) + ")"); + b.declaration("int", "numVariadics", "bc[bci + " + getArgumentOffset(inputs.length - 1) + "]"); int additionalInputs = inputs.length - 1; @@ -281,6 +279,9 @@ public String dumpInfo() { sb.append(" ").append(sd.getId()).append("\n"); } + sb.append(" Num children: ").append(numChildNodes).append("\n"); + sb.append(" Num constants: ").append(numConsts).append("\n"); + return sb.toString(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index a178414cd36e..1bf9d7d8458d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -42,4 +82,4 @@ public CodeTree[] createTracingArguments(ExecutionVariables vars) { CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_OTHER") }; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index 4256335e838e..981392b38c0c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -1,6 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; -import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -19,11 +58,11 @@ public enum FrameKind { private final String frameName; private final String typeNameBoxed; - private FrameKind(String typeName, String frameName) { + FrameKind(String typeName, String frameName) { this(typeName, frameName, frameName); } - private FrameKind(String typeName, String frameName, String typeNameBoxed) { + FrameKind(String typeName, String frameName, String typeNameBoxed) { this.typeName = typeName; this.frameName = frameName; this.typeNameBoxed = typeNameBoxed; @@ -71,4 +110,4 @@ public TypeMirror getType() { } } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 8428b4f37275..bd7494eb53bc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; @@ -33,20 +73,20 @@ public static class ExecutionVariables { public CodeVariableElement tracer; } - public static enum InputType { + public enum InputType { STACK_VALUE(1), STACK_VALUE_IGNORED(0), - VARARG_VALUE(2), - CONST_POOL(2), - LOCAL(2), - ARGUMENT(2), - INSTRUMENT(2), - BRANCH_PROFILE(2), - BRANCH_TARGET(2); + VARARG_VALUE(1), + CONST_POOL(1), + LOCAL(1), + ARGUMENT(1), + INSTRUMENT(1), + BRANCH_PROFILE(1), + BRANCH_TARGET(1); final int argumentLength; - private InputType(int argumentLength) { + InputType(int argumentLength) { this.argumentLength = argumentLength; } @@ -132,45 +172,29 @@ public final CodeTree getImplicitValue(BuilderVariables vars, Instruction instr) public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { switch (this) { case STACK_VALUE: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("pop[-%d]") // - .startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + op.getArgumentOffset(n) + "]").end() // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("pop[-%d]").startGroup().variable(vars.bc).string( + "[").variable(vars.bci).string(" + " + op.getArgumentOffset(n) + "]").end().end(3).build(); case STACK_VALUE_IGNORED: return CodeTreeBuilder.createBuilder().statement("sb.append(\"_\")").build(); case CONST_POOL: - return CodeTreeBuilder.createBuilder().startBlock()// - .declaration("Object", "o", CodeTreeBuilder.createBuilder().variable(vars.consts).string("[").tree(op.createReadArgumentCode(n, vars)).string("]").build()) // - .startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("%s %s") // - .string("o.getClass().getSimpleName()") // - .string("o") // - .end(4).build(); + return CodeTreeBuilder.createBuilder().startBlock().declaration("Object", "o", + CodeTreeBuilder.createBuilder().variable(vars.consts).string("[").tree(op.createReadArgumentCode(n, vars)).string("]").build()).startStatement().startCall("sb", + "append").startCall("String", "format").doubleQuote("%s %s").string("o.getClass().getSimpleName()").string("o").end(4).build(); case LOCAL: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("loc[%d]") // - .tree(op.createReadArgumentCode(n, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("loc[%d]").tree(op.createReadArgumentCode(n, vars)).end( + 3).build(); case ARGUMENT: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("arg[%d]") // - .tree(op.createReadArgumentCode(n, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("arg[%d]").tree(op.createReadArgumentCode(n, vars)).end( + 3).build(); case BRANCH_TARGET: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("%04x") // - .tree(op.createReadArgumentCode(n, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("%04x").tree(op.createReadArgumentCode(n, vars)).end( + 3).build(); case INSTRUMENT: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("instrument[%d]") // - .tree(op.createReadArgumentCode(n, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("instrument[%d]").tree( + op.createReadArgumentCode(n, vars)).end(3).build(); case VARARG_VALUE: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("**%d") // - .tree(op.createReadArgumentCode(n, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("**%d").tree(op.createReadArgumentCode(n, vars)).end( + 3).build(); case BRANCH_PROFILE: return null; default: @@ -184,15 +208,15 @@ boolean isStackValue() { } - public static enum ResultType { + public enum ResultType { STACK_VALUE(0), - SET_LOCAL(2), + SET_LOCAL(1), BRANCH(0), RETURN(0); final int argumentLength; - private ResultType(int argumentLength) { + ResultType(int argumentLength) { this.argumentLength = argumentLength; } @@ -231,10 +255,8 @@ public CodeTree createDumpCode(int i, Instruction op, ExecutionVariables vars) { case RETURN: return CodeTreeBuilder.createBuilder().statement("sb.append(\"return\")").build(); case SET_LOCAL: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format") // - .doubleQuote("loc[%d]") // - .tree(op.createReadArgumentCode(i + op.inputs.length, vars)) // - .end(3).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("loc[%d]").tree( + op.createReadArgumentCode(i + op.inputs.length, vars)).end(3).build(); default: throw new IllegalArgumentException("Unexpected value: " + this); } @@ -322,10 +344,7 @@ public final CodeTree createReadArgumentCode(int n, ExecutionVariables vars) { return null; } - return CodeTreeBuilder.createBuilder().startCall("LE_BYTES", "getShort") // - .variable(vars.bc) // - .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end() // - .end().build(); + return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("]").build(); } public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, CodeTree val) { @@ -336,25 +355,20 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code CodeTree value = val; if (n < inputs.length && inputs[n] == InputType.BRANCH_TARGET) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("createOffset") // - .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end()// - .tree(value) // - .end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("createOffset").startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end().tree(value).end(2).build(); } if (n < inputs.length && inputs[n] == InputType.STACK_VALUE) { int svIndex = 0; for (int i = 0; i < n; i++) { - if (inputs[i].isStackValue()) + if (inputs[i].isStackValue()) { svIndex++; + } } - return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc) // - .string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ") // - .string("predecessorBcis[" + svIndex + "] < ").variable(vars.bci).string(" - 255") // - .string(" ? 0") // - .string(" : (byte)(").variable(vars.bci).string(" - predecessorBcis[" + svIndex + "])") // - .end().build(); + return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ").string( + "predecessorBcis[" + svIndex + "] < ").variable(vars.bci).string(" - 255").string(" ? 0").string(" : (byte)(").variable(vars.bci).string( + " - predecessorBcis[" + svIndex + "])").end().build(); } if (n < inputs.length && inputs[n] == InputType.VARARG_VALUE) { @@ -373,15 +387,12 @@ public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, Code value = CodeTreeBuilder.createBuilder().startCall("getLocalIndex").tree(value).end().build(); } - return CodeTreeBuilder.createBuilder().startStatement().startCall("LE_BYTES", "putShort") // - .variable(vars.bc) // - .startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end() // - .startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).cast(new CodeTypeMirror(TypeKind.INT)).tree(value).end() // - .end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ").cast( + new CodeTypeMirror(TypeKind.SHORT)).cast(new CodeTypeMirror(TypeKind.INT)).tree(value).end().build(); } public int opcodeLength() { - return 2; + return 1; } public int getArgumentOffset(int index) { @@ -614,12 +625,7 @@ public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { for (int i = 0; i < inputs.length; i++) { if (inputs[i] == InputType.STACK_VALUE || inputs[i] == InputType.STACK_VALUE_IGNORED) { if (curIndex-- == 0) { - return CodeTreeBuilder.createBuilder().startParantheses() // - .variable(vars.bc) // - .string("[") // - .variable(vars.bci).string(" + " + getArgumentOffset(i)) // - .string("] & 0xff") // - .end().build(); + return CodeTreeBuilder.createBuilder().startParantheses().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(i)).string("] & 0xff").end().build(); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index d064dc8b040c..cc9ff4e40c57 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 64207e00b0d7..9ccea62825e5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -23,9 +63,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.declaration(OperationGeneratorUtils.getTypes().ProbeNode, "probe", - CodeTreeBuilder.createBuilder().variable(vars.probeNodes) // - .string("[").variable(vars.inputs[0]).string("].") // - .startCall("getTreeProbeNode").end(2).build()); + CodeTreeBuilder.createBuilder().variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("].").startCall("getTreeProbeNode").end(2).build()); b.startIf().string("probe != null").end(); b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index feca809209f9..802423dc44c0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 40c071e4b8b2..2e5f0efc3fcf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -26,11 +66,9 @@ private CodeTree createGetValue(ExecutionVariables vars) { b.startCall(vars.frame, "getArguments").end(); b.string("["); - b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); - b.end(); - b.string("]").end(); + b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); + b.string("]"); return b.build(); } @@ -48,19 +86,19 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); } else { b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - { - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.variable(vars.sp); - b.string("(", kind.getTypeName(), ") value"); - b.end(2); - } + // { + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.string("(", kind.getTypeName(), ") value"); + b.end(2); + // } b.end().startElseBlock(); - { - b.startStatement().startCall(vars.frame, "setObject"); - b.variable(vars.sp); - b.string("value"); - b.end(2); - } + // { + b.startStatement().startCall(vars.frame, "setObject"); + b.variable(vars.sp); + b.string("value"); + b.end(2); + // } b.end(); } @@ -96,7 +134,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public CodeTree[] createTracingArguments(ExecutionVariables vars) { return new CodeTree[]{ CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_ARGUMENT"), - CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") }; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 30fb30661bb3..900f4500b328 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -43,9 +83,8 @@ private CodeTree createGetArgument(ExecutionVariables vars) { b.string("(", kind.getTypeName(), ") "); } b.variable(vars.consts).string("["); - b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); + b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); b.end().string("]"); return b.build(); } @@ -81,7 +120,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public CodeTree[] createTracingArguments(ExecutionVariables vars) { return new CodeTree[]{ CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_CONSTANT"), - CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") }; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index ea77b667f77f..e628ca02cc54 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.TypeKind; @@ -33,10 +73,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("int localIdx"); - b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); - b.end(); + b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); b.string(" + VALUES_OFFSET"); b.end(); @@ -47,22 +85,22 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { createCopyAsObject(vars, b); } else if (kind == FrameKind.OBJECT) { b.startIf(); - { - b.startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(); - b.string(" != "); - b.staticReference(StoreLocalInstruction.FrameSlotKind, "Object"); - } + // { + b.startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(); + b.string(" != "); + b.staticReference(StoreLocalInstruction.FrameSlotKind, "Object"); + // } b.end().startBlock(); - { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, frame.getValue(localIdx))"); - } + // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - createReplaceObject(vars, b); + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, frame.getValue(localIdx))"); } + + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + createReplaceObject(vars, b); + // } b.end(); if (LOG_LOCAL_LOADS) { @@ -78,51 +116,52 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf(); b.string("localType != ").staticReference(StoreLocalInstruction.FrameSlotKind, kind.getFrameName()); b.end().startBlock(); - { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.declaration("Object", "localValue", (CodeTree) null); - - b.startIf(); - { - b.string("localType == ").staticReference(StoreLocalInstruction.FrameSlotKind, "Illegal"); - b.string(" && "); - b.string("(localValue = frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); - } - b.end().startBlock(); - { - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, frame.getValue(localIdx))"); - } - - createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); - - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.string("localIdx"); - b.startGroup().cast(kind.getType()).string("localValue").end(); - b.end(2); - } - b.end().startElseBlock(); - { - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(localIdx))"); - } - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - } - b.end(); + // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.declaration("Object", "localValue", (CodeTree) null); + + b.startIf(); + // { + b.string("localType == ").staticReference(StoreLocalInstruction.FrameSlotKind, "Illegal"); + b.string(" && "); + b.string("(localValue = frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); + // } + b.end().startBlock(); + // { + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, frame.getValue(localIdx))"); } - b.end(); + createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); + + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.string("localIdx"); + b.startGroup().cast(kind.getType()).string("localValue").end(); + b.end(2); + // } + b.end().startElseBlock(); + // { if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(localIdx))"); } + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + // } + b.end(); + } + b.end(); - createCopy(vars, b); + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); } + createCopy(vars, b); + // } + b.startStatement().variable(vars.sp).string("++").end(); return b.build(); + } @Override @@ -187,7 +226,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public CodeTree[] createTracingArguments(ExecutionVariables vars) { return new CodeTree[]{ CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_LOCAL"), - CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(0) + ")") + CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") }; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index ac2258e0546b..1e7c12ee9078 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -55,7 +55,7 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData if (activeSpecNames.isEmpty()) { data.addWarning("Invalid quickened instruction %s: no specializations defined.", data.getName()); - activeSpecs = null; + activeSpecs = new ArrayList<>(); return; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 29e120afaa2c..0c67e2003594 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 4632de0fd0d8..277d90ac6ed7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -31,17 +71,17 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.bci); b.variable(vars.sp); b.end(2).startBlock(); - { - b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); - b.statement("continue loop"); - } + // { + b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.statement("continue loop"); + // } b.end().startElseBlock(); - { - b.startAssign(vars.bci).tree(createReadArgumentCode(1, vars)).end(); + // { + b.startAssign(vars.bci).tree(createReadArgumentCode(1, vars)).end(); - b.statement("continue loop"); - } + b.statement("continue loop"); + // } b.end(); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 9e4b8b83b7ac..d13108fa2770 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -87,10 +87,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // TODO: implement version w/o BE, if a language does not need it b.startAssign("int localIdx"); - b.startCall("LE_BYTES", "getShort"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(1)).end(); - b.end(); + b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(1)).string("]"); b.string(" + VALUES_OFFSET"); b.end(); @@ -246,7 +244,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public CodeTree[] createTracingArguments(ExecutionVariables vars) { return new CodeTree[]{ CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_STORE_LOCAL"), - CodeTreeBuilder.singleString("LE_BYTES.getShort(bc, bci + " + getArgumentOffset(1) + ")"), + CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(1) + "]"), CodeTreeBuilder.singleString("frame.getValue(sp - 1).getClass()") }; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index b86f1307b426..b434bc8ac4e0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -1,7 +1,47 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; -import java.util.Stack; +import java.util.List; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -96,7 +136,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeVariableElement[] realInputs = vars.inputs; CodeVariableElement[] realResults = vars.results; - Stack tmpStack = new Stack<>(); + List tmpStack = new ArrayList<>(); int realInputIndex = 0; int realResultIndex = 0; for (int i = 0; i < instrs.length; i++) { @@ -108,7 +148,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { switch (instrs[i].inputs[j]) { case STACK_VALUE: if (!tmpStack.isEmpty()) { - innerInputs[j] = tmpStack.pop(); + innerInputs[j] = tmpStack.remove(tmpStack.size() - 1); break; } // fall-through @@ -120,7 +160,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { break; case STACK_VALUE_IGNORED: if (!tmpStack.isEmpty()) { - tmpStack.pop(); + tmpStack.remove(tmpStack.size() - 1); } else { realInputIndex++; } @@ -162,4 +202,4 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index 9a912bc71114..f7cc67162f2e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -18,14 +58,14 @@ public boolean standardPrologue() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // TODO since we do not have a typecheck in a catch + // todo: since we do not have a typecheck in a catch // we can convert this to a jump to a statically determined handler // or a throw out of a function - b.startAssign("int slot").startCall("LE_BYTES", "getShort"); + b.startAssign("int slot"); b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + getArgumentOffset(0)).end(); - b.end(2); + b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); + b.end(); b.startThrow(); b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 8fb3630b3284..abf6ad8eb735 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.operations; import com.oracle.truffle.api.Assumption; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 8192a24614f8..71c22ed7bd97 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -138,7 +138,7 @@ public Void visitFunction(FunctionContext ctx) { try { System.out.println("----------------------------------------------"); System.out.printf(" Node: %s%n", name); - System.out.println(node); + System.out.println(node.dump()); System.out.println("----------------------------------------------"); } catch (Exception ignored) { } From 99a37c5c28de510d49ae99e0d6dd0c60d248f63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 21 Jun 2022 17:57:57 +0200 Subject: [PATCH 094/312] [wip] new instruction gen --- .../truffle/api/operation/LocalSetter.java | 48 +- .../api/operation/OperationBuilder.java | 25 +- .../api/operation/OperationsConstantPool.java | 46 +- .../dsl/processor/operations/Operation.java | 155 +--- .../operations/OperationGeneratorUtils.java | 32 +- .../OperationsBytecodeCodeGenerator.java | 641 ++++++------- .../OperationsBytecodeNodeGeneratorPlugs.java | 185 ++-- .../operations/OperationsCodeGenerator.java | 35 +- .../operations/OperationsContext.java | 6 +- .../instructions/BranchInstruction.java | 28 +- .../ConditionalBranchInstruction.java | 44 +- .../instructions/CustomInstruction.java | 261 ++---- .../instructions/DiscardInstruction.java | 16 +- .../operations/instructions/Instruction.java | 877 +++++++++--------- .../InstrumentationEnterInstruction.java | 3 +- .../InstrumentationExitInstruction.java | 6 +- .../InstrumentationLeaveInstruction.java | 9 +- .../instructions/LoadArgumentInstruction.java | 18 +- .../instructions/LoadConstantInstruction.java | 20 +- .../instructions/LoadLocalInstruction.java | 19 +- .../instructions/QuickenedInstruction.java | 51 +- .../instructions/ReturnInstruction.java | 19 +- .../instructions/ShortCircuitInstruction.java | 12 +- .../instructions/StoreLocalInstruction.java | 212 +++-- .../instructions/SuperInstruction.java | 205 ---- .../instructions/ThrowInstruction.java | 13 +- .../src/tests/LoopCall.sl | 2 +- .../truffle/sl/operations/SLOperations.java | 4 +- .../sl/parser/SLOperationsVisitor.java | 57 +- 29 files changed, 1406 insertions(+), 1643 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index 3901ce2c584f..c2e5ce2d0134 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.HashMap; @@ -36,7 +76,7 @@ public void setLong(VirtualFrame frame, long value) { if (slotKind == FrameSlotKind.Long) { frame.setLong(index, value); } else { - // TODO this should be compatible with local boxing elimination + // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } @@ -46,7 +86,7 @@ public void setInt(VirtualFrame frame, int value) { if (slotKind == FrameSlotKind.Int) { frame.setInt(index, value); } else { - // TODO this should be compatible with local boxing elimination + // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } @@ -56,10 +96,10 @@ public void setDouble(VirtualFrame frame, double value) { if (slotKind == FrameSlotKind.Double) { frame.setDouble(index, value); } else { - // TODO this should be compatible with local boxing elimination + // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } - // TODO other primitives + // todo: other primitives } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index bd30f082f108..c5fc14550817 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -51,7 +51,6 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.impl.FrameWithoutBoxing; import com.oracle.truffle.api.instrumentation.Tag; -import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -262,10 +261,10 @@ protected final OperationLocal createParentLocal() { return local; } - protected int getLocalIndex(Object value) { + protected short getLocalIndex(Object value) { BuilderOperationLocal local = (BuilderOperationLocal) value; assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return local.id; + return (short) local.id; } protected int[] getLocalIndices(Object[] value) { @@ -278,6 +277,17 @@ protected int[] getLocalIndices(Object[] value) { return result; } + protected short getLocalRunStart(Object arg) { + // todo: validate local run + OperationLocal[] arr = (OperationLocal[]) arg; + return (short) ((BuilderOperationLocal) arr[0]).id; + } + + protected short getLocalRunLength(Object arg) { + OperationLocal[] arr = (OperationLocal[]) arg; + return (short) arr.length; + } + private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { BuilderOperationData cur = child; while (cur.depth > parent.depth) { @@ -324,7 +334,8 @@ public final void endSourceSection(int length) { private ArrayList labelFills = new ArrayList<>(); private ArrayList labels = new ArrayList<>(); - protected final void createOffset(int locationBci, Object label) { + @SuppressWarnings("unused") + protected final void putBranchTarget(short[] unusedBc, int locationBci, Object label) { BuilderLabelFill fill = new BuilderLabelFill(locationBci, (BuilderOperationLabel) label); labelFills.add(fill); } @@ -360,8 +371,8 @@ protected final void calculateLeaves(BuilderOperationData fromData) { calculateLeaves(fromData, (BuilderOperationData) null); } - protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationLabel toLabel) { - calculateLeaves(fromData, toLabel.data); + protected final void calculateLeaves(BuilderOperationData fromData, Object toLabel) { + calculateLeaves(fromData, ((BuilderOperationLabel) toLabel).data); } protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { @@ -392,7 +403,7 @@ protected final void calculateLeaves(BuilderOperationData fromData, BuilderOpera @SuppressWarnings("unused") protected final int doBranchInstruction(int instr, OperationLabel label) { - createOffset(bci, label); + putBranchTarget(bc, bci, label); return 2; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java index 51d84f3bbdb3..5163585fda64 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.ArrayList; @@ -9,8 +49,9 @@ public class OperationsConstantPool { private Object[] frozenValues = null; public synchronized int add(Object o) { - if (frozen) + if (frozen) { throw new IllegalStateException("constant pool already frozen"); + } int idx = values.indexOf(o); if (idx == -1) { idx = values.size(); @@ -24,8 +65,9 @@ public synchronized int reserve() { } public synchronized int reserve(int count) { - if (frozen) + if (frozen) { throw new IllegalStateException("constant pool already frozen"); + } int idx = values.size(); for (int i = 0; i < count; i++) { values.add(null); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index ae6eb5096656..64d498d11db8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -41,6 +41,7 @@ package com.oracle.truffle.dsl.processor.operations; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitBranchInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.getTypes; @@ -57,8 +58,8 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ResultType; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; @@ -167,27 +168,43 @@ protected Simple(OperationsContext builder, String name, int id, int children, I this.instruction = instruction; } + private static int moveArguments(BuilderVariables vars, int startIndex, CodeTree[] array) { + int index = startIndex; + for (int i = 0; i < array.length; i++) { + array[i] = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[" + index + "]").build(); + index++; + } + + return index; + } + @Override public CodeTree createEndCode(BuilderVariables vars) { - CodeTree[] arguments = new CodeTree[instruction.inputs.length + instruction.results.length]; + int index = 0; + + EmitArguments args = new EmitArguments(); - for (int i = 0; i < arguments.length; i++) { - arguments[i] = CodeTreeBuilder.createBuilder().string("operationData.arguments[" + i + "]").build(); + args.locals = new CodeTree[instruction.numLocals()]; + args.localRuns = new CodeTree[instruction.numLocalRuns()]; + args.arguments = new CodeTree[instruction.numArguments()]; + args.branchTargets = new CodeTree[instruction.numBranchTargets()]; + + index = moveArguments(vars, index, args.locals); + index = moveArguments(vars, index, args.localRuns); + index = moveArguments(vars, index, args.arguments); + index = moveArguments(vars, index, args.branchTargets); + + if (instruction.isVariadic()) { + args.variadicCount = CodeTreeBuilder.createBuilder().string("numChildren - " + instruction.numPopStatic()).build(); } - return OperationGeneratorUtils.createEmitInstruction(vars, instruction, arguments); + return OperationGeneratorUtils.createEmitInstruction(vars, instruction, args); } @Override public CodeTree createPushCountCode(BuilderVariables vars) { - int result = 0; - for (int i = 0; i < instruction.results.length; i++) { - if (instruction.results[i] == ResultType.STACK_VALUE) { - result++; - } - } - return CodeTreeBuilder.singleString("" + result); + return CodeTreeBuilder.singleString("" + instruction.numPushedValues); } @Override @@ -213,9 +230,10 @@ protected LoadConstant(OperationsContext builder, int id, LoadConstantInstructio public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - CodeTree[] arguments = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; + EmitArguments args = new EmitArguments(); + args.constants = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instructions[FrameKind.OBJECT.ordinal()], arguments)); + b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instructions[FrameKind.OBJECT.ordinal()], args)); return b.build(); } @@ -299,7 +317,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varEndLabel)); + b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, varEndLabel)); // } b.end().startElseBlock(); // { @@ -367,7 +385,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, varElseLabel)); + b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, varElseLabel)); // } b.end(); b.startElseIf().variable(vars.childIndex).string(" == 1").end(); @@ -385,7 +403,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(createEmitBranchInstruction(vars, builder.commonBranch, varEndLabel)); b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); // } b.end().startElseBlock(); @@ -451,13 +469,13 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); // } b.end().startElseBlock(); // { b.tree(createPopLastChildCode(vars)); - b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitBranchInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); // } @@ -554,7 +572,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".endBci = ").variable(vars.bci).end(); - b.tree(createEmitInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitBranchInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); b.end().startElseBlock(); @@ -597,7 +615,7 @@ public static class InstrumentTag extends Block { private final Instruction startInstruction; private final Instruction endInstruction; private final Instruction endVoidInstruction; - private final Instruction leaveInstruction; + @SuppressWarnings("unused") private final Instruction leaveInstruction; public static final String NAME = "Tag"; @@ -642,7 +660,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitInstruction(vars, startInstruction, varCurInstrumentId)); + b.tree(createEmitBranchInstruction(vars, startInstruction, varCurInstrumentId)); b.tree(super.createBeginCode(vars)); return b.build(); @@ -654,9 +672,9 @@ public CodeTree createEndCode(BuilderVariables vars) { b.startIf().variable(vars.lastChildPushCount).string(" != 0").end(); b.startBlock(); - b.tree(createEmitInstruction(vars, endInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); + b.tree(createEmitBranchInstruction(vars, endInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); b.end().startElseBlock(); - b.tree(createEmitInstruction(vars, endVoidInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); + b.tree(createEmitBranchInstruction(vars, endVoidInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); b.end(); b.tree(super.createEndCode(vars)); @@ -667,10 +685,11 @@ public CodeTree createEndCode(BuilderVariables vars) { public CodeTree createLeaveCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(createEmitInstruction(vars, leaveInstruction, - createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)), - createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel), - createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + // b.tree(createEmitInstruction(vars, leaveInstruction, + // createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)), + // createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel), + // createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + // todo return b.build(); } @@ -782,7 +801,7 @@ public CodeTree createEndCode(BuilderVariables vars) { b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); b.startBlock(); - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, builder.commonBranch, varEndLabel)); b.end(); b.declaration(getTypes().BuilderExceptionHandler, "beh", createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)); @@ -793,7 +812,7 @@ public CodeTree createEndCode(BuilderVariables vars) { b.startBlock(); CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").build(); - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, builder.commonThrow, localIdx)); + b.tree(OperationGeneratorUtils.createEmitLocalInstruction(vars, builder.commonThrow, localIdx)); b.end(); b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); @@ -861,7 +880,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" > 0").end().startBlock(); // { - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); // } b.end(); @@ -879,78 +898,6 @@ public CodeTree createEndCode(BuilderVariables vars) { } - public static class LocalSetter extends Operation { - - protected LocalSetter(OperationsContext context, int id) { - super(context, "LocalSetter", id, 0); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(getTypes().OperationLocal); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().variable(vars.operationData).string(".localReferences[").variable(vars.operationData).string(".numLocalReferences++] = arg0").end(); - - return b.build(); - } - - @Override - public boolean needsOperationData() { - return false; - } - - @Override - public boolean isRealOperation() { - return false; - } - } - - public static class LocalSetterArray extends Operation { - - protected LocalSetterArray(OperationsContext context, int id) { - super(context, "LocalSetterArray", id, 0); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(new CodeTypeMirror.ArrayCodeTypeMirror(getTypes().OperationLocal)); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().variable(vars.operationData).string(".localReferences = arg0").end(); - - return b.build(); - } - - @Override - public boolean needsOperationData() { - return false; - } - - @Override - public boolean isRealOperation() { - return false; - } - } - private static CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement().variable(vars.operationData).string(".aux[" + index + "] = ").tree(value).end().build(); } @@ -964,7 +911,7 @@ protected final CodeTree createPopLastChildCode(BuilderVariables vars) { b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); b.startBlock(); // { - b.tree(createEmitInstruction(vars, builder.commonPop, new CodeTree[0])); + b.tree(createEmitInstruction(vars, builder.commonPop, new EmitArguments())); b.end(); // } return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index e6ffad8f15f2..c7aebd8ad58d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -59,6 +59,7 @@ import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; public class OperationGeneratorUtils { @@ -68,20 +69,27 @@ public static TruffleTypes getTypes() { } public static String toScreamCase(String s) { - return s.replaceAll("([a-z])([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); + return s.replaceAll("([a-z]|[A-Z]+)([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); } - public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement... arguments) { - CodeTree[] trees = new CodeTree[arguments.length]; - for (int i = 0; i < trees.length; i++) { - trees[i] = CodeTreeBuilder.singleVariable(arguments[i]); - } + public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, EmitArguments arguments) { + return instr.createEmitCode(vars, arguments); + } - return createEmitInstruction(vars, instr, trees); + public static CodeTree createEmitBranchInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement arguments) { + return createEmitBranchInstruction(vars, instr, CodeTreeBuilder.singleVariable(arguments)); } - public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, CodeTree... arguments) { - return instr.createEmitCode(vars, arguments); + public static CodeTree createEmitBranchInstruction(BuilderVariables vars, Instruction instr, CodeTree arguments) { + EmitArguments args = new EmitArguments(); + args.branchTargets = new CodeTree[]{arguments}; + return createEmitInstruction(vars, instr, args); + } + + public static CodeTree createEmitLocalInstruction(BuilderVariables vars, Instruction instr, CodeTree arguments) { + EmitArguments args = new EmitArguments(); + args.locals = new CodeTree[]{arguments}; + return createEmitInstruction(vars, instr, args); } public static CodeTree createCreateLabel() { @@ -212,17 +220,17 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar return b.build(); } - public static CodeTree callSetResultBoxed(String bciOffset, FrameKind kind) { + public static CodeTree callSetResultBoxed(CodeTree bciOffset, FrameKind kind) { return callSetResultBoxed(bciOffset, toFrameTypeConstant(kind)); } - public static CodeTree callSetResultBoxed(String bciOffset, CodeTree kind) { + public static CodeTree callSetResultBoxed(CodeTree bciOffset, CodeTree kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); b.string("bc"); b.string("$bci"); - b.string(bciOffset); + b.tree(bciOffset); b.tree(kind); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index dc3353a6f7ac..c3164555f676 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -69,7 +69,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; @@ -126,459 +125,423 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); builderBytecodeNodeType.add(ctor); - { - StaticConstants staticConstants = new StaticConstants(true); - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - continue; - } + initializeInstructions(builderBytecodeNodeType, fldBc, fldConsts, fldChildren); - CustomInstruction cinstr = (CustomInstruction) instr; + ExecutionVariables vars = new ExecutionVariables(); + // vars.bytecodeNodeType = builderBytecodeNodeType; + vars.bc = fldBc; + vars.consts = fldConsts; + vars.probeNodes = fldProbeNodes; + // vars.handlers = fldHandlers; + // vars.tracer = fldTracer; - boolean isVariadic = cinstr.getData().getMainProperties().isVariadic; - boolean isShortCircuit = cinstr.getData().isShortCircuit(); - boolean regularReturn = isVariadic || isShortCircuit; + createBytecodeLoop(builderBytecodeNodeType, fldBc, fldHandlers, vars); - final Set methodNames = new HashSet<>(); - final Set innerTypeNames = new HashSet<>(); + if (m.isGenerateAOT()) { + createPrepareAot(builderBytecodeNodeType, vars); + } - final SingleOperationData soData = cinstr.getData(); - final List additionalData = new ArrayList<>(); - final List additionalDataKinds = new ArrayList<>(); + createDumpCode(builderBytecodeNodeType, fldHandlers, vars); - final List childIndices = new ArrayList<>(); - final List constIndices = new ArrayList<>(); + return builderBytecodeNodeType; + } - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( - m, fldBc, fldChildren, constIndices, - innerTypeNames, additionalData, - methodNames, isVariadic, - additionalDataKinds, - fldConsts, cinstr, childIndices, - staticConstants); - cinstr.setPlugs(plugs); + private void createPrepareAot(CodeTypeElement builderBytecodeNodeType, ExecutionVariables vars) { + builderBytecodeNodeType.getImplements().add(types.GenerateAOT_Provider); - NodeCodeGenerator generator = new NodeCodeGenerator(); - generator.setPlugs(plugs); + CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(types.GenerateAOT_Provider, "prepareForAOT"); + builderBytecodeNodeType.add(mPrepareForAot); - List resultList = generator.create(context, null, soData.getNodeData()); - if (resultList.size() != 1) { - throw new AssertionError("Node generator did not return exactly one class"); - } - plugs.finishUp(); - CodeTypeElement result = resultList.get(0); + mPrepareForAot.renameArguments("language", "root"); - CodeExecutableElement uncExec = null; - List execs = new ArrayList<>(); - for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { - if (!methodNames.contains(ex.getSimpleName().toString())) { - continue; - } + CodeTreeBuilder b = mPrepareForAot.createBuilder(); - if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName("execute"))) { - uncExec = (CodeExecutableElement) ex; - } + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + b.declaration("int", "bci", "0"); - execs.add((CodeExecutableElement) ex); - } + b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); - if (uncExec == null) { - throw new AssertionError(String.format("execute method not found in: %s", result.getSimpleName())); - } + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, instr -> { + if (instr == null) { + return null; + } - for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { - if (!innerTypeNames.contains(te.getSimpleName().toString())) { - continue; - } + CodeTreeBuilder binstr = b.create(); - builderBytecodeNodeType.add(te); - } + binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); + binstr.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); + binstr.statement("break"); - CodeExecutableElement metPrepareForAOT = null; + return binstr.build(); + })); - for (CodeExecutableElement exToCopy : execs) { - boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); + b.end(); + } - String exName = exToCopy.getSimpleName().toString(); - boolean isExecute = exName.contains("_execute_"); - boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); - boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); + private void createDumpCode(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldHandlers, ExecutionVariables vars) { + CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); + builderBytecodeNodeType.add(mDump); - if (instr instanceof QuickenedInstruction) { - if (isExecuteAndSpecialize) { - continue; - } - } + CodeTreeBuilder b = mDump.getBuilder(); - if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { - List params = exToCopy.getParameters(); + b.declaration("int", "bci", "0"); + b.declaration("int", "instrIndex", "0"); + b.declaration("StringBuilder", "sb", "new StringBuilder()"); - for (int i = 0; i < params.size(); i++) { - TypeMirror paramType = params.get(i).asType(); - if (ElementUtils.typeEquals(paramType, types.Frame) || ElementUtils.typeEquals(paramType, types.VirtualFrame)) { - params.remove(i); - i--; - } - } - } + vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - if (!regularReturn) { - if (isExecute || isExecuteAndSpecialize) { - exToCopy.setReturnType(context.getType(void.class)); - } - } + b.startWhile().string("bci < bc.length").end(); + b.startBlock(); // while block - exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$sp")); - exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); - if (!isBoundary) { - exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); - } - exToCopy.getModifiers().remove(Modifier.PUBLIC); - exToCopy.getModifiers().add(Modifier.PRIVATE); - exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); - builderBytecodeNodeType.add(exToCopy); + b.statement("sb.append(String.format(\" [%04x]\", bci))"); - if (exName.equals(plugs.transformNodeMethodName("prepareForAOT"))) { - metPrepareForAOT = exToCopy; - } - } + b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - cinstr.setExecuteMethod(uncExec); - cinstr.setDataKinds(additionalDataKinds.toArray(new DataKind[additionalDataKinds.size()])); - cinstr.setNumChildNodes(childIndices.size()); - cinstr.setNumConsts(constIndices); - cinstr.setPrepareAOTMethod(metPrepareForAOT); + if (op == null) { + builder.statement("sb.append(String.format(\" unknown 0x%02x\", bc[bci++]))"); + } else { + builder.tree(op.createDumpCode(vars)); + builder.startAssign("bci").string("bci + ").tree(op.createLength()).end(); + } - if (m.isTracing()) { - CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), - "doGetStateBits_" + cinstr.getUniqueName() + "_"); - metGetSpecBits.setEnclosingElement(typBuilderImpl); - typBuilderImpl.add(metGetSpecBits); + builder.statement("break"); + return builder.build(); + })); - metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "bc")); - metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); - CodeTreeBuilder b = metGetSpecBits.createBuilder(); - b.tree(plugs.createGetSpecializationBits()); + b.statement("sb.append(\"\\n\")"); - cinstr.setGetSpecializationBits(metGetSpecBits); - } - } + b.end(); // while block - for (CodeVariableElement element : staticConstants.elements()) { - builderBytecodeNodeType.add(element); - } + b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); + b.startBlock(); - builderBytecodeNodeType.add(StoreLocalInstruction.createStoreLocalInitialization(m.getOperationsContext())); - } + b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); - ExecutionVariables vars = new ExecutionVariables(); - // vars.bytecodeNodeType = builderBytecodeNodeType; - vars.bc = fldBc; - vars.consts = fldConsts; - vars.probeNodes = fldProbeNodes; - // vars.handlers = fldHandlers; - // vars.tracer = fldTracer; + b.end(); - { - CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); - CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); - CodeVariableElement argStartSp = new CodeVariableElement(context.getType(int.class), "startSp"); - CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PROTECTED), context.getType(Object.class), "continueAt", - argFrame, argStartBci, argStartSp); - builderBytecodeNodeType.getEnclosedElements().add(0, mContinueAt); - - { - CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); - mContinueAt.addAnnotationMirror(annExplodeLoop); - annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( - context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); - } + // b.startIf().string("sourceInfo != null").end(); + // b.startBlock(); + // { + // b.statement("sb.append(\"Source info:\\n\")"); + // b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); + // b.startBlock(); + // + // b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", + // sourceInfo[0][i], + // sourceInfo[1][i], sourceInfo[2][i]))"); + // + // b.end(); + // } + // b.end(); - mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); + b.startReturn().string("sb.toString()").end(); - CodeTreeBuilder b = mContinueAt.getBuilder(); + vars.bci = null; + } - CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); - CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); - CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); + private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldBc, CodeVariableElement fldHandlers, ExecutionVariables vars) { + CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); + CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); + CodeVariableElement argStartSp = new CodeVariableElement(context.getType(int.class), "startSp"); + CodeExecutableElement mContinueAt = new CodeExecutableElement( + Set.of(Modifier.PROTECTED), context.getType(Object.class), "continueAt", + argFrame, argStartBci, argStartSp); + builderBytecodeNodeType.getEnclosedElements().add(0, mContinueAt); - b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); - b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); + createExplodeLoop(mContinueAt); - CodeVariableElement varTracer; + mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); - if (m.isTracing()) { - varTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); - b.startAssign("ExecutionTracer " + varTracer.getName()).startStaticCall(types.ExecutionTracer, "get"); - b.typeLiteral(m.getTemplateType().asType()); - b.end(2); + CodeTreeBuilder b = mContinueAt.getBuilder(); - b.startStatement().startCall(varTracer, "startFunction").string("this").end(2); - } else { - varTracer = null; - } + CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); + CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); - CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); - b.statement("Object " + varReturnValue.getName() + " = null"); + b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); + b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); - b.string("loop: "); - b.startWhile().string("true").end(); - b.startBlock(); - CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); - b.statement("int nextBci"); + CodeVariableElement varTracer; + + if (m.isTracing()) { + varTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); + b.startAssign("ExecutionTracer " + varTracer.getName()).startStaticCall(types.ExecutionTracer, "get"); + b.typeLiteral(m.getTemplateType().asType()); + b.end(2); - vars.bci = varBci; - vars.nextBci = varNextBci; - vars.frame = argFrame; - vars.sp = varSp; - vars.returnValue = varReturnValue; - vars.tracer = varTracer; + b.startStatement().startCall(varTracer, "startFunction").string("this").end(2); + } else { + varTracer = null; + } - b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(fldBc, varBci)); + CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); + b.statement("Object " + varReturnValue.getName() + " = null"); - b.startTryBlock(); + b.string("loop: "); + b.startWhile().string("true").end(); + b.startBlock(); + CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); + b.statement("int nextBci"); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); + vars.bci = varBci; + vars.nextBci = varNextBci; + vars.frame = argFrame; + vars.sp = varSp; + vars.returnValue = varReturnValue; + vars.tracer = varTracer; - b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); - b.startBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); - b.end(); + b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(fldBc, varBci)); - b.startSwitch().string("curOpcode").end(); - b.startBlock(); + b.startTryBlock(); - for (Instruction op : m.getInstructions()) { - if (op.isInstrumentationOnly() && !withInstrumentation) { - continue; - } + b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); - b.startDoc(); - for (String line : op.dumpInfo().split("\n")) { - b.string(line).newLine(); - } - b.end(); + b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); + b.startBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); + b.end(); - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); + b.startSwitch().string("curOpcode").end(); + b.startBlock(); - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "traceInstruction"); - b.variable(varBci); - b.variable(op.opcodeIdField); - b.end(2); - } + for (Instruction op : m.getInstructions()) { + if (op.isInstrumentationOnly() && !withInstrumentation) { + continue; + } - if (op.standardPrologue()) { - throw new AssertionError("standard prologue: " + op.name); - } + for (String line : op.dumpInfo().split("\n")) { + b.lineComment(line); + } - b.tree(op.createExecuteCode(vars)); + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); - if (op.isReturnInstruction()) { - b.statement("break loop"); - } else if (!op.isBranchInstruction()) { - b.startAssign(varNextBci).variable(varBci).string(" + " + op.length()).end(); - b.statement("break"); - } + if (m.isTracing()) { + b.startStatement().startCall(varTracer, "traceInstruction"); + b.variable(varBci); + b.variable(op.opcodeIdField); + b.end(2); + } - b.end(); + b.tree(op.createExecuteCode(vars)); - vars.inputs = null; - vars.results = null; + if (!op.isBranchInstruction()) { + b.startAssign(varNextBci).variable(varBci).string(" + ").tree(op.createLength()).end(); + b.statement("break"); } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")); b.end(); - b.end(); // switch block + vars.inputs = null; + vars.results = null; + } - b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")); + b.end(); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + b.end(); // switch block - // if (m.isTracing()) { - // b.startStatement().startCall(fldTracer, "traceException"); - // b.string("ex"); - // b.end(2); - // } + b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); - b.startFor().string("int handlerIndex = " + fldHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); - b.startBlock(); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); - b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); + // if (m.isTracing()) { + // b.startStatement().startCall(fldTracer, "traceException"); + // b.string("ex"); + // b.end(2); + // } - b.declaration(types.BuilderExceptionHandler, "handler", fldHandlers.getName() + "[handlerIndex]"); + b.startFor().string("int handlerIndex = " + fldHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); + b.startBlock(); - b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); - b.statement("continue"); + b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); - b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET + maxLocals").end(); - // TODO check exception type (?) + b.declaration(types.BuilderExceptionHandler, "handler", fldHandlers.getName() + "[handlerIndex]"); - b.startStatement().startCall(argFrame, "setObject") // - .string("VALUES_OFFSET + handler.exceptionIndex") // - .string("ex") // - .end(2); + b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); + b.statement("continue"); - b.statement("bci = handler.handlerBci"); - b.statement("continue loop"); + b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET + maxLocals").end(); + // todo: check exception type (?) - b.end(); // for (handlerIndex ...) + b.startStatement().startCall(argFrame, "setObject").string("VALUES_OFFSET + handler.exceptionIndex").string("ex").end(2); - b.startThrow().string("ex").end(); + b.statement("bci = handler.handlerBci"); + b.statement("continue loop"); - b.end(); // catch block + b.end(); // for (handlerIndex ...) - b.tree(GeneratorUtils.createPartialEvaluationConstant(varNextBci)); - b.statement("bci = nextBci"); - b.end(); // while block + b.startThrow().string("ex").end(); - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "endFunction"); - b.string("this"); - b.end(2); - } + b.end(); // catch block - b.startReturn().string("returnValue").end(); - - vars.tracer = null; - vars.bci = null; - vars.nextBci = null; - vars.frame = null; - vars.sp = null; - vars.returnValue = null; + b.tree(GeneratorUtils.createPartialEvaluationConstant(varNextBci)); + b.statement("bci = nextBci"); + b.end(); // while block + if (m.isTracing()) { + b.startStatement().startCall(varTracer, "endFunction"); + b.string("this"); + b.end(2); } - if (m.isGenerateAOT()) { - builderBytecodeNodeType.getImplements().add(types.GenerateAOT_Provider); + b.startReturn().string("returnValue").end(); - CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(types.GenerateAOT_Provider, "prepareForAOT"); - builderBytecodeNodeType.add(mPrepareForAot); + vars.tracer = null; + vars.bci = null; + vars.nextBci = null; + vars.frame = null; + vars.sp = null; + vars.returnValue = null; + } - mPrepareForAot.renameArguments("language", "root"); + private void createExplodeLoop(CodeExecutableElement mContinueAt) { + CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); + mContinueAt.addAnnotationMirror(annExplodeLoop); + annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( + context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); + } - CodeTreeBuilder b = mPrepareForAot.createBuilder(); + private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldBc, CodeVariableElement fldConsts, CodeVariableElement fldChildren) throws AssertionError { + StaticConstants staticConstants = new StaticConstants(true); + for (Instruction instr : m.getInstructions()) { + if (!(instr instanceof CustomInstruction)) { + continue; + } - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("int", "bci", "0"); + CustomInstruction cinstr = (CustomInstruction) instr; - b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); + boolean isVariadic = cinstr.getData().getMainProperties().isVariadic; + boolean isShortCircuit = cinstr.getData().isShortCircuit(); + boolean regularReturn = isVariadic || isShortCircuit; - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, instr -> { - if (instr == null) { - return null; - } + final Set methodNames = new HashSet<>(); + final Set innerTypeNames = new HashSet<>(); - CodeTreeBuilder binstr = b.create(); + final SingleOperationData soData = cinstr.getData(); - binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); - binstr.startAssign(vars.bci).variable(vars.bci).string(" + " + instr.length()).end(); - binstr.statement("break"); + OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( + m, fldBc, fldChildren, + innerTypeNames, + methodNames, isVariadic, + fldConsts, cinstr, + staticConstants); + cinstr.setPlugs(plugs); - return binstr.build(); - })); + NodeCodeGenerator generator = new NodeCodeGenerator(); + generator.setPlugs(plugs); - b.end(); - } + List resultList = generator.create(context, null, soData.getNodeData()); + if (resultList.size() != 1) { + throw new AssertionError("Node generator did not return exactly one class"); + } + plugs.finishUp(); + CodeTypeElement result = resultList.get(0); - { - CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); - builderBytecodeNodeType.add(mDump); + CodeExecutableElement uncExec = null; + List execs = new ArrayList<>(); + for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { + if (!methodNames.contains(ex.getSimpleName().toString())) { + continue; + } + + if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName("execute"))) { + uncExec = (CodeExecutableElement) ex; + } - CodeTreeBuilder b = mDump.getBuilder(); + execs.add((CodeExecutableElement) ex); + } - b.declaration("int", "bci", "0"); - b.declaration("int", "instrIndex", "0"); - b.declaration("StringBuilder", "sb", "new StringBuilder()"); + if (uncExec == null) { + throw new AssertionError(String.format("execute method not found in: %s", result.getSimpleName())); + } - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { + if (!innerTypeNames.contains(te.getSimpleName().toString())) { + continue; + } - b.startWhile().string("bci < bc.length").end(); - b.startBlock(); // while block + builderBytecodeNodeType.add(te); + } - b.statement("sb.append(String.format(\" %04x \", bci))"); + CodeExecutableElement metPrepareForAOT = null; - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + for (CodeExecutableElement exToCopy : execs) { + boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); - if (op == null) { - builder.statement("sb.append(String.format(\"unknown 0x%02x\", bc[bci++]))"); - builder.statement("break"); - return builder.build(); - } + String exName = exToCopy.getSimpleName().toString(); + boolean isExecute = exName.contains("_execute_"); + boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); + boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); - for (int i = 0; i < 16; i++) { - if (i < op.length()) { - builder.statement("sb.append(String.format(\"%04x \", bc[bci + " + i + "]))"); - } else { - builder.statement("sb.append(\" \")"); + if (instr instanceof QuickenedInstruction) { + if (isExecuteAndSpecialize) { + continue; } } - builder.statement("sb.append(\"" + op.name + " ".repeat(op.name.length() < 32 ? 32 - op.name.length() : 0) + " \")"); + if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { + List params = exToCopy.getParameters(); - for (int i = 0; i < op.inputs.length; i++) { - if (i != 0) { - builder.statement("sb.append(\", \")"); + int i = 0; + for (; i < params.size(); i++) { + TypeMirror paramType = params.get(i).asType(); + if (ElementUtils.typeEquals(paramType, types.Frame) || ElementUtils.typeEquals(paramType, types.VirtualFrame)) { + params.remove(i); + i--; + } } - builder.tree(op.inputs[i].createDumpCode(i, op, vars)); } - builder.statement("sb.append(\" -> \")"); - - for (int i = 0; i < op.results.length; i++) { - if (i != 0) { - builder.statement("sb.append(\", \")"); + if (!regularReturn) { + if (isExecute || isExecuteAndSpecialize) { + exToCopy.setReturnType(context.getType(void.class)); } - builder.tree(op.results[i].createDumpCode(i, op, vars)); } - builder.statement("bci += " + op.length()); - builder.statement("break"); - - return builder.build(); - })); + exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$sp")); + exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + if (!isBoundary) { + exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); + } + exToCopy.getModifiers().remove(Modifier.PUBLIC); + exToCopy.getModifiers().add(Modifier.PRIVATE); + exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); + builderBytecodeNodeType.add(exToCopy); - b.statement("sb.append(\"\\n\")"); + if (exName.equals(plugs.transformNodeMethodName("prepareForAOT"))) { + metPrepareForAOT = exToCopy; + } + } - b.end(); // while block + cinstr.setExecuteMethod(uncExec); + cinstr.setPrepareAOTMethod(metPrepareForAOT); - b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); - b.startBlock(); - - b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); + if (m.isTracing()) { + CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), + "doGetStateBits_" + cinstr.getUniqueName() + "_"); + metGetSpecBits.setEnclosingElement(typBuilderImpl); + typBuilderImpl.add(metGetSpecBits); - b.end(); + metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "bc")); + metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); + CodeTreeBuilder b = metGetSpecBits.createBuilder(); + b.tree(plugs.createGetSpecializationBits()); - // b.startIf().string("sourceInfo != null").end(); - // b.startBlock(); - // { - // b.statement("sb.append(\"Source info:\\n\")"); - // b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); - // b.startBlock(); - // - // b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", - // sourceInfo[0][i], - // sourceInfo[1][i], sourceInfo[2][i]))"); - // - // b.end(); - // } - // b.end(); - - b.startReturn().string("sb.toString()").end(); - - vars.bci = null; + cinstr.setGetSpecializationBits(metGetSpecBits); + } + } + for (CodeVariableElement element : staticConstants.elements()) { + builderBytecodeNodeType.add(element); } - return builderBytecodeNodeType; + builderBytecodeNodeType.add(StoreLocalInstruction.createStoreLocalInitialization(m.getOperationsContext())); } private static TypeMirror arrayOf(TypeMirror el) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 0c3986c4d927..89beeb91ae52 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; @@ -35,23 +75,19 @@ import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction.DataKind; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final CodeVariableElement fldBc; private final CodeVariableElement fldChildren; - private final List constIndices; private final Set innerTypeNames; - private final List additionalData; private final Set methodNames; private final boolean isVariadic; - private final List additionalDataKinds; private final CodeVariableElement fldConsts; private final CustomInstruction cinstr; - private final List childIndices; private final StaticConstants staticConstants; private final ProcessorContext context; @@ -65,30 +101,33 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private OperationsData m; private final SingleOperationData data; - OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, List constIndices, - Set innerTypeNames, List additionalData, - Set methodNames, boolean isVariadic, List additionalDataKinds, CodeVariableElement fldConsts, CustomInstruction cinstr, - List childIndices, StaticConstants staticConstants) { + private final ExecutionVariables dummyVariables = new ExecutionVariables(); + + { + context = ProcessorContext.getInstance(); + types = context.getTypes(); + dummyVariables.bc = new CodeVariableElement(context.getType(short[].class), "bc"); + dummyVariables.bci = new CodeVariableElement(context.getType(int.class), "$bci"); + dummyVariables.frame = new CodeVariableElement(types.Frame, "$frame"); + } + + OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, + Set innerTypeNames, + Set methodNames, boolean isVariadic, CodeVariableElement fldConsts, CustomInstruction cinstr, + StaticConstants staticConstants) { this.m = m; this.fldBc = fldBc; this.fldChildren = fldChildren; - this.constIndices = constIndices; this.innerTypeNames = innerTypeNames; - this.additionalData = additionalData; this.methodNames = methodNames; this.isVariadic = isVariadic; - this.additionalDataKinds = additionalDataKinds; this.fldConsts = fldConsts; this.cinstr = cinstr; - this.childIndices = childIndices; this.staticConstants = staticConstants; - this.context = ProcessorContext.getInstance(); - this.types = context.getTypes(); - this.data = cinstr.getData(); - if (cinstr.numPush() == 0 || data.isShortCircuit()) { + if (cinstr.numPushedValues == 0 || data.isShortCircuit()) { resultUnboxedState = null; } else { resultUnboxedState = new Object() { @@ -112,9 +151,7 @@ public void addAdditionalStateBits(List stateObjects) { @Override public void setStateObjects(List stateObjects) { - this.specializationStates = stateObjects.stream() // - .filter(x -> x instanceof SpecializationData) // - .collect(Collectors.toUnmodifiableList()); + this.specializationStates = stateObjects.stream().filter(x -> x instanceof SpecializationData).collect(Collectors.toUnmodifiableList()); } @Override @@ -177,23 +214,9 @@ public TypeMirror getBitSetType(TypeMirror defaultType) { return new CodeTypeMirror(TypeKind.SHORT); } - private int bitSetOffset(BitSet bits) { - int index = additionalData.indexOf(bits); - if (index == -1) { - index = additionalData.size(); - additionalData.add(bits); - - additionalDataKinds.add(DataKind.BITS); - } - - return index; - } - @Override public CodeTree createBitSetReference(BitSet bits) { - int index = bitSetOffset(bits); - - return CodeTreeBuilder.createBuilder().variable(fldBc).string("[$bci + " + cinstr.lengthWithoutState() + " + " + index + "]").build(); + return cinstr.createStateBitsIndex(dummyVariables, cinstr.addStateBits(bits)); } @Override @@ -209,22 +232,13 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea throw new IllegalArgumentException("refObject is null"); } - List refList = isChild ? childIndices : constIndices; - int index = refList.indexOf(refObject); - int baseIndex = additionalData.indexOf(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (index == -1) { - if (baseIndex == -1) { - baseIndex = additionalData.size(); - additionalData.add(isChild ? OperationsBytecodeCodeGenerator.MARKER_CHILD : OperationsBytecodeCodeGenerator.MARKER_CONST); - - additionalDataKinds.add(isChild ? DataKind.CHILD : DataKind.CONST); - } - - index = refList.size(); - refList.add(refObject); + int index; + if (isChild) { + index = cinstr.addChild(refObject); + } else { + index = cinstr.addConstant(refObject, null); } String offsetName = isChild ? CHILD_OFFSET_NAME : CONST_OFFSET_NAME; @@ -244,15 +258,21 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea b.variable(targetField).string("["); if (frame == null || !frame.getBoolean("definedOffsets", false)) { - b.variable(fldBc); - b.string("[$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex + "]"); + if (isChild) { + b.tree(cinstr.createChildIndex(dummyVariables, 0)); + } else { + b.tree(cinstr.createConstantIndex(dummyVariables, 0)); + } } else if (frame.getBoolean("has_" + offsetName, false)) { b.string(offsetName); } else { frame.setBoolean("has_" + offsetName, true); b.string("(" + offsetName + " = "); - b.variable(fldBc); - b.string("[$bci + " + cinstr.lengthWithoutState() + " + " + baseIndex + "]"); + if (isChild) { + b.tree(cinstr.createChildIndex(dummyVariables, 0)); + } else { + b.tree(cinstr.createConstantIndex(dummyVariables, 0)); + } b.string(")"); } @@ -268,7 +288,7 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea @Override public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original) { - // TODO maybe this would be needed at some point? + // todo: maybe this would be needed at some point? return new ReportPolymorphismAction(false, false); } @@ -344,7 +364,7 @@ public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) } private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { - if (cinstr.numPush() == 0) { + if (cinstr.numPushedValues == 0) { b.statement(specializationCall); b.returnStatement(); return; @@ -357,7 +377,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree return; } - assert cinstr.numPush() == 1; + assert cinstr.numPushedValues == 1; int destOffset = cinstr.numPopStatic(); @@ -386,21 +406,21 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree } else { b.declaration(retType, "value", value); b.startIf().tree(isResultBoxed).end().startBlock(); - { - b.startStatement(); - b.startCall("$frame", "setObject"); - b.string("$sp - " + destOffset); - b.string("value"); - b.end(2); - } + // { + b.startStatement(); + b.startCall("$frame", "setObject"); + b.string("$sp - " + destOffset); + b.string("value"); + b.end(2); + // } b.end().startElseBlock(); - { - b.startStatement(); - b.startCall("$frame", "set" + typeName); - b.string("$sp - " + destOffset); - b.string("value"); - b.end(2); - } + // { + b.startStatement(); + b.startCall("$frame", "set" + typeName); + b.string("$sp - " + destOffset); + b.string("value"); + b.end(2); + // } b.end(); } @@ -410,8 +430,9 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree @Override public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary, CodeTree[] bindings) { - if (inBoundary || regularReturn()) + if (inBoundary || regularReturn()) { return false; + } // if (m.isTracing()) { // b.startStatement().startCall("tracer", "traceSpecialization"); @@ -582,9 +603,9 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ elseIf = b.startIf(elseIf); b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); b.end().startBlock(); - { - b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); - } + // { + b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); + // } b.end(); } } @@ -652,7 +673,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed("bc[$bci + " + cinstr.getArgumentOffset(i) + "]", CodeTreeBuilder.singleString("type" + i))); + b.tree(OperationGeneratorUtils.callSetResultBoxed(cinstr.createPopIndexedIndex(dummyVariables, i), CodeTreeBuilder.singleString("type" + i))); } } @@ -695,9 +716,9 @@ private boolean createBoxingSplitUnboxingThing(CodeTreeBuilder b, FrameState fra b.tree(multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sourceType), 1, new Object[]{typeGuard}, new Object[]{typeGuard})); b.end().startBlock(); - { - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); - } + // { + b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); + // } b.end(); } @@ -777,8 +798,8 @@ public boolean isStateGuaranteed(boolean stateGuaranteed) { public void finishUp() { if (data.isShortCircuit()) { - cinstr.setBoxingEliminationData(0, 0); - } else if (cinstr.numPush() > 0) { + cinstr.setBoxingEliminationData(CodeTreeBuilder.singleString("0"), 0); + } else if (cinstr.numPushedValues > 0) { int offset = -1; BitSet targetSet = null; for (StateBitSet set : multiState.getSets()) { @@ -793,11 +814,11 @@ public void finishUp() { throw new AssertionError(); } - cinstr.setBoxingEliminationData(cinstr.lengthWithoutState() + bitSetOffset(targetSet), 1 << offset); + cinstr.setBoxingEliminationData(cinstr.createStateBitsOffset(cinstr.addStateBits(targetSet)), 1 << offset); } } public StaticConstants createConstants() { return staticConstants; } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 61419289879e..f0d5d9fac8b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -277,15 +277,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldId); } - // instruction IDs - for (Instruction instr : m.getOperationsContext().instructions) { - CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "INSTR_" + OperationGeneratorUtils.toScreamCase(instr.name)); - CodeTreeBuilder b = fldId.createInitBuilder(); - b.string("" + instr.id); - instr.setOpcodeIdField(fldId); - typBuilderImpl.add(fldId); - } - CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(); typBuilderImpl.add(typOperationNodeImpl); @@ -334,6 +325,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(createDoLeave(vars)); typBuilderImpl.add(createBeforeChild(vars)); typBuilderImpl.add(createAfterChild(vars)); + + // instruction IDs + for (Instruction instr : m.getOperationsContext().instructions) { + typBuilderImpl.addAll(instr.createInstructionFields()); + } + typBuilderImpl.add(createBoxingDescriptors()); builderBytecodeNodeType.add(createSetResultUnboxed()); @@ -585,7 +582,7 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B b.string("" + op.numLocalReferences()); for (VariableElement el : metBegin.getParameters()) { - b.variable(el); + b.startGroup().cast(context.getType(Object.class)).variable(el).end(); } b.end(2); @@ -639,25 +636,27 @@ private CodeVariableElement createBoxingDescriptors() { b.string("{").startCommaGroup(); b.string("-1"); for (Instruction instr : m.getInstructions()) { - String value; switch (instr.boxingEliminationBehaviour()) { case DO_NOTHING: - value = "0"; + b.string("0"); break; case REPLACE: - value = instr.boxingEliminationReplacement(kind).getName(); + b.variable(instr.boxingEliminationReplacement(kind)); break; case SET_BIT: { - int bitOffset = instr.boxingEliminationBitOffset(); - int bitMask = instr.boxingEliminationBitMask(); - short shortValue = (short) (0x8000 | (bitOffset << 8) | bitMask); - value = shortValue + " /* " + bitOffset + "," + Integer.toHexString(bitMask) + " */"; + b.startGroup(); + b.cast(context.getType(short.class)); + b.startParantheses(); + b.string("0x8000 | "); + b.startParantheses().startParantheses().tree(instr.boxingEliminationBitOffset()).end().string(" << 8").end(); + b.string(" | "); + b.string("" + instr.boxingEliminationBitMask()); + b.end(2); break; } default: throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); } - b.string(value); } b.end().string("}").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 8f5a513038cd..e3eeec11d97b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -55,7 +55,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.InputType; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; @@ -105,7 +104,7 @@ public void initializeContext() { } private void createCommonInstructions() { - commonPop = add(new DiscardInstruction("pop", instructionId++, InputType.STACK_VALUE_IGNORED)); + commonPop = add(new DiscardInstruction("pop", instructionId++)); commonBranch = add(new BranchInstruction(instructionId++)); commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++)); commonThrow = add(new ThrowInstruction(instructionId++)); @@ -129,9 +128,6 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); - add(new Operation.LocalSetter(this, operationId++)); - add(new Operation.LocalSetterArray(this, operationId++)); - add(new Operation.InstrumentTag(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++)), diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index cfc5fcc519e4..73524580aaba 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -43,7 +43,6 @@ import javax.lang.model.type.DeclaredType; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -56,23 +55,15 @@ public class BranchInstruction extends Instruction { private static final DeclaredType BYTECODE_OSR_NODE = context.getDeclaredType("com.oracle.truffle.api.nodes.BytecodeOSRNode"); public BranchInstruction(int id) { - super("branch", id, ResultType.BRANCH, InputType.BRANCH_TARGET); - } - - @Override - public boolean standardPrologue() { - return false; - } - - private CodeTree createGetBranchTarget(ExecutionVariables vars) { - return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]").build(); + super("branch", id, 0); + addBranchTarget("target"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration("int", "targetBci", createGetBranchTarget(vars)); + b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0)); b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { @@ -114,13 +105,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { + public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - TruffleTypes types = ProcessorContext.getInstance().getTypes(); b.startStatement().startCall("calculateLeaves"); b.variable(vars.operationData); - b.startGroup().cast(types.BuilderOperationLabel).tree(arguments[0]).end(); + b.tree(arguments.branchTargets[0]); b.end(2); return b.build(); @@ -140,12 +130,4 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_BRANCH"), - createGetBranchTarget(vars) - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 3b622e02124d..669d745dc049 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -42,7 +42,6 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; @@ -59,22 +58,11 @@ public class ConditionalBranchInstruction extends Instruction { private OperationsContext ctx; public ConditionalBranchInstruction(OperationsContext ctx, int id) { - super("branch.false", id, ResultType.BRANCH, InputType.BRANCH_TARGET, InputType.STACK_VALUE, InputType.BRANCH_PROFILE); + super("branch.false", id, 0); this.ctx = ctx; - } - - @Override - public TypeMirror[] expectedInputTypes(ProcessorContext c) { - return new TypeMirror[]{ - context.getType(short.class), - context.getType(boolean.class), - typeConditionProfile - }; - } - - @Override - public boolean standardPrologue() { - return false; + addPopSimple("condition"); + addBranchTarget("target"); + addBranchProfile("profile"); } @Override @@ -82,16 +70,13 @@ public boolean isBranchInstruction() { return true; } - @SuppressWarnings("unused") - private CodeTree createBranchTarget(ExecutionVariables vars) { - return CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]"); - } - @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration(typeConditionProfile, "profile", "conditionProfiles[bc[bci + " + getArgumentOffset(2) + "]]"); + // b.declaration(typeConditionProfile, "profile", + // CodeTreeBuilder.createBuilder().string("conditionProfiles[").tree(createBranchProfileIndex(vars, + // 0)).string("]")); // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) TypeSystemData data = ctx.getData().getTypeSystem(); @@ -101,12 +86,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("sp -= 1"); - b.startIf().startCall("profile", "profile").string("cond").end(2); + // b.startIf().startCall("profile", "profile").string("cond").end(2); + b.startIf().string("cond").end(); b.startBlock(); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.statement("continue loop"); b.end().startElseBlock(); - b.startAssign(vars.bci).tree(createBranchTarget(vars)).end(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0)).end(); b.statement("continue loop"); b.end(); @@ -122,12 +108,4 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_BRANCH_COND"), - createBranchTarget(vars) - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index cd3c81ca153e..606869116229 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -1,44 +1,69 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; import java.util.List; import javax.lang.model.element.ExecutableElement; -import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs.LocalRefHandle; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public class CustomInstruction extends Instruction { - public enum DataKind { - BITS, - CONST, - CHILD, - CONTINUATION, - } private final SingleOperationData data; protected ExecutableElement executeMethod; - private DataKind[] dataKinds = null; - private int numChildNodes; - private int numConsts; private OperationsBytecodeNodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; private CodeExecutableElement getSpecializationBits; private final List quickenedVariants = new ArrayList<>(); - private int boxingEliminationBitOffset; + private CodeTree boxingEliminationBitOffset; private int boxingEliminationBitMask; - private ArrayList localRefIndices; public SingleOperationData getData() { return data; @@ -60,104 +85,38 @@ public void setExecuteMethod(ExecutableElement executeMethod) { this.executeMethod = executeMethod; } - private static InputType[] createInputs(SingleOperationData data) { - MethodProperties props = data.getMainProperties(); - InputType[] inputs = new InputType[props.numStackValues]; - for (int i = 0; i < inputs.length; i++) { - inputs[i] = InputType.STACK_VALUE; - } - - if (props.isVariadic) { - inputs[inputs.length - 1] = InputType.VARARG_VALUE; - } - - return inputs; - } - public CustomInstruction(String name, int id, SingleOperationData data) { - super(name, id, data.getMainProperties().returnsValue - ? new ResultType[]{ResultType.STACK_VALUE} - : new ResultType[]{}, createInputs(data)); - this.data = data; - } - - protected CustomInstruction(String name, int id, SingleOperationData data, ResultType[] results, InputType[] inputs) { - super(name, id, results, inputs); + super(name, id, data.getMainProperties().returnsValue ? 1 : 0); this.data = data; + initializePops(); } - @Override - protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { - if (getAdditionalStateBytes() == 0) { - return null; - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + protected void initializePops() { + MethodProperties props = data.getMainProperties(); - int lengthWithoutState = lengthWithoutState(); - - b.lineComment("additionalData = " + dataKinds.length + " bytes: " + List.of(dataKinds)); - b.lineComment(" numChildNodes = " + numChildNodes); - b.lineComment(" numConsts = " + numConsts); - - for (int i = 0; i < dataKinds.length; i++) { - CodeTree index = b.create().variable(vars.bci).string(" + " + lengthWithoutState + " + " + i).build(); - switch (dataKinds[i]) { - case BITS: - b.startStatement(); - b.variable(vars.bc).string("[").tree(index).string("] = 0"); - b.end(); - break; - case CHILD: - b.startStatement(); - b.variable(vars.bc); - b.string("[").tree(index).string("] = "); - b.startCall("createChildNodes").string("" + numChildNodes).end(); - b.end(); - break; - case CONST: - b.startAssign("int constantOffset").startCall(vars.consts, "reserve").string("" + numConsts).end(2); - - b.startStatement(); - b.variable(vars.bc); - b.string("[").tree(index).string("] = "); - b.startGroup().cast(new CodeTypeMirror(TypeKind.SHORT)).string("constantOffset").end(); - b.end(); - break; - case CONTINUATION: - break; - default: - throw new UnsupportedOperationException("unexpected value: " + dataKinds[i]); + if (props.isVariadic) { + setVariadic(); + for (int i = 0; i < props.numStackValues - 1; i++) { + addPopSimple("arg" + i); + } + } else { + for (int i = 0; i < props.numStackValues; i++) { + addPopIndexed("arg" + i); } - - b.end(); } - int iLocal = 0; - for (int localIndex : localRefIndices) { - b.startStatement().startCall(vars.consts, "setValue"); - b.string("constantOffset + " + localIndex); - - if (data.getMainProperties().numLocalReferences == -1) { - b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "createArray"); - b.startCall("getLocalIndices"); - b.startGroup().variable(vars.operationData).string(".localReferences").end(); - b.end(2); - } else { - b.startStaticCall(OperationGeneratorUtils.getTypes().LocalSetter, "create"); - b.startCall("getLocalIndex"); - b.startGroup().variable(vars.operationData).string(".localReferences[" + (iLocal++) + "]").end(); - b.end(2); + if (props.numLocalReferences == -1) { + addLocalRun("localRefs"); + } else { + for (int i = 0; i < props.numLocalReferences; i++) { + addLocal("local" + i); } - b.end(2); } - - return b.build(); } - @Override - public boolean standardPrologue() { - return false; + protected CustomInstruction(String name, int id, SingleOperationData data, int pushCount) { + super(name, id, pushCount); + this.data = data; } @Override @@ -168,9 +127,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (data.getMainProperties().isVariadic) { - b.declaration("int", "numVariadics", "bc[bci + " + getArgumentOffset(inputs.length - 1) + "]"); + b.declaration("int", "numVariadics", createVariadicIndex(vars)); - int additionalInputs = inputs.length - 1; + int additionalInputs = data.getMainProperties().numStackValues - 1; int inputIndex = 0; CodeTree[] inputTrees = new CodeTree[data.getMainProperties().parameters.size()]; @@ -196,7 +155,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } } - if (results.length > 0) { + if (numPushedValues > 0) { b.startAssign("Object result"); } else { b.startStatement(); @@ -209,9 +168,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.trees(inputTrees); b.end(2); - b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + ", results.length > 0 ? "1" : "0").end(); + b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + " + numPushedValues).end(); - if (results.length > 0) { + if (numPushedValues > 0) { b.startStatement().startCall(vars.frame, "setObject"); b.string("sp - 1"); b.string("result"); @@ -226,7 +185,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.sp); b.end(2); - b.startAssign(vars.sp).variable(vars.sp).string(" - " + this.numPopStatic() + " + " + this.numPush()).end(); + b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues).end(); } return b.build(); @@ -247,60 +206,6 @@ protected void createTracerCode(ExecutionVariables vars, CodeTreeBuilder b) { } } - @Override - public int getAdditionalStateBytes() { - if (dataKinds == null) { - throw new UnsupportedOperationException("state bytes not yet initialized"); - } - - return dataKinds.length; - } - - public void setDataKinds(DataKind[] dataKinds) { - this.dataKinds = dataKinds; - } - - @Override - public String dumpInfo() { - StringBuilder sb = new StringBuilder(super.dumpInfo()); - - sb.append(" Additional Data:\n"); - int ofs = -1; - for (DataKind kind : dataKinds) { - ofs += 1; - if (kind == DataKind.CONTINUATION) { - continue; - } - sb.append(" ").append(ofs).append(" ").append(kind).append("\n"); - } - - sb.append(" Specializations:\n"); - for (SpecializationData sd : data.getNodeData().getSpecializations()) { - sb.append(" ").append(sd.getId()).append("\n"); - } - - sb.append(" Num children: ").append(numChildNodes).append("\n"); - sb.append(" Num constants: ").append(numConsts).append("\n"); - - return sb.toString(); - } - - public void setNumChildNodes(int numChildNodes) { - this.numChildNodes = numChildNodes; - } - - public void setNumConsts(List consts) { - this.numConsts = consts.size(); - this.localRefIndices = new ArrayList<>(); - int i = 0; - for (Object c : consts) { - if (c instanceof LocalRefHandle) { - localRefIndices.add(i); - } - i++; - } - } - public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { this.prepareAOTMethod = prepareAOTMethod; } @@ -309,19 +214,19 @@ public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits this.getSpecializationBits = getSpecializationBits; } - public void setBoxingEliminationData(int boxingEliminationBitOffset, int boxingEliminationBitMask) { + public void setBoxingEliminationData(CodeTree boxingEliminationBitOffset, int boxingEliminationBitMask) { this.boxingEliminationBitOffset = boxingEliminationBitOffset; this.boxingEliminationBitMask = boxingEliminationBitMask; } @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.SET_BIT; + return numPushedValues > 0 ? BoxingEliminationBehaviour.SET_BIT : BoxingEliminationBehaviour.DO_NOTHING; } @Override - public int boxingEliminationBitOffset() { - return boxingEliminationBitOffset; + public CodeTree boxingEliminationBitOffset() { + return boxingEliminationBitOffset == null ? CodeTreeBuilder.singleString("0") : boxingEliminationBitOffset; } @Override @@ -343,22 +248,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - return CodeTreeBuilder.createBuilder().startStatement()// - .startCall("this", prepareAOTMethod) // - .string("null") // frame - .variable(vars.bci) // - .string("-1") // stack pointer - .tree(language) // - .tree(root) // - .end(2).build(); - } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - CodeTree[] result = new CodeTree[2]; - result[0] = CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_CUSTOM"); - result[1] = CodeTreeBuilder.createBuilder().startStaticCall(getSpecializationBits).variable(vars.bc).variable(vars.bci).end().build(); - return result; + return CodeTreeBuilder.createBuilder().startStatement().startCall("this", prepareAOTMethod).string("null").variable(vars.bci).string("-1").tree(language).tree(root).end(2).build(); } public void addQuickenedVariant(QuickenedInstruction quick) { @@ -368,9 +258,4 @@ public void addQuickenedVariant(QuickenedInstruction quick) { public List getQuickenedVariants() { return quickenedVariants; } - - @Override - public int numLocalReferences() { - return data.getMainProperties().numLocalReferences; - } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 1bf9d7d8458d..b97d64dc6168 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -44,13 +44,9 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; public class DiscardInstruction extends Instruction { - public DiscardInstruction(String name, int id, InputType input) { - super(name, id, new ResultType[0], input); - } - - @Override - public boolean standardPrologue() { - return false; + public DiscardInstruction(String name, int id) { + super(name, id, 0); + addPopSimple("value"); } @Override @@ -76,10 +72,4 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_OTHER") - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index bd7494eb53bc..148efe9fdf69 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -41,17 +41,17 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; +import java.util.Set; -import javax.lang.model.type.TypeKind; +import javax.lang.model.element.Modifier; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; @@ -73,536 +73,452 @@ public static class ExecutionVariables { public CodeVariableElement tracer; } - public enum InputType { - STACK_VALUE(1), - STACK_VALUE_IGNORED(0), - VARARG_VALUE(1), - CONST_POOL(1), - LOCAL(1), - ARGUMENT(1), - INSTRUMENT(1), - BRANCH_PROFILE(1), - BRANCH_TARGET(1); - - final int argumentLength; - - InputType(int argumentLength) { - this.argumentLength = argumentLength; - } - - public final TypeMirror getDefaultExecutionType(ProcessorContext context) { - switch (this) { - case STACK_VALUE_IGNORED: - return null; - case STACK_VALUE: - case CONST_POOL: - case LOCAL: - case ARGUMENT: - return context.getType(Object.class); - case VARARG_VALUE: - return new ArrayCodeTypeMirror(context.getType(Object.class)); - case BRANCH_PROFILE: - return context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); - case BRANCH_TARGET: - case INSTRUMENT: - return context.getType(short.class); - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } - } + public static class EmitArguments { + public CodeTree[] constants; + public CodeTree[] children; + public CodeTree[] locals; + public CodeTree[] localRuns; + public CodeTree[] branchTargets; + public CodeTree variadicCount; + public CodeTree[] arguments; + } - boolean needsBuilderArgument() { - switch (this) { - case STACK_VALUE: - case STACK_VALUE_IGNORED: - case VARARG_VALUE: - case BRANCH_PROFILE: - return false; - case CONST_POOL: - case LOCAL: - case ARGUMENT: - case BRANCH_TARGET: - case INSTRUMENT: - return true; - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } - } + public enum BoxingEliminationBehaviour { + DO_NOTHING, + SET_BIT, + REPLACE + } - public final TypeMirror getDefaultBuilderType(ProcessorContext context) { - switch (this) { - case STACK_VALUE: - case STACK_VALUE_IGNORED: - case VARARG_VALUE: - case INSTRUMENT: - case BRANCH_PROFILE: - return null; - case CONST_POOL: - return context.getType(Object.class); - case LOCAL: - return context.getTypes().OperationLocal; - case ARGUMENT: - return context.getType(int.class); - case BRANCH_TARGET: - return context.getTypes().OperationLabel; - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } - } + private final ProcessorContext context = ProcessorContext.getInstance(); + private final TruffleTypes types = context.getTypes(); - public final CodeTree getImplicitValue(BuilderVariables vars, Instruction instr) { - switch (this) { - case STACK_VALUE: - case STACK_VALUE_IGNORED: - case CONST_POOL: - case LOCAL: - case ARGUMENT: - case BRANCH_TARGET: - case INSTRUMENT: - return null; - case BRANCH_PROFILE: - return CodeTreeBuilder.singleString("ConditionProfile.createCountingProfile()"); - case VARARG_VALUE: - return CodeTreeBuilder.createBuilder().variable(vars.numChildren).string(" - " + instr.numStackValuesExclVarargs()).build(); - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } + public final String name; + public final int id; + public final int numPushedValues; + + private final String internalName; + + // --------------------- arguments ------------------------ + + private List constants = new ArrayList<>(); + private List constantTypes = new ArrayList<>(); + private List children = new ArrayList<>(); + private List locals = new ArrayList<>(); + private List localRuns = new ArrayList<>(); + private List arguments = new ArrayList<>(); + private List popIndexed = new ArrayList<>(); + private List popSimple = new ArrayList<>(); + private boolean isVariadic; + private List branchTargets = new ArrayList<>(); + private List branchProfiles = new ArrayList<>(); + private List stateBits = new ArrayList<>(); + private List instruments = new ArrayList<>(); + + private static final String CONSTANT_OFFSET_SUFFIX = "_CONSTANT_OFFSET"; + private static final String CHILDREN_OFFSET_SUFFIX = "_CHILDREN_OFFSET"; + private static final String LOCALS_OFFSET_SUFFIX = "_LOCALS_OFFSET"; + private static final String LOCAL_RUNS_OFFSET_SUFFIX = "_LOCAL_RUNS_OFFSET"; + private static final String ARGUMENT_OFFSET_SUFFIX = "_ARGUMENT_OFFSET"; + private static final String POP_INDEXED_OFFSET_SUFFIX = "_POP_INDEXED_OFFSET"; + private static final String VARIADIC_OFFSET_SUFFIX = "_VARIADIC_OFFSET"; + private static final String BRANCH_TARGET_OFFSET_SUFFIX = "_BRANCH_TARGET_OFFSET"; + private static final String BRANCH_PROFILE_OFFSET_SUFFIX = "_BRANCH_PROFILE_OFFSET"; + private static final String STATE_BITS_OFFSET_SUFFIX = "_STATE_BITS_OFFSET"; + private static final String LENGTH_SUFFIX = "_LENGTH"; + + private static int addInstructionArgument(List holder, Object marker) { + int index = -1; + + if (marker != null) { + index = holder.indexOf(marker); } - public CodeTree createDumpCode(int n, Instruction op, ExecutionVariables vars) { - switch (this) { - case STACK_VALUE: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("pop[-%d]").startGroup().variable(vars.bc).string( - "[").variable(vars.bci).string(" + " + op.getArgumentOffset(n) + "]").end().end(3).build(); - case STACK_VALUE_IGNORED: - return CodeTreeBuilder.createBuilder().statement("sb.append(\"_\")").build(); - case CONST_POOL: - return CodeTreeBuilder.createBuilder().startBlock().declaration("Object", "o", - CodeTreeBuilder.createBuilder().variable(vars.consts).string("[").tree(op.createReadArgumentCode(n, vars)).string("]").build()).startStatement().startCall("sb", - "append").startCall("String", "format").doubleQuote("%s %s").string("o.getClass().getSimpleName()").string("o").end(4).build(); - case LOCAL: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("loc[%d]").tree(op.createReadArgumentCode(n, vars)).end( - 3).build(); - case ARGUMENT: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("arg[%d]").tree(op.createReadArgumentCode(n, vars)).end( - 3).build(); - case BRANCH_TARGET: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("%04x").tree(op.createReadArgumentCode(n, vars)).end( - 3).build(); - case INSTRUMENT: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("instrument[%d]").tree( - op.createReadArgumentCode(n, vars)).end(3).build(); - case VARARG_VALUE: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("**%d").tree(op.createReadArgumentCode(n, vars)).end( - 3).build(); - case BRANCH_PROFILE: - return null; - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } + if (index == -1) { + index = holder.size(); + holder.add(marker); } + return index; + } - boolean isStackValue() { - return this == STACK_VALUE || this == STACK_VALUE_IGNORED; + public int addConstant(Object marker, TypeMirror type) { + int result = addInstructionArgument(constants, marker); + if (result == constantTypes.size()) { + constantTypes.add(type); } + return result; } - public enum ResultType { - STACK_VALUE(0), - SET_LOCAL(1), - BRANCH(0), - RETURN(0); + public int addChild(Object marker) { + return addInstructionArgument(children, marker); + } - final int argumentLength; + public int addLocal(Object marker) { + return addInstructionArgument(locals, marker); + } - ResultType(int argumentLength) { - this.argumentLength = argumentLength; - } + public int addLocalRun(Object marker) { + return addInstructionArgument(localRuns, marker); + } - boolean needsBuilderArgument() { - switch (this) { - case STACK_VALUE: - case BRANCH: - case RETURN: - return false; - case SET_LOCAL: - return true; - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } + public int addArgument(Object marker) { + return addInstructionArgument(arguments, marker); + } + + public int addPopIndexed(Object marker) { + if (isVariadic) { + throw new AssertionError("variadic cannot have indexed pops in variadic"); + } + if (!popSimple.isEmpty()) { + throw new AssertionError("cannot mix simple and indexed pops"); } + return addInstructionArgument(popIndexed, marker); + } - public final TypeMirror getDefaultBuilderType(ProcessorContext context) { - switch (this) { - case STACK_VALUE: - case BRANCH: - case RETURN: - return null; - case SET_LOCAL: - return context.getTypes().OperationLocal; - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } + public int addPopSimple(Object marker) { + if (!popIndexed.isEmpty()) { + throw new AssertionError("cannot mix simple and indexed pops"); } + return addInstructionArgument(popSimple, marker); + } - public CodeTree createDumpCode(int i, Instruction op, ExecutionVariables vars) { - switch (this) { - case STACK_VALUE: - return CodeTreeBuilder.createBuilder().statement("sb.append(\"x\")").build(); - case BRANCH: - return CodeTreeBuilder.createBuilder().statement("sb.append(\"branch\")").build(); - case RETURN: - return CodeTreeBuilder.createBuilder().statement("sb.append(\"return\")").build(); - case SET_LOCAL: - return CodeTreeBuilder.createBuilder().startStatement().startCall("sb", "append").startCall("String", "format").doubleQuote("loc[%d]").tree( - op.createReadArgumentCode(i + op.inputs.length, vars)).end(3).build(); - default: - throw new IllegalArgumentException("Unexpected value: " + this); - } + public void setVariadic() { + if (!popIndexed.isEmpty()) { + throw new AssertionError("variadic cannot have indexed pops in variadic"); } + isVariadic = true; } - public enum BoxingEliminationBehaviour { - DO_NOTHING, - SET_BIT, - REPLACE + public int addBranchTarget(Object marker) { + return addInstructionArgument(branchTargets, marker); } - public final String name; - public final int id; - public final InputType[] inputs; - public final ResultType[] results; + public int addBranchProfile(Object marker) { + return addInstructionArgument(branchProfiles, marker); + } - @SuppressWarnings("unused") - public CodeTree createStackEffect(BuilderVariables vars, CodeTree[] arguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - int result = 0; - int argIndex = 0; - - for (InputType input : inputs) { - if (input == InputType.STACK_VALUE) { - result--; - } else if (input == InputType.VARARG_VALUE) { - b.string("-").startParantheses().tree(arguments[argIndex]).end().string(" + "); - } - argIndex++; - } + public int addStateBits(Object marker) { + return addInstructionArgument(stateBits, marker); + } - for (ResultType rt : results) { - if (rt == ResultType.STACK_VALUE) { - result++; - } - } + public int addInstrument(Object marker) { + return addInstructionArgument(instruments, marker); + } - return b.string("" + result).build(); + private int getConstantsOffset() { + return opcodeLength(); } - public CodeVariableElement opcodeIdField; + private int getChildrenOffset() { + return getConstantsOffset() + (constants.isEmpty() ? 0 : 1); + } - public void setOpcodeIdField(CodeVariableElement opcodeIdField) { - this.opcodeIdField = opcodeIdField; + private int getLocalsOffset() { + return getChildrenOffset() + (children.isEmpty() ? 0 : 1); } - Instruction(String name, int id, ResultType result, InputType... inputs) { - this.name = name; - this.id = id; - this.results = new ResultType[]{result}; - this.inputs = inputs; + private int getLocalRunsOffset() { + return getLocalsOffset() + locals.size(); } - Instruction(String name, int id, ResultType[] results, InputType... inputs) { - this.name = name; - this.id = id; - this.results = results; - this.inputs = inputs; + private int getArgumentsOffset() { + return getLocalRunsOffset() + localRuns.size() * 2; } - public int numStackValuesExclVarargs() { - int result = 0; - for (int i = 0; i < inputs.length; i++) { - if (inputs[i] == InputType.STACK_VALUE) { - result++; - } + private int getPopIndexedOffset() { + return getArgumentsOffset() + arguments.size(); + } + + private int getVariadicOffset() { + return getPopIndexedOffset(); // they are always same since we can never have both + } + + private int getBranchTargetsOffset() { + if (isVariadic) { + return getVariadicOffset() + 1; + } else { + return getPopIndexedOffset() + ((popIndexed.size() + 1) / 2); } + } - return result; + private int getBranchProfileOffset() { + return getBranchTargetsOffset() + branchTargets.size(); } - public TypeMirror[] expectedInputTypes(ProcessorContext context) { - TypeMirror[] result = new TypeMirror[inputs.length]; + private int getStateBitsOffset() { + return getBranchProfileOffset() + (branchProfiles.isEmpty() ? 0 : 1); + } - for (int i = 0; i < inputs.length; i++) { - result[i] = inputs[i].getDefaultExecutionType(context); - } - return result; + public CodeTree createStateBitsOffset(int index) { + return CodeTreeBuilder.singleString(internalName + STATE_BITS_OFFSET_SUFFIX + " + " + index); } - public final CodeTree createReadArgumentCode(int n, ExecutionVariables vars) { - if (!isArgumentInBytecode(n)) { - return null; - } + private int getInstrumentsOffset() { + return getStateBitsOffset() + stateBits.size(); + } - return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("]").build(); + private int length() { + return getInstrumentsOffset() + instruments.size(); } - public final CodeTree createWriteArgumentCode(int n, BuilderVariables vars, CodeTree val) { - if (!isArgumentInBytecode(n)) { - return null; - } + private CodeTree createIndirectIndex(ExecutionVariables vars, String suffix, int index) { + return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + internalName + suffix + "] + " + index).build(); + } + + private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int index) { + return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + internalName + suffix + " + " + index + "]").build(); + } - CodeTree value = val; + public CodeTree createConstantIndex(ExecutionVariables vars, int index) { + return createIndirectIndex(vars, CONSTANT_OFFSET_SUFFIX, index); + } - if (n < inputs.length && inputs[n] == InputType.BRANCH_TARGET) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("createOffset").startGroup().variable(vars.bci).string(" + " + getArgumentOffset(n)).end().tree(value).end(2).build(); - } + public CodeTree createChildIndex(ExecutionVariables vars, int index) { + return createIndirectIndex(vars, CHILDREN_OFFSET_SUFFIX, index); + } - if (n < inputs.length && inputs[n] == InputType.STACK_VALUE) { - int svIndex = 0; - for (int i = 0; i < n; i++) { - if (inputs[i].isStackValue()) { - svIndex++; - } - } + public CodeTree createLocalIndex(ExecutionVariables vars, int index) { + return createDirectIndex(vars, LOCALS_OFFSET_SUFFIX, index); + } - return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ").string( - "predecessorBcis[" + svIndex + "] < ").variable(vars.bci).string(" - 255").string(" ? 0").string(" : (byte)(").variable(vars.bci).string( - " - predecessorBcis[" + svIndex + "])").end().build(); - } + public CodeTree createArgumentIndex(ExecutionVariables vars, int index) { + return createDirectIndex(vars, ARGUMENT_OFFSET_SUFFIX, index); + } - if (n < inputs.length && inputs[n] == InputType.VARARG_VALUE) { - value = CodeTreeBuilder.createBuilder().startParantheses().variable(vars.numChildren).string(" - " + numStackValuesExclVarargs()).end().build(); - } + public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (n < inputs.length && inputs[n] == InputType.BRANCH_PROFILE) { - value = CodeTreeBuilder.singleString("createBranchProfile()"); + b.startParantheses(); + if (index % 2 == 1) { + b.startParantheses(); } - if (n < inputs.length && inputs[n] == InputType.CONST_POOL) { - value = CodeTreeBuilder.createBuilder().startCall(vars.consts, "add").tree(value).end().build(); - } + b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2)); - if ((n < inputs.length && inputs[n] == InputType.LOCAL) || (n >= inputs.length && results[n - inputs.length] == ResultType.SET_LOCAL)) { - value = CodeTreeBuilder.createBuilder().startCall("getLocalIndex").tree(value).end().build(); + if (index % 2 == 1) { + b.string(" >> 8").end(); } - return CodeTreeBuilder.createBuilder().startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(n)).string("] = ").cast( - new CodeTypeMirror(TypeKind.SHORT)).cast(new CodeTypeMirror(TypeKind.INT)).tree(value).end().build(); + b.string(" & 0xff").end(); + + return b.build(); } - public int opcodeLength() { - return 1; + public CodeTree createVariadicIndex(ExecutionVariables vars) { + return createDirectIndex(vars, VARIADIC_OFFSET_SUFFIX, 0); } - public int getArgumentOffset(int index) { - int res = opcodeLength(); - for (int i = 0; i < index; i++) { - if (i < inputs.length) { - res += inputs[i].argumentLength; - } else { - res += results[i - inputs.length].argumentLength; - } - } - return res; + public CodeTree createBranchTargetIndex(ExecutionVariables vars, int index) { + return createDirectIndex(vars, BRANCH_TARGET_OFFSET_SUFFIX, index); } - public int getStackValueArgumentOffset(int index) { - int svIndex = 0; - for (int i = 0; i < inputs.length; i++) { - if (inputs[i].isStackValue()) { - if (svIndex == index) { - return getArgumentOffset(i); - } else { - svIndex++; - } - } - } + public CodeTree createBranchProfileIndex(ExecutionVariables vars, int index) { + return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index); + } - throw new AssertionError("should not reach here"); + public CodeTree createStateBitsIndex(ExecutionVariables vars, int index) { + return createDirectIndex(vars, STATE_BITS_OFFSET_SUFFIX, index); } - public boolean isArgumentInBytecode(int index) { - if (index < inputs.length) { - return inputs[index].argumentLength > 0; - } else { - return results[index - inputs.length].argumentLength > 0; - } + public CodeTree createLength() { + return CodeTreeBuilder.singleString(internalName + LENGTH_SUFFIX); } - public boolean needsBuilderArgument(int index) { - if (index < inputs.length) { - return inputs[index].needsBuilderArgument(); - } else { - return results[index - inputs.length].needsBuilderArgument(); - } + public int numLocals() { + return locals.size(); } - public int lengthWithoutState() { - return getArgumentOffset(inputs.length + results.length); + public int numLocalRuns() { + return localRuns.size(); } - public int length() { - return lengthWithoutState() + getAdditionalStateBytes(); + public int numArguments() { + return arguments.size(); } - public List getBuilderArgumentTypes() { - ProcessorContext context = ProcessorContext.getInstance(); - List result = new ArrayList<>(); + public int numBranchTargets() { + return branchTargets.size(); + } - for (int i = 0; i < inputs.length; i++) { - TypeMirror m = inputs[i].getDefaultBuilderType(context); - if (m != null) { - result.add(m); - } - } - for (int i = 0; i < results.length; i++) { - TypeMirror m = results[i].getDefaultBuilderType(context); - if (m != null) { - result.add(m); - } - } + public CodeVariableElement opcodeIdField; - return result; + public void setOpcodeIdField(CodeVariableElement opcodeIdField) { + this.opcodeIdField = opcodeIdField; + } + + Instruction(String name, int id, int numPushedValues) { + this.name = name; + this.id = id; + this.internalName = OperationGeneratorUtils.toScreamCase(name); + this.numPushedValues = numPushedValues; + + this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.STATIC, Modifier.FINAL), context.getType(int.class), "INSTR_" + internalName); + opcodeIdField.createInitBuilder().string("" + id); + } + + public int opcodeLength() { + return 1; } @SuppressWarnings("unused") - protected CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { + protected CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments args) { return null; } @SuppressWarnings("unused") - protected CodeTree createCustomEmitCodeAfter(BuilderVariables vars, CodeTree[] arguments) { + protected CodeTree createCustomEmitCodeAfter(BuilderVariables vars, EmitArguments args) { return null; } - public final CodeTree createEmitCode(BuilderVariables vars, CodeTree[] arguments) { + public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(createCustomEmitCode(vars, arguments)); + b.tree(createCustomEmitCode(vars, args)); + + CodeTree numPop; - // calculate stack offset - int numPush = numPush(); - CodeTree numPop = numPop(vars); + if (isVariadic) { + numPop = CodeTreeBuilder.createBuilder().tree(args.variadicCount).string(" + " + popSimple.size()).build(); + } else { + numPop = CodeTreeBuilder.singleString(popSimple.size() + popIndexed.size() + ""); + } - assert numPush == 1 || numPush == 0; + if (popIndexed.size() > 0) { + b.startAssign("int[] predecessorBcis"); + } else { + b.startStatement(); + } - b.startAssign("int[] predecessorBcis"); b.startCall("doBeforeEmitInstruction"); b.tree(numPop); - b.string(numPush == 0 ? "false" : "true"); + b.string(numPushedValues == 0 ? "false" : "true"); b.end(2); // emit opcode b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, opcodeIdField)); - // emit arguments - int argIndex = 0; - for (int i = 0; i < inputs.length + results.length; i++) { - CodeTree argument = needsBuilderArgument(i) ? arguments[argIndex++] : null; - b.tree(createWriteArgumentCode(i, vars, argument)); + if (!constants.isEmpty()) { + b.startAssign("int constantsStart"); + b.startCall(vars.consts, "reserve").string("" + constants.size()).end(); + b.end(); + + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); + + if (args.constants != null) { + for (int i = 0; i < args.constants.length; i++) { + if (args.constants[i] != null) { + b.startStatement().startCall(vars.consts, "setValue"); + b.string("constantsStart + " + i); + b.tree(args.constants[i]); + b.end(2); + } + } + } } - // emit state bytes - - b.tree(createInitializeAdditionalStateBytes(vars, arguments)); + if (!children.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); + b.startCall("createChildNodes").string("" + children.size()).end(); + b.end(); + } - b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + for (int i = 0; i < locals.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalsOffset() + " + " + i + "] = (short) "); + b.startCall("getLocalIndex").tree(args.locals[i]).end(); + b.end(); + } - b.tree(createCustomEmitCodeAfter(vars, arguments)); + for (int i = 0; i < localRuns.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2) + "] = (short) "); + b.startCall("getLocalRunStart").tree(args.localRuns[i]).end(); + b.end(); - return b.build(); - } + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2 + 1) + "] = (short) "); + b.startCall("getLocalRunLength").tree(args.localRuns[i]).end(); + b.end(); + } - public int numPush() { - int stackPush = 0; - for (ResultType r : results) { - if (r == ResultType.STACK_VALUE) { - stackPush++; + if (isVariadic) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getVariadicOffset() + "] = (short) "); + b.startParantheses().tree(args.variadicCount).end(); + b.end(); + } else { + for (int i = 0; i < popIndexed.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getPopIndexedOffset() + " + " + (i / 2) + "] "); + if (i % 2 == 1) { + b.string("|"); + } + b.string("= (short) ((").variable(vars.bci).string(" - predecessorBcis[" + i + "] < 256 ? ").variable(vars.bci).string(" - predecessorBcis[" + i + "] : 0)"); + if (i % 2 == 1) { + b.string(" << 8"); + } + b.string(")").end(); } } - return stackPush; - } - public boolean isVariadic() { - for (InputType i : inputs) { - if (i == InputType.VARARG_VALUE) { - return true; - } + for (int i = 0; i < branchTargets.size(); i++) { + b.startStatement().startCall("putBranchTarget"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + getBranchTargetsOffset() + " + " + i).end(); + b.tree(args.branchTargets[i]); + b.end(2); } - return false; - } + // todo: condition profiles - public int numPopStatic() { - int stackPop = 0; - for (InputType i : inputs) { - if (i == InputType.STACK_VALUE || i == InputType.STACK_VALUE_IGNORED) { - stackPop++; - } else if (i == InputType.VARARG_VALUE) { - throw new UnsupportedOperationException("number of pops not static"); - } + for (int i = 0; i < stateBits.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getStateBitsOffset() + " + " + i + "] = 0").end(); } - return stackPop; - } - public CodeTree numPop(BuilderVariables vars) { - int stackPop = 0; - for (InputType i : inputs) { - if (i == InputType.STACK_VALUE || i == InputType.STACK_VALUE_IGNORED) { - stackPop++; - } else if (i == InputType.VARARG_VALUE) { - return CodeTreeBuilder.singleVariable(vars.numChildren); - } + for (int i = 0; i < arguments.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentsOffset() + " + " + i + "] = (short) (int) "); + b.tree(args.arguments[i]); + b.end(); } - return CodeTreeBuilder.singleString("" + stackPop); - } - public abstract CodeTree createExecuteCode(ExecutionVariables vars); + // todo: instruments - public boolean isInstrumentationOnly() { - return false; - } + b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); - // state + b.tree(createCustomEmitCodeAfter(vars, args)); - public int getAdditionalStateBytes() { - return 0; + return b.build(); } - @SuppressWarnings("unused") - protected CodeTree createInitializeAdditionalStateBytes(BuilderVariables vars, CodeTree[] arguments) { - return null; + public abstract CodeTree createExecuteCode(ExecutionVariables vars); + + private static void printList(StringBuilder sb, List holder, String name) { + if (!holder.isEmpty()) { + sb.append(" ").append(name).append(":\n"); + int index = 0; + for (Object marker : holder) { + sb.append(String.format(" [%2d] %s\n", index++, marker == null ? "" : marker)); + } + } } public String dumpInfo() { StringBuilder sb = new StringBuilder(); sb.append(name).append("\n"); - sb.append(" Inputs:\n"); - for (InputType type : inputs) { - sb.append(" ").append(type).append("\n"); - } - sb.append(" Results:\n"); - for (ResultType type : results) { - sb.append(" ").append(type).append("\n"); + printList(sb, constants, "Constants"); + printList(sb, children, "Children"); + printList(sb, locals, "Locals"); + printList(sb, localRuns, "Local Runs"); + printList(sb, popIndexed, "Indexed Pops"); + printList(sb, popSimple, "Simple Pops"); + if (isVariadic) { + sb.append(" Variadic\n"); } + sb.append(" Pushed Values: ").append(numPushedValues).append("\n"); + printList(sb, branchTargets, "Branch Targets"); + printList(sb, branchProfiles, "Branch Profiles"); + printList(sb, stateBits, "State Bitsets"); return sb.toString(); } - public boolean standardPrologue() { - return true; - } - - public boolean isBranchInstruction() { - return Arrays.stream(results).anyMatch(x -> x == ResultType.BRANCH); - } - - public boolean isReturnInstruction() { - return Arrays.stream(results).anyMatch(x -> x == ResultType.RETURN); - } - public abstract BoxingEliminationBehaviour boxingEliminationBehaviour(); @SuppressWarnings("unused") @@ -610,7 +526,7 @@ public CodeVariableElement boxingEliminationReplacement(FrameKind kind) { throw new AssertionError(); } - public int boxingEliminationBitOffset() { + public CodeTree boxingEliminationBitOffset() { throw new AssertionError(); } @@ -620,25 +536,154 @@ public int boxingEliminationBitMask() { public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); - public CodeTree getPredecessorOffset(ExecutionVariables vars, int index) { - int curIndex = index; - for (int i = 0; i < inputs.length; i++) { - if (inputs[i] == InputType.STACK_VALUE || inputs[i] == InputType.STACK_VALUE_IGNORED) { - if (curIndex-- == 0) { - return CodeTreeBuilder.createBuilder().startParantheses().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(i)).string("] & 0xff").end().build(); - } + public boolean isBranchInstruction() { + return false; + } + + public boolean isInstrumentationOnly() { + return false; + } + + public List getBuilderArgumentTypes() { + ArrayList result = new ArrayList<>(); + + for (TypeMirror mir : constantTypes) { + if (mir != null) { + result.add(mir); } } - throw new AssertionError("should not reach here"); - } + for (int i = 0; i < locals.size(); i++) { + result.add(types.OperationLocal); + } - @SuppressWarnings("unused") - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[0]; + for (int i = 0; i < localRuns.size(); i++) { + result.add(new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); + } + + for (int i = 0; i < arguments.size(); i++) { + result.add(context.getType(int.class)); + } + + for (int i = 0; i < branchTargets.size(); i++) { + result.add(types.OperationLabel); + } + + return result; } public int numLocalReferences() { return 0; } + + public int numPopStatic() { + return popIndexed.size() + popSimple.size(); + } + + private static void sbAppend(CodeTreeBuilder b, String format, Runnable r) { + b.startStatement().startCall("sb", "append"); + b.startCall("String", "format"); + b.doubleQuote(format); + r.run(); + b.end(3); + } + + public CodeTree createDumpCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + for (int i = 0; i < length(); i++) { + int ic = i; + sbAppend(b, " %04x", () -> b.startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + ic + "]").end()); + } + + for (int i = length(); i < 8; i++) { + b.startStatement().startCall("sb", "append").doubleQuote(" ").end(2); + } + + b.startStatement().startCall("sb", "append").doubleQuote(name + " ".repeat(name.length() < 30 ? 30 - name.length() : 0)).end(2); + + for (int i = 0; i < constants.size(); i++) { + int ci = i; + sbAppend(b, " const(%s)", () -> b.startGroup().variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]").end()); + } + + for (int i = 0; i < locals.size(); i++) { + int ci = i; + sbAppend(b, " local(%s)", () -> b.startGroup().tree(createLocalIndex(vars, ci)).end()); + } + + for (int i = 0; i < arguments.size(); i++) { + int ci = i; + sbAppend(b, " arg(%s)", () -> b.startGroup().tree(createArgumentIndex(vars, ci)).end()); + } + + for (int i = 0; i < popIndexed.size(); i++) { + int ci = i; + sbAppend(b, " pop(-%s)", () -> b.startGroup().tree(createPopIndexedIndex(vars, ci)).end()); + } + + if (isVariadic) { + sbAppend(b, " var(%s)", () -> b.startGroup().tree(createVariadicIndex(vars)).end()); + } + + for (int i = 0; i < branchTargets.size(); i++) { + int ci = i; + sbAppend(b, " branch(%04x)", () -> b.startGroup().tree(createBranchTargetIndex(vars, ci)).end()); + } + + return b.build(); + + } + + private CodeVariableElement createConstant(String constantName, int value) { + CodeVariableElement result = new CodeVariableElement( + Set.of(Modifier.STATIC, Modifier.FINAL), + context.getType(int.class), + constantName); + result.createInitBuilder().string("" + value); + + return result; + } + + public List createInstructionFields() { + List result = new ArrayList<>(); + result.add(opcodeIdField); + if (!constants.isEmpty()) { + result.add(createConstant(internalName + CONSTANT_OFFSET_SUFFIX, getConstantsOffset())); + } + if (!children.isEmpty()) { + result.add(createConstant(internalName + CHILDREN_OFFSET_SUFFIX, getChildrenOffset())); + } + if (!localRuns.isEmpty()) { + result.add(createConstant(internalName + LOCAL_RUNS_OFFSET_SUFFIX, getLocalRunsOffset())); + } + if (!arguments.isEmpty()) { + result.add(createConstant(internalName + ARGUMENT_OFFSET_SUFFIX, getArgumentsOffset())); + } + if (!locals.isEmpty()) { + result.add(createConstant(internalName + LOCALS_OFFSET_SUFFIX, getLocalsOffset())); + } + if (!popIndexed.isEmpty()) { + result.add(createConstant(internalName + POP_INDEXED_OFFSET_SUFFIX, getPopIndexedOffset())); + } + if (isVariadic) { + result.add(createConstant(internalName + VARIADIC_OFFSET_SUFFIX, getVariadicOffset())); + } + if (!branchTargets.isEmpty()) { + result.add(createConstant(internalName + BRANCH_TARGET_OFFSET_SUFFIX, getBranchTargetsOffset())); + } + if (!branchProfiles.isEmpty()) { + result.add(createConstant(internalName + BRANCH_PROFILE_OFFSET_SUFFIX, getBranchProfileOffset())); + } + if (!stateBits.isEmpty()) { + result.add(createConstant(internalName + STATE_BITS_OFFSET_SUFFIX, getStateBitsOffset())); + } + result.add(createConstant(internalName + LENGTH_SUFFIX, length())); + + return result; + } + + public boolean isVariadic() { + return isVariadic; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index cc9ff4e40c57..5b096afa7ae0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -46,7 +46,8 @@ public class InstrumentationEnterInstruction extends Instruction { public InstrumentationEnterInstruction(int id) { - super("instrument.enter", id, new ResultType[0], InputType.INSTRUMENT); + super("instrument.enter", id, 0); + addInstrument("instrument"); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 9ccea62825e5..9623eda5fa45 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -48,14 +48,16 @@ public class InstrumentationExitInstruction extends Instruction { private final boolean returnsValue; public InstrumentationExitInstruction(int id) { - super("instrument.exit.void", id, new ResultType[0], InputType.INSTRUMENT); + super("instrument.exit.void", id, 0); this.returnsValue = false; + addInstrument("instrument"); } public InstrumentationExitInstruction(int id, boolean returnsValue) { - super("instrument.exit", id, ResultType.STACK_VALUE, InputType.INSTRUMENT, InputType.STACK_VALUE); + super("instrument.exit", id, 0); assert returnsValue; this.returnsValue = true; + addInstrument("instrument"); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index 802423dc44c0..810380c2d4f8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -45,7 +45,10 @@ public class InstrumentationLeaveInstruction extends Instruction { public InstrumentationLeaveInstruction(int id) { - super("instrument.leave", id, ResultType.BRANCH, InputType.INSTRUMENT, InputType.BRANCH_TARGET, InputType.BRANCH_TARGET); + super("instrument.leave", id, 0); + addInstrument("instrument"); + addBranchTarget("startBranch"); + addBranchTarget("endBranch"); } @Override @@ -81,12 +84,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end().startElseBlock(); - b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.results[0]).variable(vars.bci).string(" + ").tree(createLength()).end(); b.end(); b.end().startElseBlock(); - b.startAssign(vars.results[0]).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.results[0]).variable(vars.bci).string(" + ").tree(createLength()).end(); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 2e5f0efc3fcf..d919201c2209 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -51,14 +51,10 @@ public class LoadArgumentInstruction extends Instruction { private OperationsContext ctx; public LoadArgumentInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.argument." + kind.getTypeName().toLowerCase(), id, ResultType.STACK_VALUE, InputType.ARGUMENT); + super("load.argument." + kind.getTypeName().toLowerCase(), id, 1); this.ctx = ctx; this.kind = kind; - } - - @Override - public boolean standardPrologue() { - return false; + addArgument("argument"); } private CodeTree createGetValue(ExecutionVariables vars) { @@ -66,8 +62,7 @@ private CodeTree createGetValue(ExecutionVariables vars) { b.startCall(vars.frame, "getArguments").end(); b.string("["); - b.variable(vars.bc); - b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); + b.tree(createArgumentIndex(vars, 0)); b.string("]"); return b.build(); @@ -130,11 +125,4 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_ARGUMENT"), - CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 900f4500b328..b03f7587c627 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; @@ -51,14 +52,10 @@ public class LoadConstantInstruction extends Instruction { private final OperationsContext ctx; public LoadConstantInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.constant." + kind.toString().toLowerCase(), id, ResultType.STACK_VALUE, InputType.CONST_POOL); + super("load.constant." + kind.toString().toLowerCase(), id, 1); this.ctx = ctx; this.kind = kind; - } - - @Override - public boolean standardPrologue() { - return false; + addConstant("constant", ProcessorContext.getInstance().getType(Object.class)); } @Override @@ -83,8 +80,7 @@ private CodeTree createGetArgument(ExecutionVariables vars) { b.string("(", kind.getTypeName(), ") "); } b.variable(vars.consts).string("["); - b.variable(vars.bc); - b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); + b.tree(createConstantIndex(vars, 0)); b.end().string("]"); return b.build(); } @@ -115,12 +111,4 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField); } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_CONSTANT"), - CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index e628ca02cc54..f75d2f7364d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -58,14 +58,10 @@ public class LoadLocalInstruction extends Instruction { private static final boolean LOG_LOCAL_LOADS = false; public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, ResultType.STACK_VALUE, InputType.LOCAL); + super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 1); this.ctx = ctx; this.kind = kind; - } - - @Override - public boolean standardPrologue() { - return false; + addLocal("local"); } @Override @@ -73,9 +69,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("int localIdx"); - b.variable(vars.bc); - b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); - b.string(" + VALUES_OFFSET"); + b.tree(createLocalIndex(vars, 0)); b.end(); if (kind == null) { @@ -222,11 +216,4 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_LOAD_LOCAL"), - CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(0) + "]") - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 1e7c12ee9078..ab0d3ad2a9e8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.ArrayList; @@ -71,9 +111,7 @@ public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData } } - List realSpecNames = data.getNodeData().getSpecializations().stream()// - .map(x -> x.getId()) // - .collect(Collectors.toUnmodifiableList()); + List realSpecNames = data.getNodeData().getSpecializations().stream().map(x -> x.getId()).collect(Collectors.toUnmodifiableList()); data.addWarning("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); hasErrors = true; } @@ -100,7 +138,7 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { } @Override - public int boxingEliminationBitOffset() { + public CodeTree boxingEliminationBitOffset() { return orig.boxingEliminationBitOffset(); } @@ -114,11 +152,6 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return orig.createPrepareAOT(vars, language, root); } - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return orig.createTracingArguments(vars); - } - @Override public void addQuickenedVariant(QuickenedInstruction quick) { throw new AssertionError("should not add quickened variants to quickened instructions"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 0c67e2003594..b58bdcf8b8d2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -47,12 +47,13 @@ public class ReturnInstruction extends Instruction { public ReturnInstruction(int id) { - super("return", id, ResultType.RETURN, InputType.STACK_VALUE); + super("return", id, 0); + addPopSimple("value"); } @Override - public boolean standardPrologue() { - return false; + public boolean isBranchInstruction() { + return true; } @Override @@ -63,11 +64,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startGroup().variable(vars.sp).string(" - 1").end(); b.end(2); + b.statement("break loop"); + return b.build(); } @Override - public CodeTree createCustomEmitCode(BuilderVariables vars, CodeTree[] arguments) { + public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("calculateLeaves"); @@ -86,12 +89,4 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_OTHER"), - }; - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 277d90ac6ed7..86d8d202f9d0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -47,7 +47,8 @@ public class ShortCircuitInstruction extends CustomInstruction { public ShortCircuitInstruction(String name, int id, SingleOperationData data) { - super(name, id, data, new ResultType[]{ResultType.BRANCH}, new InputType[]{InputType.STACK_VALUE, InputType.BRANCH_TARGET}); + super(name, id, data, 0); + addBranchTarget("end"); } @Override @@ -73,12 +74,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2).startBlock(); // { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.statement("continue loop"); // } b.end().startElseBlock(); // { - b.startAssign(vars.bci).tree(createReadArgumentCode(1, vars)).end(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0)).end(); b.statement("continue loop"); // } @@ -87,4 +88,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + public boolean isBranchInstruction() { + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index d13108fa2770..58ad2cfe38f8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.Set; @@ -25,14 +65,12 @@ public class StoreLocalInstruction extends Instruction { private static final boolean LOG_LOCAL_STORES = false; public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) { - super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, ResultType.SET_LOCAL, InputType.STACK_VALUE); + super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 0); this.context = context; this.kind = kind; - } - @Override - public boolean standardPrologue() { - return false; + addPopIndexed("value"); + addLocal("target"); } public static CodeExecutableElement createStoreLocalInitialization(OperationsContext context) { @@ -53,20 +91,20 @@ public static CodeExecutableElement createStoreLocalInitialization(OperationsCon continue; } b.startIf(); - { - b.string("localTag == FRAME_TYPE_" + kind); - b.string(" && "); - b.string("value instanceof " + kind.getTypeNameBoxed()); - } + // { + b.string("localTag == FRAME_TYPE_" + kind); + b.string(" && "); + b.string("value instanceof " + kind.getTypeNameBoxed()); + // } b.end().startBlock(); - { - b.startStatement().startCall("frame", "set" + kind.getFrameName()); - b.string("localIdx"); - b.startGroup().cast(kind.getType()).string("value").end(); - b.end(2); + // { + b.startStatement().startCall("frame", "set" + kind.getFrameName()); + b.string("localIdx"); + b.startGroup().cast(kind.getType()).string("value").end(); + b.end(2); - b.startReturn().string("FRAME_TYPE_" + kind).end(); - } + b.startReturn().string("FRAME_TYPE_" + kind).end(); + // } b.end(); } @@ -84,12 +122,10 @@ public static CodeExecutableElement createStoreLocalInitialization(OperationsCon public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // TODO: implement version w/o BE, if a language does not need it + // todo: implement version w/o BE, if a language does not need it b.startAssign("int localIdx"); - b.variable(vars.bc); - b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(1)).string("]"); - b.string(" + VALUES_OFFSET"); + b.tree(createLocalIndex(vars, 0)); b.end(); b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); @@ -98,37 +134,37 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); b.startIf().string("localTag == ").staticReference(FrameSlotKind, "Illegal").end().startBlock(); - { - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, frame.getValue(sourceSlot))"); - } - b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); - createCopy(vars, b); + // { + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, frame.getValue(sourceSlot))"); } + b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); + createCopy(vars, b); + // } b.end().startElseBlock(); - { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.startAssign("int resultTag").startCall("storeLocalInitialization"); - b.variable(vars.frame); - b.string("localIdx"); - b.string("localTag.tag"); - b.string("sourceSlot"); - b.end(2); - - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); - } - - b.startStatement().startCall("setResultBoxedImpl"); - b.variable(vars.bc); - b.variable(vars.bci); - b.string("resultTag"); - b.string("BOXING_DESCRIPTORS[resultTag]"); - b.end(2); - - createSetChildBoxing(vars, b, "resultTag"); + // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.startAssign("int resultTag").startCall("storeLocalInitialization"); + b.variable(vars.frame); + b.string("localIdx"); + b.string("localTag.tag"); + b.string("sourceSlot"); + b.end(2); + + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); } + + b.startStatement().startCall("setResultBoxedImpl"); + b.variable(vars.bc); + b.variable(vars.bci); + b.string("resultTag"); + b.string("BOXING_DESCRIPTORS[resultTag]"); + b.end(2); + + createSetChildBoxing(vars, b, "resultTag"); + // } b.end(); } else if (kind == FrameKind.OBJECT) { if (LOG_LOCAL_STORES) { @@ -144,41 +180,42 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); b.startDoBlock(); - { - b.startIf().string("localTag == ").staticReference(FrameSlotKind, kind.getFrameName()).end().startBlock(); - { - b.startTryBlock(); - { - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(sourceSlot))"); - } - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.string("localIdx"); - b.startCall("expect" + kind.getFrameName()).variable(vars.frame).string("sourceSlot").end(); - b.end(2); - - b.statement("break /* goto here */"); - } - b.end().startCatchBlock(OperationGeneratorUtils.getTypes().UnexpectedResultException, "ex"); - { - - } - b.end(); - } - b.end(); - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(sourceSlot))"); - } - - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - createGenerifySelf(vars, b); - createSetChildBoxing(vars, b, "FRAME_TYPE_OBJECT"); - createCopyAsObject(vars, b); + // { + b.startIf().string("localTag == ").staticReference(FrameSlotKind, kind.getFrameName()).end().startBlock(); + // { + b.startTryBlock(); + // { + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(sourceSlot))"); + } + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.string("localIdx"); + b.startCall("expect" + kind.getFrameName()).variable(vars.frame).string("sourceSlot").end(); + b.end(2); + + b.statement("break /* goto here */"); + // } + b.end().startCatchBlock(OperationGeneratorUtils.getTypes().UnexpectedResultException, "ex"); + // { + + // } + b.end(); + // } + b.end(); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + if (LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(sourceSlot))"); } + + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + createGenerifySelf(vars, b); + createSetChildBoxing(vars, b, "FRAME_TYPE_OBJECT"); + createCopyAsObject(vars, b); + // } b.end().startDoWhile().string("false").end(2); + } b.lineComment("here:"); @@ -205,7 +242,7 @@ private void createSetChildBoxing(ExecutionVariables vars, CodeTreeBuilder b, St b.startStatement().startCall("doSetResultBoxed"); b.variable(vars.bc); b.variable(vars.bci); - b.startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]").end(); + b.startGroup().tree(createPopIndexedIndex(vars, 0)).end(); b.string(tag); b.end(2); } @@ -239,13 +276,4 @@ public CodeVariableElement boxingEliminationReplacement(FrameKind newKind) { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public CodeTree[] createTracingArguments(ExecutionVariables vars) { - return new CodeTree[]{ - CodeTreeBuilder.singleString("ExecutionTracer.INSTRUCTION_TYPE_STORE_LOCAL"), - CodeTreeBuilder.singleString("bc[bci + " + getArgumentOffset(1) + "]"), - CodeTreeBuilder.singleString("frame.getValue(sp - 1).getClass()") - }; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java deleted file mode 100644 index b434bc8ac4e0..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import java.util.ArrayList; -import java.util.List; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; - -public class SuperInstruction extends Instruction { - private static void createResults(Instruction[] instrs, ArrayList inputs, ArrayList results) { - int stackSize = 0; - - for (int i = 0; i < instrs.length; i++) { - for (int j = 0; j < instrs[i].inputs.length; j++) { - switch (instrs[i].inputs[j]) { - case STACK_VALUE: - case STACK_VALUE_IGNORED: - if (stackSize > 0) { - stackSize--; - break; - } - // fall-through - case ARGUMENT: - case BRANCH_TARGET: - case CONST_POOL: - case LOCAL: - if (inputs != null) { - inputs.add(instrs[i].inputs[j]); - } - break; - default: - throw new IllegalArgumentException("Unexpected value: " + instrs[i].inputs[j]); - } - } - - for (int j = 0; j < instrs[i].results.length; j++) { - switch (instrs[i].results[j]) { - case SET_LOCAL: - if (results != null) { - results.add(ResultType.SET_LOCAL); - } - break; - case STACK_VALUE: - stackSize++; - break; - default: - throw new UnsupportedOperationException("not yet implemented"); - } - } - } - - if (results != null) { - for (int i = 0; i < stackSize; i++) { - results.add(ResultType.STACK_VALUE); - } - } - } - - private static ResultType[] createResults(Instruction[] instrs) { - ArrayList results = new ArrayList<>(); - createResults(instrs, null, results); - return results.toArray(new ResultType[results.size()]); - } - - private static InputType[] createInputs(Instruction[] instrs) { - ArrayList results = new ArrayList<>(); - createResults(instrs, results, null); - return results.toArray(new InputType[results.size()]); - } - - private static String createName(Instruction[] instrs) { - StringBuilder sb = new StringBuilder("super."); - for (int i = 0; i < instrs.length; i++) { - if (i != 0) { - sb.append('.'); - } - sb.append(instrs[i].name); - } - return sb.toString(); - } - - Instruction[] instrs; - - public SuperInstruction(int id, Instruction[] instrs) { - super(createName(instrs), id, createResults(instrs), createInputs(instrs)); - this.instrs = instrs; - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - ProcessorContext context = ProcessorContext.getInstance(); - - CodeVariableElement[] realInputs = vars.inputs; - CodeVariableElement[] realResults = vars.results; - - List tmpStack = new ArrayList<>(); - int realInputIndex = 0; - int realResultIndex = 0; - for (int i = 0; i < instrs.length; i++) { - - CodeVariableElement[] innerInputs = new CodeVariableElement[instrs[i].inputs.length]; - CodeVariableElement[] innerResults = new CodeVariableElement[instrs[i].results.length]; - - for (int j = 0; j < instrs[i].inputs.length; j++) { - switch (instrs[i].inputs[j]) { - case STACK_VALUE: - if (!tmpStack.isEmpty()) { - innerInputs[j] = tmpStack.remove(tmpStack.size() - 1); - break; - } - // fall-through - case ARGUMENT: - case BRANCH_TARGET: - case CONST_POOL: - case LOCAL: - innerInputs[j] = realInputs[realInputIndex++]; - break; - case STACK_VALUE_IGNORED: - if (!tmpStack.isEmpty()) { - tmpStack.remove(tmpStack.size() - 1); - } else { - realInputIndex++; - } - break; - } - } - - for (int j = 0; j < instrs[i].results.length; j++) { - switch (instrs[i].results[j]) { - case SET_LOCAL: - innerResults[j] = realResults[realResultIndex++]; - break; - case STACK_VALUE: - innerResults[j] = new CodeVariableElement(context.getType(Object.class), "inner_result_" + i + "_" + j); - b.statement("Object " + innerResults[j].getName()); - tmpStack.add(innerResults[j]); - break; - } - } - - vars.inputs = innerInputs; - vars.results = innerResults; - b.tree(instrs[i].createExecuteCode(vars)); - } - - for (int i = 0; i < tmpStack.size(); i++) { - b.startAssign(realResults[realResultIndex++]).variable(tmpStack.get(i)).end(); - } - - return b.build(); - } - - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index f7cc67162f2e..0863c1da3ee9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -46,12 +46,8 @@ public class ThrowInstruction extends Instruction { public ThrowInstruction(int id) { - super("throw", id, new ResultType[0], InputType.LOCAL); - } - - @Override - public boolean standardPrologue() { - return false; + super("throw", id, 0); + addLocal("exception"); } @Override @@ -62,10 +58,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // we can convert this to a jump to a statically determined handler // or a throw out of a function - b.startAssign("int slot"); - b.variable(vars.bc); - b.string("[").variable(vars.bci).string(" + " + getArgumentOffset(0)).string("]"); - b.end(); + b.startAssign("int slot").tree(createLocalIndex(vars, 0)).end(); b.startThrow(); b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); diff --git a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl index 046055fe98bd..5df343e5a551 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl +++ b/truffle/src/com.oracle.truffle.sl.test/src/tests/LoopCall.sl @@ -10,7 +10,7 @@ function add(a, b) { function loop(n) { i = 0; while (i < n) { - i = add(i, 1); + i = add(i, 1); } return i; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index abf6ad8eb735..8aae93e00450 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -80,9 +80,7 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(// - decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) +@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 71c22ed7bd97..9d1604c16e70 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.parser; import java.math.BigInteger; @@ -5,7 +45,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Stack; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.ParseTree; @@ -51,7 +90,7 @@ /** * SL AST visitor that uses the Operation DSL for generating code. */ -public class SLOperationsVisitor extends SLBaseVisitor { +public final class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = false; @@ -136,10 +175,10 @@ public Void visitFunction(FunctionContext ctx) { if (DO_LOG_NODE_CREATION) { try { - System.out.println("----------------------------------------------"); - System.out.printf(" Node: %s%n", name); - System.out.println(node.dump()); - System.out.println("----------------------------------------------"); + System./**/out.println("----------------------------------------------"); + System./**/out.printf(" Node: %s%n", name); + System./**/out.println(node.dump()); + System./**/out.println("----------------------------------------------"); } catch (Exception ignored) { } } @@ -527,13 +566,13 @@ private void buildMemberExpressionRead(Token ident, List writeLocalsStack = new Stack<>(); + private final ArrayList writeLocalsStack = new ArrayList<>(); private void buildMemberExpressionWriteBefore(Token ident, List members, int idx, Token errorToken) { if (idx == -1) { int localIdx = getNameIndex(ident); assert localIdx != -1; - writeLocalsStack.push(localIdx); + writeLocalsStack.add(localIdx); b.beginBlock(); b.beginStoreLocal(locals.get(localIdx)); @@ -566,7 +605,7 @@ private void buildMemberExpressionWriteBefore(Token ident, List members, int idx) { if (idx == -1) { - int localIdx = writeLocalsStack.pop(); + int localIdx = writeLocalsStack.remove(writeLocalsStack.size() - 1); b.endStoreLocal(); b.emitLoadLocal(locals.get(localIdx)); b.endBlock(); From 14e78a1bf2b2a099335fd1b5863aa6cfd03d8e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 23 Jun 2022 09:56:50 +0200 Subject: [PATCH 095/312] [wip] new instruction gen --- .../test/example/TestOperations.java | 2 +- .../example/TestOperationsParserTest.java | 5 +- .../truffle/api/operation/LocalSetter.java | 102 +++++++--- .../truffle/api/operation/LocalSetterRun.java | 174 ++++++++++++++++++ .../api/operation/OperationBuilder.java | 38 ++-- .../truffle/api/frame/FrameDescriptor.java | 1 + .../truffle/dsl/processor/TruffleTypes.java | 2 + .../processor/generator/GeneratorUtils.java | 7 + .../dsl/processor/model/CacheExpression.java | 5 + .../dsl/processor/operations/Operation.java | 9 + .../OperationsBytecodeCodeGenerator.java | 1 + .../OperationsBytecodeNodeGeneratorPlugs.java | 24 +-- .../operations/SingleOperationParser.java | 5 +- .../instructions/BranchInstruction.java | 94 ++++++---- .../instructions/CustomInstruction.java | 22 ++- .../operations/instructions/Instruction.java | 83 +++++++-- .../instructions/LoadLocalInstruction.java | 35 +++- .../instructions/StoreLocalInstruction.java | 35 +++- 18 files changed, 507 insertions(+), 137 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index bc9f90aaaa40..654293e44552 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -25,7 +25,7 @@ private static class TestException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -9143719084054578413L; - public TestException(String string, Node node, int bci) { + TestException(String string, Node node, int bci) { super(string, node, bci); } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 67acf148b31a..de0ce2317984 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -19,7 +19,7 @@ public class TestOperationsParserTest { private static RootCallTarget parse(Consumer builder) { OperationNode operationsNode = parseNode(builder); - System.out.println(operationsNode); + System.out.println(operationsNode.dump()); return new TestRootNode(operationsNode).getCallTarget(); } @@ -913,9 +913,8 @@ public void testTeeLocal() { OperationLocal local = b.createLocal(); - b.beginTeeLocal(); + b.beginTeeLocal(local); b.emitConstObject(1L); - b.emitLocalSetter(local); b.endTeeLocal(); b.beginReturn(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index c2e5ce2d0134..d48e55ec199b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -40,66 +40,120 @@ */ package com.oracle.truffle.api.operation; -import java.util.HashMap; +import java.util.Arrays; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; public final class LocalSetter { - private final int index; + @CompilationFinal(dimensions = 1) // + private static LocalSetter[] localSetters = new LocalSetter[8]; - private static final HashMap LOCAL_SETTERS = new HashMap<>(); + private static synchronized void resizeLocals(int index) { + if (localSetters.length <= index) { + int size = localSetters.length; + while (size <= index) { + size = size << 1; + } + localSetters = Arrays.copyOf(localSetters, size); + } + } public static LocalSetter create(int index) { - return LOCAL_SETTERS.computeIfAbsent(index, LocalSetter::new); - } + CompilerAsserts.neverPartOfCompilation("use #get in compiled code"); + if (index < 0 || index >= Short.MAX_VALUE) { + throw new ArrayIndexOutOfBoundsException(index); + } - public static LocalSetter[] createArray(int[] index) { - LocalSetter[] result = new LocalSetter[index.length]; - for (int i = 0; i < index.length; i++) { - result[i] = create(index[i]); + if (localSetters.length <= index) { + resizeLocals(index); + } + + LocalSetter result = localSetters[index]; + if (result == null) { + result = new LocalSetter(index); + localSetters[index] = result; } return result; } - private LocalSetter(int index) { - this.index = index; + public static LocalSetter get(int index) { + return localSetters[index]; } - public void setObject(VirtualFrame frame, Object value) { + static void setObject(VirtualFrame frame, int index, Object value) { frame.setObject(index, value); } - public void setLong(VirtualFrame frame, long value) { - FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); - if (slotKind == FrameSlotKind.Long) { + private static boolean checkFrameSlot(VirtualFrame frame, int index, FrameSlotKind target) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + FrameSlotKind slotKind = descriptor.getSlotKind(index); + if (slotKind == FrameSlotKind.Illegal) { + descriptor.setSlotKind(index, target); + return true; + } else if (slotKind == target) { + return true; + } else if (slotKind == FrameSlotKind.Object) { + return false; + } else { + descriptor.setSlotKind(index, FrameSlotKind.Object); + return false; + } + } + + static void setLong(VirtualFrame frame, int index, long value) { + if (checkFrameSlot(frame, index, FrameSlotKind.Long)) { frame.setLong(index, value); } else { - // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } - public void setInt(VirtualFrame frame, int value) { - FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); - if (slotKind == FrameSlotKind.Int) { + static void setInt(VirtualFrame frame, int index, int value) { + if (checkFrameSlot(frame, index, FrameSlotKind.Int)) { frame.setInt(index, value); } else { - // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } - public void setDouble(VirtualFrame frame, double value) { - FrameSlotKind slotKind = frame.getFrameDescriptor().getSlotKind(index); - if (slotKind == FrameSlotKind.Double) { + static void setDouble(VirtualFrame frame, int index, double value) { + if (checkFrameSlot(frame, index, FrameSlotKind.Double)) { frame.setDouble(index, value); } else { - // todo: this should be compatible with local boxing elimination frame.setObject(index, value); } } + private final int index; + + private LocalSetter(int index) { + this.index = index; + } + + @Override + public String toString() { + return String.format("LocalSetter[%d]", index); + } + + public void setObject(VirtualFrame frame, Object value) { + setObject(frame, index, value); + } + + public void setInt(VirtualFrame frame, int value) { + setInt(frame, index, value); + } + + public void setLong(VirtualFrame frame, long value) { + setLong(frame, index, value); + } + + public void setDouble(VirtualFrame frame, double value) { + setDouble(frame, index, value); + } // todo: other primitives } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java new file mode 100644 index 000000000000..2a2aff0aaa4c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation; + +import java.util.Arrays; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.frame.VirtualFrame; + +public final class LocalSetterRun { + @CompilationFinal(dimensions = 2) // + private static LocalSetterRun[][] localSetterRuns = new LocalSetterRun[8][]; + + private static synchronized void resizeArray(int length) { + if (localSetterRuns.length <= length) { + int size = localSetterRuns.length; + while (size <= length) { + size = size << 1; + } + localSetterRuns = Arrays.copyOf(localSetterRuns, size); + } + } + + private static synchronized LocalSetterRun[] createSubArray(int length, int index) { + LocalSetterRun[] target = localSetterRuns[length]; + if (target == null) { + int size = 8; + while (size <= index) { + size = size << 1; + } + target = new LocalSetterRun[size]; + localSetterRuns[length] = target; + } + return target; + } + + private static synchronized LocalSetterRun[] resizeSubArray(int length, int index) { + LocalSetterRun[] target = localSetterRuns[length]; + if (target.length <= index) { + int size = target.length; + while (size <= index) { + size = size << 1; + } + target = Arrays.copyOf(target, size); + localSetterRuns[length] = target; + } + return target; + } + + public static final LocalSetterRun EMPTY = new LocalSetterRun(0, 0); + + public static LocalSetterRun create(int start, int length) { + CompilerAsserts.neverPartOfCompilation("use #get from compiled code"); + if (start < 0 || start > Short.MAX_VALUE) { + throw new ArrayIndexOutOfBoundsException(start); + } + + if (length <= 0 || length + start > Short.MAX_VALUE) { + throw new ArrayIndexOutOfBoundsException(start + length); + } + + if (localSetterRuns.length <= length) { + resizeArray(length); + } + + LocalSetterRun[] target = localSetterRuns[length]; + if (target == null) { + target = createSubArray(length, start); + } + + if (target.length <= start) { + target = resizeSubArray(length, start); + } + + LocalSetterRun result = target[start]; + if (result == null) { + result = new LocalSetterRun(start, length); + target[start] = result; + } + + return result; + } + + public static LocalSetterRun get(int start, int length) { + return localSetterRuns[length][start]; + } + + private final int start; + private final int length; + + private LocalSetterRun(int start, int length) { + this.start = start; + this.length = length; + } + + @Override + public String toString() { + if (length == 0) { + return "LocalSetterRun[]"; + } + return String.format("LocalSetterRun[%d...%d]", start, start + length - 1); + } + + public int length() { + return length; + } + + private void checkBounds(int offset) { + if (offset >= length) { + CompilerDirectives.transferToInterpreter(); + throw new ArrayIndexOutOfBoundsException(offset); + } + } + + public void setObject(VirtualFrame frame, int offset, Object value) { + checkBounds(offset); + LocalSetter.setObject(frame, start + offset, value); + } + + public void setInt(VirtualFrame frame, int offset, int value) { + checkBounds(offset); + LocalSetter.setInt(frame, start + offset, value); + } + + public void setLong(VirtualFrame frame, int offset, long value) { + checkBounds(offset); + LocalSetter.setLong(frame, start + offset, value); + } + + public void setDouble(VirtualFrame frame, int offset, double value) { + checkBounds(offset); + LocalSetter.setDouble(frame, start + offset, value); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index c5fc14550817..96d5ff6685d7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -267,25 +267,33 @@ protected short getLocalIndex(Object value) { return (short) local.id; } - protected int[] getLocalIndices(Object[] value) { - int[] result = new int[value.length]; - for (int i = 0; i < value.length; i++) { - BuilderOperationLocal local = (BuilderOperationLocal) value[i]; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - result[i] = local.id; - } - return result; + protected LocalSetter createLocalSetter(Object o) { + BuilderOperationLocal local = (BuilderOperationLocal) o; + return LocalSetter.create(local.id); } - protected short getLocalRunStart(Object arg) { - // todo: validate local run - OperationLocal[] arr = (OperationLocal[]) arg; - return (short) ((BuilderOperationLocal) arr[0]).id; + protected LocalSetterRun createLocalSetterRun(Object o) { + OperationLocal[] locals = (OperationLocal[]) o; + assert checkLocalSetterRun(locals); + if (locals.length == 0) { + return LocalSetterRun.EMPTY; + } + + return LocalSetterRun.create(getLocalIndex(locals[0]), locals.length); } - protected short getLocalRunLength(Object arg) { - OperationLocal[] arr = (OperationLocal[]) arg; - return (short) arr.length; + private static boolean checkLocalSetterRun(OperationLocal[] locals) { + if (locals.length == 0) { + return true; + } + int start = ((BuilderOperationLocal) locals[0]).id; + for (int i = 0; i < locals.length; i++) { + if (((BuilderOperationLocal) locals[i]).id != start + i) { + return false; + } + } + + return true; } private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java index 097214a18a67..cf2ff2738f8c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java @@ -687,6 +687,7 @@ public String toString() { if (getSlotName(slot) != null) { sb.append(":").append(getSlotName(slot)); } + sb.append('[').append(getSlotKind(slot)).append(']'); } EconomicMap map = auxiliarySlotMap; if (map != null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 1dbaa5fc6737..7e71b7039eb0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -235,6 +235,7 @@ public class TruffleTypes { public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal"; public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; public static final String LocalSetter_Name = "com.oracle.truffle.api.operation.LocalSetter"; + public static final String LocalSetterRun_Name = "com.oracle.truffle.api.operation.LocalSetterRun"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; @@ -258,6 +259,7 @@ public class TruffleTypes { public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name); public final DeclaredType LocalSetter = c.getDeclaredTypeOptional(LocalSetter_Name); + public final DeclaredType LocalSetterRun = c.getDeclaredTypeOptional(LocalSetterRun_Name); public final DeclaredType MetadataKey = c.getDeclaredTypeOptional(MetadataKey_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index e7fae0d55028..e42abbf20fb6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -154,6 +154,13 @@ public static CodeTree createInInterpreter() { return builder.build(); } + public static CodeTree createHasNextTier() { + ProcessorContext context = ProcessorContext.getInstance(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.startStaticCall(context.getTypes().CompilerDirectives, "hasNextTier").end(); + return builder.build(); + } + public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) { TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); ExecutableElement constructor = findConstructor(superClass); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java index 3786bc5005ab..3e0254d80da1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java @@ -94,6 +94,11 @@ public CacheExpression copy() { return copy; } + @Override + public String toString() { + return String.format("CacheExpression[%s]", sourceParameter.getLocalName()); + } + public void setIsUsedInGuard(boolean b) { this.usedInGuard = b; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 64d498d11db8..f6a1e9685109 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -184,11 +184,20 @@ public CodeTree createEndCode(BuilderVariables vars) { EmitArguments args = new EmitArguments(); + args.constants = new CodeTree[instruction.numConstants()]; args.locals = new CodeTree[instruction.numLocals()]; args.localRuns = new CodeTree[instruction.numLocalRuns()]; args.arguments = new CodeTree[instruction.numArguments()]; args.branchTargets = new CodeTree[instruction.numBranchTargets()]; + boolean[] typedConstants = instruction.typedConstants(); + for (int i = 0; i < typedConstants.length; i++) { + if (typedConstants[i]) { + args.constants[i] = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[" + index + "]").build(); + index++; + } + } + index = moveArguments(vars, index, args.locals); index = moveArguments(vars, index, args.localRuns); index = moveArguments(vars, index, args.arguments); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index c3164555f676..18bb8797cd97 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -261,6 +261,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); + b.declaration("int", "loopCount", "0"); CodeVariableElement varTracer; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 89beeb91ae52..cb94b493171b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -67,7 +67,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; @@ -544,33 +543,14 @@ private FrameKind getFrameType(TypeKind type) { return OperationsData.convertToFrameType(type); } - public static final class LocalRefHandle { - private final String name; - - private LocalRefHandle(String name) { - this.name = name; - - } - - @Override - public boolean equals(Object obj) { - return obj instanceof LocalRefHandle && ((LocalRefHandle) obj).name.equals(this.name); - } - - @Override - public int hashCode() { - return name.hashCode(); - } - } - @Override public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { if (execution.getName().startsWith("$localRefArray")) { - return createArrayReference(frameState, new LocalRefHandle(execution.getName()), true, new ArrayCodeTypeMirror(types.LocalSetter), false); + return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRun, false); } if (execution.getName().startsWith("$localRef")) { - return createArrayReference(frameState, new LocalRefHandle(execution.getName()), true, types.LocalSetter, false); + return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false); } int childIndex = execution.getIndex(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 3d054cd32ad5..f7b2acca0073 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -65,7 +65,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; @@ -349,7 +348,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetter)) { parameters.add(ParameterKind.LOCAL_SETTER); numLocalSetters++; - } else if (ElementUtils.typeEquals(param.asType(), new ArrayCodeTypeMirror(types.LocalSetter))) { + } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRun)) { parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); if (numLocalSetters != 0) { data.addError(param, "Mixing regular and array local setters not allowed"); @@ -422,7 +421,7 @@ private CodeTypeElement createLocalSetterArrayNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, new ArrayCodeTypeMirror(types.LocalSetter))); + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetterRun)); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 73524580aaba..0e5b66d67291 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -50,9 +50,16 @@ public class BranchInstruction extends Instruction { - private static final ProcessorContext context = ProcessorContext.getInstance(); - private static final DeclaredType TRUFFLE_SAFEPOINT = context.getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"); - private static final DeclaredType BYTECODE_OSR_NODE = context.getDeclaredType("com.oracle.truffle.api.nodes.BytecodeOSRNode"); + private final ProcessorContext context = ProcessorContext.getInstance(); + private final DeclaredType typeTruffleSafepoint = context.getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"); + private final DeclaredType typeBytecodeOsrNode = context.getDeclaredType("com.oracle.truffle.api.nodes.BytecodeOSRNode"); + private final DeclaredType typeLoopNode = context.getDeclaredType("com.oracle.truffle.api.nodes.LoopNode"); + + private static final boolean SAFEPOINT_POLL = true; + private static final boolean LOOP_COUNTING = true; + private static final boolean TRY_OSR = false; + + private static final int REPORT_LOOP_STRIDE = 1 << 8; public BranchInstruction(int id) { super("branch", id, 0); @@ -65,37 +72,56 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0)); - b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); - // { - b.startStatement().startStaticCall(TRUFFLE_SAFEPOINT, "poll"); - b.string("this"); - b.end(2); - - // todo: reporting loop count - - b.startIf(); - b.tree(GeneratorUtils.createInInterpreter()); - b.string(" && "); - b.startStaticCall(BYTECODE_OSR_NODE, "pollOSRBackEdge").string("this").end(); - b.end().startBlock(); - // { - b.startAssign("Object osrResult").startStaticCall(BYTECODE_OSR_NODE, "tryOSR"); - b.string("this"); - b.string("targetBci"); - b.variable(vars.sp); - b.string("null"); - b.variable(vars.frame); - b.end(2); - - b.startIf().string("osrResult != null").end().startBlock(); - // { - b.startReturn().string("osrResult").end(); - // } - b.end(); - // } - b.end(); - // } - b.end(); + if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR) { + b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { + + if (SAFEPOINT_POLL) { + b.startStatement().startStaticCall(typeTruffleSafepoint, "poll"); + b.string("this"); + b.end(2); + } + + // todo: reporting loop count + + if (LOOP_COUNTING) { + b.startIf(); + b.tree(GeneratorUtils.createHasNextTier()); + b.string(" && "); + b.string("++loopCount >= " + REPORT_LOOP_STRIDE); + b.end().startBlock(); // { + + b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); + b.string("this"); + b.string("" + REPORT_LOOP_STRIDE); + b.end(2); + + b.statement("loopCount = 0"); + + b.end(); // } + } + + if (TRY_OSR) { + b.startIf(); + b.tree(GeneratorUtils.createInInterpreter()); + b.string(" && "); + b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("this").end(); + b.end().startBlock(); // { + b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); + b.string("this"); + b.string("targetBci"); + b.variable(vars.sp); + b.string("null"); + b.variable(vars.frame); + b.end(2); + + b.startIf().string("osrResult != null").end().startBlock(); // { + b.startReturn().string("osrResult").end(); + b.end(); // } + + b.end(); // } + } + b.end(); // } + } b.startAssign(vars.bci).string("targetBci").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 606869116229..9c9c0b9c1907 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -48,9 +48,11 @@ import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -91,6 +93,9 @@ public CustomInstruction(String name, int id, SingleOperationData data) { initializePops(); } + public static final String MARKER_LOCAL_REFS = "LocalSetterRun"; + public static final String MARKER_LOCAL_REF_PREFIX = "LocalSetter_"; + protected void initializePops() { MethodProperties props = data.getMainProperties(); @@ -106,10 +111,10 @@ protected void initializePops() { } if (props.numLocalReferences == -1) { - addLocalRun("localRefs"); + addConstant(MARKER_LOCAL_REFS, new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); } else { for (int i = 0; i < props.numLocalReferences; i++) { - addLocal("local" + i); + addConstant(MARKER_LOCAL_REF_PREFIX + i, types.OperationLocal); } } } @@ -191,6 +196,19 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { + if (marker.equals(MARKER_LOCAL_REFS)) { + return CodeTreeBuilder.createBuilder().startCall("createLocalSetterRun").tree(args.constants[index]).end().build(); + } + + if (marker instanceof String && ((String) marker).startsWith(MARKER_LOCAL_REF_PREFIX)) { + return CodeTreeBuilder.createBuilder().startCall("createLocalSetter").tree(args.constants[index]).end().build(); + } + + return super.createConstantInitCode(vars, args, marker, index); + } + protected void createTracerCode(ExecutionVariables vars, CodeTreeBuilder b) { if (vars.tracer != null) { b.startStatement().startCall(vars.tracer, "traceActiveSpecializations"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 148efe9fdf69..446aaa8babcb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -89,8 +89,8 @@ public enum BoxingEliminationBehaviour { REPLACE } - private final ProcessorContext context = ProcessorContext.getInstance(); - private final TruffleTypes types = context.getTypes(); + protected final ProcessorContext context = ProcessorContext.getInstance(); + protected final TruffleTypes types = context.getTypes(); public final String name; public final int id; @@ -325,6 +325,19 @@ public CodeTree createLength() { return CodeTreeBuilder.singleString(internalName + LENGTH_SUFFIX); } + public boolean[] typedConstants() { + boolean[] result = new boolean[constantTypes.size()]; + for (int i = 0; i < result.length; i++) { + result[i] = constantTypes.get(i) != null; + } + + return result; + } + + public int numConstants() { + return constants.size(); + } + public int numLocals() { return locals.size(); } @@ -405,14 +418,21 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); - if (args.constants != null) { - for (int i = 0; i < args.constants.length; i++) { - if (args.constants[i] != null) { - b.startStatement().startCall(vars.consts, "setValue"); - b.string("constantsStart + " + i); - b.tree(args.constants[i]); - b.end(2); - } + for (int i = 0; i < constants.size(); i++) { + CodeTree initCode = null; + if (constants.get(i) != null) { + initCode = createConstantInitCode(vars, args, constants.get(i), i); + } + + if (initCode == null && args.constants != null) { + initCode = args.constants[i]; + } + + if (initCode != null) { + b.startStatement().startCall(vars.consts, "setValue"); + b.string("constantsStart + " + i); + b.tree(initCode); + b.end(2); } } } @@ -488,6 +508,11 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) public abstract CodeTree createExecuteCode(ExecutionVariables vars); + @SuppressWarnings("unused") + protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { + return null; + } + private static void printList(StringBuilder sb, List holder, String name) { if (!holder.isEmpty()) { sb.append(" ").append(name).append(":\n"); @@ -516,6 +541,28 @@ public String dumpInfo() { printList(sb, branchProfiles, "Branch Profiles"); printList(sb, stateBits, "State Bitsets"); + sb.append(" Boxing Elimination: "); + switch (boxingEliminationBehaviour()) { + case DO_NOTHING: + sb.append("Do Nothing\n"); + break; + case REPLACE: + sb.append("Replace\n"); + for (FrameKind kind : FrameKind.values()) { + try { + String el = boxingEliminationReplacement(kind).getName(); + sb.append(" ").append(kind).append(" -> ").append(el).append("\n"); + } catch (Exception ex) { + } + } + break; + case SET_BIT: + sb.append("Bit Mask\n"); + break; + default: + throw new AssertionError(); + } + return sb.toString(); } @@ -553,14 +600,6 @@ public List getBuilderArgumentTypes() { } } - for (int i = 0; i < locals.size(); i++) { - result.add(types.OperationLocal); - } - - for (int i = 0; i < localRuns.size(); i++) { - result.add(new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); - } - for (int i = 0; i < arguments.size(); i++) { result.add(context.getType(int.class)); } @@ -569,6 +608,14 @@ public List getBuilderArgumentTypes() { result.add(types.OperationLabel); } + for (int i = 0; i < locals.size(); i++) { + result.add(types.OperationLocal); + } + + for (int i = 0; i < localRuns.size(); i++) { + result.add(new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); + } + return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index f75d2f7364d3..8c0b8f1d72b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -48,6 +48,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadLocalInstruction extends Instruction { @@ -55,7 +56,9 @@ public class LoadLocalInstruction extends Instruction { private final OperationsContext ctx; private final FrameKind kind; + static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; private static final boolean LOG_LOCAL_LOADS = false; + private static final boolean LOG_LOCAL_LOADS_SPEC = false; public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 1); @@ -72,6 +75,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(createLocalIndex(vars, 0)); b.end(); + if (INTERPRETER_ONLY_BOXING_ELIMINATION) { + b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); // { + } + if (kind == null) { if (LOG_LOCAL_LOADS) { b.statement("System.out.printf(\" local load %2d : %s [uninit]%n\", localIdx, frame.getValue(localIdx))"); @@ -88,7 +95,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (LOG_LOCAL_LOADS) { + if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, frame.getValue(localIdx))"); } @@ -123,7 +130,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // } b.end().startBlock(); // { - if (LOG_LOCAL_LOADS) { + + if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, frame.getValue(localIdx))"); } @@ -136,21 +144,30 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // } b.end().startElseBlock(); // { - if (LOG_LOCAL_LOADS) { + + if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(localIdx))"); } + createSetSlotKind(vars, b, "FrameSlotKind.Object"); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); + // } + b.end(); // } b.end(); - } - b.end(); - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + if (LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + } + + createCopy(vars, b); } - createCopy(vars, b); - // } + if (INTERPRETER_ONLY_BOXING_ELIMINATION) { + b.end().startElseBlock(); // } else { + createCopy(vars, b); + b.end(); // } + } b.startStatement().variable(vars.sp).string("++").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 58ad2cfe38f8..4bfd14f71c26 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -55,6 +55,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; +import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class StoreLocalInstruction extends Instruction { private final FrameKind kind; @@ -62,7 +63,9 @@ public class StoreLocalInstruction extends Instruction { static final DeclaredType FrameSlotKind = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.frame.FrameSlotKind"); + static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = LoadLocalInstruction.INTERPRETER_ONLY_BOXING_ELIMINATION; private static final boolean LOG_LOCAL_STORES = false; + private static final boolean LOG_LOCAL_STORES_SPEC = false; public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) { super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 0); @@ -130,6 +133,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); + if (INTERPRETER_ONLY_BOXING_ELIMINATION) { + b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); // { + } + if (kind == null) { b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); @@ -152,7 +159,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("sourceSlot"); b.end(2); - if (LOG_LOCAL_STORES) { + if (LOG_LOCAL_STORES || LOG_LOCAL_STORES_SPEC) { b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); } @@ -205,8 +212,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(sourceSlot))"); + if (LOG_LOCAL_STORES || LOG_LOCAL_STORES_SPEC) { + b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic] (%s) %n\", localIdx, frame.getValue(sourceSlot), localTag)"); } createSetSlotKind(vars, b, "FrameSlotKind.Object"); @@ -215,10 +222,15 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { createCopyAsObject(vars, b); // } b.end().startDoWhile().string("false").end(2); + b.lineComment("here:"); + } + if (INTERPRETER_ONLY_BOXING_ELIMINATION) { + b.end().startElseBlock(); // } else { + createCopy(vars, b); + b.end(); // } } - b.lineComment("here:"); b.startStatement().variable(vars.sp).string("--").end(); return b.build(); @@ -260,15 +272,26 @@ private void createGenerifySelf(ExecutionVariables vars, CodeTreeBuilder b) { @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.REPLACE; + if (kind == FrameKind.OBJECT) { + return BoxingEliminationBehaviour.DO_NOTHING; + } else { + return BoxingEliminationBehaviour.REPLACE; + } } @Override public CodeVariableElement boxingEliminationReplacement(FrameKind newKind) { if (kind == null) { + // unitialized -> anything return context.storeLocalInstructions[newKind.ordinal()].opcodeIdField; } else { - return context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; + if (newKind == kind || kind == FrameKind.OBJECT) { + // do nothing + return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "0"); + } else { + // prim -> anything different = object + return context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; + } } } From 07cda2f14f44bdf5c0fa433da369e40ef80bd9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 23 Jun 2022 13:32:48 +0200 Subject: [PATCH 096/312] [wip] cache ordering --- .../api/operation/OperationBuilder.java | 64 +++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 1 + .../generator/NodeGeneratorPlugs.java | 4 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 12 ++++ .../instructions/StoreLocalInstruction.java | 44 ++----------- 5 files changed, 86 insertions(+), 39 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 96d5ff6685d7..73642f449b53 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -727,6 +727,70 @@ protected static double expectDouble(VirtualFrame frame, int slot) throws Unexpe throw new UnexpectedResultException(frame.getValue(slot)); } + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + try { + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + try { + frame.setLong(localSlot, expectLong(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + + protected static boolean storeLocalIntCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Int) { + try { + frame.setInt(localSlot, expectInt(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + + protected static boolean storeLocalDoubleCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Double) { + try { + frame.setDouble(localSlot, expectDouble(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + protected abstract String dump(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 94c13fc6c2c7..19968455a6bc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -235,6 +235,7 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData List stateObjects = new ArrayList<>(); if (plugs != null) { plugs.addAdditionalStateBits(stateObjects); + plugs.setNodeData(node); } List excludeObjects = new ArrayList<>(); int activeStateStartIndex = -1; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 8dd7db9b633a..3b9a85715e48 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -54,11 +54,14 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; public interface NodeGeneratorPlugs { + void setNodeData(NodeData node); + String transformNodeMethodName(String name); String transformNodeInnerTypeName(String name); @@ -120,5 +123,4 @@ public interface NodeGeneratorPlugs { StaticConstants createConstants(); ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original); - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index cb94b493171b..1c06b3e29e95 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -70,7 +70,9 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.NodeFieldData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; @@ -101,6 +103,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final SingleOperationData data; private final ExecutionVariables dummyVariables = new ExecutionVariables(); + private NodeData nodeData; { context = ProcessorContext.getInstance(); @@ -138,6 +141,15 @@ public String toString() { } } + public void setNodeData(NodeData node) { + this.nodeData = node; + for (SpecializationData spec : node.getSpecializations()) { + for (CacheExpression cache : spec.getCaches()) { + createCacheReference(null, spec, cache, cache.getSharedGroup(), false); + } + } + } + @Override public void addAdditionalStateBits(List stateObjects) { if (!stateObjects.isEmpty()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 4bfd14f71c26..0cb10cb66359 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -183,46 +183,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); b.end(2); } else { - // primitive - b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); - - b.startDoBlock(); - // { - b.startIf().string("localTag == ").staticReference(FrameSlotKind, kind.getFrameName()).end().startBlock(); - // { - b.startTryBlock(); - // { - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(sourceSlot))"); - } - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.startIf().string("!").startCall("storeLocal" + kind.getFrameName() + "Check"); + b.variable(vars.frame); b.string("localIdx"); - b.startCall("expect" + kind.getFrameName()).variable(vars.frame).string("sourceSlot").end(); - b.end(2); - - b.statement("break /* goto here */"); - // } - b.end().startCatchBlock(OperationGeneratorUtils.getTypes().UnexpectedResultException, "ex"); - // { - - // } - b.end(); - // } - b.end(); - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - if (LOG_LOCAL_STORES || LOG_LOCAL_STORES_SPEC) { - b.statement("System.out.printf(\" local store %2d : %s [" + kind + " -> generic] (%s) %n\", localIdx, frame.getValue(sourceSlot), localTag)"); - } - - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - createGenerifySelf(vars, b); + b.string("sourceSlot"); + b.end(2).startBlock(); // { + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); createSetChildBoxing(vars, b, "FRAME_TYPE_OBJECT"); - createCopyAsObject(vars, b); - // } - b.end().startDoWhile().string("false").end(2); - b.lineComment("here:"); + b.end(); // } } if (INTERPRETER_ONLY_BOXING_ELIMINATION) { From 602f5d11f7b403db323f85b17aca5231771e4c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 23 Jun 2022 15:27:49 +0200 Subject: [PATCH 097/312] [wip] fix shortcircuiting ops --- .../truffle/api/operation/OperationBuilder.java | 8 ++++++++ .../truffle/dsl/processor/model/CacheExpression.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 11 +++++++++-- .../operations/instructions/Instruction.java | 4 +++- .../instructions/ShortCircuitInstruction.java | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 73642f449b53..197d71b277e2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -792,6 +792,14 @@ protected static boolean storeLocalDoubleCheck(VirtualFrame frame, int localSlot } protected abstract String dump(); + + protected static String formatConstant(Object obj) { + if (obj == null) { + return "null"; + } else { + return String.format("%s %s", obj.getClass().getSimpleName(), obj); + } + } } protected abstract static class InstrumentedBytecodeNode extends BytecodeNode { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java index 3e0254d80da1..1dbd4d2f5c0d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java @@ -96,7 +96,7 @@ public CacheExpression copy() { @Override public String toString() { - return String.format("CacheExpression[%s]", sourceParameter.getLocalName()); + return String.format("CacheExpression [sourceParameter = %s]", sourceParameter.getLocalName()); } public void setIsUsedInGuard(boolean b) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 1c06b3e29e95..bd595f05f592 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -72,7 +72,6 @@ import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.NodeFieldData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; @@ -751,8 +750,16 @@ public CodeTree createGetSpecializationBits() { b.declaration("boolean[]", "result", "new boolean[" + specializationStates.size() + "]"); for (int i = 0; i < specializationStates.size(); i++) { + SpecializationData data = (SpecializationData) specializationStates.get(i); b.startAssign("result[" + i + "]"); - b.tree(multiState.createContains(frame, new Object[]{specializationStates.get(i)})); + b.tree(multiState.createContains(frame, new Object[]{data})); + Set excludedBy = data.getExcludedBy(); + + if (!excludedBy.isEmpty()) { + b.string(" && "); + b.tree(multiState.createNotContains(frame, excludedBy.toArray())); + } + b.end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 446aaa8babcb..35bb7f670b47 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -651,7 +651,9 @@ public CodeTree createDumpCode(ExecutionVariables vars) { for (int i = 0; i < constants.size(); i++) { int ci = i; - sbAppend(b, " const(%s)", () -> b.startGroup().variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]").end()); + sbAppend(b, " const(%s)", () -> { + b.startCall("formatConstant").startGroup().variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]").end(2); + }); } for (int i = 0; i < locals.size(); i++) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 86d8d202f9d0..d45d59fe7700 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -48,6 +48,7 @@ public class ShortCircuitInstruction extends CustomInstruction { public ShortCircuitInstruction(String name, int id, SingleOperationData data) { super(name, id, data, 0); + addPopIndexed("value"); addBranchTarget("end"); } From 21d7ef31fa9bbb21283c6a43f2d842401e039cd0 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 23 Jun 2022 17:32:17 +0200 Subject: [PATCH 098/312] Operation builder fixes. --- .../api/operation/OperationBuilder.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 197d71b277e2..ad85ebbc9d34 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -46,6 +46,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.HostCompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; @@ -628,6 +629,7 @@ protected static Object expectObject(VirtualFrame frame, int slot) { // this should only happen in edge cases, when we have specialized to a generic case // on one thread, but other threads have already executed the child with primitive // return type + CompilerDirectives.transferToInterpreterAndInvalidate(); return frame.getValue(slot); } } @@ -645,7 +647,7 @@ protected static byte expectByte(VirtualFrame frame, int slot) throws Unexpected } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); + throw throwUnexpectedValue(frame, slot); } protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { @@ -659,8 +661,8 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex } break; } - - throw new UnexpectedResultException(frame.getValue(slot)); + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw throwUnexpectedValue(frame, slot); } protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { @@ -676,7 +678,7 @@ protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedRe } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); + throw throwUnexpectedValue(frame, slot); } protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { @@ -692,7 +694,7 @@ protected static float expectFloat(VirtualFrame frame, int slot) throws Unexpect } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); + throw throwUnexpectedValue(frame, slot); } protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { @@ -708,7 +710,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); + throw throwUnexpectedValue(frame, slot); + } + + private static UnexpectedResultException throwUnexpectedValue(VirtualFrame frame, int slot) { + return new UnexpectedResultException(frame.getValue(slot)); } protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { @@ -724,7 +730,7 @@ protected static double expectDouble(VirtualFrame frame, int slot) throws Unexpe } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); + throw throwUnexpectedValue(frame, slot); } protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { From 85285456fda0d763eaca62a0a8c9239e00f6f5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 27 Jun 2022 09:07:40 +0200 Subject: [PATCH 099/312] [wip] update tests --- .../operation/test/example/TestOperationsParserTest.java | 3 ++- .../oracle/truffle/api/operation/OperationBuilder.java | 8 +++++++- .../truffle/dsl/processor/operations/Operation.java | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index de0ce2317984..c4ca0dd9682d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -167,7 +167,8 @@ public void testSumLoop() { @Test public void testTryCatch() { RootCallTarget root = parse(b -> { - b.beginTryCatch(0); + OperationLocal local = b.createLocal(); + b.beginTryCatch(local); b.beginIfThen(); b.beginLessThanOperation(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 197d71b277e2..6ef8d54601e0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -111,6 +111,8 @@ private void reset() { numChildNodes = 0; numBranchProfiles = 0; + exceptionHandlers.clear(); + resetMetadata(); } @@ -797,7 +799,11 @@ protected static String formatConstant(Object obj) { if (obj == null) { return "null"; } else { - return String.format("%s %s", obj.getClass().getSimpleName(), obj); + Object repr = obj; + if (repr instanceof Object[]) { + repr = Arrays.deepToString((Object[]) obj); + } + return String.format("%s %s", obj.getClass().getSimpleName(), repr); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index f6a1e9685109..c0cc52abaaab 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -557,7 +557,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = (int)").variable(vars.operationData).string(".arguments[0]").end(); + b.startStatement().variable(varBeh).string(".exceptionIndex = getLocalIndex(").variable(vars.operationData).string(".arguments[0])").end(); b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); @@ -616,7 +616,7 @@ public CodeTree createEndCode(BuilderVariables vars) { @Override public List getBuilderArgumentTypes() { - return List.of(new CodeTypeMirror(TypeKind.INT)); + return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); } } From 204139f9aea0cf825c1df2887899726728b0c7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 27 Jun 2022 09:21:49 +0200 Subject: [PATCH 100/312] [wip] rename LocalSetterRun => Range --- ...alSetterRun.java => LocalSetterRange.java} | 32 +++++++++---------- .../api/operation/OperationBuilder.java | 10 +++--- .../truffle/dsl/processor/TruffleTypes.java | 4 +-- .../OperationsBytecodeNodeGeneratorPlugs.java | 2 +- .../operations/SingleOperationParser.java | 4 +-- .../instructions/CustomInstruction.java | 4 +-- 6 files changed, 28 insertions(+), 28 deletions(-) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/{LocalSetterRun.java => LocalSetterRange.java} (83%) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java similarity index 83% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java index 2a2aff0aaa4c..0dc0d50015f7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRun.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java @@ -47,9 +47,9 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.VirtualFrame; -public final class LocalSetterRun { +public final class LocalSetterRange { @CompilationFinal(dimensions = 2) // - private static LocalSetterRun[][] localSetterRuns = new LocalSetterRun[8][]; + private static LocalSetterRange[][] localSetterRuns = new LocalSetterRange[8][]; private static synchronized void resizeArray(int length) { if (localSetterRuns.length <= length) { @@ -61,21 +61,21 @@ private static synchronized void resizeArray(int length) { } } - private static synchronized LocalSetterRun[] createSubArray(int length, int index) { - LocalSetterRun[] target = localSetterRuns[length]; + private static synchronized LocalSetterRange[] createSubArray(int length, int index) { + LocalSetterRange[] target = localSetterRuns[length]; if (target == null) { int size = 8; while (size <= index) { size = size << 1; } - target = new LocalSetterRun[size]; + target = new LocalSetterRange[size]; localSetterRuns[length] = target; } return target; } - private static synchronized LocalSetterRun[] resizeSubArray(int length, int index) { - LocalSetterRun[] target = localSetterRuns[length]; + private static synchronized LocalSetterRange[] resizeSubArray(int length, int index) { + LocalSetterRange[] target = localSetterRuns[length]; if (target.length <= index) { int size = target.length; while (size <= index) { @@ -87,9 +87,9 @@ private static synchronized LocalSetterRun[] resizeSubArray(int length, int inde return target; } - public static final LocalSetterRun EMPTY = new LocalSetterRun(0, 0); + public static final LocalSetterRange EMPTY = new LocalSetterRange(0, 0); - public static LocalSetterRun create(int start, int length) { + public static LocalSetterRange create(int start, int length) { CompilerAsserts.neverPartOfCompilation("use #get from compiled code"); if (start < 0 || start > Short.MAX_VALUE) { throw new ArrayIndexOutOfBoundsException(start); @@ -103,7 +103,7 @@ public static LocalSetterRun create(int start, int length) { resizeArray(length); } - LocalSetterRun[] target = localSetterRuns[length]; + LocalSetterRange[] target = localSetterRuns[length]; if (target == null) { target = createSubArray(length, start); } @@ -112,23 +112,23 @@ public static LocalSetterRun create(int start, int length) { target = resizeSubArray(length, start); } - LocalSetterRun result = target[start]; + LocalSetterRange result = target[start]; if (result == null) { - result = new LocalSetterRun(start, length); + result = new LocalSetterRange(start, length); target[start] = result; } return result; } - public static LocalSetterRun get(int start, int length) { + public static LocalSetterRange get(int start, int length) { return localSetterRuns[length][start]; } private final int start; private final int length; - private LocalSetterRun(int start, int length) { + private LocalSetterRange(int start, int length) { this.start = start; this.length = length; } @@ -136,9 +136,9 @@ private LocalSetterRun(int start, int length) { @Override public String toString() { if (length == 0) { - return "LocalSetterRun[]"; + return "LocalSetterRange[]"; } - return String.format("LocalSetterRun[%d...%d]", start, start + length - 1); + return String.format("LocalSetterRange[%d...%d]", start, start + length - 1); } public int length() { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 4155451ee25a..65e311e1b714 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -275,17 +275,17 @@ protected LocalSetter createLocalSetter(Object o) { return LocalSetter.create(local.id); } - protected LocalSetterRun createLocalSetterRun(Object o) { + protected LocalSetterRange createLocalSetterRange(Object o) { OperationLocal[] locals = (OperationLocal[]) o; - assert checkLocalSetterRun(locals); + assert checkLocalSetterRange(locals); if (locals.length == 0) { - return LocalSetterRun.EMPTY; + return LocalSetterRange.EMPTY; } - return LocalSetterRun.create(getLocalIndex(locals[0]), locals.length); + return LocalSetterRange.create(getLocalIndex(locals[0]), locals.length); } - private static boolean checkLocalSetterRun(OperationLocal[] locals) { + private static boolean checkLocalSetterRange(OperationLocal[] locals) { if (locals.length == 0) { return true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 7e71b7039eb0..21e69d6d05e5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -235,7 +235,7 @@ public class TruffleTypes { public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal"; public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey"; public static final String LocalSetter_Name = "com.oracle.truffle.api.operation.LocalSetter"; - public static final String LocalSetterRun_Name = "com.oracle.truffle.api.operation.LocalSetterRun"; + public static final String LocalSetterRange_Name = "com.oracle.truffle.api.operation.LocalSetterRange"; public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; @@ -259,7 +259,7 @@ public class TruffleTypes { public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name); public final DeclaredType LocalSetter = c.getDeclaredTypeOptional(LocalSetter_Name); - public final DeclaredType LocalSetterRun = c.getDeclaredTypeOptional(LocalSetterRun_Name); + public final DeclaredType LocalSetterRange = c.getDeclaredTypeOptional(LocalSetterRange_Name); public final DeclaredType MetadataKey = c.getDeclaredTypeOptional(MetadataKey_Name); public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index bd595f05f592..8d0f15784c40 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -557,7 +557,7 @@ private FrameKind getFrameType(TypeKind type) { @Override public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { if (execution.getName().startsWith("$localRefArray")) { - return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRun, false); + return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRange, false); } if (execution.getName().startsWith("$localRef")) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index f7b2acca0073..9632f528f202 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -348,7 +348,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetter)) { parameters.add(ParameterKind.LOCAL_SETTER); numLocalSetters++; - } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRun)) { + } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRange)) { parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); if (numLocalSetters != 0) { data.addError(param, "Mixing regular and array local setters not allowed"); @@ -421,7 +421,7 @@ private CodeTypeElement createLocalSetterArrayNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetterRun)); + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetterRange)); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 9c9c0b9c1907..fc0ad0950ce9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -93,7 +93,7 @@ public CustomInstruction(String name, int id, SingleOperationData data) { initializePops(); } - public static final String MARKER_LOCAL_REFS = "LocalSetterRun"; + public static final String MARKER_LOCAL_REFS = "LocalSetterRange"; public static final String MARKER_LOCAL_REF_PREFIX = "LocalSetter_"; protected void initializePops() { @@ -199,7 +199,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { if (marker.equals(MARKER_LOCAL_REFS)) { - return CodeTreeBuilder.createBuilder().startCall("createLocalSetterRun").tree(args.constants[index]).end().build(); + return CodeTreeBuilder.createBuilder().startCall("createLocalSetterRange").tree(args.constants[index]).end().build(); } if (marker instanceof String && ((String) marker).startsWith(MARKER_LOCAL_REF_PREFIX)) { From 917251a7ca98078fa7663d9c25b09f3f11912a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 28 Jun 2022 10:41:12 +0200 Subject: [PATCH 101/312] [wip] add null checks for caches in Operation DSL --- .../generator/FlatNodeGenFactory.java | 26 ++++++++++++++++--- .../generator/NodeCodeGenerator.java | 7 ++++- .../OperationsBytecodeCodeGenerator.java | 2 ++ .../OperationsBytecodeNodeGeneratorPlugs.java | 4 +++ .../processor/operations/OperationsData.java | 6 +++++ .../dsl/processor/parser/NodeParser.java | 5 ++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 19968455a6bc..02f2bb06d9c7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -206,7 +206,8 @@ public String toString() { public enum GeneratorMode { DEFAULT, - EXPORTED_MESSAGE + EXPORTED_MESSAGE, + OPERATIONS, } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, @@ -3419,6 +3420,8 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par builder.statement("hasLock = false"); } + int numCachedNullChecks = 0; + if (specialization.getMethod() == null) { builder.tree(createThrowUnsupported(builder, frameState)); } else { @@ -3428,11 +3431,24 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par Parameter parameter = specialization.getParameters().get(i); if (parameter.getSpecification().isCached()) { - LocalVariable var = frameState.get(createFieldName(specialization, parameter)); + String fieldName = createFieldName(specialization, parameter); + LocalVariable var = frameState.get(fieldName); if (var != null) { bindings[i] = var.createReference(); - } else { - bindings[i] = createCacheReference(frameState, specialization, specialization.findCache(parameter), true); + } + if (var == null) { + CodeTree cacheReference = createCacheReference(frameState, specialization, specialization.findCache(parameter), true); + if (generatorMode == GeneratorMode.OPERATIONS && frameState.getMode() == NodeExecutionMode.FAST_PATH) { + String localName = createCacheLocalName(specialization, specialization.findCache(parameter)); + var = new LocalVariable(parameter.getType(), localName, null); + frameState.set(fieldName, var); + builder.tree(var.createDeclaration(cacheReference)); + bindings[i] = var.createReference(); + builder.startIf().tree(var.createReference()).string(" != null").end().startBlock(); + numCachedNullChecks++; + } else { + bindings[i] = cacheReference; + } } bindingTypes[i] = parameter.getType(); } else { @@ -3485,6 +3501,8 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par builder.end(); } } + + builder.end(numCachedNullChecks); } return createCatchRewriteException(builder, specialization, forType, frameState, builder.build()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index 86b63e07e900..ab15f2941ecb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -76,6 +76,7 @@ public class NodeCodeGenerator extends CodeTypeElementFactory { private NodeGeneratorPlugs plugs; + private GeneratorMode generatorMode = GeneratorMode.DEFAULT; @Override public List create(ProcessorContext context, AnnotationProcessor processor, NodeData node) { @@ -130,6 +131,10 @@ public void setPlugs(NodeGeneratorPlugs plugs) { this.plugs = plugs; } + public void setGeneratorMode(GeneratorMode generatorMode) { + this.generatorMode = generatorMode; + } + private static CodeTypeElement makeInnerClass(CodeTypeElement type) { Set modifiers = type.getModifiers(); modifiers.add(Modifier.STATIC); @@ -284,7 +289,7 @@ private List generateNodes(ProcessorContext context, NodeData n return Arrays.asList(type); } - type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, plugs).create(type); + type = new FlatNodeGenFactory(context, generatorMode, node, constants, plugs).create(type); return Arrays.asList(type); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 18bb8797cd97..edf5d38e9409 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -59,6 +59,7 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; @@ -436,6 +437,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, Cod NodeCodeGenerator generator = new NodeCodeGenerator(); generator.setPlugs(plugs); + generator.setGeneratorMode(GeneratorMode.OPERATIONS); List resultList = generator.create(context, null, soData.getNodeData()); if (resultList.size() != 1) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 8d0f15784c40..ab65a2e63b5b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -203,6 +203,10 @@ public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, b } builder.string("$bci"); builder.string("$sp"); + + for (int i = 0; i < m.getNumTosSlots(); i++) { + builder.string("$tos_" + i); + } } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index cb2c20d10d47..2eaa3bcc843c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -70,6 +70,8 @@ public class OperationsData extends Template { private TypeSystemData typeSystem; private final Set boxingEliminatedTypes = new HashSet<>(); + private int numTosSlots; + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } @@ -78,6 +80,10 @@ public OperationsContext getOperationsContext() { return context; } + public int getNumTosSlots() { + return numTosSlots; + } + public void addOperationData(SingleOperationData data) { operations.add(data); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 5aabb45a6444..9375b35c1027 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2335,6 +2335,11 @@ private SpecializationData initializeCaches(SpecializationData specialization, D if (cache.isCached()) { boolean weakReference = getAnnotationValue(Boolean.class, foundCached, "weak"); + if (mode == ParseMode.OPERATION) { + if (ElementUtils.isPrimitive(cache.getParameter().getType())) { + cache.addError("Cahced parameters with primitive types not allowed in Operation DSL."); + } + } if (weakReference) { if (ElementUtils.isPrimitive(cache.getParameter().getType())) { cache.addError("Cached parameters with primitive types cannot be weak. Set weak to false to resolve this."); From 8ff5c13db5f8105fd4c7bc7c0e9cd69ad7903331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 28 Jun 2022 12:30:26 +0200 Subject: [PATCH 102/312] [wip] add copyObject and copyPrimitive to Frame --- .../com/oracle/truffle/api/frame/Frame.java | 24 +++++++++++++++++++ .../truffle/api/impl/FrameWithoutBoxing.java | 18 ++++++++++++++ .../OperationsBytecodeNodeGeneratorPlugs.java | 9 ++++++- .../instructions/LoadLocalInstruction.java | 22 ++++++++--------- .../instructions/StoreLocalInstruction.java | 24 ++++++++----------- 5 files changed, 71 insertions(+), 26 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java index cc5de1b12b0a..6083077572b8 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java @@ -591,6 +591,30 @@ default void copy(int srcSlot, int destSlot) { throw new UnsupportedOperationException(); } + /** + * Copies, including the type, from one slot to another. The type must be Object. + * + * @param srcSlot the slot of the source local variable + * @param destSlot the slot of the target local variable + * @since XXX + */ + default void copyObject(int srcSlot, int destSlot) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnsupportedOperationException(); + } + + /** + * Copies, including the type, from one slot to another. The type must be primitive. + * + * @param srcSlot the slot of the source local variable + * @param destSlot the slot of the target local variable + * @since XXX + */ + default void copyPrimitive(int srcSlot, int destSlot) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnsupportedOperationException(); + } + /** * Swaps, including the type, the contents of two slots. * diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index c687ee0d2882..667321bd127f 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -715,6 +715,24 @@ public void copy(int srcSlot, int destSlot) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); } + @Override + public void copyObject(int srcSlot, int destSlot) { + byte tag = getIndexedTagChecked(srcSlot); + assert tag == OBJECT_TAG : "copyObject must be used with Object slots"; + Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + verifyIndexedSet(destSlot, tag); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + } + + @Override + public void copyPrimitive(int srcSlot, int destSlot) { + byte tag = getIndexedTagChecked(srcSlot); + assert tag == OBJECT_TAG : "copyObject must be used with Object slots"; + long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); + verifyIndexedSet(destSlot, tag); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); + } + public void swap(int first, int second) { byte firstTag = getIndexedTagChecked(first); Object firstValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index ab65a2e63b5b..d81e103cff1c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -485,7 +485,10 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui } if (DO_LOG_ENS_CALLS) { - builder.statement("System.out.printf(\" [!!] calling E&S @ %04x : " + cinstr.name + " " + (ensCall++) + "%n\", $bci)"); + builder.statement("System.out.printf(\" [!!] calling E&S @ %04x : " + cinstr.name + " " + (ensCall++) + " \", $bci)"); + builder.startStatement().startCall("System.out.println").startCall("java.util.Arrays.asList"); + frameState.addReferencesTo(builder); + builder.end(3); } if (regularReturn()) { @@ -586,6 +589,10 @@ public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, Execut @Override public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder b) { + if (DO_LOG_ENS_CALLS) { + b.statement("System.out.println(\" [!!] finished E&S - " + specialization.getId() + " \")"); + } + // quickening if (!(cinstr instanceof QuickenedInstruction)) { List quickened = cinstr.getQuickenedVariants(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 8c0b8f1d72b4..402757f44442 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -108,7 +108,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("System.out.printf(\" local load %2d : %s [generic]%n\", localIdx, frame.getValue(localIdx))"); } - createCopy(vars, b); + createCopyObject(vars, b); } else { b.declaration(StoreLocalInstruction.FrameSlotKind, "localType", @@ -160,15 +160,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); } - createCopy(vars, b); + createCopyPrimitive(vars, b); } - - if (INTERPRETER_ONLY_BOXING_ELIMINATION) { - b.end().startElseBlock(); // } else { - createCopy(vars, b); - b.end(); // } - } - b.startStatement().variable(vars.sp).string("++").end(); return b.build(); @@ -184,8 +177,15 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { } } - private static void createCopy(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copy"); + private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copyObject"); + b.string("localIdx"); + b.variable(vars.sp); + b.end(2); + } + + private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copyPrimitive"); b.string("localIdx"); b.variable(vars.sp); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 0cb10cb66359..9e4ff9c27048 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -63,7 +63,6 @@ public class StoreLocalInstruction extends Instruction { static final DeclaredType FrameSlotKind = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.frame.FrameSlotKind"); - static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = LoadLocalInstruction.INTERPRETER_ONLY_BOXING_ELIMINATION; private static final boolean LOG_LOCAL_STORES = false; private static final boolean LOG_LOCAL_STORES_SPEC = false; @@ -133,10 +132,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); - if (INTERPRETER_ONLY_BOXING_ELIMINATION) { - b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); // { - } - if (kind == null) { b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); @@ -146,7 +141,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, frame.getValue(sourceSlot))"); } b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); - createCopy(vars, b); + createCopyObject(vars, b); // } b.end().startElseBlock(); // { @@ -193,19 +188,20 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); // } } - if (INTERPRETER_ONLY_BOXING_ELIMINATION) { - b.end().startElseBlock(); // } else { - createCopy(vars, b); - b.end(); // } - } - b.startStatement().variable(vars.sp).string("--").end(); return b.build(); } - private static void createCopy(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copy"); + private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copyPrimitive"); + b.string("sourceSlot"); + b.string("localIdx"); + b.end(2); + } + + private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall(vars.frame, "copyObject"); b.string("sourceSlot"); b.string("localIdx"); b.end(2); From 9c7944540757f2567cc2ecabf852ab8d4ed8ed93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 28 Jun 2022 14:06:54 +0200 Subject: [PATCH 103/312] [wip] clear object slot on copyPrimitive --- .../src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 667321bd127f..731f55363ee2 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -617,8 +617,7 @@ private long[] getIndexedPrimitiveLocals() { } private byte[] getIndexedTags() { - return indexedTags; - // return unsafeCast(indexedTags, byte[].class, true, true, true); + return unsafeCast(indexedTags, byte[].class, true, true, true); } @Override @@ -727,10 +726,11 @@ public void copyObject(int srcSlot, int destSlot) { @Override public void copyPrimitive(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); - assert tag == OBJECT_TAG : "copyObject must be used with Object slots"; + assert tag != OBJECT_TAG : "copyObject must be used with non-Object slots"; long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); verifyIndexedSet(destSlot, tag); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); } public void swap(int first, int second) { From 4383568322b75e0b215221a770dd132505563772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 29 Jun 2022 09:46:41 +0200 Subject: [PATCH 104/312] [wip] fix boundary calls --- .../api/dsl/BoundaryCallFailedException.java | 52 +++++++++++++++++++ .../truffle/api/impl/FrameWithoutBoxing.java | 3 ++ .../truffle/dsl/processor/TruffleTypes.java | 2 + .../generator/FlatNodeGenFactory.java | 10 +++- .../processor/model/SpecializationData.java | 9 ++++ .../OperationsBytecodeCodeGenerator.java | 2 +- .../dsl/processor/parser/NodeParser.java | 1 + .../processor/parser/SpecializationGroup.java | 4 +- .../nodes/expression/SLWritePropertyNode.java | 4 +- 9 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java new file mode 100644 index 000000000000..04e9f069061b --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import com.oracle.truffle.api.nodes.ControlFlowException; + +public final class BoundaryCallFailedException extends ControlFlowException { + private static final long serialVersionUID = 4967477438708874100L; + + public static final BoundaryCallFailedException INSTANCE = new BoundaryCallFailedException(); + + private BoundaryCallFailedException() { + } +} diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 731f55363ee2..be16645ecc5e 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -721,6 +721,9 @@ public void copyObject(int srcSlot, int destSlot) { Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); verifyIndexedSet(destSlot, tag); unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + if (CompilerDirectives.inCompiledCode()) { + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), 0L, PRIMITIVE_LOCATION); + } } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 21e69d6d05e5..1b03c6c8dac1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -146,6 +146,7 @@ public class TruffleTypes { // DSL API public static final String Bind_Name = "com.oracle.truffle.api.dsl.Bind"; + public static final String BoundaryCallFailedException_Name = "com.oracle.truffle.api.dsl.BoundaryCallFailedException"; public static final String Cached_Exclusive_Name = "com.oracle.truffle.api.dsl.Cached.Exclusive"; public static final String Cached_Name = "com.oracle.truffle.api.dsl.Cached"; public static final String Cached_Shared_Name = "com.oracle.truffle.api.dsl.Cached.Shared"; @@ -186,6 +187,7 @@ public class TruffleTypes { public static final String UnsupportedSpecializationException_Name = "com.oracle.truffle.api.dsl.UnsupportedSpecializationException"; public final DeclaredType Bind = c.getDeclaredType(Bind_Name); + public final DeclaredType BoundaryCallFailedException = c.getDeclaredType(BoundaryCallFailedException_Name); public final DeclaredType Cached = c.getDeclaredType(Cached_Name); public final DeclaredType Cached_Exclusive = c.getDeclaredType(Cached_Exclusive_Name); public final DeclaredType Cached_Shared = c.getDeclaredType(Cached_Shared_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 02f2bb06d9c7..ae343cea3404 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -3404,6 +3404,7 @@ private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableT } builder.tree(createCallSpecialization(builder, frameState, forType, specialization, inBoundary)); builder.end(ifCount); + return builder.build(); } @@ -3503,6 +3504,9 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } builder.end(numCachedNullChecks); + if (numCachedNullChecks > 0 && inBoundary) { + builder.startThrow().staticReference(types.BoundaryCallFailedException, "INSTANCE").end(); + } } return createCatchRewriteException(builder, specialization, forType, frameState, builder.build()); @@ -3827,6 +3831,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } nonBoundaryIfCount = nonBoundaryIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(nonBoundaryGuards), false)); innerBuilder = extractInBoundaryMethod(builder, frameState, specialization); + frameState.setBoolean("operations_had_cache_null_check", false); if (plugs != null) { plugs.initializeFrameState(innerFrameState, innerBuilder); @@ -3888,7 +3893,8 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.end(ifCount.blockCount); - hasFallthrough |= ifCount.ifCount > 0; + + hasFallthrough |= ifCount.blockCount > 0; } else if (mode.isSlowPath()) { @@ -4173,10 +4179,12 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt frameState.addReferencesTo(b, includeFrameParameter, createSpecializationLocalName(specialization)); }); } else { + builder.startTryBlock(); builder.startReturn().startCall("this", boundaryMethod); multiState.addReferencesTo(frameState, builder); frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); builder.end().end(); + builder.end().startCatchBlock(types.BoundaryCallFailedException, "ex").end(); } return innerBuilder; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java index d675fa70f26f..93d1786fa4ec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java @@ -91,6 +91,7 @@ public enum SpecializationKind { private final boolean reportMegamorphism; private boolean aotReachable; + private boolean hasCachedExpression; public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind, List exceptions, boolean hasUnexpectedResultRewrite, boolean reportPolymorphism, boolean reportMegamorphism) { @@ -803,4 +804,12 @@ public CacheExpression findCache(Parameter resolvedParameter) { return null; } + public void setHasCachedExpression(boolean b) { + this.hasCachedExpression = b; + } + + public boolean hasCachedExpression() { + return hasCachedExpression; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index edf5d38e9409..00661072d9fa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -246,7 +246,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); CodeVariableElement argStartSp = new CodeVariableElement(context.getType(int.class), "startSp"); CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PROTECTED), context.getType(Object.class), "continueAt", + Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(Object.class), "continueAt", argFrame, argStartBci, argStartSp); builderBytecodeNodeType.getEnclosedElements().add(0, mContinueAt); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 9375b35c1027..8625825caece 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2336,6 +2336,7 @@ private SpecializationData initializeCaches(SpecializationData specialization, D if (cache.isCached()) { boolean weakReference = getAnnotationValue(Boolean.class, foundCached, "weak"); if (mode == ParseMode.OPERATION) { + specialization.setHasCachedExpression(true); if (ElementUtils.isPrimitive(cache.getParameter().getType())) { cache.addError("Cahced parameters with primitive types not allowed in Operation DSL."); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java index bd22240505e6..70ca6511be74 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java @@ -394,11 +394,13 @@ public boolean hasFallthrough() { if (hasFallthrough) { return true; } + if (specialization != null) { + return specialization.hasCachedExpression(); + } SpecializationGroup lastChild = getLast(); if (lastChild != null) { return lastChild.hasFallthrough(); } return false; } - } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 451569c69960..41614b2c9b40 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -79,8 +79,8 @@ public abstract class SLWritePropertyNode extends SLExpressionNode { @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object writeArray(Object receiver, Object index, Object value, - @Cached("this") Node node, - @Cached("$bci") int bci, + @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { try { From 5aad2a20792e984c53bb2a112888b56bad22c3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 1 Jul 2022 11:20:08 +0200 Subject: [PATCH 105/312] [wip] new generator --- .../test/example/BoxingOperationsTest.java | 42 +- .../test/example/TestOperations.java | 42 +- .../example/TestOperationsParserTest.java | 40 + .../operation/test/example/TestRootNode.java | 40 + .../AbstractOperationsTruffleException.java | 42 +- .../operation/BuilderExceptionHandler.java | 29 - .../api/operation/BuilderLabelFill.java | 15 - .../api/operation/BuilderOperationData.java | 27 - .../api/operation/BuilderOperationLabel.java | 34 - .../api/operation/BuilderOperationLocal.java | 12 - .../api/operation/BuilderSourceInfo.java | 148 --- .../api/operation/GenerateOperations.java | 42 +- .../api/operation/LocalSetterRange.java | 20 + .../truffle/api/operation/MetadataKey.java | 40 + .../truffle/api/operation/Operation.java | 40 + .../api/operation/OperationBuilder.java | 785 ----------- .../api/operation/OperationConfig.java | 40 + .../truffle/api/operation/OperationLabel.java | 40 + .../truffle/api/operation/OperationLocal.java | 42 +- .../truffle/api/operation/OperationNode.java | 138 +- .../truffle/api/operation/OperationNodes.java | 52 +- .../api/operation/OperationProxies.java | 40 + .../truffle/api/operation/OperationProxy.java | 40 + .../api/operation/OperationsBytesSupport.java | 33 - .../api/operation/OperationsConstantPool.java | 101 -- .../OperationsInstrumentTreeNode.java | 42 +- .../OperationsStackTraceElement.java | 44 +- .../api/operation/ShortCircuitOperation.java | 42 +- .../api/operation/ShortCircuitOperations.java | 42 +- .../truffle/api/operation/Variadic.java | 48 +- .../operation/tracing/ExecutionTracer.java | 42 +- .../tracing/OperationsStatistics.java | 60 +- .../truffle/dsl/processor/TruffleTypes.java | 14 +- .../expression/DSLExpressionResolver.java | 19 +- .../generator/FlatNodeGenFactory.java | 71 +- .../generator/NodeGeneratorPlugs.java | 4 + .../dsl/processor/library/ExportsParser.java | 3 +- .../dsl/processor/operations/Operation.java | 222 +++- .../operations/OperationGeneratorFlags.java} | 39 +- .../operations/OperationGeneratorUtils.java | 6 +- .../OperationsBytecodeCodeGenerator.java | 192 ++- .../OperationsBytecodeNodeGeneratorPlugs.java | 75 +- .../operations/OperationsCodeGenerator.java | 1171 +++++++++++++++-- .../operations/OperationsContext.java | 8 +- .../instructions/BranchInstruction.java | 4 +- .../ConditionalBranchInstruction.java | 4 +- .../instructions/CustomInstruction.java | 37 +- .../operations/instructions/FrameKind.java | 20 + .../operations/instructions/Instruction.java | 24 +- .../instructions/LoadLocalInstruction.java | 51 +- .../instructions/ReturnInstruction.java | 6 +- .../instructions/ShortCircuitInstruction.java | 6 +- .../instructions/StoreLocalInstruction.java | 38 +- .../dsl/processor/parser/NodeParser.java | 4 +- .../processor/parser/SpecializationGroup.java | 17 +- .../com/oracle/truffle/sl/SLException.java | 6 + .../sl/parser/SLOperationsVisitor.java | 9 +- 57 files changed, 2573 insertions(+), 1721 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java rename truffle/src/{com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java => com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java} (62%) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index bbe4ac4956e9..9d893a0f8c25 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.test.example; import java.util.function.Consumer; @@ -22,7 +62,7 @@ public class BoxingOperationsTest { - // TODO all of these tests should somehow check that e&s is not called more times + // todo: all of these tests should somehow check that e&s is not called more times // than it needs to private static RootCallTarget parse(Consumer parser) { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 654293e44552..693311482960 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.test.example; import java.util.List; @@ -101,4 +141,4 @@ public static Object doGeneric(VirtualFrame frame, Object value, LocalSetter set return value; } } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index c4ca0dd9682d..caed8027f74e 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.test.example; import java.util.ArrayList; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java index 549d802bdd81..15727b64e027 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.test.example; import com.oracle.truffle.api.frame.VirtualFrame; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index f8765978dfd0..b1f28bafa318 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.exception.AbstractTruffleException; @@ -33,7 +73,7 @@ public AbstractOperationsTruffleException(String message) { private static Node getLocation(Node location, int bci) { if (bci >= 0) { - return ((OperationNode) location.getParent()).createLocationNode(bci); + return ((OperationNode) location).createLocationNode(bci); } else { return location; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java deleted file mode 100644 index 54d6e2c3c85c..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderExceptionHandler.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.oracle.truffle.api.operation; - -public class BuilderExceptionHandler { - public int startBci; - public int startStack; - public int endBci; - public int exceptionIndex; - public int handlerBci; - - public BuilderExceptionHandler() { - } - - private BuilderExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { - this.startBci = startBci; - this.startStack = startStack; - this.endBci = endBci; - this.exceptionIndex = exceptionIndex; - this.handlerBci = handlerBci; - } - - public BuilderExceptionHandler offset(int offset, int stackOffset) { - return new BuilderExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); - } - - @Override - public String toString() { - return String.format("{start=%04x, end=%04x, handler=%04x, index=%d}", startBci, endBci, handlerBci, exceptionIndex); - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java deleted file mode 100644 index c16b0cbd86a2..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderLabelFill.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.oracle.truffle.api.operation; - -class BuilderLabelFill { - int locationBci; - BuilderOperationLabel label; - - BuilderLabelFill(int locationBci, BuilderOperationLabel label) { - this.locationBci = locationBci; - this.label = label; - } - - BuilderLabelFill offset(int offset) { - return new BuilderLabelFill(offset + locationBci, label); - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java deleted file mode 100644 index a03aa7441fbd..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationData.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.oracle.truffle.api.operation; - -public class BuilderOperationData { - public final BuilderOperationData parent; - public final int depth; - public final int stackDepth; - public final int operationId; - public final boolean needsLeave; - public final Object[] aux; - public final Object[] arguments; - public OperationLocal[] localReferences; - public int numChildren = 0; - public int numLocalReferences = 0; - - public BuilderOperationData(BuilderOperationData parent, int id, int stackDepth, int numAux, boolean needsLeave, int numLocalReferences, Object... arguments) { - this.parent = parent; - this.depth = parent == null ? 0 : parent.depth + 1; - this.operationId = id; - this.stackDepth = stackDepth; - this.aux = new Object[numAux]; - this.needsLeave = needsLeave || (parent != null ? parent.needsLeave : false); - this.arguments = arguments; - if (numLocalReferences > 0) { - this.localReferences = new OperationLocal[numLocalReferences]; - } - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java deleted file mode 100644 index a0d26d4c52fe..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLabel.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.oracle.truffle.api.operation; - -public class BuilderOperationLabel extends OperationLabel { - BuilderOperationData data; - boolean hasValue = false; - int targetBci = 0; - BuilderFinallyTryContext finallyTry; - - public BuilderOperationLabel(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { - this.data = data; - this.finallyTry = finallyTry; - } - - boolean belongsTo(BuilderFinallyTryContext context) { - BuilderFinallyTryContext cur = finallyTry; - while (cur != null) { - if (cur == context) { - return true; - } - cur = cur.prev; - } - - return false; - } - - @Override - public String toString() { - if (!hasValue) { - return "BuilderOperationLabel [unresolved]"; - } else { - return String.format("BuilderOperationLabel [target=%04x]", targetBci); - } - } -} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java deleted file mode 100644 index a869eebc75b0..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderOperationLocal.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.oracle.truffle.api.operation; - -class BuilderOperationLocal extends OperationLocal { - final BuilderOperationData owner; - final int id; - - BuilderOperationLocal(BuilderOperationData owner, int id) { - this.owner = owner; - this.id = id; - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java deleted file mode 100644 index c13b4ba558fd..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderSourceInfo.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.oracle.truffle.api.operation; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Stack; - -import com.oracle.truffle.api.operation.OperationNode.SourceInfo; -import com.oracle.truffle.api.source.Source; - -public class BuilderSourceInfo { - - private static final int NOT_AVAILABLE = -1; - - private Stack sourceStack = new Stack<>(); - int currentSource = -1; - - private ArrayList sourceList = new ArrayList<>(); - - private static class SourceData { - final int start; - int length; - final int sourceIndex; - - public SourceData(int start, int sourceIndex) { - this.start = start; - this.sourceIndex = sourceIndex; - } - } - - private ArrayList bciList = new ArrayList<>(); - private ArrayList sourceDataList = new ArrayList<>(); - private Stack sourceDataStack = new Stack<>(); - - public BuilderSourceInfo() { - } - - public void reset() { - sourceStack.clear(); - sourceDataList.clear(); - sourceDataStack.clear(); - bciList.clear(); - } - - public void beginSource(int bci, Source src) { - int idx = -1; - for (int i = 0; i < sourceList.size(); i++) { - if (sourceList.get(i) == src) { - idx = i; - break; - } - } - - if (idx == -1) { - idx = sourceList.size(); - sourceList.add(src); - } - - sourceStack.push(currentSource); - - currentSource = idx; - beginSourceSection(bci, NOT_AVAILABLE); - } - - public void endSource(int bci) { - endSourceSection(bci, NOT_AVAILABLE); - currentSource = sourceStack.pop(); - } - - public void beginSourceSection(int bci, int start) { - - SourceData data = new SourceData(start, currentSource); - - bciList.add(bci); - sourceDataList.add(data); - sourceDataStack.add(data); - } - - public void endSourceSection(int bci, int length) { - SourceData data = sourceDataStack.pop(); - data.length = length; - - SourceData prev; - if (sourceDataStack.isEmpty()) { - prev = new SourceData(-1, currentSource); - prev.length = -1; - } else { - prev = sourceDataStack.peek(); - } - - bciList.add(bci); - sourceDataList.add(prev); - } - - public Source[] buildSource() { - return sourceList.toArray(new Source[sourceList.size()]); - } - - public SourceInfo build() { - if (!sourceStack.isEmpty()) { - throw new IllegalStateException("not all sources ended"); - } - if (!sourceDataStack.isEmpty()) { - throw new IllegalStateException("not all source sections ended"); - } - - int size = bciList.size(); - - int[] bciArray = new int[size]; - int[] startArray = new int[size]; - int[] lengthArray = new int[size]; - int[] sourceIndexArray = new int[size]; - - int index = 0; - int lastBci = -1; - boolean isFirst = true; - - for (int i = 0; i < size; i++) { - SourceData data = sourceDataList.get(i); - int curBci = bciList.get(i); - - if (data.start == NOT_AVAILABLE && isFirst) { - // skip over all leading -1s - continue; - } - - isFirst = false; - - if (curBci == lastBci && index > 1) { - // overwrite if same bci - index--; - } - - bciArray[index] = curBci; - startArray[index] = data.start; - lengthArray[index] = data.length; - sourceIndexArray[index] = data.sourceIndex; - - index++; - lastBci = curBci; - } - - return new SourceInfo( - Arrays.copyOf(bciArray, index), - Arrays.copyOf(sourceIndexArray, index), - Arrays.copyOf(startArray, index), - Arrays.copyOf(lengthArray, index)); - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index c1b7921af56e..ab83633cb110 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; @@ -18,7 +58,7 @@ @Retention(RetentionPolicy.SOURCE) @Target({ElementType.FIELD}) - public @interface Metadata { + @interface Metadata { String name() default ""; } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java index 0dc0d50015f7..4fe3d547345c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetterRange.java @@ -89,6 +89,26 @@ private static synchronized LocalSetterRange[] resizeSubArray(int length, int in public static final LocalSetterRange EMPTY = new LocalSetterRange(0, 0); + public static LocalSetterRange create(int[] indices) { + CompilerAsserts.neverPartOfCompilation("use #get from compiled code"); + if (indices.length == 0) { + return EMPTY; + } else { + assert checkContiguous(indices); + return create(indices[0], indices.length); + } + } + + private static boolean checkContiguous(int[] indices) { + int start = indices[0]; + for (int i = 1; i < indices.length; i++) { + if (start + i != indices[i]) { + return false; + } + } + return true; + } + public static LocalSetterRange create(int start, int length) { CompilerAsserts.neverPartOfCompilation("use #get from compiled code"); if (start < 0 || start > Short.MAX_VALUE) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java index af09ea5df519..80d18ed5a1c2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.Objects; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index 6686067af2dd..2c09200d2db6 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 65e311e1b714..3942f110a36c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -40,790 +40,5 @@ */ package com.oracle.truffle.api.operation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.function.Supplier; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.HostCompilerDirectives; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.impl.FrameWithoutBoxing; -import com.oracle.truffle.api.instrumentation.Tag; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.operation.OperationNode.SourceInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.source.Source; - public abstract class OperationBuilder { - - private final boolean isReparse; - private final ArrayList builtNodes = new ArrayList<>(); - private final OperationNodes nodes; - - private int buildIndex = 0; - private BuilderSourceInfo sourceBuilder; - - protected final boolean withSource; - protected final boolean withInstrumentation; - - protected final short[] bc = new short[65536]; - protected int bci = 0; - protected final OperationsConstantPool constPool = new OperationsConstantPool(); - - protected BuilderOperationData operationData; - protected BuilderFinallyTryContext finallyTryContext; - - protected OperationBuilder(OperationNodes nodes, boolean isReparse, OperationConfig config) { - this.nodes = nodes; - this.isReparse = isReparse; - - if (isReparse) { - builtNodes.addAll(nodes.getNodes()); - } - - this.withSource = config.isWithSource(); - this.withInstrumentation = config.isWithInstrumentation(); - - if (withSource) { - sourceBuilder = new BuilderSourceInfo(); - } else { - sourceBuilder = null; - } - - reset(); - } - - private void reset() { - bci = 0; - curStack = 0; - maxStack = 0; - numLocals = 0; - constPool.reset(); - - operationData = new BuilderOperationData(null, getBlockOperationIndex(), 0, 0, false, 0); - - labelFills.clear(); - - numChildNodes = 0; - numBranchProfiles = 0; - - exceptionHandlers.clear(); - - resetMetadata(); - } - - public final OperationNode publish() { - if (operationData.depth != 0) { - throw new IllegalStateException("Not all operations closed"); - } - - OperationNode result; - if (!isReparse) { - SourceInfo sourceInfo = withSource ? sourceBuilder.build() : null; - result = createNode(nodes, sourceInfo, publishBytecode()); - assignMetadata(result); - assert buildIndex == builtNodes.size(); - builtNodes.add(result); - } else { - result = builtNodes.get(buildIndex); - - if (withSource && !result.hasSourceInfo()) { - result.setSourceInfo(sourceBuilder.build()); - } - - if (withInstrumentation && !result.isBytecodeInstrumented()) { - BytecodeNode instrumentedBytecode = publishBytecode(); - assert instrumentedBytecode instanceof InstrumentedBytecodeNode; - result.changeBytecode(instrumentedBytecode); - } - } - - reset(); - - buildIndex++; - - return result; - } - - protected final void finish() { - if (withSource) { - nodes.setSources(sourceBuilder.buildSource()); - } - if (!isReparse) { - nodes.setNodes(builtNodes.toArray(new OperationNode[0])); - } - } - - private BytecodeNode publishBytecode() { - - labelPass(); - - short[] bcCopy = Arrays.copyOf(bc, bci); - Object[] consts = constPool.getValues(); - Node[] childrenCopy = new Node[numChildNodes]; - BuilderExceptionHandler[] handlers = exceptionHandlers.toArray(new BuilderExceptionHandler[0]); - - ConditionProfile[] conditionProfiles = new ConditionProfile[numBranchProfiles]; - for (int i = 0; i < conditionProfiles.length; i++) { - conditionProfiles[i] = ConditionProfile.createCountingProfile(); - } - - if (withInstrumentation) { - return createInstrumentedBytecode(maxStack, numLocals, bcCopy, consts, childrenCopy, handlers, conditionProfiles); - } else { - return createBytecode(maxStack, numLocals, bcCopy, consts, childrenCopy, handlers, conditionProfiles); - } - } - - protected abstract OperationNode createNode(OperationNodes arg0, Object arg1, BytecodeNode arg2); - - protected abstract BytecodeNode createBytecode(int arg0, int arg1, short[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, ConditionProfile[] arg6); - - protected abstract InstrumentedBytecodeNode createInstrumentedBytecode(int arg0, int arg1, short[] arg2, Object[] arg3, Node[] arg4, BuilderExceptionHandler[] arg5, - ConditionProfile[] arg6); - - protected abstract int getBlockOperationIndex(); - - // ------------------------ branch profiles ------------------------ - - private short numChildNodes; - - protected final short createChildNodes(int count) { - short curIndex = numChildNodes; - numChildNodes += count; - return curIndex; - } - - // ------------------------ branch profiles ------------------------ - - private short numBranchProfiles; - - protected final short createBranchProfile() { - return numBranchProfiles++; - } - - // ------------------------ stack / successor handling ------------------------ - - private int[] stackSourceBci = new int[1024]; - private int curStack; - private int maxStack; - - protected int[] doBeforeEmitInstruction(int numPops, boolean pushValue) { - int[] result = new int[numPops]; - - for (int i = numPops - 1; i >= 0; i--) { - curStack--; - int predBci = stackSourceBci[curStack]; - result[i] = predBci; - } - - if (pushValue) { - stackSourceBci[curStack] = bci; - - curStack++; - - if (curStack > maxStack) { - maxStack = curStack; - } - } - - return result; - } - - protected int createMaxStack() { - return maxStack; - } - - protected int getCurStack() { - return curStack; - } - - protected void setCurStack(int curStack) { - // this should probably be: - // assert this.curStack == curStack; - this.curStack = curStack; - } - - // ------------------------ locals handling ------------------------ - - protected int numLocals; - - public final OperationLocal createLocal() { - BuilderOperationLocal local = new BuilderOperationLocal(operationData, numLocals++); - return local; - } - - protected final OperationLocal createParentLocal() { - BuilderOperationData parent = operationData.parent; - BuilderOperationLocal local = new BuilderOperationLocal(parent, numLocals++); - return local; - } - - protected short getLocalIndex(Object value) { - BuilderOperationLocal local = (BuilderOperationLocal) value; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return (short) local.id; - } - - protected LocalSetter createLocalSetter(Object o) { - BuilderOperationLocal local = (BuilderOperationLocal) o; - return LocalSetter.create(local.id); - } - - protected LocalSetterRange createLocalSetterRange(Object o) { - OperationLocal[] locals = (OperationLocal[]) o; - assert checkLocalSetterRange(locals); - if (locals.length == 0) { - return LocalSetterRange.EMPTY; - } - - return LocalSetterRange.create(getLocalIndex(locals[0]), locals.length); - } - - private static boolean checkLocalSetterRange(OperationLocal[] locals) { - if (locals.length == 0) { - return true; - } - int start = ((BuilderOperationLocal) locals[0]).id; - for (int i = 0; i < locals.length; i++) { - if (((BuilderOperationLocal) locals[i]).id != start + i) { - return false; - } - } - - return true; - } - - private static boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { - BuilderOperationData cur = child; - while (cur.depth > parent.depth) { - cur = cur.parent; - } - - return cur == parent; - } - - // ------------------------ source sections ------------------------ - - public final void beginSource(Source source) { - if (withSource) { - sourceBuilder.beginSource(bci, source); - } - } - - public final void beginSource(Supplier supplier) { - if (withSource) { - sourceBuilder.beginSource(bci, supplier.get()); - } - } - - public final void endSource() { - if (withSource) { - sourceBuilder.endSource(bci); - } - } - - public final void beginSourceSection(int start) { - if (withSource) { - sourceBuilder.beginSourceSection(bci, start); - } - } - - public final void endSourceSection(int length) { - if (withSource) { - sourceBuilder.endSourceSection(bci, length); - } - } - - // ------------------------------- labels ------------------------------- - - private ArrayList labelFills = new ArrayList<>(); - private ArrayList labels = new ArrayList<>(); - - @SuppressWarnings("unused") - protected final void putBranchTarget(short[] unusedBc, int locationBci, Object label) { - BuilderLabelFill fill = new BuilderLabelFill(locationBci, (BuilderOperationLabel) label); - labelFills.add(fill); - } - - protected final void labelPass() { - labelPass(null); - } - - private void labelPass(BuilderFinallyTryContext finallyTry) { - for (BuilderLabelFill fill : labelFills) { - if (finallyTry != null) { - if (fill.label.belongsTo(finallyTry)) { - assert fill.label.hasValue : "inner label should have been resolved by now"; - finallyTry.relocationOffsets.add(fill.locationBci); - } else { - finallyTry.handlerLabelFills.add(fill); - } - } - - bc[fill.locationBci] = (short) fill.label.targetBci; - } - } - - public final OperationLabel createLabel() { - BuilderOperationLabel label = new BuilderOperationLabel(operationData, currentFinallyTry); - labels.add(label); - return label; - } - - protected abstract void doLeaveOperation(BuilderOperationData data); - - protected final void calculateLeaves(BuilderOperationData fromData) { - calculateLeaves(fromData, (BuilderOperationData) null); - } - - protected final void calculateLeaves(BuilderOperationData fromData, Object toLabel) { - calculateLeaves(fromData, ((BuilderOperationLabel) toLabel).data); - } - - protected final void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { - if (toData != null && fromData.depth < toData.depth) { - throw new UnsupportedOperationException("illegal jump to deeper operation"); - } - - if (fromData == toData) { - return; // nothing to leave - } - - BuilderOperationData cur = fromData; - while (true) { - doLeaveOperation(cur); - cur = cur.parent; - - if (toData == null && cur == null) { - break; - } else if (toData != null && cur.depth <= toData.depth) { - break; - } - } - - if (cur != toData) { - throw new UnsupportedOperationException("illegal jump to non-parent operation"); - } - } - - @SuppressWarnings("unused") - protected final int doBranchInstruction(int instr, OperationLabel label) { - putBranchTarget(bc, bci, label); - return 2; - } - - protected final void doEmitLabel(OperationLabel label) { - BuilderOperationLabel lbl = (BuilderOperationLabel) label; - if (lbl.hasValue) { - throw new UnsupportedOperationException("label already emitted"); - } - if (operationData != lbl.data) { - throw new UnsupportedOperationException("label must be created and emitted inside same operation"); - } - lbl.hasValue = true; - lbl.targetBci = bci; - } - - // ------------------------ exceptions ------------------------ - - private ArrayList exceptionHandlers = new ArrayList<>(); - - protected final void addExceptionHandler(BuilderExceptionHandler handler) { - exceptionHandlers.add(handler); - } - - // ------------------------ try / finally ------------------------ - - private BuilderFinallyTryContext currentFinallyTry = null; - - protected final Object doBeginFinallyTry() { - - // save outer code - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - - // reset builder for handler - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - - return currentFinallyTry; - } - - protected final void doEndFinallyBlock() { - labelPass(currentFinallyTry); - - // save handler code - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - - // restore outer code - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - - currentFinallyTry = currentFinallyTry.prev; - - } - - protected final void doLeaveFinallyTry(BuilderOperationData opData) { - BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; - - if (!context.finalized()) { - // leave out of a finally block - return; - } - - System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); - - for (int offset : context.relocationOffsets) { - short oldOffset = bc[bci + offset]; - - bc[bci + offset] = (short) (oldOffset + bci); - } - - for (BuilderExceptionHandler handler : context.handlerHandlers) { - addExceptionHandler(handler.offset(bci, curStack)); - } - - for (BuilderLabelFill fill : context.handlerLabelFills) { - labelFills.add(fill.offset(bci)); - } - - if (maxStack < curStack + context.handlerMaxStack) { - maxStack = curStack + context.handlerMaxStack; - } - - bci += context.handlerBc.length; - } - - // ------------------------ instrumentation ------------------------ - - @SuppressWarnings({"static-method", "unused"}) - protected final int doBeginInstrumentation(Class cls) { - // TODO - return 0; - } - - // ------------------------ metadata ------------------------ - - protected abstract void resetMetadata(); - - protected abstract void assignMetadata(OperationNode node); - - // ------------------------ nodes ------------------------ - - protected abstract static class BytecodeNode extends Node implements BytecodeOSRNode { - - // Thevalues of these must be the same as FrameKind.ordinal && Frame tags - public static final int FRAME_TYPE_OBJECT = 0; - public static final int FRAME_TYPE_LONG = 1; - public static final int FRAME_TYPE_INT = 2; - public static final int FRAME_TYPE_DOUBLE = 3; - public static final int FRAME_TYPE_FLOAT = 4; - public static final int FRAME_TYPE_BOOLEAN = 5; - public static final int FRAME_TYPE_BYTE = 6; - public static final int FRAME_TYPE_ILLEGAL = 7; - - static { - assert FRAME_TYPE_OBJECT == FrameSlotKind.Object.tag; - assert FRAME_TYPE_LONG == FrameSlotKind.Long.tag; - assert FRAME_TYPE_INT == FrameSlotKind.Int.tag; - assert FRAME_TYPE_DOUBLE == FrameSlotKind.Double.tag; - assert FRAME_TYPE_FLOAT == FrameSlotKind.Float.tag; - assert FRAME_TYPE_BOOLEAN == FrameSlotKind.Boolean.tag; - assert FRAME_TYPE_BYTE == FrameSlotKind.Byte.tag; - assert FRAME_TYPE_ILLEGAL == FrameSlotKind.Illegal.tag; - } - - protected final int maxStack; - protected final int maxLocals; - - @CompilationFinal(dimensions = 1) protected final short[] bc; - @CompilationFinal(dimensions = 1) protected final Object[] consts; - @Children protected final Node[] children; - @CompilationFinal(dimensions = 1) protected final BuilderExceptionHandler[] handlers; - @CompilationFinal(dimensions = 1) protected final ConditionProfile[] conditionProfiles; - - protected static final int VALUES_OFFSET = 0; - - protected BytecodeNode(int maxStack, int maxLocals, short[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, ConditionProfile[] conditionProfiles) { - this.maxStack = maxStack; - this.maxLocals = maxLocals; - this.bc = bc; - this.consts = consts; - this.children = children; - this.handlers = handlers; - this.conditionProfiles = conditionProfiles; - } - - FrameDescriptor createFrameDescriptor() { - FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); - builder.addSlots(maxLocals, FrameSlotKind.Illegal); - builder.addSlots(maxStack, FrameSlotKind.Illegal); - return builder.build(); - } - - Object execute(VirtualFrame frame) { - return continueAt(frame, 0, maxLocals + VALUES_OFFSET); - } - - protected abstract Object continueAt(VirtualFrame frame, int bci, int sp); - - boolean isInstrumented() { - return false; - } - - // OSR - - @CompilationFinal private Object osrMetadata; - - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return continueAt(osrFrame, target, (int) interpreterState); - } - - public Object getOSRMetadata() { - return osrMetadata; - } - - public void setOSRMetadata(Object osrMetadata) { - this.osrMetadata = osrMetadata; - } - - // boxing elim - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, short[] descriptor) { - int op = bc[bci] & 0xffff; - short todo = descriptor[op]; - - if (todo > 0) { - // quicken - bc[bci] = todo; - } else { - // set bit - int offset = (todo >> 8) & 0x7f; - int bit = todo & 0xff; - if (targetType == FRAME_TYPE_OBJECT) { - bc[bci + offset] &= ~bit; - } else { - bc[bci + offset] |= bit; - } - } - } - - protected static Object expectObject(VirtualFrame frame, int slot) { - if (frame.isObject(slot)) { - return frame.getObject(slot); - } else { - // this should only happen in edge cases, when we have specialized to a generic case - // on one thread, but other threads have already executed the child with primitive - // return type - CompilerDirectives.transferToInterpreterAndInvalidate(); - return frame.getValue(slot); - } - } - - protected static byte expectByte(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.BYTE_TAG: - return frame.getByte(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Byte) { - return (byte) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.BOOLEAN_TAG: - return frame.getBoolean(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - protected static int expectInt(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.INT_TAG: - return frame.getInt(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Integer) { - return (int) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - protected static float expectFloat(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.FLOAT_TAG: - return frame.getFloat(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Float) { - return (float) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.LONG_TAG: - return frame.getLong(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - private static UnexpectedResultException throwUnexpectedValue(VirtualFrame frame, int slot) { - return new UnexpectedResultException(frame.getValue(slot)); - } - - protected static double expectDouble(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case FrameWithoutBoxing.DOUBLE_TAG: - return frame.getDouble(slot); - case FrameWithoutBoxing.OBJECT_TAG: - Object value = frame.getObject(slot); - if (value instanceof Double) { - return (double) value; - } - break; - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw throwUnexpectedValue(frame, slot); - } - - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { - try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { - try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - protected static boolean storeLocalIntCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Int) { - try { - frame.setInt(localSlot, expectInt(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - protected static boolean storeLocalDoubleCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Double) { - try { - frame.setDouble(localSlot, expectDouble(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - protected abstract String dump(); - - protected static String formatConstant(Object obj) { - if (obj == null) { - return "null"; - } else { - Object repr = obj; - if (repr instanceof Object[]) { - repr = Arrays.deepToString((Object[]) obj); - } - return String.format("%s %s", obj.getClass().getSimpleName(), repr); - } - } - } - - protected abstract static class InstrumentedBytecodeNode extends BytecodeNode { - - protected InstrumentedBytecodeNode(int maxStack, int maxLocals, short[] bc, Object[] consts, Node[] children, BuilderExceptionHandler[] handlers, - ConditionProfile[] conditionProfiles) { - super(maxStack, maxLocals, bc, consts, children, handlers, conditionProfiles); - } - - @Override - boolean isInstrumented() { - return true; - } - } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java index cd98378d65ae..3fcccccaa3f7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; public final class OperationConfig { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java index 3289d438e83f..3e18ca74b7b2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLabel.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; public abstract class OperationLabel { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java index e0fedc17ff56..63447fef538c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationLocal.java @@ -1,5 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; -public class OperationLocal { +public abstract class OperationLocal { } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 46c9e10a5b68..cca51545d045 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -1,60 +1,74 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.function.Function; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode; import com.oracle.truffle.api.source.SourceSection; public abstract class OperationNode extends Node { - private final OperationNodes nodes; - @CompilationFinal private SourceInfo sourceInfo; + protected final OperationNodes nodes; - @Child private BytecodeNode bcNode; + private static final int SOURCE_INFO_BCI_INDEX = 0; + private static final int SOURCE_INFO_START = 1; + private static final int SOURCE_INFO_LENGTH = 2; + private static final int SOURCE_INFO_STRIDE = 3; - protected OperationNode(OperationNodes nodes, Object sourceInfo, BytecodeNode bcNode) { + protected OperationNode(OperationNodes nodes) { this.nodes = nodes; - this.sourceInfo = (SourceInfo) sourceInfo; - this.bcNode = bcNode; } - public FrameDescriptor createFrameDescriptor() { - return bcNode.createFrameDescriptor(); - } - - public Object execute(VirtualFrame frame) { - return bcNode.execute(frame); - } - - public T getMetadata(MetadataKey key) { - return key.getValue(this); - } + protected abstract int[] getSourceInfo(); - // ------------------------------------ internal accessors ------------------------------------ + public abstract FrameDescriptor createFrameDescriptor(); - boolean isBytecodeInstrumented() { - return bcNode.isInstrumented(); - } - - void changeBytecode(BytecodeNode node) { - CompilerAsserts.neverPartOfCompilation(); - bcNode = insert(node); - } - - boolean hasSourceInfo() { - return sourceInfo != null; - } + public abstract Object execute(VirtualFrame frame); - void setSourceInfo(SourceInfo sourceInfo) { - CompilerAsserts.neverPartOfCompilation(); - assert !hasSourceInfo() : "already have source info"; - this.sourceInfo = sourceInfo; + public final T getMetadata(MetadataKey key) { + return key.getValue(this); } protected static void setMetadataAccessor(MetadataKey key, Function getter) { @@ -64,18 +78,20 @@ protected static void setMetadataAccessor(MetadataKey key, Function= 0) { + for (int i = 0; i < sourceInfo.length; i += SOURCE_INFO_STRIDE) { + if (sourceInfo[i + SOURCE_INFO_START] >= 0) { // return the first defined source section - that one should encompass the entire // function - return nodes.sources[sourceInfo.sourceIndex[i]].createSection(sourceInfo.sourceStart[i], sourceInfo.sourceLength[i]); + return nodes.sources[sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16].createSection(sourceInfo[i + SOURCE_INFO_START], sourceInfo[i + SOURCE_INFO_LENGTH]); } } @@ -86,14 +102,16 @@ public SourceSection getSourceSection() { protected final SourceSection getSourceSectionAtBci(int bci) { nodes.ensureSources(); + int[] sourceInfo = getSourceInfo(); + if (sourceInfo == null) { return null; } int i; // find the index of the first greater BCI - for (i = 0; i < sourceInfo.length(); i++) { - if (sourceInfo.bci[i] > bci) { + for (i = 0; i < sourceInfo.length; i += SOURCE_INFO_STRIDE) { + if ((sourceInfo[i + SOURCE_INFO_BCI_INDEX] & 0xffff) > bci) { break; } } @@ -101,13 +119,14 @@ protected final SourceSection getSourceSectionAtBci(int bci) { if (i == 0) { return null; } else { - int sourceIndex = sourceInfo.sourceIndex[i - 1]; + i -= SOURCE_INFO_STRIDE; + int sourceIndex = sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16; if (sourceIndex < 0) { return null; } - int sourceStart = sourceInfo.sourceStart[i - 1]; - int sourceLength = sourceInfo.sourceLength[i - 1]; + int sourceStart = sourceInfo[i + SOURCE_INFO_START]; + int sourceLength = sourceInfo[i + SOURCE_INFO_LENGTH]; if (sourceStart < 0) { return null; } @@ -115,28 +134,6 @@ protected final SourceSection getSourceSectionAtBci(int bci) { } } - static class SourceInfo { - @CompilationFinal(dimensions = 1) final int[] bci; - @CompilationFinal(dimensions = 1) final int[] sourceIndex; - @CompilationFinal(dimensions = 1) final int[] sourceStart; - @CompilationFinal(dimensions = 1) final int[] sourceLength; - - SourceInfo(int[] bci, int[] sourceIndex, int[] start, int[] length) { - assert bci.length == sourceIndex.length; - assert bci.length == start.length; - assert bci.length == length.length; - - this.bci = bci; - this.sourceIndex = sourceIndex; - this.sourceStart = start; - this.sourceLength = length; - } - - int length() { - return bci.length; - } - } - public final Node createLocationNode(final int bci) { return new Node() { @Override @@ -151,8 +148,5 @@ public SourceSection getEncapsulatingSourceSection() { }; } - public final String dump() { - return bcNode.dump(); - } - + public abstract String dump(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 015ecaae85a2..387b17804256 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.util.List; @@ -10,8 +50,8 @@ public abstract class OperationNodes { private final Consumer parse; - @CompilationFinal(dimensions = 1) private OperationNode[] nodes; - @CompilationFinal(dimensions = 1) Source[] sources; + @CompilationFinal(dimensions = 1) protected OperationNode[] nodes; + @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; protected OperationNodes(Consumer parse) { @@ -22,18 +62,10 @@ public List getNodes() { return List.of(nodes); } - void setNodes(OperationNode[] nodes) { - this.nodes = nodes; - } - public boolean hasSources() { return sources != null; } - void setSources(Source[] sources) { - this.sources = sources; - } - public boolean hasInstrumentation() { return hasInstrumentation; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java index 0bd768f4155d..901bcbb4a220 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxies.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java index 80e558d5ab22..904dcfee281b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationProxy.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java deleted file mode 100644 index 717df8c6ede7..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsBytesSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.oracle.truffle.api.operation; - -public class OperationsBytesSupport { - public static final OperationsBytesSupport INSTANCE = new OperationsBytesSupport(); - - public static OperationsBytesSupport littleEndian() { - return INSTANCE; - } - - private OperationsBytesSupport() { - } - - @SuppressWarnings("static-method") - public final byte getByte(byte[] data, int index) { - return data[index]; - } - - @SuppressWarnings("static-method") - public final void putByte(byte[] data, int index, byte value) { - data[index] = value; - } - - @SuppressWarnings("static-method") - public final short getShort(byte[] data, int index) { - return (short) (((data[index + 1] & 0xff) << 8) | (data[index] & 0xff)); - } - - @SuppressWarnings("static-method") - public final void putShort(byte[] data, int index, short value) { - data[index] = (byte) (value & 0xff); - data[index + 1] = (byte) ((value >>> 8) & 0xff); - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java deleted file mode 100644 index 5163585fda64..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsConstantPool.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.api.operation; - -import java.util.ArrayList; - -public class OperationsConstantPool { - - private ArrayList values = new ArrayList<>(); - private boolean frozen = false; - private Object[] frozenValues = null; - - public synchronized int add(Object o) { - if (frozen) { - throw new IllegalStateException("constant pool already frozen"); - } - int idx = values.indexOf(o); - if (idx == -1) { - idx = values.size(); - values.add(o); - } - return idx; - } - - public synchronized int reserve() { - return reserve(1); - } - - public synchronized int reserve(int count) { - if (frozen) { - throw new IllegalStateException("constant pool already frozen"); - } - int idx = values.size(); - for (int i = 0; i < count; i++) { - values.add(null); - } - return idx; - } - - public synchronized void reset() { - this.frozen = false; - this.values = new ArrayList<>(); - this.frozenValues = null; - } - - public void setValue(int offset, Object value) { - values.set(offset, value); - } - - public synchronized void freeze() { - frozen = true; - } - - public synchronized Object[] getValues() { - freeze(); - if (frozenValues == null) { - frozenValues = values.toArray(); - values = null; - } - return frozenValues; - } - -} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java index 40f9404efea7..889718b0bffa 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsInstrumentTreeNode.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.instrumentation.InstrumentableNode; @@ -11,7 +51,7 @@ private static class Wrapper extends OperationsInstrumentTreeNode implements Wra private final Node delegateNode; private final ProbeNode probeNode; - public Wrapper(OperationsInstrumentTreeNode delegateNode, ProbeNode probeNode) { + Wrapper(OperationsInstrumentTreeNode delegateNode, ProbeNode probeNode) { super(delegateNode.tag); this.delegateNode = delegateNode; this.probeNode = probeNode; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java index 38ebc45d61a8..165a77c1aaf0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationsStackTraceElement.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -15,7 +55,7 @@ final class OperationsStackTraceElement implements TruffleObject { private final SourceSection sourceSection; private final RootNode rootNode; - public OperationsStackTraceElement(RootNode rootNode, SourceSection sourceSection) { + OperationsStackTraceElement(RootNode rootNode, SourceSection sourceSection) { this.rootNode = rootNode; this.sourceSection = sourceSection; } @@ -58,4 +98,4 @@ boolean hasDeclaringMetaObject() { Object getDeclaringMetaObject() throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java index 5c3d0fc5b1b4..d6b18e21a762 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperation.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; @@ -15,4 +55,4 @@ boolean continueWhen(); Class booleanConverter() default void.class; -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java index 9426afe1d15d..fc4fc559e677 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ShortCircuitOperations.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import java.lang.annotation.ElementType; @@ -9,4 +49,4 @@ @Target(ElementType.TYPE) public @interface ShortCircuitOperations { ShortCircuitOperation[] value(); -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java index 91aa3cf20fb1..d32fea0fcd97 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Variadic.java @@ -1,5 +1,51 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; -public @interface Variadic { +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.PARAMETER) +public @interface Variadic { } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index 1bcb3d2ef192..9c1e7ee35e5f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.tracing; import java.util.HashMap; @@ -36,4 +76,4 @@ public static void initialize(Class opsClass, String decisionsFile, String[] public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations); public abstract void traceSpecialization(int bci, int id, int specializationId, Object... values); -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 636c9f9efe7f..48af627c1578 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.tracing; import java.io.IOException; @@ -114,7 +154,7 @@ static final class GlobalOperationStatistics { private String[] instrNames; private String[][] specNames; - public GlobalOperationStatistics(Class opsClass) { + GlobalOperationStatistics(Class opsClass) { this.opsClass = opsClass; } @@ -224,12 +264,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } SpecializationKey other = (SpecializationKey) obj; return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId == other.instructionId; } @@ -365,12 +408,9 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats) { result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); int numDecisions = 10; - activeSpecializationsMap.entrySet().stream() // - .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) // - .limit(numDecisions) // - .forEachOrdered(e -> { - result.put(e.getKey().serializeDecision(stats)); - }); + activeSpecializationsMap.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).limit(numDecisions).forEachOrdered(e -> { + result.put(e.getKey().serializeDecision(stats)); + }); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 1b03c6c8dac1..5750b2b8045a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -77,6 +77,7 @@ public class TruffleTypes { // Truffle API public static final String Assumption_Name = "com.oracle.truffle.api.Assumption"; + public static final String BytecodeOSRNode_Name = "com.oracle.truffle.api.nodes.BytecodeOSRNode"; public static final String CompilerAsserts_Name = "com.oracle.truffle.api.CompilerAsserts"; public static final String CompilerDirectives_CompilationFinal_Name = "com.oracle.truffle.api.CompilerDirectives.CompilationFinal"; public static final String CompilerDirectives_Name = "com.oracle.truffle.api.CompilerDirectives"; @@ -85,6 +86,8 @@ public class TruffleTypes { public static final String EncapsulatingNodeReference_Name = "com.oracle.truffle.api.nodes.EncapsulatingNodeReference"; public static final String ExplodeLoop_Name = "com.oracle.truffle.api.nodes.ExplodeLoop"; public static final String Frame_Name = "com.oracle.truffle.api.frame.Frame"; + public static final String FrameDescriptor_Name = "com.oracle.truffle.api.frame.FrameDescriptor"; + public static final String FrameSlotKind_Name = "com.oracle.truffle.api.frame.FrameSlotKind"; public static final String FinalBitSet_Name = "com.oracle.truffle.api.utilities.FinalBitSet"; public static final String InvalidAssumptionException_Name = "com.oracle.truffle.api.nodes.InvalidAssumptionException"; public static final String MaterializedFrame_Name = "com.oracle.truffle.api.frame.MaterializedFrame"; @@ -98,6 +101,7 @@ public class TruffleTypes { public static final String Option_Group_Name = "com.oracle.truffle.api.Option.Group"; public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; + public static final String RootNode_Name = "com.oracle.truffle.api.nodes.RootNode"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; public static final String Source_Name = "com.oracle.truffle.api.source.Source"; public static final String SourceSection_Name = "com.oracle.truffle.api.source.SourceSection"; @@ -112,6 +116,7 @@ public class TruffleTypes { public static final String HostLanguage_Name = "com.oracle.truffle.polyglot.HostLanguage"; public final DeclaredType Assumption = c.getDeclaredType(Assumption_Name); + public final DeclaredType BytecodeOSRNode = c.getDeclaredType(BytecodeOSRNode_Name); public final DeclaredType CompilerAsserts = c.getDeclaredType(CompilerAsserts_Name); public final DeclaredType CompilerDirectives = c.getDeclaredType(CompilerDirectives_Name); public final DeclaredType CompilerDirectives_CompilationFinal = c.getDeclaredType(CompilerDirectives_CompilationFinal_Name); @@ -120,6 +125,8 @@ public class TruffleTypes { public final DeclaredType EncapsulatingNodeReference = c.getDeclaredType(EncapsulatingNodeReference_Name); public final DeclaredType ExplodeLoop = c.getDeclaredType(ExplodeLoop_Name); public final DeclaredType Frame = c.getDeclaredType(Frame_Name); + public final DeclaredType FrameDescriptor = c.getDeclaredType(FrameDescriptor_Name); + public final DeclaredType FrameSlotKind = c.getDeclaredType(FrameSlotKind_Name); public final DeclaredType FinalBitSet = c.getDeclaredType(FinalBitSet_Name); public final DeclaredType InvalidAssumptionException = c.getDeclaredType(InvalidAssumptionException_Name); public final DeclaredType MaterializedFrame = c.getDeclaredType(MaterializedFrame_Name); @@ -131,6 +138,7 @@ public class TruffleTypes { public final DeclaredType NodeInterface = c.getDeclaredType(NodeInterface_Name); public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); + public final DeclaredType RootNode = c.getDeclaredTypeOptional(RootNode_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); public final DeclaredType Source = c.getDeclaredType(Source_Name); public final DeclaredType SourceSection = c.getDeclaredType(SourceSection_Name); @@ -228,9 +236,6 @@ public class TruffleTypes { public final DeclaredType UnsupportedSpecializationException = c.getDeclaredType(UnsupportedSpecializationException_Name); // Operation DSL API - public static final String BuilderExceptionHandler_Name = "com.oracle.truffle.api.operation.BuilderExceptionHandler"; - public static final String BuilderOperationData_Name = "com.oracle.truffle.api.operation.BuilderOperationData"; - public static final String BuilderOperationLabel_Name = "com.oracle.truffle.api.operation.BuilderOperationLabel"; public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo"; public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations"; public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata"; @@ -253,9 +258,6 @@ public class TruffleTypes { public static final String ShortCircuitOperation_Name = "com.oracle.truffle.api.operation.ShortCircuitOperation"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; - public final DeclaredType BuilderExceptionHandler = c.getDeclaredTypeOptional(BuilderExceptionHandler_Name); - public final DeclaredType BuilderOperationData = c.getDeclaredTypeOptional(BuilderOperationData_Name); - public final DeclaredType BuilderOperationLabel = c.getDeclaredTypeOptional(BuilderOperationLabel_Name); public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name); public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index 8c0f5e6c8ca2..ee24a0d6e000 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -68,6 +68,7 @@ import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.parser.NodeParser.ParseMode; public class DSLExpressionResolver implements DSLExpressionVisitor { @@ -85,16 +86,18 @@ public class DSLExpressionResolver implements DSLExpressionVisitor { private final List unprocessedElements; private boolean processed; + private final ParseMode parseMode; - private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements) { + private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements, ParseMode parseMode) { this.context = context; this.parent = parent; this.accessType = accessType; this.unprocessedElements = new ArrayList<>(lookupElements); + this.parseMode = parseMode; } - public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements) { - this(context, accessType, null, lookupElements); + public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements, ParseMode parseMode) { + this(context, accessType, null, lookupElements, parseMode); } public TypeElement getAccessType() { @@ -132,7 +135,7 @@ private void processElements(List lookupElements) { } public DSLExpressionResolver copy(List prefixElements) { - return new DSLExpressionResolver(context, accessType, this, prefixElements); + return new DSLExpressionResolver(context, accessType, this, prefixElements, parseMode); } private static String getMethodName(ExecutableElement method) { @@ -229,6 +232,10 @@ private static boolean matchExecutable(Call call, ExecutableElement method) { private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); + if (parseMode == ParseMode.OPERATION && "this".equals(name)) { + return new CodeVariableElement(ProcessorContext.getInstance().getTypes().OperationNode, "$this"); + } + switch (name) { case "null": return new CodeVariableElement(new CodeTypeMirror(TypeKind.NULL), "null"); @@ -279,7 +286,7 @@ public void visitCall(Call call) { } } } - resolver = new DSLExpressionResolver(context, this.accessType, elements); + resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode); } ExecutableElement resolvedMethod = resolver.resolveCall(call); @@ -323,7 +330,7 @@ public void visitVariable(Variable variable) { } else if (type.getKind() == TypeKind.ARRAY) { elements.add(new CodeVariableElement(context.getType(int.class), "length")); } - resolver = new DSLExpressionResolver(context, this.accessType, elements); + resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode); } VariableElement var = resolver.resolveVariable(variable); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index ae343cea3404..d6fcae1e3ec1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -665,7 +665,10 @@ public CodeTypeElement create(CodeTypeElement clazz) { } clazz.addOptional(createExecuteAndSpecialize()); - final ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); + ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); + if (plugs != null) { + reportPolymorphismAction = plugs.createReportPolymorhoismAction(reportPolymorphismAction); + } if (reportPolymorphismAction.required()) { clazz.addOptional(createCheckForPolymorphicSpecialize(reportPolymorphismAction)); if (requiresCacheCheck(reportPolymorphismAction)) { @@ -825,9 +828,11 @@ private void generateAOT(CodeTypeElement clazz) { } } + CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); + builder.startAssert(); builder.string("!isAdoptable() || "); - builder.string("(").cast(context.getType(ReentrantLock.class), CodeTreeBuilder.singleString("getLock()")); + builder.string("(").cast(context.getType(ReentrantLock.class), getLockTree); builder.string(").isHeldByCurrentThread()"); builder.string(" : ").doubleQuote("During prepare AST lock must be held."); builder.end(); @@ -2151,8 +2156,15 @@ private CodeExecutableElement createExecuteAndSpecialize() { plugs.initializeFrameState(frameState, builder); } + CodeTree getLockTree; + if (plugs != null) { + getLockTree = plugs.createGetLock(); + } else { + getLockTree = CodeTreeBuilder.singleString("getLock()"); + } + if (needsSpecializeLocking) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); + builder.declaration(context.getType(Lock.class), "lock", getLockTree); builder.declaration(context.getType(boolean.class), "hasLock", "true"); builder.statement("lock.lock()"); } @@ -2174,7 +2186,7 @@ private CodeExecutableElement createExecuteAndSpecialize() { if (plugs != null) { resetName = plugs.transformNodeMethodName(resetName); } - builder.startStatement().startCall("this." + resetName); + builder.startStatement().startCall(resetName); if (plugs != null) { plugs.addNodeCallParameters(builder, false, false); } @@ -2198,7 +2210,7 @@ private CodeExecutableElement createExecuteAndSpecialize() { builder.tree(execution); - if (group.hasFallthrough()) { + if (group.hasFallthroughInSlowPath()) { builder.tree(createThrowUnsupported(builder, originalFrameState)); } @@ -2409,6 +2421,8 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram ExecutableElement method = parent.findMethod(); if (method != null && method.getModifiers().contains(STATIC)) { builder.string("null"); + } else if (generatorMode == GeneratorMode.OPERATIONS) { + builder.string("$this"); } else { builder.string("this"); } @@ -3733,6 +3747,8 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization boolean useSpecializationClass = specialization != null && useSpecializationClass(specialization); boolean needsRewrites = needsRewrites(); + String encapsulatingThis = generatorMode == GeneratorMode.OPERATIONS ? "$this" : "this"; + if (mode.isFastPath()) { BlockState ifCount = BlockState.NONE; @@ -3806,7 +3822,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } if (pushEncapsulatingNode && libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(builder, "this"); + GeneratorUtils.pushEncapsulatingNode(builder, encapsulatingThis); builder.startTryBlock(); } @@ -3858,7 +3874,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } if (pushEncapsulatingNode && !libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(innerBuilder, "this"); + GeneratorUtils.pushEncapsulatingNode(innerBuilder, encapsulatingThis); innerBuilder.startTryBlock(); } @@ -3930,7 +3946,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization boolean pushBoundary = specialization.needsPushEncapsulatingNode(); if (pushBoundary) { builder.startBlock(); - GeneratorUtils.pushEncapsulatingNode(builder, "this"); + GeneratorUtils.pushEncapsulatingNode(builder, encapsulatingThis); builder.startTryBlock(); } BlockState innerIfCount = BlockState.NONE; @@ -4509,10 +4525,6 @@ private Collection initializeSpecializationClass(FrameState GeneratedTypeMirror type = new GeneratedTypeMirror("", typeName); CodeTreeBuilder initBuilder = new CodeTreeBuilder(null); - boolean isNode = specializationClassIsNode(specialization); - if (isNode) { - initBuilder.startCall("super", "insert"); - } initBuilder.startNew(typeName); if (specialization.getMaximumNumberOfInstances() > 1) { if (plugs != null) { @@ -4523,12 +4535,17 @@ private Collection initializeSpecializationClass(FrameState } } initBuilder.end(); // new - if (isNode) { - initBuilder.end(); - } CodeTree init = initBuilder.build(); + if (specializationClassIsNode(specialization)) { + if (plugs != null) { + init = plugs.createSuperInsert(init); + } else { + init = CodeTreeBuilder.createBuilder().startCall("super", "insert").tree(init).end().build(); + } + } + CodeTreeBuilder builder = new CodeTreeBuilder(null); builder.startStatement(); if (frameState.get(localName) == null) { @@ -4660,7 +4677,8 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState // slow path might be already already locked if (!frameState.getMode().isSlowPath()) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); + CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); + builder.declaration(context.getType(Lock.class), "lock", getLockTree); } if (needsSpecializeLocking) { @@ -4734,7 +4752,8 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, } if (needsSpecializeLocking) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); + CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); + builder.declaration(context.getType(Lock.class), "lock", getLockTree); builder.statement("lock.lock()"); builder.startTryBlock(); } @@ -4765,7 +4784,11 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.startIf().string("prev == null").end().startBlock(); builder.startStatement().tree(fieldRefWrite).string(" = "); if (specializedIsNode) { - builder.string("this.insert"); + if (generatorMode == GeneratorMode.OPERATIONS) { + builder.string("$this.insertAccessor"); + } else { + builder.string("this.insert"); + } } builder.string("(cur.next_)").end(); builder.end().startElseBlock(); @@ -5012,6 +5035,8 @@ private Collection persistCache(FrameState frameState, SpecializationD String insertTarget; if (useSpecializationClass) { insertTarget = createSpecializationLocalName(specialization); + } else if (generatorMode == GeneratorMode.OPERATIONS) { + insertTarget = "$this"; } else { insertTarget = "super"; } @@ -5027,7 +5052,11 @@ private Collection persistCache(FrameState frameState, SpecializationD builder = new CodeTreeBuilder(null); String insertName; if (cache.isAdopt()) { - insertName = useSpecializationClass ? useInsertAccessor(specialization, isNodeInterfaceArray) : "insert"; + insertName = useSpecializationClass + ? useInsertAccessor(specialization, isNodeInterfaceArray) + : (generatorMode == GeneratorMode.OPERATIONS + ? "insertAccessor" + : "insert"); } else { insertName = null; } @@ -5114,7 +5143,9 @@ private Collection storeCache(FrameState frameState, SpecializationDat CodeTree useValue; if ((ElementUtils.isAssignable(type, types.Node) || ElementUtils.isAssignable(type, new ArrayCodeTypeMirror(types.Node))) && (!cache.isAlwaysInitialized()) && cache.isAdopt()) { - useValue = builder.create().startCall("super.insert").tree(value).end().build(); + useValue = plugs != null + ? plugs.createSuperInsert(value) + : CodeTreeBuilder.createBuilder().startCall("super.insert").tree(value).end().build(); } else { useValue = value; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 3b9a85715e48..1480f937f66c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -123,4 +123,8 @@ public interface NodeGeneratorPlugs { StaticConstants createConstants(); ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original); + + CodeTree createGetLock(); + + CodeTree createSuperInsert(CodeTree value); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java index a3c04a9bd758..b428612cd140 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java @@ -103,6 +103,7 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; +import com.oracle.truffle.dsl.processor.parser.NodeParser.ParseMode; public class ExportsParser extends AbstractParser { @@ -696,7 +697,7 @@ private ExportsData parseExports(TypeElement type, List elemen String transitionLimit = ElementUtils.getAnnotationValue(String.class, annotationMirror, "transitionLimit", false); if (transitionLimit != null) { DSLExpressionResolver resolver = new DSLExpressionResolver(context, model.getTemplateType(), - NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false)); + NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false), ParseMode.EXPORTED_MESSAGE); try { DSLExpression expression = DSLExpression.parse(transitionLimit); expression.accept(resolver); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index c0cc52abaaab..ea7727a9770e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -44,7 +44,6 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitBranchInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.getTypes; import java.util.List; @@ -66,15 +65,15 @@ public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; - public final OperationsContext builder; + public final OperationsContext context; public final String name; public final int id; public final int children; public CodeVariableElement idConstantField; - protected Operation(OperationsContext builder, String name, int id, int children) { - this.builder = builder; + protected Operation(OperationsContext context, String name, int id, int children) { + this.context = context; this.name = name; this.id = id; this.children = children; @@ -84,6 +83,10 @@ public final boolean isVariableChildren() { return children == VARIABLE_CHILDREN; } + public String conditionedOn() { + return null; + } + public void setIdConstantField(CodeVariableElement idConstantField) { this.idConstantField = idConstantField; } @@ -168,10 +171,15 @@ protected Simple(OperationsContext builder, String name, int id, int children, I this.instruction = instruction; } - private static int moveArguments(BuilderVariables vars, int startIndex, CodeTree[] array) { + private static int moveArguments(BuilderVariables vars, int startIndex, CodeTree[] array, String castTarget) { int index = startIndex; for (int i = 0; i < array.length; i++) { - array[i] = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[" + index + "]").build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (castTarget != null) { + b.string("(", castTarget, ") "); + } + b.variable(vars.operationData).string(".arguments[" + index + "]"); + array[i] = b.build(); index++; } @@ -198,10 +206,10 @@ public CodeTree createEndCode(BuilderVariables vars) { } } - index = moveArguments(vars, index, args.locals); - index = moveArguments(vars, index, args.localRuns); - index = moveArguments(vars, index, args.arguments); - index = moveArguments(vars, index, args.branchTargets); + index = moveArguments(vars, index, args.locals, null); + index = moveArguments(vars, index, args.localRuns, null); + index = moveArguments(vars, index, args.arguments, null); + index = moveArguments(vars, index, args.branchTargets, "OperationLabelImpl"); if (instruction.isVariadic()) { args.variadicCount = CodeTreeBuilder.createBuilder().string("numChildren - " + instruction.numPopStatic()).build(); @@ -321,18 +329,18 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { // { b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, varEndLabel)); + b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varEndLabel)); // } b.end().startElseBlock(); // { b.tree(createPopLastChildCode(vars)); - b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); // } b.end(); @@ -389,18 +397,18 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { // { b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - CodeVariableElement varElseLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "elseLabel"); - b.declaration(getTypes().BuilderOperationLabel, varElseLabel.getName(), createCreateLabel()); + CodeVariableElement varElseLabel = new CodeVariableElement(context.labelType, "elseLabel"); + b.declaration(context.labelType, varElseLabel.getName(), createCreateLabel()); b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); - b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, varElseLabel)); + b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varElseLabel)); // } b.end(); b.startElseIf().variable(vars.childIndex).string(" == 1").end(); b.startBlock(); // { // { - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); if (hasValue) { b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); @@ -408,12 +416,12 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createPopLastChildCode(vars)); } - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitBranchInstruction(vars, builder.commonBranch, varEndLabel)); - b.tree(createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + b.tree(createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); + b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); // } b.end().startElseBlock(); // { @@ -424,7 +432,7 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createPopLastChildCode(vars)); } - b.tree(createEmitLabel(vars, createGetAux(vars, 1, getTypes().BuilderOperationLabel))); + b.tree(createEmitLabel(vars, createGetAux(vars, 1, context.labelType))); // } b.end(); @@ -454,8 +462,8 @@ public int getNumAuxValues() { public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); - b.declaration(getTypes().BuilderOperationLabel, varStartLabel.getName(), createCreateLabel()); + CodeVariableElement varStartLabel = new CodeVariableElement(context.labelType, "startLabel"); + b.declaration(context.labelType, varStartLabel.getName(), createCreateLabel()); b.tree(createEmitLabel(vars, varStartLabel)); @@ -471,22 +479,22 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); // { - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - b.tree(createEmitBranchInstruction(vars, builder.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); + b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); // } b.end().startElseBlock(); // { b.tree(createPopLastChildCode(vars)); - b.tree(createEmitBranchInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_START_LABEL, context.labelType))); - b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); // } b.end(); @@ -553,17 +561,17 @@ public CodeTree createPushCountCode(BuilderVariables vars) { public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + CodeVariableElement varBeh = new CodeVariableElement(context.exceptionType, "beh"); + b.declaration(context.exceptionType, "beh", CodeTreeBuilder.createBuilder().startNew(context.exceptionType).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); + b.startStatement().variable(varBeh).string(".startStack = curStack").end(); b.startStatement().variable(varBeh).string(".exceptionIndex = getLocalIndex(").variable(vars.operationData).string(".arguments[0])").end(); - b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); + b.startStatement().startCall("exceptionHandlers.add").variable(varBeh).end(2); b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); @@ -579,9 +587,9 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end(); b.startBlock(); - b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".endBci = ").variable(vars.bci).end(); + b.startStatement().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".endBci = ").variable(vars.bci).end(); - b.tree(createEmitBranchInstruction(vars, builder.commonBranch, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_END_LABEL, context.labelType))); b.end().startElseBlock(); @@ -597,8 +605,8 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 1").end(); b.startBlock(); - b.startStatement().startCall("setCurStack").startGroup().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".startStack").end(3); - b.startStatement().tree(createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)).string(".handlerBci = ").variable(vars.bci).end(); + b.startAssign("curStack").startGroup().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".startStack").end(2); + b.startStatement().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".handlerBci = ").variable(vars.bci).end(); b.end(); @@ -609,7 +617,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); return b.build(); } @@ -620,6 +628,65 @@ public List getBuilderArgumentTypes() { } } + public static class Source extends Block { + + public static final String NAME = "Source"; + + public Source(OperationsContext builder, int id) { + super(builder, NAME, id); + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getTypes().Source); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().statement("sourceBuilder.beginSource(bci, arg0)").build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().statement("sourceBuilder.endSource(bci)").build(); + } + + @Override + public String conditionedOn() { + return "withSource"; + } + } + + public static class SourceSection extends Block { + + public static final String NAME = "SourceSection"; + + public SourceSection(OperationsContext builder, int id) { + super(builder, NAME, id); + } + + @Override + public List getBuilderArgumentTypes() { + ProcessorContext pc = ProcessorContext.getInstance(); + return List.of(pc.getType(int.class), pc.getType(int.class)); + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().statement("sourceBuilder.beginSourceSection(bci, arg0, arg1)").build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + return CodeTreeBuilder.createBuilder().statement("sourceBuilder.endSourceSection(bci)").build(); + } + + @Override + public String conditionedOn() { + return "withSource"; + } + } + public static class InstrumentTag extends Block { private final Instruction startInstruction; private final Instruction endInstruction; @@ -645,10 +712,14 @@ public int getNumAuxValues() { return 3; } + @Override + public String conditionedOn() { + return "withInstrumentation"; + } + @Override public List getBuilderArgumentTypes() { - ProcessorContext context = ProcessorContext.getInstance(); - return List.of(context.getType(Class.class)); + return List.of(ProcessorContext.getInstance().getType(Class.class)); } @Override @@ -656,12 +727,13 @@ public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); CodeVariableElement varCurInstrumentId = new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "curInstrumentId"); - CodeVariableElement varStartLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "startLabel"); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); + CodeVariableElement varStartLabel = new CodeVariableElement(context.labelType, "startLabel"); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - b.declaration("int", varCurInstrumentId.getName(), "doBeginInstrumentation((Class) arg0)"); - b.declaration(getTypes().BuilderOperationLabel, varStartLabel.getName(), createCreateLabel()); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + // todo + b.declaration("int", varCurInstrumentId.getName(), "0"); + b.declaration(context.labelType, varStartLabel.getName(), createCreateLabel()); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.tree(createEmitLabel(vars, varStartLabel)); @@ -696,8 +768,8 @@ public CodeTree createLeaveCode(BuilderVariables vars) { // b.tree(createEmitInstruction(vars, leaveInstruction, // createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)), - // createGetAux(vars, AUX_START_LABEL, getTypes().BuilderOperationLabel), - // createGetAux(vars, AUX_END_LABEL, getTypes().BuilderOperationLabel))); + // createGetAux(vars, AUX_START_LABEL, builder.labelType), + // createGetAux(vars, AUX_END_LABEL, builder.labelType))); // todo return b.build(); @@ -743,7 +815,16 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.end(2); } - b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = ").startCall("doBeginFinallyTry").end(2); + b.statement("currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack)"); + + b.statement("bci = 0"); + b.statement("exceptionHandlers = new ArrayList<>()"); + b.statement("labelFills = new ArrayList<>()"); + b.statement("labels = new ArrayList<>()"); + b.statement("curStack = 0"); + b.statement("maxStack = 0"); + + b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = currentFinallyTry").end(2); return b.build(); } @@ -756,20 +837,35 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" == 0").end().startBlock(); // { - b.startStatement().startCall("doEndFinallyBlock").end(2); + + b.statement("labelPass(currentFinallyTry)"); + + b.statement("currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci)"); + b.statement("currentFinallyTry.handlerHandlers = exceptionHandlers"); + b.statement("currentFinallyTry.handlerMaxStack = maxStack"); + + b.statement("System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length)"); + b.statement("bci = currentFinallyTry.bc.length"); + b.statement("exceptionHandlers = currentFinallyTry.exceptionHandlers"); + b.statement("labelFills = currentFinallyTry.labelFills"); + b.statement("labels = currentFinallyTry.labels"); + b.statement("curStack = currentFinallyTry.curStack"); + b.statement("maxStack = currentFinallyTry.maxStack"); + + b.statement("currentFinallyTry = currentFinallyTry.prev"); if (!noExcept) { - CodeVariableElement varBeh = new CodeVariableElement(getTypes().BuilderExceptionHandler, "beh"); - b.declaration(getTypes().BuilderExceptionHandler, "beh", CodeTreeBuilder.createBuilder().startNew(getTypes().BuilderExceptionHandler).end().build()); + CodeVariableElement varBeh = new CodeVariableElement(context.exceptionType, "beh"); + b.declaration(context.exceptionType, "beh", CodeTreeBuilder.createBuilder().startNew(context.exceptionType).end().build()); b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = getCurStack()").end(); + b.startStatement().variable(varBeh).string(".startStack = curStack").end(); b.startStatement().variable(varBeh).string(".exceptionIndex = "); b.startCall("getLocalIndex"); b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); b.end(); b.end(); - b.startStatement().startCall("addExceptionHandler").variable(varBeh).end(2); + b.startStatement().startCall("exceptionHandlers.add").variable(varBeh).end(2); b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); } @@ -806,14 +902,14 @@ public CodeTree createEndCode(BuilderVariables vars) { emitLeaveCode(vars, b); - CodeVariableElement varEndLabel = new CodeVariableElement(getTypes().BuilderOperationLabel, "endLabel"); - b.declaration(getTypes().BuilderOperationLabel, varEndLabel.getName(), createCreateLabel()); + CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); + b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); b.startBlock(); - b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, builder.commonBranch, varEndLabel)); + b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); b.end(); - b.declaration(getTypes().BuilderExceptionHandler, "beh", createGetAux(vars, AUX_BEH, getTypes().BuilderExceptionHandler)); + b.declaration(context.exceptionType, "beh", createGetAux(vars, AUX_BEH, context.exceptionType)); b.startAssign("beh.endBci").string("endBci").end(); b.startAssign("beh.handlerBci").variable(vars.bci).end(); @@ -821,7 +917,7 @@ public CodeTree createEndCode(BuilderVariables vars) { b.startBlock(); CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").build(); - b.tree(OperationGeneratorUtils.createEmitLocalInstruction(vars, builder.commonThrow, localIdx)); + b.tree(OperationGeneratorUtils.createEmitLocalInstruction(vars, context.commonThrow, localIdx)); b.end(); b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); @@ -889,7 +985,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { b.startIf().variable(vars.childIndex).string(" > 0").end().startBlock(); // { - b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, instruction, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, instruction, createGetAux(vars, 0, context.labelType))); // } b.end(); @@ -900,7 +996,7 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(OperationGeneratorUtils.createEmitLabel(vars, createGetAux(vars, 0, getTypes().BuilderOperationLabel))); + b.tree(OperationGeneratorUtils.createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); return b.build(); } @@ -920,7 +1016,7 @@ protected final CodeTree createPopLastChildCode(BuilderVariables vars) { b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); b.startBlock(); // { - b.tree(createEmitInstruction(vars, builder.commonPop, new EmitArguments())); + b.tree(createEmitInstruction(vars, context.commonPop, new EmitArguments())); b.end(); // } return b.build(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java similarity index 62% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java rename to truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index a74d8107446a..f2b2eb8ce2b7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/BuilderFinallyTryContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -38,37 +38,20 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.oracle.truffle.api.operation; +package com.oracle.truffle.dsl.processor.operations; -import java.util.ArrayList; +public class OperationGeneratorFlags { -class BuilderFinallyTryContext { - final BuilderFinallyTryContext prev; - final short[] bc; - final ArrayList exceptionHandlers; - final ArrayList labelFills; - final ArrayList labels; - final int curStack; - final int maxStack; + public static final boolean LOG_LOCAL_STORES = false; + public static final boolean LOG_LOCAL_STORES_SPEC = false; + public static final boolean LOG_LOCAL_LOADS = LOG_LOCAL_STORES; + public static final boolean LOG_LOCAL_LOADS_SPEC = LOG_LOCAL_STORES_SPEC; - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, - ArrayList labels, int curStack, int maxStack) { - this.prev = prev; - this.bc = bc; - this.exceptionHandlers = exceptionHandlers; - this.labelFills = labelFills; - this.labels = labels; - this.curStack = curStack; - this.maxStack = maxStack; - } + public static final boolean LOG_EXECUTE_AND_SPECIALIZE_CALLS = false; + public static final boolean LOG_STACK_READS = false; - short[] handlerBc; - ArrayList handlerHandlers; - public ArrayList handlerLabelFills = new ArrayList<>(); - public ArrayList relocationOffsets = new ArrayList<>(); - public int handlerMaxStack; + public static final boolean FLAG_NODE_AST_PRINTING = false; + public static final boolean ENABLE_INSTRUMENTATION = false; + public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; - boolean finalized() { - return handlerBc != null; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index c7aebd8ad58d..ada7e373f94f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -93,7 +93,7 @@ public static CodeTree createEmitLocalInstruction(BuilderVariables vars, Instruc } public static CodeTree createCreateLabel() { - return CodeTreeBuilder.createBuilder().cast(getTypes().BuilderOperationLabel).startCall("createLabel").end().build(); + return CodeTreeBuilder.createBuilder().startCall("(OperationLabelImpl) createLabel").end().build(); } @SuppressWarnings("unused") @@ -228,7 +228,7 @@ public static CodeTree callSetResultBoxed(CodeTree bciOffset, CodeTree kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startCall("doSetResultBoxed"); - b.string("bc"); + b.string("$bc"); b.string("$bci"); b.tree(bciOffset); b.tree(kind); @@ -238,6 +238,6 @@ public static CodeTree callSetResultBoxed(CodeTree bciOffset, CodeTree kind) { } public static CodeTree toFrameTypeConstant(FrameKind kind) { - return CodeTreeBuilder.singleString("FRAME_TYPE_" + kind.getFrameName().toUpperCase()); + return CodeTreeBuilder.singleString(kind.ordinal() + " /* " + kind + " */"); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 00661072d9fa..a475cf8bc336 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -50,23 +50,21 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; @@ -78,6 +76,7 @@ public class OperationsBytecodeCodeGenerator { private static final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); + private static final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); static final Object MARKER_CHILD = new Object(); @@ -94,9 +93,16 @@ public class OperationsBytecodeCodeGenerator { private final CodeTypeElement typBuilderImpl; private final OperationsData m; private final boolean withInstrumentation; + private final CodeTypeElement baseClass; + private final CodeTypeElement opNodeImpl; + private final CodeTypeElement typExceptionHandler; - public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, OperationsData m, boolean withInstrumentation) { + public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, + boolean withInstrumentation) { this.typBuilderImpl = typBuilderImpl; + this.baseClass = baseClass; + this.opNodeImpl = opNodeImpl; + this.typExceptionHandler = typExceptionHandler; this.m = m; this.withInstrumentation = withInstrumentation; } @@ -108,57 +114,32 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, Operation public CodeTypeElement createBuilderBytecodeNode() { String namePrefix = withInstrumentation ? "Instrumentable" : ""; - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", types.OperationBytecodeNode); - - CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(short.class)), "bc"); - - CodeVariableElement fldConsts = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(context.getType(Object.class)), "consts"); - - CodeVariableElement fldChildren = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.Node), "children"); - - CodeVariableElement fldHandlers = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.BuilderExceptionHandler), "handlers"); - - CodeVariableElement fldProbeNodes = null; - if (withInstrumentation) { - fldProbeNodes = new CodeVariableElement(MOD_PRIVATE_FINAL, arrayOf(types.OperationsInstrumentTreeNode), "instruments"); - } + CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", baseClass.asType()); - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), builderBytecodeNodeType); - builderBytecodeNodeType.add(ctor); + initializeInstructions(builderBytecodeNodeType); - initializeInstructions(builderBytecodeNodeType, fldBc, fldConsts, fldChildren); - - ExecutionVariables vars = new ExecutionVariables(); - // vars.bytecodeNodeType = builderBytecodeNodeType; - vars.bc = fldBc; - vars.consts = fldConsts; - vars.probeNodes = fldProbeNodes; - // vars.handlers = fldHandlers; - // vars.tracer = fldTracer; - - createBytecodeLoop(builderBytecodeNodeType, fldBc, fldHandlers, vars); + builderBytecodeNodeType.add(createBytecodeLoop(baseClass)); if (m.isGenerateAOT()) { - createPrepareAot(builderBytecodeNodeType, vars); + builderBytecodeNodeType.add(createPrepareAot(baseClass)); + + builderBytecodeNodeType.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "isAdoptable")).getBuilder().statement("return true"); } - createDumpCode(builderBytecodeNodeType, fldHandlers, vars); + builderBytecodeNodeType.add(createDumpCode(baseClass)); return builderBytecodeNodeType; } - private void createPrepareAot(CodeTypeElement builderBytecodeNodeType, ExecutionVariables vars) { - builderBytecodeNodeType.getImplements().add(types.GenerateAOT_Provider); - - CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(types.GenerateAOT_Provider, "prepareForAOT"); - builderBytecodeNodeType.add(mPrepareForAot); - - mPrepareForAot.renameArguments("language", "root"); + private CodeExecutableElement createPrepareAot(CodeTypeElement baseType) { + CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(baseType, "prepareForAOT"); CodeTreeBuilder b = mPrepareForAot.createBuilder(); - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); - b.declaration("int", "bci", "0"); + ExecutionVariables vars = new ExecutionVariables(); + populateVariables(vars); + + b.declaration("int", vars.bci.getName(), "0"); b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); @@ -177,33 +158,34 @@ private void createPrepareAot(CodeTypeElement builderBytecodeNodeType, Execution })); b.end(); + + return mPrepareForAot; } - private void createDumpCode(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldHandlers, ExecutionVariables vars) { - CodeExecutableElement mDump = new CodeExecutableElement(Set.of(Modifier.PUBLIC), context.getType(String.class), "dump"); - builderBytecodeNodeType.add(mDump); + private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { + CodeExecutableElement mDump = GeneratorUtils.overrideImplement(baseType, "dump"); CodeTreeBuilder b = mDump.getBuilder(); + ExecutionVariables vars = new ExecutionVariables(); + populateVariables(vars); - b.declaration("int", "bci", "0"); - b.declaration("int", "instrIndex", "0"); - b.declaration("StringBuilder", "sb", "new StringBuilder()"); + CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); - vars.bci = new CodeVariableElement(context.getType(int.class), "bci"); + b.declaration("int", vars.bci.getName(), "0"); + b.declaration("StringBuilder", "sb", "new StringBuilder()"); - b.startWhile().string("bci < bc.length").end(); - b.startBlock(); // while block + b.startWhile().string("$bci < $bc.length").end().startBlock(); // while { - b.statement("sb.append(String.format(\" [%04x]\", bci))"); + b.statement("sb.append(String.format(\" [%04x]\", $bci))"); b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); if (op == null) { - builder.statement("sb.append(String.format(\" unknown 0x%02x\", bc[bci++]))"); + builder.statement("sb.append(String.format(\" unknown 0x%02x\", $bc[$bci++]))"); } else { builder.tree(op.createDumpCode(vars)); - builder.startAssign("bci").string("bci + ").tree(op.createLength()).end(); + builder.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); } builder.statement("break"); @@ -212,12 +194,12 @@ private void createDumpCode(CodeTypeElement builderBytecodeNodeType, CodeVariabl b.statement("sb.append(\"\\n\")"); - b.end(); // while block + b.end(); // } - b.startFor().string("int i = 0; i < ").variable(fldHandlers).string(".length; i++").end(); + b.startFor().string("int i = 0; i < ").variable(varHandlers).string(".length; i++").end(); b.startBlock(); - b.startStatement().string("sb.append(").variable(fldHandlers).string("[i] + \"\\n\")").end(); + b.startStatement().string("sb.append(").variable(varHandlers).string("[i] + \"\\n\")").end(); b.end(); @@ -239,29 +221,38 @@ private void createDumpCode(CodeTypeElement builderBytecodeNodeType, CodeVariabl b.startReturn().string("sb.toString()").end(); vars.bci = null; + + return mDump; } - private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldBc, CodeVariableElement fldHandlers, ExecutionVariables vars) { - CodeVariableElement argFrame = new CodeVariableElement(types.VirtualFrame, "frame"); - CodeVariableElement argStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); - CodeVariableElement argStartSp = new CodeVariableElement(context.getType(int.class), "startSp"); - CodeExecutableElement mContinueAt = new CodeExecutableElement( - Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(Object.class), "continueAt", - argFrame, argStartBci, argStartSp); - builderBytecodeNodeType.getEnclosedElements().add(0, mContinueAt); + static void populateVariables(ExecutionVariables vars) { + ProcessorContext context = ProcessorContext.getInstance(); + TruffleTypes types = context.getTypes(); + vars.bc = new CodeVariableElement(context.getType(short[].class), "$bc"); + vars.sp = new CodeVariableElement(context.getType(int.class), "$sp"); + vars.bci = new CodeVariableElement(context.getType(int.class), "$bci"); + vars.frame = new CodeVariableElement(types.Frame, "$frame"); + vars.consts = new CodeVariableElement(context.getType(Object[].class), "$consts"); + vars.children = new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children"); + } + + private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { + CodeExecutableElement mContinueAt = GeneratorUtils.overrideImplement(baseType, "continueAt"); createExplodeLoop(mContinueAt); + ExecutionVariables vars = new ExecutionVariables(); + populateVariables(vars); + mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); CodeTreeBuilder b = mContinueAt.getBuilder(); - CodeVariableElement varSp = new CodeVariableElement(context.getType(int.class), "sp"); - CodeVariableElement varBci = new CodeVariableElement(context.getType(int.class), "bci"); CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); + CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); - b.declaration("int", varSp.getName(), CodeTreeBuilder.singleVariable(argStartSp)); - b.declaration("int", varBci.getName(), CodeTreeBuilder.singleVariable(argStartBci)); + b.declaration("int", vars.sp.getName(), CodeTreeBuilder.singleString("$startSp")); + b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); b.declaration("int", "loopCount", "0"); CodeVariableElement varTracer; @@ -277,31 +268,24 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar varTracer = null; } - CodeVariableElement varReturnValue = new CodeVariableElement(context.getType(Object.class), "returnValue"); - b.statement("Object " + varReturnValue.getName() + " = null"); - b.string("loop: "); b.startWhile().string("true").end(); b.startBlock(); CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); b.statement("int nextBci"); - vars.bci = varBci; vars.nextBci = varNextBci; - vars.frame = argFrame; - vars.sp = varSp; - vars.returnValue = varReturnValue; vars.tracer = varTracer; - b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(fldBc, varBci)); + b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); b.startTryBlock(); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varSp)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.sp)); b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); - b.startIf().variable(varSp).string(" < maxLocals + VALUES_OFFSET").end(); + b.startIf().variable(vars.sp).string(" < maxLocals").end(); b.startBlock(); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); b.end(); @@ -323,7 +307,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar if (m.isTracing()) { b.startStatement().startCall(varTracer, "traceInstruction"); - b.variable(varBci); + b.variable(vars.bci); b.variable(op.opcodeIdField); b.end(2); } @@ -331,7 +315,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar b.tree(op.createExecuteCode(vars)); if (!op.isBranchInstruction()) { - b.startAssign(varNextBci).variable(varBci).string(" + ").tree(op.createLength()).end(); + b.startAssign(varNextBci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); b.statement("break"); } @@ -350,7 +334,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); - b.tree(GeneratorUtils.createPartialEvaluationConstant(varBci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); // if (m.isTracing()) { // b.startStatement().startCall(fldTracer, "traceException"); @@ -358,22 +342,22 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar // b.end(2); // } - b.startFor().string("int handlerIndex = " + fldHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); + b.startFor().string("int handlerIndex = " + varHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); b.startBlock(); b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); - b.declaration(types.BuilderExceptionHandler, "handler", fldHandlers.getName() + "[handlerIndex]"); + b.declaration(typExceptionHandler.asType(), "handler", varHandlers.getName() + "[handlerIndex]"); - b.startIf().string("handler.startBci > bci || handler.endBci <= bci").end(); + b.startIf().string("handler.startBci > $bci || handler.endBci <= $bci").end(); b.statement("continue"); - b.startAssign(varSp).string("handler.startStack + VALUES_OFFSET + maxLocals").end(); + b.startAssign(vars.sp).string("handler.startStack + maxLocals").end(); // todo: check exception type (?) - b.startStatement().startCall(argFrame, "setObject").string("VALUES_OFFSET + handler.exceptionIndex").string("ex").end(2); + b.startStatement().startCall(vars.frame, "setObject").string("handler.exceptionIndex").string("ex").end(2); - b.statement("bci = handler.handlerBci"); + b.statement("$bci = handler.handlerBci"); b.statement("continue loop"); b.end(); // for (handlerIndex ...) @@ -383,7 +367,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar b.end(); // catch block b.tree(GeneratorUtils.createPartialEvaluationConstant(varNextBci)); - b.statement("bci = nextBci"); + b.statement("$bci = nextBci"); b.end(); // while block if (m.isTracing()) { @@ -392,14 +376,7 @@ private void createBytecodeLoop(CodeTypeElement builderBytecodeNodeType, CodeVar b.end(2); } - b.startReturn().string("returnValue").end(); - - vars.tracer = null; - vars.bci = null; - vars.nextBci = null; - vars.frame = null; - vars.sp = null; - vars.returnValue = null; + return mContinueAt; } private void createExplodeLoop(CodeExecutableElement mContinueAt) { @@ -409,7 +386,7 @@ private void createExplodeLoop(CodeExecutableElement mContinueAt) { context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); } - private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, CodeVariableElement fldBc, CodeVariableElement fldConsts, CodeVariableElement fldChildren) throws AssertionError { + private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) throws AssertionError { StaticConstants staticConstants = new StaticConstants(true); for (Instruction instr : m.getInstructions()) { if (!(instr instanceof CustomInstruction)) { @@ -427,12 +404,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, Cod final SingleOperationData soData = cinstr.getData(); - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs( - m, fldBc, fldChildren, - innerTypeNames, - methodNames, isVariadic, - fldConsts, cinstr, - staticConstants); + OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, isVariadic, cinstr, staticConstants); cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); @@ -507,13 +479,18 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, Cod } } - exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$sp")); - exToCopy.getParameters().add(0, new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "$bci")); + exToCopy.getParameters().add(0, new CodeVariableElement(arrayOf(types.Node), "$children")); + exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(Object[].class), "$consts")); + exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$sp")); + exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$bci")); + exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(short[].class), "$bc")); + exToCopy.getParameters().add(0, new CodeVariableElement(opNodeImpl.asType(), "$this")); if (!isBoundary) { exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); } exToCopy.getModifiers().remove(Modifier.PUBLIC); exToCopy.getModifiers().add(Modifier.PRIVATE); + exToCopy.getModifiers().add(Modifier.STATIC); exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); builderBytecodeNodeType.add(exToCopy); @@ -550,5 +527,4 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType, Cod private static TypeMirror arrayOf(TypeMirror el) { return new ArrayCodeTypeMirror(el); } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index d81e103cff1c..67830f1f79bc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -81,12 +81,9 @@ import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { - private final CodeVariableElement fldBc; - private final CodeVariableElement fldChildren; private final Set innerTypeNames; private final Set methodNames; private final boolean isVariadic; - private final CodeVariableElement fldConsts; private final CustomInstruction cinstr; private final StaticConstants staticConstants; @@ -107,22 +104,14 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator { context = ProcessorContext.getInstance(); types = context.getTypes(); - dummyVariables.bc = new CodeVariableElement(context.getType(short[].class), "bc"); - dummyVariables.bci = new CodeVariableElement(context.getType(int.class), "$bci"); - dummyVariables.frame = new CodeVariableElement(types.Frame, "$frame"); + OperationsBytecodeCodeGenerator.populateVariables(dummyVariables); } - OperationsBytecodeNodeGeneratorPlugs(OperationsData m, CodeVariableElement fldBc, CodeVariableElement fldChildren, - Set innerTypeNames, - Set methodNames, boolean isVariadic, CodeVariableElement fldConsts, CustomInstruction cinstr, - StaticConstants staticConstants) { + OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, boolean isVariadic, CustomInstruction cinstr, StaticConstants staticConstants) { this.m = m; - this.fldBc = fldBc; - this.fldChildren = fldChildren; this.innerTypeNames = innerTypeNames; this.methodNames = methodNames; this.isVariadic = isVariadic; - this.fldConsts = fldConsts; this.cinstr = cinstr; this.staticConstants = staticConstants; @@ -201,8 +190,13 @@ public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, b if (!isBoundary) { builder.string("$frame"); } + + builder.string("$this"); + builder.string("$bc"); builder.string("$bci"); builder.string("$sp"); + builder.string("$consts"); + builder.string("$children"); for (int i = 0; i < m.getNumTosSlots(); i++) { builder.string("$tos_" + i); @@ -264,9 +258,9 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea VariableElement targetField; if (isChild) { - targetField = fldChildren; + targetField = dummyVariables.children; } else { - targetField = fldConsts; + targetField = dummyVariables.consts; } b.variable(targetField).string("["); @@ -444,9 +438,6 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree @Override public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary, CodeTree[] bindings) { - if (inBoundary || regularReturn()) { - return false; - } // if (m.isTracing()) { // b.startStatement().startCall("tracer", "traceSpecialization"); @@ -462,7 +453,17 @@ public boolean createCallSpecialization(FrameState frameState, SpecializationDat // b.end(2); // } - createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); + if (inBoundary || regularReturn()) { + if (ElementUtils.isVoid(specialization.getMethod().getReturnType())) { + b.statement(specializationCall); + b.returnStatement(); + } else { + b.startReturn().tree(specializationCall).end(); + } + } else { + createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); + } + return true; } @@ -470,7 +471,6 @@ private boolean regularReturn() { return isVariadic || data.isShortCircuit(); } - private static final boolean DO_LOG_ENS_CALLS = false; private int ensCall = 0; @Override @@ -480,11 +480,11 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; // unquicken call parent EAS - builder.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.getOrig().opcodeIdField)); + builder.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, qinstr.getOrig().opcodeIdField)); easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; } - if (DO_LOG_ENS_CALLS) { + if (OperationGeneratorFlags.LOG_EXECUTE_AND_SPECIALIZE_CALLS) { builder.statement("System.out.printf(\" [!!] calling E&S @ %04x : " + cinstr.name + " " + (ensCall++) + " \", $bci)"); builder.startStatement().startCall("System.out.println").startCall("java.util.Arrays.asList"); frameState.addReferencesTo(builder); @@ -512,8 +512,8 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui @Override public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { if (regularReturn()) { - builder.startReturn().startCall("this", boundaryMethod); - builder.string("$bci"); + builder.startReturn().startCall(boundaryMethod.getSimpleName().toString()); + addNodeCallParameters(builder, true, false); addArguments.accept(builder); builder.end(2); return; @@ -521,9 +521,8 @@ public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameSt CodeTreeBuilder callBuilder = builder.create(); - callBuilder.startCall("this", boundaryMethod); - callBuilder.string("$bci"); - callBuilder.string("$sp"); + callBuilder.startCall(boundaryMethod.getSimpleName().toString()); + addNodeCallParameters(callBuilder, true, false); addArguments.accept(callBuilder); callBuilder.end(); @@ -589,7 +588,7 @@ public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, Execut @Override public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder b) { - if (DO_LOG_ENS_CALLS) { + if (OperationGeneratorFlags.LOG_EXECUTE_AND_SPECIALIZE_CALLS) { b.statement("System.out.println(\" [!!] finished E&S - " + specialization.getId() + " \")"); } @@ -606,7 +605,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); b.end().startBlock(); // { - b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", qinstr.opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, qinstr.opcodeIdField)); // } b.end(); } @@ -617,7 +616,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // quicken to generic - b.tree(OperationGeneratorUtils.createWriteOpcode(fldBc, "$bci", cinstr.opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, cinstr.opcodeIdField)); if (elseIf) { b.end(); @@ -761,10 +760,10 @@ public CodeTree createGetSpecializationBits() { b.declaration("boolean[]", "result", "new boolean[" + specializationStates.size() + "]"); for (int i = 0; i < specializationStates.size(); i++) { - SpecializationData data = (SpecializationData) specializationStates.get(i); + SpecializationData specData = (SpecializationData) specializationStates.get(i); b.startAssign("result[" + i + "]"); - b.tree(multiState.createContains(frame, new Object[]{data})); - Set excludedBy = data.getExcludedBy(); + b.tree(multiState.createContains(frame, new Object[]{specData})); + Set excludedBy = specData.getExcludedBy(); if (!excludedBy.isEmpty()) { b.string(" && "); @@ -831,4 +830,14 @@ public void finishUp() { public StaticConstants createConstants() { return staticConstants; } + + @Override + public CodeTree createGetLock() { + return CodeTreeBuilder.singleString("$this.getLockAccessor()"); + } + + @Override + public CodeTree createSuperInsert(CodeTree value) { + return CodeTreeBuilder.createBuilder().startCall("$this.insertAccessor").tree(value).end().build(); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index f0d5d9fac8b7..96cb9ca343e5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -41,19 +41,23 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; +import java.util.concurrent.locks.Lock; import java.util.function.Consumer; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.AnnotationProcessor; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -62,7 +66,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.Operation.InstrumentTag; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; @@ -72,22 +75,25 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_FINAL = Set.of(Modifier.FINAL); private static final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); private static final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private static final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); + private static final Set MOD_ABSTRACT = Set.of(Modifier.ABSTRACT); + private static final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); private static final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); + private static final Set MOD_PRIVATE_STATIC_ABSTRACT = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.ABSTRACT); private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); private static final Set MOD_PROTECTED = Set.of(Modifier.PROTECTED); + private static final Set MOD_PROTECTED_STATIC = Set.of(Modifier.PROTECTED, Modifier.STATIC); private static final Set MOD_STATIC = Set.of(Modifier.STATIC); private OperationsBytecodeCodeGenerator bytecodeGenerator; - private static final boolean FLAG_NODE_AST_PRINTING = false; - private static final boolean ENABLE_INSTRUMENTATION = false; - private static final String OPERATION_NODES_IMPL_NAME = "OperationNodesImpl"; private static final String OPERATION_BUILDER_IMPL_NAME = "BuilderImpl"; + private static final String BYTECODE_BASE_NAME = "BytecodeLoopBase"; CodeTypeElement createOperationNodes() { CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, types.OperationNodes); @@ -102,6 +108,16 @@ CodeTypeElement createOperationNodes() { b.statement("((Consumer) parse).accept(builder)"); b.statement("builder.finish()"); + CodeExecutableElement mSetSources = new CodeExecutableElement(context.getType(void.class), "setSources"); + mSetSources.addParameter(new CodeVariableElement(arrayOf(types.Source), "sources")); + mSetSources.createBuilder().statement("this.sources = sources"); + typOperationNodes.add(mSetSources); + + CodeExecutableElement mSetNodes = new CodeExecutableElement(context.getType(void.class), "setNodes"); + mSetNodes.addParameter(new CodeVariableElement(arrayOf(types.OperationNode), "nodes")); + mSetNodes.createBuilder().statement("this.nodes = nodes"); + typOperationNodes.add(mSetNodes); + return typOperationNodes; } @@ -118,7 +134,9 @@ CodeTypeElement createBuilder(String simpleName) { CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(MOD_PROTECTED, typBuilder); typBuilder.add(ctor); - typBuilder.add(createOperationNodes()); + CodeTypeElement opNodesImpl = createOperationNodes(); + + typBuilder.add(opNodesImpl); // begin/end or emit methods for (Operation op : m.getOperations()) { @@ -144,7 +162,11 @@ CodeTypeElement createBuilder(String simpleName) { } } - CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder); + typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLocal, "createLocal")); + typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLabel, "createLabel")); + typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationNode, "publish")); + + CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder, opNodesImpl); typBuilder.add(typBuilderImpl); for (OperationMetadataData metadata : m.getMetadatas()) { @@ -165,7 +187,7 @@ private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, Cod CodeTreeBuilder b = metCreate.getBuilder(); - b.declaration(types.OperationNodes, "nodes", "new OperationNodesImpl(generator)"); + b.declaration("OperationNodesImpl", "nodes", "new OperationNodesImpl(generator)"); b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); // ( b.string("nodes"); @@ -185,10 +207,38 @@ private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, Cod return metCreate; } - CodeTypeElement createOperationNodeImpl() { + private static CodeVariableElement compFinal(CodeVariableElement el) { + if (el.getType().getKind() == TypeKind.ARRAY) { + GeneratorUtils.addCompilationFinalAnnotation(el, 1); + } else { + GeneratorUtils.addCompilationFinalAnnotation(el); + } + return el; + } + + private static CodeVariableElement children(CodeVariableElement el) { + el.addAnnotationMirror(new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().Node_Children)); + return el; + } + + CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTypeElement typExceptionHandler) { CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationNodeImpl", types.OperationNode); + + typOperationNodeImpl.getImplements().add(types.BytecodeOSRNode); + typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl)); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(short[].class), "_bc"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(Object[].class), "_consts"))); + typOperationNodeImpl.add(children(new CodeVariableElement(arrayOf(types.Node), "_children"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(arrayOf(typExceptionHandler.asType()), "_handlers"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "_conditionProfiles"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxLocals"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); + + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); + if (!m.getMetadatas().isEmpty()) { CodeExecutableElement staticInit = new CodeExecutableElement(MOD_STATIC, null, ""); typOperationNodeImpl.add(staticInit); @@ -196,7 +246,7 @@ CodeTypeElement createOperationNodeImpl() { CodeTreeBuilder initBuilder = staticInit.createBuilder(); for (OperationMetadataData metadata : m.getMetadatas()) { - String fieldName = metadata.getName(); + String fieldName = "_metadata_" + metadata.getName(); CodeVariableElement fldMetadata = new CodeVariableElement(MOD_PRIVATE, metadata.getType(), fieldName); typOperationNodeImpl.add(fldMetadata); @@ -213,10 +263,87 @@ CodeTypeElement createOperationNodeImpl() { } } + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new BytecodeNode()")); + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = COMMON_EXECUTE")); + + typOperationNodeImpl.add(createNodeImplExecuteAt()); + + CodeExecutableElement mExecute = GeneratorUtils.overrideImplement(types.OperationNode, "execute"); + typOperationNodeImpl.add(mExecute); + mExecute.createBuilder().startReturn().startCall("executeAt").string("frame, _maxLocals << 16").end(2); + + CodeExecutableElement mGetSourceInfo = GeneratorUtils.overrideImplement(types.OperationNode, "getSourceInfo"); + typOperationNodeImpl.add(mGetSourceInfo); + mGetSourceInfo.createBuilder().statement("return sourceInfo"); + + CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationNode, "dump"); + typOperationNodeImpl.add(mDump); + mDump.createBuilder().startReturn().startCall("switchImpl.dump").string("_bc, _handlers, _consts").end(2); + + CodeExecutableElement mGetLockAccessor = new CodeExecutableElement(MOD_PRIVATE, context.getType(Lock.class), "getLockAccessor"); + typOperationNodeImpl.add(mGetLockAccessor); + mGetLockAccessor.createBuilder().startReturn().startCall("getLock").end(2); + + CodeExecutableElement mInsertAccessor = new CodeExecutableElement(MOD_PRIVATE, null, " T insertAccessor(T node) { // "); + typOperationNodeImpl.add(mInsertAccessor); + mInsertAccessor.createBuilder().startReturn().startCall("insert").string("node").end(2); + + typOperationNodeImpl.add(createNodeImplCreateFrameDescriptor()); + + CodeExecutableElement mExecuteOSR = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "executeOSR"); + typOperationNodeImpl.add(mExecuteOSR); + mExecuteOSR.createBuilder().startReturn().startCall("executeAt").string("osrFrame, target").end(2); + + CodeExecutableElement mGetOSRMetadata = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "getOSRMetadata"); + typOperationNodeImpl.add(mGetOSRMetadata); + mGetOSRMetadata.createBuilder().startReturn().string("_osrMetadata").end(); + + CodeExecutableElement mSetOSRMetadata = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "setOSRMetadata"); + typOperationNodeImpl.add(mSetOSRMetadata); + mSetOSRMetadata.createBuilder().startAssign("_osrMetadata").string("osrMetadata").end(); + return typOperationNodeImpl; } - private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { + private CodeExecutableElement createNodeImplCreateFrameDescriptor() { + CodeExecutableElement mCreateFrameDescriptor = GeneratorUtils.overrideImplement(types.OperationNode, "createFrameDescriptor"); + CodeTreeBuilder b = mCreateFrameDescriptor.createBuilder(); + b.statement("FrameDescriptor.Builder builder = FrameDescriptor.newBuilder()"); + b.statement("builder.addSlots(_maxLocals + _maxStack, FrameSlotKind.Illegal)"); + b.statement("return builder.build()"); + return mCreateFrameDescriptor; + } + + private CodeExecutableElement createNodeImplExecuteAt() { + CodeExecutableElement mExecuteAt = new CodeExecutableElement(MOD_PRIVATE, context.getType(Object.class), "executeAt"); + mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + mExecuteAt.addParameter(new CodeVariableElement(context.getType(int.class), "storedLocation")); + + CodeTreeBuilder b = mExecuteAt.createBuilder(); + b.declaration("int", "result", "storedLocation"); + b.startDoBlock(); + + b.startAssign("result").startCall("switchImpl", "continueAt"); + b.string("this"); + b.string("frame"); + b.string("_bc"); + b.string("result & 0xffff"); + b.string("(result >> 16) & 0xffff"); + b.string("_consts"); + b.string("_children"); + b.string("_handlers"); + b.string("_conditionProfiles"); + b.string("_maxLocals"); + b.end(2); + + b.end().startDoWhile().string("(result & 0xffff) != 0xffff").end(); + + b.startReturn().string("frame.getObject((result >> 16) & 0xffff)").end(); + + return mExecuteAt; + } + + private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeElement opNodesImpl) { CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), OPERATION_BUILDER_IMPL_NAME, typBuilder.asType()); typBuilderImpl.setEnclosingElement(typBuilder); @@ -265,8 +392,74 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { } - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(Set.of(), typBuilderImpl); - typBuilderImpl.add(ctor); + CodeTypeElement opDataImpl = createOperationDataImpl(); + typBuilderImpl.add(opDataImpl); + + CodeTypeElement typFinallyTryContext = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "BuilderFinallyTryContext", null); + + CodeTypeElement typLabelData = createOperationLabelImpl(opDataImpl, typFinallyTryContext); + typBuilderImpl.add(typLabelData); + + CodeTypeElement typLocalData = createOperationLocalImpl(opDataImpl); + typBuilderImpl.add(typLocalData); + + CodeTypeElement typLabelFill = typBuilderImpl.add(createLabelFill(typLabelData)); + + CodeTypeElement typExceptionHandler = typBuilderImpl.add(createExceptionHandler()); + + CodeTypeElement typSourceBuilder = createSourceBuilder(typBuilderImpl); + typBuilderImpl.add(typSourceBuilder); + + createFinallyTryContext(typFinallyTryContext, typExceptionHandler, typLabelFill, typLabelData); + typBuilderImpl.add(typFinallyTryContext); + + m.getOperationsContext().labelType = typLabelData.asType(); + m.getOperationsContext().exceptionType = typExceptionHandler.asType(); + + typBuilderImpl.add(createBuilderImplCtor(opNodesImpl)); + + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, opNodesImpl.asType(), "nodes")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "isReparse")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withSource")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withInstrumentation")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, typSourceBuilder.asType(), "sourceBuilder")); + + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "bc = new short[65535]")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "bci")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "curStack")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "maxStack")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLocals")); + CodeVariableElement fldConstPool = typBuilderImpl.add( + new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); + fldConstPool.createInitBuilder().string("new ArrayList<>()"); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, opDataImpl.asType(), "operationData")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelData.asType())), "labels = new ArrayList<>()")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelFill.asType())), "labelFills = new ArrayList<>()")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numChildNodes")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numBranchProfiles")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typExceptionHandler.asType())), + "exceptionHandlers = new ArrayList<>()")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typFinallyTryContext.asType(), "currentFinallyTry")); + + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "buildIndex")); + + typBuilderImpl.add(createBuilderImplFinish()); + typBuilderImpl.add(createBuilderImplReset()); + + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "stackSourceBci = new int[1024]")); + typBuilderImpl.add(createBuilderImplDoBeforeEmitInstruction()); + + typBuilderImpl.add(createDoLeaveFinallyTry(opDataImpl)); + typBuilderImpl.add(createBuilderImplDoEmitLabel(typLabelData)); + typBuilderImpl.addAll(createBuilderImplCalculateLeaves(opDataImpl, typLabelData)); + + typBuilderImpl.add(createBuilderImplCreateLocal(typBuilder, typLocalData)); + typBuilderImpl.add(createBuilderImplCreateParentLocal(typBuilder, typLocalData)); + typBuilderImpl.add(createBuilderImplCreateLabel(typBuilder, typLabelData)); + typBuilderImpl.addAll(createBuilderImplGetLocalIndex(typLocalData)); + typBuilderImpl.add(createBuilderImplVerifyNesting(opDataImpl)); + typBuilderImpl.add(createBuilderImplPublish()); + typBuilderImpl.add(createBuilderImplLabelPass(typFinallyTryContext)); // operation IDs for (Operation op : m.getOperationsContext().operations) { @@ -277,29 +470,42 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(fldId); } - CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(); + CodeTypeElement bytecodeBaseClass = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); + + CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(bytecodeBaseClass, typExceptionHandler); typBuilderImpl.add(typOperationNodeImpl); + createBytecodeBaseClass(bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler); + typBuilderImpl.add(bytecodeBaseClass); + + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typOperationNodeImpl.asType())), "builtNodes")); + + CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, bytecodeBaseClass.asType(), "switchImpl"); + GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); + fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); + typOperationNodeImpl.add(fldSwitchImpl); + CodeTypeElement builderBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, false); + + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); - if (ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, m, true); + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, true); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); } else { builderInstrBytecodeNodeType = null; } - CodeVariableElement fldOperationData = new CodeVariableElement(types.BuilderOperationData, "operationData"); + CodeVariableElement fldOperationData = new CodeVariableElement(opDataImpl.asType(), "operationData"); CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); CodeVariableElement fldIndent = null; - if (FLAG_NODE_AST_PRINTING) { + if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { fldIndent = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "indent"); typBuilderImpl.add(fldIndent); } @@ -309,8 +515,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastChildPush"); typBuilderImpl.add(fldLastPush); - CodeVariableElement fldConstPool = new CodeVariableElement(types.OperationsConstantPool, "constPool"); - BuilderVariables vars = new BuilderVariables(); vars.bc = fldBc; vars.bci = fldBci; @@ -318,11 +522,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { vars.lastChildPushCount = fldLastPush; vars.consts = fldConstPool; - typBuilderImpl.add(createForwardingConstructorCall(typOperationNodeImpl, "createNode")); - typBuilderImpl.add(createForwardingConstructorCall(builderBytecodeNodeType, "createBytecode")); - typBuilderImpl.add(createForwardingConstructorCall(null, "createInstrumentedBytecode")); - - typBuilderImpl.add(createDoLeave(vars)); + typBuilderImpl.add(createDoLeave(vars, opDataImpl)); typBuilderImpl.add(createBeforeChild(vars)); typBuilderImpl.add(createAfterChild(vars)); @@ -343,10 +543,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { params[i] = new CodeVariableElement(args.get(i), "arg" + i); } - if (op.name.equals("Block")) { - typBuilderImpl.add(createGetBlockOperationIndex(op)); - } - if (op.children != 0) { typBuilderImpl.add(createBeginOperation(typBuilder, vars, op)); typBuilderImpl.add(createEndOperation(typBuilder, vars, op)); @@ -361,22 +557,514 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder) { typBuilderImpl.add(createSetMetadata(metadata, false)); } - typBuilderImpl.add(createMetadataReset()); - typBuilderImpl.add(createMetadataSet(typOperationNodeImpl)); - return typBuilderImpl; } - private CodeExecutableElement createMetadataReset() { - CodeExecutableElement method = GeneratorUtils.overrideImplement(types.OperationBuilder, "resetMetadata"); - CodeTreeBuilder b = method.createBuilder(); + private List createBuilderImplGetLocalIndex(CodeTypeElement typLocalData) { + CodeExecutableElement mGetLocalIndex = new CodeExecutableElement(MOD_PRIVATE, context.getType(short.class), "getLocalIndex"); + mGetLocalIndex.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); + CodeTreeBuilder b = mGetLocalIndex.createBuilder(); + b.declaration(typLocalData.asType(), "local", "(" + typLocalData.getSimpleName() + ") value"); + b.startAssert().string("verifyNesting(local.owner, operationData) : \"local access not nested properly\"").end(); + b.startReturn().string("(short) local.id").end(); + + CodeExecutableElement mGetLocalIndices = new CodeExecutableElement(MOD_PRIVATE, context.getType(int[].class), "getLocalIndices"); + mGetLocalIndices.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); + b = mGetLocalIndices.createBuilder(); + b.declaration(arrayOf(types.OperationLocal), "locals", "(OperationLocal[]) value"); + b.declaration("int[]", "result", "new int[locals.length]"); + b.startFor().string("int i = 0; i < locals.length; i++").end().startBlock(); + b.statement("result[i] = getLocalIndex(locals[i])"); + b.end(); + b.statement("return result"); - for (OperationMetadataData metadata : m.getMetadatas()) { - b.startAssign("metadata_" + metadata.getName()).string("null").end(); + return List.of(mGetLocalIndex, mGetLocalIndices); + } + + private CodeExecutableElement createBuilderImplVerifyNesting(CodeTypeElement opDataImpl) { + CodeExecutableElement mDoEmitLabel = new CodeExecutableElement(MOD_PRIVATE, context.getType(boolean.class), "verifyNesting"); + mDoEmitLabel.addParameter(new CodeVariableElement(opDataImpl.asType(), "parent")); + mDoEmitLabel.addParameter(new CodeVariableElement(opDataImpl.asType(), "child")); + + CodeTreeBuilder b = mDoEmitLabel.createBuilder(); + + b.declaration(opDataImpl.asType(), "cur", "child"); + b.startWhile().string("cur.depth > parent.depth").end().startBlock(); + b.statement("cur = cur.parent"); + b.end(); + + b.statement("return cur == parent"); + + return mDoEmitLabel; + } + + private CodeExecutableElement createBuilderImplDoEmitLabel(CodeTypeElement typLabelData) { + CodeExecutableElement mDoEmitLabel = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEmitLabel"); + mDoEmitLabel.addParameter(new CodeVariableElement(types.OperationLabel, "label")); + + CodeTreeBuilder b = mDoEmitLabel.createBuilder(); + + b.declaration(typLabelData.asType(), "lbl", "(" + typLabelData.getSimpleName() + ") label"); + + b.startIf().string("lbl.hasValue").end().startBlock(); + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("label already emitted").end(2); + b.end(); + + b.startIf().string("operationData != lbl.data").end().startBlock(); + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("label must be created and emitted inside same opeartion").end(2); + b.end(); + + b.statement("lbl.hasValue = true"); + b.statement("lbl.targetBci = bci"); + + return mDoEmitLabel; + } + + private List createBuilderImplCalculateLeaves(CodeTypeElement opDataImpl, CodeTypeElement typLabelData) { + CodeExecutableElement mCalculateLeaves = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); + mCalculateLeaves.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); + mCalculateLeaves.addParameter(new CodeVariableElement(opDataImpl.asType(), "toData")); + + CodeTreeBuilder b = mCalculateLeaves.createBuilder(); + + b.startIf().string("toData != null && fromData.depth < toData.depth").end().startBlock(); + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("illegal jump to deeper operation").end(2); + b.end(); + + b.startIf().string("fromData == toData").end().startBlock().returnStatement().end(); + + b.declaration(opDataImpl.asType(), "cur", "fromData"); + + b.startWhile().string("true").end().startBlock(); + + b.statement("doLeaveOperation(cur)"); + b.statement("cur = cur.parent"); + + b.startIf().string("toData == null && cur == null").end().startBlock(); + b.statement("break"); + b.end().startElseIf().string("toData != null && cur.depth <= toData.depth").end(); + b.statement("break"); + b.end(); + + b.end(); + + b.startIf().string("cur != toData").end(); + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("illegal jump to non-parent operation").end(2); + b.end(); + + CodeExecutableElement oneArg = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); + oneArg.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); + oneArg.createBuilder().statement("calculateLeaves(fromData, (BuilderOperationData) null)"); + + CodeExecutableElement labelArg = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); + labelArg.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); + labelArg.addParameter(new CodeVariableElement(context.getType(Object.class), "toLabel")); + labelArg.createBuilder().statement("calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data)"); + + return List.of(mCalculateLeaves, oneArg, labelArg); + } + + private CodeTypeElement createOperationLabelImpl(CodeTypeElement opDataImpl, CodeTypeElement typFTC) { + CodeTypeElement typOperationLabel = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationLabelImpl", types.OperationLabel); + + typOperationLabel.add(new CodeVariableElement(opDataImpl.asType(), "data")); + typOperationLabel.add(new CodeVariableElement(typFTC.asType(), "finallyTry")); + + typOperationLabel.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationLabel)); + + typOperationLabel.add(new CodeVariableElement(context.getType(int.class), "targetBci = 0")); + typOperationLabel.add(new CodeVariableElement(context.getType(boolean.class), "hasValue = false")); + + CodeExecutableElement mBelongsTo = typOperationLabel.add(new CodeExecutableElement(context.getType(boolean.class), "belongsTo")); + mBelongsTo.addParameter(new CodeVariableElement(typFTC.asType(), "context")); + CodeTreeBuilder b = mBelongsTo.createBuilder(); + b.declaration(typFTC.asType(), "cur", "finallyTry"); + b.startWhile().string("cur != null").end().startBlock(); // { + + b.startIf().string("cur == context").end().startBlock().returnTrue().end(); + b.statement("cur = cur.prev"); + + b.end(); // } + + b.returnFalse(); + + return typOperationLabel; + } + + private CodeTypeElement createOperationLocalImpl(CodeTypeElement opDataImpl) { + CodeTypeElement typLocalData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationLocalImpl", types.OperationLocal); + + typLocalData.add(new CodeVariableElement(MOD_FINAL, opDataImpl.asType(), "owner")); + typLocalData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "id")); + + typLocalData.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typLocalData)); + + return typLocalData; + } + + @SuppressWarnings("static-method") + private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { + CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLocal"); + mCreateLocal.createBuilder().startReturn().startNew(typLocalData.asType()).string("operationData").string("numLocals++").end(2); + return mCreateLocal; + } + + @SuppressWarnings("static-method") + private CodeExecutableElement createBuilderImplCreateParentLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { + CodeExecutableElement mCreateLocal = new CodeExecutableElement(typLocalData.asType(), "createParentLocal"); + mCreateLocal.createBuilder().startReturn().startNew(typLocalData.asType()).string("operationData.parent").string("numLocals++").end(2); + return mCreateLocal; + } + + @SuppressWarnings("static-method") + private CodeExecutableElement createBuilderImplCreateLabel(CodeTypeElement typBuilder, CodeTypeElement typLabelData) { + CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); + + CodeTreeBuilder b = mCreateLocal.createBuilder(); + b.startAssign("OperationLabelImpl label").startNew(typLabelData.asType()).string("operationData").string("currentFinallyTry").end(2); + b.startStatement().startCall("labels", "add").string("label").end(2); + b.startReturn().string("label").end(); + + return mCreateLocal; + } + + private CodeTypeElement createExceptionHandler() { + CodeTypeElement typ = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "ExceptionHandler", null); + + typ.add(new CodeVariableElement(context.getType(int.class), "startBci")); + typ.add(new CodeVariableElement(context.getType(int.class), "startStack")); + typ.add(new CodeVariableElement(context.getType(int.class), "endBci")); + typ.add(new CodeVariableElement(context.getType(int.class), "exceptionIndex")); + typ.add(new CodeVariableElement(context.getType(int.class), "handlerBci")); + + typ.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typ)); + + typ.add(new CodeExecutableElement(null, typ.getSimpleName().toString())); + + CodeExecutableElement metOffset = typ.add(new CodeExecutableElement(typ.asType(), "offset")); + metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "offset")); + metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "stackOffset")); + + CodeTreeBuilder b = metOffset.createBuilder(); + b.startReturn().startNew(typ.asType()); + b.string("startBci + offset"); + b.string("startStack + stackOffset"); + b.string("endBci + offset"); + b.string("exceptionIndex"); + b.string("handlerBci + offset"); + b.end(2); + + CodeExecutableElement mToString = typ.add(GeneratorUtils.override(context.getDeclaredType(Object.class), "toString")); + + b = mToString.createBuilder(); + b.startReturn().startCall("String.format"); + b.doubleQuote("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}"); + b.string("startBci").string("endBci").string("startStack").string("exceptionIndex").string("handlerBci"); + b.end(2); + + return typ; + } + + // -------------------------------- source builder ---------------------------- + + private CodeTypeElement createSourceBuilder(CodeTypeElement typBuilderImpl) { + CodeTypeElement typSourceBuilder = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceInfoBuilder", null); + typSourceBuilder.setEnclosingElement(typBuilderImpl); + + CodeTypeElement typSourceData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceData", null); + typSourceBuilder.add(typSourceData); + typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "start")); + typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "length")); + typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "sourceIndex")); + typSourceData.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typSourceData)); + + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "sourceStack = new ArrayList<>()")); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, types.Source), "sourceList = new ArrayList<>()")); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "currentSource = -1")); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "bciList = new ArrayList<>()")); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, typSourceData.asType()), "sourceDataList = new ArrayList<>()")); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, typSourceData.asType()), "sourceDataStack = new ArrayList<>()")); + + typSourceBuilder.add(createSourceBuilderReset()); + typSourceBuilder.add(createSourceBuilderBeginSource()); + typSourceBuilder.add(createSourceBuilderEndSource()); + typSourceBuilder.add(createSourceBuilderBeginSourceSection()); + typSourceBuilder.add(createSourceBuilderEndSourceSection()); + typSourceBuilder.add(createSourceBuilderBuild()); + typSourceBuilder.add(createSourceBuilderBuildSource()); + + return typSourceBuilder; + } + + private CodeExecutableElement createSourceBuilderReset() { + CodeExecutableElement mReset = new CodeExecutableElement(context.getType(void.class), "reset"); + + CodeTreeBuilder b = mReset.createBuilder(); + b.statement("sourceStack.clear()"); + b.statement("sourceDataList.clear()"); + b.statement("sourceDataStack.clear()"); + b.statement("bciList.clear()"); + return mReset; + } + + private CodeExecutableElement createSourceBuilderBeginSource() { + CodeExecutableElement mBeginSource = new CodeExecutableElement(context.getType(void.class), "beginSource"); + mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + mBeginSource.addParameter(new CodeVariableElement(types.Source, "src")); + + CodeTreeBuilder b = mBeginSource.createBuilder(); + b.statement("int idx = sourceList.indexOf(src)"); + + b.startIf().string("idx == -1").end().startBlock(); + b.statement("idx = sourceList.size()"); + b.statement("sourceList.add(src)"); + b.end(); + + b.statement("sourceStack.add(currentSource)"); + b.statement("currentSource = idx"); + b.statement("beginSourceSection(bci, -1, -1)"); + return mBeginSource; + } + + private CodeExecutableElement createSourceBuilderEndSource() { + CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(void.class), "endSource"); + mEndSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + + CodeTreeBuilder b = mEndSource.createBuilder(); + b.statement("endSourceSection(bci)"); + b.statement("currentSource = sourceStack.remove(sourceStack.size() - 1)"); + return mEndSource; + } + + private CodeExecutableElement createSourceBuilderBeginSourceSection() { + CodeExecutableElement mBeginSource = new CodeExecutableElement(context.getType(void.class), "beginSourceSection"); + mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "start")); + mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "length")); + + CodeTreeBuilder b = mBeginSource.createBuilder(); + b.statement("SourceData data = new SourceData(start, length, currentSource)"); + b.statement("bciList.add(bci)"); + b.statement("sourceDataList.add(data)"); + b.statement("sourceDataStack.add(data)"); + return mBeginSource; + } + + private CodeExecutableElement createSourceBuilderEndSourceSection() { + CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(void.class), "endSourceSection"); + mEndSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + + CodeTreeBuilder b = mEndSource.createBuilder(); + b.statement("SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1)"); + b.statement("SourceData prev"); + + b.startIf().string("sourceDataStack.isEmpty()").end().startBlock(); + b.statement("prev = new SourceData(-1, -1, currentSource)"); + b.end().startElseBlock(); + b.statement("prev = sourceDataStack.get(sourceDataStack.size() - 1)"); + b.end(); + + b.statement("bciList.add(bci)"); + b.statement("sourceDataList.add(prev)"); + return mEndSource; + } + + private CodeExecutableElement createSourceBuilderBuildSource() { + CodeExecutableElement mEndSource = new CodeExecutableElement(arrayOf(types.Source), "buildSource"); + + CodeTreeBuilder b = mEndSource.createBuilder(); + b.statement("return sourceList.toArray(new Source[0])"); + + return mEndSource; + } + + private CodeExecutableElement createSourceBuilderBuild() { + CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(int[].class), "build"); + + CodeTreeBuilder b = mEndSource.createBuilder(); + + b.startIf().string("!sourceStack.isEmpty()").end().startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("not all sources ended").end(2); + b.end(); + + b.startIf().string("!sourceDataStack.isEmpty()").end().startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("not all source sections ended").end(2); + b.end(); + + int sourceStride = 3; + + b.statement("int size = bciList.size()"); + + b.statement("int[] resultArray = new int[size * " + sourceStride + "]"); + + b.statement("int index = 0"); + b.statement("int lastBci = -1"); + b.statement("boolean isFirst = true"); + + b.startFor().string("int i = 0; i < size; i++").end().startBlock(); + b.statement("SourceData data = sourceDataList.get(i)"); + b.statement("int curBci = bciList.get(i)"); + + b.startIf().string("data.start == -1 && isFirst").end().startBlock().statement("continue").end(); + + b.statement("isFirst = false"); + + b.startIf().string("curBci == lastBci && index > 1").end().startBlock(); + b.statement("index -= " + sourceStride); + b.end(); + + b.statement("resultArray[index + 0] = curBci | (data.sourceIndex << 16)"); + b.statement("resultArray[index + 1] = data.start"); + b.statement("resultArray[index + 2] = data.length"); + + b.statement("index += " + sourceStride); + b.statement("lastBci = curBci"); + + b.end(); + + b.statement("return Arrays.copyOf(resultArray, index)"); + + return mEndSource; + } + // ------------------------------ operadion data impl ------------------------ + + private CodeTypeElement createOperationDataImpl() { + CodeTypeElement opDataImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "BuilderOperationData", null); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, opDataImpl.asType(), "parent")); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "operationId")); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "stackDepth")); + + CodeExecutableElement ctor = opDataImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, opDataImpl)); + ctor.addParameter(new CodeVariableElement(context.getType(int.class), "numAux")); + ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "needsLeave")); + ctor.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); + + CodeTreeBuilder b = ctor.appendBuilder(); + b.statement("this.depth = parent == null ? 0 : parent.depth + 1"); + b.statement("this.aux = numAux > 0 ? new Object[numAux] : null"); + b.statement("this.needsLeave = needsLeave || (parent != null && parent.needsLeave)"); + b.statement("this.arguments = arguments"); + + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(boolean.class), "needsLeave")); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "depth")); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(Object[].class), "arguments")); + opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(Object[].class), "aux")); + opDataImpl.add(new CodeVariableElement(context.getType(int.class), "numChildren")); + + return opDataImpl; + } + + private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler) { + + CodeExecutableElement loopMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(int.class), "continueAt"); + loopMethod.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); + loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); + loopMethod.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); + loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); + loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); + loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); + loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); + loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); + loopMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "maxLocals")); + baseClass.add(loopMethod); + + CodeExecutableElement dumpMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(String.class), "dump"); + dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(context.getType(short.class)), "$bc")); + dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); + dumpMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); + baseClass.add(dumpMethod); + + if (m.isGenerateAOT()) { + CodeExecutableElement prepareAot = new CodeExecutableElement(MOD_ABSTRACT, context.getType(void.class), "prepareForAOT"); + prepareAot.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); + prepareAot.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); + prepareAot.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); + prepareAot.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); + prepareAot.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); + prepareAot.addParameter(new CodeVariableElement(types.RootNode, "root")); + baseClass.add(prepareAot); } - return method; + baseClass.add(createFormatConstant()); + baseClass.add(createExpectObject()); + baseClass.add(createSetResultBoxedImpl()); + for (TypeKind kind : m.getBoxingEliminatedTypes()) { + FrameKind frameKind = FrameKind.valueOfPrimitive(kind); + baseClass.add(createExpectPrimitive(frameKind)); + baseClass.add(createStoreLocalCheck(frameKind)); + } + + return baseClass; + } + + private CodeTypeElement createLabelFill(CodeTypeElement typLabelImpl) { + CodeTypeElement typ = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "LabelFill", null); + typ.add(new CodeVariableElement(context.getType(int.class), "locationBci")); + typ.add(new CodeVariableElement(typLabelImpl.asType(), "label")); + + typ.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typ)); + + CodeExecutableElement metOffset = typ.add(new CodeExecutableElement(typ.asType(), "offset")); + metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "offset")); + + metOffset.createBuilder().statement("return new LabelFill(offset + locationBci, label)"); + + return typ; + } + + private CodeTypeElement createFinallyTryContext(CodeTypeElement typFtc, CodeTypeElement typExceptionHandler, CodeTypeElement typLabelFill, CodeTypeElement typLabelImpl) { + typFtc.add(new CodeVariableElement(MOD_FINAL, typFtc.asType(), "prev")); + typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(short[].class), "bc")); + typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typExceptionHandler.asType()), "exceptionHandlers")); + typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typLabelFill.asType()), "labelFills")); + typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typLabelImpl.asType()), "labels")); + typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "curStack")); + typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "maxStack")); + + typFtc.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typFtc)); + + typFtc.add(new CodeVariableElement(Set.of(), context.getType(short[].class), "handlerBc")); + typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, typExceptionHandler.asType()), "handlerHandlers")); + typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, typLabelFill.asType()), "handlerLabelFills = new ArrayList<>()")); + typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, context.getType(Integer.class)), "relocationOffsets = new ArrayList<>()")); + typFtc.add(new CodeVariableElement(Set.of(), context.getType(int.class), "handlerMaxStack")); + + return typFtc; + } + + private CodeExecutableElement createDoLeaveFinallyTry(CodeTypeElement typOperationData) { + CodeExecutableElement mDoLeaveFinallyTry = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doLeaveFinallyTry", + new CodeVariableElement(typOperationData.asType(), "opData")); + + CodeTreeBuilder b = mDoLeaveFinallyTry.createBuilder(); + b.statement("BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]"); + + b.startIf().string("context.handlerBc == null").end().startBlock().returnStatement().end(); + + b.statement("System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length)"); + + b.startFor().string("int offset : context.relocationOffsets").end().startBlock(); + b.statement("short oldOffset = bc[bci + offset]"); + b.statement("bc[bci + offset] = (short) (oldOffset + bci)"); + b.end(); + + b.startFor().string("ExceptionHandler handler : context.handlerHandlers").end().startBlock(); + b.statement("exceptionHandlers.add(handler.offset(bci, curStack))"); + b.end(); + + b.startFor().string("LabelFill fill : context.handlerLabelFills").end().startBlock(); + b.statement("labelFills.add(fill.offset(bci))"); + b.end(); + + b.startIf().string("maxStack < curStack + context.handlerMaxStack").end(); + b.statement("maxStack = curStack + context.handlerMaxStack"); + b.end(); + + b.statement("bci += context.handlerBc.length"); + + return mDoLeaveFinallyTry; } private CodeExecutableElement createMetadataSet(CodeTypeElement typOperationNodeImpl) { @@ -385,10 +1073,6 @@ private CodeExecutableElement createMetadataSet(CodeTypeElement typOperationNode b.startAssign(typOperationNodeImpl.getSimpleName() + " nodeImpl").cast(typOperationNodeImpl.asType()).string("node").end(); - for (OperationMetadataData metadata : m.getMetadatas()) { - b.statement("nodeImpl." + metadata.getName() + " = metadata_" + metadata.getName()); - } - return method; } @@ -410,39 +1094,19 @@ private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, return method; } - private CodeExecutableElement createGetBlockOperationIndex(Operation op) { - CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, "getBlockOperationIndex"); - - result.getBuilder().startReturn().variable(op.idConstantField).end(); - - return result; - } - - private CodeExecutableElement createForwardingConstructorCall(TypeElement typeName, String methodName) { - CodeExecutableElement result = GeneratorUtils.overrideImplement(types.OperationBuilder, methodName); - CodeTreeBuilder b = result.getBuilder(); - - if (typeName != null) { - b.startReturn().startNew(typeName.asType()); - for (VariableElement par : result.getParameters()) { - b.variable(par); - } - b.end(2); - } else { - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("not implemented").end(2); - } - - return result; - } - private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); CodeTreeBuilder b = metEmit.getBuilder(); - if (FLAG_NODE_AST_PRINTING) { + if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } + String condition = op.conditionedOn(); + if (condition != null) { + b.startIf().string(condition).end().startBlock(); + } + if (op.isRealOperation()) { b.statement("doBeforeChild()"); } @@ -451,16 +1115,14 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu if (needsData) { b.startAssign(vars.operationData); - b.startNew(types.BuilderOperationData); + b.startNew("BuilderOperationData"); b.variable(vars.operationData); b.variable(op.idConstantField); - b.string("getCurStack()"); + b.string("curStack"); b.string("" + op.getNumAuxValues()); b.string("false"); - b.string("" + op.numLocalReferences()); - for (VariableElement v : metEmit.getParameters()) { b.variable(v); } @@ -480,6 +1142,10 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.statement("doAfterChild()"); } + if (condition != null) { + b.end(); + } + return metEmit; } @@ -495,11 +1161,12 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); - if (op instanceof InstrumentTag) { - b.startIf().string("!withInstrumentation").end().startBlock().returnStatement().end(); + String condition = op.conditionedOn(); + if (condition != null) { + b.startIf().string(condition).end().startBlock(); } - if (FLAG_NODE_AST_PRINTING) { + if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\")\")"); b.statement("indent--"); } @@ -540,6 +1207,10 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui b.statement("doAfterChild()"); } + if (condition != null) { + b.end(); + } + vars.numChildren = null; return metEnd; @@ -557,11 +1228,12 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B CodeTreeBuilder b = metBegin.getBuilder(); - if (op instanceof InstrumentTag) { - b.startIf().string("!withInstrumentation").end().startBlock().returnStatement().end(); + String condition = op.conditionedOn(); + if (condition != null) { + b.startIf().string(condition).end().startBlock(); } - if (FLAG_NODE_AST_PRINTING) { + if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); b.statement("indent++"); } @@ -571,16 +1243,14 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B } if (op.needsOperationData()) { - b.startAssign(vars.operationData).startNew(types.BuilderOperationData); + b.startAssign(vars.operationData).startNew("BuilderOperationData"); b.variable(vars.operationData); b.variable(op.idConstantField); - b.string("getCurStack()"); + b.string("curStack"); b.string("" + op.getNumAuxValues()); b.string("" + op.hasLeaveCode()); - b.string("" + op.numLocalReferences()); - for (VariableElement el : metBegin.getParameters()) { b.startGroup().cast(context.getType(Object.class)).variable(el).end(); } @@ -590,6 +1260,10 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B b.tree(op.createBeginCode(vars)); + if (condition != null) { + b.end(); + } + return metBegin; } @@ -623,6 +1297,89 @@ private CodeExecutableElement createSetResultUnboxed() { return mDoSetResultUnboxed; } + private CodeExecutableElement createBuilderImplPublish() { + CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PUBLIC, types.OperationNode, "publish"); + + CodeTreeBuilder b = mPublish.createBuilder(); + + b.startIf().string("operationData.depth != 0").end().startBlock(); + b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("Not all operations closed").end(2); + b.end(); + + b.declaration("OperationNodeImpl", "result", (CodeTree) null); + + b.startIf().string("!isReparse").end().startBlock(); + + b.statement("result = new OperationNodeImpl(nodes)"); + + b.statement("labelPass(null)"); + b.statement("result._bc = Arrays.copyOf(bc, bci)"); + b.statement("result._consts = constPool.toArray()"); + b.statement("result._children = new Node[numChildNodes]"); + b.statement("result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0])"); + b.statement("result._conditionProfiles = new int[numBranchProfiles * 2]"); + b.statement("result._maxLocals = numLocals"); + b.statement("result._maxStack = maxStack"); + + b.startIf().string("sourceBuilder != null").end().startBlock(); + b.statement("result.sourceInfo = sourceBuilder.build()"); + b.end(); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.statement("result._metadata_" + metadata.getName() + " = metadata_" + metadata.getName()); + } + + b.statement("assert builtNodes.size() == buildIndex"); + b.statement("builtNodes.add(result)"); + + b.end().startElseBlock(); + + b.statement("result = builtNodes.get(buildIndex)"); + + b.startIf().string("withSource && result.sourceInfo == null").end().startBlock(); + b.statement("result.sourceInfo = sourceBuilder.build()"); + b.end(); + + // todo instrumentation + + b.end(); + + b.statement("buildIndex++"); + b.statement("reset()"); + + b.statement("return result"); + + return mPublish; + } + + private CodeExecutableElement createBuilderImplLabelPass(CodeTypeElement typFtc) { + CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "labelPass"); + mPublish.addParameter(new CodeVariableElement(typFtc.asType(), "finallyTry")); + + CodeTreeBuilder b = mPublish.createBuilder(); + + b.startFor().string("LabelFill fill : labelFills").end().startBlock(); // { + b.startIf().string("finallyTry != null").end().startBlock(); // { + b.startIf().string("fill.label.belongsTo(finallyTry)").end().startBlock(); // { + + b.statement("assert fill.label.hasValue : \"inner label should have been resolved by now\""); + b.statement("finallyTry.relocationOffsets.add(fill.locationBci)"); + + b.end().startElseBlock(); // } { + + b.statement("finallyTry.handlerLabelFills.add(fill)"); + + b.end(); // } + b.end(); // } + + b.statement("bc[fill.locationBci] = (short) fill.label.targetBci"); + + b.end(); // } + + return mPublish; + + } + private CodeVariableElement createBoxingDescriptors() { CodeVariableElement fldBoxingDescriptors = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, arrayOf(arrayOf(context.getType(short.class))), "BOXING_DESCRIPTORS"); @@ -739,9 +1496,9 @@ private CodeExecutableElement createBeforeChild(BuilderVariables vars) { return mBeforeChild; } - private CodeExecutableElement createDoLeave(BuilderVariables vars) { - CodeVariableElement parData = new CodeVariableElement(types.BuilderOperationData, "data"); - CodeExecutableElement mDoLeave = GeneratorUtils.overrideImplement(types.OperationBuilder, "doLeaveOperation"); + private CodeExecutableElement createDoLeave(BuilderVariables vars, CodeTypeElement typOperationData) { + CodeVariableElement parData = new CodeVariableElement(typOperationData.asType(), "data"); + CodeExecutableElement mDoLeave = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doLeaveOperation", parData); CodeTreeBuilder b = mDoLeave.createBuilder(); @@ -783,6 +1540,14 @@ private static TypeMirror consumer(TypeMirror el) { return new DeclaredCodeTypeMirror(ProcessorContext.getInstance().getTypeElement(Consumer.class), List.of(el)); } + private static TypeMirror generic(TypeElement el, TypeMirror... args) { + return new DeclaredCodeTypeMirror(el, List.of(args)); + } + + private static TypeMirror generic(Class cls, TypeMirror... args) { + return generic(ProcessorContext.getInstance().getTypeElement(cls), args); + } + @Override @SuppressWarnings("hiding") public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { @@ -794,4 +1559,240 @@ public List create(ProcessorContext context, AnnotationProcesso return List.of(createBuilder(simpleName)); } + // -------------------------- helper methods moved to generated code -------------------------- + + private CodeExecutableElement createExpectObject() { + CodeExecutableElement mExpectObject = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(Object.class), "expectObject"); + mExpectObject.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + + CodeTreeBuilder b = mExpectObject.createBuilder(); + + b.startIf().string("frame.isObject(slot)").end().startBlock(); // if { + b.startReturn().string("frame.getObject(slot)").end(); + b.end().startElseBlock(); // } else { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startReturn().string("frame.getValue(slot)").end(); + b.end(); // } + + return mExpectObject; + } + + private CodeExecutableElement createExpectPrimitive(FrameKind kind) { + CodeExecutableElement mExpectPrimitive = new CodeExecutableElement(MOD_PROTECTED_STATIC, kind.getType(), "expect" + kind.getFrameName()); + mExpectPrimitive.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + + mExpectPrimitive.addThrownType(types.UnexpectedResultException); + + CodeTreeBuilder b = mExpectPrimitive.createBuilder(); + + if (OperationGeneratorFlags.LOG_STACK_READS) { + b.statement("System.out.println(\" [SR] stack read @ \" + slot + \" : \" + frame.getValue(slot) + \"\")"); + } + + b.startSwitch().string("frame.getTag(slot)").end().startBlock(); // switch { + + b.startCase().string(kind.ordinal() + " /* " + kind + " */").end().startCaseBlock(); // { + b.startReturn().string("frame.get" + kind.getFrameName() + "(slot)").end(); + b.end(); // } + + b.startCase().string(FrameKind.OBJECT.ordinal() + " /* OBJECT */").end().startCaseBlock(); // { + b.declaration("Object", "value", "frame.getObject(slot)"); + + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + b.startReturn().string("(" + kind.getTypeName() + ") value").end(); + b.end(); + + b.statement("break"); + b.end(); // } + + b.end(); // } + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startThrow().startNew(types.UnexpectedResultException).string("frame.getValue(slot)").end(2); + + return mExpectPrimitive; + } + + private CodeExecutableElement createStoreLocalCheck(FrameKind kind) { + CodeExecutableElement mStoreLocalCheck = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(boolean.class), "storeLocal" + kind.getFrameName() + "Check"); + + mStoreLocalCheck.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + mStoreLocalCheck.addParameter(new CodeVariableElement(context.getType(int.class), "localSlot")); + mStoreLocalCheck.addParameter(new CodeVariableElement(context.getType(int.class), "stackSlot")); + + CodeTreeBuilder b = mStoreLocalCheck.createBuilder(); + + b.declaration(types.FrameDescriptor, "descriptor", "frame.getFrameDescriptor()"); + + b.startIf().string("descriptor.getSlotKind(localSlot) == ").staticReference(types.FrameSlotKind, kind.getFrameName()).end().startBlock(); + b.startTryBlock(); + b.statement("frame.set" + kind.getFrameName() + "(localSlot, expect" + kind.getFrameName() + "(frame, stackSlot))"); + b.returnTrue(); + b.end().startCatchBlock(types.UnexpectedResultException, "ex").end(); + b.end(); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.statement("descriptor.setSlotKind(localSlot, FrameSlotKind.Object)"); + b.statement("frame.setObject(localSlot, frame.getValue(stackSlot))"); + b.returnFalse(); + + return mStoreLocalCheck; + } + + private CodeExecutableElement createFormatConstant() { + CodeExecutableElement mFormatConstant = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(String.class), "formatConstant"); + + mFormatConstant.addParameter(new CodeVariableElement(context.getType(Object.class), "obj")); + + CodeTreeBuilder b = mFormatConstant.createBuilder(); + + b.startIf().string("obj == null").end().startBlock(); + b.startReturn().doubleQuote("null").end(); + b.end().startElseBlock(); + b.declaration("Object", "repr", "obj"); + + b.startIf().string("obj instanceof Object[]").end().startBlock(); + b.startAssign("repr").startStaticCall(context.getType(Arrays.class), "deepToString").string("(Object[]) obj").end(2); + b.end(); + + b.startReturn().startStaticCall(context.getType(String.class), "format"); + b.doubleQuote("%s %s"); + b.string("obj.getClass().getSimpleName()"); + b.string("repr"); + b.end(2); + + b.end(); + + return mFormatConstant; + } + + private CodeExecutableElement createSetResultBoxedImpl() { + CodeExecutableElement mSetResultBoxedImpl = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(void.class), "setResultBoxedImpl"); + mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "targetType")); + mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(short[].class), "descriptor")); + + CodeTreeBuilder b = mSetResultBoxedImpl.createBuilder(); + b.declaration("int", "op", "bc[bci] & 0xffff"); + b.declaration("short", "todo", "descriptor[op]"); + + b.startIf().string("todo > 0").end().startBlock(); + + b.statement("bc[bci] = todo"); + + b.end().startElseBlock(); + + b.declaration("int", "offset", "(todo >> 8) & 0x7f"); + b.declaration("int", "bit", "todo & 0xff"); + + b.startIf().string("targetType == 0 /* OBJECT */").end().startBlock(); + b.statement("bc[bci + offset] &= ~bit"); + b.end().startElseBlock(); + b.statement("bc[bci + offset] |= bit"); + b.end(); + + b.end(); + + return mSetResultBoxedImpl; + } + + // ---------------------- builder static code ----------------- + + private CodeExecutableElement createBuilderImplCtor(CodeTypeElement opNodesImpl) { + CodeExecutableElement ctor = new CodeExecutableElement(MOD_PRIVATE, null, OPERATION_BUILDER_IMPL_NAME); + ctor.addParameter(new CodeVariableElement(opNodesImpl.asType(), "nodes")); + ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "isReparse")); + ctor.addParameter(new CodeVariableElement(types.OperationConfig, "config")); + + CodeTreeBuilder b = ctor.createBuilder(); + + b.statement("this.nodes = nodes"); + b.statement("this.isReparse = isReparse"); + b.statement("builtNodes = new ArrayList<>()"); + + b.startIf().string("isReparse").end().startBlock(); + b.statement("builtNodes.addAll((java.util.Collection) nodes.getNodes())"); + b.end(); + + b.statement("this.withSource = config.isWithSource()"); + b.statement("this.withInstrumentation = config.isWithInstrumentation()"); + + b.statement("this.sourceBuilder = withSource ? new SourceInfoBuilder() : null"); + + b.statement("reset()"); + + return ctor; + } + + private CodeExecutableElement createBuilderImplFinish() { + CodeExecutableElement mFinish = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "finish"); + + CodeTreeBuilder b = mFinish.createBuilder(); + + b.startIf().string("withSource").end().startBlock(); + b.statement("nodes.setSources(sourceBuilder.buildSource())"); + b.end(); + + b.startIf().string("!isReparse").end().startBlock(); + b.statement("nodes.setNodes(builtNodes.toArray(new OperationNode[0]))"); + b.end(); + + return mFinish; + } + + private CodeExecutableElement createBuilderImplReset() { + CodeExecutableElement mReset = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "reset"); + + CodeTreeBuilder b = mReset.createBuilder(); + + b.statement("bci = 0"); + b.statement("curStack = 0"); + b.statement("maxStack = 0"); + b.statement("numLocals = 0"); + b.statement("constPool.clear()"); + b.statement("operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0)"); + b.statement("labelFills.clear()"); + b.statement("numChildNodes = 0"); + b.statement("numBranchProfiles = 0"); + b.statement("exceptionHandlers.clear()"); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.startAssign("metadata_" + metadata.getName()).string("null").end(); + } + + return mReset; + } + + private CodeExecutableElement createBuilderImplDoBeforeEmitInstruction() { + CodeExecutableElement mDoBeforeEmitInstruction = new CodeExecutableElement(MOD_PRIVATE, context.getType(int[].class), "doBeforeEmitInstruction"); + mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(int.class), "numPops")); + mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(boolean.class), "pushValue")); + + CodeTreeBuilder b = mDoBeforeEmitInstruction.createBuilder(); + + b.statement("int[] result = new int[numPops]"); + + b.startFor().string("int i = numPops - 1; i >= 0; i--").end().startBlock(); + b.statement("curStack--"); + b.statement("int predBci = stackSourceBci[curStack]"); + b.statement("result[i] = predBci"); + b.end(); + + b.startIf().string("pushValue").end().startBlock(); + + b.statement("stackSourceBci[curStack] = bci"); + b.statement("curStack++"); + b.startIf().string("curStack > maxStack").end().startBlock(); + b.statement("maxStack = curStack"); + b.end(); + + b.end(); + + b.startReturn().string("result").end(); + + return mDoBeforeEmitInstruction; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index e3eeec11d97b..fa70fdc3b3f0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -47,6 +47,8 @@ import java.util.Map; import java.util.Set; +import javax.lang.model.type.TypeMirror; + import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -89,6 +91,8 @@ public class OperationsContext { private final OperationsData data; private final Set operationNames = new HashSet<>(); + public TypeMirror labelType; + public TypeMirror exceptionType; public OperationsContext(OperationsData data) { this.data = data; @@ -128,12 +132,14 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); + add(new Operation.Source(this, operationId++)); + add(new Operation.SourceSection(this, operationId++)); + add(new Operation.InstrumentTag(this, operationId++, add(new InstrumentationEnterInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++)), add(new InstrumentationExitInstruction(instructionId++, true)), add(new InstrumentationLeaveInstruction(instructionId++)))); - } private void createLoadStoreLocal() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 0e5b66d67291..b5c12e9b69aa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -77,7 +77,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (SAFEPOINT_POLL) { b.startStatement().startStaticCall(typeTruffleSafepoint, "poll"); - b.string("this"); + b.string("$this"); b.end(2); } @@ -91,7 +91,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end().startBlock(); // { b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); - b.string("this"); + b.string("$this"); b.string("" + REPORT_LOOP_STRIDE); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 669d745dc049..0e9959a7872d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -80,11 +80,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) TypeSystemData data = ctx.getData().getTypeSystem(); - CodeTree conditionCode = TypeSystemCodeGenerator.cast(data, new CodeTypeMirror(TypeKind.BOOLEAN), CodeTreeBuilder.singleString("frame.getObject(sp - 1)")); + CodeTree conditionCode = TypeSystemCodeGenerator.cast(data, new CodeTypeMirror(TypeKind.BOOLEAN), CodeTreeBuilder.singleString("$frame.getObject($sp - 1)")); b.declaration("boolean", "cond", conditionCode); - b.statement("sp -= 1"); + b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); // b.startIf().startCall("profile", "profile").string("cond").end(2); b.startIf().string("cond").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index fc0ad0950ce9..14137bc916aa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -142,13 +142,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { String inputName = "input_" + inputIndex; switch (kind) { case STACK_VALUE: - b.declaration("Object", inputName, "frame.getObject(sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); + b.declaration("Object", inputName, "$frame.getObject($sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VARIADIC: b.declaration("Object[]", inputName, "new Object[numVariadics]"); b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); - b.startStatement().string(inputName, "[varIndex] = frame.getObject(sp - numVariadics + varIndex)").end(); + b.startStatement().string(inputName, "[varIndex] = $frame.getObject($sp - numVariadics + varIndex)").end(); b.end(); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; @@ -166,10 +166,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement(); } - b.startCall("this", executeMethod); + b.startStaticCall(executeMethod); b.variable(vars.frame); + b.string("$this"); + b.variable(vars.bc); b.variable(vars.bci); b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); b.trees(inputTrees); b.end(2); @@ -177,17 +181,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (numPushedValues > 0) { b.startStatement().startCall(vars.frame, "setObject"); - b.string("sp - 1"); + b.string("$sp - 1"); b.string("result"); b.end(2); } } else { b.startStatement(); - b.startCall("this", executeMethod); + b.startStaticCall(executeMethod); b.variable(vars.frame); + b.string("$this"); + b.variable(vars.bc); b.variable(vars.bci); b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); b.end(2); b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues).end(); @@ -199,11 +207,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { if (marker.equals(MARKER_LOCAL_REFS)) { - return CodeTreeBuilder.createBuilder().startCall("createLocalSetterRange").tree(args.constants[index]).end().build(); + return CodeTreeBuilder.createBuilder().startStaticCall(types.LocalSetterRange, "create").startCall("getLocalIndices").tree(args.constants[index]).end(2).build(); } if (marker instanceof String && ((String) marker).startsWith(MARKER_LOCAL_REF_PREFIX)) { - return CodeTreeBuilder.createBuilder().startCall("createLocalSetter").tree(args.constants[index]).end().build(); + return CodeTreeBuilder.createBuilder().startStaticCall(types.LocalSetter, "create").startCall("getLocalIndex").tree(args.constants[index]).end(2).build(); } return super.createConstantInitCode(vars, args, marker, index); @@ -266,7 +274,20 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } - return CodeTreeBuilder.createBuilder().startStatement().startCall("this", prepareAOTMethod).string("null").variable(vars.bci).string("-1").tree(language).tree(root).end(2).build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement().startStaticCall(prepareAOTMethod); + b.string("null"); + b.string("$this"); + b.string("$bc"); + b.variable(vars.bci); + b.string("-1"); + b.string("$consts"); + b.string("$children"); + b.tree(language); + b.tree(root); + b.end(2); + + return b.build(); } public void addQuickenedVariant(QuickenedInstruction quick) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index 981392b38c0c..3e5d19640e78 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -110,4 +111,23 @@ public TypeMirror getType() { } } + + public static FrameKind valueOfPrimitive(TypeKind typeKind) { + switch (typeKind) { + case BOOLEAN: + return BOOLEAN; + case BYTE: + return BYTE; + case DOUBLE: + return DOUBLE; + case FLOAT: + return FLOAT; + case INT: + return INT; + case LONG: + return LONG; + default: + throw new UnsupportedOperationException(); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 35bb7f670b47..cc8d5a0c1648 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -64,8 +64,8 @@ public static class ExecutionVariables { public CodeVariableElement nextBci; public CodeVariableElement frame; public CodeVariableElement sp; - public CodeVariableElement returnValue; public CodeVariableElement consts; + public CodeVariableElement children; public CodeVariableElement[] inputs; public CodeVariableElement[] results; @@ -413,7 +413,7 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) if (!constants.isEmpty()) { b.startAssign("int constantsStart"); - b.startCall(vars.consts, "reserve").string("" + constants.size()).end(); + b.startCall(vars.consts, "size").end(); b.end(); b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); @@ -428,19 +428,22 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) initCode = args.constants[i]; } - if (initCode != null) { - b.startStatement().startCall(vars.consts, "setValue"); - b.string("constantsStart + " + i); - b.tree(initCode); - b.end(2); + if (initCode == null) { + initCode = CodeTreeBuilder.singleString("null"); } + + b.startStatement().startCall(vars.consts, "add"); + b.tree(initCode); + b.end(2); } } if (!children.isEmpty()) { b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); - b.startCall("createChildNodes").string("" + children.size()).end(); + b.string("numChildNodes"); b.end(); + + b.statement("numChildNodes += " + children.size()); } for (int i = 0; i < locals.size(); i++) { @@ -478,11 +481,10 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) } for (int i = 0; i < branchTargets.size(); i++) { - b.startStatement().startCall("putBranchTarget"); - b.variable(vars.bc); + b.startStatement().startCall("labelFills", "add").startNew("LabelFill"); b.startGroup().variable(vars.bci).string(" + " + getBranchTargetsOffset() + " + " + i).end(); b.tree(args.branchTargets[i]); - b.end(2); + b.end(3); } // todo: condition profiles diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 402757f44442..9d2d63459e2e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -48,6 +48,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -56,10 +57,6 @@ public class LoadLocalInstruction extends Instruction { private final OperationsContext ctx; private final FrameKind kind; - static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; - private static final boolean LOG_LOCAL_LOADS = false; - private static final boolean LOG_LOCAL_LOADS_SPEC = false; - public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 1); this.ctx = ctx; @@ -75,13 +72,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(createLocalIndex(vars, 0)); b.end(); - if (INTERPRETER_ONLY_BOXING_ELIMINATION) { + if (OperationGeneratorFlags.INTERPRETER_ONLY_BOXING_ELIMINATION) { b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); // { } if (kind == null) { - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [uninit]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [uninit]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyAsObject(vars, b); } else if (kind == FrameKind.OBJECT) { @@ -95,8 +92,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind.Object"); @@ -104,8 +101,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // } b.end(); - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [generic]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [generic]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyObject(vars, b); @@ -126,13 +123,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { b.string("localType == ").staticReference(StoreLocalInstruction.FrameSlotKind, "Illegal"); b.string(" && "); - b.string("(localValue = frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); + b.string("(localValue = $frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); // } b.end().startBlock(); // { - if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); @@ -141,26 +138,30 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("localIdx"); b.startGroup().cast(kind.getType()).string("localValue").end(); b.end(2); + + createCopyPrimitive(vars, b); // } b.end().startElseBlock(); // { - if (LOG_LOCAL_LOADS || LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind.Object"); b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - // } - b.end(); - // } - b.end(); + createCopyObject(vars, b); + + b.end(); // } + b.end().startElseBlock(); // } else { - if (LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, frame.getValue(localIdx))"); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { + b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyPrimitive(vars, b); + b.end(); // } + } b.startStatement().variable(vars.sp).string("++").end(); @@ -177,15 +178,17 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { } } + private static final boolean USE_SPEC_FRAME_COPY = true; + private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copyObject"); + b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyObject" : "copy"); b.string("localIdx"); b.variable(vars.sp); b.end(2); } private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copyPrimitive"); + b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyPrimitive" : "copy"); b.string("localIdx"); b.variable(vars.sp); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index b58bdcf8b8d2..71dbcaee5f9b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -60,11 +60,7 @@ public boolean isBranchInstruction() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign(vars.returnValue).startCall(vars.frame, "getObject"); - b.startGroup().variable(vars.sp).string(" - 1").end(); - b.end(2); - - b.statement("break loop"); + b.startReturn().string("((").variable(vars.sp).string(" - 1) << 16) | 0xffff").end(); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index d45d59fe7700..2d22442d821e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -68,10 +68,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("!"); } - b.startCall("this", executeMethod); + b.startStaticCall(executeMethod); b.variable(vars.frame); + b.string("$this"); + b.variable(vars.bc); b.variable(vars.bci); b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); b.end(2).startBlock(); // { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 9e4ff9c27048..57f3bbfef750 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -53,6 +53,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; @@ -63,9 +64,6 @@ public class StoreLocalInstruction extends Instruction { static final DeclaredType FrameSlotKind = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.frame.FrameSlotKind"); - private static final boolean LOG_LOCAL_STORES = false; - private static final boolean LOG_LOCAL_STORES_SPEC = false; - public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) { super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 0); this.context = context; @@ -78,11 +76,11 @@ public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) public static CodeExecutableElement createStoreLocalInitialization(OperationsContext context) { ProcessorContext ctx = ProcessorContext.getInstance(); - CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), new CodeTypeMirror(TypeKind.INT), "storeLocalInitialization"); + CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), ctx.getType(int.class), "storeLocalInitialization"); method.addParameter(new CodeVariableElement(ctx.getTypes().VirtualFrame, "frame")); - method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "localIdx")); - method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "localTag")); - method.addParameter(new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "sourceSlot")); + method.addParameter(new CodeVariableElement(ctx.getType(int.class), "localIdx")); + method.addParameter(new CodeVariableElement(ctx.getType(int.class), "localTag")); + method.addParameter(new CodeVariableElement(ctx.getType(int.class), "sourceSlot")); CodeTreeBuilder b = method.createBuilder(); @@ -94,7 +92,7 @@ public static CodeExecutableElement createStoreLocalInitialization(OperationsCon } b.startIf(); // { - b.string("localTag == FRAME_TYPE_" + kind); + b.string("localTag == " + kind.ordinal() + " /* " + kind + " */"); b.string(" && "); b.string("value instanceof " + kind.getTypeNameBoxed()); // } @@ -105,7 +103,7 @@ public static CodeExecutableElement createStoreLocalInitialization(OperationsCon b.startGroup().cast(kind.getType()).string("value").end(); b.end(2); - b.startReturn().string("FRAME_TYPE_" + kind).end(); + b.startReturn().string(kind.ordinal() + " /* " + kind + " */").end(); // } b.end(); } @@ -115,7 +113,7 @@ public static CodeExecutableElement createStoreLocalInitialization(OperationsCon b.string("value"); b.end(2); - b.startReturn().string("FRAME_TYPE_OBJECT").end(); + b.startReturn().string("0 /* OBJECT */").end(); return method; } @@ -137,8 +135,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf().string("localTag == ").staticReference(FrameSlotKind, "Illegal").end().startBlock(); // { - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, frame.getValue(sourceSlot))"); + if (OperationGeneratorFlags.LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, $frame.getValue(sourceSlot))"); } b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); createCopyObject(vars, b); @@ -154,8 +152,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("sourceSlot"); b.end(2); - if (LOG_LOCAL_STORES || LOG_LOCAL_STORES_SPEC) { - b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); + if (OperationGeneratorFlags.LOG_LOCAL_STORES || OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { + b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, $frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); } b.startStatement().startCall("setResultBoxedImpl"); @@ -169,8 +167,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // } b.end(); } else if (kind == FrameKind.OBJECT) { - if (LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [generic]%n\", localIdx, frame.getValue(sourceSlot))"); + if (OperationGeneratorFlags.LOG_LOCAL_STORES) { + b.statement("System.out.printf(\" local store %2d : %s [generic]%n\", localIdx, $frame.getValue(sourceSlot))"); } b.startStatement().startCall(vars.frame, "setObject"); @@ -184,7 +182,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("sourceSlot"); b.end(2).startBlock(); // { b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - createSetChildBoxing(vars, b, "FRAME_TYPE_OBJECT"); + createSetChildBoxing(vars, b, "0 /* OBJECT */"); b.end(); // } } @@ -193,15 +191,17 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + private static final boolean USE_SPEC_FRAME_COPY = true; + private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copyPrimitive"); + b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyPrimitive" : "copy"); b.string("sourceSlot"); b.string("localIdx"); b.end(2); } private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "copyObject"); + b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyObject" : "copy"); b.string("sourceSlot"); b.string("localIdx"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 8625825caece..c44770351633 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -1816,7 +1816,7 @@ private void initializeChildren(NodeData node) { child.addError("Node type '%s' is invalid or not a subclass of Node.", getQualifiedName(nodeType)); } else { if (child.isImplicit() || child.isAllowUncached()) { - DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList()); + DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList(), mode); resolver = importStatics(resolver, node.getNodeType()); if (NodeCodeGenerator.isSpecializedNode(nodeType)) { List executables = parseNodeFactoryMethods(nodeType); @@ -2198,7 +2198,7 @@ private void initializeExpressions(List elements, NodeData no if (mode == ParseMode.OPERATION) { globalMembers.add(new CodeVariableElement(context.getType(int.class), "$bci")); } - DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); + DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers, mode); // the number of specializations might grow while expressions are initialized. List specializations = node.getSpecializations(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java index 70ca6511be74..eef00ded2323 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java @@ -394,13 +394,28 @@ public boolean hasFallthrough() { if (hasFallthrough) { return true; } + + SpecializationGroup lastChild = getLast(); + if (lastChild != null) { + return lastChild.hasFallthrough(); + } + if (specialization != null) { return specialization.hasCachedExpression(); } + return false; + } + + public boolean hasFallthroughInSlowPath() { + if (hasFallthrough) { + return true; + } + SpecializationGroup lastChild = getLast(); if (lastChild != null) { - return lastChild.hasFallthrough(); + return lastChild.hasFallthroughInSlowPath(); } + return false; } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 982236a3eede..0938ef9f6259 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -60,15 +60,18 @@ public class SLException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -6799734410727348507L; private static final InteropLibrary UNCACHED_LIB = InteropLibrary.getFactory().getUncached(); + private final int bci; @TruffleBoundary public SLException(String message, Node location, int bci) { super(message, location, bci); + this.bci = bci; } @TruffleBoundary public SLException(String message, Node location) { super(message, location, -1); + this.bci = -1; } /** @@ -88,6 +91,9 @@ public static SLException typeError(Node operation, int bci, Object... values) { if (ss != null && ss.isAvailable()) { result.append(" at ").append(ss.getSource().getName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn()); } + if (bci != -1) { + result.append(String.format(" @%04x", bci)); + } } result.append(": operation"); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 9d1604c16e70..dbd6e5b887f0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -47,6 +47,7 @@ import java.util.Map; import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.misc.Interval; import org.antlr.v4.runtime.tree.ParseTree; import com.oracle.truffle.api.RootCallTarget; @@ -92,7 +93,7 @@ */ public final class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = false; + private static final boolean DO_LOG_NODE_CREATION = true; public static void parseSL(SLLanguage language, Source source, Map functions) { OperationNodes nodes = SLOperationsBuilder.create(OperationConfig.DEFAULT, builder -> { @@ -128,10 +129,10 @@ private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuil @Override public Void visit(ParseTree tree) { - b.beginSourceSection(tree.getSourceInterval().a); + Interval sourceInterval = tree.getSourceInterval(); + b.beginSourceSection(sourceInterval.a, sourceInterval.length()); super.visit(tree); - b.endSourceSection(tree.getSourceInterval().length()); - + b.endSourceSection(); return null; } From 86bc8d680ae053db8215e50314d208a1a968e47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 4 Jul 2022 10:28:07 +0200 Subject: [PATCH 106/312] [wip] remove removed types --- .../dsl/processor/operations/SingleOperationParser.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 9632f528f202..85e6fa1fec5c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -381,10 +381,6 @@ private boolean isIgnoredParameter(VariableElement param) { return true; } else if (ElementUtils.findAnnotationMirror(param, types.CachedLibrary) != null) { return true; - } else if (ElementUtils.findAnnotationMirror(param, types.CachedLanguage) != null) { - return true; - } else if (ElementUtils.findAnnotationMirror(param, types.CachedContext) != null) { - return true; } else if (ElementUtils.findAnnotationMirror(param, types.Bind) != null) { return true; } From e343c92aceb914f05a64c456ead45fe296bbaf2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 7 Jul 2022 10:36:22 +0200 Subject: [PATCH 107/312] [wip] fixes --- .../api/dsl/test/ChildExecutionTest.java | 37 ++++++++++ .../truffle/api/operation/LocalSetter.java | 2 + .../truffle/api/operation/OperationNode.java | 10 ++- .../generator/FlatNodeGenFactory.java | 41 +++++++---- .../generator/NodeGeneratorPlugs.java | 7 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 72 ++++++++++++++++--- .../operations/OperationsCodeGenerator.java | 63 +++++++++++++++- .../instructions/CustomInstruction.java | 1 - .../instructions/LoadLocalInstruction.java | 12 ++-- .../instructions/StoreLocalInstruction.java | 9 ++- 10 files changed, 210 insertions(+), 44 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java index 79a58713e302..41df83da6316 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java @@ -43,6 +43,8 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystem; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -81,6 +83,17 @@ public String executeString(VirtualFrame frame) { } } + public static class ChildExecutionChildNodeWithError extends Node { + + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { + throw new UnexpectedResultException(null); + } + + public Object executeObject(VirtualFrame frame) { + return 0; + } + } + @ExpectError("Child execution method: String ChildExecutionChildNode2::executeString(VirtualFrame) called from method: boolean TestNode2::executeBool(boolean) requires a frame parameter.") @NodeChildren({ @NodeChild(value = "first", type = ChildExecutionChildNode2.class), @@ -131,4 +144,28 @@ protected boolean doIt(String a, String b) { return a.isEmpty() && b.isEmpty(); } } + + @TypeSystem({int.class}) + public static class TestTypeSystem { + } + + @NodeChildren({ + @NodeChild(value = "first", type = ChildExecutionChildNodeWithError.class), + @NodeChild(value = "second", type = ChildExecutionChildNode2.class) + }) + @TypeSystemReference(TestTypeSystem.class) + public abstract static class TestNode4 extends Node { + + public abstract Object execute(VirtualFrame frame); + + @Specialization + protected boolean doItPrim(int a, String b) { + return true; + } + + @Specialization + protected boolean doIt(String a, String b) { + return true; + } + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index d48e55ec199b..dc35bbf154a4 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -86,6 +86,8 @@ public static LocalSetter get(int index) { } static void setObject(VirtualFrame frame, int index, Object value) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + descriptor.setSlotKind(index, FrameSlotKind.Object); frame.setObject(index, value); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index cca51545d045..1152e720b4e8 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -46,6 +46,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; public abstract class OperationNode extends Node { @@ -79,11 +80,10 @@ protected static void setMetadataAccessor(MetadataKey key, Function= 0) { // return the first defined source section - that one should encompass the entire // function - return nodes.sources[sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16].createSection(sourceInfo[i + SOURCE_INFO_START], sourceInfo[i + SOURCE_INFO_LENGTH]); + return sources[sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16].createSection(sourceInfo[i + SOURCE_INFO_START], sourceInfo[i + SOURCE_INFO_LENGTH]); } } @@ -100,8 +100,6 @@ public final SourceSection getSourceSection() { @ExplodeLoop protected final SourceSection getSourceSectionAtBci(int bci) { - nodes.ensureSources(); - int[] sourceInfo = getSourceInfo(); if (sourceInfo == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 6eaf48e743d4..a5a8d8da63b0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -233,6 +233,7 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData List stateObjects = new ArrayList<>(); if (plugs != null) { + plugs.setUseSpecializationClass(this::useSpecializationClass); plugs.addAdditionalStateBits(stateObjects); plugs.setNodeData(node); } @@ -445,7 +446,7 @@ private String createAssumptionFieldName(SpecializationData specialization, Assu } } - private static String createSpecializationLocalName(SpecializationData s) { + public static String createSpecializationLocalName(SpecializationData s) { if (s == null) { return null; } @@ -2738,7 +2739,8 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt boolean found = false; for (NodeExecutionData otherExecution : node.getChildExecutions()) { if (found) { - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericType); + TypeMirror genericReturnType = otherExecution.getChild().findAnyGenericExecutableType(context).getReturnType(); + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericReturnType); builder.tree(createAssignExecuteChild(slowPathFrameState.copy(), slowPathFrameState, builder, otherExecution, delegateType, childEvaluatedValue)); slowPathFrameState.setValue(otherExecution, childEvaluatedValue); } else { @@ -3372,6 +3374,7 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } int numCachedNullChecks = 0; + boolean useSpecializationClass = useSpecializationClass(specialization); if (specialization.getMethod() == null) { builder.tree(createThrowUnsupported(builder, frameState)); @@ -3389,7 +3392,7 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } if (var == null) { CodeTree cacheReference = createCacheReference(frameState, specialization, specialization.findCache(parameter), true); - if (generatorMode == GeneratorMode.OPERATIONS && frameState.getMode() == NodeExecutionMode.FAST_PATH) { + if (generatorMode == GeneratorMode.OPERATIONS && frameState.getMode() == NodeExecutionMode.FAST_PATH && !useSpecializationClass) { String localName = createCacheLocalName(specialization, specialization.findCache(parameter)); var = new LocalVariable(parameter.getType(), localName, null); frameState.set(fieldName, var); @@ -4343,7 +4346,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (useSpecializationClass(excludes)) { if (plugs != null) { builder.startStatement(); - builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, true, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, null)); builder.string(" = null"); builder.end(); } else { @@ -4429,7 +4432,7 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.end(); builder.startStatement(); if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, true, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, null)); } else { builder.string("this.", createSpecializationFieldName(specialization)); } @@ -4464,7 +4467,7 @@ private Collection initializeSpecializationClass(FrameState initBuilder.startNew(typeName); if (specialization.getMaximumNumberOfInstances() > 1) { if (plugs != null) { - initBuilder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, useSpecializationClass, + initBuilder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, new GeneratedTypeMirror("", createSpecializationTypeName(specialization)))); } else { initBuilder.string(createSpecializationFieldName(specialization)); @@ -4547,7 +4550,7 @@ private static CodeTree createTryExecuteChild(LocalVariable value, CodeTree exec CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); boolean hasDeclaration = false; if ((hasTry || !executeChild.isSingleLine()) && needDeclaration) { - builder.tree(value.createDeclaration(null)); + builder.startStatement().type(value.getTypeMirror()).string(" ", value.getName()).end(); hasDeclaration = true; } @@ -4635,7 +4638,13 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState for (SpecializationData removeSpecialization : specializations) { if (useSpecializationClass(removeSpecialization)) { String fieldName = createSpecializationFieldName(removeSpecialization); - builder.statement("this." + fieldName + " = null"); + builder.startStatement(); + if (plugs != null) { + builder.tree(plugs.createSpecializationFieldReference(frameState, removeSpecialization, fieldName, null)); + } else { + builder.string("this." + fieldName); + } + builder.string(" = null").end(); } } @@ -4650,7 +4659,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState if (hasReexecutingRewrite) { if (hasUnexpectedResultRewrite) { builder.startIf().string("ex").instanceOf(types.UnexpectedResultException).end().startBlock(); - builder.tree(createReturnUnexpectedResult(forType, true)); + builder.tree(createReturnUnexpectedResult(frameState, forType, true)); builder.end().startElseBlock(); builder.tree(createCallExecuteAndSpecialize(forType, frameState)); builder.end(); @@ -4659,7 +4668,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState } } else { assert hasUnexpectedResultRewrite; - builder.tree(createReturnUnexpectedResult(forType, false)); + builder.tree(createReturnUnexpectedResult(frameState, forType, false)); } builder.end(); @@ -4697,9 +4706,9 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, CodeTree fieldRefWrite = fieldRef; if (plugs != null) { String fieldName = useSpecializationClass ? null : createSpecializationFieldName(specialization); - fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, useSpecializationClass, + fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, new GeneratedTypeMirror("", createSpecializationTypeName(specialization))); - fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, useSpecializationClass, null); + fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, null); } if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { // single instance remove @@ -4843,7 +4852,11 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram return builder.build(); } - private CodeTree createReturnUnexpectedResult(ExecutableTypeData forType, boolean needsCast) { + private CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast) { + if (plugs != null) { + return plugs.createReturnUnexpectedResult(frameState, forType, needsCast); + } + TypeMirror returnType = context.getType(Object.class); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); @@ -5347,7 +5360,7 @@ private CodeTree createSpecializationFieldReference(FrameState frameState, Speci builder.string(localName); } else { if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, true, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); + builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); } else { builder.string("this.", createSpecializationFieldName(s)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 1480f937f66c..efc330cf3bd1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.function.Consumer; +import java.util.function.Predicate; import javax.lang.model.type.TypeMirror; @@ -78,7 +79,7 @@ public interface NodeGeneratorPlugs { CodeTree transformValueBeforePersist(CodeTree tree); - CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType); + CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType); CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead); @@ -127,4 +128,8 @@ public interface NodeGeneratorPlugs { CodeTree createGetLock(); CodeTree createSuperInsert(CodeTree value); + + CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast); + + void setUseSpecializationClass(Predicate useSpecializationClass); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 67830f1f79bc..e9749fa4b5f1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -45,6 +45,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.stream.Collectors; import javax.lang.model.element.VariableElement; @@ -54,6 +55,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.BitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; @@ -68,6 +70,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.model.CacheExpression; import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; import com.oracle.truffle.dsl.processor.model.NodeData; @@ -100,6 +103,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final ExecutionVariables dummyVariables = new ExecutionVariables(); private NodeData nodeData; + private Predicate useSpecializationClass; { context = ProcessorContext.getInstance(); @@ -129,6 +133,10 @@ public String toString() { } } + public void setUseSpecializationClass(Predicate useSpecializationClass) { + this.useSpecializationClass = useSpecializationClass; + } + public void setNodeData(NodeData node) { this.nodeData = node; for (SpecializationData spec : node.getSpecializations()) { @@ -301,9 +309,11 @@ public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphis } @Override - public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, boolean useSpecializationClass, TypeMirror fieldType) { - Object refObject = useSpecializationClass ? s : fieldName; - return createArrayReference(frame, refObject, fieldType != null, fieldType, false); + public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType) { + boolean specClass = useSpecializationClass.test(s); + Object refObject = specClass ? s : fieldName; + boolean isChild = specClass ? true : ElementUtils.isAssignable(fieldType, types.Node); + return createArrayReference(frame, refObject, fieldType != null, fieldType, isChild); } @Override @@ -316,19 +326,49 @@ public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData exe @Override public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { - Object refObject; + Object refObject = null; + TypeMirror mir = null; + String fieldName = null; + boolean innerForRead = forRead; + CodeTree base = null; + boolean isChild; + if (sharedName != null) { refObject = sharedName; - } else { - String sharedGroup = cache.getSharedGroup(); - if (sharedGroup != null) { - refObject = sharedGroup; + mir = cache.getParameter().getType(); + isChild = ElementUtils.isAssignable(mir, types.Node); + } else if (cache.getSharedGroup() != null) { + refObject = cache.getSharedGroup(); + mir = cache.getParameter().getType(); + isChild = ElementUtils.isAssignable(mir, types.Node); + } else if (useSpecializationClass.test(specialization)) { + LocalVariable specLocal = frame != null + ? frame.get(FlatNodeGenFactory.createSpecializationLocalName(specialization)) + : null; + fieldName = cache.getParameter().getLocalName() + "_"; + isChild = true; + if (specLocal != null) { + base = specLocal.createReference(); } else { - refObject = cache; + refObject = specialization; + mir = new GeneratedTypeMirror("", cinstr.getUniqueName() + "_" + specialization.getId() + "Data"); + innerForRead = true; } + } else { + refObject = cache; + mir = cache.getParameter().getType(); + isChild = ElementUtils.isAssignable(mir, types.Node); + } + + if (base == null) { + base = createArrayReference(frame, refObject, innerForRead, mir, isChild); + } + + if (fieldName == null) { + return base; + } else { + return CodeTreeBuilder.createBuilder().tree(base).string("." + fieldName).build(); } - boolean isChild = ElementUtils.isAssignable(cache.getParameter().getType(), types.Node); - return createArrayReference(frame, refObject, forRead, cache.getParameter().getType(), isChild); } public int getStackOffset(LocalVariable value) { @@ -840,4 +880,14 @@ public CodeTree createGetLock() { public CodeTree createSuperInsert(CodeTree value) { return CodeTreeBuilder.createBuilder().startCall("$this.insertAccessor").tree(value).end().build(); } + + @Override + public CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + TypeMirror retType = context.getType(Object.class); + createPushResult(frameState, b, CodeTreeBuilder.singleString((needsCast ? "((UnexpectedResultException) ex)" : "ex") + ".getResult()"), retType); + + return b.build(); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 96cb9ca343e5..cda67c6d926b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -302,9 +302,60 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(mSetOSRMetadata); mSetOSRMetadata.createBuilder().startAssign("_osrMetadata").string("osrMetadata").end(); + typOperationNodeImpl.add(createNodeImplDeepCopy(typOperationNodeImpl)); + typOperationNodeImpl.add(createNodeImplCopy(typOperationNodeImpl)); + return typOperationNodeImpl; } + private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperationNodeImpl) { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "deepCopy"); + CodeTreeBuilder b = met.createBuilder(); + + b.declaration(typOperationNodeImpl.asType(), "result", "new OperationNodeImpl(nodes)"); + + b.statement("result._bc = Arrays.copyOf(_bc, _bc.length)"); + b.statement("result._consts = Arrays.copyOf(_consts, _consts.length)"); + b.statement("result._children = Arrays.copyOf(_children, _children.length)"); + b.statement("result._handlers = _handlers"); + b.statement("result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length)"); + b.statement("result._maxLocals = _maxLocals"); + b.statement("result._maxStack = _maxStack"); + b.statement("result.sourceInfo = sourceInfo"); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.statement("result._metadata_" + metadata.getName() + " = _metadata_" + metadata.getName()); + } + + b.statement("return result"); + + return met; + } + + private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNodeImpl) { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "copy"); + CodeTreeBuilder b = met.createBuilder(); + + b.declaration(typOperationNodeImpl.asType(), "result", "new OperationNodeImpl(nodes)"); + + b.statement("result._bc = _bc"); + b.statement("result._consts = _consts"); + b.statement("result._children = _children"); + b.statement("result._handlers = _handlers"); + b.statement("result._conditionProfiles = _conditionProfiles"); + b.statement("result._maxLocals = _maxLocals"); + b.statement("result._maxStack = _maxStack"); + b.statement("result.sourceInfo = sourceInfo"); + + for (OperationMetadataData metadata : m.getMetadatas()) { + b.statement("result._metadata_" + metadata.getName() + " = _metadata_" + metadata.getName()); + } + + b.statement("return result"); + + return met; + } + private CodeExecutableElement createNodeImplCreateFrameDescriptor() { CodeExecutableElement mCreateFrameDescriptor = GeneratorUtils.overrideImplement(types.OperationNode, "createFrameDescriptor"); CodeTreeBuilder b = mCreateFrameDescriptor.createBuilder(); @@ -1123,8 +1174,12 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.string("" + op.getNumAuxValues()); b.string("false"); - for (VariableElement v : metEmit.getParameters()) { - b.variable(v); + if (metEmit.getParameters().size() == 1 && metEmit.getParameters().get(0).asType().getKind() == TypeKind.ARRAY) { + b.startGroup().cast(context.getType(Object.class)).variable(metEmit.getParameters().get(0)).end(); + } else { + for (VariableElement v : metEmit.getParameters()) { + b.variable(v); + } } b.end(2); } @@ -1783,6 +1838,10 @@ private CodeExecutableElement createBuilderImplDoBeforeEmitInstruction() { b.startIf().string("pushValue").end().startBlock(); + b.startIf().string("curStack >= stackSourceBci.length").end().startBlock(); + b.statement("stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2)"); + b.end(); + b.statement("stackSourceBci[curStack] = bci"); b.statement("curStack++"); b.startIf().string("curStack > maxStack").end().startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 14137bc916aa..59232e76c3b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -153,7 +153,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VIRTUAL_FRAME: - inputTrees[inputIndex++] = CodeTreeBuilder.singleVariable(vars.frame); break; default: throw new IllegalArgumentException("Unexpected value: " + kind); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 9d2d63459e2e..9a9d8385c30a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -78,7 +78,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (kind == null) { if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [uninit]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [uninit]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyAsObject(vars, b); } else if (kind == FrameKind.OBJECT) { @@ -93,7 +93,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [init object]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [init object]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind.Object"); @@ -102,7 +102,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [generic]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [generic]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyObject(vars, b); @@ -129,7 +129,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); @@ -145,7 +145,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, $frame.getValue(localIdx))"); } createSetSlotKind(vars, b, "FrameSlotKind.Object"); @@ -156,7 +156,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end().startElseBlock(); // } else { if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.out.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); } createCopyPrimitive(vars, b); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 57f3bbfef750..b4e15a6d65ba 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -136,7 +136,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf().string("localTag == ").staticReference(FrameSlotKind, "Illegal").end().startBlock(); // { if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [uninit]%n\", localIdx, $frame.getValue(sourceSlot))"); + b.statement("System.err.printf(\" local store %2d : %s [uninit]%n\", localIdx, $frame.getValue(sourceSlot))"); } b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); createCopyObject(vars, b); @@ -153,7 +153,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); if (OperationGeneratorFlags.LOG_LOCAL_STORES || OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { - b.statement("System.out.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, $frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); + b.statement("System.err.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, $frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); } b.startStatement().startCall("setResultBoxedImpl"); @@ -168,7 +168,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); } else if (kind == FrameKind.OBJECT) { if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.out.printf(\" local store %2d : %s [generic]%n\", localIdx, $frame.getValue(sourceSlot))"); + b.statement("System.err.printf(\" local store %2d : %s [generic]%n\", localIdx, $frame.getValue(sourceSlot))"); } b.startStatement().startCall(vars.frame, "setObject"); @@ -176,6 +176,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); b.end(2); } else { + if (OperationGeneratorFlags.LOG_LOCAL_STORES) { + b.statement("System.err.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(sourceSlot))"); + } b.startIf().string("!").startCall("storeLocal" + kind.getFrameName() + "Check"); b.variable(vars.frame); b.string("localIdx"); From 8d33257adabe308123ca57188da9a79e2764eed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 7 Jul 2022 15:01:54 +0200 Subject: [PATCH 108/312] [wip] different loop code gen --- .../processor/operations/OperationsCodeGenerator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index cda67c6d926b..2eefedf10899 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -372,7 +372,7 @@ private CodeExecutableElement createNodeImplExecuteAt() { CodeTreeBuilder b = mExecuteAt.createBuilder(); b.declaration("int", "result", "storedLocation"); - b.startDoBlock(); + b.startWhile().string("true").end().startBlock(); b.startAssign("result").startCall("switchImpl", "continueAt"); b.string("this"); @@ -387,7 +387,13 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.string("_maxLocals"); b.end(2); - b.end().startDoWhile().string("(result & 0xffff) != 0xffff").end(); + b.startIf().string("(result & 0xffff) == 0xffff").end().startBlock(); + b.statement("break"); + b.end().startElseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.end(); + + b.end(); b.startReturn().string("frame.getObject((result >> 16) & 0xffff)").end(); From 3f831eef298d6e9eb1041da5b8b63d47001e3309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 7 Jul 2022 15:14:08 +0200 Subject: [PATCH 109/312] [wip] --- .../sl/operations/SLOperationsBuilder.java | 8535 +++++++++++++++++ .../oracle/truffle/api/TruffleOptions.java | 6 - 2 files changed, 8535 insertions(+), 6 deletions(-) create mode 100644 truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java new file mode 100644 index 000000000000..7f8ac2e80848 --- /dev/null +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -0,0 +1,8535 @@ +// CheckStyle: start generated +package com.oracle.truffle.sl.operations; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; +import com.oracle.truffle.api.dsl.BoundaryCallFailedException; +import com.oracle.truffle.api.dsl.GeneratedBy; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.LibraryFactory; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.LoopNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.operation.OperationBuilder; +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; +import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleString.ConcatNode; +import com.oracle.truffle.api.strings.TruffleString.EqualNode; +import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; +import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.SLTypesGen; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; +import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.operations.SLOperations.SLInvoke; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLFunction; +import com.oracle.truffle.sl.runtime.SLNull; +import com.oracle.truffle.sl.runtime.SLObject; +import java.lang.invoke.VarHandle; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.locks.Lock; +import java.util.function.Consumer; + +@GeneratedBy(SLOperations.class) +@SuppressWarnings({"unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) +public abstract class SLOperationsBuilder extends OperationBuilder { + + protected SLOperationsBuilder() { + } + + public abstract void beginBlock(); + + public abstract void endBlock(); + + public abstract void beginIfThen(); + + public abstract void endIfThen(); + + public abstract void beginIfThenElse(); + + public abstract void endIfThenElse(); + + public abstract void beginConditional(); + + public abstract void endConditional(); + + public abstract void beginWhile(); + + public abstract void endWhile(); + + public abstract void beginTryCatch(OperationLocal arg0); + + public abstract void endTryCatch(); + + public abstract void beginFinallyTry(); + + public abstract void endFinallyTry(); + + public abstract void beginFinallyTryNoExcept(); + + public abstract void endFinallyTryNoExcept(); + + public abstract void emitLabel(OperationLabel arg0); + + public abstract void emitBranch(OperationLabel arg0); + + public abstract void emitConstObject(Object arg0); + + public abstract void emitLoadArgument(int arg0); + + public abstract void beginStoreLocal(OperationLocal arg0); + + public abstract void endStoreLocal(); + + public abstract void emitLoadLocal(OperationLocal arg0); + + public abstract void beginReturn(); + + public abstract void endReturn(); + + public abstract void beginSource(Source arg0); + + public abstract void endSource(); + + public abstract void beginSourceSection(int arg0, int arg1); + + public abstract void endSourceSection(); + + public abstract void beginTag(Class arg0); + + public abstract void endTag(); + + public abstract void beginSLAdd(); + + public abstract void endSLAdd(); + + public abstract void beginSLDiv(); + + public abstract void endSLDiv(); + + public abstract void beginSLEqual(); + + public abstract void endSLEqual(); + + public abstract void beginSLLessOrEqual(); + + public abstract void endSLLessOrEqual(); + + public abstract void beginSLLessThan(); + + public abstract void endSLLessThan(); + + public abstract void beginSLLogicalNot(); + + public abstract void endSLLogicalNot(); + + public abstract void beginSLMul(); + + public abstract void endSLMul(); + + public abstract void beginSLReadProperty(); + + public abstract void endSLReadProperty(); + + public abstract void beginSLSub(); + + public abstract void endSLSub(); + + public abstract void beginSLWriteProperty(); + + public abstract void endSLWriteProperty(); + + public abstract void beginSLUnbox(); + + public abstract void endSLUnbox(); + + public abstract void beginSLFunctionLiteral(); + + public abstract void endSLFunctionLiteral(); + + public abstract void beginSLToBoolean(); + + public abstract void endSLToBoolean(); + + public abstract void beginSLInvoke(); + + public abstract void endSLInvoke(); + + public abstract void beginSLAnd(); + + public abstract void endSLAnd(); + + public abstract void beginSLOr(); + + public abstract void endSLOr(); + + public abstract OperationLocal createLocal(); + + public abstract OperationLabel createLabel(); + + public abstract OperationNode publish(); + + public abstract void setMethodName(TruffleString value); + + public static OperationNodes create(OperationConfig config, Consumer generator) { + OperationNodesImpl nodes = new OperationNodesImpl(generator); + BuilderImpl builder = new BuilderImpl(nodes, false, config); + generator.accept(builder); + builder.finish(); + return nodes; + } + + @GeneratedBy(SLOperations.class) + private static final class OperationNodesImpl extends OperationNodes { + + OperationNodesImpl(Consumer parse) { + super(parse); + } + + @Override + protected void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes) { + BuilderImpl builder = new BuilderImpl(this, true, config); + ((Consumer) parse).accept(builder); + builder.finish(); + } + + void setSources(Source[] sources) { + this.sources = sources; + } + + void setNodes(OperationNode[] nodes) { + this.nodes = nodes; + } + + } + @GeneratedBy(SLOperations.class) + private static class BuilderImpl extends SLOperationsBuilder { + + private static final int OP_BLOCK = 1; + private static final int OP_IF_THEN = 2; + private static final int OP_IF_THEN_ELSE = 3; + private static final int OP_CONDITIONAL = 4; + private static final int OP_WHILE = 5; + private static final int OP_TRY_CATCH = 6; + private static final int OP_FINALLY_TRY = 7; + private static final int OP_FINALLY_TRY_NO_EXCEPT = 8; + private static final int OP_LABEL = 9; + private static final int OP_BRANCH = 10; + private static final int OP_CONST_OBJECT = 11; + private static final int OP_LOAD_ARGUMENT = 12; + private static final int OP_STORE_LOCAL = 13; + private static final int OP_LOAD_LOCAL = 14; + private static final int OP_RETURN = 15; + private static final int OP_SOURCE = 16; + private static final int OP_SOURCE_SECTION = 17; + private static final int OP_TAG = 18; + private static final int OP_SL_ADD = 19; + private static final int OP_SL_DIV = 20; + private static final int OP_SL_EQUAL = 21; + private static final int OP_SL_LESS_OR_EQUAL = 22; + private static final int OP_SL_LESS_THAN = 23; + private static final int OP_SL_LOGICAL_NOT = 24; + private static final int OP_SL_MUL = 25; + private static final int OP_SL_READ_PROPERTY = 26; + private static final int OP_SL_SUB = 27; + private static final int OP_SL_WRITE_PROPERTY = 28; + private static final int OP_SL_UNBOX = 29; + private static final int OP_SL_FUNCTION_LITERAL = 30; + private static final int OP_SL_TO_BOOLEAN = 31; + private static final int OP_SL_INVOKE = 32; + private static final int OP_SL_AND = 33; + private static final int OP_SL_OR = 34; + static final int INSTR_POP = 1; + static final int POP_LENGTH = 1; + static final int INSTR_BRANCH = 2; + static final int BRANCH_BRANCH_TARGET_OFFSET = 1; + static final int BRANCH_LENGTH = 2; + static final int INSTR_BRANCH_FALSE = 3; + static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; + static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; + static final int BRANCH_FALSE_LENGTH = 3; + static final int INSTR_THROW = 4; + static final int THROW_LOCALS_OFFSET = 1; + static final int THROW_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_OBJECT = 5; + static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_LONG = 6; + static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_LONG_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; + static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_LONG = 9; + static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_LONG_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; + static final int INSTR_STORE_LOCAL_OBJECT = 11; + static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_OBJECT_LENGTH = 3; + static final int INSTR_STORE_LOCAL_LONG = 12; + static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_LONG_LENGTH = 3; + static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; + static final int INSTR_STORE_LOCAL_UNINIT = 14; + static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_UNINIT_LENGTH = 3; + static final int INSTR_LOAD_LOCAL_OBJECT = 15; + static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_OBJECT_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_LONG = 16; + static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_LONG_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_UNINIT = 18; + static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_UNINIT_LENGTH = 2; + static final int INSTR_RETURN = 19; + static final int RETURN_LENGTH = 1; + static final int INSTR_INSTRUMENT_ENTER = 20; + static final int INSTRUMENT_ENTER_LENGTH = 2; + static final int INSTR_INSTRUMENT_EXIT_VOID = 21; + static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; + static final int INSTR_INSTRUMENT_EXIT = 22; + static final int INSTRUMENT_EXIT_LENGTH = 2; + static final int INSTR_INSTRUMENT_LEAVE = 23; + static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; + static final int INSTRUMENT_LEAVE_LENGTH = 4; + static final int INSTR_C_SL_ADD = 24; + static final int C_SL_ADD_CONSTANT_OFFSET = 1; + static final int C_SL_ADD_CHILDREN_OFFSET = 2; + static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; + static final int C_SL_ADD_STATE_BITS_OFFSET = 4; + static final int C_SL_ADD_LENGTH = 6; + static final int INSTR_C_SL_DIV = 25; + static final int C_SL_DIV_CONSTANT_OFFSET = 1; + static final int C_SL_DIV_CHILDREN_OFFSET = 2; + static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; + static final int C_SL_DIV_STATE_BITS_OFFSET = 4; + static final int C_SL_DIV_LENGTH = 6; + static final int INSTR_C_SL_EQUAL = 26; + static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; + static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; + static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; + static final int C_SL_EQUAL_LENGTH = 5; + static final int INSTR_C_SL_LESS_OR_EQUAL = 27; + static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; + static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; + static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; + static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; + static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; + static final int INSTR_C_SL_LESS_THAN = 28; + static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; + static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; + static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; + static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; + static final int C_SL_LESS_THAN_LENGTH = 5; + static final int INSTR_C_SL_LOGICAL_NOT = 29; + static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; + static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; + static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; + static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; + static final int C_SL_LOGICAL_NOT_LENGTH = 5; + static final int INSTR_C_SL_MUL = 30; + static final int C_SL_MUL_CONSTANT_OFFSET = 1; + static final int C_SL_MUL_CHILDREN_OFFSET = 2; + static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; + static final int C_SL_MUL_STATE_BITS_OFFSET = 4; + static final int C_SL_MUL_LENGTH = 6; + static final int INSTR_C_SL_READ_PROPERTY = 31; + static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; + static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; + static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; + static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; + static final int C_SL_READ_PROPERTY_LENGTH = 6; + static final int INSTR_C_SL_SUB = 32; + static final int C_SL_SUB_CONSTANT_OFFSET = 1; + static final int C_SL_SUB_CHILDREN_OFFSET = 2; + static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; + static final int C_SL_SUB_STATE_BITS_OFFSET = 4; + static final int C_SL_SUB_LENGTH = 6; + static final int INSTR_C_SL_WRITE_PROPERTY = 33; + static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; + static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; + static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; + static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; + static final int C_SL_WRITE_PROPERTY_LENGTH = 7; + static final int INSTR_C_SL_UNBOX = 34; + static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; + static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; + static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; + static final int C_SL_UNBOX_LENGTH = 5; + static final int INSTR_C_SL_FUNCTION_LITERAL = 35; + static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; + static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; + static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; + static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; + static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; + static final int INSTR_C_SL_TO_BOOLEAN = 36; + static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; + static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; + static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; + static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; + static final int C_SL_TO_BOOLEAN_LENGTH = 5; + static final int INSTR_C_SL_INVOKE = 37; + static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; + static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; + static final int C_SL_INVOKE_VARIADIC_OFFSET = 3; + static final int C_SL_INVOKE_STATE_BITS_OFFSET = 4; + static final int C_SL_INVOKE_LENGTH = 6; + static final int INSTR_SC_SL_AND = 38; + static final int SC_SL_AND_CONSTANT_OFFSET = 1; + static final int SC_SL_AND_CHILDREN_OFFSET = 2; + static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; + static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; + static final int SC_SL_AND_STATE_BITS_OFFSET = 5; + static final int SC_SL_AND_LENGTH = 6; + static final int INSTR_SC_SL_OR = 39; + static final int SC_SL_OR_CONSTANT_OFFSET = 1; + static final int SC_SL_OR_CHILDREN_OFFSET = 2; + static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; + static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; + static final int SC_SL_OR_STATE_BITS_OFFSET = 5; + static final int SC_SL_OR_LENGTH = 6; + static final int INSTR_C_SL_UNBOX_Q_FROM_LONG = 40; + static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; + static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; + static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; + static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + static final int INSTR_C_SL_ADD_Q_ADD_LONG = 41; + static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; + static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; + static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; + static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; + static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; + static final int INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 42; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + static final int INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 43; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + static final int INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 44; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; + static final int INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET = 1; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CHILDREN_OFFSET = 2; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET = 3; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET = 4; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 5; + static final int INSTR_C_SL_INVOKE_Q_DIRECT = 46; + static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; + static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; + static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 3; + static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 4; + static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 6; + static final int INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 47; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; + static final int INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 48; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; + static final int INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 = 49; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET = 1; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_CHILDREN_OFFSET = 2; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET = 3; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET = 4; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 5; + private static final short[][] BOXING_DESCRIPTORS = { + // OBJECT + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + // LONG + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + // INT + null, + // DOUBLE + null, + // FLOAT + null, + // BOOLEAN + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + // BYTE + null}; + + private final OperationNodesImpl nodes; + private final boolean isReparse; + private final boolean withSource; + private final boolean withInstrumentation; + private final SourceInfoBuilder sourceBuilder; + private short[] bc = new short[65535]; + private int bci; + private int curStack; + private int maxStack; + private int numLocals; + private ArrayList constPool = new ArrayList<>(); + private BuilderOperationData operationData; + private ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private int numChildNodes; + private int numBranchProfiles; + private ArrayList exceptionHandlers = new ArrayList<>(); + private BuilderFinallyTryContext currentFinallyTry; + private int buildIndex; + private int[] stackSourceBci = new int[1024]; + private final ArrayList builtNodes; + int lastChildPush; + private TruffleString metadata_MethodName; + + private BuilderImpl(OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { + this.nodes = nodes; + this.isReparse = isReparse; + builtNodes = new ArrayList<>(); + if (isReparse) { + builtNodes.addAll((java.util.Collection) nodes.getNodes()); + } + this.withSource = config.isWithSource(); + this.withInstrumentation = config.isWithInstrumentation(); + this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; + reset(); + } + + private void finish() { + if (withSource) { + nodes.setSources(sourceBuilder.buildSource()); + } + if (!isReparse) { + nodes.setNodes(builtNodes.toArray(new OperationNode[0])); + } + } + + private void reset() { + bci = 0; + curStack = 0; + maxStack = 0; + numLocals = 0; + constPool.clear(); + operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0); + labelFills.clear(); + numChildNodes = 0; + numBranchProfiles = 0; + exceptionHandlers.clear(); + metadata_MethodName = null; + } + + private int[] doBeforeEmitInstruction(int numPops, boolean pushValue) { + int[] result = new int[numPops]; + for (int i = numPops - 1; i >= 0; i--) { + curStack--; + int predBci = stackSourceBci[curStack]; + result[i] = predBci; + } + if (pushValue) { + if (curStack >= stackSourceBci.length) { + stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); + } + stackSourceBci[curStack] = bci; + curStack++; + if (curStack > maxStack) { + maxStack = curStack; + } + } + return result; + } + + private void doLeaveFinallyTry(BuilderOperationData opData) { + BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; + if (context.handlerBc == null) { + return; + } + System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); + for (int offset : context.relocationOffsets) { + short oldOffset = bc[bci + offset]; + bc[bci + offset] = (short) (oldOffset + bci); + } + for (ExceptionHandler handler : context.handlerHandlers) { + exceptionHandlers.add(handler.offset(bci, curStack)); + } + for (LabelFill fill : context.handlerLabelFills) { + labelFills.add(fill.offset(bci)); + } + if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; + bci += context.handlerBc.length; + } + + private void doEmitLabel(OperationLabel label) { + OperationLabelImpl lbl = (OperationLabelImpl) label; + if (lbl.hasValue) { + throw new UnsupportedOperationException("label already emitted"); + } + if (operationData != lbl.data) { + throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); + } + lbl.hasValue = true; + lbl.targetBci = bci; + } + + private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { + if (toData != null && fromData.depth < toData.depth) { + throw new UnsupportedOperationException("illegal jump to deeper operation"); + } + if (fromData == toData) { + return; + } + BuilderOperationData cur = fromData; + while (true) { + doLeaveOperation(cur); + cur = cur.parent; + if (toData == null && cur == null) { + break; + } else if (toData != null && cur.depth <= toData.depth) break; + } + if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); + } + + private void calculateLeaves(BuilderOperationData fromData) { + calculateLeaves(fromData, (BuilderOperationData) null); + } + + private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { + calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); + } + + @Override + public OperationLocal createLocal() { + return new OperationLocalImpl(operationData, numLocals++); + } + + OperationLocalImpl createParentLocal() { + return new OperationLocalImpl(operationData.parent, numLocals++); + } + + @Override + public OperationLabel createLabel() { + OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); + labels.add(label); + return label; + } + + private short getLocalIndex(Object value) { + OperationLocalImpl local = (OperationLocalImpl) value; + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + return (short) local.id; + } + + private int[] getLocalIndices(Object value) { + OperationLocal[] locals = (OperationLocal[]) value; + int[] result = new int[locals.length]; + for (int i = 0; i < locals.length; i++) { + result[i] = getLocalIndex(locals[i]); + } + return result; + } + + private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { + BuilderOperationData cur = child; + while (cur.depth > parent.depth) { + cur = cur.parent; + } + return cur == parent; + } + + @Override + public OperationNode publish() { + if (operationData.depth != 0) { + throw new UnsupportedOperationException("Not all operations closed"); + } + OperationNodeImpl result; + if (!isReparse) { + result = new OperationNodeImpl(nodes); + labelPass(null); + result._bc = Arrays.copyOf(bc, bci); + result._consts = constPool.toArray(); + result._children = new Node[numChildNodes]; + result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); + result._conditionProfiles = new int[numBranchProfiles * 2]; + result._maxLocals = numLocals; + result._maxStack = maxStack; + if (sourceBuilder != null) { + result.sourceInfo = sourceBuilder.build(); + } + result._metadata_MethodName = metadata_MethodName; + assert builtNodes.size() == buildIndex; + builtNodes.add(result); + } else { + result = builtNodes.get(buildIndex); + if (withSource && result.sourceInfo == null) { + result.sourceInfo = sourceBuilder.build(); + } + } + buildIndex++; + reset(); + return result; + } + + private void labelPass(BuilderFinallyTryContext finallyTry) { + for (LabelFill fill : labelFills) { + if (finallyTry != null) { + if (fill.label.belongsTo(finallyTry)) { + assert fill.label.hasValue : "inner label should have been resolved by now"; + finallyTry.relocationOffsets.add(fill.locationBci); + } else { + finallyTry.handlerLabelFills.add(fill); + } + } + bc[fill.locationBci] = (short) fill.label.targetBci; + } + } + + private void doLeaveOperation(BuilderOperationData data) { + switch (data.operationId) { + case OP_FINALLY_TRY : + { + doLeaveFinallyTry(data); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + doLeaveFinallyTry(data); + break; + } + case OP_TAG : + { + break; + } + } + } + + @SuppressWarnings("unused") + void doBeforeChild() { + int childIndex = operationData.numChildren; + switch (operationData.operationId) { + case OP_BLOCK : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + } + break; + } + case OP_TRY_CATCH : + { + if (childIndex == 1) { + curStack = ((ExceptionHandler) operationData.aux[0]).startStack; + ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; + } + break; + } + case OP_SOURCE : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + } + break; + } + case OP_SOURCE_SECTION : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + } + break; + } + case OP_TAG : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + } + break; + } + case OP_SL_AND : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_SC_SL_AND); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + bci = bci + 6; + } + break; + } + case OP_SL_OR : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_SC_SL_OR); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + bci = bci + 6; + } + break; + } + } + } + + @SuppressWarnings("unused") + void doAfterChild() { + int childIndex = operationData.numChildren++; + switch (operationData.operationId) { + case OP_IF_THEN : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = endLabel; + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + 3; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } + break; + } + case OP_IF_THEN_ELSE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bci = bci + 3; + } else if (childIndex == 1) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + 2; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_CONDITIONAL : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bci = bci + 3; + } else if (childIndex == 1) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + 2; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + assert lastChildPush == 1; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_WHILE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + 3; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bci = bci + 2; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_TRY_CATCH : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + if (childIndex == 0) { + ((ExceptionHandler) operationData.aux[0]).endBci = bci; + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); + bci = bci + 2; + } else { + } + break; + } + case OP_FINALLY_TRY : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.aux[2]); + exceptionHandlers.add(beh); + operationData.aux[1] = beh; + } + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_POP); + bci = bci + 1; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + } + break; + } + } + } + + @SuppressWarnings("unused") + @Override + public void beginBlock() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); + lastChildPush = 0; + } + + @SuppressWarnings("unused") + @Override + public void endBlock() { + if (operationData.operationId != OP_BLOCK) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); + } + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginIfThen() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); + } + + @SuppressWarnings("unused") + @Override + public void endIfThen() { + if (operationData.operationId != OP_IF_THEN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginIfThenElse() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); + } + + @SuppressWarnings("unused") + @Override + public void endIfThenElse() { + if (operationData.operationId != OP_IF_THEN_ELSE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginConditional() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); + } + + @SuppressWarnings("unused") + @Override + public void endConditional() { + if (operationData.operationId != OP_CONDITIONAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); + } + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginWhile() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = startLabel; + } + + @SuppressWarnings("unused") + @Override + public void endWhile() { + if (operationData.operationId != OP_WHILE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("While expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginTryCatch(OperationLocal arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); + exceptionHandlers.add(beh); + operationData.aux[0] = beh; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + } + + @SuppressWarnings("unused") + @Override + public void endTryCatch() { + if (operationData.operationId != OP_TRY_CATCH) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginFinallyTry() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); + operationData.aux[2] = createParentLocal(); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + @Override + public void endFinallyTry() { + if (operationData.operationId != OP_FINALLY_TRY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); + } + int endBci = bci; + doLeaveFinallyTry(operationData); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + { + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + 2; + } + ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); + beh.endBci = endBci; + beh.handlerBci = bci; + doLeaveFinallyTry(operationData); + { + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_THROW); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); + bci = bci + 2; + } + doEmitLabel(endLabel); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginFinallyTryNoExcept() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + @Override + public void endFinallyTryNoExcept() { + if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); + } + doLeaveFinallyTry(operationData); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLabel(OperationLabel arg0) { + doBeforeChild(); + doEmitLabel(arg0); + lastChildPush = 0; + doAfterChild(); + } + + @Override + public void emitBranch(OperationLabel arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); + calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); + bci = bci + 2; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitConstObject(Object arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_CONST_OBJECT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true); + bc[bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(arg0); + bci = bci + 2; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLoadArgument(int arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true); + bc[bci] = (short) (INSTR_LOAD_ARGUMENT_OBJECT); + bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; + bci = bci + 2; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginStoreLocal(OperationLocal arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + @Override + public void endStoreLocal() { + if (operationData.operationId != OP_STORE_LOCAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_STORE_LOCAL_UNINIT); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bci = bci + 3; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void emitLoadLocal(OperationLocal arg0) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true); + bc[bci] = (short) (INSTR_LOAD_LOCAL_UNINIT); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + bci = bci + 2; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginReturn() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endReturn() { + if (operationData.operationId != OP_RETURN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("Return expected 1 children, got " + numChildren); + } + calculateLeaves(operationData); + doBeforeEmitInstruction(1, false); + bc[bci] = (short) (INSTR_RETURN); + bci = bci + 1; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSource(Source arg0) { + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); + sourceBuilder.beginSource(bci, arg0); + } + } + + @SuppressWarnings("unused") + @Override + public void endSource() { + if (withSource) { + if (operationData.operationId != OP_SOURCE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSource(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + @Override + public void beginSourceSection(int arg0, int arg1) { + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); + sourceBuilder.beginSourceSection(bci, arg0, arg1); + } + } + + @SuppressWarnings("unused") + @Override + public void endSourceSection() { + if (withSource) { + if (operationData.operationId != OP_SOURCE_SECTION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSourceSection(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + @Override + public void beginTag(Class arg0) { + if (withInstrumentation) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); + int curInstrumentId = 0; + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = curInstrumentId; + operationData.aux[1] = startLabel; + operationData.aux[2] = endLabel; + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_INSTRUMENT_ENTER); + bci = bci + 2; + lastChildPush = 0; + } + } + + @SuppressWarnings("unused") + @Override + public void endTag() { + if (withInstrumentation) { + if (operationData.operationId != OP_TAG) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); + } + if (lastChildPush != 0) { + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_INSTRUMENT_EXIT_VOID); + bci = bci + 2; + } else { + doBeforeEmitInstruction(0, false); + bc[bci] = (short) (INSTR_INSTRUMENT_EXIT); + bci = bci + 2; + } + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + @Override + public void beginSLAdd() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLAdd() { + if (operationData.operationId != OP_SL_ADD) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_ADD); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 2; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLDiv() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLDiv() { + if (operationData.operationId != OP_SL_DIV) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_DIV); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLEqual() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLEqual() { + if (operationData.operationId != OP_SL_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_EQUAL); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 4; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLessOrEqual() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLessOrEqual() { + if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLessThan() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLessThan() { + if (operationData.operationId != OP_SL_LESS_THAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_LESS_THAN); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLLogicalNot() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLLogicalNot() { + if (operationData.operationId != OP_SL_LOGICAL_NOT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true); + bc[bci] = (short) (INSTR_C_SL_LOGICAL_NOT); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLMul() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLMul() { + if (operationData.operationId != OP_SL_MUL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_MUL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLReadProperty() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLReadProperty() { + if (operationData.operationId != OP_SL_READ_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 12; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLSub() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLSub() { + if (operationData.operationId != OP_SL_SUB) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true); + bc[bci] = (short) (INSTR_C_SL_SUB); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLWriteProperty() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLWriteProperty() { + if (operationData.operationId != OP_SL_WRITE_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(3, true); + bc[bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 11; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); + bc[bci + 5 + 0] = 0; + bc[bci + 5 + 1] = 0; + bci = bci + 7; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLUnbox() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLUnbox() { + if (operationData.operationId != OP_SL_UNBOX) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true); + bc[bci] = (short) (INSTR_C_SL_UNBOX); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 3; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLFunctionLiteral() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLFunctionLiteral() { + if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true); + bc[bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLToBoolean() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLToBoolean() { + if (operationData.operationId != OP_SL_TO_BOOLEAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true); + bc[bci] = (short) (INSTR_C_SL_TO_BOOLEAN); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + 5; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLInvoke() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); + } + + @SuppressWarnings("unused") + @Override + public void endSLInvoke() { + if (operationData.operationId != OP_SL_INVOKE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); + } + doBeforeEmitInstruction(numChildren - 1 + 1, true); + bc[bci] = (short) (INSTR_C_SL_INVOKE); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 4; + bc[bci + 3] = (short) (numChildren - 1); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + 6; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLAnd() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + @Override + public void endSLAnd() { + if (operationData.operationId != OP_SL_AND) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + @Override + public void beginSLOr() { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + @Override + public void endSLOr() { + if (operationData.operationId != OP_SL_OR) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @Override + public void setMethodName(TruffleString value) { + metadata_MethodName = value; + } + + @GeneratedBy(SLOperations.class) + private static final class BuilderOperationData { + + final BuilderOperationData parent; + final int operationId; + final int stackDepth; + final boolean needsLeave; + final int depth; + final Object[] arguments; + final Object[] aux; + int numChildren; + + private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { + this.parent = parent; + this.operationId = operationId; + this.stackDepth = stackDepth; + this.depth = parent == null ? 0 : parent.depth + 1; + this.aux = numAux > 0 ? new Object[numAux] : null; + this.needsLeave = needsLeave || (parent != null && parent.needsLeave); + this.arguments = arguments; + } + + } + @GeneratedBy(SLOperations.class) + private static final class OperationLabelImpl extends OperationLabel { + + BuilderOperationData data; + BuilderFinallyTryContext finallyTry; + int targetBci = 0; + boolean hasValue = false; + + OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { + this.data = data; + this.finallyTry = finallyTry; + } + + boolean belongsTo(BuilderFinallyTryContext context) { + BuilderFinallyTryContext cur = finallyTry; + while (cur != null) { + if (cur == context) { + return true; + } + cur = cur.prev; + } + return false; + } + + } + @GeneratedBy(SLOperations.class) + private static final class OperationLocalImpl extends OperationLocal { + + final BuilderOperationData owner; + final int id; + + OperationLocalImpl(BuilderOperationData owner, int id) { + this.owner = owner; + this.id = id; + } + + } + @GeneratedBy(SLOperations.class) + private static final class LabelFill { + + int locationBci; + OperationLabelImpl label; + + LabelFill(int locationBci, OperationLabelImpl label) { + this.locationBci = locationBci; + this.label = label; + } + + LabelFill offset(int offset) { + return new LabelFill(offset + locationBci, label); + } + + } + @GeneratedBy(SLOperations.class) + private static final class ExceptionHandler { + + int startBci; + int startStack; + int endBci; + int exceptionIndex; + int handlerBci; + + ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { + this.startBci = startBci; + this.startStack = startStack; + this.endBci = endBci; + this.exceptionIndex = exceptionIndex; + this.handlerBci = handlerBci; + } + + ExceptionHandler() { + } + + ExceptionHandler offset(int offset, int stackOffset) { + return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); + } + + @Override + public String toString() { + return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); + } + + } + @GeneratedBy(SLOperations.class) + private static final class SourceInfoBuilder { + + private final ArrayList sourceStack = new ArrayList<>(); + private final ArrayList sourceList = new ArrayList<>(); + private int currentSource = -1; + private final ArrayList bciList = new ArrayList<>(); + private final ArrayList sourceDataList = new ArrayList<>(); + private final ArrayList sourceDataStack = new ArrayList<>(); + + void reset() { + sourceStack.clear(); + sourceDataList.clear(); + sourceDataStack.clear(); + bciList.clear(); + } + + void beginSource(int bci, Source src) { + int idx = sourceList.indexOf(src); + if (idx == -1) { + idx = sourceList.size(); + sourceList.add(src); + } + sourceStack.add(currentSource); + currentSource = idx; + beginSourceSection(bci, -1, -1); + } + + void endSource(int bci) { + endSourceSection(bci); + currentSource = sourceStack.remove(sourceStack.size() - 1); + } + + void beginSourceSection(int bci, int start, int length) { + SourceData data = new SourceData(start, length, currentSource); + bciList.add(bci); + sourceDataList.add(data); + sourceDataStack.add(data); + } + + void endSourceSection(int bci) { + SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); + SourceData prev; + if (sourceDataStack.isEmpty()) { + prev = new SourceData(-1, -1, currentSource); + } else { + prev = sourceDataStack.get(sourceDataStack.size() - 1); + } + bciList.add(bci); + sourceDataList.add(prev); + } + + int[] build() { + if (!sourceStack.isEmpty()) { + throw new IllegalStateException("not all sources ended"); + } + if (!sourceDataStack.isEmpty()) { + throw new IllegalStateException("not all source sections ended"); + } + int size = bciList.size(); + int[] resultArray = new int[size * 3]; + int index = 0; + int lastBci = -1; + boolean isFirst = true; + for (int i = 0; i < size; i++) { + SourceData data = sourceDataList.get(i); + int curBci = bciList.get(i); + if (data.start == -1 && isFirst) { + continue; + } + isFirst = false; + if (curBci == lastBci && index > 1) { + index -= 3; + } + resultArray[index + 0] = curBci | (data.sourceIndex << 16); + resultArray[index + 1] = data.start; + resultArray[index + 2] = data.length; + index += 3; + lastBci = curBci; + } + return Arrays.copyOf(resultArray, index); + } + + Source[] buildSource() { + return sourceList.toArray(new Source[0]); + } + + @GeneratedBy(SLOperations.class) + private static final class SourceData { + + final int start; + final int length; + final int sourceIndex; + + SourceData(int start, int length, int sourceIndex) { + this.start = start; + this.length = length; + this.sourceIndex = sourceIndex; + } + + } + } + @GeneratedBy(SLOperations.class) + private static final class BuilderFinallyTryContext { + + final BuilderFinallyTryContext prev; + final short[] bc; + final ArrayList exceptionHandlers; + final ArrayList labelFills; + final ArrayList labels; + final int curStack; + final int maxStack; + short[] handlerBc; + ArrayList handlerHandlers; + ArrayList handlerLabelFills = new ArrayList<>(); + ArrayList relocationOffsets = new ArrayList<>(); + int handlerMaxStack; + + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { + this.prev = prev; + this.bc = bc; + this.exceptionHandlers = exceptionHandlers; + this.labelFills = labelFills; + this.labels = labels; + this.curStack = curStack; + this.maxStack = maxStack; + } + + } + @GeneratedBy(SLOperations.class) + private static final class OperationNodeImpl extends OperationNode implements BytecodeOSRNode { + + private static final BytecodeLoopBase COMMON_EXECUTE = new BytecodeNode(); + private static final BytecodeLoopBase INITIAL_EXECUTE = COMMON_EXECUTE; + + @CompilationFinal(dimensions = 1) short[] _bc; + @CompilationFinal(dimensions = 1) Object[] _consts; + @Children Node[] _children; + @CompilationFinal(dimensions = 1) ExceptionHandler[] _handlers; + @CompilationFinal(dimensions = 1) int[] _conditionProfiles; + @CompilationFinal int _maxLocals; + @CompilationFinal int _maxStack; + @CompilationFinal(dimensions = 1) int[] sourceInfo; + @CompilationFinal private Object _osrMetadata; + private TruffleString _metadata_MethodName; + @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; + + private OperationNodeImpl(OperationNodes nodes) { + super(nodes); + } + + static { + setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n)._metadata_MethodName); + } + + private T insertAccessor(T node) { // () { + return insert(node); + } + + private Object executeAt(VirtualFrame frame, int storedLocation) { + int result = storedLocation; + while (true) { + result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _handlers, _conditionProfiles, _maxLocals); + if ((result & 0xffff) == 0xffff) { + break; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + } + return frame.getObject((result >> 16) & 0xffff); + } + + @Override + public Object execute(VirtualFrame frame) { + return executeAt(frame, _maxLocals << 16); + } + + @Override + protected int[] getSourceInfo() { + return sourceInfo; + } + + @Override + public String dump() { + return switchImpl.dump(_bc, _handlers, _consts); + } + + private Lock getLockAccessor() { + return getLock(); + } + + @Override + public FrameDescriptor createFrameDescriptor() { + FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); + builder.addSlots(_maxLocals + _maxStack, FrameSlotKind.Illegal); + return builder.build(); + } + + @Override + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target); + } + + @Override + public Object getOSRMetadata() { + return _osrMetadata; + } + + @Override + public void setOSRMetadata(Object osrMetadata) { + _osrMetadata = osrMetadata; + } + + @Override + public Node deepCopy() { + OperationNodeImpl result = new OperationNodeImpl(nodes); + result._bc = Arrays.copyOf(_bc, _bc.length); + result._consts = Arrays.copyOf(_consts, _consts.length); + result._children = Arrays.copyOf(_children, _children.length); + result._handlers = _handlers; + result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + @Override + public Node copy() { + OperationNodeImpl result = new OperationNodeImpl(nodes); + result._bc = _bc; + result._consts = _consts; + result._children = _children; + result._handlers = _handlers; + result._conditionProfiles = _conditionProfiles; + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + } + @GeneratedBy(SLOperations.class) + private abstract static class BytecodeLoopBase { + + abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); + + abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); + + abstract void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); + + protected static String formatConstant(Object obj) { + if (obj == null) { + return "null"; + } else { + Object repr = obj; + if (obj instanceof Object[]) { + repr = Arrays.deepToString((Object[]) obj); + } + return String.format("%s %s", obj.getClass().getSimpleName(), repr); + } + } + + protected static Object expectObject(VirtualFrame frame, int slot) { + if (frame.isObject(slot)) { + return frame.getObject(slot); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return frame.getValue(slot); + } + } + + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, short[] descriptor) { + int op = bc[bci] & 0xffff; + short todo = descriptor[op]; + if (todo > 0) { + bc[bci] = todo; + } else { + int offset = (todo >> 8) & 0x7f; + int bit = todo & 0xff; + if (targetType == 0 /* OBJECT */) { + bc[bci + offset] &= ~bit; + } else { + bc[bci + offset] |= bit; + } + } + } + + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case 1 /* LONG */ : + return frame.getLong(slot); + case 0 /* OBJECT */ : + Object value = frame.getObject(slot); + if (value instanceof Long) { + return (long) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + try { + frame.setLong(localSlot, expectLong(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + switch (frame.getTag(slot)) { + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); + case 0 /* OBJECT */ : + Object value = frame.getObject(slot); + if (value instanceof Boolean) { + return (boolean) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(frame.getValue(slot)); + } + + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + FrameDescriptor descriptor = frame.getFrameDescriptor(); + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + try { + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + return true; + } catch (UnexpectedResultException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + descriptor.setSlotKind(localSlot, FrameSlotKind.Object); + frame.setObject(localSlot, frame.getValue(stackSlot)); + return false; + } + + } + @GeneratedBy(SLOperations.class) + private static final class BytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + int loopCount = 0; + loop: while (true) { + int nextBci; + short curOpcode = $bc[$bci]; + try { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + CompilerAsserts.partialEvaluationConstant(curOpcode); + if ($sp < maxLocals) { + throw CompilerDirectives.shouldNotReachHere("stack underflow"); + } + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_POP : + { + $sp = $sp - 1; + $frame.clear($sp); + nextBci = $bci + POP_LENGTH; + break; + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Boxing Elimination: Do Nothing + case INSTR_BRANCH : + { + int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; + if (targetBci <= $bci) { + TruffleSafepoint.poll($this); + if (CompilerDirectives.hasNextTier() && ++loopCount >= 256) { + LoopNode.reportLoopCount($this, 256); + loopCount = 0; + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + // Boxing Elimination: Do Nothing + case INSTR_BRANCH_FALSE : + { + boolean cond = (boolean) $frame.getObject($sp - 1); + $sp = $sp - 1; + if (cond) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_THROW : + { + int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; + throw (AbstractTruffleException) $frame.getObject(slot); + } + // load.constant.object + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_OBJECT : + { + $frame.setObject($sp, $consts[$bc[$bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET] + 0]); + $sp = $sp + 1; + nextBci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + break; + } + // load.constant.long + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG : + { + $frame.setLong($sp, (long) $consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]); + $sp = $sp + 1; + nextBci = $bci + LOAD_CONSTANT_LONG_LENGTH; + break; + } + // load.constant.boolean + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN + // INT -> INSTR_LOAD_CONSTANT_BOOLEAN + // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN + // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + $frame.setBoolean($sp, (boolean) $consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]); + $sp = $sp + 1; + nextBci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + break; + } + // load.argument.object + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); + $sp = $sp + 1; + nextBci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + break; + } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + nextBci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; + } + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + nextBci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + break; + } + // store.local.object + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_STORE_LOCAL_OBJECT : + { + int localIdx = $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0]; + int sourceSlot = $sp - 1; + $frame.setObject(localIdx, expectObject($frame, sourceSlot)); + $sp--; + nextBci = $bci + STORE_LOCAL_OBJECT_LENGTH; + break; + } + // store.local.long + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_LONG : + { + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int sourceSlot = $sp - 1; + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + } + $sp--; + nextBci = $bci + STORE_LOCAL_LONG_LENGTH; + break; + } + // store.local.boolean + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_OBJECT + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_BOOLEAN : + { + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int sourceSlot = $sp - 1; + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + } + $sp--; + nextBci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + break; + } + // store.local.uninit + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_LONG + // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN + case INSTR_STORE_LOCAL_UNINIT : + { + int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; + int sourceSlot = $sp - 1; + FrameSlotKind localTag = $frame.getFrameDescriptor().getSlotKind(localIdx); + if (localTag == FrameSlotKind.Illegal) { + assert $frame.isObject(sourceSlot); + $frame.copyObject(sourceSlot, localIdx); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + int resultTag = storeLocalInitialization($frame, localIdx, localTag.tag, sourceSlot); + setResultBoxedImpl($bc, $bci, resultTag, BOXING_DESCRIPTORS[resultTag]); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff), resultTag); + } + $sp--; + nextBci = $bci + STORE_LOCAL_UNINIT_LENGTH; + break; + } + // load.local.object + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Do Nothing + case INSTR_LOAD_LOCAL_OBJECT : + { + int localIdx = $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0]; + if ($frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + $frame.setObject(localIdx, $frame.getValue(localIdx)); + } + $frame.copyObject(localIdx, $sp); + $sp++; + nextBci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + break; + } + // load.local.long + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_LONG : + { + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); + if (localType != FrameSlotKind.Long) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object localValue; + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); + $frame.copyPrimitive(localIdx, $sp); + } else { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + $bc[$bci] = (short) (INSTR_LOAD_LOCAL_OBJECT); + $frame.copyObject(localIdx, $sp); + } + } else { + $frame.copyPrimitive(localIdx, $sp); + } + $sp++; + nextBci = $bci + LOAD_LOCAL_LONG_LENGTH; + break; + } + // load.local.boolean + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_OBJECT + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_BOOLEAN : + { + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); + if (localType != FrameSlotKind.Boolean) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object localValue; + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); + $frame.copyPrimitive(localIdx, $sp); + } else { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); + $bc[$bci] = (short) (INSTR_LOAD_LOCAL_OBJECT); + $frame.copyObject(localIdx, $sp); + } + } else { + $frame.copyPrimitive(localIdx, $sp); + } + $sp++; + nextBci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + break; + } + // load.local.uninit + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_LONG + // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN + case INSTR_LOAD_LOCAL_UNINIT : + { + int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; + $frame.setObject($sp, expectObject($frame, localIdx)); + $sp++; + nextBci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + break; + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_RETURN : + { + return (($sp - 1) << 16) | 0xffff; + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e79d949 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@172a1de + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD : + { + BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_ADD_LENGTH; + break; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65b021d3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@64ce13c7 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_DIV : + { + BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_DIV_LENGTH; + break; + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@148d3d86 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@650298 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_EQUAL : + { + BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_EQUAL_LENGTH; + break; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@643f05fe + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL : + { + BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@707b6295 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN : + { + BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@de71011 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LOGICAL_NOT : + { + BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@25bea2f7 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@39b2434b + // Boxing Elimination: Bit Mask + case INSTR_C_SL_MUL : + { + BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_MUL_LENGTH; + break; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@12f6e122 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27a41cf5 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY : + { + BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77ddabec + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5cde0647 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_SUB : + { + BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_SUB_LENGTH; + break; + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7984030f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ec0eb7e + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY : + { + BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 3 + 1; + nextBci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6458bd81 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48187373 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX : + { + BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_UNBOX_LENGTH; + break; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@115d9d04 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL : + { + BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@683f0f4a + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN : + { + BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@49aa0379 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@42a262d4 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE : + { + int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; + Object input_0 = $frame.getObject($sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); + } + Object result = BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); + $sp = $sp - 1 - numVariadics + 1; + $frame.setObject($sp - 1, result); + nextBci = $bci + C_SL_INVOKE_LENGTH; + break; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f6a7239 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_AND : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2fbf7fc1 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_OR : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36170084 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@67727050 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + // c.SLAdd.q.AddLong + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b652d3d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5ff01ae7 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@516d32bd + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@25e93830 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c7f575 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58bff048 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + // c.SLToBoolean.q.Boolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@607fd938 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + // c.SLLessOrEqual.q.LessOrEqual0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@c3b45bf + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { + BytecodeNode.SLLessOrEqual_q_LessOrEqual0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + break; + } + // c.SLInvoke.q.Direct + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@346f7510 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@13f5fe65 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + int numVariadics = $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0]; + Object input_0 = $frame.getObject($sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); + } + Object result = BytecodeNode.SLInvoke_q_Direct_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); + $sp = $sp - 1 - numVariadics + 1; + $frame.setObject($sp - 1, result); + nextBci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + // c.SLFunctionLiteral.q.Perform + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ddd433a + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 1 + 1; + nextBci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + // c.SLWriteProperty.q.WriteSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b1de983 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1495c005 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 3 + 1; + nextBci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + // c.SLLessThan.q.LessThan0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28af0224 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { + BytecodeNode.SLLessThan_q_LessThan0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp = $sp - 2 + 1; + nextBci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + break; + } + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + CompilerAsserts.partialEvaluationConstant(nextBci); + $bci = nextBci; + } + } + + @Override + void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ($bc[$bci]) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_OBJECT : + { + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_LONG : + { + $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_LONG : + { + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_OBJECT : + { + $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_LONG : + { + $bci = $bci + STORE_LOCAL_LONG_LENGTH; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN : + { + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_UNINIT : + { + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_OBJECT : + { + $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_LONG : + { + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + { + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_UNINIT : + { + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + break; + } + } + } + } + + @Override + String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + StringBuilder sb = new StringBuilder(); + while ($bci < $bc.length) { + sb.append(String.format(" [%04x]", $bci)); + switch ($bc[$bci]) { + default : + { + sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); + break; + } + case INSTR_POP : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("pop "); + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch "); + sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch.false "); + sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("throw "); + sb.append(String.format(" local(%s)", $bc[$bci + THROW_LOCALS_OFFSET + 0])); + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_OBJECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.object "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET] + 0]))); + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.object "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_OBJECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.object "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_UNINIT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.uninit "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_OBJECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.object "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_UNINIT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.uninit "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_RETURN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_ADD_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLDiv "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_DIV_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEqual "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_THAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLMul "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_MUL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 2]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLSub "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_SUB_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLInvoke "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_INVOKE_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLAnd "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + SC_SL_AND_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_AND_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLOr "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + SC_SL_OR_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_OR_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.AddLong "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty.q.ReadSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 2]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBoolean "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual0"); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLInvoke.q.Direct "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral.q.Perform "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty.q.WriteSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1] & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan0 "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < $handlers.length; i++) { + sb.append($handlers[i] + "\n"); + } + return sb.toString(); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static void SLAdd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */; + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + + private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLAddNode.addLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_ADD_CHILDREN_OFFSET] + 0) + 0]); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); + return; + } + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1]; + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { + $bc[$bci] = (short) (INSTR_C_SL_ADD_Q_ADD_LONG); + } else { + $bc[$bci] = (short) (INSTR_C_SL_ADD); + } + int type0; + int type1; + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + try { + lock.unlock(); + hasLock = false; + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + $bc[$bci] = (short) (INSTR_C_SL_ADD); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); + return; + } + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = $bc[$bci + C_SL_ADD_CHILDREN_OFFSET] + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + $bc[$bci] = (short) (INSTR_C_SL_ADD); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci] = (short) (INSTR_C_SL_ADD); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLDiv_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; + try { + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + + private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLDivNode.divLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1]; + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + try { + lock.unlock(); + hasLock = false; + long value = SLDivNode.divLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */; + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + boolean value = SLEqualNode.doString($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 0]); + if (truffleString_equalNode__ != null) { + boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1110000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + if ((state_0 & 0b1100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1]); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b1000000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + $frame.setObject($sp - 2, SLEqual_generic1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); + int type0; + int type1; + if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); + int type0; + int type1; + if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */) { + type0 = 5 /* BOOLEAN */; + type1 = 5 /* BOOLEAN */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doString($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) $children[childArrayOffset_ + 0])); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1]); + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.leftInterop_.accepts($child0Value)); + // assert (s7_.rightInterop_.accepts($child1Value)); + if (count7_ < (4)) { + s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) $children[childArrayOffset_ + 1]))); + s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1] = null; + state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0); + } else { + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + } + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0); + } else { + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); + } + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLLogicalNotNode.doBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return; + } + + private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + int type0; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { + type0 = 5 /* BOOLEAN */; + } else { + type0 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLMul_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; + try { + long value = SLMulNode.mulLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + + private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLMulNode.mulLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1]; + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + try { + lock.unlock(); + hasLock = false; + long value = SLMulNode.mulLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0]; + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_)); + return; + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 2, SLReadProperty_readArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__1 = ($this); + int bci__1 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 2, SLReadProperty_readSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_)); + return; + } + } + if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 8]); + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { + Node node__2 = ($this); + int bci__2 = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_)); + return; + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + $frame.setObject($sp - 2, SLReadProperty_readObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 11]); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1]; + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) $children[childArrayOffset_ + 0]))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_)); + return; + } + } + } + { + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = ($this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) $children[childArrayOffset_ + 4]))); + node__1 = ($this); + bci__1 = ($bci); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0); + } else { + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + } + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = ($this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); + return; + } + } + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 8]); + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { + node__2 = ($this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (s4_.objects_.accepts($child0Value)); + InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) $children[childArrayOffset_ + 8]))); + node__2 = ($this); + bci__2 = ($bci); + s4_.objects_ = s4_.insertAccessor(objects__); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 8] = s4_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_)); + return; + } + } + } + { + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = ($this); + readObject1_bci__ = ($bci); + $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 8] = null; + state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) $children[childArrayOffset_ + 11]))); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLSub_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; + try { + long value = SLSubNode.subLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + + private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + long value = SLSubNode.subLong($child0Value__, $child1Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + return; + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); + return; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1]; + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + int type0; + int type1; + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { + type0 = 1 /* LONG */; + type1 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + try { + lock.unlock(); + hasLock = false; + long value = SLSubNode.subLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); + return; + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + int type0; + int type1; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 3); + Object $child1Value_ = expectObject($frame, $sp - 2); + Object $child2Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_)); + return; + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + $frame.setObject($sp - 3, SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $frame.setObject($sp - 3, SLWriteProperty_writeSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_)); + return; + } + } + if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__1 = ($this); + int bci__1 = ($bci); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_)); + return; + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + $frame.setObject($sp - 3, SLWriteProperty_writeObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); + return; + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 6]); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 10]); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1]; + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) $children[childArrayOffset_ + 0]))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_)); + return; + } + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + int writeArray1_bci__ = 0; + Node writeArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + writeArray1_node__ = ($this); + writeArray1_bci__ = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__)); + return; + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) $children[childArrayOffset_ + 4]))); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0); + } else { + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + } + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); + return; + } + } + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (s4_.objectLibrary_.accepts($child0Value)); + s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) $children[childArrayOffset_ + 7]))); + node__1 = ($this); + bci__1 = ($bci); + s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 7] = s4_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_)); + return; + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = ($this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 7] = null; + state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + int type0; + int type1; + int type2; + type0 = 0 /* OBJECT */; + type1 = 0 /* OBJECT */; + type2 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); + doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); + return; + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLUnbox_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + assert (state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */; + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 0]); + if (fromString_fromJavaStringNode__ != null) { + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__)); + return; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); + return; + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLUnboxNode.fromBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + long value = SLUnboxNode.fromLong($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); + return; + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); + return; + } + if ((state_0 & 0b1100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1]); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); + return; + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b1000000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + $frame.setObject($sp - 1, SLUnbox_fromForeign1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)); + return; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return; + } + + private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1]; + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) $children[childArrayOffset_ + 0]))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); + if ((state_0 & 0b1111111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */) { + $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN); + } else { + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + } + int type0; + if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */) { + type0 = 5 /* BOOLEAN */; + } else { + type0 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); + if ((state_0 & 0b1111111110) == 0b10000/* is-exact-state_0 fromLong(long) */) { + $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG); + } else { + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + } + int type0; + if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */) { + type0 = 1 /* LONG */; + } else { + type0 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); + return; + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1]); + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.interop_.accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) $children[childArrayOffset_ + 1]))); + s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, s7_.interop_)); + return; + } + } + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1] = null; + state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); + return; + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLFunctionLiteral_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0]; + Object $child0Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0) + 0]); + if (result__ != null) { + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return; + } + + private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0]; + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + node__ = ($this); + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM); + } else { + $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); + } + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) $consts[constArrayOffset_ + 0]), node__)); + return; + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } else { + SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return; + } + } + + private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + boolean value = SLToBooleanNode.doBoolean($child0Value__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return; + } + + private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { + $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN); + } else { + $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); + } + int type0; + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { + type0 = 5 /* BOOLEAN */; + } else { + type0 = 0 /* OBJECT */; + } + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); + int type0; + type0 = 0 /* OBJECT */; + doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); + lock.unlock(); + hasLock = false; + boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, s0_); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 1]); + if (indirect_callNode__ != null) { + return SLInvoke.doIndirect(arg0Value_, arg1Value, indirect_callNode__); + } + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = ($this); + int interop_bci__ = ($bci); + InteropLibrary interop_library__ = ((InteropLibrary) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 2]); + if (interop_library__ != null) { + return SLInvoke.doInterop(arg0Value, arg1Value, interop_library__, interop_node__, interop_bci__); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); + } + + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1]; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if ((arg0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); + if ((arg0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) $children[childArrayOffset_ + 0]))); + s0_.callTargetStable_ = callTargetStable__; + s0_.cachedTarget_ = cachedTarget__; + s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + $bc[$bci] = (short) (INSTR_C_SL_INVOKE_Q_DIRECT); + } else { + $bc[$bci] = (short) (INSTR_C_SL_INVOKE); + } + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + } + $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[childArrayOffset_ + 0] = null; + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + $bc[$bci] = (short) (INSTR_C_SL_INVOKE); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) $children[childArrayOffset_ + 1])); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = ($this); + interop_bci__ = ($bci); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + $bc[$bci] = (short) (INSTR_C_SL_INVOKE); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) $children[childArrayOffset_ + 2]), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLInvoke_removeDirect__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLAnd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */; + long value = SLUnboxNode.fromLong($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static void SLAdd_q_AddLong_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + $bc[$bci] = (short) (INSTR_C_SL_ADD); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_ADD); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */; + try { + long value = SLAddNode.addLong($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setLong($sp - 2, value); + } + return; + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + $bc[$bci] = (short) (INSTR_C_SL_ADD); + SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + } + + @ExplodeLoop + private static void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0]; + Object $child0Value_ = expectObject($frame, $sp - 2); + Object $child1Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET] + 0) + 4]); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__ = ($this); + int bci__ = ($bci); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); + SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return; + } + + private static void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0]; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_UNBOX); + SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0]; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); + SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); + SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + @ExplodeLoop + private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + short state_0 = $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0]; + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET] + 0) + 0]); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_q_Direct_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, s0_); + $bc[$bci] = (short) (INSTR_C_SL_INVOKE); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value_, arg1Value); + } + if ((arg0Value_.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_INVOKE); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); + } + + private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET] + 0) + 0]); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET + 0]; + Object $child0Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET] + 0) + 0]); + if (result__ != null) { + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); + return; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); + SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return; + } + + @ExplodeLoop + private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET + 0]; + Object $child0Value_ = expectObject($frame, $sp - 3); + Object $child1Value_ = expectObject($frame, $sp - 2); + Object $child2Value_ = expectObject($frame, $sp - 1); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET] + 0) + 4]); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); + return; + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); + SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + return; + } + + private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = $bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 0]; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1); + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); + SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + return; + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); + SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return; + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { + Object value = frame.getValue(sourceSlot); + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } + frame.setObject(localIdx, value); + return 0 /* OBJECT */; + } + + private static boolean isAdoptable() { + return true; + } + + private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { + if (bciOffset != 0) { + setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); + } + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperations.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + } +} diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java index 297a24c2daee..41f4d619dced 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java @@ -113,8 +113,6 @@ private TruffleOptions() { */ public static final boolean AOT; - public static final String OperationDecisionsFile; - private static NodeCost parseNodeInfoKind(String kind) { if (kind == null) { return null; @@ -139,8 +137,6 @@ class GetOptions implements PrivilegedAction { NodeCost traceRewritesFilterFromCost; NodeCost traceRewritesFilterToCost; - String operationDecisionsFile; - @Override public Void run() { aot = Boolean.getBoolean("com.oracle.graalvm.isaot"); @@ -149,7 +145,6 @@ public Void run() { traceRewritesFilterClass = System.getProperty("truffle.TraceRewritesFilterClass"); traceRewritesFilterFromCost = parseNodeInfoKind(System.getProperty("truffle.TraceRewritesFilterFromCost")); traceRewritesFilterToCost = parseNodeInfoKind(System.getProperty("truffle.TraceRewritesFilterToCost")); - operationDecisionsFile = System.getProperty("truffle.dsl.operation.DecisionsFile"); return null; } } @@ -162,6 +157,5 @@ public Void run() { TraceRewritesFilterClass = options.traceRewritesFilterClass; TraceRewritesFilterFromCost = options.traceRewritesFilterFromCost; TraceRewritesFilterToCost = options.traceRewritesFilterToCost; - OperationDecisionsFile = options.operationDecisionsFile; } } From 4fa6e847653a84546e9279c673721599809dd200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 13 Jul 2022 14:36:04 +0200 Subject: [PATCH 110/312] [wip] fix quickening decisions --- .../sl/operations/SLOperationsBuilder.java | 627 ++++++++++-------- .../truffle/api/operation/OperationNode.java | 44 ++ .../tracing/OperationsStatistics.java | 42 +- .../OperationsBytecodeCodeGenerator.java | 32 +- .../operations/OperationsCodeGenerator.java | 66 +- .../operations/OperationsContext.java | 6 +- .../instructions/BranchInstruction.java | 6 +- .../ConditionalBranchInstruction.java | 12 +- .../operations/instructions/Instruction.java | 11 +- .../instructions/ReturnInstruction.java | 12 +- 10 files changed, 526 insertions(+), 332 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 7f8ac2e80848..a5cdbc12d4c3 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -296,33 +296,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 6; - static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_LONG_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_LONG_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 9; - static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_LONG_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_LONG_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 12; - static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_LONG_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int INSTR_STORE_LOCAL_BOOLEAN = 12; static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; + static final int INSTR_STORE_LOCAL_LONG = 13; + static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_LONG_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -330,12 +330,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 16; - static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_LONG_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_LONG_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -508,7 +508,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // INT null, // DOUBLE @@ -516,7 +516,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // BYTE null}; @@ -535,7 +535,7 @@ private static class BuilderImpl extends SLOperationsBuilder { private ArrayList labels = new ArrayList<>(); private ArrayList labelFills = new ArrayList<>(); private int numChildNodes; - private int numBranchProfiles; + private int numConditionProfiles; private ArrayList exceptionHandlers = new ArrayList<>(); private BuilderFinallyTryContext currentFinallyTry; private int buildIndex; @@ -575,7 +575,7 @@ private void reset() { operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0); labelFills.clear(); numChildNodes = 0; - numBranchProfiles = 0; + numConditionProfiles = 0; exceptionHandlers.clear(); metadata_MethodName = null; } @@ -710,7 +710,7 @@ public OperationNode publish() { result._consts = constPool.toArray(); result._children = new Node[numChildNodes]; result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); - result._conditionProfiles = new int[numBranchProfiles * 2]; + result._conditionProfiles = new int[numConditionProfiles]; result._maxLocals = numLocals; result._maxStack = maxStack; if (sourceBuilder != null) { @@ -869,6 +869,8 @@ void doAfterChild() { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_BRANCH_FALSE); labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; bci = bci + 3; } else { for (int i = 0; i < lastChildPush; i++) { @@ -889,6 +891,8 @@ void doAfterChild() { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_BRANCH_FALSE); labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; bci = bci + 3; } else if (childIndex == 1) { for (int i = 0; i < lastChildPush; i++) { @@ -923,6 +927,8 @@ void doAfterChild() { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_BRANCH_FALSE); labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; bci = bci + 3; } else if (childIndex == 1) { assert lastChildPush == 1; @@ -949,6 +955,8 @@ void doAfterChild() { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_BRANCH_FALSE); labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; bci = bci + 3; } else { for (int i = 0; i < lastChildPush; i++) { @@ -1997,6 +2005,43 @@ public void setMethodName(TruffleString value) { metadata_MethodName = value; } + private static boolean do_profileCondition(boolean value, int[] profiles, int index) { + int t = profiles[index]; + int f = profiles[index + 1]; + boolean val = value; + if (val) { + if (t == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (f == 0) { + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < 1073741823) { + profiles[index] = t + 1; + } + } + } else { + if (f == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (t == 0) { + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < 1073741823) { + profiles[index + 1] = f + 1; + } + } + } + if (CompilerDirectives.inInterpreter()) { + return val; + } else { + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } + @GeneratedBy(SLOperations.class) private static final class BuilderOperationData { @@ -2393,14 +2438,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -2408,11 +2453,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2423,14 +2468,14 @@ protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, return false; } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -2438,11 +2483,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2466,14 +2511,13 @@ private static final class BytecodeNode extends BytecodeLoopBase { int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { int $sp = $startSp; int $bci = $startBci; - int loopCount = 0; + Counter loopCounter = new Counter(); loop: while (true) { - int nextBci; + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); short curOpcode = $bc[$bci]; + CompilerAsserts.partialEvaluationConstant(curOpcode); try { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - CompilerAsserts.partialEvaluationConstant(curOpcode); if ($sp < maxLocals) { throw CompilerDirectives.shouldNotReachHere("stack underflow"); } @@ -2487,8 +2531,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { $sp = $sp - 1; $frame.clear($sp); - nextBci = $bci + POP_LENGTH; - break; + $bci = $bci + POP_LENGTH; + continue loop; } // branch // Pushed Values: 0 @@ -2500,9 +2544,9 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { TruffleSafepoint.poll($this); - if (CompilerDirectives.hasNextTier() && ++loopCount >= 256) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { LoopNode.reportLoopCount($this, 256); - loopCount = 0; + loopCounter.count = 0; } } $bci = targetBci; @@ -2521,7 +2565,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { boolean cond = (boolean) $frame.getObject($sp - 1); $sp = $sp - 1; - if (cond) { + if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { $bci = $bci + BRANCH_FALSE_LENGTH; continue loop; } else { @@ -2551,27 +2595,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { $frame.setObject($sp, $consts[$bc[$bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET] + 0]); $sp = $sp + 1; - nextBci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - break; - } - // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG : - { - $frame.setLong($sp, (long) $consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]); - $sp = $sp + 1; - nextBci = $bci + LOAD_CONSTANT_LONG_LENGTH; - break; + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + continue loop; } // load.constant.boolean // Constants: @@ -2589,44 +2614,41 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { $frame.setBoolean($sp, (boolean) $consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]); $sp = $sp + 1; - nextBci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - break; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + continue loop; } - // load.argument.object + // load.constant.long + // Constants: + // [ 0] constant // Pushed Values: 1 // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); + $frame.setLong($sp, (long) $consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]); $sp = $sp + 1; - nextBci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - break; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + continue loop; } - // load.argument.long + // load.argument.object // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); $sp = $sp + 1; - nextBci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - break; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + continue loop; } // load.argument.boolean // Pushed Values: 1 @@ -2647,8 +2669,30 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.setObject($sp, value); } $sp = $sp + 1; - nextBci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + continue loop; + } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + continue loop; } // store.local.object // Locals: @@ -2663,10 +2707,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s int sourceSlot = $sp - 1; $frame.setObject(localIdx, expectObject($frame, sourceSlot)); $sp--; - nextBci = $bci + STORE_LOCAL_OBJECT_LENGTH; - break; + $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; + continue loop; } - // store.local.long + // store.local.boolean // Locals: // [ 0] target // Indexed Pops: @@ -2674,25 +2718,25 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_STORE_LOCAL_OBJECT // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - nextBci = $bci + STORE_LOCAL_LONG_LENGTH; - break; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + continue loop; } - // store.local.boolean + // store.local.long // Locals: // [ 0] target // Indexed Pops: @@ -2700,23 +2744,23 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - nextBci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - break; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; + continue loop; } // store.local.uninit // Locals: @@ -2743,8 +2787,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff), resultTag); } $sp--; - nextBci = $bci + STORE_LOCAL_UNINIT_LENGTH; - break; + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + continue loop; } // load.local.object // Locals: @@ -2761,31 +2805,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } $frame.copyObject(localIdx, $sp); $sp++; - nextBci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + continue loop; } - // load.local.long + // load.local.boolean // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_LOAD_LOCAL_OBJECT // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2796,31 +2840,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - nextBci = $bci + LOAD_LOCAL_LONG_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + continue loop; } - // load.local.boolean + // load.local.long // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2831,8 +2875,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - nextBci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + continue loop; } // load.local.uninit // Locals: @@ -2847,8 +2891,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; $frame.setObject($sp, expectObject($frame, localIdx)); $sp++; - nextBci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + continue loop; } // return // Simple Pops: @@ -2870,15 +2914,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e79d949 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@172a1de + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65a11b0c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@f79df7c // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_ADD_LENGTH; - break; + $bci = $bci + C_SL_ADD_LENGTH; + continue loop; } // c.SLDiv // Constants: @@ -2890,15 +2934,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65b021d3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@64ce13c7 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6c341dfe + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@286b0311 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_DIV_LENGTH; - break; + $bci = $bci + C_SL_DIV_LENGTH; + continue loop; } // c.SLEqual // Children: @@ -2911,15 +2955,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@148d3d86 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@650298 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45ff046b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4bca197 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_EQUAL_LENGTH; - break; + $bci = $bci + C_SL_EQUAL_LENGTH; + continue loop; } // c.SLLessOrEqual // Constants: @@ -2931,14 +2975,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@643f05fe + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48ab9713 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + continue loop; } // c.SLLessThan // Constants: @@ -2950,14 +2994,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@707b6295 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@38a8769c // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_LESS_THAN_LENGTH; - break; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + continue loop; } // c.SLLogicalNot // Constants: @@ -2968,14 +3012,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@de71011 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@549e1be // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + continue loop; } // c.SLMul // Constants: @@ -2987,15 +3031,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@25bea2f7 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@39b2434b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@64185899 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@709f4806 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_MUL_LENGTH; - break; + $bci = $bci + C_SL_MUL_LENGTH; + continue loop; } // c.SLReadProperty // Constants: @@ -3020,15 +3064,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@12f6e122 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27a41cf5 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b78dc1f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41f688df // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + continue loop; } // c.SLSub // Constants: @@ -3040,15 +3084,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77ddabec - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5cde0647 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@678cdce8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d597767 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_SUB_LENGTH; - break; + $bci = $bci + C_SL_SUB_LENGTH; + continue loop; } // c.SLWriteProperty // Constants: @@ -3072,15 +3116,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7984030f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ec0eb7e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@200cc6f7 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@55c91259 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; - nextBci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + continue loop; } // c.SLUnbox // Children: @@ -3091,15 +3135,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6458bd81 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48187373 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@54a3ff94 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@72e74828 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; } // c.SLFunctionLiteral // Constants: @@ -3110,14 +3154,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@115d9d04 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@341a03fd // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + continue loop; } // c.SLToBoolean // Constants: @@ -3128,14 +3172,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@683f0f4a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dc94fd // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + continue loop; } // c.SLInvoke // Constants: @@ -3150,8 +3194,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@49aa0379 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@42a262d4 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6248910d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2aa62364 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -3164,8 +3208,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s Object result = BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); $sp = $sp - 1 - numVariadics + 1; $frame.setObject($sp - 1, result); - nextBci = $bci + C_SL_INVOKE_LENGTH; - break; + $bci = $bci + C_SL_INVOKE_LENGTH; + continue loop; } // sc.SLAnd // Constants: @@ -3178,7 +3222,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f6a7239 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ec7d826 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -3202,7 +3246,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2fbf7fc1 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@371c67f // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -3224,15 +3268,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36170084 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@67727050 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2517ffe5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3e315520 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + continue loop; } // c.SLAdd.q.AddLong // Constants: @@ -3245,15 +3289,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b652d3d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5ff01ae7 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ec7bc28 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4308d9b1 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + continue loop; } // c.SLReadProperty.q.ReadSLObject0 // Constants: @@ -3278,15 +3322,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@516d32bd - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@25e93830 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59faeee2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6dd628a8 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + continue loop; } // c.SLUnbox.q.FromBoolean // Children: @@ -3297,15 +3341,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c7f575 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58bff048 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1e03efc6 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1bc378e6 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + continue loop; } // c.SLToBoolean.q.Boolean // Constants: @@ -3316,14 +3360,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@607fd938 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15c00882 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + continue loop; } // c.SLLessOrEqual.q.LessOrEqual0 // Constants: @@ -3335,14 +3379,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@c3b45bf + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@490fe1fa // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { BytecodeNode.SLLessOrEqual_q_LessOrEqual0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - break; + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + continue loop; } // c.SLInvoke.q.Direct // Constants: @@ -3357,8 +3401,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@346f7510 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@13f5fe65 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48735ac2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48770f62 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -3371,8 +3415,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s Object result = BytecodeNode.SLInvoke_q_Direct_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); $sp = $sp - 1 - numVariadics + 1; $frame.setObject($sp - 1, result); - nextBci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + continue loop; } // c.SLFunctionLiteral.q.Perform // Constants: @@ -3383,14 +3427,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ddd433a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d668af6 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; - nextBci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + continue loop; } // c.SLWriteProperty.q.WriteSLObject0 // Constants: @@ -3414,15 +3458,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b1de983 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1495c005 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6bd0b091 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@39274263 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; - nextBci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + continue loop; } // c.SLLessThan.q.LessThan0 // Constants: @@ -3434,14 +3478,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28af0224 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@495b463a // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { BytecodeNode.SLLessThan_q_LessThan0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; - nextBci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - break; + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + continue loop; } default : CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -3460,8 +3504,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } throw ex; } - CompilerAsserts.partialEvaluationConstant(nextBci); - $bci = nextBci; } } @@ -3495,16 +3537,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -3512,14 +3554,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -3527,14 +3569,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -3547,14 +3589,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -3787,7 +3829,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3797,12 +3839,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3812,9 +3854,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -3832,7 +3874,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3842,12 +3884,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3857,9 +3899,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -3878,7 +3920,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3888,13 +3930,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3904,10 +3946,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -3941,7 +3983,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3951,12 +3993,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3966,9 +4008,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -8308,14 +8350,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return 5 /* BOOLEAN */; } + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -8532,4 +8574,9 @@ T insertAccessor(T node) { } } } + private static final class Counter { + + public int count; + + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 1152e720b4e8..68f38744b1e8 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -42,6 +42,8 @@ import java.util.function.Function; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; @@ -147,4 +149,46 @@ public SourceSection getEncapsulatingSourceSection() { } public abstract String dump(); + + private static boolean conditionProfile(boolean value, long[] profiles, int index) { + + long profile = profiles[index]; + CompilerAsserts.compilationConstant(profile); + + int t = (int) (profile >> 32); + int f = (int) profile; + + boolean val = value; + if (val) { + if (t == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (f == 0) { + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < 0x3FFFFFFF) { + profiles[index] = profile + (1 << 32); + } + } + } else { + if (f == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (t == 0) { + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < 0x3FFFFFFF) { + profiles[index] = profile + 1; + } + } + } + if (CompilerDirectives.inInterpreter()) { + return val; + } else { + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 48af627c1578..43c1f3b520b5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -247,6 +247,7 @@ private static class EnabledExecutionTracer extends ExecutionTracer { private static class SpecializationKey { final int instructionId; @CompilationFinal(dimensions = 1) final boolean[] activeSpecializations; + int countActive = -1; SpecializationKey(int instructionId, boolean[] activeSpecializations) { this.instructionId = instructionId; @@ -262,6 +263,20 @@ public int hashCode() { return result; } + public int getCountActive() { + if (countActive == -1) { + int c = 0; + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + c++; + } + } + countActive = c; + } + + return countActive; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -310,8 +325,14 @@ public JSONObject serializeDecision(GlobalOperationStatistics stats) { JSONObject result = new JSONObject(); result.put("type", "Quicken"); String instrName = stats.instrNames[instructionId]; - assert instrName.startsWith("c."); - result.put("operation", instrName.substring(2)); + String shortName; + if (instrName.startsWith("c.")) { + shortName = instrName.substring(2); + } else { + assert instrName.startsWith("sc."); + shortName = instrName.substring(3); + } + result.put("operation", shortName); JSONArray specsData = new JSONArray(); result.put("specializations", specsData); @@ -346,6 +367,14 @@ public void traceInstruction(int bci, int id) { @Override public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { +// boolean anyTrue = false; +// for (int i = 0; i < activeSpecializations.length; i++) { +// anyTrue |= activeSpecializations[i]; +// } +// if (!anyTrue) { +// return; +// } + SpecializationKey key = new SpecializationKey(id, activeSpecializations); Long l = activeSpecializationsMap.get(key); if (l == null) { @@ -407,10 +436,11 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats) { result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); - int numDecisions = 10; - activeSpecializationsMap.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).limit(numDecisions).forEachOrdered(e -> { - result.put(e.getKey().serializeDecision(stats)); - }); + int numDecisions = 100; + activeSpecializationsMap.entrySet().stream().filter(e -> e.getKey().getCountActive() > 0).sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).limit(numDecisions).forEachOrdered( + e -> { + result.put(e.getKey().serializeDecision(stats)); + }); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index a475cf8bc336..ab785e20c0fc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -253,7 +253,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("int", vars.sp.getName(), CodeTreeBuilder.singleString("$startSp")); b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); - b.declaration("int", "loopCount", "0"); + b.declaration("Counter", "loopCounter", "new Counter()"); CodeVariableElement varTracer; @@ -263,7 +263,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.typeLiteral(m.getTemplateType().asType()); b.end(2); - b.startStatement().startCall(varTracer, "startFunction").string("this").end(2); + b.startStatement().startCall(varTracer, "startFunction").string("$this").end(2); } else { varTracer = null; } @@ -271,20 +271,18 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.string("loop: "); b.startWhile().string("true").end(); b.startBlock(); - CodeVariableElement varNextBci = new CodeVariableElement(context.getType(int.class), "nextBci"); - b.statement("int nextBci"); - vars.nextBci = varNextBci; vars.tracer = varTracer; - b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); - - b.startTryBlock(); - b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.sp)); + + b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); + b.startTryBlock(); + b.startIf().variable(vars.sp).string(" < maxLocals").end(); b.startBlock(); b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); @@ -315,8 +313,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.tree(op.createExecuteCode(vars)); if (!op.isBranchInstruction()) { - b.startAssign(varNextBci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); - b.statement("break"); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); + b.statement("continue loop"); } b.end(); @@ -366,15 +364,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); // catch block - b.tree(GeneratorUtils.createPartialEvaluationConstant(varNextBci)); - b.statement("$bci = nextBci"); - b.end(); // while block - - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "endFunction"); - b.string("this"); - b.end(2); - } + b.end(); // while loop return mContinueAt; } @@ -508,7 +498,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr metGetSpecBits.setEnclosingElement(typBuilderImpl); typBuilderImpl.add(metGetSpecBits); - metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "bc")); + metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "$bc")); metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); CodeTreeBuilder b = metGetSpecBits.createBuilder(); b.tree(plugs.createGetSpecializationBits()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 2eefedf10899..1fe5fdc9320f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -47,6 +47,7 @@ import java.util.concurrent.locks.Lock; import java.util.function.Consumer; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -175,6 +176,9 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(createCreateMethod(typBuilder, typBuilderImpl)); + CodeTypeElement typCounter = typBuilder.add(new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter")); + typCounter.add(new CodeVariableElement(MOD_PUBLIC, context.getType(int.class), "count")); + return typBuilder; } @@ -493,7 +497,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelData.asType())), "labels = new ArrayList<>()")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelFill.asType())), "labelFills = new ArrayList<>()")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numChildNodes")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numBranchProfiles")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numConditionProfiles")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typExceptionHandler.asType())), "exceptionHandlers = new ArrayList<>()")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typFinallyTryContext.asType(), "currentFinallyTry")); @@ -614,10 +618,66 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(createSetMetadata(metadata, false)); } + typBuilderImpl.add(createConditionProfile()); + return typBuilderImpl; } + private CodeExecutableElement createConditionProfile() { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "do_profileCondition"); + met.addParameter(new CodeVariableElement(context.getType(boolean.class), "value")); + met.addParameter(new CodeVariableElement(context.getType(int[].class), "profiles")); + met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); + + CodeTreeBuilder b = met.createBuilder(); + + final int maxInt = 0x3FFFFFFF; + + b.declaration("int", "t", "profiles[index]"); + b.declaration("int", "f", "profiles[index + 1]"); + + b.declaration("boolean", "val", "value"); + b.startIf().string("val").end().startBlock(); + + b.startIf().string("t == 0").end().startBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.end(); + b.startIf().string("f == 0").end().startBlock(); + b.statement("val = true"); + b.end(); + b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); + b.startIf().string("t < " + maxInt).end().startBlock(); + b.statement("profiles[index] = t + 1"); + b.end(); + b.end(); + + b.end().startElseBlock(); + + b.startIf().string("f == 0").end().startBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.end(); + b.startIf().string("t == 0").end().startBlock(); + b.statement("val = false"); + b.end(); + b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); + b.startIf().string("f < " + maxInt).end().startBlock(); + b.statement("profiles[index + 1] = f + 1"); + b.end(); + b.end(); + + b.end(); + + b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); + b.statement("return val"); + b.end().startElseBlock(); + b.statement("int sum = t + f"); + b.statement("return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val)"); + b.end(); + + return met; + } + private List createBuilderImplGetLocalIndex(CodeTypeElement typLocalData) { CodeExecutableElement mGetLocalIndex = new CodeExecutableElement(MOD_PRIVATE, context.getType(short.class), "getLocalIndex"); mGetLocalIndex.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); @@ -1378,7 +1438,7 @@ private CodeExecutableElement createBuilderImplPublish() { b.statement("result._consts = constPool.toArray()"); b.statement("result._children = new Node[numChildNodes]"); b.statement("result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0])"); - b.statement("result._conditionProfiles = new int[numBranchProfiles * 2]"); + b.statement("result._conditionProfiles = new int[numConditionProfiles]"); b.statement("result._maxLocals = numLocals"); b.statement("result._maxStack = maxStack"); @@ -1817,7 +1877,7 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0)"); b.statement("labelFills.clear()"); b.statement("numChildNodes = 0"); - b.statement("numBranchProfiles = 0"); + b.statement("numConditionProfiles = 0"); b.statement("exceptionHandlers.clear()"); for (OperationMetadataData metadata : m.getMetadatas()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index fa70fdc3b3f0..9c4fdaa0b9d4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -177,7 +177,7 @@ private void createLoadConstant() { } private void createReturn() { - ReturnInstruction retInit = add(new ReturnInstruction(instructionId++)); + ReturnInstruction retInit = add(new ReturnInstruction(this, instructionId++)); add(new Operation.Simple(this, "Return", operationId++, 1, retInit)); } @@ -240,6 +240,10 @@ public void processDecisions(OperationDecisions decisions) { data.addWarning("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); continue; } + if (cinstr instanceof ShortCircuitInstruction) { + // todo: make these work + continue; + } SingleOperationData opData = opDataNameMap.get(quicken.getOperation()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index b5c12e9b69aa..14346a3ef423 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -81,13 +81,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); } - // todo: reporting loop count - if (LOOP_COUNTING) { b.startIf(); b.tree(GeneratorUtils.createHasNextTier()); b.string(" && "); - b.string("++loopCount >= " + REPORT_LOOP_STRIDE); + b.string("++loopCounter.count >= " + REPORT_LOOP_STRIDE); b.end().startBlock(); // { b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); @@ -95,7 +93,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("" + REPORT_LOOP_STRIDE); b.end(2); - b.statement("loopCount = 0"); + b.statement("loopCounter.count = 0"); b.end(); // } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 0e9959a7872d..c67c43521789 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -86,14 +86,20 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - // b.startIf().startCall("profile", "profile").string("cond").end(2); - b.startIf().string("cond").end(); - b.startBlock(); + b.startIf().startCall("do_profileCondition"); + + b.string("cond"); + b.string("$conditionProfiles"); + b.tree(createBranchProfileIndex(vars, 0)); + + b.end(2).startBlock(); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.statement("continue loop"); b.end().startElseBlock(); b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0)).end(); b.statement("continue loop"); + b.end(); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index cc8d5a0c1648..10a3b4afe956 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -61,7 +61,6 @@ public abstract class Instruction { public static class ExecutionVariables { public CodeVariableElement bc; public CodeVariableElement bci; - public CodeVariableElement nextBci; public CodeVariableElement frame; public CodeVariableElement sp; public CodeVariableElement consts; @@ -314,7 +313,7 @@ public CodeTree createBranchTargetIndex(ExecutionVariables vars, int index) { } public CodeTree createBranchProfileIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index); + return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index * 2); } public CodeTree createStateBitsIndex(ExecutionVariables vars, int index) { @@ -487,7 +486,13 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) b.end(3); } - // todo: condition profiles + if (!branchProfiles.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getBranchProfileOffset() + "] = (short) "); + b.string("numConditionProfiles"); + b.end(); + + b.statement("numConditionProfiles += " + branchProfiles.size() * 2); + } for (int i = 0; i < stateBits.size(); i++) { b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getStateBitsOffset() + " + " + i + "] = 0").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 71dbcaee5f9b..fc9aee7608f7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -43,11 +43,15 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ReturnInstruction extends Instruction { - public ReturnInstruction(int id) { + private final OperationsContext ctx; + + public ReturnInstruction(OperationsContext ctx, int id) { super("return", id, 0); + this.ctx = ctx; addPopSimple("value"); } @@ -60,6 +64,12 @@ public boolean isBranchInstruction() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (ctx.getData().isTracing()) { + b.startStatement().startCall("tracer", "endFunction"); + b.string("$this"); + b.end(2); + } + b.startReturn().string("((").variable(vars.sp).string(" - 1) << 16) | 0xffff").end(); return b.build(); From 83bc2f7432eb8516ac25aecaf3cb0a55e14b6bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 18 Jul 2022 09:17:29 +0200 Subject: [PATCH 111/312] [wip] GenerateUncached for operations --- .../sl/operations/SLOperationsBuilder.java | 7813 +++++++++++++---- .../truffle/api/impl/FrameWithoutBoxing.java | 4 +- .../operations/OperationGeneratorFlags.java | 2 + .../operations/OperationGeneratorUtils.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 63 +- .../operations/OperationsCodeGenerator.java | 52 +- .../processor/operations/OperationsData.java | 11 + .../operations/OperationsParser.java | 10 +- .../operations/SingleOperationParser.java | 77 +- .../instructions/BranchInstruction.java | 22 +- .../ConditionalBranchInstruction.java | 13 +- .../instructions/CustomInstruction.java | 27 +- .../operations/instructions/Instruction.java | 19 +- .../instructions/LoadConstantInstruction.java | 5 + .../instructions/LoadLocalInstruction.java | 5 + .../instructions/QuickenedInstruction.java | 5 + .../instructions/ReturnInstruction.java | 16 + .../instructions/ShortCircuitInstruction.java | 5 + .../instructions/StoreLocalInstruction.java | 26 + .../expression/SLFunctionLiteralNode.java | 4 +- .../truffle/sl/operations/SLOperations.java | 2 + 21 files changed, 6632 insertions(+), 1551 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index a5cdbc12d4c3..18d8eb8e6155 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -213,6 +213,10 @@ protected SLOperationsBuilder() { public abstract void setMethodName(TruffleString value); + private static short unsafeFromBytecode(short[] bc, int index) { + return bc[index]; + } + public static OperationNodes create(OperationConfig config, Consumer generator) { OperationNodesImpl nodes = new OperationNodesImpl(generator); BuilderImpl builder = new BuilderImpl(nodes, false, config); @@ -244,6 +248,7 @@ void setNodes(OperationNode[] nodes) { } } + @GeneratedBy(SLOperations.class) private static class BuilderImpl extends SLOperationsBuilder { @@ -296,33 +301,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int INSTR_LOAD_CONSTANT_LONG = 6; static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_LONG_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int INSTR_LOAD_ARGUMENT_LONG = 9; static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_LONG_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 12; - static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 13; + static final int INSTR_STORE_LOCAL_LONG = 12; static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_LONG_LENGTH = 3; + static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -330,12 +335,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; - static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int INSTR_LOAD_LOCAL_LONG = 16; static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_LONG_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -355,170 +360,210 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int C_SL_ADD_CHILDREN_OFFSET = 2; static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_LENGTH = 6; + static final int C_SL_ADD_LENGTH = 8; static final int INSTR_C_SL_DIV = 25; static final int C_SL_DIV_CONSTANT_OFFSET = 1; static final int C_SL_DIV_CHILDREN_OFFSET = 2; static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - static final int C_SL_DIV_LENGTH = 6; + static final int C_SL_DIV_LENGTH = 8; static final int INSTR_C_SL_EQUAL = 26; static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - static final int C_SL_EQUAL_LENGTH = 5; + static final int C_SL_EQUAL_LENGTH = 7; static final int INSTR_C_SL_LESS_OR_EQUAL = 27; static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; + static final int C_SL_LESS_OR_EQUAL_LENGTH = 6; static final int INSTR_C_SL_LESS_THAN = 28; static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_LENGTH = 5; + static final int C_SL_LESS_THAN_LENGTH = 6; static final int INSTR_C_SL_LOGICAL_NOT = 29; static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - static final int C_SL_LOGICAL_NOT_LENGTH = 5; + static final int C_SL_LOGICAL_NOT_LENGTH = 6; static final int INSTR_C_SL_MUL = 30; static final int C_SL_MUL_CONSTANT_OFFSET = 1; static final int C_SL_MUL_CHILDREN_OFFSET = 2; static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - static final int C_SL_MUL_LENGTH = 6; + static final int C_SL_MUL_LENGTH = 8; static final int INSTR_C_SL_READ_PROPERTY = 31; static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_LENGTH = 6; + static final int C_SL_READ_PROPERTY_LENGTH = 8; static final int INSTR_C_SL_SUB = 32; static final int C_SL_SUB_CONSTANT_OFFSET = 1; static final int C_SL_SUB_CHILDREN_OFFSET = 2; static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - static final int C_SL_SUB_LENGTH = 6; + static final int C_SL_SUB_LENGTH = 8; static final int INSTR_C_SL_WRITE_PROPERTY = 33; static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_LENGTH = 7; + static final int C_SL_WRITE_PROPERTY_LENGTH = 9; static final int INSTR_C_SL_UNBOX = 34; static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_LENGTH = 5; + static final int C_SL_UNBOX_LENGTH = 7; static final int INSTR_C_SL_FUNCTION_LITERAL = 35; static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; + static final int C_SL_FUNCTION_LITERAL_LENGTH = 6; static final int INSTR_C_SL_TO_BOOLEAN = 36; static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_LENGTH = 5; + static final int C_SL_TO_BOOLEAN_LENGTH = 6; static final int INSTR_C_SL_INVOKE = 37; static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; static final int C_SL_INVOKE_VARIADIC_OFFSET = 3; static final int C_SL_INVOKE_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_LENGTH = 6; + static final int C_SL_INVOKE_LENGTH = 8; static final int INSTR_SC_SL_AND = 38; static final int SC_SL_AND_CONSTANT_OFFSET = 1; static final int SC_SL_AND_CHILDREN_OFFSET = 2; static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - static final int SC_SL_AND_LENGTH = 6; + static final int SC_SL_AND_LENGTH = 7; static final int INSTR_SC_SL_OR = 39; static final int SC_SL_OR_CONSTANT_OFFSET = 1; static final int SC_SL_OR_CHILDREN_OFFSET = 2; static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - static final int SC_SL_OR_LENGTH = 6; + static final int SC_SL_OR_LENGTH = 7; static final int INSTR_C_SL_UNBOX_Q_FROM_LONG = 40; static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 7; static final int INSTR_C_SL_ADD_Q_ADD_LONG = 41; static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; + static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 8; static final int INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 42; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 8; static final int INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 43; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 7; static final int INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 44; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 6; static final int INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET = 1; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CHILDREN_OFFSET = 2; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 5; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 6; static final int INSTR_C_SL_INVOKE_Q_DIRECT = 46; static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 3; static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 6; + static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 8; static final int INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 47; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 6; static final int INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 48; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 9; static final int INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 = 49; static final int C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET = 1; static final int C_SL_LESS_THAN_Q_LESS_THAN0_CHILDREN_OFFSET = 2; static final int C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 5; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 6; private static final short[][] BOXING_DESCRIPTORS = { - // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // INT - null, - // DOUBLE - null, - // FLOAT - null, - // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // BYTE - null}; + // OBJECT + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, + INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, + INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // LONG + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, + INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, + (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, + (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // INT + null, + // DOUBLE + null, + // FLOAT + null, + // BOOLEAN + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, + INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, + (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, + (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), + (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), + (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // BYTE + null}; private final OperationNodesImpl nodes; private final boolean isReparse; @@ -616,7 +661,8 @@ private void doLeaveFinallyTry(BuilderOperationData opData) { for (LabelFill fill : context.handlerLabelFills) { labelFills.add(fill.offset(bci)); } - if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; + if (maxStack < curStack + context.handlerMaxStack) + maxStack = curStack + context.handlerMaxStack; bci += context.handlerBc.length; } @@ -645,9 +691,11 @@ private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData cur = cur.parent; if (toData == null && cur == null) { break; - } else if (toData != null && cur.depth <= toData.depth) break; + } else if (toData != null && cur.depth <= toData.depth) + break; } - if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); + if (cur != toData) + throw new UnsupportedOperationException("illegal jump to non-parent operation"); } private void calculateLeaves(BuilderOperationData fromData) { @@ -746,18 +794,15 @@ private void labelPass(BuilderFinallyTryContext finallyTry) { private void doLeaveOperation(BuilderOperationData data) { switch (data.operationId) { - case OP_FINALLY_TRY : - { + case OP_FINALLY_TRY: { doLeaveFinallyTry(data); break; } - case OP_FINALLY_TRY_NO_EXCEPT : - { + case OP_FINALLY_TRY_NO_EXCEPT: { doLeaveFinallyTry(data); break; } - case OP_TAG : - { + case OP_TAG: { break; } } @@ -767,8 +812,7 @@ private void doLeaveOperation(BuilderOperationData data) { void doBeforeChild() { int childIndex = operationData.numChildren; switch (operationData.operationId) { - case OP_BLOCK : - { + case OP_BLOCK: { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -778,16 +822,14 @@ void doBeforeChild() { } break; } - case OP_TRY_CATCH : - { + case OP_TRY_CATCH: { if (childIndex == 1) { curStack = ((ExceptionHandler) operationData.aux[0]).startStack; ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; } break; } - case OP_SOURCE : - { + case OP_SOURCE: { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -797,8 +839,7 @@ void doBeforeChild() { } break; } - case OP_SOURCE_SECTION : - { + case OP_SOURCE_SECTION: { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -808,8 +849,7 @@ void doBeforeChild() { } break; } - case OP_TAG : - { + case OP_TAG: { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -819,8 +859,7 @@ void doBeforeChild() { } break; } - case OP_SL_AND : - { + case OP_SL_AND: { if (childIndex > 0) { int[] predecessorBcis = doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_SC_SL_AND); @@ -832,12 +871,12 @@ void doBeforeChild() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); bc[bci + 5 + 0] = 0; - bci = bci + 6; + bc[bci + 5 + 1] = 0; + bci = bci + 7; } break; } - case OP_SL_OR : - { + case OP_SL_OR: { if (childIndex > 0) { int[] predecessorBcis = doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_SC_SL_OR); @@ -849,7 +888,8 @@ void doBeforeChild() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); bc[bci + 5 + 0] = 0; - bci = bci + 6; + bc[bci + 5 + 1] = 0; + bci = bci + 7; } break; } @@ -860,8 +900,7 @@ void doBeforeChild() { void doAfterChild() { int childIndex = operationData.numChildren++; switch (operationData.operationId) { - case OP_IF_THEN : - { + case OP_IF_THEN: { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -882,8 +921,7 @@ void doAfterChild() { } break; } - case OP_IF_THEN_ELSE : - { + case OP_IF_THEN_ELSE: { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); @@ -918,8 +956,7 @@ void doAfterChild() { } break; } - case OP_CONDITIONAL : - { + case OP_CONDITIONAL: { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); @@ -946,8 +983,7 @@ void doAfterChild() { } break; } - case OP_WHILE : - { + case OP_WHILE: { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -973,8 +1009,7 @@ void doAfterChild() { } break; } - case OP_TRY_CATCH : - { + case OP_TRY_CATCH: { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -991,8 +1026,7 @@ void doAfterChild() { } break; } - case OP_FINALLY_TRY : - { + case OP_FINALLY_TRY: { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -1020,8 +1054,7 @@ void doAfterChild() { } break; } - case OP_FINALLY_TRY_NO_EXCEPT : - { + case OP_FINALLY_TRY_NO_EXCEPT: { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -1516,7 +1549,9 @@ public void endSLAdd() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1550,7 +1585,9 @@ public void endSLDiv() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1581,7 +1618,9 @@ public void endSLEqual() { bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; - bci = bci + 5; + bc[bci + 3 + 2] = 0; + bc[bci + 3 + 3] = 0; + bci = bci + 7; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1614,7 +1653,8 @@ public void endSLLessOrEqual() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; - bci = bci + 5; + bc[bci + 4 + 1] = 0; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1647,7 +1687,8 @@ public void endSLLessThan() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; - bci = bci + 5; + bc[bci + 4 + 1] = 0; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1679,7 +1720,8 @@ public void endSLLogicalNot() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bci = bci + 5; + bc[bci + 4 + 1] = 0; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1713,7 +1755,9 @@ public void endSLMul() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1749,7 +1793,9 @@ public void endSLReadProperty() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1783,7 +1829,9 @@ public void endSLSub() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1819,7 +1867,9 @@ public void endSLWriteProperty() { bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); bc[bci + 5 + 0] = 0; bc[bci + 5 + 1] = 0; - bci = bci + 7; + bc[bci + 5 + 2] = 0; + bc[bci + 5 + 3] = 0; + bci = bci + 9; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1849,7 +1899,9 @@ public void endSLUnbox() { bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; - bci = bci + 5; + bc[bci + 3 + 2] = 0; + bc[bci + 3 + 3] = 0; + bci = bci + 7; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1881,7 +1933,8 @@ public void endSLFunctionLiteral() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bci = bci + 5; + bc[bci + 4 + 1] = 0; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1913,7 +1966,8 @@ public void endSLToBoolean() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bci = bci + 5; + bc[bci + 4 + 1] = 0; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1946,7 +2000,9 @@ public void endSLInvoke() { bc[bci + 3] = (short) (numChildren - 1); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bci = bci + 6; + bc[bci + 4 + 2] = 0; + bc[bci + 4 + 3] = 0; + bci = bci + 8; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2054,7 +2110,7 @@ private static final class BuilderOperationData { final Object[] aux; int numChildren; - private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { + private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { this.parent = parent; this.operationId = operationId; this.stackDepth = stackDepth; @@ -2065,6 +2121,7 @@ private BuilderOperationData(BuilderOperationData parent, int operationId, int s } } + @GeneratedBy(SLOperations.class) private static final class OperationLabelImpl extends OperationLabel { @@ -2090,6 +2147,7 @@ boolean belongsTo(BuilderFinallyTryContext context) { } } + @GeneratedBy(SLOperations.class) private static final class OperationLocalImpl extends OperationLocal { @@ -2102,6 +2160,7 @@ private static final class OperationLocalImpl extends OperationLocal { } } + @GeneratedBy(SLOperations.class) private static final class LabelFill { @@ -2118,6 +2177,7 @@ LabelFill offset(int offset) { } } + @GeneratedBy(SLOperations.class) private static final class ExceptionHandler { @@ -2148,6 +2208,7 @@ public String toString() { } } + @GeneratedBy(SLOperations.class) private static final class SourceInfoBuilder { @@ -2250,6 +2311,7 @@ private static final class SourceData { } } + @GeneratedBy(SLOperations.class) private static final class BuilderFinallyTryContext { @@ -2266,7 +2328,8 @@ private static final class BuilderFinallyTryContext { ArrayList relocationOffsets = new ArrayList<>(); int handlerMaxStack; - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, + int curStack, int maxStack) { this.prev = prev; this.bc = bc; this.exceptionHandlers = exceptionHandlers; @@ -2277,11 +2340,13 @@ private static final class BuilderFinallyTryContext { } } + @GeneratedBy(SLOperations.class) private static final class OperationNodeImpl extends OperationNode implements BytecodeOSRNode { + private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); private static final BytecodeLoopBase COMMON_EXECUTE = new BytecodeNode(); - private static final BytecodeLoopBase INITIAL_EXECUTE = COMMON_EXECUTE; + private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; @CompilationFinal(dimensions = 1) short[] _bc; @CompilationFinal(dimensions = 1) Object[] _consts; @@ -2291,6 +2356,7 @@ private static final class OperationNodeImpl extends OperationNode implements By @CompilationFinal int _maxLocals; @CompilationFinal int _maxStack; @CompilationFinal(dimensions = 1) int[] sourceInfo; + @CompilationFinal int uncachedExecuteCount; @CompilationFinal private Object _osrMetadata; private TruffleString _metadata_MethodName; @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; @@ -2299,7 +2365,7 @@ private OperationNodeImpl(OperationNodes nodes) { super(nodes); } - static { + static { setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n)._metadata_MethodName); } @@ -2310,6 +2376,7 @@ private T insertAccessor(T node) { // () { private Object executeAt(VirtualFrame frame, int storedLocation) { int result = storedLocation; while (true) { + System.err.printf("[running] %08x%n", result); result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _handlers, _conditionProfiles, _maxLocals); if ((result & 0xffff) == 0xffff) { break; @@ -2391,11 +2458,17 @@ public Node copy() { return result; } + void changeInterpreters(BytecodeLoopBase impl) { + this.switchImpl = impl; + } + } + @GeneratedBy(SLOperations.class) private abstract static class BytecodeLoopBase { - abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); + abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, + int[] $conditionProfiles, int maxLocals); abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); @@ -2438,14 +2511,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -2453,11 +2526,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2468,14 +2541,14 @@ protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlo return false; } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -2483,11 +2556,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2499,6 +2572,7 @@ protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, } } + @GeneratedBy(SLOperations.class) private static final class BytecodeNode extends BytecodeLoopBase { @@ -2508,14 +2582,15 @@ private static final class BytecodeNode extends BytecodeLoopBase { @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @BytecodeInterpreterSwitch @Override - int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, + int[] $conditionProfiles, int maxLocals) { int $sp = $startSp; int $bci = $startBci; Counter loopCounter = new Counter(); loop: while (true) { CompilerAsserts.partialEvaluationConstant($bci); CompilerAsserts.partialEvaluationConstant($sp); - short curOpcode = $bc[$bci]; + short curOpcode = unsafeFromBytecode($bc, $bci); CompilerAsserts.partialEvaluationConstant(curOpcode); try { if ($sp < maxLocals) { @@ -2523,24 +2598,22 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } switch (curOpcode) { // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_POP : - { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_POP: { $sp = $sp - 1; $frame.clear($sp); $bci = $bci + POP_LENGTH; continue loop; } // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Boxing Elimination: Do Nothing - case INSTR_BRANCH : - { + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Boxing Elimination: Do Nothing + case INSTR_BRANCH: { int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { TruffleSafepoint.poll($this); @@ -2553,17 +2626,16 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - // Boxing Elimination: Do Nothing - case INSTR_BRANCH_FALSE : - { - boolean cond = (boolean) $frame.getObject($sp - 1); + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + // Boxing Elimination: Do Nothing + case INSTR_BRANCH_FALSE: { + boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; $sp = $sp - 1; if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { $bci = $bci + BRANCH_FALSE_LENGTH; @@ -2574,135 +2646,127 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_THROW : - { + // Locals: + // [ 0] exception + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_THROW: { int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; throw (AbstractTruffleException) $frame.getObject(slot); } // load.constant.object - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_OBJECT : - { - $frame.setObject($sp, $consts[$bc[$bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET] + 0]); + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_OBJECT: { + $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } - // load.constant.boolean - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN - // INT -> INSTR_LOAD_CONSTANT_BOOLEAN - // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN - // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $frame.setBoolean($sp, (boolean) $consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]); + // load.constant.long + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG: { + $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } - // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG : - { - $frame.setLong($sp, (long) $consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]); + // load.constant.boolean + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN + // INT -> INSTR_LOAD_CONSTANT_BOOLEAN + // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN + // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_BOOLEAN: { + $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } // load.argument.object - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : - { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT: { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; $frame.setObject($sp, value); $sp = $sp + 1; $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } - // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG: { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); } else { $frame.setObject($sp, value); } $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; continue loop; } - // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN: { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); } else { $frame.setObject($sp, value); } $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; continue loop; } // store.local.object - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_STORE_LOCAL_OBJECT : - { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_STORE_LOCAL_OBJECT: { int localIdx = $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; $frame.setObject(localIdx, expectObject($frame, sourceSlot)); @@ -2710,70 +2774,71 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; continue loop; } - // store.local.boolean - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : - { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + // store.local.long + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_LONG: { + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* + * OBJECT + */); } $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } - // store.local.long - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : - { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + // store.local.boolean + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_OBJECT + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_BOOLEAN: { + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* + * OBJECT + */); } $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } // store.local.uninit - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_LONG - // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN - case INSTR_STORE_LOCAL_UNINIT : - { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_LONG + // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN + case INSTR_STORE_LOCAL_UNINIT: { int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; FrameSlotKind localTag = $frame.getFrameDescriptor().getSlotKind(localIdx); @@ -2791,12 +2856,11 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.object - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Do Nothing - case INSTR_LOAD_LOCAL_OBJECT : - { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Do Nothing + case INSTR_LOAD_LOCAL_OBJECT: { int localIdx = $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0]; if ($frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -2808,28 +2872,27 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; continue loop; } - // load.local.boolean - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : - { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + // load.local.long + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_LONG: { + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2840,31 +2903,30 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; continue loop; } - // load.local.long - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : - { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + // load.local.boolean + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_OBJECT + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_BOOLEAN: { + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2875,19 +2937,18 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; continue loop; } // load.local.uninit - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_LONG - // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN - case INSTR_LOAD_LOCAL_UNINIT : - { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_LONG + // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN + case INSTR_LOAD_LOCAL_UNINIT: { int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; $frame.setObject($sp, expectObject($frame, localIdx)); $sp++; @@ -2895,310 +2956,383 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_RETURN : - { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_RETURN: { return (($sp - 1) << 16) | 0xffff; } // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65a11b0c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@f79df7c - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static + // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, + // java.lang.Object, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = + // [Guard[(SLAddNode.isString(left, right))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f1a38a + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@375dedc + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD: { BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_ADD_LENGTH; continue loop; } // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6c341dfe - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@286b0311 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_DIV : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5119e3c8 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16b0a9c1 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_DIV: { BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_DIV_LENGTH; continue loop; } // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45ff046b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4bca197 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_EQUAL : - { + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0, method = public static + // boolean doGeneric(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(leftInterop.accepts(left))], + // Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, + // java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@18d3b56e + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@357d1b96 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_EQUAL: { BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_EQUAL_LENGTH; continue loop; } // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48ab9713 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2b64a952 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL: { BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; continue loop; } // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@38a8769c - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3809e35e + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN: { BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_THAN_LENGTH; continue loop; } // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@549e1be - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LOGICAL_NOT : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d7459f4 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LOGICAL_NOT: { BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; continue loop; } // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@64185899 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@709f4806 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_MUL : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@60885467 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e284f1d + // Boxing Elimination: Bit Mask + case INSTR_C_SL_MUL: { BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_MUL_LENGTH; continue loop; } // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b78dc1f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41f688df - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static + // java.lang.Object readArray(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static + // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static + // java.lang.Object readObject(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objects.accepts(receiver))], + // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], + // Guard[(objects.hasMembers(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@194c5295 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@66803b1 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY: { BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_READ_PROPERTY_LENGTH; continue loop; } // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@678cdce8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d597767 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_SUB : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24614477 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@89db741 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_SUB: { BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_SUB_LENGTH; continue loop; } // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@200cc6f7 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@55c91259 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static + // java.lang.Object writeArray(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static + // java.lang.Object + // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, + // java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static + // java.lang.Object writeObject(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))], + // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73be843d + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@358d7470 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY: { BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; continue loop; } // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@54a3ff94 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@72e74828 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX : - { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static + // java.lang.Object fromForeign(java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1be1cc4a + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ea357c8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX: { BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_LENGTH; continue loop; } // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@341a03fd - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79bbab4d + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL: { BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; continue loop; } // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dc94fd - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@27cb6efe + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN: { BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; continue loop; } // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6248910d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2aa62364 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static + // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, + // java.lang.Object[], com.oracle.truffle.api.Assumption, + // com.oracle.truffle.api.RootCallTarget, + // com.oracle.truffle.api.nodes.DirectCallNode) , guards = + // [Guard[(function.getCallTarget() == cachedTarget)]], signature = + // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@325d65d1 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56247945 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE: { int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; Object input_0 = $frame.getObject($sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -3212,20 +3346,20 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ec7d826 - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_AND : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e1410f + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_AND: { if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_AND_LENGTH; @@ -3236,20 +3370,20 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@371c67f - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_OR : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ea17d33 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_OR: { if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_OR_LENGTH; @@ -3260,152 +3394,197 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2517ffe5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3e315520 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static + // java.lang.Object fromForeign(java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@578be2db + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2290573e + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_LONG: { BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; continue loop; } // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ec7bc28 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4308d9b1 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD_Q_ADD_LONG : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static + // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, + // java.lang.Object, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = + // [Guard[(SLAddNode.isString(left, right))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5a81935a + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5fcc35dc + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD_Q_ADD_LONG: { BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; continue loop; } // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59faeee2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6dd628a8 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static + // java.lang.Object readArray(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static + // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static + // java.lang.Object readObject(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objects.accepts(receiver))], + // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], + // Guard[(objects.hasMembers(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@575999c4 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@77501db6 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; continue loop; } // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1e03efc6 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1bc378e6 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static + // java.lang.Object fromForeign(java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@211d4b45 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f41f86f + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; continue loop; } // c.SLToBoolean.q.Boolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15c00882 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@44dd5fa + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; continue loop; } // c.SLLessOrEqual.q.LessOrEqual0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@490fe1fa - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7307d568 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { BytecodeNode.SLLessOrEqual_q_LessOrEqual0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; continue loop; } // c.SLInvoke.q.Direct - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48735ac2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48770f62 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE_Q_DIRECT : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static + // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, + // java.lang.Object[], com.oracle.truffle.api.Assumption, + // com.oracle.truffle.api.RootCallTarget, + // com.oracle.truffle.api.nodes.DirectCallNode) , guards = + // [Guard[(function.getCallTarget() == cachedTarget)]], signature = + // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@388bff2e + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2819ead0 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE_Q_DIRECT: { int numVariadics = $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0]; Object input_0 = $frame.getObject($sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -3419,84 +3598,108 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // c.SLFunctionLiteral.q.Perform - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d668af6 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4211182c + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; continue loop; } // c.SLWriteProperty.q.WriteSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6bd0b091 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@39274263 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static + // java.lang.Object writeArray(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static + // java.lang.Object + // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, + // java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static + // java.lang.Object writeObject(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))], + // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ff02993 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6865d5cc + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; continue loop; } // c.SLLessThan.q.LessThan0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@495b463a - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@f4ded7a + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { BytecodeNode.SLLessThan_q_LessThan0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; continue loop; } - default : + default: CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered"); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); } } catch (AbstractTruffleException ex) { CompilerAsserts.partialEvaluationConstant($bci); for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { CompilerAsserts.partialEvaluationConstant(handlerIndex); ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; + if (handler.startBci > $bci || handler.endBci <= $bci) + continue; $sp = handler.startStack + maxLocals; $frame.setObject(handler.exceptionIndex, ex); $bci = handler.handlerBci; @@ -3511,231 +3714,186 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { int $bci = 0; while ($bci < $bc.length) { - switch ($bc[$bci]) { - case INSTR_POP : - { + switch (unsafeFromBytecode($bc, $bci)) { + case INSTR_POP: { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH : - { + case INSTR_BRANCH: { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE : - { + case INSTR_BRANCH_FALSE: { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW : - { + case INSTR_THROW: { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT : - { + case INSTR_LOAD_CONSTANT_OBJECT: { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { + case INSTR_LOAD_CONSTANT_LONG: { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : - { + case INSTR_LOAD_CONSTANT_BOOLEAN: { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT : - { + case INSTR_LOAD_ARGUMENT_OBJECT: { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + case INSTR_LOAD_ARGUMENT_LONG: { + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : - { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + case INSTR_LOAD_ARGUMENT_BOOLEAN: { + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT : - { + case INSTR_STORE_LOCAL_OBJECT: { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : - { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + case INSTR_STORE_LOCAL_LONG: { + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : - { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + case INSTR_STORE_LOCAL_BOOLEAN: { + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT : - { + case INSTR_STORE_LOCAL_UNINIT: { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT : - { + case INSTR_LOAD_LOCAL_OBJECT: { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + case INSTR_LOAD_LOCAL_LONG: { + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : - { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + case INSTR_LOAD_LOCAL_BOOLEAN: { + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT : - { + case INSTR_LOAD_LOCAL_UNINIT: { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN : - { + case INSTR_RETURN: { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD : - { + case INSTR_C_SL_ADD: { $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV : - { + case INSTR_C_SL_DIV: { $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL : - { + case INSTR_C_SL_EQUAL: { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL : - { + case INSTR_C_SL_LESS_OR_EQUAL: { $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN : - { + case INSTR_C_SL_LESS_THAN: { $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT : - { + case INSTR_C_SL_LOGICAL_NOT: { $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL : - { + case INSTR_C_SL_MUL: { $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY : - { + case INSTR_C_SL_READ_PROPERTY: { $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB : - { + case INSTR_C_SL_SUB: { $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY : - { + case INSTR_C_SL_WRITE_PROPERTY: { $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX : - { + case INSTR_C_SL_UNBOX: { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL : - { + case INSTR_C_SL_FUNCTION_LITERAL: { $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN : - { + case INSTR_C_SL_TO_BOOLEAN: { $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE : - { + case INSTR_C_SL_INVOKE: { $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND : - { + case INSTR_SC_SL_AND: { $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR : - { + case INSTR_SC_SL_OR: { $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { + case INSTR_C_SL_UNBOX_Q_FROM_LONG: { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { + case INSTR_C_SL_ADD_Q_ADD_LONG: { $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { + case INSTR_C_SL_INVOKE_Q_DIRECT: { $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; break; } @@ -3749,14 +3907,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { StringBuilder sb = new StringBuilder(); while ($bci < $bc.length) { sb.append(String.format(" [%04x]", $bci)); - switch ($bc[$bci]) { - default : - { + switch (unsafeFromBytecode($bc, $bci)) { + default: { sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); break; } - case INSTR_POP : - { + case INSTR_POP: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -3769,8 +3925,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH : - { + case INSTR_BRANCH: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3784,8 +3939,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE : - { + case INSTR_BRANCH_FALSE: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3799,8 +3953,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW : - { + case INSTR_THROW: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3814,8 +3967,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT : - { + case INSTR_LOAD_CONSTANT_OBJECT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3825,12 +3977,11 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("load.constant.object "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]))); $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { + case INSTR_LOAD_CONSTANT_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3839,13 +3990,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET] + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : - { + case INSTR_LOAD_CONSTANT_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3854,13 +4004,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET] + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT : - { + case INSTR_LOAD_ARGUMENT_OBJECT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3874,8 +4023,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { + case INSTR_LOAD_ARGUMENT_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3884,13 +4032,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; } - case INSTR_LOAD_ARGUMENT_LONG : - { + case INSTR_LOAD_ARGUMENT_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3899,13 +4046,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT : - { + case INSTR_STORE_LOCAL_OBJECT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3920,8 +4066,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : - { + case INSTR_STORE_LOCAL_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3930,14 +4075,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : - { + case INSTR_STORE_LOCAL_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3946,14 +4090,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT : - { + case INSTR_STORE_LOCAL_UNINIT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3968,8 +4111,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT : - { + case INSTR_LOAD_LOCAL_OBJECT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3983,8 +4125,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : - { + case INSTR_LOAD_LOCAL_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3993,13 +4134,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : - { + case INSTR_LOAD_LOCAL_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4008,13 +4148,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT : - { + case INSTR_LOAD_LOCAL_UNINIT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4028,8 +4167,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN : - { + case INSTR_RETURN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -4042,8 +4180,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD : - { + case INSTR_C_SL_ADD: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4053,14 +4190,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLAdd "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_ADD_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV : - { + case INSTR_C_SL_DIV: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4070,14 +4206,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLDiv "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_DIV_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL : - { + case INSTR_C_SL_EQUAL: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4092,8 +4227,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL : - { + case INSTR_C_SL_LESS_OR_EQUAL: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4103,14 +4237,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLLessOrEqual "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN : - { + case INSTR_C_SL_LESS_THAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4120,14 +4253,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLLessThan "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_THAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT : - { + case INSTR_C_SL_LOGICAL_NOT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4137,13 +4269,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLLogicalNot "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff))); $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL : - { + case INSTR_C_SL_MUL: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4153,14 +4284,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLMul "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_MUL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY : - { + case INSTR_C_SL_READ_PROPERTY: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4170,16 +4300,15 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLReadProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET] + 2]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB : - { + case INSTR_C_SL_SUB: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4189,14 +4318,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLSub "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_SUB_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY : - { + case INSTR_C_SL_WRITE_PROPERTY: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4206,16 +4334,15 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 6])); sb.append(" "); sb.append("c.SLWriteProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET] + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff))); $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX : - { + case INSTR_C_SL_UNBOX: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4229,8 +4356,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL : - { + case INSTR_C_SL_FUNCTION_LITERAL: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4240,13 +4366,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLFunctionLiteral "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff))); $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN : - { + case INSTR_C_SL_TO_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4256,13 +4381,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLToBoolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE : - { + case INSTR_C_SL_INVOKE: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4272,13 +4396,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLInvoke "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_INVOKE_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND : - { + case INSTR_SC_SL_AND: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4288,14 +4411,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("sc.SLAnd "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + SC_SL_AND_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_AND_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0])); $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR : - { + case INSTR_SC_SL_OR: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4305,14 +4427,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("sc.SLOr "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + SC_SL_OR_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_OR_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0])); $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { + case INSTR_C_SL_UNBOX_Q_FROM_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4326,8 +4447,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { + case INSTR_C_SL_ADD_Q_ADD_LONG: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4337,14 +4457,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4354,16 +4473,15 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLReadProperty.q.ReadSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET] + 2]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4377,8 +4495,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4388,13 +4505,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4404,14 +4520,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLLessOrEqual.q.LessOrEqual0"); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { + case INSTR_C_SL_INVOKE_Q_DIRECT: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4421,13 +4536,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4437,13 +4551,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0] & 0xff))); $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4453,16 +4566,15 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 6])); sb.append(" "); sb.append("c.SLWriteProperty.q.WriteSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET] + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET] + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1] & 0xff))); $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4472,7 +4584,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append("c.SLLessThan.q.LessThan0 "); - sb.append(String.format(" const(%s)", formatConstant($consts[$bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET] + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] & 0xff))); sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; @@ -4487,11 +4599,16 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { return sb.toString(); } - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + if (((state_0 & 0b1000)) == 0 /* + * is-not-state_0 add(Object, Object, + * SLToTruffleStringNode, SLToTruffleStringNode, + * ConcatNode) + */ && (SLAddNode.isString($child0Value, $child1Value))) { return false; } return true; @@ -4499,7 +4616,35 @@ private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLAdd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* + * is + * - + * not + * addLong + * ( + * long, + * long) + * && + * add + * ( + * SLBigNumber, + * SLBigNumber) + * && + * add + * ( + * Object, + * Object, + * SLToTruffleStringNode, + * SLToTruffleStringNode, + * ConcatNode) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -4542,8 +4687,24 @@ private static void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * addLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * addLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4574,8 +4735,24 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * addLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * addLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4584,17 +4761,57 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); return; } } - if ((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_ADD_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b11000) != 0 /* + * is-state_0 add(Object, Object, + * SLToTruffleStringNode, SLToTruffleStringNode, + * ConcatNode) || typeError(Object, Object, Node, int) + */) { + if ((state_0 & 0b1000) != 0 /* + * is-state_0 add(Object, Object, + * SLToTruffleStringNode, SLToTruffleStringNode, + * ConcatNode) + */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0]); if (s2_ != null) { if ((SLAddNode.isString($child0Value_, $child1Value_))) { $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); @@ -4602,7 +4819,9 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b10000) != 0 /* + * is-state_0 typeError(Object, Object, Node, int) + */) { { Node fallback_node__ = ($this); int fallback_bci__ = ($bci); @@ -4618,7 +4837,8 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -4631,8 +4851,18 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * addLong + * ( + * long, + * long) + */); + if ((state_0 & 0b11110) == 0b10/* + * is-exact-state_0 addLong(long, long) + */) { $bc[$bci] = (short) (INSTR_C_SL_ADD_Q_ADD_LONG); } else { $bc[$bci] = (short) (INSTR_C_SL_ADD); @@ -4662,8 +4892,24 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * addLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * addLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4679,11 +4925,38 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * addLong + * ( + * long, + * long) + */); + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * addLong(long, long) + */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * add + * ( + * SLBigNumber, + * SLBigNumber) + */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -4704,8 +4977,19 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = $bc[$bci + C_SL_ADD_CHILDREN_OFFSET] + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * add + * ( + * Object, + * Object, + * SLToTruffleStringNode, + * SLToTruffleStringNode, + * ConcatNode) + */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -4723,7 +5007,17 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -4743,7 +5037,8 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo } } - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -4752,7 +5047,27 @@ private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLDiv_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* + * is + * - + * not + * divLong + * ( + * long, + * long) + * && + * div + * ( + * SLBigNumber, + * SLBigNumber) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -4795,8 +5110,24 @@ private static void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * divLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * divLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4827,8 +5158,24 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * divLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * divLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4837,10 +5184,42 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); return; } @@ -4860,7 +5239,8 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -4873,7 +5253,15 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * divLong + * ( + * long, + * long) + */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { @@ -4899,8 +5287,24 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * divLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * divLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -4916,11 +5320,38 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * divLong + * ( + * long, + * long) + */); + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * divLong(long, long) + */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * div + * ( + * SLBigNumber, + * SLBigNumber) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -4939,7 +5370,17 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -4958,12 +5399,139 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo } } + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, + Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + private static void SLEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* + * is + * - + * not + * doLong + * ( + * long, + * long) + * && + * doBigNumber + * ( + * SLBigNumber, + * SLBigNumber) + * && + * doBoolean + * ( + * boolean, + * boolean) + * && + * doString + * ( + * String, + * String) + * && + * doTruffleString + * ( + * TruffleString, + * TruffleString, + * EqualNode) + * && + * doNull + * ( + * SLNull, + * SLNull) + * && + * doFunction + * ( + * SLFunction, + * Object) + * && + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + * && + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + */)) { SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; - } else if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + } else if ((state_0 & 0b1111110110) == 0 /* + * only-active doBoolean(boolean, boolean) + */ && ((state_0 & 0b1111111110) != 0 /* + * is + * - + * not + * doLong + * ( + * long, + * long) + * && + * doBigNumber + * ( + * SLBigNumber, + * SLBigNumber) + * && + * doBoolean + * ( + * boolean, + * boolean) + * && + * doString + * ( + * String, + * String) + * && + * doTruffleString + * ( + * TruffleString, + * TruffleString, + * EqualNode) + * && + * doNull + * ( + * SLNull, + * SLNull) + * && + * doFunction + * ( + * SLFunction, + * Object) + * && + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + * && + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + */)) { SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5002,7 +5570,8 @@ private static void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, Op return; } - private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -5032,24 +5601,6 @@ private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $fra return; } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - @ExplodeLoop private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; @@ -5069,10 +5620,45 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* + * extract + * - + * implicit + * - + * state_0 + * 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -5108,11 +5694,14 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + if ((state_0 & 0b100000) != 0 /* + * is-state_0 doTruffleString(TruffleString, + * TruffleString, EqualNode) + */ && $child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; if ($child1Value_ instanceof TruffleString) { TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 0]); + EqualNode truffleString_equalNode__ = ((EqualNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0]); if (truffleString_equalNode__ != null) { boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { @@ -5137,7 +5726,12 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b1110000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1110000000) != 0 /* + * is-state_0 doFunction(SLFunction, Object) || + * doGeneric(Object, Object, InteropLibrary, + * InteropLibrary) || doGeneric(Object, Object, + * InteropLibrary, InteropLibrary) + */) { if ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { SLFunction $child0Value__ = (SLFunction) $child0Value_; boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); @@ -5148,9 +5742,17 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper } return; } - if ((state_0 & 0b1100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1]); + if ((state_0 & 0b1100000000) != 0 /* + * is-state_0 doGeneric(Object, Object, + * InteropLibrary, InteropLibrary) || + * doGeneric(Object, Object, InteropLibrary, + * InteropLibrary) + */) { + if ((state_0 & 0b100000000) != 0 /* + * is-state_0 doGeneric(Object, Object, + * InteropLibrary, InteropLibrary) + */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); while (s7_ != null) { if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); @@ -5164,7 +5766,10 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper s7_ = s7_.next_; } } - if ((state_0 & 0b1000000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000000) != 0 /* + * is-state_0 doGeneric(Object, Object, + * InteropLibrary, InteropLibrary) + */) { $frame.setObject($sp - 2, SLEqual_generic1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); return; } @@ -5175,7 +5780,8 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } - private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5188,7 +5794,15 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doLong + * ( + * long, + * long) + */); int type0; int type1; if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */) { @@ -5218,9 +5832,27 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* + * set- + * implicit- + * state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* + * set- + * implicit- + * state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * doBigNumber + * ( + * SLBigNumber, + * SLBigNumber) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5243,10 +5875,21 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation boolean $child0Value_ = (boolean) $child0Value; if ($child1Value instanceof Boolean) { boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * doBoolean + * ( + * boolean, + * boolean) + */); int type0; int type1; - if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */) { + if ((state_0 & 0b1111110110) == 0 /* + * only-active doBoolean(boolean, + * boolean) + */) { type0 = 5 /* BOOLEAN */; type1 = 5 /* BOOLEAN */; } else { @@ -5270,7 +5913,15 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation String $child0Value_ = (String) $child0Value; if ($child1Value instanceof String) { String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* + * add + * - + * state_0 + * doString + * ( + * String, + * String) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5292,8 +5943,17 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation TruffleString $child0Value_ = (TruffleString) $child0Value; if ($child1Value instanceof TruffleString) { TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* + * add + * - + * state_0 + * doTruffleString + * ( + * TruffleString, + * TruffleString, + * EqualNode) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5315,7 +5975,15 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation SLNull $child0Value_ = SLTypes.asSLNull($child0Value); if (SLTypes.isSLNull($child1Value)) { SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* + * add + * - + * state_0 + * doNull + * ( + * SLNull, + * SLNull) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5335,7 +6003,15 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* + * add + * - + * state_0 + * doFunction + * ( + * SLFunction, + * Object) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5352,10 +6028,16 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } return; } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((exclude) == 0 /* + * is-not-exclude doGeneric(Object, Object, InteropLibrary, + * InteropLibrary) + */) { int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); + if ((state_0 & 0b100000000) != 0 /* + * is-state_0 doGeneric(Object, Object, + * InteropLibrary, InteropLibrary) + */) { while (s7_ != null) { if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { break; @@ -5373,7 +6055,17 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* + * add + * - + * state_0 + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5403,10 +6095,35 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation try { generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = $bc[$bci + C_SL_EQUAL_CHILDREN_OFFSET] + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xfffffeff /* + * remove-state_0 + * doGeneric(Object, Object, + * InteropLibrary, + * InteropLibrary) + */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* + * add + * - + * state_0 + * doGeneric + * ( + * Object, + * Object, + * InteropLibrary, + * InteropLibrary) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5434,7 +6151,8 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } } - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -5443,7 +6161,27 @@ private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, Operat private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* + * is + * - + * not + * lessOrEqual + * ( + * long, + * long) + * && + * lessOrEqual + * ( + * SLBigNumber, + * SLBigNumber) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5452,7 +6190,8 @@ private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImp } } - private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; @@ -5482,7 +6221,8 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFram return; } - private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); @@ -5500,10 +6240,42 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -5528,7 +6300,8 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame return; } - private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5540,8 +6313,19 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * lessOrEqual + * ( + * long, + * long) + */); + if ((state_0 & 0b1110) == 0b10/* + * is-exact-state_0 lessOrEqual(long, + * long) + */) { $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0); } else { $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); @@ -5575,9 +6359,25 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * lessOrEqual + * ( + * SLBigNumber, + * SLBigNumber) + */); $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); int type0; int type1; @@ -5602,7 +6402,17 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); int type0; int type1; @@ -5622,7 +6432,8 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope } } - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -5631,7 +6442,27 @@ private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, Operation private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* + * is + * - + * not + * lessThan + * ( + * long, + * long) + * && + * lessThan + * ( + * SLBigNumber, + * SLBigNumber) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5640,7 +6471,8 @@ private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $ } } - private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; @@ -5670,7 +6502,8 @@ private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $fra return; } - private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); @@ -5688,10 +6521,42 @@ private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -5716,7 +6581,8 @@ private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame return; } - private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5728,8 +6594,18 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * lessThan + * ( + * long, + * long) + */); + if ((state_0 & 0b1110) == 0b10/* + * is-exact-state_0 lessThan(long, long) + */) { $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0); } else { $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); @@ -5763,9 +6639,25 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * lessThan + * ( + * SLBigNumber, + * SLBigNumber) + */); $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); int type0; int type1; @@ -5790,7 +6682,17 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); int type0; int type1; @@ -5810,7 +6712,8 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat } } - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -5819,7 +6722,20 @@ private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, Operati private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* + * is + * - + * not + * doBoolean + * ( + * boolean) + * && + * typeError + * ( + * Object, + * Node, + * int) + */)) { SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5828,7 +6744,8 @@ private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl } } - private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -5849,7 +6766,8 @@ private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $f return; } - private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); @@ -5878,7 +6796,8 @@ private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $f return; } - private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5888,7 +6807,14 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doBoolean + * ( + * boolean) + */); int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = 5 /* BOOLEAN */; @@ -5911,7 +6837,16 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Node, + * int) + */); int type0; type0 = 0 /* OBJECT */; doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); @@ -5927,7 +6862,8 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper } } - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -5936,7 +6872,27 @@ private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLMul_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* + * is + * - + * not + * mulLong + * ( + * long, + * long) + * && + * mul + * ( + * SLBigNumber, + * SLBigNumber) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5979,8 +6935,24 @@ private static void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * mulLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * mulLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6011,8 +6983,24 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * mulLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * mulLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6021,10 +7009,42 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); return; } @@ -6044,7 +7064,8 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6057,7 +7078,15 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * mulLong + * ( + * long, + * long) + */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { @@ -6083,8 +7112,24 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * mulLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * mulLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6100,11 +7145,38 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * mulLong + * ( + * long, + * long) + */); + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * mulLong(long, long) + */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * mul + * ( + * SLBigNumber, + * SLBigNumber) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6123,7 +7195,17 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6142,6 +7224,59 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo } } + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, + Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + SLObject $child0Value_, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, + readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, + Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11]); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + @ExplodeLoop private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0]; @@ -6149,10 +7284,32 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b1111110) != 0 /* + * is-state_0 readArray(Object, Object, Node, int, + * InteropLibrary, InteropLibrary) || + * readArray(Object, Object, Node, int, + * InteropLibrary, InteropLibrary) || + * readSLObject(SLObject, Object, Node, int, + * DynamicObjectLibrary, SLToTruffleStringNode) || + * readSLObject(SLObject, Object, Node, int, + * DynamicObjectLibrary, SLToTruffleStringNode) || + * readObject(Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) || + * readObject(Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) + */) { + if ((state_0 & 0b110) != 0 /* + * is-state_0 readArray(Object, Object, Node, int, + * InteropLibrary, InteropLibrary) || + * readArray(Object, Object, Node, int, + * InteropLibrary, InteropLibrary) + */) { + if ((state_0 & 0b10) != 0 /* + * is-state_0 readArray(Object, Object, Node, int, + * InteropLibrary, InteropLibrary) + */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + + 0) + 0]); while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { Node node__ = ($this); @@ -6163,7 +7320,10 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b100) != 0 /* + * is-state_0 readArray(Object, Object, Node, + * int, InteropLibrary, InteropLibrary) + */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { @@ -6179,10 +7339,21 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm } } } - if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + if ((state_0 & 0b11000) != 0 /* + * is-state_0 readSLObject(SLObject, Object, Node, + * int, DynamicObjectLibrary, + * SLToTruffleStringNode) || readSLObject(SLObject, + * Object, Node, int, DynamicObjectLibrary, + * SLToTruffleStringNode) + */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* + * is-state_0 readSLObject(SLObject, Object, + * Node, int, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { Node node__1 = ($this); @@ -6193,14 +7364,27 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s2_ = s2_.next_; } } - if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + if ((state_0 & 0b10000) != 0 /* + * is-state_0 readSLObject(SLObject, Object, + * Node, int, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { $frame.setObject($sp - 2, SLReadProperty_readSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_)); return; } } - if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 8]); + if ((state_0 & 0b1100000) != 0 /* + * is-state_0 readObject(Object, Object, Node, + * int, InteropLibrary, SLToMemberNode) || + * readObject(Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) + */) { + if ((state_0 & 0b100000) != 0 /* + * is-state_0 readObject(Object, Object, Node, + * int, InteropLibrary, SLToMemberNode) + */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + + 0) + 8]); while (s4_ != null) { if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { Node node__2 = ($this); @@ -6211,7 +7395,10 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s4_ = s4_.next_; } } - if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b1000000) != 0 /* + * is-state_0 readObject(Object, Object, + * Node, int, InteropLibrary, SLToMemberNode) + */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { @@ -6233,55 +7420,8 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm return; } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 11]); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6293,10 +7433,17 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op { int bci__ = 0; Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if (((exclude & 0b1)) == 0 /* + * is-not-exclude readArray(Object, Object, Node, + * int, InteropLibrary, InteropLibrary) + */) { int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + + 0) + 0]); + if ((state_0 & 0b10) != 0 /* + * is-state_0 readArray(Object, Object, Node, + * int, InteropLibrary, InteropLibrary) + */) { while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { node__ = ($this); @@ -6320,7 +7467,19 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * readArray + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -6354,10 +7513,41 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op readArray1_node__ = ($this); readArray1_bci__ = ($bci); readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * readArray + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * readArray(Object, + * Object, Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * readArray + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -6367,7 +7557,8 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); + $frame.setObject($sp - 2, + SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); return; } } @@ -6381,10 +7572,20 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op { int bci__1 = 0; Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + if (((exclude & 0b10)) == 0 /* + * is-not-exclude readSLObject(SLObject, + * Object, Node, int, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* + * is-state_0 readSLObject(SLObject, + * Object, Node, int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value_))) { node__1 = ($this); @@ -6405,8 +7606,26 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * readSLObject + * ( + * SLObject, + * Object, + * Node, + * int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); + if ((state_0 & 0b1111110) == 0b1000/* + * is-exact-state_0 + * readSLObject(SLObject, + * Object, Node, int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0); } else { $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); @@ -6434,11 +7653,41 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op readSLObject1_node__ = ($this); readSLObject1_bci__ = ($bci); readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* + * add + * - + * exclude + * readSLObject + * ( + * SLObject, + * Object, + * Node, + * int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + state_0 = (short) (state_0 & 0xfffffff7 /* + * remove-state_0 + * readSLObject(SLObject, + * Object, Node, int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* + * add + * - + * state_0 + * readSLObject + * ( + * SLObject, + * Object, + * Node, + * int, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -6448,17 +7697,26 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, + ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); return; } } { int bci__2 = 0; Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if (((exclude & 0b100)) == 0 /* + * is-not-exclude readObject(Object, Object, + * Node, int, InteropLibrary, SLToMemberNode) + */) { int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 8]); - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + + 0) + 8]); + if ((state_0 & 0b100000) != 0 /* + * is-state_0 readObject(Object, Object, + * Node, int, InteropLibrary, + * SLToMemberNode) + */) { while (s4_ != null) { if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { node__2 = ($this); @@ -6481,7 +7739,19 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* + * add + * - + * state_0 + * readObject + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -6513,11 +7783,43 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op if ((readObject1_objects__.hasMembers($child0Value))) { readObject1_node__ = ($this); readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET] + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor( + (SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* + * add + * - + * exclude + * readObject + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + state_0 = (short) (state_0 & 0xffffffdf /* + * remove-state_0 + * readObject( + * Object, Object, + * Node, int, + * InteropLibrary, + * SLToMemberNode) + */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* + * add + * - + * state_0 + * readObject + * ( + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -6527,7 +7829,8 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) $children[childArrayOffset_ + 11]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, + ((SLToMemberNode) $children[childArrayOffset_ + 11]))); return; } } @@ -6536,7 +7839,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op } } } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -6544,7 +7847,8 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op } } - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -6553,7 +7857,27 @@ private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLSub_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* + * is + * - + * not + * subLong + * ( + * long, + * long) + * && + * sub + * ( + * SLBigNumber, + * SLBigNumber) + * && + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */)) { SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -6596,8 +7920,24 @@ private static void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * subLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * subLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6628,8 +7968,24 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * subLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * subLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6638,10 +7994,42 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract- + * implicit- + * state_0 1: + * SLBigNumber + */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* + * extract + * - + * implicit + * - + * state_0 + * 1 + * : + * SLBigNumber + */, $child1Value_); $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); return; } @@ -6661,7 +8049,8 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6674,7 +8063,15 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * subLong + * ( + * long, + * long) + */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { @@ -6700,8 +8097,24 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * subLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * subLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -6717,11 +8130,38 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * subLong + * ( + * long, + * long) + */); + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * subLong(long, long) + */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* + * set-implicit + * -state_0 0: + * SLBigNumber + */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* + * set-implicit + * -state_0 1: + * SLBigNumber + */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * sub + * ( + * SLBigNumber, + * SLBigNumber) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6740,7 +8180,17 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * typeError + * ( + * Object, + * Object, + * Node, + * int) + */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6759,6 +8209,63 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo } } + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, + Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + SLObject $child0Value_, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6]); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, + Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10]); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, + writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + @ExplodeLoop private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; @@ -6767,10 +8274,32 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI Object $child0Value_ = expectObject($frame, $sp - 3); Object $child1Value_ = expectObject($frame, $sp - 2); Object $child2Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b1111110) != 0 /* + * is-state_0 writeArray(Object, Object, Object, + * Node, int, InteropLibrary, InteropLibrary) || + * writeArray(Object, Object, Object, Node, int, + * InteropLibrary, InteropLibrary) || + * writeSLObject(SLObject, Object, Object, + * DynamicObjectLibrary, SLToTruffleStringNode) || + * writeSLObject(SLObject, Object, Object, + * DynamicObjectLibrary, SLToTruffleStringNode) || + * writeObject(Object, Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) || + * writeObject(Object, Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) + */) { + if ((state_0 & 0b110) != 0 /* + * is-state_0 writeArray(Object, Object, Object, + * Node, int, InteropLibrary, InteropLibrary) || + * writeArray(Object, Object, Object, Node, int, + * InteropLibrary, InteropLibrary) + */) { + if ((state_0 & 0b10) != 0 /* + * is-state_0 writeArray(Object, Object, Object, + * Node, int, InteropLibrary, InteropLibrary) + */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { Node node__ = ($this); @@ -6781,14 +8310,18 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b100) != 0 /* + * is-state_0 writeArray(Object, Object, Object, + * Node, int, InteropLibrary, InteropLibrary) + */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { { InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); + $frame.setObject($sp - 3, + SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); return; } } @@ -6797,10 +8330,21 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI } } } - if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + if ((state_0 & 0b11000) != 0 /* + * is-state_0 writeSLObject(SLObject, Object, + * Object, DynamicObjectLibrary, + * SLToTruffleStringNode) || + * writeSLObject(SLObject, Object, Object, + * DynamicObjectLibrary, SLToTruffleStringNode) + */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* + * is-state_0 writeSLObject(SLObject, Object, + * Object, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); @@ -6809,14 +8353,28 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s2_ = s2_.next_; } } - if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + if ((state_0 & 0b10000) != 0 /* + * is-state_0 writeSLObject(SLObject, Object, + * Object, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { $frame.setObject($sp - 3, SLWriteProperty_writeSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_)); return; } } - if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); + if ((state_0 & 0b1100000) != 0 /* + * is-state_0 writeObject(Object, Object, Object, + * Node, int, InteropLibrary, SLToMemberNode) || + * writeObject(Object, Object, Object, Node, int, + * InteropLibrary, SLToMemberNode) + */) { + if ((state_0 & 0b100000) != 0 /* + * is-state_0 writeObject(Object, Object, + * Object, Node, int, InteropLibrary, + * SLToMemberNode) + */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); while (s4_ != null) { if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { Node node__1 = ($this); @@ -6827,7 +8385,11 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s4_ = s4_.next_; } } - if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b1000000) != 0 /* + * is-state_0 writeObject(Object, Object, + * Object, Node, int, InteropLibrary, + * SLToMemberNode) + */) { if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { $frame.setObject($sp - 3, SLWriteProperty_writeObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); return; @@ -6840,74 +8402,32 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI return; } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 6]); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value, Object $child2Value) { int childArrayOffset_; int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 10]); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1]; + short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; + short exclude = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1]; { int bci__ = 0; Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if (((exclude & 0b1)) == 0 /* + * is-not-exclude writeArray(Object, Object, + * Object, Node, int, InteropLibrary, + * InteropLibrary) + */) { int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); + if ((state_0 & 0b10) != 0 /* + * is-state_0 writeArray(Object, Object, + * Object, Node, int, InteropLibrary, + * InteropLibrary) + */) { while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { node__ = ($this); @@ -6931,7 +8451,20 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * writeArray + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -6968,10 +8501,44 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O writeArray1_node__ = ($this); writeArray1_bci__ = ($bci); writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * writeArray + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * writeArray( + * Object, Object, + * Object, Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * writeArray + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -6984,7 +8551,8 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__)); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, + writeArray1_numbers__)); return; } } @@ -6995,10 +8563,19 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + if (((exclude & 0b10)) == 0 /* + * is-not-exclude writeSLObject(SLObject, + * Object, Object, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* + * is-state_0 writeSLObject(SLObject, + * Object, Object, DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value_))) { break; @@ -7015,8 +8592,25 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * writeSLObject + * ( + * SLObject, + * Object, + * Object, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); + if ((state_0 & 0b1111110) == 0b1000/* + * is-exact-state_0 + * writeSLObject(SLObject, + * Object, Object, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */) { $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0); } else { $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); @@ -7042,11 +8636,39 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O { DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* + * add + * - + * exclude + * writeSLObject + * ( + * SLObject, + * Object, + * Object, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + state_0 = (short) (state_0 & 0xfffffff7 /* + * remove-state_0 + * writeSLObject(SLObject, + * Object, Object, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* + * add + * - + * state_0 + * writeSLObject + * ( + * SLObject, + * Object, + * Object, + * DynamicObjectLibrary, + * SLToTruffleStringNode) + */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -7059,17 +8681,27 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, + ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); return; } } { int bci__1 = 0; Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if (((exclude & 0b100)) == 0 /* + * is-not-exclude writeObject(Object, Object, + * Object, Node, int, InteropLibrary, + * SLToMemberNode) + */) { int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 7]); - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); + if ((state_0 & 0b100000) != 0 /* + * is-state_0 writeObject(Object, Object, + * Object, Node, int, InteropLibrary, + * SLToMemberNode) + */) { while (s4_ != null) { if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { node__1 = ($this); @@ -7090,7 +8722,20 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* + * add + * - + * state_0 + * writeObject + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -7123,11 +8768,43 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O writeObject1_node__ = ($this); writeObject1_bci__ = ($bci); writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET] + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* + * add + * - + * exclude + * writeObject + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + state_0 = (short) (state_0 & 0xffffffdf /* + * remove-state_0 + * writeObject(Object, + * Object, Object, Node, + * int, InteropLibrary, + * SLToMemberNode) + */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* + * add + * - + * state_0 + * writeObject + * ( + * Object, + * Object, + * Object, + * Node, + * int, + * InteropLibrary, + * SLToMemberNode) + */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -7140,7 +8817,8 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, + writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); return; } } finally { @@ -7148,7 +8826,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O } } } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -7156,12 +8834,113 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O } } + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + private static void SLUnbox_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* + * is + * - + * not + * fromString + * ( + * String, + * FromJavaStringNode) + * && + * fromTruffleString + * ( + * TruffleString) + * && + * fromBoolean + * ( + * boolean) + * && + * fromLong + * ( + * long) + * && + * fromBigNumber + * ( + * SLBigNumber) + * && + * fromFunction + * ( + * SLFunction) + * && + * fromFunction + * ( + * SLNull) + * && + * fromForeign + * ( + * Object, + * InteropLibrary) + * && + * fromForeign + * ( + * Object, + * InteropLibrary) + */)) { SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; - } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* + * is + * - + * not + * fromString + * ( + * String, + * FromJavaStringNode) + * && + * fromTruffleString + * ( + * TruffleString) + * && + * fromBoolean + * ( + * boolean) + * && + * fromLong + * ( + * long) + * && + * fromBigNumber + * ( + * SLBigNumber) + * && + * fromFunction + * ( + * SLFunction) + * && + * fromFunction + * ( + * SLNull) + * && + * fromForeign + * ( + * Object, + * InteropLibrary) + * && + * fromForeign + * ( + * Object, + * InteropLibrary) + */)) { SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -7212,23 +8991,6 @@ private static void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, Operati return; } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - @ExplodeLoop private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; @@ -7236,7 +8998,7 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper Object $child0Value_ = expectObject($frame, $sp - 1); if ((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 0]); + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0]); if (fromString_fromJavaStringNode__ != null) { $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__)); return; @@ -7267,8 +9029,26 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper } return; } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* + * extract + * - + * implicit + * - + * state_0 + * 0 + * : + * SLBigNumber + */, $child0Value_); $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); return; } @@ -7282,9 +9062,15 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); return; } - if ((state_0 & 0b1100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1]); + if ((state_0 & 0b1100000000) != 0 /* + * is-state_0 fromForeign(Object, InteropLibrary) + * || fromForeign(Object, InteropLibrary) + */) { + if ((state_0 & 0b100000000) != 0 /* + * is-state_0 fromForeign(Object, + * InteropLibrary) + */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); while (s7_ != null) { if ((s7_.interop_.accepts($child0Value_))) { $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); @@ -7293,7 +9079,10 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper s7_ = s7_.next_; } } - if ((state_0 & 0b1000000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b1000000000) != 0 /* + * is-state_0 fromForeign(Object, + * InteropLibrary) + */) { $frame.setObject($sp - 1, SLUnbox_fromForeign1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)); return; } @@ -7314,8 +9103,16 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation short exclude = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1]; if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * fromString + * ( + * String, + * FromJavaStringNode) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7327,7 +9124,14 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * fromTruffleString + * ( + * TruffleString) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7339,8 +9143,18 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); - if ((state_0 & 0b1111111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */) { + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * fromBoolean + * ( + * boolean) + */); + if ((state_0 & 0b1111111110) == 0b1000/* + * is-exact-state_0 + * fromBoolean(boolean) + */) { $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN); } else { $bc[$bci] = (short) (INSTR_C_SL_UNBOX); @@ -7364,7 +9178,14 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* + * add + * - + * state_0 + * fromLong + * ( + * long) + */); if ((state_0 & 0b1111111110) == 0b10000/* is-exact-state_0 fromLong(long) */) { $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG); } else { @@ -7391,8 +9212,19 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation int sLBigNumberCast0; if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* + * set-implicit- + * state_0 + * 0:SLBigNumber + */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* + * add + * - + * state_0 + * fromBigNumber + * ( + * SLBigNumber) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7405,7 +9237,14 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* + * add + * - + * state_0 + * fromFunction + * ( + * SLFunction) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7417,7 +9256,14 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if (SLTypes.isSLNull($child0Value)) { SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* + * add + * - + * state_0 + * fromFunction + * ( + * SLNull) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7429,8 +9275,11 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); + if ((state_0 & 0b100000000) != 0 /* + * is-state_0 fromForeign(Object, + * InteropLibrary) + */) { while (s7_ != null) { if ((s7_.interop_.accepts($child0Value))) { break; @@ -7446,7 +9295,15 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* + * add + * - + * state_0 + * fromForeign + * ( + * Object, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7467,10 +9324,30 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation Node prev_ = encapsulating_.set($this); try { fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = $bc[$bci + C_SL_UNBOX_CHILDREN_OFFSET] + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * fromForeign + * ( + * Object, + * InteropLibrary) + */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xfffffeff /* + * remove-state_0 + * fromForeign(Object, + * InteropLibrary) + */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* + * add + * - + * state_0 + * fromForeign + * ( + * Object, + * InteropLibrary) + */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -7500,7 +9377,7 @@ private static void SLFunctionLiteral_execute_(VirtualFrame $frame, OperationNod TruffleString $child0Value__ = (TruffleString) $child0Value_; { Node node__ = ($this); - SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0) + 0]); + SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0]); if (result__ != null) { $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); return; @@ -7512,7 +9389,8 @@ private static void SLFunctionLiteral_execute_(VirtualFrame $frame, OperationNod return; } - private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -7524,10 +9402,23 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, Node node__ = null; if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET] + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, + $this)); node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * perform + * ( + * TruffleString, + * SLFunction, + * Node) + */); + if ((state_0 & 0b10) == 0b10/* + * is-exact-state_0 perform(TruffleString, + * SLFunction, Node) + */) { $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM); } else { $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); @@ -7541,7 +9432,7 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, return; } } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -7549,7 +9440,8 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, } } - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -7558,7 +9450,20 @@ private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, Operatio private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* + * is + * - + * not + * doBoolean + * ( + * boolean) + * && + * doFallback + * ( + * Object, + * Node, + * int) + */)) { SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -7567,7 +9472,8 @@ private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl } } - private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -7588,7 +9494,8 @@ private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $fra return; } - private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); @@ -7622,7 +9529,8 @@ private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $fra return; } - private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -7632,7 +9540,14 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doBoolean + * ( + * boolean) + */); if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN); } else { @@ -7660,7 +9575,16 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * doFallback + * ( + * Object, + * Node, + * int) + */); $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); int type0; type0 = 0 /* OBJECT */; @@ -7683,15 +9607,29 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera } @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, + Object[] arg1Value) { short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { + if ((state_0 & 0b1110) != 0 /* + * is-state_0 doDirect(SLFunction, Object[], Assumption, + * RootCallTarget, DirectCallNode) || + * doIndirect(SLFunction, Object[], IndirectCallNode) || + * doInterop(Object, Object[], InteropLibrary, Node, + * int) + */) { + if ((state_0 & 0b110) != 0 /* + * is-state_0 doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, DirectCallNode) || + * doIndirect(SLFunction, Object[], IndirectCallNode) + */ && arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); + if ((state_0 & 0b10) != 0 /* + * is-state_0 doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, DirectCallNode) + */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -7704,18 +9642,24 @@ private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $ s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 1]); + if ((state_0 & 0b100) != 0 /* + * is-state_0 doIndirect(SLFunction, Object[], + * IndirectCallNode) + */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1]); if (indirect_callNode__ != null) { return SLInvoke.doIndirect(arg0Value_, arg1Value, indirect_callNode__); } } } - if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b1000) != 0 /* + * is-state_0 doInterop(Object, Object[], + * InteropLibrary, Node, int) + */) { { Node interop_node__ = ($this); int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 2]); + InteropLibrary interop_library__ = ((InteropLibrary) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2]); if (interop_library__ != null) { return SLInvoke.doInterop(arg0Value, arg1Value, interop_library__, interop_node__, interop_bci__); } @@ -7726,7 +9670,8 @@ private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $ return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); } - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, + Object[] arg1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -7737,10 +9682,16 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat short exclude = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1]; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + if ((exclude) == 0 /* + * is-not-exclude doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, DirectCallNode) + */) { int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); + if ((state_0 & 0b10) != 0 /* + * is-state_0 doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, DirectCallNode) + */) { while (s0_ != null) { if ((arg0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { break; @@ -7763,8 +9714,30 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doDirect + * ( + * SLFunction, + * Object + * [ + * ] + * , + * Assumption, + * RootCallTarget, + * DirectCallNode) + */); + if ((state_0 & 0b1110) == 0b10/* + * is-exact-state_0 + * doDirect( + * SLFunction, + * Object[], + * Assumption, + * RootCallTarget, + * DirectCallNode) + */) { $bc[$bci] = (short) (INSTR_C_SL_INVOKE_Q_DIRECT); } else { $bc[$bci] = (short) (INSTR_C_SL_INVOKE); @@ -7780,11 +9753,42 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); } } - $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* + * add + * - + * exclude + * doDirect + * ( + * SLFunction, + * Object + * [ + * ] + * , + * Assumption, + * RootCallTarget, + * DirectCallNode) + */); $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + state_0 = (short) (state_0 & 0xfffffffd /* + * remove-state_0 + * doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, + * DirectCallNode) + */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* + * add + * - + * state_0 + * doIndirect + * ( + * SLFunction, + * Object + * [ + * ] + * , + * IndirectCallNode) + */); $bc[$bci] = (short) (INSTR_C_SL_INVOKE); lock.unlock(); hasLock = false; @@ -7793,10 +9797,24 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat { int interop_bci__ = 0; Node interop_node__ = null; - $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); interop_node__ = ($this); interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* + * add + * - + * state_0 + * doInterop + * ( + * Object, + * Object + * [ + * ] + * , + * InteropLibrary, + * Node, + * int) + */); $bc[$bci] = (short) (INSTR_C_SL_INVOKE); lock.unlock(); hasLock = false; @@ -7816,7 +9834,7 @@ private static void SLInvoke_removeDirect__(VirtualFrame $frame, OperationNodeIm lock.lock(); try { SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_CHILDREN_OFFSET] + 0) + 0]); + SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); while (cur != null) { if (cur == s0_) { if (prev == null) { @@ -7830,14 +9848,29 @@ private static void SLInvoke_removeDirect__(VirtualFrame $frame, OperationNodeIm cur = cur.next_; } if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * doDirect + * ( + * SLFunction, + * Object + * [ + * ] + * , + * Assumption, + * RootCallTarget, + * DirectCallNode) + */); } } finally { lock.unlock(); } } - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value) { if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -7846,7 +9879,20 @@ private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static boolean SLAnd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* + * is + * - + * not + * doBoolean + * ( + * boolean) + * && + * doFallback + * ( + * Object, + * Node, + * int) + */)) { return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); @@ -7898,7 +9944,14 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* + * add + * - + * state_0 + * doBoolean + * ( + * boolean) + */); lock.unlock(); hasLock = false; return SLToBooleanNode.doBoolean($child0Value_); @@ -7908,7 +9961,16 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doFallback + * ( + * Object, + * Node, + * int) + */); lock.unlock(); hasLock = false; return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); @@ -7920,7 +9982,8 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio } } - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value) { if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -7929,7 +9992,20 @@ private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeIm private static boolean SLOr_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* + * is + * - + * not + * doBoolean + * ( + * boolean) + * && + * doFallback + * ( + * Object, + * Node, + * int) + */)) { return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); @@ -7981,7 +10057,14 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, Operation short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* + * add + * - + * state_0 + * doBoolean + * ( + * boolean) + */); lock.unlock(); hasLock = false; return SLToBooleanNode.doBoolean($child0Value_); @@ -7991,7 +10074,16 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, Operation Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* + * add + * - + * state_0 + * doFallback + * ( + * Object, + * Node, + * int) + */); lock.unlock(); hasLock = false; return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); @@ -8026,11 +10118,16 @@ private static void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, OperationNo return; } - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, + Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + if (((state_0 & 0b1000)) == 0 /* + * is-not-state_0 add(Object, Object, + * SLToTruffleStringNode, SLToTruffleStringNode, + * ConcatNode) + */ && (SLAddNode.isString($child0Value, $child1Value))) { return false; } return true; @@ -8073,8 +10170,24 @@ private static void SLAdd_q_AddLong_execute_(VirtualFrame $frame, OperationNodeI Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* + * add + * - + * exclude + * addLong + * ( + * long, + * long) + */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * addLong + * ( + * long, + * long) + */); } finally { lock.unlock(); } @@ -8091,10 +10204,14 @@ private static void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, Object $child1Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + assert (state_0 & 0b1000) != 0 /* + * is-state_0 readSLObject(SLObject, Object, Node, + * int, DynamicObjectLibrary, SLToTruffleStringNode) + */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET] + 0) + 4]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { Node node__ = ($this); @@ -8134,7 +10251,8 @@ private static void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, Operatio return; } - private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + short state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -8164,7 +10282,8 @@ private static void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, Operatio return; } - private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -8205,14 +10324,18 @@ private static void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, O } @ExplodeLoop - private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, + Object[] arg1Value) { short state_0 = $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0]; int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + assert (state_0 & 0b10) != 0 /* + * is-state_0 doDirect(SLFunction, Object[], + * Assumption, RootCallTarget, DirectCallNode) + */; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET] + 0) + 0]); + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -8238,7 +10361,7 @@ private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, Operat lock.lock(); try { SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = $bc[$bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET] + 0) + 0]); + SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0]); while (cur != null) { if (cur == s0_) { if (prev == null) { @@ -8252,7 +10375,21 @@ private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, Operat cur = cur.next_; } if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* + * remove + * - + * state_0 + * doDirect + * ( + * SLFunction, + * Object + * [ + * ] + * , + * Assumption, + * RootCallTarget, + * DirectCallNode) + */); } } finally { lock.unlock(); @@ -8264,12 +10401,14 @@ private static void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, Op Object $child0Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + assert (state_0 & 0b10) != 0 /* + * is-state_0 perform(TruffleString, SLFunction, Node) + */; if ($child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { Node node__ = ($this); - SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = $bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET] + 0) + 0]); + SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0) + 0]); if (result__ != null) { $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); return; @@ -8290,10 +10429,14 @@ private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $fram Object $child2Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + assert (state_0 & 0b1000) != 0 /* + * is-state_0 writeSLObject(SLObject, Object, Object, + * DynamicObjectLibrary, SLToTruffleStringNode) + */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = $bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET] + 0) + 4]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, + $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); @@ -8308,7 +10451,8 @@ private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $fram return; } - private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -8350,14 +10494,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } if (localTag == 1 /* LONG */ && value instanceof Long) { frame.setLong(localIdx, (long) value); return 1 /* LONG */; } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -8391,6 +10535,7 @@ T insertAccessor(T node) { } } + private static final class SLEqual_Generic0Data extends Node { @Child SLEqual_Generic0Data next_; @@ -8411,6 +10556,7 @@ T insertAccessor(T node) { } } + private static final class SLReadProperty_ReadArray0Data extends Node { @Child SLReadProperty_ReadArray0Data next_; @@ -8431,6 +10577,7 @@ T insertAccessor(T node) { } } + private static final class SLReadProperty_ReadSLObject0Data extends Node { @Child SLReadProperty_ReadSLObject0Data next_; @@ -8451,6 +10598,7 @@ T insertAccessor(T node) { } } + private static final class SLReadProperty_ReadObject0Data extends Node { @Child SLReadProperty_ReadObject0Data next_; @@ -8471,6 +10619,7 @@ T insertAccessor(T node) { } } + private static final class SLWriteProperty_WriteArray0Data extends Node { @Child SLWriteProperty_WriteArray0Data next_; @@ -8491,6 +10640,7 @@ T insertAccessor(T node) { } } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { @Child SLWriteProperty_WriteSLObject0Data next_; @@ -8511,6 +10661,7 @@ T insertAccessor(T node) { } } + private static final class SLWriteProperty_WriteObject0Data extends Node { @Child SLWriteProperty_WriteObject0Data next_; @@ -8531,6 +10682,7 @@ T insertAccessor(T node) { } } + private static final class SLUnbox_FromForeign0Data extends Node { @Child SLUnbox_FromForeign0Data next_; @@ -8550,6 +10702,7 @@ T insertAccessor(T node) { } } + @GeneratedBy(SLOperations.class) private static final class SLInvoke_DirectData extends Node { @@ -8573,7 +10726,2669 @@ T insertAccessor(T node) { } } - } + + @GeneratedBy(SLOperations.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, + int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + int uncachedExecuteCount = $this.uncachedExecuteCount; + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + short curOpcode = unsafeFromBytecode($bc, $bci); + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + if ($sp < maxLocals) { + throw CompilerDirectives.shouldNotReachHere("stack underflow"); + } + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_POP: { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + continue loop; + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Boxing Elimination: Do Nothing + case INSTR_BRANCH: { + int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; + if (targetBci <= $bci) { + TruffleSafepoint.poll($this); + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + } + uncachedExecuteCount++; + if (uncachedExecuteCount > 16) { + $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + // Boxing Elimination: Do Nothing + case INSTR_BRANCH_FALSE: { + boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_THROW: { + int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; + throw (AbstractTruffleException) $frame.getObject(slot); + } + // load.constant.object + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_OBJECT: { + $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + continue loop; + } + // load.argument.object + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT: { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + continue loop; + } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG: { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + continue loop; + } + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN: { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + continue loop; + } + // store.local.uninit + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_LONG + // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN + case INSTR_STORE_LOCAL_UNINIT: { + int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; + int sourceSlot = $sp - 1; + $frame.copyObject(sourceSlot, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + continue loop; + } + // load.local.uninit + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_LONG + // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN + case INSTR_LOAD_LOCAL_UNINIT: { + int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; + $frame.setObject($sp, expectObject($frame, localIdx)); + $sp++; + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + continue loop; + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_RETURN: { + uncachedExecuteCount++; + if (uncachedExecuteCount > 16) { + $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); + } + return (($sp - 1) << 16) | 0xffff; + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static + // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, + // java.lang.Object, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, + // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = + // [Guard[(SLAddNode.isString(left, right))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f1a38a + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@375dedc + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@35cc264b + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1d4a35d2 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD: { + UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_ADD_LENGTH; + continue loop; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5119e3c8 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16b0a9c1 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e2d136 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@24dc4ee8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_DIV: { + UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_DIV_LENGTH; + continue loop; + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0, method = public static + // boolean doGeneric(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(leftInterop.accepts(left))], + // Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, + // java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@18d3b56e + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@357d1b96 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7076da46 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c5e853f + // Boxing Elimination: Bit Mask + case INSTR_C_SL_EQUAL: { + UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_EQUAL_LENGTH; + continue loop; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2b64a952 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@58d188e3 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL: { + UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + continue loop; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3809e35e + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1e3c361f + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN: { + UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + continue loop; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d7459f4 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@58de6b74 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LOGICAL_NOT: { + UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); + $sp = $sp - 1 + 1; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + continue loop; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@60885467 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e284f1d + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10617a2d + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44a37e52 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_MUL: { + UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_MUL_LENGTH; + continue loop; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static + // java.lang.Object readArray(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static + // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static + // java.lang.Object readObject(java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objects.accepts(receiver))], + // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], + // Guard[(objects.hasMembers(receiver))]], signature = + // [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@194c5295 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@66803b1 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b503417 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fe7dc2 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY: { + UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + continue loop; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24614477 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@89db741 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b55dde2 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@545b6334 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_SUB: { + UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); + $sp = $sp - 2 + 1; + $bci = $bci + C_SL_SUB_LENGTH; + continue loop; + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static + // java.lang.Object writeArray(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], + // Guard[(arrays.hasArrayElements(receiver))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static + // java.lang.Object + // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, + // java.lang.Object, java.lang.Object, + // com.oracle.truffle.api.object.DynamicObjectLibrary, + // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))]], signature = + // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, + // java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static + // java.lang.Object writeObject(java.lang.Object, java.lang.Object, + // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, + // com.oracle.truffle.api.interop.InteropLibrary, + // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = + // [Guard[(objectLibrary.accepts(receiver))], + // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = + // [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73be843d + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@358d7470 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e111524 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@de27549 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY: { + UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 3), $frame.getObject($sp - 2), + $frame.getObject($sp - 1)); + $sp = $sp - 3 + 1; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + continue loop; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static + // java.lang.Object fromForeign(java.lang.Object, + // com.oracle.truffle.api.interop.InteropLibrary) , guards = + // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1be1cc4a + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ea357c8 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28fd03da + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27309732 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX: { + UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); + $sp = $sp - 1 + 1; + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79bbab4d + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@41ee1ec5 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL: { + UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); + $sp = $sp - 1 + 1; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + continue loop; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@27cb6efe + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5fb8638c + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN: { + UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); + $sp = $sp - 1 + 1; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + continue loop; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static + // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, + // java.lang.Object[], com.oracle.truffle.api.Assumption, + // com.oracle.truffle.api.RootCallTarget, + // com.oracle.truffle.api.nodes.DirectCallNode) , guards = + // [Guard[(function.getCallTarget() == cachedTarget)]], signature = + // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@325d65d1 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56247945 + // [ 2] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f1b5872 + // [ 3] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c31d5a4 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE: { + int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; + Object input_0 = $frame.getObject($sp - numVariadics - 1); + Object[] input_1 = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); + } + Object result = UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); + $sp = $sp - 1 - numVariadics + 1; + $frame.setObject($sp - 1, result); + $bci = $bci + C_SL_INVOKE_LENGTH; + continue loop; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e1410f + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d18ecd1 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_AND: { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ea17d33 + // [ 1] + // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11205afd + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_OR: { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0]; + continue loop; + } + } + default: + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) + continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch (unsafeFromBytecode($bc, $bci)) { + case INSTR_POP: { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH: { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE: { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW: { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_OBJECT: { + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_LONG: { + $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN: { + $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT: { + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_LONG: { + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN: { + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_OBJECT: { + $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_LONG: { + $bci = $bci + STORE_LOCAL_LONG_LENGTH; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN: { + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_UNINIT: { + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_OBJECT: { + $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_LONG: { + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN: { + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_UNINIT: { + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_RETURN: { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_C_SL_ADD: { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV: { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL: { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL: { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN: { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT: { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL: { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY: { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB: { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY: { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX: { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL: { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN: { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE: { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND: { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR: { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG: { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT: { + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + break; + } + } + } + } + + @Override + String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + StringBuilder sb = new StringBuilder(); + while ($bci < $bc.length) { + sb.append(String.format(" [%04x]", $bci)); + switch (unsafeFromBytecode($bc, $bci)) { + default: { + sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); + break; + } + case INSTR_POP: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("pop "); + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch "); + sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch.false "); + sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("throw "); + sb.append(String.format(" local(%s)", $bc[$bci + THROW_LOCALS_OFFSET + 0])); + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_OBJECT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.object "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_OBJECT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.object "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_OBJECT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.object "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; + break; + } + case INSTR_STORE_LOCAL_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_STORE_LOCAL_UNINIT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.uninit "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_OBJECT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.object "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_UNINIT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.uninit "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; + break; + } + case INSTR_RETURN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_C_SL_ADD: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLAdd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLDiv "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLEqual "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLMul "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLReadProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLSub "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(String.format(" %04x", $bc[$bci + 8])); + sb.append("c.SLWriteProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLUnbox "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLInvoke "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("sc.SLAnd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_AND_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("sc.SLOr "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_OR_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0])); + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLAdd.q.AddLong "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLReadProperty.q.ReadSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBoolean "); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append("c.SLInvoke.q.Direct "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral.q.Perform "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(String.format(" %04x", $bc[$bci + 8])); + sb.append("c.SLWriteProperty.q.WriteSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1] & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan0 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] & 0xff))); + sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < $handlers.length; i++) { + sb.append($handlers[i] + "\n"); + } + return sb.toString(); + } + + private static void SLAdd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); + return; + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + $frame.setObject($sp - 2, + SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); + return; + } + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLDiv_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); + return; + } + } + $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + boolean value = SLEqualNode.doString($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not-state_0 + * RESULT-UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + + private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is- + * not- + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is- + * not- + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLLogicalNot_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLLogicalNotNode.doBoolean($child0Value_); + if ((($bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, ($this), ($bci))); + return; + } + + private static void SLMul_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); + return; + } + } + $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLReadProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (INTEROP_LIBRARY_.getUncached($child1Value)))); + return; + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), + (SLToTruffleStringNodeGen.getUncached()))); + return; + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + $frame.setObject($sp - 2, + SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } + + private static void SLSub_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); + return; + } + } + $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLWriteProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value, Object $child2Value) { + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (INTEROP_LIBRARY_.getUncached($child1Value)))); + return; + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), + (SLToTruffleStringNodeGen.getUncached()))); + return; + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (SLToMemberNodeGen.getUncached()))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } + + private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + long value = SLUnboxNode.fromLong($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); + return; + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); + return; + } + + private static void SLFunctionLiteral_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); + } + + private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is-not- + * state_0 + * RESULT- + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, + Object[] arg1Value) { + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop(arg0Value, arg1Value, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + long value = SLUnboxNode.fromLong($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); + return; + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); + return; + } + + private static void SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, + Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); + return; + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + $frame.setObject($sp - 2, + SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); + return; + } + $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static void SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (INTEROP_LIBRARY_.getUncached($child1Value)))); + return; + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), + (SLToTruffleStringNodeGen.getUncached()))); + return; + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + $frame.setObject($sp - 2, + SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } + + private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); + return; + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); + return; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLUnboxNode.fromBoolean($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + long value = SLUnboxNode.fromLong($child0Value_); + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setLong($sp - 1, value); + } + return; + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); + return; + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); + return; + } + $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); + return; + } + + private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + boolean value = SLToBooleanNode.doBoolean($child0Value_); + if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 1, value); + } else { + $frame.setBoolean($sp - 1, value); + } + return; + } + + private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, + Object[] arg1Value) { + if (arg0Value instanceof SLFunction) { + SLFunction arg0Value_ = (SLFunction) arg0Value; + return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop(arg0Value, arg1Value, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static void SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value) { + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); + } + + private static void SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value, Object $child2Value) { + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (INTEROP_LIBRARY_.getUncached($child1Value)))); + return; + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), + (SLToTruffleStringNodeGen.getUncached()))); + return; + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), + (SLToMemberNodeGen.getUncached()))); + return; + } + throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + } + + private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, + Object $child0Value, Object $child1Value) { + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); + if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* + * is + * - + * not + * - + * state_0 + * RESULT + * - + * UNBOXED + */) { + $frame.setObject($sp - 2, value); + } else { + $frame.setBoolean($sp - 2, value); + } + return; + } + } + $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci))); + return; + } + + private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { + Object value = frame.getValue(sourceSlot); + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } + frame.setObject(localIdx, value); + return 0 /* OBJECT */; + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + + @GeneratedBy(SLOperations.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + } + private static final class Counter { public int count; diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index a41362798d12..63fa33af9673 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -366,7 +366,7 @@ public void copy(int srcSlot, int destSlot) { @Override public void copyObject(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); - assert tag == OBJECT_TAG : "copyObject must be used with Object slots"; + assert tag == OBJECT_TAG : "copyObject must be used with Object slots, not " + FrameSlotKind.fromTag(tag); Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); verifyIndexedSet(destSlot, tag); unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); @@ -378,7 +378,7 @@ public void copyObject(int srcSlot, int destSlot) { @Override public void copyPrimitive(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); - assert tag != OBJECT_TAG : "copyObject must be used with non-Object slots"; + assert tag != OBJECT_TAG : "copyPrimitive must be used with non-Object slots"; long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); verifyIndexedSet(destSlot, tag); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index f2b2eb8ce2b7..09548a2b83d8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -54,4 +54,6 @@ public class OperationGeneratorFlags { public static final boolean ENABLE_INSTRUMENTATION = false; public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; + public static final boolean USE_UNSAFE = false; + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index ada7e373f94f..52befc14ea6e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -106,7 +106,7 @@ public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElemen } public static CodeTree createReadOpcode(CodeTree bc, CodeTree bci) { - return CodeTreeBuilder.createBuilder().tree(bc).string("[").tree(bci).string("]").build(); + return CodeTreeBuilder.createBuilder().startCall("unsafeFromBytecode").tree(bc).tree(bci).end().build(); } public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElement bci) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index ab785e20c0fc..db8f57a1dc4c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -93,18 +93,20 @@ public class OperationsBytecodeCodeGenerator { private final CodeTypeElement typBuilderImpl; private final OperationsData m; private final boolean withInstrumentation; + private final boolean isUncached; private final CodeTypeElement baseClass; private final CodeTypeElement opNodeImpl; private final CodeTypeElement typExceptionHandler; public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, - boolean withInstrumentation) { + boolean withInstrumentation, boolean isUncached) { this.typBuilderImpl = typBuilderImpl; this.baseClass = baseClass; this.opNodeImpl = opNodeImpl; this.typExceptionHandler = typExceptionHandler; this.m = m; this.withInstrumentation = withInstrumentation; + this.isUncached = isUncached; } /** @@ -112,7 +114,7 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, CodeTypeE * executable Truffle node. */ public CodeTypeElement createBuilderBytecodeNode() { - String namePrefix = withInstrumentation ? "Instrumentable" : ""; + String namePrefix = withInstrumentation ? "Instrumentable" : isUncached ? "Uncached" : ""; CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", baseClass.asType()); @@ -255,6 +257,10 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); b.declaration("Counter", "loopCounter", "new Counter()"); + if (isUncached) { + b.declaration("int", "uncachedExecuteCount", "$this.uncachedExecuteCount"); + } + CodeVariableElement varTracer; if (m.isTracing()) { @@ -296,6 +302,10 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { continue; } + if (op.neverInUncached() && isUncached) { + continue; + } + for (String line : op.dumpInfo().split("\n")) { b.lineComment(line); } @@ -310,7 +320,11 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(2); } - b.tree(op.createExecuteCode(vars)); + if (isUncached) { + b.tree(op.createExecuteUncachedCode(vars)); + } else { + b.tree(op.createExecuteCode(vars)); + } if (!op.isBranchInstruction()) { b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); @@ -325,7 +339,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.caseDefault().startCaseBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered")); + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \"")); b.end(); b.end(); // switch block @@ -408,24 +422,47 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr plugs.finishUp(); CodeTypeElement result = resultList.get(0); - CodeExecutableElement uncExec = null; + CodeExecutableElement executeMethod = null; List execs = new ArrayList<>(); - for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { + + TypeElement target = result; + + if (isUncached) { + target = (TypeElement) result.getEnclosedElements().stream().filter(x -> x.getSimpleName().toString().equals("Uncached")).findFirst().get(); + } + + Set copiedMethod = new HashSet<>(); + + for (ExecutableElement ex : ElementFilter.methodsIn(target.getEnclosedElements())) { if (!methodNames.contains(ex.getSimpleName().toString())) { continue; } - if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName("execute"))) { - uncExec = (CodeExecutableElement) ex; + if (copiedMethod.contains(ex.getSimpleName().toString())) { + continue; + } + + String targetName = isUncached ? "executeUncached" : "execute"; + String otherTargetName = !isUncached ? "executeUncached" : "execute"; + + if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName(targetName))) { + executeMethod = (CodeExecutableElement) ex; + } + + if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName(otherTargetName))) { + continue; } execs.add((CodeExecutableElement) ex); + copiedMethod.add(ex.getSimpleName().toString()); } - if (uncExec == null) { + if (executeMethod == null) { throw new AssertionError(String.format("execute method not found in: %s", result.getSimpleName())); } + executeMethod.getAnnotationMirrors().removeIf(x -> ElementUtils.typeEquals(x.getAnnotationType(), types.CompilerDirectives_TruffleBoundary)); + for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { if (!innerTypeNames.contains(te.getSimpleName().toString())) { continue; @@ -440,7 +477,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); String exName = exToCopy.getSimpleName().toString(); - boolean isExecute = exName.contains("_execute_"); + boolean isExecute = exName.contains("_execute_") || exName.contains("_executeUncached_"); boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); @@ -489,7 +526,11 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr } } - cinstr.setExecuteMethod(uncExec); + if (isUncached) { + cinstr.setUncachedExecuteMethod(executeMethod); + } else { + cinstr.setExecuteMethod(executeMethod); + } cinstr.setPrepareAOTMethod(metPrepareForAOT); if (m.isTracing()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 1fe5fdc9320f..f853f4294d82 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -71,6 +71,8 @@ import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import sun.misc.Unsafe; + public class OperationsCodeGenerator extends CodeTypeElementFactory { private ProcessorContext context; @@ -167,6 +169,20 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLabel, "createLabel")); typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationNode, "publish")); + // unsafe stuff + if (OperationGeneratorFlags.USE_UNSAFE) { + typBuilder.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(Unsafe.class), "theUnsafe")).setInit(CodeTreeBuilder.singleString("Unsafe.getUnsafe()")); + } + CodeExecutableElement metUnsafeFromBytecode = typBuilder.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode")); + metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(int.class), "index")); + + if (OperationGeneratorFlags.USE_UNSAFE) { + metUnsafeFromBytecode.createBuilder().startReturn().string("theUnsafe.getShort(bc, Unsafe.ARRAY_SHORT_BASE_OFFSET + index * Unsafe.ARRAY_SHORT_INDEX_SCALE)").end(); + } else { + metUnsafeFromBytecode.createBuilder().startReturn().string("bc[index]").end(); + } + CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder, opNodesImpl); typBuilder.add(typBuilderImpl); @@ -241,6 +257,8 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "uncachedExecuteCount"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); if (!m.getMetadatas().isEmpty()) { @@ -267,8 +285,12 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp } } + if (m.isGenerateUncached()) { + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCACHED_EXECUTE = new UncachedBytecodeNode()")); + } typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new BytecodeNode()")); - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = COMMON_EXECUTE")); + + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = " + (m.isGenerateUncached() ? "UNCACHED_EXECUTE" : "COMMON_EXECUTE"))); typOperationNodeImpl.add(createNodeImplExecuteAt()); @@ -309,9 +331,24 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(createNodeImplDeepCopy(typOperationNodeImpl)); typOperationNodeImpl.add(createNodeImplCopy(typOperationNodeImpl)); + typOperationNodeImpl.add(createChangeInterpreter(typBytecodeBase)); + return typOperationNodeImpl; } + private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) { + CodeExecutableElement met = new CodeExecutableElement(context.getType(void.class), "changeInterpreters"); + met.addParameter(new CodeVariableElement(loopBase.asType(), "impl")); + + CodeTreeBuilder b = met.createBuilder(); + + // todo: everything here + + b.statement("this.switchImpl = impl"); + + return met; + } + private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperationNodeImpl) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "deepCopy"); CodeTreeBuilder b = met.createBuilder(); @@ -547,14 +584,23 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typOperationNodeImpl.add(fldSwitchImpl); CodeTypeElement builderBytecodeNodeType; + CodeTypeElement builderUncachedBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typBuilderImpl.add(builderBytecodeNodeType); + if (m.isGenerateUncached()) { + builderUncachedBytecodeNodeType = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false, + true).createBuilderBytecodeNode(); + typBuilderImpl.add(builderUncachedBytecodeNodeType); + } else { + builderUncachedBytecodeNodeType = null; + } + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, true); + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, true, false); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typBuilderImpl.add(builderInstrBytecodeNodeType); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 2eaa3bcc843c..c3097c68ccdc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -70,6 +70,9 @@ public class OperationsData extends Template { private TypeSystemData typeSystem; private final Set boxingEliminatedTypes = new HashSet<>(); + private boolean isGenerateAOT; + private boolean isGenerateUncached; + private int numTosSlots; public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { @@ -144,6 +147,14 @@ public boolean isGenerateAOT() { return true; } + public void setGenerateUncached(boolean value) { + isGenerateUncached = true; + } + + public boolean isGenerateUncached() { + return isGenerateUncached; + } + public void setDecisions(OperationDecisions decisions) { this.decisions = decisions; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 2e3e88d0c0f7..66a4638baab6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -104,6 +104,12 @@ protected OperationsData parse(Element element, List mirror) { } } + // find @GenerateUncached + AnnotationMirror generateUncachedMirror = ElementUtils.findAnnotationMirror(typeElement, types.GenerateUncached); + if (generateUncachedMirror != null) { + data.setGenerateUncached(true); + } + // find and bind type system AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); if (typeSystemRefMirror != null) { @@ -152,8 +158,6 @@ protected OperationsData parse(Element element, List mirror) { } data.addOperationData(opData); - opData.redirectMessages(data); - opData.redirectMessagesOnGeneratedElements(data); } // find and bind all inner declared operations @@ -183,8 +187,6 @@ protected OperationsData parse(Element element, List mirror) { } data.addOperationData(opData); - opData.redirectMessages(data); - opData.redirectMessagesOnGeneratedElements(data); opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 85e6fa1fec5c..15f8632c00be 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -236,17 +236,21 @@ protected SingleOperationData parse(Element element, List mirr // remove all non-static or private elements // this includes all the execute methods ct.getEnclosedElements().removeIf(e -> !e.getModifiers().contains(Modifier.STATIC) || e.getModifiers().contains(Modifier.PRIVATE)); - - if (!isVariadic) { - addBoxingEliminationNodeChildAnnotations(props, ct); - } - }); if (proxyMirror == null || isShortCircuit) { clonedType.setSuperClass(types.Node); } + if (!isVariadic) { + addBoxingEliminationNodeChildAnnotations(props, clonedType); + } + + if (parentData.isGenerateUncached()) { + clonedType.getAnnotationMirrors().add(new CodeAnnotationMirror(types.GenerateUncached)); + clonedType.add(createExecuteUncachedMethod(props)); + } + clonedType.add(createExecuteMethod(props, isVariadic)); NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); @@ -256,14 +260,14 @@ protected SingleOperationData parse(Element element, List mirr return data; } + nodeData.redirectMessagesOnGeneratedElements(data); + data.setNodeData(nodeData); + // replace the default node type system with Operations one if we have it if (nodeData.getTypeSystem().isDefault() && parentData.getTypeSystem() != null) { nodeData.setTypeSystem(parentData.getTypeSystem()); } - nodeData.redirectMessagesOnGeneratedElements(data); - data.setNodeData(nodeData); - return data; } @@ -309,15 +313,24 @@ private CodeExecutableElement createExecuteMethod(MethodProperties props, boolea Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), context.getType(resType), "execute"); - metExecute.addParameter(new CodeVariableElement(types.Frame, "frame")); + metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); if (isVariadic) { int i = 0; for (ParameterKind param : props.parameters) { - if (param == ParameterKind.STACK_VALUE) { - metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); - } else if (param == ParameterKind.VARIADIC) { - metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); + switch (param) { + case STACK_VALUE: + metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); + break; + case VARIADIC: + metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); + break; + case LOCAL_SETTER: + case LOCAL_SETTER_ARRAY: + case VIRTUAL_FRAME: + break; + default: + throw new UnsupportedOperationException("" + param); } i++; } @@ -325,6 +338,44 @@ private CodeExecutableElement createExecuteMethod(MethodProperties props, boolea return metExecute; } + private CodeExecutableElement createExecuteUncachedMethod(MethodProperties props) { + + Class resType; + if (isShortCircuit) { + resType = boolean.class; + } else if (props.returnsValue) { + resType = Object.class; + } else { + resType = void.class; + } + CodeExecutableElement metExecute = new CodeExecutableElement( + Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), + context.getType(resType), "executeUncached"); + + metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + + int i = 0; + for (ParameterKind param : props.parameters) { + switch (param) { + case STACK_VALUE: + metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); + break; + case VARIADIC: + metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); + break; + case LOCAL_SETTER: + case LOCAL_SETTER_ARRAY: + case VIRTUAL_FRAME: + break; + default: + throw new UnsupportedOperationException("" + param); + } + i++; + } + + return metExecute; + } + @Override public DeclaredType getAnnotationType() { return types.Operation; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 14346a3ef423..0366fa354f46 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -68,11 +68,20 @@ public BranchInstruction(int id) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + return createExecuteImpl(vars, false); + } + + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + return createExecuteImpl(vars, true); + } + + private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0)); - if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR) { + if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR || uncached) { b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { if (SAFEPOINT_POLL) { @@ -118,6 +127,17 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); // } } + + if (uncached) { + b.statement("uncachedExecuteCount++"); + b.startIf().string("uncachedExecuteCount > 16").end().startBlock(); + + b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); + b.statement("return ($sp << 16) | targetBci"); + + b.end(); + } + b.end(); // } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index c67c43521789..2c5ba6cf9e2c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -41,14 +41,10 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { @@ -74,15 +70,8 @@ public boolean isBranchInstruction() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // b.declaration(typeConditionProfile, "profile", - // CodeTreeBuilder.createBuilder().string("conditionProfiles[").tree(createBranchProfileIndex(vars, - // 0)).string("]")); - // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) - TypeSystemData data = ctx.getData().getTypeSystem(); - CodeTree conditionCode = TypeSystemCodeGenerator.cast(data, new CodeTypeMirror(TypeKind.BOOLEAN), CodeTreeBuilder.singleString("$frame.getObject($sp - 1)")); - - b.declaration("boolean", "cond", conditionCode); + b.declaration("boolean", "cond", "$frame.getObject($sp - 1) == Boolean.TRUE"); b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 59232e76c3b4..e3f9287d8f39 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -60,6 +60,7 @@ public class CustomInstruction extends Instruction { private final SingleOperationData data; protected ExecutableElement executeMethod; + protected ExecutableElement uncachedExecuteMethod; private OperationsBytecodeNodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; private CodeExecutableElement getSpecializationBits; @@ -126,10 +127,21 @@ protected CustomInstruction(String name, int id, SingleOperationData data, int p @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + return createExecuteImpl(vars, false); + } + + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + return createExecuteImpl(vars, true); + } + + private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); createTracerCode(vars, b); + ExecutableElement method = uncached ? uncachedExecuteMethod : executeMethod; + if (data.getMainProperties().isVariadic) { b.declaration("int", "numVariadics", createVariadicIndex(vars)); @@ -165,7 +177,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement(); } - b.startStaticCall(executeMethod); + b.startStaticCall(method); b.variable(vars.frame); b.string("$this"); b.variable(vars.bc); @@ -187,7 +199,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } else { b.startStatement(); - b.startStaticCall(executeMethod); + b.startStaticCall(method); b.variable(vars.frame); b.string("$this"); b.variable(vars.bc); @@ -195,6 +207,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.sp); b.variable(vars.consts); b.variable(vars.children); + + if (uncached) { + for (int i = numPopStatic(); i > 0; i--) { + b.string("$frame.getObject($sp - " + i + ")"); + } + } + b.end(2); b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues).end(); @@ -296,4 +315,8 @@ public void addQuickenedVariant(QuickenedInstruction quick) { public List getQuickenedVariants() { return quickenedVariants; } + + public void setUncachedExecuteMethod(ExecutableElement uncachedExecuteMethod) { + this.uncachedExecuteMethod = uncachedExecuteMethod; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 10a3b4afe956..68a48c19d0e5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -262,10 +262,19 @@ private int length() { } private CodeTree createIndirectIndex(ExecutionVariables vars, String suffix, int index) { - return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + internalName + suffix + "] + " + index).build(); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startCall("unsafeFromBytecode"); + b.variable(vars.bc); + b.startGroup().variable(vars.bci).string(" + " + internalName + suffix).end(); + b.end(); + b.string(" + " + index); + + return b.build(); } private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int index) { + // this should also become unsafe based, but we need to separate out reads and writes return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + internalName + suffix + " + " + index + "]").build(); } @@ -515,6 +524,14 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) public abstract CodeTree createExecuteCode(ExecutionVariables vars); + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + return createExecuteCode(vars); + } + + public boolean neverInUncached() { + return false; + } + @SuppressWarnings("unused") protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index b03f7587c627..7c9cca188b37 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -111,4 +111,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField); } + + @Override + public boolean neverInUncached() { + return kind != FrameKind.OBJECT; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 9a9d8385c30a..656f54e80907 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -236,4 +236,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } + @Override + public boolean neverInUncached() { + return kind != null; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index ab0d3ad2a9e8..5376d748c410 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -156,4 +156,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public void addQuickenedVariant(QuickenedInstruction quick) { throw new AssertionError("should not add quickened variants to quickened instructions"); } + + @Override + public boolean neverInUncached() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index fc9aee7608f7..946a3d20f34e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -62,6 +62,10 @@ public boolean isBranchInstruction() { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + return createExecuteImpl(vars, false); + } + + private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (ctx.getData().isTracing()) { @@ -70,11 +74,23 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); } + if (uncached) { + b.statement("uncachedExecuteCount++"); + b.startIf().string("uncachedExecuteCount > 16").end().startBlock(); + b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); + b.end(); + } + b.startReturn().string("((").variable(vars.sp).string(" - 1) << 16) | 0xffff").end(); return b.build(); } + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + return createExecuteImpl(vars, true); + } + @Override public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arguments) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 2d22442d821e..e9cd3436ce19 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -93,6 +93,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + return createExecuteCode(vars); + } + @Override public boolean isBranchInstruction() { return true; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index b4e15a6d65ba..766f3c4acf71 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -194,6 +194,27 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (kind != null) { + throw new AssertionError("only store.local.uninit should appear uncached"); + } + + b.startAssign("int localIdx"); + b.tree(createLocalIndex(vars, 0)); + b.end(); + + b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); + + createCopyObject(vars, b); + + b.startStatement().variable(vars.sp).string("--").end(); + + return b.build(); + } + private static final boolean USE_SPEC_FRAME_COPY = true; private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { @@ -266,4 +287,9 @@ public CodeVariableElement boxingEliminationReplacement(FrameKind newKind) { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public boolean neverInUncached() { + return kind != null; + } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java index 6c885c2f640c..39af818ac69a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLFunctionLiteralNode.java @@ -68,7 +68,7 @@ public abstract class SLFunctionLiteralNode extends SLExpressionNode { @Specialization public static SLFunction perform( TruffleString functionName, - @Cached("lookupFunctionCached(functionName, this)") SLFunction result, + @Cached(value = "lookupFunctionCached(functionName, this)", uncached = "lookupFunction(functionName, this)") SLFunction result, @Bind("this") Node node) { if (result == null) { return lookupFunction(functionName, node); @@ -78,7 +78,7 @@ public static SLFunction perform( } } - private static SLFunction lookupFunction(TruffleString functionName, Node node) { + public static SLFunction lookupFunction(TruffleString functionName, Node node) { return SLContext.get(node).getFunctionRegistry().lookup(functionName, true); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java index 8aae93e00450..bf65d4f424f5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.interop.ArityException; @@ -81,6 +82,7 @@ import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) +@GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @OperationProxy(SLDivNode.class) From 70003da8992110a91afc3a19adabb1ebba9dc7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 19 Jul 2022 12:14:54 +0200 Subject: [PATCH 112/312] [wip] --- .../sl/operations/SLOperationsBuilder.java | 5939 +++++------------ .../test/example/TestOperations.java | 4 +- .../generator/FlatNodeGenFactory.java | 4 + .../operations/SingleOperationParser.java | 15 +- .../instructions/CustomInstruction.java | 26 +- 5 files changed, 1866 insertions(+), 4122 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 18d8eb8e6155..9a5678dc550f 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -248,7 +248,6 @@ void setNodes(OperationNode[] nodes) { } } - @GeneratedBy(SLOperations.class) private static class BuilderImpl extends SLOperationsBuilder { @@ -510,60 +509,20 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET = 4; static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 6; private static final short[][] BOXING_DESCRIPTORS = { - // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, - INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, - INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, - // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, - INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, - (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, - (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, - // INT - null, - // DOUBLE - null, - // FLOAT - null, - // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, - INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, - (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, - (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), - (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), - (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, - // BYTE - null}; + // OBJECT + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // LONG + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // INT + null, + // DOUBLE + null, + // FLOAT + null, + // BOOLEAN + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + // BYTE + null}; private final OperationNodesImpl nodes; private final boolean isReparse; @@ -661,8 +620,7 @@ private void doLeaveFinallyTry(BuilderOperationData opData) { for (LabelFill fill : context.handlerLabelFills) { labelFills.add(fill.offset(bci)); } - if (maxStack < curStack + context.handlerMaxStack) - maxStack = curStack + context.handlerMaxStack; + if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; bci += context.handlerBc.length; } @@ -691,11 +649,9 @@ private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData cur = cur.parent; if (toData == null && cur == null) { break; - } else if (toData != null && cur.depth <= toData.depth) - break; + } else if (toData != null && cur.depth <= toData.depth) break; } - if (cur != toData) - throw new UnsupportedOperationException("illegal jump to non-parent operation"); + if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); } private void calculateLeaves(BuilderOperationData fromData) { @@ -794,15 +750,18 @@ private void labelPass(BuilderFinallyTryContext finallyTry) { private void doLeaveOperation(BuilderOperationData data) { switch (data.operationId) { - case OP_FINALLY_TRY: { + case OP_FINALLY_TRY : + { doLeaveFinallyTry(data); break; } - case OP_FINALLY_TRY_NO_EXCEPT: { + case OP_FINALLY_TRY_NO_EXCEPT : + { doLeaveFinallyTry(data); break; } - case OP_TAG: { + case OP_TAG : + { break; } } @@ -812,7 +771,8 @@ private void doLeaveOperation(BuilderOperationData data) { void doBeforeChild() { int childIndex = operationData.numChildren; switch (operationData.operationId) { - case OP_BLOCK: { + case OP_BLOCK : + { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -822,14 +782,16 @@ void doBeforeChild() { } break; } - case OP_TRY_CATCH: { + case OP_TRY_CATCH : + { if (childIndex == 1) { curStack = ((ExceptionHandler) operationData.aux[0]).startStack; ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; } break; } - case OP_SOURCE: { + case OP_SOURCE : + { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -839,7 +801,8 @@ void doBeforeChild() { } break; } - case OP_SOURCE_SECTION: { + case OP_SOURCE_SECTION : + { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -849,7 +812,8 @@ void doBeforeChild() { } break; } - case OP_TAG: { + case OP_TAG : + { if (childIndex != 0) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); @@ -859,7 +823,8 @@ void doBeforeChild() { } break; } - case OP_SL_AND: { + case OP_SL_AND : + { if (childIndex > 0) { int[] predecessorBcis = doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_SC_SL_AND); @@ -876,7 +841,8 @@ void doBeforeChild() { } break; } - case OP_SL_OR: { + case OP_SL_OR : + { if (childIndex > 0) { int[] predecessorBcis = doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_SC_SL_OR); @@ -900,7 +866,8 @@ void doBeforeChild() { void doAfterChild() { int childIndex = operationData.numChildren++; switch (operationData.operationId) { - case OP_IF_THEN: { + case OP_IF_THEN : + { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -921,7 +888,8 @@ void doAfterChild() { } break; } - case OP_IF_THEN_ELSE: { + case OP_IF_THEN_ELSE : + { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); @@ -956,7 +924,8 @@ void doAfterChild() { } break; } - case OP_CONDITIONAL: { + case OP_CONDITIONAL : + { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); @@ -983,7 +952,8 @@ void doAfterChild() { } break; } - case OP_WHILE: { + case OP_WHILE : + { if (childIndex == 0) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -1009,7 +979,8 @@ void doAfterChild() { } break; } - case OP_TRY_CATCH: { + case OP_TRY_CATCH : + { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -1026,7 +997,8 @@ void doAfterChild() { } break; } - case OP_FINALLY_TRY: { + case OP_FINALLY_TRY : + { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -1054,7 +1026,8 @@ void doAfterChild() { } break; } - case OP_FINALLY_TRY_NO_EXCEPT: { + case OP_FINALLY_TRY_NO_EXCEPT : + { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false); bc[bci] = (short) (INSTR_POP); @@ -2110,7 +2083,7 @@ private static final class BuilderOperationData { final Object[] aux; int numChildren; - private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object... arguments) { + private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { this.parent = parent; this.operationId = operationId; this.stackDepth = stackDepth; @@ -2121,7 +2094,6 @@ private BuilderOperationData(BuilderOperationData parent, int operationId, int s } } - @GeneratedBy(SLOperations.class) private static final class OperationLabelImpl extends OperationLabel { @@ -2147,7 +2119,6 @@ boolean belongsTo(BuilderFinallyTryContext context) { } } - @GeneratedBy(SLOperations.class) private static final class OperationLocalImpl extends OperationLocal { @@ -2160,7 +2131,6 @@ private static final class OperationLocalImpl extends OperationLocal { } } - @GeneratedBy(SLOperations.class) private static final class LabelFill { @@ -2177,7 +2147,6 @@ LabelFill offset(int offset) { } } - @GeneratedBy(SLOperations.class) private static final class ExceptionHandler { @@ -2208,7 +2177,6 @@ public String toString() { } } - @GeneratedBy(SLOperations.class) private static final class SourceInfoBuilder { @@ -2311,7 +2279,6 @@ private static final class SourceData { } } - @GeneratedBy(SLOperations.class) private static final class BuilderFinallyTryContext { @@ -2328,8 +2295,7 @@ private static final class BuilderFinallyTryContext { ArrayList relocationOffsets = new ArrayList<>(); int handlerMaxStack; - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, - int curStack, int maxStack) { + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { this.prev = prev; this.bc = bc; this.exceptionHandlers = exceptionHandlers; @@ -2340,7 +2306,6 @@ private static final class BuilderFinallyTryContext { } } - @GeneratedBy(SLOperations.class) private static final class OperationNodeImpl extends OperationNode implements BytecodeOSRNode { @@ -2365,7 +2330,7 @@ private OperationNodeImpl(OperationNodes nodes) { super(nodes); } - static { + static { setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n)._metadata_MethodName); } @@ -2376,7 +2341,6 @@ private T insertAccessor(T node) { // () { private Object executeAt(VirtualFrame frame, int storedLocation) { int result = storedLocation; while (true) { - System.err.printf("[running] %08x%n", result); result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _handlers, _conditionProfiles, _maxLocals); if ((result & 0xffff) == 0xffff) { break; @@ -2463,12 +2427,10 @@ void changeInterpreters(BytecodeLoopBase impl) { } } - @GeneratedBy(SLOperations.class) private abstract static class BytecodeLoopBase { - abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, - int[] $conditionProfiles, int maxLocals); + abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); @@ -2572,7 +2534,6 @@ protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlo } } - @GeneratedBy(SLOperations.class) private static final class BytecodeNode extends BytecodeLoopBase { @@ -2582,8 +2543,7 @@ private static final class BytecodeNode extends BytecodeLoopBase { @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @BytecodeInterpreterSwitch @Override - int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, - int[] $conditionProfiles, int maxLocals) { + int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { int $sp = $startSp; int $bci = $startBci; Counter loopCounter = new Counter(); @@ -2598,22 +2558,24 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } switch (curOpcode) { // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_POP: { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_POP : + { $sp = $sp - 1; $frame.clear($sp); $bci = $bci + POP_LENGTH; continue loop; } // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Boxing Elimination: Do Nothing - case INSTR_BRANCH: { + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Boxing Elimination: Do Nothing + case INSTR_BRANCH : + { int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { TruffleSafepoint.poll($this); @@ -2626,15 +2588,16 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - // Boxing Elimination: Do Nothing - case INSTR_BRANCH_FALSE: { + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + // Boxing Elimination: Do Nothing + case INSTR_BRANCH_FALSE : + { boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; $sp = $sp - 1; if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { @@ -2646,71 +2609,76 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_THROW: { + // Locals: + // [ 0] exception + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_THROW : + { int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; throw (AbstractTruffleException) $frame.getObject(slot); } // load.constant.object - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_OBJECT: { + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_OBJECT : + { $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG: { + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG : + { $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } // load.constant.boolean - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN - // INT -> INSTR_LOAD_CONSTANT_BOOLEAN - // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN - // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_BOOLEAN: { + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN + // INT -> INSTR_LOAD_CONSTANT_BOOLEAN + // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN + // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_BOOLEAN : + { $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } // load.argument.object - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; $frame.setObject($sp, value); $sp = $sp + 1; @@ -2718,16 +2686,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; if (value instanceof Long) { $frame.setLong($sp, (long) value); @@ -2739,16 +2708,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; if (value instanceof Boolean) { $frame.setBoolean($sp, (boolean) value); @@ -2760,13 +2730,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // store.local.object - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_STORE_LOCAL_OBJECT: { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_STORE_LOCAL_OBJECT : + { int localIdx = $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; $frame.setObject(localIdx, expectObject($frame, sourceSlot)); @@ -2775,70 +2746,69 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // store.local.long - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG: { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_LONG : + { int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* - * OBJECT - */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } // store.local.boolean - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN: { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_OBJECT + // INT -> INSTR_STORE_LOCAL_OBJECT + // DOUBLE -> INSTR_STORE_LOCAL_OBJECT + // FLOAT -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_STORE_LOCAL_OBJECT + case INSTR_STORE_LOCAL_BOOLEAN : + { int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* - * OBJECT - */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } // store.local.uninit - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_LONG - // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN - case INSTR_STORE_LOCAL_UNINIT: { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_LONG + // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN + case INSTR_STORE_LOCAL_UNINIT : + { int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; FrameSlotKind localTag = $frame.getFrameDescriptor().getSlotKind(localIdx); @@ -2856,11 +2826,12 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.object - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Do Nothing - case INSTR_LOAD_LOCAL_OBJECT: { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Do Nothing + case INSTR_LOAD_LOCAL_OBJECT : + { int localIdx = $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0]; if ($frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -2873,18 +2844,19 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.long - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG: { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_LONG : + { int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); if (localType != FrameSlotKind.Long) { @@ -2907,18 +2879,19 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.boolean - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN: { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_OBJECT + // INT -> INSTR_LOAD_LOCAL_OBJECT + // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT + // FLOAT -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 + // BYTE -> INSTR_LOAD_LOCAL_OBJECT + case INSTR_LOAD_LOCAL_BOOLEAN : + { int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); if (localType != FrameSlotKind.Boolean) { @@ -2941,14 +2914,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.uninit - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_LONG - // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN - case INSTR_LOAD_LOCAL_UNINIT: { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_LONG + // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN + case INSTR_LOAD_LOCAL_UNINIT : + { int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; $frame.setObject($sp, expectObject($frame, localIdx)); $sp++; @@ -2956,383 +2930,310 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_RETURN: { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_RETURN : + { return (($sp - 1) << 16) | 0xffff; } // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1, method = public static - // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, - // java.lang.Object, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = - // [Guard[(SLAddNode.isString(left, right))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f1a38a - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@375dedc - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b0e5992 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41791417 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD : + { BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_ADD_LENGTH; continue loop; } // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5119e3c8 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16b0a9c1 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_DIV: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c48e45c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@567d16d3 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_DIV : + { BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_DIV_LENGTH; continue loop; } // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static - // boolean doGeneric(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(leftInterop.accepts(left))], - // Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, - // java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@18d3b56e - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@357d1b96 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_EQUAL: { + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f760747 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16267112 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_EQUAL : + { BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_EQUAL_LENGTH; continue loop; } // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2b64a952 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d770d8e + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL : + { BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; continue loop; } // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3809e35e - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@13825d7d + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN : + { BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_THAN_LENGTH; continue loop; } // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d7459f4 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LOGICAL_NOT: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3c613c75 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LOGICAL_NOT : + { BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; continue loop; } // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@60885467 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e284f1d - // Boxing Elimination: Bit Mask - case INSTR_C_SL_MUL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@196a740a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@c6401d4 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_MUL : + { BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_MUL_LENGTH; continue loop; } // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static - // java.lang.Object readArray(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static - // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static - // java.lang.Object readObject(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objects.accepts(receiver))], - // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], - // Guard[(objects.hasMembers(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@194c5295 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@66803b1 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d8ccc90 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@383bdbc0 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY : + { BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_READ_PROPERTY_LENGTH; continue loop; } // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24614477 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@89db741 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_SUB: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@723b32e9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5efde7db + // Boxing Elimination: Bit Mask + case INSTR_C_SL_SUB : + { BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_SUB_LENGTH; continue loop; } // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static - // java.lang.Object writeArray(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static - // java.lang.Object - // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, - // java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static - // java.lang.Object writeObject(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))], - // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73be843d - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@358d7470 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@357e48d8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@537d706c + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY : + { BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; continue loop; } // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static - // java.lang.Object fromForeign(java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1be1cc4a - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ea357c8 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX: { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78fabc90 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49885f6b + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX : + { BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_LENGTH; continue loop; } // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79bbab4d - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@e77e60a + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL : + { BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; continue loop; } // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@27cb6efe - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36b119b8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN : + { BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; continue loop; } // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct, method = protected static - // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, - // java.lang.Object[], com.oracle.truffle.api.Assumption, - // com.oracle.truffle.api.RootCallTarget, - // com.oracle.truffle.api.nodes.DirectCallNode) , guards = - // [Guard[(function.getCallTarget() == cachedTarget)]], signature = - // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@325d65d1 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56247945 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b822dc2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fa4ade + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE : + { int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; Object input_0 = $frame.getObject($sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -3346,20 +3247,20 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e1410f - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_AND: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@218ca97d + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_AND : + { if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_AND_LENGTH; @@ -3370,20 +3271,20 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ea17d33 - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_OR: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fce182d + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_OR : + { if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_OR_LENGTH; @@ -3394,197 +3295,152 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static - // java.lang.Object fromForeign(java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@578be2db - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2290573e - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15a8da2b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5746cefa + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; continue loop; } // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1, method = public static - // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, - // java.lang.Object, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = - // [Guard[(SLAddNode.isString(left, right))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5a81935a - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5fcc35dc - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD_Q_ADD_LONG: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1345422e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ca52f1b + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD_Q_ADD_LONG : + { BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; continue loop; } // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static - // java.lang.Object readArray(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static - // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static - // java.lang.Object readObject(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objects.accepts(receiver))], - // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], - // Guard[(objects.hasMembers(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@575999c4 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@77501db6 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f8fdb26 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4edff133 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; continue loop; } // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static - // java.lang.Object fromForeign(java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@211d4b45 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f41f86f - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77329ef4 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@22baaafe + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; continue loop; } // c.SLToBoolean.q.Boolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@44dd5fa - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73bd0364 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; continue loop; } // c.SLLessOrEqual.q.LessOrEqual0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7307d568 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@425a2249 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { BytecodeNode.SLLessOrEqual_q_LessOrEqual0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; continue loop; } // c.SLInvoke.q.Direct - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct, method = protected static - // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, - // java.lang.Object[], com.oracle.truffle.api.Assumption, - // com.oracle.truffle.api.RootCallTarget, - // com.oracle.truffle.api.nodes.DirectCallNode) , guards = - // [Guard[(function.getCallTarget() == cachedTarget)]], signature = - // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@388bff2e - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2819ead0 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE_Q_DIRECT: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21fcd1c8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56666253 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE_Q_DIRECT : + { int numVariadics = $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0]; Object input_0 = $frame.getObject($sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -3598,98 +3454,75 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // c.SLFunctionLiteral.q.Perform - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4211182c - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ddbedd8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 1 + 1; $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; continue loop; } // c.SLWriteProperty.q.WriteSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static - // java.lang.Object writeArray(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static - // java.lang.Object - // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, - // java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static - // java.lang.Object writeObject(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))], - // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ff02993 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6865d5cc - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5e00c640 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19b53ed9 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 3 + 1; $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; continue loop; } // c.SLLessThan.q.LessThan0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@f4ded7a - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ca4b346 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { BytecodeNode.SLLessThan_q_LessThan0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; continue loop; } - default: + default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); } @@ -3698,8 +3531,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { CompilerAsserts.partialEvaluationConstant(handlerIndex); ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) - continue; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; $sp = handler.startStack + maxLocals; $frame.setObject(handler.exceptionIndex, ex); $bci = handler.handlerBci; @@ -3715,185 +3547,230 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ int $bci = 0; while ($bci < $bc.length) { switch (unsafeFromBytecode($bc, $bci)) { - case INSTR_POP: { + case INSTR_POP : + { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH: { + case INSTR_BRANCH : + { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE: { + case INSTR_BRANCH_FALSE : + { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW: { + case INSTR_THROW : + { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT: { + case INSTR_LOAD_CONSTANT_OBJECT : + { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG: { + case INSTR_LOAD_CONSTANT_LONG : + { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN: { + case INSTR_LOAD_CONSTANT_BOOLEAN : + { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT: { + case INSTR_LOAD_ARGUMENT_OBJECT : + { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG: { + case INSTR_LOAD_ARGUMENT_LONG : + { $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT: { + case INSTR_STORE_LOCAL_OBJECT : + { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG: { + case INSTR_STORE_LOCAL_LONG : + { $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN: { + case INSTR_STORE_LOCAL_BOOLEAN : + { $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT: { + case INSTR_STORE_LOCAL_UNINIT : + { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT: { + case INSTR_LOAD_LOCAL_OBJECT : + { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG: { + case INSTR_LOAD_LOCAL_LONG : + { $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN: { + case INSTR_LOAD_LOCAL_BOOLEAN : + { $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT: { + case INSTR_LOAD_LOCAL_UNINIT : + { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN: { + case INSTR_RETURN : + { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD: { + case INSTR_C_SL_ADD : + { $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV: { + case INSTR_C_SL_DIV : + { $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL: { + case INSTR_C_SL_EQUAL : + { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL: { + case INSTR_C_SL_LESS_OR_EQUAL : + { $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN: { + case INSTR_C_SL_LESS_THAN : + { $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT: { + case INSTR_C_SL_LOGICAL_NOT : + { $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL: { + case INSTR_C_SL_MUL : + { $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY: { + case INSTR_C_SL_READ_PROPERTY : + { $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB: { + case INSTR_C_SL_SUB : + { $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY: { + case INSTR_C_SL_WRITE_PROPERTY : + { $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX: { + case INSTR_C_SL_UNBOX : + { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL: { + case INSTR_C_SL_FUNCTION_LITERAL : + { $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN : + { $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE: { + case INSTR_C_SL_INVOKE : + { $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND: { + case INSTR_SC_SL_AND : + { $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR: { + case INSTR_SC_SL_OR : + { $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG: { + case INSTR_C_SL_ADD_Q_ADD_LONG : + { $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT: { + case INSTR_C_SL_INVOKE_Q_DIRECT : + { $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; break; } @@ -3908,11 +3785,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { while ($bci < $bc.length) { sb.append(String.format(" [%04x]", $bci)); switch (unsafeFromBytecode($bc, $bci)) { - default: { + default : + { sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); break; } - case INSTR_POP: { + case INSTR_POP : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -3925,7 +3804,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH: { + case INSTR_BRANCH : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3939,7 +3819,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE: { + case INSTR_BRANCH_FALSE : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -3953,7 +3834,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW: { + case INSTR_THROW : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3967,7 +3849,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT: { + case INSTR_LOAD_CONSTANT_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3981,7 +3864,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG: { + case INSTR_LOAD_CONSTANT_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -3995,7 +3879,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN: { + case INSTR_LOAD_CONSTANT_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4009,7 +3894,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT: { + case INSTR_LOAD_ARGUMENT_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4023,7 +3909,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG: { + case INSTR_LOAD_ARGUMENT_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4037,7 +3924,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4051,7 +3939,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT: { + case INSTR_STORE_LOCAL_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4066,7 +3955,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG: { + case INSTR_STORE_LOCAL_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4081,7 +3971,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN: { + case INSTR_STORE_LOCAL_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4096,7 +3987,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT: { + case INSTR_STORE_LOCAL_UNINIT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4111,7 +4003,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT: { + case INSTR_LOAD_LOCAL_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4125,7 +4018,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG: { + case INSTR_LOAD_LOCAL_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4139,7 +4033,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN: { + case INSTR_LOAD_LOCAL_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4153,7 +4048,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT: { + case INSTR_LOAD_LOCAL_UNINIT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -4167,7 +4063,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN: { + case INSTR_RETURN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -4180,7 +4077,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD: { + case INSTR_C_SL_ADD : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4196,7 +4094,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV: { + case INSTR_C_SL_DIV : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4212,7 +4111,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL: { + case INSTR_C_SL_EQUAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4227,7 +4127,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL: { + case INSTR_C_SL_LESS_OR_EQUAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4243,7 +4144,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN: { + case INSTR_C_SL_LESS_THAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4259,7 +4161,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT: { + case INSTR_C_SL_LOGICAL_NOT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4274,7 +4177,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL: { + case INSTR_C_SL_MUL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4290,7 +4194,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY: { + case INSTR_C_SL_READ_PROPERTY : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4308,7 +4213,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB: { + case INSTR_C_SL_SUB : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4324,7 +4230,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY: { + case INSTR_C_SL_WRITE_PROPERTY : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4342,7 +4249,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX: { + case INSTR_C_SL_UNBOX : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4356,7 +4264,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL: { + case INSTR_C_SL_FUNCTION_LITERAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4371,7 +4280,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4386,7 +4296,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE: { + case INSTR_C_SL_INVOKE : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4401,7 +4312,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND: { + case INSTR_SC_SL_AND : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4417,7 +4329,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR: { + case INSTR_SC_SL_OR : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4433,7 +4346,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4447,7 +4361,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG: { + case INSTR_C_SL_ADD_Q_ADD_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4463,7 +4378,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4481,7 +4397,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4495,7 +4412,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4510,7 +4428,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4526,7 +4445,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT: { + case INSTR_C_SL_INVOKE_Q_DIRECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4541,7 +4461,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4556,7 +4477,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4574,7 +4496,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -4599,16 +4522,11 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { return sb.toString(); } - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value, Object $child1Value) { + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } - if (((state_0 & 0b1000)) == 0 /* - * is-not-state_0 add(Object, Object, - * SLToTruffleStringNode, SLToTruffleStringNode, - * ConcatNode) - */ && (SLAddNode.isString($child0Value, $child1Value))) { + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { return false; } return true; @@ -4616,35 +4534,7 @@ private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLAdd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* - * is - * - - * not - * addLong - * ( - * long, - * long) - * && - * add - * ( - * SLBigNumber, - * SLBigNumber) - * && - * add - * ( - * Object, - * Object, - * SLToTruffleStringNode, - * SLToTruffleStringNode, - * ConcatNode) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -4687,24 +4577,8 @@ private static void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * addLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * addLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); } finally { lock.unlock(); } @@ -4735,24 +4609,8 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * addLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * addLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); } finally { lock.unlock(); } @@ -4761,56 +4619,16 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); return; } } - if ((state_0 & 0b11000) != 0 /* - * is-state_0 add(Object, Object, - * SLToTruffleStringNode, SLToTruffleStringNode, - * ConcatNode) || typeError(Object, Object, Node, int) - */) { - if ((state_0 & 0b1000) != 0 /* - * is-state_0 add(Object, Object, - * SLToTruffleStringNode, SLToTruffleStringNode, - * ConcatNode) - */) { + if ((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0]); if (s2_ != null) { if ((SLAddNode.isString($child0Value_, $child1Value_))) { @@ -4819,9 +4637,7 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b10000) != 0 /* - * is-state_0 typeError(Object, Object, Node, int) - */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { Node fallback_node__ = ($this); int fallback_bci__ = ($bci); @@ -4837,8 +4653,7 @@ private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -4851,18 +4666,8 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * addLong - * ( - * long, - * long) - */); - if ((state_0 & 0b11110) == 0b10/* - * is-exact-state_0 addLong(long, long) - */) { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); + if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { $bc[$bci] = (short) (INSTR_C_SL_ADD_Q_ADD_LONG); } else { $bc[$bci] = (short) (INSTR_C_SL_ADD); @@ -4892,24 +4697,8 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * addLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * addLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); } finally { lock.unlock(); } @@ -4925,38 +4714,11 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * addLong - * ( - * long, - * long) - */); - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * addLong(long, long) - */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * add - * ( - * SLBigNumber, - * SLBigNumber) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -4978,18 +4740,7 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); VarHandle.storeStoreFence(); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * add - * ( - * Object, - * Object, - * SLToTruffleStringNode, - * SLToTruffleStringNode, - * ConcatNode) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -5007,17 +4758,7 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); $bc[$bci] = (short) (INSTR_C_SL_ADD); int type0; int type1; @@ -5037,8 +4778,7 @@ private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNo } } - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -5047,27 +4787,7 @@ private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLDiv_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* - * is - * - - * not - * divLong - * ( - * long, - * long) - * && - * div - * ( - * SLBigNumber, - * SLBigNumber) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5110,24 +4830,8 @@ private static void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * divLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * divLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); } finally { lock.unlock(); } @@ -5158,24 +4862,8 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * divLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * divLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); } finally { lock.unlock(); } @@ -5184,42 +4872,10 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); return; } @@ -5239,8 +4895,7 @@ private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5253,15 +4908,7 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * divLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { @@ -5287,24 +4934,8 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * divLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * divLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); } finally { lock.unlock(); } @@ -5320,38 +4951,11 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * divLong - * ( - * long, - * long) - */); - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * divLong(long, long) - */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * div - * ( - * SLBigNumber, - * SLBigNumber) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5370,17 +4974,7 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5401,8 +4995,7 @@ private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNo @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, - Object $child1Value) { + private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); @@ -5420,118 +5013,10 @@ private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] private static void SLEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* - * is - * - - * not - * doLong - * ( - * long, - * long) - * && - * doBigNumber - * ( - * SLBigNumber, - * SLBigNumber) - * && - * doBoolean - * ( - * boolean, - * boolean) - * && - * doString - * ( - * String, - * String) - * && - * doTruffleString - * ( - * TruffleString, - * TruffleString, - * EqualNode) - * && - * doNull - * ( - * SLNull, - * SLNull) - * && - * doFunction - * ( - * SLFunction, - * Object) - * && - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - * && - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - */)) { + if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; - } else if ((state_0 & 0b1111110110) == 0 /* - * only-active doBoolean(boolean, boolean) - */ && ((state_0 & 0b1111111110) != 0 /* - * is - * - - * not - * doLong - * ( - * long, - * long) - * && - * doBigNumber - * ( - * SLBigNumber, - * SLBigNumber) - * && - * doBoolean - * ( - * boolean, - * boolean) - * && - * doString - * ( - * String, - * String) - * && - * doTruffleString - * ( - * TruffleString, - * TruffleString, - * EqualNode) - * && - * doNull - * ( - * SLNull, - * SLNull) - * && - * doFunction - * ( - * SLFunction, - * Object) - * && - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - * && - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - */)) { + } else if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -5570,8 +5055,7 @@ private static void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, Op return; } - private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -5620,45 +5104,10 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* - * extract - * - - * implicit - * - - * state_0 - * 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -5694,10 +5143,7 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b100000) != 0 /* - * is-state_0 doTruffleString(TruffleString, - * TruffleString, EqualNode) - */ && $child0Value_ instanceof TruffleString) { + if ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; if ($child1Value_ instanceof TruffleString) { TruffleString $child1Value__ = (TruffleString) $child1Value_; @@ -5726,12 +5172,7 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } } - if ((state_0 & 0b1110000000) != 0 /* - * is-state_0 doFunction(SLFunction, Object) || - * doGeneric(Object, Object, InteropLibrary, - * InteropLibrary) || doGeneric(Object, Object, - * InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b1110000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { if ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { SLFunction $child0Value__ = (SLFunction) $child0Value_; boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); @@ -5742,16 +5183,8 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper } return; } - if ((state_0 & 0b1100000000) != 0 /* - * is-state_0 doGeneric(Object, Object, - * InteropLibrary, InteropLibrary) || - * doGeneric(Object, Object, InteropLibrary, - * InteropLibrary) - */) { - if ((state_0 & 0b100000000) != 0 /* - * is-state_0 doGeneric(Object, Object, - * InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b1100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); while (s7_ != null) { if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { @@ -5766,10 +5199,7 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper s7_ = s7_.next_; } } - if ((state_0 & 0b1000000000) != 0 /* - * is-state_0 doGeneric(Object, Object, - * InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b1000000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { $frame.setObject($sp - 2, SLEqual_generic1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); return; } @@ -5780,8 +5210,7 @@ private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, Oper return; } - private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -5794,15 +5223,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); int type0; int type1; if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */) { @@ -5832,27 +5253,9 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* - * set- - * implicit- - * state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* - * set- - * implicit- - * state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * doBigNumber - * ( - * SLBigNumber, - * SLBigNumber) - */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5875,21 +5278,10 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation boolean $child0Value_ = (boolean) $child0Value; if ($child1Value instanceof Boolean) { boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * doBoolean - * ( - * boolean, - * boolean) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); int type0; int type1; - if ((state_0 & 0b1111110110) == 0 /* - * only-active doBoolean(boolean, - * boolean) - */) { + if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */) { type0 = 5 /* BOOLEAN */; type1 = 5 /* BOOLEAN */; } else { @@ -5913,15 +5305,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation String $child0Value_ = (String) $child0Value; if ($child1Value instanceof String) { String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* - * add - * - - * state_0 - * doString - * ( - * String, - * String) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5944,16 +5328,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation if ($child1Value instanceof TruffleString) { TruffleString $child1Value_ = (TruffleString) $child1Value; $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* - * add - * - - * state_0 - * doTruffleString - * ( - * TruffleString, - * TruffleString, - * EqualNode) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -5975,15 +5350,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation SLNull $child0Value_ = SLTypes.asSLNull($child0Value); if (SLTypes.isSLNull($child1Value)) { SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* - * add - * - - * state_0 - * doNull - * ( - * SLNull, - * SLNull) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6003,15 +5370,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* - * add - * - - * state_0 - * doFunction - * ( - * SLFunction, - * Object) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6028,16 +5387,10 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } return; } - if ((exclude) == 0 /* - * is-not-exclude doGeneric(Object, Object, InteropLibrary, - * InteropLibrary) - */) { + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { int count7_ = 0; SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* - * is-state_0 doGeneric(Object, Object, - * InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { while (s7_ != null) { if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { break; @@ -6055,17 +5408,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* - * add - * - - * state_0 - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6095,35 +5438,10 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation try { generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* - * remove-state_0 - * doGeneric(Object, Object, - * InteropLibrary, - * InteropLibrary) - */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* - * add - * - - * state_0 - * doGeneric - * ( - * Object, - * Object, - * InteropLibrary, - * InteropLibrary) - */); + state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -6151,8 +5469,7 @@ private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, Operation } } - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -6161,27 +5478,7 @@ private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, Operat private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* - * is - * - - * not - * lessOrEqual - * ( - * long, - * long) - * && - * lessOrEqual - * ( - * SLBigNumber, - * SLBigNumber) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -6190,8 +5487,7 @@ private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImp } } - private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; @@ -6221,8 +5517,7 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFram return; } - private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); @@ -6240,42 +5535,10 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -6300,8 +5563,7 @@ private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame return; } - private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6313,19 +5575,8 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * lessOrEqual - * ( - * long, - * long) - */); - if ((state_0 & 0b1110) == 0b10/* - * is-exact-state_0 lessOrEqual(long, - * long) - */) { + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0); } else { $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); @@ -6359,25 +5610,9 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * lessOrEqual - * ( - * SLBigNumber, - * SLBigNumber) - */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); int type0; int type1; @@ -6402,17 +5637,7 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); int type0; int type1; @@ -6432,8 +5657,7 @@ private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, Ope } } - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -6442,27 +5666,7 @@ private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, Operation private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* - * is - * - - * not - * lessThan - * ( - * long, - * long) - * && - * lessThan - * ( - * SLBigNumber, - * SLBigNumber) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -6471,8 +5675,7 @@ private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $ } } - private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; @@ -6502,8 +5705,7 @@ private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $fra return; } - private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); @@ -6521,42 +5723,10 @@ private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame return; } } - if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); @@ -6581,8 +5751,7 @@ private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame return; } - private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6594,18 +5763,8 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * lessThan - * ( - * long, - * long) - */); - if ((state_0 & 0b1110) == 0b10/* - * is-exact-state_0 lessThan(long, long) - */) { + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0); } else { $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); @@ -6639,25 +5798,9 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * lessThan - * ( - * SLBigNumber, - * SLBigNumber) - */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); int type0; int type1; @@ -6682,17 +5825,7 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); int type0; int type1; @@ -6712,8 +5845,7 @@ private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, Operat } } - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value) { + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -6722,20 +5854,7 @@ private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, Operati private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* - * is - * - - * not - * doBoolean - * ( - * boolean) - * && - * typeError - * ( - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -6744,8 +5863,7 @@ private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl } } - private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -6766,8 +5884,7 @@ private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $f return; } - private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); @@ -6796,8 +5913,7 @@ private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $f return; } - private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -6807,14 +5923,7 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doBoolean - * ( - * boolean) - */); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); int type0; if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { type0 = 5 /* BOOLEAN */; @@ -6837,16 +5946,7 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); int type0; type0 = 0 /* OBJECT */; doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); @@ -6862,8 +5962,7 @@ private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, Oper } } - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -6872,27 +5971,7 @@ private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLMul_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* - * is - * - - * not - * mulLong - * ( - * long, - * long) - * && - * mul - * ( - * SLBigNumber, - * SLBigNumber) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -6935,24 +6014,8 @@ private static void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * mulLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * mulLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } @@ -6983,24 +6046,8 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * mulLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * mulLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } @@ -7009,42 +6056,10 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); return; } @@ -7064,8 +6079,7 @@ private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -7078,15 +6092,7 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * mulLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { @@ -7112,24 +6118,8 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * mulLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * mulLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); } finally { lock.unlock(); } @@ -7145,38 +6135,11 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * mulLong - * ( - * long, - * long) - */); - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * mulLong(long, long) - */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * mul - * ( - * SLBigNumber, - * SLBigNumber) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -7195,17 +6158,7 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -7226,8 +6179,7 @@ private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNo @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, - Object $child1Value) { + private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; { @@ -7241,19 +6193,16 @@ private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - SLObject $child0Value_, Object $child1Value) { + private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; { Node readSLObject1_node__ = ($this); int readSLObject1_bci__ = ($bci); DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, - readSLObject1_toTruffleStringNode__); + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); } throw BoundaryCallFailedException.INSTANCE; } @@ -7261,8 +6210,7 @@ private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $t @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, - Object $child1Value) { + private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; { @@ -7284,32 +6232,10 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 2); Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* - * is-state_0 readArray(Object, Object, Node, int, - * InteropLibrary, InteropLibrary) || - * readArray(Object, Object, Node, int, - * InteropLibrary, InteropLibrary) || - * readSLObject(SLObject, Object, Node, int, - * DynamicObjectLibrary, SLToTruffleStringNode) || - * readSLObject(SLObject, Object, Node, int, - * DynamicObjectLibrary, SLToTruffleStringNode) || - * readObject(Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) || - * readObject(Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) - */) { - if ((state_0 & 0b110) != 0 /* - * is-state_0 readArray(Object, Object, Node, int, - * InteropLibrary, InteropLibrary) || - * readArray(Object, Object, Node, int, - * InteropLibrary, InteropLibrary) - */) { - if ((state_0 & 0b10) != 0 /* - * is-state_0 readArray(Object, Object, Node, int, - * InteropLibrary, InteropLibrary) - */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + - 0) + 0]); + if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { Node node__ = ($this); @@ -7320,10 +6246,7 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* - * is-state_0 readArray(Object, Object, Node, - * int, InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { @@ -7339,21 +6262,10 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm } } } - if ((state_0 & 0b11000) != 0 /* - * is-state_0 readSLObject(SLObject, Object, Node, - * int, DynamicObjectLibrary, - * SLToTruffleStringNode) || readSLObject(SLObject, - * Object, Node, int, DynamicObjectLibrary, - * SLToTruffleStringNode) - */ && $child0Value_ instanceof SLObject) { + if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* - * is-state_0 readSLObject(SLObject, Object, - * Node, int, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { Node node__1 = ($this); @@ -7364,27 +6276,14 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s2_ = s2_.next_; } } - if ((state_0 & 0b10000) != 0 /* - * is-state_0 readSLObject(SLObject, Object, - * Node, int, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { $frame.setObject($sp - 2, SLReadProperty_readSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_)); return; } } - if ((state_0 & 0b1100000) != 0 /* - * is-state_0 readObject(Object, Object, Node, - * int, InteropLibrary, SLToMemberNode) || - * readObject(Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) - */) { - if ((state_0 & 0b100000) != 0 /* - * is-state_0 readObject(Object, Object, Node, - * int, InteropLibrary, SLToMemberNode) - */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + - 0) + 8]); + if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8]); while (s4_ != null) { if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { Node node__2 = ($this); @@ -7395,10 +6294,7 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm s4_ = s4_.next_; } } - if ((state_0 & 0b1000000) != 0 /* - * is-state_0 readObject(Object, Object, - * Node, int, InteropLibrary, SLToMemberNode) - */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { @@ -7420,8 +6316,7 @@ private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeIm return; } - private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -7433,17 +6328,10 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op { int bci__ = 0; Node node__ = null; - if (((exclude & 0b1)) == 0 /* - * is-not-exclude readArray(Object, Object, Node, - * int, InteropLibrary, InteropLibrary) - */) { + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + - 0) + 0]); - if ((state_0 & 0b10) != 0 /* - * is-state_0 readArray(Object, Object, Node, - * int, InteropLibrary, InteropLibrary) - */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { node__ = ($this); @@ -7467,19 +6355,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * readArray - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -7513,41 +6389,10 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op readArray1_node__ = ($this); readArray1_bci__ = ($bci); readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * readArray - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * readArray(Object, - * Object, Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * readArray - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -7557,8 +6402,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, - SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); return; } } @@ -7572,20 +6416,10 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op { int bci__1 = 0; Node node__1 = null; - if (((exclude & 0b10)) == 0 /* - * is-not-exclude readSLObject(SLObject, - * Object, Node, int, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* - * is-state_0 readSLObject(SLObject, - * Object, Node, int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value_))) { node__1 = ($this); @@ -7606,26 +6440,8 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * readSLObject - * ( - * SLObject, - * Object, - * Node, - * int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); - if ((state_0 & 0b1111110) == 0b1000/* - * is-exact-state_0 - * readSLObject(SLObject, - * Object, Node, int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0); } else { $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); @@ -7654,40 +6470,10 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op readSLObject1_bci__ = ($bci); readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* - * add - * - - * exclude - * readSLObject - * ( - * SLObject, - * Object, - * Node, - * int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* - * remove-state_0 - * readSLObject(SLObject, - * Object, Node, int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* - * add - * - - * state_0 - * readSLObject - * ( - * SLObject, - * Object, - * Node, - * int, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); + state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -7697,26 +6483,17 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, - ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); return; } } { int bci__2 = 0; Node node__2 = null; - if (((exclude & 0b100)) == 0 /* - * is-not-exclude readObject(Object, Object, - * Node, int, InteropLibrary, SLToMemberNode) - */) { + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + - 0) + 8]); - if ((state_0 & 0b100000) != 0 /* - * is-state_0 readObject(Object, Object, - * Node, int, InteropLibrary, - * SLToMemberNode) - */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8]); + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { node__2 = ($this); @@ -7739,19 +6516,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* - * add - * - - * state_0 - * readObject - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -7783,43 +6548,11 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op if ((readObject1_objects__.hasMembers($child0Value))) { readObject1_node__ = ($this); readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor( - (SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* - * add - * - - * exclude - * readObject - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffdf /* - * remove-state_0 - * readObject( - * Object, Object, - * Node, int, - * InteropLibrary, - * SLToMemberNode) - */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* - * add - * - - * state_0 - * readObject - * ( - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); int type0; int type1; @@ -7829,8 +6562,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); lock.unlock(); hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, - ((SLToMemberNode) $children[childArrayOffset_ + 11]))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) $children[childArrayOffset_ + 11]))); return; } } @@ -7839,7 +6571,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op } } } - throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -7847,8 +6579,7 @@ private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, Op } } - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -7857,27 +6588,7 @@ private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static void SLSub_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* - * is - * - - * not - * subLong - * ( - * long, - * long) - * && - * sub - * ( - * SLBigNumber, - * SLBigNumber) - * && - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -7920,24 +6631,8 @@ private static void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, Operat Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * subLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * subLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); } finally { lock.unlock(); } @@ -7968,24 +6663,8 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * subLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * subLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); } finally { lock.unlock(); } @@ -7994,42 +6673,10 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio } } } - if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract- - * implicit- - * state_0 1: - * SLBigNumber - */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* - * extract - * - - * implicit - * - - * state_0 - * 1 - * : - * SLBigNumber - */, $child1Value_); + if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); return; } @@ -8049,8 +6696,7 @@ private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, Operatio return; } - private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -8063,15 +6709,7 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * subLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); int type0; int type1; if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { @@ -8097,24 +6735,8 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * subLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * subLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); } finally { lock.unlock(); } @@ -8130,38 +6752,11 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * subLong - * ( - * long, - * long) - */); - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * subLong(long, long) - */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* - * set-implicit - * -state_0 0: - * SLBigNumber - */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* - * set-implicit - * -state_0 1: - * SLBigNumber - */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * sub - * ( - * SLBigNumber, - * SLBigNumber) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -8180,17 +6775,7 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * typeError - * ( - * Object, - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); int type0; int type1; type0 = 0 /* OBJECT */; @@ -8211,8 +6796,7 @@ private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNo @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, - Object $child1Value, Object $child2Value) { + private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { int childArrayOffset_; int constArrayOffset_; { @@ -8226,14 +6810,12 @@ private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $th @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - SLObject $child0Value_, Object $child1Value, Object $child2Value) { + private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { int childArrayOffset_; int constArrayOffset_; { DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6]); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6]); if (writeSLObject1_toTruffleStringNode__ != null) { return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); } @@ -8243,8 +6825,7 @@ private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, - Object $child1Value, Object $child2Value) { + private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { int childArrayOffset_; int constArrayOffset_; EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); @@ -8256,8 +6837,7 @@ private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $t InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10]); if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, - writeObject1_asMember__); + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); } throw BoundaryCallFailedException.INSTANCE; } @@ -8274,32 +6854,10 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI Object $child0Value_ = expectObject($frame, $sp - 3); Object $child1Value_ = expectObject($frame, $sp - 2); Object $child2Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* - * is-state_0 writeArray(Object, Object, Object, - * Node, int, InteropLibrary, InteropLibrary) || - * writeArray(Object, Object, Object, Node, int, - * InteropLibrary, InteropLibrary) || - * writeSLObject(SLObject, Object, Object, - * DynamicObjectLibrary, SLToTruffleStringNode) || - * writeSLObject(SLObject, Object, Object, - * DynamicObjectLibrary, SLToTruffleStringNode) || - * writeObject(Object, Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) || - * writeObject(Object, Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) - */) { - if ((state_0 & 0b110) != 0 /* - * is-state_0 writeArray(Object, Object, Object, - * Node, int, InteropLibrary, InteropLibrary) || - * writeArray(Object, Object, Object, Node, int, - * InteropLibrary, InteropLibrary) - */) { - if ((state_0 & 0b10) != 0 /* - * is-state_0 writeArray(Object, Object, Object, - * Node, int, InteropLibrary, InteropLibrary) - */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); + if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { Node node__ = ($this); @@ -8310,18 +6868,14 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* - * is-state_0 writeArray(Object, Object, Object, - * Node, int, InteropLibrary, InteropLibrary) - */) { + if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { { InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, - SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); + $frame.setObject($sp - 3, SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); return; } } @@ -8330,21 +6884,10 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI } } } - if ((state_0 & 0b11000) != 0 /* - * is-state_0 writeSLObject(SLObject, Object, - * Object, DynamicObjectLibrary, - * SLToTruffleStringNode) || - * writeSLObject(SLObject, Object, Object, - * DynamicObjectLibrary, SLToTruffleStringNode) - */ && $child0Value_ instanceof SLObject) { + if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* - * is-state_0 writeSLObject(SLObject, Object, - * Object, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); @@ -8353,28 +6896,14 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s2_ = s2_.next_; } } - if ((state_0 & 0b10000) != 0 /* - * is-state_0 writeSLObject(SLObject, Object, - * Object, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { $frame.setObject($sp - 3, SLWriteProperty_writeSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_)); return; } } - if ((state_0 & 0b1100000) != 0 /* - * is-state_0 writeObject(Object, Object, Object, - * Node, int, InteropLibrary, SLToMemberNode) || - * writeObject(Object, Object, Object, Node, int, - * InteropLibrary, SLToMemberNode) - */) { - if ((state_0 & 0b100000) != 0 /* - * is-state_0 writeObject(Object, Object, - * Object, Node, int, InteropLibrary, - * SLToMemberNode) - */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); + if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); while (s4_ != null) { if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { Node node__1 = ($this); @@ -8385,11 +6914,7 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI s4_ = s4_.next_; } } - if ((state_0 & 0b1000000) != 0 /* - * is-state_0 writeObject(Object, Object, - * Object, Node, int, InteropLibrary, - * SLToMemberNode) - */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { $frame.setObject($sp - 3, SLWriteProperty_writeObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); return; @@ -8402,8 +6927,7 @@ private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeI return; } - private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value, Object $child2Value) { + private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -8415,19 +6939,10 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O { int bci__ = 0; Node node__ = null; - if (((exclude & 0b1)) == 0 /* - * is-not-exclude writeArray(Object, Object, - * Object, Node, int, InteropLibrary, - * InteropLibrary) - */) { + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); - if ((state_0 & 0b10) != 0 /* - * is-state_0 writeArray(Object, Object, - * Object, Node, int, InteropLibrary, - * InteropLibrary) - */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { node__ = ($this); @@ -8451,20 +6966,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * writeArray - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -8501,44 +7003,10 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O writeArray1_node__ = ($this); writeArray1_bci__ = ($bci); writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * writeArray - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * writeArray( - * Object, Object, - * Object, Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * writeArray - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * InteropLibrary) - */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -8551,8 +7019,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, - writeArray1_numbers__)); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__)); return; } } @@ -8563,19 +7030,10 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* - * is-not-exclude writeSLObject(SLObject, - * Object, Object, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* - * is-state_0 writeSLObject(SLObject, - * Object, Object, DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value_))) { break; @@ -8592,25 +7050,8 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * writeSLObject - * ( - * SLObject, - * Object, - * Object, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); - if ((state_0 & 0b1111110) == 0b1000/* - * is-exact-state_0 - * writeSLObject(SLObject, - * Object, Object, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */) { + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0); } else { $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); @@ -8637,38 +7078,10 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* - * add - * - - * exclude - * writeSLObject - * ( - * SLObject, - * Object, - * Object, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* - * remove-state_0 - * writeSLObject(SLObject, - * Object, Object, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* - * add - * - - * state_0 - * writeSLObject - * ( - * SLObject, - * Object, - * Object, - * DynamicObjectLibrary, - * SLToTruffleStringNode) - */); + state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -8681,27 +7094,17 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, - ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); return; } } { int bci__1 = 0; Node node__1 = null; - if (((exclude & 0b100)) == 0 /* - * is-not-exclude writeObject(Object, Object, - * Object, Node, int, InteropLibrary, - * SLToMemberNode) - */) { + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); - if ((state_0 & 0b100000) != 0 /* - * is-state_0 writeObject(Object, Object, - * Object, Node, int, InteropLibrary, - * SLToMemberNode) - */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { while (s4_ != null) { if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { node__1 = ($this); @@ -8722,20 +7125,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* - * add - * - - * state_0 - * writeObject - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -8769,42 +7159,10 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O writeObject1_bci__ = ($bci); writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* - * add - * - - * exclude - * writeObject - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffdf /* - * remove-state_0 - * writeObject(Object, - * Object, Object, Node, - * int, InteropLibrary, - * SLToMemberNode) - */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* - * add - * - - * state_0 - * writeObject - * ( - * Object, - * Object, - * Object, - * Node, - * int, - * InteropLibrary, - * SLToMemberNode) - */); + state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); int type0; int type1; @@ -8817,8 +7175,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); lock.unlock(); hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, - writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); return; } } finally { @@ -8826,7 +7183,7 @@ private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, O } } } - throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -8853,94 +7210,10 @@ private static Object SLUnbox_fromForeign1Boundary_(OperationNodeImpl $this, sho private static void SLUnbox_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* - * is - * - - * not - * fromString - * ( - * String, - * FromJavaStringNode) - * && - * fromTruffleString - * ( - * TruffleString) - * && - * fromBoolean - * ( - * boolean) - * && - * fromLong - * ( - * long) - * && - * fromBigNumber - * ( - * SLBigNumber) - * && - * fromFunction - * ( - * SLFunction) - * && - * fromFunction - * ( - * SLNull) - * && - * fromForeign - * ( - * Object, - * InteropLibrary) - * && - * fromForeign - * ( - * Object, - * InteropLibrary) - */)) { + if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; - } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* - * is - * - - * not - * fromString - * ( - * String, - * FromJavaStringNode) - * && - * fromTruffleString - * ( - * TruffleString) - * && - * fromBoolean - * ( - * boolean) - * && - * fromLong - * ( - * long) - * && - * fromBigNumber - * ( - * SLBigNumber) - * && - * fromFunction - * ( - * SLFunction) - * && - * fromFunction - * ( - * SLNull) - * && - * fromForeign - * ( - * Object, - * InteropLibrary) - * && - * fromForeign - * ( - * Object, - * InteropLibrary) - */)) { + } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -9029,26 +7302,8 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper } return; } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* - * extract - * - - * implicit - * - - * state_0 - * 0 - * : - * SLBigNumber - */, $child0Value_); + if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); return; } @@ -9062,14 +7317,8 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); return; } - if ((state_0 & 0b1100000000) != 0 /* - * is-state_0 fromForeign(Object, InteropLibrary) - * || fromForeign(Object, InteropLibrary) - */) { - if ((state_0 & 0b100000000) != 0 /* - * is-state_0 fromForeign(Object, - * InteropLibrary) - */) { + if ((state_0 & 0b1100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); while (s7_ != null) { if ((s7_.interop_.accepts($child0Value_))) { @@ -9079,10 +7328,7 @@ private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, Oper s7_ = s7_.next_; } } - if ((state_0 & 0b1000000000) != 0 /* - * is-state_0 fromForeign(Object, - * InteropLibrary) - */) { + if ((state_0 & 0b1000000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { $frame.setObject($sp - 1, SLUnbox_fromForeign1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)); return; } @@ -9104,15 +7350,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * fromString - * ( - * String, - * FromJavaStringNode) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9124,14 +7362,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * fromTruffleString - * ( - * TruffleString) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9143,18 +7374,8 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * fromBoolean - * ( - * boolean) - */); - if ((state_0 & 0b1111111110) == 0b1000/* - * is-exact-state_0 - * fromBoolean(boolean) - */) { + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); + if ((state_0 & 0b1111111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */) { $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN); } else { $bc[$bci] = (short) (INSTR_C_SL_UNBOX); @@ -9178,14 +7399,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* - * add - * - - * state_0 - * fromLong - * ( - * long) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); if ((state_0 & 0b1111111110) == 0b10000/* is-exact-state_0 fromLong(long) */) { $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG); } else { @@ -9212,19 +7426,8 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation int sLBigNumberCast0; if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* - * set-implicit- - * state_0 - * 0:SLBigNumber - */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* - * add - * - - * state_0 - * fromBigNumber - * ( - * SLBigNumber) - */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9237,14 +7440,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* - * add - * - - * state_0 - * fromFunction - * ( - * SLFunction) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9256,14 +7452,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation } if (SLTypes.isSLNull($child0Value)) { SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* - * add - * - - * state_0 - * fromFunction - * ( - * SLNull) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9276,10 +7465,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { int count7_ = 0; SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* - * is-state_0 fromForeign(Object, - * InteropLibrary) - */) { + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { while (s7_ != null) { if ((s7_.interop_.accepts($child0Value))) { break; @@ -9295,15 +7481,7 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* - * add - * - - * state_0 - * fromForeign - * ( - * Object, - * InteropLibrary) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9324,30 +7502,10 @@ private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, Operation Node prev_ = encapsulating_.set($this); try { fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * fromForeign - * ( - * Object, - * InteropLibrary) - */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* - * remove-state_0 - * fromForeign(Object, - * InteropLibrary) - */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* - * add - * - - * state_0 - * fromForeign - * ( - * Object, - * InteropLibrary) - */); + state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); $bc[$bci] = (short) (INSTR_C_SL_UNBOX); int type0; type0 = 0 /* OBJECT */; @@ -9389,8 +7547,7 @@ private static void SLFunctionLiteral_execute_(VirtualFrame $frame, OperationNod return; } - private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -9402,23 +7559,10 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, Node node__ = null; if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, - $this)); + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * perform - * ( - * TruffleString, - * SLFunction, - * Node) - */); - if ((state_0 & 0b10) == 0b10/* - * is-exact-state_0 perform(TruffleString, - * SLFunction, Node) - */) { + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM); } else { $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); @@ -9432,7 +7576,7 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, return; } } - throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); } finally { if (hasLock) { lock.unlock(); @@ -9440,8 +7584,7 @@ private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, } } - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value) { + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -9450,20 +7593,7 @@ private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, Operatio private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* - * is - * - - * not - * doBoolean - * ( - * boolean) - * && - * doFallback - * ( - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); return; } else { @@ -9472,8 +7602,7 @@ private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl } } - private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; boolean $child0Value_; @@ -9494,8 +7623,7 @@ private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $fra return; } - private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0) { + private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; Object $child0Value_ = expectObject($frame, $sp - 1); @@ -9529,8 +7657,7 @@ private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $fra return; } - private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -9540,14 +7667,7 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doBoolean - * ( - * boolean) - */); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN); } else { @@ -9575,16 +7695,7 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * doFallback - * ( - * Object, - * Node, - * int) - */); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); int type0; type0 = 0 /* OBJECT */; @@ -9607,28 +7718,14 @@ private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, Opera } @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, - Object[] arg1Value) { + private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b1110) != 0 /* - * is-state_0 doDirect(SLFunction, Object[], Assumption, - * RootCallTarget, DirectCallNode) || - * doIndirect(SLFunction, Object[], IndirectCallNode) || - * doInterop(Object, Object[], InteropLibrary, Node, - * int) - */) { - if ((state_0 & 0b110) != 0 /* - * is-state_0 doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, DirectCallNode) || - * doIndirect(SLFunction, Object[], IndirectCallNode) - */ && arg0Value instanceof SLFunction) { + if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* - * is-state_0 doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, DirectCallNode) - */) { + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); while (s0_ != null) { if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { @@ -9642,20 +7739,14 @@ private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $ s0_ = s0_.next_; } } - if ((state_0 & 0b100) != 0 /* - * is-state_0 doIndirect(SLFunction, Object[], - * IndirectCallNode) - */) { + if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { IndirectCallNode indirect_callNode__ = ((IndirectCallNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1]); if (indirect_callNode__ != null) { return SLInvoke.doIndirect(arg0Value_, arg1Value, indirect_callNode__); } } } - if ((state_0 & 0b1000) != 0 /* - * is-state_0 doInterop(Object, Object[], - * InteropLibrary, Node, int) - */) { + if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { { Node interop_node__ = ($this); int interop_bci__ = ($bci); @@ -9670,8 +7761,7 @@ private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $ return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); } - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, - Object[] arg1Value) { + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); @@ -9682,16 +7772,10 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat short exclude = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1]; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* - * is-not-exclude doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, DirectCallNode) - */) { + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { int count0_ = 0; SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); - if ((state_0 & 0b10) != 0 /* - * is-state_0 doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, DirectCallNode) - */) { + if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { while (s0_ != null) { if ((arg0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { break; @@ -9714,30 +7798,8 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doDirect - * ( - * SLFunction, - * Object - * [ - * ] - * , - * Assumption, - * RootCallTarget, - * DirectCallNode) - */); - if ((state_0 & 0b1110) == 0b10/* - * is-exact-state_0 - * doDirect( - * SLFunction, - * Object[], - * Assumption, - * RootCallTarget, - * DirectCallNode) - */) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { $bc[$bci] = (short) (INSTR_C_SL_INVOKE_Q_DIRECT); } else { $bc[$bci] = (short) (INSTR_C_SL_INVOKE); @@ -9754,41 +7816,10 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat } } $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* - * add - * - - * exclude - * doDirect - * ( - * SLFunction, - * Object - * [ - * ] - * , - * Assumption, - * RootCallTarget, - * DirectCallNode) - */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* - * remove-state_0 - * doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, - * DirectCallNode) - */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* - * add - * - - * state_0 - * doIndirect - * ( - * SLFunction, - * Object - * [ - * ] - * , - * IndirectCallNode) - */); + state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); $bc[$bci] = (short) (INSTR_C_SL_INVOKE); lock.unlock(); hasLock = false; @@ -9800,21 +7831,7 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, Operat $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); interop_node__ = ($this); interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* - * add - * - - * state_0 - * doInterop - * ( - * Object, - * Object - * [ - * ] - * , - * InteropLibrary, - * Node, - * int) - */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); $bc[$bci] = (short) (INSTR_C_SL_INVOKE); lock.unlock(); hasLock = false; @@ -9848,29 +7865,14 @@ private static void SLInvoke_removeDirect__(VirtualFrame $frame, OperationNodeIm cur = cur.next_; } if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * doDirect - * ( - * SLFunction, - * Object - * [ - * ] - * , - * Assumption, - * RootCallTarget, - * DirectCallNode) - */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } } finally { lock.unlock(); } } - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value) { + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -9879,20 +7881,7 @@ private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeI private static boolean SLAnd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* - * is - * - - * not - * doBoolean - * ( - * boolean) - * && - * doFallback - * ( - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); @@ -9944,14 +7933,7 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* - * add - * - - * state_0 - * doBoolean - * ( - * boolean) - */); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); lock.unlock(); hasLock = false; return SLToBooleanNode.doBoolean($child0Value_); @@ -9961,16 +7943,7 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doFallback - * ( - * Object, - * Node, - * int) - */); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); lock.unlock(); hasLock = false; return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); @@ -9982,8 +7955,7 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, Operatio } } - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value) { + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -9992,20 +7964,7 @@ private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeIm private static boolean SLOr_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* - * is - * - - * not - * doBoolean - * ( - * boolean) - * && - * doFallback - * ( - * Object, - * Node, - * int) - */)) { + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); @@ -10057,14 +8016,7 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, Operation short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* - * add - * - - * state_0 - * doBoolean - * ( - * boolean) - */); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); lock.unlock(); hasLock = false; return SLToBooleanNode.doBoolean($child0Value_); @@ -10074,16 +8026,7 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, Operation Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* - * add - * - - * state_0 - * doFallback - * ( - * Object, - * Node, - * int) - */); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); lock.unlock(); hasLock = false; return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); @@ -10118,16 +8061,11 @@ private static void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, OperationNo return; } - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, - Object $child0Value, Object $child1Value) { + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } - if (((state_0 & 0b1000)) == 0 /* - * is-not-state_0 add(Object, Object, - * SLToTruffleStringNode, SLToTruffleStringNode, - * ConcatNode) - */ && (SLAddNode.isString($child0Value, $child1Value))) { + if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { return false; } return true; @@ -10170,24 +8108,8 @@ private static void SLAdd_q_AddLong_execute_(VirtualFrame $frame, OperationNodeI Lock lock = $this.getLockAccessor(); lock.lock(); try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* - * add - * - - * exclude - * addLong - * ( - * long, - * long) - */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * addLong - * ( - * long, - * long) - */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); } finally { lock.unlock(); } @@ -10204,14 +8126,10 @@ private static void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, Object $child1Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* - * is-state_0 readSLObject(SLObject, Object, Node, - * int, DynamicObjectLibrary, SLToTruffleStringNode) - */; + assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { Node node__ = ($this); @@ -10251,8 +8169,7 @@ private static void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, Operatio return; } - private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - short state_0, Object $child0Value) { + private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { return false; } @@ -10282,8 +8199,7 @@ private static void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, Operatio return; } - private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -10324,15 +8240,11 @@ private static void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, O } @ExplodeLoop - private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, - Object[] arg1Value) { + private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { short state_0 = $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0]; int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* - * is-state_0 doDirect(SLFunction, Object[], - * Assumption, RootCallTarget, DirectCallNode) - */; + assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0]); @@ -10375,21 +8287,7 @@ private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, Operat cur = cur.next_; } if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* - * remove - * - - * state_0 - * doDirect - * ( - * SLFunction, - * Object - * [ - * ] - * , - * Assumption, - * RootCallTarget, - * DirectCallNode) - */); + $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } } finally { lock.unlock(); @@ -10401,9 +8299,7 @@ private static void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, Op Object $child0Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* - * is-state_0 perform(TruffleString, SLFunction, Node) - */; + assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; if ($child0Value_ instanceof TruffleString) { TruffleString $child0Value__ = (TruffleString) $child0Value_; { @@ -10429,14 +8325,10 @@ private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $fram Object $child2Value_ = expectObject($frame, $sp - 1); int childArrayOffset_; int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* - * is-state_0 writeSLObject(SLObject, Object, Object, - * DynamicObjectLibrary, SLToTruffleStringNode) - */; + assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; if ($child0Value_ instanceof SLObject) { SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, - $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); while (s2_ != null) { if ((s2_.objectLibrary_.accepts($child0Value__))) { $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); @@ -10451,8 +8343,7 @@ private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $fram return; } - private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } @@ -10535,7 +8426,6 @@ T insertAccessor(T node) { } } - private static final class SLEqual_Generic0Data extends Node { @Child SLEqual_Generic0Data next_; @@ -10556,7 +8446,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadArray0Data extends Node { @Child SLReadProperty_ReadArray0Data next_; @@ -10577,7 +8466,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadSLObject0Data extends Node { @Child SLReadProperty_ReadSLObject0Data next_; @@ -10598,7 +8486,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadObject0Data extends Node { @Child SLReadProperty_ReadObject0Data next_; @@ -10619,7 +8506,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteArray0Data extends Node { @Child SLWriteProperty_WriteArray0Data next_; @@ -10640,7 +8526,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { @Child SLWriteProperty_WriteSLObject0Data next_; @@ -10661,7 +8546,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteObject0Data extends Node { @Child SLWriteProperty_WriteObject0Data next_; @@ -10682,7 +8566,6 @@ T insertAccessor(T node) { } } - private static final class SLUnbox_FromForeign0Data extends Node { @Child SLUnbox_FromForeign0Data next_; @@ -10702,7 +8585,6 @@ T insertAccessor(T node) { } } - @GeneratedBy(SLOperations.class) private static final class SLInvoke_DirectData extends Node { @@ -10726,7 +8608,6 @@ T insertAccessor(T node) { } } - @GeneratedBy(SLOperations.class) private static final class UncachedBytecodeNode extends BytecodeLoopBase { @@ -10736,8 +8617,7 @@ private static final class UncachedBytecodeNode extends BytecodeLoopBase { @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) @BytecodeInterpreterSwitch @Override - int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, - int[] $conditionProfiles, int maxLocals) { + int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { int $sp = $startSp; int $bci = $startBci; Counter loopCounter = new Counter(); @@ -10753,22 +8633,24 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } switch (curOpcode) { // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_POP: { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_POP : + { $sp = $sp - 1; $frame.clear($sp); $bci = $bci + POP_LENGTH; continue loop; } // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Boxing Elimination: Do Nothing - case INSTR_BRANCH: { + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Boxing Elimination: Do Nothing + case INSTR_BRANCH : + { int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { TruffleSafepoint.poll($this); @@ -10786,15 +8668,16 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - // Boxing Elimination: Do Nothing - case INSTR_BRANCH_FALSE: { + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + // Boxing Elimination: Do Nothing + case INSTR_BRANCH_FALSE : + { boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; $sp = $sp - 1; if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { @@ -10806,35 +8689,38 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_THROW: { + // Locals: + // [ 0] exception + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_THROW : + { int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; throw (AbstractTruffleException) $frame.getObject(slot); } // load.constant.object - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_OBJECT: { + // Constants: + // [ 0] constant + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_OBJECT : + { $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } // load.argument.object - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; $frame.setObject($sp, value); $sp = $sp + 1; @@ -10842,16 +8728,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; if (value instanceof Long) { $frame.setLong($sp, (long) value); @@ -10863,16 +8750,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; if (value instanceof Boolean) { $frame.setBoolean($sp, (boolean) value); @@ -10884,16 +8772,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // store.local.uninit - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_LONG - // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN - case INSTR_STORE_LOCAL_UNINIT: { + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Replace + // OBJECT -> INSTR_STORE_LOCAL_OBJECT + // LONG -> INSTR_STORE_LOCAL_LONG + // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN + case INSTR_STORE_LOCAL_UNINIT : + { int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; $frame.copyObject(sourceSlot, localIdx); @@ -10902,14 +8791,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // load.local.uninit - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_LONG - // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN - case INSTR_LOAD_LOCAL_UNINIT: { + // Locals: + // [ 0] local + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> INSTR_LOAD_LOCAL_LONG + // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN + case INSTR_LOAD_LOCAL_UNINIT : + { int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; $frame.setObject($sp, expectObject($frame, localIdx)); $sp++; @@ -10917,11 +8807,12 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_RETURN: { + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + // Boxing Elimination: Do Nothing + case INSTR_RETURN : + { uncachedExecuteCount++; if (uncachedExecuteCount > 16) { $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); @@ -10929,422 +8820,324 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s return (($sp - 1) << 16) | 0xffff; } // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1, method = public static - // com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, - // java.lang.Object, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, - // com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = - // [Guard[(SLAddNode.isString(left, right))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f1a38a - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@375dedc - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@35cc264b - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1d4a35d2 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b0e5992 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41791417 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4a2aea20 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@8bb9c4b + // Boxing Elimination: Bit Mask + case INSTR_C_SL_ADD : + { UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_ADD_LENGTH; continue loop; } // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5119e3c8 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16b0a9c1 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e2d136 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@24dc4ee8 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_DIV: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c48e45c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@567d16d3 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e590fd4 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@119e11b8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_DIV : + { UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_DIV_LENGTH; continue loop; } // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static - // boolean doGeneric(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(leftInterop.accepts(left))], - // Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, - // java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@18d3b56e - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@357d1b96 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7076da46 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c5e853f - // Boxing Elimination: Bit Mask - case INSTR_C_SL_EQUAL: { + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f760747 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16267112 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@cf88241 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58f51e51 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_EQUAL : + { UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_EQUAL_LENGTH; continue loop; } // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2b64a952 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@58d188e3 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d770d8e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2ea49d34 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_OR_EQUAL : + { UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; continue loop; } // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3809e35e - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1e3c361f - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@13825d7d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4f565a89 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LESS_THAN : + { UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_LESS_THAN_LENGTH; continue loop; } // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d7459f4 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@58de6b74 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LOGICAL_NOT: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3c613c75 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77423a8 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_LOGICAL_NOT : + { UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); $sp = $sp - 1 + 1; $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; continue loop; } // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@60885467 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e284f1d - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10617a2d - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44a37e52 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_MUL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@196a740a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@c6401d4 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7783b281 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc4dc78 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_MUL : + { UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_MUL_LENGTH; continue loop; } // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static - // java.lang.Object readArray(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static - // java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static - // java.lang.Object readObject(java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objects.accepts(receiver))], - // Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], - // Guard[(objects.hasMembers(receiver))]], signature = - // [java.lang.Object, java.lang.Object]] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@194c5295 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@66803b1 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b503417 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fe7dc2 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d8ccc90 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@383bdbc0 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b535b + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26f44997 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_READ_PROPERTY : + { UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_READ_PROPERTY_LENGTH; continue loop; } // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24614477 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@89db741 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@b55dde2 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@545b6334 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_SUB: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@723b32e9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5efde7db + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c09e072 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f5c297 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_SUB : + { UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 2 + 1; $bci = $bci + C_SL_SUB_LENGTH; continue loop; } // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static - // java.lang.Object writeArray(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], - // Guard[(arrays.hasArrayElements(receiver))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static - // java.lang.Object - // writeSLObject(com.oracle.truffle.sl.runtime.SLObject, - // java.lang.Object, java.lang.Object, - // com.oracle.truffle.api.object.DynamicObjectLibrary, - // com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))]], signature = - // [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, - // java.lang.Object]] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static - // java.lang.Object writeObject(java.lang.Object, java.lang.Object, - // java.lang.Object, com.oracle.truffle.api.nodes.Node, int, - // com.oracle.truffle.api.interop.InteropLibrary, - // com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = - // [Guard[(objectLibrary.accepts(receiver))], - // Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = - // [java.lang.Object, java.lang.Object, java.lang.Object]] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73be843d - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@358d7470 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e111524 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@de27549 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY: { - UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 3), $frame.getObject($sp - 2), - $frame.getObject($sp - 1)); + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@357e48d8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@537d706c + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d0eeab9 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4932aa7e + // Boxing Elimination: Bit Mask + case INSTR_C_SL_WRITE_PROPERTY : + { + UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 3), $frame.getObject($sp - 2), $frame.getObject($sp - 1)); $sp = $sp - 3 + 1; $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; continue loop; } // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static - // java.lang.Object fromForeign(java.lang.Object, - // com.oracle.truffle.api.interop.InteropLibrary) , guards = - // [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1be1cc4a - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ea357c8 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28fd03da - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27309732 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX: { + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78fabc90 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49885f6b + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4abbc95a + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73e35be0 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_UNBOX : + { UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); $sp = $sp - 1 + 1; $bci = $bci + C_SL_UNBOX_LENGTH; continue loop; } // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79bbab4d - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@41ee1ec5 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL: { + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@e77e60a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@49823c07 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_FUNCTION_LITERAL : + { UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); $sp = $sp - 1 + 1; $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; continue loop; } // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@27cb6efe - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5fb8638c - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36b119b8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15bf1e13 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_TO_BOOLEAN : + { UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); $sp = $sp - 1 + 1; $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; continue loop; } // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct, method = protected static - // java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, - // java.lang.Object[], com.oracle.truffle.api.Assumption, - // com.oracle.truffle.api.RootCallTarget, - // com.oracle.truffle.api.nodes.DirectCallNode) , guards = - // [Guard[(function.getCallTarget() == cachedTarget)]], signature = - // [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@325d65d1 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56247945 - // [ 2] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f1b5872 - // [ 3] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c31d5a4 - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // Simple Pops: + // [ 0] arg0 + // Variadic + // Pushed Values: 1 + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b822dc2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fa4ade + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1dae4e7 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@680f8367 + // Boxing Elimination: Bit Mask + case INSTR_C_SL_INVOKE : + { int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; Object input_0 = $frame.getObject($sp - numVariadics - 1); Object[] input_1 = new Object[numVariadics]; @@ -11358,22 +9151,21 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@72e1410f - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d18ecd1 - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_AND: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@218ca97d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30b5f865 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_AND : + { if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_AND_LENGTH; @@ -11384,22 +9176,21 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s } } // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@ea17d33 - // [ 1] - // com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11205afd - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_OR: { + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fce182d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d9737e6 + // Boxing Elimination: Do Nothing + case INSTR_SC_SL_OR : + { if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; $bci = $bci + SC_SL_OR_LENGTH; @@ -11409,7 +9200,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s continue loop; } } - default: + default : CompilerDirectives.transferToInterpreterAndInvalidate(); throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); } @@ -11418,8 +9209,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { CompilerAsserts.partialEvaluationConstant(handlerIndex); ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) - continue; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; $sp = handler.startStack + maxLocals; $frame.setObject(handler.exceptionIndex, ex); $bci = handler.handlerBci; @@ -11435,185 +9225,230 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ int $bci = 0; while ($bci < $bc.length) { switch (unsafeFromBytecode($bc, $bci)) { - case INSTR_POP: { + case INSTR_POP : + { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH: { + case INSTR_BRANCH : + { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE: { + case INSTR_BRANCH_FALSE : + { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW: { + case INSTR_THROW : + { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT: { + case INSTR_LOAD_CONSTANT_OBJECT : + { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG: { + case INSTR_LOAD_CONSTANT_LONG : + { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN: { + case INSTR_LOAD_CONSTANT_BOOLEAN : + { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT: { + case INSTR_LOAD_ARGUMENT_OBJECT : + { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG: { + case INSTR_LOAD_ARGUMENT_LONG : + { $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT: { + case INSTR_STORE_LOCAL_OBJECT : + { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG: { + case INSTR_STORE_LOCAL_LONG : + { $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN: { + case INSTR_STORE_LOCAL_BOOLEAN : + { $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT: { + case INSTR_STORE_LOCAL_UNINIT : + { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT: { + case INSTR_LOAD_LOCAL_OBJECT : + { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG: { + case INSTR_LOAD_LOCAL_LONG : + { $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN: { + case INSTR_LOAD_LOCAL_BOOLEAN : + { $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT: { + case INSTR_LOAD_LOCAL_UNINIT : + { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN: { + case INSTR_RETURN : + { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD: { + case INSTR_C_SL_ADD : + { $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV: { + case INSTR_C_SL_DIV : + { $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL: { + case INSTR_C_SL_EQUAL : + { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL: { + case INSTR_C_SL_LESS_OR_EQUAL : + { $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN: { + case INSTR_C_SL_LESS_THAN : + { $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT: { + case INSTR_C_SL_LOGICAL_NOT : + { $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL: { + case INSTR_C_SL_MUL : + { $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY: { + case INSTR_C_SL_READ_PROPERTY : + { $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB: { + case INSTR_C_SL_SUB : + { $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY: { + case INSTR_C_SL_WRITE_PROPERTY : + { $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX: { + case INSTR_C_SL_UNBOX : + { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL: { + case INSTR_C_SL_FUNCTION_LITERAL : + { $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN : + { $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE: { + case INSTR_C_SL_INVOKE : + { $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND: { + case INSTR_SC_SL_AND : + { $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR: { + case INSTR_SC_SL_OR : + { $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG: { + case INSTR_C_SL_ADD_Q_ADD_LONG : + { $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT: { + case INSTR_C_SL_INVOKE_Q_DIRECT : + { $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; break; } @@ -11628,11 +9463,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { while ($bci < $bc.length) { sb.append(String.format(" [%04x]", $bci)); switch (unsafeFromBytecode($bc, $bci)) { - default: { + default : + { sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); break; } - case INSTR_POP: { + case INSTR_POP : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -11645,7 +9482,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + POP_LENGTH; break; } - case INSTR_BRANCH: { + case INSTR_BRANCH : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11659,7 +9497,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_BRANCH_FALSE: { + case INSTR_BRANCH_FALSE : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11673,7 +9512,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_THROW: { + case INSTR_THROW : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11687,7 +9527,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + THROW_LENGTH; break; } - case INSTR_LOAD_CONSTANT_OBJECT: { + case INSTR_LOAD_CONSTANT_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11701,7 +9542,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG: { + case INSTR_LOAD_CONSTANT_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11715,7 +9557,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN: { + case INSTR_LOAD_CONSTANT_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11729,7 +9572,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_OBJECT: { + case INSTR_LOAD_ARGUMENT_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11743,7 +9587,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG: { + case INSTR_LOAD_ARGUMENT_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11757,7 +9602,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN: { + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11771,7 +9617,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_OBJECT: { + case INSTR_STORE_LOCAL_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11786,7 +9633,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG: { + case INSTR_STORE_LOCAL_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11801,7 +9649,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN: { + case INSTR_STORE_LOCAL_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11816,7 +9665,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_UNINIT: { + case INSTR_STORE_LOCAL_UNINIT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11831,7 +9681,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; break; } - case INSTR_LOAD_LOCAL_OBJECT: { + case INSTR_LOAD_LOCAL_OBJECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11845,7 +9696,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG: { + case INSTR_LOAD_LOCAL_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11859,7 +9711,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN: { + case INSTR_LOAD_LOCAL_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11873,7 +9726,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_UNINIT: { + case INSTR_LOAD_LOCAL_UNINIT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(" "); @@ -11887,7 +9741,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; break; } - case INSTR_RETURN: { + case INSTR_RETURN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(" "); sb.append(" "); @@ -11900,7 +9755,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + RETURN_LENGTH; break; } - case INSTR_C_SL_ADD: { + case INSTR_C_SL_ADD : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11916,7 +9772,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_ADD_LENGTH; break; } - case INSTR_C_SL_DIV: { + case INSTR_C_SL_DIV : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11932,7 +9789,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_DIV_LENGTH; break; } - case INSTR_C_SL_EQUAL: { + case INSTR_C_SL_EQUAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11947,7 +9805,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL: { + case INSTR_C_SL_LESS_OR_EQUAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11963,7 +9822,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; break; } - case INSTR_C_SL_LESS_THAN: { + case INSTR_C_SL_LESS_THAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11979,7 +9839,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_THAN_LENGTH; break; } - case INSTR_C_SL_LOGICAL_NOT: { + case INSTR_C_SL_LOGICAL_NOT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -11994,7 +9855,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; break; } - case INSTR_C_SL_MUL: { + case INSTR_C_SL_MUL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12010,7 +9872,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_MUL_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY: { + case INSTR_C_SL_READ_PROPERTY : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12028,7 +9891,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_READ_PROPERTY_LENGTH; break; } - case INSTR_C_SL_SUB: { + case INSTR_C_SL_SUB : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12044,7 +9908,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_SUB_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY: { + case INSTR_C_SL_WRITE_PROPERTY : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12063,7 +9928,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; break; } - case INSTR_C_SL_UNBOX: { + case INSTR_C_SL_UNBOX : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12077,7 +9943,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL: { + case INSTR_C_SL_FUNCTION_LITERAL : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12092,7 +9959,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12107,7 +9975,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_INVOKE: { + case INSTR_C_SL_INVOKE : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12122,7 +9991,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_INVOKE_LENGTH; break; } - case INSTR_SC_SL_AND: { + case INSTR_SC_SL_AND : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12138,7 +10008,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + SC_SL_AND_LENGTH; break; } - case INSTR_SC_SL_OR: { + case INSTR_SC_SL_OR : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12154,7 +10025,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG: { + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12168,7 +10040,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; break; } - case INSTR_C_SL_ADD_Q_ADD_LONG: { + case INSTR_C_SL_ADD_Q_ADD_LONG : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12184,7 +10057,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; break; } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0: { + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12202,7 +10076,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN: { + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12216,7 +10091,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN: { + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12231,7 +10107,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; break; } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0: { + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12247,7 +10124,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; break; } - case INSTR_C_SL_INVOKE_Q_DIRECT: { + case INSTR_C_SL_INVOKE_Q_DIRECT : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12262,7 +10140,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; break; } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM: { + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12277,7 +10156,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; break; } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0: { + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12296,7 +10176,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; break; } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0: { + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : + { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); sb.append(String.format(" %04x", $bc[$bci + 2])); @@ -12321,8 +10202,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { return sb.toString(); } - private static void SLAdd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLAdd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { @@ -12332,16 +10214,16 @@ private static void SLAdd_executeUncached_(VirtualFrame $frame, OperationNodeImp } } if ((SLAddNode.isString($child0Value, $child1Value))) { - $frame.setObject($sp - 2, - SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); return; } $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); return; } - private static void SLDiv_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLDiv_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { @@ -12354,19 +10236,15 @@ private static void SLDiv_executeUncached_(VirtualFrame $frame, OperationNodeImp return; } - private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12379,12 +10257,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12397,12 +10270,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child1Value instanceof Boolean) { boolean $child1Value_ = (boolean) $child1Value; boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12415,12 +10283,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child1Value instanceof String) { String $child1Value_ = (String) $child1Value; boolean value = SLEqualNode.doString($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12433,12 +10296,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child1Value instanceof TruffleString) { TruffleString $child1Value_ = (TruffleString) $child1Value; boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12451,12 +10309,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if (SLTypes.isSLNull($child1Value)) { SLNull $child1Value_ = SLTypes.asSLNull($child1Value); boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12467,12 +10320,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12480,10 +10328,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI return; } boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not-state_0 - * RESULT-UNBOXED - */) { + if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12491,23 +10336,15 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI return; } - private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12520,16 +10357,7 @@ private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, Operatio if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12541,21 +10369,15 @@ private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, Operatio return; } - private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is- - * not- - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12568,14 +10390,7 @@ private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNo if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is- - * not- - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -12588,15 +10403,12 @@ private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNo } private static void SLLogicalNot_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12607,8 +10419,9 @@ private static void SLLogicalNot_executeUncached_(VirtualFrame $frame, Operation return; } - private static void SLMul_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLMul_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { @@ -12621,29 +10434,28 @@ private static void SLMul_executeUncached_(VirtualFrame $frame, OperationNodeImp return; } - private static void SLReadProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLReadProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (INTEROP_LIBRARY_.getUncached($child1Value)))); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); return; } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), - (SLToTruffleStringNodeGen.getUncached()))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); return; } if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - $frame.setObject($sp - 2, - SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } - private static void SLSub_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLSub_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { @@ -12656,28 +10468,28 @@ private static void SLSub_executeUncached_(VirtualFrame $frame, OperationNodeImp return; } - private static void SLWriteProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value, Object $child2Value) { + private static void SLWriteProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (INTEROP_LIBRARY_.getUncached($child1Value)))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); return; } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), - (SLToTruffleStringNodeGen.getUncached()))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); return; } if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (SLToMemberNodeGen.getUncached()))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); @@ -12691,12 +10503,7 @@ private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12706,12 +10513,7 @@ private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeI if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setLong($sp - 1, value); @@ -12737,26 +10539,24 @@ private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeI return; } - private static void SLFunctionLiteral_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLFunctionLiteral_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); } private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLToBooleanNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12764,12 +10564,7 @@ private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationN return; } boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is-not- - * state_0 - * RESULT- - * UNBOXED - */) { + if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12777,8 +10572,9 @@ private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationN return; } - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, - Object[] arg1Value) { + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + int childArrayOffset_; + int constArrayOffset_; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); @@ -12787,6 +10583,8 @@ private static Object SLInvoke_executeUncached_(VirtualFrame $frame, OperationNo } private static boolean SLAnd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; return SLToBooleanNode.doBoolean($child0Value_); @@ -12795,6 +10593,8 @@ private static boolean SLAnd_executeUncached_(VirtualFrame $frame, OperationNode } private static boolean SLOr_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; return SLToBooleanNode.doBoolean($child0Value_); @@ -12802,8 +10602,9 @@ private static boolean SLOr_executeUncached_(VirtualFrame $frame, OperationNodeI return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); @@ -12817,16 +10618,7 @@ private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, Ope if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12836,16 +10628,7 @@ private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, Ope if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setLong($sp - 1, value); @@ -12871,8 +10654,9 @@ private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, Ope return; } - private static void SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, - Object $child1Value) { + private static void SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { @@ -12882,37 +10666,35 @@ private static void SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, Operat } } if ((SLAddNode.isString($child0Value, $child1Value))) { - $frame.setObject($sp - 2, - SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); + $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); return; } $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); return; } - private static void SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static void SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (INTEROP_LIBRARY_.getUncached($child1Value)))); + $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); return; } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), - (SLToTruffleStringNodeGen.getUncached()))); + $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); return; } if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - $frame.setObject($sp - 2, - SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); + $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } - private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof String) { String $child0Value_ = (String) $child0Value; $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); @@ -12926,16 +10708,7 @@ private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -12945,16 +10718,7 @@ private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setLong($sp - 1, value); @@ -12980,21 +10744,13 @@ private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, return; } - private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; boolean value = SLToBooleanNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -13002,16 +10758,7 @@ private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, return; } boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 1, value); } else { $frame.setBoolean($sp - 1, value); @@ -13019,23 +10766,15 @@ private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, return; } - private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -13048,16 +10787,7 @@ private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $ if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -13069,8 +10799,9 @@ private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $ return; } - private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, - Object[] arg1Value) { + private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { + int childArrayOffset_; + int constArrayOffset_; if (arg0Value instanceof SLFunction) { SLFunction arg0Value_ = (SLFunction) arg0Value; return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); @@ -13078,54 +10809,45 @@ private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, Op return SLInvoke.doInterop(arg0Value, arg1Value, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); } - private static void SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value) { + private static void SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null}, $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); } - private static void SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value, Object $child2Value) { + private static void SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (INTEROP_LIBRARY_.getUncached($child1Value)))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); return; } if ($child0Value instanceof SLObject) { SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), - (SLToTruffleStringNodeGen.getUncached()))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); return; } if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), - (SLToMemberNodeGen.getUncached()))); + $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); return; } - throw new UnsupportedSpecializationException($this, new Node[]{null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); } - private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, - Object $child0Value, Object $child1Value) { + private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -13138,16 +10860,7 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* - * is - * - - * not - * - - * state_0 - * RESULT - * - - * UNBOXED - */) { + if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { $frame.setObject($sp - 2, value); } else { $frame.setBoolean($sp - 2, value); @@ -13196,7 +10909,6 @@ T insertAccessor(T node) { } } - private static final class SLEqual_Generic0Data extends Node { @Child SLEqual_Generic0Data next_; @@ -13217,7 +10929,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadArray0Data extends Node { @Child SLReadProperty_ReadArray0Data next_; @@ -13238,7 +10949,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadSLObject0Data extends Node { @Child SLReadProperty_ReadSLObject0Data next_; @@ -13259,7 +10969,6 @@ T insertAccessor(T node) { } } - private static final class SLReadProperty_ReadObject0Data extends Node { @Child SLReadProperty_ReadObject0Data next_; @@ -13280,7 +10989,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteArray0Data extends Node { @Child SLWriteProperty_WriteArray0Data next_; @@ -13301,7 +11009,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { @Child SLWriteProperty_WriteSLObject0Data next_; @@ -13322,7 +11029,6 @@ T insertAccessor(T node) { } } - private static final class SLWriteProperty_WriteObject0Data extends Node { @Child SLWriteProperty_WriteObject0Data next_; @@ -13343,7 +11049,6 @@ T insertAccessor(T node) { } } - private static final class SLUnbox_FromForeign0Data extends Node { @Child SLUnbox_FromForeign0Data next_; @@ -13363,7 +11068,6 @@ T insertAccessor(T node) { } } - @GeneratedBy(SLOperations.class) private static final class SLInvoke_DirectData extends Node { @@ -13388,7 +11092,6 @@ T insertAccessor(T node) { } } } - private static final class Counter { public int count; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 693311482960..e71c1b585fd2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateAOT; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -55,8 +56,9 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.Variadic; -@GenerateAOT @GenerateOperations +@GenerateUncached +@GenerateAOT public final class TestOperations { @Metadata public static final MetadataKey TestData = new MetadataKey<>("default value"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index a5a8d8da63b0..8f9086288ef3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1878,6 +1878,10 @@ private CodeExecutableElement createUncachedExecute(ExecutableTypeData forType) CodeTreeBuilder builder = method.createBuilder(); + if (plugs != null) { + plugs.initializeFrameState(frameState, builder); + } + int effectiveEvaluatedCount = forType.getEvaluatedCount(); while (effectiveEvaluatedCount < node.getExecutionCount()) { NodeExecutionData childExecution = node.getChildExecutions().get(effectiveEvaluatedCount); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 15f8632c00be..de3f41562863 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -68,6 +68,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; +import com.oracle.truffle.dsl.processor.model.MessageContainer.Message; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; @@ -260,7 +261,14 @@ protected SingleOperationData parse(Element element, List mirr return data; } - nodeData.redirectMessagesOnGeneratedElements(data); + if (proxyMirror != null && nodeData.hasErrors()) { + for (Message m : nodeData.collectMessages()) { + Message nm = new Message(proxyMirror, null, null, m.getOriginalContainer(), m.getText(), m.getKind()); + data.getMessages().add(nm); + } + } else { + nodeData.redirectMessagesOnGeneratedElements(data); + } data.setNodeData(nodeData); // replace the default node type system with Operations one if we have it @@ -355,6 +363,7 @@ private CodeExecutableElement createExecuteUncachedMethod(MethodProperties props metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); int i = 0; + int lr = 0; for (ParameterKind param : props.parameters) { switch (param) { case STACK_VALUE: @@ -364,7 +373,11 @@ private CodeExecutableElement createExecuteUncachedMethod(MethodProperties props metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); break; case LOCAL_SETTER: + metExecute.addParameter(new CodeVariableElement(types.LocalSetter, "localRef" + (lr++))); + break; case LOCAL_SETTER_ARRAY: + metExecute.addParameter(new CodeVariableElement(types.LocalSetterRange, "localRefs")); + break; case VIRTUAL_FRAME: break; default: diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index e3f9287d8f39..c1a21d212d6e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -49,6 +49,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -97,6 +98,8 @@ public CustomInstruction(String name, int id, SingleOperationData data) { public static final String MARKER_LOCAL_REFS = "LocalSetterRange"; public static final String MARKER_LOCAL_REF_PREFIX = "LocalSetter_"; + private int[] localRefs = null; + protected void initializePops() { MethodProperties props = data.getMainProperties(); @@ -112,10 +115,12 @@ protected void initializePops() { } if (props.numLocalReferences == -1) { - addConstant(MARKER_LOCAL_REFS, new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); + localRefs = new int[0]; + localRefs[0] = addConstant(MARKER_LOCAL_REFS, new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); } else { + localRefs = new int[props.numLocalReferences]; for (int i = 0; i < props.numLocalReferences; i++) { - addConstant(MARKER_LOCAL_REF_PREFIX + i, types.OperationLocal); + localRefs[i] = addConstant(MARKER_LOCAL_REF_PREFIX + i, types.OperationLocal); } } } @@ -135,6 +140,16 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { return createExecuteImpl(vars, true); } + private void addLocalRefs(CodeTreeBuilder b, ExecutionVariables vars) { + if (data.getMainProperties().numLocalReferences == -1) { + b.startGroup().cast(types.LocalSetterRange).variable(vars.consts).string("[").tree(createConstantIndex(vars, localRefs[0])).string("]").end(); + } else { + for (int i = 0; i < data.getMainProperties().numLocalReferences; i++) { + b.startGroup().cast(types.LocalSetter).variable(vars.consts).string("[").tree(createConstantIndex(vars, localRefs[i])).string("]").end(); + } + } + } + private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -186,6 +201,11 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.variable(vars.consts); b.variable(vars.children); b.trees(inputTrees); + + if (uncached) { + addLocalRefs(b, vars); + } + b.end(2); b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + " + numPushedValues).end(); @@ -212,6 +232,8 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { for (int i = numPopStatic(); i > 0; i--) { b.string("$frame.getObject($sp - " + i + ")"); } + + addLocalRefs(b, vars); } b.end(2); From ce138646eb4921830374de8ac2121175dc79e231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 20 Jul 2022 11:54:04 +0200 Subject: [PATCH 113/312] [wip] serialization prototype --- .../sl/operations/SLOperationsBuilder.java | 1702 +++++++++++++---- .../test/example/TestOperationsSerTest.java | 117 ++ .../truffle/api/operation/OperationNode.java | 44 - .../truffle/api/operation/OperationNodes.java | 10 +- .../OperationDeserializationCallback.java | 54 + .../OperationSerializationCallback.java | 55 + .../operations/OperationGeneratorFlags.java | 2 + .../operations/OperationsCodeGenerator.java | 394 +++- .../instructions/CustomInstruction.java | 3 +- 9 files changed, 1976 insertions(+), 405 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 9a5678dc550f..fafe5ac41c5e 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -37,6 +37,8 @@ import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback; +import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.ConcatNode; @@ -66,6 +68,9 @@ import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.lang.invoke.VarHandle; import java.util.ArrayList; import java.util.Arrays; @@ -73,7 +78,7 @@ import java.util.function.Consumer; @GeneratedBy(SLOperations.class) -@SuppressWarnings({"unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) +@SuppressWarnings({"serial", "unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) public abstract class SLOperationsBuilder extends OperationBuilder { protected SLOperationsBuilder() { @@ -225,6 +230,14 @@ public static OperationNodes create(OperationConfig config, Consumer BuilderImpl.deserializeParser(input, callback, b)); + } catch (WrappedIOException ex) { + throw (IOException) ex.getCause(); + } + } + @GeneratedBy(SLOperations.class) private static final class OperationNodesImpl extends OperationNodes { @@ -247,6 +260,16 @@ void setNodes(OperationNode[] nodes) { this.nodes = nodes; } + @Override + public void serialize(DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { + BuilderImpl builder = new BuilderImpl(null, false, OperationConfig.COMPLETE); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + ((Consumer) parse).accept(builder); + buffer.writeShort((short) -5); + } + } @GeneratedBy(SLOperations.class) private static class BuilderImpl extends SLOperationsBuilder { @@ -300,33 +323,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 6; - static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_LONG_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_LONG_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 9; - static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_LONG_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_LONG_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 12; - static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_LONG_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int INSTR_STORE_LOCAL_BOOLEAN = 12; static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; + static final int INSTR_STORE_LOCAL_LONG = 13; + static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_LONG_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -334,12 +357,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 16; - static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_LONG_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_LONG_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -512,7 +535,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // INT null, // DOUBLE @@ -520,7 +543,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // BYTE null}; @@ -534,6 +557,7 @@ private static class BuilderImpl extends SLOperationsBuilder { private int curStack; private int maxStack; private int numLocals; + private int numLabels; private ArrayList constPool = new ArrayList<>(); private BuilderOperationData operationData; private ArrayList labels = new ArrayList<>(); @@ -543,7 +567,17 @@ private static class BuilderImpl extends SLOperationsBuilder { private ArrayList exceptionHandlers = new ArrayList<>(); private BuilderFinallyTryContext currentFinallyTry; private int buildIndex; + private boolean isSerializing; + private DataOutputStream serBuffer; + private OperationSerializationCallback serCallback; private int[] stackSourceBci = new int[1024]; + com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context SER_CONTEXT = new com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context() { + @Override + public void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException { + buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); + } + } + ; private final ArrayList builtNodes; int lastChildPush; private TruffleString metadata_MethodName; @@ -664,6 +698,14 @@ private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { @Override public OperationLocal createLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -3); + return new OperationLocalImpl(null, numLocals++); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + } return new OperationLocalImpl(operationData, numLocals++); } @@ -673,6 +715,14 @@ OperationLocalImpl createParentLocal() { @Override public OperationLabel createLabel() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -2); + return new OperationSerLabelImpl(numLabels++); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + } OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); labels.add(label); return label; @@ -703,6 +753,17 @@ private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData @Override public OperationNode publish() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -1); + OperationNode result = new OperationSerNodeImpl(null, buildIndex++); + numLocals = 0; + numLabels = 0; + return result; + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + } if (operationData.depth != 0) { throw new UnsupportedOperationException("Not all operations closed"); } @@ -1055,6 +1116,14 @@ void doAfterChild() { @SuppressWarnings("unused") @Override public void beginBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BLOCK << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); lastChildPush = 0; @@ -1063,6 +1132,14 @@ public void beginBlock() { @SuppressWarnings("unused") @Override public void endBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_BLOCK) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1077,6 +1154,14 @@ public void endBlock() { @SuppressWarnings("unused") @Override public void beginIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); } @@ -1084,6 +1169,14 @@ public void beginIfThen() { @SuppressWarnings("unused") @Override public void endIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_IF_THEN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1099,6 +1192,14 @@ public void endIfThen() { @SuppressWarnings("unused") @Override public void beginIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); } @@ -1106,6 +1207,14 @@ public void beginIfThenElse() { @SuppressWarnings("unused") @Override public void endIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_IF_THEN_ELSE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1121,6 +1230,14 @@ public void endIfThenElse() { @SuppressWarnings("unused") @Override public void beginConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); } @@ -1128,6 +1245,14 @@ public void beginConditional() { @SuppressWarnings("unused") @Override public void endConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_CONDITIONAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1143,6 +1268,14 @@ public void endConditional() { @SuppressWarnings("unused") @Override public void beginWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_WHILE << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); @@ -1153,6 +1286,14 @@ public void beginWhile() { @SuppressWarnings("unused") @Override public void endWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_WHILE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1168,6 +1309,15 @@ public void endWhile() { @SuppressWarnings("unused") @Override public void beginTryCatch(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); ExceptionHandler beh = new ExceptionHandler(); @@ -1183,6 +1333,14 @@ public void beginTryCatch(OperationLocal arg0) { @SuppressWarnings("unused") @Override public void endTryCatch() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_TRY_CATCH) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1199,6 +1357,14 @@ public void endTryCatch() { @SuppressWarnings("unused") @Override public void beginFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); operationData.aux[2] = createParentLocal(); @@ -1215,6 +1381,14 @@ public void beginFinallyTry() { @SuppressWarnings("unused") @Override public void endFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_FINALLY_TRY) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1251,6 +1425,14 @@ public void endFinallyTry() { @SuppressWarnings("unused") @Override public void beginFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); @@ -1266,6 +1448,14 @@ public void beginFinallyTryNoExcept() { @SuppressWarnings("unused") @Override public void endFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1281,6 +1471,15 @@ public void endFinallyTryNoExcept() { @Override public void emitLabel(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LABEL << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); doEmitLabel(arg0); lastChildPush = 0; @@ -1289,6 +1488,15 @@ public void emitLabel(OperationLabel arg0) { @Override public void emitBranch(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BRANCH << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); @@ -1303,6 +1511,22 @@ public void emitBranch(OperationLabel arg0) { @Override public void emitConstObject(Object arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_CONST_OBJECT << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_CONST_OBJECT, curStack, 0, false, arg0); doBeforeEmitInstruction(0, true); @@ -1318,6 +1542,15 @@ public void emitConstObject(Object arg0) { @Override public void emitLoadArgument(int arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); + serBuffer.writeInt(arg0); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); doBeforeEmitInstruction(0, true); @@ -1332,6 +1565,15 @@ public void emitLoadArgument(int arg0) { @SuppressWarnings("unused") @Override public void beginStoreLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); } @@ -1339,6 +1581,14 @@ public void beginStoreLocal(OperationLocal arg0) { @SuppressWarnings("unused") @Override public void endStoreLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_STORE_LOCAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1358,6 +1608,15 @@ public void endStoreLocal() { @Override public void emitLoadLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); doBeforeEmitInstruction(0, true); @@ -1372,6 +1631,14 @@ public void emitLoadLocal(OperationLocal arg0) { @SuppressWarnings("unused") @Override public void beginReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_RETURN << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); } @@ -1379,6 +1646,14 @@ public void beginReturn() { @SuppressWarnings("unused") @Override public void endReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_RETURN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1398,6 +1673,22 @@ public void endReturn() { @SuppressWarnings("unused") @Override public void beginSource(Source arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_SOURCE << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withSource) { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); @@ -1408,6 +1699,14 @@ public void beginSource(Source arg0) { @SuppressWarnings("unused") @Override public void endSource() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withSource) { if (operationData.operationId != OP_SOURCE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); @@ -1425,6 +1724,16 @@ public void endSource() { @SuppressWarnings("unused") @Override public void beginSourceSection(int arg0, int arg1) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); + serBuffer.writeInt(arg0); + serBuffer.writeInt(arg1); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withSource) { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); @@ -1435,6 +1744,14 @@ public void beginSourceSection(int arg0, int arg1) { @SuppressWarnings("unused") @Override public void endSourceSection() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withSource) { if (operationData.operationId != OP_SOURCE_SECTION) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); @@ -1452,6 +1769,22 @@ public void endSourceSection() { @SuppressWarnings("unused") @Override public void beginTag(Class arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_TAG << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withInstrumentation) { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); @@ -1472,6 +1805,14 @@ public void beginTag(Class arg0) { @SuppressWarnings("unused") @Override public void endTag() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (withInstrumentation) { if (operationData.operationId != OP_TAG) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); @@ -1497,6 +1838,14 @@ public void endTag() { @SuppressWarnings("unused") @Override public void beginSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_ADD << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); } @@ -1504,6 +1853,14 @@ public void beginSLAdd() { @SuppressWarnings("unused") @Override public void endSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_ADD) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1533,6 +1890,14 @@ public void endSLAdd() { @SuppressWarnings("unused") @Override public void beginSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_DIV << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); } @@ -1540,6 +1905,14 @@ public void beginSLDiv() { @SuppressWarnings("unused") @Override public void endSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_DIV) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1569,6 +1942,14 @@ public void endSLDiv() { @SuppressWarnings("unused") @Override public void beginSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); } @@ -1576,6 +1957,14 @@ public void beginSLEqual() { @SuppressWarnings("unused") @Override public void endSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_EQUAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1602,6 +1991,14 @@ public void endSLEqual() { @SuppressWarnings("unused") @Override public void beginSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); } @@ -1609,6 +2006,14 @@ public void beginSLLessOrEqual() { @SuppressWarnings("unused") @Override public void endSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1636,6 +2041,14 @@ public void endSLLessOrEqual() { @SuppressWarnings("unused") @Override public void beginSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); } @@ -1643,6 +2056,14 @@ public void beginSLLessThan() { @SuppressWarnings("unused") @Override public void endSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_LESS_THAN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1670,6 +2091,14 @@ public void endSLLessThan() { @SuppressWarnings("unused") @Override public void beginSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); } @@ -1677,6 +2106,14 @@ public void beginSLLogicalNot() { @SuppressWarnings("unused") @Override public void endSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_LOGICAL_NOT) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1703,6 +2140,14 @@ public void endSLLogicalNot() { @SuppressWarnings("unused") @Override public void beginSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_MUL << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); } @@ -1710,6 +2155,14 @@ public void beginSLMul() { @SuppressWarnings("unused") @Override public void endSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_MUL) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1739,6 +2192,14 @@ public void endSLMul() { @SuppressWarnings("unused") @Override public void beginSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); } @@ -1746,6 +2207,14 @@ public void beginSLReadProperty() { @SuppressWarnings("unused") @Override public void endSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_READ_PROPERTY) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1777,6 +2246,14 @@ public void endSLReadProperty() { @SuppressWarnings("unused") @Override public void beginSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_SUB << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); } @@ -1784,6 +2261,14 @@ public void beginSLSub() { @SuppressWarnings("unused") @Override public void endSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_SUB) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1813,6 +2298,14 @@ public void endSLSub() { @SuppressWarnings("unused") @Override public void beginSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); } @@ -1820,6 +2313,14 @@ public void beginSLWriteProperty() { @SuppressWarnings("unused") @Override public void endSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_WRITE_PROPERTY) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1851,6 +2352,14 @@ public void endSLWriteProperty() { @SuppressWarnings("unused") @Override public void beginSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); } @@ -1858,6 +2367,14 @@ public void beginSLUnbox() { @SuppressWarnings("unused") @Override public void endSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_UNBOX) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1883,6 +2400,14 @@ public void endSLUnbox() { @SuppressWarnings("unused") @Override public void beginSLFunctionLiteral() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); } @@ -1890,9 +2415,17 @@ public void beginSLFunctionLiteral() { @SuppressWarnings("unused") @Override public void endSLFunctionLiteral() { - if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } + if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } int numChildren = operationData.numChildren; if (numChildren != 1) { throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); @@ -1916,6 +2449,14 @@ public void endSLFunctionLiteral() { @SuppressWarnings("unused") @Override public void beginSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); } @@ -1923,6 +2464,14 @@ public void beginSLToBoolean() { @SuppressWarnings("unused") @Override public void endSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_TO_BOOLEAN) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1949,6 +2498,14 @@ public void endSLToBoolean() { @SuppressWarnings("unused") @Override public void beginSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); } @@ -1956,6 +2513,14 @@ public void beginSLInvoke() { @SuppressWarnings("unused") @Override public void endSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_INVOKE) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -1984,6 +2549,14 @@ public void endSLInvoke() { @SuppressWarnings("unused") @Override public void beginSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_AND << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); operationData.aux[0] = (OperationLabelImpl) createLabel(); @@ -1992,6 +2565,14 @@ public void beginSLAnd() { @SuppressWarnings("unused") @Override public void endSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_AND) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -2008,6 +2589,14 @@ public void endSLAnd() { @SuppressWarnings("unused") @Override public void beginSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_OR << 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); operationData.aux[0] = (OperationLabelImpl) createLabel(); @@ -2016,6 +2605,14 @@ public void beginSLOr() { @SuppressWarnings("unused") @Override public void endSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + return; + } if (operationData.operationId != OP_SL_OR) { throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); } @@ -2071,6 +2668,380 @@ private static boolean do_profileCondition(boolean value, int[] profiles, int in } } + private static void deserializeParser(DataInputStream buffer, OperationDeserializationCallback callback, SLOperationsBuilder builder) { + try { + ArrayList consts = new ArrayList<>(); + ArrayList locals = new ArrayList<>(); + ArrayList labels = new ArrayList<>(); + ArrayList builtNodes = new ArrayList<>(); + com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context context = new com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context(){ + @Override + public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOException { + return builtNodes.get(buffer.readInt()); + } + } + ; + while (true) { + switch (buffer.readShort()) { + case -1 : + { + builtNodes.add(builder.publish()); + locals.clear(); + labels.clear(); + break; + } + case -2 : + { + labels.add(builder.createLabel()); + break; + } + case -3 : + { + locals.add(builder.createLocal()); + break; + } + case -4 : + { + consts.add(callback.deserialize(context, buffer)); + break; + } + case -5 : + { + return; + } + case OP_BLOCK << 1 : + { + builder.beginBlock(); + break; + } + case (OP_BLOCK << 1) | 1 : + { + builder.endBlock(); + break; + } + case OP_IF_THEN << 1 : + { + builder.beginIfThen(); + break; + } + case (OP_IF_THEN << 1) | 1 : + { + builder.endIfThen(); + break; + } + case OP_IF_THEN_ELSE << 1 : + { + builder.beginIfThenElse(); + break; + } + case (OP_IF_THEN_ELSE << 1) | 1 : + { + builder.endIfThenElse(); + break; + } + case OP_CONDITIONAL << 1 : + { + builder.beginConditional(); + break; + } + case (OP_CONDITIONAL << 1) | 1 : + { + builder.endConditional(); + break; + } + case OP_WHILE << 1 : + { + builder.beginWhile(); + break; + } + case (OP_WHILE << 1) | 1 : + { + builder.endWhile(); + break; + } + case OP_TRY_CATCH << 1 : + { + OperationLocal arg0 = locals.get(buffer.readShort()); + builder.beginTryCatch(arg0); + break; + } + case (OP_TRY_CATCH << 1) | 1 : + { + builder.endTryCatch(); + break; + } + case OP_FINALLY_TRY << 1 : + { + builder.beginFinallyTry(); + break; + } + case (OP_FINALLY_TRY << 1) | 1 : + { + builder.endFinallyTry(); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT << 1 : + { + builder.beginFinallyTryNoExcept(); + break; + } + case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : + { + builder.endFinallyTryNoExcept(); + break; + } + case OP_LABEL << 1 : + { + OperationLabel arg0 = labels.get(buffer.readShort()); + builder.emitLabel(arg0); + break; + } + case OP_BRANCH << 1 : + { + OperationLabel arg0 = labels.get(buffer.readShort()); + builder.emitBranch(arg0); + break; + } + case OP_CONST_OBJECT << 1 : + { + Object arg0 = (Object) consts.get(buffer.readShort()); + builder.emitConstObject(arg0); + break; + } + case OP_LOAD_ARGUMENT << 1 : + { + int arg0 = buffer.readInt(); + builder.emitLoadArgument(arg0); + break; + } + case OP_STORE_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.readShort()); + builder.beginStoreLocal(arg0); + break; + } + case (OP_STORE_LOCAL << 1) | 1 : + { + builder.endStoreLocal(); + break; + } + case OP_LOAD_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.readShort()); + builder.emitLoadLocal(arg0); + break; + } + case OP_RETURN << 1 : + { + builder.beginReturn(); + break; + } + case (OP_RETURN << 1) | 1 : + { + builder.endReturn(); + break; + } + case OP_SOURCE << 1 : + { + Source arg0 = (Source) consts.get(buffer.readShort()); + builder.beginSource(arg0); + break; + } + case (OP_SOURCE << 1) | 1 : + { + builder.endSource(); + break; + } + case OP_SOURCE_SECTION << 1 : + { + int arg0 = buffer.readInt(); + int arg1 = buffer.readInt(); + builder.beginSourceSection(arg0, arg1); + break; + } + case (OP_SOURCE_SECTION << 1) | 1 : + { + builder.endSourceSection(); + break; + } + case OP_TAG << 1 : + { + Class arg0 = (Class) consts.get(buffer.readShort()); + builder.beginTag(arg0); + break; + } + case (OP_TAG << 1) | 1 : + { + builder.endTag(); + break; + } + case OP_SL_ADD << 1 : + { + builder.beginSLAdd(); + break; + } + case (OP_SL_ADD << 1) | 1 : + { + builder.endSLAdd(); + break; + } + case OP_SL_DIV << 1 : + { + builder.beginSLDiv(); + break; + } + case (OP_SL_DIV << 1) | 1 : + { + builder.endSLDiv(); + break; + } + case OP_SL_EQUAL << 1 : + { + builder.beginSLEqual(); + break; + } + case (OP_SL_EQUAL << 1) | 1 : + { + builder.endSLEqual(); + break; + } + case OP_SL_LESS_OR_EQUAL << 1 : + { + builder.beginSLLessOrEqual(); + break; + } + case (OP_SL_LESS_OR_EQUAL << 1) | 1 : + { + builder.endSLLessOrEqual(); + break; + } + case OP_SL_LESS_THAN << 1 : + { + builder.beginSLLessThan(); + break; + } + case (OP_SL_LESS_THAN << 1) | 1 : + { + builder.endSLLessThan(); + break; + } + case OP_SL_LOGICAL_NOT << 1 : + { + builder.beginSLLogicalNot(); + break; + } + case (OP_SL_LOGICAL_NOT << 1) | 1 : + { + builder.endSLLogicalNot(); + break; + } + case OP_SL_MUL << 1 : + { + builder.beginSLMul(); + break; + } + case (OP_SL_MUL << 1) | 1 : + { + builder.endSLMul(); + break; + } + case OP_SL_READ_PROPERTY << 1 : + { + builder.beginSLReadProperty(); + break; + } + case (OP_SL_READ_PROPERTY << 1) | 1 : + { + builder.endSLReadProperty(); + break; + } + case OP_SL_SUB << 1 : + { + builder.beginSLSub(); + break; + } + case (OP_SL_SUB << 1) | 1 : + { + builder.endSLSub(); + break; + } + case OP_SL_WRITE_PROPERTY << 1 : + { + builder.beginSLWriteProperty(); + break; + } + case (OP_SL_WRITE_PROPERTY << 1) | 1 : + { + builder.endSLWriteProperty(); + break; + } + case OP_SL_UNBOX << 1 : + { + builder.beginSLUnbox(); + break; + } + case (OP_SL_UNBOX << 1) | 1 : + { + builder.endSLUnbox(); + break; + } + case OP_SL_FUNCTION_LITERAL << 1 : + { + builder.beginSLFunctionLiteral(); + break; + } + case (OP_SL_FUNCTION_LITERAL << 1) | 1 : + { + builder.endSLFunctionLiteral(); + break; + } + case OP_SL_TO_BOOLEAN << 1 : + { + builder.beginSLToBoolean(); + break; + } + case (OP_SL_TO_BOOLEAN << 1) | 1 : + { + builder.endSLToBoolean(); + break; + } + case OP_SL_INVOKE << 1 : + { + builder.beginSLInvoke(); + break; + } + case (OP_SL_INVOKE << 1) | 1 : + { + builder.endSLInvoke(); + break; + } + case OP_SL_AND << 1 : + { + builder.beginSLAnd(); + break; + } + case (OP_SL_AND << 1) | 1 : + { + builder.endSLAnd(); + break; + } + case OP_SL_OR << 1 : + { + builder.beginSLOr(); + break; + } + case (OP_SL_OR << 1) | 1 : + { + builder.endSLOr(); + break; + } + } + } + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + } + @GeneratedBy(SLOperations.class) private static final class BuilderOperationData { @@ -2118,6 +3089,16 @@ boolean belongsTo(BuilderFinallyTryContext context) { return false; } + } + @GeneratedBy(SLOperations.class) + private static final class OperationSerLabelImpl extends OperationLabel { + + int id; + + OperationSerLabelImpl(int id) { + this.id = id; + } + } @GeneratedBy(SLOperations.class) private static final class OperationLocalImpl extends OperationLocal { @@ -2426,6 +3407,37 @@ void changeInterpreters(BytecodeLoopBase impl) { this.switchImpl = impl; } + } + @GeneratedBy(SLOperations.class) + private static final class OperationSerNodeImpl extends OperationNode { + + @CompilationFinal int buildOrder; + + private OperationSerNodeImpl(OperationNodes nodes, int buildOrder) { + super(nodes); + this.buildOrder = buildOrder; + } + + @Override + public String dump() { + throw new UnsupportedOperationException(); + } + + @Override + protected int[] getSourceInfo() { + throw new UnsupportedOperationException(); + } + + @Override + public Object execute(VirtualFrame frame) { + throw new UnsupportedOperationException(); + } + + @Override + public FrameDescriptor createFrameDescriptor() { + throw new UnsupportedOperationException(); + } + } @GeneratedBy(SLOperations.class) private abstract static class BytecodeLoopBase { @@ -2473,14 +3485,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -2488,11 +3500,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2503,14 +3515,14 @@ protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, return false; } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -2518,11 +3530,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -2633,25 +3645,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } - // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG : - { - $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - continue loop; - } // load.constant.boolean // Constants: // [ 0] constant @@ -2671,40 +3664,37 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } - // load.argument.object + // load.constant.long + // Constants: + // [ 0] constant // Pushed Values: 1 // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); + $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } - // load.argument.long + // load.argument.object // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } // load.argument.boolean @@ -2729,6 +3719,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; continue loop; } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + continue loop; + } // store.local.object // Locals: // [ 0] target @@ -2745,7 +3757,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; continue loop; } - // store.local.long + // store.local.boolean // Locals: // [ 0] target // Indexed Pops: @@ -2753,25 +3765,25 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_STORE_LOCAL_OBJECT // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } - // store.local.boolean + // store.local.long // Locals: // [ 0] target // Indexed Pops: @@ -2779,22 +3791,22 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } // store.local.uninit @@ -2843,28 +3855,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; continue loop; } - // load.local.long + // load.local.boolean // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_LOAD_LOCAL_OBJECT // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2875,31 +3887,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; continue loop; } - // load.local.boolean + // load.local.long // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -2910,7 +3922,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; continue loop; } // load.local.uninit @@ -2949,8 +3961,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b0e5992 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41791417 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37eafb86 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35fd158f // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -2969,8 +3981,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c48e45c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@567d16d3 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@53cc14a0 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@778c7e37 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -2990,8 +4002,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f760747 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16267112 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@175a9d8b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ad6a382 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -3010,7 +4022,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d770d8e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@790cc76c // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -3029,7 +4041,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@13825d7d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6de573bc // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -3047,7 +4059,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3c613c75 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2e901d4e // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -3066,8 +4078,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@196a740a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@c6401d4 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@512561ad + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4e0dfb42 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -3099,8 +4111,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d8ccc90 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@383bdbc0 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8b319ac + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26671f99 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -3119,8 +4131,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@723b32e9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5efde7db + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5c353af1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc30dde // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -3151,8 +4163,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@357e48d8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@537d706c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6dad05b3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73284448 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -3170,8 +4182,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78fabc90 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49885f6b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@63f1a6e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@63f75a8a // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -3189,7 +4201,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@e77e60a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@66725bda // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -3207,7 +4219,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36b119b8 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57494958 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -3229,8 +4241,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b822dc2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fa4ade + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dbd5b5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70a1e90e // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -3257,7 +4269,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@218ca97d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@479d04b // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -3281,7 +4293,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fce182d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19e74a15 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -3303,8 +4315,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15a8da2b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5746cefa + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6ee642e1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@11f03faa // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -3324,8 +4336,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1345422e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ca52f1b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b415e57 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78d510c8 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -3357,8 +4369,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f8fdb26 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4edff133 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2478b479 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3465c233 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -3376,8 +4388,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77329ef4 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@22baaafe + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6507810e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35048e36 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -3395,7 +4407,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73bd0364 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@54be2f93 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -3414,7 +4426,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@425a2249 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4e500b6d // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -3436,8 +4448,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21fcd1c8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@56666253 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1706ec58 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662b5b0 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -3462,7 +4474,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ddbedd8 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2305d058 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -3493,8 +4505,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5e00c640 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19b53ed9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6d40bc36 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4d84f9ea // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -3513,7 +4525,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ca4b346 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ed81adf // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -3572,16 +4584,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -3589,14 +4601,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -3604,14 +4616,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -3624,14 +4636,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -3864,7 +4876,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3874,12 +4886,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3889,9 +4901,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -3909,7 +4921,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3919,12 +4931,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3934,9 +4946,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -3955,7 +4967,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3965,13 +4977,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -3981,10 +4993,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -4018,7 +5030,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4028,12 +5040,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4043,9 +5055,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -8385,14 +9397,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return 5 /* BOOLEAN */; } + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -8727,28 +9739,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } - // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - continue loop; - } // load.argument.boolean // Pushed Values: 1 // Boxing Elimination: Replace @@ -8771,6 +9761,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; continue loop; } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + continue loop; + } // store.local.uninit // Locals: // [ 0] target @@ -8830,10 +9842,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b0e5992 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41791417 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4a2aea20 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@8bb9c4b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37eafb86 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35fd158f + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6bd8a396 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c671254 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -8852,10 +9864,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c48e45c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@567d16d3 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e590fd4 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@119e11b8 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@53cc14a0 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@778c7e37 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6ba25d6e + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5aadbdfd // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -8875,10 +9887,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f760747 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@16267112 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@cf88241 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58f51e51 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@175a9d8b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ad6a382 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7447612d + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70362843 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -8897,8 +9909,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d770d8e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2ea49d34 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@790cc76c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@9865206 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -8917,8 +9929,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@13825d7d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4f565a89 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6de573bc + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3ef3449e // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -8936,8 +9948,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3c613c75 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@77423a8 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2e901d4e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@71f20464 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -8956,10 +9968,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@196a740a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@c6401d4 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7783b281 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc4dc78 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@512561ad + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4e0dfb42 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30c74e29 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@bea3c55 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -8991,10 +10003,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d8ccc90 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@383bdbc0 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3b535b - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26f44997 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8b319ac + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26671f99 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f995e02 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ea9beb1 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -9013,10 +10025,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@723b32e9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5efde7db - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c09e072 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f5c297 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5c353af1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc30dde + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4415074b + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1e479308 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -9047,10 +10059,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@357e48d8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@537d706c - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d0eeab9 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4932aa7e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6dad05b3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73284448 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b4bb78c + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7814d262 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -9068,10 +10080,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78fabc90 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49885f6b - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4abbc95a - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73e35be0 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@63f1a6e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@63f75a8a + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@14d7ad74 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@362ab335 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -9089,8 +10101,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@e77e60a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@49823c07 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@66725bda + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10fb85ab // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -9108,8 +10120,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@36b119b8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@15bf1e13 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57494958 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ea2d214 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -9131,10 +10143,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b822dc2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@10fa4ade - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1dae4e7 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@680f8367 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dbd5b5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70a1e90e + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@67376ab9 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@467ce71 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -9161,8 +10173,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@218ca97d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30b5f865 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@479d04b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48fdd58b // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -9186,8 +10198,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fce182d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d9737e6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19e74a15 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10978cf2 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -9250,16 +10262,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -9267,14 +10279,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -9282,14 +10294,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -9302,14 +10314,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -9542,7 +10554,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9552,12 +10564,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9567,9 +10579,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -9587,7 +10599,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9597,12 +10609,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9612,9 +10624,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -9633,7 +10645,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9643,13 +10655,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9659,10 +10671,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -9696,7 +10708,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9706,12 +10718,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -9721,9 +10733,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -10874,14 +11886,14 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return 5 /* BOOLEAN */; } + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -11091,6 +12103,22 @@ T insertAccessor(T node) { } } + @GeneratedBy(SLOperations.class) + private static final class WrappedIOException extends RuntimeException { + + WrappedIOException(IOException ex) { + super(ex); + } + + } + } + @GeneratedBy(SLOperations.class) + private static final class WrappedIOException extends RuntimeException { + + WrappedIOException(IOException ex) { + super(ex); + } + } private static final class Counter { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java new file mode 100644 index 000000000000..827f72906943 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.test.example; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; + +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationNodes; + +public class TestOperationsSerTest { + + @Test + public void testSer() { + byte[] byteArray = createByteArray(); + TestRootNode root = deserialize(byteArray); + + Assert.assertEquals(3L, root.getCallTarget().call()); + } + + private TestRootNode deserialize(byte[] byteArray) { + ByteArrayInputStream input = new ByteArrayInputStream(byteArray); + + OperationNodes nodes2 = null; + try { + nodes2 = TestOperationsBuilder.deserialize(OperationConfig.DEFAULT, new DataInputStream(input), (ctx, buf2) -> { + return buf2.readLong(); + }); + } catch (IOException e) { + assert false; + } + + OperationNode node = nodes2.getNodes().get(0); + TestRootNode root = new TestRootNode(node); + return root; + } + + private static byte[] createByteArray() { + + OperationNodes nodes = TestOperationsBuilder.create(OperationConfig.DEFAULT, b -> { + b.beginReturn(); + b.beginAddOperation(); + b.emitConstObject(1L); + b.emitConstObject(2L); + b.endAddOperation(); + b.endReturn(); + + b.publish(); + }); + + boolean[] haveConsts = new boolean[2]; + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try { + nodes.serialize(new DataOutputStream(output), (ctx, buf2, obj) -> { + if (obj instanceof Long) { + haveConsts[(int) (long) obj - 1] = true; + buf2.writeLong((long) obj); + } else { + assert false; + } + }); + } catch (IOException e) { + assert false; + } + + Assert.assertArrayEquals(new boolean[]{true, true}, haveConsts); + + byte[] byteArray = output.toByteArray(); + return byteArray; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 68f38744b1e8..1152e720b4e8 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -42,8 +42,6 @@ import java.util.function.Function; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; @@ -149,46 +147,4 @@ public SourceSection getEncapsulatingSourceSection() { } public abstract String dump(); - - private static boolean conditionProfile(boolean value, long[] profiles, int index) { - - long profile = profiles[index]; - CompilerAsserts.compilationConstant(profile); - - int t = (int) (profile >> 32); - int f = (int) profile; - - boolean val = value; - if (val) { - if (t == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (f == 0) { - val = true; - } - if (CompilerDirectives.inInterpreter()) { - if (t < 0x3FFFFFFF) { - profiles[index] = profile + (1 << 32); - } - } - } else { - if (f == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (t == 0) { - val = false; - } - if (CompilerDirectives.inInterpreter()) { - if (f < 0x3FFFFFFF) { - profiles[index] = profile + 1; - } - } - } - if (CompilerDirectives.inInterpreter()) { - return val; - } else { - int sum = t + f; - return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); - } - } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 387b17804256..cabe16925bda 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -40,16 +40,19 @@ */ package com.oracle.truffle.api.operation; +import java.io.DataOutputStream; +import java.io.IOException; import java.util.List; import java.util.function.Consumer; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; import com.oracle.truffle.api.source.Source; public abstract class OperationNodes { - private final Consumer parse; + protected final Consumer parse; @CompilationFinal(dimensions = 1) protected OperationNode[] nodes; @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; @@ -107,4 +110,9 @@ final void ensureSources() { reparse(OperationConfig.WITH_SOURCE); } } + + @SuppressWarnings("unused") + public void serialize(DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { + throw new UnsupportedOperationException("Serialization not supported"); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java new file mode 100644 index 000000000000..6a32674d7157 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.serialization; + +import java.io.DataInputStream; +import java.io.IOException; + +import com.oracle.truffle.api.operation.OperationNode; + +public interface OperationDeserializationCallback { + interface Context { + OperationNode deserializeOperationNode(DataInputStream buffer) throws IOException; + } + + Object deserialize(Context context, DataInputStream buffer) throws IOException; +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java new file mode 100644 index 000000000000..d11b0fe7efe9 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.serialization; + +import java.io.DataOutputStream; +import java.io.IOException; + +import com.oracle.truffle.api.operation.OperationNode; + +@FunctionalInterface +public interface OperationSerializationCallback { + interface Context { + void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException; + } + + void serialize(Context context, DataOutputStream buffer, Object object) throws IOException; +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index 09548a2b83d8..e0157195ba43 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -56,4 +56,6 @@ public class OperationGeneratorFlags { public static final boolean USE_UNSAFE = false; + public static final boolean ENABLE_SERIALIZATION = true; + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index f853f4294d82..4e4849e4b13a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -40,6 +40,11 @@ */ package com.oracle.truffle.dsl.processor.operations; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -51,6 +56,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -58,6 +64,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -66,6 +73,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; @@ -98,18 +106,17 @@ public class OperationsCodeGenerator extends CodeTypeElementFactorycreateBuilder method. @@ -138,7 +177,6 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(ctor); CodeTypeElement opNodesImpl = createOperationNodes(); - typBuilder.add(opNodesImpl); // begin/end or emit methods @@ -173,6 +211,7 @@ CodeTypeElement createBuilder(String simpleName) { if (OperationGeneratorFlags.USE_UNSAFE) { typBuilder.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(Unsafe.class), "theUnsafe")).setInit(CodeTreeBuilder.singleString("Unsafe.getUnsafe()")); } + CodeExecutableElement metUnsafeFromBytecode = typBuilder.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode")); metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(int.class), "index")); @@ -190,7 +229,12 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(createSetMetadata(metadata, true)); } + CodeTypeElement typWrappedEx = typBuilderImpl.add(GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "WrappedIOException", context.getType(RuntimeException.class))); + typWrappedEx.add(new CodeExecutableElement(Set.of(), null, "WrappedIOException", new CodeVariableElement(context.getType(IOException.class), "ex"))).createBuilder().statement("super(ex)"); + typBuilder.add(typWrappedEx); + typBuilder.add(createCreateMethod(typBuilder, typBuilderImpl)); + typBuilder.add(createDeserializeMethod()); CodeTypeElement typCounter = typBuilder.add(new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter")); typCounter.add(new CodeVariableElement(MOD_PUBLIC, context.getType(int.class), "count")); @@ -198,6 +242,32 @@ CodeTypeElement createBuilder(String simpleName) { return typBuilder; } + private CodeExecutableElement createDeserializeMethod() { + CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); + CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DataInputStream.class), "input"); + CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback"); + CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parConfig, parBuffer, parCallback); + + met.addThrownType(context.getType(IOException.class)); + + CodeTreeBuilder b = met.createBuilder(); + + b.startTryBlock(); + + b.startReturn().startCall("create"); + b.variable(parConfig); + b.string("b -> BuilderImpl.deserializeParser(input, callback, b)"); + b.end(2); + + b.end().startCatchBlock(new GeneratedTypeMirror("", "WrappedIOException"), "ex"); + + b.startThrow().string("(IOException) ex.getCause()").end(); + + b.end(); + + return met; + } + private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parParser = new CodeVariableElement(consumer(typBuilder.asType()), "generator"); @@ -241,6 +311,39 @@ private static CodeVariableElement children(CodeVariableElement el) { return el; } + private CodeTypeElement createOperationSerNodeImpl() { + CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerNodeImpl", types.OperationNode); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); + typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl)); + + for (String methodName : new String[]{"dump", "getSourceInfo", "execute", "createFrameDescriptor"}) { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationNode, methodName); + met.createBuilder().startThrow().startNew(context.getType(UnsupportedOperationException.class)).end(2); + typOperationNodeImpl.add(met); + } + + return typOperationNodeImpl; + } + + private CodeVariableElement createSerializationContext() { + DeclaredType typeContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context"); + CodeVariableElement fld = new CodeVariableElement(typeContext, "SER_CONTEXT"); + CodeTreeBuilder b = fld.createInitBuilder(); + + b.startNew(typeContext).end().string(" ").startBlock(); + + b.string("@Override").newLine(); + b.string("public void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException ").startBlock(); + + b.statement("buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder)"); + + b.end(); + + b.end(); + + return fld; + } + CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTypeElement typExceptionHandler) { CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationNodeImpl", types.OperationNode); @@ -487,7 +590,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl b.end(); b.end(2); - } CodeTypeElement opDataImpl = createOperationDataImpl(); @@ -498,6 +600,10 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl CodeTypeElement typLabelData = createOperationLabelImpl(opDataImpl, typFinallyTryContext); typBuilderImpl.add(typLabelData); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilderImpl.add(createOperationSerLabelImpl()); + } + CodeTypeElement typLocalData = createOperationLocalImpl(opDataImpl); typBuilderImpl.add(typLocalData); @@ -527,6 +633,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "curStack")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "maxStack")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLocals")); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLabels")); + } CodeVariableElement fldConstPool = typBuilderImpl.add( new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); fldConstPool.createInitBuilder().string("new ArrayList<>()"); @@ -541,6 +650,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "buildIndex")); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean.class), "isSerializing")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(DataOutputStream.class), "serBuffer")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback"), "serCallback")); + } + typBuilderImpl.add(createBuilderImplFinish()); typBuilderImpl.add(createBuilderImplReset()); @@ -573,6 +688,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(bytecodeBaseClass, typExceptionHandler); typBuilderImpl.add(typOperationNodeImpl); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilderImpl.add(createOperationSerNodeImpl()); + typBuilderImpl.add(createSerializationContext()); + } + createBytecodeBaseClass(bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler); typBuilderImpl.add(bytecodeBaseClass); @@ -666,10 +786,130 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(createConditionProfile()); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilderImpl.add(createBuilderImplDeserializeParser(typBuilder)); + } + return typBuilderImpl; } + private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement typBuilder) { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); + met.addParameter(new CodeVariableElement(context.getType(DataInputStream.class), "buffer")); + met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback")); + met.addParameter(new CodeVariableElement(typBuilder.asType(), "builder")); + + CodeTreeBuilder b = met.createBuilder(); + serializationWrapException(b, () -> { + b.statement("ArrayList consts = new ArrayList<>()"); + b.statement("ArrayList locals = new ArrayList<>()"); + b.statement("ArrayList labels = new ArrayList<>()"); + b.statement("ArrayList builtNodes = new ArrayList<>()"); + + TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context"); + + b.startStatement(); + b.type(deserContext); + b.string(" context = ").startNew(deserContext).end().startBlock(); + + b.string("@Override").newLine(); + b.string("public OperationNode deserializeOperationNode(").type(context.getType(DataInputStream.class)).string(" buffer) throws IOException ").startBlock(); + b.statement("return builtNodes.get(buffer.readInt())"); + b.end(); + + b.end(2); + + b.startWhile().string("true").end().startBlock(); + b.startSwitch().string("buffer.readShort()").end().startBlock(); + + b.startCase().string("" + SER_CODE_PUBLISH).end().startBlock(); + b.statement("builtNodes.add(builder.publish())"); + b.statement("locals.clear()"); + b.statement("labels.clear()"); + b.statement("break"); + b.end(); + + b.startCase().string("" + SER_CODE_CREATE_LABEL).end().startBlock(); + b.statement("labels.add(builder.createLabel())"); + b.statement("break"); + b.end(); + + b.startCase().string("" + SER_CODE_CREATE_LOCAL).end().startBlock(); + b.statement("locals.add(builder.createLocal())"); + b.statement("break"); + b.end(); + + b.startCase().string("" + SER_CODE_CREATE_OBJECT).end().startBlock(); + b.statement("consts.add(callback.deserialize(context, buffer))"); + b.statement("break"); + b.end(); + + b.startCase().string("" + SER_CODE_END).end().startBlock(); + b.returnStatement(); + b.end(); + + for (Operation op : m.getOperations()) { + + // create begin/emit code + b.startCase().variable(op.idConstantField).string(" << 1").end().startBlock(); + + int i = 0; + for (TypeMirror argType : op.getBuilderArgumentTypes()) { + // ARGUMENT DESERIALIZATION + if (ElementUtils.typeEquals(argType, types.OperationLocal)) { + b.statement("OperationLocal arg" + i + " = locals.get(buffer.readShort())"); + } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { + b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer.readShort()]"); + b.startFor().string("int i = 0; i < locals.length; i++").end().startBlock(); + // this can be optimized since they are consecutive + b.statement("arg" + i + "[i] = locals.get(buffer.readShort());"); + b.end(); + } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { + b.statement("OperationLabel arg" + i + " = labels.get(buffer.readShort())"); + } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { + b.statement("int arg" + i + " = buffer.readInt()"); + } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { + b.startStatement().type(argType).string(" arg" + i + " = ").cast(argType).string("consts.get(buffer.readShort())").end(); + } else { + throw new UnsupportedOperationException("cannot deserialize: " + argType); + } + i++; + } + + b.startStatement(); + if (op.children == 0) { + b.startCall("builder.emit" + op.name); + } else { + b.startCall("builder.begin" + op.name); + } + + for (int j = 0; j < i; j++) { + b.string("arg" + j); + } + + b.end(2); // statement, call + + b.statement("break"); + + b.end(); // case block + + if (op.children != 0) { + b.startCase().string("(").variable(op.idConstantField).string(" << 1) | 1").end().startBlock(); + b.statement("builder.end" + op.name + "()"); + b.statement("break"); + b.end(); + } + + } + + b.end(); + b.end(); + }); + + return met; + } + private CodeExecutableElement createConditionProfile() { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "do_profileCondition"); met.addParameter(new CodeVariableElement(context.getType(boolean.class), "value")); @@ -855,6 +1095,16 @@ private CodeTypeElement createOperationLabelImpl(CodeTypeElement opDataImpl, Cod return typOperationLabel; } + private CodeTypeElement createOperationSerLabelImpl() { + CodeTypeElement typOperationLabel = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerLabelImpl", types.OperationLabel); + + typOperationLabel.add(new CodeVariableElement(context.getType(int.class), "id")); + + typOperationLabel.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationLabel)); + + return typOperationLabel; + } + private CodeTypeElement createOperationLocalImpl(CodeTypeElement opDataImpl) { CodeTypeElement typLocalData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationLocalImpl", types.OperationLocal); @@ -866,10 +1116,29 @@ private CodeTypeElement createOperationLocalImpl(CodeTypeElement opDataImpl) { return typLocalData; } + private void serializationWrapException(CodeTreeBuilder b, Runnable r) { + b.startTryBlock(); + r.run(); + b.end().startCatchBlock(context.getType(IOException.class), "ex"); + b.startThrow().startNew("WrappedIOException").string("ex").end(2); + b.end(); + } + @SuppressWarnings("static-method") private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLocal"); - mCreateLocal.createBuilder().startReturn().startNew(typLocalData.asType()).string("operationData").string("numLocals++").end(2); + CodeTreeBuilder b = mCreateLocal.createBuilder(); + + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + b.startIf().string("isSerializing").end().startBlock(); + serializationWrapException(b, () -> { + b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_LOCAL + ")"); + b.statement("return new OperationLocalImpl(null, numLocals++)"); + }); + b.end(); + } + + b.startReturn().startNew(typLocalData.asType()).string("operationData").string("numLocals++").end(2); return mCreateLocal; } @@ -885,6 +1154,16 @@ private CodeExecutableElement createBuilderImplCreateLabel(CodeTypeElement typBu CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); CodeTreeBuilder b = mCreateLocal.createBuilder(); + + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + b.startIf().string("isSerializing").end().startBlock(); + serializationWrapException(b, () -> { + b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_LABEL + ")"); + b.statement("return new OperationSerLabelImpl(numLabels++)"); + }); + b.end(); + } + b.startAssign("OperationLabelImpl label").startNew(typLabelData.asType()).string("operationData").string("currentFinallyTry").end(2); b.startStatement().startCall("labels", "add").string("label").end(2); b.startReturn().string("label").end(); @@ -1230,15 +1509,6 @@ private CodeExecutableElement createDoLeaveFinallyTry(CodeTypeElement typOperati return mDoLeaveFinallyTry; } - private CodeExecutableElement createMetadataSet(CodeTypeElement typOperationNodeImpl) { - CodeExecutableElement method = GeneratorUtils.overrideImplement(types.OperationBuilder, "assignMetadata"); - CodeTreeBuilder b = method.createBuilder(); - - b.startAssign(typOperationNodeImpl.getSimpleName() + " nodeImpl").cast(typOperationNodeImpl.asType()).string("node").end(); - - return method; - } - private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, boolean isAbstract) { CodeVariableElement parValue = new CodeVariableElement(metadata.getType(), "value"); CodeExecutableElement method = new CodeExecutableElement( @@ -1261,6 +1531,8 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); CodeTreeBuilder b = metEmit.getBuilder(); + createBeginOperationSerialize(vars, op, b); + if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); } @@ -1328,6 +1600,15 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui // doAfterChild(); CodeTreeBuilder b = metEnd.getBuilder(); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + b.startIf().string("isSerializing").end().startBlock(); + serializationWrapException(b, () -> { + b.startStatement().string("serBuffer.writeShort((short) ((").variable(op.idConstantField).string(" << 1) | 1))").end(); + }); + b.returnStatement(); + b.end(); + } + String condition = op.conditionedOn(); if (condition != null) { b.startIf().string(condition).end().startBlock(); @@ -1395,6 +1676,8 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B CodeTreeBuilder b = metBegin.getBuilder(); + createBeginOperationSerialize(vars, op, b); + String condition = op.conditionedOn(); if (condition != null) { b.startIf().string(condition).end().startBlock(); @@ -1434,6 +1717,50 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B return metBegin; } + private void createBeginOperationSerialize(BuilderVariables vars, Operation op, CodeTreeBuilder b) { + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + b.startIf().string("isSerializing").end().startBlock(); + + serializationWrapException(b, () -> { + ArrayList after = new ArrayList<>(); + + int i = 0; + for (TypeMirror argType : op.getBuilderArgumentTypes()) { + // ARGUMENT SERIALIZATION + if (ElementUtils.typeEquals(argType, types.OperationLocal)) { + after.add("serBuffer.writeShort((short) ((OperationLocalImpl) arg" + i + ").id)"); + } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { + after.add("serBuffer.writeShort((short) arg" + i + ".length)"); + } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { + after.add("serBuffer.writeShort((short) ((OperationSerLabelImpl) arg" + i + ").id)"); + } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { + after.add("serBuffer.writeInt(arg" + i + ")"); + } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { + String index = "arg" + i + "_index"; + b.startAssign("int " + index).variable(vars.consts).startCall(".indexOf").string("arg" + i).end(2); + b.startIf().string(index + " == -1").end().startBlock(); + b.startAssign(index).variable(vars.consts).startCall(".size").end(2); + b.startStatement().variable(vars.consts).startCall(".add").string("arg" + i).end(2); + b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_OBJECT + ")"); + b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, arg" + i + ")"); + b.end(); + after.add("serBuffer.writeShort((short) arg" + i + "_index)"); + } else { + throw new UnsupportedOperationException("cannot serialize: " + argType); + } + i++; + } + + b.startStatement().string("serBuffer.writeShort((short) (").variable(op.idConstantField).string(" << 1))").end(); + + after.forEach(b::statement); + }); + + b.returnStatement(); + b.end(); + } + } + private CodeExecutableElement createSetResultUnboxed() { CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); @@ -1469,6 +1796,18 @@ private CodeExecutableElement createBuilderImplPublish() { CodeTreeBuilder b = mPublish.createBuilder(); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + b.startIf().string("isSerializing").end().startBlock(); + serializationWrapException(b, () -> { + b.statement("serBuffer.writeShort((short) " + SER_CODE_PUBLISH + ")"); + b.declaration("OperationNode", "result", "new OperationSerNodeImpl(null, buildIndex++)"); + b.statement("numLocals = 0"); + b.statement("numLabels = 0"); + b.statement("return result"); + }); + b.end(); + } + b.startIf().string("operationData.depth != 0").end().startBlock(); b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("Not all operations closed").end(2); b.end(); @@ -1723,7 +2062,20 @@ public List create(ProcessorContext context, AnnotationProcesso String simpleName = m.getTemplateType().getSimpleName() + "Builder"; - return List.of(createBuilder(simpleName)); + try { + return List.of(createBuilder(simpleName)); + } catch (Throwable e) { + CodeTypeElement el = GeneratorUtils.createClass(m, null, Set.of(), simpleName, null); + CodeTreeBuilder b = el.createDocBuilder(); + + StringWriter sb = new StringWriter(); + e.printStackTrace(new PrintWriter(sb)); + for (String line : sb.toString().split("\n")) { + b.string("// " + line).newLine(); + } + + return List.of(el); + } } // -------------------------- helper methods moved to generated code -------------------------- diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index c1a21d212d6e..d7d4dcdca21e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -49,11 +49,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; From 102df026e9bb024705f680b9bc97a33d3fb0e096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 20 Jul 2022 13:15:44 +0200 Subject: [PATCH 114/312] [wip] SL serialization --- .../sl/operations/SLOperationsBuilder.java | 201 ++++++++++-------- .../operations/OperationsCodeGenerator.java | 30 +++ .../sl/nodes/SLOperationsRootNode.java | 3 +- .../operations/SLOperationSerialization.java | 150 +++++++++++++ .../truffle/sl/parser/SLBaseVisitor.java | 40 ++++ .../truffle/sl/parser/SLNodeVisitor.java | 40 ++++ .../sl/parser/SLOperationsVisitor.java | 12 ++ 7 files changed, 384 insertions(+), 92 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index fafe5ac41c5e..f9f22631599d 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -2628,6 +2628,16 @@ public void endSLOr() { @Override public void setMethodName(TruffleString value) { + if (isSerializing) { + try { + serBuffer.writeShort((short) -6); + serBuffer.writeShort(0); + serCallback.serialize(SER_CONTEXT, serBuffer, value); + return; + } catch (IOException ex) { + throw new WrappedIOException(ex); + } + } metadata_MethodName = value; } @@ -2709,6 +2719,15 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE { return; } + case -6 : + { + switch (buffer.readShort()) { + case 0 : + builder.setMethodName((TruffleString) callback.deserialize(context, buffer)); + break; + } + break; + } case OP_BLOCK << 1 : { builder.beginBlock(); @@ -3961,8 +3980,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37eafb86 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35fd158f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73302ab8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3bfe997d // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -3981,8 +4000,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@53cc14a0 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@778c7e37 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43099317 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@451eeb4b // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -4002,8 +4021,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@175a9d8b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ad6a382 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37097cba + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78f32e57 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -4022,7 +4041,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@790cc76c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@776d9b75 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -4041,7 +4060,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6de573bc + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@451b6260 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -4059,7 +4078,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2e901d4e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@390b2ad5 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -4078,8 +4097,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@512561ad - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4e0dfb42 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@586b2a35 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@43c6a47e // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -4111,8 +4130,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8b319ac - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26671f99 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d50c604 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3ded02f9 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -4131,8 +4150,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5c353af1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc30dde + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3cd6bdf3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a450b43 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -4163,8 +4182,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6dad05b3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73284448 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@117e84e9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44d1b6f5 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -4182,8 +4201,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@63f1a6e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@63f75a8a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d61a2b9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f1cb745 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -4201,7 +4220,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@66725bda + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4aa03783 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -4219,7 +4238,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57494958 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30f463c // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -4241,8 +4260,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dbd5b5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70a1e90e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43bb488e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@9577923 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -4269,7 +4288,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@479d04b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42004ba5 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -4293,7 +4312,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19e74a15 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3bc7db7f // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -4315,8 +4334,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6ee642e1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@11f03faa + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@22a10bb1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@108df0a7 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -4336,8 +4355,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b415e57 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78d510c8 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5090dc70 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5509f93e // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -4369,8 +4388,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2478b479 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3465c233 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7fdf8cad + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@284339 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -4388,8 +4407,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6507810e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35048e36 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@560d7c10 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4cd7afe6 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -4407,7 +4426,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@54be2f93 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4feee835 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -4426,7 +4445,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4e500b6d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d1d5b7a // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -4448,8 +4467,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1706ec58 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662b5b0 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@304d5b35 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41946a45 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -4474,7 +4493,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2305d058 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79038d02 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -4505,8 +4524,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6d40bc36 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4d84f9ea + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1ea2cfd3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@446cabc1 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -4525,7 +4544,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ed81adf + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2648274b // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -9842,10 +9861,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37eafb86 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@35fd158f - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6bd8a396 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3c671254 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73302ab8 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3bfe997d + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7efc1f7 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48239ed1 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -9864,10 +9883,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@53cc14a0 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@778c7e37 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6ba25d6e - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5aadbdfd + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43099317 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@451eeb4b + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2911da80 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6421b394 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -9887,10 +9906,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@175a9d8b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ad6a382 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7447612d - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70362843 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37097cba + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78f32e57 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1db8269e + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49b9e6ee // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -9909,8 +9928,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@790cc76c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@9865206 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@776d9b75 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6edbe083 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -9929,8 +9948,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6de573bc - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3ef3449e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@451b6260 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70f43df // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -9948,8 +9967,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2e901d4e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@71f20464 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@390b2ad5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b5f1976 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -9968,10 +9987,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@512561ad - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4e0dfb42 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30c74e29 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@bea3c55 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@586b2a35 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@43c6a47e + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5dd71a65 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6cb926a4 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -10003,10 +10022,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8b319ac - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26671f99 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f995e02 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4ea9beb1 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d50c604 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3ded02f9 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11d58157 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3262beb2 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -10025,10 +10044,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5c353af1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7dc30dde - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4415074b - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1e479308 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3cd6bdf3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a450b43 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57038ea9 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@722a0eeb // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -10059,10 +10078,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6dad05b3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@73284448 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b4bb78c - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7814d262 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@117e84e9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44d1b6f5 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4f48f6c0 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@68f846b5 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -10080,10 +10099,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@63f1a6e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@63f75a8a - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@14d7ad74 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@362ab335 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d61a2b9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f1cb745 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@23c5fbc5 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@13af400 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -10101,8 +10120,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@66725bda - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10fb85ab + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4aa03783 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@9ccec11 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -10120,8 +10139,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57494958 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4ea2d214 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30f463c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@23abde73 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -10143,10 +10162,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@29dbd5b5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@70a1e90e - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@67376ab9 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@467ce71 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43bb488e + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@9577923 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2fbc1210 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@79707913 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -10173,8 +10192,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@479d04b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48fdd58b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42004ba5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1732be48 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -10198,8 +10217,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19e74a15 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10978cf2 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3bc7db7f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6a17b29b // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 4e4849e4b13a..728905a11eda 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -111,6 +111,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory { + b.statement("serBuffer.writeShort((short) " + SER_CODE_METADATA + ")"); + b.statement("serBuffer.writeShort(" + m.getMetadatas().indexOf(metadata) + ")"); + b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, value)"); + b.returnStatement(); + }); + b.end(); + b.startAssign("metadata_" + metadata.getName()).variable(parValue).end(); return method; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java index 8f6cb3c77c05..65923f870656 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java @@ -1,5 +1,7 @@ package com.oracle.truffle.sl.nodes; +import java.io.DataOutputStream; + import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.source.SourceSection; @@ -35,5 +37,4 @@ public SLExpressionNode getBodyNode() { public TruffleString getTSName() { return operationsNode.getMetadata(SLOperations.MethodName); } - } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java new file mode 100644 index 000000000000..c122c92d5ed8 --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.sl.operations; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.math.BigInteger; + +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback; +import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLNull; + +public class SLOperationSerialization { + + private static final byte CODE_SL_NULL = 0; + private static final byte CODE_STRING = 1; + private static final byte CODE_LONG = 2; + private static final byte CODE_SOURCE = 3; + private static final byte CODE_CLASS = 4; + private static final byte CODE_BIG_INT = 5; + + public static byte[] serializeNodes(OperationNodes nodes) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream); + + nodes.serialize(outputStream, new OperationSerializationCallback() { + public void serialize(OperationSerializationCallback.Context context, DataOutputStream buffer, Object object) throws IOException { + if (object instanceof SLNull) { + buffer.writeByte(CODE_SL_NULL); + } else if (object instanceof TruffleString) { + TruffleString str = (TruffleString) object; + buffer.writeByte(CODE_STRING); + writeByteArray(buffer, str.getInternalByteArrayUncached(SLLanguage.STRING_ENCODING).getArray()); + } else if (object instanceof Long) { + buffer.writeByte(CODE_LONG); + buffer.writeLong((long) object); + } else if (object instanceof SLBigNumber) { + SLBigNumber num = (SLBigNumber) object; + buffer.writeByte(CODE_BIG_INT); + writeByteArray(buffer, num.getValue().toByteArray()); + } else if (object instanceof Source) { + Source s = (Source) object; + buffer.writeByte(CODE_SOURCE); + writeByteArray(buffer, s.getName().getBytes()); + } else if (object instanceof Class) { + buffer.writeByte(CODE_CLASS); + writeByteArray(buffer, ((Class) object).getName().getBytes()); + } else { + throw new UnsupportedOperationException("unsupported constant: " + object.getClass().getSimpleName() + " " + object); + } + } + }); + + return byteArrayOutputStream.toByteArray(); + } + + private static byte[] readByteArray(DataInputStream buffer) throws IOException { + int len = buffer.readInt(); + return buffer.readNBytes(len); + } + + private static void writeByteArray(DataOutputStream buffer, byte[] data) throws IOException { + buffer.writeInt(data.length); + buffer.write(data); + } + + public static OperationNodes deserializeNodes(byte[] inputData) throws IOException { + ByteArrayInputStream byteArrayOutputStream = new ByteArrayInputStream(inputData); + DataInputStream outputStream = new DataInputStream(byteArrayOutputStream); + + return SLOperationsBuilder.deserialize(OperationConfig.DEFAULT, outputStream, new OperationDeserializationCallback() { + public Object deserialize(OperationDeserializationCallback.Context context, DataInputStream buffer) throws IOException { + byte tag; + switch (tag = buffer.readByte()) { + case CODE_SL_NULL: + return SLNull.SINGLETON; + case CODE_STRING: { + return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); + } + case CODE_LONG: + return buffer.readLong(); + case CODE_BIG_INT: { + return new SLBigNumber(new BigInteger(readByteArray(buffer))); + } + case CODE_SOURCE: { + String name = new String(readByteArray(buffer)); + return Source.newBuilder(SLLanguage.ID, "", name).build(); + } + case CODE_CLASS: { + String name = new String(readByteArray(buffer)); + try { + return Class.forName(name); + } catch (ClassNotFoundException ex) { + throw new UnsupportedOperationException("could not load class: " + name); + } + } + default: + throw new UnsupportedOperationException("unsupported tag: " + tag); + } + } + }); + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index ab6883878cb0..3ab40f909a70 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.parser; import java.util.ArrayList; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index c44c15ac2466..e3d4e94222f9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.parser; import java.math.BigInteger; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index dbd6e5b887f0..a82924648866 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.parser; +import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; @@ -62,6 +63,7 @@ import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLOperationsRootNode; +import com.oracle.truffle.sl.operations.SLOperationSerialization; import com.oracle.truffle.sl.operations.SLOperations; import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ArithmeticContext; @@ -94,6 +96,7 @@ public final class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = true; + private static final boolean FORCE_SERIALIZE = true; public static void parseSL(SLLanguage language, Source source, Map functions) { OperationNodes nodes = SLOperationsBuilder.create(OperationConfig.DEFAULT, builder -> { @@ -101,6 +104,15 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Wed, 20 Jul 2022 15:24:42 +0200 Subject: [PATCH 115/312] [wip] fix serialization --- .../sl/operations/SLOperationsBuilder.java | 666 +++++++++--------- .../truffle/api/operation/OperationNode.java | 4 + .../operations/OperationGeneratorFlags.java | 2 - .../operations/OperationsCodeGenerator.java | 17 +- .../instructions/CustomInstruction.java | 2 +- 5 files changed, 342 insertions(+), 349 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index f9f22631599d..62e954e76fed 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -323,33 +323,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int INSTR_LOAD_CONSTANT_LONG = 6; static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_LONG_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int INSTR_LOAD_ARGUMENT_LONG = 9; static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_LONG_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 12; - static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 13; + static final int INSTR_STORE_LOCAL_LONG = 12; static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_LONG_LENGTH = 3; + static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -357,12 +357,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; - static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int INSTR_LOAD_LOCAL_LONG = 16; static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_LONG_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -535,7 +535,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // INT null, // DOUBLE @@ -543,7 +543,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, // BYTE null}; @@ -3504,14 +3504,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -3519,11 +3519,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3534,14 +3534,14 @@ protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlo return false; } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -3549,11 +3549,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3664,25 +3664,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } - // load.constant.boolean - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN - // INT -> INSTR_LOAD_CONSTANT_BOOLEAN - // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN - // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - continue loop; - } // load.constant.long // Constants: // [ 0] constant @@ -3702,40 +3683,37 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } - // load.argument.object + // load.constant.boolean + // Constants: + // [ 0] constant // Pushed Values: 1 // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN + // INT -> INSTR_LOAD_CONSTANT_BOOLEAN + // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN + // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_BOOLEAN : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); + $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } - // load.argument.boolean + // load.argument.object // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // LONG -> INSTR_LOAD_ARGUMENT_LONG // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_OBJECT : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); - } else { - $frame.setObject($sp, value); - } + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } // load.argument.long @@ -3760,6 +3738,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; continue loop; } + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + continue loop; + } // store.local.object // Locals: // [ 0] target @@ -3776,7 +3776,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; continue loop; } - // store.local.boolean + // store.local.long // Locals: // [ 0] target // Indexed Pops: @@ -3784,25 +3784,25 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } - // store.local.long + // store.local.boolean // Locals: // [ 0] target // Indexed Pops: @@ -3810,22 +3810,22 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_STORE_LOCAL_OBJECT // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } // store.local.uninit @@ -3874,28 +3874,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; continue loop; } - // load.local.boolean + // load.local.long // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3906,31 +3906,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; continue loop; } - // load.local.long + // load.local.boolean // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_LOAD_LOCAL_OBJECT // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3941,7 +3941,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; continue loop; } // load.local.uninit @@ -3980,8 +3980,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73302ab8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3bfe997d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2aa90b56 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6f016f82 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -4000,8 +4000,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43099317 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@451eeb4b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48269d21 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19ac272d // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -4021,8 +4021,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37097cba - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78f32e57 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7bbd7cf5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1fa4717f // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -4041,7 +4041,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@776d9b75 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6317283f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -4060,7 +4060,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@451b6260 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b7afe3f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -4078,7 +4078,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@390b2ad5 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@bb06371 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -4097,8 +4097,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@586b2a35 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@43c6a47e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37a3c4f1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d2f44ea // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -4130,8 +4130,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d50c604 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3ded02f9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21e8d476 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@29cb80d1 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -4150,8 +4150,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3cd6bdf3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a450b43 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@664d55 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f951a7 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -4182,8 +4182,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@117e84e9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44d1b6f5 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70556c4a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5eda799 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -4201,8 +4201,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d61a2b9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f1cb745 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37d34e94 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6afa55a0 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -4220,7 +4220,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4aa03783 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@31165389 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -4238,7 +4238,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30f463c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59affb5d // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -4260,8 +4260,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43bb488e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@9577923 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@74a5a912 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4c4aa573 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -4288,7 +4288,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42004ba5 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4fc32d68 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -4312,7 +4312,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3bc7db7f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@691052de // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -4334,8 +4334,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@22a10bb1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@108df0a7 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30a48bd7 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@295cd18d // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -4355,8 +4355,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5090dc70 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5509f93e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7f2201a3 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@144f2a3b // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -4388,8 +4388,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7fdf8cad - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@284339 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@a1f156 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4f3e8876 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -4407,8 +4407,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@560d7c10 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4cd7afe6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@207ea72b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4d8d5fed // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -4426,7 +4426,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4feee835 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42293c4b // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -4445,7 +4445,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@d1d5b7a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@796f6140 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -4467,8 +4467,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@304d5b35 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@41946a45 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c7dc6b9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b2896ec // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -4493,7 +4493,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79038d02 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6828a6 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -4524,8 +4524,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1ea2cfd3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@446cabc1 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28f2c8a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@40857a6c // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -4544,7 +4544,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2648274b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@fd50b66 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -4603,16 +4603,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4620,14 +4620,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4635,14 +4635,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -4655,14 +4655,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -4895,7 +4895,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4905,12 +4905,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4920,9 +4920,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4940,7 +4940,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4950,12 +4950,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4965,9 +4965,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4986,7 +4986,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4996,13 +4996,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5012,10 +5012,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -5049,7 +5049,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5059,12 +5059,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5074,9 +5074,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -9416,14 +9416,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } if (localTag == 1 /* LONG */ && value instanceof Long) { frame.setLong(localIdx, (long) value); return 1 /* LONG */; } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -9758,28 +9758,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } - // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - continue loop; - } // load.argument.long // Pushed Values: 1 // Boxing Elimination: Replace @@ -9802,6 +9780,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; continue loop; } + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + continue loop; + } // store.local.uninit // Locals: // [ 0] target @@ -9861,10 +9861,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73302ab8 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3bfe997d - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7efc1f7 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@48239ed1 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2aa90b56 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6f016f82 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@414f1d74 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28e409a6 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -9883,10 +9883,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43099317 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@451eeb4b - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2911da80 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6421b394 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48269d21 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19ac272d + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@55a22fa0 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3593e650 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -9906,10 +9906,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37097cba - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@78f32e57 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1db8269e - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@49b9e6ee + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7bbd7cf5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1fa4717f + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@c0ef92b + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4af6835 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -9928,8 +9928,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@776d9b75 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6edbe083 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6317283f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4034982f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -9948,8 +9948,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@451b6260 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70f43df + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b7afe3f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6a3f571f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -9967,8 +9967,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@390b2ad5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b5f1976 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@bb06371 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11832cd2 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -9987,10 +9987,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@586b2a35 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@43c6a47e - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5dd71a65 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6cb926a4 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37a3c4f1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d2f44ea + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e121017 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@a03181a // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -10022,10 +10022,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5d50c604 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3ded02f9 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11d58157 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3262beb2 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21e8d476 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@29cb80d1 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1a9431ea + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12f96bd6 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -10044,10 +10044,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3cd6bdf3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a450b43 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57038ea9 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@722a0eeb + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@664d55 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f951a7 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6c154336 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ec45566 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -10078,10 +10078,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@117e84e9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44d1b6f5 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4f48f6c0 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@68f846b5 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70556c4a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5eda799 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45643035 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1c9a4494 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -10099,10 +10099,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4d61a2b9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f1cb745 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@23c5fbc5 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@13af400 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37d34e94 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6afa55a0 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ad0b8c2 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@663b99b // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -10120,8 +10120,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4aa03783 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@9ccec11 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@31165389 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62e2d4fa // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -10139,8 +10139,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30f463c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@23abde73 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59affb5d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c9292d6 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -10162,10 +10162,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43bb488e - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@9577923 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2fbc1210 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@79707913 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@74a5a912 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4c4aa573 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@735b292e + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@686ff9bf // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -10192,8 +10192,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42004ba5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1732be48 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4fc32d68 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cdeb54c // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -10217,8 +10217,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3bc7db7f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6a17b29b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@691052de + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24628023 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -10281,16 +10281,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10298,14 +10298,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10313,14 +10313,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10333,14 +10333,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -10573,7 +10573,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10583,12 +10583,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10598,9 +10598,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10618,7 +10618,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10628,12 +10628,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10643,9 +10643,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10664,7 +10664,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10674,13 +10674,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10690,10 +10690,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10727,7 +10727,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10737,12 +10737,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10752,9 +10752,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -11905,14 +11905,14 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } if (localTag == 1 /* LONG */ && value instanceof Long) { frame.setLong(localIdx, (long) value); return 1 /* LONG */; } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java index 1152e720b4e8..b0a7cfafbf85 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java @@ -68,6 +68,10 @@ protected OperationNode(OperationNodes nodes) { public abstract Object execute(VirtualFrame frame); + public final OperationNodes getOperationNodes() { + return nodes; + } + public final T getMetadata(MetadataKey key) { return key.getValue(this); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index e0157195ba43..34d2a2d86f3a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -54,8 +54,6 @@ public class OperationGeneratorFlags { public static final boolean ENABLE_INSTRUMENTATION = false; public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; - public static final boolean USE_UNSAFE = false; - public static final boolean ENABLE_SERIALIZATION = true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 728905a11eda..c8738281f0b8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -79,8 +79,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import sun.misc.Unsafe; - public class OperationsCodeGenerator extends CodeTypeElementFactory { private ProcessorContext context; @@ -208,20 +206,11 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLabel, "createLabel")); typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationNode, "publish")); - // unsafe stuff - if (OperationGeneratorFlags.USE_UNSAFE) { - typBuilder.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(Unsafe.class), "theUnsafe")).setInit(CodeTreeBuilder.singleString("Unsafe.getUnsafe()")); - } - CodeExecutableElement metUnsafeFromBytecode = typBuilder.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode")); metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - if (OperationGeneratorFlags.USE_UNSAFE) { - metUnsafeFromBytecode.createBuilder().startReturn().string("theUnsafe.getShort(bc, Unsafe.ARRAY_SHORT_BASE_OFFSET + index * Unsafe.ARRAY_SHORT_INDEX_SCALE)").end(); - } else { - metUnsafeFromBytecode.createBuilder().startReturn().string("bc[index]").end(); - } + metUnsafeFromBytecode.createBuilder().startReturn().string("bc[index]").end(); CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder, opNodesImpl); typBuilder.add(typBuilderImpl); @@ -863,6 +852,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.end(3); b.statement("break"); b.end(); + i++; } b.end(); @@ -882,7 +872,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.statement("OperationLocal arg" + i + " = locals.get(buffer.readShort())"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer.readShort()]"); - b.startFor().string("int i = 0; i < locals.length; i++").end().startBlock(); + b.startFor().string("int i = 0; i < arg" + i + ".length; i++").end().startBlock(); // this can be optimized since they are consecutive b.statement("arg" + i + "[i] = locals.get(buffer.readShort());"); b.end(); @@ -1761,6 +1751,7 @@ private void createBeginOperationSerialize(BuilderVariables vars, Operation op, after.add("serBuffer.writeShort((short) ((OperationLocalImpl) arg" + i + ").id)"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { after.add("serBuffer.writeShort((short) arg" + i + ".length)"); + after.add("for (int i = 0; i < arg" + i + ".length; i++) { serBuffer.writeShort((short) ((OperationLocalImpl) arg" + i + "[i]).id); }"); } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { after.add("serBuffer.writeShort((short) ((OperationSerLabelImpl) arg" + i + ").id)"); } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index d7d4dcdca21e..ee26a3751025 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -114,7 +114,7 @@ protected void initializePops() { } if (props.numLocalReferences == -1) { - localRefs = new int[0]; + localRefs = new int[1]; localRefs[0] = addConstant(MARKER_LOCAL_REFS, new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); } else { localRefs = new int[props.numLocalReferences]; From a81f68082ca15d0746c5d67732f43085663692e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 21 Jul 2022 08:32:41 +0200 Subject: [PATCH 116/312] [wip] fix NodeFactory breaking operations gen --- .../sl/operations/SLOperationsBuilder.java | 242 +++++++++--------- .../api/dsl/test/ChildExecutionTest.java | 4 +- .../test/example/TestOperations.java | 14 + .../example/TestOperationsParserTest.java | 84 +----- .../test/example/TestOperationsSerTest.java | 2 +- .../operations/SingleOperationParser.java | 1 + 6 files changed, 140 insertions(+), 207 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 62e954e76fed..a3fd2b8e8b68 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -3973,15 +3973,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2aa90b56 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6f016f82 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6cae1f5a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26078062 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -4000,8 +4000,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48269d21 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19ac272d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fbfc170 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@458f431a // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -4013,7 +4013,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0, method = doGeneric(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -4021,8 +4021,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7bbd7cf5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1fa4717f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c6de31b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1a73e479 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -4041,7 +4041,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6317283f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b261206 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -4060,7 +4060,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b7afe3f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@440e09eb // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -4078,7 +4078,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@bb06371 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57e84f4a // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -4097,8 +4097,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37a3c4f1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d2f44ea + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@523d29e2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1940b781 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -4113,15 +4113,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4130,8 +4130,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21e8d476 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@29cb80d1 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d35b413 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@38322ce0 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -4150,8 +4150,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@664d55 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f951a7 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fb603d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f9b337c // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -4165,14 +4165,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4182,8 +4182,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70556c4a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5eda799 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f0e89b0 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@36f2f39d // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -4195,14 +4195,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37d34e94 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6afa55a0 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e5097f6 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28965993 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -4220,7 +4220,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@31165389 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43be1638 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -4238,7 +4238,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59affb5d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62f16bc9 // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -4251,7 +4251,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4260,8 +4260,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@74a5a912 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4c4aa573 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@874af46 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12b4351a // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -4288,7 +4288,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4fc32d68 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65edfeb9 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -4312,7 +4312,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@691052de + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56c20bfb // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -4328,14 +4328,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromLong // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30a48bd7 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@295cd18d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3059126f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b1fd733 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -4348,15 +4348,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7f2201a3 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@144f2a3b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10de8df + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@47d6b6d6 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -4371,15 +4371,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4388,8 +4388,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@a1f156 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4f3e8876 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fe40e29 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a37e0a9 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -4401,14 +4401,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromBoolean // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@207ea72b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4d8d5fed + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2492b220 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5680c062 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -4426,7 +4426,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@42293c4b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@490a09dd // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -4445,7 +4445,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@796f6140 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3ccd8afd // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -4458,7 +4458,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4467,8 +4467,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c7dc6b9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b2896ec + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@dff3cf6 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5dac6efb // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -4493,7 +4493,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6828a6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4471d072 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -4507,14 +4507,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4524,8 +4524,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@28f2c8a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@40857a6c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@14bb2063 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6057b68e // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -4544,7 +4544,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@fd50b66 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5e32c7c9 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -9854,17 +9854,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2aa90b56 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6f016f82 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@414f1d74 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28e409a6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6cae1f5a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26078062 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c54c74d + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@47b2f91d // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -9883,10 +9883,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@48269d21 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@19ac272d - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@55a22fa0 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3593e650 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fbfc170 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@458f431a + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73248fd6 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58ae9528 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -9898,7 +9898,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0, method = doGeneric(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -9906,10 +9906,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7bbd7cf5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1fa4717f - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@c0ef92b - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4af6835 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c6de31b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1a73e479 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@524a5fdf + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2e02e9a // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -9928,8 +9928,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6317283f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4034982f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b261206 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@55ed4b2f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -9948,8 +9948,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1b7afe3f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6a3f571f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@440e09eb + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79c6936f // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -9967,8 +9967,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@bb06371 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11832cd2 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57e84f4a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79f28f2f // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -9987,10 +9987,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37a3c4f1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6d2f44ea - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e121017 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@a03181a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@523d29e2 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1940b781 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7a65fa75 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@45ee6225 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -10005,15 +10005,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -10022,10 +10022,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@21e8d476 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@29cb80d1 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1a9431ea - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12f96bd6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d35b413 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@38322ce0 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8fecc1c + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6518a1db // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -10044,10 +10044,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@664d55 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@17f951a7 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6c154336 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7ec45566 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fb603d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f9b337c + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@307b595f + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@632ea3f // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -10061,14 +10061,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -10078,10 +10078,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@70556c4a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5eda799 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45643035 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1c9a4494 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f0e89b0 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@36f2f39d + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78d248c9 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58e43871 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -10093,16 +10093,16 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37d34e94 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6afa55a0 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ad0b8c2 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@663b99b + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e5097f6 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28965993 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@32bf3393 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@23cd44e9 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -10120,8 +10120,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@31165389 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62e2d4fa + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43be1638 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4933d459 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -10139,8 +10139,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@59affb5d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c9292d6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62f16bc9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30ed4abe // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -10153,7 +10153,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -10162,10 +10162,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@74a5a912 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4c4aa573 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@735b292e - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@686ff9bf + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@874af46 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12b4351a + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b05d49b + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@32a63d1e // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -10192,8 +10192,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4fc32d68 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cdeb54c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65edfeb9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65e0b60f // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -10217,8 +10217,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@691052de - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@24628023 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56c20bfb + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f82a8b7 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java index 41df83da6316..0bb1d49c822e 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ChildExecutionTest.java @@ -146,14 +146,14 @@ protected boolean doIt(String a, String b) { } @TypeSystem({int.class}) - public static class TestTypeSystem { + public static class ChildTestTypeSystem { } @NodeChildren({ @NodeChild(value = "first", type = ChildExecutionChildNodeWithError.class), @NodeChild(value = "second", type = ChildExecutionChildNode2.class) }) - @TypeSystemReference(TestTypeSystem.class) + @TypeSystemReference(ChildTestTypeSystem.class) public abstract static class TestNode4 extends Node { public abstract Object execute(VirtualFrame frame); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index e71c1b585fd2..5c5137dc0e4e 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateAOT; +import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -54,11 +55,13 @@ import com.oracle.truffle.api.operation.LocalSetter; import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.Variadic; @GenerateOperations @GenerateUncached @GenerateAOT +@OperationProxy(SomeOperationNode.class) public final class TestOperations { @Metadata public static final MetadataKey TestData = new MetadataKey<>("default value"); @@ -144,3 +147,14 @@ public static Object doGeneric(VirtualFrame frame, Object value, LocalSetter set } } } + +@GenerateNodeFactory +abstract class SomeOperationNode extends Node { + + abstract int execute(); + + @Specialization + static int doMagic() { + return 1337; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index caed8027f74e..49f82704b81b 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -56,6 +56,7 @@ import com.oracle.truffle.api.operation.OperationNode; public class TestOperationsParserTest { + // @formatter:off private static RootCallTarget parse(Consumer builder) { OperationNode operationsNode = parseNode(builder); @@ -164,34 +165,26 @@ public void testSumLoop() { b.endStoreLocal(); b.beginWhile(); - { b.beginLessThanOperation(); b.emitLoadLocal(locI); b.emitLoadArgument(0); b.endLessThanOperation(); b.beginBlock(); - { b.beginStoreLocal(locJ); - { b.beginAddOperation(); b.emitLoadLocal(locJ); b.emitLoadLocal(locI); b.endAddOperation(); - } b.endStoreLocal(); b.beginStoreLocal(locI); - { b.beginAddOperation(); b.emitLoadLocal(locI); b.emitConstObject(1L); b.endAddOperation(); - } b.endStoreLocal(); - } b.endBlock(); - } b.endWhile(); b.beginReturn(); @@ -316,8 +309,6 @@ public void testFinallyTryBasic() { RootCallTarget root = parse(b -> { b.beginFinallyTry(); - { - b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(2L); @@ -327,7 +318,6 @@ public void testFinallyTryBasic() { b.emitLoadArgument(0); b.emitConstObject(1L); b.endAppenderOperation(); - } b.endFinallyTry(); b.beginReturn(); @@ -348,14 +338,12 @@ public void testFinallyTryException() { RootCallTarget root = parse(b -> { b.beginFinallyTry(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -367,9 +355,7 @@ public void testFinallyTryException() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.beginReturn(); @@ -386,14 +372,12 @@ public void testFinallyTryException() { public void testFinallyTryReturn() { RootCallTarget root = parse(b -> { b.beginFinallyTry(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); b.endAppenderOperation(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(2L); @@ -402,9 +386,7 @@ public void testFinallyTryReturn() { b.beginReturn(); b.emitConstObject(0L); b.endReturn(); - } b.endBlock(); - } b.endFinallyTry(); b.beginAppenderOperation(); @@ -428,14 +410,12 @@ public void testFinallyTryBranchOut() { OperationLabel lbl = b.createLabel(); b.beginFinallyTry(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -447,9 +427,7 @@ public void testFinallyTryBranchOut() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.beginAppenderOperation(); @@ -484,20 +462,16 @@ public void testFinallyTryCancel() { OperationLabel lbl = b.createLabel(); b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); b.emitBranch(lbl); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -506,9 +480,7 @@ public void testFinallyTryCancel() { b.beginReturn(); b.emitConstObject(0L); b.endReturn(); - } b.endBlock(); - } b.endFinallyTry(); b.beginAppenderOperation(); @@ -541,9 +513,7 @@ public void testFinallyTryInnerCf() { // expected: 1, 3, 5 b.beginFinallyTry(); - { b.beginBlock(); - { OperationLabel lbl = b.createLabel(); b.beginAppenderOperation(); @@ -564,11 +534,9 @@ public void testFinallyTryInnerCf() { b.emitLoadArgument(0); b.emitConstObject(5L); b.endAppenderOperation(); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -582,9 +550,7 @@ public void testFinallyTryInnerCf() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.publish(); @@ -601,29 +567,22 @@ public void testFinallyTryNestedTry() { // expected: 1, 3, 4 b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(4L); b.endAppenderOperation(); - } b.endBlock(); b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -637,11 +596,8 @@ public void testFinallyTryNestedTry() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); - } b.endFinallyTry(); b.publish(); @@ -658,20 +614,15 @@ public void testFinallyTryNestedFinally() { // expected: 1, 3, 5 b.beginFinallyTry(); - { b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(5L); b.endAppenderOperation(); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); @@ -685,13 +636,10 @@ public void testFinallyTryNestedFinally() { b.emitLoadArgument(0); b.emitConstObject(4L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -705,9 +653,7 @@ public void testFinallyTryNestedFinally() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.publish(); @@ -724,29 +670,22 @@ public void testFinallyTryNestedTryThrow() { // expected: 1, 3, 4 b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(4L); b.endAppenderOperation(); - } b.endBlock(); b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -758,11 +697,8 @@ public void testFinallyTryNestedTryThrow() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); - } b.endFinallyTry(); b.publish(); @@ -779,20 +715,15 @@ public void testFinallyTryNestedFinallyThrow() { // expected: 1, 3, 5 b.beginFinallyTry(); - { b.beginFinallyTry(); - { b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(5L); b.endAppenderOperation(); - } b.endBlock(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); @@ -804,13 +735,10 @@ public void testFinallyTryNestedFinallyThrow() { b.emitLoadArgument(0); b.emitConstObject(4L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -822,9 +750,7 @@ public void testFinallyTryNestedFinallyThrow() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTry(); b.publish(); @@ -841,14 +767,12 @@ public void testFinallyTryNoExceptReturn() { RootCallTarget root = parse(b -> { b.beginFinallyTryNoExcept(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -862,9 +786,7 @@ public void testFinallyTryNoExceptReturn() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTryNoExcept(); b.publish(); @@ -881,14 +803,12 @@ public void testFinallyTryNoExceptException() { RootCallTarget root = parse(b -> { b.beginFinallyTryNoExcept(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(3L); b.endAppenderOperation(); b.beginBlock(); - { b.beginAppenderOperation(); b.emitLoadArgument(0); b.emitConstObject(1L); @@ -900,9 +820,7 @@ public void testFinallyTryNoExceptException() { b.emitLoadArgument(0); b.emitConstObject(2L); b.endAppenderOperation(); - } b.endBlock(); - } b.endFinallyTryNoExcept(); b.publish(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 827f72906943..855e450812ed 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -63,7 +63,7 @@ public void testSer() { Assert.assertEquals(3L, root.getCallTarget().call()); } - private TestRootNode deserialize(byte[] byteArray) { + private static TestRootNode deserialize(byte[] byteArray) { ByteArrayInputStream input = new ByteArrayInputStream(byteArray); OperationNodes nodes2 = null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index de3f41562863..3de81a5a1afc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -233,6 +233,7 @@ protected SingleOperationData parse(Element element, List mirr ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChild) || ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChildren)); // remove GenerateUncached annotations - we do not care ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.GenerateUncached)); + ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.GenerateNodeFactory)); // remove all non-static or private elements // this includes all the execute methods From 37d33e22b7dea930b40851d94af3053e2e5bce9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 21 Jul 2022 12:21:38 +0200 Subject: [PATCH 117/312] [wip] move safepoint poll and enable OSR --- .../sl/operations/SLOperationsBuilder.java | 273 ++++++++++-------- .../OperationsBytecodeCodeGenerator.java | 2 + .../operations/OperationsCodeGenerator.java | 2 +- .../instructions/BranchInstruction.java | 39 +-- .../instructions/ReturnInstruction.java | 6 +- 5 files changed, 174 insertions(+), 148 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index a3fd2b8e8b68..08ff8e0c3561 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -3321,7 +3321,7 @@ private static final class OperationNodeImpl extends OperationNode implements By @CompilationFinal int _maxLocals; @CompilationFinal int _maxStack; @CompilationFinal(dimensions = 1) int[] sourceInfo; - @CompilationFinal int uncachedExecuteCount; + @CompilationFinal int uncachedExecuteCount = 16; @CompilationFinal private Object _osrMetadata; private TruffleString _metadata_MethodName; @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; @@ -3609,11 +3609,18 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { - TruffleSafepoint.poll($this); if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); LoopNode.reportLoopCount($this, 256); loopCounter.count = 0; } + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, targetBci, $sp, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } } $bci = targetBci; continue loop; @@ -3973,15 +3980,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6cae1f5a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26078062 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19cfc07 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@643f16e7 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -4000,8 +4007,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fbfc170 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@458f431a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@587558fe + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e56aaae // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -4013,7 +4020,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = doGeneric(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -4021,8 +4028,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c6de31b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1a73e479 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8cc0fa7 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@14d8a877 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -4041,7 +4048,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b261206 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6618a0ba // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -4060,7 +4067,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@440e09eb + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d40650d // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -4078,7 +4085,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57e84f4a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5599f435 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -4097,8 +4104,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@523d29e2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1940b781 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45365e1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@276d18a1 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -4113,15 +4120,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4130,8 +4137,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d35b413 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@38322ce0 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19bb694c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3990e12 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -4150,8 +4157,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fb603d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f9b337c + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cfa1fed + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@539da4c3 // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -4165,14 +4172,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4182,8 +4189,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f0e89b0 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@36f2f39d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11ae46f5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5a8c334c // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -4195,14 +4202,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e5097f6 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28965993 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@16455a87 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28c05f30 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -4220,7 +4227,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43be1638 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4b3a2d33 // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -4238,7 +4245,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62f16bc9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7097614b // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -4251,7 +4258,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4260,8 +4267,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@874af46 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12b4351a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c3a8cbc + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662973d4 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -4288,7 +4295,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65edfeb9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ce08997 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -4312,7 +4319,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56c20bfb + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37362279 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -4328,14 +4335,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromLong // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3059126f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b1fd733 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f71174f + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26b76a6 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -4348,15 +4355,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@10de8df - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@47d6b6d6 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7abffb4d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7c1c2b89 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -4371,15 +4378,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4388,8 +4395,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fe40e29 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@4a37e0a9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b70802a + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27703a4 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -4401,14 +4408,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromBoolean // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2492b220 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5680c062 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@717f534 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1acad63c // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -4426,7 +4433,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@490a09dd + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45e4649f // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -4445,7 +4452,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3ccd8afd + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7f3435a4 // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -4458,7 +4465,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4467,8 +4474,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@dff3cf6 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5dac6efb + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4732d123 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b8584cf // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -4493,7 +4500,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4471d072 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6da3d9bc // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -4507,14 +4514,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4524,8 +4531,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@14bb2063 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6057b68e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@33e448b9 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@620e3c2f // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -4544,7 +4551,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5e32c7c9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@458a6f5d // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -9652,6 +9659,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s int $sp = $startSp; int $bci = $startBci; Counter loopCounter = new Counter(); + CompilerDirectives.transferToInterpreterAndInvalidate(); int uncachedExecuteCount = $this.uncachedExecuteCount; loop: while (true) { CompilerAsserts.partialEvaluationConstant($bci); @@ -9684,13 +9692,20 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s { int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; if (targetBci <= $bci) { - TruffleSafepoint.poll($this); if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); LoopNode.reportLoopCount($this, 256); loopCounter.count = 0; } - uncachedExecuteCount++; - if (uncachedExecuteCount > 16) { + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, targetBci, $sp, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + uncachedExecuteCount--; + if (uncachedExecuteCount <= 0) { $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); return ($sp << 16) | targetBci; } @@ -9844,9 +9859,11 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Boxing Elimination: Do Nothing case INSTR_RETURN : { - uncachedExecuteCount++; - if (uncachedExecuteCount > 16) { + uncachedExecuteCount--; + if (uncachedExecuteCount <= 0) { $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount; } return (($sp - 1) << 16) | 0xffff; } @@ -9854,17 +9871,17 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = add(java.lang.Object,java.lang.Object,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode,com.oracle.truffle.api.strings.TruffleString.ConcatNode), guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6cae1f5a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26078062 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2c54c74d - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@47b2f91d + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19cfc07 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@643f16e7 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ec7fc1 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@45a827e9 // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -9883,10 +9900,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1fbfc170 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@458f431a - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@73248fd6 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58ae9528 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@587558fe + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e56aaae + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e16eb33 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f88b46 // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -9898,7 +9915,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = doGeneric(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -9906,10 +9923,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c6de31b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1a73e479 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@524a5fdf - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2e02e9a + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8cc0fa7 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@14d8a877 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@640cfeaf + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@609f0aa8 // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -9928,8 +9945,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b261206 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@55ed4b2f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6618a0ba + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@69d93afb // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -9948,8 +9965,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@440e09eb - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79c6936f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d40650d + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f3d2e3d // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -9967,8 +9984,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@57e84f4a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@79f28f2f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5599f435 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2cc754f3 // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -9987,10 +10004,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@523d29e2 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1940b781 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7a65fa75 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@45ee6225 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45365e1 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@276d18a1 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3495d189 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@143b2b02 // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -10005,15 +10022,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = readArray(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = readSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = readObject(java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -10022,10 +10039,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2d35b413 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@38322ce0 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8fecc1c - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6518a1db + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19bb694c + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3990e12 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@52b1a37e + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44c71517 // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -10044,10 +10061,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3fb603d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1f9b337c - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@307b595f - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@632ea3f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cfa1fed + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@539da4c3 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ec48d9f + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@136ace7e // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -10061,14 +10078,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = writeArray(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = writeSLObject(com.oracle.truffle.sl.runtime.SLObject,java.lang.Object,java.lang.Object,com.oracle.truffle.api.object.DynamicObjectLibrary,com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode), guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = writeObject(java.lang.Object,java.lang.Object,java.lang.Object,com.oracle.truffle.api.nodes.Node,int,com.oracle.truffle.api.interop.InteropLibrary,com.oracle.truffle.sl.nodes.util.SLToMemberNode), guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -10078,10 +10095,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1f0e89b0 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@36f2f39d - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@78d248c9 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@58e43871 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11ae46f5 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5a8c334c + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c9f353e + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@300cfe17 // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -10093,16 +10110,16 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = fromForeign(java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary), guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6e5097f6 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28965993 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@32bf3393 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@23cd44e9 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@16455a87 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28c05f30 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4a5e35fc + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@f021bf7 // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -10120,8 +10137,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43be1638 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4933d459 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4b3a2d33 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3a81e9ec // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -10139,8 +10156,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@62f16bc9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@30ed4abe + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7097614b + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6daa44ed // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -10153,7 +10170,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = doDirect(com.oracle.truffle.sl.runtime.SLFunction,java.lang.Object[],com.oracle.truffle.api.Assumption,com.oracle.truffle.api.RootCallTarget,com.oracle.truffle.api.nodes.DirectCallNode), guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -10162,10 +10179,10 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@874af46 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@12b4351a - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7b05d49b - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@32a63d1e + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c3a8cbc + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662973d4 + // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56e06d71 + // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@492209f9 // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -10192,8 +10209,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65edfeb9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@65e0b60f + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ce08997 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c5957b8 // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -10217,8 +10234,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56c20bfb - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3f82a8b7 + // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37362279 + // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43ebf9f2 // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index db8f57a1dc4c..40e35bd3baf7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -258,6 +258,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("Counter", "loopCounter", "new Counter()"); if (isUncached) { + // todo: better signaling to compiler that the method is not ready for compilation + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.declaration("int", "uncachedExecuteCount", "$this.uncachedExecuteCount"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index c8738281f0b8..f8bb07cae1d8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -350,7 +350,7 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "uncachedExecuteCount"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "uncachedExecuteCount = 16"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 0366fa354f46..e757e8a23fa1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -48,6 +48,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +@SuppressWarnings("unused") public class BranchInstruction extends Instruction { private final ProcessorContext context = ProcessorContext.getInstance(); @@ -57,7 +58,7 @@ public class BranchInstruction extends Instruction { private static final boolean SAFEPOINT_POLL = true; private static final boolean LOOP_COUNTING = true; - private static final boolean TRY_OSR = false; + private static final boolean TRY_OSR = true; private static final int REPORT_LOOP_STRIDE = 1 << 8; @@ -84,23 +85,25 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR || uncached) { b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { - if (SAFEPOINT_POLL) { - b.startStatement().startStaticCall(typeTruffleSafepoint, "poll"); - b.string("$this"); - b.end(2); - } - - if (LOOP_COUNTING) { + if (LOOP_COUNTING || SAFEPOINT_POLL) { b.startIf(); b.tree(GeneratorUtils.createHasNextTier()); b.string(" && "); b.string("++loopCounter.count >= " + REPORT_LOOP_STRIDE); b.end().startBlock(); // { - b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); - b.string("$this"); - b.string("" + REPORT_LOOP_STRIDE); - b.end(2); + if (SAFEPOINT_POLL) { + b.startStatement().startStaticCall(typeTruffleSafepoint, "poll"); + b.string("$this"); + b.end(2); + } + + if (LOOP_COUNTING) { + b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); + b.string("$this"); + b.string("" + REPORT_LOOP_STRIDE); + b.end(2); + } b.statement("loopCounter.count = 0"); @@ -111,10 +114,10 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.startIf(); b.tree(GeneratorUtils.createInInterpreter()); b.string(" && "); - b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("this").end(); + b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("$this").end(); b.end().startBlock(); // { b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); - b.string("this"); + b.string("$this"); b.string("targetBci"); b.variable(vars.sp); b.string("null"); @@ -122,15 +125,17 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.end(2); b.startIf().string("osrResult != null").end().startBlock(); // { - b.startReturn().string("osrResult").end(); + // todo: check if this will overwrite a local in reused frames + b.statement("$frame.setObject(0, osrResult)"); + b.startReturn().string("0x0000ffff").end(); b.end(); // } b.end(); // } } if (uncached) { - b.statement("uncachedExecuteCount++"); - b.startIf().string("uncachedExecuteCount > 16").end().startBlock(); + b.statement("uncachedExecuteCount--"); + b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); b.statement("return ($sp << 16) | targetBci"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 946a3d20f34e..ae0f47ed7d89 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -75,9 +75,11 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } if (uncached) { - b.statement("uncachedExecuteCount++"); - b.startIf().string("uncachedExecuteCount > 16").end().startBlock(); + b.statement("uncachedExecuteCount--"); + b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); + b.end().startElseBlock(); + b.statement("$this.uncachedExecuteCount = uncachedExecuteCount"); b.end(); } From 6b3895bb29a6881a76a7bfb9a35d7f77a3789551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 21 Jul 2022 12:51:27 +0200 Subject: [PATCH 118/312] [wip] fix uncached generation --- .../sl/operations/SLOperationsBuilder.java | 645 ++++++------------ .../dsl/processor/generator/BitSet.java | 28 + .../generator/FlatNodeGenFactory.java | 3 - .../processor/model/SpecializationData.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 8 +- .../instructions/LoadArgumentInstruction.java | 4 + 7 files changed, 247 insertions(+), 445 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 08ff8e0c3561..fc9399f16049 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -382,160 +382,160 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int C_SL_ADD_CHILDREN_OFFSET = 2; static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_LENGTH = 8; + static final int C_SL_ADD_LENGTH = 6; static final int INSTR_C_SL_DIV = 25; static final int C_SL_DIV_CONSTANT_OFFSET = 1; static final int C_SL_DIV_CHILDREN_OFFSET = 2; static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - static final int C_SL_DIV_LENGTH = 8; + static final int C_SL_DIV_LENGTH = 6; static final int INSTR_C_SL_EQUAL = 26; static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - static final int C_SL_EQUAL_LENGTH = 7; + static final int C_SL_EQUAL_LENGTH = 5; static final int INSTR_C_SL_LESS_OR_EQUAL = 27; static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_LENGTH = 6; + static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; static final int INSTR_C_SL_LESS_THAN = 28; static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_LENGTH = 6; + static final int C_SL_LESS_THAN_LENGTH = 5; static final int INSTR_C_SL_LOGICAL_NOT = 29; static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - static final int C_SL_LOGICAL_NOT_LENGTH = 6; + static final int C_SL_LOGICAL_NOT_LENGTH = 5; static final int INSTR_C_SL_MUL = 30; static final int C_SL_MUL_CONSTANT_OFFSET = 1; static final int C_SL_MUL_CHILDREN_OFFSET = 2; static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - static final int C_SL_MUL_LENGTH = 8; + static final int C_SL_MUL_LENGTH = 6; static final int INSTR_C_SL_READ_PROPERTY = 31; static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_LENGTH = 8; + static final int C_SL_READ_PROPERTY_LENGTH = 6; static final int INSTR_C_SL_SUB = 32; static final int C_SL_SUB_CONSTANT_OFFSET = 1; static final int C_SL_SUB_CHILDREN_OFFSET = 2; static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - static final int C_SL_SUB_LENGTH = 8; + static final int C_SL_SUB_LENGTH = 6; static final int INSTR_C_SL_WRITE_PROPERTY = 33; static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_LENGTH = 9; + static final int C_SL_WRITE_PROPERTY_LENGTH = 7; static final int INSTR_C_SL_UNBOX = 34; static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_LENGTH = 7; + static final int C_SL_UNBOX_LENGTH = 5; static final int INSTR_C_SL_FUNCTION_LITERAL = 35; static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_LENGTH = 6; + static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; static final int INSTR_C_SL_TO_BOOLEAN = 36; static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_LENGTH = 6; + static final int C_SL_TO_BOOLEAN_LENGTH = 5; static final int INSTR_C_SL_INVOKE = 37; static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; static final int C_SL_INVOKE_VARIADIC_OFFSET = 3; static final int C_SL_INVOKE_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_LENGTH = 8; + static final int C_SL_INVOKE_LENGTH = 6; static final int INSTR_SC_SL_AND = 38; static final int SC_SL_AND_CONSTANT_OFFSET = 1; static final int SC_SL_AND_CHILDREN_OFFSET = 2; static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - static final int SC_SL_AND_LENGTH = 7; + static final int SC_SL_AND_LENGTH = 6; static final int INSTR_SC_SL_OR = 39; static final int SC_SL_OR_CONSTANT_OFFSET = 1; static final int SC_SL_OR_CHILDREN_OFFSET = 2; static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - static final int SC_SL_OR_LENGTH = 7; + static final int SC_SL_OR_LENGTH = 6; static final int INSTR_C_SL_UNBOX_Q_FROM_LONG = 40; static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 7; + static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; static final int INSTR_C_SL_ADD_Q_ADD_LONG = 41; static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 8; + static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; static final int INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 42; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 8; + static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; static final int INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 43; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 7; + static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; static final int INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 44; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 6; + static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; static final int INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET = 1; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CHILDREN_OFFSET = 2; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 6; + static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 5; static final int INSTR_C_SL_INVOKE_Q_DIRECT = 46; static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 3; static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 8; + static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 6; static final int INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 47; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 6; + static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; static final int INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 48; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 9; + static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; static final int INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 = 49; static final int C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET = 1; static final int C_SL_LESS_THAN_Q_LESS_THAN0_CHILDREN_OFFSET = 2; static final int C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET = 3; static final int C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 6; + static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 5; private static final short[][] BOXING_DESCRIPTORS = { // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // INT null, // DOUBLE @@ -543,7 +543,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 1) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 2) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 1) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // BYTE null}; @@ -897,8 +897,7 @@ void doBeforeChild() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - bci = bci + 7; + bci = bci + 6; } break; } @@ -915,8 +914,7 @@ void doBeforeChild() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - bci = bci + 7; + bci = bci + 6; } break; } @@ -1879,9 +1877,7 @@ public void endSLAdd() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1931,9 +1927,7 @@ public void endSLDiv() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -1980,9 +1974,7 @@ public void endSLEqual() { bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; - bc[bci + 3 + 2] = 0; - bc[bci + 3 + 3] = 0; - bci = bci + 7; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2031,8 +2023,7 @@ public void endSLLessOrEqual() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2081,8 +2072,7 @@ public void endSLLessThan() { bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2130,8 +2120,7 @@ public void endSLLogicalNot() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2181,9 +2170,7 @@ public void endSLMul() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2235,9 +2222,7 @@ public void endSLReadProperty() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2287,9 +2272,7 @@ public void endSLSub() { bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2341,9 +2324,7 @@ public void endSLWriteProperty() { bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); bc[bci + 5 + 0] = 0; bc[bci + 5 + 1] = 0; - bc[bci + 5 + 2] = 0; - bc[bci + 5 + 3] = 0; - bci = bci + 9; + bci = bci + 7; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2389,9 +2370,7 @@ public void endSLUnbox() { bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; - bc[bci + 3 + 2] = 0; - bc[bci + 3 + 3] = 0; - bci = bci + 7; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2439,8 +2418,7 @@ public void endSLFunctionLiteral() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2488,8 +2466,7 @@ public void endSLToBoolean() { numChildNodes += 1; bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; + bci = bci + 5; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -2538,9 +2515,7 @@ public void endSLInvoke() { bc[bci + 3] = (short) (numChildren - 1); bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; - bc[bci + 4 + 2] = 0; - bc[bci + 4 + 3] = 0; - bci = bci + 8; + bci = bci + 6; lastChildPush = 1; operationData = operationData.parent; doAfterChild(); @@ -3980,15 +3955,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19cfc07 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@643f16e7 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -4007,8 +3982,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@587558fe - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e56aaae + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -4020,7 +3995,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -4028,8 +4003,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8cc0fa7 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@14d8a877 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -4048,7 +4023,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6618a0ba + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -4067,7 +4042,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d40650d + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -4085,7 +4060,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5599f435 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -4104,8 +4079,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45365e1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@276d18a1 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -4120,15 +4095,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4137,8 +4112,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19bb694c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3990e12 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -4157,8 +4132,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cfa1fed - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@539da4c3 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -4172,14 +4147,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4189,8 +4164,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11ae46f5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5a8c334c + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -4202,14 +4177,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@16455a87 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28c05f30 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -4227,7 +4202,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4b3a2d33 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -4245,7 +4220,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7097614b + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -4258,7 +4233,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4267,8 +4242,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c3a8cbc - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662973d4 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -4295,7 +4270,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ce08997 + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -4319,7 +4294,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37362279 + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -4335,14 +4310,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromLong // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f71174f - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@26b76a6 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_LONG : { @@ -4355,15 +4330,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7abffb4d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@7c1c2b89 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD_Q_ADD_LONG : { @@ -4378,15 +4353,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -4395,8 +4370,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5b70802a - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@27703a4 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : { @@ -4408,14 +4383,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox.q.FromBoolean // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@717f534 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@1acad63c + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : { @@ -4433,7 +4408,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45e4649f + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : { @@ -4452,7 +4427,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7f3435a4 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : { @@ -4465,7 +4440,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -4474,8 +4449,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4732d123 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@b8584cf + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE_Q_DIRECT : { @@ -4500,7 +4475,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6da3d9bc + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : { @@ -4514,14 +4489,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -4531,8 +4506,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@33e448b9 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@620e3c2f + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : { @@ -4551,7 +4526,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@458a6f5d + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : { @@ -9773,50 +9748,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } - // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - continue loop; - } - // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - continue loop; - } // store.local.uninit // Locals: // [ 0] target @@ -9871,17 +9802,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Add1, method = public static com.oracle.truffle.api.strings.TruffleString add(java.lang.Object, java.lang.Object, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode, com.oracle.truffle.api.strings.TruffleString.ConcatNode) , guards = [Guard[(SLAddNode.isString(left, right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = Add1] // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19cfc07 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@643f16e7 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ec7fc1 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@45a827e9 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_ADD : { @@ -9900,10 +9829,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@587558fe - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@6e56aaae - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3e16eb33 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@2f88b46 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_DIV : { @@ -9915,7 +9842,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLEqual // Children: // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0, method = public static boolean doGeneric(java.lang.Object, java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(leftInterop.accepts(left))], Guard[(rightInterop.accepts(right))]], signature = [java.lang.Object, java.lang.Object]] + // [ 1] SpecializationData [id = Generic0] // [ 2] CacheExpression [sourceParameter = leftInterop] // [ 3] CacheExpression [sourceParameter = rightInterop] // Indexed Pops: @@ -9923,10 +9850,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@8cc0fa7 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@14d8a877 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@640cfeaf - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@609f0aa8 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_EQUAL : { @@ -9945,8 +9870,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6618a0ba - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@69d93afb + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_OR_EQUAL : { @@ -9965,8 +9889,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3d40650d - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2f3d2e3d + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] // Boxing Elimination: Bit Mask case INSTR_C_SL_LESS_THAN : { @@ -9984,8 +9907,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5599f435 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@2cc754f3 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_LOGICAL_NOT : { @@ -10004,10 +9926,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@45365e1 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@276d18a1 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3495d189 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@143b2b02 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_MUL : { @@ -10022,15 +9942,15 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] CacheExpression [sourceParameter = bci] // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = ReadArray0, method = public static java.lang.Object readArray(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = ReadArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0, method = public static java.lang.Object readSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object]] + // [ 4] SpecializationData [id = ReadSLObject0] // [ 5] CacheExpression [sourceParameter = node] // [ 6] CacheExpression [sourceParameter = objectLibrary] // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0, method = public static java.lang.Object readObject(java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objects.accepts(receiver))], Guard[(!(SLReadPropertyNode.isSLObject(receiver)))], Guard[(objects.hasMembers(receiver))]], signature = [java.lang.Object, java.lang.Object]] + // [ 8] SpecializationData [id = ReadObject0] // [ 9] CacheExpression [sourceParameter = node] // [10] CacheExpression [sourceParameter = objects] // [11] CacheExpression [sourceParameter = asMember] @@ -10039,10 +9959,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@19bb694c - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@3990e12 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@52b1a37e - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@44c71517 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_READ_PROPERTY : { @@ -10061,10 +9979,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 1] arg1 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@1cfa1fed - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@539da4c3 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@5ec48d9f - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@136ace7e + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_SUB : { @@ -10078,14 +9994,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] CacheExpression [sourceParameter = bci] // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = WriteArray0, method = public static java.lang.Object writeArray(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(arrays.accepts(receiver))], Guard[(numbers.accepts(index))], Guard[(arrays.hasArrayElements(receiver))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 0] SpecializationData [id = WriteArray0] // [ 1] CacheExpression [sourceParameter = node] // [ 2] CacheExpression [sourceParameter = arrays] // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0, method = public static java.lang.Object writeSLObject(com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object, com.oracle.truffle.api.object.DynamicObjectLibrary, com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode) , guards = [Guard[(objectLibrary.accepts(receiver))]], signature = [com.oracle.truffle.sl.runtime.SLObject, java.lang.Object, java.lang.Object]] + // [ 4] SpecializationData [id = WriteSLObject0] // [ 5] CacheExpression [sourceParameter = objectLibrary] // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0, method = public static java.lang.Object writeObject(java.lang.Object, java.lang.Object, java.lang.Object, com.oracle.truffle.api.nodes.Node, int, com.oracle.truffle.api.interop.InteropLibrary, com.oracle.truffle.sl.nodes.util.SLToMemberNode) , guards = [Guard[(objectLibrary.accepts(receiver))], Guard[(!(SLWritePropertyNode.isSLObject(receiver)))]], signature = [java.lang.Object, java.lang.Object, java.lang.Object]] + // [ 7] SpecializationData [id = WriteObject0] // [ 8] CacheExpression [sourceParameter = node] // [ 9] CacheExpression [sourceParameter = objectLibrary] // [10] CacheExpression [sourceParameter = asMember] @@ -10095,10 +10011,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 2] arg2 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@11ae46f5 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@5a8c334c - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c9f353e - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@300cfe17 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_WRITE_PROPERTY : { @@ -10110,16 +10024,14 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // c.SLUnbox // Children: // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0, method = public static java.lang.Object fromForeign(java.lang.Object, com.oracle.truffle.api.interop.InteropLibrary) , guards = [Guard[(interop.accepts(value))]], signature = [java.lang.Object]] + // [ 1] SpecializationData [id = FromForeign0] // [ 2] CacheExpression [sourceParameter = interop] // Indexed Pops: // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@16455a87 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@28c05f30 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4a5e35fc - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@f021bf7 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] // Boxing Elimination: Bit Mask case INSTR_C_SL_UNBOX : { @@ -10137,8 +10049,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4b3a2d33 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@3a81e9ec + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] // Boxing Elimination: Bit Mask case INSTR_C_SL_FUNCTION_LITERAL : { @@ -10156,8 +10067,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // [ 0] arg0 // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7097614b - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@6daa44ed + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Bit Mask case INSTR_C_SL_TO_BOOLEAN : { @@ -10170,7 +10080,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] SpecializationData [id = Direct, method = protected static java.lang.Object doDirect(com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[], com.oracle.truffle.api.Assumption, com.oracle.truffle.api.RootCallTarget, com.oracle.truffle.api.nodes.DirectCallNode) , guards = [Guard[(function.getCallTarget() == cachedTarget)]], signature = [com.oracle.truffle.sl.runtime.SLFunction, java.lang.Object[]]] + // [ 0] SpecializationData [id = Direct] // [ 1] CacheExpression [sourceParameter = callNode] // [ 2] CacheExpression [sourceParameter = library] // [ 3] CacheExpression [sourceParameter = node] @@ -10179,10 +10089,8 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Variadic // Pushed Values: 1 // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@4c3a8cbc - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@662973d4 - // [ 2] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@56e06d71 - // [ 3] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$ExcludeBitSet@492209f9 + // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] // Boxing Elimination: Bit Mask case INSTR_C_SL_INVOKE : { @@ -10209,8 +10117,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7ce08997 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@7c5957b8 + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Do Nothing case INSTR_SC_SL_AND : { @@ -10234,8 +10141,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Branch Targets: // [ 0] end // State Bitsets: - // [ 0] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@37362279 - // [ 1] com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory$StateBitSet@43ebf9f2 + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] // Boxing Elimination: Do Nothing case INSTR_SC_SL_OR : { @@ -10811,8 +10717,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLAdd "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10828,8 +10734,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLDiv "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10844,8 +10750,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append(" "); sb.append(" "); sb.append("c.SLEqual "); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10860,7 +10766,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLLessOrEqual "); @@ -10877,7 +10783,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLLessThan "); @@ -10894,7 +10800,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLLogicalNot "); @@ -10911,8 +10817,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLMul "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10928,8 +10834,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLReadProperty "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); @@ -10947,8 +10853,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLSub "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10965,8 +10871,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); - sb.append(String.format(" %04x", $bc[$bci + 8])); + sb.append(" "); sb.append("c.SLWriteProperty "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); @@ -10983,8 +10888,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append(" "); sb.append(" "); sb.append("c.SLUnbox "); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -10998,7 +10903,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLFunctionLiteral "); @@ -11014,7 +10919,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLToBoolean "); @@ -11031,8 +10936,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLInvoke "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); @@ -11047,7 +10952,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); sb.append(" "); sb.append("sc.SLAnd "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); @@ -11064,7 +10969,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); sb.append(" "); sb.append("sc.SLOr "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); @@ -11080,8 +10985,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append(" "); sb.append(" "); sb.append("c.SLUnbox.q.FromLong "); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -11096,8 +11001,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLAdd.q.AddLong "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -11113,8 +11018,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLReadProperty.q.ReadSLObject0"); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); @@ -11131,8 +11036,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append(" "); sb.append(" "); sb.append("c.SLUnbox.q.FromBoolean "); sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); @@ -11146,7 +11051,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLToBoolean.q.Boolean "); @@ -11162,7 +11067,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLLessOrEqual.q.LessOrEqual0"); @@ -11180,8 +11085,8 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); + sb.append(" "); + sb.append(" "); sb.append("c.SLInvoke.q.Direct "); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); @@ -11195,7 +11100,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLFunctionLiteral.q.Perform "); @@ -11213,8 +11118,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 4])); sb.append(String.format(" %04x", $bc[$bci + 5])); sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(String.format(" %04x", $bc[$bci + 7])); - sb.append(String.format(" %04x", $bc[$bci + 8])); + sb.append(" "); sb.append("c.SLWriteProperty.q.WriteSLObject0"); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); @@ -11231,7 +11135,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(String.format(" %04x", $bc[$bci + 2])); sb.append(String.format(" %04x", $bc[$bci + 3])); sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); sb.append(" "); sb.append(" "); sb.append("c.SLLessThan.q.LessThan0 "); @@ -11291,12 +11195,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doLong($child0Value_, $child1Value_)); return; } } @@ -11304,12 +11203,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doBigNumber($child0Value_, $child1Value_)); return; } } @@ -11317,12 +11211,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI boolean $child0Value_ = (boolean) $child0Value; if ($child1Value instanceof Boolean) { boolean $child1Value_ = (boolean) $child1Value; - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doBoolean($child0Value_, $child1Value_)); return; } } @@ -11330,12 +11219,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI String $child0Value_ = (String) $child0Value; if ($child1Value instanceof String) { String $child1Value_ = (String) $child1Value; - boolean value = SLEqualNode.doString($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doString($child0Value_, $child1Value_)); return; } } @@ -11343,12 +11227,7 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI TruffleString $child0Value_ = (TruffleString) $child0Value; if ($child1Value instanceof TruffleString) { TruffleString $child1Value_ = (TruffleString) $child1Value; - boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached()))); return; } } @@ -11356,31 +11235,16 @@ private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeI SLNull $child0Value_ = SLTypes.asSLNull($child0Value); if (SLTypes.isSLNull($child1Value)) { SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doNull($child0Value_, $child1Value_)); return; } } if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; - boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doFunction($child0Value_, $child1Value)); return; } - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - if ((($bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); return; } @@ -11391,12 +11255,7 @@ private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, Operatio long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); return; } } @@ -11404,12 +11263,7 @@ private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, Operatio SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); return; } } @@ -11424,12 +11278,7 @@ private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNo long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); return; } } @@ -11437,12 +11286,7 @@ private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNo SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); return; } } @@ -11455,12 +11299,7 @@ private static void SLLogicalNot_executeUncached_(VirtualFrame $frame, Operation int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLLogicalNotNode.doBoolean($child0Value_)); return; } $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, ($this), ($bci))); @@ -11550,22 +11389,12 @@ private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeI } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); return; } if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); return; } if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { @@ -11603,20 +11432,10 @@ private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationN int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLToBooleanNode.doBoolean($child0Value_)); return; } - boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - if ((($bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLToBooleanNode.doFallback($child0Value, ($this), ($bci))); return; } @@ -11665,22 +11484,12 @@ private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, Ope } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); return; } if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); return; } if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { @@ -11755,22 +11564,12 @@ private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, } if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); return; } if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - long value = SLUnboxNode.fromLong($child0Value_); - if ((($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 2] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } + $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); return; } if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { @@ -11797,20 +11596,10 @@ private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, int constArrayOffset_; if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLToBooleanNode.doBoolean($child0Value_)); return; } - boolean value = SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - if ((($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } + $frame.setObject($sp - 1, SLToBooleanNode.doFallback($child0Value, ($this), ($bci))); return; } @@ -11821,12 +11610,7 @@ private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $ long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); return; } } @@ -11834,12 +11618,7 @@ private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $ SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); return; } } @@ -11894,12 +11673,7 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); return; } } @@ -11907,12 +11681,7 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if ((($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 1] & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } + $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); return; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index d8c0e19c292e..199acefbde77 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -44,9 +44,11 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -453,4 +455,30 @@ private int getStateOffset(Object object) { return value; } + @Override + public String toString() { + return String.format("%s %s %s", getClass().getSimpleName(), getName(), Arrays.toString(getObjects())); + } + + @Override + public int hashCode() { + return Objects.hash(getClass(), getName()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + // names and types must be the same + if (obj.getClass() != getClass()) { + return false; + } + + BitSet bs = (BitSet) obj; + + return bs.getName().equals(getName()); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 8f9086288ef3..723091708c3f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5865,7 +5865,6 @@ String getOldName() { String getNewName() { return "new" + ElementUtils.firstLetterUpperCase(getName()); } - } public class StateBitSet extends NodeBitSet { @@ -5898,7 +5897,6 @@ boolean containsSpecialization() { } return false; } - } private static class ExcludeBitSet extends NodeBitSet { @@ -5920,7 +5918,6 @@ protected int calculateRequiredBits(Object object) { } throw new IllegalArgumentException(); } - } public static final class FrameState { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java index 0245a739f9ad..e04b6d1ec005 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java @@ -602,7 +602,7 @@ public SpecializationData findNextSpecialization() { @Override public String toString() { - return String.format("%s [id = %s, method = %s, guards = %s, signature = %s]", getClass().getSimpleName(), getId(), getMethod(), getGuards(), getDynamicTypes()); + return String.format("%s [id = %s]", getClass().getSimpleName(), getId()); } public boolean isFrameUsedByGuard() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 40e35bd3baf7..47f85f9ee157 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -410,7 +410,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr final SingleOperationData soData = cinstr.getData(); - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, isVariadic, cinstr, staticConstants); + OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, isVariadic, cinstr, staticConstants, isUncached); cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index e9749fa4b5f1..6924d7c7017a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -104,6 +104,7 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator private final ExecutionVariables dummyVariables = new ExecutionVariables(); private NodeData nodeData; private Predicate useSpecializationClass; + private final boolean uncached; { context = ProcessorContext.getInstance(); @@ -111,7 +112,8 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator OperationsBytecodeCodeGenerator.populateVariables(dummyVariables); } - OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, boolean isVariadic, CustomInstruction cinstr, StaticConstants staticConstants) { + OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, boolean isVariadic, CustomInstruction cinstr, StaticConstants staticConstants, + boolean uncached) { this.m = m; this.innerTypeNames = innerTypeNames; this.methodNames = methodNames; @@ -131,6 +133,8 @@ public String toString() { } }; } + + this.uncached = uncached; } public void setUseSpecializationClass(Predicate useSpecializationClass) { @@ -445,7 +449,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree CodeTree isResultBoxed = multiState.createNotContains(frameState, new Object[]{resultUnboxedState}); - if (typeName.equals("Object")) { + if (uncached || typeName.equals("Object")) { b.startStatement(); b.startCall("$frame", "setObject"); b.string("$sp - " + destOffset); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index d919201c2209..7d03705de86a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -125,4 +125,8 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } + @Override + public boolean neverInUncached() { + return kind != FrameKind.OBJECT; + } } From 459159b5f05d89e66879afb0f4cf35f6922818b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 3 Aug 2022 18:14:49 +0200 Subject: [PATCH 119/312] [wip] fix codegen codegen was breaking when there is no specialization class, but there is removeThis --- .../test/example/TestOperations.java | 21 +++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 20 +++++++++++------- .../generator/NodeGeneratorPlugs.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 4 ++-- .../operations/OperationsCodeGenerator.java | 2 +- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 5c5137dc0e4e..b2bd00c28c61 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -42,7 +42,9 @@ import java.util.List; +import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -146,6 +148,25 @@ public static Object doGeneric(VirtualFrame frame, Object value, LocalSetter set return value; } } + + @Operation + public static final class GlobalCachedReadOp { + @Specialization(assumptions = "cachedAssumption") + public static Object doCached(final Association assoc, + @Cached(value = "assoc.getAssumption()", allowUncached = true) final Assumption cachedAssumption) { + return assoc.getValue(); + } + } +} + +class Association { + public Object getValue() { + return new Object(); + } + + public Assumption getAssumption() { + return Assumption.ALWAYS_VALID; + } } @GenerateNodeFactory diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 723091708c3f..57e5bd711718 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -4350,7 +4350,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (useSpecializationClass(excludes)) { if (plugs != null) { builder.startStatement(); - builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, createSpecializationTypeMirror(specialization), true)); builder.string(" = null"); builder.end(); } else { @@ -4436,7 +4436,7 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.end(); builder.startStatement(); if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, createSpecializationTypeMirror(specialization), true)); } else { builder.string("this.", createSpecializationFieldName(specialization)); } @@ -4472,7 +4472,7 @@ private Collection initializeSpecializationClass(FrameState if (specialization.getMaximumNumberOfInstances() > 1) { if (plugs != null) { initBuilder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, - new GeneratedTypeMirror("", createSpecializationTypeName(specialization)))); + createSpecializationTypeMirror(specialization), false)); } else { initBuilder.string(createSpecializationFieldName(specialization)); } @@ -4644,7 +4644,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState String fieldName = createSpecializationFieldName(removeSpecialization); builder.startStatement(); if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, removeSpecialization, fieldName, null)); + builder.tree(plugs.createSpecializationFieldReference(frameState, removeSpecialization, fieldName, createSpecializationTypeMirror(specialization), true)); } else { builder.string("this." + fieldName); } @@ -4710,9 +4710,9 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, CodeTree fieldRefWrite = fieldRef; if (plugs != null) { String fieldName = useSpecializationClass ? null : createSpecializationFieldName(specialization); - fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, - new GeneratedTypeMirror("", createSpecializationTypeName(specialization))); - fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, null); + TypeMirror typeMirror = createSpecializationTypeMirror(specialization); + fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, typeMirror, false); + fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, typeMirror, true); } if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { // single instance remove @@ -4779,6 +4779,10 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, return builder.build(); } + private TypeMirror createSpecializationTypeMirror(SpecializationData specialization) { + return new GeneratedTypeMirror("", createSpecializationTypeName(specialization)); + } + private CodeTree createCallExecute(ExecutableTypeData forType, ExecutableTypeData targetType, FrameState frameState) { TypeMirror returnType = targetType.getReturnType(); @@ -5364,7 +5368,7 @@ private CodeTree createSpecializationFieldReference(FrameState frameState, Speci builder.string(localName); } else { if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, new GeneratedTypeMirror("", createSpecializationTypeName(s)))); + builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, createSpecializationTypeMirror(s), false)); } else { builder.string("this.", createSpecializationFieldName(s)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index efc330cf3bd1..a6e7726faef5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -79,7 +79,7 @@ public interface NodeGeneratorPlugs { CodeTree transformValueBeforePersist(CodeTree tree); - CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType); + CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write); CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 6924d7c7017a..701ffd8b8eb9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -313,11 +313,11 @@ public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphis } @Override - public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType) { + public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write) { boolean specClass = useSpecializationClass.test(s); Object refObject = specClass ? s : fieldName; boolean isChild = specClass ? true : ElementUtils.isAssignable(fieldType, types.Node); - return createArrayReference(frame, refObject, fieldType != null, fieldType, isChild); + return createArrayReference(frame, refObject, !write, fieldType, isChild); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index f8bb07cae1d8..a4e03bfb9883 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -219,7 +219,7 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(createSetMetadata(metadata, true)); } - CodeTypeElement typWrappedEx = typBuilderImpl.add(GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "WrappedIOException", context.getType(RuntimeException.class))); + CodeTypeElement typWrappedEx = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "WrappedIOException", context.getType(RuntimeException.class)); typWrappedEx.add(new CodeExecutableElement(Set.of(), null, "WrappedIOException", new CodeVariableElement(context.getType(IOException.class), "ex"))).createBuilder().statement("super(ex)"); typBuilder.add(typWrappedEx); From 87d054e5633422072da0e8477ad3a6e2bd276987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 4 Aug 2022 11:38:11 +0200 Subject: [PATCH 120/312] [wip] serialization changes --- .../sl/operations/SLOperationsBuilder.java | 519 +++++++++--------- .../truffle/api/operation/OperationNodes.java | 9 +- .../api/operation/OperationParser.java | 46 ++ .../OperationDeserializationCallback.java | 6 +- .../operations/OperationsCodeGenerator.java | 134 +++-- .../sl/nodes/util/SLToBooleanNode.java | 40 ++ .../operations/SLOperationSerialization.java | 24 +- 7 files changed, 463 insertions(+), 315 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationParser.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index fc9399f16049..b75920e0ad30 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -37,6 +37,7 @@ import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationParser; import com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback; import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; import com.oracle.truffle.api.source.Source; @@ -68,14 +69,13 @@ import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLNull; import com.oracle.truffle.sl.runtime.SLObject; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.invoke.VarHandle; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.concurrent.locks.Lock; -import java.util.function.Consumer; @GeneratedBy(SLOperations.class) @SuppressWarnings({"serial", "unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) @@ -222,15 +222,15 @@ private static short unsafeFromBytecode(short[] bc, int index) { return bc[index]; } - public static OperationNodes create(OperationConfig config, Consumer generator) { + public static OperationNodes create(OperationConfig config, OperationParser generator) { OperationNodesImpl nodes = new OperationNodesImpl(generator); BuilderImpl builder = new BuilderImpl(nodes, false, config); - generator.accept(builder); + generator.parse(builder); builder.finish(); return nodes; } - public static OperationNodes deserialize(OperationConfig config, DataInputStream input, OperationDeserializationCallback callback) throws IOException { + public static OperationNodes deserialize(OperationConfig config, ByteBuffer input, OperationDeserializationCallback callback) throws IOException { try { return create(config, b -> BuilderImpl.deserializeParser(input, callback, b)); } catch (WrappedIOException ex) { @@ -238,17 +238,30 @@ public static OperationNodes deserialize(OperationConfig config, DataInputStream } } + public static void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback, OperationParser generator) throws IOException { + BuilderImpl builder = new BuilderImpl(null, false, config); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + try { + generator.parse(builder); + } catch (WrappedIOException ex) { + throw (IOException) ex.getCause(); + } + buffer.writeShort((short) -5); + } + @GeneratedBy(SLOperations.class) private static final class OperationNodesImpl extends OperationNodes { - OperationNodesImpl(Consumer parse) { + OperationNodesImpl(OperationParser parse) { super(parse); } @Override - protected void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes) { + protected void reparseImpl(OperationConfig config, OperationParser parse, OperationNode[] nodes) { BuilderImpl builder = new BuilderImpl(this, true, config); - ((Consumer) parse).accept(builder); + ((OperationParser) parse).parse(builder); builder.finish(); } @@ -261,12 +274,16 @@ void setNodes(OperationNode[] nodes) { } @Override - public void serialize(DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { - BuilderImpl builder = new BuilderImpl(null, false, OperationConfig.COMPLETE); + public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { + BuilderImpl builder = new BuilderImpl(null, false, config); builder.isSerializing = true; builder.serBuffer = buffer; builder.serCallback = callback; - ((Consumer) parse).accept(builder); + try { + ((OperationParser) parse).parse(builder); + } catch (WrappedIOException ex) { + throw (IOException) ex.getCause(); + } buffer.writeShort((short) -5); } @@ -323,33 +340,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 6; - static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_LONG_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_LONG_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 9; - static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_LONG_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_LONG_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 12; - static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_LONG_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int INSTR_STORE_LOCAL_BOOLEAN = 12; static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; + static final int INSTR_STORE_LOCAL_LONG = 13; + static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_LONG_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -357,12 +374,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 16; - static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_LONG_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_LONG_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -535,7 +552,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // INT null, // DOUBLE @@ -543,7 +560,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // BYTE null}; @@ -2653,7 +2670,7 @@ private static boolean do_profileCondition(boolean value, int[] profiles, int in } } - private static void deserializeParser(DataInputStream buffer, OperationDeserializationCallback callback, SLOperationsBuilder builder) { + private static void deserializeParser(ByteBuffer buffer, OperationDeserializationCallback callback, SLOperationsBuilder builder) { try { ArrayList consts = new ArrayList<>(); ArrayList locals = new ArrayList<>(); @@ -2661,13 +2678,13 @@ private static void deserializeParser(DataInputStream buffer, OperationDeseriali ArrayList builtNodes = new ArrayList<>(); com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context context = new com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context(){ @Override - public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOException { - return builtNodes.get(buffer.readInt()); + public OperationNode deserializeOperationNode(ByteBuffer buffer) throws IOException { + return builtNodes.get(buffer.getInt()); } } ; while (true) { - switch (buffer.readShort()) { + switch (buffer.getShort()) { case -1 : { builtNodes.add(builder.publish()); @@ -2696,7 +2713,7 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case -6 : { - switch (buffer.readShort()) { + switch (buffer.getShort()) { case 0 : builder.setMethodName((TruffleString) callback.deserialize(context, buffer)); break; @@ -2755,7 +2772,7 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_TRY_CATCH << 1 : { - OperationLocal arg0 = locals.get(buffer.readShort()); + OperationLocal arg0 = locals.get(buffer.getShort()); builder.beginTryCatch(arg0); break; } @@ -2786,31 +2803,31 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_LABEL << 1 : { - OperationLabel arg0 = labels.get(buffer.readShort()); + OperationLabel arg0 = labels.get(buffer.getShort()); builder.emitLabel(arg0); break; } case OP_BRANCH << 1 : { - OperationLabel arg0 = labels.get(buffer.readShort()); + OperationLabel arg0 = labels.get(buffer.getShort()); builder.emitBranch(arg0); break; } case OP_CONST_OBJECT << 1 : { - Object arg0 = (Object) consts.get(buffer.readShort()); + Object arg0 = (Object) consts.get(buffer.getShort()); builder.emitConstObject(arg0); break; } case OP_LOAD_ARGUMENT << 1 : { - int arg0 = buffer.readInt(); + int arg0 = buffer.getInt(); builder.emitLoadArgument(arg0); break; } case OP_STORE_LOCAL << 1 : { - OperationLocal arg0 = locals.get(buffer.readShort()); + OperationLocal arg0 = locals.get(buffer.getShort()); builder.beginStoreLocal(arg0); break; } @@ -2821,7 +2838,7 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_LOAD_LOCAL << 1 : { - OperationLocal arg0 = locals.get(buffer.readShort()); + OperationLocal arg0 = locals.get(buffer.getShort()); builder.emitLoadLocal(arg0); break; } @@ -2837,7 +2854,7 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_SOURCE << 1 : { - Source arg0 = (Source) consts.get(buffer.readShort()); + Source arg0 = (Source) consts.get(buffer.getShort()); builder.beginSource(arg0); break; } @@ -2848,8 +2865,8 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_SOURCE_SECTION << 1 : { - int arg0 = buffer.readInt(); - int arg1 = buffer.readInt(); + int arg0 = buffer.getInt(); + int arg1 = buffer.getInt(); builder.beginSourceSection(arg0, arg1); break; } @@ -2860,7 +2877,7 @@ public OperationNode deserializeOperationNode(DataInputStream buffer) throws IOE } case OP_TAG << 1 : { - Class arg0 = (Class) consts.get(buffer.readShort()); + Class arg0 = (Class) consts.get(buffer.getShort()); builder.beginTag(arg0); break; } @@ -3479,14 +3496,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -3494,11 +3511,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3509,14 +3526,14 @@ protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, return false; } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -3524,11 +3541,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3646,25 +3663,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } - // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG : - { - $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - continue loop; - } // load.constant.boolean // Constants: // [ 0] constant @@ -3684,40 +3682,37 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } - // load.argument.object + // load.constant.long + // Constants: + // [ 0] constant // Pushed Values: 1 // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_LONG + // INT -> INSTR_LOAD_CONSTANT_LONG + // DOUBLE -> INSTR_LOAD_CONSTANT_LONG + // FLOAT -> INSTR_LOAD_CONSTANT_LONG + // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG + // BYTE -> INSTR_LOAD_CONSTANT_LONG + case INSTR_LOAD_CONSTANT_LONG : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); + $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } - // load.argument.long + // load.argument.object // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_OBJECT : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } // load.argument.boolean @@ -3742,6 +3737,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; continue loop; } + // load.argument.long + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_LONG + // INT -> INSTR_LOAD_ARGUMENT_LONG + // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG + // FLOAT -> INSTR_LOAD_ARGUMENT_LONG + // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG + // BYTE -> INSTR_LOAD_ARGUMENT_LONG + case INSTR_LOAD_ARGUMENT_LONG : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; + if (value instanceof Long) { + $frame.setLong($sp, (long) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + continue loop; + } // store.local.object // Locals: // [ 0] target @@ -3758,7 +3775,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; continue loop; } - // store.local.long + // store.local.boolean // Locals: // [ 0] target // Indexed Pops: @@ -3766,25 +3783,25 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_STORE_LOCAL_OBJECT // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } - // store.local.boolean + // store.local.long // Locals: // [ 0] target // Indexed Pops: @@ -3792,22 +3809,22 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } // store.local.uninit @@ -3856,28 +3873,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; continue loop; } - // load.local.long + // load.local.boolean // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_LOAD_LOCAL_OBJECT // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3888,31 +3905,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; continue loop; } - // load.local.boolean + // load.local.long // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3923,7 +3940,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; continue loop; } // load.local.uninit @@ -4585,16 +4602,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4602,14 +4619,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4617,14 +4634,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -4637,14 +4654,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -4877,7 +4894,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4887,12 +4904,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4902,9 +4919,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4922,7 +4939,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4932,12 +4949,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4947,9 +4964,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4968,7 +4985,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4978,13 +4995,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4994,10 +5011,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -5031,7 +5048,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5041,12 +5058,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5056,9 +5073,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -9398,14 +9415,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return 5 /* BOOLEAN */; } + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -10204,16 +10221,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10221,14 +10238,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10236,14 +10253,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10256,14 +10273,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -10496,7 +10513,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10506,12 +10523,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10521,9 +10538,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10541,7 +10558,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10551,12 +10568,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10566,9 +10583,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10587,7 +10604,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10597,13 +10614,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10613,10 +10630,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10650,7 +10667,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10660,12 +10677,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10675,9 +10692,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -11691,14 +11708,14 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { frame.setBoolean(localIdx, (boolean) value); return 5 /* BOOLEAN */; } + if (localTag == 1 /* LONG */ && value instanceof Long) { + frame.setLong(localIdx, (long) value); + return 1 /* LONG */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -11908,14 +11925,6 @@ T insertAccessor(T node) { } } - @GeneratedBy(SLOperations.class) - private static final class WrappedIOException extends RuntimeException { - - WrappedIOException(IOException ex) { - super(ex); - } - - } } @GeneratedBy(SLOperations.class) private static final class WrappedIOException extends RuntimeException { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index cabe16925bda..2e98bfea7c37 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -43,7 +43,6 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.List; -import java.util.function.Consumer; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; @@ -52,12 +51,12 @@ import com.oracle.truffle.api.source.Source; public abstract class OperationNodes { - protected final Consumer parse; + protected final OperationParser parse; @CompilationFinal(dimensions = 1) protected OperationNode[] nodes; @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; - protected OperationNodes(Consumer parse) { + protected OperationNodes(OperationParser parse) { this.parse = parse; } @@ -94,7 +93,7 @@ public boolean updateConfiguration(OperationConfig config) { } @SuppressWarnings("hiding") - protected abstract void reparseImpl(OperationConfig config, Consumer parse, OperationNode[] nodes); + protected abstract void reparseImpl(OperationConfig config, OperationParser parse, OperationNode[] nodes); void reparse(OperationConfig config) { CompilerAsserts.neverPartOfCompilation("parsing should never be compiled"); @@ -112,7 +111,7 @@ final void ensureSources() { } @SuppressWarnings("unused") - public void serialize(DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { + public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { throw new UnsupportedOperationException("Serialization not supported"); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationParser.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationParser.java new file mode 100644 index 000000000000..1473974742d4 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationParser.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation; + +@FunctionalInterface +public interface OperationParser { + void parse(T builder); +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java index 6a32674d7157..4d56371a3bfe 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java @@ -40,15 +40,15 @@ */ package com.oracle.truffle.api.operation.serialization; -import java.io.DataInputStream; import java.io.IOException; +import java.nio.ByteBuffer; import com.oracle.truffle.api.operation.OperationNode; public interface OperationDeserializationCallback { interface Context { - OperationNode deserializeOperationNode(DataInputStream buffer) throws IOException; + OperationNode deserializeOperationNode(ByteBuffer buffer) throws IOException; } - Object deserialize(Context context, DataInputStream buffer) throws IOException; + Object deserialize(Context context, ByteBuffer buffer) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index a4e03bfb9883..24eb1cbbf00f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -40,17 +40,16 @@ */ package com.oracle.truffle.dsl.processor.operations; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.concurrent.locks.Lock; -import java.util.function.Consumer; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; @@ -111,6 +110,11 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory DATA_INPUT_CLASS = ByteBuffer.class; + private static final Class DATA_OUTPUT_CLASS = DataOutputStream.class; + private static final String DATA_READ_METHOD_PREFIX = "get"; + private static final String DATA_WRITE_METHOD_PREFIX = "write"; + CodeTypeElement createOperationNodes() { CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, types.OperationNodes); typOperationNodes.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationNodes)); @@ -140,7 +144,7 @@ private CodeExecutableElement createOperationNodedsReparse() { CodeTreeBuilder b = metReparse.createBuilder(); b.statement("BuilderImpl builder = new BuilderImpl(this, true, config)"); - b.statement("((Consumer) parse).accept(builder)"); + b.statement("((OperationParser) parse).parse(builder)"); b.statement("builder.finish()"); return metReparse; } @@ -150,14 +154,16 @@ private CodeExecutableElement createOperationNodesSerialize() { CodeTreeBuilder b = met.createBuilder(); - b.statement("BuilderImpl builder = new BuilderImpl(null, false, OperationConfig.COMPLETE)"); + b.statement("BuilderImpl builder = new BuilderImpl(null, false, config)"); b.statement("builder.isSerializing = true"); b.statement("builder.serBuffer = buffer"); b.statement("builder.serCallback = callback"); - b.statement("((Consumer) parse).accept(builder)"); + unwrapWrappedIOException(b, () -> { + b.statement("((OperationParser) parse).parse(builder)"); + }); - b.statement("buffer.writeShort((short) " + SER_CODE_END + ")"); + b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_END + ")"); return met; } @@ -224,7 +230,10 @@ CodeTypeElement createBuilder(String simpleName) { typBuilder.add(typWrappedEx); typBuilder.add(createCreateMethod(typBuilder, typBuilderImpl)); - typBuilder.add(createDeserializeMethod()); + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { + typBuilder.add(createDeserializeMethod()); + typBuilder.add(createSerializeMethod(typBuilder, typBuilderImpl)); + } CodeTypeElement typCounter = typBuilder.add(new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter")); typCounter.add(new CodeVariableElement(MOD_PUBLIC, context.getType(int.class), "count")); @@ -234,7 +243,7 @@ CodeTypeElement createBuilder(String simpleName) { private CodeExecutableElement createDeserializeMethod() { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DataInputStream.class), "input"); + CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "input"); CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback"); CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parConfig, parBuffer, parCallback); @@ -258,9 +267,54 @@ private CodeExecutableElement createDeserializeMethod() { return met; } + private static void unwrapWrappedIOException(CodeTreeBuilder b, Runnable inner) { + b.startTryBlock(); + inner.run(); + b.end().startCatchBlock(new GeneratedTypeMirror("", "WrappedIOException"), "ex"); + b.startThrow().string("(IOException) ex.getCause()").end(); + b.end(); + } + + private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { + CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); + CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_OUTPUT_CLASS), "buffer"); + CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback"), "callback"); + CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); + CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, context.getType(void.class), "serialize"); + metCreate.addParameter(parConfig); + metCreate.addParameter(parBuffer); + metCreate.addParameter(parCallback); + metCreate.addParameter(parParser); + metCreate.addThrownType(context.getType(IOException.class)); + + CodeTreeBuilder b = metCreate.getBuilder(); + + b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); + // ( + b.string("null"); + b.string("false"); // isReparse + b.variable(parConfig); + // ) + b.end(2); + + b.statement("builder.isSerializing = true"); + b.statement("builder.serBuffer = buffer"); + b.statement("builder.serCallback = callback"); + + unwrapWrappedIOException(b, () -> { + b.startStatement().startCall("generator", "parse"); + b.string("builder"); + b.end(2); + }); + + b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_END + ")"); + + return metCreate; + } + private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parParser = new CodeVariableElement(consumer(typBuilder.asType()), "generator"); + CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "create"); metCreate.addParameter(parConfig); metCreate.addParameter(parParser); @@ -276,7 +330,7 @@ private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, Cod // ) b.end(2); - b.startStatement().startCall("generator", "accept"); + b.startStatement().startCall("generator", "parse"); b.string("builder"); b.end(2); @@ -323,9 +377,9 @@ private CodeVariableElement createSerializationContext() { b.startNew(typeContext).end().string(" ").startBlock(); b.string("@Override").newLine(); - b.string("public void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException ").startBlock(); + b.string("public void serializeOperationNode(" + DATA_OUTPUT_CLASS.getSimpleName() + " buffer, OperationNode node) throws IOException ").startBlock(); - b.statement("buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder)"); + b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationSerNodeImpl) node).buildOrder)"); b.end(); @@ -642,7 +696,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean.class), "isSerializing")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(DataOutputStream.class), "serBuffer")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(DATA_OUTPUT_CLASS), "serBuffer")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback"), "serCallback")); } @@ -786,7 +840,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement typBuilder) { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); - met.addParameter(new CodeVariableElement(context.getType(DataInputStream.class), "buffer")); + met.addParameter(new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "buffer")); met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback")); met.addParameter(new CodeVariableElement(typBuilder.asType(), "builder")); @@ -804,14 +858,14 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.string(" context = ").startNew(deserContext).end().startBlock(); b.string("@Override").newLine(); - b.string("public OperationNode deserializeOperationNode(").type(context.getType(DataInputStream.class)).string(" buffer) throws IOException ").startBlock(); - b.statement("return builtNodes.get(buffer.readInt())"); + b.string("public OperationNode deserializeOperationNode(").type(context.getType(DATA_INPUT_CLASS)).string(" buffer) throws IOException ").startBlock(); + b.statement("return builtNodes.get(buffer." + DATA_READ_METHOD_PREFIX + "Int())"); b.end(); b.end(2); b.startWhile().string("true").end().startBlock(); - b.startSwitch().string("buffer.readShort()").end().startBlock(); + b.startSwitch().string("buffer." + DATA_READ_METHOD_PREFIX + "Short()").end().startBlock(); b.startCase().string("" + SER_CODE_PUBLISH).end().startBlock(); b.statement("builtNodes.add(builder.publish())"); @@ -842,7 +896,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement if (!m.getMetadatas().isEmpty()) { b.startCase().string("" + SER_CODE_METADATA).end().startBlock(); // todo: we only need a byte if < 255 metadata types - b.startSwitch().string("buffer.readShort()").end().startBlock(); + b.startSwitch().string("buffer." + DATA_READ_METHOD_PREFIX + "Short()").end().startBlock(); int i = 0; for (OperationMetadataData metadata : m.getMetadatas()) { b.startCase().string("" + i).end().startCaseBlock(); @@ -869,19 +923,19 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement for (TypeMirror argType : op.getBuilderArgumentTypes()) { // ARGUMENT DESERIALIZATION if (ElementUtils.typeEquals(argType, types.OperationLocal)) { - b.statement("OperationLocal arg" + i + " = locals.get(buffer.readShort())"); + b.statement("OperationLocal arg" + i + " = locals.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { - b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer.readShort()]"); + b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer." + DATA_READ_METHOD_PREFIX + "Short()]"); b.startFor().string("int i = 0; i < arg" + i + ".length; i++").end().startBlock(); // this can be optimized since they are consecutive - b.statement("arg" + i + "[i] = locals.get(buffer.readShort());"); + b.statement("arg" + i + "[i] = locals.get(buffer." + DATA_READ_METHOD_PREFIX + "Short());"); b.end(); } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { - b.statement("OperationLabel arg" + i + " = labels.get(buffer.readShort())"); + b.statement("OperationLabel arg" + i + " = labels.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())"); } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { - b.statement("int arg" + i + " = buffer.readInt()"); + b.statement("int arg" + i + " = buffer." + DATA_READ_METHOD_PREFIX + "Int()"); } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { - b.startStatement().type(argType).string(" arg" + i + " = ").cast(argType).string("consts.get(buffer.readShort())").end(); + b.startStatement().type(argType).string(" arg" + i + " = ").cast(argType).string("consts.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())").end(); } else { throw new UnsupportedOperationException("cannot deserialize: " + argType); } @@ -1143,7 +1197,7 @@ private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBu if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { - b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_LOCAL + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_LOCAL + ")"); b.statement("return new OperationLocalImpl(null, numLocals++)"); }); b.end(); @@ -1169,7 +1223,7 @@ private CodeExecutableElement createBuilderImplCreateLabel(CodeTypeElement typBu if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { - b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_LABEL + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_LABEL + ")"); b.statement("return new OperationSerLabelImpl(numLabels++)"); }); b.end(); @@ -1535,8 +1589,8 @@ private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { - b.statement("serBuffer.writeShort((short) " + SER_CODE_METADATA + ")"); - b.statement("serBuffer.writeShort(" + m.getMetadatas().indexOf(metadata) + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_METADATA + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short(" + m.getMetadatas().indexOf(metadata) + ")"); b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, value)"); b.returnStatement(); }); @@ -1623,7 +1677,7 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { - b.startStatement().string("serBuffer.writeShort((short) ((").variable(op.idConstantField).string(" << 1) | 1))").end(); + b.startStatement().string("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((").variable(op.idConstantField).string(" << 1) | 1))").end(); }); b.returnStatement(); b.end(); @@ -1748,31 +1802,31 @@ private void createBeginOperationSerialize(BuilderVariables vars, Operation op, for (TypeMirror argType : op.getBuilderArgumentTypes()) { // ARGUMENT SERIALIZATION if (ElementUtils.typeEquals(argType, types.OperationLocal)) { - after.add("serBuffer.writeShort((short) ((OperationLocalImpl) arg" + i + ").id)"); + after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationLocalImpl) arg" + i + ").id)"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { - after.add("serBuffer.writeShort((short) arg" + i + ".length)"); - after.add("for (int i = 0; i < arg" + i + ".length; i++) { serBuffer.writeShort((short) ((OperationLocalImpl) arg" + i + "[i]).id); }"); + after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) arg" + i + ".length)"); + after.add("for (int i = 0; i < arg" + i + ".length; i++) { serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationLocalImpl) arg" + i + "[i]).id); }"); } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { - after.add("serBuffer.writeShort((short) ((OperationSerLabelImpl) arg" + i + ").id)"); + after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationSerLabelImpl) arg" + i + ").id)"); } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { - after.add("serBuffer.writeInt(arg" + i + ")"); + after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Int(arg" + i + ")"); } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { String index = "arg" + i + "_index"; b.startAssign("int " + index).variable(vars.consts).startCall(".indexOf").string("arg" + i).end(2); b.startIf().string(index + " == -1").end().startBlock(); b.startAssign(index).variable(vars.consts).startCall(".size").end(2); b.startStatement().variable(vars.consts).startCall(".add").string("arg" + i).end(2); - b.statement("serBuffer.writeShort((short) " + SER_CODE_CREATE_OBJECT + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_OBJECT + ")"); b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, arg" + i + ")"); b.end(); - after.add("serBuffer.writeShort((short) arg" + i + "_index)"); + after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) arg" + i + "_index)"); } else { throw new UnsupportedOperationException("cannot serialize: " + argType); } i++; } - b.startStatement().string("serBuffer.writeShort((short) (").variable(op.idConstantField).string(" << 1))").end(); + b.startStatement().string("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) (").variable(op.idConstantField).string(" << 1))").end(); after.forEach(b::statement); }); @@ -1820,7 +1874,7 @@ private CodeExecutableElement createBuilderImplPublish() { if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { - b.statement("serBuffer.writeShort((short) " + SER_CODE_PUBLISH + ")"); + b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_PUBLISH + ")"); b.declaration("OperationNode", "result", "new OperationSerNodeImpl(null, buildIndex++)"); b.statement("numLocals = 0"); b.statement("numLabels = 0"); @@ -2063,8 +2117,8 @@ private static TypeMirror arrayOf(TypeMirror el) { return new ArrayCodeTypeMirror(el); } - private static TypeMirror consumer(TypeMirror el) { - return new DeclaredCodeTypeMirror(ProcessorContext.getInstance().getTypeElement(Consumer.class), List.of(el)); + private static TypeMirror operationParser(TypeMirror el) { + return new DeclaredCodeTypeMirror(ProcessorContext.getInstance().getTypeElement("com.oracle.truffle.api.operation.OperationParser"), List.of(el)); } private static TypeMirror generic(TypeElement el, TypeMirror... args) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java index 840e4af939c8..05988ef662c5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.nodes.util; import com.oracle.truffle.api.dsl.Bind; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java index c122c92d5ed8..72f88b8095e1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -40,12 +40,11 @@ */ package com.oracle.truffle.sl.operations; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.math.BigInteger; +import java.nio.ByteBuffer; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNodes; @@ -70,7 +69,7 @@ public static byte[] serializeNodes(OperationNodes nodes) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream); - nodes.serialize(outputStream, new OperationSerializationCallback() { + nodes.serialize(OperationConfig.COMPLETE, outputStream, new OperationSerializationCallback() { public void serialize(OperationSerializationCallback.Context context, DataOutputStream buffer, Object object) throws IOException { if (object instanceof SLNull) { buffer.writeByte(CODE_SL_NULL); @@ -101,9 +100,11 @@ public void serialize(OperationSerializationCallback.Context context, DataOutput return byteArrayOutputStream.toByteArray(); } - private static byte[] readByteArray(DataInputStream buffer) throws IOException { - int len = buffer.readInt(); - return buffer.readNBytes(len); + private static byte[] readByteArray(ByteBuffer buffer) { + int len = buffer.getInt(); + byte[] dest = new byte[len]; + buffer.get(dest); + return dest; } private static void writeByteArray(DataOutputStream buffer, byte[] data) throws IOException { @@ -112,20 +113,19 @@ private static void writeByteArray(DataOutputStream buffer, byte[] data) throws } public static OperationNodes deserializeNodes(byte[] inputData) throws IOException { - ByteArrayInputStream byteArrayOutputStream = new ByteArrayInputStream(inputData); - DataInputStream outputStream = new DataInputStream(byteArrayOutputStream); + ByteBuffer buf = ByteBuffer.wrap(inputData); - return SLOperationsBuilder.deserialize(OperationConfig.DEFAULT, outputStream, new OperationDeserializationCallback() { - public Object deserialize(OperationDeserializationCallback.Context context, DataInputStream buffer) throws IOException { + return SLOperationsBuilder.deserialize(OperationConfig.DEFAULT, buf, new OperationDeserializationCallback() { + public Object deserialize(OperationDeserializationCallback.Context context, ByteBuffer buffer) throws IOException { byte tag; - switch (tag = buffer.readByte()) { + switch (tag = buffer.get()) { case CODE_SL_NULL: return SLNull.SINGLETON; case CODE_STRING: { return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); } case CODE_LONG: - return buffer.readLong(); + return buffer.getLong(); case CODE_BIG_INT: { return new SLBigNumber(new BigInteger(readByteArray(buffer))); } From c64342f8f84992822de21ea013cd342f3c2cc980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 9 Aug 2022 17:30:15 +0200 Subject: [PATCH 121/312] [wip] fix tests and osr --- .../truffle/sl/operations/SLOperationsBuilder.java | 4 ++-- .../operation/test/example/BoxingOperationsTest.java | 5 ++--- .../test/example/TestOperationsParserTest.java | 6 +++--- .../operation/test/example/TestOperationsSerTest.java | 11 ++++------- .../operations/instructions/BranchInstruction.java | 10 ++++++---- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index b75920e0ad30..716cbf57a355 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -3607,7 +3607,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s loopCounter.count = 0; } if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, targetBci, $sp, null, $frame); + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, null, null, $frame); if (osrResult != null) { $frame.setObject(0, osrResult); return 0x0000ffff; @@ -9690,7 +9690,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s loopCounter.count = 0; } if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, targetBci, $sp, null, $frame); + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, null, null, $frame); if (osrResult != null) { $frame.setObject(0, osrResult); return 0x0000ffff; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 9d893a0f8c25..bfd33e6f0cd7 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -40,8 +40,6 @@ */ package com.oracle.truffle.api.operation.test.example; -import java.util.function.Consumer; - import org.junit.Assert; import org.junit.Test; @@ -58,6 +56,7 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationParser; import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; public class BoxingOperationsTest { @@ -65,7 +64,7 @@ public class BoxingOperationsTest { // todo: all of these tests should somehow check that e&s is not called more times // than it needs to - private static RootCallTarget parse(Consumer parser) { + private static RootCallTarget parse(OperationParser parser) { OperationNodes nodes = BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser); OperationNode node = nodes.getNodes().get(0); return new TestRootNode(node).getCallTarget(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 49f82704b81b..f6f08825faf0 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -43,7 +43,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.function.Consumer; import org.junit.Assert; import org.junit.Test; @@ -54,17 +53,18 @@ import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationParser; public class TestOperationsParserTest { // @formatter:off - private static RootCallTarget parse(Consumer builder) { + private static RootCallTarget parse(OperationParser builder) { OperationNode operationsNode = parseNode(builder); System.out.println(operationsNode.dump()); return new TestRootNode(operationsNode).getCallTarget(); } - private static OperationNode parseNode(Consumer builder) { + private static OperationNode parseNode(OperationParser builder) { return TestOperationsBuilder.create(OperationConfig.DEFAULT, builder).getNodes().get(0); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 855e450812ed..0175786cfe6f 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -40,11 +40,10 @@ */ package com.oracle.truffle.api.operation.test.example; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.nio.ByteBuffer; import org.junit.Assert; import org.junit.Test; @@ -64,12 +63,10 @@ public void testSer() { } private static TestRootNode deserialize(byte[] byteArray) { - ByteArrayInputStream input = new ByteArrayInputStream(byteArray); - OperationNodes nodes2 = null; try { - nodes2 = TestOperationsBuilder.deserialize(OperationConfig.DEFAULT, new DataInputStream(input), (ctx, buf2) -> { - return buf2.readLong(); + nodes2 = TestOperationsBuilder.deserialize(OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), (ctx, buf2) -> { + return buf2.getLong(); }); } catch (IOException e) { assert false; @@ -97,7 +94,7 @@ private static byte[] createByteArray() { ByteArrayOutputStream output = new ByteArrayOutputStream(); try { - nodes.serialize(new DataOutputStream(output), (ctx, buf2, obj) -> { + nodes.serialize(OperationConfig.DEFAULT, new DataOutputStream(output), (ctx, buf2, obj) -> { if (obj instanceof Long) { haveConsts[(int) (long) obj - 1] = true; buf2.writeLong((long) obj); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index e757e8a23fa1..24e192f39418 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -88,8 +88,10 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (LOOP_COUNTING || SAFEPOINT_POLL) { b.startIf(); b.tree(GeneratorUtils.createHasNextTier()); - b.string(" && "); - b.string("++loopCounter.count >= " + REPORT_LOOP_STRIDE); + if (LOOP_COUNTING) { + b.string(" && "); + b.string("++loopCounter.count >= " + REPORT_LOOP_STRIDE); + } b.end().startBlock(); // { if (SAFEPOINT_POLL) { @@ -118,8 +120,8 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.end().startBlock(); // { b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); b.string("$this"); - b.string("targetBci"); - b.variable(vars.sp); + b.string("($sp << 16) | targetBci"); + b.string("null"); b.string("null"); b.variable(vars.frame); b.end(2); From fc9947390ae1761b60332b6c9f3607efcd305893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 9 Aug 2022 17:50:17 +0200 Subject: [PATCH 122/312] [wip] make non-node spec instances work --- .../sl/operations/SLOperationsBuilder.java | 440 +++++++++--------- .../test/example/TestOperations.java | 8 + .../OperationsBytecodeNodeGeneratorPlugs.java | 25 +- 3 files changed, 252 insertions(+), 221 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java index 716cbf57a355..268518b3ed89 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java @@ -340,33 +340,33 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_CONSTANT_OBJECT = 5; static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 6; - static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 7; + static final int INSTR_LOAD_CONSTANT_LONG = 6; static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; static final int LOAD_CONSTANT_LONG_LENGTH = 2; + static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; + static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; + static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 9; - static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 10; + static final int INSTR_LOAD_ARGUMENT_LONG = 9; static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; static final int LOAD_ARGUMENT_LONG_LENGTH = 2; + static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; + static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; + static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; static final int INSTR_STORE_LOCAL_OBJECT = 11; static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 12; - static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 13; + static final int INSTR_STORE_LOCAL_LONG = 12; static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; static final int STORE_LOCAL_LONG_LENGTH = 3; + static final int INSTR_STORE_LOCAL_BOOLEAN = 13; + static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; + static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; static final int INSTR_STORE_LOCAL_UNINIT = 14; static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; @@ -374,12 +374,12 @@ private static class BuilderImpl extends SLOperationsBuilder { static final int INSTR_LOAD_LOCAL_OBJECT = 15; static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 16; - static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 17; + static final int INSTR_LOAD_LOCAL_LONG = 16; static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_LONG_LENGTH = 2; + static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; + static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; + static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; static final int INSTR_LOAD_LOCAL_UNINIT = 18; static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; static final int LOAD_LOCAL_UNINIT_LENGTH = 2; @@ -552,7 +552,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // OBJECT {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_LONG, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // INT null, // DOUBLE @@ -560,7 +560,7 @@ private static class BuilderImpl extends SLOperationsBuilder { // FLOAT null, // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_BOOLEAN, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, + {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, // BYTE null}; @@ -3496,14 +3496,14 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, sh } } - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); + case 1 /* LONG */ : + return frame.getLong(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } break; } @@ -3511,11 +3511,11 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot) throws Unex throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); + frame.setLong(localSlot, expectLong(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3526,14 +3526,14 @@ protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlo return false; } - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); + case 5 /* BOOLEAN */ : + return frame.getBoolean(slot); case 0 /* OBJECT */ : Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } break; } @@ -3541,11 +3541,11 @@ protected static long expectLong(VirtualFrame frame, int slot) throws Unexpected throw new UnexpectedResultException(frame.getValue(slot)); } - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { + protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { + if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); + frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); return true; } catch (UnexpectedResultException ex) { } @@ -3663,25 +3663,6 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; continue loop; } - // load.constant.boolean - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN - // INT -> INSTR_LOAD_CONSTANT_BOOLEAN - // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN - // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - continue loop; - } // load.constant.long // Constants: // [ 0] constant @@ -3701,40 +3682,37 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; continue loop; } - // load.argument.object + // load.constant.boolean + // Constants: + // [ 0] constant // Pushed Values: 1 // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : + // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT + // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN + // INT -> INSTR_LOAD_CONSTANT_BOOLEAN + // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN + // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN + // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN + case INSTR_LOAD_CONSTANT_BOOLEAN : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); + $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; continue loop; } - // load.argument.boolean + // load.argument.object // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // LONG -> INSTR_LOAD_ARGUMENT_LONG // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_OBJECT : { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); - } else { - $frame.setObject($sp, value); - } + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; + $frame.setObject($sp, value); $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; continue loop; } // load.argument.long @@ -3759,6 +3737,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; continue loop; } + // load.argument.boolean + // Pushed Values: 1 + // Boxing Elimination: Replace + // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT + // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN + // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN + // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN + // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN + case INSTR_LOAD_ARGUMENT_BOOLEAN : + { + Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; + if (value instanceof Boolean) { + $frame.setBoolean($sp, (boolean) value); + } else { + $frame.setObject($sp, value); + } + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + continue loop; + } // store.local.object // Locals: // [ 0] target @@ -3775,7 +3775,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; continue loop; } - // store.local.boolean + // store.local.long // Locals: // [ 0] target // Indexed Pops: @@ -3783,25 +3783,25 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; continue loop; } - // store.local.long + // store.local.boolean // Locals: // [ 0] target // Indexed Pops: @@ -3809,22 +3809,22 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s // Pushed Values: 0 // Boxing Elimination: Replace // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_STORE_LOCAL_OBJECT // INT -> INSTR_STORE_LOCAL_OBJECT // DOUBLE -> INSTR_STORE_LOCAL_OBJECT // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { + if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); + doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); } $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; continue loop; } // store.local.uninit @@ -3873,28 +3873,28 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; continue loop; } - // load.local.boolean + // load.local.long // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT + // LONG -> 0 // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 + // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { + if (localType != FrameSlotKind.Long) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); + $frame.setLong(localIdx, (long) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3905,31 +3905,31 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; continue loop; } - // load.local.long + // load.local.boolean // Locals: // [ 0] local // Pushed Values: 1 // Boxing Elimination: Replace // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 + // LONG -> INSTR_LOAD_LOCAL_OBJECT // INT -> INSTR_LOAD_LOCAL_OBJECT // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT + // BOOLEAN -> 0 // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; + int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { + if (localType != FrameSlotKind.Boolean) { CompilerDirectives.transferToInterpreterAndInvalidate(); Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); + if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { + $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); + $frame.setBoolean(localIdx, (boolean) localValue); $frame.copyPrimitive(localIdx, $sp); } else { $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); @@ -3940,7 +3940,7 @@ int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $s $frame.copyPrimitive(localIdx, $sp); } $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; continue loop; } // load.local.uninit @@ -4602,16 +4602,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4619,14 +4619,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4634,14 +4634,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -4654,14 +4654,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -4894,7 +4894,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4904,12 +4904,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4919,9 +4919,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -4939,7 +4939,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4949,12 +4949,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4964,9 +4964,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -4985,7 +4985,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -4995,13 +4995,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5011,10 +5011,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -5048,7 +5048,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5058,12 +5058,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -5073,9 +5073,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -9415,14 +9415,14 @@ private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, Operati private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } if (localTag == 1 /* LONG */ && value instanceof Long) { frame.setLong(localIdx, (long) value); return 1 /* LONG */; } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } @@ -10221,16 +10221,16 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10238,14 +10238,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10253,14 +10253,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10273,14 +10273,14 @@ void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[ $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -10513,7 +10513,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; break; } - case INSTR_LOAD_CONSTANT_BOOLEAN : + case INSTR_LOAD_CONSTANT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10523,12 +10523,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; + sb.append("load.constant.long "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; break; } - case INSTR_LOAD_CONSTANT_LONG : + case INSTR_LOAD_CONSTANT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10538,9 +10538,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; + sb.append("load.constant.boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; break; } case INSTR_LOAD_ARGUMENT_OBJECT : @@ -10558,7 +10558,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_BOOLEAN : + case INSTR_LOAD_ARGUMENT_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10568,12 +10568,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; + sb.append("load.argument.long "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; break; } - case INSTR_LOAD_ARGUMENT_LONG : + case INSTR_LOAD_ARGUMENT_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10583,9 +10583,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; + sb.append("load.argument.boolean "); + sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); + $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_OBJECT : @@ -10604,7 +10604,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; break; } - case INSTR_STORE_LOCAL_BOOLEAN : + case INSTR_STORE_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10614,13 +10614,13 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; + sb.append("store.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_LONG_LENGTH; break; } - case INSTR_STORE_LOCAL_LONG : + case INSTR_STORE_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10630,10 +10630,10 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; + sb.append("store.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); + $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_STORE_LOCAL_UNINIT : @@ -10667,7 +10667,7 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; break; } - case INSTR_LOAD_LOCAL_BOOLEAN : + case INSTR_LOAD_LOCAL_LONG : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10677,12 +10677,12 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; + sb.append("load.local.long "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_LONG_LENGTH; break; } - case INSTR_LOAD_LOCAL_LONG : + case INSTR_LOAD_LOCAL_BOOLEAN : { sb.append(String.format(" %04x", $bc[$bci + 0])); sb.append(String.format(" %04x", $bc[$bci + 1])); @@ -10692,9 +10692,9 @@ String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { sb.append(" "); sb.append(" "); sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; + sb.append("load.local.boolean "); + sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); + $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; break; } case INSTR_LOAD_LOCAL_UNINIT : @@ -11708,14 +11708,14 @@ private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { Object value = frame.getValue(sourceSlot); - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } if (localTag == 1 /* LONG */ && value instanceof Long) { frame.setLong(localIdx, (long) value); return 1 /* LONG */; } + if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { + frame.setBoolean(localIdx, (boolean) value); + return 5 /* BOOLEAN */; + } frame.setObject(localIdx, value); return 0 /* OBJECT */; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index b2bd00c28c61..c094232dacbc 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -157,6 +157,14 @@ public static Object doCached(final Association assoc, return assoc.getValue(); } } + + @Operation + public static final class NonNodeInstance { + @Specialization(limit = "3", guards = "i == cachedI") + public static Integer doCached(Integer i, @Cached("i") Integer cachedI) { + return cachedI; + } + } } class Association { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 701ffd8b8eb9..209c4f3953b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor.operations; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -49,6 +51,7 @@ import java.util.stream.Collectors; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -316,10 +319,30 @@ public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphis public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write) { boolean specClass = useSpecializationClass.test(s); Object refObject = specClass ? s : fieldName; - boolean isChild = specClass ? true : ElementUtils.isAssignable(fieldType, types.Node); + boolean isChild = specClass ? specializationClassIsNode(s) : ElementUtils.isAssignable(fieldType, types.Node); return createArrayReference(frame, refObject, !write, fieldType, isChild); } + /* Specialization class needs to be a Node in such a case. */ + private boolean specializationClassIsNode(SpecializationData specialization) { + for (CacheExpression cache : specialization.getCaches()) { + TypeMirror type = cache.getParameter().getType(); + if (isAssignable(type, types.NodeInterface)) { + return true; + } else if (isNodeInterfaceArray(type)) { + return true; + } + } + return false; + } + + private boolean isNodeInterfaceArray(TypeMirror type) { + if (type == null) { + return false; + } + return type.getKind() == TypeKind.ARRAY && isAssignable(((ArrayType) type).getComponentType(), types.NodeInterface); + } + @Override public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead) { if (nodeFieldName.startsWith("$child")) { From 72bd27879e32a1dbe5cad45d73f5fbeeca3ac267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 11 Aug 2022 20:59:06 +0200 Subject: [PATCH 123/312] [wip] fix BE when first arg is nog BEd also remove SLOperationsBuilder --- .../sl/operations/SLOperationsBuilder.java | 11942 ---------------- .../test/example/BoxingOperationsTest.java | 18 + .../OperationsBytecodeNodeGeneratorPlugs.java | 1 + 3 files changed, 19 insertions(+), 11942 deletions(-) delete mode 100644 truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java deleted file mode 100644 index 268518b3ed89..000000000000 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationsBuilder.java +++ /dev/null @@ -1,11942 +0,0 @@ -// CheckStyle: start generated -package com.oracle.truffle.sl.operations; - -import com.oracle.truffle.api.Assumption; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleSafepoint; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; -import com.oracle.truffle.api.dsl.BoundaryCallFailedException; -import com.oracle.truffle.api.dsl.GeneratedBy; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.exception.AbstractTruffleException; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.LibraryFactory; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.DirectCallNode; -import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.IndirectCallNode; -import com.oracle.truffle.api.nodes.LoopNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; -import com.oracle.truffle.api.object.DynamicObjectLibrary; -import com.oracle.truffle.api.operation.OperationBuilder; -import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNode; -import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.OperationParser; -import com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback; -import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.ConcatNode; -import com.oracle.truffle.api.strings.TruffleString.EqualNode; -import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; -import com.oracle.truffle.sl.nodes.SLTypes; -import com.oracle.truffle.sl.nodes.SLTypesGen; -import com.oracle.truffle.sl.nodes.expression.SLAddNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNode; -import com.oracle.truffle.sl.nodes.expression.SLEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; -import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.operations.SLOperations.SLInvoke; -import com.oracle.truffle.sl.runtime.SLBigNumber; -import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLNull; -import com.oracle.truffle.sl.runtime.SLObject; -import java.io.DataOutputStream; -import java.io.IOException; -import java.lang.invoke.VarHandle; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.locks.Lock; - -@GeneratedBy(SLOperations.class) -@SuppressWarnings({"serial", "unused", "cast", "hiding", "unchecked", "rawtypes", "static-method"}) -public abstract class SLOperationsBuilder extends OperationBuilder { - - protected SLOperationsBuilder() { - } - - public abstract void beginBlock(); - - public abstract void endBlock(); - - public abstract void beginIfThen(); - - public abstract void endIfThen(); - - public abstract void beginIfThenElse(); - - public abstract void endIfThenElse(); - - public abstract void beginConditional(); - - public abstract void endConditional(); - - public abstract void beginWhile(); - - public abstract void endWhile(); - - public abstract void beginTryCatch(OperationLocal arg0); - - public abstract void endTryCatch(); - - public abstract void beginFinallyTry(); - - public abstract void endFinallyTry(); - - public abstract void beginFinallyTryNoExcept(); - - public abstract void endFinallyTryNoExcept(); - - public abstract void emitLabel(OperationLabel arg0); - - public abstract void emitBranch(OperationLabel arg0); - - public abstract void emitConstObject(Object arg0); - - public abstract void emitLoadArgument(int arg0); - - public abstract void beginStoreLocal(OperationLocal arg0); - - public abstract void endStoreLocal(); - - public abstract void emitLoadLocal(OperationLocal arg0); - - public abstract void beginReturn(); - - public abstract void endReturn(); - - public abstract void beginSource(Source arg0); - - public abstract void endSource(); - - public abstract void beginSourceSection(int arg0, int arg1); - - public abstract void endSourceSection(); - - public abstract void beginTag(Class arg0); - - public abstract void endTag(); - - public abstract void beginSLAdd(); - - public abstract void endSLAdd(); - - public abstract void beginSLDiv(); - - public abstract void endSLDiv(); - - public abstract void beginSLEqual(); - - public abstract void endSLEqual(); - - public abstract void beginSLLessOrEqual(); - - public abstract void endSLLessOrEqual(); - - public abstract void beginSLLessThan(); - - public abstract void endSLLessThan(); - - public abstract void beginSLLogicalNot(); - - public abstract void endSLLogicalNot(); - - public abstract void beginSLMul(); - - public abstract void endSLMul(); - - public abstract void beginSLReadProperty(); - - public abstract void endSLReadProperty(); - - public abstract void beginSLSub(); - - public abstract void endSLSub(); - - public abstract void beginSLWriteProperty(); - - public abstract void endSLWriteProperty(); - - public abstract void beginSLUnbox(); - - public abstract void endSLUnbox(); - - public abstract void beginSLFunctionLiteral(); - - public abstract void endSLFunctionLiteral(); - - public abstract void beginSLToBoolean(); - - public abstract void endSLToBoolean(); - - public abstract void beginSLInvoke(); - - public abstract void endSLInvoke(); - - public abstract void beginSLAnd(); - - public abstract void endSLAnd(); - - public abstract void beginSLOr(); - - public abstract void endSLOr(); - - public abstract OperationLocal createLocal(); - - public abstract OperationLabel createLabel(); - - public abstract OperationNode publish(); - - public abstract void setMethodName(TruffleString value); - - private static short unsafeFromBytecode(short[] bc, int index) { - return bc[index]; - } - - public static OperationNodes create(OperationConfig config, OperationParser generator) { - OperationNodesImpl nodes = new OperationNodesImpl(generator); - BuilderImpl builder = new BuilderImpl(nodes, false, config); - generator.parse(builder); - builder.finish(); - return nodes; - } - - public static OperationNodes deserialize(OperationConfig config, ByteBuffer input, OperationDeserializationCallback callback) throws IOException { - try { - return create(config, b -> BuilderImpl.deserializeParser(input, callback, b)); - } catch (WrappedIOException ex) { - throw (IOException) ex.getCause(); - } - } - - public static void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback, OperationParser generator) throws IOException { - BuilderImpl builder = new BuilderImpl(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - generator.parse(builder); - } catch (WrappedIOException ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - @GeneratedBy(SLOperations.class) - private static final class OperationNodesImpl extends OperationNodes { - - OperationNodesImpl(OperationParser parse) { - super(parse); - } - - @Override - protected void reparseImpl(OperationConfig config, OperationParser parse, OperationNode[] nodes) { - BuilderImpl builder = new BuilderImpl(this, true, config); - ((OperationParser) parse).parse(builder); - builder.finish(); - } - - void setSources(Source[] sources) { - this.sources = sources; - } - - void setNodes(OperationNode[] nodes) { - this.nodes = nodes; - } - - @Override - public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { - BuilderImpl builder = new BuilderImpl(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - ((OperationParser) parse).parse(builder); - } catch (WrappedIOException ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - } - @GeneratedBy(SLOperations.class) - private static class BuilderImpl extends SLOperationsBuilder { - - private static final int OP_BLOCK = 1; - private static final int OP_IF_THEN = 2; - private static final int OP_IF_THEN_ELSE = 3; - private static final int OP_CONDITIONAL = 4; - private static final int OP_WHILE = 5; - private static final int OP_TRY_CATCH = 6; - private static final int OP_FINALLY_TRY = 7; - private static final int OP_FINALLY_TRY_NO_EXCEPT = 8; - private static final int OP_LABEL = 9; - private static final int OP_BRANCH = 10; - private static final int OP_CONST_OBJECT = 11; - private static final int OP_LOAD_ARGUMENT = 12; - private static final int OP_STORE_LOCAL = 13; - private static final int OP_LOAD_LOCAL = 14; - private static final int OP_RETURN = 15; - private static final int OP_SOURCE = 16; - private static final int OP_SOURCE_SECTION = 17; - private static final int OP_TAG = 18; - private static final int OP_SL_ADD = 19; - private static final int OP_SL_DIV = 20; - private static final int OP_SL_EQUAL = 21; - private static final int OP_SL_LESS_OR_EQUAL = 22; - private static final int OP_SL_LESS_THAN = 23; - private static final int OP_SL_LOGICAL_NOT = 24; - private static final int OP_SL_MUL = 25; - private static final int OP_SL_READ_PROPERTY = 26; - private static final int OP_SL_SUB = 27; - private static final int OP_SL_WRITE_PROPERTY = 28; - private static final int OP_SL_UNBOX = 29; - private static final int OP_SL_FUNCTION_LITERAL = 30; - private static final int OP_SL_TO_BOOLEAN = 31; - private static final int OP_SL_INVOKE = 32; - private static final int OP_SL_AND = 33; - private static final int OP_SL_OR = 34; - static final int INSTR_POP = 1; - static final int POP_LENGTH = 1; - static final int INSTR_BRANCH = 2; - static final int BRANCH_BRANCH_TARGET_OFFSET = 1; - static final int BRANCH_LENGTH = 2; - static final int INSTR_BRANCH_FALSE = 3; - static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; - static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; - static final int BRANCH_FALSE_LENGTH = 3; - static final int INSTR_THROW = 4; - static final int THROW_LOCALS_OFFSET = 1; - static final int THROW_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_OBJECT = 5; - static final int LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_LONG = 6; - static final int LOAD_CONSTANT_LONG_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_LONG_LENGTH = 2; - static final int INSTR_LOAD_CONSTANT_BOOLEAN = 7; - static final int LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET = 1; - static final int LOAD_CONSTANT_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_OBJECT = 8; - static final int LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_LONG = 9; - static final int LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_LONG_LENGTH = 2; - static final int INSTR_LOAD_ARGUMENT_BOOLEAN = 10; - static final int LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET = 1; - static final int LOAD_ARGUMENT_BOOLEAN_LENGTH = 2; - static final int INSTR_STORE_LOCAL_OBJECT = 11; - static final int STORE_LOCAL_OBJECT_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_OBJECT_LENGTH = 3; - static final int INSTR_STORE_LOCAL_LONG = 12; - static final int STORE_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_LONG_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_LONG_LENGTH = 3; - static final int INSTR_STORE_LOCAL_BOOLEAN = 13; - static final int STORE_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_BOOLEAN_LENGTH = 3; - static final int INSTR_STORE_LOCAL_UNINIT = 14; - static final int STORE_LOCAL_UNINIT_LOCALS_OFFSET = 1; - static final int STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET = 2; - static final int STORE_LOCAL_UNINIT_LENGTH = 3; - static final int INSTR_LOAD_LOCAL_OBJECT = 15; - static final int LOAD_LOCAL_OBJECT_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_OBJECT_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_LONG = 16; - static final int LOAD_LOCAL_LONG_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_LONG_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_BOOLEAN = 17; - static final int LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_BOOLEAN_LENGTH = 2; - static final int INSTR_LOAD_LOCAL_UNINIT = 18; - static final int LOAD_LOCAL_UNINIT_LOCALS_OFFSET = 1; - static final int LOAD_LOCAL_UNINIT_LENGTH = 2; - static final int INSTR_RETURN = 19; - static final int RETURN_LENGTH = 1; - static final int INSTR_INSTRUMENT_ENTER = 20; - static final int INSTRUMENT_ENTER_LENGTH = 2; - static final int INSTR_INSTRUMENT_EXIT_VOID = 21; - static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; - static final int INSTR_INSTRUMENT_EXIT = 22; - static final int INSTRUMENT_EXIT_LENGTH = 2; - static final int INSTR_INSTRUMENT_LEAVE = 23; - static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; - static final int INSTRUMENT_LEAVE_LENGTH = 4; - static final int INSTR_C_SL_ADD = 24; - static final int C_SL_ADD_CONSTANT_OFFSET = 1; - static final int C_SL_ADD_CHILDREN_OFFSET = 2; - static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; - static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_LENGTH = 6; - static final int INSTR_C_SL_DIV = 25; - static final int C_SL_DIV_CONSTANT_OFFSET = 1; - static final int C_SL_DIV_CHILDREN_OFFSET = 2; - static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; - static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - static final int C_SL_DIV_LENGTH = 6; - static final int INSTR_C_SL_EQUAL = 26; - static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; - static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; - static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - static final int C_SL_EQUAL_LENGTH = 5; - static final int INSTR_C_SL_LESS_OR_EQUAL = 27; - static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; - static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; - static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; - static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; - static final int INSTR_C_SL_LESS_THAN = 28; - static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; - static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; - static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; - static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_LENGTH = 5; - static final int INSTR_C_SL_LOGICAL_NOT = 29; - static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; - static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; - static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; - static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - static final int C_SL_LOGICAL_NOT_LENGTH = 5; - static final int INSTR_C_SL_MUL = 30; - static final int C_SL_MUL_CONSTANT_OFFSET = 1; - static final int C_SL_MUL_CHILDREN_OFFSET = 2; - static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; - static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - static final int C_SL_MUL_LENGTH = 6; - static final int INSTR_C_SL_READ_PROPERTY = 31; - static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; - static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; - static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; - static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_LENGTH = 6; - static final int INSTR_C_SL_SUB = 32; - static final int C_SL_SUB_CONSTANT_OFFSET = 1; - static final int C_SL_SUB_CHILDREN_OFFSET = 2; - static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; - static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - static final int C_SL_SUB_LENGTH = 6; - static final int INSTR_C_SL_WRITE_PROPERTY = 33; - static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; - static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; - static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; - static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_LENGTH = 7; - static final int INSTR_C_SL_UNBOX = 34; - static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; - static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; - static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_LENGTH = 5; - static final int INSTR_C_SL_FUNCTION_LITERAL = 35; - static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; - static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; - static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; - static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; - static final int INSTR_C_SL_TO_BOOLEAN = 36; - static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; - static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; - static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; - static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_LENGTH = 5; - static final int INSTR_C_SL_INVOKE = 37; - static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; - static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; - static final int C_SL_INVOKE_VARIADIC_OFFSET = 3; - static final int C_SL_INVOKE_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_LENGTH = 6; - static final int INSTR_SC_SL_AND = 38; - static final int SC_SL_AND_CONSTANT_OFFSET = 1; - static final int SC_SL_AND_CHILDREN_OFFSET = 2; - static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; - static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; - static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - static final int SC_SL_AND_LENGTH = 6; - static final int INSTR_SC_SL_OR = 39; - static final int SC_SL_OR_CONSTANT_OFFSET = 1; - static final int SC_SL_OR_CHILDREN_OFFSET = 2; - static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; - static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; - static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - static final int SC_SL_OR_LENGTH = 6; - static final int INSTR_C_SL_UNBOX_Q_FROM_LONG = 40; - static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; - static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; - static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; - static final int INSTR_C_SL_ADD_Q_ADD_LONG = 41; - static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; - static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; - static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; - static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; - static final int INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 42; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; - static final int INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 43; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; - static final int INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 44; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; - static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; - static final int INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 = 45; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET = 1; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CHILDREN_OFFSET = 2; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET = 3; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH = 5; - static final int INSTR_C_SL_INVOKE_Q_DIRECT = 46; - static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; - static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; - static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 3; - static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 4; - static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 6; - static final int INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 47; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; - static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; - static final int INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 48; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; - static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; - static final int INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 = 49; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET = 1; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_CHILDREN_OFFSET = 2; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET = 3; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET = 4; - static final int C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH = 5; - private static final short[][] BOXING_DESCRIPTORS = { - // OBJECT - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_CONSTANT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, INSTR_LOAD_ARGUMENT_OBJECT, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_OBJECT, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // LONG - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, 0, INSTR_STORE_LOCAL_OBJECT, INSTR_STORE_LOCAL_LONG, 0, 0, INSTR_LOAD_LOCAL_OBJECT, INSTR_LOAD_LOCAL_LONG, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // INT - null, - // DOUBLE - null, - // FLOAT - null, - // BOOLEAN - {-1, 0, 0, 0, 0, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_CONSTANT_LONG, INSTR_LOAD_CONSTANT_BOOLEAN, INSTR_LOAD_ARGUMENT_BOOLEAN, INSTR_LOAD_ARGUMENT_LONG, INSTR_LOAD_ARGUMENT_BOOLEAN, 0, INSTR_STORE_LOCAL_OBJECT, 0, INSTR_STORE_LOCAL_BOOLEAN, 0, INSTR_LOAD_LOCAL_OBJECT, 0, INSTR_LOAD_LOCAL_BOOLEAN, 0, 0, 0, 0, 0, (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_DIV_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_MUL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_SUB_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), 0, 0, (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_ADD_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_UNBOX_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_INVOKE_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0) << 8) | 1), (short) (0x8000 | ((C_SL_LESS_THAN_STATE_BITS_OFFSET + 0) << 8) | 1)}, - // BYTE - null}; - - private final OperationNodesImpl nodes; - private final boolean isReparse; - private final boolean withSource; - private final boolean withInstrumentation; - private final SourceInfoBuilder sourceBuilder; - private short[] bc = new short[65535]; - private int bci; - private int curStack; - private int maxStack; - private int numLocals; - private int numLabels; - private ArrayList constPool = new ArrayList<>(); - private BuilderOperationData operationData; - private ArrayList labels = new ArrayList<>(); - private ArrayList labelFills = new ArrayList<>(); - private int numChildNodes; - private int numConditionProfiles; - private ArrayList exceptionHandlers = new ArrayList<>(); - private BuilderFinallyTryContext currentFinallyTry; - private int buildIndex; - private boolean isSerializing; - private DataOutputStream serBuffer; - private OperationSerializationCallback serCallback; - private int[] stackSourceBci = new int[1024]; - com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context SER_CONTEXT = new com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context() { - @Override - public void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException { - buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); - } - } - ; - private final ArrayList builtNodes; - int lastChildPush; - private TruffleString metadata_MethodName; - - private BuilderImpl(OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { - this.nodes = nodes; - this.isReparse = isReparse; - builtNodes = new ArrayList<>(); - if (isReparse) { - builtNodes.addAll((java.util.Collection) nodes.getNodes()); - } - this.withSource = config.isWithSource(); - this.withInstrumentation = config.isWithInstrumentation(); - this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; - reset(); - } - - private void finish() { - if (withSource) { - nodes.setSources(sourceBuilder.buildSource()); - } - if (!isReparse) { - nodes.setNodes(builtNodes.toArray(new OperationNode[0])); - } - } - - private void reset() { - bci = 0; - curStack = 0; - maxStack = 0; - numLocals = 0; - constPool.clear(); - operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0); - labelFills.clear(); - numChildNodes = 0; - numConditionProfiles = 0; - exceptionHandlers.clear(); - metadata_MethodName = null; - } - - private int[] doBeforeEmitInstruction(int numPops, boolean pushValue) { - int[] result = new int[numPops]; - for (int i = numPops - 1; i >= 0; i--) { - curStack--; - int predBci = stackSourceBci[curStack]; - result[i] = predBci; - } - if (pushValue) { - if (curStack >= stackSourceBci.length) { - stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); - } - stackSourceBci[curStack] = bci; - curStack++; - if (curStack > maxStack) { - maxStack = curStack; - } - } - return result; - } - - private void doLeaveFinallyTry(BuilderOperationData opData) { - BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; - if (context.handlerBc == null) { - return; - } - System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); - for (int offset : context.relocationOffsets) { - short oldOffset = bc[bci + offset]; - bc[bci + offset] = (short) (oldOffset + bci); - } - for (ExceptionHandler handler : context.handlerHandlers) { - exceptionHandlers.add(handler.offset(bci, curStack)); - } - for (LabelFill fill : context.handlerLabelFills) { - labelFills.add(fill.offset(bci)); - } - if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; - bci += context.handlerBc.length; - } - - private void doEmitLabel(OperationLabel label) { - OperationLabelImpl lbl = (OperationLabelImpl) label; - if (lbl.hasValue) { - throw new UnsupportedOperationException("label already emitted"); - } - if (operationData != lbl.data) { - throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); - } - lbl.hasValue = true; - lbl.targetBci = bci; - } - - private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { - if (toData != null && fromData.depth < toData.depth) { - throw new UnsupportedOperationException("illegal jump to deeper operation"); - } - if (fromData == toData) { - return; - } - BuilderOperationData cur = fromData; - while (true) { - doLeaveOperation(cur); - cur = cur.parent; - if (toData == null && cur == null) { - break; - } else if (toData != null && cur.depth <= toData.depth) break; - } - if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); - } - - private void calculateLeaves(BuilderOperationData fromData) { - calculateLeaves(fromData, (BuilderOperationData) null); - } - - private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { - calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); - } - - @Override - public OperationLocal createLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -3); - return new OperationLocalImpl(null, numLocals++); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - } - return new OperationLocalImpl(operationData, numLocals++); - } - - OperationLocalImpl createParentLocal() { - return new OperationLocalImpl(operationData.parent, numLocals++); - } - - @Override - public OperationLabel createLabel() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -2); - return new OperationSerLabelImpl(numLabels++); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - } - OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); - labels.add(label); - return label; - } - - private short getLocalIndex(Object value) { - OperationLocalImpl local = (OperationLocalImpl) value; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return (short) local.id; - } - - private int[] getLocalIndices(Object value) { - OperationLocal[] locals = (OperationLocal[]) value; - int[] result = new int[locals.length]; - for (int i = 0; i < locals.length; i++) { - result[i] = getLocalIndex(locals[i]); - } - return result; - } - - private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { - BuilderOperationData cur = child; - while (cur.depth > parent.depth) { - cur = cur.parent; - } - return cur == parent; - } - - @Override - public OperationNode publish() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -1); - OperationNode result = new OperationSerNodeImpl(null, buildIndex++); - numLocals = 0; - numLabels = 0; - return result; - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - } - if (operationData.depth != 0) { - throw new UnsupportedOperationException("Not all operations closed"); - } - OperationNodeImpl result; - if (!isReparse) { - result = new OperationNodeImpl(nodes); - labelPass(null); - result._bc = Arrays.copyOf(bc, bci); - result._consts = constPool.toArray(); - result._children = new Node[numChildNodes]; - result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); - result._conditionProfiles = new int[numConditionProfiles]; - result._maxLocals = numLocals; - result._maxStack = maxStack; - if (sourceBuilder != null) { - result.sourceInfo = sourceBuilder.build(); - } - result._metadata_MethodName = metadata_MethodName; - assert builtNodes.size() == buildIndex; - builtNodes.add(result); - } else { - result = builtNodes.get(buildIndex); - if (withSource && result.sourceInfo == null) { - result.sourceInfo = sourceBuilder.build(); - } - } - buildIndex++; - reset(); - return result; - } - - private void labelPass(BuilderFinallyTryContext finallyTry) { - for (LabelFill fill : labelFills) { - if (finallyTry != null) { - if (fill.label.belongsTo(finallyTry)) { - assert fill.label.hasValue : "inner label should have been resolved by now"; - finallyTry.relocationOffsets.add(fill.locationBci); - } else { - finallyTry.handlerLabelFills.add(fill); - } - } - bc[fill.locationBci] = (short) fill.label.targetBci; - } - } - - private void doLeaveOperation(BuilderOperationData data) { - switch (data.operationId) { - case OP_FINALLY_TRY : - { - doLeaveFinallyTry(data); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - doLeaveFinallyTry(data); - break; - } - case OP_TAG : - { - break; - } - } - } - - @SuppressWarnings("unused") - void doBeforeChild() { - int childIndex = operationData.numChildren; - switch (operationData.operationId) { - case OP_BLOCK : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - } - break; - } - case OP_TRY_CATCH : - { - if (childIndex == 1) { - curStack = ((ExceptionHandler) operationData.aux[0]).startStack; - ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; - } - break; - } - case OP_SOURCE : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - } - break; - } - case OP_SOURCE_SECTION : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - } - break; - } - case OP_TAG : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - } - break; - } - case OP_SL_AND : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_SC_SL_AND); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - bci = bci + 6; - } - break; - } - case OP_SL_OR : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_SC_SL_OR); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - bci = bci + 6; - } - break; - } - } - } - - @SuppressWarnings("unused") - void doAfterChild() { - int childIndex = operationData.numChildren++; - switch (operationData.operationId) { - case OP_IF_THEN : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = endLabel; - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + 3; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } - break; - } - case OP_IF_THEN_ELSE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + 3; - } else if (childIndex == 1) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + 2; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_CONDITIONAL : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + 3; - } else if (childIndex == 1) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + 2; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - assert lastChildPush == 1; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_WHILE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + 3; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bci = bci + 2; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_TRY_CATCH : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - if (childIndex == 0) { - ((ExceptionHandler) operationData.aux[0]).endBci = bci; - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); - bci = bci + 2; - } else { - } - break; - } - case OP_FINALLY_TRY : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.aux[2]); - exceptionHandlers.add(beh); - operationData.aux[1] = beh; - } - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_POP); - bci = bci + 1; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - } - break; - } - } - } - - @SuppressWarnings("unused") - @Override - public void beginBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BLOCK << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); - lastChildPush = 0; - } - - @SuppressWarnings("unused") - @Override - public void endBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_BLOCK) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); - } - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); - } - - @SuppressWarnings("unused") - @Override - public void endIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); - } - - @SuppressWarnings("unused") - @Override - public void endIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN_ELSE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); - } - - @SuppressWarnings("unused") - @Override - public void endConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_CONDITIONAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); - } - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_WHILE << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = startLabel; - } - - @SuppressWarnings("unused") - @Override - public void endWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_WHILE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("While expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginTryCatch(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); - exceptionHandlers.add(beh); - operationData.aux[0] = beh; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - } - - @SuppressWarnings("unused") - @Override - public void endTryCatch() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_TRY_CATCH) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); - operationData.aux[2] = createParentLocal(); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - @Override - public void endFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); - } - int endBci = bci; - doLeaveFinallyTry(operationData); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - { - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + 2; - } - ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); - beh.endBci = endBci; - beh.handlerBci = bci; - doLeaveFinallyTry(operationData); - { - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_THROW); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); - bci = bci + 2; - } - doEmitLabel(endLabel); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - @Override - public void endFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); - } - doLeaveFinallyTry(operationData); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLabel(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LABEL << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - doEmitLabel(arg0); - lastChildPush = 0; - doAfterChild(); - } - - @Override - public void emitBranch(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BRANCH << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); - calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); - bci = bci + 2; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitConstObject(Object arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_CONST_OBJECT << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONST_OBJECT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true); - bc[bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(arg0); - bci = bci + 2; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLoadArgument(int arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); - serBuffer.writeInt(arg0); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true); - bc[bci] = (short) (INSTR_LOAD_ARGUMENT_OBJECT); - bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; - bci = bci + 2; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginStoreLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - @Override - public void endStoreLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_STORE_LOCAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_STORE_LOCAL_UNINIT); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bci = bci + 3; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void emitLoadLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true); - bc[bci] = (short) (INSTR_LOAD_LOCAL_UNINIT); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - bci = bci + 2; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_RETURN << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_RETURN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("Return expected 1 children, got " + numChildren); - } - calculateLeaves(operationData); - doBeforeEmitInstruction(1, false); - bc[bci] = (short) (INSTR_RETURN); - bci = bci + 1; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSource(Source arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_SOURCE << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); - sourceBuilder.beginSource(bci, arg0); - } - } - - @SuppressWarnings("unused") - @Override - public void endSource() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSource(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - @Override - public void beginSourceSection(int arg0, int arg1) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); - serBuffer.writeInt(arg0); - serBuffer.writeInt(arg1); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); - sourceBuilder.beginSourceSection(bci, arg0, arg1); - } - } - - @SuppressWarnings("unused") - @Override - public void endSourceSection() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE_SECTION) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSourceSection(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - @Override - public void beginTag(Class arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_TAG << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withInstrumentation) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); - int curInstrumentId = 0; - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = curInstrumentId; - operationData.aux[1] = startLabel; - operationData.aux[2] = endLabel; - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_INSTRUMENT_ENTER); - bci = bci + 2; - lastChildPush = 0; - } - } - - @SuppressWarnings("unused") - @Override - public void endTag() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (withInstrumentation) { - if (operationData.operationId != OP_TAG) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); - } - if (lastChildPush != 0) { - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_INSTRUMENT_EXIT_VOID); - bci = bci + 2; - } else { - doBeforeEmitInstruction(0, false); - bc[bci] = (short) (INSTR_INSTRUMENT_EXIT); - bci = bci + 2; - } - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - @Override - public void beginSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_ADD << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_ADD) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_ADD); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 2; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_DIV << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_DIV) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_DIV); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_EQUAL); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 4; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_THAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_LESS_THAN); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_LOGICAL_NOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - bc[bci] = (short) (INSTR_C_SL_LOGICAL_NOT); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_MUL << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_MUL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_MUL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_READ_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 12; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_SUB << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_SUB) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true); - bc[bci] = (short) (INSTR_C_SL_SUB); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_WRITE_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(3, true); - bc[bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 11; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); - bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - bci = bci + 7; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_UNBOX) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - bc[bci] = (short) (INSTR_C_SL_UNBOX); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 3; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - bc[bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_TO_BOOLEAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true); - bc[bci] = (short) (INSTR_C_SL_TO_BOOLEAN); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + 5; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); - } - - @SuppressWarnings("unused") - @Override - public void endSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_INVOKE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); - } - doBeforeEmitInstruction(numChildren - 1 + 1, true); - bc[bci] = (short) (INSTR_C_SL_INVOKE); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 4; - bc[bci + 3] = (short) (numChildren - 1); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + 6; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_AND << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - @Override - public void endSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_AND) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - @Override - public void beginSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_OR << 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - @Override - public void endSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - return; - } - if (operationData.operationId != OP_SL_OR) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @Override - public void setMethodName(TruffleString value) { - if (isSerializing) { - try { - serBuffer.writeShort((short) -6); - serBuffer.writeShort(0); - serCallback.serialize(SER_CONTEXT, serBuffer, value); - return; - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - } - metadata_MethodName = value; - } - - private static boolean do_profileCondition(boolean value, int[] profiles, int index) { - int t = profiles[index]; - int f = profiles[index + 1]; - boolean val = value; - if (val) { - if (t == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (f == 0) { - val = true; - } - if (CompilerDirectives.inInterpreter()) { - if (t < 1073741823) { - profiles[index] = t + 1; - } - } - } else { - if (f == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (t == 0) { - val = false; - } - if (CompilerDirectives.inInterpreter()) { - if (f < 1073741823) { - profiles[index + 1] = f + 1; - } - } - } - if (CompilerDirectives.inInterpreter()) { - return val; - } else { - int sum = t + f; - return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); - } - } - - private static void deserializeParser(ByteBuffer buffer, OperationDeserializationCallback callback, SLOperationsBuilder builder) { - try { - ArrayList consts = new ArrayList<>(); - ArrayList locals = new ArrayList<>(); - ArrayList labels = new ArrayList<>(); - ArrayList builtNodes = new ArrayList<>(); - com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context context = new com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context(){ - @Override - public OperationNode deserializeOperationNode(ByteBuffer buffer) throws IOException { - return builtNodes.get(buffer.getInt()); - } - } - ; - while (true) { - switch (buffer.getShort()) { - case -1 : - { - builtNodes.add(builder.publish()); - locals.clear(); - labels.clear(); - break; - } - case -2 : - { - labels.add(builder.createLabel()); - break; - } - case -3 : - { - locals.add(builder.createLocal()); - break; - } - case -4 : - { - consts.add(callback.deserialize(context, buffer)); - break; - } - case -5 : - { - return; - } - case -6 : - { - switch (buffer.getShort()) { - case 0 : - builder.setMethodName((TruffleString) callback.deserialize(context, buffer)); - break; - } - break; - } - case OP_BLOCK << 1 : - { - builder.beginBlock(); - break; - } - case (OP_BLOCK << 1) | 1 : - { - builder.endBlock(); - break; - } - case OP_IF_THEN << 1 : - { - builder.beginIfThen(); - break; - } - case (OP_IF_THEN << 1) | 1 : - { - builder.endIfThen(); - break; - } - case OP_IF_THEN_ELSE << 1 : - { - builder.beginIfThenElse(); - break; - } - case (OP_IF_THEN_ELSE << 1) | 1 : - { - builder.endIfThenElse(); - break; - } - case OP_CONDITIONAL << 1 : - { - builder.beginConditional(); - break; - } - case (OP_CONDITIONAL << 1) | 1 : - { - builder.endConditional(); - break; - } - case OP_WHILE << 1 : - { - builder.beginWhile(); - break; - } - case (OP_WHILE << 1) | 1 : - { - builder.endWhile(); - break; - } - case OP_TRY_CATCH << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginTryCatch(arg0); - break; - } - case (OP_TRY_CATCH << 1) | 1 : - { - builder.endTryCatch(); - break; - } - case OP_FINALLY_TRY << 1 : - { - builder.beginFinallyTry(); - break; - } - case (OP_FINALLY_TRY << 1) | 1 : - { - builder.endFinallyTry(); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT << 1 : - { - builder.beginFinallyTryNoExcept(); - break; - } - case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : - { - builder.endFinallyTryNoExcept(); - break; - } - case OP_LABEL << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitLabel(arg0); - break; - } - case OP_BRANCH << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitBranch(arg0); - break; - } - case OP_CONST_OBJECT << 1 : - { - Object arg0 = (Object) consts.get(buffer.getShort()); - builder.emitConstObject(arg0); - break; - } - case OP_LOAD_ARGUMENT << 1 : - { - int arg0 = buffer.getInt(); - builder.emitLoadArgument(arg0); - break; - } - case OP_STORE_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginStoreLocal(arg0); - break; - } - case (OP_STORE_LOCAL << 1) | 1 : - { - builder.endStoreLocal(); - break; - } - case OP_LOAD_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.emitLoadLocal(arg0); - break; - } - case OP_RETURN << 1 : - { - builder.beginReturn(); - break; - } - case (OP_RETURN << 1) | 1 : - { - builder.endReturn(); - break; - } - case OP_SOURCE << 1 : - { - Source arg0 = (Source) consts.get(buffer.getShort()); - builder.beginSource(arg0); - break; - } - case (OP_SOURCE << 1) | 1 : - { - builder.endSource(); - break; - } - case OP_SOURCE_SECTION << 1 : - { - int arg0 = buffer.getInt(); - int arg1 = buffer.getInt(); - builder.beginSourceSection(arg0, arg1); - break; - } - case (OP_SOURCE_SECTION << 1) | 1 : - { - builder.endSourceSection(); - break; - } - case OP_TAG << 1 : - { - Class arg0 = (Class) consts.get(buffer.getShort()); - builder.beginTag(arg0); - break; - } - case (OP_TAG << 1) | 1 : - { - builder.endTag(); - break; - } - case OP_SL_ADD << 1 : - { - builder.beginSLAdd(); - break; - } - case (OP_SL_ADD << 1) | 1 : - { - builder.endSLAdd(); - break; - } - case OP_SL_DIV << 1 : - { - builder.beginSLDiv(); - break; - } - case (OP_SL_DIV << 1) | 1 : - { - builder.endSLDiv(); - break; - } - case OP_SL_EQUAL << 1 : - { - builder.beginSLEqual(); - break; - } - case (OP_SL_EQUAL << 1) | 1 : - { - builder.endSLEqual(); - break; - } - case OP_SL_LESS_OR_EQUAL << 1 : - { - builder.beginSLLessOrEqual(); - break; - } - case (OP_SL_LESS_OR_EQUAL << 1) | 1 : - { - builder.endSLLessOrEqual(); - break; - } - case OP_SL_LESS_THAN << 1 : - { - builder.beginSLLessThan(); - break; - } - case (OP_SL_LESS_THAN << 1) | 1 : - { - builder.endSLLessThan(); - break; - } - case OP_SL_LOGICAL_NOT << 1 : - { - builder.beginSLLogicalNot(); - break; - } - case (OP_SL_LOGICAL_NOT << 1) | 1 : - { - builder.endSLLogicalNot(); - break; - } - case OP_SL_MUL << 1 : - { - builder.beginSLMul(); - break; - } - case (OP_SL_MUL << 1) | 1 : - { - builder.endSLMul(); - break; - } - case OP_SL_READ_PROPERTY << 1 : - { - builder.beginSLReadProperty(); - break; - } - case (OP_SL_READ_PROPERTY << 1) | 1 : - { - builder.endSLReadProperty(); - break; - } - case OP_SL_SUB << 1 : - { - builder.beginSLSub(); - break; - } - case (OP_SL_SUB << 1) | 1 : - { - builder.endSLSub(); - break; - } - case OP_SL_WRITE_PROPERTY << 1 : - { - builder.beginSLWriteProperty(); - break; - } - case (OP_SL_WRITE_PROPERTY << 1) | 1 : - { - builder.endSLWriteProperty(); - break; - } - case OP_SL_UNBOX << 1 : - { - builder.beginSLUnbox(); - break; - } - case (OP_SL_UNBOX << 1) | 1 : - { - builder.endSLUnbox(); - break; - } - case OP_SL_FUNCTION_LITERAL << 1 : - { - builder.beginSLFunctionLiteral(); - break; - } - case (OP_SL_FUNCTION_LITERAL << 1) | 1 : - { - builder.endSLFunctionLiteral(); - break; - } - case OP_SL_TO_BOOLEAN << 1 : - { - builder.beginSLToBoolean(); - break; - } - case (OP_SL_TO_BOOLEAN << 1) | 1 : - { - builder.endSLToBoolean(); - break; - } - case OP_SL_INVOKE << 1 : - { - builder.beginSLInvoke(); - break; - } - case (OP_SL_INVOKE << 1) | 1 : - { - builder.endSLInvoke(); - break; - } - case OP_SL_AND << 1 : - { - builder.beginSLAnd(); - break; - } - case (OP_SL_AND << 1) | 1 : - { - builder.endSLAnd(); - break; - } - case OP_SL_OR << 1 : - { - builder.beginSLOr(); - break; - } - case (OP_SL_OR << 1) | 1 : - { - builder.endSLOr(); - break; - } - } - } - } catch (IOException ex) { - throw new WrappedIOException(ex); - } - } - - @GeneratedBy(SLOperations.class) - private static final class BuilderOperationData { - - final BuilderOperationData parent; - final int operationId; - final int stackDepth; - final boolean needsLeave; - final int depth; - final Object[] arguments; - final Object[] aux; - int numChildren; - - private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { - this.parent = parent; - this.operationId = operationId; - this.stackDepth = stackDepth; - this.depth = parent == null ? 0 : parent.depth + 1; - this.aux = numAux > 0 ? new Object[numAux] : null; - this.needsLeave = needsLeave || (parent != null && parent.needsLeave); - this.arguments = arguments; - } - - } - @GeneratedBy(SLOperations.class) - private static final class OperationLabelImpl extends OperationLabel { - - BuilderOperationData data; - BuilderFinallyTryContext finallyTry; - int targetBci = 0; - boolean hasValue = false; - - OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { - this.data = data; - this.finallyTry = finallyTry; - } - - boolean belongsTo(BuilderFinallyTryContext context) { - BuilderFinallyTryContext cur = finallyTry; - while (cur != null) { - if (cur == context) { - return true; - } - cur = cur.prev; - } - return false; - } - - } - @GeneratedBy(SLOperations.class) - private static final class OperationSerLabelImpl extends OperationLabel { - - int id; - - OperationSerLabelImpl(int id) { - this.id = id; - } - - } - @GeneratedBy(SLOperations.class) - private static final class OperationLocalImpl extends OperationLocal { - - final BuilderOperationData owner; - final int id; - - OperationLocalImpl(BuilderOperationData owner, int id) { - this.owner = owner; - this.id = id; - } - - } - @GeneratedBy(SLOperations.class) - private static final class LabelFill { - - int locationBci; - OperationLabelImpl label; - - LabelFill(int locationBci, OperationLabelImpl label) { - this.locationBci = locationBci; - this.label = label; - } - - LabelFill offset(int offset) { - return new LabelFill(offset + locationBci, label); - } - - } - @GeneratedBy(SLOperations.class) - private static final class ExceptionHandler { - - int startBci; - int startStack; - int endBci; - int exceptionIndex; - int handlerBci; - - ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { - this.startBci = startBci; - this.startStack = startStack; - this.endBci = endBci; - this.exceptionIndex = exceptionIndex; - this.handlerBci = handlerBci; - } - - ExceptionHandler() { - } - - ExceptionHandler offset(int offset, int stackOffset) { - return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); - } - - @Override - public String toString() { - return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); - } - - } - @GeneratedBy(SLOperations.class) - private static final class SourceInfoBuilder { - - private final ArrayList sourceStack = new ArrayList<>(); - private final ArrayList sourceList = new ArrayList<>(); - private int currentSource = -1; - private final ArrayList bciList = new ArrayList<>(); - private final ArrayList sourceDataList = new ArrayList<>(); - private final ArrayList sourceDataStack = new ArrayList<>(); - - void reset() { - sourceStack.clear(); - sourceDataList.clear(); - sourceDataStack.clear(); - bciList.clear(); - } - - void beginSource(int bci, Source src) { - int idx = sourceList.indexOf(src); - if (idx == -1) { - idx = sourceList.size(); - sourceList.add(src); - } - sourceStack.add(currentSource); - currentSource = idx; - beginSourceSection(bci, -1, -1); - } - - void endSource(int bci) { - endSourceSection(bci); - currentSource = sourceStack.remove(sourceStack.size() - 1); - } - - void beginSourceSection(int bci, int start, int length) { - SourceData data = new SourceData(start, length, currentSource); - bciList.add(bci); - sourceDataList.add(data); - sourceDataStack.add(data); - } - - void endSourceSection(int bci) { - SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); - SourceData prev; - if (sourceDataStack.isEmpty()) { - prev = new SourceData(-1, -1, currentSource); - } else { - prev = sourceDataStack.get(sourceDataStack.size() - 1); - } - bciList.add(bci); - sourceDataList.add(prev); - } - - int[] build() { - if (!sourceStack.isEmpty()) { - throw new IllegalStateException("not all sources ended"); - } - if (!sourceDataStack.isEmpty()) { - throw new IllegalStateException("not all source sections ended"); - } - int size = bciList.size(); - int[] resultArray = new int[size * 3]; - int index = 0; - int lastBci = -1; - boolean isFirst = true; - for (int i = 0; i < size; i++) { - SourceData data = sourceDataList.get(i); - int curBci = bciList.get(i); - if (data.start == -1 && isFirst) { - continue; - } - isFirst = false; - if (curBci == lastBci && index > 1) { - index -= 3; - } - resultArray[index + 0] = curBci | (data.sourceIndex << 16); - resultArray[index + 1] = data.start; - resultArray[index + 2] = data.length; - index += 3; - lastBci = curBci; - } - return Arrays.copyOf(resultArray, index); - } - - Source[] buildSource() { - return sourceList.toArray(new Source[0]); - } - - @GeneratedBy(SLOperations.class) - private static final class SourceData { - - final int start; - final int length; - final int sourceIndex; - - SourceData(int start, int length, int sourceIndex) { - this.start = start; - this.length = length; - this.sourceIndex = sourceIndex; - } - - } - } - @GeneratedBy(SLOperations.class) - private static final class BuilderFinallyTryContext { - - final BuilderFinallyTryContext prev; - final short[] bc; - final ArrayList exceptionHandlers; - final ArrayList labelFills; - final ArrayList labels; - final int curStack; - final int maxStack; - short[] handlerBc; - ArrayList handlerHandlers; - ArrayList handlerLabelFills = new ArrayList<>(); - ArrayList relocationOffsets = new ArrayList<>(); - int handlerMaxStack; - - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { - this.prev = prev; - this.bc = bc; - this.exceptionHandlers = exceptionHandlers; - this.labelFills = labelFills; - this.labels = labels; - this.curStack = curStack; - this.maxStack = maxStack; - } - - } - @GeneratedBy(SLOperations.class) - private static final class OperationNodeImpl extends OperationNode implements BytecodeOSRNode { - - private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); - private static final BytecodeLoopBase COMMON_EXECUTE = new BytecodeNode(); - private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; - - @CompilationFinal(dimensions = 1) short[] _bc; - @CompilationFinal(dimensions = 1) Object[] _consts; - @Children Node[] _children; - @CompilationFinal(dimensions = 1) ExceptionHandler[] _handlers; - @CompilationFinal(dimensions = 1) int[] _conditionProfiles; - @CompilationFinal int _maxLocals; - @CompilationFinal int _maxStack; - @CompilationFinal(dimensions = 1) int[] sourceInfo; - @CompilationFinal int uncachedExecuteCount = 16; - @CompilationFinal private Object _osrMetadata; - private TruffleString _metadata_MethodName; - @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; - - private OperationNodeImpl(OperationNodes nodes) { - super(nodes); - } - - static { - setMetadataAccessor(SLOperations.MethodName, n -> ((OperationNodeImpl) n)._metadata_MethodName); - } - - private T insertAccessor(T node) { // () { - return insert(node); - } - - private Object executeAt(VirtualFrame frame, int storedLocation) { - int result = storedLocation; - while (true) { - result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _handlers, _conditionProfiles, _maxLocals); - if ((result & 0xffff) == 0xffff) { - break; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - } - return frame.getObject((result >> 16) & 0xffff); - } - - @Override - public Object execute(VirtualFrame frame) { - return executeAt(frame, _maxLocals << 16); - } - - @Override - protected int[] getSourceInfo() { - return sourceInfo; - } - - @Override - public String dump() { - return switchImpl.dump(_bc, _handlers, _consts); - } - - private Lock getLockAccessor() { - return getLock(); - } - - @Override - public FrameDescriptor createFrameDescriptor() { - FrameDescriptor.Builder builder = FrameDescriptor.newBuilder(); - builder.addSlots(_maxLocals + _maxStack, FrameSlotKind.Illegal); - return builder.build(); - } - - @Override - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return executeAt(osrFrame, target); - } - - @Override - public Object getOSRMetadata() { - return _osrMetadata; - } - - @Override - public void setOSRMetadata(Object osrMetadata) { - _osrMetadata = osrMetadata; - } - - @Override - public Node deepCopy() { - OperationNodeImpl result = new OperationNodeImpl(nodes); - result._bc = Arrays.copyOf(_bc, _bc.length); - result._consts = Arrays.copyOf(_consts, _consts.length); - result._children = Arrays.copyOf(_children, _children.length); - result._handlers = _handlers; - result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - @Override - public Node copy() { - OperationNodeImpl result = new OperationNodeImpl(nodes); - result._bc = _bc; - result._consts = _consts; - result._children = _children; - result._handlers = _handlers; - result._conditionProfiles = _conditionProfiles; - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - void changeInterpreters(BytecodeLoopBase impl) { - this.switchImpl = impl; - } - - } - @GeneratedBy(SLOperations.class) - private static final class OperationSerNodeImpl extends OperationNode { - - @CompilationFinal int buildOrder; - - private OperationSerNodeImpl(OperationNodes nodes, int buildOrder) { - super(nodes); - this.buildOrder = buildOrder; - } - - @Override - public String dump() { - throw new UnsupportedOperationException(); - } - - @Override - protected int[] getSourceInfo() { - throw new UnsupportedOperationException(); - } - - @Override - public Object execute(VirtualFrame frame) { - throw new UnsupportedOperationException(); - } - - @Override - public FrameDescriptor createFrameDescriptor() { - throw new UnsupportedOperationException(); - } - - } - @GeneratedBy(SLOperations.class) - private abstract static class BytecodeLoopBase { - - abstract int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); - - abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); - - abstract void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); - - protected static String formatConstant(Object obj) { - if (obj == null) { - return "null"; - } else { - Object repr = obj; - if (obj instanceof Object[]) { - repr = Arrays.deepToString((Object[]) obj); - } - return String.format("%s %s", obj.getClass().getSimpleName(), repr); - } - } - - protected static Object expectObject(VirtualFrame frame, int slot) { - if (frame.isObject(slot)) { - return frame.getObject(slot); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return frame.getValue(slot); - } - } - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType, short[] descriptor) { - int op = bc[bci] & 0xffff; - short todo = descriptor[op]; - if (todo > 0) { - bc[bci] = todo; - } else { - int offset = (todo >> 8) & 0x7f; - int bit = todo & 0xff; - if (targetType == 0 /* OBJECT */) { - bc[bci + offset] &= ~bit; - } else { - bc[bci + offset] |= bit; - } - } - } - - protected static long expectLong(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case 1 /* LONG */ : - return frame.getLong(slot); - case 0 /* OBJECT */ : - Object value = frame.getObject(slot); - if (value instanceof Long) { - return (long) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static boolean storeLocalLongCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Long) { - try { - frame.setLong(localSlot, expectLong(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - protected static boolean expectBoolean(VirtualFrame frame, int slot) throws UnexpectedResultException { - switch (frame.getTag(slot)) { - case 5 /* BOOLEAN */ : - return frame.getBoolean(slot); - case 0 /* OBJECT */ : - Object value = frame.getObject(slot); - if (value instanceof Boolean) { - return (boolean) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(frame.getValue(slot)); - } - - protected static boolean storeLocalBooleanCheck(VirtualFrame frame, int localSlot, int stackSlot) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - if (descriptor.getSlotKind(localSlot) == FrameSlotKind.Boolean) { - try { - frame.setBoolean(localSlot, expectBoolean(frame, stackSlot)); - return true; - } catch (UnexpectedResultException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - descriptor.setSlotKind(localSlot, FrameSlotKind.Object); - frame.setObject(localSlot, frame.getValue(stackSlot)); - return false; - } - - } - @GeneratedBy(SLOperations.class) - private static final class BytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - short curOpcode = unsafeFromBytecode($bc, $bci); - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - if ($sp < maxLocals) { - throw CompilerDirectives.shouldNotReachHere("stack underflow"); - } - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_POP : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - continue loop; - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Boxing Elimination: Do Nothing - case INSTR_BRANCH : - { - int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - } - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, null, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - // Boxing Elimination: Do Nothing - case INSTR_BRANCH_FALSE : - { - boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_THROW : - { - int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; - throw (AbstractTruffleException) $frame.getObject(slot); - } - // load.constant.object - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_OBJECT : - { - $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - continue loop; - } - // load.constant.long - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // INT -> INSTR_LOAD_CONSTANT_LONG - // DOUBLE -> INSTR_LOAD_CONSTANT_LONG - // FLOAT -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_LONG - // BYTE -> INSTR_LOAD_CONSTANT_LONG - case INSTR_LOAD_CONSTANT_LONG : - { - $frame.setLong($sp, (long) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - continue loop; - } - // load.constant.boolean - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_BOOLEAN - // INT -> INSTR_LOAD_CONSTANT_BOOLEAN - // DOUBLE -> INSTR_LOAD_CONSTANT_BOOLEAN - // FLOAT -> INSTR_LOAD_CONSTANT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - // BYTE -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $frame.setBoolean($sp, (boolean) $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - continue loop; - } - // load.argument.object - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - continue loop; - } - // load.argument.long - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // INT -> INSTR_LOAD_ARGUMENT_LONG - // DOUBLE -> INSTR_LOAD_ARGUMENT_LONG - // FLOAT -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_LONG - // BYTE -> INSTR_LOAD_ARGUMENT_LONG - case INSTR_LOAD_ARGUMENT_LONG : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0]]; - if (value instanceof Long) { - $frame.setLong($sp, (long) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - continue loop; - } - // load.argument.boolean - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_BOOLEAN - // INT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // DOUBLE -> INSTR_LOAD_ARGUMENT_BOOLEAN - // FLOAT -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - // BYTE -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0]]; - if (value instanceof Boolean) { - $frame.setBoolean($sp, (boolean) value); - } else { - $frame.setObject($sp, value); - } - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - continue loop; - } - // store.local.object - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_STORE_LOCAL_OBJECT : - { - int localIdx = $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0]; - int sourceSlot = $sp - 1; - $frame.setObject(localIdx, expectObject($frame, sourceSlot)); - $sp--; - $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; - continue loop; - } - // store.local.long - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> INSTR_STORE_LOCAL_OBJECT - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_LONG : - { - int localIdx = $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0]; - int sourceSlot = $sp - 1; - if (!storeLocalLongCheck($frame, localIdx, sourceSlot)) { - $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); - } - $sp--; - $bci = $bci + STORE_LOCAL_LONG_LENGTH; - continue loop; - } - // store.local.boolean - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_OBJECT - // INT -> INSTR_STORE_LOCAL_OBJECT - // DOUBLE -> INSTR_STORE_LOCAL_OBJECT - // FLOAT -> INSTR_STORE_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_STORE_LOCAL_OBJECT - case INSTR_STORE_LOCAL_BOOLEAN : - { - int localIdx = $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; - int sourceSlot = $sp - 1; - if (!storeLocalBooleanCheck($frame, localIdx, sourceSlot)) { - $bc[$bci] = (short) (INSTR_STORE_LOCAL_OBJECT); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), 0 /* OBJECT */); - } - $sp--; - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - continue loop; - } - // store.local.uninit - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_LONG - // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN - case INSTR_STORE_LOCAL_UNINIT : - { - int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; - int sourceSlot = $sp - 1; - FrameSlotKind localTag = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localTag == FrameSlotKind.Illegal) { - assert $frame.isObject(sourceSlot); - $frame.copyObject(sourceSlot, localIdx); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - int resultTag = storeLocalInitialization($frame, localIdx, localTag.tag, sourceSlot); - setResultBoxedImpl($bc, $bci, resultTag, BOXING_DESCRIPTORS[resultTag]); - doSetResultBoxed($bc, $bci, ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff), resultTag); - } - $sp--; - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - continue loop; - } - // load.local.object - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Do Nothing - case INSTR_LOAD_LOCAL_OBJECT : - { - int localIdx = $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0]; - if ($frame.getFrameDescriptor().getSlotKind(localIdx) != FrameSlotKind.Object) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - $frame.setObject(localIdx, $frame.getValue(localIdx)); - } - $frame.copyObject(localIdx, $sp); - $sp++; - $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - continue loop; - } - // load.local.long - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> 0 - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> INSTR_LOAD_LOCAL_OBJECT - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_LONG : - { - int localIdx = $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0]; - FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Long) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Long) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Long); - $frame.setLong(localIdx, (long) localValue); - $frame.copyPrimitive(localIdx, $sp); - } else { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - $bc[$bci] = (short) (INSTR_LOAD_LOCAL_OBJECT); - $frame.copyObject(localIdx, $sp); - } - } else { - $frame.copyPrimitive(localIdx, $sp); - } - $sp++; - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; - continue loop; - } - // load.local.boolean - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_OBJECT - // INT -> INSTR_LOAD_LOCAL_OBJECT - // DOUBLE -> INSTR_LOAD_LOCAL_OBJECT - // FLOAT -> INSTR_LOAD_LOCAL_OBJECT - // BOOLEAN -> 0 - // BYTE -> INSTR_LOAD_LOCAL_OBJECT - case INSTR_LOAD_LOCAL_BOOLEAN : - { - int localIdx = $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0]; - FrameSlotKind localType = $frame.getFrameDescriptor().getSlotKind(localIdx); - if (localType != FrameSlotKind.Boolean) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object localValue; - if (localType == FrameSlotKind.Illegal && (localValue = $frame.getObject(localIdx)) instanceof Boolean) { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Boolean); - $frame.setBoolean(localIdx, (boolean) localValue); - $frame.copyPrimitive(localIdx, $sp); - } else { - $frame.getFrameDescriptor().setSlotKind(localIdx, FrameSlotKind.Object); - $bc[$bci] = (short) (INSTR_LOAD_LOCAL_OBJECT); - $frame.copyObject(localIdx, $sp); - } - } else { - $frame.copyPrimitive(localIdx, $sp); - } - $sp++; - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - continue loop; - } - // load.local.uninit - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_LONG - // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN - case INSTR_LOAD_LOCAL_UNINIT : - { - int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; - $frame.setObject($sp, expectObject($frame, localIdx)); - $sp++; - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - continue loop; - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_RETURN : - { - return (($sp - 1) << 16) | 0xffff; - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD : - { - BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_ADD_LENGTH; - continue loop; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_DIV : - { - BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_DIV_LENGTH; - continue loop; - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_EQUAL : - { - BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_EQUAL_LENGTH; - continue loop; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL : - { - BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - continue loop; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN : - { - BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - continue loop; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LOGICAL_NOT : - { - BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - continue loop; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_MUL : - { - BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_MUL_LENGTH; - continue loop; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY : - { - BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - continue loop; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_SUB : - { - BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_SUB_LENGTH; - continue loop; - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY : - { - BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 3 + 1; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - continue loop; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX : - { - BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL : - { - BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - continue loop; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN : - { - BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - continue loop; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE : - { - int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; - Object input_0 = $frame.getObject($sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); - } - Object result = BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); - $sp = $sp - 1 - numVariadics + 1; - $frame.setObject($sp - 1, result); - $bci = $bci + C_SL_INVOKE_LENGTH; - continue loop; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_AND : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_OR : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - continue loop; - } - // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - continue loop; - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - continue loop; - } - // c.SLToBoolean.q.Boolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - continue loop; - } - // c.SLLessOrEqual.q.LessOrEqual0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - BytecodeNode.SLLessOrEqual_q_LessOrEqual0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - continue loop; - } - // c.SLInvoke.q.Direct - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - int numVariadics = $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0]; - Object input_0 = $frame.getObject($sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); - } - Object result = BytecodeNode.SLInvoke_q_Direct_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); - $sp = $sp - 1 - numVariadics + 1; - $frame.setObject($sp - 1, result); - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - continue loop; - } - // c.SLFunctionLiteral.q.Perform - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - continue loop; - } - // c.SLWriteProperty.q.WriteSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 3 + 1; - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - continue loop; - } - // c.SLLessThan.q.LessThan0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { - BytecodeNode.SLLessThan_q_LessThan0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - continue loop; - } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch (unsafeFromBytecode($bc, $bci)) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - break; - } - } - } - } - - @Override - String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { - int $bci = 0; - StringBuilder sb = new StringBuilder(); - while ($bci < $bc.length) { - sb.append(String.format(" [%04x]", $bci)); - switch (unsafeFromBytecode($bc, $bci)) { - default : - { - sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); - break; - } - case INSTR_POP : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("pop "); - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch "); - sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch.false "); - sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("throw "); - sb.append(String.format(" local(%s)", $bc[$bci + THROW_LOCALS_OFFSET + 0])); - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.object "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.object "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.object "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.uninit "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.object "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.uninit "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_RETURN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDiv "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqual "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLMul "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLSub "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_AND_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLOr "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_OR_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty.q.ReadSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBoolean "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty.q.WriteSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1] & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan0 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - break; - } - } - sb.append("\n"); - } - for (int i = 0; i < $handlers.length; i++) { - sb.append($handlers[i] + "\n"); - } - return sb.toString(); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static void SLAdd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b11110) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */; - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - - private static void SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLAddNode.addLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000) >>> 7 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLAddNode.add($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b11000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b1000) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0]); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); - return; - } - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLAdd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1]; - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 addLong(long, long) */); - if ((state_0 & 0b11110) == 0b10/* is-exact-state_0 addLong(long, long) */) { - $bc[$bci] = (short) (INSTR_C_SL_ADD_Q_ADD_LONG); - } else { - $bc[$bci] = (short) (INSTR_C_SL_ADD); - } - int type0; - int type1; - if ((state_0 & 0b11100) == 0 /* only-active addLong(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - try { - lock.unlock(); - hasLock = false; - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 5) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 7) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - $bc[$bci] = (short) (INSTR_C_SL_ADD); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); - return; - } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - $bc[$bci] = (short) (INSTR_C_SL_ADD); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 typeError(Object, Object, Node, int) */); - $bc[$bci] = (short) (INSTR_C_SL_ADD); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLDiv_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */; - try { - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - - private static void SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLDivNode.divLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLDivNode.div($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLDiv_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1]; - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 divLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active divLong(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - try { - lock.unlock(); - hasLock = false; - long value = SLDivNode.divLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static void SLEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */; - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private static void SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @ExplodeLoop - private static void SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLEqualNode.doLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000000) >>> 12 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLEqualNode.doBigNumber($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - boolean value = SLEqualNode.doBoolean($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - boolean value = SLEqualNode.doString($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0]); - if (truffleString_equalNode__ != null) { - boolean value = SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - boolean value = SLEqualNode.doNull($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1110000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - boolean value = SLEqualNode.doFunction($child0Value__, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - if ((state_0 & 0b1100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - boolean value = SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b1000000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - $frame.setObject($sp - 2, SLEqual_generic1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1111111100) == 0 /* only-active doLong(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 12) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doBigNumber($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doBoolean(boolean, boolean) */); - int type0; - int type1; - if ((state_0 & 0b1111110110) == 0 /* only-active doBoolean(boolean, boolean) */) { - type0 = 5 /* BOOLEAN */; - type1 = 5 /* BOOLEAN */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doBoolean($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doString(String, String) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doString($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) $children[childArrayOffset_ + 0])); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doNull(SLNull, SLNull) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doNull($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doFunction(SLFunction, Object) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doFunction($child0Value_, $child1Value); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.leftInterop_.accepts($child0Value)); - // assert (s7_.rightInterop_.accepts($child1Value)); - if (count7_ < (4)) { - s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) $children[childArrayOffset_ + 1]))); - s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLLessOrEqual_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private static void SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessOrEqual(long, long) */) { - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0); - } else { - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - } - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessOrEqual(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLLessThan_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private static void SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - boolean value = SLLessThanNode.lessThan($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLLessThan_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(long, long) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 lessThan(long, long) */) { - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0); - } else { - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); - } - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active lessThan(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static void SLLogicalNot_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private static void SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLLogicalNotNode.doBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - return; - } - - private static void SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { - type0 = 5 /* BOOLEAN */; - } else { - type0 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - boolean value = SLLogicalNotNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Node, int) */); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLMul_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */; - try { - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - - private static void SLMul_SLMul_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLMulNode.mulLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLMulNode.mul($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLMul_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1]; - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mulLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active mulLong(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - try { - lock.unlock(); - hasLock = false; - long value = SLMulNode.mulLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11]); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @ExplodeLoop - private static void SLReadProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0]; - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_)); - return; - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 2, SLReadProperty_readArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b11000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__1 = ($this); - int bci__1 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 2, SLReadProperty_readSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_)); - return; - } - } - if ((state_0 & 0b1100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8]); - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { - Node node__2 = ($this); - int bci__2 = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_)); - return; - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - $frame.setObject($sp - 2, SLReadProperty_readObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1]; - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) $children[childArrayOffset_ + 0]))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_)); - return; - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = ($this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) $children[childArrayOffset_ + 4]))); - node__1 = ($this); - bci__1 = ($bci); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0); - } else { - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - } - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = ($this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 7]))); - return; - } - } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8]); - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { - node__2 = ($this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (s4_.objects_.accepts($child0Value)); - InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) $children[childArrayOffset_ + 8]))); - node__2 = ($this); - bci__2 = ($bci); - s4_.objects_ = s4_.insertAccessor(objects__); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_)); - return; - } - } - } - { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = ($this); - readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) $children[childArrayOffset_ + 11]))); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLSub_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b1110) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */; - try { - long value = SLSubNode.subLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - - private static void SLSub_SLSub_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - long value = SLSubNode.subLong($child0Value__, $child1Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - return; - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - $frame.setObject($sp - 2, SLSubNode.sub($child0Value__, $child1Value__)); - return; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLSub_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1]; - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 subLong(long, long) */); - int type0; - int type1; - if ((state_0 & 0b1100) == 0 /* only-active subLong(long, long) */) { - type0 = 1 /* LONG */; - type1 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - try { - lock.unlock(); - hasLock = false; - long value = SLSubNode.subLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 subLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); - return; - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - int type0; - int type1; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__)); - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6]); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10]); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static void SLWriteProperty_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3); - Object $child1Value_ = expectObject($frame, $sp - 2); - Object $child2Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1111110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_)); - return; - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - $frame.setObject($sp - 3, SLWriteProperty_writeArray1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b11000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $frame.setObject($sp - 3, SLWriteProperty_writeSLObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_)); - return; - } - } - if ((state_0 & 0b1100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__1 = ($this); - int bci__1 = ($bci); - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_)); - return; - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - $frame.setObject($sp - 3, SLWriteProperty_writeObject1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_)); - return; - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private static void SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1]; - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) $children[childArrayOffset_ + 0]))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_)); - return; - } - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - int writeArray1_bci__ = 0; - Node writeArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - writeArray1_node__ = ($this); - writeArray1_bci__ = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__)); - return; - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4]); - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) $children[childArrayOffset_ + 4]))); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - if ((state_0 & 0b1111110) == 0b1000/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0); - } else { - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - } - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffff7 /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) $children[childArrayOffset_ + 6]))); - return; - } - } - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7]); - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (s4_.objectLibrary_.accepts($child0Value)); - s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) $children[childArrayOffset_ + 7]))); - node__1 = ($this); - bci__1 = ($bci); - s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_)); - return; - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = ($this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffdf /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - int type0; - int type1; - int type2; - type0 = 0 /* OBJECT */; - type1 = 0 /* OBJECT */; - type2 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff), type0); - doSetResultBoxed($bc, $bci, (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff), type1); - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff), type2); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) $children[childArrayOffset_ + 10]))); - return; - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static void SLUnbox_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1111111110) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private static void SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - assert (state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */; - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - @ExplodeLoop - private static void SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0]); - if (fromString_fromJavaStringNode__ != null) { - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__)); - return; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value__)); - return; - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLUnboxNode.fromBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - long value = SLUnboxNode.fromLong($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000000000) >>> 10 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value__)); - return; - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value__)); - return; - } - if ((state_0 & 0b1100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); - return; - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b1000000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - $frame.setObject($sp - 1, SLUnbox_fromForeign1Boundary_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)); - return; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - return; - } - - private static void SLUnbox_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1]; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromString(String, FromJavaStringNode) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) $children[childArrayOffset_ + 0]))); - return; - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromTruffleString(TruffleString) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); - return; - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromBoolean(boolean) */); - if ((state_0 & 0b1111111110) == 0b1000/* is-exact-state_0 fromBoolean(boolean) */) { - $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN); - } else { - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - } - int type0; - if ((state_0 & 0b1111110110) == 0 /* only-active fromBoolean(boolean) */) { - type0 = 5 /* BOOLEAN */; - } else { - type0 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromLong(long) */); - if ((state_0 & 0b1111111110) == 0b10000/* is-exact-state_0 fromLong(long) */) { - $bc[$bci] = (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG); - } else { - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - } - int type0; - if ((state_0 & 0b1111101110) == 0 /* only-active fromLong(long) */) { - type0 = 1 /* LONG */; - } else { - type0 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 10) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromBigNumber(SLBigNumber) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLFunction) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromFunction(SLNull) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1]); - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.interop_.accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) $children[childArrayOffset_ + 1]))); - s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, s7_.interop_)); - return; - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xfffffeff /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__)); - return; - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLFunctionLiteral_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0]); - if (result__ != null) { - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - return; - } - - private static void SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0]; - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); - node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - if ((state_0 & 0b10) == 0b10/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM); - } else { - $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); - } - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) $consts[constArrayOffset_ + 0]), node__)); - return; - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static void SLToBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */ && ((state_0 & 0b110) != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } else { - SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - return; - } - } - - private static void SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private static void SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - boolean value = SLToBooleanNode.doBoolean($child0Value__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - if ((state_0 & 0b100) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - boolean value = SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - return; - } - - private static void SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBoolean(boolean) */); - if ((state_0 & 0b110) == 0b10/* is-exact-state_0 doBoolean(boolean) */) { - $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN); - } else { - $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); - } - int type0; - if ((state_0 & 0b100) == 0 /* only-active doBoolean(boolean) */) { - type0 = 5 /* BOOLEAN */; - } else { - type0 = 0 /* OBJECT */; - } - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doFallback(Object, Node, int) */); - $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); - int type0; - type0 = 0 /* OBJECT */; - doSetResultBoxed($bc, $bci, ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff), type0); - lock.unlock(); - hasLock = false; - boolean value = SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { - short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b110) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, s0_); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1]); - if (indirect_callNode__ != null) { - return SLInvoke.doIndirect(arg0Value_, arg1Value, indirect_callNode__); - } - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = ($this); - int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2]); - if (interop_library__ != null) { - return SLInvoke.doInterop(arg0Value, arg1Value, interop_library__, interop_node__, interop_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); - } - - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0]; - short exclude = $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1]; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); - if ((state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if ((arg0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = (arg0Value_.getCallTarget()); - if ((arg0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = (arg0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) $children[childArrayOffset_ + 0]))); - s0_.callTargetStable_ = callTargetStable__; - s0_.cachedTarget_ = cachedTarget__; - s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - if ((state_0 & 0b1110) == 0b10/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - $bc[$bci] = (short) (INSTR_C_SL_INVOKE_Q_DIRECT); - } else { - $bc[$bci] = (short) (INSTR_C_SL_INVOKE); - } - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - } - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - $bc[$bci] = (short) (INSTR_C_SL_INVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect(arg0Value_, arg1Value, ((IndirectCallNode) $children[childArrayOffset_ + 1])); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = ($this); - interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - $bc[$bci] = (short) (INSTR_C_SL_INVOKE); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop(arg0Value, arg1Value, ((InteropLibrary) $children[childArrayOffset_ + 2]), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLInvoke_removeDirect__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLOr_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0]; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLUnbox_q_FromLong_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromLong(long) */; - long value = SLUnboxNode.fromLong($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setLong($sp - 1, value); - } - return; - } - - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b1000)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static void SLAdd_q_AddLong_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - $bc[$bci] = (short) (INSTR_C_SL_ADD); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_ADD); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 addLong(long, long) */; - try { - long value = SLAddNode.addLong($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setLong($sp - 2, value); - } - return; - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - $bc[$bci] = (short) (INSTR_C_SL_ADD); - SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - } - - @ExplodeLoop - private static void SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0]; - Object $child0Value_ = expectObject($frame, $sp - 2); - Object $child1Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__ = ($this); - int bci__ = ($bci); - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_READ_PROPERTY); - SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - return; - } - - private static void SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_UNBOX); - SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromBoolean(boolean) */; - boolean value = SLUnboxNode.fromBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b10)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static void SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0]; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_TO_BOOLEAN); - SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 doBoolean(boolean) */; - boolean value = SLToBooleanNode.doBoolean($child0Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 1, value); - } else { - $frame.setBoolean($sp - 1, value); - } - return; - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLLessOrEqual_q_LessOrEqual0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_STATE_BITS_OFFSET + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_LESS_OR_EQUAL); - SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(long, long) */; - boolean value = SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - @ExplodeLoop - private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { - short state_0 = $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0]; - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0]); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_q_Direct_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, s0_); - $bc[$bci] = (short) (INSTR_C_SL_INVOKE); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value_, arg1Value); - } - if ((arg0Value_.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect(arg0Value_, arg1Value, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_INVOKE); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, arg0Value, arg1Value); - } - - private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0]); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffd /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static void SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET + 0]; - Object $child0Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0) + 0]); - if (result__ != null) { - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value__, result__, node__)); - return; - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_FUNCTION_LITERAL); - SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - return; - } - - @ExplodeLoop - private static void SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET + 0]; - Object $child0Value_ = expectObject($frame, $sp - 3); - Object $child1Value_ = expectObject($frame, $sp - 2); - Object $child2Value_ = expectObject($frame, $sp - 1); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4]); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_)); - return; - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_WRITE_PROPERTY); - SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - return; - } - - private static boolean SLLessThan_q_LessThan0_fallbackGuard__(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static void SLLessThan_q_LessThan0_execute_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = $bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_STATE_BITS_OFFSET + 0]; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1); - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); - SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - return; - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - $bc[$bci] = (short) (INSTR_C_SL_LESS_THAN); - SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - return; - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(long, long) */; - boolean value = SLLessThanNode.lessThan($child0Value_, $child1Value_); - if (((state_0 & 0b1)) == 0 /* is-not-state_0 RESULT-UNBOXED */) { - $frame.setObject($sp - 2, value); - } else { - $frame.setBoolean($sp - 2, value); - } - return; - } - - private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { - Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } - frame.setObject(localIdx, value); - return 0 /* OBJECT */; - } - - private static boolean isAdoptable() { - return true; - } - - private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { - if (bciOffset != 0) { - setResultBoxedImpl(bc, startBci - bciOffset, targetType, BOXING_DESCRIPTORS[targetType]); - } - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperations.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperations.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(OperationNodeImpl $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - CompilerDirectives.transferToInterpreterAndInvalidate(); - int uncachedExecuteCount = $this.uncachedExecuteCount; - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - short curOpcode = unsafeFromBytecode($bc, $bci); - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - if ($sp < maxLocals) { - throw CompilerDirectives.shouldNotReachHere("stack underflow"); - } - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_POP : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - continue loop; - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Boxing Elimination: Do Nothing - case INSTR_BRANCH : - { - int targetBci = $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0]; - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - } - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, null, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - uncachedExecuteCount--; - if (uncachedExecuteCount <= 0) { - $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - // Boxing Elimination: Do Nothing - case INSTR_BRANCH_FALSE : - { - boolean cond = $frame.getObject($sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition(cond, $conditionProfiles, $bc[$bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0])) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_THROW : - { - int slot = $bc[$bci + THROW_LOCALS_OFFSET + 0]; - throw (AbstractTruffleException) $frame.getObject(slot); - } - // load.constant.object - // Constants: - // [ 0] constant - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_CONSTANT_OBJECT - // LONG -> INSTR_LOAD_CONSTANT_LONG - // BOOLEAN -> INSTR_LOAD_CONSTANT_BOOLEAN - case INSTR_LOAD_CONSTANT_OBJECT : - { - $frame.setObject($sp, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - continue loop; - } - // load.argument.object - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_ARGUMENT_OBJECT - // LONG -> INSTR_LOAD_ARGUMENT_LONG - // BOOLEAN -> INSTR_LOAD_ARGUMENT_BOOLEAN - case INSTR_LOAD_ARGUMENT_OBJECT : - { - Object value = $frame.getArguments()[$bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0]]; - $frame.setObject($sp, value); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - continue loop; - } - // store.local.uninit - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Replace - // OBJECT -> INSTR_STORE_LOCAL_OBJECT - // LONG -> INSTR_STORE_LOCAL_LONG - // BOOLEAN -> INSTR_STORE_LOCAL_BOOLEAN - case INSTR_STORE_LOCAL_UNINIT : - { - int localIdx = $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0]; - int sourceSlot = $sp - 1; - $frame.copyObject(sourceSlot, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - continue loop; - } - // load.local.uninit - // Locals: - // [ 0] local - // Pushed Values: 1 - // Boxing Elimination: Replace - // OBJECT -> INSTR_LOAD_LOCAL_OBJECT - // LONG -> INSTR_LOAD_LOCAL_LONG - // BOOLEAN -> INSTR_LOAD_LOCAL_BOOLEAN - case INSTR_LOAD_LOCAL_UNINIT : - { - int localIdx = $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0]; - $frame.setObject($sp, expectObject($frame, localIdx)); - $sp++; - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - continue loop; - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - // Boxing Elimination: Do Nothing - case INSTR_RETURN : - { - uncachedExecuteCount--; - if (uncachedExecuteCount <= 0) { - $this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount; - } - return (($sp - 1) << 16) | 0xffff; - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_ADD : - { - UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_ADD_LENGTH; - continue loop; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_DIV : - { - UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_DIV_LENGTH; - continue loop; - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_EQUAL : - { - UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_EQUAL_LENGTH; - continue loop; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_OR_EQUAL : - { - UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - continue loop; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LESS_THAN : - { - UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - continue loop; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_LOGICAL_NOT : - { - UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - continue loop; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_MUL : - { - UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_MUL_LENGTH; - continue loop; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_READ_PROPERTY : - { - UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - continue loop; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_SUB : - { - UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 2 + 1; - $bci = $bci + C_SL_SUB_LENGTH; - continue loop; - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_WRITE_PROPERTY : - { - UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 3), $frame.getObject($sp - 2), $frame.getObject($sp - 1)); - $sp = $sp - 3 + 1; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - continue loop; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_UNBOX : - { - UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Perform]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_FUNCTION_LITERAL : - { - UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - continue loop; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_TO_BOOLEAN : - { - UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $frame.getObject($sp - 1)); - $sp = $sp - 1 + 1; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - continue loop; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // Simple Pops: - // [ 0] arg0 - // Variadic - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [RESULT-UNBOXED, SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // Boxing Elimination: Bit Mask - case INSTR_C_SL_INVOKE : - { - int numVariadics = $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0]; - Object input_0 = $frame.getObject($sp - numVariadics - 1); - Object[] input_1 = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - input_1[varIndex] = $frame.getObject($sp - numVariadics + varIndex); - } - Object result = UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, input_0, input_1); - $sp = $sp - 1 - numVariadics + 1; - $frame.setObject($sp - 1, result); - $bci = $bci + C_SL_INVOKE_LENGTH; - continue loop; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_AND : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - // Boxing Elimination: Do Nothing - case INSTR_SC_SL_OR : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0]; - continue loop; - } - } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(OperationNodeImpl $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch (unsafeFromBytecode($bc, $bci)) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - $bc[$bci] = (short) (INSTR_LOAD_CONSTANT_OBJECT); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - $bci = $bci + STORE_LOCAL_LONG_LENGTH; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - break; - } - } - } - } - - @Override - String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { - int $bci = 0; - StringBuilder sb = new StringBuilder(); - while ($bci < $bc.length) { - sb.append(String.format(" [%04x]", $bci)); - switch (unsafeFromBytecode($bc, $bci)) { - default : - { - sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); - break; - } - case INSTR_POP : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("pop "); - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch "); - sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch.false "); - sb.append(String.format(" branch(%04x)", $bc[$bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("throw "); - sb.append(String.format(" local(%s)", $bc[$bci + THROW_LOCALS_OFFSET + 0])); - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.object "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_OBJECT_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.long "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_LONG_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LONG_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant.boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_BOOLEAN_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.object "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_OBJECT_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.long "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_LONG_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_LONG_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument.boolean "); - sb.append(String.format(" arg(%s)", $bc[$bci + LOAD_ARGUMENT_BOOLEAN_ARGUMENT_OFFSET + 0])); - $bci = $bci + LOAD_ARGUMENT_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.object "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_OBJECT_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_OBJECT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_LONG_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_LONG_LENGTH; - break; - } - case INSTR_STORE_LOCAL_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_STORE_LOCAL_UNINIT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.uninit "); - sb.append(String.format(" local(%s)", $bc[$bci + STORE_LOCAL_UNINIT_LOCALS_OFFSET + 0])); - sb.append(String.format(" pop(-%s)", ($bc[$bci + STORE_LOCAL_UNINIT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + STORE_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_OBJECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.object "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_OBJECT_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_OBJECT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.long "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_LONG_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_LONG_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boolean "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_BOOLEAN_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_BOOLEAN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_UNINIT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.uninit "); - sb.append(String.format(" local(%s)", $bc[$bci + LOAD_LOCAL_UNINIT_LOCALS_OFFSET + 0])); - $bci = $bci + LOAD_LOCAL_UNINIT_LENGTH; - break; - } - case INSTR_RETURN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDiv "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_DIV_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqual "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLMul "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_MUL_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLSub "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_SUB_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1] & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_VARIADIC_OFFSET + 0])); - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_AND_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLOr "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + SC_SL_OR_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" branch(%04x)", $bc[$bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0])); - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty.q.ReadSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBoolean "); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" var(%s)", $bc[$bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0])); - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0] & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty.q.WriteSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1] & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan0 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", ($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] & 0xff))); - sb.append(String.format(" pop(-%s)", (($bc[$bci + C_SL_LESS_THAN_Q_LESS_THAN0_POP_INDEXED_OFFSET + 0] >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LENGTH; - break; - } - } - sb.append("\n"); - } - for (int i = 0; i < $handlers.length; i++) { - sb.append($handlers[i] + "\n"); - } - return sb.toString(); - } - - private static void SLAdd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); - return; - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); - return; - } - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLDiv_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLDivNode.div($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $frame.setObject($sp - 2, SLEqualNode.doLong($child0Value_, $child1Value_)); - return; - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLEqualNode.doBigNumber($child0Value_, $child1Value_)); - return; - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $frame.setObject($sp - 2, SLEqualNode.doBoolean($child0Value_, $child1Value_)); - return; - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $frame.setObject($sp - 2, SLEqualNode.doString($child0Value_, $child1Value_)); - return; - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $frame.setObject($sp - 2, SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached()))); - return; - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $frame.setObject($sp - 2, SLEqualNode.doNull($child0Value_, $child1Value_)); - return; - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $frame.setObject($sp - 2, SLEqualNode.doFunction($child0Value_, $child1Value)); - return; - } - $frame.setObject($sp - 2, SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); - return; - } - - private static void SLLessOrEqual_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); - return; - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLLessThan_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); - return; - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLLogicalNot_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLLogicalNotNode.doBoolean($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLLogicalNotNode.typeError($child0Value, ($this), ($bci))); - return; - } - - private static void SLMul_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLMulNode.mul($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLReadProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); - return; - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); - return; - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } - - private static void SLSub_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLSubNode.sub($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLWriteProperty_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); - return; - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); - return; - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } - - private static void SLUnbox_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); - return; - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); - return; - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); - return; - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); - return; - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); - return; - } - - private static void SLFunctionLiteral_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); - } - - private static void SLToBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLToBooleanNode.doBoolean($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLToBooleanNode.doFallback($child0Value, ($this), ($bci))); - return; - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop(arg0Value, arg1Value, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static boolean SLOr_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static void SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); - return; - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); - return; - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); - return; - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); - return; - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); - return; - } - - private static void SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLAddNode.add($child0Value_, $child1Value_)); - return; - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - $frame.setObject($sp - 2, SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached()))); - return; - } - $frame.setObject($sp - 2, SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static void SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); - return; - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 2, SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); - return; - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - $frame.setObject($sp - 2, SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } - - private static void SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached()))); - return; - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromTruffleString($child0Value_)); - return; - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromBoolean($child0Value_)); - return; - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromLong($child0Value_)); - return; - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromBigNumber($child0Value_)); - return; - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $frame.setObject($sp - 1, SLUnboxNode.fromFunction($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value)))); - return; - } - - private static void SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $frame.setObject($sp - 1, SLToBooleanNode.doBoolean($child0Value_)); - return; - } - $frame.setObject($sp - 1, SLToBooleanNode.doFallback($child0Value, ($this), ($bci))); - return; - } - - private static void SLLessOrEqual_q_LessOrEqual0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); - return; - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object arg0Value, Object[] arg1Value) { - int childArrayOffset_; - int constArrayOffset_; - if (arg0Value instanceof SLFunction) { - SLFunction arg0Value_ = (SLFunction) arg0Value; - return SLInvoke.doIndirect(arg0Value_, arg1Value, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop(arg0Value, arg1Value, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static void SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $frame.setObject($sp - 1, SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $frame.getValue($sp - 1)); - } - - private static void SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value)))); - return; - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - $frame.setObject($sp - 3, SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached()))); - return; - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - $frame.setObject($sp - 3, SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached()))); - return; - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $frame.getValue($sp - 3), $frame.getValue($sp - 2), $frame.getValue($sp - 1)); - } - - private static void SLLessThan_q_LessThan0_executeUncached_(VirtualFrame $frame, OperationNodeImpl $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); - return; - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - $frame.setObject($sp - 2, SLLessThanNode.lessThan($child0Value_, $child1Value_)); - return; - } - } - $frame.setObject($sp - 2, SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci))); - return; - } - - private static int storeLocalInitialization(VirtualFrame frame, int localIdx, int localTag, int sourceSlot) { - Object value = frame.getValue(sourceSlot); - if (localTag == 1 /* LONG */ && value instanceof Long) { - frame.setLong(localIdx, (long) value); - return 1 /* LONG */; - } - if (localTag == 5 /* BOOLEAN */ && value instanceof Boolean) { - frame.setBoolean(localIdx, (boolean) value); - return 5 /* BOOLEAN */; - } - frame.setObject(localIdx, value); - return 0 /* OBJECT */; - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperations.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - } - @GeneratedBy(SLOperations.class) - private static final class WrappedIOException extends RuntimeException { - - WrappedIOException(IOException ex) { - super(ex); - } - - } - private static final class Counter { - - public int count; - - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index bfd33e6f0cd7..c68bf51a6f56 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -436,4 +436,22 @@ public static String operate(String value) { return value; } } + + @Operation + public static final class SecondValueBoxingElim { + @Specialization + public static Object doInt(Object a, int b) { + return null; + } + + @Specialization + public static Object doLong(Object a, long b) { + return null; + } + + @Specialization + public static Object doGeneric(Object a, Object b) { + return null; + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 209c4f3953b5..768965244616 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -610,6 +610,7 @@ public boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder pa parentBuilder.startCall(method.getSimpleName().toString()); addNodeCallParameters(parentBuilder, false, false); addStateParameters.run(); + frameState.addReferencesTo(parentBuilder); parentBuilder.end(2); if (needsReturn) { From b37fb9a0b2630b5094220dc2bfd5300b0f236294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 12 Aug 2022 08:39:37 +0200 Subject: [PATCH 124/312] [wip] remove local boxing elim until fixed --- .../test/example/BoxingOperationsTest.java | 35 +++- .../truffle/api/operation/LocalSetter.java | 27 +-- .../OperationsBytecodeCodeGenerator.java | 3 - .../operations/OperationsCodeGenerator.java | 4 +- .../operations/OperationsContext.java | 19 +- .../instructions/LoadLocalInstruction.java | 131 +------------ .../instructions/StoreLocalInstruction.java | 177 +----------------- 7 files changed, 65 insertions(+), 331 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index c68bf51a6f56..d28a974d2251 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -54,6 +54,7 @@ import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationParser; @@ -65,9 +66,14 @@ public class BoxingOperationsTest { // than it needs to private static RootCallTarget parse(OperationParser parser) { + OperationNode node = parseNode(parser); + return new TestRootNode(node).getCallTarget(); + } + + private static OperationNode parseNode(OperationParser parser) { OperationNodes nodes = BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser); OperationNode node = nodes.getNodes().get(0); - return new TestRootNode(node).getCallTarget(); + return node; } @Test @@ -253,6 +259,33 @@ public void testCastsChangeSpecRef() { } catch (UnsupportedSpecializationException e) { } } + + @Test + public void testLBEMultipleLoads() { + OperationNode node = parseNode(b -> { + OperationLocal local = b.createLocal(); + + b.beginStoreLocal(local); + b.emitConstObject(1L); + b.endStoreLocal(); + + b.beginLongOperator(); + b.emitLoadLocal(local); + b.endLongOperator(); + + b.beginReturn(); + b.emitLoadLocal(local); + b.endReturn(); + + b.publish(); + }); + + RootCallTarget root = new TestRootNode(node).getCallTarget(); + + for (int i = 0; i < 100; i++) { + Assert.assertEquals(1L, root.call()); + } + } } class BoxingLanguage extends TruffleLanguage { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index dc35bbf154a4..41217c355736 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -92,19 +92,20 @@ static void setObject(VirtualFrame frame, int index, Object value) { } private static boolean checkFrameSlot(VirtualFrame frame, int index, FrameSlotKind target) { - FrameDescriptor descriptor = frame.getFrameDescriptor(); - FrameSlotKind slotKind = descriptor.getSlotKind(index); - if (slotKind == FrameSlotKind.Illegal) { - descriptor.setSlotKind(index, target); - return true; - } else if (slotKind == target) { - return true; - } else if (slotKind == FrameSlotKind.Object) { - return false; - } else { - descriptor.setSlotKind(index, FrameSlotKind.Object); - return false; - } + return false; + // FrameDescriptor descriptor = frame.getFrameDescriptor(); + // FrameSlotKind slotKind = descriptor.getSlotKind(index); + // if (slotKind == FrameSlotKind.Illegal) { + // descriptor.setSlotKind(index, target); + // return true; + // } else if (slotKind == target) { + // return true; + // } else if (slotKind == FrameSlotKind.Object) { + // return false; + // } else { + // descriptor.setSlotKind(index, FrameSlotKind.Object); + // return false; + // } } static void setLong(VirtualFrame frame, int index, long value) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 47f85f9ee157..d6c6538e6e4e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -71,7 +71,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; public class OperationsBytecodeCodeGenerator { @@ -553,8 +552,6 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr for (CodeVariableElement element : staticConstants.elements()) { builderBytecodeNodeType.add(element); } - - builderBytecodeNodeType.add(StoreLocalInstruction.createStoreLocalInitialization(m.getOperationsContext())); } private static TypeMirror arrayOf(TypeMirror el) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 24eb1cbbf00f..4faa63921794 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -548,7 +548,7 @@ private CodeExecutableElement createNodeImplCreateFrameDescriptor() { CodeExecutableElement mCreateFrameDescriptor = GeneratorUtils.overrideImplement(types.OperationNode, "createFrameDescriptor"); CodeTreeBuilder b = mCreateFrameDescriptor.createBuilder(); b.statement("FrameDescriptor.Builder builder = FrameDescriptor.newBuilder()"); - b.statement("builder.addSlots(_maxLocals + _maxStack, FrameSlotKind.Illegal)"); + b.startStatement().string("builder.addSlots(_maxLocals + _maxStack,").type(types.FrameSlotKind).string(".Illegal)").end(); b.statement("return builder.build()"); return mCreateFrameDescriptor; } @@ -1500,7 +1500,7 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT for (TypeKind kind : m.getBoxingEliminatedTypes()) { FrameKind frameKind = FrameKind.valueOfPrimitive(kind); baseClass.add(createExpectPrimitive(frameKind)); - baseClass.add(createStoreLocalCheck(frameKind)); + // baseClass.add(createStoreLocalCheck(frameKind)); } return baseClass; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 9c4fdaa0b9d4..29693bc4dd98 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -81,8 +81,6 @@ public class OperationsContext { public LoadArgumentInstruction[] loadArgumentInstructions; public LoadConstantInstruction[] loadConstantInstructions; - public LoadLocalInstruction[] loadLocalInstructions; - public StoreLocalInstruction[] storeLocalInstructions; public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); @@ -143,20 +141,11 @@ private void createBuiltinOperations() { } private void createLoadStoreLocal() { - storeLocalInstructions = new StoreLocalInstruction[FrameKind.values().length]; - for (FrameKind kind : data.getFrameKinds()) { - storeLocalInstructions[kind.ordinal()] = add(new StoreLocalInstruction(this, instructionId++, kind)); - } - StoreLocalInstruction uninitStoreLocal = add(new StoreLocalInstruction(this, instructionId++, null)); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, uninitStoreLocal)); - - loadLocalInstructions = new LoadLocalInstruction[FrameKind.values().length]; - for (FrameKind kind : data.getFrameKinds()) { - loadLocalInstructions[kind.ordinal()] = add(new LoadLocalInstruction(this, instructionId++, kind)); - } - LoadLocalInstruction uninitLoadLocal = add(new LoadLocalInstruction(this, instructionId++, null)); + StoreLocalInstruction storeLocal = add(new StoreLocalInstruction(this, instructionId++)); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, storeLocal)); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, uninitLoadLocal)); + LoadLocalInstruction loadLocal = add(new LoadLocalInstruction(this, instructionId++)); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocal)); } private void createLoadArgument() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 656f54e80907..3f4bdeaafad6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -40,27 +40,17 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; -import javax.lang.model.type.TypeKind; - -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadLocalInstruction extends Instruction { private final OperationsContext ctx; - private final FrameKind kind; - public LoadLocalInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 1); + public LoadLocalInstruction(OperationsContext ctx, int id) { + super("load.local", id, 1); this.ctx = ctx; - this.kind = kind; addLocal("local"); } @@ -72,97 +62,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(createLocalIndex(vars, 0)); b.end(); - if (OperationGeneratorFlags.INTERPRETER_ONLY_BOXING_ELIMINATION) { - b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); // { - } - - if (kind == null) { - if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" local load %2d : %s [uninit]%n\", localIdx, $frame.getValue(localIdx))"); - } - createCopyAsObject(vars, b); - } else if (kind == FrameKind.OBJECT) { - b.startIf(); - // { - b.startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(); - b.string(" != "); - b.staticReference(StoreLocalInstruction.FrameSlotKind, "Object"); - // } - b.end().startBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" local load %2d : %s [init object]%n\", localIdx, $frame.getValue(localIdx))"); - } - - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - createReplaceObject(vars, b); - // } - b.end(); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" local load %2d : %s [generic]%n\", localIdx, $frame.getValue(localIdx))"); - } - - createCopyObject(vars, b); - } else { - - b.declaration(StoreLocalInstruction.FrameSlotKind, "localType", - b.create().startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end().build()); - - b.startIf(); - b.string("localType != ").staticReference(StoreLocalInstruction.FrameSlotKind, kind.getFrameName()); - b.end().startBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.declaration("Object", "localValue", (CodeTree) null); - - b.startIf(); - // { - b.string("localType == ").staticReference(StoreLocalInstruction.FrameSlotKind, "Illegal"); - b.string(" && "); - b.string("(localValue = $frame.getObject(localIdx))").instanceOf(ElementUtils.boxType(kind.getType())); - // } - b.end().startBlock(); - // { - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" local load %2d : %s [init " + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); - } - - createSetSlotKind(vars, b, "FrameSlotKind." + kind.getFrameName()); - - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.string("localIdx"); - b.startGroup().cast(kind.getType()).string("localValue").end(); - b.end(2); - - createCopyPrimitive(vars, b); - // } - b.end().startElseBlock(); - // { - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS || OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" local load %2d : %s [" + kind + " -> generic]%n\", localIdx, $frame.getValue(localIdx))"); - } - - createSetSlotKind(vars, b, "FrameSlotKind.Object"); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - createCopyObject(vars, b); - - b.end(); // } - b.end().startElseBlock(); // } else { - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" local load %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(localIdx))"); - } - - createCopyPrimitive(vars, b); - b.end(); // } - - } + createCopyObject(vars, b); + b.startStatement().variable(vars.sp).string("++").end(); return b.build(); @@ -171,11 +72,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - if (kind == FrameKind.OBJECT) { - return BoxingEliminationBehaviour.DO_NOTHING; - } else { - return BoxingEliminationBehaviour.REPLACE; - } + return BoxingEliminationBehaviour.DO_NOTHING; } private static final boolean USE_SPEC_FRAME_COPY = true; @@ -215,22 +112,6 @@ private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b.end(2); } - @Override - public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { - if (kind == null) { - // unitialized -> anything - return ctx.loadLocalInstructions[targetKind.ordinal()].opcodeIdField; - } else { - if (targetKind == kind || kind == FrameKind.OBJECT) { - // do nothing - return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "0"); - } else { - // prim -> anything different = object - return ctx.loadLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; - } - } - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; @@ -238,7 +119,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod @Override public boolean neverInUncached() { - return kind != null; + return false; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 766f3c4acf71..f59a68bef0d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -40,168 +40,25 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; -import java.util.Set; - -import javax.lang.model.element.Modifier; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.BoxingEliminationBehaviour; public class StoreLocalInstruction extends Instruction { - private final FrameKind kind; private final OperationsContext context; - static final DeclaredType FrameSlotKind = ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.frame.FrameSlotKind"); - - public StoreLocalInstruction(OperationsContext context, int id, FrameKind kind) { - super("store.local." + (kind == null ? "uninit" : kind.getTypeName().toLowerCase()), id, 0); + public StoreLocalInstruction(OperationsContext context, int id) { + super("store.local", id, 0); this.context = context; - this.kind = kind; - addPopIndexed("value"); + addPopSimple("value"); addLocal("target"); } - public static CodeExecutableElement createStoreLocalInitialization(OperationsContext context) { - ProcessorContext ctx = ProcessorContext.getInstance(); - - CodeExecutableElement method = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), ctx.getType(int.class), "storeLocalInitialization"); - method.addParameter(new CodeVariableElement(ctx.getTypes().VirtualFrame, "frame")); - method.addParameter(new CodeVariableElement(ctx.getType(int.class), "localIdx")); - method.addParameter(new CodeVariableElement(ctx.getType(int.class), "localTag")); - method.addParameter(new CodeVariableElement(ctx.getType(int.class), "sourceSlot")); - - CodeTreeBuilder b = method.createBuilder(); - - b.startAssign("Object value").string("frame.getValue(sourceSlot)").end(); - - for (FrameKind kind : context.getData().getFrameKinds()) { - if (kind == FrameKind.OBJECT) { - continue; - } - b.startIf(); - // { - b.string("localTag == " + kind.ordinal() + " /* " + kind + " */"); - b.string(" && "); - b.string("value instanceof " + kind.getTypeNameBoxed()); - // } - b.end().startBlock(); - // { - b.startStatement().startCall("frame", "set" + kind.getFrameName()); - b.string("localIdx"); - b.startGroup().cast(kind.getType()).string("value").end(); - b.end(2); - - b.startReturn().string(kind.ordinal() + " /* " + kind + " */").end(); - // } - b.end(); - } - - b.startStatement().startCall("frame", "setObject"); - b.string("localIdx"); - b.string("value"); - b.end(2); - - b.startReturn().string("0 /* OBJECT */").end(); - - return method; - } - @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // todo: implement version w/o BE, if a language does not need it - - b.startAssign("int localIdx"); - b.tree(createLocalIndex(vars, 0)); - b.end(); - - b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); - - if (kind == null) { - b.startAssign("FrameSlotKind localTag").startCall(vars.frame, "getFrameDescriptor().getSlotKind").string("localIdx").end(2); - - b.startIf().string("localTag == ").staticReference(FrameSlotKind, "Illegal").end().startBlock(); - // { - if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" local store %2d : %s [uninit]%n\", localIdx, $frame.getValue(sourceSlot))"); - } - b.startAssert().startCall(vars.frame, "isObject").string("sourceSlot").end(2); - createCopyObject(vars, b); - // } - b.end().startElseBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.startAssign("int resultTag").startCall("storeLocalInitialization"); - b.variable(vars.frame); - b.string("localIdx"); - b.string("localTag.tag"); - b.string("sourceSlot"); - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_STORES || OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { - b.statement("System.err.printf(\" local store %2d : %s [init -> %s]%n\", localIdx, $frame.getValue(sourceSlot), FrameSlotKind.fromTag((byte) resultTag))"); - } - - b.startStatement().startCall("setResultBoxedImpl"); - b.variable(vars.bc); - b.variable(vars.bci); - b.string("resultTag"); - b.string("BOXING_DESCRIPTORS[resultTag]"); - b.end(2); - - createSetChildBoxing(vars, b, "resultTag"); - // } - b.end(); - } else if (kind == FrameKind.OBJECT) { - if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" local store %2d : %s [generic]%n\", localIdx, $frame.getValue(sourceSlot))"); - } - - b.startStatement().startCall(vars.frame, "setObject"); - b.string("localIdx"); - b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); - b.end(2); - } else { - if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" local store %2d : %s [" + kind + "]%n\", localIdx, $frame.getValue(sourceSlot))"); - } - b.startIf().string("!").startCall("storeLocal" + kind.getFrameName() + "Check"); - b.variable(vars.frame); - b.string("localIdx"); - b.string("sourceSlot"); - b.end(2).startBlock(); // { - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - createSetChildBoxing(vars, b, "0 /* OBJECT */"); - b.end(); // } - } - - b.startStatement().variable(vars.sp).string("--").end(); - - return b.build(); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (kind != null) { - throw new AssertionError("only store.local.uninit should appear uncached"); - } - b.startAssign("int localIdx"); b.tree(createLocalIndex(vars, 0)); b.end(); @@ -254,33 +111,9 @@ private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b.end(2); } - private void createGenerifySelf(ExecutionVariables vars, CodeTreeBuilder b) { - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField)); - } - @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - if (kind == FrameKind.OBJECT) { - return BoxingEliminationBehaviour.DO_NOTHING; - } else { - return BoxingEliminationBehaviour.REPLACE; - } - } - - @Override - public CodeVariableElement boxingEliminationReplacement(FrameKind newKind) { - if (kind == null) { - // unitialized -> anything - return context.storeLocalInstructions[newKind.ordinal()].opcodeIdField; - } else { - if (newKind == kind || kind == FrameKind.OBJECT) { - // do nothing - return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "0"); - } else { - // prim -> anything different = object - return context.storeLocalInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField; - } - } + return BoxingEliminationBehaviour.DO_NOTHING; } @Override @@ -290,6 +123,6 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod @Override public boolean neverInUncached() { - return kind != null; + return false; } } From ea4a6e112d17c6739854b369a3cf85ec9b948fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 12 Aug 2022 09:03:38 +0200 Subject: [PATCH 125/312] [wip] fix error --- .../truffle/dsl/processor/generator/FlatNodeGenFactory.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 5acbf4d13b91..b6be929de117 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -4124,6 +4124,8 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt LocalVariable materializedFrame = new LocalVariable(types.MaterializedFrame, FRAME_VALUE, read.build()); frameState.set(includeFrameParameter, materializedFrame); } + } else { + includeFrameParameter = null; } CodeExecutableElement boundaryMethod = new CodeExecutableElement(modifiers(PRIVATE), parentMethod.getReturnType(), boundaryMethodName); From 871a0658783fba79fc0acadf6f4586bd799edaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 19 Aug 2022 10:15:08 +0200 Subject: [PATCH 126/312] [wip] refactored API --- .../test/example/BoxingOperationsTest.java | 10 +- .../example/TestOperationsParserTest.java | 12 +- .../test/example/TestOperationsSerTest.java | 4 +- .../operation/test/example/TestRootNode.java | 6 +- .../AbstractOperationsTruffleException.java | 2 +- .../api/operation/GenerateOperations.java | 5 + .../truffle/api/operation/MetadataKey.java | 6 +- .../api/operation/OperationBuilder.java | 4 + .../truffle/api/operation/OperationNodes.java | 6 +- ...rationNode.java => OperationRootNode.java} | 42 +- .../OperationDeserializationCallback.java | 4 +- .../OperationSerializationCallback.java | 4 +- .../truffle/dsl/processor/TruffleTypes.java | 4 +- .../expression/DSLExpressionResolver.java | 2 +- .../operations/OperationGeneratorFlags.java | 2 + .../OperationsBytecodeCodeGenerator.java | 10 +- .../operations/OperationsCodeGenerator.java | 375 +++++++++--------- .../processor/operations/OperationsData.java | 3 + .../operations/OperationsParser.java | 6 +- .../instructions/BranchInstruction.java | 2 +- .../operations/instructions/Instruction.java | 6 +- .../instructions/ReturnInstruction.java | 2 +- .../truffle/sl/nodes/SLAstRootNode.java | 40 ++ .../sl/nodes/SLOperationsRootNode.java | 40 -- ...erations.java => SLOperationRootNode.java} | 23 +- .../operations/SLOperationSerialization.java | 4 +- .../truffle/sl/parser/SLBaseVisitor.java | 2 +- .../truffle/sl/parser/SLNodeVisitor.java | 28 +- .../sl/parser/SLOperationsVisitor.java | 38 +- 29 files changed, 373 insertions(+), 319 deletions(-) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/{OperationNode.java => OperationRootNode.java} (82%) delete mode 100644 truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java rename truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/{SLOperations.java => SLOperationRootNode.java} (88%) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index d28a974d2251..9f0aed8f47f1 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -55,7 +55,7 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationParser; import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; @@ -66,13 +66,13 @@ public class BoxingOperationsTest { // than it needs to private static RootCallTarget parse(OperationParser parser) { - OperationNode node = parseNode(parser); + OperationRootNode node = parseNode(parser); return new TestRootNode(node).getCallTarget(); } - private static OperationNode parseNode(OperationParser parser) { + private static OperationRootNode parseNode(OperationParser parser) { OperationNodes nodes = BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser); - OperationNode node = nodes.getNodes().get(0); + OperationRootNode node = nodes.getNodes().get(0); return node; } @@ -262,7 +262,7 @@ public void testCastsChangeSpecRef() { @Test public void testLBEMultipleLoads() { - OperationNode node = parseNode(b -> { + OperationRootNode node = parseNode(b -> { OperationLocal local = b.createLocal(); b.beginStoreLocal(local); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index f6f08825faf0..1679fcffe670 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -52,19 +52,19 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationParser; public class TestOperationsParserTest { // @formatter:off private static RootCallTarget parse(OperationParser builder) { - OperationNode operationsNode = parseNode(builder); + OperationRootNode operationsNode = parseNode(builder); System.out.println(operationsNode.dump()); return new TestRootNode(operationsNode).getCallTarget(); } - private static OperationNode parseNode(OperationParser builder) { + private static OperationRootNode parseNode(OperationParser builder) { return TestOperationsBuilder.create(OperationConfig.DEFAULT, builder).getNodes().get(0); } @@ -833,7 +833,7 @@ public void testFinallyTryNoExceptException() { public void testMetadata() { final String value = "test data"; - OperationNode node = parseNode(b -> { + OperationRootNode node = parseNode(b -> { b.setTestData(value); b.publish(); }); @@ -846,7 +846,7 @@ public void testMetadata() { public void testMetadataChange() { final String value = "test data"; - OperationNode node = parseNode(b -> { + OperationRootNode node = parseNode(b -> { b.setTestData("some old value"); b.setTestData(value); b.publish(); @@ -858,7 +858,7 @@ public void testMetadataChange() { @Test public void testMetadataDefaultValue() { - OperationNode node = parseNode(b -> { + OperationRootNode node = parseNode(b -> { b.publish(); }); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 0175786cfe6f..3b3f7b543c0b 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -49,7 +49,7 @@ import org.junit.Test; import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationNodes; public class TestOperationsSerTest { @@ -72,7 +72,7 @@ private static TestRootNode deserialize(byte[] byteArray) { assert false; } - OperationNode node = nodes2.getNodes().get(0); + OperationRootNode node = nodes2.getNodes().get(0); TestRootNode root = new TestRootNode(node); return root; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java index 15727b64e027..752d7fcbfb72 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java @@ -42,13 +42,13 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; public class TestRootNode extends RootNode { - @Child private OperationNode node; + @Child private OperationRootNode node; - TestRootNode(OperationNode node) { + TestRootNode(OperationRootNode node) { super(null, node.createFrameDescriptor()); this.node = node; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index b1f28bafa318..ecb9ac3b67ba 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -73,7 +73,7 @@ public AbstractOperationsTruffleException(String message) { private static Node getLocation(Node location, int bci) { if (bci >= 0) { - return ((OperationNode) location).createLocationNode(bci); + return ((OperationRootNode) location).createLocationNode(bci); } else { return location; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index ab83633cb110..e7a5c992a418 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -45,9 +45,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.oracle.truffle.api.TruffleLanguage; + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface GenerateOperations { + + Class> languageClass(); + String decisionsFile() default ""; String[] decisionOverrideFiles() default {}; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java index 80d18ed5a1c2..d19e1e28af20 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java @@ -47,13 +47,13 @@ public class MetadataKey { private final T defaultValue; - @CompilationFinal private Function getter; + @CompilationFinal private Function getter; public MetadataKey(T defaultValue) { this.defaultValue = Objects.requireNonNull(defaultValue); } - void setGetter(Function getter) { + void setGetter(Function getter) { this.getter = getter; } @@ -61,7 +61,7 @@ public T getDefaultValue() { return defaultValue; } - public T getValue(OperationNode node) { + public T getValue(OperationRootNode node) { if (getter == null) { throw new ClassCastException(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 3942f110a36c..2bffaf13a640 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -41,4 +41,8 @@ package com.oracle.truffle.api.operation; public abstract class OperationBuilder { + + protected static void setNodeNodes(OperationRootNode node, OperationNodes nodes) { + node.nodes = nodes; + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 2e98bfea7c37..812157c7f88f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -52,7 +52,7 @@ public abstract class OperationNodes { protected final OperationParser parse; - @CompilationFinal(dimensions = 1) protected OperationNode[] nodes; + @CompilationFinal(dimensions = 1) protected OperationRootNode[] nodes; @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; @@ -60,7 +60,7 @@ protected OperationNodes(OperationParser parse) { this.parse = parse; } - public List getNodes() { + public List getNodes() { return List.of(nodes); } @@ -93,7 +93,7 @@ public boolean updateConfiguration(OperationConfig config) { } @SuppressWarnings("hiding") - protected abstract void reparseImpl(OperationConfig config, OperationParser parse, OperationNode[] nodes); + protected abstract void reparseImpl(OperationConfig config, OperationParser parse, OperationRootNode[] nodes); void reparse(OperationConfig config) { CompilerAsserts.neverPartOfCompilation("parsing should never be compiled"); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java similarity index 82% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index b0a7cfafbf85..b41a142a44e1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -40,43 +40,69 @@ */ package com.oracle.truffle.api.operation; +import java.lang.reflect.Field; import java.util.function.Function; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -public abstract class OperationNode extends Node { +import sun.misc.Unsafe; - protected final OperationNodes nodes; +public abstract class OperationRootNode extends RootNode { + + protected OperationNodes nodes; + + protected static final Unsafe UNSAFE; + + static { + Unsafe u; + try { + u = Unsafe.getUnsafe(); + } catch (SecurityException e) { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + u = (Unsafe) f.get(null); + } catch (Exception ex) { + throw new Error(ex); + } + } + UNSAFE = u; + } private static final int SOURCE_INFO_BCI_INDEX = 0; private static final int SOURCE_INFO_START = 1; private static final int SOURCE_INFO_LENGTH = 2; private static final int SOURCE_INFO_STRIDE = 3; - protected OperationNode(OperationNodes nodes) { - this.nodes = nodes; + protected OperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); } - protected abstract int[] getSourceInfo(); + protected OperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { + this(language, frameDescriptor.build()); + } - public abstract FrameDescriptor createFrameDescriptor(); + protected abstract int[] getSourceInfo(); + @Override public abstract Object execute(VirtualFrame frame); public final OperationNodes getOperationNodes() { return nodes; } - public final T getMetadata(MetadataKey key) { + public T getMetadata(MetadataKey key) { return key.getValue(this); } - protected static void setMetadataAccessor(MetadataKey key, Function getter) { + protected static void setMetadataAccessor(MetadataKey key, Function getter) { key.setGetter(getter); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java index 4d56371a3bfe..bffb8a0fa34e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java @@ -43,11 +43,11 @@ import java.io.IOException; import java.nio.ByteBuffer; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; public interface OperationDeserializationCallback { interface Context { - OperationNode deserializeOperationNode(ByteBuffer buffer) throws IOException; + OperationRootNode deserializeOperationNode(ByteBuffer buffer) throws IOException; } Object deserialize(Context context, ByteBuffer buffer) throws IOException; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java index d11b0fe7efe9..93c8cfcee0f4 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java @@ -43,12 +43,12 @@ import java.io.DataOutputStream; import java.io.IOException; -import com.oracle.truffle.api.operation.OperationNode; +import com.oracle.truffle.api.operation.OperationRootNode; @FunctionalInterface public interface OperationSerializationCallback { interface Context { - void serializeOperationNode(DataOutputStream buffer, OperationNode node) throws IOException; + void serializeOperationNode(DataOutputStream buffer, OperationRootNode node) throws IOException; } void serialize(Context context, DataOutputStream buffer, Object object) throws IOException; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index b0f95aa0e002..0cb346333107 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -244,7 +244,7 @@ public class TruffleTypes { public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; - public static final String OperationNode_Name = "com.oracle.truffle.api.operation.OperationNode"; + public static final String OperationRootNode_Name = "com.oracle.truffle.api.operation.OperationRootNode"; public static final String OperationNodes_Name = "com.oracle.truffle.api.operation.OperationNodes"; public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy"; public static final String OperationBuilder_Name = "com.oracle.truffle.api.operation.OperationBuilder"; @@ -266,7 +266,7 @@ public class TruffleTypes { public final DeclaredType OperationConfig = c.getDeclaredTypeOptional(OperationConfig_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); public final DeclaredType OperationLocal = c.getDeclaredTypeOptional(OperationLocal_Name); - public final DeclaredType OperationNode = c.getDeclaredTypeOptional(OperationNode_Name); + public final DeclaredType OperationRootNode = c.getDeclaredTypeOptional(OperationRootNode_Name); public final DeclaredType OperationNodes = c.getDeclaredTypeOptional(OperationNodes_Name); public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name); public final DeclaredType OperationBuilder = c.getDeclaredTypeOptional(OperationBuilder_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index ee24a0d6e000..f03039af551d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -233,7 +233,7 @@ private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); if (parseMode == ParseMode.OPERATION && "this".equals(name)) { - return new CodeVariableElement(ProcessorContext.getInstance().getTypes().OperationNode, "$this"); + return new CodeVariableElement(ProcessorContext.getInstance().getTypes().OperationRootNode, "$this"); } switch (name) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index 34d2a2d86f3a..662621507969 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -56,4 +56,6 @@ public class OperationGeneratorFlags { public static final boolean ENABLE_SERIALIZATION = true; + public static final boolean USE_UNSAFE = false; + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index d6c6538e6e4e..628c6ba7b984 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -89,7 +89,7 @@ public class OperationsBytecodeCodeGenerator { private static final String ConditionProfile_Name = "com.oracle.truffle.api.profiles.ConditionProfile"; final DeclaredType typeConditionProfile = context.getDeclaredType(ConditionProfile_Name); - private final CodeTypeElement typBuilderImpl; + private final CodeTypeElement typEnclosingElement; private final OperationsData m; private final boolean withInstrumentation; private final boolean isUncached; @@ -97,9 +97,9 @@ public class OperationsBytecodeCodeGenerator { private final CodeTypeElement opNodeImpl; private final CodeTypeElement typExceptionHandler; - public OperationsBytecodeCodeGenerator(CodeTypeElement typBuilderImpl, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, + public OperationsBytecodeCodeGenerator(CodeTypeElement typEnclosingElement, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, boolean withInstrumentation, boolean isUncached) { - this.typBuilderImpl = typBuilderImpl; + this.typEnclosingElement = typEnclosingElement; this.baseClass = baseClass; this.opNodeImpl = opNodeImpl; this.typExceptionHandler = typExceptionHandler; @@ -537,8 +537,8 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr if (m.isTracing()) { CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), "doGetStateBits_" + cinstr.getUniqueName() + "_"); - metGetSpecBits.setEnclosingElement(typBuilderImpl); - typBuilderImpl.add(metGetSpecBits); + metGetSpecBits.setEnclosingElement(typEnclosingElement); + typEnclosingElement.add(metGetSpecBits); metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "$bc")); metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 4faa63921794..22e60634945e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -41,6 +41,7 @@ package com.oracle.truffle.dsl.processor.operations; import java.io.DataOutputStream; +import java.io.IOError; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -52,12 +53,14 @@ import java.util.concurrent.locks.Lock; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.AnnotationProcessor; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -66,18 +69,20 @@ import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; +import sun.misc.Unsafe; + public class OperationsCodeGenerator extends CodeTypeElementFactory { private ProcessorContext context; @@ -86,6 +91,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory MOD_FINAL = Set.of(Modifier.FINAL); private static final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); private static final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); + private static final Set MOD_PUBLIC_FINAL = Set.of(Modifier.PUBLIC, Modifier.FINAL); private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); private static final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); private static final Set MOD_ABSTRACT = Set.of(Modifier.ABSTRACT); @@ -100,7 +106,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory { + unwrapIOError(b, () -> { b.statement("((OperationParser) parse).parse(builder)"); }); @@ -168,84 +174,12 @@ private CodeExecutableElement createOperationNodesSerialize() { return met; } - /** - * Creates the builder class itself. This class only contains abstract methods, the builder - * implementation class, and the createBuilder method. - * - * @return The created builder class - */ - CodeTypeElement createBuilder(String simpleName) { - CodeTypeElement typBuilder = GeneratorUtils.createClass(m, null, MOD_PUBLIC_ABSTRACT, simpleName, types.OperationBuilder); - GeneratorUtils.addSuppressWarnings(context, typBuilder, "cast", "hiding", "unchecked", "rawtypes", "static-method"); - - CodeExecutableElement ctor = GeneratorUtils.createConstructorUsingFields(MOD_PROTECTED, typBuilder); - typBuilder.add(ctor); - - CodeTypeElement opNodesImpl = createOperationNodes(); - typBuilder.add(opNodesImpl); - - // begin/end or emit methods - for (Operation op : m.getOperations()) { - - List args = op.getBuilderArgumentTypes(); - ArrayList params = new ArrayList<>(); - - for (int i = 0; i < args.size(); i++) { - params.add(new CodeVariableElement(args.get(i), "arg" + i)); - } - - CodeVariableElement[] paramsArr = params.toArray(new CodeVariableElement[0]); - - if (op.children != 0) { - CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "begin" + op.name, paramsArr); - typBuilder.add(metBegin); - - CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "end" + op.name); - typBuilder.add(metEnd); - } else { - CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, context.getType(void.class), "emit" + op.name, paramsArr); - typBuilder.add(metEmit); - } - } - - typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLocal, "createLocal")); - typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationLabel, "createLabel")); - typBuilder.add(new CodeExecutableElement(MOD_PUBLIC_ABSTRACT, types.OperationNode, "publish")); - - CodeExecutableElement metUnsafeFromBytecode = typBuilder.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode")); - metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - metUnsafeFromBytecode.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - - metUnsafeFromBytecode.createBuilder().startReturn().string("bc[index]").end(); - - CodeTypeElement typBuilderImpl = createBuilderImpl(typBuilder, opNodesImpl); - typBuilder.add(typBuilderImpl); - - for (OperationMetadataData metadata : m.getMetadatas()) { - typBuilder.add(createSetMetadata(metadata, true)); - } - - CodeTypeElement typWrappedEx = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "WrappedIOException", context.getType(RuntimeException.class)); - typWrappedEx.add(new CodeExecutableElement(Set.of(), null, "WrappedIOException", new CodeVariableElement(context.getType(IOException.class), "ex"))).createBuilder().statement("super(ex)"); - typBuilder.add(typWrappedEx); - - typBuilder.add(createCreateMethod(typBuilder, typBuilderImpl)); - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilder.add(createDeserializeMethod()); - typBuilder.add(createSerializeMethod(typBuilder, typBuilderImpl)); - } - - CodeTypeElement typCounter = typBuilder.add(new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter")); - typCounter.add(new CodeVariableElement(MOD_PUBLIC, context.getType(int.class), "count")); - - return typBuilder; - } - private CodeExecutableElement createDeserializeMethod() { + CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "input"); CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback"); - CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parConfig, parBuffer, parCallback); + CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parLanguage, parConfig, parBuffer, parCallback); met.addThrownType(context.getType(IOException.class)); @@ -255,10 +189,10 @@ private CodeExecutableElement createDeserializeMethod() { b.startReturn().startCall("create"); b.variable(parConfig); - b.string("b -> BuilderImpl.deserializeParser(input, callback, b)"); + b.string("b -> " + OPERATION_BUILDER_IMPL_NAME + ".deserializeParser(language, input, callback, b)"); b.end(2); - b.end().startCatchBlock(new GeneratedTypeMirror("", "WrappedIOException"), "ex"); + b.end().startCatchBlock(context.getType(IOError.class), "ex"); b.startThrow().string("(IOException) ex.getCause()").end(); @@ -267,10 +201,10 @@ private CodeExecutableElement createDeserializeMethod() { return met; } - private static void unwrapWrappedIOException(CodeTreeBuilder b, Runnable inner) { + private void unwrapIOError(CodeTreeBuilder b, Runnable inner) { b.startTryBlock(); inner.run(); - b.end().startCatchBlock(new GeneratedTypeMirror("", "WrappedIOException"), "ex"); + b.end().startCatchBlock(context.getType(IOError.class), "ex"); b.startThrow().string("(IOException) ex.getCause()").end(); b.end(); } @@ -289,7 +223,7 @@ private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, CodeTreeBuilder b = metCreate.getBuilder(); - b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); + b.startAssign(OPERATION_BUILDER_IMPL_NAME + " builder").startNew(typBuilderImpl.asType()); // ( b.string("null"); b.string("false"); // isReparse @@ -301,7 +235,7 @@ private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, b.statement("builder.serBuffer = buffer"); b.statement("builder.serCallback = callback"); - unwrapWrappedIOException(b, () -> { + unwrapIOError(b, () -> { b.startStatement().startCall("generator", "parse"); b.string("builder"); b.end(2); @@ -322,7 +256,7 @@ private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, Cod CodeTreeBuilder b = metCreate.getBuilder(); b.declaration("OperationNodesImpl", "nodes", "new OperationNodesImpl(generator)"); - b.startAssign("BuilderImpl builder").startNew(typBuilderImpl.asType()); + b.startAssign(OPERATION_BUILDER_IMPL_NAME + " builder").startNew(typBuilderImpl.asType()); // ( b.string("nodes"); b.string("false"); // isReparse @@ -356,12 +290,12 @@ private static CodeVariableElement children(CodeVariableElement el) { } private CodeTypeElement createOperationSerNodeImpl() { - CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerNodeImpl", types.OperationNode); + CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerNodeImpl", m.getTemplateType().asType()); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl)); - for (String methodName : new String[]{"dump", "getSourceInfo", "execute", "createFrameDescriptor"}) { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationNode, methodName); + for (String methodName : new String[]{"dump", "getSourceInfo", "execute"}) { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, methodName); met.createBuilder().startThrow().startNew(context.getType(UnsupportedOperationException.class)).end(2); typOperationNodeImpl.add(met); } @@ -377,7 +311,7 @@ private CodeVariableElement createSerializationContext() { b.startNew(typeContext).end().string(" ").startBlock(); b.string("@Override").newLine(); - b.string("public void serializeOperationNode(" + DATA_OUTPUT_CLASS.getSimpleName() + " buffer, OperationNode node) throws IOException ").startBlock(); + b.string("public void serializeOperationNode(" + DATA_OUTPUT_CLASS.getSimpleName() + " buffer, OperationRootNode node) throws IOException ").startBlock(); b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationSerNodeImpl) node).buildOrder)"); @@ -388,12 +322,25 @@ private CodeVariableElement createSerializationContext() { return fld; } - CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTypeElement typExceptionHandler) { - CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationNodeImpl", types.OperationNode); + CodeTypeElement createOperationNodeImpl() { + String simpleName = m.getTemplateType().getSimpleName().toString() + "Gen"; + CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PUBLIC_FINAL, simpleName, m.getTemplateType().asType()); + + GeneratorUtils.addSuppressWarnings(context, typOperationNodeImpl, "unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"); typOperationNodeImpl.getImplements().add(types.BytecodeOSRNode); - typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl)); + CodeTypeElement typExceptionHandler = typOperationNodeImpl.add(createExceptionHandler()); + + CodeTypeElement typBytecodeBase = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); + typOperationNodeImpl.add(createBytecodeBaseClass(typBytecodeBase, typOperationNodeImpl, typExceptionHandler)); + + for (ExecutableElement ctor : ElementFilter.constructorsIn(m.getTemplateType().getEnclosedElements())) { + CodeExecutableElement genCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), ctor)); + genCtor.setSimpleName(CodeNames.of(simpleName)); + genCtor.getModifiers().clear(); + genCtor.getModifiers().add(Modifier.PRIVATE); + } typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(short[].class), "_bc"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(Object[].class), "_consts"))); @@ -404,6 +351,11 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); + CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); + GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); + fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); + typOperationNodeImpl.add(fldSwitchImpl); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "uncachedExecuteCount = 16"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); @@ -441,15 +393,15 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(createNodeImplExecuteAt()); - CodeExecutableElement mExecute = GeneratorUtils.overrideImplement(types.OperationNode, "execute"); + CodeExecutableElement mExecute = GeneratorUtils.overrideImplement(types.RootNode, "execute"); typOperationNodeImpl.add(mExecute); mExecute.createBuilder().startReturn().startCall("executeAt").string("frame, _maxLocals << 16").end(2); - CodeExecutableElement mGetSourceInfo = GeneratorUtils.overrideImplement(types.OperationNode, "getSourceInfo"); + CodeExecutableElement mGetSourceInfo = GeneratorUtils.overrideImplement(types.OperationRootNode, "getSourceInfo"); typOperationNodeImpl.add(mGetSourceInfo); mGetSourceInfo.createBuilder().statement("return sourceInfo"); - CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationNode, "dump"); + CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationRootNode, "dump"); typOperationNodeImpl.add(mDump); mDump.createBuilder().startReturn().startCall("switchImpl.dump").string("_bc, _handlers, _consts").end(2); @@ -461,8 +413,6 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(mInsertAccessor); mInsertAccessor.createBuilder().startReturn().startCall("insert").string("node").end(2); - typOperationNodeImpl.add(createNodeImplCreateFrameDescriptor()); - CodeExecutableElement mExecuteOSR = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "executeOSR"); typOperationNodeImpl.add(mExecuteOSR); mExecuteOSR.createBuilder().startReturn().startCall("executeAt").string("osrFrame, target").end(2); @@ -477,12 +427,79 @@ CodeTypeElement createOperationNodeImpl(CodeTypeElement typBytecodeBase, CodeTyp typOperationNodeImpl.add(createNodeImplDeepCopy(typOperationNodeImpl)); typOperationNodeImpl.add(createNodeImplCopy(typOperationNodeImpl)); + CodeTypeElement typOpNodesImpl = createOperationNodes(); + typOperationNodeImpl.add(typOpNodesImpl); + + CodeTypeElement builderBytecodeNodeType; + CodeTypeElement builderUncachedBytecodeNodeType; + CodeTypeElement builderInstrBytecodeNodeType; + + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false); + builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); + typOperationNodeImpl.add(builderBytecodeNodeType); + if (m.isGenerateUncached()) { + builderUncachedBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, + true).createBuilderBytecodeNode(); + typOperationNodeImpl.add(builderUncachedBytecodeNodeType); + } else { + builderUncachedBytecodeNodeType = null; + } + + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, true, false); + builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); + typOperationNodeImpl.add(builderInstrBytecodeNodeType); + } else { + builderInstrBytecodeNodeType = null; + } + + CodeTypeElement typBuilderImpl = createBuilderImpl(typOperationNodeImpl, typOpNodesImpl, typExceptionHandler); + typOperationNodeImpl.add(typBuilderImpl); typOperationNodeImpl.add(createChangeInterpreter(typBytecodeBase)); + // instruction IDs + for (Instruction instr : m.getOperationsContext().instructions) { + typOperationNodeImpl.addAll(instr.createInstructionFields()); + } + + typOperationNodeImpl.add(createBoxingDescriptors()); + typOperationNodeImpl.add(createSetResultUnboxed()); + typOperationNodeImpl.add(createSetResultBoxedImpl()); + typOperationNodeImpl.add(createCounter()); + typOperationNodeImpl.add(createUnsafeFromBytecode()); + typOperationNodeImpl.add(createConditionProfile()); + + typOperationNodeImpl.add(createCreateMethod(typBuilderImpl, typBuilderImpl)); + typOperationNodeImpl.add(createDeserializeMethod()); + typOperationNodeImpl.add(createSerializeMethod(typBuilderImpl, typBuilderImpl)); + return typOperationNodeImpl; } + private CodeExecutableElement createUnsafeFromBytecode() { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode"); + met.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); + + CodeTreeBuilder b = met.createBuilder(); + b.startReturn(); + if (OperationGeneratorFlags.USE_UNSAFE) { + b.startCall("UNSAFE", "getShort"); + b.string("bc"); + b.startGroup(); + b.staticReference(context.getType(Unsafe.class), "ARRAY_SHORT_BASE_OFFSET"); + b.string(" + "); + b.staticReference(context.getType(Unsafe.class), "ARRAY_SHORT_BASE_SCALE"); + b.string(" * index").end(2); + } else { + b.string("bc[index]"); + } + b.end(); + + return met; + } + private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) { CodeExecutableElement met = new CodeExecutableElement(context.getType(void.class), "changeInterpreters"); met.addParameter(new CodeVariableElement(loopBase.asType(), "impl")); @@ -496,12 +513,22 @@ private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) return met; } + private CodeTree createNodeCopy(CodeTypeElement typOperationNodeImpl) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startNew(typOperationNodeImpl.asType()); + b.startCall("getLanguage").typeLiteral(m.languageClass).end(); + b.startCall("getFrameDescriptor().copy").end(); + b.end(); + return b.build(); + } + private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperationNodeImpl) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "deepCopy"); CodeTreeBuilder b = met.createBuilder(); - b.declaration(typOperationNodeImpl.asType(), "result", "new OperationNodeImpl(nodes)"); + b.declaration(typOperationNodeImpl.asType(), "result", createNodeCopy(typOperationNodeImpl)); + b.statement("result.nodes = nodes"); b.statement("result._bc = Arrays.copyOf(_bc, _bc.length)"); b.statement("result._consts = Arrays.copyOf(_consts, _consts.length)"); b.statement("result._children = Arrays.copyOf(_children, _children.length)"); @@ -524,8 +551,9 @@ private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNod CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "copy"); CodeTreeBuilder b = met.createBuilder(); - b.declaration(typOperationNodeImpl.asType(), "result", "new OperationNodeImpl(nodes)"); + b.declaration(typOperationNodeImpl.asType(), "result", createNodeCopy(typOperationNodeImpl)); + b.statement("result.nodes = nodes"); b.statement("result._bc = _bc"); b.statement("result._consts = _consts"); b.statement("result._children = _children"); @@ -544,15 +572,6 @@ private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNod return met; } - private CodeExecutableElement createNodeImplCreateFrameDescriptor() { - CodeExecutableElement mCreateFrameDescriptor = GeneratorUtils.overrideImplement(types.OperationNode, "createFrameDescriptor"); - CodeTreeBuilder b = mCreateFrameDescriptor.createBuilder(); - b.statement("FrameDescriptor.Builder builder = FrameDescriptor.newBuilder()"); - b.startStatement().string("builder.addSlots(_maxLocals + _maxStack,").type(types.FrameSlotKind).string(".Illegal)").end(); - b.statement("return builder.build()"); - return mCreateFrameDescriptor; - } - private CodeExecutableElement createNodeImplExecuteAt() { CodeExecutableElement mExecuteAt = new CodeExecutableElement(MOD_PRIVATE, context.getType(Object.class), "executeAt"); mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); @@ -588,9 +607,9 @@ private CodeExecutableElement createNodeImplExecuteAt() { return mExecuteAt; } - private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeElement opNodesImpl) { - CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PRIVATE, Modifier.STATIC), OPERATION_BUILDER_IMPL_NAME, typBuilder.asType()); - typBuilderImpl.setEnclosingElement(typBuilder); + private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, CodeTypeElement opNodesImpl, CodeTypeElement typExceptionHandler) { + CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), OPERATION_BUILDER_IMPL_NAME, types.OperationBuilder); + typBuilderImpl.setEnclosingElement(typOperationNodeImpl); if (m.isTracing()) { String decisionsFilePath = m.getDecisionsFilePath(); @@ -653,8 +672,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl CodeTypeElement typLabelFill = typBuilderImpl.add(createLabelFill(typLabelData)); - CodeTypeElement typExceptionHandler = typBuilderImpl.add(createExceptionHandler()); - CodeTypeElement typSourceBuilder = createSourceBuilder(typBuilderImpl); typBuilderImpl.add(typSourceBuilder); @@ -710,12 +727,12 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(createBuilderImplDoEmitLabel(typLabelData)); typBuilderImpl.addAll(createBuilderImplCalculateLeaves(opDataImpl, typLabelData)); - typBuilderImpl.add(createBuilderImplCreateLocal(typBuilder, typLocalData)); - typBuilderImpl.add(createBuilderImplCreateParentLocal(typBuilder, typLocalData)); - typBuilderImpl.add(createBuilderImplCreateLabel(typBuilder, typLabelData)); + typBuilderImpl.add(createBuilderImplCreateLocal(typBuilderImpl, typLocalData)); + typBuilderImpl.add(createBuilderImplCreateParentLocal(typBuilderImpl, typLocalData)); + typBuilderImpl.add(createBuilderImplCreateLabel(typBuilderImpl, typLabelData)); typBuilderImpl.addAll(createBuilderImplGetLocalIndex(typLocalData)); typBuilderImpl.add(createBuilderImplVerifyNesting(opDataImpl)); - typBuilderImpl.add(createBuilderImplPublish()); + typBuilderImpl.add(createBuilderImplPublish(typOperationNodeImpl)); typBuilderImpl.add(createBuilderImplLabelPass(typFinallyTryContext)); // operation IDs @@ -727,50 +744,13 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(fldId); } - CodeTypeElement bytecodeBaseClass = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); - - CodeTypeElement typOperationNodeImpl = createOperationNodeImpl(bytecodeBaseClass, typExceptionHandler); - typBuilderImpl.add(typOperationNodeImpl); - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typBuilderImpl.add(createOperationSerNodeImpl()); typBuilderImpl.add(createSerializationContext()); } - createBytecodeBaseClass(bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler); - typBuilderImpl.add(bytecodeBaseClass); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typOperationNodeImpl.asType())), "builtNodes")); - CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, bytecodeBaseClass.asType(), "switchImpl"); - GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); - fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); - typOperationNodeImpl.add(fldSwitchImpl); - - CodeTypeElement builderBytecodeNodeType; - CodeTypeElement builderUncachedBytecodeNodeType; - CodeTypeElement builderInstrBytecodeNodeType; - - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false, false); - builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); - typBuilderImpl.add(builderBytecodeNodeType); - - if (m.isGenerateUncached()) { - builderUncachedBytecodeNodeType = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, false, - true).createBuilderBytecodeNode(); - typBuilderImpl.add(builderUncachedBytecodeNodeType); - } else { - builderUncachedBytecodeNodeType = null; - } - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typBuilderImpl, bytecodeBaseClass, typOperationNodeImpl, typExceptionHandler, m, true, false); - builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); - typBuilderImpl.add(builderInstrBytecodeNodeType); - } else { - builderInstrBytecodeNodeType = null; - } - CodeVariableElement fldOperationData = new CodeVariableElement(opDataImpl.asType(), "operationData"); CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); @@ -797,15 +777,6 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(createBeforeChild(vars)); typBuilderImpl.add(createAfterChild(vars)); - // instruction IDs - for (Instruction instr : m.getOperationsContext().instructions) { - typBuilderImpl.addAll(instr.createInstructionFields()); - } - - typBuilderImpl.add(createBoxingDescriptors()); - - builderBytecodeNodeType.add(createSetResultUnboxed()); - for (Operation op : m.getOperations()) { List args = op.getBuilderArgumentTypes(); CodeVariableElement[] params = new CodeVariableElement[args.size()]; @@ -815,10 +786,10 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl } if (op.children != 0) { - typBuilderImpl.add(createBeginOperation(typBuilder, vars, op)); - typBuilderImpl.add(createEndOperation(typBuilder, vars, op)); + typBuilderImpl.add(createBeginOperation(typBuilderImpl, vars, op)); + typBuilderImpl.add(createEndOperation(typBuilderImpl, vars, op)); } else { - typBuilderImpl.add(createEmitOperation(typBuilder, vars, op)); + typBuilderImpl.add(createEmitOperation(typBuilderImpl, vars, op)); } } @@ -828,18 +799,16 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typBuilder, CodeTypeEl typBuilderImpl.add(createSetMetadata(metadata, false)); } - typBuilderImpl.add(createConditionProfile()); - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(createBuilderImplDeserializeParser(typBuilder)); + typBuilderImpl.add(createBuilderImplDeserializeParser(typBuilderImpl)); } return typBuilderImpl; - } private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement typBuilder) { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); + met.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); met.addParameter(new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "buffer")); met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback")); met.addParameter(new CodeVariableElement(typBuilder.asType(), "builder")); @@ -849,7 +818,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.statement("ArrayList consts = new ArrayList<>()"); b.statement("ArrayList locals = new ArrayList<>()"); b.statement("ArrayList labels = new ArrayList<>()"); - b.statement("ArrayList builtNodes = new ArrayList<>()"); + b.statement("ArrayList<" + m.getTemplateType().getSimpleName() + "> builtNodes = new ArrayList<>()"); TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context"); @@ -858,7 +827,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.string(" context = ").startNew(deserContext).end().startBlock(); b.string("@Override").newLine(); - b.string("public OperationNode deserializeOperationNode(").type(context.getType(DATA_INPUT_CLASS)).string(" buffer) throws IOException ").startBlock(); + b.string("public " + m.getTemplateType().getSimpleName() + " deserializeOperationNode(").type(context.getType(DATA_INPUT_CLASS)).string(" buffer) throws IOException ").startBlock(); b.statement("return builtNodes.get(buffer." + DATA_READ_METHOD_PREFIX + "Int())"); b.end(); @@ -868,7 +837,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.startSwitch().string("buffer." + DATA_READ_METHOD_PREFIX + "Short()").end().startBlock(); b.startCase().string("" + SER_CODE_PUBLISH).end().startBlock(); - b.statement("builtNodes.add(builder.publish())"); + b.statement("builtNodes.add(builder.publish(language))"); b.statement("locals.clear()"); b.statement("labels.clear()"); b.statement("break"); @@ -1185,13 +1154,13 @@ private void serializationWrapException(CodeTreeBuilder b, Runnable r) { b.startTryBlock(); r.run(); b.end().startCatchBlock(context.getType(IOException.class), "ex"); - b.startThrow().startNew("WrappedIOException").string("ex").end(2); + b.startThrow().startNew(context.getType(IOError.class)).string("ex").end(2); b.end(); } @SuppressWarnings("static-method") private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { - CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLocal"); + CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PUBLIC_FINAL, types.OperationLocal, "createLocal"); CodeTreeBuilder b = mCreateLocal.createBuilder(); if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { @@ -1216,7 +1185,7 @@ private CodeExecutableElement createBuilderImplCreateParentLocal(CodeTypeElement @SuppressWarnings("static-method") private CodeExecutableElement createBuilderImplCreateLabel(CodeTypeElement typBuilder, CodeTypeElement typLabelData) { - CodeExecutableElement mCreateLocal = GeneratorUtils.overrideImplement(typBuilder, "createLabel"); + CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PUBLIC_FINAL, types.OperationLabel, "createLabel"); CodeTreeBuilder b = mCreateLocal.createBuilder(); @@ -1602,7 +1571,10 @@ private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, } private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metEmit = GeneratorUtils.overrideImplement(typBuilder, "emit" + op.name); + CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "emit" + op.name); + + createBeginArguments(op, metEmit); + CodeTreeBuilder b = metEmit.getBuilder(); createBeginOperationSerialize(vars, op, b); @@ -1662,8 +1634,23 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu return metEmit; } + private void createBeginArguments(Operation op, CodeExecutableElement metEmit) { + int i = 0; + for (TypeMirror mir : op.getBuilderArgumentTypes()) { + metEmit.addParameter(new CodeVariableElement(mir, "arg" + i)); + i++; + } + } + + private CodeTypeElement createCounter() { + CodeTypeElement typ = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter"); + typ.add(new CodeVariableElement(context.getType(int.class), "count")); + + return typ; + } + private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metEnd = GeneratorUtils.overrideImplement(typBuilder, "end" + op.name); + CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "end" + op.name); GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); // if (operationData.id != ID) throw; @@ -1739,9 +1726,11 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui } private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metBegin = GeneratorUtils.overrideImplement(typBuilder, "begin" + op.name); + CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "begin" + op.name); GeneratorUtils.addSuppressWarnings(context, metBegin, "unused"); + createBeginArguments(op, metBegin); + // doBeforeChild(); // operationData = new ...(operationData, ID, , args...); @@ -1866,8 +1855,11 @@ private CodeExecutableElement createSetResultUnboxed() { return mDoSetResultUnboxed; } - private CodeExecutableElement createBuilderImplPublish() { - CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PUBLIC, types.OperationNode, "publish"); + private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperationNodeImpl) { + CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PUBLIC, m.getTemplateType().asType(), "publish"); + + CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); + mPublish.addParameter(parLanguage); CodeTreeBuilder b = mPublish.createBuilder(); @@ -1875,7 +1867,7 @@ private CodeExecutableElement createBuilderImplPublish() { b.startIf().string("isSerializing").end().startBlock(); serializationWrapException(b, () -> { b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_PUBLISH + ")"); - b.declaration("OperationNode", "result", "new OperationSerNodeImpl(null, buildIndex++)"); + b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder(), buildIndex++)"); b.statement("numLocals = 0"); b.statement("numLabels = 0"); b.statement("return result"); @@ -1887,11 +1879,16 @@ private CodeExecutableElement createBuilderImplPublish() { b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("Not all operations closed").end(2); b.end(); - b.declaration("OperationNodeImpl", "result", (CodeTree) null); + b.declaration(typOperationNodeImpl.asType(), "result", (CodeTree) null); b.startIf().string("!isReparse").end().startBlock(); - b.statement("result = new OperationNodeImpl(nodes)"); + b.declaration(types.FrameDescriptor, ".Builder frameDescriptor", (CodeTree) null); + b.startAssign("frameDescriptor").startStaticCall(types.FrameDescriptor, "newBuilder").string("numLocals + maxStack").end(2); + b.startStatement().startCall("frameDescriptor.addSlots").string("numLocals + maxStack").staticReference(types.FrameSlotKind, "Illegal").end(2); + + b.startAssign("result").startNew(typOperationNodeImpl.asType()).variable(parLanguage).string("frameDescriptor").end(2); + b.startAssign("result.nodes").string("nodes").end(); b.statement("labelPass(null)"); b.statement("result._bc = Arrays.copyOf(bc, bci)"); @@ -2135,10 +2132,10 @@ public List create(ProcessorContext context, AnnotationProcesso this.context = context; this.m = m; - String simpleName = m.getTemplateType().getSimpleName() + "Builder"; + String simpleName = m.getTemplateType().getSimpleName() + "Gen"; try { - return List.of(createBuilder(simpleName)); + return List.of(createOperationNodeImpl()); } catch (Throwable e) { CodeTypeElement el = GeneratorUtils.createClass(m, null, Set.of(), simpleName, null); CodeTreeBuilder b = el.createDocBuilder(); @@ -2331,7 +2328,7 @@ private CodeExecutableElement createBuilderImplFinish() { b.end(); b.startIf().string("!isReparse").end().startBlock(); - b.statement("nodes.setNodes(builtNodes.toArray(new OperationNode[0]))"); + b.statement("nodes.setNodes(builtNodes.toArray(new OperationRootNode[0]))"); b.end(); return mFinish; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index c3097c68ccdc..4f8e84fe4c93 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -48,6 +48,7 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -73,6 +74,8 @@ public class OperationsData extends Template { private boolean isGenerateAOT; private boolean isGenerateUncached; + public DeclaredType languageClass; + private int numTosSlots; public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 66a4638baab6..f62bfd7deb01 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -83,9 +83,11 @@ protected OperationsData parse(Element element, List mirror) { OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); + data.languageClass = (DeclaredType) ElementUtils.getAnnotationValue(generateOperationsMirror, "languageClass").getValue(); + // check basic declaration properties - if (!typeElement.getModifiers().contains(Modifier.FINAL)) { - data.addError(typeElement, "Operations class must be declared final."); + if (!typeElement.getModifiers().contains(Modifier.ABSTRACT)) { + data.addError(typeElement, "Operations class must be declared abstract."); } if (ElementUtils.findParentEnclosingType(typeElement).isPresent()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 24e192f39418..a34b4dd9605b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -139,7 +139,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.statement("uncachedExecuteCount--"); b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); - b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); + b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); b.statement("return ($sp << 16) | targetBci"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 68a48c19d0e5..fedf282a8e99 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -374,7 +374,7 @@ public void setOpcodeIdField(CodeVariableElement opcodeIdField) { this.internalName = OperationGeneratorUtils.toScreamCase(name); this.numPushedValues = numPushedValues; - this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.STATIC, Modifier.FINAL), context.getType(int.class), "INSTR_" + internalName); + this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), context.getType(int.class), "INSTR_" + internalName); opcodeIdField.createInitBuilder().string("" + id); } @@ -515,7 +515,7 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) // todo: instruments - b.startAssign(vars.bci).variable(vars.bci).string(" + " + length()).end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.tree(createCustomEmitCodeAfter(vars, args)); @@ -710,7 +710,7 @@ public CodeTree createDumpCode(ExecutionVariables vars) { private CodeVariableElement createConstant(String constantName, int value) { CodeVariableElement result = new CodeVariableElement( - Set.of(Modifier.STATIC, Modifier.FINAL), + Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), context.getType(int.class), constantName); result.createInitBuilder().string("" + value); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index ae0f47ed7d89..f2dde70c90b6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -77,7 +77,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (uncached) { b.statement("uncachedExecuteCount--"); b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); - b.statement("$this.changeInterpreters(OperationNodeImpl.COMMON_EXECUTE)"); + b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); b.end().startElseBlock(); b.statement("$this.uncachedExecuteCount = uncachedExecuteCount"); b.end(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java index 44b01ddecd8a..8adef2e81c77 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLAstRootNode.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.sl.nodes; import com.oracle.truffle.api.frame.FrameDescriptor; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java deleted file mode 100644 index 65923f870656..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLOperationsRootNode.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.oracle.truffle.sl.nodes; - -import java.io.DataOutputStream; - -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.operation.OperationNode; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.operations.SLOperations; - -public class SLOperationsRootNode extends SLRootNode { - - @Child private OperationNode operationsNode; - - public SLOperationsRootNode(SLLanguage language, OperationNode operationsNode) { - super(language, operationsNode.createFrameDescriptor()); - this.operationsNode = insert(operationsNode); - } - - @Override - public Object execute(VirtualFrame frame) { - return operationsNode.execute(frame); - } - - @Override - public SourceSection getSourceSection() { - return operationsNode.getSourceSection(); - } - - @Override - public SLExpressionNode getBodyNode() { - return null; - } - - @Override - public TruffleString getTSName() { - return operationsNode.getMetadata(SLOperations.MethodName); - } -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java similarity index 88% rename from truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java rename to truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index bf65d4f424f5..70b6856a620f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperations.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -42,11 +42,13 @@ import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -56,13 +58,14 @@ import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; -import com.oracle.truffle.api.operation.GenerateOperations.Metadata; import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.ShortCircuitOperation; import com.oracle.truffle.api.operation.Variadic; import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; @@ -81,7 +84,10 @@ import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; -@GenerateOperations(decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) +@GenerateOperations(// + languageClass = SLLanguage.class, // + decisionsFile = "decisions.json", // + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @@ -99,9 +105,18 @@ @OperationProxy(SLToBooleanNode.class) @ShortCircuitOperation(name = "SLAnd", booleanConverter = SLToBooleanNode.class, continueWhen = true) @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) -public final class SLOperations { +public abstract class SLOperationRootNode extends OperationRootNode { - @Metadata public static final MetadataKey MethodName = new MetadataKey<>(SLStrings.EMPTY_STRING); + protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { + super(language, frameDescriptor); + } + + protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + @GenerateOperations.Metadata // + public static final MetadataKey MethodName = new MetadataKey<>(SLStrings.EMPTY_STRING); @Operation @TypeSystemReference(SLTypes.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java index 72f88b8095e1..0377507e658d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -112,10 +112,10 @@ private static void writeByteArray(DataOutputStream buffer, byte[] data) throws buffer.write(data); } - public static OperationNodes deserializeNodes(byte[] inputData) throws IOException { + public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException { ByteBuffer buf = ByteBuffer.wrap(inputData); - return SLOperationsBuilder.deserialize(OperationConfig.DEFAULT, buf, new OperationDeserializationCallback() { + return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, new OperationDeserializationCallback() { public Object deserialize(OperationDeserializationCallback.Context context, ByteBuffer buffer) throws IOException { byte tag; switch (tag = buffer.get()) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java index 3ab40f909a70..e9351d4f28a8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLBaseVisitor.java @@ -92,7 +92,7 @@ protected SLBaseVisitor(SLLanguage language, Source source) { sourceString = SLStrings.fromJavaString(source.getCharacters().toString()); } - protected void SemErr(Token token, String message) { + protected void semErr(Token token, String message) { assert token != null; throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java index e3d4e94222f9..f556b6c28e92 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLNodeVisitor.java @@ -127,8 +127,8 @@ public static Map parseSL(SLLanguage language, So private FrameDescriptor.Builder frameDescriptorBuilder; - private SLStatementVisitor STATEMENT_VISITOR = new SLStatementVisitor(); - private SLExpressionVisitor EXPRESSION_VISITOR = new SLExpressionVisitor(); + private SLStatementVisitor statementVisitor = new SLStatementVisitor(); + private SLExpressionVisitor expressionVisitor = new SLExpressionVisitor(); private int loopDepth = 0; private final Map functions = new HashMap<>(); @@ -162,7 +162,7 @@ public Void visitFunction(FunctionContext ctx) { methodNodes.add(assignment); } - SLStatementNode bodyNode = STATEMENT_VISITOR.visitBlock(ctx.body); + SLStatementNode bodyNode = statementVisitor.visitBlock(ctx.body); exitFunction(); @@ -243,7 +243,7 @@ public SLStatementNode visitDebugger_statement(Debugger_statementContext ctx) { @Override public SLStatementNode visitBreak_statement(Break_statementContext ctx) { if (loopDepth == 0) { - SemErr(ctx.b, "break used outside of loop"); + semErr(ctx.b, "break used outside of loop"); } final SLBreakNode breakNode = new SLBreakNode(); srcFromToken(breakNode, ctx.b); @@ -253,7 +253,7 @@ public SLStatementNode visitBreak_statement(Break_statementContext ctx) { @Override public SLStatementNode visitContinue_statement(Continue_statementContext ctx) { if (loopDepth == 0) { - SemErr(ctx.c, "continue used outside of loop"); + semErr(ctx.c, "continue used outside of loop"); } final SLContinueNode continueNode = new SLContinueNode(); srcFromToken(continueNode, ctx.c); @@ -262,7 +262,7 @@ public SLStatementNode visitContinue_statement(Continue_statementContext ctx) { @Override public SLStatementNode visitWhile_statement(While_statementContext ctx) { - SLExpressionNode conditionNode = EXPRESSION_VISITOR.visitExpression(ctx.condition); + SLExpressionNode conditionNode = expressionVisitor.visitExpression(ctx.condition); loopDepth++; SLStatementNode bodyNode = visitBlock(ctx.body); @@ -278,7 +278,7 @@ public SLStatementNode visitWhile_statement(While_statementContext ctx) { @Override public SLStatementNode visitIf_statement(If_statementContext ctx) { - SLExpressionNode conditionNode = EXPRESSION_VISITOR.visitExpression(ctx.condition); + SLExpressionNode conditionNode = expressionVisitor.visitExpression(ctx.condition); SLStatementNode thenPartNode = visitBlock(ctx.then); SLStatementNode elsePartNode = ctx.alt == null ? null : visitBlock(ctx.alt); @@ -295,7 +295,7 @@ public SLStatementNode visitReturn_statement(Return_statementContext ctx) { final SLExpressionNode valueNode; if (ctx.expression() != null) { - valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + valueNode = expressionVisitor.visitExpression(ctx.expression()); } else { valueNode = null; } @@ -314,7 +314,7 @@ public SLStatementNode visitStatement(StatementContext ctx) { @Override public SLStatementNode visitExpression_statement(Expression_statementContext ctx) { - return EXPRESSION_VISITOR.visitExpression(ctx.expression()); + return expressionVisitor.visitExpression(ctx.expression()); } @Override @@ -500,7 +500,7 @@ public SLExpressionNode visitMemberCall(MemberCallContext ctx) { } for (ExpressionContext child : ctx.expression()) { - parameters.add(EXPRESSION_VISITOR.visitExpression(child)); + parameters.add(expressionVisitor.visitExpression(child)); } final SLExpressionNode result = new SLInvokeNode(receiver, parameters.toArray(new SLExpressionNode[parameters.size()])); @@ -520,14 +520,14 @@ public SLExpressionNode visitMemberCall(MemberCallContext ctx) { public SLExpressionNode visitMemberAssign(MemberAssignContext ctx) { final SLExpressionNode result; if (assignmentName == null) { - SemErr(ctx.expression().start, "invalid assignment target"); + semErr(ctx.expression().start, "invalid assignment target"); result = null; } else if (assignmentReceiver == null) { - SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + SLExpressionNode valueNode = expressionVisitor.visitExpression(ctx.expression()); result = createAssignment((SLStringLiteralNode) assignmentName, valueNode, null); } else { // create write property - SLExpressionNode valueNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + SLExpressionNode valueNode = expressionVisitor.visitExpression(ctx.expression()); result = SLWritePropertyNodeGen.create(assignmentReceiver, assignmentName, valueNode); @@ -572,7 +572,7 @@ public SLExpressionNode visitMemberIndex(MemberIndexContext ctx) { receiver = createRead(assignmentName); } - SLExpressionNode nameNode = EXPRESSION_VISITOR.visitExpression(ctx.expression()); + SLExpressionNode nameNode = expressionVisitor.visitExpression(ctx.expression()); assignmentName = nameNode; final SLExpressionNode result = SLReadPropertyNodeGen.create(receiver, nameNode); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index a82924648866..44861707aa52 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -57,15 +57,14 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNode; import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; -import com.oracle.truffle.sl.nodes.SLOperationsRootNode; +import com.oracle.truffle.sl.operations.SLOperationRootNode; +import com.oracle.truffle.sl.operations.SLOperationRootNodeGen; import com.oracle.truffle.sl.operations.SLOperationSerialization; -import com.oracle.truffle.sl.operations.SLOperations; -import com.oracle.truffle.sl.operations.SLOperationsBuilder; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.ArithmeticContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.BlockContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Break_statementContext; @@ -96,10 +95,10 @@ public final class SLOperationsVisitor extends SLBaseVisitor { private static final boolean DO_LOG_NODE_CREATION = true; - private static final boolean FORCE_SERIALIZE = true; + private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { - OperationNodes nodes = SLOperationsBuilder.create(OperationConfig.DEFAULT, builder -> { + OperationNodes nodes = SLOperationRootNodeGen.create(OperationConfig.DEFAULT, builder -> { SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, builder); parseSLImpl(source, visitor); }); @@ -107,16 +106,15 @@ public static void parseSL(SLLanguage language, Source source, Map parseSL(SLLanguage language, So return roots; } - private SLOperationsVisitor(SLLanguage language, Source source, SLOperationsBuilder builder) { + private SLOperationsVisitor(SLLanguage language, Source source, SLOperationRootNodeGen.Builder builder) { super(language, source); this.b = builder; } - private final SLOperationsBuilder b; + private final SLOperationRootNodeGen.Builder b; private OperationLabel breakLabel; private OperationLabel continueLabel; @@ -184,7 +182,7 @@ public Void visitFunction(FunctionContext ctx) { b.endTag(); b.endSource(); - OperationNode node = b.publish(); + OperationRootNode node = b.publish(language); if (DO_LOG_NODE_CREATION) { try { @@ -192,7 +190,9 @@ public Void visitFunction(FunctionContext ctx) { System./**/out.printf(" Node: %s%n", name); System./**/out.println(node.dump()); System./**/out.println("----------------------------------------------"); - } catch (Exception ignored) { + } catch (Exception ex) { + System./**/out.println("error while dumping: "); + ex.printStackTrace(System.out); } } @@ -219,7 +219,7 @@ public Void visitBlock(BlockContext ctx) { @Override public Void visitBreak_statement(Break_statementContext ctx) { if (breakLabel == null) { - SemErr(ctx.b, "break used outside of loop"); + semErr(ctx.b, "break used outside of loop"); } b.beginTag(StandardTags.StatementTag.class); @@ -232,7 +232,7 @@ public Void visitBreak_statement(Break_statementContext ctx) { @Override public Void visitContinue_statement(Continue_statementContext ctx) { if (continueLabel == null) { - SemErr(ctx.c, "continue used outside of loop"); + semErr(ctx.c, "continue used outside of loop"); } b.beginTag(StandardTags.StatementTag.class); @@ -595,9 +595,9 @@ private void buildMemberExpressionWriteBefore(Token ident, List Date: Fri, 19 Aug 2022 10:26:56 +0200 Subject: [PATCH 127/312] [wip] update tests --- .../test/example/BoxingOperationsTest.java | 44 ++++++--- .../test/example/TestOperations.java | 25 ++++- .../example/TestOperationsParserTest.java | 99 +++++++++++-------- .../test/example/TestOperationsSerTest.java | 17 ++-- .../operation/test/example/TestRootNode.java | 61 ------------ 5 files changed, 117 insertions(+), 129 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 9f0aed8f47f1..c77a6ee3e3e7 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -51,6 +51,8 @@ import com.oracle.truffle.api.dsl.TypeSystem; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameDescriptor.Builder; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; @@ -65,13 +67,15 @@ public class BoxingOperationsTest { // todo: all of these tests should somehow check that e&s is not called more times // than it needs to - private static RootCallTarget parse(OperationParser parser) { + private static final BoxingLanguage LANGUAGE = null; + + private static RootCallTarget parse(OperationParser parser) { OperationRootNode node = parseNode(parser); - return new TestRootNode(node).getCallTarget(); + return node.getCallTarget(); } - private static OperationRootNode parseNode(OperationParser parser) { - OperationNodes nodes = BoxingOperationsBuilder.create(OperationConfig.DEFAULT, parser); + private static OperationRootNode parseNode(OperationParser parser) { + OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); OperationRootNode node = nodes.getNodes().get(0); return node; } @@ -85,7 +89,7 @@ public void testCastsPrimToPrim() { b.endLongOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -102,7 +106,7 @@ public void testCastsRefToPrim() { b.endLongOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -119,7 +123,7 @@ public void testCastsPrimToRef() { b.endStringOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -136,7 +140,7 @@ public void testCastsRefToRef() { b.endStringOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -155,7 +159,7 @@ public void testCastsChangePrim() { b.endLongOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -184,7 +188,7 @@ public void testCastsChangeRef() { b.endStringOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -213,7 +217,7 @@ public void testCastsChangeSpecPrim() { b.endLongOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -242,7 +246,7 @@ public void testCastsChangeSpecRef() { b.endStringOperator(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); for (int i = 0; i < 3; i++) { @@ -277,10 +281,10 @@ public void testLBEMultipleLoads() { b.emitLoadLocal(local); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); - RootCallTarget root = new TestRootNode(node).getCallTarget(); + RootCallTarget root = node.getCallTarget(); for (int i = 0; i < 100; i++) { Assert.assertEquals(1L, root.call()); @@ -338,9 +342,17 @@ static long castLong(ReferenceTypeB b) { } } -@GenerateOperations(boxingEliminationTypes = {boolean.class, int.class, long.class}) +@GenerateOperations(languageClass = BoxingLanguage.class, boxingEliminationTypes = {boolean.class, int.class, long.class}) @SuppressWarnings("unused") -final class BoxingOperations { +abstract class BoxingOperations extends OperationRootNode { + + protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) { + super(language, frameDescriptor); + } + + protected BoxingOperations(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } @Operation @TypeSystemReference(BoxingTypeSystem.class) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index c094232dacbc..3744d3f843b1 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -43,12 +43,15 @@ import java.util.List; import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.FrameDescriptor.Builder; +import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; @@ -58,18 +61,26 @@ import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.Variadic; -@GenerateOperations +@GenerateOperations(languageClass = TestLanguage.class) @GenerateUncached @GenerateAOT @OperationProxy(SomeOperationNode.class) -public final class TestOperations { +public abstract class TestOperations extends OperationRootNode { + + protected TestOperations(TruffleLanguage language, Builder frameDescriptor) { + super(language, frameDescriptor); + } + + protected TestOperations(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } @Metadata public static final MetadataKey TestData = new MetadataKey<>("default value"); private static class TestException extends AbstractOperationsTruffleException { - private static final long serialVersionUID = -9143719084054578413L; TestException(String string, Node node, int bci) { @@ -167,6 +178,14 @@ public static Integer doCached(Integer i, @Cached("i") Integer cachedI) { } } +class TestLanguage extends TruffleLanguage { + @Override + protected Object createContext(Env env) { + return new Object(); + } + +} + class Association { public Object getValue() { return new Object(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 1679fcffe670..f606433e5aaf 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -58,14 +58,16 @@ public class TestOperationsParserTest { // @formatter:off - private static RootCallTarget parse(OperationParser builder) { + private static final TestLanguage LANGUAGE = null; + + private static RootCallTarget parse(OperationParser builder) { OperationRootNode operationsNode = parseNode(builder); System.out.println(operationsNode.dump()); - return new TestRootNode(operationsNode).getCallTarget(); + return operationsNode.getCallTarget(); } - private static OperationRootNode parseNode(OperationParser builder) { - return TestOperationsBuilder.create(OperationConfig.DEFAULT, builder).getNodes().get(0); + private static OperationRootNode parseNode(OperationParser builder) { + return TestOperationsGen.create(OperationConfig.DEFAULT, builder).getNodes().get(0); } @Test @@ -78,7 +80,7 @@ public void testAdd() { b.endAddOperation(); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); Assert.assertEquals(42L, root.call(20L, 22L)); @@ -106,7 +108,7 @@ public void testMax() { b.endIfThenElse(); - b.publish(); + b.publish(LANGUAGE); }); Assert.assertEquals(42L, root.call(42L, 13L)); @@ -135,7 +137,7 @@ public void testIfThen() { b.emitLoadArgument(0); b.endReturn(); - b.publish(); + b.publish(LANGUAGE); }); Assert.assertEquals(0L, root.call(-2L)); @@ -148,8 +150,8 @@ public void testIfThen() { @Test public void testSumLoop() { - // i = 0; j = 0; - // while ( i < arg0 ) { j = j + i; i = i + 1; } + // i = 0;j = 0; + // while ( i < arg0 ) { j = j + i;i = i + 1;} // return j; RootCallTarget root = parse(b -> { @@ -191,7 +193,8 @@ public void testSumLoop() { b.emitLoadLocal(locJ); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(45L, root.call(10L)); @@ -223,7 +226,8 @@ public void testTryCatch() { b.emitConstObject(0L); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(1L, root.call(-1L)); @@ -278,7 +282,8 @@ public void testVariableBoxingElim() { b.emitLoadLocal(local1); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(4950L, root.call()); @@ -304,7 +309,7 @@ private static void testOrdering(boolean expectException, RootCallTarget root, L @Test public void testFinallyTryBasic() { - // try { 1; } finally { 2; } + // try { 1;} finally { 2;} // expected 1, 2 RootCallTarget root = parse(b -> { @@ -324,7 +329,8 @@ public void testFinallyTryBasic() { b.emitConstObject(0L); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 2L); @@ -333,7 +339,7 @@ public void testFinallyTryBasic() { @Test public void testFinallyTryException() { - // try { 1; throw; 2; } finally { 3; } + // try { 1;throw;2;} finally { 3;} // expected: 1, 3 RootCallTarget root = parse(b -> { @@ -362,7 +368,8 @@ public void testFinallyTryException() { b.emitConstObject(0L); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(true, root, 1L, 3L); @@ -394,7 +401,8 @@ public void testFinallyTryReturn() { b.emitConstObject(3L); b.endAppenderOperation(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 2L, 1L); @@ -404,7 +412,7 @@ public void testFinallyTryReturn() { public void testFinallyTryBranchOut() { RootCallTarget root = parse(b -> { - // try { 1; goto lbl; 2; } finally { 3; } 4; lbl: 5; + // try { 1;goto lbl;2;} finally { 3;} 4;lbl: 5; // expected: 1, 3, 5 OperationLabel lbl = b.createLabel(); @@ -446,7 +454,8 @@ public void testFinallyTryBranchOut() { b.emitConstObject(0L); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 3L, 5L); @@ -456,7 +465,7 @@ public void testFinallyTryBranchOut() { public void testFinallyTryCancel() { RootCallTarget root = parse(b -> { - // try { 1; return; } finally { 2; goto lbl; } 3; lbl: 4; + // try { 1;return;} finally { 2;goto lbl;} 3;lbl: 4; // expected: 1, 2, 4 OperationLabel lbl = b.createLabel(); @@ -499,7 +508,8 @@ public void testFinallyTryCancel() { b.emitConstObject(0L); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 2L, 4L); @@ -509,7 +519,7 @@ public void testFinallyTryCancel() { public void testFinallyTryInnerCf() { RootCallTarget root = parse(b -> { - // try { 1; return; 2 } finally { 3; goto lbl; 4; lbl: 5; } + // try { 1;return;2 } finally { 3;goto lbl;4;lbl: 5;} // expected: 1, 3, 5 b.beginFinallyTry(); @@ -553,7 +563,8 @@ public void testFinallyTryInnerCf() { b.endBlock(); b.endFinallyTry(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 3L, 5L); @@ -563,7 +574,7 @@ public void testFinallyTryInnerCf() { public void testFinallyTryNestedTry() { RootCallTarget root = parse(b -> { - // try { try { 1; return; 2; } finally { 3; } } finally { 4; } + // try { try { 1;return;2;} finally { 3;} } finally { 4;} // expected: 1, 3, 4 b.beginFinallyTry(); @@ -600,7 +611,8 @@ public void testFinallyTryNestedTry() { b.endFinallyTry(); b.endFinallyTry(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 3L, 4L); @@ -610,7 +622,7 @@ public void testFinallyTryNestedTry() { public void testFinallyTryNestedFinally() { RootCallTarget root = parse(b -> { - // try { 1; return; 2; } finally { try { 3; return; 4; } finally { 5; } } + // try { 1;return;2;} finally { try { 3;return;4;} finally { 5;} } // expected: 1, 3, 5 b.beginFinallyTry(); @@ -656,7 +668,8 @@ public void testFinallyTryNestedFinally() { b.endBlock(); b.endFinallyTry(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 3L, 5L); @@ -666,7 +679,7 @@ public void testFinallyTryNestedFinally() { public void testFinallyTryNestedTryThrow() { RootCallTarget root = parse(b -> { - // try { try { 1; throw; 2; } finally { 3; } } finally { 4; } + // try { try { 1;throw;2;} finally { 3;} } finally { 4;} // expected: 1, 3, 4 b.beginFinallyTry(); @@ -701,7 +714,8 @@ public void testFinallyTryNestedTryThrow() { b.endFinallyTry(); b.endFinallyTry(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(true, root, 1L, 3L, 4L); @@ -711,7 +725,7 @@ public void testFinallyTryNestedTryThrow() { public void testFinallyTryNestedFinallyThrow() { RootCallTarget root = parse(b -> { - // try { 1; throw; 2; } finally { try { 3; throw; 4; } finally { 5; } } + // try { 1;throw;2;} finally { try { 3;throw;4;} finally { 5;} } // expected: 1, 3, 5 b.beginFinallyTry(); @@ -753,7 +767,8 @@ public void testFinallyTryNestedFinallyThrow() { b.endBlock(); b.endFinallyTry(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(true, root, 1L, 3L, 5L); @@ -762,7 +777,7 @@ public void testFinallyTryNestedFinallyThrow() { @Test public void testFinallyTryNoExceptReturn() { - // try { 1; return; 2; } finally noexcept { 3; } + // try { 1;return;2;} finally noexcept { 3;} // expected: 1, 3 RootCallTarget root = parse(b -> { @@ -789,7 +804,8 @@ public void testFinallyTryNoExceptReturn() { b.endBlock(); b.endFinallyTryNoExcept(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(false, root, 1L, 3L); @@ -798,7 +814,7 @@ public void testFinallyTryNoExceptReturn() { @Test public void testFinallyTryNoExceptException() { - // try { 1; throw; 2; } finally noexcept { 3; } + // try { 1;throw;2;} finally noexcept { 3;} // expected: 1 RootCallTarget root = parse(b -> { @@ -823,7 +839,8 @@ public void testFinallyTryNoExceptException() { b.endBlock(); b.endFinallyTryNoExcept(); - b.publish(); + + b.publish(LANGUAGE); }); testOrdering(true, root, 1L); @@ -835,7 +852,8 @@ public void testMetadata() { OperationRootNode node = parseNode(b -> { b.setTestData(value); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); @@ -849,7 +867,8 @@ public void testMetadataChange() { OperationRootNode node = parseNode(b -> { b.setTestData("some old value"); b.setTestData(value); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); @@ -859,7 +878,8 @@ public void testMetadataChange() { @Test public void testMetadataDefaultValue() { OperationRootNode node = parseNode(b -> { - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(TestOperations.TestData.getDefaultValue(), node.getMetadata(TestOperations.TestData)); @@ -880,7 +900,8 @@ public void testTeeLocal() { b.emitLoadLocal(local); b.endReturn(); - b.publish(); + + b.publish(LANGUAGE); }); Assert.assertEquals(1L, root.call()); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 3b3f7b543c0b..9b2434caac93 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -49,7 +49,6 @@ import org.junit.Test; import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationNodes; public class TestOperationsSerTest { @@ -57,29 +56,27 @@ public class TestOperationsSerTest { @Test public void testSer() { byte[] byteArray = createByteArray(); - TestRootNode root = deserialize(byteArray); + TestOperations root = deserialize(byteArray); Assert.assertEquals(3L, root.getCallTarget().call()); } - private static TestRootNode deserialize(byte[] byteArray) { + private static TestOperations deserialize(byte[] byteArray) { OperationNodes nodes2 = null; try { - nodes2 = TestOperationsBuilder.deserialize(OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), (ctx, buf2) -> { + nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), (ctx, buf2) -> { return buf2.getLong(); }); } catch (IOException e) { - assert false; + Assert.fail(); } - OperationRootNode node = nodes2.getNodes().get(0); - TestRootNode root = new TestRootNode(node); - return root; + return (TestOperations) nodes2.getNodes().get(0); } private static byte[] createByteArray() { - OperationNodes nodes = TestOperationsBuilder.create(OperationConfig.DEFAULT, b -> { + OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, b -> { b.beginReturn(); b.beginAddOperation(); b.emitConstObject(1L); @@ -87,7 +84,7 @@ private static byte[] createByteArray() { b.endAddOperation(); b.endReturn(); - b.publish(); + b.publish(null); }); boolean[] haveConsts = new boolean[2]; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java deleted file mode 100644 index 752d7fcbfb72..000000000000 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestRootNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.api.operation.test.example; - -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.OperationRootNode; - -public class TestRootNode extends RootNode { - - @Child private OperationRootNode node; - - TestRootNode(OperationRootNode node) { - super(null, node.createFrameDescriptor()); - this.node = node; - } - - @Override - public Object execute(VirtualFrame frame) { - return node.execute(frame); - } - -} From d65d0f8f08f7b9cd00aae5b291bad869d1d0209c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 23 Aug 2022 13:48:55 +0200 Subject: [PATCH 128/312] [wip] new rootnode api --- truffle/mx.truffle/suite.py | 12 +- .../test/example/BoxingOperationsTest.java | 9 +- .../test/example/TestOperations.java | 8 +- .../example/TestOperationsParserTest.java | 3 +- .../AbstractOperationsTruffleException.java | 22 ++- .../api/operation/OperationBuilder.java | 4 - .../api/operation/OperationRootNode.java | 127 +------------- .../expression/DSLExpressionResolver.java | 2 +- .../operations/OperationGeneratorUtils.java | 2 +- .../operations/OperationsCodeGenerator.java | 156 ++++++++++++++++-- .../operations/instructions/Instruction.java | 2 +- .../sl/operations/SLOperationRootNode.java | 24 ++- .../sl/parser/SLOperationsVisitor.java | 3 +- 13 files changed, 220 insertions(+), 154 deletions(-) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 68c91ecaf465..ec2ed171f6a6 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -312,7 +312,17 @@ "com.oracle.truffle.api.operation" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api", "com.oracle.truffle.api.library", "com.oracle.truffle.api.interop", "com.oracle.truffle.api.exception", "com.oracle.truffle.api.instrumentation", "TruffleJSON"], + "dependencies" : [ + "com.oracle.truffle.api", + "com.oracle.truffle.api.library", + "com.oracle.truffle.api.interop", + "com.oracle.truffle.api.exception", + "com.oracle.truffle.api.instrumentation", + "TruffleJSON", + ], + "requires" : [ + "jdk.unsupported", # sun.misc.Unsafe + ], "checkstyle" : "com.oracle.truffle.api", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "javaCompliance" : "11+", diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index c77a6ee3e3e7..0cb4336e5e87 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -53,6 +53,7 @@ import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameDescriptor.Builder; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; @@ -71,7 +72,7 @@ public class BoxingOperationsTest { private static RootCallTarget parse(OperationParser parser) { OperationRootNode node = parseNode(parser); - return node.getCallTarget(); + return ((RootNode) node).getCallTarget(); } private static OperationRootNode parseNode(OperationParser parser) { @@ -284,7 +285,7 @@ public void testLBEMultipleLoads() { b.publish(LANGUAGE); }); - RootCallTarget root = node.getCallTarget(); + RootCallTarget root = ((RootNode) node).getCallTarget(); for (int i = 0; i < 100; i++) { Assert.assertEquals(1L, root.call()); @@ -344,10 +345,10 @@ static long castLong(ReferenceTypeB b) { @GenerateOperations(languageClass = BoxingLanguage.class, boxingEliminationTypes = {boolean.class, int.class, long.class}) @SuppressWarnings("unused") -abstract class BoxingOperations extends OperationRootNode { +abstract class BoxingOperations extends RootNode implements OperationRootNode { protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) { - super(language, frameDescriptor); + super(language, frameDescriptor.build()); } protected BoxingOperations(TruffleLanguage language, FrameDescriptor frameDescriptor) { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 3744d3f843b1..48e615dddef0 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -50,10 +50,10 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.FrameDescriptor.Builder; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.GenerateOperations.Metadata; @@ -68,10 +68,10 @@ @GenerateUncached @GenerateAOT @OperationProxy(SomeOperationNode.class) -public abstract class TestOperations extends OperationRootNode { +public abstract class TestOperations extends RootNode implements OperationRootNode { - protected TestOperations(TruffleLanguage language, Builder frameDescriptor) { - super(language, frameDescriptor); + protected TestOperations(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { + super(language, frameDescriptor.build()); } protected TestOperations(TruffleLanguage language, FrameDescriptor frameDescriptor) { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index f606433e5aaf..409fe623aa8b 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -49,6 +49,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; @@ -63,7 +64,7 @@ public class TestOperationsParserTest { private static RootCallTarget parse(OperationParser builder) { OperationRootNode operationsNode = parseNode(builder); System.out.println(operationsNode.dump()); - return operationsNode.getCallTarget(); + return ((RootNode) operationsNode).getCallTarget(); } private static OperationRootNode parseNode(OperationParser builder) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java index ecb9ac3b67ba..3ea29c6acd5b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/AbstractOperationsTruffleException.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.source.SourceSection; public abstract class AbstractOperationsTruffleException extends AbstractTruffleException { @@ -73,9 +74,28 @@ public AbstractOperationsTruffleException(String message) { private static Node getLocation(Node location, int bci) { if (bci >= 0) { - return ((OperationRootNode) location).createLocationNode(bci); + return new SourceLocationNode(((OperationRootNode) location).getSourceSectionAtBci(bci)); } else { return location; } } + + private static class SourceLocationNode extends Node { + private final SourceSection location; + + SourceLocationNode(SourceSection location) { + this.location = location; + } + + @Override + public SourceSection getSourceSection() { + return location; + } + + @Override + public SourceSection getEncapsulatingSourceSection() { + return location; + } + + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java index 2bffaf13a640..3942f110a36c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationBuilder.java @@ -41,8 +41,4 @@ package com.oracle.truffle.api.operation; public abstract class OperationBuilder { - - protected static void setNodeNodes(OperationRootNode node, OperationNodes nodes) { - node.nodes = nodes; - } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index b41a142a44e1..6ce8ffc7c8b5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -40,141 +40,32 @@ */ package com.oracle.truffle.api.operation; -import java.lang.reflect.Field; import java.util.function.Function; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.nodes.NodeInterface; import com.oracle.truffle.api.source.SourceSection; -import sun.misc.Unsafe; - -public abstract class OperationRootNode extends RootNode { - - protected OperationNodes nodes; - - protected static final Unsafe UNSAFE; - - static { - Unsafe u; - try { - u = Unsafe.getUnsafe(); - } catch (SecurityException e) { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - u = (Unsafe) f.get(null); - } catch (Exception ex) { - throw new Error(ex); - } - } - UNSAFE = u; - } - - private static final int SOURCE_INFO_BCI_INDEX = 0; - private static final int SOURCE_INFO_START = 1; - private static final int SOURCE_INFO_LENGTH = 2; - private static final int SOURCE_INFO_STRIDE = 3; - - protected OperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); - } - - protected OperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { - this(language, frameDescriptor.build()); - } - - protected abstract int[] getSourceInfo(); - - @Override - public abstract Object execute(VirtualFrame frame); - - public final OperationNodes getOperationNodes() { - return nodes; - } - - public T getMetadata(MetadataKey key) { +public interface OperationRootNode extends NodeInterface { + default T getMetadata(MetadataKey key) { return key.getValue(this); } - protected static void setMetadataAccessor(MetadataKey key, Function getter) { + static void setMetadataAccessor(MetadataKey key, Function getter) { key.setGetter(getter); } // ------------------------------------ sources ------------------------------------ - @Override - public final SourceSection getSourceSection() { - int[] sourceInfo = getSourceInfo(); - Source[] sources = nodes.sources; + String dump(); - if (sourceInfo == null || sources == null) { - return null; - } + Object execute(VirtualFrame frame); - for (int i = 0; i < sourceInfo.length; i += SOURCE_INFO_STRIDE) { - if (sourceInfo[i + SOURCE_INFO_START] >= 0) { - // return the first defined source section - that one should encompass the entire - // function - return sources[sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16].createSection(sourceInfo[i + SOURCE_INFO_START], sourceInfo[i + SOURCE_INFO_LENGTH]); - } - } + SourceSection getSourceSectionAtBci(int bci); - return null; + default void executeProlog(VirtualFrame frame) { } - @ExplodeLoop - protected final SourceSection getSourceSectionAtBci(int bci) { - int[] sourceInfo = getSourceInfo(); - - if (sourceInfo == null) { - return null; - } - - int i; - // find the index of the first greater BCI - for (i = 0; i < sourceInfo.length; i += SOURCE_INFO_STRIDE) { - if ((sourceInfo[i + SOURCE_INFO_BCI_INDEX] & 0xffff) > bci) { - break; - } - } - - if (i == 0) { - return null; - } else { - i -= SOURCE_INFO_STRIDE; - int sourceIndex = sourceInfo[i + SOURCE_INFO_BCI_INDEX] >> 16; - if (sourceIndex < 0) { - return null; - } - - int sourceStart = sourceInfo[i + SOURCE_INFO_START]; - int sourceLength = sourceInfo[i + SOURCE_INFO_LENGTH]; - if (sourceStart < 0) { - return null; - } - return nodes.sources[sourceIndex].createSection(sourceStart, sourceLength); - } + default void executeEpilog(VirtualFrame frame, Object returnValue, Throwable throwable) { } - - public final Node createLocationNode(final int bci) { - return new Node() { - @Override - public SourceSection getSourceSection() { - return getSourceSectionAtBci(bci); - } - - @Override - public SourceSection getEncapsulatingSourceSection() { - return getSourceSectionAtBci(bci); - } - }; - } - - public abstract String dump(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index f03039af551d..3aaa0986929f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -233,7 +233,7 @@ private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); if (parseMode == ParseMode.OPERATION && "this".equals(name)) { - return new CodeVariableElement(ProcessorContext.getInstance().getTypes().OperationRootNode, "$this"); + return new CodeVariableElement(ProcessorContext.getInstance().getTypes().Node, "$this"); } switch (name) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 52befc14ea6e..e337a934475a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -116,7 +116,7 @@ public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElem } public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement().tree(bc).string("[").tree(bci).string("] = (short) (").tree(value).string(")").end().build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("unsafeWriteBytecode").tree(bc).tree(bci).tree(value).end(2).build(); } public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 22e60634945e..76f5591b687a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -76,13 +76,12 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import sun.misc.Unsafe; - public class OperationsCodeGenerator extends CodeTypeElementFactory { private ProcessorContext context; @@ -121,6 +120,8 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory RuntimeException sneakyThrow(Throwable e) throws E { //"); + met.createBuilder().statement("throw (E) e"); + GeneratorUtils.addSuppressWarnings(context, met, "unchecked"); + + return met; + } + private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNodeImpl) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "copy"); CodeTreeBuilder b = met.createBuilder(); @@ -607,6 +671,70 @@ private CodeExecutableElement createNodeImplExecuteAt() { return mExecuteAt; } + private static final int SOURCE_INFO_BCI_INDEX = 0; + private static final int SOURCE_INFO_START = 1; + private static final int SOURCE_INFO_LENGTH = 2; + private static final int SOURCE_INFO_STRIDE = 3; + + private CodeExecutableElement createNodeImplGetSourceSection() { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); + + CodeTreeBuilder b = met.createBuilder(); + + b.declaration("int[]", "sourceInfo", "this.sourceInfo"); + + b.startIf().string("sourceInfo == null").end().startBlock().returnNull().end(); + + b.declaration("int", "i", (CodeTree) null); + + b.startFor().string("i = 0; i < sourceInfo.length; i += " + SOURCE_INFO_STRIDE).end().startBlock(); + b.startIf().string("sourceInfo[i + " + SOURCE_INFO_START + "] >= 0").end().startBlock(); + b.statement("int sourceIndex = sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] >> 16"); + b.statement("int sourceStart = sourceInfo[i + " + SOURCE_INFO_START + "]"); + b.statement("int sourceLength = sourceInfo[i + " + SOURCE_INFO_LENGTH + "]"); + b.startReturn().string("nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)").end(); + b.end(); + b.end(); + + b.returnNull(); + + return met; + } + + private CodeExecutableElement createNodeImplGetSourceSectionAtBci() { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, "getSourceSectionAtBci"); + + CodeTreeBuilder b = met.createBuilder(); + + b.declaration("int[]", "sourceInfo", "this.sourceInfo"); + + b.startIf().string("sourceInfo == null").end().startBlock().returnNull().end(); + + b.declaration("int", "i", (CodeTree) null); + + b.startFor().string("i = 0; i < sourceInfo.length; i += " + SOURCE_INFO_STRIDE).end().startBlock(); + b.startIf().string("(sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] & 0xffff) > bci").end().startBlock(); + b.statement("break"); + b.end(); + b.end(); + + b.startIf().string("i == 0").end().startBlock(); + b.returnNull(); + b.end().startElseBlock(); + + b.statement("i -= " + SOURCE_INFO_STRIDE); + b.statement("int sourceIndex = sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] >> 16"); + b.startIf().string("sourceIndex < 0").end().startBlock().returnNull().end(); + b.statement("int sourceStart = sourceInfo[i + " + SOURCE_INFO_START + "]"); + b.startIf().string("sourceStart < 0").end().startBlock().returnNull().end(); + b.statement("int sourceLength = sourceInfo[i + " + SOURCE_INFO_LENGTH + "]"); + b.startReturn().string("nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)").end(); + + b.end(); + + return met; + } + private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, CodeTypeElement opNodesImpl, CodeTypeElement typExceptionHandler) { CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), OPERATION_BUILDER_IMPL_NAME, types.OperationBuilder); typBuilderImpl.setEnclosingElement(typOperationNodeImpl); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index fedf282a8e99..ec1533cbf921 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -374,7 +374,7 @@ public void setOpcodeIdField(CodeVariableElement opcodeIdField) { this.internalName = OperationGeneratorUtils.toScreamCase(name); this.numPushedValues = numPushedValues; - this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), context.getType(int.class), "INSTR_" + internalName); + this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), context.getType(short.class), "INSTR_" + internalName); opcodeIdField.createInitBuilder().string("" + id); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index 70b6856a620f..6baa666e5c52 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -64,8 +64,11 @@ import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.ShortCircuitOperation; import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; +import com.oracle.truffle.sl.nodes.SLExpressionNode; +import com.oracle.truffle.sl.nodes.SLRootNode; import com.oracle.truffle.sl.nodes.SLTypes; import com.oracle.truffle.sl.nodes.expression.SLAddNode; import com.oracle.truffle.sl.nodes.expression.SLDivNode; @@ -105,14 +108,29 @@ @OperationProxy(SLToBooleanNode.class) @ShortCircuitOperation(name = "SLAnd", booleanConverter = SLToBooleanNode.class, continueWhen = true) @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) -public abstract class SLOperationRootNode extends OperationRootNode { +public abstract class SLOperationRootNode extends SLRootNode implements OperationRootNode { protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { - super(language, frameDescriptor); + super((SLLanguage) language, frameDescriptor.build()); + } + + @Override + public SLExpressionNode getBodyNode() { + return null; + } + + @Override + public SourceSection getSourceSection() { + return getSourceSectionAtBci(0); + } + + @Override + public TruffleString getTSName() { + return getMetadata(MethodName); } protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); + super((SLLanguage) language, frameDescriptor); } @GenerateOperations.Metadata // diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 44861707aa52..68b3adf8f415 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -54,6 +54,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.debug.DebuggerTags; import com.oracle.truffle.api.instrumentation.StandardTags; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; @@ -114,7 +115,7 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Mon, 29 Aug 2022 06:50:29 +0200 Subject: [PATCH 129/312] [wip] more error reporting --- .../operations/OperationsParser.java | 52 +++++++++++++++++++ .../sl/operations/SLOperationRootNode.java | 8 +-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index f62bfd7deb01..d105a7bfca87 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -53,6 +53,7 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -63,6 +64,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; +import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.model.TypeSystemData; @@ -94,6 +96,56 @@ protected OperationsData parse(Element element, List mirror) { data.addError(typeElement, "Operations class must be a top-level class."); } + if (!ElementUtils.isAssignable(typeElement.asType(), types.RootNode)) { + data.addError(typeElement, "Operation class must directly or indirectly subclass RootNode"); + } + + if (!ElementUtils.isAssignable(typeElement.asType(), types.OperationRootNode)) { + data.addError(typeElement, "Operation class must directly or indirectly implement OperationRootNode"); + } + + if (data.hasErrors()) { + return data; + } + + boolean haveNonBuilderCtor = false; + boolean haveBuilderCtor = false; + + for (ExecutableElement ctor : ElementFilter.constructorsIn(typeElement.getEnclosedElements())) { + boolean isValid = ctor.getParameters().size() == 2; + + isValid = isValid && ElementUtils.isAssignable(ctor.getParameters().get(0).asType(), types.TruffleLanguage); + + isValid = isValid && (ctor.getModifiers().contains(Modifier.PUBLIC) || ctor.getModifiers().contains(Modifier.PROTECTED)); + + if (isValid) { + TypeMirror paramType2 = ctor.getParameters().get(1).asType(); + if (ElementUtils.isAssignable(paramType2, types.FrameDescriptor)) { + haveNonBuilderCtor = true; + } else if (ElementUtils.isAssignable(paramType2, context.getDeclaredType(TruffleTypes.FrameDescriptor_Name + ".Builder"))) { + haveBuilderCtor = true; + } else { + isValid = false; + } + } + + if (!isValid) { + data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder)"); + } + } + + if (!haveNonBuilderCtor) { + data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor) constructor"); + } + + if (!haveBuilderCtor) { + data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor.Builder) constructor"); + } + + if (data.hasErrors()) { + return data; + } + // find all metadata for (VariableElement ve : ElementFilter.fieldsIn(typeElement.getEnclosedElements())) { if (ElementUtils.findAnnotationMirror(ve, types.GenerateOperations_Metadata) != null) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index 6baa666e5c52..db897e391bf4 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -114,6 +114,10 @@ protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor.Build super((SLLanguage) language, frameDescriptor.build()); } + protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super((SLLanguage) language, frameDescriptor); + } + @Override public SLExpressionNode getBodyNode() { return null; @@ -129,10 +133,6 @@ public TruffleString getTSName() { return getMetadata(MethodName); } - protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super((SLLanguage) language, frameDescriptor); - } - @GenerateOperations.Metadata // public static final MetadataKey MethodName = new MetadataKey<>(SLStrings.EMPTY_STRING); From 17760e08ab4cce960bcc76c14708a03d3f442cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 29 Aug 2022 13:17:05 +0200 Subject: [PATCH 130/312] [wip] benchmark tests --- truffle/mx.truffle/suite.py | 8 +- .../api/operation/test/bml/BMLNode.java | 188 +++++++++++ .../operation/test/bml/BenchmarkLanguage.java | 136 ++++++++ .../api/operation/test/bml/BenmarkSimple.java | 297 ++++++++++++++++++ .../test/bml/ManualBytecodeNode.java | 262 +++++++++++++++ .../api/operation/test/bml/decisions.json | 7 + .../truffle/api/operation/Operation.java | 1 + .../truffle/api/operation/OperationNodes.java | 6 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 2 +- .../operations/OperationsCodeGenerator.java | 4 +- .../operations/OperationsContext.java | 7 +- .../operations/SingleOperationData.java | 9 + .../operations/SingleOperationParser.java | 18 +- .../instructions/LoadConstantInstruction.java | 46 ++- 14 files changed, 965 insertions(+), 26 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index ec2ed171f6a6..5ab51ad64f81 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -333,20 +333,18 @@ "subDir" : "src", "sourceDirs" : ["src"], "dependencies" : [ - "com.oracle.truffle.polyglot", - "com.oracle.truffle.api.test", - "com.oracle.truffle.api.operation", + "TRUFFLE_API", "mx:JUNIT", + "mx:JMH_1_21", ], "checkstyle" : "com.oracle.truffle.dsl.processor", "javaCompliance" : "11+", - "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], + "annotationProcessors" : ["mx:JMH_1_21", "TRUFFLE_DSL_PROCESSOR"], "workingSets" : "API,Truffle,Codegen,Test", "testProject" : True, "jacoco" : "exclude", }, - "com.oracle.truffle.api.dsl" : { "subDir" : "src", "sourceDirs" : ["src"], diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java new file mode 100644 index 000000000000..2971560e553b --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java @@ -0,0 +1,188 @@ +package com.oracle.truffle.api.operation.test.bml; + +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.NodeChild; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.ControlFlowException; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; + +public abstract class BMLNode extends Node { + + protected static final Object VOID = new Object(); + + public abstract Object execute(VirtualFrame frame); + + public abstract int executeInt(VirtualFrame frame) throws UnexpectedResultException; + + public abstract boolean executeBool(VirtualFrame frame) throws UnexpectedResultException; +} + +@SuppressWarnings("serial") +class ReturnException extends ControlFlowException { + private final Object value; + + ReturnException(Object value) { + this.value = value; + } + + public Object getValue() { + return value; + } +} + +class BMLRootNode extends RootNode { + + @Children private final BMLNode[] children; + + BMLRootNode(BenchmarkLanguage lang, int locals, BMLNode... children) { + super(lang, createFrame(locals)); + this.children = children; + } + + private static FrameDescriptor createFrame(int locals) { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(locals); + b.addSlots(locals, FrameSlotKind.Int); + return b.build(); + } + + @Override + @ExplodeLoop + public Object execute(VirtualFrame frame) { + try { + for (BMLNode child : children) { + child.execute(frame); + } + } catch (ReturnException ex) { + return ex.getValue(); + } + + throw new AssertionError(); + } + +} + +@NodeChild(type = BMLNode.class) +@NodeChild(type = BMLNode.class) +abstract class AddNode extends BMLNode { + @Specialization + public int addInts(int lhs, int rhs) { + return lhs + rhs; + } + + @Fallback + @SuppressWarnings("unused") + public Object fallback(Object lhs, Object rhs) { + throw new AssertionError(); + } +} + +@NodeChild(type = BMLNode.class) +@NodeChild(type = BMLNode.class) +abstract class LessNode extends BMLNode { + @Specialization + public boolean compareInts(int lhs, int rhs) { + return lhs < rhs; + } + + @Fallback + @SuppressWarnings("unused") + public Object fallback(Object lhs, Object rhs) { + throw new AssertionError(); + } +} + +@NodeChild(type = BMLNode.class) +abstract class StoreLocalNode extends BMLNode { + + private final int local; + + StoreLocalNode(int local) { + this.local = local; + } + + @Specialization + public Object storeValue(VirtualFrame frame, int value) { + frame.setInt(local, value); + return VOID; + } +} + +@NodeChild(type = BMLNode.class) +abstract class ReturnNode extends BMLNode { + @Specialization + public Object doReturn(Object value) { + throw new ReturnException(value); + } +} + +abstract class LoadLocalNode extends BMLNode { + private final int local; + + LoadLocalNode(int local) { + this.local = local; + } + + @Specialization + public int loadValue(VirtualFrame frame) { + return frame.getInt(local); + } +} + +class WhileNode extends BMLNode { + + @Child private BMLNode condition; + @Child private BMLNode body; + + public static WhileNode create(BMLNode condition, BMLNode body) { + return new WhileNode(condition, body); + } + + WhileNode(BMLNode condition, BMLNode body) { + this.condition = condition; + this.body = body; + + } + + @Override + public Object execute(VirtualFrame frame) { + try { + while (condition.executeBool(frame)) { + body.execute(frame); + } + return VOID; + } catch (UnexpectedResultException e) { + throw new AssertionError(); + } + } + + @Override + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { + throw new AssertionError(); + } + + @Override + public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { + throw new AssertionError(); + } + +} + +abstract class ConstNode extends BMLNode { + + private final int value; + + ConstNode(int value) { + this.value = value; + } + + @Specialization + public int doIt() { + return value; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java new file mode 100644 index 000000000000..b09273095ae9 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.test.bml; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleLanguage.Registration; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationRootNode; + +@Registration(id = "bm", name = "bm") +class BenchmarkLanguage extends TruffleLanguage { + + private static final Map> NAMES = new HashMap<>(); + + @Override + protected Object createContext(Env env) { + return new Object(); + } + + public static void registerName(String name, BiConsumer parser) { + registerName2(name, l -> { + OperationNodes nodes = BMOperationRootNodeGen.create(OperationConfig.DEFAULT, b -> parser.accept(l, b)); + return nodes.getNodes().get(nodes.getNodes().size() - 1).getCallTarget(); + }); + } + + public static void registerName2(String name, Function parser) { + NAMES.put(name, parser); + } + + @Override + protected CallTarget parse(ParsingRequest request) throws Exception { + String name = request.getSource().getCharacters().toString(); + if (!NAMES.containsKey(name)) { + throw new AssertionError("source not registered: " + name); + } + + return NAMES.get(name).apply(this); + } +} + +@GenerateOperations(// + languageClass = BenchmarkLanguage.class, // + boxingEliminationTypes = {int.class}, // + decisionsFile = "decisions.json") +abstract class BMOperationRootNode extends RootNode implements OperationRootNode { + protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { + super(language, frameDescriptor.build()); + } + + @Operation + static final class Add { + @Specialization + static int doInts(int left, int right) { + return left + right; + } + } + + @Operation + static final class AddQuickened { + @Specialization + static int doInts(int left, int right) { + return left + right; + } + } + + @Operation(disableBoxingElimination = true) + static final class AddBoxed { + @Specialization + static int doInts(int left, int right) { + return left + right; + } + } + + @Operation + static final class Less { + @Specialization + static boolean doInts(int left, int right) { + return left < right; + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java new file mode 100644 index 000000000000..86122cbd282f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.test.bml; + +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_ADD; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_CONST; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_JUMP; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_JUMP_FALSE; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_LD_LOC; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_LESS; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_RETURN; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_ST_LOC; + +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.Source; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.operation.OperationLocal; +import com.oracle.truffle.api.operation.test.bml.BMOperationRootNodeGen.Builder; + +@State(Scope.Benchmark) +public class BenmarkSimple extends BaseBenchmark { + + private static final int TARGET_AMOUNT = 100000; + + private static final String NAME_TEST_LOOP = "simple:test-loop"; + private static final String NAME_TEST_LOOP_NO_BE = "simple:test-loop-no-be"; + private static final String NAME_TEST_LOOP_QUICKEN = "simple:test-loop-quicken"; + private static final String NAME_MANUAL = "simple:manual"; + private static final String NAME_MANUAL_NO_BE = "simple:manual-no-be"; + private static final String NAME_AST = "simple:ast"; + + private static final Source SOURCE_TEST_LOOP = Source.create("bm", NAME_TEST_LOOP); + private static final Source SOURCE_TEST_LOOP_NO_BE = Source.create("bm", NAME_TEST_LOOP_NO_BE); + private static final Source SOURCE_TEST_LOOP_QUICKEN = Source.create("bm", NAME_TEST_LOOP_QUICKEN); + private static final Source SOURCE_MANUAL = Source.create("bm", NAME_MANUAL); + private static final Source SOURCE_MANUAL_NO_BE = Source.create("bm", NAME_MANUAL_NO_BE); + private static final Source SOURCE_AST = Source.create("bm", NAME_AST); + + private static final short[] BYTECODE = { + /* 00 */ OP_CONST, 0, 0, + /* 03 */ OP_ST_LOC, 2, + /* 05 */ OP_LD_LOC, 2, + /* 07 */ OP_CONST, (short) (TARGET_AMOUNT >> 16), (short) (TARGET_AMOUNT & 0xffff), + /* 10 */ OP_LESS, + /* 11 */ OP_JUMP_FALSE, 35, + /* 13 */ OP_LD_LOC, 2, + /* 15 */ OP_CONST, 0, 1, + /* 18 */ OP_ADD, + /* 19 */ OP_CONST, 0, 1, + /* 22 */ OP_ADD, + /* 23 */ OP_CONST, 0, 1, + /* 26 */ OP_ADD, + /* 27 */ OP_CONST, 0, 1, + /* 30 */ OP_ADD, + /* 31 */ OP_ST_LOC, 2, + /* 33 */ OP_JUMP, 5, + /* 35 */ OP_CONST, 0, 0, + /* 38 */ OP_RETURN + }; + + private Context context; + + private static final int MODE_NORMAL = 0; + private static final int MODE_NO_BE = 1; + private static final int MODE_QUICKEN = 2; + + /** + * The code is equivalent to: + * + *
+     * int i = 0;
+     * while (i < 100000) {
+     *     i = i + 1 + 1 + 1 + 1
+     * }
+     * return 0;
+     * 
+ */ + static { + BenchmarkLanguage.registerName(NAME_TEST_LOOP, (lang, b) -> { + createSimpleLoop(lang, b, MODE_NORMAL); + }); + BenchmarkLanguage.registerName(NAME_TEST_LOOP_NO_BE, (lang, b) -> { + createSimpleLoop(lang, b, MODE_NO_BE); + }); + BenchmarkLanguage.registerName(NAME_TEST_LOOP_QUICKEN, (lang, b) -> { + createSimpleLoop(lang, b, MODE_QUICKEN); + }); + BenchmarkLanguage.registerName2(NAME_MANUAL, lang -> { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); + b.addSlots(3, FrameSlotKind.Illegal); + ManualBytecodeNode node = new ManualBytecodeNode(lang, b.build(), BYTECODE); + return node.getCallTarget(); + }); + BenchmarkLanguage.registerName2(NAME_MANUAL_NO_BE, lang -> { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); + b.addSlots(3, FrameSlotKind.Illegal); + ManualBytecodeNodeNBE node = new ManualBytecodeNodeNBE(lang, b.build(), BYTECODE); + return node.getCallTarget(); + }); + BenchmarkLanguage.registerName2(NAME_AST, lang -> { + return new BMLRootNode(lang, 1, + StoreLocalNodeGen.create(0, ConstNodeGen.create(0)), + WhileNode.create( + LessNodeGen.create(LoadLocalNodeGen.create(0), ConstNodeGen.create(TARGET_AMOUNT)), + StoreLocalNodeGen.create(0, + AddNodeGen.create( + AddNodeGen.create( + AddNodeGen.create( + AddNodeGen.create( + LoadLocalNodeGen.create(0), + ConstNodeGen.create(1)), + ConstNodeGen.create(1)), + ConstNodeGen.create(1)), + ConstNodeGen.create(1)))), + ReturnNodeGen.create(ConstNodeGen.create(0))).getCallTarget(); + }); + } + + private static void beginAdd(Builder b, int mode) { + switch (mode) { + case MODE_NORMAL: + b.beginAdd(); + break; + case MODE_NO_BE: + b.beginAddBoxed(); + break; + case MODE_QUICKEN: + b.beginAddQuickened(); + break; + default: + throw new UnsupportedOperationException(); + } + } + + private static void endAdd(Builder b, int mode) { + switch (mode) { + case MODE_NORMAL: + b.endAdd(); + break; + case MODE_NO_BE: + b.endAddBoxed(); + break; + case MODE_QUICKEN: + b.endAddQuickened(); + break; + default: + throw new UnsupportedOperationException(); + } + } + + private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode) { + OperationLocal i = b.createLocal(); + + // i = 0 + b.beginStoreLocal(i); + b.emitConstObject(0); + b.endStoreLocal(); + + // while (i < 100000) { + b.beginWhile(); + b.beginLess(); + b.emitLoadLocal(i); + b.emitConstObject(100000); + b.endLess(); + + // i = i + 1 + 1 + 1 + 1 + b.beginStoreLocal(i); + beginAdd(b, mode); + beginAdd(b, mode); + beginAdd(b, mode); + beginAdd(b, mode); + b.emitLoadLocal(i); + b.emitConstObject(1); + endAdd(b, mode); + b.emitConstObject(1); + endAdd(b, mode); + b.emitConstObject(1); + endAdd(b, mode); + b.emitConstObject(1); + endAdd(b, mode); + b.endStoreLocal(); + + // } + b.endWhile(); + + // return 0 + b.beginReturn(); + b.emitConstObject(0); + b.endReturn(); + + b.publish(lang); + } + + @Setup(Level.Trial) + public void setup() { + context = Context.create(); + } + + @Setup(Level.Iteration) + public void enterContext() { + context.enter(); + } + + @TearDown(Level.Iteration) + public void leaveContext() { + context.leave(); + } + + @Benchmark + public void operation() { + context.eval(SOURCE_TEST_LOOP); + } + + @Benchmark + public void operationNoBe() { + context.eval(SOURCE_TEST_LOOP_NO_BE); + } + + @Benchmark + public void operationQuicken() { + context.eval(SOURCE_TEST_LOOP_QUICKEN); + } + + @Benchmark + public void manual() { + context.eval(SOURCE_MANUAL); + } + + @Benchmark + public void manualNoBE() { + context.eval(SOURCE_MANUAL_NO_BE); + } + + @Benchmark + public void ast() { + context.eval(SOURCE_AST); + } +} + +@Warmup(iterations = BaseBenchmark.WARMUP_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) +@Measurement(iterations = BaseBenchmark.MEASUREMENT_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) +@Fork(BaseBenchmark.FORKS) +class BaseBenchmark { + public static final int MEASUREMENT_ITERATIONS = 10; + public static final int WARMUP_ITERATIONS = 10; + public static final int ITERATION_TIME = 1; + public static final int FORKS = 1; +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java new file mode 100644 index 000000000000..8f669f17de2d --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.test.bml; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.nodes.RootNode; + +public class ManualBytecodeNode extends RootNode { + + @CompilationFinal(dimensions = 1) private short[] bc; + + static final short OP_JUMP = 1; + static final short OP_CONST = 2; + static final short OP_ADD = 3; + static final short OP_JUMP_FALSE = 4; + static final short OP_LESS = 5; + static final short OP_RETURN = 6; + static final short OP_ST_LOC = 7; + static final short OP_LD_LOC = 8; + + protected ManualBytecodeNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { + super(language, frameDescriptor); + this.bc = bc; + } + + @Override + public Object execute(VirtualFrame frame) { + return executeAt(frame, 0, 0); + } + + @BytecodeInterpreterSwitch + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + private Object executeAt(VirtualFrame frame, int startBci, int startSp) { + short[] localBc = bc; + int bci = startBci; + int sp = startSp; + + loop: while (true) { + short opcode = localBc[bci]; + CompilerAsserts.partialEvaluationConstant(opcode); + switch (opcode) { + // ( -- ) + case OP_JUMP: { + int nextBci = localBc[bci + 1]; + CompilerAsserts.partialEvaluationConstant(nextBci); + bci = nextBci; + continue loop; + } + // (i1 i2 -- i3) + case OP_ADD: { + int lhs = frame.getInt(sp - 2); + int rhs = frame.getInt(sp - 1); + frame.setInt(sp - 2, lhs + rhs); + sp -= 1; + bci += 1; + continue loop; + } + // ( -- i) + case OP_CONST: { + frame.setInt(sp, (localBc[bci + 1] << 16) | (localBc[bci + 2] & 0xffff)); + sp += 1; + bci += 3; + continue loop; + } + // (b -- ) + case OP_JUMP_FALSE: { + boolean cond = frame.getBoolean(sp - 1); + sp -= 1; + if (!cond) { + bci = localBc[bci + 1]; + continue loop; + } else { + bci += 2; + continue loop; + } + } + // (i1 i2 -- b) + case OP_LESS: { + int lhs = frame.getInt(sp - 2); + int rhs = frame.getInt(sp - 1); + frame.setBoolean(sp - 2, lhs < rhs); + sp -= 1; + bci += 1; + continue loop; + } + // (i -- ) + case OP_RETURN: { + return frame.getInt(sp - 1); + } + // (i -- ) + case OP_ST_LOC: { + frame.copy(sp - 1, localBc[bci + 1]); + sp -= 1; + bci += 2; + continue loop; + } + // ( -- i) + case OP_LD_LOC: { + frame.copy(localBc[bci + 1], sp); + sp += 1; + bci += 2; + continue loop; + } + default: + CompilerDirectives.shouldNotReachHere(); + } + } + } +} + +class ManualBytecodeNodeNBE extends RootNode { + + @CompilationFinal(dimensions = 1) private short[] bc; + + static final short OP_JUMP = 1; + static final short OP_CONST = 2; + static final short OP_ADD = 3; + static final short OP_JUMP_FALSE = 4; + static final short OP_LESS = 5; + static final short OP_RETURN = 6; + static final short OP_ST_LOC = 7; + static final short OP_LD_LOC = 8; + + protected ManualBytecodeNodeNBE(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { + super(language, frameDescriptor); + this.bc = bc; + } + + @Override + public Object execute(VirtualFrame frame) { + return executeAt(frame, 0, 0); + } + + @BytecodeInterpreterSwitch + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + private Object executeAt(VirtualFrame frame, int startBci, int startSp) { + short[] localBc = bc; + int bci = startBci; + int sp = startSp; + + loop: while (true) { + short opcode = localBc[bci]; + CompilerAsserts.partialEvaluationConstant(opcode); + switch (opcode) { + // ( -- ) + case OP_JUMP: { + int nextBci = localBc[bci + 1]; + CompilerAsserts.partialEvaluationConstant(nextBci); + bci = nextBci; + continue loop; + } + // (i1 i2 -- i3) + case OP_ADD: { + int lhs = (int) frame.getObject(sp - 2); + int rhs = (int) frame.getObject(sp - 1); + frame.setObject(sp - 2, lhs + rhs); + frame.clear(sp - 1); + sp -= 1; + bci += 1; + continue loop; + } + // ( -- i) + case OP_CONST: { + frame.setObject(sp, (localBc[bci + 1] << 16) | (localBc[bci + 2] & 0xffff)); + sp += 1; + bci += 3; + continue loop; + } + // (b -- ) + case OP_JUMP_FALSE: { + boolean cond = frame.getObject(sp - 1) == Boolean.TRUE; + frame.clear(sp - 1); + sp -= 1; + if (!cond) { + bci = localBc[bci + 1]; + continue loop; + } else { + bci += 2; + continue loop; + } + } + // (i1 i2 -- b) + case OP_LESS: { + int lhs = (int) frame.getObject(sp - 2); + int rhs = (int) frame.getObject(sp - 1); + frame.setObject(sp - 2, lhs < rhs); + frame.clear(sp - 1); + sp -= 1; + bci += 1; + continue loop; + } + // (i -- ) + case OP_RETURN: { + return frame.getObject(sp - 1); + } + // (i -- ) + case OP_ST_LOC: { + frame.copy(sp - 1, localBc[bci + 1]); + frame.clear(sp - 1); + sp -= 1; + bci += 2; + continue loop; + } + // ( -- i) + case OP_LD_LOC: { + frame.copy(localBc[bci + 1], sp); + sp += 1; + bci += 2; + continue loop; + } + default: + CompilerDirectives.shouldNotReachHere(); + } + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json new file mode 100644 index 000000000000..bf1b1438d956 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json @@ -0,0 +1,7 @@ +[ + { + "type": "Quicken", + "operation": "AddQuickened", + "specializations": ["Ints"] + } +] \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index 2c09200d2db6..dcabfc8538e4 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -48,4 +48,5 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Operation { + boolean disableBoxingElimination() default false; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 812157c7f88f..4ffb9b9eceb5 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; import com.oracle.truffle.api.source.Source; @@ -60,8 +61,9 @@ protected OperationNodes(OperationParser parse) { this.parse = parse; } - public List getNodes() { - return List.of(nodes); + @SuppressWarnings("unchecked") + public List getNodes() { + return (List) List.of(nodes); } public boolean hasSources() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 768965244616..f94c498936bb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -472,7 +472,7 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree CodeTree isResultBoxed = multiState.createNotContains(frameState, new Object[]{resultUnboxedState}); - if (uncached || typeName.equals("Object")) { + if (uncached || data.isDisableBoxingElimination() || typeName.equals("Object")) { b.startStatement(); b.startCall("$frame", "setObject"); b.string("$sp - " + destOffset); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 76f5591b687a..da0c8dcec21f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -332,9 +332,10 @@ private CodeVariableElement createSerializationContext() { CodeTypeElement createOperationNodeImpl() { String simpleName = m.getTemplateType().getSimpleName().toString() + "Gen"; CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PUBLIC_FINAL, simpleName, m.getTemplateType().asType()); - GeneratorUtils.addSuppressWarnings(context, typOperationNodeImpl, "unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"); + m.getOperationsContext().outerType = typOperationNodeImpl; + typOperationNodeImpl.getImplements().add(types.BytecodeOSRNode); CodeTypeElement typExceptionHandler = typOperationNodeImpl.add(createExceptionHandler()); @@ -808,6 +809,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, m.getOperationsContext().labelType = typLabelData.asType(); m.getOperationsContext().exceptionType = typExceptionHandler.asType(); + m.getOperationsContext().outerType = typOperationNodeImpl; typBuilderImpl.add(createBuilderImplCtor(opNodesImpl)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 29693bc4dd98..04aec4dc2e1d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -49,6 +49,7 @@ import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -88,6 +89,8 @@ public class OperationsContext { private final Map opDataNameMap = new HashMap<>(); private final OperationsData data; + public CodeTypeElement outerType; + private final Set operationNames = new HashSet<>(); public TypeMirror labelType; public TypeMirror exceptionType; @@ -158,9 +161,7 @@ private void createLoadArgument() { private void createLoadConstant() { loadConstantInstructions = new LoadConstantInstruction[FrameKind.values().length]; - for (FrameKind kind : data.getFrameKinds()) { - loadConstantInstructions[kind.ordinal()] = add(new LoadConstantInstruction(this, instructionId++, kind)); - } + loadConstantInstructions[FrameKind.OBJECT.ordinal()] = add(new LoadConstantInstruction(this, instructionId++, FrameKind.OBJECT)); add(new Operation.LoadConstant(this, operationId++, loadConstantInstructions)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 0048fc28532b..2633ab9bb87e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -65,6 +65,7 @@ public class SingleOperationData extends Template { private final Set throwDeclarations = new HashSet<>(); private final boolean isShortCircuit; private boolean shortCircuitContinueWhen; + private boolean disableBoxingElimination; public enum ParameterKind { STACK_VALUE, @@ -232,4 +233,12 @@ public void setShortCircuitContinueWhen(boolean shortCircuitContinueWhen) { this.shortCircuitContinueWhen = shortCircuitContinueWhen; } + public boolean isDisableBoxingElimination() { + return disableBoxingElimination; + } + + public void setDisableBoxingElimination(boolean disableBoxingElimination) { + this.disableBoxingElimination = disableBoxingElimination; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 3de81a5a1afc..f7c97bb724e9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -153,6 +153,9 @@ protected SingleOperationData parse(Element element, List mirr return null; } + AnnotationMirror mir = ElementUtils.findAnnotationMirror(mirror, getAnnotationType()); + AnnotationValue valDBE = ElementUtils.getAnnotationValue(mir, "disableBoxingElimination", true); + te = (TypeElement) element; if (isShortCircuit) { name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); @@ -161,6 +164,7 @@ protected SingleOperationData parse(Element element, List mirr } data = new SingleOperationData(context, te, null, parentData, name, false); + data.setDisableBoxingElimination((boolean) valDBE.getValue()); } List operationFunctions = new ArrayList<>(); @@ -245,7 +249,7 @@ protected SingleOperationData parse(Element element, List mirr } if (!isVariadic) { - addBoxingEliminationNodeChildAnnotations(props, clonedType); + addBoxingEliminationNodeChildAnnotations(data, props, clonedType); } if (parentData.isGenerateUncached()) { @@ -280,10 +284,10 @@ protected SingleOperationData parse(Element element, List mirr return data; } - private void addBoxingEliminationNodeChildAnnotations(MethodProperties props, CodeTypeElement ct) { + private void addBoxingEliminationNodeChildAnnotations(SingleOperationData data, MethodProperties props, CodeTypeElement ct) { int i = 0; int localI = 0; - CodeTypeElement childType = createRegularNodeChild(); + CodeTypeElement childType = createRegularNodeChild(!data.isDisableBoxingElimination()); CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); List anns = new ArrayList<>(); for (ParameterKind param : props.parameters) { @@ -455,15 +459,17 @@ private boolean isIgnoredParameter(VariableElement param) { private static final String GENERIC_EXECUTE_NAME = "Generic"; - private CodeTypeElement createRegularNodeChild() { + private CodeTypeElement createRegularNodeChild(boolean withBoxingElimination) { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); - for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { - result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); + if (withBoxingElimination) { + for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { + result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); + } } return result; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 7c9cca188b37..4dd2c6844c5e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -40,7 +40,12 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.EnumSet; + +import javax.lang.model.element.Modifier; + import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; @@ -60,16 +65,41 @@ public LoadConstantInstruction(OperationsContext ctx, int id, FrameKind kind) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); - b.variable(vars.sp); - b.tree(createGetArgument(vars)); - b.end(2); + if (!ctx.outerType.getEnclosedElements().stream().anyMatch(x -> x.getSimpleName().toString().equals("do_loadConstantObject"))) { + CodeExecutableElement metImpl = new CodeExecutableElement( + EnumSet.of(Modifier.PRIVATE, Modifier.STATIC), + context.getType(void.class), + "do_loadConstantObject"); - b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + metImpl.addParameter(vars.frame); + metImpl.addParameter(vars.bc); + metImpl.addParameter(vars.bci); + metImpl.addParameter(vars.sp); + metImpl.addParameter(vars.consts); - return b.build(); + CodeTreeBuilder b = metImpl.getBuilder(); + + b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.variable(vars.sp); + b.tree(createGetArgument(vars)); + b.end(2); + + ctx.outerType.add(metImpl); + } + + CodeTreeBuilder bOuter = CodeTreeBuilder.createBuilder(); + bOuter.startStatement().startCall("do_loadConstantObject"); + bOuter.variable(vars.frame); + bOuter.variable(vars.bc); + bOuter.variable(vars.bci); + bOuter.variable(vars.sp); + bOuter.variable(vars.consts); + bOuter.end(2); + + bOuter.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + + return bOuter.build(); } @@ -87,7 +117,7 @@ private CodeTree createGetArgument(ExecutionVariables vars) { @Override public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.REPLACE; + return BoxingEliminationBehaviour.DO_NOTHING; } @Override From edc56fa99e537bfa33ec7e5cd78ccaaa4be74cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 30 Aug 2022 15:01:51 +0200 Subject: [PATCH 131/312] [wip] yields and unsafes --- .../test/bml/ManualBytecodeNode.java | 38 +++- .../test/example/TestOperations.java | 2 +- .../example/TestOperationsParserTest.java | 28 +++ .../api/operation/ContinuationLocation.java | 13 ++ .../api/operation/ContinuationResult.java | 23 ++ .../api/operation/GenerateOperations.java | 2 + .../com/oracle/truffle/api/frame/Frame.java | 12 + .../truffle/api/impl/FrameWithoutBoxing.java | 213 +++++++++++++++++- .../truffle/api/impl/UnsafeFrameAccess.java | 182 +++++++++++++++ .../truffle/api/nodes/ExecutableNode.java | 4 + .../OperationsBytecodeNodeGeneratorPlugs.java | 9 +- .../operations/OperationsCodeGenerator.java | 101 ++++++++- .../operations/OperationsContext.java | 7 + .../processor/operations/OperationsData.java | 2 + .../operations/OperationsParser.java | 1 + .../instructions/CustomInstruction.java | 9 +- .../instructions/LoadArgumentInstruction.java | 8 +- .../instructions/LoadConstantInstruction.java | 3 +- .../instructions/LoadLocalInstruction.java | 6 +- .../instructions/StoreLocalInstruction.java | 6 +- .../instructions/YieldInstruction.java | 71 ++++++ 21 files changed, 718 insertions(+), 22 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java create mode 100644 truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java index 8f669f17de2d..8fac9473c51f 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -45,13 +45,16 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleSafepoint; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; import com.oracle.truffle.api.nodes.RootNode; -public class ManualBytecodeNode extends RootNode { +public class ManualBytecodeNode extends RootNode implements BytecodeOSRNode { @CompilationFinal(dimensions = 1) private short[] bc; @@ -74,6 +77,10 @@ public Object execute(VirtualFrame frame) { return executeAt(frame, 0, 0); } + private static class Counter { + int count; + } + @BytecodeInterpreterSwitch @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) private Object executeAt(VirtualFrame frame, int startBci, int startSp) { @@ -81,6 +88,8 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { int bci = startBci; int sp = startSp; + Counter loopCounter = new Counter(); + loop: while (true) { short opcode = localBc[bci]; CompilerAsserts.partialEvaluationConstant(opcode); @@ -89,6 +98,19 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { case OP_JUMP: { int nextBci = localBc[bci + 1]; CompilerAsserts.partialEvaluationConstant(nextBci); + if (nextBci <= bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll(this); + LoopNode.reportLoopCount(this, 256); + loopCounter.count = 0; + } + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { + Object osrResult = BytecodeOSRNode.tryOSR(this, (sp << 16) | nextBci, null, null, frame); + if (osrResult != null) { + return osrResult; + } + } + } bci = nextBci; continue loop; } @@ -152,6 +174,20 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { } } } + + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target >> 16, target & 0xffff); + } + + @CompilationFinal private Object osrMetadata; + + public Object getOSRMetadata() { + return osrMetadata; + } + + public void setOSRMetadata(Object osrMetadata) { + this.osrMetadata = osrMetadata; + } } class ManualBytecodeNodeNBE extends RootNode { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 48e615dddef0..a46518bdb124 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -64,7 +64,7 @@ import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.Variadic; -@GenerateOperations(languageClass = TestLanguage.class) +@GenerateOperations(languageClass = TestLanguage.class, enableYield = true) @GenerateUncached @GenerateAOT @OperationProxy(SomeOperationNode.class) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 409fe623aa8b..e31fee8f37da 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -50,6 +50,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.ContinuationResult; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; @@ -907,4 +908,31 @@ public void testTeeLocal() { Assert.assertEquals(1L, root.call()); } + + @Test + public void testYield() { + RootCallTarget root = parse(b -> { + b.beginYield(); + b.emitConstObject(1L); + b.endYield(); + + b.beginYield(); + b.emitConstObject(2L); + b.endYield(); + + b.beginReturn(); + b.emitConstObject(3L); + b.endReturn(); + + b.publish(LANGUAGE); + }); + + ContinuationResult r1 = (ContinuationResult) root.call(); + Assert.assertEquals(1L, r1.getResult()); + + ContinuationResult r2 = (ContinuationResult) r1.continueWith(null); + Assert.assertEquals(2L, r2.getResult()); + + Assert.assertEquals(3L, r2.continueWith(null)); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java new file mode 100644 index 000000000000..a3007dbef78a --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java @@ -0,0 +1,13 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.RootNode; + +public abstract class ContinuationLocation { + public abstract RootNode getRootNode(); + + // todo: create accessor + public final ContinuationResult createResult(VirtualFrame frame, Object result) { + return new ContinuationResult(this, frame.materialize(), result); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java new file mode 100644 index 000000000000..917013a6aa76 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java @@ -0,0 +1,23 @@ +package com.oracle.truffle.api.operation; + +import com.oracle.truffle.api.frame.MaterializedFrame; + +public final class ContinuationResult { + private final ContinuationLocation location; + private final MaterializedFrame frame; + private final Object result; + + ContinuationResult(ContinuationLocation location, MaterializedFrame frame, Object result) { + this.location = location; + this.frame = frame; + this.result = result; + } + + public Object continueWith(Object value) { + return location.getRootNode().getCallTarget().call(frame, value); + } + + public Object getResult() { + return result; + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index e7a5c992a418..8273dc28405a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -61,6 +61,8 @@ boolean forceTracing() default false; + boolean enableYield() default false; + @Retention(RetentionPolicy.SOURCE) @Target({ElementType.FIELD}) @interface Metadata { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java index 0dbbc3f17cf3..cb9dc9970857 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java @@ -771,4 +771,16 @@ default void clearObjectStatic(int slot) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnsupportedOperationException(); } + + /** + * Copies values from this frame to the given frame. The frames are required to have the same + * {@link Frame#getFrameDescriptor() frame descriptors}. + * + * @param slot the slot of the local variable + * @since 22.2 + */ + default void copyTo(Frame other, int start, int length) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnsupportedOperationException(); + } } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 63fa33af9673..8da3221d8039 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.FrameSlotTypeException; @@ -97,7 +98,7 @@ public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame private static final long[] EMPTY_LONG_ARRAY = {}; private static final byte[] EMPTY_BYTE_ARRAY = {}; - private static final Unsafe UNSAFE = initUnsafe(); + static final Unsafe UNSAFE = initUnsafe(); static { assert OBJECT_TAG == FrameSlotKind.Object.tag; @@ -208,6 +209,10 @@ public byte getTag(int slotIndex) { } } + byte unsafeGetTag(int slotIndex) { + return unsafeGetIndexedTag(slotIndex); + } + @SuppressWarnings({"unchecked", "unused"}) private static T unsafeCast(Object value, Class type, boolean condition, boolean nonNull, boolean exact) { return (T) value; @@ -275,84 +280,154 @@ public Object getObject(int slot) throws FrameSlotTypeException { return unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, condition, OBJECT_LOCATION); } + Object unsafeGetObject(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, OBJECT_TAG); + return unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, condition, OBJECT_LOCATION); + } + @Override public void setObject(int slot, Object value) { verifyIndexedSet(slot, OBJECT_TAG); unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); } + void unsafeSetObject(int slot, Object value) throws FrameSlotTypeException { + unsafeVerifyIndexedSet(slot, OBJECT_TAG); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + } + @Override public byte getByte(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, BYTE_TAG); return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + byte unsafeGetByte(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, BYTE_TAG); + return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); + } + @Override public void setByte(int slot, byte value) { verifyIndexedSet(slot, BYTE_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(value), PRIMITIVE_LOCATION); } + void unsafeSetByte(int slot, byte value) { + unsafeVerifyIndexedSet(slot, BYTE_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(value), PRIMITIVE_LOCATION); + } + @Override public boolean getBoolean(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, BOOLEAN_TAG); return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION) != 0; } + boolean unsafeGetBoolean(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, BOOLEAN_TAG); + return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION) != 0; + } + @Override public void setBoolean(int slot, boolean value) { verifyIndexedSet(slot, BOOLEAN_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), value ? 1L : 0L, PRIMITIVE_LOCATION); } + void unsafeSetBoolean(int slot, boolean value) { + unsafeVerifyIndexedSet(slot, BOOLEAN_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), value ? 1L : 0L, PRIMITIVE_LOCATION); + } + @Override public float getFloat(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, FLOAT_TAG); return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); } + float unsafeGetFloat(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, FLOAT_TAG); + return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); + } + @Override public void setFloat(int slot, float value) { verifyIndexedSet(slot, FLOAT_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(Float.floatToRawIntBits(value)), PRIMITIVE_LOCATION); } + void unsafeSetFloat(int slot, float value) { + unsafeVerifyIndexedSet(slot, FLOAT_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(Float.floatToRawIntBits(value)), PRIMITIVE_LOCATION); + } + @Override public long getLong(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, LONG_TAG); return unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + long unsafeGetLong(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, LONG_TAG); + return unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); + } + @Override public void setLong(int slot, long value) { verifyIndexedSet(slot, LONG_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), value, PRIMITIVE_LOCATION); } + void unsafeSetLong(int slot, long value) { + unsafeVerifyIndexedSet(slot, LONG_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), value, PRIMITIVE_LOCATION); + } + @Override public int getInt(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, INT_TAG); return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + int unsafeGetInt(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, INT_TAG); + return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); + } + @Override public void setInt(int slot, int value) { verifyIndexedSet(slot, INT_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(value), PRIMITIVE_LOCATION); } + void unsafeSetInt(int slot, int value) { + unsafeVerifyIndexedSet(slot, INT_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), extend(value), PRIMITIVE_LOCATION); + } + @Override public double getDouble(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, DOUBLE_TAG); return Double.longBitsToDouble(unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); } + double unsafeGetDouble(int slot) throws FrameSlotTypeException { + boolean condition = unsafeVerifyIndexedGet(slot, DOUBLE_TAG); + return Double.longBitsToDouble(unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); + } + @Override public void setDouble(int slot, double value) { verifyIndexedSet(slot, DOUBLE_TAG); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), Double.doubleToRawLongBits(value), PRIMITIVE_LOCATION); } + void unsafeSetDouble(int slot, double value) { + unsafeVerifyIndexedSet(slot, DOUBLE_TAG); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), Double.doubleToRawLongBits(value), PRIMITIVE_LOCATION); + } + @Override public void copy(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); @@ -363,6 +438,15 @@ public void copy(int srcSlot, int destSlot) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); } + void unsafeCopy(int srcSlot, int destSlot) { + byte tag = unsafeGetIndexedTag(srcSlot); + Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + unsafeVerifyIndexedSet(destSlot, tag); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); + } + @Override public void copyObject(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); @@ -375,6 +459,17 @@ public void copyObject(int srcSlot, int destSlot) { } } + void unsafeCopyObject(int srcSlot, int destSlot) { + byte tag = unsafeGetIndexedTag(srcSlot); + assert tag == OBJECT_TAG : "copyObject must be used with Object slots, not " + FrameSlotKind.fromTag(tag); + Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + unsafeVerifyIndexedSet(destSlot, tag); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + if (CompilerDirectives.inCompiledCode()) { + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), 0L, PRIMITIVE_LOCATION); + } + } + @Override public void copyPrimitive(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); @@ -385,6 +480,15 @@ public void copyPrimitive(int srcSlot, int destSlot) { unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); } + void unsafeCopyPrimitive(int srcSlot, int destSlot) { + byte tag = unsafeGetIndexedTag(srcSlot); + assert tag != OBJECT_TAG : "copyPrimitive must be used with non-Object slots"; + long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); + unsafeVerifyIndexedSet(destSlot, tag); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + } + public void swap(int first, int second) { byte firstTag = getIndexedTagChecked(first); Object firstValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); @@ -401,12 +505,33 @@ public void swap(int first, int second) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), firstPrimitiveValue, PRIMITIVE_LOCATION); } + void unsafeSwap(int first, int second) { + byte firstTag = unsafeGetIndexedTag(first); + Object firstValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + long firstPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), true, PRIMITIVE_LOCATION); + byte secondTag = unsafeGetIndexedTag(second); + Object secondValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + long secondPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), true, PRIMITIVE_LOCATION); + + verifyIndexedSet(first, secondTag); + verifyIndexedSet(second, firstTag); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, secondValue, OBJECT_LOCATION); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), secondPrimitiveValue, PRIMITIVE_LOCATION); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, firstValue, OBJECT_LOCATION); + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), firstPrimitiveValue, PRIMITIVE_LOCATION); + } + private void verifyIndexedSet(int slot, byte tag) { assert getIndexedTags()[slot] != STATIC_TAG : UNEXPECTED_NON_STATIC_WRITE; // this may raise an AIOOBE getIndexedTags()[slot] = tag; } + private void unsafeVerifyIndexedSet(int slot, byte tag) { + assert getIndexedTags()[slot] != STATIC_TAG : UNEXPECTED_NON_STATIC_WRITE; + UNSAFE.putByte(getIndexedTags(), Unsafe.ARRAY_BYTE_BASE_OFFSET + slot * Unsafe.ARRAY_BYTE_INDEX_SCALE, tag); + } + private boolean verifyIndexedGet(int slot, byte expectedTag) throws FrameSlotTypeException { byte actualTag = getIndexedTagChecked(slot); boolean condition = actualTag == expectedTag; @@ -417,6 +542,16 @@ private boolean verifyIndexedGet(int slot, byte expectedTag) throws FrameSlotTyp return condition; } + private boolean unsafeVerifyIndexedGet(int slot, byte expectedTag) throws FrameSlotTypeException { + byte actualTag = unsafeGetIndexedTag(slot); + boolean condition = actualTag == expectedTag; + if (!condition) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw frameSlotTypeException(); + } + return condition; + } + private byte getIndexedTagChecked(int slot) { // this may raise an AIOOBE byte tag = getIndexedTags()[slot]; @@ -424,41 +559,75 @@ private byte getIndexedTagChecked(int slot) { return tag; } + private byte unsafeGetIndexedTag(int slot) { + byte tag = UNSAFE.getByte(getIndexedTags(), Unsafe.ARRAY_BYTE_BASE_OFFSET + slot * Unsafe.ARRAY_BYTE_INDEX_SCALE); + assert tag != STATIC_TAG : UNEXPECTED_NON_STATIC_READ; + return tag; + } + @Override public boolean isObject(int slot) { return getTag(slot) == OBJECT_TAG; } + boolean unsafeIsObject(int slot) { + return unsafeGetTag(slot) == OBJECT_TAG; + } + @Override public boolean isByte(int slot) { return getTag(slot) == BYTE_TAG; } + boolean unsafeIsByte(int slot) { + return unsafeGetTag(slot) == BYTE_TAG; + } + @Override public boolean isBoolean(int slot) { return getTag(slot) == BOOLEAN_TAG; } + boolean unsafeIsBoolean(int slot) { + return unsafeGetTag(slot) == BOOLEAN_TAG; + } + @Override public boolean isInt(int slot) { return getTag(slot) == INT_TAG; } + boolean unsafeIsInt(int slot) { + return unsafeGetTag(slot) == INT_TAG; + } + @Override public boolean isLong(int slot) { return getTag(slot) == LONG_TAG; } + boolean unsafeIsLong(int slot) { + return unsafeGetTag(slot) == LONG_TAG; + } + @Override public boolean isFloat(int slot) { return getTag(slot) == FLOAT_TAG; } + boolean unsafeIsFloat(int slot) { + return unsafeGetTag(slot) == FLOAT_TAG; + } + @Override public boolean isDouble(int slot) { return getTag(slot) == DOUBLE_TAG; } + boolean unsafeIsDouble(int slot) { + return unsafeGetTag(slot) == DOUBLE_TAG; + } + @Override public boolean isStatic(int slot) { return getTag(slot) == STATIC_TAG; @@ -473,6 +642,14 @@ public void clear(int slot) { } } + void unsafeClear(int slot) { + unsafeVerifyIndexedSet(slot, ILLEGAL_TAG); + unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + if (CompilerDirectives.inCompiledCode()) { + unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), 0L, PRIMITIVE_LOCATION); + } + } + @Override public void setAuxiliarySlot(int slot, Object value) { if (auxiliarySlots.length <= slot) { @@ -597,4 +774,38 @@ public void clearObjectStatic(int slot) { assert indexedTags[slot] == STATIC_TAG : UNEXPECTED_STATIC_CLEAR; indexedLocals[slot] = null; } + + public void copyTo(Frame other, int offset, int length) { + FrameWithoutBoxing o = (FrameWithoutBoxing) other; + if (o.descriptor != descriptor || offset < 0 || offset + length >= getIndexedTags().length) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw frameSlotTypeException(); + } + + unsafeCopyTo(o, offset, length); + } + + void unsafeCopyTo(FrameWithoutBoxing o, int offset, int length) { + if (length == 0) { + return; + } + + System.arraycopy(getIndexedTags(), offset, o.getIndexedTags(), offset, length); + System.arraycopy(getIndexedLocals(), offset, o.getIndexedLocals(), offset, length); + System.arraycopy(getIndexedPrimitiveLocals(), offset, o.getIndexedPrimitiveLocals(), offset, length); + + // int offsetTag = Unsafe.ARRAY_BYTE_BASE_OFFSET + offset * Unsafe.ARRAY_BYTE_INDEX_SCALE; + // UNSAFE.copyMemory(getIndexedTags(), offsetTag, o.getIndexedTags(), offsetTag, length * + // Unsafe.ARRAY_BYTE_INDEX_SCALE); + // + // int offsetObj = Unsafe.ARRAY_OBJECT_BASE_OFFSET + offset * + // Unsafe.ARRAY_OBJECT_INDEX_SCALE; + // UNSAFE.copyMemory(getIndexedLocals(), offsetObj, o.getIndexedLocals(), offsetObj, length + // * Unsafe.ARRAY_OBJECT_INDEX_SCALE); + // + // int offsetLong = Unsafe.ARRAY_LONG_BASE_OFFSET + offset * Unsafe.ARRAY_LONG_INDEX_SCALE; + // UNSAFE.copyMemory(getIndexedPrimitiveLocals(), offsetLong, o.getIndexedPrimitiveLocals(), + // offsetLong, length * Unsafe.ARRAY_LONG_INDEX_SCALE); + } + } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java new file mode 100644 index 000000000000..c22be5d37b64 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.impl; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.frame.Frame; + +public abstract class UnsafeFrameAccess { + + public static UnsafeFrameAccess lookup() { + return INSTANCE; + } + + private static final UnsafeFrameAccess INSTANCE = new Impl(); + + public abstract byte unsafeGetTag(Frame frame, int slot); + + public abstract Object unsafeGetObject(Frame frame, int slot); + + public abstract int unsafeGetInt(Frame frame, int slot); + + public abstract long unsafeGetLong(Frame frame, int slot); + + public abstract double unsafeGetDouble(Frame frame, int slot); + + public abstract void unsafeSetObject(Frame frame, int slot, Object value); + + public abstract void unsafeSetInt(Frame frame, int slot, int value); + + public abstract void unsafeSetLong(Frame frame, int slot, long value); + + public abstract void unsafeSetDouble(Frame frame, int slot, double value); + + public abstract boolean unsafeIsObject(Frame frame, int slot); + + public abstract boolean unsafeIsInt(Frame frame, int slot); + + public abstract boolean unsafeIsLong(Frame frame, int slot); + + public abstract boolean unsafeIsDouble(Frame frame, int slot); + + public abstract void unsafeCopy(Frame frame, int srcSlot, int dstSlot); + + public abstract void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot); + + public abstract void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot); + + UnsafeFrameAccess() { + } + + private static final class Impl extends UnsafeFrameAccess { + + @SuppressWarnings("unchecked") + private static T unsafeCast(Object o) { + return (T) o; + } + + private static FrameWithoutBoxing castFrame(Frame frame) { + return CompilerDirectives.castExact(frame, FrameWithoutBoxing.class); + } + + @Override + public byte unsafeGetTag(Frame frame, int slot) { + return castFrame(frame).unsafeGetTag(slot); + } + + @Override + public Object unsafeGetObject(Frame frame, int slot) { + return castFrame(frame).unsafeGetObject(slot); + } + + @Override + public int unsafeGetInt(Frame frame, int slot) { + return castFrame(frame).unsafeGetInt(slot); + } + + @Override + public long unsafeGetLong(Frame frame, int slot) { + return castFrame(frame).unsafeGetLong(slot); + } + + @Override + public double unsafeGetDouble(Frame frame, int slot) { + return castFrame(frame).unsafeGetDouble(slot); + } + + @Override + public void unsafeSetObject(Frame frame, int slot, Object value) { + castFrame(frame).unsafeSetObject(slot, value); + } + + @Override + public void unsafeSetInt(Frame frame, int slot, int value) { + castFrame(frame).unsafeSetInt(slot, value); + } + + @Override + public void unsafeSetLong(Frame frame, int slot, long value) { + castFrame(frame).unsafeSetLong(slot, value); + } + + @Override + public void unsafeSetDouble(Frame frame, int slot, double value) { + castFrame(frame).unsafeSetDouble(slot, value); + } + + @Override + public boolean unsafeIsObject(Frame frame, int slot) { + return castFrame(frame).unsafeIsObject(slot); + } + + @Override + public boolean unsafeIsInt(Frame frame, int slot) { + return castFrame(frame).unsafeIsInt(slot); + } + + @Override + public boolean unsafeIsLong(Frame frame, int slot) { + return castFrame(frame).unsafeIsLong(slot); + } + + @Override + public boolean unsafeIsDouble(Frame frame, int slot) { + return castFrame(frame).unsafeIsDouble(slot); + } + + @Override + public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { + castFrame(frame).unsafeCopy(srcSlot, dstSlot); + } + + @Override + public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { + castFrame(frame).unsafeCopyObject(srcSlot, dstSlot); + } + + @Override + public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { + castFrame(frame).unsafeCopyPrimitive(srcSlot, dstSlot); + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java index 5808e95ee380..5fee2341eb97 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java @@ -166,4 +166,8 @@ public final C getLanguage(Class languageClass) { } return (C) language; } + + public final TruffleLanguage getLanguageInternal() { + return getLanguage(); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index f94c498936bb..66a9b0aa0de2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -474,7 +474,8 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree if (uncached || data.isDisableBoxingElimination() || typeName.equals("Object")) { b.startStatement(); - b.startCall("$frame", "setObject"); + b.startCall("UFA", "unsafeSetObject"); + b.string("$frame"); b.string("$sp - " + destOffset); b.tree(value); b.end(2); @@ -483,7 +484,8 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree b.startIf().tree(isResultBoxed).end().startBlock(); // { b.startStatement(); - b.startCall("$frame", "setObject"); + b.startCall("UFA", "unsafeSetObject"); + b.string("$frame"); b.string("$sp - " + destOffset); b.string("value"); b.end(2); @@ -491,7 +493,8 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree b.end().startElseBlock(); // { b.startStatement(); - b.startCall("$frame", "set" + typeName); + b.startCall("UFA", "unsafeSet" + typeName); + b.string("$frame"); b.string("$sp - " + destOffset); b.string("value"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index da0c8dcec21f..61d22dd7d03f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -350,6 +350,8 @@ CodeTypeElement createOperationNodeImpl() { genCtor.getModifiers().add(Modifier.PRIVATE); } + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getDeclaredType("com.oracle.truffle.api.impl.UnsafeFrameAccess"), "UFA = UnsafeFrameAccess.lookup()")); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME), "nodes"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(short[].class), "_bc"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(Object[].class), "_consts"))); @@ -359,6 +361,9 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxLocals"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); + if (m.enableYield) { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(arrayOf(new GeneratedTypeMirror("", "ContinuationRoot")), "yieldEntries"))); + } CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); @@ -474,6 +479,10 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(createSetResultUnboxed()); typOperationNodeImpl.add(createSetResultBoxedImpl()); typOperationNodeImpl.add(createCounter()); + if (m.enableYield) { + typOperationNodeImpl.add(createContinuationLocationImpl(typOperationNodeImpl)); + typOperationNodeImpl.add(createContinuationRoot(typOperationNodeImpl)); + } typOperationNodeImpl.add(createUnsafeFromBytecode()); typOperationNodeImpl.add(createUnsafeWriteBytecode()); typOperationNodeImpl.add(createConditionProfile()); @@ -485,6 +494,72 @@ CodeTypeElement createOperationNodeImpl() { return typOperationNodeImpl; } + private CodeTypeElement createContinuationRoot(CodeTypeElement typOperationNodeImpl) { + CodeTypeElement cr = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "ContinuationRoot"); + cr.setSuperClass(types.RootNode); + + cr.add(new CodeVariableElement(MOD_FINAL, typOperationNodeImpl.asType(), "root")); + cr.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "target")); + + cr.add(GeneratorUtils.createConstructorUsingFields(Set.of(), cr, + // gets the (language, frameDescriptor) ctor + ElementFilter.constructorsIn(((TypeElement) types.RootNode.asElement()).getEnclosedElements()).stream().filter(x -> x.getParameters().size() == 2).findFirst().get())); + + CodeExecutableElement mExecute = cr.add(GeneratorUtils.overrideImplement(types.RootNode, "execute")); + + CodeTreeBuilder b = mExecute.getBuilder(); + + b.statement("Object[] args = frame.getArguments()"); + b.startIf().string("args.length != 2").end().startBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("expected 2 arguments: (parentFrame, inputValue)")); + b.end(); + + b.declaration(types.MaterializedFrame, "parentFrame", "(MaterializedFrame) args[0]"); + b.declaration(context.getType(Object.class), "inputValue", "args[1]"); + + b.startIf().string("parentFrame.getFrameDescriptor() != frame.getFrameDescriptor()").end().startBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere("invalid continuation parent frame passed")); + b.end(); + + b.declaration("int", "sp", "(target >> 16) & 0xffff"); + b.statement("parentFrame.copyTo(frame, 0, sp - 1)"); + b.statement("frame.setObject(sp - 1, inputValue)"); + + b.statement("return root.executeAt(frame, target)"); + + return cr; + } + + private CodeTypeElement createContinuationLocationImpl(CodeTypeElement typOperationNodeImpl) { + DeclaredType superType = context.getDeclaredType("com.oracle.truffle.api.operation.ContinuationLocation"); + + CodeTypeElement cli = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "ContinuationLocationImpl"); + cli.setSuperClass(superType); + + cli.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "entry")); + cli.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "target")); + + cli.add(GeneratorUtils.createConstructorUsingFields(Set.of(), cli)); + + cli.add(compFinal(new CodeVariableElement(typOperationNodeImpl.asType(), "root"))); + + CodeExecutableElement mGetRootNode = cli.add(GeneratorUtils.overrideImplement(superType, "getRootNode")); + CodeTreeBuilder b = mGetRootNode.getBuilder(); + b.statement("ContinuationRoot node = root.yieldEntries[entry]"); + b.startIf().string("node == null").end().startBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.statement("node = new ContinuationRoot(root.getLanguageInternal(), root.getFrameDescriptor(), root, target)"); + b.statement("root.yieldEntries[entry] = node"); + b.end(); + b.statement("return node"); + + CodeExecutableElement mToString = cli.add(GeneratorUtils.override(context.getDeclaredType(Object.class), "toString")); + b = mToString.getBuilder(); + b.statement("return String.format(\"ContinuationLocation [index=%d, sp=%s, bci=%04x]\", entry, target >> 16, target & 0xffff)"); + + return cli; + } + private CodeExecutableElement createNodeExecute() { // todo: do not generate the prolog call if not implemented // todo: do not generate the epilog call and the try/catch if not implemented @@ -827,6 +902,11 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLabels")); } + if (m.enableYield) { + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "yieldCount")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationLocationImpl")), "yieldLocations = null")); + } + CodeVariableElement fldConstPool = typBuilderImpl.add( new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); fldConstPool.createInitBuilder().string("new ArrayList<>()"); @@ -2029,6 +2109,13 @@ private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperat b.statement("result._maxLocals = numLocals"); b.statement("result._maxStack = maxStack"); + if (m.enableYield) { + b.statement("result.yieldEntries = yieldCount > 0 ? new ContinuationRoot[yieldCount] : null"); + b.startFor().string("int i = 0; i < yieldCount; i++").end().startBlock(); + b.statement("yieldLocations[i].root = result"); + b.end(); + } + b.startIf().string("sourceBuilder != null").end().startBlock(); b.statement("result.sourceInfo = sourceBuilder.build()"); b.end(); @@ -2289,8 +2376,8 @@ private CodeExecutableElement createExpectObject() { CodeTreeBuilder b = mExpectObject.createBuilder(); - b.startIf().string("frame.isObject(slot)").end().startBlock(); // if { - b.startReturn().string("frame.getObject(slot)").end(); + b.startIf().string("UFA.unsafeIsObject(frame, slot)").end().startBlock(); // if { + b.startReturn().string("UFA.unsafeGetObject(frame, slot)").end(); b.end().startElseBlock(); // } else { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.startReturn().string("frame.getValue(slot)").end(); @@ -2312,14 +2399,14 @@ private CodeExecutableElement createExpectPrimitive(FrameKind kind) { b.statement("System.out.println(\" [SR] stack read @ \" + slot + \" : \" + frame.getValue(slot) + \"\")"); } - b.startSwitch().string("frame.getTag(slot)").end().startBlock(); // switch { + b.startSwitch().string("UFA.unsafeGetTag(frame, slot)").end().startBlock(); // switch { b.startCase().string(kind.ordinal() + " /* " + kind + " */").end().startCaseBlock(); // { - b.startReturn().string("frame.get" + kind.getFrameName() + "(slot)").end(); + b.startReturn().string("UFA.unsafeGet" + kind.getFrameName() + "(frame, slot)").end(); b.end(); // } b.startCase().string(FrameKind.OBJECT.ordinal() + " /* OBJECT */").end().startCaseBlock(); // { - b.declaration("Object", "value", "frame.getObject(slot)"); + b.declaration("Object", "value", "UFA.unsafeGetObject(frame, slot)"); b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); b.startReturn().string("(" + kind.getTypeName() + ") value").end(); @@ -2480,6 +2567,10 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("numConditionProfiles = 0"); b.statement("exceptionHandlers.clear()"); + if (m.enableYield) { + b.statement("yieldCount = 0"); + } + for (OperationMetadataData metadata : m.getMetadatas()) { b.startAssign("metadata_" + metadata.getName()).string("null").end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 04aec4dc2e1d..f17b997e9726 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -49,7 +49,9 @@ import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -69,6 +71,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.YieldInstruction; public class OperationsContext { @@ -133,6 +136,10 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); + if (data.enableYield) { + add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(instructionId++)))); + } + add(new Operation.Source(this, operationId++)); add(new Operation.SourceSection(this, operationId++)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 4f8e84fe4c93..4ab28f2bfb77 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -78,6 +78,8 @@ public class OperationsData extends Template { private int numTosSlots; + public boolean enableYield; + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index d105a7bfca87..dc9c7a8a76a8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -86,6 +86,7 @@ protected OperationsData parse(Element element, List mirror) { OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); data.languageClass = (DeclaredType) ElementUtils.getAnnotationValue(generateOperationsMirror, "languageClass").getValue(); + data.enableYield = (boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "enableYield", true).getValue(); // check basic declaration properties if (!typeElement.getModifiers().contains(Modifier.ABSTRACT)) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index ee26a3751025..23e5e95597a0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -168,13 +168,13 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { String inputName = "input_" + inputIndex; switch (kind) { case STACK_VALUE: - b.declaration("Object", inputName, "$frame.getObject($sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); + b.declaration("Object", inputName, "UFA.unsafeGetObject($frame, $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VARIADIC: b.declaration("Object[]", inputName, "new Object[numVariadics]"); b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); - b.startStatement().string(inputName, "[varIndex] = $frame.getObject($sp - numVariadics + varIndex)").end(); + b.startStatement().string(inputName, "[varIndex] = UFA.unsafeGetObject($frame, $sp - numVariadics + varIndex)").end(); b.end(); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; @@ -210,7 +210,8 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + " + numPushedValues).end(); if (numPushedValues > 0) { - b.startStatement().startCall(vars.frame, "setObject"); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.string("$frame"); b.string("$sp - 1"); b.string("result"); b.end(2); @@ -229,7 +230,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (uncached) { for (int i = numPopStatic(); i > 0; i--) { - b.string("$frame.getObject($sp - " + i + ")"); + b.string("UFA.unsafeGetObject($frame, $sp - " + i + ")"); } addLocalRefs(b, vars); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 7d03705de86a..828fba059d94 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; @@ -75,20 +76,23 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("Object", "value", createGetValue(vars)); if (kind == FrameKind.OBJECT) { - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.frame); b.variable(vars.sp); b.string("value"); b.end(2); } else { b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); // { - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.frame); b.variable(vars.sp); b.string("(", kind.getTypeName(), ") value"); b.end(2); // } b.end().startElseBlock(); // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.startStatement().startCall(vars.frame, "setObject"); b.variable(vars.sp); b.string("value"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 4dd2c6844c5e..b75b182be2c9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -80,7 +80,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = metImpl.getBuilder(); - b.startStatement().startCall(vars.frame, "set" + kind.getFrameName()); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.frame); b.variable(vars.sp); b.tree(createGetArgument(vars)); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 3f4bdeaafad6..1b1a369d648c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -78,14 +78,16 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { private static final boolean USE_SPEC_FRAME_COPY = true; private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyObject" : "copy"); + b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); + b.variable(vars.frame); b.string("localIdx"); b.variable(vars.sp); b.end(2); } private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyPrimitive" : "copy"); + b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyPrimitive" : "unsafeCopy"); + b.variable(vars.frame); b.string("localIdx"); b.variable(vars.sp); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index f59a68bef0d3..b30288673087 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -75,14 +75,16 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private static final boolean USE_SPEC_FRAME_COPY = true; private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyPrimitive" : "copy"); + b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyPrimitive" : "unsafeCopy"); + b.variable(vars.frame); b.string("sourceSlot"); b.string("localIdx"); b.end(2); } private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, USE_SPEC_FRAME_COPY ? "copyObject" : "copy"); + b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); + b.variable(vars.frame); b.string("sourceSlot"); b.string("localIdx"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java new file mode 100644 index 000000000000..281c12791c8c --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -0,0 +1,71 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; + +public class YieldInstruction extends Instruction { + + private static final String CONTINUATION_POINT = "continuation-point"; + + public YieldInstruction(int id) { + super("yield", id, 1); + addPopSimple("value"); + addConstant(CONTINUATION_POINT, null); + } + + @Override + protected CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments args) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startIf().string("yieldLocations == null").end().startBlock(); + b.statement("yieldLocations = new ContinuationLocationImpl[8]"); + b.end().startElseIf().string("yieldLocations.length <= yieldCount").end().startBlock(); + b.statement("yieldLocations = Arrays.copyOf(yieldLocations, yieldCount * 2)"); + b.end(); + return b.build(); + } + + @Override + protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { + if (!CONTINUATION_POINT.equals(marker) && index != 0) { + throw new AssertionError("what constant?"); + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.string("yieldLocations[yieldCount] = "); + + b.startNew("ContinuationLocationImpl"); + b.string("yieldCount++"); + b.startGroup().string("(curStack << 16) | (bci + ").tree(createLength()).string(")").end(); + b.end(); + return b.build(); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startStatement().string("ContinuationLocationImpl cont = (ContinuationLocationImpl) $consts[").tree(createConstantIndex(vars, 0)).string("]").end(); + b.statement("$frame.setObject($sp - 1, cont.createResult($frame, $frame.getObject($sp - 1)))"); + + b.startReturn().string("(($sp - 1) << 16) | 0xffff").end(); + + return b.build(); + } + + @Override + public boolean isBranchInstruction() { + return true; + } + + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; + } + +} From 9979324e6885171de1099c14581ab04b8f784cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 30 Aug 2022 15:55:46 +0200 Subject: [PATCH 132/312] [wip] we are C now --- .../truffle/api/impl/UnsafeFrameAccess.java | 58 +++++++++++++++++- .../dsl/processor/generator/BitSet.java | 22 +++---- .../generator/FlatNodeGenFactory.java | 2 +- .../generator/NodeGeneratorPlugs.java | 2 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 12 ++-- .../operations/OperationsCodeGenerator.java | 35 ++--------- .../operations/OperationsContext.java | 2 - .../instructions/BranchInstruction.java | 2 +- .../ConditionalBranchInstruction.java | 6 +- .../instructions/CustomInstruction.java | 2 +- .../operations/instructions/Instruction.java | 60 ++++++++++++------- .../instructions/LoadArgumentInstruction.java | 2 +- .../instructions/LoadConstantInstruction.java | 5 +- .../instructions/LoadLocalInstruction.java | 2 +- .../instructions/ShortCircuitInstruction.java | 2 +- .../instructions/StoreLocalInstruction.java | 4 +- .../instructions/ThrowInstruction.java | 2 +- 17 files changed, 134 insertions(+), 86 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index c22be5d37b64..8280e85dbf1c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -43,6 +43,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.Frame; +import sun.misc.Unsafe; + public abstract class UnsafeFrameAccess { public static UnsafeFrameAccess lookup() { @@ -51,10 +53,22 @@ public static UnsafeFrameAccess lookup() { private static final UnsafeFrameAccess INSTANCE = new Impl(); + public abstract short unsafeShortArrayRead(short[] arr, int index); + + public abstract void unsafeShortArrayWrite(short[] arr, int index, short value); + + public abstract int unsafeIntArrayRead(int[] arr, int index); + + public abstract void unsafeIntArrayWrite(int[] arr, int index, int value); + + public abstract T unsafeObjectArrayRead(T[] arr, int index); + public abstract byte unsafeGetTag(Frame frame, int slot); public abstract Object unsafeGetObject(Frame frame, int slot); + public abstract boolean unsafeGetBoolean(Frame frame, int slot); + public abstract int unsafeGetInt(Frame frame, int slot); public abstract long unsafeGetLong(Frame frame, int slot); @@ -63,6 +77,8 @@ public static UnsafeFrameAccess lookup() { public abstract void unsafeSetObject(Frame frame, int slot, Object value); + public abstract void unsafeSetBoolean(Frame frame, int slot, boolean value); + public abstract void unsafeSetInt(Frame frame, int slot, int value); public abstract void unsafeSetLong(Frame frame, int slot, long value); @@ -71,6 +87,8 @@ public static UnsafeFrameAccess lookup() { public abstract boolean unsafeIsObject(Frame frame, int slot); + public abstract boolean unsafeIsBoolean(Frame frame, int slot); + public abstract boolean unsafeIsInt(Frame frame, int slot); public abstract boolean unsafeIsLong(Frame frame, int slot); @@ -88,9 +106,30 @@ public static UnsafeFrameAccess lookup() { private static final class Impl extends UnsafeFrameAccess { + @Override + public short unsafeShortArrayRead(short[] arr, int index) { + return FrameWithoutBoxing.UNSAFE.getShort(arr, Unsafe.ARRAY_SHORT_BASE_OFFSET + index * Unsafe.ARRAY_SHORT_INDEX_SCALE); + } + + @Override + public void unsafeShortArrayWrite(short[] arr, int index, short value) { + FrameWithoutBoxing.UNSAFE.putShort(arr, Unsafe.ARRAY_SHORT_BASE_OFFSET + index * Unsafe.ARRAY_SHORT_INDEX_SCALE, value); + } + + @Override + public int unsafeIntArrayRead(int[] arr, int index) { + return FrameWithoutBoxing.UNSAFE.getInt(arr, Unsafe.ARRAY_INT_BASE_OFFSET + index * Unsafe.ARRAY_INT_INDEX_SCALE); + } + + @Override + public void unsafeIntArrayWrite(int[] arr, int index, int value) { + FrameWithoutBoxing.UNSAFE.putInt(arr, Unsafe.ARRAY_INT_BASE_OFFSET + index * Unsafe.ARRAY_INT_INDEX_SCALE, value); + } + + @Override @SuppressWarnings("unchecked") - private static T unsafeCast(Object o) { - return (T) o; + public T unsafeObjectArrayRead(T[] arr, int index) { + return (T) FrameWithoutBoxing.UNSAFE.getObject(arr, Unsafe.ARRAY_OBJECT_BASE_OFFSET + index * Unsafe.ARRAY_OBJECT_INDEX_SCALE); } private static FrameWithoutBoxing castFrame(Frame frame) { @@ -112,6 +151,11 @@ public int unsafeGetInt(Frame frame, int slot) { return castFrame(frame).unsafeGetInt(slot); } + @Override + public boolean unsafeGetBoolean(Frame frame, int slot) { + return castFrame(frame).unsafeGetBoolean(slot); + } + @Override public long unsafeGetLong(Frame frame, int slot) { return castFrame(frame).unsafeGetLong(slot); @@ -132,6 +176,11 @@ public void unsafeSetInt(Frame frame, int slot, int value) { castFrame(frame).unsafeSetInt(slot, value); } + @Override + public void unsafeSetBoolean(Frame frame, int slot, boolean value) { + castFrame(frame).unsafeSetBoolean(slot, value); + } + @Override public void unsafeSetLong(Frame frame, int slot, long value) { castFrame(frame).unsafeSetLong(slot, value); @@ -147,6 +196,11 @@ public boolean unsafeIsObject(Frame frame, int slot) { return castFrame(frame).unsafeIsObject(slot); } + @Override + public boolean unsafeIsBoolean(Frame frame, int slot) { + return castFrame(frame).unsafeIsBoolean(slot); + } + @Override public boolean unsafeIsInt(Frame frame, int slot) { return castFrame(frame).unsafeIsInt(slot); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 199acefbde77..d9021d5508ee 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -138,11 +138,11 @@ private CodeTree createLocalReference(FrameState frameState) { } } - public CodeTree createReference(FrameState frameState) { + public CodeTree createReference(FrameState frameState, boolean write) { CodeTree ref = createLocalReference(frameState); if (ref == null) { if (plugs != null) { - ref = plugs.createBitSetReference(this); + ref = plugs.createBitSetReference(this, write); } else { ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); } @@ -185,7 +185,7 @@ public CodeTree createLoad(FrameState frameState) { LocalVariable var = new LocalVariable(type, name, null); CodeTreeBuilder init = builder.create(); if (plugs != null) { - init.tree(plugs.createBitSetReference(this)); + init.tree(plugs.createBitSetReference(this, false)); } else { init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); } @@ -228,18 +228,18 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec public CodeTree createIsEmpty(FrameState frameState) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.tree(createReference(frameState)).string(" == 0"); + builder.tree(createReference(frameState, false)).string(" == 0"); return builder.build(); } private CodeTree createMaskedReference(FrameState frameState, long maskedElements) { if (maskedElements == this.allMask) { // no masking needed - return createReference(frameState); + return createReference(frameState, false); } else { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); // masking needed we use the state bitset for guards as well - builder.string("(").tree(createReference(frameState)).string(" & ").string(formatMask(maskedElements)).string(")"); + builder.string("(").tree(createReference(frameState, false)).string(" & ").string(formatMask(maskedElements)).string(")"); return builder.build(); } } @@ -358,7 +358,7 @@ public CodeTree createSet(FrameState frameState, Object[] elements, boolean valu if (!hasLocal && elements.length == 0) { return valueBuilder.build(); } - valueBuilder.tree(createReference(frameState)); + valueBuilder.tree(createReference(frameState, true)); if (elements.length > 0) { if (value) { valueBuilder.string(" | "); @@ -378,7 +378,7 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu builder.startStatement(); if (persist) { if (plugs != null) { - builder.tree(plugs.createBitSetReference(this)).string(" = "); + builder.tree(plugs.createBitSetReference(this, true)).string(" = "); } else { builder.string("this.", name, "_ = "); } @@ -389,7 +389,7 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu builder.tree(localReference).string(" = "); } } else { - builder.tree(createReference(frameState)).string(" = "); + builder.tree(createReference(frameState, true)).string(" = "); } CodeTree value = valueTree; @@ -406,12 +406,12 @@ public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree int offset = getStateOffset(element); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); - builder.tree(createReference(frameState)).string(" = "); + builder.tree(createReference(frameState, true)).string(" = "); if (type.getKind() != TypeKind.INT) { builder.cast(type); } builder.startParantheses(); - builder.tree(createReference(frameState)); + builder.tree(createReference(frameState, false)); builder.string(" | ("); if (capacity > 32) { builder.string("(long) "); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index b6be929de117..2b428981dbdd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -2239,7 +2239,7 @@ private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction rep builder.declaration(s.getType(), s.getNewName(), s.createMaskedReference(frameState, reachableSpecializationsReportingPolymorphism())); } if (requiresExclude) { - builder.declaration(exclude.getType(), NEW_EXCLUDE, exclude.createReference(frameState)); + builder.declaration(exclude.getType(), NEW_EXCLUDE, exclude.createReference(frameState, false)); } } builder.startIf(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index a6e7726faef5..67ca1d6c1e8b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -75,7 +75,7 @@ public interface NodeGeneratorPlugs { TypeMirror getBitSetType(TypeMirror defaultType); - CodeTree createBitSetReference(BitSet bits); + CodeTree createBitSetReference(BitSet bits, boolean write); CodeTree transformValueBeforePersist(CodeTree tree); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 66a9b0aa0de2..f62c1f231cc7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -238,8 +238,8 @@ public TypeMirror getBitSetType(TypeMirror defaultType) { } @Override - public CodeTree createBitSetReference(BitSet bits) { - return cinstr.createStateBitsIndex(dummyVariables, cinstr.addStateBits(bits)); + public CodeTree createBitSetReference(BitSet bits, boolean write) { + return cinstr.createStateBitsIndex(dummyVariables, cinstr.addStateBits(bits), write); } @Override @@ -278,7 +278,9 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea targetField = dummyVariables.consts; } - b.variable(targetField).string("["); + b.startCall("UFA", "unsafeObjectArrayRead"); + b.variable(targetField); + b.startGroup(); if (frame == null || !frame.getBoolean("definedOffsets", false)) { if (isChild) { @@ -300,7 +302,7 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea } - b.string(" + " + index + "]"); + b.string(" + " + index).end(); if (doCast) { b.end(); @@ -745,7 +747,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed(cinstr.createPopIndexedIndex(dummyVariables, i), CodeTreeBuilder.singleString("type" + i))); + b.tree(OperationGeneratorUtils.callSetResultBoxed(cinstr.createPopIndexedIndex(dummyVariables, i, false), CodeTreeBuilder.singleString("type" + i))); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 61d22dd7d03f..b9254b1ea995 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -590,17 +590,7 @@ private CodeExecutableElement createUnsafeFromBytecode() { CodeTreeBuilder b = met.createBuilder(); b.startReturn(); - if (OperationGeneratorFlags.USE_UNSAFE) { - b.startCall("UNSAFE", "getShort"); - b.string("bc"); - b.startGroup(); - b.staticReference(TYPE_UNSAFE, "ARRAY_SHORT_BASE_OFFSET"); - b.string(" + "); - b.staticReference(TYPE_UNSAFE, "ARRAY_SHORT_INDEX_SCALE"); - b.string(" * index").end(2); - } else { - b.string("bc[index]"); - } + b.string("UFA.unsafeShortArrayRead(bc, index)"); b.end(); return met; @@ -613,20 +603,7 @@ private CodeExecutableElement createUnsafeWriteBytecode() { met.addParameter(new CodeVariableElement(context.getType(short.class), "value")); CodeTreeBuilder b = met.createBuilder(); - b.startStatement(); - if (OperationGeneratorFlags.USE_UNSAFE) { - b.startCall("UNSAFE", "putShort"); - b.string("bc"); - b.startGroup(); - b.staticReference(TYPE_UNSAFE, "ARRAY_SHORT_BASE_OFFSET"); - b.string(" + "); - b.staticReference(TYPE_UNSAFE, "ARRAY_SHORT_INDEX_SCALE"); - b.string(" * index").end(); - b.string("value"); - b.end(); - } else { - b.string("bc[index] = value"); - } + b.statement("UFA.unsafeShortArrayWrite(bc, index, value)"); b.end(); return met; @@ -1164,8 +1141,8 @@ private CodeExecutableElement createConditionProfile() { final int maxInt = 0x3FFFFFFF; - b.declaration("int", "t", "profiles[index]"); - b.declaration("int", "f", "profiles[index + 1]"); + b.declaration("int", "t", "UFA.unsafeIntArrayRead(profiles, index)"); + b.declaration("int", "f", "UFA.unsafeIntArrayRead(profiles, index + 1)"); b.declaration("boolean", "val", "value"); b.startIf().string("val").end().startBlock(); @@ -1178,7 +1155,7 @@ private CodeExecutableElement createConditionProfile() { b.end(); b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); b.startIf().string("t < " + maxInt).end().startBlock(); - b.statement("profiles[index] = t + 1"); + b.statement("UFA.unsafeIntArrayWrite(profiles, index, t + 1)"); b.end(); b.end(); @@ -1192,7 +1169,7 @@ private CodeExecutableElement createConditionProfile() { b.end(); b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); b.startIf().string("f < " + maxInt).end().startBlock(); - b.statement("profiles[index + 1] = f + 1"); + b.statement("UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1)"); b.end(); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index f17b997e9726..78d96cf59735 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -49,9 +49,7 @@ import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index a34b4dd9605b..88e348f0242e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -80,7 +80,7 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0)); + b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0, false)); if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR || uncached) { b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 2c5ba6cf9e2c..2e246b894462 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -71,7 +71,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) - b.declaration("boolean", "cond", "$frame.getObject($sp - 1) == Boolean.TRUE"); + b.declaration("boolean", "cond", "UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE"); b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); @@ -79,14 +79,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("cond"); b.string("$conditionProfiles"); - b.tree(createBranchProfileIndex(vars, 0)); + b.tree(createBranchProfileIndex(vars, 0, false)); b.end(2).startBlock(); b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.statement("continue loop"); b.end().startElseBlock(); - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0)).end(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); b.statement("continue loop"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 23e5e95597a0..8e1213593ab8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -158,7 +158,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (data.getMainProperties().isVariadic) { - b.declaration("int", "numVariadics", createVariadicIndex(vars)); + b.declaration("int", "numVariadics", createVariadicIndex(vars, false)); int additionalInputs = data.getMainProperties().numStackValues - 1; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index ec1533cbf921..87c7aa4b8cc0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -273,9 +273,25 @@ private CodeTree createIndirectIndex(ExecutionVariables vars, String suffix, int return b.build(); } - private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int index) { - // this should also become unsafe based, but we need to separate out reads and writes - return CodeTreeBuilder.createBuilder().variable(vars.bc).string("[").variable(vars.bci).string(" + " + internalName + suffix + " + " + index + "]").build(); + private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int index, boolean write) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (write) { + b.variable(vars.bc); + b.string("["); + } else { + b.startCall("unsafeFromBytecode"); + b.variable(vars.bc); + } + b.startGroup().variable(vars.bci).string(" + " + internalName + suffix + " + " + index).end(); + + if (write) { + b.string("]"); + } else { + b.end(); + } + + return b.build(); } public CodeTree createConstantIndex(ExecutionVariables vars, int index) { @@ -286,15 +302,15 @@ public CodeTree createChildIndex(ExecutionVariables vars, int index) { return createIndirectIndex(vars, CHILDREN_OFFSET_SUFFIX, index); } - public CodeTree createLocalIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, LOCALS_OFFSET_SUFFIX, index); + public CodeTree createLocalIndex(ExecutionVariables vars, int index, boolean write) { + return createDirectIndex(vars, LOCALS_OFFSET_SUFFIX, index, write); } - public CodeTree createArgumentIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, ARGUMENT_OFFSET_SUFFIX, index); + public CodeTree createArgumentIndex(ExecutionVariables vars, int index, boolean write) { + return createDirectIndex(vars, ARGUMENT_OFFSET_SUFFIX, index, write); } - public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index) { + public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index, boolean write) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startParantheses(); @@ -302,7 +318,7 @@ public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index) { b.startParantheses(); } - b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2)); + b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2, write)); if (index % 2 == 1) { b.string(" >> 8").end(); @@ -313,20 +329,20 @@ public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index) { return b.build(); } - public CodeTree createVariadicIndex(ExecutionVariables vars) { - return createDirectIndex(vars, VARIADIC_OFFSET_SUFFIX, 0); + public CodeTree createVariadicIndex(ExecutionVariables vars, boolean write) { + return createDirectIndex(vars, VARIADIC_OFFSET_SUFFIX, 0, write); } - public CodeTree createBranchTargetIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, BRANCH_TARGET_OFFSET_SUFFIX, index); + public CodeTree createBranchTargetIndex(ExecutionVariables vars, int index, boolean write) { + return createDirectIndex(vars, BRANCH_TARGET_OFFSET_SUFFIX, index, write); } - public CodeTree createBranchProfileIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index * 2); + public CodeTree createBranchProfileIndex(ExecutionVariables vars, int index, boolean write) { + return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index * 2, write); } - public CodeTree createStateBitsIndex(ExecutionVariables vars, int index) { - return createDirectIndex(vars, STATE_BITS_OFFSET_SUFFIX, index); + public CodeTree createStateBitsIndex(ExecutionVariables vars, int index, boolean write) { + return createDirectIndex(vars, STATE_BITS_OFFSET_SUFFIX, index, write); } public CodeTree createLength() { @@ -682,26 +698,26 @@ public CodeTree createDumpCode(ExecutionVariables vars) { for (int i = 0; i < locals.size(); i++) { int ci = i; - sbAppend(b, " local(%s)", () -> b.startGroup().tree(createLocalIndex(vars, ci)).end()); + sbAppend(b, " local(%s)", () -> b.startGroup().tree(createLocalIndex(vars, ci, false)).end()); } for (int i = 0; i < arguments.size(); i++) { int ci = i; - sbAppend(b, " arg(%s)", () -> b.startGroup().tree(createArgumentIndex(vars, ci)).end()); + sbAppend(b, " arg(%s)", () -> b.startGroup().tree(createArgumentIndex(vars, ci, false)).end()); } for (int i = 0; i < popIndexed.size(); i++) { int ci = i; - sbAppend(b, " pop(-%s)", () -> b.startGroup().tree(createPopIndexedIndex(vars, ci)).end()); + sbAppend(b, " pop(-%s)", () -> b.startGroup().tree(createPopIndexedIndex(vars, ci, false)).end()); } if (isVariadic) { - sbAppend(b, " var(%s)", () -> b.startGroup().tree(createVariadicIndex(vars)).end()); + sbAppend(b, " var(%s)", () -> b.startGroup().tree(createVariadicIndex(vars, false)).end()); } for (int i = 0; i < branchTargets.size(); i++) { int ci = i; - sbAppend(b, " branch(%04x)", () -> b.startGroup().tree(createBranchTargetIndex(vars, ci)).end()); + sbAppend(b, " branch(%04x)", () -> b.startGroup().tree(createBranchTargetIndex(vars, ci, false)).end()); } return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 828fba059d94..2a790e65e70d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -63,7 +63,7 @@ private CodeTree createGetValue(ExecutionVariables vars) { b.startCall(vars.frame, "getArguments").end(); b.string("["); - b.tree(createArgumentIndex(vars, 0)); + b.tree(createArgumentIndex(vars, 0, false)); b.string("]"); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index b75b182be2c9..55147621a9e2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -110,9 +110,10 @@ private CodeTree createGetArgument(ExecutionVariables vars) { if (kind != FrameKind.OBJECT) { b.string("(", kind.getTypeName(), ") "); } - b.variable(vars.consts).string("["); + b.startCall("UFA", "unsafeObjectArrayRead"); + b.variable(vars.consts); b.tree(createConstantIndex(vars, 0)); - b.end().string("]"); + b.end(); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 1b1a369d648c..95d2a896e448 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -59,7 +59,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("int localIdx"); - b.tree(createLocalIndex(vars, 0)); + b.tree(createLocalIndex(vars, 0, false)); b.end(); createCopyObject(vars, b); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index e9cd3436ce19..3a0167b03e6c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -84,7 +84,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // } b.end().startElseBlock(); // { - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0)).end(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); b.statement("continue loop"); // } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index b30288673087..331bf18c6115 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -60,7 +60,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("int localIdx"); - b.tree(createLocalIndex(vars, 0)); + b.tree(createLocalIndex(vars, 0, false)); b.end(); b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); @@ -101,7 +101,7 @@ private void createSetChildBoxing(ExecutionVariables vars, CodeTreeBuilder b, St b.startStatement().startCall("doSetResultBoxed"); b.variable(vars.bc); b.variable(vars.bci); - b.startGroup().tree(createPopIndexedIndex(vars, 0)).end(); + b.startGroup().tree(createPopIndexedIndex(vars, 0, false)).end(); b.string(tag); b.end(2); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index 0863c1da3ee9..3506c1e29b6c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -58,7 +58,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // we can convert this to a jump to a statically determined handler // or a throw out of a function - b.startAssign("int slot").tree(createLocalIndex(vars, 0)).end(); + b.startAssign("int slot").tree(createLocalIndex(vars, 0, false)).end(); b.startThrow(); b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); From 8f8610959cfd7cb686377b734a47a887fdd325da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 30 Aug 2022 16:17:48 +0200 Subject: [PATCH 133/312] [wip] fix codegen bug --- .../OperationsBytecodeNodeGeneratorPlugs.java | 28 +++++++++++++------ .../operations/instructions/Instruction.java | 3 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index f62c1f231cc7..b22ccea5be13 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -250,7 +250,7 @@ public CodeTree transformValueBeforePersist(CodeTree tree) { private static final String CHILD_OFFSET_NAME = "childArrayOffset_"; private static final String CONST_OFFSET_NAME = "constArrayOffset_"; - private CodeTree createArrayReference(FrameState frame, Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild) { + private CodeTree createArrayReference(FrameState frame, Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild, boolean write) { if (refObject == null) { throw new IllegalArgumentException("refObject is null"); } @@ -278,8 +278,13 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea targetField = dummyVariables.consts; } - b.startCall("UFA", "unsafeObjectArrayRead"); - b.variable(targetField); + if (write) { + b.variable(targetField).string("["); + } else { + b.startCall("UFA", "unsafeObjectArrayRead"); + b.variable(targetField); + } + b.startGroup(); if (frame == null || !frame.getBoolean("definedOffsets", false)) { @@ -302,7 +307,12 @@ private CodeTree createArrayReference(FrameState frame, Object refObject, boolea } - b.string(" + " + index).end(); + b.string(" + " + index).end(); // group + if (write) { + b.string("]"); + } else { + b.end(); // call + } if (doCast) { b.end(); @@ -322,7 +332,7 @@ public CodeTree createSpecializationFieldReference(FrameState frame, Specializat boolean specClass = useSpecializationClass.test(s); Object refObject = specClass ? s : fieldName; boolean isChild = specClass ? specializationClassIsNode(s) : ElementUtils.isAssignable(fieldType, types.Node); - return createArrayReference(frame, refObject, !write, fieldType, isChild); + return createArrayReference(frame, refObject, !write, fieldType, isChild, write); } /* Specialization class needs to be a Node in such a case. */ @@ -350,7 +360,7 @@ public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData exe if (nodeFieldName.startsWith("$child")) { return CodeTreeBuilder.singleString("__INVALID__"); } - return createArrayReference(frame, execution, forRead, execution.getNodeType(), true); + return createArrayReference(frame, execution, forRead, execution.getNodeType(), true, !forRead); } @Override @@ -390,7 +400,7 @@ public CodeTree createCacheReference(FrameState frame, SpecializationData specia } if (base == null) { - base = createArrayReference(frame, refObject, innerForRead, mir, isChild); + base = createArrayReference(frame, refObject, innerForRead, mir, isChild, !forRead); } if (fieldName == null) { @@ -636,11 +646,11 @@ private FrameKind getFrameType(TypeKind type) { @Override public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { if (execution.getName().startsWith("$localRefArray")) { - return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRange, false); + return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRange, false, false); } if (execution.getName().startsWith("$localRef")) { - return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false); + return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false, false); } int childIndex = execution.getIndex(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 87c7aa4b8cc0..919bb5410bb2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -277,6 +277,7 @@ private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int i CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (write) { + b.startGroup(); b.variable(vars.bc); b.string("["); } else { @@ -286,7 +287,7 @@ private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int i b.startGroup().variable(vars.bci).string(" + " + internalName + suffix + " + " + index).end(); if (write) { - b.string("]"); + b.string("]").end(); } else { b.end(); } From 9d17e89e255e93b597d5f548f037da558df279fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 20 Sep 2022 16:53:46 +0200 Subject: [PATCH 134/312] [wip] nicer bench --- .../api/operation/test/bml/BMLNode.java | 104 +++++- .../operation/test/bml/BenchmarkLanguage.java | 24 ++ .../api/operation/test/bml/BenmarkSimple.java | 329 ++++++++++++++---- .../test/bml/ManualBytecodeNode.java | 21 ++ .../api/operation/test/bml/decisions.json | 7 +- .../truffle/api/operation/OperationNodes.java | 4 +- 6 files changed, 414 insertions(+), 75 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java index 2971560e553b..e880a37f13bb 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java @@ -1,5 +1,6 @@ package com.oracle.truffle.api.operation.test.bml; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -38,16 +39,16 @@ public Object getValue() { class BMLRootNode extends RootNode { - @Children private final BMLNode[] children; + @Child BMLNode body; - BMLRootNode(BenchmarkLanguage lang, int locals, BMLNode... children) { + BMLRootNode(BenchmarkLanguage lang, int locals, BMLNode body) { super(lang, createFrame(locals)); - this.children = children; + this.body = body; } private static FrameDescriptor createFrame(int locals) { FrameDescriptor.Builder b = FrameDescriptor.newBuilder(locals); - b.addSlots(locals, FrameSlotKind.Int); + b.addSlots(locals, FrameSlotKind.Illegal); return b.build(); } @@ -55,9 +56,7 @@ private static FrameDescriptor createFrame(int locals) { @ExplodeLoop public Object execute(VirtualFrame frame) { try { - for (BMLNode child : children) { - child.execute(frame); - } + body.execute(frame); } catch (ReturnException ex) { return ex.getValue(); } @@ -82,6 +81,21 @@ public Object fallback(Object lhs, Object rhs) { } } +@NodeChild(type = BMLNode.class) +@NodeChild(type = BMLNode.class) +abstract class ModNode extends BMLNode { + @Specialization + public int modInts(int lhs, int rhs) { + return lhs % rhs; + } + + @Fallback + @SuppressWarnings("unused") + public Object fallback(Object lhs, Object rhs) { + throw new AssertionError(); + } +} + @NodeChild(type = BMLNode.class) @NodeChild(type = BMLNode.class) abstract class LessNode extends BMLNode { @@ -134,6 +148,46 @@ public int loadValue(VirtualFrame frame) { } } +class IfNode extends BMLNode { + @Child BMLNode condition; + @Child BMLNode thenBranch; + @Child BMLNode elseBranch; + + public static IfNode create(BMLNode condition, BMLNode thenBranch, BMLNode elseBranch) { + return new IfNode(condition, thenBranch, elseBranch); + } + + IfNode(BMLNode condition, BMLNode thenBranch, BMLNode elseBranch) { + this.condition = condition; + this.thenBranch = thenBranch; + this.elseBranch = elseBranch; + } + + @Override + public Object execute(VirtualFrame frame) { + try { + if (condition.executeBool(frame)) { + thenBranch.execute(frame); + } else { + thenBranch.execute(frame); + } + return VOID; + } catch (UnexpectedResultException e) { + throw CompilerDirectives.shouldNotReachHere(); + } + } + + @Override + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { + throw CompilerDirectives.shouldNotReachHere(); + } + + @Override + public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { + throw CompilerDirectives.shouldNotReachHere(); + } +} + class WhileNode extends BMLNode { @Child private BMLNode condition; @@ -157,20 +211,50 @@ public Object execute(VirtualFrame frame) { } return VOID; } catch (UnexpectedResultException e) { - throw new AssertionError(); + throw CompilerDirectives.shouldNotReachHere(); } } @Override public int executeInt(VirtualFrame frame) throws UnexpectedResultException { - throw new AssertionError(); + throw CompilerDirectives.shouldNotReachHere(); } @Override public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { - throw new AssertionError(); + throw CompilerDirectives.shouldNotReachHere(); + } +} + +class BlockNode extends BMLNode { + @Children final BMLNode[] nodes; + + public static final BlockNode create(BMLNode... nodes) { + return new BlockNode(nodes); + } + + BlockNode(BMLNode[] nodes) { + this.nodes = nodes; + } + + @Override + @ExplodeLoop + public Object execute(VirtualFrame frame) { + for (BMLNode node : nodes) { + node.execute(frame); + } + return VOID; } + @Override + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { + throw CompilerDirectives.shouldNotReachHere(); + } + + @Override + public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { + throw CompilerDirectives.shouldNotReachHere(); + } } abstract class ConstNode extends BMLNode { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java index b09273095ae9..0d6499e26801 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java @@ -110,6 +110,14 @@ static int doInts(int left, int right) { } } + @Operation + static final class Mod { + @Specialization + static int doInts(int left, int right) { + return left % right; + } + } + @Operation static final class AddQuickened { @Specialization @@ -118,6 +126,14 @@ static int doInts(int left, int right) { } } + @Operation + static final class ModQuickened { + @Specialization + static int doInts(int left, int right) { + return left % right; + } + } + @Operation(disableBoxingElimination = true) static final class AddBoxed { @Specialization @@ -126,6 +142,14 @@ static int doInts(int left, int right) { } } + @Operation(disableBoxingElimination = true) + static final class ModBoxed { + @Specialization + static int doInts(int left, int right) { + return left % right; + } + } + @Operation static final class Less { @Specialization diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index 86122cbd282f..47707695b4aa 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -46,11 +46,13 @@ import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_JUMP_FALSE; import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_LD_LOC; import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_LESS; +import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_MOD; import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_RETURN; import static com.oracle.truffle.api.operation.test.bml.ManualBytecodeNode.OP_ST_LOC; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; +import org.graalvm.polyglot.Value; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; @@ -85,26 +87,93 @@ public class BenmarkSimple extends BaseBenchmark { private static final Source SOURCE_MANUAL_NO_BE = Source.create("bm", NAME_MANUAL_NO_BE); private static final Source SOURCE_AST = Source.create("bm", NAME_AST); + private static final int LOC_I = 4; + private static final int LOC_SUM = 5; + private static final int LOC_J = 6; + private static final int LOC_TEMP = 7; + private static final short[] BYTECODE = { + // i = 0 /* 00 */ OP_CONST, 0, 0, - /* 03 */ OP_ST_LOC, 2, - /* 05 */ OP_LD_LOC, 2, - /* 07 */ OP_CONST, (short) (TARGET_AMOUNT >> 16), (short) (TARGET_AMOUNT & 0xffff), - /* 10 */ OP_LESS, - /* 11 */ OP_JUMP_FALSE, 35, - /* 13 */ OP_LD_LOC, 2, - /* 15 */ OP_CONST, 0, 1, - /* 18 */ OP_ADD, - /* 19 */ OP_CONST, 0, 1, - /* 22 */ OP_ADD, - /* 23 */ OP_CONST, 0, 1, - /* 26 */ OP_ADD, - /* 27 */ OP_CONST, 0, 1, - /* 30 */ OP_ADD, - /* 31 */ OP_ST_LOC, 2, - /* 33 */ OP_JUMP, 5, - /* 35 */ OP_CONST, 0, 0, - /* 38 */ OP_RETURN + /* 03 */ OP_ST_LOC, LOC_I, + + // sum = 0 + /* 05 */ OP_CONST, 0, 0, + /* 08 */ OP_ST_LOC, LOC_SUM, + + // while (i < 5000) { + /* while_0_start: */ + /* 10 */ OP_LD_LOC, LOC_I, + /* 12 */ OP_CONST, 0, 5000, + /* 15 */ OP_LESS, + /* 16 */ OP_JUMP_FALSE, 83, // while_0_end + + // j = 0 + /* 18 */ OP_CONST, 0, 0, + /* 21 */ OP_ST_LOC, LOC_J, + + // while (j < i) { + /* while_1_start: */ + /* 23 */ OP_LD_LOC, LOC_J, // j + /* 25 */ OP_LD_LOC, LOC_I, // i + /* 27 */ OP_LESS, + /* 28 */ OP_JUMP_FALSE, 66, // while_1_end + + // if (i % 3 < 1) { + /* 30 */ OP_LD_LOC, LOC_I, // i + /* 32 */ OP_CONST, 0, 3, + /* 35 */ OP_MOD, + /* 36 */ OP_CONST, 0, 1, + /* 39 */ OP_LESS, + /* 40 */ OP_JUMP_FALSE, 49, // if_else + + // temp = 0 + /* 42 */ OP_CONST, 0, 1, + /* 45 */ OP_ST_LOC, LOC_TEMP, // temp + + // } else { + /* 47 */ OP_JUMP, 57, // if_end + /* if_else: */ + + // temp = i % 3 + /* 49 */ OP_LD_LOC, LOC_I, // i + /* 51 */ OP_CONST, 0, 3, + /* 54 */ OP_MOD, + /* 55 */ OP_ST_LOC, LOC_TEMP, // temp + + // } // if end + /* if_end: */ + + // j = j + temp + /* 57 */ OP_LD_LOC, LOC_J, // j + /* 59 */ OP_LD_LOC, LOC_TEMP, // temp + /* 61 */ OP_ADD, + /* 62 */ OP_ST_LOC, LOC_J, // j + + // } // while end + /* 64 */ OP_JUMP, 23, // while_1_start + /* while_1_end: */ + + // sum = sum + j + /* 66 */ OP_LD_LOC, LOC_SUM, // sum + /* 68 */ OP_LD_LOC, LOC_J, // j + /* 70 */ OP_ADD, + /* 71 */ OP_ST_LOC, LOC_SUM, // sum + + // i = i + 1 + /* 73 */ OP_LD_LOC, LOC_I, // i + /* 75 */ OP_CONST, 0, 1, + /* 78 */ OP_ADD, + /* 79 */ OP_ST_LOC, LOC_I, // i + + // } // while end + /* 81 */ OP_JUMP, 10, // while_0_start + /* while_0_end: */ + + // return sum + /* 83 */ OP_LD_LOC, LOC_SUM, // sum + /* 85 */ OP_RETURN, + }; private Context context; @@ -118,13 +187,31 @@ public class BenmarkSimple extends BaseBenchmark { * *
      * int i = 0;
-     * while (i < 100000) {
-     *     i = i + 1 + 1 + 1 + 1
+     * int sum = 0;
+     * while (i < 5000) {
+     *     int j = 0;
+     *     while (j < i) {
+     *         int temp;
+     *         if (i % 3 < 1) {
+     *             temp = 1;
+     *         } else {
+     *             temp = i % 3;
+     *         }
+     *         j = j + temp;
+     *     }
+     *     sum = sum + j;
+     *     i = i + 1;
      * }
-     * return 0;
+     * return sum;
      * 
+ * + * The result should be 12498333. */ static { + if (BYTECODE.length != 86) { + throw new AssertionError("bad bytecode length: " + BYTECODE.length); + } + BenchmarkLanguage.registerName(NAME_TEST_LOOP, (lang, b) -> { createSimpleLoop(lang, b, MODE_NORMAL); }); @@ -136,32 +223,46 @@ public class BenmarkSimple extends BaseBenchmark { }); BenchmarkLanguage.registerName2(NAME_MANUAL, lang -> { FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); - b.addSlots(3, FrameSlotKind.Illegal); + b.addSlots(8, FrameSlotKind.Illegal); ManualBytecodeNode node = new ManualBytecodeNode(lang, b.build(), BYTECODE); return node.getCallTarget(); }); BenchmarkLanguage.registerName2(NAME_MANUAL_NO_BE, lang -> { FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); - b.addSlots(3, FrameSlotKind.Illegal); + b.addSlots(8, FrameSlotKind.Illegal); ManualBytecodeNodeNBE node = new ManualBytecodeNodeNBE(lang, b.build(), BYTECODE); return node.getCallTarget(); }); BenchmarkLanguage.registerName2(NAME_AST, lang -> { - return new BMLRootNode(lang, 1, - StoreLocalNodeGen.create(0, ConstNodeGen.create(0)), - WhileNode.create( - LessNodeGen.create(LoadLocalNodeGen.create(0), ConstNodeGen.create(TARGET_AMOUNT)), - StoreLocalNodeGen.create(0, - AddNodeGen.create( - AddNodeGen.create( - AddNodeGen.create( - AddNodeGen.create( - LoadLocalNodeGen.create(0), - ConstNodeGen.create(1)), - ConstNodeGen.create(1)), - ConstNodeGen.create(1)), - ConstNodeGen.create(1)))), - ReturnNodeGen.create(ConstNodeGen.create(0))).getCallTarget(); + int iLoc = 0, sumLoc = 1, jLoc = 2, tempLoc = 3; + return new BMLRootNode(lang, 4, BlockNode.create( + // i = 0 + StoreLocalNodeGen.create(iLoc, ConstNodeGen.create(0)), + // sum = 0 + StoreLocalNodeGen.create(sumLoc, ConstNodeGen.create(0)), + // while (i < 5000) { + WhileNode.create(LessNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(5000)), BlockNode.create( + // j = 0 + StoreLocalNodeGen.create(jLoc, ConstNodeGen.create(0)), + // while (j < i) { + WhileNode.create(LessNodeGen.create(LoadLocalNodeGen.create(jLoc), LoadLocalNodeGen.create(iLoc)), BlockNode.create( + // if (i % 3 < 1) { + IfNode.create(LessNodeGen.create(ModNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(3)), ConstNodeGen.create(1)), + // temp = 1 + StoreLocalNodeGen.create(tempLoc, ConstNodeGen.create(1)), + // } else { + // temp = i % 3 + StoreLocalNodeGen.create(tempLoc, ModNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(3)))), + // } + // j = j + temp + StoreLocalNodeGen.create(jLoc, AddNodeGen.create(LoadLocalNodeGen.create(jLoc), LoadLocalNodeGen.create(tempLoc))))), + // } + // sum = sum + j + StoreLocalNodeGen.create(sumLoc, AddNodeGen.create(LoadLocalNodeGen.create(sumLoc), LoadLocalNodeGen.create(jLoc))), + // i = i + 1 + StoreLocalNodeGen.create(iLoc, AddNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(1))))), + // return sum + ReturnNodeGen.create(LoadLocalNodeGen.create(sumLoc)))).getCallTarget(); }); } @@ -197,44 +298,139 @@ private static void endAdd(Builder b, int mode) { } } + private static void beginMod(Builder b, int mode) { + switch (mode) { + case MODE_NORMAL: + b.beginMod(); + break; + case MODE_NO_BE: + b.beginModBoxed(); + break; + case MODE_QUICKEN: + b.beginModQuickened(); + break; + default: + throw new UnsupportedOperationException(); + } + } + + private static void endMod(Builder b, int mode) { + switch (mode) { + case MODE_NORMAL: + b.endMod(); + break; + case MODE_NO_BE: + b.endModBoxed(); + break; + case MODE_QUICKEN: + b.endModQuickened(); + break; + default: + throw new UnsupportedOperationException(); + } + } + private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode) { - OperationLocal i = b.createLocal(); + OperationLocal iLoc = b.createLocal(); + OperationLocal sumLoc = b.createLocal(); + OperationLocal jLoc = b.createLocal(); + OperationLocal tempLoc = b.createLocal(); + + // int i = 0; + b.beginStoreLocal(iLoc); + b.emitConstObject(0); + b.endStoreLocal(); - // i = 0 - b.beginStoreLocal(i); + // int sum = 0; + b.beginStoreLocal(sumLoc); b.emitConstObject(0); b.endStoreLocal(); - // while (i < 100000) { + // while (i < 5000) { b.beginWhile(); b.beginLess(); - b.emitLoadLocal(i); - b.emitConstObject(100000); + b.emitLoadLocal(iLoc); + b.emitConstObject(5000); b.endLess(); + b.beginBlock(); - // i = i + 1 + 1 + 1 + 1 - b.beginStoreLocal(i); - beginAdd(b, mode); - beginAdd(b, mode); - beginAdd(b, mode); - beginAdd(b, mode); - b.emitLoadLocal(i); + // int j = 0; + b.beginStoreLocal(jLoc); + b.emitConstObject(0); + b.endStoreLocal(); + + // while (j < i) { + b.beginWhile(); + b.beginLess(); + b.emitLoadLocal(jLoc); + b.emitLoadLocal(iLoc); + b.endLess(); + b.beginBlock(); + + // int temp; + // if (i % 3 < 1) { + b.beginIfThenElse(); + + b.beginLess(); + beginMod(b, mode); + b.emitLoadLocal(iLoc); + b.emitConstObject(3); + endMod(b, mode); b.emitConstObject(1); - endAdd(b, mode); + b.endLess(); + + // temp = 1; + b.beginStoreLocal(tempLoc); b.emitConstObject(1); + b.endStoreLocal(); + + // } else { + // temp = i % 3; + b.beginStoreLocal(tempLoc); + beginMod(b, mode); + b.emitLoadLocal(iLoc); + b.emitConstObject(3); + endMod(b, mode); + b.endStoreLocal(); + + // } + b.endIfThenElse(); + + // j = j + temp; + b.beginStoreLocal(jLoc); + beginAdd(b, mode); + b.emitLoadLocal(jLoc); + b.emitLoadLocal(tempLoc); endAdd(b, mode); - b.emitConstObject(1); + b.endStoreLocal(); + + // } + b.endBlock(); + b.endWhile(); + + // sum = sum + j; + b.beginStoreLocal(sumLoc); + beginAdd(b, mode); + b.emitLoadLocal(sumLoc); + b.emitLoadLocal(jLoc); endAdd(b, mode); + b.endStoreLocal(); + + // i = i + 1; + b.beginStoreLocal(iLoc); + beginAdd(b, mode); + b.emitLoadLocal(iLoc); b.emitConstObject(1); endAdd(b, mode); b.endStoreLocal(); // } + b.endBlock(); b.endWhile(); - // return 0 + // return sum; b.beginReturn(); - b.emitConstObject(0); + b.emitLoadLocal(sumLoc); b.endReturn(); b.publish(lang); @@ -242,7 +438,7 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode @Setup(Level.Trial) public void setup() { - context = Context.create(); + context = Context.newBuilder("bm").allowExperimentalOptions(true).build(); } @Setup(Level.Iteration) @@ -255,34 +451,43 @@ public void leaveContext() { context.leave(); } + private static final boolean PRINT_RESULTS = System.getProperty("PrintResults") != null; + + private void doEval(Source source) { + Value v = context.eval(source); + if (PRINT_RESULTS) { + System.err.println(source.getCharacters() + " = " + v); + } + } + @Benchmark public void operation() { - context.eval(SOURCE_TEST_LOOP); + doEval(SOURCE_TEST_LOOP); } @Benchmark public void operationNoBe() { - context.eval(SOURCE_TEST_LOOP_NO_BE); + doEval(SOURCE_TEST_LOOP_NO_BE); } @Benchmark public void operationQuicken() { - context.eval(SOURCE_TEST_LOOP_QUICKEN); + doEval(SOURCE_TEST_LOOP_QUICKEN); } @Benchmark public void manual() { - context.eval(SOURCE_MANUAL); + doEval(SOURCE_MANUAL); } @Benchmark public void manualNoBE() { - context.eval(SOURCE_MANUAL_NO_BE); + doEval(SOURCE_MANUAL_NO_BE); } @Benchmark public void ast() { - context.eval(SOURCE_AST); + doEval(SOURCE_AST); } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java index 8fac9473c51f..fa332da391c2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -66,6 +66,7 @@ public class ManualBytecodeNode extends RootNode implements BytecodeOSRNode { static final short OP_RETURN = 6; static final short OP_ST_LOC = 7; static final short OP_LD_LOC = 8; + static final short OP_MOD = 9; protected ManualBytecodeNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { super(language, frameDescriptor); @@ -123,6 +124,15 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { bci += 1; continue loop; } + // (i1 i2 -- i3) + case OP_MOD: { + int lhs = frame.getInt(sp - 2); + int rhs = frame.getInt(sp - 1); + frame.setInt(sp - 2, lhs % rhs); + sp -= 1; + bci += 1; + continue loop; + } // ( -- i) case OP_CONST: { frame.setInt(sp, (localBc[bci + 1] << 16) | (localBc[bci + 2] & 0xffff)); @@ -202,6 +212,7 @@ class ManualBytecodeNodeNBE extends RootNode { static final short OP_RETURN = 6; static final short OP_ST_LOC = 7; static final short OP_LD_LOC = 8; + static final short OP_MOD = 9; protected ManualBytecodeNodeNBE(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { super(language, frameDescriptor); @@ -241,6 +252,16 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { bci += 1; continue loop; } + // (i1 i2 -- i3) + case OP_MOD: { + int lhs = (int) frame.getObject(sp - 2); + int rhs = (int) frame.getObject(sp - 1); + frame.setObject(sp - 2, lhs % rhs); + frame.clear(sp - 1); + sp -= 1; + bci += 1; + continue loop; + } // ( -- i) case OP_CONST: { frame.setObject(sp, (localBc[bci + 1] << 16) | (localBc[bci + 2] & 0xffff)); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json index bf1b1438d956..cb0565c9d27a 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json @@ -3,5 +3,10 @@ "type": "Quicken", "operation": "AddQuickened", "specializations": ["Ints"] + }, + { + "type": "Quicken", + "operation": "ModQuickened", + "specializations": ["Ints"] } -] \ No newline at end of file +] diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 4ffb9b9eceb5..4260997e9d69 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -61,9 +61,9 @@ protected OperationNodes(OperationParser parse) { this.parse = parse; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "cast", "rawtypes"}) public List getNodes() { - return (List) List.of(nodes); + return (List) (List) List.of(nodes); } public boolean hasSources() { From b94be653def1635b531c73a60587a7c8f9ad5f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 21 Sep 2022 09:36:59 +0200 Subject: [PATCH 135/312] [wip] begin/endRoot --- .../test/example/BoxingOperationsTest.java | 36 ++++++--- .../example/TestOperationsParserTest.java | 78 ++++++++++++------ .../test/example/TestOperationsSerTest.java | 4 +- .../dsl/processor/operations/Operation.java | 81 +++++++++++++++++++ .../operations/OperationsCodeGenerator.java | 75 ++++++++++++++--- .../operations/OperationsContext.java | 1 + .../operations/SingleOperationParser.java | 1 + .../sl/parser/SLOperationsVisitor.java | 3 +- 8 files changed, 230 insertions(+), 49 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 0cb4336e5e87..d0f5a12e3596 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -84,13 +84,15 @@ private static OperationRootNode parseNode(OperationParser { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginLongOperator(); b.emitIntProducer(); b.endLongOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -101,13 +103,15 @@ public void testCastsPrimToPrim() { @Test public void testCastsRefToPrim() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginLongOperator(); b.emitRefBProducer(); b.endLongOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -118,13 +122,15 @@ public void testCastsRefToPrim() { @Test public void testCastsPrimToRef() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginStringOperator(); b.emitBooleanProducer(); b.endStringOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -135,13 +141,15 @@ public void testCastsPrimToRef() { @Test public void testCastsRefToRef() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginStringOperator(); b.emitRefAProducer(); b.endStringOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -152,6 +160,8 @@ public void testCastsRefToRef() { @Test public void testCastsChangePrim() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginLongOperator(); b.beginObjectProducer(); @@ -160,7 +170,7 @@ public void testCastsChangePrim() { b.endLongOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -181,6 +191,8 @@ public void testCastsChangePrim() { @Test public void testCastsChangeRef() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginStringOperator(); b.beginObjectProducer(); @@ -189,7 +201,7 @@ public void testCastsChangeRef() { b.endStringOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -210,6 +222,8 @@ public void testCastsChangeRef() { @Test public void testCastsChangeSpecPrim() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginLongOperator(); b.beginSpecializedObjectProducer(); @@ -218,7 +232,7 @@ public void testCastsChangeSpecPrim() { b.endLongOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -239,6 +253,8 @@ public void testCastsChangeSpecPrim() { @Test public void testCastsChangeSpecRef() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginStringOperator(); b.beginSpecializedObjectProducer(); @@ -247,7 +263,7 @@ public void testCastsChangeSpecRef() { b.endStringOperator(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); for (int i = 0; i < 3; i++) { @@ -268,6 +284,8 @@ public void testCastsChangeSpecRef() { @Test public void testLBEMultipleLoads() { OperationRootNode node = parseNode(b -> { + b.beginRoot(LANGUAGE); + OperationLocal local = b.createLocal(); b.beginStoreLocal(local); @@ -282,7 +300,7 @@ public void testLBEMultipleLoads() { b.emitLoadLocal(local); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); RootCallTarget root = ((RootNode) node).getCallTarget(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index e31fee8f37da..c7f9e636d44e 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -75,6 +75,8 @@ private static OperationRootNode parseNode(OperationParser { + b.beginRoot(LANGUAGE); + b.beginReturn(); b.beginAddOperation(); b.emitLoadArgument(0); @@ -82,7 +84,7 @@ public void testAdd() { b.endAddOperation(); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(42L, root.call(20L, 22L)); @@ -93,6 +95,7 @@ public void testAdd() { @Test public void testMax() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); b.beginIfThenElse(); b.beginLessThanOperation(); @@ -110,7 +113,7 @@ public void testMax() { b.endIfThenElse(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(42L, root.call(42L, 13L)); @@ -122,6 +125,7 @@ public void testMax() { @Test public void testIfThen() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); b.beginIfThen(); b.beginLessThanOperation(); @@ -139,7 +143,7 @@ public void testIfThen() { b.emitLoadArgument(0); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(0L, root.call(-2L)); @@ -157,6 +161,7 @@ public void testSumLoop() { // return j; RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); OperationLocal locI = b.createLocal(); OperationLocal locJ = b.createLocal(); @@ -196,7 +201,7 @@ public void testSumLoop() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(45L, root.call(10L)); @@ -205,6 +210,8 @@ public void testSumLoop() { @Test public void testTryCatch() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + OperationLocal local = b.createLocal(); b.beginTryCatch(local); @@ -228,8 +235,7 @@ public void testTryCatch() { b.emitConstObject(0L); b.endReturn(); - - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(1L, root.call(-1L)); @@ -239,6 +245,7 @@ public void testTryCatch() { @Test public void testVariableBoxingElim() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); OperationLocal local0 = b.createLocal(); OperationLocal local1 = b.createLocal(); @@ -285,7 +292,7 @@ public void testVariableBoxingElim() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(4950L, root.call()); @@ -315,6 +322,7 @@ public void testFinallyTryBasic() { // expected 1, 2 RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -332,7 +340,7 @@ public void testFinallyTryBasic() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 2L); @@ -345,6 +353,7 @@ public void testFinallyTryException() { // expected: 1, 3 RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -371,7 +380,7 @@ public void testFinallyTryException() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(true, root, 1L, 3L); @@ -380,6 +389,7 @@ public void testFinallyTryException() { @Test public void testFinallyTryReturn() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -404,7 +414,7 @@ public void testFinallyTryReturn() { b.endAppenderOperation(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 2L, 1L); @@ -413,6 +423,7 @@ public void testFinallyTryReturn() { @Test public void testFinallyTryBranchOut() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { 1;goto lbl;2;} finally { 3;} 4;lbl: 5; // expected: 1, 3, 5 @@ -457,7 +468,7 @@ public void testFinallyTryBranchOut() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -466,6 +477,7 @@ public void testFinallyTryBranchOut() { @Test public void testFinallyTryCancel() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { 1;return;} finally { 2;goto lbl;} 3;lbl: 4; // expected: 1, 2, 4 @@ -511,7 +523,7 @@ public void testFinallyTryCancel() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 2L, 4L); @@ -520,6 +532,7 @@ public void testFinallyTryCancel() { @Test public void testFinallyTryInnerCf() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { 1;return;2 } finally { 3;goto lbl;4;lbl: 5;} // expected: 1, 3, 5 @@ -566,7 +579,7 @@ public void testFinallyTryInnerCf() { b.endFinallyTry(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -575,6 +588,7 @@ public void testFinallyTryInnerCf() { @Test public void testFinallyTryNestedTry() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { try { 1;return;2;} finally { 3;} } finally { 4;} // expected: 1, 3, 4 @@ -614,7 +628,7 @@ public void testFinallyTryNestedTry() { b.endFinallyTry(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 3L, 4L); @@ -623,6 +637,7 @@ public void testFinallyTryNestedTry() { @Test public void testFinallyTryNestedFinally() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { 1;return;2;} finally { try { 3;return;4;} finally { 5;} } // expected: 1, 3, 5 @@ -671,7 +686,7 @@ public void testFinallyTryNestedFinally() { b.endFinallyTry(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 3L, 5L); @@ -680,6 +695,7 @@ public void testFinallyTryNestedFinally() { @Test public void testFinallyTryNestedTryThrow() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { try { 1;throw;2;} finally { 3;} } finally { 4;} // expected: 1, 3, 4 @@ -717,7 +733,7 @@ public void testFinallyTryNestedTryThrow() { b.endFinallyTry(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(true, root, 1L, 3L, 4L); @@ -726,6 +742,7 @@ public void testFinallyTryNestedTryThrow() { @Test public void testFinallyTryNestedFinallyThrow() { RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); // try { 1;throw;2;} finally { try { 3;throw;4;} finally { 5;} } // expected: 1, 3, 5 @@ -770,7 +787,7 @@ public void testFinallyTryNestedFinallyThrow() { b.endFinallyTry(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(true, root, 1L, 3L, 5L); @@ -783,6 +800,8 @@ public void testFinallyTryNoExceptReturn() { // expected: 1, 3 RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginFinallyTryNoExcept(); b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -807,7 +826,7 @@ public void testFinallyTryNoExceptReturn() { b.endFinallyTryNoExcept(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(false, root, 1L, 3L); @@ -820,6 +839,8 @@ public void testFinallyTryNoExceptException() { // expected: 1 RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginFinallyTryNoExcept(); b.beginAppenderOperation(); b.emitLoadArgument(0); @@ -842,7 +863,7 @@ public void testFinallyTryNoExceptException() { b.endFinallyTryNoExcept(); - b.publish(LANGUAGE); + b.endRoot(); }); testOrdering(true, root, 1L); @@ -853,9 +874,11 @@ public void testMetadata() { final String value = "test data"; OperationRootNode node = parseNode(b -> { + b.beginRoot(LANGUAGE); + b.setTestData(value); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); @@ -867,10 +890,12 @@ public void testMetadataChange() { final String value = "test data"; OperationRootNode node = parseNode(b -> { + b.beginRoot(LANGUAGE); + b.setTestData("some old value"); b.setTestData(value); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); @@ -880,8 +905,9 @@ public void testMetadataChange() { @Test public void testMetadataDefaultValue() { OperationRootNode node = parseNode(b -> { + b.beginRoot(LANGUAGE); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(TestOperations.TestData.getDefaultValue(), node.getMetadata(TestOperations.TestData)); @@ -890,7 +916,7 @@ public void testMetadataDefaultValue() { @Test public void testTeeLocal() { - RootCallTarget root = parse(b -> { + RootCallTarget root = parse(b -> { b.beginRoot(LANGUAGE); OperationLocal local = b.createLocal(); @@ -903,7 +929,7 @@ public void testTeeLocal() { b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); Assert.assertEquals(1L, root.call()); @@ -911,7 +937,7 @@ public void testTeeLocal() { @Test public void testYield() { - RootCallTarget root = parse(b -> { + RootCallTarget root = parse(b -> { b.beginRoot(LANGUAGE); b.beginYield(); b.emitConstObject(1L); b.endYield(); @@ -924,7 +950,7 @@ public void testYield() { b.emitConstObject(3L); b.endReturn(); - b.publish(LANGUAGE); + b.endRoot(); }); ContinuationResult r1 = (ContinuationResult) root.call(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 9b2434caac93..f2cd2b2c9f42 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -77,6 +77,8 @@ private static TestOperations deserialize(byte[] byteArray) { private static byte[] createByteArray() { OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, b -> { + b.beginRoot(null); + b.beginReturn(); b.beginAddOperation(); b.emitConstObject(1L); @@ -84,7 +86,7 @@ private static byte[] createByteArray() { b.endAddOperation(); b.endReturn(); - b.publish(null); + b.endRoot(); }); boolean[] haveConsts = new boolean[2]; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index ea7727a9770e..8ac2c22cfb31 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -45,6 +45,7 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; +import java.util.Arrays; import java.util.List; import javax.lang.model.type.TypeKind; @@ -160,6 +161,14 @@ public boolean isRealOperation() { return true; } + public boolean isRoot() { + return false; + } + + public CodeVariableElement getResultVariable() { + return null; + } + public abstract CodeTree createPushCountCode(BuilderVariables vars); public static class Simple extends Operation { @@ -310,6 +319,78 @@ public List getBuilderArgumentTypes() { } } + public static class Root extends Block { + protected Root(OperationsContext context, int id) { + super(context, "Root", id); + } + + @Override + public boolean needsOperationData() { + return false; + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getTypes().TruffleLanguage); + } + + @Override + public CodeVariableElement getResultVariable() { + return new CodeVariableElement(context.getData().getTemplateType().asType(), "endCodeResult"); + } + + @Override + public boolean isRoot() { + return true; + } + + @Override + public CodeTree createBeginCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(super.createBeginCode(vars)); + + b.statement("this.parentData = new BuilderState(this)"); + b.statement("this.bc = new short[65535]"); + b.statement("this.constPool = new ArrayList<>()"); + b.statement("this.labels = new ArrayList<>()"); + b.statement("this.labelFills = new ArrayList<>()"); + b.statement("this.exceptionHandlers = new ArrayList<>()"); + b.statement("this.stackSourceBci = new int[1024]"); + b.statement("reset(arg0)"); + return b.build(); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(super.createBeginCode(vars)); + + b.declaration(context.getData().getTemplateType().asType(), "endCodeResult", (CodeTree) null); + + b.statement("endCodeResult = publish((TruffleLanguage) operationData.arguments[0])"); + + b.statement("this.bc = parentData.bc"); + b.statement("this.bci = parentData.bci"); + b.statement("this.curStack = parentData.curStack"); + b.statement("this.maxStack = parentData.maxStack"); + b.statement("this.numLocals = parentData.numLocals"); + b.statement("this.numLabels = parentData.numLabels"); + b.statement("this.constPool = parentData.constPool"); + b.statement("this.operationData = parentData.operationData"); + b.statement("this.labels = parentData.labels"); + b.statement("this.labelFills = parentData.labelFills"); + b.statement("this.numChildNodes = parentData.numChildNodes"); + b.statement("this.numConditionProfiles = parentData.numConditionProfiles"); + b.statement("this.exceptionHandlers = parentData.exceptionHandlers"); + b.statement("this.currentFinallyTry = parentData.currentFinallyTry"); + b.statement("this.stackSourceBci = parentData.stackSourceBci"); + + b.statement("this.parentData = parentData.parentData"); + + return b.build(); + } + } + public static class IfThen extends Operation { protected IfThen(OperationsContext builder, int id) { super(builder, "IfThen", id, 2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index b9254b1ea995..f0c5070ea3a7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -52,6 +52,7 @@ import java.util.Set; import java.util.concurrent.locks.Lock; +import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -910,6 +911,10 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "stackSourceBci = new int[1024]")); typBuilderImpl.add(createBuilderImplDoBeforeEmitInstruction()); + CodeTypeElement typBuilderState = typBuilderImpl.add(createBuilderState(typBuilderImpl, "bc", "bci", "curStack", "maxStack", "numLocals", "numLabels", "yieldCount", "yieldLocations", + "constPool", "operationData", "labels", "labelFills", "numChildNodes", "numConditionProfiles", "exceptionHandlers", "currentFinallyTry", "stackSourceBci")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typBuilderState.asType(), "parentData")); + typBuilderImpl.add(createDoLeaveFinallyTry(opDataImpl)); typBuilderImpl.add(createBuilderImplDoEmitLabel(typLabelData)); typBuilderImpl.addAll(createBuilderImplCalculateLeaves(opDataImpl, typLabelData)); @@ -993,6 +998,35 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, return typBuilderImpl; } + private CodeTypeElement createBuilderState(CodeTypeElement typBuilder, String... fields) { + CodeTypeElement typ = new CodeTypeElement(MOD_FINAL, ElementKind.CLASS, null, "BuilderState"); + typ.add(new CodeVariableElement(typ.asType(), "parentData")); + + ArrayList foundFields = new ArrayList<>(); + + for (String s : fields) { + for (VariableElement field : ElementFilter.fieldsIn(typBuilder.getEnclosedElements())) { + String fn = field.getSimpleName().toString(); + if (fn.equals(s) || fn.startsWith(s + " ")) { + typ.add(CodeVariableElement.clone(field)); + foundFields.add(s); + break; + } + } + } + + foundFields.add("parentData"); + + CodeExecutableElement ctor = typ.add(new CodeExecutableElement(null, "BuilderState")); + ctor.addParameter(new CodeVariableElement(typBuilder.asType(), "p")); + CodeTreeBuilder b = ctor.createBuilder(); + for (String s : foundFields) { + b.statement(String.format("this.%s = p.%s", s, s)); + } + + return typ; + } + private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement typBuilder) { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); met.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); @@ -1078,7 +1112,9 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement int i = 0; for (TypeMirror argType : op.getBuilderArgumentTypes()) { // ARGUMENT DESERIALIZATION - if (ElementUtils.typeEquals(argType, types.OperationLocal)) { + if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) { + b.declaration(types.TruffleLanguage, "arg" + i, "language"); + } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) { b.statement("OperationLocal arg" + i + " = locals.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer." + DATA_READ_METHOD_PREFIX + "Short()]"); @@ -1758,7 +1794,8 @@ private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, } private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "emit" + op.name); + CodeVariableElement resVariable = op.getResultVariable(); + CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_FINAL, resVariable == null ? context.getType(void.class) : resVariable.asType(), "emit" + op.name); createBeginArguments(op, metEmit); @@ -1818,6 +1855,10 @@ private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, Bu b.end(); } + if (resVariable != null) { + b.startReturn().variable(resVariable).end(); + } + return metEmit; } @@ -1837,7 +1878,8 @@ private CodeTypeElement createCounter() { } private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "end" + op.name); + CodeVariableElement resultVar = op.getResultVariable(); + CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_FINAL, resultVar == null ? context.getType(void.class) : resultVar.getType(), "end" + op.name); GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); // if (operationData.id != ID) throw; @@ -1853,7 +1895,11 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui serializationWrapException(b, () -> { b.startStatement().string("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((").variable(op.idConstantField).string(" << 1) | 1))").end(); }); - b.returnStatement(); + if (op.isRoot()) { + b.startReturn().string("publish(null)").end(); + } else { + b.returnStatement(); + } b.end(); } @@ -1899,7 +1945,7 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); } - if (op.isRealOperation()) { + if (op.isRealOperation() && !op.isRoot()) { b.statement("doAfterChild()"); } @@ -1909,6 +1955,10 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui vars.numChildren = null; + if (resultVar != null) { + b.startReturn().variable(resultVar).end(); + } + return metEnd; } @@ -1938,7 +1988,7 @@ private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, B b.statement("indent++"); } - if (op.isRealOperation()) { + if (op.isRealOperation() && !op.isRoot()) { b.statement("doBeforeChild()"); } @@ -1977,7 +2027,9 @@ private void createBeginOperationSerialize(BuilderVariables vars, Operation op, int i = 0; for (TypeMirror argType : op.getBuilderArgumentTypes()) { // ARGUMENT SERIALIZATION - if (ElementUtils.typeEquals(argType, types.OperationLocal)) { + if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) { + // nothing + } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) { after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationLocalImpl) arg" + i + ").id)"); } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) arg" + i + ".length)"); @@ -2043,7 +2095,7 @@ private CodeExecutableElement createSetResultUnboxed() { } private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperationNodeImpl) { - CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PUBLIC, m.getTemplateType().asType(), "publish"); + CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PRIVATE, m.getTemplateType().asType(), "publish"); CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); mPublish.addParameter(parLanguage); @@ -2117,7 +2169,7 @@ private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperat b.end(); b.statement("buildIndex++"); - b.statement("reset()"); + b.statement("reset(language)"); b.statement("return result"); @@ -2507,8 +2559,6 @@ private CodeExecutableElement createBuilderImplCtor(CodeTypeElement opNodesImpl) b.statement("this.sourceBuilder = withSource ? new SourceInfoBuilder() : null"); - b.statement("reset()"); - return ctor; } @@ -2530,6 +2580,7 @@ private CodeExecutableElement createBuilderImplFinish() { private CodeExecutableElement createBuilderImplReset() { CodeExecutableElement mReset = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "reset"); + mReset.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); CodeTreeBuilder b = mReset.createBuilder(); @@ -2538,7 +2589,7 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("maxStack = 0"); b.statement("numLocals = 0"); b.statement("constPool.clear()"); - b.statement("operationData = new BuilderOperationData(null, OP_BLOCK, 0, 0, false, 0)"); + b.statement("operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language)"); b.statement("labelFills.clear()"); b.statement("numChildNodes = 0"); b.statement("numConditionProfiles = 0"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 78d96cf59735..83aa18f4384b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -118,6 +118,7 @@ private void createCommonInstructions() { private void createBuiltinOperations() { add(new Operation.Block(this, operationId++)); + add(new Operation.Root(this, operationId++)); add(new Operation.IfThen(this, operationId++)); add(new Operation.IfThenElse(this, operationId++, false)); add(new Operation.IfThenElse(this, operationId++, true)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index f7c97bb724e9..896704132c1e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -58,6 +58,7 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 68b3adf8f415..3449911775eb 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -150,6 +150,7 @@ public Void visit(ParseTree tree) { @Override public Void visitFunction(FunctionContext ctx) { TruffleString name = asTruffleString(ctx.IDENTIFIER(0).getSymbol(), false); + b.beginRoot(language); b.setMethodName(name); @@ -183,7 +184,7 @@ public Void visitFunction(FunctionContext ctx) { b.endTag(); b.endSource(); - OperationRootNode node = b.publish(language); + OperationRootNode node = b.endRoot(); if (DO_LOG_NODE_CREATION) { try { From 0441a0d6a6eab75480f23c1553a7ac8d0acd4b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 22 Sep 2022 09:42:33 +0200 Subject: [PATCH 136/312] [wip] tests & serialization fix --- .../api/operation/test/bml/BenmarkSimple.java | 4 +- .../test/example/TestOperations.java | 8 ++++ .../example/TestOperationsParserTest.java | 45 +++++++++++++++++-- .../dsl/processor/operations/Operation.java | 1 + .../operations/OperationsCodeGenerator.java | 32 ++++++------- 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index 47707695b4aa..22d998a51e98 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -331,6 +331,8 @@ private static void endMod(Builder b, int mode) { } private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode) { + b.beginRoot(lang); + OperationLocal iLoc = b.createLocal(); OperationLocal sumLoc = b.createLocal(); OperationLocal jLoc = b.createLocal(); @@ -433,7 +435,7 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode b.emitLoadLocal(sumLoc); b.endReturn(); - b.publish(lang); + b.endRoot(); } @Setup(Level.Trial) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index a46518bdb124..81920a739f98 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -176,6 +176,14 @@ public static Integer doCached(Integer i, @Cached("i") Integer cachedI) { return cachedI; } } + + @Operation + public static final class Invoke { + @Specialization + public static Object doInvoke(TestOperations root, @Variadic Object[] args) { + return root.getCallTarget().call(args); + } + } } class TestLanguage extends TruffleLanguage { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index c7f9e636d44e..baa32b48b4a2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -54,6 +54,7 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; +import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationParser; @@ -64,12 +65,18 @@ public class TestOperationsParserTest { private static RootCallTarget parse(OperationParser builder) { OperationRootNode operationsNode = parseNode(builder); - System.out.println(operationsNode.dump()); return ((RootNode) operationsNode).getCallTarget(); } private static OperationRootNode parseNode(OperationParser builder) { - return TestOperationsGen.create(OperationConfig.DEFAULT, builder).getNodes().get(0); + OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, builder); + + for (OperationRootNode node : nodes.getNodes()) { + System.out.println("-------------------------------------"); + System.out.println(node.dump()); + } + + return nodes.getNodes().get(0); } @Test @@ -937,7 +944,9 @@ public void testTeeLocal() { @Test public void testYield() { - RootCallTarget root = parse(b -> { b.beginRoot(LANGUAGE); + RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + b.beginYield(); b.emitConstObject(1L); b.endYield(); @@ -961,4 +970,34 @@ public void testYield() { Assert.assertEquals(3L, r2.continueWith(null)); } + + @Test + public void testNestedFunctions() { + RootCallTarget root = parse(b -> { + // this simulates following in python: + // return (lambda: 1)() + b.beginRoot(LANGUAGE); + + b.beginReturn(); + + b.beginInvoke(); + + b.beginRoot(LANGUAGE); + + b.beginReturn(); + b.emitConstObject(1L); + b.endReturn(); + + TestOperations innerRoot = b.endRoot(); + + b.emitConstObject(innerRoot); + b.endInvoke(); + + b.endReturn(); + + b.endRoot(); + }); + + Assert.assertEquals(1L, root.call()); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 8ac2c22cfb31..e931f55e5128 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -349,6 +349,7 @@ public CodeTree createBeginCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.tree(super.createBeginCode(vars)); + // todo: there is no need to store the state at top level b.statement("this.parentData = new BuilderState(this)"); b.statement("this.bc = new short[65535]"); b.statement("this.constPool = new ArrayList<>()"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index f0c5070ea3a7..cbde6bf08c6e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -109,7 +109,6 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory { - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_PUBLISH + ")"); - b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder(), buildIndex++)"); - b.statement("numLocals = 0"); - b.statement("numLabels = 0"); - b.statement("return result"); - }); + b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder(), buildIndex++)"); + b.statement("numLocals = 0"); + b.statement("numLabels = 0"); + b.statement("return result"); b.end(); } From c73fc5b39dcea47c384afe03ff76c94ce54991a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 22 Sep 2022 10:21:34 +0200 Subject: [PATCH 137/312] [wip] fix compilation of tests --- .../api/operation/test/bml/BMLNode.java | 4 + .../test/bml/ManualBytecodeNode.java | 117 ++++++++++-------- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java index e880a37f13bb..7e4e0b0c4a19 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java @@ -9,6 +9,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ControlFlowException; import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -206,9 +207,12 @@ public static WhileNode create(BMLNode condition, BMLNode body) { @Override public Object execute(VirtualFrame frame) { try { + int count = 0; while (condition.executeBool(frame)) { body.execute(frame); + count++; } + LoopNode.reportLoopCount(this, count); return VOID; } catch (UnexpectedResultException e) { throw CompilerDirectives.shouldNotReachHere(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java index fa332da391c2..874caad55356 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -54,37 +54,15 @@ import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; import com.oracle.truffle.api.nodes.RootNode; -public class ManualBytecodeNode extends RootNode implements BytecodeOSRNode { - - @CompilationFinal(dimensions = 1) private short[] bc; - - static final short OP_JUMP = 1; - static final short OP_CONST = 2; - static final short OP_ADD = 3; - static final short OP_JUMP_FALSE = 4; - static final short OP_LESS = 5; - static final short OP_RETURN = 6; - static final short OP_ST_LOC = 7; - static final short OP_LD_LOC = 8; - static final short OP_MOD = 9; - +public class ManualBytecodeNode extends BaseBytecodeNode { protected ManualBytecodeNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { - super(language, frameDescriptor); - this.bc = bc; + super(language, frameDescriptor, bc); } @Override - public Object execute(VirtualFrame frame) { - return executeAt(frame, 0, 0); - } - - private static class Counter { - int count; - } - @BytecodeInterpreterSwitch @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - private Object executeAt(VirtualFrame frame, int startBci, int startSp) { + protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { short[] localBc = bc; int bci = startBci; int sp = startSp; @@ -100,16 +78,9 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { int nextBci = localBc[bci + 1]; CompilerAsserts.partialEvaluationConstant(nextBci); if (nextBci <= bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll(this); - LoopNode.reportLoopCount(this, 256); - loopCounter.count = 0; - } - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { - Object osrResult = BytecodeOSRNode.tryOSR(this, (sp << 16) | nextBci, null, null, frame); - if (osrResult != null) { - return osrResult; - } + Object result = backwardsJumpCheck(frame, sp, loopCounter, nextBci); + if (result != null) { + return result; } } bci = nextBci; @@ -185,24 +156,16 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { } } - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return executeAt(osrFrame, target >> 16, target & 0xffff); - } - - @CompilationFinal private Object osrMetadata; +} - public Object getOSRMetadata() { - return osrMetadata; - } +abstract class BaseBytecodeNode extends RootNode implements BytecodeOSRNode { - public void setOSRMetadata(Object osrMetadata) { - this.osrMetadata = osrMetadata; + protected BaseBytecodeNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { + super(language, frameDescriptor); + this.bc = bc; } -} - -class ManualBytecodeNodeNBE extends RootNode { - @CompilationFinal(dimensions = 1) private short[] bc; + @CompilationFinal(dimensions = 1) protected short[] bc; static final short OP_JUMP = 1; static final short OP_CONST = 2; @@ -214,9 +177,8 @@ class ManualBytecodeNodeNBE extends RootNode { static final short OP_LD_LOC = 8; static final short OP_MOD = 9; - protected ManualBytecodeNodeNBE(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { - super(language, frameDescriptor); - this.bc = bc; + protected static class Counter { + int count; } @Override @@ -224,13 +186,56 @@ public Object execute(VirtualFrame frame) { return executeAt(frame, 0, 0); } + protected abstract Object executeAt(VirtualFrame osrFrame, int startBci, int startSp); + + protected final Object backwardsJumpCheck(VirtualFrame frame, int sp, Counter loopCounter, int nextBci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll(this); + LoopNode.reportLoopCount(this, 256); + loopCounter.count = 0; + } + + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge(this)) { + Object osrResult = BytecodeOSRNode.tryOSR(this, (sp << 16) | nextBci, null, null, frame); + if (osrResult != null) { + return osrResult; + } + } + + return null; + } + + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target & 0xffff, target >> 16); + } + + @CompilationFinal private Object osrMetadata; + + public Object getOSRMetadata() { + return osrMetadata; + } + + public void setOSRMetadata(Object osrMetadata) { + this.osrMetadata = osrMetadata; + } +} + +class ManualBytecodeNodeNBE extends BaseBytecodeNode { + + protected ManualBytecodeNodeNBE(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { + super(language, frameDescriptor, bc); + } + + @Override @BytecodeInterpreterSwitch @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - private Object executeAt(VirtualFrame frame, int startBci, int startSp) { + protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { short[] localBc = bc; int bci = startBci; int sp = startSp; + Counter counter = new Counter(); + loop: while (true) { short opcode = localBc[bci]; CompilerAsserts.partialEvaluationConstant(opcode); @@ -239,6 +244,12 @@ private Object executeAt(VirtualFrame frame, int startBci, int startSp) { case OP_JUMP: { int nextBci = localBc[bci + 1]; CompilerAsserts.partialEvaluationConstant(nextBci); + if (nextBci <= bci) { + Object result = backwardsJumpCheck(frame, sp, counter, nextBci); + if (result != null) { + return result; + } + } bci = nextBci; continue loop; } From 64f7f4b1ab68e8512673aabf4d6a859c7f44f781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 26 Sep 2022 16:32:59 +0200 Subject: [PATCH 138/312] [wip] more yielding --- .../example/TestOperationsParserTest.java | 91 +++++++++++++++++++ .../com/oracle/truffle/api/frame/Frame.java | 2 +- .../truffle/api/impl/FrameWithoutBoxing.java | 21 +++-- .../truffle/api/impl/UnsafeFrameAccess.java | 7 ++ .../OperationsBytecodeCodeGenerator.java | 20 ++-- .../OperationsBytecodeNodeGeneratorPlugs.java | 22 +++-- .../operations/OperationsCodeGenerator.java | 50 ++++++++-- .../operations/OperationsContext.java | 6 +- .../instructions/BranchInstruction.java | 6 +- .../ConditionalBranchInstruction.java | 2 +- .../instructions/CustomInstruction.java | 29 ++++-- .../instructions/DiscardInstruction.java | 2 +- .../operations/instructions/Instruction.java | 3 +- .../InstrumentationEnterInstruction.java | 2 +- .../InstrumentationExitInstruction.java | 2 +- .../InstrumentationLeaveInstruction.java | 4 +- .../instructions/LoadArgumentInstruction.java | 8 +- .../instructions/LoadConstantInstruction.java | 6 +- .../instructions/LoadLocalInstruction.java | 48 +++------- .../instructions/QuickenedInstruction.java | 5 +- .../instructions/ShortCircuitInstruction.java | 10 +- .../instructions/StoreLocalInstruction.java | 51 +++-------- .../instructions/ThrowInstruction.java | 2 +- .../instructions/YieldInstruction.java | 6 +- 24 files changed, 267 insertions(+), 138 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index baa32b48b4a2..f5b4fb2fd321 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -971,6 +971,97 @@ public void testYield() { Assert.assertEquals(3L, r2.continueWith(null)); } + + @Test + public void testYieldLocal() { + RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + + OperationLocal loc = b.createLocal(); + + // loc = 0 + // yield loc + // loc = loc + 1 + // yield loc + // loc = loc + 1 + // return loc + + b.beginStoreLocal(loc); + b.emitConstObject(0L); + b.endStoreLocal(); + + b.beginYield(); + b.emitLoadLocal(loc); + b.endYield(); + + b.beginStoreLocal(loc); + b.beginAddOperation(); + b.emitLoadLocal(loc); + b.emitConstObject(1L); + b.endAddOperation(); + b.endStoreLocal(); + + b.beginYield(); + b.emitLoadLocal(loc); + b.endYield(); + + b.beginStoreLocal(loc); + b.beginAddOperation(); + b.emitLoadLocal(loc); + b.emitConstObject(1L); + b.endAddOperation(); + b.endStoreLocal(); + + b.beginReturn(); + b.emitLoadLocal(loc); + b.endReturn(); + + b.endRoot(); + }); + + ContinuationResult r1 = (ContinuationResult) root.call(); + Assert.assertEquals(0L, r1.getResult()); + + ContinuationResult r2 = (ContinuationResult) r1.continueWith(null); + Assert.assertEquals(1L, r2.getResult()); + + Assert.assertEquals(2L, r2.continueWith(null)); + } + @Test + public void testYieldStack() { + RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); + + OperationLocal loc = b.createLocal(); + + // return (yield 1) + (yield 2) + b.beginReturn(); + b.beginAddOperation(); + + b.beginYield(); + b.emitConstObject(1L); + b.endYield(); + + b.beginYield(); + b.emitConstObject(2L); + b.endYield(); + + b.endAddOperation(); + b.endReturn(); + + + b.endRoot(); + }); + + ContinuationResult r1 = (ContinuationResult) root.call(); + Assert.assertEquals(1L, r1.getResult()); + + ContinuationResult r2 = (ContinuationResult) r1.continueWith(3L); + Assert.assertEquals(2L, r2.getResult()); + + Assert.assertEquals(7L, r2.continueWith(4L)); + } + @Test public void testNestedFunctions() { RootCallTarget root = parse(b -> { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java index 235ef42086e7..759f4030112c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java @@ -789,7 +789,7 @@ default void clearObjectStatic(int slot) { * @param slot the slot of the local variable * @since 22.2 */ - default void copyTo(Frame other, int start, int length) { + default void copyTo(int srcOffset, Frame dst, int dstOffset, int length) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnsupportedOperationException(); } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index a256ad3a4c9a..260619d307ba 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -920,24 +920,29 @@ public void clearObjectStatic(int slot) { indexedLocals[slot] = null; } - public void copyTo(Frame other, int offset, int length) { - FrameWithoutBoxing o = (FrameWithoutBoxing) other; - if (o.descriptor != descriptor || offset < 0 || offset + length >= getIndexedTags().length) { + @Override + public void copyTo(int srcOffset, Frame dst, int dstOffset, int length) { + FrameWithoutBoxing o = (FrameWithoutBoxing) dst; + if (o.descriptor != descriptor // + || srcOffset < 0 // + || srcOffset + length > getIndexedTags().length // + || dstOffset < 0 // + || dstOffset + length > o.getIndexedTags().length) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw frameSlotTypeException(); } - unsafeCopyTo(o, offset, length); + unsafeCopyTo(srcOffset, o, dstOffset, length); } - void unsafeCopyTo(FrameWithoutBoxing o, int offset, int length) { + void unsafeCopyTo(int srcOffset, FrameWithoutBoxing o, int dstOffset, int length) { if (length == 0) { return; } - System.arraycopy(getIndexedTags(), offset, o.getIndexedTags(), offset, length); - System.arraycopy(getIndexedLocals(), offset, o.getIndexedLocals(), offset, length); - System.arraycopy(getIndexedPrimitiveLocals(), offset, o.getIndexedPrimitiveLocals(), offset, length); + System.arraycopy(getIndexedTags(), srcOffset, o.getIndexedTags(), dstOffset, length); + System.arraycopy(getIndexedLocals(), srcOffset, o.getIndexedLocals(), dstOffset, length); + System.arraycopy(getIndexedPrimitiveLocals(), srcOffset, o.getIndexedPrimitiveLocals(), dstOffset, length); // int offsetTag = Unsafe.ARRAY_BYTE_BASE_OFFSET + offset * Unsafe.ARRAY_BYTE_INDEX_SCALE; // UNSAFE.copyMemory(getIndexedTags(), offsetTag, o.getIndexedTags(), offsetTag, length * diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 8280e85dbf1c..9e23934bc54c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -97,6 +97,8 @@ public static UnsafeFrameAccess lookup() { public abstract void unsafeCopy(Frame frame, int srcSlot, int dstSlot); + public abstract void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length); + public abstract void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot); public abstract void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot); @@ -221,6 +223,11 @@ public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { castFrame(frame).unsafeCopy(srcSlot, dstSlot); } + @Override + public void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length) { + castFrame(srcFrame).unsafeCopyTo(srcOffset, castFrame(dstFrame), dstOffset, length); + } + @Override public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { castFrame(frame).unsafeCopyObject(srcSlot, dstSlot); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 628c6ba7b984..c35b5364c05e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -138,7 +138,7 @@ private CodeExecutableElement createPrepareAot(CodeTypeElement baseType) { CodeTreeBuilder b = mPrepareForAot.createBuilder(); ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars); + populateVariables(vars, m); b.declaration("int", vars.bci.getName(), "0"); @@ -168,7 +168,7 @@ private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { CodeTreeBuilder b = mDump.getBuilder(); ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars); + populateVariables(vars, m); CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); @@ -226,14 +226,15 @@ private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { return mDump; } - static void populateVariables(ExecutionVariables vars) { + static void populateVariables(ExecutionVariables vars, OperationsData m) { ProcessorContext context = ProcessorContext.getInstance(); TruffleTypes types = context.getTypes(); vars.bc = new CodeVariableElement(context.getType(short[].class), "$bc"); vars.sp = new CodeVariableElement(context.getType(int.class), "$sp"); vars.bci = new CodeVariableElement(context.getType(int.class), "$bci"); - vars.frame = new CodeVariableElement(types.Frame, "$frame"); + vars.stackFrame = new CodeVariableElement(types.Frame, m.enableYield ? "$stackFrame" : "$frame"); + vars.localFrame = new CodeVariableElement(types.Frame, m.enableYield ? "$localFrame" : "$frame"); vars.consts = new CodeVariableElement(context.getType(Object[].class), "$consts"); vars.children = new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children"); } @@ -243,7 +244,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { createExplodeLoop(mContinueAt); ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars); + populateVariables(vars, m); mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); @@ -368,7 +369,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startAssign(vars.sp).string("handler.startStack + maxLocals").end(); // todo: check exception type (?) - b.startStatement().startCall(vars.frame, "setObject").string("handler.exceptionIndex").string("ex").end(2); + b.startStatement().startCall(vars.stackFrame, "setObject").string("handler.exceptionIndex").string("ex").end(2); b.statement("$bci = handler.handlerBci"); b.statement("continue loop"); @@ -514,7 +515,12 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(short[].class), "$bc")); exToCopy.getParameters().add(0, new CodeVariableElement(opNodeImpl.asType(), "$this")); if (!isBoundary) { - exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); + if (m.enableYield) { + exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$localFrame")); + exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$stackFrame")); + } else { + exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); + } } exToCopy.getModifiers().remove(Modifier.PUBLIC); exToCopy.getModifiers().add(Modifier.PRIVATE); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index b22ccea5be13..52e98d876bad 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -112,12 +112,12 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator { context = ProcessorContext.getInstance(); types = context.getTypes(); - OperationsBytecodeCodeGenerator.populateVariables(dummyVariables); } OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, boolean isVariadic, CustomInstruction cinstr, StaticConstants staticConstants, boolean uncached) { this.m = m; + OperationsBytecodeCodeGenerator.populateVariables(dummyVariables, m); this.innerTypeNames = innerTypeNames; this.methodNames = methodNames; this.isVariadic = isVariadic; @@ -203,7 +203,12 @@ public String transformNodeInnerTypeName(String name) { @Override public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { if (!isBoundary) { - builder.string("$frame"); + if (m.enableYield) { + builder.string("$stackFrame"); + builder.string("$localFrame"); + } else { + builder.string("$frame"); + } } builder.string("$this"); @@ -436,7 +441,7 @@ public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List> 16) & 0xffff"); - b.statement("parentFrame.copyTo(frame, 0, sp - 1)"); + b.declaration("int", "sp", "((target >> 16) & 0xffff) + root._maxLocals"); + b.statement("parentFrame.copyTo(root._maxLocals, frame, root._maxLocals, sp - 1 - root._maxLocals)"); b.statement("frame.setObject(sp - 1, inputValue)"); - b.statement("return root.executeAt(frame, target)"); + // b.statement("System.err.printf(\" continuing: %s %s %d%n\", frame, parentFrame, (target + // >> 16) + root._maxLocals)"); + + b.statement("return root.executeAt(frame, parentFrame, (sp << 16) | (target & 0xffff))"); return cr; } @@ -569,7 +576,15 @@ private CodeExecutableElement createNodeExecute() { b.declaration("Throwable", "throwable", "null"); b.statement("executeProlog(frame)"); b.startTryBlock(); - b.startAssign("returnValue").startCall("executeAt").string("frame, _maxLocals << 16").end(2); + + b.startAssign("returnValue").startCall("executeAt"); + b.string("frame"); + if (m.enableYield) { + b.string("frame"); + } + b.string("_maxLocals << 16"); + b.end(2); + b.startReturn().string("returnValue").end(); b.end().startCatchBlock(context.getType(Throwable.class), "th"); b.statement("throw sneakyThrow(throwable = th)"); @@ -691,7 +706,12 @@ private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNod private CodeExecutableElement createNodeImplExecuteAt() { CodeExecutableElement mExecuteAt = new CodeExecutableElement(MOD_PRIVATE, context.getType(Object.class), "executeAt"); - mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + if (m.enableYield) { + mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "stackFrame")); + mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "localFrame")); + } else { + mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + } mExecuteAt.addParameter(new CodeVariableElement(context.getType(int.class), "storedLocation")); CodeTreeBuilder b = mExecuteAt.createBuilder(); @@ -700,7 +720,12 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.startAssign("result").startCall("switchImpl", "continueAt"); b.string("this"); - b.string("frame"); + if (m.enableYield) { + b.string("stackFrame"); + b.string("localFrame"); + } else { + b.string("frame"); + } b.string("_bc"); b.string("result & 0xffff"); b.string("(result >> 16) & 0xffff"); @@ -719,7 +744,9 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.end(); - b.startReturn().string("frame.getObject((result >> 16) & 0xffff)").end(); + b.startReturn(); + b.string(m.enableYield ? "stackFrame" : "frame"); + b.string(".getObject((result >> 16) & 0xffff)").end(); return mExecuteAt; } @@ -1661,7 +1688,12 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT CodeExecutableElement loopMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(int.class), "continueAt"); loopMethod.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); - loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); + if (m.enableYield) { + loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$stackFrame")); + loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$localFrame")); + } else { + loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); + } loopMethod.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 83aa18f4384b..a7296932f597 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -210,13 +210,13 @@ public void processOperation(SingleOperationData opData) { } if (opData.isShortCircuit()) { - ShortCircuitInstruction instr = add(new ShortCircuitInstruction("sc." + opData.getName(), getNextInstructionId(), opData)); + ShortCircuitInstruction instr = add(new ShortCircuitInstruction(this, "sc." + opData.getName(), getNextInstructionId(), opData)); customInstructionNameMap.put(opData.getName(), instr); opDataNameMap.put(opData.getName(), opData); add(new ShortCircuitOperation(this, opData.getName(), getNextOperationId(), instr)); } else { - CustomInstruction instr = new CustomInstruction("c." + opData.getName(), getNextInstructionId(), opData); + CustomInstruction instr = new CustomInstruction(this, "c." + opData.getName(), getNextInstructionId(), opData); add(instr); customInstructionNameMap.put(opData.getName(), instr); opDataNameMap.put(opData.getName(), opData); @@ -243,7 +243,7 @@ public void processDecisions(OperationDecisions decisions) { SingleOperationData opData = opDataNameMap.get(quicken.getOperation()); - add(new QuickenedInstruction(cinstr, instructionId++, opData, List.of(quicken.specializations))); + add(new QuickenedInstruction(this, cinstr, instructionId++, opData, List.of(quicken.specializations))); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 88e348f0242e..018a1c223a33 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -121,14 +121,14 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); b.string("$this"); b.string("($sp << 16) | targetBci"); + b.variable(vars.localFrame); b.string("null"); - b.string("null"); - b.variable(vars.frame); + b.variable(vars.stackFrame); b.end(2); b.startIf().string("osrResult != null").end().startBlock(); // { // todo: check if this will overwrite a local in reused frames - b.statement("$frame.setObject(0, osrResult)"); + b.startStatement().variable(vars.stackFrame).string(".setObject(0, osrResult)").end(); b.startReturn().string("0x0000ffff").end(); b.end(); // } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 2e246b894462..c35cbec3c238 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -71,7 +71,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) - b.declaration("boolean", "cond", "UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE"); + b.declaration("boolean", "cond", "UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - 1) == Boolean.TRUE"); b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 8e1213593ab8..82461fd649c5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -52,12 +52,14 @@ import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public class CustomInstruction extends Instruction { + protected final OperationsContext ctx; private final SingleOperationData data; protected ExecutableElement executeMethod; protected ExecutableElement uncachedExecuteMethod; @@ -88,8 +90,9 @@ public void setExecuteMethod(ExecutableElement executeMethod) { this.executeMethod = executeMethod; } - public CustomInstruction(String name, int id, SingleOperationData data) { + public CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { super(name, id, data.getMainProperties().returnsValue ? 1 : 0); + this.ctx = ctx; this.data = data; initializePops(); } @@ -124,8 +127,9 @@ protected void initializePops() { } } - protected CustomInstruction(String name, int id, SingleOperationData data, int pushCount) { + protected CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data, int pushCount) { super(name, id, pushCount); + this.ctx = ctx; this.data = data; } @@ -168,13 +172,13 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { String inputName = "input_" + inputIndex; switch (kind) { case STACK_VALUE: - b.declaration("Object", inputName, "UFA.unsafeGetObject($frame, $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); + b.declaration("Object", inputName, "UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VARIADIC: b.declaration("Object[]", inputName, "new Object[numVariadics]"); b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); - b.startStatement().string(inputName, "[varIndex] = UFA.unsafeGetObject($frame, $sp - numVariadics + varIndex)").end(); + b.startStatement().string(inputName, "[varIndex] = UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics + varIndex)").end(); b.end(); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; @@ -192,7 +196,10 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } b.startStaticCall(method); - b.variable(vars.frame); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } b.string("$this"); b.variable(vars.bc); b.variable(vars.bci); @@ -211,7 +218,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (numPushedValues > 0) { b.startStatement().startCall("UFA", "unsafeSetObject"); - b.string("$frame"); + b.variable(vars.stackFrame); b.string("$sp - 1"); b.string("result"); b.end(2); @@ -220,7 +227,10 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } else { b.startStatement(); b.startStaticCall(method); - b.variable(vars.frame); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } b.string("$this"); b.variable(vars.bc); b.variable(vars.bci); @@ -230,7 +240,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (uncached) { for (int i = numPopStatic(); i > 0; i--) { - b.string("UFA.unsafeGetObject($frame, $sp - " + i + ")"); + b.string("UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - " + i + ")"); } addLocalRefs(b, vars); @@ -317,6 +327,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().startStaticCall(prepareAOTMethod); b.string("null"); + if (ctx.getData().enableYield) { + b.string("null"); + } b.string("$this"); b.string("$bc"); b.variable(vars.bci); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index b97d64dc6168..7a673339dc80 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -55,7 +55,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - b.startStatement().startCall(vars.frame, "clear"); + b.startStatement().startCall(vars.stackFrame, "clear"); b.variable(vars.sp); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 919bb5410bb2..1a453e787d79 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -61,7 +61,8 @@ public abstract class Instruction { public static class ExecutionVariables { public CodeVariableElement bc; public CodeVariableElement bci; - public CodeVariableElement frame; + public CodeVariableElement localFrame; + public CodeVariableElement stackFrame; public CodeVariableElement sp; public CodeVariableElement consts; public CodeVariableElement children; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index 5b096afa7ae0..ee098f14c062 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -64,7 +64,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement(); b.startCall("probe", "onEnter"); - b.variable(vars.frame); + b.variable(vars.localFrame); b.end(2); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 9623eda5fa45..53e2af37be7a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -72,7 +72,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement(); b.startCall("probe", "onReturnValue"); - b.variable(vars.frame); + b.variable(vars.localFrame); if (returnsValue) { b.variable(vars.inputs[1]); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index 810380c2d4f8..a13d07f30f1e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -65,7 +65,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("Object result"); b.startCall("probe", "onReturnExceptionalOrUnwind"); - b.variable(vars.frame); + b.variable(vars.localFrame); b.string("null"); b.string("false"); b.end(2); @@ -79,7 +79,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startBlock(); // HACK, refactor this push somehow - b.startStatement().startCall(vars.frame, "setObject").string("sp++").string("result").end(2); + b.startStatement().startCall(vars.stackFrame, "setObject").string("sp++").string("result").end(2); b.startAssign(vars.results[0]).variable(vars.inputs[2]).end(); b.end().startElseBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 2a790e65e70d..c5d02c2ecbf8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -61,7 +61,7 @@ public LoadArgumentInstruction(OperationsContext ctx, int id, FrameKind kind) { private CodeTree createGetValue(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startCall(vars.frame, "getArguments").end(); + b.startCall(vars.localFrame, "getArguments").end(); b.string("["); b.tree(createArgumentIndex(vars, 0, false)); b.string("]"); @@ -77,7 +77,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (kind == FrameKind.OBJECT) { b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.frame); + b.variable(vars.localFrame); b.variable(vars.sp); b.string("value"); b.end(2); @@ -85,7 +85,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); // { b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.frame); + b.variable(vars.localFrame); b.variable(vars.sp); b.string("(", kind.getTypeName(), ") value"); b.end(2); @@ -93,7 +93,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end().startElseBlock(); // { b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall(vars.frame, "setObject"); + b.startStatement().startCall(vars.localFrame, "setObject"); b.variable(vars.sp); b.string("value"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 55147621a9e2..7160f6494a81 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -72,7 +72,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { context.getType(void.class), "do_loadConstantObject"); - metImpl.addParameter(vars.frame); + metImpl.addParameter(vars.stackFrame); metImpl.addParameter(vars.bc); metImpl.addParameter(vars.bci); metImpl.addParameter(vars.sp); @@ -81,7 +81,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = metImpl.getBuilder(); b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.frame); + b.variable(vars.stackFrame); b.variable(vars.sp); b.tree(createGetArgument(vars)); b.end(2); @@ -91,7 +91,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder bOuter = CodeTreeBuilder.createBuilder(); bOuter.startStatement().startCall("do_loadConstantObject"); - bOuter.variable(vars.frame); + bOuter.variable(vars.stackFrame); bOuter.variable(vars.bc); bOuter.variable(vars.bci); bOuter.variable(vars.sp); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 95d2a896e448..496e6252f42e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -77,40 +77,20 @@ public BoxingEliminationBehaviour boxingEliminationBehaviour() { private static final boolean USE_SPEC_FRAME_COPY = true; - private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); - b.variable(vars.frame); - b.string("localIdx"); - b.variable(vars.sp); - b.end(2); - } - - private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyPrimitive" : "unsafeCopy"); - b.variable(vars.frame); - b.string("localIdx"); - b.variable(vars.sp); - b.end(2); - } - - private static void createSetSlotKind(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.startStatement().startCall(vars.frame, "getFrameDescriptor().setSlotKind"); - b.string("localIdx"); - b.string(tag); - b.end(2); - } - - private static void createReplaceObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "setObject"); - b.string("localIdx"); - b.startCall(vars.frame, "getValue").string("localIdx").end(); - b.end(2); - } - - private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "setObject"); - b.variable(vars.sp); - b.startCall("expectObject").variable(vars.frame).string("localIdx").end(); + private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement(); + if (ctx.getData().enableYield) { + b.startCall(vars.localFrame, "copyTo"); + b.string("localIdx"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("1"); + } else { + b.startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); + b.variable(vars.stackFrame); + b.string("localIdx"); + b.variable(vars.sp); + } b.end(2); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 5376d748c410..36c55743ce9c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -46,6 +46,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; public class QuickenedInstruction extends CustomInstruction { @@ -88,8 +89,8 @@ public String getUniqueName() { return sb.toString(); } - public QuickenedInstruction(CustomInstruction orig, int id, SingleOperationData data, List activeSpecNames) { - super(makeName(orig, activeSpecNames), id, data); + public QuickenedInstruction(OperationsContext ctx, CustomInstruction orig, int id, SingleOperationData data, List activeSpecNames) { + super(ctx, makeName(orig, activeSpecNames), id, data); this.orig = orig; this.activeSpecNames = activeSpecNames; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 3a0167b03e6c..4b43eaf9d3bd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -42,12 +42,13 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; public class ShortCircuitInstruction extends CustomInstruction { - public ShortCircuitInstruction(String name, int id, SingleOperationData data) { - super(name, id, data, 0); + public ShortCircuitInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { + super(ctx, name, id, data, 0); addPopIndexed("value"); addBranchTarget("end"); } @@ -69,7 +70,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } b.startStaticCall(executeMethod); - b.variable(vars.frame); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } b.string("$this"); b.variable(vars.bc); b.variable(vars.bci); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 331bf18c6115..0055a4e857d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -74,42 +74,21 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private static final boolean USE_SPEC_FRAME_COPY = true; - private static void createCopyPrimitive(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyPrimitive" : "unsafeCopy"); - b.variable(vars.frame); - b.string("sourceSlot"); - b.string("localIdx"); - b.end(2); - } - - private static void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); - b.variable(vars.frame); - b.string("sourceSlot"); - b.string("localIdx"); - b.end(2); - } - - private static void createSetSlotKind(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.startStatement().startCall(vars.frame, "getFrameDescriptor().setSlotKind"); - b.string("localIdx"); - b.string(tag); - b.end(2); - } - - private void createSetChildBoxing(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.startStatement().startCall("doSetResultBoxed"); - b.variable(vars.bc); - b.variable(vars.bci); - b.startGroup().tree(createPopIndexedIndex(vars, 0, false)).end(); - b.string(tag); - b.end(2); - } - - private static void createCopyAsObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall(vars.frame, "setObject"); - b.string("localIdx"); - b.startCall("expectObject").variable(vars.frame).string("sourceSlot").end(); + private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement(); + + if (context.getData().enableYield) { + b.startCall(vars.stackFrame, "copyTo"); + b.string("sourceSlot"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.string("1"); + } else { + b.startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); + b.variable(vars.localFrame); + b.string("sourceSlot"); + b.string("localIdx"); + } b.end(2); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index 3506c1e29b6c..c733fef347b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -62,7 +62,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startThrow(); b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); - b.startCall(vars.frame, "getObject").string("slot").end(); + b.startCall(vars.stackFrame, "getObject").string("slot").end(); b.end(); return b.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index 281c12791c8c..26c640df7140 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -46,7 +46,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startStatement().string("ContinuationLocationImpl cont = (ContinuationLocationImpl) $consts[").tree(createConstantIndex(vars, 0)).string("]").end(); - b.statement("$frame.setObject($sp - 1, cont.createResult($frame, $frame.getObject($sp - 1)))"); + b.statement("$stackFrame.copyTo($this._maxLocals, $localFrame, $this._maxLocals, ($sp - 1 - $this._maxLocals))"); + b.statement("$stackFrame.setObject($sp - 1, cont.createResult($localFrame, $stackFrame.getObject($sp - 1)))"); + + // b.statement("System.err.printf(\" yielding: %s %s %d%n\", $stackFrame, $localFrame, + // $sp)"); b.startReturn().string("(($sp - 1) << 16) | 0xffff").end(); From 6ba7e51d1008ba211677d453ff9f9444d386db9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 27 Sep 2022 13:45:55 +0200 Subject: [PATCH 139/312] [wip] nonlocal reads/writes --- .../test/example/TestOperations.java | 30 +++++++ .../example/TestOperationsParserTest.java | 86 ++++++++++++++++++- .../dsl/processor/operations/Operation.java | 64 ++++++++++++++ .../operations/OperationsContext.java | 7 ++ .../instructions/LoadNonlocalInstruction.java | 46 ++++++++++ .../StoreNonlocalInstruction.java | 46 ++++++++++ 6 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 81920a739f98..7179587f4662 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -43,6 +43,7 @@ import java.util.List; import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -51,6 +52,7 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; @@ -183,6 +185,34 @@ public static final class Invoke { public static Object doInvoke(TestOperations root, @Variadic Object[] args) { return root.getCallTarget().call(args); } + + @Specialization + public static Object doInvoke(TestClosure root, @Variadic Object[] args) { + assert args.length == 0 : "not implemented"; + return root.call(); + } + } + + @Operation + public static final class CreateClosure { + @Specialization + public static TestClosure materialize(VirtualFrame frame, TestOperations root) { + return new TestClosure(frame.materialize(), root); + } + } +} + +class TestClosure { + private final MaterializedFrame frame; + private final RootCallTarget root; + + TestClosure(MaterializedFrame frame, TestOperations root) { + this.frame = frame; + this.root = root.getCallTarget(); + } + + public Object call() { + return root.call(frame); } } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index f5b4fb2fd321..921a028c12b4 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -76,7 +76,7 @@ private static OperationRootNode parseNode(OperationParser { + // x = 1 + // return (lambda: x)() + b.beginRoot(LANGUAGE); + + OperationLocal xLoc = b.createLocal(); + + b.beginStoreLocal(xLoc); + b.emitConstObject(1L); + b.endStoreLocal(); + + b.beginReturn(); + + b.beginInvoke(); + + b.beginRoot(LANGUAGE); + b.beginReturn(); + b.beginLoadNonlocal(xLoc); + b.emitLoadArgument(0); + b.endLoadNonlocal(); + b.endReturn(); + TestOperations inner = b.endRoot(); + + b.beginCreateClosure(); + b.emitConstObject(inner); + b.endCreateClosure(); + + b.endInvoke(); + b.endReturn(); + + b.endRoot(); + }); + + Assert.assertEquals(1L, root.call()); + } + + @Test + public void testNonlocalWrite() { + RootCallTarget root = parse(b -> { + // x = 1 + // (lambda: x = 2)() + // return x + b.beginRoot(LANGUAGE); + + OperationLocal xLoc = b.createLocal(); + + b.beginStoreLocal(xLoc); + b.emitConstObject(1L); + b.endStoreLocal(); + + + b.beginInvoke(); + + b.beginRoot(LANGUAGE); + + b.beginStoreNonlocal(xLoc); + b.emitLoadArgument(0); + b.emitConstObject(2L); + b.endStoreNonlocal(); + + b.beginReturn(); + b.emitConstObject(null); + b.endReturn(); + + TestOperations inner = b.endRoot(); + + b.beginCreateClosure(); + b.emitConstObject(inner); + b.endCreateClosure(); + + b.endInvoke(); + + b.beginReturn(); + b.emitLoadLocal(xLoc); + b.endReturn(); + + b.endRoot(); + }); + + Assert.assertEquals(2L, root.call()); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index e931f55e5128..0a92c754d558 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -61,7 +61,9 @@ import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadNonlocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreNonlocalInstruction; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -244,6 +246,68 @@ public int numLocalReferences() { } } + public static class LoadNonlocal extends Operation { + private final LoadNonlocalInstruction instr; + + public LoadNonlocal(OperationsContext context, int id, LoadNonlocalInstruction instr) { + super(context, "LoadNonlocal", id, 1); + this.instr = instr; + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + + EmitArguments args = new EmitArguments(); + args.arguments = new CodeTree[1]; + args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); + + // TODO validate the local is nested properly + // (not security critical since non-local accesses use safe API) + return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("1"); + } + } + + public static class StoreNonlocal extends Operation { + private final StoreNonlocalInstruction instr; + + public StoreNonlocal(OperationsContext context, int id, StoreNonlocalInstruction instr) { + super(context, "StoreNonlocal", id, 2); + this.instr = instr; + } + + @Override + public List getBuilderArgumentTypes() { + return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); + } + + @Override + public CodeTree createEndCode(BuilderVariables vars) { + + EmitArguments args = new EmitArguments(); + args.arguments = new CodeTree[1]; + args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); + + // TODO validate the local is nested properly + // (not security critical since non-local accesses use safe API) + return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); + } + + @Override + public CodeTree createPushCountCode(BuilderVariables vars) { + return CodeTreeBuilder.singleString("0"); + } + } + public static class LoadConstant extends Operation { private final LoadConstantInstruction[] instructions; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index a7296932f597..e49a3884162e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -49,7 +49,9 @@ import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -64,10 +66,12 @@ import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadNonlocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreNonlocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.YieldInstruction; @@ -135,6 +139,9 @@ private void createBuiltinOperations() { createLoadStoreLocal(); createReturn(); + add(new Operation.LoadNonlocal(this, operationId++, add(new LoadNonlocalInstruction(instructionId++)))); + add(new Operation.StoreNonlocal(this, operationId++, add(new StoreNonlocalInstruction(instructionId++)))); + if (data.enableYield) { add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(instructionId++)))); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java new file mode 100644 index 000000000000..f212a481b7fa --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java @@ -0,0 +1,46 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class LoadNonlocalInstruction extends Instruction { + + public LoadNonlocalInstruction(int id) { + super("load.nonlocal", id, 1); + addPopSimple("frame"); + addArgument("index"); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration(types.Frame, "outerFrame", (CodeTree) null); + + b.startAssign("outerFrame").cast(types.Frame).startCall("UFA", "unsafeGetObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.end(2); + + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.startCall("outerFrame", "getObject"); + b.tree(createArgumentIndex(vars, 0, false)); + b.end(); + b.end(2); + + return b.build(); + } + + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java new file mode 100644 index 000000000000..cb74954582a6 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java @@ -0,0 +1,46 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; + +public class StoreNonlocalInstruction extends Instruction { + + public StoreNonlocalInstruction(int id) { + super("store.nonlocal", id, 0); + addPopSimple("frame"); + addPopSimple("value"); + addArgument("index"); + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.declaration(types.Frame, "outerFrame", (CodeTree) null); + + b.startAssign("outerFrame").cast(types.Frame).startCall("UFA", "unsafeGetObject"); + b.variable(vars.stackFrame); + b.string("$sp - 2"); + b.end(2); + + b.startStatement().startCall("outerFrame", "setObject"); + b.tree(createArgumentIndex(vars, 0, false)); + b.startCall("UFA", "unsafeGetObject").variable(vars.stackFrame).string("$sp - 1").end(); + b.end(2); + + b.statement("$sp -= 2"); + + return b.build(); + } + + @Override + public BoxingEliminationBehaviour boxingEliminationBehaviour() { + return BoxingEliminationBehaviour.DO_NOTHING; + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + return null; + } + +} From 775d8aa0410f916664572711311f4b29e051fb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 27 Sep 2022 17:58:47 +0200 Subject: [PATCH 140/312] [wip] remove boxing elimination since it is borked --- .../api/operation/test/bml/BMLNode.java | 66 ++++-------------- .../operation/test/bml/BenchmarkLanguage.java | 1 - .../truffle/api/impl/FrameWithoutBoxing.java | 68 ++++++++++++++----- .../truffle/api/impl/UnsafeFrameAccess.java | 42 ++++++++++++ .../OperationsBytecodeCodeGenerator.java | 3 + .../OperationsBytecodeNodeGeneratorPlugs.java | 6 +- .../operations/OperationsCodeGenerator.java | 26 ++++--- 7 files changed, 131 insertions(+), 81 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java index 7e4e0b0c4a19..502ca99ec1ea 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java @@ -1,6 +1,5 @@ package com.oracle.truffle.api.operation.test.bml; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -12,7 +11,6 @@ import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; public abstract class BMLNode extends Node { @@ -20,9 +18,9 @@ public abstract class BMLNode extends Node { public abstract Object execute(VirtualFrame frame); - public abstract int executeInt(VirtualFrame frame) throws UnexpectedResultException; + // public abstract int executeInt(VirtualFrame frame) throws UnexpectedResultException; - public abstract boolean executeBool(VirtualFrame frame) throws UnexpectedResultException; + // public abstract boolean executeBool(VirtualFrame frame) throws UnexpectedResultException; } @SuppressWarnings("serial") @@ -166,26 +164,12 @@ public static IfNode create(BMLNode condition, BMLNode thenBranch, BMLNode elseB @Override public Object execute(VirtualFrame frame) { - try { - if (condition.executeBool(frame)) { - thenBranch.execute(frame); - } else { - thenBranch.execute(frame); - } - return VOID; - } catch (UnexpectedResultException e) { - throw CompilerDirectives.shouldNotReachHere(); + if (condition.execute(frame) == Boolean.TRUE) { + thenBranch.execute(frame); + } else { + thenBranch.execute(frame); } - } - - @Override - public int executeInt(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); - } - - @Override - public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); + return VOID; } } @@ -206,27 +190,13 @@ public static WhileNode create(BMLNode condition, BMLNode body) { @Override public Object execute(VirtualFrame frame) { - try { - int count = 0; - while (condition.executeBool(frame)) { - body.execute(frame); - count++; - } - LoopNode.reportLoopCount(this, count); - return VOID; - } catch (UnexpectedResultException e) { - throw CompilerDirectives.shouldNotReachHere(); + int count = 0; + while (condition.execute(frame) == Boolean.TRUE) { + body.execute(frame); + count++; } - } - - @Override - public int executeInt(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); - } - - @Override - public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); + LoopNode.reportLoopCount(this, count); + return VOID; } } @@ -249,16 +219,6 @@ public Object execute(VirtualFrame frame) { } return VOID; } - - @Override - public int executeInt(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); - } - - @Override - public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { - throw CompilerDirectives.shouldNotReachHere(); - } } abstract class ConstNode extends BMLNode { diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java index 0d6499e26801..9e79bff6e4a2 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java @@ -91,7 +91,6 @@ protected CallTarget parse(ParsingRequest request) throws Exception { @GenerateOperations(// languageClass = BenchmarkLanguage.class, // - boxingEliminationTypes = {int.class}, // decisionsFile = "decisions.json") abstract class BMOperationRootNode extends RootNode implements OperationRootNode { protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 260619d307ba..cbc49ffd048c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -209,6 +209,10 @@ private static FrameSlotTypeException frameSlotTypeException() throws FrameSlotT throw new FrameSlotTypeException(); } + private static long getObjectOffset(int slotIndex) { + return Unsafe.ARRAY_OBJECT_BASE_OFFSET + slotIndex * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE; + } + private static long getPrimitiveOffset(int slotIndex) { return Unsafe.ARRAY_LONG_BASE_OFFSET + slotIndex * (long) Unsafe.ARRAY_LONG_INDEX_SCALE; } @@ -291,23 +295,31 @@ private byte[] getIndexedTags() { @Override public Object getObject(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, OBJECT_TAG); - return unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, condition, OBJECT_LOCATION); + return unsafeGetObject(getIndexedLocals(), getObjectOffset(slot), condition, OBJECT_LOCATION); } Object unsafeGetObject(int slot) throws FrameSlotTypeException { boolean condition = unsafeVerifyIndexedGet(slot, OBJECT_TAG); - return unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, condition, OBJECT_LOCATION); + return unsafeGetObject(getIndexedLocals(), getObjectOffset(slot), condition, OBJECT_LOCATION); + } + + Object unsafeUncheckedGetObject(int slot) throws FrameSlotTypeException { + return unsafeGetObject(getIndexedLocals(), getObjectOffset(slot), true, OBJECT_LOCATION); } @Override public void setObject(int slot, Object value) { verifyIndexedSet(slot, OBJECT_TAG); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); } void unsafeSetObject(int slot, Object value) throws FrameSlotTypeException { unsafeVerifyIndexedSet(slot, OBJECT_TAG); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); + } + + void unsafeUncheckedSetObject(int slot, Object value) throws FrameSlotTypeException { + unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); } @Override @@ -321,6 +333,10 @@ byte unsafeGetByte(int slot) throws FrameSlotTypeException { return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + byte unsafeUncheckedGetByte(int slot) throws FrameSlotTypeException { + return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); + } + @Override public void setByte(int slot, byte value) { verifyIndexedSet(slot, BYTE_TAG); @@ -343,6 +359,10 @@ boolean unsafeGetBoolean(int slot) throws FrameSlotTypeException { return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION) != 0; } + boolean unsafeUncheckedGetBoolean(int slot) throws FrameSlotTypeException { + return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION) != 0; + } + @Override public void setBoolean(int slot, boolean value) { verifyIndexedSet(slot, BOOLEAN_TAG); @@ -365,6 +385,10 @@ float unsafeGetFloat(int slot) throws FrameSlotTypeException { return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); } + float unsafeUncheckedGetFloat(int slot) throws FrameSlotTypeException { + return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION)); + } + @Override public void setFloat(int slot, float value) { verifyIndexedSet(slot, FLOAT_TAG); @@ -387,6 +411,10 @@ long unsafeGetLong(int slot) throws FrameSlotTypeException { return unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + long unsafeUncheckedGetLong(int slot) throws FrameSlotTypeException { + return unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); + } + @Override public void setLong(int slot, long value) { verifyIndexedSet(slot, LONG_TAG); @@ -409,6 +437,10 @@ int unsafeGetInt(int slot) throws FrameSlotTypeException { return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } + int unsafeUncheckedGetInt(int slot) throws FrameSlotTypeException { + return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); + } + @Override public void setInt(int slot, int value) { verifyIndexedSet(slot, INT_TAG); @@ -431,6 +463,10 @@ public double getDouble(int slot) throws FrameSlotTypeException { return Double.longBitsToDouble(unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); } + double unsafeUncheckedGetDouble(int slot) throws FrameSlotTypeException { + return Double.longBitsToDouble(unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION)); + } + @Override public void setDouble(int slot, double value) { verifyIndexedSet(slot, DOUBLE_TAG); @@ -445,18 +481,18 @@ void unsafeSetDouble(int slot, double value) { @Override public void copy(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); - Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object value = unsafeGetObject(getIndexedLocals(), getObjectOffset(srcSlot), true, OBJECT_LOCATION); verifyIndexedSet(destSlot, tag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), value, OBJECT_LOCATION); long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); } void unsafeCopy(int srcSlot, int destSlot) { byte tag = unsafeGetIndexedTag(srcSlot); - Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object value = unsafeGetObject(getIndexedLocals(), getObjectOffset(srcSlot), true, OBJECT_LOCATION); unsafeVerifyIndexedSet(destSlot, tag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), value, OBJECT_LOCATION); long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); } @@ -465,9 +501,9 @@ void unsafeCopy(int srcSlot, int destSlot) { public void copyObject(int srcSlot, int destSlot) { byte tag = getIndexedTagChecked(srcSlot); assert tag == OBJECT_TAG : "copyObject must be used with Object slots, not " + FrameSlotKind.fromTag(tag); - Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object value = unsafeGetObject(getIndexedLocals(), getObjectOffset(srcSlot), true, OBJECT_LOCATION); verifyIndexedSet(destSlot, tag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), value, OBJECT_LOCATION); if (CompilerDirectives.inCompiledCode()) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), 0L, PRIMITIVE_LOCATION); } @@ -476,9 +512,9 @@ public void copyObject(int srcSlot, int destSlot) { void unsafeCopyObject(int srcSlot, int destSlot) { byte tag = unsafeGetIndexedTag(srcSlot); assert tag == OBJECT_TAG : "copyObject must be used with Object slots, not " + FrameSlotKind.fromTag(tag); - Object value = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + srcSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object value = unsafeGetObject(getIndexedLocals(), getObjectOffset(srcSlot), true, OBJECT_LOCATION); unsafeVerifyIndexedSet(destSlot, tag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), value, OBJECT_LOCATION); if (CompilerDirectives.inCompiledCode()) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), 0L, PRIMITIVE_LOCATION); } @@ -491,7 +527,7 @@ public void copyPrimitive(int srcSlot, int destSlot) { long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); verifyIndexedSet(destSlot, tag); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), null, OBJECT_LOCATION); } void unsafeCopyPrimitive(int srcSlot, int destSlot) { @@ -500,7 +536,7 @@ void unsafeCopyPrimitive(int srcSlot, int destSlot) { long primitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(srcSlot), true, PRIMITIVE_LOCATION); unsafeVerifyIndexedSet(destSlot, tag); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(destSlot), primitiveValue, PRIMITIVE_LOCATION); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + destSlot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(destSlot), null, OBJECT_LOCATION); } @Override @@ -651,7 +687,7 @@ public boolean isStatic(int slot) { @Override public void clear(int slot) { verifyIndexedSet(slot, ILLEGAL_TAG); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(slot), null, OBJECT_LOCATION); if (CompilerDirectives.inCompiledCode()) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), 0L, PRIMITIVE_LOCATION); } @@ -659,7 +695,7 @@ public void clear(int slot) { void unsafeClear(int slot) { unsafeVerifyIndexedSet(slot, ILLEGAL_TAG); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, null, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(slot), null, OBJECT_LOCATION); if (CompilerDirectives.inCompiledCode()) { unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), 0L, PRIMITIVE_LOCATION); } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 9e23934bc54c..0bdba9df0100 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -75,8 +75,20 @@ public static UnsafeFrameAccess lookup() { public abstract double unsafeGetDouble(Frame frame, int slot); + public abstract Object unsafeUncheckedGetObject(Frame frame, int slot); + + public abstract boolean unsafeUncheckedGetBoolean(Frame frame, int slot); + + public abstract int unsafeUncheckedGetInt(Frame frame, int slot); + + public abstract long unsafeUncheckedGetLong(Frame frame, int slot); + + public abstract double unsafeUncheckedGetDouble(Frame frame, int slot); + public abstract void unsafeSetObject(Frame frame, int slot, Object value); + public abstract void unsafeUncheckedSetObject(Frame frame, int slot, Object value); + public abstract void unsafeSetBoolean(Frame frame, int slot, boolean value); public abstract void unsafeSetInt(Frame frame, int slot, int value); @@ -168,11 +180,41 @@ public double unsafeGetDouble(Frame frame, int slot) { return castFrame(frame).unsafeGetDouble(slot); } + @Override + public Object unsafeUncheckedGetObject(Frame frame, int slot) { + return castFrame(frame).unsafeUncheckedGetObject(slot); + } + + @Override + public int unsafeUncheckedGetInt(Frame frame, int slot) { + return castFrame(frame).unsafeUncheckedGetInt(slot); + } + + @Override + public boolean unsafeUncheckedGetBoolean(Frame frame, int slot) { + return castFrame(frame).unsafeUncheckedGetBoolean(slot); + } + + @Override + public long unsafeUncheckedGetLong(Frame frame, int slot) { + return castFrame(frame).unsafeUncheckedGetLong(slot); + } + + @Override + public double unsafeUncheckedGetDouble(Frame frame, int slot) { + return castFrame(frame).unsafeUncheckedGetDouble(slot); + } + @Override public void unsafeSetObject(Frame frame, int slot, Object value) { castFrame(frame).unsafeSetObject(slot, value); } + @Override + public void unsafeUncheckedSetObject(Frame frame, int slot, Object value) { + castFrame(frame).unsafeUncheckedSetObject(slot, value); + } + @Override public void unsafeSetInt(Frame frame, int slot, int value) { castFrame(frame).unsafeSetInt(slot, value); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index c35b5364c05e..1f64d7c4052e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -257,6 +257,9 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); b.declaration("Counter", "loopCounter", "new Counter()"); + // this moves the frame null check out of the loop + b.startStatement().startCall(vars.stackFrame, "getArguments").end(2); + if (isUncached) { // todo: better signaling to compiler that the method is not ready for compilation b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 52e98d876bad..c23beba76f6e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -492,7 +492,11 @@ private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree if (uncached || data.isDisableBoxingElimination() || typeName.equals("Object")) { b.startStatement(); - b.startCall("UFA", "unsafeSetObject"); + if (m.getBoxingEliminatedTypes().size() == 0) { + b.startCall("UFA", "unsafeUncheckedSetObject"); + } else { + b.startCall("UFA", "unsafeSetObject"); + } b.string(m.enableYield ? "$stackFrame" : "$frame"); b.string("$sp - " + destOffset); b.tree(value); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 79826e46fa87..91fd50895967 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -1722,7 +1722,7 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT } baseClass.add(createFormatConstant()); - baseClass.add(createExpectObject()); + baseClass.add(createExpectObject(m.getBoxingEliminatedTypes().size() > 0)); baseClass.add(createSetResultBoxedImpl()); for (TypeKind kind : m.getBoxingEliminatedTypes()) { FrameKind frameKind = FrameKind.valueOfPrimitive(kind); @@ -2430,19 +2430,25 @@ public List create(ProcessorContext context, AnnotationProcesso // -------------------------- helper methods moved to generated code -------------------------- - private CodeExecutableElement createExpectObject() { + private CodeExecutableElement createExpectObject(boolean hasAnyBoxingElimination) { CodeExecutableElement mExpectObject = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(Object.class), "expectObject"); mExpectObject.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); CodeTreeBuilder b = mExpectObject.createBuilder(); - b.startIf().string("UFA.unsafeIsObject(frame, slot)").end().startBlock(); // if { - b.startReturn().string("UFA.unsafeGetObject(frame, slot)").end(); - b.end().startElseBlock(); // } else { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startReturn().string("frame.getValue(slot)").end(); - b.end(); // } + if (hasAnyBoxingElimination) { + b.startIf().string("UFA.unsafeIsObject(frame, slot)").end().startBlock(); // if { + } + + b.startReturn().string("UFA.unsafeUncheckedGetObject(frame, slot)").end(); + + if (hasAnyBoxingElimination) { + b.end().startElseBlock(); // } else { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startReturn().string("frame.getValue(slot)").end(); + b.end(); // } + } return mExpectObject; } @@ -2463,11 +2469,11 @@ private CodeExecutableElement createExpectPrimitive(FrameKind kind) { b.startSwitch().string("UFA.unsafeGetTag(frame, slot)").end().startBlock(); // switch { b.startCase().string(kind.ordinal() + " /* " + kind + " */").end().startCaseBlock(); // { - b.startReturn().string("UFA.unsafeGet" + kind.getFrameName() + "(frame, slot)").end(); + b.startReturn().string("UFA.unsafeUncheckedGet" + kind.getFrameName() + "(frame, slot)").end(); b.end(); // } b.startCase().string(FrameKind.OBJECT.ordinal() + " /* OBJECT */").end().startCaseBlock(); // { - b.declaration("Object", "value", "UFA.unsafeGetObject(frame, slot)"); + b.declaration("Object", "value", "UFA.unsafeUncheckedGetObject(frame, slot)"); b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); b.startReturn().string("(" + kind.getTypeName() + ") value").end(); From a7ee1ffb7cf706d4f5fbcf5c863340a6d70475e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 28 Sep 2022 10:12:42 +0200 Subject: [PATCH 141/312] [wip] rename serializers --- .../api/operation/test/bml/BenmarkSimple.java | 2 - .../truffle/api/operation/OperationNodes.java | 4 +- ...llback.java => OperationDeserializer.java} | 6 +- ...Callback.java => OperationSerializer.java} | 6 +- .../operations/OperationsCodeGenerator.java | 13 +-- .../operations/SLOperationSerialization.java | 105 +++++++++--------- 6 files changed, 65 insertions(+), 71 deletions(-) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/{OperationDeserializationCallback.java => OperationDeserializer.java} (93%) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/{OperationSerializationCallback.java => OperationSerializer.java} (92%) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index 22d998a51e98..3d583d2c52b7 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -71,8 +71,6 @@ @State(Scope.Benchmark) public class BenmarkSimple extends BaseBenchmark { - private static final int TARGET_AMOUNT = 100000; - private static final String NAME_TEST_LOOP = "simple:test-loop"; private static final String NAME_TEST_LOOP_NO_BE = "simple:test-loop-no-be"; private static final String NAME_TEST_LOOP_QUICKEN = "simple:test-loop-quicken"; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 4260997e9d69..21e261459b5b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -48,7 +48,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; +import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.source.Source; public abstract class OperationNodes { @@ -113,7 +113,7 @@ final void ensureSources() { } @SuppressWarnings("unused") - public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializationCallback callback) throws IOException { + public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { throw new UnsupportedOperationException("Serialization not supported"); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java similarity index 93% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java index bffb8a0fa34e..2972ace7dcbe 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializationCallback.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java @@ -45,10 +45,10 @@ import com.oracle.truffle.api.operation.OperationRootNode; -public interface OperationDeserializationCallback { - interface Context { +public interface OperationDeserializer { + interface DeserializerContext { OperationRootNode deserializeOperationNode(ByteBuffer buffer) throws IOException; } - Object deserialize(Context context, ByteBuffer buffer) throws IOException; + Object deserialize(DeserializerContext context, ByteBuffer buffer) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java similarity index 92% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java index 93c8cfcee0f4..32e880710ae6 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializationCallback.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java @@ -46,10 +46,10 @@ import com.oracle.truffle.api.operation.OperationRootNode; @FunctionalInterface -public interface OperationSerializationCallback { - interface Context { +public interface OperationSerializer { + interface SerializerContext { void serializeOperationNode(DataOutputStream buffer, OperationRootNode node) throws IOException; } - void serialize(Context context, DataOutputStream buffer, Object object) throws IOException; + void serialize(SerializerContext context, DataOutputStream buffer, Object object) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 91fd50895967..126459b40c5d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -52,7 +52,6 @@ import java.util.Set; import java.util.concurrent.locks.Lock; -import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -183,7 +182,7 @@ private CodeExecutableElement createDeserializeMethod() { CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "input"); - CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback"); + CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer"), "callback"); CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parLanguage, parConfig, parBuffer, parCallback); met.addThrownType(context.getType(IOException.class)); @@ -217,7 +216,7 @@ private void unwrapIOError(CodeTreeBuilder b, Runnable inner) { private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_OUTPUT_CLASS), "buffer"); - CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback"), "callback"); + CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer"), "callback"); CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, context.getType(void.class), "serialize"); metCreate.addParameter(parConfig); @@ -311,7 +310,7 @@ private CodeTypeElement createOperationSerNodeImpl() { } private CodeVariableElement createSerializationContext() { - DeclaredType typeContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback.Context"); + DeclaredType typeContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext"); CodeVariableElement fld = new CodeVariableElement(typeContext, "SER_CONTEXT"); CodeTreeBuilder b = fld.createInitBuilder(); @@ -928,7 +927,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean.class), "isSerializing")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(DATA_OUTPUT_CLASS), "serBuffer")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializationCallback"), "serCallback")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer"), "serCallback")); } typBuilderImpl.add(createBuilderImplFinish()); @@ -1057,7 +1056,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); met.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); met.addParameter(new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "buffer")); - met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback"), "callback")); + met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer"), "callback")); met.addParameter(new CodeVariableElement(typBuilder.asType(), "builder")); CodeTreeBuilder b = met.createBuilder(); @@ -1067,7 +1066,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.statement("ArrayList labels = new ArrayList<>()"); b.statement("ArrayList<" + m.getTemplateType().getSimpleName() + "> builtNodes = new ArrayList<>()"); - TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback.Context"); + TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext"); b.startStatement(); b.type(deserContext); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java index 0377507e658d..0acf4da3ad0e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -48,8 +48,9 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.serialization.OperationDeserializationCallback; -import com.oracle.truffle.api.operation.serialization.OperationSerializationCallback; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; +import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -69,31 +70,29 @@ public static byte[] serializeNodes(OperationNodes nodes) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream); - nodes.serialize(OperationConfig.COMPLETE, outputStream, new OperationSerializationCallback() { - public void serialize(OperationSerializationCallback.Context context, DataOutputStream buffer, Object object) throws IOException { - if (object instanceof SLNull) { - buffer.writeByte(CODE_SL_NULL); - } else if (object instanceof TruffleString) { - TruffleString str = (TruffleString) object; - buffer.writeByte(CODE_STRING); - writeByteArray(buffer, str.getInternalByteArrayUncached(SLLanguage.STRING_ENCODING).getArray()); - } else if (object instanceof Long) { - buffer.writeByte(CODE_LONG); - buffer.writeLong((long) object); - } else if (object instanceof SLBigNumber) { - SLBigNumber num = (SLBigNumber) object; - buffer.writeByte(CODE_BIG_INT); - writeByteArray(buffer, num.getValue().toByteArray()); - } else if (object instanceof Source) { - Source s = (Source) object; - buffer.writeByte(CODE_SOURCE); - writeByteArray(buffer, s.getName().getBytes()); - } else if (object instanceof Class) { - buffer.writeByte(CODE_CLASS); - writeByteArray(buffer, ((Class) object).getName().getBytes()); - } else { - throw new UnsupportedOperationException("unsupported constant: " + object.getClass().getSimpleName() + " " + object); - } + nodes.serialize(OperationConfig.COMPLETE, outputStream, (context, buffer, object) -> { + if (object instanceof SLNull) { + buffer.writeByte(CODE_SL_NULL); + } else if (object instanceof TruffleString) { + TruffleString str = (TruffleString) object; + buffer.writeByte(CODE_STRING); + writeByteArray(buffer, str.getInternalByteArrayUncached(SLLanguage.STRING_ENCODING).getArray()); + } else if (object instanceof Long) { + buffer.writeByte(CODE_LONG); + buffer.writeLong((long) object); + } else if (object instanceof SLBigNumber) { + SLBigNumber num = (SLBigNumber) object; + buffer.writeByte(CODE_BIG_INT); + writeByteArray(buffer, num.getValue().toByteArray()); + } else if (object instanceof Source) { + Source s = (Source) object; + buffer.writeByte(CODE_SOURCE); + writeByteArray(buffer, s.getName().getBytes()); + } else if (object instanceof Class) { + buffer.writeByte(CODE_CLASS); + writeByteArray(buffer, ((Class) object).getName().getBytes()); + } else { + throw new UnsupportedOperationException("unsupported constant: " + object.getClass().getSimpleName() + " " + object); } }); @@ -115,35 +114,33 @@ private static void writeByteArray(DataOutputStream buffer, byte[] data) throws public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException { ByteBuffer buf = ByteBuffer.wrap(inputData); - return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, new OperationDeserializationCallback() { - public Object deserialize(OperationDeserializationCallback.Context context, ByteBuffer buffer) throws IOException { - byte tag; - switch (tag = buffer.get()) { - case CODE_SL_NULL: - return SLNull.SINGLETON; - case CODE_STRING: { - return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); - } - case CODE_LONG: - return buffer.getLong(); - case CODE_BIG_INT: { - return new SLBigNumber(new BigInteger(readByteArray(buffer))); - } - case CODE_SOURCE: { - String name = new String(readByteArray(buffer)); - return Source.newBuilder(SLLanguage.ID, "", name).build(); - } - case CODE_CLASS: { - String name = new String(readByteArray(buffer)); - try { - return Class.forName(name); - } catch (ClassNotFoundException ex) { - throw new UnsupportedOperationException("could not load class: " + name); - } + return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, (context, buffer) -> { + byte tag; + switch (tag = buffer.get()) { + case CODE_SL_NULL: + return SLNull.SINGLETON; + case CODE_STRING: { + return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); + } + case CODE_LONG: + return buffer.getLong(); + case CODE_BIG_INT: { + return new SLBigNumber(new BigInteger(readByteArray(buffer))); + } + case CODE_SOURCE: { + String name = new String(readByteArray(buffer)); + return Source.newBuilder(SLLanguage.ID, "", name).build(); + } + case CODE_CLASS: { + String name = new String(readByteArray(buffer)); + try { + return Class.forName(name); + } catch (ClassNotFoundException ex) { + throw new UnsupportedOperationException("could not load class: " + name); } - default: - throw new UnsupportedOperationException("unsupported tag: " + tag); } + default: + throw new UnsupportedOperationException("unsupported tag: " + tag); } }); } From 1d7b9237a3e97cfcee2ca44f2a43b0615c430cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 28 Sep 2022 10:38:36 +0200 Subject: [PATCH 142/312] [wip] handle variadics in separate function --- .../truffle/api/impl/FrameWithoutBoxing.java | 16 +++++++++---- .../operations/OperationsCodeGenerator.java | 23 +++++++++++++++++++ .../instructions/CustomInstruction.java | 12 ++++++---- .../instructions/ThrowInstruction.java | 2 +- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index cbc49ffd048c..4fca6e1cffe4 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -303,7 +303,8 @@ Object unsafeGetObject(int slot) throws FrameSlotTypeException { return unsafeGetObject(getIndexedLocals(), getObjectOffset(slot), condition, OBJECT_LOCATION); } - Object unsafeUncheckedGetObject(int slot) throws FrameSlotTypeException { + Object unsafeUncheckedGetObject(int slot) { + assert getIndexedTagChecked(slot) == OBJECT_TAG; return unsafeGetObject(getIndexedLocals(), getObjectOffset(slot), true, OBJECT_LOCATION); } @@ -318,7 +319,8 @@ void unsafeSetObject(int slot, Object value) throws FrameSlotTypeException { unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); } - void unsafeUncheckedSetObject(int slot, Object value) throws FrameSlotTypeException { + void unsafeUncheckedSetObject(int slot, Object value) { + assert getIndexedTagChecked(slot) == OBJECT_TAG; unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); } @@ -333,7 +335,8 @@ byte unsafeGetByte(int slot) throws FrameSlotTypeException { return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION); } - byte unsafeUncheckedGetByte(int slot) throws FrameSlotTypeException { + byte unsafeUncheckedGetByte(int slot) { + assert getIndexedTagChecked(slot) == BYTE_TAG; return (byte) (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); } @@ -360,6 +363,7 @@ boolean unsafeGetBoolean(int slot) throws FrameSlotTypeException { } boolean unsafeUncheckedGetBoolean(int slot) throws FrameSlotTypeException { + assert getIndexedTagChecked(slot) == BOOLEAN_TAG; return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION) != 0; } @@ -385,7 +389,8 @@ float unsafeGetFloat(int slot) throws FrameSlotTypeException { return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), condition, PRIMITIVE_LOCATION)); } - float unsafeUncheckedGetFloat(int slot) throws FrameSlotTypeException { + float unsafeUncheckedGetFloat(int slot) { + assert getIndexedTagChecked(slot) == FLOAT_TAG; return Float.intBitsToFloat((int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION)); } @@ -412,6 +417,7 @@ long unsafeGetLong(int slot) throws FrameSlotTypeException { } long unsafeUncheckedGetLong(int slot) throws FrameSlotTypeException { + assert getIndexedTagChecked(slot) == LONG_TAG; return unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); } @@ -438,6 +444,7 @@ int unsafeGetInt(int slot) throws FrameSlotTypeException { } int unsafeUncheckedGetInt(int slot) throws FrameSlotTypeException { + assert getIndexedTagChecked(slot) == INT_TAG; return (int) unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION); } @@ -464,6 +471,7 @@ public double getDouble(int slot) throws FrameSlotTypeException { } double unsafeUncheckedGetDouble(int slot) throws FrameSlotTypeException { + assert getIndexedTagChecked(slot) == DOUBLE_TAG; return Double.longBitsToDouble(unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(slot), true, PRIMITIVE_LOCATION)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 126459b40c5d..7196363aaa70 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -52,6 +52,7 @@ import java.util.Set; import java.util.concurrent.locks.Lock; +import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -480,6 +481,7 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(createBoxingDescriptors()); typOperationNodeImpl.add(createSetResultUnboxed()); + typOperationNodeImpl.add(createLoadVariadicArguments()); typOperationNodeImpl.add(createSetResultBoxedImpl()); typOperationNodeImpl.add(createCounter()); if (m.enableYield) { @@ -497,6 +499,27 @@ CodeTypeElement createOperationNodeImpl() { return typOperationNodeImpl; } + private CodeExecutableElement createLoadVariadicArguments() { + CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, arrayOf(context.getType(Object.class)), "do_loadVariadicArguments"); + el.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); + el.addParameter(new CodeVariableElement(context.getType(int.class), "$sp")); + el.addParameter(new CodeVariableElement(context.getType(int.class), "numVariadics")); + el.addAnnotationMirror(new CodeAnnotationMirror(types.ExplodeLoop)); + + CodeTreeBuilder b = el.createBuilder(); + b.tree(GeneratorUtils.createPartialEvaluationConstant("$sp")); + b.tree(GeneratorUtils.createPartialEvaluationConstant("numVariadics")); + b.declaration("Object[]", "result", "new Object[numVariadics]"); + + b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); + b.statement("result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex)"); + b.end(); + + b.startReturn().string("result").end(); + + return el; + } + private CodeTypeElement createContinuationRoot(CodeTypeElement typOperationNodeImpl) { CodeTypeElement cr = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "ContinuationRoot"); cr.setSuperClass(types.RootNode); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 82461fd649c5..c9c57e744595 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -172,14 +172,16 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { String inputName = "input_" + inputIndex; switch (kind) { case STACK_VALUE: - b.declaration("Object", inputName, "UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); + // safety: use unchecked since we never BE variadic functions + b.declaration("Object", inputName, "UFA.unsafeUncheckedGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VARIADIC: - b.declaration("Object[]", inputName, "new Object[numVariadics]"); - b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); - b.startStatement().string(inputName, "[varIndex] = UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics + varIndex)").end(); - b.end(); + b.startAssign("Object[] " + inputName).startCall("do_loadVariadicArguments"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("numVariadics"); + b.end(2); inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); break; case VIRTUAL_FRAME: diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index c733fef347b5..681af0b4e01a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -62,7 +62,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startThrow(); b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); - b.startCall(vars.stackFrame, "getObject").string("slot").end(); + b.startCall("UFA", "unsafeUncheckedGetObject").variable(vars.stackFrame).string("slot").end(); b.end(); return b.build(); From 1c81d028ee6b62b956fa86528e5561bc5f63b53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 3 Oct 2022 16:11:41 +0200 Subject: [PATCH 143/312] [wip] boxing elimination v981273 --- .../api/operation/test/bml/BMLNode.java | 11 +- .../test/bml/BMOperationRootNode.java | 85 ++++ .../operation/test/bml/BenchmarkLanguage.java | 75 --- .../api/operation/test/bml/BenmarkSimple.java | 15 +- .../test/bml/ManualBytecodeNode.java | 110 +++++ .../test/example/BoxingOperationsTest.java | 165 ++++--- .../test/example/TestOperations.java | 1 - .../truffle/api/operation/Operation.java | 1 - .../truffle/api/impl/FrameWithoutBoxing.java | 5 - .../truffle/api/impl/UnsafeFrameAccess.java | 7 - .../truffle/dsl/processor/TruffleTypes.java | 2 + .../generator/FlatNodeGenFactory.java | 84 ++-- .../processor/generator/GeneratorUtils.java | 21 +- .../generator/NodeGeneratorPlugs.java | 15 +- .../generator/TypeSystemCodeGenerator.java | 16 +- .../processor/java/model/CodeTreeBuilder.java | 7 + .../operations/OperationGeneratorFlags.java | 3 - .../operations/OperationGeneratorUtils.java | 24 +- .../OperationsBytecodeCodeGenerator.java | 61 +-- .../OperationsBytecodeNodeGeneratorPlugs.java | 426 ++++-------------- .../operations/OperationsCodeGenerator.java | 162 +++---- .../operations/OperationsContext.java | 76 ++-- .../operations/SingleOperationData.java | 9 - .../operations/SingleOperationParser.java | 127 +++--- .../instructions/BranchInstruction.java | 10 +- .../ConditionalBranchInstruction.java | 9 +- .../instructions/CustomInstruction.java | 262 ++++++----- .../instructions/DiscardInstruction.java | 10 +- .../operations/instructions/FrameKind.java | 23 + .../operations/instructions/Instruction.java | 67 +-- .../InstrumentationEnterInstruction.java | 10 +- .../InstrumentationExitInstruction.java | 14 +- .../InstrumentationLeaveInstruction.java | 10 +- .../instructions/LoadArgumentInstruction.java | 89 ++-- .../instructions/LoadConstantInstruction.java | 86 ++-- .../instructions/LoadLocalInstruction.java | 164 +++++-- .../instructions/LoadNonlocalInstruction.java | 10 +- .../instructions/QuickenedInstruction.java | 15 - .../instructions/ReturnInstruction.java | 10 +- .../instructions/ShortCircuitInstruction.java | 7 +- .../instructions/StoreLocalInstruction.java | 247 +++++++++- .../StoreNonlocalInstruction.java | 10 +- .../instructions/ThrowInstruction.java | 10 +- .../instructions/YieldInstruction.java | 10 +- .../sl/operations/SLOperationRootNode.java | 2 + 45 files changed, 1398 insertions(+), 1185 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMOperationRootNode.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java index 502ca99ec1ea..8e71738ea4f7 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMLNode.java @@ -11,6 +11,7 @@ import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; public abstract class BMLNode extends Node { @@ -18,9 +19,15 @@ public abstract class BMLNode extends Node { public abstract Object execute(VirtualFrame frame); - // public abstract int executeInt(VirtualFrame frame) throws UnexpectedResultException; + @SuppressWarnings("unused") + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { + throw new AssertionError(); + } - // public abstract boolean executeBool(VirtualFrame frame) throws UnexpectedResultException; + @SuppressWarnings("unused") + public boolean executeBool(VirtualFrame frame) throws UnexpectedResultException { + throw new AssertionError(); + } } @SuppressWarnings("serial") diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMOperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMOperationRootNode.java new file mode 100644 index 000000000000..b395cbf31f9f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BMOperationRootNode.java @@ -0,0 +1,85 @@ +package com.oracle.truffle.api.operation.test.bml; + +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationRootNode; + +@GenerateOperations(// + languageClass = BenchmarkLanguage.class, // + decisionsFile = "decisions.json", // + boxingEliminationTypes = {int.class, boolean.class}) +abstract class BMOperationRootNode extends RootNode implements OperationRootNode { + + protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { + super(language, frameDescriptor.build()); + } + + @Operation + static final class Add { + @Specialization + static int doInts(int left, int right) { + return left + right; + } + + @Specialization + static Object doOther(Object left, Object right) { + return "" + left + right; + } + } + + @Operation + static final class Mod { + @Specialization + static int doInts(int left, int right) { + return left % right; + } + } + + @Operation + static final class AddQuickened { + @Specialization + static int doInts(int left, int right) { + return left + right; + } + } + + @Operation + static final class ModQuickened { + @Specialization + static int doInts(int left, int right) { + return left % right; + } + } + + @Operation + static final class AddBoxed { + @Specialization + static Object doInts(Object left, Object right) { + return (int) left + (int) right; + } + } + + @Operation + static final class ModBoxed { + @Specialization + static Object doInts(Object left, Object right) { + return (int) left % (int) right; + } + } + + @Operation + static final class Less { + @Specialization + static boolean doInts(int left, int right) { + return left < right; + } + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java index 9e79bff6e4a2..61611b45df34 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java @@ -48,14 +48,8 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleLanguage.Registration; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.GenerateOperations; -import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.OperationRootNode; @Registration(id = "bm", name = "bm") class BenchmarkLanguage extends TruffleLanguage { @@ -88,72 +82,3 @@ protected CallTarget parse(ParsingRequest request) throws Exception { return NAMES.get(name).apply(this); } } - -@GenerateOperations(// - languageClass = BenchmarkLanguage.class, // - decisionsFile = "decisions.json") -abstract class BMOperationRootNode extends RootNode implements OperationRootNode { - protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); - } - - protected BMOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { - super(language, frameDescriptor.build()); - } - - @Operation - static final class Add { - @Specialization - static int doInts(int left, int right) { - return left + right; - } - } - - @Operation - static final class Mod { - @Specialization - static int doInts(int left, int right) { - return left % right; - } - } - - @Operation - static final class AddQuickened { - @Specialization - static int doInts(int left, int right) { - return left + right; - } - } - - @Operation - static final class ModQuickened { - @Specialization - static int doInts(int left, int right) { - return left % right; - } - } - - @Operation(disableBoxingElimination = true) - static final class AddBoxed { - @Specialization - static int doInts(int left, int right) { - return left + right; - } - } - - @Operation(disableBoxingElimination = true) - static final class ModBoxed { - @Specialization - static int doInts(int left, int right) { - return left % right; - } - } - - @Operation - static final class Less { - @Specialization - static boolean doInts(int left, int right) { - return left < right; - } - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index 3d583d2c52b7..e4e515423100 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -76,6 +76,7 @@ public class BenmarkSimple extends BaseBenchmark { private static final String NAME_TEST_LOOP_QUICKEN = "simple:test-loop-quicken"; private static final String NAME_MANUAL = "simple:manual"; private static final String NAME_MANUAL_NO_BE = "simple:manual-no-be"; + private static final String NAME_MANUAL_UNSAFE = "simple:manual-unsafe"; private static final String NAME_AST = "simple:ast"; private static final Source SOURCE_TEST_LOOP = Source.create("bm", NAME_TEST_LOOP); @@ -83,6 +84,7 @@ public class BenmarkSimple extends BaseBenchmark { private static final Source SOURCE_TEST_LOOP_QUICKEN = Source.create("bm", NAME_TEST_LOOP_QUICKEN); private static final Source SOURCE_MANUAL = Source.create("bm", NAME_MANUAL); private static final Source SOURCE_MANUAL_NO_BE = Source.create("bm", NAME_MANUAL_NO_BE); + private static final Source SOURCE_MANUAL_UNSAFE = Source.create("bm", NAME_MANUAL_UNSAFE); private static final Source SOURCE_AST = Source.create("bm", NAME_AST); private static final int LOC_I = 4; @@ -231,6 +233,12 @@ public class BenmarkSimple extends BaseBenchmark { ManualBytecodeNodeNBE node = new ManualBytecodeNodeNBE(lang, b.build(), BYTECODE); return node.getCallTarget(); }); + BenchmarkLanguage.registerName2(NAME_MANUAL_UNSAFE, lang -> { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); + b.addSlots(8, FrameSlotKind.Illegal); + ManualUnsafeBytecodeNode node = new ManualUnsafeBytecodeNode(lang, b.build(), BYTECODE); + return node.getCallTarget(); + }); BenchmarkLanguage.registerName2(NAME_AST, lang -> { int iLoc = 0, sumLoc = 1, jLoc = 2, tempLoc = 3; return new BMLRootNode(lang, 4, BlockNode.create( @@ -485,6 +493,11 @@ public void manualNoBE() { doEval(SOURCE_MANUAL_NO_BE); } + @Benchmark + public void manualUnsafe() { + doEval(SOURCE_MANUAL_UNSAFE); + } + @Benchmark public void ast() { doEval(SOURCE_AST); @@ -496,7 +509,7 @@ public void ast() { @Fork(BaseBenchmark.FORKS) class BaseBenchmark { public static final int MEASUREMENT_ITERATIONS = 10; - public static final int WARMUP_ITERATIONS = 10; + public static final int WARMUP_ITERATIONS = 20; public static final int ITERATION_TIME = 1; public static final int FORKS = 1; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java index 874caad55356..c58cfebc7576 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -44,10 +44,12 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; +import com.oracle.truffle.api.dsl.GeneratedBy; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleSafepoint; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.impl.UnsafeFrameAccess; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.LoopNode; @@ -155,7 +157,114 @@ protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { } } } +} + +@GeneratedBy(ManualUnsafeBytecodeNode.class) // needed for UFA +class ManualUnsafeBytecodeNode extends BaseBytecodeNode { + protected ManualUnsafeBytecodeNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc) { + super(language, frameDescriptor, bc); + } + + private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); + + @Override + @BytecodeInterpreterSwitch + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { + short[] localBc = bc; + int bci = startBci; + int sp = startSp; + + Counter loopCounter = new Counter(); + + frame.getArguments(); + loop: while (true) { + short opcode = UFA.unsafeShortArrayRead(localBc, bci); + CompilerAsserts.partialEvaluationConstant(opcode); + switch (opcode) { + // ( -- ) + case OP_JUMP: { + int nextBci = UFA.unsafeShortArrayRead(localBc, bci + 1); + CompilerAsserts.partialEvaluationConstant(nextBci); + if (nextBci <= bci) { + Object result = backwardsJumpCheck(frame, sp, loopCounter, nextBci); + if (result != null) { + return result; + } + } + bci = nextBci; + continue loop; + } + // (i1 i2 -- i3) + case OP_ADD: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetInt(frame, sp - 2, lhs + rhs); + sp -= 1; + bci += 1; + continue loop; + } + // (i1 i2 -- i3) + case OP_MOD: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetInt(frame, sp - 2, lhs % rhs); + sp -= 1; + bci += 1; + continue loop; + } + // ( -- i) + case OP_CONST: { + UFA.unsafeSetInt(frame, sp, (UFA.unsafeShortArrayRead(localBc, bci + 2) << 16) | (UFA.unsafeShortArrayRead(localBc, bci + 1) & 0xffff)); + sp += 1; + bci += 3; + continue loop; + } + // (b -- ) + case OP_JUMP_FALSE: { + boolean cond = UFA.unsafeGetBoolean(frame, sp - 1); + sp -= 1; + if (!cond) { + bci = UFA.unsafeShortArrayRead(localBc, bci + 1); + continue loop; + } else { + bci += 2; + continue loop; + } + } + // (i1 i2 -- b) + case OP_LESS: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetBoolean(frame, sp - 2, lhs < rhs); + sp -= 1; + bci += 1; + continue loop; + } + // (i -- ) + case OP_RETURN: { + return UFA.unsafeGetInt(frame, sp - 1); + } + // (i -- ) + case OP_ST_LOC: { + UFA.unsafeCopyPrimitive(frame, sp - 1, UFA.unsafeShortArrayRead(localBc, bci + 1)); + sp -= 1; + bci += 2; + continue loop; + } + // ( -- i) + case OP_LD_LOC: { + UFA.unsafeCopyPrimitive(frame, UFA.unsafeShortArrayRead(localBc, bci + 1), sp); + sp += 1; + bci += 2; + continue loop; + } + default: + CompilerDirectives.shouldNotReachHere(); + } + } + } } abstract class BaseBytecodeNode extends RootNode implements BytecodeOSRNode { @@ -177,6 +286,7 @@ protected BaseBytecodeNode(TruffleLanguage language, FrameDescriptor frameDes static final short OP_LD_LOC = 8; static final short OP_MOD = 9; + @CompilerDirectives.ValueType protected static class Counter { int count; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index d0f5a12e3596..c43bb3c428f8 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -58,18 +58,18 @@ import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationParser; +import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.test.example.BoxingOperations.ObjectProducer; public class BoxingOperationsTest { - // todo: all of these tests should somehow check that e&s is not called more times - // than it needs to - private static final BoxingLanguage LANGUAGE = null; + private static final int NUM_ITERATIONS = 10_000; + private static final int MAX_INVALIDATIONS = 20; + private static RootCallTarget parse(OperationParser parser) { OperationRootNode node = parseNode(parser); return ((RootNode) node).getCallTarget(); @@ -81,6 +81,16 @@ private static OperationRootNode parseNode(OperationParser { @@ -95,9 +105,11 @@ public void testCastsPrimToPrim() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call()); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call()); + } + }); } @Test @@ -114,9 +126,11 @@ public void testCastsRefToPrim() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call()); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call()); + } + }); } @Test @@ -133,9 +147,11 @@ public void testCastsPrimToRef() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call()); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call()); + } + }); } @Test @@ -152,9 +168,11 @@ public void testCastsRefToRef() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call()); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call()); + } + }); } @Test @@ -173,19 +191,19 @@ public void testCastsChangePrim() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); - } - - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); - } - - try { - root.call(ObjectProducer.PRODUCE_BOOLEAN); - Assert.fail(); - } catch (UnsupportedSpecializationException e) { - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + } + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + } + try { + root.call(ObjectProducer.PRODUCE_BOOLEAN); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + }); } @Test @@ -204,19 +222,21 @@ public void testCastsChangeRef() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + } - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); - } + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + } - try { - root.call(ObjectProducer.PRODUCE_INT); - Assert.fail(); - } catch (UnsupportedSpecializationException e) { - } + try { + root.call(ObjectProducer.PRODUCE_INT); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + }); } @Test @@ -235,19 +255,21 @@ public void testCastsChangeSpecPrim() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + } - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); - } + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + } - try { - root.call(ObjectProducer.PRODUCE_BOOLEAN); - Assert.fail(); - } catch (UnsupportedSpecializationException e) { - } + try { + root.call(ObjectProducer.PRODUCE_BOOLEAN); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + }); } @Test @@ -266,19 +288,19 @@ public void testCastsChangeSpecRef() { b.endRoot(); }); - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); - } - - for (int i = 0; i < 3; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); - } - - try { - root.call(ObjectProducer.PRODUCE_INT); - Assert.fail(); - } catch (UnsupportedSpecializationException e) { - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + } + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + } + try { + root.call(ObjectProducer.PRODUCE_INT); + Assert.fail(); + } catch (UnsupportedSpecializationException e) { + } + }); } @Test @@ -305,9 +327,11 @@ public void testLBEMultipleLoads() { RootCallTarget root = ((RootNode) node).getCallTarget(); - for (int i = 0; i < 100; i++) { - Assert.assertEquals(1L, root.call()); - } + testInvalidations(() -> { + for (int i = 0; i < NUM_ITERATIONS; i++) { + Assert.assertEquals(1L, root.call()); + } + }); } } @@ -361,10 +385,15 @@ static long castLong(ReferenceTypeB b) { } } -@GenerateOperations(languageClass = BoxingLanguage.class, boxingEliminationTypes = {boolean.class, int.class, long.class}) +@GenerateOperations(// + languageClass = BoxingLanguage.class, // + boxingEliminationTypes = {boolean.class, int.class, long.class}) @SuppressWarnings("unused") abstract class BoxingOperations extends RootNode implements OperationRootNode { + static final boolean __magic_LogInvalidations = false; + static int __magic_CountInvalidations = 0; + protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) { super(language, frameDescriptor.build()); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 7179587f4662..f22fdd563283 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -67,7 +67,6 @@ import com.oracle.truffle.api.operation.Variadic; @GenerateOperations(languageClass = TestLanguage.class, enableYield = true) -@GenerateUncached @GenerateAOT @OperationProxy(SomeOperationNode.class) public abstract class TestOperations extends RootNode implements OperationRootNode { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java index dcabfc8538e4..2c09200d2db6 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/Operation.java @@ -48,5 +48,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Operation { - boolean disableBoxingElimination() default false; } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 4fca6e1cffe4..135c0e3f7bb7 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -319,11 +319,6 @@ void unsafeSetObject(int slot, Object value) throws FrameSlotTypeException { unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); } - void unsafeUncheckedSetObject(int slot, Object value) { - assert getIndexedTagChecked(slot) == OBJECT_TAG; - unsafePutObject(getIndexedLocals(), getObjectOffset(slot), value, OBJECT_LOCATION); - } - @Override public byte getByte(int slot) throws FrameSlotTypeException { boolean condition = verifyIndexedGet(slot, BYTE_TAG); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 0bdba9df0100..523c1a68a748 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -87,8 +87,6 @@ public static UnsafeFrameAccess lookup() { public abstract void unsafeSetObject(Frame frame, int slot, Object value); - public abstract void unsafeUncheckedSetObject(Frame frame, int slot, Object value); - public abstract void unsafeSetBoolean(Frame frame, int slot, boolean value); public abstract void unsafeSetInt(Frame frame, int slot, int value); @@ -210,11 +208,6 @@ public void unsafeSetObject(Frame frame, int slot, Object value) { castFrame(frame).unsafeSetObject(slot, value); } - @Override - public void unsafeUncheckedSetObject(Frame frame, int slot, Object value) { - castFrame(frame).unsafeUncheckedSetObject(slot, value); - } - @Override public void unsafeSetInt(Frame frame, int slot, int value) { castFrame(frame).unsafeSetInt(slot, value); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 0cb346333107..5e7e9365e3bd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -88,6 +88,7 @@ public class TruffleTypes { public static final String Frame_Name = "com.oracle.truffle.api.frame.Frame"; public static final String FrameDescriptor_Name = "com.oracle.truffle.api.frame.FrameDescriptor"; public static final String FrameSlotKind_Name = "com.oracle.truffle.api.frame.FrameSlotKind"; + public static final String FrameSlotTypeException_Name = "com.oracle.truffle.api.frame.FrameSlotTypeException"; public static final String FinalBitSet_Name = "com.oracle.truffle.api.utilities.FinalBitSet"; public static final String InvalidAssumptionException_Name = "com.oracle.truffle.api.nodes.InvalidAssumptionException"; public static final String MaterializedFrame_Name = "com.oracle.truffle.api.frame.MaterializedFrame"; @@ -127,6 +128,7 @@ public class TruffleTypes { public final DeclaredType Frame = c.getDeclaredType(Frame_Name); public final DeclaredType FrameDescriptor = c.getDeclaredType(FrameDescriptor_Name); public final DeclaredType FrameSlotKind = c.getDeclaredType(FrameSlotKind_Name); + public final DeclaredType FrameSlotTypeException = c.getDeclaredType(FrameSlotTypeException_Name); public final DeclaredType FinalBitSet = c.getDeclaredType(FinalBitSet_Name); public final DeclaredType InvalidAssumptionException = c.getDeclaredType(InvalidAssumptionException_Name); public final DeclaredType MaterializedFrame = c.getDeclaredType(MaterializedFrame_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 2b428981dbdd..379a6fc2f186 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -2072,7 +2072,7 @@ private String createExecuteAndSpecializeName() { } if (plugs != null) { - result = plugs.transformNodeMethodName(result); + result = plugs.createExecuteAndSpecializeName(result); } return result; @@ -2442,6 +2442,10 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List builder.tree(executeFastPathGroup(builder, frameState, currentType, originalGroup, sharedExecutes, null)); addExplodeLoop(builder, originalGroup); } else { + if (plugs != null) { + plugs.initializeFrameState(frameState, builder); + } + FrameState originalFrameState = frameState.copy(); boolean elseIf = false; @@ -2483,26 +2487,33 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group CodeExecutableElement parentMethod = (CodeExecutableElement) parent.findMethod(); CodeTypeElement parentClass = (CodeTypeElement) parentMethod.getEnclosingElement(); String name = parentMethod.getSimpleName().toString() + "_" + suffix + (boxingSplitIndex++); + + String[] optNames; + if (plugs != null) { name = plugs.transformNodeMethodName(name); + optNames = new String[0]; + } else { + optNames = new String[]{FRAME_VALUE}; } CodeExecutableElement method = parentClass.add(new CodeExecutableElement(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name)); multiState.addParametersTo(frameState, method); - frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); + frameState.addParametersTo(method, Integer.MAX_VALUE, optNames); CodeTreeBuilder builder = method.createBuilder(); builder.tree(codeTree); method.getThrownTypes().addAll(parentMethod.getThrownTypes()); addExplodeLoop(builder, group); CodeTreeBuilder parentBuilder = parent.create(); - if (plugs == null || !plugs.createCallWrapInAMethod(frameState, parentBuilder, method, () -> multiState.addReferencesTo(frameState, parentBuilder))) { - parentBuilder.startReturn(); - parentBuilder.startCall(method.getSimpleName().toString()); - multiState.addReferencesTo(frameState, parentBuilder); - frameState.addReferencesTo(parentBuilder, FRAME_VALUE); - parentBuilder.end(); - parentBuilder.end(); + parentBuilder.startReturn(); + parentBuilder.startCall(method.getSimpleName().toString()); + if (plugs != null) { + plugs.addNodeCallParameters(parentBuilder, false, false); } + multiState.addReferencesTo(frameState, parentBuilder); + frameState.addReferencesTo(parentBuilder, optNames); + parentBuilder.end(); + parentBuilder.end(); return parentBuilder.build(); } @@ -3234,7 +3245,7 @@ private CodeTree cast(TypeMirror sourceType, TypeMirror targetType, CodeTree con private CodeTree expect(TypeMirror sourceType, TypeMirror forType, CodeTree tree) { if (sourceType == null || needsCastTo(sourceType, forType)) { expectedTypes.add(forType); - return TypeSystemCodeGenerator.expect(typeSystem, forType, tree); + return TypeSystemCodeGenerator.expect(typeSystem, forType, tree, plugs); } return tree; } @@ -3445,19 +3456,17 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par } CodeTree specializationCall = callMethod(frameState, null, specialization.getMethod(), bindings); - if (plugs == null || !plugs.createCallSpecialization(frameState, specialization, specializationCall, builder, inBoundary, bindings)) { - if (isVoid(specialization.getMethod().getReturnType())) { - builder.statement(specializationCall); - if (isVoid(forType.getReturnType())) { - builder.returnStatement(); - } else { - builder.startReturn().defaultValue(forType.getReturnType()).end(); - } + if (isVoid(specialization.getMethod().getReturnType())) { + builder.statement(specializationCall); + if (isVoid(forType.getReturnType())) { + builder.returnStatement(); } else { - builder.startReturn(); - builder.tree(expectOrCast(specialization.getReturnType().getType(), forType, specializationCall)); - builder.end(); + builder.startReturn().defaultValue(forType.getReturnType()).end(); } + } else { + builder.startReturn(); + builder.tree(expectOrCast(specialization.getReturnType().getType(), forType, specializationCall)); + builder.end(); } builder.end(numCachedNullChecks); @@ -4108,12 +4117,12 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt boundaryMethodName = boundaryMethodName + (boundaryIndex++); } + usedBoundaryNames.add(boundaryMethodName); + if (plugs != null) { boundaryMethodName = plugs.transformNodeMethodName(boundaryMethodName); } - usedBoundaryNames.add(boundaryMethodName); - String includeFrameParameter; if (specialization != null && specialization.getFrame() != null) { if (ElementUtils.typeEquals(types.MaterializedFrame, specialization.getFrame().getType())) { @@ -4139,19 +4148,15 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt innerBuilder = boundaryMethod.createBuilder(); ((CodeTypeElement) parentMethod.getEnclosingElement()).add(boundaryMethod); + builder.startTryBlock(); + builder.startReturn().startCall(boundaryMethodName); if (plugs != null) { - plugs.createCallBoundaryMethod(builder, frameState, boundaryMethod, b -> { - multiState.addReferencesTo(frameState, b); - frameState.addReferencesTo(b, includeFrameParameter, createSpecializationLocalName(specialization)); - }); - } else { - builder.startTryBlock(); - builder.startReturn().startCall("this", boundaryMethod); - multiState.addReferencesTo(frameState, builder); - frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); - builder.end().end(); - builder.end().startCatchBlock(types.BoundaryCallFailedException, "ex").end(); + plugs.addNodeCallParameters(builder, true, false); } + multiState.addReferencesTo(frameState, builder); + frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); + builder.end().end(); + builder.end().startCatchBlock(types.BoundaryCallFailedException, "ex").end(); return innerBuilder; } @@ -4821,7 +4826,12 @@ private CodeTree createCallExecute(ExecutableTypeData forType, ExecutableTypeDat } } - CodeTree call = callMethod(frameState, null, targetType.getMethod(), bindings.toArray(new CodeTree[0])); + CodeTree call; + if (plugs == null) { + call = callMethod(frameState, null, targetType.getMethod(), bindings.toArray(new CodeTree[0])); + } else { + call = plugs.createCallExecute(frameState, targetType.getMethod(), bindings.toArray(new CodeTree[0])); + } CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder = builder.create(); if (isVoid(forType.getReturnType())) { @@ -4868,10 +4878,6 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram } private CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast) { - if (plugs != null) { - return plugs.createReturnUnexpectedResult(frameState, forType, needsCast); - } - TypeMirror returnType = context.getType(Object.class); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 5ab2bea35e9f..78664f278331 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -94,10 +94,22 @@ public static void popEncapsulatingNode(CodeTreeBuilder builder) { builder.startStatement().string("encapsulating_.set(prev_)").end(); } + private static ThreadLocal hookTransferToInterpreter = ThreadLocal.withInitial(() -> false); + + public static void setHookTransferToInterpreter(boolean value) { + hookTransferToInterpreter.set(value); + } + public static CodeTree createTransferToInterpreterAndInvalidate() { ProcessorContext context = ProcessorContext.getInstance(); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.startStatement().startStaticCall(context.getTypes().CompilerDirectives, "transferToInterpreterAndInvalidate").end().end(); + builder.startStatement(); + if (hookTransferToInterpreter.get()) { + builder.startCall("hook_transferToInterpreterAndInvalidate").end(); + } else { + builder.startStaticCall(context.getTypes().CompilerDirectives, "transferToInterpreterAndInvalidate").end(); + } + builder.end(); return builder.build(); } @@ -112,6 +124,13 @@ public static CodeTree createPartialEvaluationConstant(String variable) { return builder.build(); } + public static CodeTree createNeverPartOfCompilation() { + ProcessorContext context = ProcessorContext.getInstance(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.startStatement().startStaticCall(context.getTypes().CompilerAsserts, "neverPartOfCompilation").end(2); + return builder.build(); + } + public static CodeTree createShouldNotReachHere() { ProcessorContext context = ProcessorContext.getInstance(); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 67ca1d6c1e8b..44f82689ae7c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -44,6 +44,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; @@ -89,14 +90,8 @@ public interface NodeGeneratorPlugs { void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); - boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder builder, boolean inBoundary, CodeTree[] bindings); - boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call); - void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments); - - boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters); - CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState); CodeTree createThrowUnsupportedChild(NodeExecutionData execution); @@ -129,7 +124,11 @@ public interface NodeGeneratorPlugs { CodeTree createSuperInsert(CodeTree value); - CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast); - void setUseSpecializationClass(Predicate useSpecializationClass); + + String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type); + + CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees); + + String createExecuteAndSpecializeName(String result); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index bca87480b2fd..6c43229a5b16 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -129,15 +129,15 @@ public static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, CodeTree return builder.build(); } - static CodeTree expect(TypeSystemData typeSystem, TypeMirror type, CodeTree content) { + static CodeTree expect(TypeSystemData typeSystem, TypeMirror type, CodeTree content, NodeGeneratorPlugs plugs) { if (ElementUtils.isObject(type) || ElementUtils.isVoid(type)) { return content; } CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); if (typeSystem.hasType(type)) { - builder.startStaticCall(createTypeSystemGen(typeSystem), expectTypeMethodName(typeSystem, type)).tree(content).end(); + builder.startStaticCall(createTypeSystemGen(typeSystem), expectTypeMethodName(typeSystem, type, null)).tree(content).end(); } else { - builder.startCall(expectTypeMethodName(typeSystem, type)).tree(content).end(); + builder.startCall(expectTypeMethodName(typeSystem, type, plugs)).tree(content).end(); } return builder.build(); @@ -150,7 +150,7 @@ static CodeExecutableElement createExpectMethod(Modifier visibility, TypeSystemD return null; } - CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), expectedType, TypeSystemCodeGenerator.expectTypeMethodName(typeSystem, expectedType)); + CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), expectedType, TypeSystemCodeGenerator.expectTypeMethodName(typeSystem, expectedType, null)); method.setVisibility(visibility); method.addParameter(new CodeVariableElement(sourceType, LOCAL_VALUE)); method.addThrownType(typeSystem.getContext().getTypes().UnexpectedResultException); @@ -215,8 +215,12 @@ private static String expectImplicitTypeMethodName(TypeSystemData typeSystem, Ty return "expectImplicit" + getTypeId(typeSystem, type); } - private static String expectTypeMethodName(TypeSystemData typeSystem, TypeMirror type) { - return "expect" + getTypeId(typeSystem, type); + private static String expectTypeMethodName(TypeSystemData typeSystem, TypeMirror type, NodeGeneratorPlugs plugs) { + String name = "expect" + getTypeId(typeSystem, type); + if (plugs != null) { + name = plugs.createExpectTypeMethodName(typeSystem, type); + } + return name; } static String typeName(TypeSystemData typeSystem) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index 5bc109e97cad..e85ff2c1b55e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -1020,6 +1020,13 @@ public CodeTreeBuilder variable(VariableElement variable) { return string(variable.getSimpleName().toString()); } + public CodeTreeBuilder variables(List variables) { + for (VariableElement variable : variables) { + variable(variable); + } + return this; + } + public CodeTreeBuilder field(String receiver, VariableElement field) { if (receiver == null && field.getModifiers().contains(Modifier.STATIC)) { return staticReference(field); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index 662621507969..e44c0ba85532 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -55,7 +55,4 @@ public class OperationGeneratorFlags { public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; public static final boolean ENABLE_SERIALIZATION = true; - - public static final boolean USE_UNSAFE = false; - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index e337a934475a..c4f3b4a51e1f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -45,12 +45,15 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import java.util.function.Function; +import java.util.function.Supplier; import javax.lang.model.element.Element; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; @@ -126,6 +129,13 @@ public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableEle CodeTreeBuilder.singleVariable(value)); } + public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, String value) { + return createWriteOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleVariable(bci), + CodeTreeBuilder.singleString(value)); + } + public static CodeTree createWriteOpcode(CodeVariableElement bc, String bci, CodeVariableElement value) { return createWriteOpcode( CodeTreeBuilder.singleVariable(bc), @@ -202,7 +212,7 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar } - b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).end().startBlock(); + b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).string(" & 0x1fff").end().startBlock(); for (int i = 0; i < trees.size(); i++) { if (treeInstructions.get(i) == null) { b.caseDefault(); @@ -238,6 +248,16 @@ public static CodeTree callSetResultBoxed(CodeTree bciOffset, CodeTree kind) { } public static CodeTree toFrameTypeConstant(FrameKind kind) { - return CodeTreeBuilder.singleString(kind.ordinal() + " /* " + kind + " */"); + return CodeTreeBuilder.singleString(kind.toOrdinal()); + } + + public static void createHelperMethod(CodeTypeElement element, String name, Supplier e) { + if (!element.getEnclosedElements().stream().anyMatch(x -> x.getSimpleName().toString().equals(name))) { + CodeExecutableElement ex = e.get(); + if (!ex.getSimpleName().toString().equals(name)) { + throw new IllegalArgumentException("names do not match"); + } + element.add(ex); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 1f64d7c4052e..9dcbd5abbd05 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -44,6 +44,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -68,6 +69,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; @@ -290,6 +292,11 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); + if (m.getOperationsContext().hasBoxingElimination()) { + b.declaration("short", "primitiveTag", isUncached ? "0" : "(short)((curOpcode >> 13) & 0x0007)"); + b.startAssign(varCurOpcode).string("(short) (").variable(varCurOpcode).string(" & 0x1fff)").end(); + } + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); b.startTryBlock(); @@ -344,7 +351,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.caseDefault().startCaseBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \"")); + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); b.end(); b.end(); // switch block @@ -404,16 +411,12 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr CustomInstruction cinstr = (CustomInstruction) instr; - boolean isVariadic = cinstr.getData().getMainProperties().isVariadic; - boolean isShortCircuit = cinstr.getData().isShortCircuit(); - boolean regularReturn = isVariadic || isShortCircuit; - final Set methodNames = new HashSet<>(); final Set innerTypeNames = new HashSet<>(); final SingleOperationData soData = cinstr.getData(); - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, isVariadic, cinstr, staticConstants, isUncached); + OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, cinstr, staticConstants, isUncached); cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); @@ -427,7 +430,9 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr plugs.finishUp(); CodeTypeElement result = resultList.get(0); - CodeExecutableElement executeMethod = null; + List executeNames = m.getOperationsContext().getBoxingKinds().stream().map( + x -> plugs.transformNodeMethodName(x == FrameKind.OBJECT ? "execute" : "execute" + x.getFrameName())).collect(Collectors.toList()); + CodeExecutableElement[] executeMethods = new CodeExecutableElement[isUncached ? 1 : executeNames.size()]; List execs = new ArrayList<>(); TypeElement target = result; @@ -447,27 +452,32 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr continue; } - String targetName = isUncached ? "executeUncached" : "execute"; - String otherTargetName = !isUncached ? "executeUncached" : "execute"; + String simpleName = ex.getSimpleName().toString(); - if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName(targetName))) { - executeMethod = (CodeExecutableElement) ex; - } - - if (ex.getSimpleName().toString().equals(plugs.transformNodeMethodName(otherTargetName))) { - continue; + if (isUncached) { + if (simpleName.equals(plugs.transformNodeMethodName("executeUncached"))) { + executeMethods[0] = (CodeExecutableElement) ex; + } else if (executeNames.contains(simpleName)) { + continue; + } + } else { + if (simpleName.equals(plugs.transformNodeMethodName("executeUncached"))) { + continue; + } else if (executeNames.contains(simpleName)) { + executeMethods[executeNames.indexOf(simpleName)] = (CodeExecutableElement) ex; + } } execs.add((CodeExecutableElement) ex); copiedMethod.add(ex.getSimpleName().toString()); } - if (executeMethod == null) { - throw new AssertionError(String.format("execute method not found in: %s", result.getSimpleName())); + for (CodeExecutableElement el : executeMethods) { + if (el != null) { + el.getAnnotationMirrors().removeIf(x -> ElementUtils.typeEquals(x.getAnnotationType(), types.CompilerDirectives_TruffleBoundary)); + } } - executeMethod.getAnnotationMirrors().removeIf(x -> ElementUtils.typeEquals(x.getAnnotationType(), types.CompilerDirectives_TruffleBoundary)); - for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { if (!innerTypeNames.contains(te.getSimpleName().toString())) { continue; @@ -482,7 +492,7 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); String exName = exToCopy.getSimpleName().toString(); - boolean isExecute = exName.contains("_execute_") || exName.contains("_executeUncached_"); + boolean isExecute = executeNames.contains(exName) || exName.contains("_executeUncached_"); boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); @@ -505,12 +515,9 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr } } - if (!regularReturn) { - if (isExecute || isExecuteAndSpecialize) { - exToCopy.setReturnType(context.getType(void.class)); - } + if (cinstr.isVariadic()) { + exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$numVariadics")); } - exToCopy.getParameters().add(0, new CodeVariableElement(arrayOf(types.Node), "$children")); exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(Object[].class), "$consts")); exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$sp")); @@ -537,9 +544,9 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr } if (isUncached) { - cinstr.setUncachedExecuteMethod(executeMethod); + cinstr.setUncachedExecuteMethod(executeMethods[0]); } else { - cinstr.setExecuteMethod(executeMethod); + cinstr.setExecuteMethod(executeMethods); } cinstr.setPrepareAOTMethod(metPrepareForAOT); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index c23beba76f6e..f5ebb9cd74ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -50,6 +50,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeKind; @@ -59,6 +61,7 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.BitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; @@ -67,6 +70,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.StateBitSet; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -89,13 +93,11 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final Set innerTypeNames; private final Set methodNames; - private final boolean isVariadic; private final CustomInstruction cinstr; private final StaticConstants staticConstants; private final ProcessorContext context; private final TruffleTypes types; - private final Object resultUnboxedState; private List specializationStates; private MultiStateBitSet multiState; @@ -114,29 +116,17 @@ public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGenerator types = context.getTypes(); } - OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, boolean isVariadic, CustomInstruction cinstr, StaticConstants staticConstants, + OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, CustomInstruction cinstr, StaticConstants staticConstants, boolean uncached) { this.m = m; OperationsBytecodeCodeGenerator.populateVariables(dummyVariables, m); this.innerTypeNames = innerTypeNames; this.methodNames = methodNames; - this.isVariadic = isVariadic; this.cinstr = cinstr; this.staticConstants = staticConstants; this.data = cinstr.getData(); - if (cinstr.numPushedValues == 0 || data.isShortCircuit()) { - resultUnboxedState = null; - } else { - resultUnboxedState = new Object() { - @Override - public String toString() { - return "RESULT-UNBOXED"; - } - }; - } - this.uncached = uncached; } @@ -155,12 +145,6 @@ public void setNodeData(NodeData node) { @Override public void addAdditionalStateBits(List stateObjects) { - if (!stateObjects.isEmpty()) { - throw new AssertionError("stateObjects must be empty"); - } - if (resultUnboxedState != null) { - stateObjects.add(resultUnboxedState); - } } @Override @@ -218,6 +202,10 @@ public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, b builder.string("$consts"); builder.string("$children"); + if (cinstr.isVariadic()) { + builder.string("$numVariadics"); + } + for (int i = 0; i < m.getNumTosSlots(); i++) { builder.string("$tos_" + i); } @@ -436,15 +424,7 @@ public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { @Override public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { - if (regularReturn()) { - return values.toArray(new CodeTree[values.size()]); - } - CodeTree[] result = new CodeTree[values.size()]; - for (int i = 0; i < values.size(); i++) { - result[i] = CodeTreeBuilder.singleString((m.enableYield ? "$stackFrame" : "$frame") + ".getValue($sp - " + (cinstr.numPopStatic() - i) + ")"); - } - - return result; + return values.toArray(new CodeTree[values.size()]); } @Override @@ -456,113 +436,6 @@ public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) frameState.setBoolean("definedOffsets", true); } - private void createPushResult(FrameState frameState, CodeTreeBuilder b, CodeTree specializationCall, TypeMirror retType) { - if (cinstr.numPushedValues == 0) { - b.statement(specializationCall); - b.returnStatement(); - return; - } - - if (data.isShortCircuit()) { - b.startReturn(); - b.tree(specializationCall); - b.end(); - return; - } - - assert cinstr.numPushedValues == 1; - - int destOffset = cinstr.numPopStatic(); - - CodeTree value; - String typeName; - if (retType.getKind() == TypeKind.VOID) { - // we need to push something, lets just push a `null`. - // maybe this should be an error? DSL just returns default value - - b.statement(specializationCall); - value = CodeTreeBuilder.singleString("null"); - typeName = "Object"; - } else { - value = specializationCall; - typeName = getFrameType(retType.getKind()).getFrameName(); - } - - CodeTree isResultBoxed = multiState.createNotContains(frameState, new Object[]{resultUnboxedState}); - - if (uncached || data.isDisableBoxingElimination() || typeName.equals("Object")) { - b.startStatement(); - if (m.getBoxingEliminatedTypes().size() == 0) { - b.startCall("UFA", "unsafeUncheckedSetObject"); - } else { - b.startCall("UFA", "unsafeSetObject"); - } - b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp - " + destOffset); - b.tree(value); - b.end(2); - } else { - b.declaration(retType, "value", value); - b.startIf().tree(isResultBoxed).end().startBlock(); - // { - b.startStatement(); - b.startCall("UFA", "unsafeSetObject"); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp - " + destOffset); - b.string("value"); - b.end(2); - // } - b.end().startElseBlock(); - // { - b.startStatement(); - b.startCall("UFA", "unsafeSet" + typeName); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp - " + destOffset); - b.string("value"); - b.end(2); - // } - b.end(); - } - - b.returnStatement(); - - } - - @Override - public boolean createCallSpecialization(FrameState frameState, SpecializationData specialization, CodeTree specializationCall, CodeTreeBuilder b, boolean inBoundary, CodeTree[] bindings) { - - // if (m.isTracing()) { - // b.startStatement().startCall("tracer", "traceSpecialization"); - // b.string("$bci"); - // b.variable(cinstr.opcodeIdField); - // b.string("" + specialization.getIntrospectionIndex()); - // for (int i = 0; i < bindings.length; i++) { - // Parameter parameter = specialization.getParameters().get(i); - // if (parameter.getSpecification().isSignature()) { - // b.tree(bindings[i]); - // } - // } - // b.end(2); - // } - - if (inBoundary || regularReturn()) { - if (ElementUtils.isVoid(specialization.getMethod().getReturnType())) { - b.statement(specializationCall); - b.returnStatement(); - } else { - b.startReturn().tree(specializationCall).end(); - } - } else { - createPushResult(frameState, b, specializationCall, specialization.getMethod().getReturnType()); - } - - return true; - } - - private boolean regularReturn() { - return isVariadic || data.isShortCircuit(); - } - private int ensCall = 0; @Override @@ -583,66 +456,7 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui builder.end(3); } - if (regularReturn()) { - builder.startReturn(); - } else { - builder.startStatement(); - } - - builder.startCall(easName); - addNodeCallParameters(builder, false, false); - frameState.addReferencesTo(builder); - builder.end(2); - - if (!regularReturn()) { - builder.returnStatement(); - } - - return true; - } - - @Override - public void createCallBoundaryMethod(CodeTreeBuilder builder, FrameState frameState, CodeExecutableElement boundaryMethod, Consumer addArguments) { - if (regularReturn()) { - builder.startReturn().startCall(boundaryMethod.getSimpleName().toString()); - addNodeCallParameters(builder, true, false); - addArguments.accept(builder); - builder.end(2); - return; - } - - CodeTreeBuilder callBuilder = builder.create(); - - callBuilder.startCall(boundaryMethod.getSimpleName().toString()); - addNodeCallParameters(callBuilder, true, false); - addArguments.accept(callBuilder); - callBuilder.end(); - - createPushResult(frameState, builder, callBuilder.build(), boundaryMethod.getReturnType()); - } - - @Override - public boolean createCallWrapInAMethod(FrameState frameState, CodeTreeBuilder parentBuilder, CodeExecutableElement method, Runnable addStateParameters) { - boolean needsReturn; - if (regularReturn() && method.getReturnType().getKind() != TypeKind.VOID) { - parentBuilder.startReturn(); - needsReturn = false; - } else { - parentBuilder.startStatement(); - needsReturn = true; - } - - parentBuilder.startCall(method.getSimpleName().toString()); - addNodeCallParameters(parentBuilder, false, false); - addStateParameters.run(); - frameState.addReferencesTo(parentBuilder); - parentBuilder.end(2); - - if (needsReturn) { - parentBuilder.returnStatement(); - } - - return true; + return false; } private FrameKind getFrameType(TypeKind type) { @@ -663,16 +477,34 @@ public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, Execut return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false, false); } + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (execution.getName().equals("$variadicChild")) { + b.startCall("do_loadVariadicArguments"); + b.string(m.enableYield ? "$stackFrame" : "$frame"); + b.string("$sp"); + b.string("$numVariadics"); + b.end(); + return b.build(); + } + int childIndex = execution.getIndex(); int offset = cinstr.numPopStatic() - childIndex; - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - FrameKind resultKind = getFrameType(method.getReturnType().getKind()); b.startCall("expect" + resultKind.getFrameName()); b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp - " + offset); + if (cinstr.isVariadic()) { + b.string("$sp - " + offset + " - $numVariadics"); + } else { + b.string("$sp - " + offset); + } + if (m.getOperationsContext().hasBoxingElimination()) { + b.string("$bc"); + b.string("$bci"); + b.tree(cinstr.createPopIndexedIndex(dummyVariables, childIndex, false)); + } b.end(); return b.build(); @@ -690,6 +522,9 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ List quickened = cinstr.getQuickenedVariants(); if (!quickened.isEmpty()) { + + b.startAssign("short primitiveTagBits").string("(short) (").tree(OperationGeneratorUtils.createReadOpcode(dummyVariables.bc, dummyVariables.bci)).string(" & 0xe000)").end(); + // only quicken/unquicken for instructions that have quickened versions boolean elseIf = false; for (QuickenedInstruction qinstr : quickened) { @@ -698,7 +533,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); b.end().startBlock(); // { - b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, qinstr.opcodeIdField)); + b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, "(short) (" + qinstr.opcodeIdField.getName() + " | primitiveTagBits)")); // } b.end(); } @@ -709,138 +544,13 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // quicken to generic - b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, cinstr.opcodeIdField)); - - if (elseIf) { - b.end(); - } - } - } - - // boxing elimination - if (!regularReturn() && cinstr.numPopStatic() > 0) { - boolean elseIf = false; - boolean[] needsElse = new boolean[]{true}; - - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.declaration("int", "type" + i, (CodeTree) null); - } - - if (boxingSplits != null && !boxingSplits.isEmpty()) { - for (BoxingSplit split : boxingSplits) { - elseIf = createBoxingSplitUnboxingThing(b, frameState, elseIf, specialization, split.getGroup().collectSpecializations(), split.getPrimitiveSignature(), needsElse); - } - } else { - TypeMirror[] primMirrors = new TypeMirror[cinstr.numPopStatic()]; - List specs = cinstr.getData().getNodeData().getSpecializations(); - for (SpecializationData spec : specs) { - if (spec.isFallback()) { - continue; - } - for (int i = 0; i < primMirrors.length; i++) { - TypeMirror paramType = spec.getParameters().get(i).getType(); - if (primMirrors[i] == null) { - primMirrors[i] = paramType; - } else if (!ElementUtils.typeEquals(primMirrors[i], paramType)) { - // we only care about primitive types, so we do not care about type - // compatibility - primMirrors[i] = ProcessorContext.getInstance().getType(Object.class); - } - } - } - - elseIf = createBoxingSplitUnboxingThing(b, frameState, elseIf, specialization, specs, primMirrors, needsElse); - } - - if (needsElse[0]) { - if (elseIf) { - b.startElseBlock(); - } - - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); - } + b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, "(short) (" + cinstr.opcodeIdField.getName() + " | primitiveTagBits)")); if (elseIf) { b.end(); } } - - for (int i = 0; i < cinstr.numPopStatic(); i++) { - b.tree(OperationGeneratorUtils.callSetResultBoxed(cinstr.createPopIndexedIndex(dummyVariables, i, false), CodeTreeBuilder.singleString("type" + i))); - } } - - } - - // creates the if / else cascade for determining the type required for doSetResultBoxed - private boolean createBoxingSplitUnboxingThing(CodeTreeBuilder b, FrameState frameState, boolean elseIf, SpecializationData specialization, List specializations, - TypeMirror[] primitiveMirrors, boolean[] needsElse) { - if (!specializations.contains(specialization)) { - return elseIf; - } - - CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), specializationStates.toArray()); - if (!tree.isEmpty()) { - b.startIf(elseIf); - b.tree(tree).end().startBlock(); - } else { - needsElse[0] = false; - } - - TypeSystemData tsData = cinstr.getData().getNodeData().getTypeSystem(); - for (int i = 0; i < cinstr.numPopStatic(); i++) { - TypeMirror targetType = i < primitiveMirrors.length ? primitiveMirrors[i] : context.getType(Object.class); - if (!tsData.hasImplicitSourceTypes(targetType)) { - FrameKind frameType = getFrameType(targetType.getKind()); - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); - } else { - boolean elseIf2 = false; - List originalSourceTypes = new ArrayList<>(tsData.lookupSourceTypes(targetType)); - for (TypeMirror sourceType : originalSourceTypes) { - FrameKind frameType = getFrameType(sourceType.getKind()); - if (frameType == FrameKind.OBJECT) { - continue; - } - - TypeGuard typeGuard = new TypeGuard(targetType, i); - - elseIf2 = b.startIf(elseIf2); - - b.tree(multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sourceType), 1, new Object[]{typeGuard}, new Object[]{typeGuard})); - - b.end().startBlock(); - // { - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(frameType)).end(); - // } - b.end(); - } - - if (elseIf2) { - b.startElseBlock(); - } - b.startAssign("type" + i).tree(OperationGeneratorUtils.toFrameTypeConstant(FrameKind.OBJECT)).end(); - if (elseIf2) { - b.end(); - } - } - } - - if (!tree.isEmpty()) { - b.end(); - } - - return true; - } - - public CodeTree createSetResultBoxed(CodeVariableElement varUnboxed) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().variable(varUnboxed).end().startBlock(); - b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultUnboxedState}, true, true)); - b.end().startElseBlock(); - b.tree(multiState.createSet(FrameState.createEmpty(), new Object[]{resultUnboxedState}, false, true)); - b.end(); - return b.build(); } @SuppressWarnings("unchecked") @@ -899,25 +609,6 @@ public boolean isStateGuaranteed(boolean stateGuaranteed) { } public void finishUp() { - if (data.isShortCircuit()) { - cinstr.setBoxingEliminationData(CodeTreeBuilder.singleString("0"), 0); - } else if (cinstr.numPushedValues > 0) { - int offset = -1; - BitSet targetSet = null; - for (StateBitSet set : multiState.getSets()) { - if (set.contains(resultUnboxedState)) { - targetSet = set; - offset = Arrays.asList(set.getObjects()).indexOf(resultUnboxedState); - break; - } - } - - if (offset < 0 || targetSet == null) { - throw new AssertionError(); - } - - cinstr.setBoxingEliminationData(cinstr.createStateBitsOffset(cinstr.addStateBits(targetSet)), 1 << offset); - } } public StaticConstants createConstants() { @@ -935,12 +626,49 @@ public CodeTree createSuperInsert(CodeTree value) { } @Override - public CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast) { + public String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type) { + String name = "result_expect" + ElementUtils.getTypeId(ElementUtils.boxType(type)); + OperationGeneratorUtils.createHelperMethod(m.getOperationsContext().outerType, name, () -> { + CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), type, name); + + el.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); + el.addThrownType(types.UnexpectedResultException); + + CodeTreeBuilder b = el.createBuilder(); + + b.startIf().string("value").instanceOf(ElementUtils.boxType(type)).end().startBlock(); + b.startReturn().cast(type).string("value").end(); + b.end().startElseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startThrow().startNew(types.UnexpectedResultException).string("value").end(2); + b.end(); + + return el; + }); + + return name; + } + + public CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - TypeMirror retType = context.getType(Object.class); - createPushResult(frameState, b, CodeTreeBuilder.singleString((needsCast ? "((UnexpectedResultException) ex)" : "ex") + ".getResult()"), retType); + if (codeTrees.length > 1) { + throw new AssertionError(Arrays.toString(codeTrees)); + } + + b.startCall(transformNodeMethodName(executableElement.getSimpleName().toString())); + addNodeCallParameters(b, false, false); + b.end(); return b.build(); } + + public String createExecuteAndSpecializeName(String result) { + CustomInstruction instr = cinstr; + if (cinstr instanceof QuickenedInstruction) { + instr = ((QuickenedInstruction) cinstr).getOrig(); + } + + return instr.getUniqueName() + "_executeAndSpecialize_"; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 7196363aaa70..88115d2b3efe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -350,6 +350,13 @@ CodeTypeElement createOperationNodeImpl() { genCtor.getModifiers().add(Modifier.PRIVATE); } + boolean doHookTti = ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements()).stream().anyMatch(x -> x.getSimpleName().toString().equals("__magic_LogInvalidations")); + + if (doHookTti) { + GeneratorUtils.setHookTransferToInterpreter(true); + typOperationNodeImpl.add(createHookTransferToInterpreterAndInvalidate()); + } + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getDeclaredType("com.oracle.truffle.api.impl.UnsafeFrameAccess"), "UFA = UnsafeFrameAccess.lookup()")); typOperationNodeImpl.add(compFinal(new CodeVariableElement(new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME), "nodes"))); @@ -479,7 +486,6 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.addAll(instr.createInstructionFields()); } - typOperationNodeImpl.add(createBoxingDescriptors()); typOperationNodeImpl.add(createSetResultUnboxed()); typOperationNodeImpl.add(createLoadVariadicArguments()); typOperationNodeImpl.add(createSetResultBoxedImpl()); @@ -496,9 +502,41 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(createDeserializeMethod()); typOperationNodeImpl.add(createSerializeMethod(typBuilderImpl, typBuilderImpl)); + if (doHookTti) { + GeneratorUtils.setHookTransferToInterpreter(false); + } + return typOperationNodeImpl; } + private CodeExecutableElement createHookTransferToInterpreterAndInvalidate() { + CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "hook_transferToInterpreterAndInvalidate"); + + CodeTreeBuilder b = el.createBuilder(); + + TypeMirror swType = context.getType(StackWalker.class); + + b.startStatement().startStaticCall(types.CompilerDirectives, "transferToInterpreterAndInvalidate").end(2); + + for (VariableElement field : ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements())) { + if (field.getSimpleName().toString().equals("__magic_CountInvalidations")) { + b.startStatement().staticReference(field).string(" += 1").end(); + } + } + + b.startIf().string("__magic_LogInvalidations").end().startBlock(); + b.startStatement().startCall("System.err", "printf"); + b.doubleQuote("[ INV ] %s%s%n"); + b.doubleQuote(""); + b.startStaticCall(swType, "getInstance().walk"); + b.string("s -> s.skip(1).findFirst().get().toStackTraceElement().toString()"); + b.end(); + b.end(2); + b.end(); + + return el; + } + private CodeExecutableElement createLoadVariadicArguments() { CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, arrayOf(context.getType(Object.class)), "do_loadVariadicArguments"); el.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); @@ -2144,7 +2182,6 @@ private CodeExecutableElement createSetResultUnboxed() { b.variable(varBc); b.string("startBci - bciOffset"); b.variable(varTargetType); - b.startGroup().string("BOXING_DESCRIPTORS[").variable(varTargetType).string("]").end(); b.end(2); // } b.end(); @@ -2258,51 +2295,6 @@ private CodeExecutableElement createBuilderImplLabelPass(CodeTypeElement typFtc) } - private CodeVariableElement createBoxingDescriptors() { - CodeVariableElement fldBoxingDescriptors = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, arrayOf(arrayOf(context.getType(short.class))), "BOXING_DESCRIPTORS"); - - CodeTreeBuilder b = fldBoxingDescriptors.createInitBuilder(); - - b.string("{").startCommaGroup(); - for (FrameKind kind : FrameKind.values()) { - b.startGroup().newLine(); - b.lineComment("" + kind); - if (m.getFrameKinds().contains(kind)) { - b.string("{").startCommaGroup(); - b.string("-1"); - for (Instruction instr : m.getInstructions()) { - switch (instr.boxingEliminationBehaviour()) { - case DO_NOTHING: - b.string("0"); - break; - case REPLACE: - b.variable(instr.boxingEliminationReplacement(kind)); - break; - case SET_BIT: { - b.startGroup(); - b.cast(context.getType(short.class)); - b.startParantheses(); - b.string("0x8000 | "); - b.startParantheses().startParantheses().tree(instr.boxingEliminationBitOffset()).end().string(" << 8").end(); - b.string(" | "); - b.string("" + instr.boxingEliminationBitMask()); - b.end(2); - break; - } - default: - throw new UnsupportedOperationException("unknown boxing behaviour: " + instr.boxingEliminationBehaviour()); - } - - } - b.end().string("}").end(); - } else { - b.string("null").end(); - } - } - b.end().string("}"); - return fldBoxingDescriptors; - } - private CodeExecutableElement createAfterChild(BuilderVariables vars) { CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); CodeTreeBuilder b = mAfterChild.getBuilder(); @@ -2457,18 +2449,27 @@ private CodeExecutableElement createExpectObject(boolean hasAnyBoxingElimination mExpectObject.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + if (hasAnyBoxingElimination) { + mExpectObject.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "bciOffset")); + } + CodeTreeBuilder b = mExpectObject.createBuilder(); if (hasAnyBoxingElimination) { - b.startIf().string("UFA.unsafeIsObject(frame, slot)").end().startBlock(); // if { + b.startIf().string("bciOffset == 0 || UFA.unsafeIsObject(frame, slot)").end().startBlock(); } b.startReturn().string("UFA.unsafeUncheckedGetObject(frame, slot)").end(); if (hasAnyBoxingElimination) { b.end().startElseBlock(); // } else { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string("0").end(2); b.startReturn().string("frame.getValue(slot)").end(); + b.end(); // } } @@ -2479,36 +2480,61 @@ private CodeExecutableElement createExpectPrimitive(FrameKind kind) { CodeExecutableElement mExpectPrimitive = new CodeExecutableElement(MOD_PROTECTED_STATIC, kind.getType(), "expect" + kind.getFrameName()); mExpectPrimitive.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); + mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "bciOffset")); mExpectPrimitive.addThrownType(types.UnexpectedResultException); CodeTreeBuilder b = mExpectPrimitive.createBuilder(); if (OperationGeneratorFlags.LOG_STACK_READS) { - b.statement("System.out.println(\" [SR] stack read @ \" + slot + \" : \" + frame.getValue(slot) + \"\")"); + b.statement("System.err.println(\"[ SRD ] stack read @ \" + slot + \" : \" + frame.getValue(slot) + \" as \" + frame.getTag(slot))"); } - b.startSwitch().string("UFA.unsafeGetTag(frame, slot)").end().startBlock(); // switch { + b.startIf().string("bciOffset == 0").end().startBlock(); - b.startCase().string(kind.ordinal() + " /* " + kind + " */").end().startCaseBlock(); // { - b.startReturn().string("UFA.unsafeUncheckedGet" + kind.getFrameName() + "(frame, slot)").end(); - b.end(); // } + b.startAssign("Object value").startCall("UFA", "unsafeUncheckedGetObject"); + b.string("frame"); + b.string("slot"); + b.end(2); + + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + b.startReturn().string("(", kind.getTypeName(), ") value").end(); + b.end().startElseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startThrow().startNew(types.UnexpectedResultException).string("value").end(2); + b.end(); + + b.end().startElseBlock(); + + b.startSwitch().startCall("UFA", "unsafeGetTag").string("frame").string("slot").end(2).startBlock(); + + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + b.startReturn().startCall("UFA", "unsafeUncheckedGet" + kind.getFrameName()).string("frame").string("slot").end(2); + b.end(); - b.startCase().string(FrameKind.OBJECT.ordinal() + " /* OBJECT */").end().startCaseBlock(); // { + b.startCase().string(FrameKind.OBJECT.toOrdinal()).end().startCaseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.declaration("Object", "value", "UFA.unsafeUncheckedGetObject(frame, slot)"); b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - b.startReturn().string("(" + kind.getTypeName() + ") value").end(); - b.end(); + b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string(kind.toOrdinal()).end(2); + b.startReturn().string("(", kind.getTypeName(), ") value").end(); + b.end(); // if b.statement("break"); - b.end(); // } + b.end(); // case - b.end(); // } + b.end();// switch b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + + b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string("0").end(2); b.startThrow().startNew(types.UnexpectedResultException).string("frame.getValue(slot)").end(2); + b.end();// else + return mExpectPrimitive; } @@ -2570,28 +2596,10 @@ private CodeExecutableElement createSetResultBoxedImpl() { mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "targetType")); - mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(short[].class), "descriptor")); CodeTreeBuilder b = mSetResultBoxedImpl.createBuilder(); - b.declaration("int", "op", "bc[bci] & 0xffff"); - b.declaration("short", "todo", "descriptor[op]"); - - b.startIf().string("todo > 0").end().startBlock(); - - b.statement("bc[bci] = todo"); - b.end().startElseBlock(); - - b.declaration("int", "offset", "(todo >> 8) & 0x7f"); - b.declaration("int", "bit", "todo & 0xff"); - - b.startIf().string("targetType == 0 /* OBJECT */").end().startBlock(); - b.statement("bc[bci + offset] &= ~bit"); - b.end().startElseBlock(); - b.statement("bc[bci + offset] |= bit"); - b.end(); - - b.end(); + b.statement("bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff))"); return mSetResultBoxedImpl; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index e49a3884162e..5f608be9b173 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -46,12 +46,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; @@ -114,10 +113,10 @@ public void initializeContext() { } private void createCommonInstructions() { - commonPop = add(new DiscardInstruction("pop", instructionId++)); - commonBranch = add(new BranchInstruction(instructionId++)); + commonPop = add(new DiscardInstruction(this, "pop", instructionId++)); + commonBranch = add(new BranchInstruction(this, instructionId++)); commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++)); - commonThrow = add(new ThrowInstruction(instructionId++)); + commonThrow = add(new ThrowInstruction(this, instructionId++)); } private void createBuiltinOperations() { @@ -134,54 +133,27 @@ private void createBuiltinOperations() { add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - createLoadConstant(); - createLoadArgument(); - createLoadStoreLocal(); - createReturn(); + add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new LoadConstantInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new LoadArgumentInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "Return", operationId++, 1, add(new ReturnInstruction(this, instructionId++)))); - add(new Operation.LoadNonlocal(this, operationId++, add(new LoadNonlocalInstruction(instructionId++)))); - add(new Operation.StoreNonlocal(this, operationId++, add(new StoreNonlocalInstruction(instructionId++)))); + add(new Operation.LoadNonlocal(this, operationId++, add(new LoadNonlocalInstruction(this, instructionId++)))); + add(new Operation.StoreNonlocal(this, operationId++, add(new StoreNonlocalInstruction(this, instructionId++)))); if (data.enableYield) { - add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(instructionId++)))); + add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(this, instructionId++)))); } add(new Operation.Source(this, operationId++)); add(new Operation.SourceSection(this, operationId++)); add(new Operation.InstrumentTag(this, operationId++, - add(new InstrumentationEnterInstruction(instructionId++)), - add(new InstrumentationExitInstruction(instructionId++)), - add(new InstrumentationExitInstruction(instructionId++, true)), - add(new InstrumentationLeaveInstruction(instructionId++)))); - } - - private void createLoadStoreLocal() { - StoreLocalInstruction storeLocal = add(new StoreLocalInstruction(this, instructionId++)); - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, storeLocal)); - - LoadLocalInstruction loadLocal = add(new LoadLocalInstruction(this, instructionId++)); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocal)); - } - - private void createLoadArgument() { - loadArgumentInstructions = new LoadArgumentInstruction[FrameKind.values().length]; - for (FrameKind kind : data.getFrameKinds()) { - loadArgumentInstructions[kind.ordinal()] = add(new LoadArgumentInstruction(this, instructionId++, kind)); - } - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, loadArgumentInstructions[FrameKind.OBJECT.ordinal()])); - } - - private void createLoadConstant() { - loadConstantInstructions = new LoadConstantInstruction[FrameKind.values().length]; - loadConstantInstructions[FrameKind.OBJECT.ordinal()] = add(new LoadConstantInstruction(this, instructionId++, FrameKind.OBJECT)); - - add(new Operation.LoadConstant(this, operationId++, loadConstantInstructions)); - } - - private void createReturn() { - ReturnInstruction retInit = add(new ReturnInstruction(this, instructionId++)); - add(new Operation.Simple(this, "Return", operationId++, 1, retInit)); + add(new InstrumentationEnterInstruction(this, instructionId++)), + add(new InstrumentationExitInstruction(this, instructionId++)), + add(new InstrumentationExitInstruction(this, instructionId++, true)), + add(new InstrumentationLeaveInstruction(this, instructionId++)))); } public T add(T elem) { @@ -253,4 +225,20 @@ public void processDecisions(OperationDecisions decisions) { add(new QuickenedInstruction(this, cinstr, instructionId++, opData, List.of(quicken.specializations))); } } + + public boolean hasBoxingElimination() { + return data.getBoxingEliminatedTypes().size() > 0; + } + + public List getPrimitiveBoxingKinds() { + return data.getBoxingEliminatedTypes().stream().sorted().map(FrameKind::valueOfPrimitive).collect(Collectors.toList()); + } + + public List getBoxingKinds() { + ArrayList result = new ArrayList<>(); + result.add(FrameKind.OBJECT); + result.addAll(getPrimitiveBoxingKinds()); + + return result; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 2633ab9bb87e..0048fc28532b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -65,7 +65,6 @@ public class SingleOperationData extends Template { private final Set throwDeclarations = new HashSet<>(); private final boolean isShortCircuit; private boolean shortCircuitContinueWhen; - private boolean disableBoxingElimination; public enum ParameterKind { STACK_VALUE, @@ -233,12 +232,4 @@ public void setShortCircuitContinueWhen(boolean shortCircuitContinueWhen) { this.shortCircuitContinueWhen = shortCircuitContinueWhen; } - public boolean isDisableBoxingElimination() { - return disableBoxingElimination; - } - - public void setDisableBoxingElimination(boolean disableBoxingElimination) { - this.disableBoxingElimination = disableBoxingElimination; - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 896704132c1e..b8382fce3603 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -73,6 +73,7 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; @@ -165,7 +166,6 @@ protected SingleOperationData parse(Element element, List mirr } data = new SingleOperationData(context, te, null, parentData, name, false); - data.setDisableBoxingElimination((boolean) valDBE.getValue()); } List operationFunctions = new ArrayList<>(); @@ -217,10 +217,20 @@ protected SingleOperationData parse(Element element, List mirr MethodProperties props = processMethod(data, operationFunctions.get(0)); boolean isVariadic = props.isVariadic; + boolean[] canPossiblyReturn = new boolean[FrameKind.values().length]; + canPossiblyReturn[FrameKind.OBJECT.ordinal()] = true; + for (ExecutableElement fun : operationFunctions) { MethodProperties props2 = processMethod(data, fun); props2.checkMatches(data, props); data.getThrowDeclarations().addAll(fun.getThrownTypes()); + if (ElementUtils.isObject(fun.getReturnType())) { + for (int i = 0; i < canPossiblyReturn.length; i++) { + canPossiblyReturn[i] = true; + } + } else { + canPossiblyReturn[FrameKind.valueOfWithBoxing(fun.getReturnType().getKind()).ordinal()] = true; + } } if (isShortCircuit && (props.numStackValues != 1 || props.isVariadic || !props.returnsValue)) { @@ -249,16 +259,24 @@ protected SingleOperationData parse(Element element, List mirr clonedType.setSuperClass(types.Node); } - if (!isVariadic) { - addBoxingEliminationNodeChildAnnotations(data, props, clonedType); - } + addBoxingEliminationNodeChildAnnotations(data, props, clonedType); if (parentData.isGenerateUncached()) { clonedType.getAnnotationMirrors().add(new CodeAnnotationMirror(types.GenerateUncached)); clonedType.add(createExecuteUncachedMethod(props)); } - clonedType.add(createExecuteMethod(props, isVariadic)); + if (isShortCircuit) { + clonedType.add(createExecuteMethod(props, "execute", context.getType(boolean.class), false)); + } else if (!props.returnsValue) { + clonedType.add(createExecuteMethod(props, "execute", context.getType(void.class), false)); + } else { + for (FrameKind kind : parentData.getFrameKinds()) { + if (canPossiblyReturn[kind.ordinal()]) { + clonedType.add(createExecuteMethod(props, kind == FrameKind.OBJECT ? "execute" : "execute" + kind.getFrameName(), kind.getType(), kind != FrameKind.OBJECT)); + } + } + } NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); @@ -288,67 +306,52 @@ protected SingleOperationData parse(Element element, List mirr private void addBoxingEliminationNodeChildAnnotations(SingleOperationData data, MethodProperties props, CodeTypeElement ct) { int i = 0; int localI = 0; - CodeTypeElement childType = createRegularNodeChild(!data.isDisableBoxingElimination()); + CodeTypeElement childType = createRegularNodeChild(); CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); List anns = new ArrayList<>(); for (ParameterKind param : props.parameters) { CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); - if (param == ParameterKind.STACK_VALUE) { - ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); - anns.add(new CodeAnnotationValue(ann)); - i++; - } else if (param == ParameterKind.LOCAL_SETTER) { - ann.setElementValue("value", new CodeAnnotationValue("$localRef" + localI)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterNodeChild()))); - anns.add(new CodeAnnotationValue(ann)); - localI++; - } else if (param == ParameterKind.LOCAL_SETTER_ARRAY) { - ann.setElementValue("value", new CodeAnnotationValue("$localRefArray")); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterArrayNodeChild()))); - anns.add(new CodeAnnotationValue(ann)); + switch (param) { + case STACK_VALUE: + ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); + anns.add(new CodeAnnotationValue(ann)); + i++; + break; + case LOCAL_SETTER: + ann.setElementValue("value", new CodeAnnotationValue("$localRef" + localI)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterNodeChild()))); + anns.add(new CodeAnnotationValue(ann)); + localI++; + break; + case LOCAL_SETTER_ARRAY: + ann.setElementValue("value", new CodeAnnotationValue("$localRefArray")); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterArrayNodeChild()))); + anns.add(new CodeAnnotationValue(ann)); + break; + case VARIADIC: + ann.setElementValue("value", new CodeAnnotationValue("$variadicChild")); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createVariadicNodeChild()))); + anns.add(new CodeAnnotationValue(ann)); + break; + case VIRTUAL_FRAME: + break; + default: + throw new IllegalArgumentException("" + param); } } repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); ct.addAnnotationMirror(repAnnotation); } - private CodeExecutableElement createExecuteMethod(MethodProperties props, boolean isVariadic) { - - Class resType; - if (isShortCircuit) { - resType = boolean.class; - } else if (props.returnsValue) { - resType = Object.class; - } else { - resType = void.class; - } - CodeExecutableElement metExecute = new CodeExecutableElement( - Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), - context.getType(resType), "execute"); - + private CodeExecutableElement createExecuteMethod(MethodProperties props, String name, TypeMirror resType, boolean hasUre) { + CodeExecutableElement metExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), resType, name); metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - if (isVariadic) { - int i = 0; - for (ParameterKind param : props.parameters) { - switch (param) { - case STACK_VALUE: - metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); - break; - case VARIADIC: - metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); - break; - case LOCAL_SETTER: - case LOCAL_SETTER_ARRAY: - case VIRTUAL_FRAME: - break; - default: - throw new UnsupportedOperationException("" + param); - } - i++; - } + if (hasUre) { + metExecute.addThrownType(types.UnexpectedResultException); } + return metExecute; } @@ -460,22 +463,30 @@ private boolean isIgnoredParameter(VariableElement param) { private static final String GENERIC_EXECUTE_NAME = "Generic"; - private CodeTypeElement createRegularNodeChild(boolean withBoxingElimination) { + private CodeTypeElement createRegularNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); - if (withBoxingElimination) { - for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { - result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); - } + for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { + result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); } return result; } + private CodeTypeElement createVariadicNodeChild() { + + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + result.setSuperClass(types.Node); + + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object[].class))); + + return result; + } + private CodeTypeElement createLocalSetterNodeChild() { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 018a1c223a33..352269e7bcba 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -47,6 +47,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; @SuppressWarnings("unused") public class BranchInstruction extends Instruction { @@ -62,8 +63,8 @@ public class BranchInstruction extends Instruction { private static final int REPORT_LOOP_STRIDE = 1 << 8; - public BranchInstruction(int id) { - super("branch", id, 0); + public BranchInstruction(OperationsContext ctx, int id) { + super(ctx, "branch", id, 0); addBranchTarget("target"); } @@ -172,11 +173,6 @@ public boolean isBranchInstruction() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index c35cbec3c238..c60065d0197e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -51,11 +51,9 @@ public class ConditionalBranchInstruction extends Instruction { private final ProcessorContext context = ProcessorContext.getInstance(); private final DeclaredType typeConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); - private OperationsContext ctx; public ConditionalBranchInstruction(OperationsContext ctx, int id) { - super("branch.false", id, 0); - this.ctx = ctx; + super(ctx, "branch.false", id, 0); addPopSimple("condition"); addBranchTarget("target"); addBranchProfile("profile"); @@ -94,11 +92,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index c9c57e744595..7bdc8798bd5c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -42,15 +42,21 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.VariableElement; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -59,16 +65,13 @@ public class CustomInstruction extends Instruction { - protected final OperationsContext ctx; private final SingleOperationData data; - protected ExecutableElement executeMethod; + protected ExecutableElement[] executeMethods; protected ExecutableElement uncachedExecuteMethod; private OperationsBytecodeNodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; private CodeExecutableElement getSpecializationBits; private final List quickenedVariants = new ArrayList<>(); - private CodeTree boxingEliminationBitOffset; - private int boxingEliminationBitMask; public SingleOperationData getData() { return data; @@ -86,13 +89,12 @@ public List getSpecializationNames() { return result; } - public void setExecuteMethod(ExecutableElement executeMethod) { - this.executeMethod = executeMethod; + public void setExecuteMethod(ExecutableElement[] executeMethods) { + this.executeMethods = executeMethods; } public CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { - super(name, id, data.getMainProperties().returnsValue ? 1 : 0); - this.ctx = ctx; + super(ctx, name, id, data.getMainProperties().returnsValue ? 1 : 0); this.data = data; initializePops(); } @@ -108,7 +110,7 @@ protected void initializePops() { if (props.isVariadic) { setVariadic(); for (int i = 0; i < props.numStackValues - 1; i++) { - addPopSimple("arg" + i); + addPopIndexed("arg" + i); } } else { for (int i = 0; i < props.numStackValues; i++) { @@ -128,8 +130,7 @@ protected void initializePops() { } protected CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data, int pushCount) { - super(name, id, pushCount); - this.ctx = ctx; + super(ctx, name, id, pushCount); this.data = data; } @@ -154,105 +155,169 @@ private void addLocalRefs(CodeTreeBuilder b, ExecutionVariables vars) { } private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - createTracerCode(vars, b); + String exName = getUniqueName() + "_entryPoint" + (uncached ? "_uncached" : ""); + OperationGeneratorUtils.createHelperMethod(ctx.outerType, exName, () -> { + CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), exName); + el.getParameters().addAll(executeMethods[0].getParameters()); + + if (!uncached && ctx.hasBoxingElimination()) { + el.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + } + + CodeTreeBuilder b = el.createBuilder(); + + if (numPushedValues > 0) { + + if (isVariadic()) { + b.declaration("int", "destSlot", "$sp - " + (data.getMainProperties().numStackValues - 1) + " - $numVariadics"); + } else { + b.declaration("int", "destSlot", "$sp - " + data.getMainProperties().numStackValues); + } + + if (!uncached && ctx.hasBoxingElimination()) { + boolean needsUnexpectedResult = false; + for (ExecutableElement exm : executeMethods) { + if (exm != null && exm.getThrownTypes().size() > 0) { + needsUnexpectedResult = true; + break; + } + } + + if (needsUnexpectedResult) { + b.startTryBlock(); + } + + b.startSwitch().string("primitiveTag").end().startBlock(); + + int i = 0; + for (FrameKind kind : ctx.getBoxingKinds()) { + if (executeMethods[i] != null) { + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + + b.variable(vars.stackFrame); + b.string("destSlot"); + + b.startStaticCall(executeMethods[i]); + b.variables(executeMethods[i].getParameters()); + b.end(); + + b.end(2); - ExecutableElement method = uncached ? uncachedExecuteMethod : executeMethod; + b.returnStatement(); + b.end(); + } - if (data.getMainProperties().isVariadic) { + i++; + } - b.declaration("int", "numVariadics", createVariadicIndex(vars, false)); + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); - int additionalInputs = data.getMainProperties().numStackValues - 1; + b.end(); - int inputIndex = 0; - CodeTree[] inputTrees = new CodeTree[data.getMainProperties().parameters.size()]; - for (ParameterKind kind : data.getMainProperties().parameters) { - String inputName = "input_" + inputIndex; - switch (kind) { - case STACK_VALUE: - // safety: use unchecked since we never BE variadic functions - b.declaration("Object", inputName, "UFA.unsafeUncheckedGetObject(" + vars.stackFrame.getName() + ", $sp - numVariadics - " + (additionalInputs + inputIndex) + ")"); - inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); - break; - case VARIADIC: - b.startAssign("Object[] " + inputName).startCall("do_loadVariadicArguments"); + if (needsUnexpectedResult) { + b.end().startCatchBlock(types.UnexpectedResultException, "ex"); + + b.startStatement().startCall("UFA", "unsafeSetObject"); b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("numVariadics"); + b.string("destSlot"); + b.string("ex.getResult()"); + b.end(2); - inputTrees[inputIndex++] = CodeTreeBuilder.singleString(inputName); - break; - case VIRTUAL_FRAME: - break; - default: - throw new IllegalArgumentException("Unexpected value: " + kind); - } - } - if (numPushedValues > 0) { - b.startAssign("Object result"); - } else { - b.startStatement(); - } + b.end(); + } - b.startStaticCall(method); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.string("$this"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); - b.trees(inputTrees); + } else { + ExecutableElement target = uncached ? uncachedExecuteMethod : executeMethods[0]; - if (uncached) { - addLocalRefs(b, vars); - } + b.startStatement().startCall("UFA", "unsafeSetObject"); - b.end(2); + b.variable(vars.stackFrame); + b.string("destSlot"); - b.startAssign(vars.sp).variable(vars.sp).string(" - " + additionalInputs + " - numVariadics + " + numPushedValues).end(); + b.startStaticCall(target); + b.variables(el.getParameters()); - if (numPushedValues > 0) { - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.string("result"); - b.end(2); - } + if (uncached) { + for (int i = 0; i < numPopStatic(); i++) { + int offset = numPopStatic() - i; + b.startCall("UFA", "unsafeUncheckedGetObject"); + b.variable(vars.stackFrame); + if (isVariadic()) { + b.string("$sp - " + offset + " - $numVariadics"); + } else { + b.string("$sp - " + offset); + } + b.end(); + } - } else { - b.startStatement(); - b.startStaticCall(method); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.string("$this"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); + if (isVariadic()) { + b.startCall("do_loadVariadicArguments"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("$numVariadics"); + b.end(); + } + + addLocalRefs(b, vars); + } + + b.end(); - if (uncached) { - for (int i = numPopStatic(); i > 0; i--) { - b.string("UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - " + i + ")"); + b.end(2); } + } else { - addLocalRefs(b, vars); + b.startStatement().startStaticCall(executeMethods[0]); + b.variables(executeMethods[0].getParameters()); + b.end(2); } - b.end(2); + return el; + }); + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + createTracerCode(vars, b); - b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues).end(); + if (isVariadic()) { + b.startAssign("int numVariadics").tree(createVariadicIndex(vars, false)).end(); } + b.startStatement(); + b.startCall(exName); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } + b.string("$this"); + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); + + if (isVariadic()) { + b.string("numVariadics"); + } + + if (!uncached && ctx.hasBoxingElimination()) { + b.string("primitiveTag"); + } + + b.end(2); + + b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues); + if (isVariadic()) { + b.string(" - numVariadics + 1"); + } + b.end(); + return b.build(); } @@ -292,26 +357,6 @@ public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits this.getSpecializationBits = getSpecializationBits; } - public void setBoxingEliminationData(CodeTree boxingEliminationBitOffset, int boxingEliminationBitMask) { - this.boxingEliminationBitOffset = boxingEliminationBitOffset; - this.boxingEliminationBitMask = boxingEliminationBitMask; - } - - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return numPushedValues > 0 ? BoxingEliminationBehaviour.SET_BIT : BoxingEliminationBehaviour.DO_NOTHING; - } - - @Override - public CodeTree boxingEliminationBitOffset() { - return boxingEliminationBitOffset == null ? CodeTreeBuilder.singleString("0") : boxingEliminationBitOffset; - } - - @Override - public int boxingEliminationBitMask() { - return boxingEliminationBitMask; - } - public OperationsBytecodeNodeGeneratorPlugs getPlugs() { return plugs; } @@ -338,6 +383,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod b.string("-1"); b.string("$consts"); b.string("$children"); + if (isVariadic()) { + b.tree(createVariadicIndex(vars, false)); + } b.tree(language); b.tree(root); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java index 7a673339dc80..c282b5c583fa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java @@ -42,10 +42,11 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class DiscardInstruction extends Instruction { - public DiscardInstruction(String name, int id) { - super(name, id, 0); + public DiscardInstruction(OperationsContext ctx, String name, int id) { + super(ctx, name, id, 0); addPopSimple("value"); } @@ -62,11 +63,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java index 3e5d19640e78..b8f4c9ec3588 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java @@ -112,6 +112,10 @@ public TypeMirror getType() { } } + public String toOrdinal() { + return "" + this.ordinal() + " /* " + this + " */"; + } + public static FrameKind valueOfPrimitive(TypeKind typeKind) { switch (typeKind) { case BOOLEAN: @@ -130,4 +134,23 @@ public static FrameKind valueOfPrimitive(TypeKind typeKind) { throw new UnsupportedOperationException(); } } + + public static FrameKind valueOfWithBoxing(TypeKind typeKind) { + switch (typeKind) { + case BOOLEAN: + return BOOLEAN; + case BYTE: + return BYTE; + case DOUBLE: + return DOUBLE; + case FLOAT: + return FLOAT; + case INT: + return INT; + case LONG: + return LONG; + default: + return OBJECT; + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 1a453e787d79..50a67c55a573 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -43,8 +43,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.lang.model.element.Modifier; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -55,6 +57,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public abstract class Instruction { @@ -83,15 +86,10 @@ public static class EmitArguments { public CodeTree[] arguments; } - public enum BoxingEliminationBehaviour { - DO_NOTHING, - SET_BIT, - REPLACE - } - protected final ProcessorContext context = ProcessorContext.getInstance(); protected final TruffleTypes types = context.getTypes(); + protected final OperationsContext ctx; public final String name; public final int id; public final int numPushedValues; @@ -166,8 +164,8 @@ public int addArgument(Object marker) { } public int addPopIndexed(Object marker) { - if (isVariadic) { - throw new AssertionError("variadic cannot have indexed pops in variadic"); + if (!ctx.hasBoxingElimination()) { + return addPopSimple(marker); } if (!popSimple.isEmpty()) { throw new AssertionError("cannot mix simple and indexed pops"); @@ -183,10 +181,6 @@ public int addPopSimple(Object marker) { } public void setVariadic() { - if (!popIndexed.isEmpty()) { - throw new AssertionError("variadic cannot have indexed pops in variadic"); - } - isVariadic = true; } @@ -231,15 +225,11 @@ private int getPopIndexedOffset() { } private int getVariadicOffset() { - return getPopIndexedOffset(); // they are always same since we can never have both + return getPopIndexedOffset() + (popIndexed.size() + 1) / 2; } private int getBranchTargetsOffset() { - if (isVariadic) { - return getVariadicOffset() + 1; - } else { - return getPopIndexedOffset() + ((popIndexed.size() + 1) / 2); - } + return getVariadicOffset() + (isVariadic ? 1 : 0); } private int getBranchProfileOffset() { @@ -313,6 +303,10 @@ public CodeTree createArgumentIndex(ExecutionVariables vars, int index, boolean } public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index, boolean write) { + if (!ctx.hasBoxingElimination()) { + throw new AssertionError("there is no boxing elimination"); + // return CodeTreeBuilder.singleString("0 /* XXXXXXXXXXX */"); + } CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startParantheses(); @@ -386,7 +380,8 @@ public void setOpcodeIdField(CodeVariableElement opcodeIdField) { this.opcodeIdField = opcodeIdField; } - Instruction(String name, int id, int numPushedValues) { + Instruction(OperationsContext ctx, String name, int id, int numPushedValues) { + this.ctx = ctx; this.name = name; this.id = id; this.internalName = OperationGeneratorUtils.toScreamCase(name); @@ -583,44 +578,12 @@ public String dumpInfo() { printList(sb, branchProfiles, "Branch Profiles"); printList(sb, stateBits, "State Bitsets"); - sb.append(" Boxing Elimination: "); - switch (boxingEliminationBehaviour()) { - case DO_NOTHING: - sb.append("Do Nothing\n"); - break; - case REPLACE: - sb.append("Replace\n"); - for (FrameKind kind : FrameKind.values()) { - try { - String el = boxingEliminationReplacement(kind).getName(); - sb.append(" ").append(kind).append(" -> ").append(el).append("\n"); - } catch (Exception ex) { - } - } - break; - case SET_BIT: - sb.append("Bit Mask\n"); - break; - default: - throw new AssertionError(); - } - return sb.toString(); } - public abstract BoxingEliminationBehaviour boxingEliminationBehaviour(); - @SuppressWarnings("unused") public CodeVariableElement boxingEliminationReplacement(FrameKind kind) { - throw new AssertionError(); - } - - public CodeTree boxingEliminationBitOffset() { - throw new AssertionError(); - } - - public int boxingEliminationBitMask() { - throw new AssertionError(); + return null; } public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index ee098f14c062..25d653628393 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -42,11 +42,12 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class InstrumentationEnterInstruction extends Instruction { - public InstrumentationEnterInstruction(int id) { - super("instrument.enter", id, 0); + public InstrumentationEnterInstruction(OperationsContext ctx, int id) { + super(ctx, "instrument.enter", id, 0); addInstrument("instrument"); } @@ -77,11 +78,6 @@ public boolean isInstrumentationOnly() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 53e2af37be7a..00e94713822f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -43,18 +43,19 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class InstrumentationExitInstruction extends Instruction { private final boolean returnsValue; - public InstrumentationExitInstruction(int id) { - super("instrument.exit.void", id, 0); + public InstrumentationExitInstruction(OperationsContext ctx, int id) { + super(ctx, "instrument.exit.void", id, 0); this.returnsValue = false; addInstrument("instrument"); } - public InstrumentationExitInstruction(int id, boolean returnsValue) { - super("instrument.exit", id, 0); + public InstrumentationExitInstruction(OperationsContext ctx, int id, boolean returnsValue) { + super(ctx, "instrument.exit", id, 0); assert returnsValue; this.returnsValue = true; addInstrument("instrument"); @@ -94,11 +95,6 @@ public boolean isInstrumentationOnly() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index a13d07f30f1e..de03408a5d5f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -42,10 +42,11 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class InstrumentationLeaveInstruction extends Instruction { - public InstrumentationLeaveInstruction(int id) { - super("instrument.leave", id, 0); + public InstrumentationLeaveInstruction(OperationsContext ctx, int id) { + super(ctx, "instrument.leave", id, 0); addInstrument("instrument"); addBranchTarget("startBranch"); addBranchTarget("endBranch"); @@ -101,11 +102,6 @@ public boolean isInstrumentationOnly() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index c5d02c2ecbf8..889c668845b8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -43,18 +43,12 @@ import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadArgumentInstruction extends Instruction { - private FrameKind kind; - private OperationsContext ctx; - - public LoadArgumentInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.argument." + kind.getTypeName().toLowerCase(), id, 1); - this.ctx = ctx; - this.kind = kind; + public LoadArgumentInstruction(OperationsContext ctx, int id) { + super(ctx, "load.argument", id, 1); addArgument("argument"); } @@ -75,30 +69,46 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("Object", "value", createGetValue(vars)); - if (kind == FrameKind.OBJECT) { - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.localFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); + if (ctx.hasBoxingElimination()) { + b.startSwitch().string("primitiveTag").end().startBlock(); + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + if (kind == FrameKind.OBJECT) { + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); + } else { + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + // { + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("(", kind.getTypeName(), ") value"); + b.end(2); + // } + b.end().startElseBlock(); + // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); + // } + b.end(); + } + b.statement("break"); + b.end(); + } + b.end(); } else { - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - // { - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.localFrame); - b.variable(vars.sp); - b.string("(", kind.getTypeName(), ") value"); - b.end(2); - // } - b.end().startElseBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall(vars.localFrame, "setObject"); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); b.variable(vars.sp); b.string("value"); b.end(2); - // } - b.end(); } b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); @@ -106,31 +116,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.REPLACE; - } - - @Override - public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { - if (kind == FrameKind.OBJECT) { - return ctx.loadArgumentInstructions[targetKind.ordinal()].opcodeIdField; - } else { - if (targetKind == FrameKind.OBJECT) { - return ctx.loadArgumentInstructions[targetKind.ordinal()].opcodeIdField; - } else { - return opcodeIdField; - } - } - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public boolean neverInUncached() { - return kind != FrameKind.OBJECT; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 7160f6494a81..cb05d1b66ae4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -45,6 +45,7 @@ import javax.lang.model.element.Modifier; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -53,20 +54,16 @@ import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadConstantInstruction extends Instruction { - private final FrameKind kind; - private final OperationsContext ctx; - public LoadConstantInstruction(OperationsContext ctx, int id, FrameKind kind) { - super("load.constant." + kind.toString().toLowerCase(), id, 1); - this.ctx = ctx; - this.kind = kind; + public LoadConstantInstruction(OperationsContext ctx, int id) { + super(ctx, "load.constant", id, 1); addConstant("constant", ProcessorContext.getInstance().getType(Object.class)); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - if (!ctx.outerType.getEnclosedElements().stream().anyMatch(x -> x.getSimpleName().toString().equals("do_loadConstantObject"))) { + OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_loadConstantObject", () -> { CodeExecutableElement metImpl = new CodeExecutableElement( EnumSet.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), @@ -77,17 +74,43 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { metImpl.addParameter(vars.bci); metImpl.addParameter(vars.sp); metImpl.addParameter(vars.consts); + if (ctx.hasBoxingElimination()) { + metImpl.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + } CodeTreeBuilder b = metImpl.getBuilder(); - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetArgument(vars)); - b.end(2); + if (ctx.hasBoxingElimination()) { + b.startSwitch().string("primitiveTag").end().startBlock(); - ctx.outerType.add(metImpl); - } + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.tree(createGetArgument(vars, kind)); + b.end(2); + + b.statement("break"); + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); + + b.end(); + } else { + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.tree(createGetArgument(vars, FrameKind.OBJECT)); + b.end(2); + } + + return metImpl; + }); CodeTreeBuilder bOuter = CodeTreeBuilder.createBuilder(); bOuter.startStatement().startCall("do_loadConstantObject"); @@ -96,6 +119,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { bOuter.variable(vars.bci); bOuter.variable(vars.sp); bOuter.variable(vars.consts); + if (ctx.hasBoxingElimination()) { + bOuter.string("primitiveTag"); + } bOuter.end(2); bOuter.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); @@ -104,7 +130,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } - private CodeTree createGetArgument(ExecutionVariables vars) { + private CodeTree createGetArgument(ExecutionVariables vars, FrameKind kind) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (kind != FrameKind.OBJECT) { @@ -114,38 +140,12 @@ private CodeTree createGetArgument(ExecutionVariables vars) { b.variable(vars.consts); b.tree(createConstantIndex(vars, 0)); b.end(); - return b.build(); - } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - - @Override - public CodeVariableElement boxingEliminationReplacement(FrameKind targetKind) { - if (kind == FrameKind.OBJECT) { - return ctx.loadConstantInstructions[targetKind.ordinal()].opcodeIdField; - } else { - if (targetKind == FrameKind.OBJECT) { - return ctx.loadConstantInstructions[targetKind.ordinal()].opcodeIdField; - } else { - return opcodeIdField; - } - } + return b.build(); } @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - if (kind == FrameKind.OBJECT) { - return null; - } - - return OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadConstantInstructions[FrameKind.OBJECT.ordinal()].opcodeIdField); - } - - @Override - public boolean neverInUncached() { - return kind != FrameKind.OBJECT; + return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 496e6252f42e..782445e92d35 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -40,58 +40,162 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.Set; + +import javax.lang.model.element.Modifier; + +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadLocalInstruction extends Instruction { - private final OperationsContext ctx; - public LoadLocalInstruction(OperationsContext ctx, int id) { - super("load.local", id, 1); - this.ctx = ctx; + super(ctx, "load.local", id, 1); addLocal("local"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_loadLocal", () -> { + CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), "do_loadLocal"); + + res.addParameter(vars.stackFrame); + if (ctx.getData().enableYield) { + res.addParameter(vars.localFrame); + } + res.addParameter(vars.bc); + res.addParameter(vars.bci); + res.addParameter(vars.sp); + if (ctx.hasBoxingElimination()) { + res.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + } + res.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); + + CodeTreeBuilder b = res.createBuilder(); + + if (ctx.hasBoxingElimination()) { + b.startSwitch().string("primitiveTag").end().startBlock(); + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + + if (kind == FrameKind.OBJECT) { + b.statement("Object value"); + // this switch should be made to fold + b.startSwitch().startCall("UFA", "unsafeGetTag").variable(vars.localFrame).string("localIdx").end(2).startBlock(); + for (FrameKind localKind : ctx.getBoxingKinds()) { + b.startCase().string(localKind.toOrdinal()).end().startCaseBlock(); + + b.startAssign("value").startCall("UFA", "unsafeUncheckedGet" + localKind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.end(2); + + b.statement("break"); + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); + + b.end(); // switch + + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); + + b.returnStatement(); + } else { + b.startTryBlock(); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.end(); + b.end(2); + + b.returnStatement(); + + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + b.end(); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.statement("break"); + } + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); + + b.end(); + + b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); + + b.startStatement().startCall(vars.localFrame, "getFrameDescriptor().setSlotKind"); + b.string("localIdx"); + b.string("primitiveTag == 7 ? FrameSlotKind.Object : FrameSlotKind.fromTag((byte) primitiveTag)"); + b.end(2); + + b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.localFrame).string("localIdx").string("result").end(2); + b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.stackFrame).variable(vars.sp).string("result").end(2); + + } else { + if (ctx.getData().enableYield) { + b.startStatement().startCall("UFA", "unsafeCopyTo"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("1"); + b.end(2); + } else { + b.startStatement().startCall("UFA", "unsafeCopy"); + b.variable(vars.stackFrame); + b.string("localIdx"); + b.variable(vars.sp); + b.end(2); + } + } + + return res; + }); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("int localIdx"); b.tree(createLocalIndex(vars, 0, false)); b.end(); - createCopyObject(vars, b); + b.startStatement().startCall("do_loadLocal"); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + if (ctx.hasBoxingElimination()) { + b.string("primitiveTag"); + } + b.string("localIdx"); + b.end(2); b.startStatement().variable(vars.sp).string("++").end(); return b.build(); - - } - - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - - private static final boolean USE_SPEC_FRAME_COPY = true; - - private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement(); - if (ctx.getData().enableYield) { - b.startCall(vars.localFrame, "copyTo"); - b.string("localIdx"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("1"); - } else { - b.startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); - b.variable(vars.stackFrame); - b.string("localIdx"); - b.variable(vars.sp); - } - b.end(2); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java index f212a481b7fa..13b8650dfb93 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java @@ -2,11 +2,12 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadNonlocalInstruction extends Instruction { - public LoadNonlocalInstruction(int id) { - super("load.nonlocal", id, 1); + public LoadNonlocalInstruction(OperationsContext ctx, int id) { + super(ctx, "load.nonlocal", id, 1); addPopSimple("frame"); addArgument("index"); } @@ -33,11 +34,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java index 36c55743ce9c..660347977760 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java @@ -133,21 +133,6 @@ public QuickenedInstruction(OperationsContext ctx, CustomInstruction orig, int i orig.addQuickenedVariant(this); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.SET_BIT; - } - - @Override - public CodeTree boxingEliminationBitOffset() { - return orig.boxingEliminationBitOffset(); - } - - @Override - public int boxingEliminationBitMask() { - return orig.boxingEliminationBitMask(); - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return orig.createPrepareAOT(vars, language, root); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index f2dde70c90b6..3fb354922a48 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -47,11 +47,8 @@ public class ReturnInstruction extends Instruction { - private final OperationsContext ctx; - public ReturnInstruction(OperationsContext ctx, int id) { - super("return", id, 0); - this.ctx = ctx; + super(ctx, "return", id, 0); addPopSimple("value"); } @@ -104,11 +101,6 @@ public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments argume return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 4b43eaf9d3bd..308a5cc89c65 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -53,11 +53,6 @@ public ShortCircuitInstruction(OperationsContext ctx, String name, int id, Singl addBranchTarget("end"); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -69,7 +64,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("!"); } - b.startStaticCall(executeMethod); + b.startStaticCall(executeMethods[0]); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 0055a4e857d3..639c86390d99 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -40,32 +40,219 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.Set; + +import javax.lang.model.element.Modifier; + +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class StoreLocalInstruction extends Instruction { - private final OperationsContext context; - public StoreLocalInstruction(OperationsContext context, int id) { - super("store.local", id, 0); - this.context = context; + public StoreLocalInstruction(OperationsContext ctx, int id) { + super(ctx, "store.local", id, 0); - addPopSimple("value"); + addPopIndexed("value"); addLocal("target"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (ctx.hasBoxingElimination()) { + OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_storeLocalSpecialize", () -> { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), "do_storeLocalSpecialize"); + + ex.addParameter(vars.stackFrame); + if (ctx.getData().enableYield) { + ex.addParameter(vars.localFrame); + } + ex.addParameter(vars.bc); + ex.addParameter(vars.bci); + ex.addParameter(vars.sp); + ex.addParameter(new CodeVariableElement(types.FrameDescriptor, "fd")); + if (ctx.hasBoxingElimination()) { + ex.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + } + ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "sourceSlot")); + + CodeTreeBuilder b = ex.getBuilder(); + + b.tree(GeneratorUtils.createNeverPartOfCompilation()); + + b.startAssign("Object value").startCall(vars.stackFrame, "getValue"); + b.string("sourceSlot"); + b.end(2); + + b.declaration(types.FrameSlotKind, "curKind", "fd.getSlotKind(localIdx)"); + + b.statement("// System.err.printf(\"primitiveTag=%d value=%s %s curKind=%s tag=%s%n\", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot))"); + + for (FrameKind primKind : ctx.getPrimitiveBoxingKinds()) { + // todo: use implicit conversions here + + b.startIf(); + b.string("(primitiveTag == 0 || primitiveTag == " + primKind.toOrdinal() + ")"); + b.string(" && (curKind == FrameSlotKind.Illegal || curKind == FrameSlotKind." + primKind.getFrameName() + ")"); + b.end().startBlock(); + + b.startIf().string("value instanceof ", primKind.getTypeNameBoxed()).end().startBlock(); + + createSetFrameDescriptorKind(vars, b, primKind.getFrameName()); + createSetPrimitiveTag(vars, b, primKind.toOrdinal()); + createBoxingEliminateChild(vars, b, primKind.toOrdinal()); + + b.startStatement().startCall("UFA", "unsafeSet" + primKind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startGroup().cast(primKind.getType()).string("value").end(); + b.end(2); + + b.returnStatement(); + + b.end(); + + b.end(); + } + + createSetFrameDescriptorKind(vars, b, "Object"); + createSetPrimitiveTag(vars, b, "7 /* generic */"); + createBoxingEliminateChild(vars, b, "0 /* OBJECT */"); + + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.string("value"); + b.end(2); + + return ex; + }); + } + + OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_storeLocal", () -> { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), "do_storeLocal"); + + ex.addParameter(vars.stackFrame); + if (ctx.getData().enableYield) { + ex.addParameter(vars.localFrame); + } + ex.addParameter(vars.bc); + ex.addParameter(vars.bci); + ex.addParameter(vars.sp); + if (ctx.hasBoxingElimination()) { + ex.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + } + ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); + + CodeTreeBuilder b = ex.getBuilder(); + + b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); + + if (!ctx.hasBoxingElimination()) { + createCopyObject(vars, b); + } else { + // if Frame ever supports an 8th primitive type, we will need more bits here + b.declaration(types.FrameDescriptor, "fd", vars.localFrame.getName() + ".getFrameDescriptor()"); + b.declaration(types.FrameSlotKind, "curKind", "fd.getSlotKind(localIdx)"); + b.startSwitch().string("primitiveTag").end().startBlock(); + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + + if (kind == FrameKind.OBJECT) { + // this is the uninitialized case + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + createCallSpecialize(vars, b); + } else { + // primitive case + + b.startIf().string("curKind == FrameSlotKind." + kind.getFrameName()).end().startBlock(); + + b.startTryBlock(); + + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.string("sourceSlot"); + b.end(); + b.end(2); + + b.returnStatement(); - b.startAssign("int localIdx"); - b.tree(createLocalIndex(vars, 0, false)); - b.end(); + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + b.end(); // try catch - b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); + b.end(); // if - createCopyObject(vars, b); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + createCallSpecialize(vars, b); + } + + b.statement("break"); + b.end(); + } + + b.startCase().string("7 /* generic */").end().startCaseBlock(); + + b.startTryBlock(); + + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall("UFA", "unsafeGetObject"); + b.variable(vars.stackFrame); + b.string("sourceSlot"); + b.end(); + b.end(2); + + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall(vars.stackFrame, "getValue"); + b.string("sourceSlot"); + b.end(); + b.end(2); + + b.end(); + b.statement("break"); + b.end(); + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); + + b.end(); + } + + return ex; + }); + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); + + b.startStatement().startCall("do_storeLocal"); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + if (ctx.hasBoxingElimination()) { + b.string("primitiveTag"); + } + b.string("localIdx"); + b.end(2); b.startStatement().variable(vars.sp).string("--").end(); @@ -76,8 +263,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { b.startStatement(); - - if (context.getData().enableYield) { + if (ctx.getData().enableYield) { b.startCall(vars.stackFrame, "copyTo"); b.string("sourceSlot"); b.variable(vars.localFrame); @@ -92,9 +278,38 @@ private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { b.end(2); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; + private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b) { + b.startStatement().startCall("do_storeLocalSpecialize"); + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + b.string("fd"); + if (ctx.hasBoxingElimination()) { + b.string("primitiveTag"); + } + b.string("localIdx"); + b.string("sourceSlot"); + b.end(2); + } + + @SuppressWarnings("unused") + private void createSetFrameDescriptorKind(ExecutionVariables vars, CodeTreeBuilder b, String kind) { + b.startStatement().startCall("fd", "setSlotKind"); + b.string("localIdx"); + b.staticReference(types.FrameSlotKind, kind); + b.end(2); + } + + private void createSetPrimitiveTag(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, "(short) ((" + tag + " << 13) | " + opcodeIdField.getName() + ")")); + } + + private void createBoxingEliminateChild(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.tree(OperationGeneratorUtils.callSetResultBoxed(createPopIndexedIndex(vars, 0, false), CodeTreeBuilder.singleString(tag))); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java index cb74954582a6..742f43cd4b18 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java @@ -2,11 +2,12 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class StoreNonlocalInstruction extends Instruction { - public StoreNonlocalInstruction(int id) { - super("store.nonlocal", id, 0); + public StoreNonlocalInstruction(OperationsContext ctx, int id) { + super(ctx, "store.nonlocal", id, 0); addPopSimple("frame"); addPopSimple("value"); addArgument("index"); @@ -33,11 +34,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { return b.build(); } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index 681af0b4e01a..de4a8f5f598f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -43,10 +43,11 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ThrowInstruction extends Instruction { - public ThrowInstruction(int id) { - super("throw", id, 0); + public ThrowInstruction(OperationsContext ctx, int id) { + super(ctx, "throw", id, 0); addLocal("exception"); } @@ -73,11 +74,6 @@ public boolean isBranchInstruction() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index 26c640df7140..832af9747f28 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -2,14 +2,15 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; public class YieldInstruction extends Instruction { private static final String CONTINUATION_POINT = "continuation-point"; - public YieldInstruction(int id) { - super("yield", id, 1); + public YieldInstruction(OperationsContext ctx, int id) { + super(ctx, "yield", id, 1); addPopSimple("value"); addConstant(CONTINUATION_POINT, null); } @@ -62,11 +63,6 @@ public boolean isBranchInstruction() { return true; } - @Override - public BoxingEliminationBehaviour boxingEliminationBehaviour() { - return BoxingEliminationBehaviour.DO_NOTHING; - } - @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index db897e391bf4..6de963709761 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -110,6 +110,8 @@ @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) public abstract class SLOperationRootNode extends SLRootNode implements OperationRootNode { + static final boolean __magic_LogInvalidations = true; + protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { super((SLLanguage) language, frameDescriptor.build()); } From d4964f7ffbbc3a63866f221981940bcfb7c5771e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 5 Oct 2022 12:04:29 +0200 Subject: [PATCH 144/312] [wip] boxing elimination again --- .../api/operation/test/bml/BenmarkSimple.java | 12 +- .../test/example/TestOperations.java | 1 - .../truffle/api/impl/UnsafeFrameAccess.java | 205 +++++++++++++++++- .../operations/OperationGeneratorFlags.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 82 +++++-- .../OperationsBytecodeNodeGeneratorPlugs.java | 5 + .../operations/OperationsCodeGenerator.java | 18 ++ .../operations/SingleOperationData.java | 38 ++-- .../operations/SingleOperationParser.java | 27 ++- .../instructions/BranchInstruction.java | 42 ++-- .../instructions/CustomInstruction.java | 70 +++--- .../operations/instructions/Instruction.java | 11 +- .../instructions/LoadArgumentInstruction.java | 61 +++--- .../instructions/LoadConstantInstruction.java | 43 ++-- .../instructions/LoadLocalInstruction.java | 144 +++++++----- .../instructions/StoreLocalInstruction.java | 173 ++++++++------- 16 files changed, 610 insertions(+), 324 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index e4e515423100..a0dda8b45296 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -71,6 +71,8 @@ @State(Scope.Benchmark) public class BenmarkSimple extends BaseBenchmark { + private static final int TOTAL_ITERATIONS = 5000; + private static final String NAME_TEST_LOOP = "simple:test-loop"; private static final String NAME_TEST_LOOP_NO_BE = "simple:test-loop-no-be"; private static final String NAME_TEST_LOOP_QUICKEN = "simple:test-loop-quicken"; @@ -104,7 +106,7 @@ public class BenmarkSimple extends BaseBenchmark { // while (i < 5000) { /* while_0_start: */ /* 10 */ OP_LD_LOC, LOC_I, - /* 12 */ OP_CONST, 0, 5000, + /* 12 */ OP_CONST, 0, TOTAL_ITERATIONS, /* 15 */ OP_LESS, /* 16 */ OP_JUMP_FALSE, 83, // while_0_end @@ -247,7 +249,7 @@ public class BenmarkSimple extends BaseBenchmark { // sum = 0 StoreLocalNodeGen.create(sumLoc, ConstNodeGen.create(0)), // while (i < 5000) { - WhileNode.create(LessNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(5000)), BlockNode.create( + WhileNode.create(LessNodeGen.create(LoadLocalNodeGen.create(iLoc), ConstNodeGen.create(TOTAL_ITERATIONS)), BlockNode.create( // j = 0 StoreLocalNodeGen.create(jLoc, ConstNodeGen.create(0)), // while (j < i) { @@ -354,11 +356,11 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode b.emitConstObject(0); b.endStoreLocal(); - // while (i < 5000) { + // while (i < TOTAL_ITERATIONS) { b.beginWhile(); b.beginLess(); b.emitLoadLocal(iLoc); - b.emitConstObject(5000); + b.emitConstObject(TOTAL_ITERATIONS); b.endLess(); b.beginBlock(); @@ -509,7 +511,7 @@ public void ast() { @Fork(BaseBenchmark.FORKS) class BaseBenchmark { public static final int MEASUREMENT_ITERATIONS = 10; - public static final int WARMUP_ITERATIONS = 20; + public static final int WARMUP_ITERATIONS = 10; public static final int ITERATION_TIME = 1; public static final int FORKS = 1; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index f22fdd563283..5074e83219e5 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -49,7 +49,6 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.MaterializedFrame; diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 523c1a68a748..ef4160de22e6 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -57,6 +57,10 @@ public static UnsafeFrameAccess lookup() { public abstract void unsafeShortArrayWrite(short[] arr, int index, short value); + public abstract byte unsafeByteArrayRead(byte[] arr, int index); + + public abstract void unsafeByteArrayWrite(byte[] arr, int index, byte value); + public abstract int unsafeIntArrayRead(int[] arr, int index); public abstract void unsafeIntArrayWrite(int[] arr, int index, int value); @@ -116,6 +120,196 @@ public static UnsafeFrameAccess lookup() { UnsafeFrameAccess() { } + private static final class ImplSafe extends UnsafeFrameAccess { + + @Override + public short unsafeShortArrayRead(short[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeShortArrayWrite(short[] arr, int index, short value) { + arr[index] = value; + } + + @Override + public byte unsafeByteArrayRead(byte[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeByteArrayWrite(byte[] arr, int index, byte value) { + arr[index] = value; + } + + @Override + public int unsafeIntArrayRead(int[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeIntArrayWrite(int[] arr, int index, int value) { + arr[index] = value; + } + + @Override + public T unsafeObjectArrayRead(T[] arr, int index) { + // TODO Auto-generated method stub + return null; + } + + @Override + public byte unsafeGetTag(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Object unsafeGetObject(Frame frame, int slot) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean unsafeGetBoolean(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int unsafeGetInt(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long unsafeGetLong(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public double unsafeGetDouble(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Object unsafeUncheckedGetObject(Frame frame, int slot) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean unsafeUncheckedGetBoolean(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int unsafeUncheckedGetInt(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public long unsafeUncheckedGetLong(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public double unsafeUncheckedGetDouble(Frame frame, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void unsafeSetObject(Frame frame, int slot, Object value) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeSetBoolean(Frame frame, int slot, boolean value) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeSetInt(Frame frame, int slot, int value) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeSetLong(Frame frame, int slot, long value) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeSetDouble(Frame frame, int slot, double value) { + // TODO Auto-generated method stub + + } + + @Override + public boolean unsafeIsObject(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean unsafeIsBoolean(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean unsafeIsInt(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean unsafeIsLong(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean unsafeIsDouble(Frame frame, int slot) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { + // TODO Auto-generated method stub + + } + + @Override + public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { + // TODO Auto-generated method stub + + } + + } + private static final class Impl extends UnsafeFrameAccess { @Override @@ -128,6 +322,16 @@ public void unsafeShortArrayWrite(short[] arr, int index, short value) { FrameWithoutBoxing.UNSAFE.putShort(arr, Unsafe.ARRAY_SHORT_BASE_OFFSET + index * Unsafe.ARRAY_SHORT_INDEX_SCALE, value); } + @Override + public byte unsafeByteArrayRead(byte[] arr, int index) { + return FrameWithoutBoxing.UNSAFE.getByte(arr, Unsafe.ARRAY_BYTE_BASE_OFFSET + index * Unsafe.ARRAY_BYTE_INDEX_SCALE); + } + + @Override + public void unsafeByteArrayWrite(byte[] arr, int index, byte value) { + FrameWithoutBoxing.UNSAFE.putShort(arr, Unsafe.ARRAY_BYTE_BASE_OFFSET + index * Unsafe.ARRAY_BYTE_INDEX_SCALE, value); + } + @Override public int unsafeIntArrayRead(int[] arr, int index) { return FrameWithoutBoxing.UNSAFE.getInt(arr, Unsafe.ARRAY_INT_BASE_OFFSET + index * Unsafe.ARRAY_INT_INDEX_SCALE); @@ -272,7 +476,6 @@ public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { castFrame(frame).unsafeCopyPrimitive(srcSlot, dstSlot); } - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index e44c0ba85532..c310bcea52f9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -43,7 +43,7 @@ public class OperationGeneratorFlags { public static final boolean LOG_LOCAL_STORES = false; - public static final boolean LOG_LOCAL_STORES_SPEC = false; + public static final boolean LOG_LOCAL_STORES_SPEC = true; public static final boolean LOG_LOCAL_LOADS = LOG_LOCAL_STORES; public static final boolean LOG_LOCAL_LOADS_SPEC = LOG_LOCAL_STORES_SPEC; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 9dcbd5abbd05..d67fea9e7812 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -245,6 +245,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { CodeExecutableElement mContinueAt = GeneratorUtils.overrideImplement(baseType, "continueAt"); createExplodeLoop(mContinueAt); + var ctx = m.getOperationsContext(); + ExecutionVariables vars = new ExecutionVariables(); populateVariables(vars, m); @@ -292,11 +294,6 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); - if (m.getOperationsContext().hasBoxingElimination()) { - b.declaration("short", "primitiveTag", isUncached ? "0" : "(short)((curOpcode >> 13) & 0x0007)"); - b.startAssign(varCurOpcode).string("(short) (").variable(varCurOpcode).string(" & 0x1fff)").end(); - } - b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); b.startTryBlock(); @@ -322,29 +319,68 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.lineComment(line); } - b.startCase().variable(op.opcodeIdField).end(); - b.startBlock(); + Runnable createBody = () -> { + if (m.isTracing()) { + b.startStatement().startCall(varTracer, "traceInstruction"); + b.variable(vars.bci); + b.variable(op.opcodeIdField); + b.end(2); + } - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "traceInstruction"); - b.variable(vars.bci); - b.variable(op.opcodeIdField); - b.end(2); - } + if (isUncached) { + b.tree(op.createExecuteUncachedCode(vars)); + } else { + b.tree(op.createExecuteCode(vars)); + } - if (isUncached) { - b.tree(op.createExecuteUncachedCode(vars)); - } else { - b.tree(op.createExecuteCode(vars)); - } + if (!op.isBranchInstruction()) { + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); + b.statement("continue loop"); + } + }; + + if (ctx.hasBoxingElimination() && !isUncached) { + if (op.splitOnBoxingElimination()) { + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); + b.startBlock(); + vars.specializedKind = kind; + createBody.run(); + vars.specializedKind = null; + b.end(); + } + if (op.hasGeneric()) { + b.startCase().variable(op.opcodeIdField).string(" | (short) (7 << 13)").end(); + b.startBlock(); + createBody.run(); + b.end(); + } + } else if (op.numPushedValues == 0) { + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); + createBody.run(); + b.end(); + } else { + for (FrameKind kind : ctx.getBoxingKinds()) { + b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); + } - if (!op.isBranchInstruction()) { - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); - b.statement("continue loop"); + b.startBlock(); + b.declaration("short", "primitiveTag", "(short) ((curOpcode >> 13) & 0x0007)"); + createBody.run(); + b.end(); + } + } else { + b.startCase().variable(op.opcodeIdField).end(); + b.startBlock(); + if (ctx.hasBoxingElimination()) { + vars.specializedKind = FrameKind.OBJECT; + } + createBody.run(); + vars.specializedKind = null; + b.end(); } - b.end(); - vars.inputs = null; vars.results = null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index f5ebb9cd74ac..0f4be9be8648 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -477,6 +477,11 @@ public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, Execut return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false, false); } + if (execution.getName().startsWith("$immediate")) { + int index = Integer.parseInt(execution.getName().substring(10)); + return createArrayReference(frameState, CustomInstruction.MARKER_IMMEDIATEE_PREFIX + index, true, data.getMainProperties().immediateTypes.get(index), false, false); + } + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (execution.getName().equals("$variadicChild")) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 88115d2b3efe..bd9aa1642b68 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -363,6 +363,9 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(short[].class), "_bc"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(Object[].class), "_consts"))); typOperationNodeImpl.add(children(new CodeVariableElement(arrayOf(types.Node), "_children"))); + if (m.getOperationsContext().hasBoxingElimination()) { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(byte[].class), "_localTags"))); + } typOperationNodeImpl.add(compFinal(new CodeVariableElement(arrayOf(typExceptionHandler.asType()), "_handlers"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "_conditionProfiles"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxLocals"))); @@ -716,6 +719,9 @@ private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperatio b.statement("result._bc = Arrays.copyOf(_bc, _bc.length)"); b.statement("result._consts = Arrays.copyOf(_consts, _consts.length)"); b.statement("result._children = Arrays.copyOf(_children, _children.length)"); + if (m.getOperationsContext().hasBoxingElimination()) { + b.statement("result._localTags = Arrays.copyOf(_localTags, _localTags.length)"); + } b.statement("result._handlers = _handlers"); b.statement("result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length)"); b.statement("result._maxLocals = _maxLocals"); @@ -749,6 +755,9 @@ private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNod b.statement("result._bc = _bc"); b.statement("result._consts = _consts"); b.statement("result._children = _children"); + if (m.getOperationsContext().hasBoxingElimination()) { + b.statement("result._localTags = _localTags"); + } b.statement("result._handlers = _handlers"); b.statement("result._conditionProfiles = _conditionProfiles"); b.statement("result._maxLocals = _maxLocals"); @@ -791,6 +800,9 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.string("(result >> 16) & 0xffff"); b.string("_consts"); b.string("_children"); + if (m.getOperationsContext().hasBoxingElimination()) { + b.string("_localTags"); + } b.string("_handlers"); b.string("_conditionProfiles"); b.string("_maxLocals"); @@ -1759,6 +1771,9 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); + if (m.getOperationsContext().hasBoxingElimination()) { + loopMethod.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + } loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); loopMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "maxLocals")); @@ -2224,6 +2239,9 @@ private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperat b.statement("result._bc = Arrays.copyOf(bc, bci)"); b.statement("result._consts = constPool.toArray()"); b.statement("result._children = new Node[numChildNodes]"); + if (m.getOperationsContext().hasBoxingElimination()) { + b.statement("result._localTags = new byte[numLocals]"); + } b.statement("result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0])"); b.statement("result._conditionProfiles = new int[numConditionProfiles]"); b.statement("result._maxLocals = numLocals"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 0048fc28532b..cc6d26c08df9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -52,7 +53,7 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.Template; @@ -69,33 +70,18 @@ public class SingleOperationData extends Template { public enum ParameterKind { STACK_VALUE, VARIADIC, + IMMEDIATE, VIRTUAL_FRAME, LOCAL_SETTER, LOCAL_SETTER_ARRAY; - public TypeMirror getParameterType(ProcessorContext context) { - switch (this) { - case STACK_VALUE: - return context.getType(Object.class); - case VARIADIC: - return new ArrayCodeTypeMirror(context.getType(Object.class)); - case VIRTUAL_FRAME: - return context.getTypes().VirtualFrame; - case LOCAL_SETTER: - return context.getTypes().LocalSetter; - case LOCAL_SETTER_ARRAY: - return new ArrayCodeTypeMirror(context.getTypes().LocalSetter); - default: - throw new IllegalArgumentException("" + this); - } - } - public boolean isStackValue() { switch (this) { case STACK_VALUE: case VARIADIC: return true; case VIRTUAL_FRAME: + case IMMEDIATE: case LOCAL_SETTER: case LOCAL_SETTER_ARRAY: return false; @@ -112,10 +98,12 @@ public static class MethodProperties { public final boolean returnsValue; public final int numStackValues; public final int numLocalReferences; + public final List immediateTypes; - public MethodProperties(ExecutableElement element, List parameters, boolean isVariadic, boolean returnsValue, int numLocalReferences) { + public MethodProperties(ExecutableElement element, List parameters, List immediateTypes, boolean isVariadic, boolean returnsValue, int numLocalReferences) { this.element = element; this.parameters = parameters; + this.immediateTypes = immediateTypes; int stackValues = 0; for (ParameterKind param : parameters) { if (param.isStackValue()) { @@ -137,6 +125,18 @@ public void checkMatches(SingleOperationData data, MethodProperties other) { data.addError(element, "All methods must (not) be variadic"); } + if (other.immediateTypes.size() != immediateTypes.size()) { + data.addError(element, "All methods must have same number of immediate arguments"); + } else { + for (int i = 0; i < immediateTypes.size(); i++) { + TypeMirror type1 = other.immediateTypes.get(i); + TypeMirror type2 = immediateTypes.get(i); + if (!ElementUtils.typeEquals(type1, type2)) { + data.addError(element, "Immediate arguments %d have differing types: %s and %s", type1, type2); + } + } + } + if (other.returnsValue != returnsValue) { data.addError(element, "All methods must (not) return value"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index b8382fce3603..0d3a16aa138e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -306,6 +306,7 @@ protected SingleOperationData parse(Element element, List mirr private void addBoxingEliminationNodeChildAnnotations(SingleOperationData data, MethodProperties props, CodeTypeElement ct) { int i = 0; int localI = 0; + int immediateI = 0; CodeTypeElement childType = createRegularNodeChild(); CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); List anns = new ArrayList<>(); @@ -320,13 +321,19 @@ private void addBoxingEliminationNodeChildAnnotations(SingleOperationData data, break; case LOCAL_SETTER: ann.setElementValue("value", new CodeAnnotationValue("$localRef" + localI)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterNodeChild()))); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(types.LocalSetter)))); anns.add(new CodeAnnotationValue(ann)); localI++; break; + case IMMEDIATE: + ann.setElementValue("value", new CodeAnnotationValue("$immediate" + immediateI)); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(props.immediateTypes.get(immediateI))))); + anns.add(new CodeAnnotationValue(ann)); + immediateI++; + break; case LOCAL_SETTER_ARRAY: ann.setElementValue("value", new CodeAnnotationValue("$localRefArray")); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createLocalSetterArrayNodeChild()))); + ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(types.LocalSetterRange)))); anns.add(new CodeAnnotationValue(ann)); break; case VARIADIC: @@ -407,6 +414,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme boolean isVariadic = false; int numLocalSetters = 0; List parameters = new ArrayList<>(); + List immediateTypes = new ArrayList<>(); for (VariableElement param : method.getParameters()) { if (isVariadicParameter(param)) { @@ -444,7 +452,7 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; - MethodProperties props = new MethodProperties(method, parameters, isVariadic, returnsValue, numLocalSetters); + MethodProperties props = new MethodProperties(method, parameters, immediateTypes, isVariadic, returnsValue, numLocalSetters); return props; } @@ -487,20 +495,11 @@ private CodeTypeElement createVariadicNodeChild() { return result; } - private CodeTypeElement createLocalSetterNodeChild() { - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); - result.setSuperClass(types.Node); - - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetter)); - - return result; - } - - private CodeTypeElement createLocalSetterArrayNodeChild() { + private CodeTypeElement createConstantNodeChild(TypeMirror returnType) { CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); result.setSuperClass(types.Node); - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, types.LocalSetterRange)); + result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, returnType)); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 352269e7bcba..43bb70eb92a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -110,28 +110,28 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.statement("loopCounter.count = 0"); - b.end(); // } - } + if (TRY_OSR) { + b.startIf(); + b.tree(GeneratorUtils.createInInterpreter()); + b.string(" && "); + b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("$this").end(); + b.end().startBlock(); // { + b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); + b.string("$this"); + b.string("($sp << 16) | targetBci"); + b.variable(vars.localFrame); + b.string("null"); + b.variable(vars.stackFrame); + b.end(2); - if (TRY_OSR) { - b.startIf(); - b.tree(GeneratorUtils.createInInterpreter()); - b.string(" && "); - b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("$this").end(); - b.end().startBlock(); // { - b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); - b.string("$this"); - b.string("($sp << 16) | targetBci"); - b.variable(vars.localFrame); - b.string("null"); - b.variable(vars.stackFrame); - b.end(2); - - b.startIf().string("osrResult != null").end().startBlock(); // { - // todo: check if this will overwrite a local in reused frames - b.startStatement().variable(vars.stackFrame).string(".setObject(0, osrResult)").end(); - b.startReturn().string("0x0000ffff").end(); - b.end(); // } + b.startIf().string("osrResult != null").end().startBlock(); // { + // todo: check if this will overwrite a local in reused frames + b.startStatement().variable(vars.stackFrame).string(".setObject(0, osrResult)").end(); + b.startReturn().string("0x0000ffff").end(); + b.end(); // } + + b.end(); // } + } b.end(); // } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 7bdc8798bd5c..ef66a55970f7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -47,6 +47,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -101,8 +102,10 @@ public CustomInstruction(OperationsContext ctx, String name, int id, SingleOpera public static final String MARKER_LOCAL_REFS = "LocalSetterRange"; public static final String MARKER_LOCAL_REF_PREFIX = "LocalSetter_"; + public static final String MARKER_IMMEDIATEE_PREFIX = "Immediate_"; private int[] localRefs = null; + private int[] immediates = null; protected void initializePops() { MethodProperties props = data.getMainProperties(); @@ -127,6 +130,13 @@ protected void initializePops() { localRefs[i] = addConstant(MARKER_LOCAL_REF_PREFIX + i, types.OperationLocal); } } + + if (props.immediateTypes.size() > 0) { + immediates = new int[props.immediateTypes.size()]; + for (int i = 0; i < props.immediateTypes.size(); i++) { + immediates[i] = addConstant(MARKER_IMMEDIATEE_PREFIX + i, props.immediateTypes.get(i)); + } + } } protected CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data, int pushCount) { @@ -154,17 +164,18 @@ private void addLocalRefs(CodeTreeBuilder b, ExecutionVariables vars) { } } + @Override + public boolean splitOnBoxingElimination() { + return data.getMainProperties().returnsValue; + } + private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - String exName = getUniqueName() + "_entryPoint" + (uncached ? "_uncached" : ""); + String exName = getUniqueName() + "_entryPoint_" + (uncached ? "uncached" : ctx.hasBoxingElimination() ? vars.specializedKind : ""); OperationGeneratorUtils.createHelperMethod(ctx.outerType, exName, () -> { CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), exName); el.getParameters().addAll(executeMethods[0].getParameters()); - if (!uncached && ctx.hasBoxingElimination()) { - el.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); - } - CodeTreeBuilder b = el.createBuilder(); if (numPushedValues > 0) { @@ -176,47 +187,31 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } if (!uncached && ctx.hasBoxingElimination()) { - boolean needsUnexpectedResult = false; - for (ExecutableElement exm : executeMethods) { - if (exm != null && exm.getThrownTypes().size() > 0) { - needsUnexpectedResult = true; - break; - } - } + int i = ctx.getBoxingKinds().indexOf(vars.specializedKind); + + boolean needsUnexpectedResult = executeMethods[i] != null && executeMethods[i].getThrownTypes().size() > 0; if (needsUnexpectedResult) { b.startTryBlock(); } - b.startSwitch().string("primitiveTag").end().startBlock(); + if (executeMethods[i] != null) { + b.startStatement().startCall("UFA", "unsafeSet" + vars.specializedKind.getFrameName()); - int i = 0; - for (FrameKind kind : ctx.getBoxingKinds()) { - if (executeMethods[i] != null) { - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); - - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - - b.variable(vars.stackFrame); - b.string("destSlot"); - - b.startStaticCall(executeMethods[i]); - b.variables(executeMethods[i].getParameters()); - b.end(); + b.variable(vars.stackFrame); + b.string("destSlot"); - b.end(2); + b.startStaticCall(executeMethods[i]); + b.variables(executeMethods[i].getParameters()); + b.end(); - b.returnStatement(); - b.end(); - } + b.end(2); - i++; + b.returnStatement(); + } else { + b.tree(GeneratorUtils.createShouldNotReachHere()); } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); - b.end(); if (needsUnexpectedResult) { @@ -305,11 +300,6 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (isVariadic()) { b.string("numVariadics"); } - - if (!uncached && ctx.hasBoxingElimination()) { - b.string("primitiveTag"); - } - b.end(2); b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 50a67c55a573..f85a0fc9416a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -74,6 +74,8 @@ public static class ExecutionVariables { public CodeVariableElement probeNodes; public CodeVariableElement tracer; + + public FrameKind specializedKind; } public static class EmitArguments { @@ -126,7 +128,6 @@ public static class EmitArguments { private static int addInstructionArgument(List holder, Object marker) { int index = -1; - if (marker != null) { index = holder.indexOf(marker); } @@ -374,6 +375,14 @@ public int numBranchTargets() { return branchTargets.size(); } + public boolean splitOnBoxingElimination() { + return false; + } + + public boolean hasGeneric() { + return false; + } + public CodeVariableElement opcodeIdField; public void setOpcodeIdField(CodeVariableElement opcodeIdField) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 889c668845b8..0916f581b595 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -70,39 +70,33 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("Object", "value", createGetValue(vars)); if (ctx.hasBoxingElimination()) { - b.startSwitch().string("primitiveTag").end().startBlock(); - for (FrameKind kind : ctx.getBoxingKinds()) { - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); - if (kind == FrameKind.OBJECT) { - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - } else { - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - // { - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("(", kind.getTypeName(), ") value"); - b.end(2); - // } - b.end().startElseBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - // } - b.end(); - } - b.statement("break"); + FrameKind kind = vars.specializedKind; + if (kind == FrameKind.OBJECT) { + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); + } else { + b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + // { + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("(", kind.getTypeName(), ") value"); + b.end(2); + // } + b.end().startElseBlock(); + // { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); + // } b.end(); } - b.end(); } else { b.startStatement().startCall("UFA", "unsafeSetObject"); b.variable(vars.stackFrame); @@ -120,4 +114,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public boolean splitOnBoxingElimination() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index cb05d1b66ae4..f7ebeb412117 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -63,43 +63,28 @@ public LoadConstantInstruction(OperationsContext ctx, int id) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_loadConstantObject", () -> { + String helperName = "do_loadConstant_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); + + OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { CodeExecutableElement metImpl = new CodeExecutableElement( EnumSet.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), - "do_loadConstantObject"); + helperName); metImpl.addParameter(vars.stackFrame); metImpl.addParameter(vars.bc); metImpl.addParameter(vars.bci); metImpl.addParameter(vars.sp); metImpl.addParameter(vars.consts); - if (ctx.hasBoxingElimination()) { - metImpl.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); - } CodeTreeBuilder b = metImpl.getBuilder(); if (ctx.hasBoxingElimination()) { - b.startSwitch().string("primitiveTag").end().startBlock(); - - for (FrameKind kind : ctx.getBoxingKinds()) { - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); - - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetArgument(vars, kind)); - b.end(2); - - b.statement("break"); - b.end(); - } - - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); - + b.startStatement().startCall("UFA", "unsafeSet" + vars.specializedKind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.tree(createGetArgument(vars, vars.specializedKind)); + b.end(2); b.end(); } else { b.startStatement().startCall("UFA", "unsafeSetObject"); @@ -113,15 +98,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { }); CodeTreeBuilder bOuter = CodeTreeBuilder.createBuilder(); - bOuter.startStatement().startCall("do_loadConstantObject"); + bOuter.startStatement().startCall(helperName); bOuter.variable(vars.stackFrame); bOuter.variable(vars.bc); bOuter.variable(vars.bci); bOuter.variable(vars.sp); bOuter.variable(vars.consts); - if (ctx.hasBoxingElimination()) { - bOuter.string("primitiveTag"); - } bOuter.end(2); bOuter.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); @@ -148,4 +130,9 @@ private CodeTree createGetArgument(ExecutionVariables vars, FrameKind kind) { public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public boolean splitOnBoxingElimination() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 782445e92d35..152c9c9d161c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -49,6 +49,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -61,8 +62,9 @@ public LoadLocalInstruction(OperationsContext ctx, int id) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_loadLocal", () -> { - CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), "do_loadLocal"); + String helperName = "do_loadLocal_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); + OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { + CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), helperName); res.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { @@ -72,85 +74,106 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { res.addParameter(vars.bci); res.addParameter(vars.sp); if (ctx.hasBoxingElimination()) { - res.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + res.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); } res.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); CodeTreeBuilder b = res.createBuilder(); if (ctx.hasBoxingElimination()) { - b.startSwitch().string("primitiveTag").end().startBlock(); - for (FrameKind kind : ctx.getBoxingKinds()) { - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); + FrameKind kind = vars.specializedKind; + if (kind == FrameKind.OBJECT) { + b.statement("Object value"); + // this switch should be made to fold + b.startSwitch().startCall("UFA", "unsafeGetTag").variable(vars.localFrame).string("localIdx").end(2).startBlock(); + for (FrameKind localKind : ctx.getBoxingKinds()) { + b.startCase().string(localKind.toOrdinal()).end().startCaseBlock(); + + b.startAssign("value").startCall("UFA", "unsafeUncheckedGet" + localKind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.end(2); - if (kind == FrameKind.OBJECT) { - b.statement("Object value"); - // this switch should be made to fold - b.startSwitch().startCall("UFA", "unsafeGetTag").variable(vars.localFrame).string("localIdx").end(2).startBlock(); - for (FrameKind localKind : ctx.getBoxingKinds()) { - b.startCase().string(localKind.toOrdinal()).end().startCaseBlock(); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { + b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + localKind + " (as OBJECT)%n\", localIdx, $frame.getValue(localIdx))"); + } - b.startAssign("value").startCall("UFA", "unsafeUncheckedGet" + localKind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.end(2); + b.statement("break"); - b.statement("break"); + b.end(); + } - b.end(); - } + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createShouldNotReachHere()); + b.end(); - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); + b.end(); // switch - b.end(); // switch + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.string("value"); + b.end(2); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); + b.returnStatement(); + } else { + b.startTryBlock(); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.end(); + b.end(2); - b.returnStatement(); - } else { - b.startTryBlock(); - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.startCall("UFA", "unsafeGet" + kind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.end(); - b.end(2); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { + b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + kind + "%n\", localIdx, $frame.getValue(localIdx))"); + } - b.returnStatement(); + b.returnStatement(); - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - b.end(); + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.statement("break"); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); + + b.startIf().string("result instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + + if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + "%n\", localIdx, $frame.getValue(localIdx))"); } + b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); + b.string("localTags"); + b.string("localIdx"); + b.string("(byte) ", kind.toOrdinal()); + b.end(2); + + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()).variable(vars.localFrame).string("localIdx").string("(", kind.getTypeName(), ") result").end(2); + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()).variable(vars.stackFrame).variable(vars.sp).string("(", kind.getTypeName(), ") result").end(2); + b.returnStatement(); + + b.end(); b.end(); } - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); - - b.end(); + if (kind != FrameKind.OBJECT) { + b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); - b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=" + kind + "->OBJECT%n\", localIdx, $frame.getValue(localIdx))"); + } - b.startStatement().startCall(vars.localFrame, "getFrameDescriptor().setSlotKind"); - b.string("localIdx"); - b.string("primitiveTag == 7 ? FrameSlotKind.Object : FrameSlotKind.fromTag((byte) primitiveTag)"); - b.end(2); + b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); + b.string("localTags"); + b.string("localIdx"); + b.string("(byte) 7"); + b.end(2); - b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.localFrame).string("localIdx").string("result").end(2); - b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.stackFrame).variable(vars.sp).string("result").end(2); + b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.localFrame).string("localIdx").string("result").end(2); + b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.stackFrame).variable(vars.sp).string("result").end(2); + } } else { if (ctx.getData().enableYield) { @@ -179,7 +202,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.tree(createLocalIndex(vars, 0, false)); b.end(); - b.startStatement().startCall("do_loadLocal"); + b.startStatement().startCall(helperName); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); @@ -188,7 +211,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.bci); b.variable(vars.sp); if (ctx.hasBoxingElimination()) { - b.string("primitiveTag"); + b.string("$localTags"); } b.string("localIdx"); b.end(2); @@ -208,4 +231,9 @@ public boolean neverInUncached() { return false; } + @Override + public boolean splitOnBoxingElimination() { + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 639c86390d99..2fc1c8675ac2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -49,6 +49,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -74,8 +75,8 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { ex.addParameter(vars.bc); ex.addParameter(vars.bci); ex.addParameter(vars.sp); - ex.addParameter(new CodeVariableElement(types.FrameDescriptor, "fd")); if (ctx.hasBoxingElimination()) { + ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); } ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); @@ -89,7 +90,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("sourceSlot"); b.end(2); - b.declaration(types.FrameSlotKind, "curKind", "fd.getSlotKind(localIdx)"); + b.declaration("byte", "curKind", "UFA.unsafeByteArrayRead(localTags, localIdx)"); b.statement("// System.err.printf(\"primitiveTag=%d value=%s %s curKind=%s tag=%s%n\", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot))"); @@ -98,12 +99,16 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf(); b.string("(primitiveTag == 0 || primitiveTag == " + primKind.toOrdinal() + ")"); - b.string(" && (curKind == FrameSlotKind.Illegal || curKind == FrameSlotKind." + primKind.getFrameName() + ")"); + b.string(" && (curKind == 0 || curKind == " + primKind.toOrdinal() + ")"); b.end().startBlock(); b.startIf().string("value instanceof ", primKind.getTypeNameBoxed()).end().startBlock(); - createSetFrameDescriptorKind(vars, b, primKind.getFrameName()); + if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { + b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->" + primKind + "%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); + } + + createSetFrameDescriptorKind(vars, b, primKind.toOrdinal()); createSetPrimitiveTag(vars, b, primKind.toOrdinal()); createBoxingEliminateChild(vars, b, primKind.toOrdinal()); @@ -120,7 +125,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); } - createSetFrameDescriptorKind(vars, b, "Object"); + if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { + b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->OBJECT%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); + } + + createSetFrameDescriptorKind(vars, b, "7 /* generic */"); createSetPrimitiveTag(vars, b, "7 /* generic */"); createBoxingEliminateChild(vars, b, "0 /* OBJECT */"); @@ -134,8 +143,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { }); } - OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_storeLocal", () -> { - CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), "do_storeLocal"); + String helperName = ctx.hasBoxingElimination() ? "do_storeLocal_" + vars.specializedKind : "do_storeLocal"; + OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), helperName); ex.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { @@ -145,7 +155,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { ex.addParameter(vars.bci); ex.addParameter(vars.sp); if (ctx.hasBoxingElimination()) { - ex.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); + ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); } ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); @@ -156,81 +166,71 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { if (!ctx.hasBoxingElimination()) { createCopyObject(vars, b); } else { - // if Frame ever supports an 8th primitive type, we will need more bits here - b.declaration(types.FrameDescriptor, "fd", vars.localFrame.getName() + ".getFrameDescriptor()"); - b.declaration(types.FrameSlotKind, "curKind", "fd.getSlotKind(localIdx)"); - b.startSwitch().string("primitiveTag").end().startBlock(); - for (FrameKind kind : ctx.getBoxingKinds()) { - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); - - if (kind == FrameKind.OBJECT) { - // this is the uninitialized case - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - createCallSpecialize(vars, b); - } else { - // primitive case - - b.startIf().string("curKind == FrameSlotKind." + kind.getFrameName()).end().startBlock(); - - b.startTryBlock(); - - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall("UFA", "unsafeGet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.string("sourceSlot"); - b.end(); - b.end(2); - - b.returnStatement(); - - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - b.end(); // try catch - - b.end(); // if - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - createCallSpecialize(vars, b); - } + b.declaration("byte", "curKind", "UFA.unsafeByteArrayRead(localTags, localIdx)"); + FrameKind kind = vars.specializedKind; + if (kind == FrameKind.OBJECT) { + // this is the uninitialized case + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + createCallSpecialize(vars, b, FrameKind.OBJECT); + } else if (kind != null) { + // primitive case + + b.startIf().string("curKind == " + kind.toOrdinal()).end().startBlock(); - b.statement("break"); + b.startTryBlock(); + + b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + b.variable(vars.stackFrame); + b.string("sourceSlot"); b.end(); - } + b.end(2); - b.startCase().string("7 /* generic */").end().startCaseBlock(); + if (OperationGeneratorFlags.LOG_LOCAL_STORES) { + b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=" + kind + "%n\", localIdx, $frame.getValue(sourceSlot))"); + } - b.startTryBlock(); + b.returnStatement(); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall("UFA", "unsafeGetObject"); - b.variable(vars.stackFrame); - b.string("sourceSlot"); - b.end(); - b.end(2); + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + b.end(); // try catch - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + b.end(); // if - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall(vars.stackFrame, "getValue"); - b.string("sourceSlot"); - b.end(); - b.end(2); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + createCallSpecialize(vars, b, kind); + } else { + // generic case + b.startTryBlock(); - b.end(); - b.statement("break"); - b.end(); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall("UFA", "unsafeGetObject"); + b.variable(vars.stackFrame); + b.string("sourceSlot"); + b.end(); + b.end(2); - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); + if (OperationGeneratorFlags.LOG_LOCAL_STORES) { + b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=OBJECT%n\", localIdx, $frame.getValue(sourceSlot))"); + } + + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - b.end(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.startCall(vars.stackFrame, "getValue"); + b.string("sourceSlot"); + b.end(); + b.end(2); + + b.end(); + } } return ex; @@ -240,7 +240,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); - b.startStatement().startCall("do_storeLocal"); + b.startStatement().startCall(helperName); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); @@ -249,7 +249,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.bci); b.variable(vars.sp); if (ctx.hasBoxingElimination()) { - b.string("primitiveTag"); + b.string("$localTags"); } b.string("localIdx"); b.end(2); @@ -278,7 +278,7 @@ private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { b.end(2); } - private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b) { + private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b, FrameKind kind) { b.startStatement().startCall("do_storeLocalSpecialize"); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { @@ -287,9 +287,9 @@ private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b) { b.variable(vars.bc); b.variable(vars.bci); b.variable(vars.sp); - b.string("fd"); + b.string("localTags"); if (ctx.hasBoxingElimination()) { - b.string("primitiveTag"); + b.string(kind.toOrdinal()); } b.string("localIdx"); b.string("sourceSlot"); @@ -297,10 +297,11 @@ private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b) { } @SuppressWarnings("unused") - private void createSetFrameDescriptorKind(ExecutionVariables vars, CodeTreeBuilder b, String kind) { - b.startStatement().startCall("fd", "setSlotKind"); + private static void createSetFrameDescriptorKind(ExecutionVariables vars, CodeTreeBuilder b, String kind) { + b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); + b.string("localTags"); b.string("localIdx"); - b.staticReference(types.FrameSlotKind, kind); + b.string("(byte) " + kind); b.end(2); } @@ -321,4 +322,14 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public boolean neverInUncached() { return false; } + + @Override + public boolean splitOnBoxingElimination() { + return true; + } + + @Override + public boolean hasGeneric() { + return true; + } } From e65136ff5a5e47e3b3dd04b81b2388d4f65b4dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 7 Oct 2022 11:55:59 +0200 Subject: [PATCH 145/312] [wip] --- .../test/example/BoxingOperationsTest.java | 1 + .../truffle/api/impl/FrameWithoutBoxing.java | 25 ++- .../truffle/api/impl/UnsafeFrameAccess.java | 192 +----------------- .../truffle/api/nodes/ExecutableNode.java | 6 +- .../dsl/processor/operations/Operation.java | 20 +- .../operations/OperationGeneratorFlags.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 11 +- .../operations/OperationsCodeGenerator.java | 7 +- .../operations/OperationsContext.java | 19 +- .../operations/SingleOperationData.java | 21 +- .../operations/SingleOperationParser.java | 27 ++- .../instructions/CustomInstruction.java | 39 +++- .../operations/instructions/Instruction.java | 14 ++ .../instructions/LoadArgumentInstruction.java | 44 +--- .../instructions/LoadConstantInstruction.java | 61 +----- .../instructions/LoadLocalInstruction.java | 66 +++++- ... => LoadLocalMaterializedInstruction.java} | 11 +- .../instructions/ShortCircuitInstruction.java | 1 - .../instructions/StoreLocalInstruction.java | 19 +- ...=> StoreLocalMaterializedInstruction.java} | 6 +- .../instructions/YieldInstruction.java | 5 + .../sl/parser/SLOperationsVisitor.java | 14 +- 22 files changed, 243 insertions(+), 368 deletions(-) rename truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/{LoadNonlocalInstruction.java => LoadLocalMaterializedInstruction.java} (81%) rename truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/{StoreNonlocalInstruction.java => StoreLocalMaterializedInstruction.java} (86%) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index c43bb3c428f8..0e8d439bbd58 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -78,6 +78,7 @@ private static RootCallTarget parse(OperationParser private static OperationRootNode parseNode(OperationParser parser) { OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); OperationRootNode node = nodes.getNodes().get(0); + // System.out.println(node.dump()); return node; } diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index 135c0e3f7bb7..b7f8e3b74977 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -545,33 +545,35 @@ void unsafeCopyPrimitive(int srcSlot, int destSlot) { @Override public void swap(int first, int second) { byte firstTag = getIndexedTagChecked(first); - Object firstValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object firstValue = unsafeGetObject(getIndexedLocals(), getObjectOffset(first), true, OBJECT_LOCATION); long firstPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), true, PRIMITIVE_LOCATION); + byte secondTag = getIndexedTagChecked(second); - Object secondValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object secondValue = unsafeGetObject(getIndexedLocals(), getObjectOffset(second), true, OBJECT_LOCATION); long secondPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), true, PRIMITIVE_LOCATION); verifyIndexedSet(first, secondTag); verifyIndexedSet(second, firstTag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, secondValue, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(first), secondValue, OBJECT_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), secondPrimitiveValue, PRIMITIVE_LOCATION); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, firstValue, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(second), firstValue, OBJECT_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), firstPrimitiveValue, PRIMITIVE_LOCATION); } void unsafeSwap(int first, int second) { byte firstTag = unsafeGetIndexedTag(first); - Object firstValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object firstValue = unsafeGetObject(getIndexedLocals(), getObjectOffset(first), true, OBJECT_LOCATION); long firstPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), true, PRIMITIVE_LOCATION); + byte secondTag = unsafeGetIndexedTag(second); - Object secondValue = unsafeGetObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, true, OBJECT_LOCATION); + Object secondValue = unsafeGetObject(getIndexedLocals(), getObjectOffset(second), true, OBJECT_LOCATION); long secondPrimitiveValue = unsafeGetLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), true, PRIMITIVE_LOCATION); - verifyIndexedSet(first, secondTag); - verifyIndexedSet(second, firstTag); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + first * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, secondValue, OBJECT_LOCATION); + unsafeVerifyIndexedSet(first, secondTag); + unsafeVerifyIndexedSet(second, firstTag); + unsafePutObject(getIndexedLocals(), getObjectOffset(first), secondValue, OBJECT_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(first), secondPrimitiveValue, PRIMITIVE_LOCATION); - unsafePutObject(getIndexedLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + second * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, firstValue, OBJECT_LOCATION); + unsafePutObject(getIndexedLocals(), getObjectOffset(second), firstValue, OBJECT_LOCATION); unsafePutLong(getIndexedPrimitiveLocals(), getPrimitiveOffset(second), firstPrimitiveValue, PRIMITIVE_LOCATION); } @@ -615,7 +617,7 @@ private byte getIndexedTagChecked(int slot) { private byte unsafeGetIndexedTag(int slot) { byte tag = UNSAFE.getByte(getIndexedTags(), Unsafe.ARRAY_BYTE_BASE_OFFSET + slot * Unsafe.ARRAY_BYTE_INDEX_SCALE); - assert tag != STATIC_TAG : UNEXPECTED_NON_STATIC_READ; + assert (tag & STATIC_TAG) == 0 : UNEXPECTED_NON_STATIC_READ; return tag; } @@ -963,6 +965,7 @@ public void clearObjectStatic(int slot) { public void copyTo(int srcOffset, Frame dst, int dstOffset, int length) { FrameWithoutBoxing o = (FrameWithoutBoxing) dst; if (o.descriptor != descriptor // + || length < 0 // || srcOffset < 0 // || srcOffset + length > getIndexedTags().length // || dstOffset < 0 // diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index ef4160de22e6..14c9644e5209 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -120,196 +120,6 @@ public static UnsafeFrameAccess lookup() { UnsafeFrameAccess() { } - private static final class ImplSafe extends UnsafeFrameAccess { - - @Override - public short unsafeShortArrayRead(short[] arr, int index) { - return arr[index]; - } - - @Override - public void unsafeShortArrayWrite(short[] arr, int index, short value) { - arr[index] = value; - } - - @Override - public byte unsafeByteArrayRead(byte[] arr, int index) { - return arr[index]; - } - - @Override - public void unsafeByteArrayWrite(byte[] arr, int index, byte value) { - arr[index] = value; - } - - @Override - public int unsafeIntArrayRead(int[] arr, int index) { - return arr[index]; - } - - @Override - public void unsafeIntArrayWrite(int[] arr, int index, int value) { - arr[index] = value; - } - - @Override - public T unsafeObjectArrayRead(T[] arr, int index) { - // TODO Auto-generated method stub - return null; - } - - @Override - public byte unsafeGetTag(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public Object unsafeGetObject(Frame frame, int slot) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean unsafeGetBoolean(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public int unsafeGetInt(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public long unsafeGetLong(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public double unsafeGetDouble(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public Object unsafeUncheckedGetObject(Frame frame, int slot) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean unsafeUncheckedGetBoolean(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public int unsafeUncheckedGetInt(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public long unsafeUncheckedGetLong(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public double unsafeUncheckedGetDouble(Frame frame, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void unsafeSetObject(Frame frame, int slot, Object value) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeSetBoolean(Frame frame, int slot, boolean value) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeSetInt(Frame frame, int slot, int value) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeSetLong(Frame frame, int slot, long value) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeSetDouble(Frame frame, int slot, double value) { - // TODO Auto-generated method stub - - } - - @Override - public boolean unsafeIsObject(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean unsafeIsBoolean(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean unsafeIsInt(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean unsafeIsLong(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean unsafeIsDouble(Frame frame, int slot) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { - // TODO Auto-generated method stub - - } - - @Override - public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { - // TODO Auto-generated method stub - - } - - } - private static final class Impl extends UnsafeFrameAccess { @Override @@ -329,7 +139,7 @@ public byte unsafeByteArrayRead(byte[] arr, int index) { @Override public void unsafeByteArrayWrite(byte[] arr, int index, byte value) { - FrameWithoutBoxing.UNSAFE.putShort(arr, Unsafe.ARRAY_BYTE_BASE_OFFSET + index * Unsafe.ARRAY_BYTE_INDEX_SCALE, value); + FrameWithoutBoxing.UNSAFE.putByte(arr, Unsafe.ARRAY_BYTE_BASE_OFFSET + index * Unsafe.ARRAY_BYTE_INDEX_SCALE, value); } @Override diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java index 5fee2341eb97..a3373abd158b 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExecutableNode.java @@ -89,7 +89,7 @@ protected ExecutableNode(TruffleLanguage language) { assert language == null || getLanguageInfo() != null : "Truffle language instance is not initialized."; } - final TruffleLanguage getLanguage() { + protected final TruffleLanguage getLanguage() { Object ref = polyglotRef; if (ref instanceof TruffleLanguage) { return (TruffleLanguage) ref; @@ -166,8 +166,4 @@ public final C getLanguage(Class languageClass) { } return (C) language; } - - public final TruffleLanguage getLanguageInternal() { - return getLanguage(); - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 0a92c754d558..62405b3aa2c5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -61,9 +61,9 @@ import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadNonlocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalMaterializedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreNonlocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalMaterializedInstruction; public abstract class Operation { public static final int VARIABLE_CHILDREN = -1; @@ -246,11 +246,11 @@ public int numLocalReferences() { } } - public static class LoadNonlocal extends Operation { - private final LoadNonlocalInstruction instr; + public static class LoadLocalMaterialized extends Operation { + private final LoadLocalMaterializedInstruction instr; - public LoadNonlocal(OperationsContext context, int id, LoadNonlocalInstruction instr) { - super(context, "LoadNonlocal", id, 1); + public LoadLocalMaterialized(OperationsContext context, int id, LoadLocalMaterializedInstruction instr) { + super(context, "MaterializedLoadLocal", id, 1); this.instr = instr; } @@ -277,11 +277,11 @@ public CodeTree createPushCountCode(BuilderVariables vars) { } } - public static class StoreNonlocal extends Operation { - private final StoreNonlocalInstruction instr; + public static class StoreLocalMaterialized extends Operation { + private final StoreLocalMaterializedInstruction instr; - public StoreNonlocal(OperationsContext context, int id, StoreNonlocalInstruction instr) { - super(context, "StoreNonlocal", id, 2); + public StoreLocalMaterialized(OperationsContext context, int id, StoreLocalMaterializedInstruction instr) { + super(context, "StoreLocalMaterialized", id, 2); this.instr = instr; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index c310bcea52f9..e44c0ba85532 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -43,7 +43,7 @@ public class OperationGeneratorFlags { public static final boolean LOG_LOCAL_STORES = false; - public static final boolean LOG_LOCAL_STORES_SPEC = true; + public static final boolean LOG_LOCAL_STORES_SPEC = false; public static final boolean LOG_LOCAL_LOADS = LOG_LOCAL_STORES; public static final boolean LOG_LOCAL_LOADS_SPEC = LOG_LOCAL_STORES_SPEC; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index d67fea9e7812..7d376e0de3f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -298,10 +298,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startTryBlock(); - b.startIf().variable(vars.sp).string(" < maxLocals").end(); - b.startBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("stack underflow")); - b.end(); + b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); b.startSwitch().string("curOpcode").end(); b.startBlock(); @@ -341,7 +338,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { if (ctx.hasBoxingElimination() && !isUncached) { if (op.splitOnBoxingElimination()) { - for (FrameKind kind : ctx.getBoxingKinds()) { + for (FrameKind kind : op.getBoxingEliminationSplits()) { b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); b.startBlock(); vars.specializedKind = kind; @@ -355,13 +352,13 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { createBody.run(); b.end(); } - } else if (op.numPushedValues == 0) { + } else if (op.numPushedValues == 0 || op.alwaysBoxed()) { b.startCase().variable(op.opcodeIdField).end(); b.startBlock(); createBody.run(); b.end(); } else { - for (FrameKind kind : ctx.getBoxingKinds()) { + for (FrameKind kind : op.getBoxingEliminationSplits()) { b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index bd9aa1642b68..a688023c2be4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -618,7 +618,7 @@ private CodeTypeElement createContinuationLocationImpl(CodeTypeElement typOperat b.statement("ContinuationRoot node = root.yieldEntries[entry]"); b.startIf().string("node == null").end().startBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.statement("node = new ContinuationRoot(root.getLanguageInternal(), root.getFrameDescriptor(), root, target)"); + b.statement("node = new ContinuationRoot(root.getLanguage(), root.getFrameDescriptor(), root, target)"); b.statement("root.yieldEntries[entry] = node"); b.end(); b.statement("return node"); @@ -703,7 +703,7 @@ private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) private CodeTree createNodeCopy(CodeTypeElement typOperationNodeImpl) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startNew(typOperationNodeImpl.asType()); - b.startCall("getLanguage").typeLiteral(m.languageClass).end(); + b.startCall("getLanguage").end(); b.startCall("getFrameDescriptor().copy").end(); b.end(); return b.build(); @@ -2696,6 +2696,7 @@ private CodeExecutableElement createBuilderImplDoBeforeEmitInstruction() { CodeExecutableElement mDoBeforeEmitInstruction = new CodeExecutableElement(MOD_PRIVATE, context.getType(int[].class), "doBeforeEmitInstruction"); mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(int.class), "numPops")); mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(boolean.class), "pushValue")); + mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(boolean.class), "doBoxing")); CodeTreeBuilder b = mDoBeforeEmitInstruction.createBuilder(); @@ -2713,7 +2714,7 @@ private CodeExecutableElement createBuilderImplDoBeforeEmitInstruction() { b.statement("stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2)"); b.end(); - b.statement("stackSourceBci[curStack] = bci"); + b.statement("stackSourceBci[curStack] = doBoxing ? bci : -65535"); b.statement("curStack++"); b.startIf().string("curStack > maxStack").end().startBlock(); b.statement("maxStack = curStack"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 5f608be9b173..210fd6da7ec1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -65,12 +65,12 @@ import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadNonlocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalMaterializedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreNonlocalInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalMaterializedInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.YieldInstruction; @@ -84,6 +84,9 @@ public class OperationsContext { public Instruction commonBranchFalse; public Instruction commonThrow; + public LoadLocalInstruction loadLocalUnboxed; + public LoadLocalInstruction loadLocalBoxed; + public LoadArgumentInstruction[] loadArgumentInstructions; public LoadConstantInstruction[] loadConstantInstructions; @@ -133,14 +136,18 @@ private void createBuiltinOperations() { add(new Operation.Label(this, operationId++)); add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - add(new Operation.Simple(this, "ConstObject", operationId++, 0, add(new LoadConstantInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "LoadConstant", operationId++, 0, add(new LoadConstantInstruction(this, instructionId++)))); add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new LoadArgumentInstruction(this, instructionId++)))); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, add(new LoadLocalInstruction(this, instructionId++)))); + loadLocalUnboxed = add(new LoadLocalInstruction(this, instructionId++, false)); + add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalUnboxed)); + if (hasBoxingElimination()) { + loadLocalBoxed = add(new LoadLocalInstruction(this, instructionId++, true)); + } add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(this, instructionId++)))); add(new Operation.Simple(this, "Return", operationId++, 1, add(new ReturnInstruction(this, instructionId++)))); - add(new Operation.LoadNonlocal(this, operationId++, add(new LoadNonlocalInstruction(this, instructionId++)))); - add(new Operation.StoreNonlocal(this, operationId++, add(new StoreNonlocalInstruction(this, instructionId++)))); + add(new Operation.LoadLocalMaterialized(this, operationId++, add(new LoadLocalMaterializedInstruction(this, instructionId++)))); + add(new Operation.StoreLocalMaterialized(this, operationId++, add(new StoreLocalMaterializedInstruction(this, instructionId++)))); if (data.enableYield) { add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(this, instructionId++)))); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index cc6d26c08df9..15c0bf5b88f9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.dsl.processor.operations; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -57,6 +56,7 @@ import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.Template; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; public class SingleOperationData extends Template { private String name; @@ -67,6 +67,9 @@ public class SingleOperationData extends Template { private final boolean isShortCircuit; private boolean shortCircuitContinueWhen; + private List possiblePrimitiveTypes; + private boolean isAlwaysBoxed; + public enum ParameterKind { STACK_VALUE, VARIADIC, @@ -232,4 +235,20 @@ public void setShortCircuitContinueWhen(boolean shortCircuitContinueWhen) { this.shortCircuitContinueWhen = shortCircuitContinueWhen; } + public List getPossiblePrimitiveTypes() { + return possiblePrimitiveTypes; + } + + public void setPossiblePrimitiveTypes(List prossiblePrimitiveTypes) { + this.possiblePrimitiveTypes = prossiblePrimitiveTypes; + } + + public boolean isAlwaysBoxed() { + return isAlwaysBoxed; + } + + public void setAlwaysBoxed(boolean isAlwaysBoxed) { + this.isAlwaysBoxed = isAlwaysBoxed; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 0d3a16aa138e..b61d348f56af 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -40,8 +40,10 @@ */ package com.oracle.truffle.dsl.processor.operations; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Consumer; @@ -58,7 +60,6 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; @@ -155,9 +156,6 @@ protected SingleOperationData parse(Element element, List mirr return null; } - AnnotationMirror mir = ElementUtils.findAnnotationMirror(mirror, getAnnotationType()); - AnnotationValue valDBE = ElementUtils.getAnnotationValue(mir, "disableBoxingElimination", true); - te = (TypeElement) element; if (isShortCircuit) { name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); @@ -215,24 +213,37 @@ protected SingleOperationData parse(Element element, List mirr } MethodProperties props = processMethod(data, operationFunctions.get(0)); - boolean isVariadic = props.isVariadic; boolean[] canPossiblyReturn = new boolean[FrameKind.values().length]; canPossiblyReturn[FrameKind.OBJECT.ordinal()] = true; + Set possiblePrimitiveReturns = new HashSet<>(); + boolean isAlwaysBoxed = true; + for (ExecutableElement fun : operationFunctions) { MethodProperties props2 = processMethod(data, fun); props2.checkMatches(data, props); data.getThrowDeclarations().addAll(fun.getThrownTypes()); + if (ElementUtils.isObject(fun.getReturnType())) { + // object => all primitives could potentially be returned (boxed) for (int i = 0; i < canPossiblyReturn.length; i++) { canPossiblyReturn[i] = true; + possiblePrimitiveReturns.addAll(parentData.getOperationsContext().getPrimitiveBoxingKinds()); + } + } else if (parentData.getBoxingEliminatedTypes().contains(fun.getReturnType().getKind())) { + isAlwaysBoxed = false; + FrameKind kind = FrameKind.valueOfWithBoxing(fun.getReturnType().getKind()); + canPossiblyReturn[kind.ordinal()] = true; + if (kind != FrameKind.OBJECT && !possiblePrimitiveReturns.contains(kind)) { + possiblePrimitiveReturns.add(kind); } - } else { - canPossiblyReturn[FrameKind.valueOfWithBoxing(fun.getReturnType().getKind()).ordinal()] = true; } } + data.setPossiblePrimitiveTypes(possiblePrimitiveReturns.stream().collect(Collectors.toList())); + data.setAlwaysBoxed(isAlwaysBoxed); + if (isShortCircuit && (props.numStackValues != 1 || props.isVariadic || !props.returnsValue)) { data.addError("Boolean converter must take exactly one argument, not be variadic, and return a value"); } @@ -270,6 +281,8 @@ protected SingleOperationData parse(Element element, List mirr clonedType.add(createExecuteMethod(props, "execute", context.getType(boolean.class), false)); } else if (!props.returnsValue) { clonedType.add(createExecuteMethod(props, "execute", context.getType(void.class), false)); + } else if (isAlwaysBoxed) { + clonedType.add(createExecuteMethod(props, "execute", context.getType(Object.class), false)); } else { for (FrameKind kind : parentData.getFrameKinds()) { if (canPossiblyReturn[kind.ordinal()]) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index ef66a55970f7..113ee5c93da2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -166,12 +166,26 @@ private void addLocalRefs(CodeTreeBuilder b, ExecutionVariables vars) { @Override public boolean splitOnBoxingElimination() { - return data.getMainProperties().returnsValue; + return !data.isAlwaysBoxed() && data.getMainProperties().returnsValue; + } + + @Override + public boolean alwaysBoxed() { + return data.isAlwaysBoxed(); + } + + @Override + public List getBoxingEliminationSplits() { + List result = new ArrayList<>(); + result.add(FrameKind.OBJECT); + result.addAll(data.getPossiblePrimitiveTypes()); + + return result; } private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - String exName = getUniqueName() + "_entryPoint_" + (uncached ? "uncached" : ctx.hasBoxingElimination() ? vars.specializedKind : ""); + String exName = getUniqueName() + "_entryPoint_" + (uncached ? "uncached" : (!alwaysBoxed() && ctx.hasBoxingElimination() ? vars.specializedKind : "")); OperationGeneratorUtils.createHelperMethod(ctx.outerType, exName, () -> { CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), exName); el.getParameters().addAll(executeMethods[0].getParameters()); @@ -186,9 +200,13 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.declaration("int", "destSlot", "$sp - " + data.getMainProperties().numStackValues); } - if (!uncached && ctx.hasBoxingElimination()) { + if (!uncached && ctx.hasBoxingElimination() && !alwaysBoxed()) { int i = ctx.getBoxingKinds().indexOf(vars.specializedKind); + if (i == -1) { + throw new AssertionError("kind=" + vars.specializedKind + " name=" + name + "bk=" + ctx.getBoxingKinds()); + } + boolean needsUnexpectedResult = executeMethods[i] != null && executeMethods[i].getThrownTypes().size() > 0; if (needsUnexpectedResult) { @@ -302,11 +320,18 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } b.end(2); - b.startAssign(vars.sp).variable(vars.sp).string(" - " + data.getMainProperties().numStackValues + " + " + numPushedValues); - if (isVariadic()) { - b.string(" - numVariadics + 1"); + int stackDelta = numPushedValues - data.getMainProperties().numStackValues + (isVariadic() ? 1 : 0); + + if (isVariadic() || stackDelta != 0) { + b.startStatement().variable(vars.sp).string(" += "); + if (stackDelta != 0) { + b.string("" + stackDelta); + } + if (isVariadic()) { + b.string(" - numVariadics"); + } + b.end(); } - b.end(); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index f85a0fc9416a..b55e30ef681d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -379,6 +379,14 @@ public boolean splitOnBoxingElimination() { return false; } + public boolean alwaysBoxed() { + throw new AssertionError(name); + } + + public List getBoxingEliminationSplits() { + return ctx.getBoxingKinds(); + } + public boolean hasGeneric() { return false; } @@ -436,6 +444,7 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) b.startCall("doBeforeEmitInstruction"); b.tree(numPop); b.string(numPushedValues == 0 ? "false" : "true"); + b.string(numPushedValues > 0 && !alwaysBoxed() ? "true" : "false"); b.end(2); // emit opcode @@ -582,6 +591,11 @@ public String dumpInfo() { if (isVariadic) { sb.append(" Variadic\n"); } + if (numPushedValues > 0 && alwaysBoxed()) { + sb.append(" Always Boxed\n"); + } else if (splitOnBoxingElimination()) { + sb.append(" Split on Boxing Elimination\n"); + } sb.append(" Pushed Values: ").append(numPushedValues).append("\n"); printList(sb, branchTargets, "Branch Targets"); printList(sb, branchProfiles, "Branch Profiles"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 0916f581b595..432fb9e6fc56 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -67,43 +67,11 @@ private CodeTree createGetValue(ExecutionVariables vars) { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration("Object", "value", createGetValue(vars)); - - if (ctx.hasBoxingElimination()) { - FrameKind kind = vars.specializedKind; - if (kind == FrameKind.OBJECT) { - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - } else { - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - // { - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("(", kind.getTypeName(), ") value"); - b.end(2); - // } - b.end().startElseBlock(); - // { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - // } - b.end(); - } - } else { - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - } + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.tree(createGetValue(vars)); + b.end(2); b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); @@ -116,7 +84,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod } @Override - public boolean splitOnBoxingElimination() { + public boolean alwaysBoxed() { return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index f7ebeb412117..631f3e6adc29 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -40,17 +40,9 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; -import java.util.EnumSet; - -import javax.lang.model.element.Modifier; - import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadConstantInstruction extends Instruction { @@ -63,52 +55,17 @@ public LoadConstantInstruction(OperationsContext ctx, int id) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - String helperName = "do_loadConstant_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); - - OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { - CodeExecutableElement metImpl = new CodeExecutableElement( - EnumSet.of(Modifier.PRIVATE, Modifier.STATIC), - context.getType(void.class), - helperName); - - metImpl.addParameter(vars.stackFrame); - metImpl.addParameter(vars.bc); - metImpl.addParameter(vars.bci); - metImpl.addParameter(vars.sp); - metImpl.addParameter(vars.consts); - - CodeTreeBuilder b = metImpl.getBuilder(); - - if (ctx.hasBoxingElimination()) { - b.startStatement().startCall("UFA", "unsafeSet" + vars.specializedKind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetArgument(vars, vars.specializedKind)); - b.end(2); - b.end(); - } else { - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetArgument(vars, FrameKind.OBJECT)); - b.end(2); - } - - return metImpl; - }); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - CodeTreeBuilder bOuter = CodeTreeBuilder.createBuilder(); - bOuter.startStatement().startCall(helperName); - bOuter.variable(vars.stackFrame); - bOuter.variable(vars.bc); - bOuter.variable(vars.bci); - bOuter.variable(vars.sp); - bOuter.variable(vars.consts); - bOuter.end(2); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.variable(vars.sp); + b.tree(createGetArgument(vars, FrameKind.OBJECT)); + b.end(2); - bOuter.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); + b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); - return bOuter.build(); + return b.build(); } @@ -132,7 +89,7 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod } @Override - public boolean splitOnBoxingElimination() { + public boolean alwaysBoxed() { return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 152c9c9d161c..7d1fc1526e37 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -40,9 +40,11 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import java.util.List; import java.util.Set; import javax.lang.model.element.Modifier; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -55,14 +57,18 @@ public class LoadLocalInstruction extends Instruction { - public LoadLocalInstruction(OperationsContext ctx, int id) { - super(ctx, "load.local", id, 1); + private final boolean boxed; + + public LoadLocalInstruction(OperationsContext ctx, int id, boolean boxed) { + super(ctx, "load.local" + (boxed ? ".boxed" : ""), id, 1); + this.boxed = boxed; addLocal("local"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - String helperName = "do_loadLocal_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); + + String helperName = "do_loadLocal" + (boxed ? "Boxed" : "") + "_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), helperName); @@ -121,25 +127,49 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); b.variable(vars.stackFrame); b.variable(vars.sp); - b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + + b.startGroup(); + if (boxed) { + b.string("(", kind.getTypeName() + ") "); + b.startCall("UFA", "unsafeGetObject"); + } else { + b.startCall("UFA", "unsafeGet" + kind.getFrameName()); + } b.variable(vars.localFrame); b.string("localIdx"); - b.end(); + b.end(2); + b.end(2); if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + kind + "%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + kind + " boxed=" + boxed + "%n\", localIdx, $frame.getValue(localIdx))"); } b.returnStatement(); - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + if (boxed) { + b.end().startCatchBlock(new TypeMirror[]{types.FrameSlotTypeException, context.getType(ClassCastException.class)}, "ex"); + } else { + b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); + } b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); b.startIf().string("result instanceof " + kind.getTypeNameBoxed()).end().startBlock(); + b.startIf().startCall("UFA", "unsafeByteArrayRead").string("localTags").string("localIdx").end().string(" == 7").end().startBlock(); + + if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { + b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + " (boxed)%n\", localIdx, $frame.getValue(localIdx))"); + } + + b.tree(OperationGeneratorUtils.createWriteOpcode( + vars.bc, vars.bci, + "(short) (" + ctx.loadLocalBoxed.opcodeIdField.getName() + " | (" + kind.toOrdinal() + " << 13))")); + + b.end().startElseBlock(); + if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + "%n\", localIdx, $frame.getValue(localIdx))"); } @@ -154,15 +184,16 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()).variable(vars.stackFrame).variable(vars.sp).string("(", kind.getTypeName(), ") result").end(2); b.returnStatement(); - b.end(); - b.end(); + b.end(); // if tag + b.end(); // if instanceof + b.end(); // try } if (kind != FrameKind.OBJECT) { b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=" + kind + "->OBJECT%n\", localIdx, $frame.getValue(localIdx))"); + b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=" + kind + "->OBJECT boxed=" + boxed + "%n\", localIdx, $frame.getValue(localIdx))"); } b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); @@ -174,7 +205,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.localFrame).string("localIdx").string("result").end(2); b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.stackFrame).variable(vars.sp).string("result").end(2); } - } else { if (ctx.getData().enableYield) { b.startStatement().startCall("UFA", "unsafeCopyTo"); @@ -236,4 +266,18 @@ public boolean splitOnBoxingElimination() { return true; } + @Override + public List getBoxingEliminationSplits() { + if (boxed) { + return ctx.getPrimitiveBoxingKinds(); + } else { + return ctx.getBoxingKinds(); + } + } + + @Override + public boolean alwaysBoxed() { + return boxed; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java similarity index 81% rename from truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java rename to truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java index 13b8650dfb93..7f4411951063 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadNonlocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java @@ -4,10 +4,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationsContext; -public class LoadNonlocalInstruction extends Instruction { +public class LoadLocalMaterializedInstruction extends Instruction { - public LoadNonlocalInstruction(OperationsContext ctx, int id) { - super(ctx, "load.nonlocal", id, 1); + public LoadLocalMaterializedInstruction(OperationsContext ctx, int id) { + super(ctx, "load.local.mat", id, 1); addPopSimple("frame"); addArgument("index"); } @@ -39,4 +39,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } + @Override + public boolean alwaysBoxed() { + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 308a5cc89c65..7c9e34aee997 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -101,5 +101,4 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { public boolean isBranchInstruction() { return true; } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 2fc1c8675ac2..be12a0783fd1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -92,8 +92,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.declaration("byte", "curKind", "UFA.unsafeByteArrayRead(localTags, localIdx)"); + b.declaration("int", "bciOffset", createPopIndexedIndex(vars, 0, false)); + b.statement("// System.err.printf(\"primitiveTag=%d value=%s %s curKind=%s tag=%s%n\", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot))"); + b.startIf().string("bciOffset != 0").end().startBlock(); + for (FrameKind primKind : ctx.getPrimitiveBoxingKinds()) { // todo: use implicit conversions here @@ -129,9 +133,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->OBJECT%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); } + createBoxingEliminateChild(vars, b, "0 /* OBJECT */"); + + b.end(); + createSetFrameDescriptorKind(vars, b, "7 /* generic */"); createSetPrimitiveTag(vars, b, "7 /* generic */"); - createBoxingEliminateChild(vars, b, "0 /* OBJECT */"); b.startStatement().startCall("UFA", "unsafeSetObject"); b.variable(vars.localFrame); @@ -139,6 +146,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("value"); b.end(2); + if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { + b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->GENERIC%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); + } + return ex; }); } @@ -215,7 +226,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2); if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=OBJECT%n\", localIdx, $frame.getValue(sourceSlot))"); + b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=GENERIC%n\", localIdx, $frame.getValue(sourceSlot))"); } b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); @@ -309,8 +320,8 @@ private void createSetPrimitiveTag(ExecutionVariables vars, CodeTreeBuilder b, S b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, "(short) ((" + tag + " << 13) | " + opcodeIdField.getName() + ")")); } - private void createBoxingEliminateChild(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.tree(OperationGeneratorUtils.callSetResultBoxed(createPopIndexedIndex(vars, 0, false), CodeTreeBuilder.singleString(tag))); + private static void createBoxingEliminateChild(ExecutionVariables vars, CodeTreeBuilder b, String tag) { + b.tree(OperationGeneratorUtils.callSetResultBoxed(CodeTreeBuilder.singleString("bciOffset"), CodeTreeBuilder.singleString(tag))); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java similarity index 86% rename from truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java rename to truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java index 742f43cd4b18..5e722aea87f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreNonlocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java @@ -4,10 +4,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationsContext; -public class StoreNonlocalInstruction extends Instruction { +public class StoreLocalMaterializedInstruction extends Instruction { - public StoreNonlocalInstruction(OperationsContext ctx, int id) { - super(ctx, "store.nonlocal", id, 0); + public StoreLocalMaterializedInstruction(OperationsContext ctx, int id) { + super(ctx, "store.local.mat", id, 0); addPopSimple("frame"); addPopSimple("value"); addArgument("index"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index 832af9747f28..eeabe2aa84fc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -68,4 +68,9 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod return null; } + @Override + public boolean alwaysBoxed() { + return true; + } + } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 3449911775eb..bb8bdae42785 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -178,7 +178,7 @@ public Void visitFunction(FunctionContext ctx) { b.endTag(); b.beginReturn(); - b.emitConstObject(SLNull.SINGLETON); + b.emitLoadConstant(SLNull.SINGLETON); b.endReturn(); b.endTag(); @@ -317,7 +317,7 @@ public Void visitReturn_statement(Return_statementContext ctx) { b.beginReturn(); if (ctx.expression() == null) { - b.emitConstObject(SLNull.SINGLETON); + b.emitLoadConstant(SLNull.SINGLETON); } else { visit(ctx.expression()); } @@ -531,7 +531,7 @@ private void buildMemberExpressionRead(Token ident, List Date: Fri, 7 Oct 2022 12:53:42 +0200 Subject: [PATCH 146/312] [wip] cleanup --- .../truffle/api/operation/LocalSetter.java | 14 +- .../truffle/api/operation/OperationNodes.java | 8 +- .../api/operation/OperationRootNode.java | 2 + .../serialization/ByteBufferDataInput.java | 178 ++++++++++++++++++ .../serialization/OperationDeserializer.java | 6 +- .../serialization/OperationSerializer.java | 6 +- .../operations/OperationsCodeGenerator.java | 35 ++-- .../com/oracle/truffle/sl/SLException.java | 3 - .../operations/SLOperationSerialization.java | 27 ++- .../sl/parser/SLOperationsVisitor.java | 8 +- 10 files changed, 229 insertions(+), 58 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java index 41217c355736..b138d83f3dd0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/LocalSetter.java @@ -91,21 +91,9 @@ static void setObject(VirtualFrame frame, int index, Object value) { frame.setObject(index, value); } + @SuppressWarnings("unused") private static boolean checkFrameSlot(VirtualFrame frame, int index, FrameSlotKind target) { return false; - // FrameDescriptor descriptor = frame.getFrameDescriptor(); - // FrameSlotKind slotKind = descriptor.getSlotKind(index); - // if (slotKind == FrameSlotKind.Illegal) { - // descriptor.setSlotKind(index, target); - // return true; - // } else if (slotKind == target) { - // return true; - // } else if (slotKind == FrameSlotKind.Object) { - // return false; - // } else { - // descriptor.setSlotKind(index, FrameSlotKind.Object); - // return false; - // } } static void setLong(VirtualFrame frame, int index, long value) { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 21e261459b5b..68b4ee3e9c94 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -51,9 +51,9 @@ import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.source.Source; -public abstract class OperationNodes { +public abstract class OperationNodes { protected final OperationParser parse; - @CompilationFinal(dimensions = 1) protected OperationRootNode[] nodes; + @CompilationFinal(dimensions = 1) protected NodeType[] nodes; @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; @@ -62,8 +62,8 @@ protected OperationNodes(OperationParser parse) { } @SuppressWarnings({"unchecked", "cast", "rawtypes"}) - public List getNodes() { - return (List) (List) List.of(nodes); + public List getNodes() { + return List.of(nodes); } public boolean hasSources() { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index 6ce8ffc7c8b5..b26c73955b6d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -63,9 +63,11 @@ static void setMetadataAccessor(MetadataKey key, Function n ? buffer.remaining() : n; + buffer.position(buffer.position() + skip); + return skip; + } + + public boolean readBoolean() throws IOException { + try { + return buffer.get() != 0; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public byte readByte() throws IOException { + try { + return buffer.get(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readUnsignedByte() throws IOException { + try { + return buffer.get() & 0xff; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public short readShort() throws IOException { + try { + return buffer.getShort(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readUnsignedShort() throws IOException { + try { + return buffer.getShort() & 0xffff; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public char readChar() throws IOException { + try { + return buffer.getChar(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readInt() throws IOException { + try { + return buffer.getInt(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public long readLong() throws IOException { + try { + return buffer.getLong(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public float readFloat() throws IOException { + try { + return buffer.getFloat(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public double readDouble() throws IOException { + try { + return buffer.getDouble(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + /** + * Reads the next line of text from the input stream. It reads successive bytes, converting + * each byte separately into a character, until it encounters a line terminator or end of + * file; the characters read are then returned as a {@code String}. Note that because this + * method processes bytes, it does not support input of the full Unicode character set. + *

+ * If end of file is encountered before even one byte can be read, then {@code null} is + * returned. Otherwise, each byte that is read is converted to type {@code char} by + * zero-extension. If the character {@code '\n'} is encountered, it is discarded and reading + * ceases. If the character {@code '\r'} is encountered, it is discarded and, if the + * following byte converts to the character {@code '\n'}, then that is discarded also; + * reading then ceases. If end of file is encountered before either of the characters + * {@code '\n'} and {@code '\r'} is encountered, reading ceases. Once reading has ceased, a + * {@code String} is returned that contains all the characters read and not discarded, taken + * in order. Note that every character in this string will have a value less than + * {@code \u005Cu0100}, that is, {@code (char)256}. + * + * @return the next line of text from the input stream, or {@code null} if the end of file + * is encountered before a byte can be read. + * @exception IOException if an I/O error occurs. + */ + public String readLine() throws IOException { + int remaining = buffer.remaining(); + if (remaining == 0) { + return null; + } + + StringBuilder sb = new StringBuilder(); + while (remaining > 0) { + char c = (char) buffer.get(); + if (c == '\r') { + if (remaining > 1 && (char) buffer.get() != '\n') { + buffer.position(buffer.position() - 1); + } + break; + } else if (c == '\n') { + break; + } else { + sb.append(c); + remaining--; + } + } + + return sb.toString(); + } + + public String readUTF() throws IOException { + return DataInputStream.readUTF(this); + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java index 2972ace7dcbe..5a2b4eaef343 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java @@ -40,15 +40,15 @@ */ package com.oracle.truffle.api.operation.serialization; +import java.io.DataInput; import java.io.IOException; -import java.nio.ByteBuffer; import com.oracle.truffle.api.operation.OperationRootNode; public interface OperationDeserializer { interface DeserializerContext { - OperationRootNode deserializeOperationNode(ByteBuffer buffer) throws IOException; + OperationRootNode deserializeOperationNode(DataInput buffer) throws IOException; } - Object deserialize(DeserializerContext context, ByteBuffer buffer) throws IOException; + Object deserialize(DeserializerContext context, DataInput buffer) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java index 32e880710ae6..c0492e7fc88c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java @@ -40,7 +40,7 @@ */ package com.oracle.truffle.api.operation.serialization; -import java.io.DataOutputStream; +import java.io.DataOutput; import java.io.IOException; import com.oracle.truffle.api.operation.OperationRootNode; @@ -48,8 +48,8 @@ @FunctionalInterface public interface OperationSerializer { interface SerializerContext { - void serializeOperationNode(DataOutputStream buffer, OperationRootNode node) throws IOException; + void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException; } - void serialize(SerializerContext context, DataOutputStream buffer, Object object) throws IOException; + void serialize(SerializerContext context, DataOutput buffer, Object object) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index a688023c2be4..556bc3de39d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -40,7 +40,8 @@ */ package com.oracle.truffle.dsl.processor.operations; -import java.io.DataOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.IOError; import java.io.IOException; import java.io.PrintWriter; @@ -52,7 +53,6 @@ import java.util.Set; import java.util.concurrent.locks.Lock; -import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -116,14 +116,17 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory DATA_INPUT_CLASS = ByteBuffer.class; - private static final Class DATA_OUTPUT_CLASS = DataOutputStream.class; + private static final Class DATA_INPUT_WRAP_CLASS = DataInput.class; + private static final Class DATA_OUTPUT_CLASS = DataOutput.class; + private static final String DATA_READ_METHOD_PREFIX = "get"; private static final String DATA_WRITE_METHOD_PREFIX = "write"; private static final TypeMirror TYPE_UNSAFE = new GeneratedTypeMirror("sun.misc", "Unsafe"); CodeTypeElement createOperationNodes() { - CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, types.OperationNodes); + CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, + generic(types.OperationNodes, m.getTemplateType().asType())); typOperationNodes.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationNodes)); typOperationNodes.add(createOperationNodedsReparse()); @@ -138,7 +141,7 @@ CodeTypeElement createOperationNodes() { typOperationNodes.add(mGetSources); CodeExecutableElement mSetNodes = new CodeExecutableElement(context.getType(void.class), "setNodes"); - mSetNodes.addParameter(new CodeVariableElement(arrayOf(types.OperationRootNode), "nodes")); + mSetNodes.addParameter(new CodeVariableElement(arrayOf(m.getTemplateType().asType()), "nodes")); mSetNodes.createBuilder().statement("this.nodes = nodes"); typOperationNodes.add(mSetNodes); @@ -184,7 +187,8 @@ private CodeExecutableElement createDeserializeMethod() { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "input"); CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer"), "callback"); - CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "deserialize", parLanguage, parConfig, parBuffer, parCallback); + CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, generic(types.OperationNodes, m.getTemplateType().asType()), "deserialize", parLanguage, parConfig, parBuffer, + parCallback); met.addThrownType(context.getType(IOException.class)); @@ -254,7 +258,7 @@ private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); - CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, types.OperationNodes, "create"); + CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, generic(types.OperationNodes, m.getTemplateType().asType()), "create"); metCreate.addParameter(parConfig); metCreate.addParameter(parParser); @@ -1139,6 +1143,9 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.statement("ArrayList labels = new ArrayList<>()"); b.statement("ArrayList<" + m.getTemplateType().getSimpleName() + "> builtNodes = new ArrayList<>()"); + b.statement("buffer.rewind()"); + b.declaration(context.getType(DATA_INPUT_WRAP_CLASS), "dataInput", "com.oracle.truffle.api.operation.serialization.ByteBufferDataInput.createDataInput(buffer)"); + TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext"); b.startStatement(); @@ -1146,8 +1153,8 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.string(" context = ").startNew(deserContext).end().startBlock(); b.string("@Override").newLine(); - b.string("public " + m.getTemplateType().getSimpleName() + " deserializeOperationNode(").type(context.getType(DATA_INPUT_CLASS)).string(" buffer) throws IOException ").startBlock(); - b.statement("return builtNodes.get(buffer." + DATA_READ_METHOD_PREFIX + "Int())"); + b.string("public " + m.getTemplateType().getSimpleName() + " deserializeOperationNode(").type(context.getType(DATA_INPUT_WRAP_CLASS)).string(" buffer) throws IOException ").startBlock(); + b.statement("return builtNodes.get(buffer.readInt())"); b.end(); b.end(2); @@ -1166,7 +1173,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.end(); b.startCase().string("" + SER_CODE_CREATE_OBJECT).end().startBlock(); - b.statement("consts.add(callback.deserialize(context, buffer))"); + b.statement("consts.add(callback.deserialize(context, dataInput))"); b.statement("break"); b.end(); @@ -1183,7 +1190,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.startCase().string("" + i).end().startCaseBlock(); b.startStatement().startCall("builder", "set" + metadata.getName()); b.startGroup().maybeCast(context.getType(Object.class), metadata.getType()); - b.string("callback.deserialize(context, buffer)"); + b.string("callback.deserialize(context, dataInput)"); b.end(3); b.statement("break"); b.end(); @@ -2432,6 +2439,10 @@ private static TypeMirror generic(TypeElement el, TypeMirror... args) { return new DeclaredCodeTypeMirror(el, List.of(args)); } + private static TypeMirror generic(DeclaredType el, TypeMirror... args) { + return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args)); + } + private static TypeMirror generic(Class cls, TypeMirror... args) { return generic(ProcessorContext.getInstance().getTypeElement(cls), args); } @@ -2658,7 +2669,7 @@ private CodeExecutableElement createBuilderImplFinish() { b.end(); b.startIf().string("!isReparse").end().startBlock(); - b.statement("nodes.setNodes(builtNodes.toArray(new OperationRootNode[0]))"); + b.statement("nodes.setNodes(builtNodes.toArray(new " + m.getTemplateType().getSimpleName() + "[0]))"); b.end(); return mFinish; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 0938ef9f6259..0c014ba1d350 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -60,18 +60,15 @@ public class SLException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -6799734410727348507L; private static final InteropLibrary UNCACHED_LIB = InteropLibrary.getFactory().getUncached(); - private final int bci; @TruffleBoundary public SLException(String message, Node location, int bci) { super(message, location, bci); - this.bci = bci; } @TruffleBoundary public SLException(String message, Node location) { super(message, location, -1); - this.bci = -1; } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java index 0acf4da3ad0e..1e7a574d2dac 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -41,6 +41,8 @@ package com.oracle.truffle.sl.operations; import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.DataOutputStream; import java.io.IOException; import java.math.BigInteger; @@ -48,9 +50,6 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; -import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -66,7 +65,7 @@ public class SLOperationSerialization { private static final byte CODE_CLASS = 4; private static final byte CODE_BIG_INT = 5; - public static byte[] serializeNodes(OperationNodes nodes) throws IOException { + public static byte[] serializeNodes(OperationNodes nodes) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream); @@ -99,34 +98,32 @@ public static byte[] serializeNodes(OperationNodes nodes) throws IOException { return byteArrayOutputStream.toByteArray(); } - private static byte[] readByteArray(ByteBuffer buffer) { - int len = buffer.getInt(); + private static byte[] readByteArray(DataInput buffer) throws IOException { + int len = buffer.readInt(); byte[] dest = new byte[len]; - buffer.get(dest); + buffer.readFully(dest); return dest; } - private static void writeByteArray(DataOutputStream buffer, byte[] data) throws IOException { + private static void writeByteArray(DataOutput buffer, byte[] data) throws IOException { buffer.writeInt(data.length); buffer.write(data); } - public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException { + public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException { ByteBuffer buf = ByteBuffer.wrap(inputData); return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, (context, buffer) -> { byte tag; - switch (tag = buffer.get()) { + switch (tag = buffer.readByte()) { case CODE_SL_NULL: return SLNull.SINGLETON; - case CODE_STRING: { + case CODE_STRING: return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); - } case CODE_LONG: - return buffer.getLong(); - case CODE_BIG_INT: { + return buffer.readLong(); + case CODE_BIG_INT: return new SLBigNumber(new BigInteger(readByteArray(buffer))); - } case CODE_SOURCE: { String name = new String(readByteArray(buffer)); return Source.newBuilder(SLLanguage.ID, "", name).build(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index bb8bdae42785..f0ad6983be79 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -54,11 +54,9 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.debug.DebuggerTags; import com.oracle.truffle.api.instrumentation.StandardTags; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; @@ -99,7 +97,7 @@ public final class SLOperationsVisitor extends SLBaseVisitor { private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { - OperationNodes nodes = SLOperationRootNodeGen.create(OperationConfig.DEFAULT, builder -> { + var nodes = SLOperationRootNodeGen.create(OperationConfig.DEFAULT, builder -> { SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, builder); parseSLImpl(source, visitor); }); @@ -113,9 +111,9 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Fri, 7 Oct 2022 17:43:35 +0200 Subject: [PATCH 147/312] [wip] visibility check --- .../operations/OperationGeneratorUtils.java | 27 +++++++++- .../operations/OperationsCodeGenerator.java | 49 ++++++++++--------- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index c4f3b4a51e1f..533ba1434157 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -45,11 +45,12 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; +import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; @@ -260,4 +261,28 @@ public static void createHelperMethod(CodeTypeElement element, String name, Supp element.add(ex); } } + + public static void checkAccessibility(Element el) { + checkAccessibility(el, ""); + } + + private static void checkAccessibility(Element el, String namePrefix) { + Set mods = el.getModifiers(); + + if (mods.contains(Modifier.PRIVATE) || el.getSimpleName().toString().equals("")) { + return; + } + + if (mods.contains(Modifier.PUBLIC) || mods.contains(Modifier.PROTECTED)) { + List els = el.getEnclosedElements(); + if (els != null) { + for (Element cel : els) { + checkAccessibility(cel, namePrefix + el.getSimpleName() + "."); + } + } + return; + } + + throw new AssertionError(namePrefix + el.getSimpleName() + " must not be package-protected"); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 556bc3de39d3..9cb6e2eac360 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -316,7 +316,7 @@ private CodeTypeElement createOperationSerNodeImpl() { private CodeVariableElement createSerializationContext() { DeclaredType typeContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext"); - CodeVariableElement fld = new CodeVariableElement(typeContext, "SER_CONTEXT"); + CodeVariableElement fld = new CodeVariableElement(MOD_PRIVATE, typeContext, "SER_CONTEXT"); CodeTreeBuilder b = fld.createInitBuilder(); b.startNew(typeContext).end().string(" ").startBlock(); @@ -363,20 +363,20 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getDeclaredType("com.oracle.truffle.api.impl.UnsafeFrameAccess"), "UFA = UnsafeFrameAccess.lookup()")); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME), "nodes"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(short[].class), "_bc"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(Object[].class), "_consts"))); - typOperationNodeImpl.add(children(new CodeVariableElement(arrayOf(types.Node), "_children"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME), "nodes"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "_bc"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_consts"))); + typOperationNodeImpl.add(children(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.Node), "_children"))); if (m.getOperationsContext().hasBoxingElimination()) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(byte[].class), "_localTags"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(byte[].class), "_localTags"))); } - typOperationNodeImpl.add(compFinal(new CodeVariableElement(arrayOf(typExceptionHandler.asType()), "_handlers"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "_conditionProfiles"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxLocals"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "_maxStack"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int[].class), "sourceInfo"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(typExceptionHandler.asType()), "_handlers"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "_conditionProfiles"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxLocals"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxStack"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "sourceInfo"))); if (m.enableYield) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(arrayOf(new GeneratedTypeMirror("", "ContinuationRoot")), "yieldEntries"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationRoot")), "yieldEntries"))); } CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); @@ -384,7 +384,7 @@ CodeTypeElement createOperationNodeImpl() { fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); typOperationNodeImpl.add(fldSwitchImpl); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "uncachedExecuteCount = 16"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "uncachedExecuteCount = 16"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); @@ -692,7 +692,7 @@ private CodeExecutableElement createUnsafeWriteBytecode() { } private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) { - CodeExecutableElement met = new CodeExecutableElement(context.getType(void.class), "changeInterpreters"); + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "changeInterpreters"); met.addParameter(new CodeVariableElement(loopBase.asType(), "impl")); CodeTreeBuilder b = met.createBuilder(); @@ -1045,9 +1045,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typOperationNodeImpl.asType())), "builtNodes")); - CodeVariableElement fldOperationData = new CodeVariableElement(opDataImpl.asType(), "operationData"); + CodeVariableElement fldOperationData = new CodeVariableElement(MOD_PRIVATE, opDataImpl.asType(), "operationData"); - CodeVariableElement fldBc = new CodeVariableElement(arrayOf(context.getType(byte.class)), "bc"); + CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE, arrayOf(context.getType(byte.class)), "bc"); CodeVariableElement fldIndent = null; if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { @@ -1055,9 +1055,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(fldIndent); } - CodeVariableElement fldBci = new CodeVariableElement(context.getType(int.class), "bci"); + CodeVariableElement fldBci = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "bci"); - CodeVariableElement fldLastPush = new CodeVariableElement(context.getType(int.class), "lastChildPush"); + CodeVariableElement fldLastPush = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "lastChildPush"); typBuilderImpl.add(fldLastPush); BuilderVariables vars = new BuilderVariables(); @@ -1101,7 +1101,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, } private CodeTypeElement createBuilderState(CodeTypeElement typBuilder, String... fields) { - CodeTypeElement typ = new CodeTypeElement(MOD_FINAL, ElementKind.CLASS, null, "BuilderState"); + CodeTypeElement typ = new CodeTypeElement(MOD_PRIVATE_FINAL, ElementKind.CLASS, null, "BuilderState"); typ.add(new CodeVariableElement(typ.asType(), "parentData")); ArrayList foundFields = new ArrayList<>(); @@ -1510,7 +1510,7 @@ private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBu @SuppressWarnings("static-method") private CodeExecutableElement createBuilderImplCreateParentLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { - CodeExecutableElement mCreateLocal = new CodeExecutableElement(typLocalData.asType(), "createParentLocal"); + CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PRIVATE, typLocalData.asType(), "createParentLocal"); mCreateLocal.createBuilder().startReturn().startNew(typLocalData.asType()).string("operationData.parent").string("numLocals++").end(2); return mCreateLocal; } @@ -2321,7 +2321,7 @@ private CodeExecutableElement createBuilderImplLabelPass(CodeTypeElement typFtc) } private CodeExecutableElement createAfterChild(BuilderVariables vars) { - CodeExecutableElement mAfterChild = new CodeExecutableElement(context.getType(void.class), "doAfterChild"); + CodeExecutableElement mAfterChild = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doAfterChild"); CodeTreeBuilder b = mAfterChild.getBuilder(); GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); @@ -2356,7 +2356,7 @@ private CodeExecutableElement createAfterChild(BuilderVariables vars) { } private CodeExecutableElement createBeforeChild(BuilderVariables vars) { - CodeExecutableElement mBeforeChild = new CodeExecutableElement(context.getType(void.class), "doBeforeChild"); + CodeExecutableElement mBeforeChild = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doBeforeChild"); CodeTreeBuilder b = mBeforeChild.getBuilder(); GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); @@ -2456,7 +2456,10 @@ public List create(ProcessorContext context, AnnotationProcesso String simpleName = m.getTemplateType().getSimpleName() + "Gen"; try { - return List.of(createOperationNodeImpl()); + CodeTypeElement el = createOperationNodeImpl(); + OperationGeneratorUtils.checkAccessibility(el); + return List.of(el); + } catch (Throwable e) { CodeTypeElement el = GeneratorUtils.createClass(m, null, Set.of(), simpleName, null); CodeTreeBuilder b = el.createDocBuilder(); From 8feb89902b8ee5047fed6c707b08e431f78b5b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 7 Oct 2022 18:22:09 +0200 Subject: [PATCH 148/312] [wip] toString & make ctor optional --- .../truffle/api/operation/OperationNodes.java | 6 ++++ .../truffle/dsl/processor/TruffleTypes.java | 2 ++ .../operations/OperationsCodeGenerator.java | 29 +++++++++++++------ .../processor/operations/OperationsData.java | 4 +++ .../operations/OperationsParser.java | 23 +++------------ .../sl/operations/SLOperationRootNode.java | 4 --- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 68b4ee3e9c94..4942d461820c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -42,6 +42,7 @@ import java.io.DataOutputStream; import java.io.IOException; +import java.util.Arrays; import java.util.List; import com.oracle.truffle.api.CompilerAsserts; @@ -61,6 +62,11 @@ protected OperationNodes(OperationParser parse) { this.parse = parse; } + @Override + public String toString() { + return String.format("OperationNodes %s", Arrays.toString(nodes)); + } + @SuppressWarnings({"unchecked", "cast", "rawtypes"}) public List getNodes() { return List.of(nodes); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 5e7e9365e3bd..907a8e5b196f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -87,6 +87,7 @@ public class TruffleTypes { public static final String ExplodeLoop_Name = "com.oracle.truffle.api.nodes.ExplodeLoop"; public static final String Frame_Name = "com.oracle.truffle.api.frame.Frame"; public static final String FrameDescriptor_Name = "com.oracle.truffle.api.frame.FrameDescriptor"; + public static final String FrameDescriptor_Builder_Name = "com.oracle.truffle.api.frame.FrameDescriptor.Builder"; public static final String FrameSlotKind_Name = "com.oracle.truffle.api.frame.FrameSlotKind"; public static final String FrameSlotTypeException_Name = "com.oracle.truffle.api.frame.FrameSlotTypeException"; public static final String FinalBitSet_Name = "com.oracle.truffle.api.utilities.FinalBitSet"; @@ -127,6 +128,7 @@ public class TruffleTypes { public final DeclaredType ExplodeLoop = c.getDeclaredType(ExplodeLoop_Name); public final DeclaredType Frame = c.getDeclaredType(Frame_Name); public final DeclaredType FrameDescriptor = c.getDeclaredType(FrameDescriptor_Name); + public final DeclaredType FrameDescriptor_Builder = c.getDeclaredType(FrameDescriptor_Builder_Name); public final DeclaredType FrameSlotKind = c.getDeclaredType(FrameSlotKind_Name); public final DeclaredType FrameSlotTypeException = c.getDeclaredType(FrameSlotTypeException_Name); public final DeclaredType FinalBitSet = c.getDeclaredType(FinalBitSet_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 9cb6e2eac360..55aacb53e7b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -301,9 +301,7 @@ private static CodeVariableElement children(CodeVariableElement el) { private CodeTypeElement createOperationSerNodeImpl() { CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerNodeImpl", m.getTemplateType().asType()); typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); - for (ExecutableElement el : ElementFilter.constructorsIn(m.getTemplateType().getEnclosedElements())) { - typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl, el)); - } + typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl, m.fdConstructor)); for (String methodName : new String[]{"dump", "execute", "getSourceSectionAtBci"}) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, methodName); @@ -347,11 +345,24 @@ CodeTypeElement createOperationNodeImpl() { CodeTypeElement typBytecodeBase = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); typOperationNodeImpl.add(createBytecodeBaseClass(typBytecodeBase, typOperationNodeImpl, typExceptionHandler)); - for (ExecutableElement ctor : ElementFilter.constructorsIn(m.getTemplateType().getEnclosedElements())) { - CodeExecutableElement genCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), ctor)); - genCtor.setSimpleName(CodeNames.of(simpleName)); - genCtor.getModifiers().clear(); - genCtor.getModifiers().add(Modifier.PRIVATE); + CodeExecutableElement genCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), m.fdConstructor)); + genCtor.setSimpleName(CodeNames.of(simpleName)); + genCtor.getModifiers().clear(); + genCtor.getModifiers().add(Modifier.PRIVATE); + + if (m.fdBuilderConstructor == null) { + CodeExecutableElement genBuilderCtor = typOperationNodeImpl.add(new CodeExecutableElement(MOD_PRIVATE, null, simpleName)); + genBuilderCtor.addParameter(genCtor.getParameters().get(0)); + genBuilderCtor.addParameter(new CodeVariableElement(types.FrameDescriptor_Builder, "builder")); + genBuilderCtor.renameArguments("language", "builder"); + + CodeTreeBuilder b = genBuilderCtor.createBuilder(); + b.startStatement().startCall("this").string("language").string("builder.build()").end(2); + } else { + CodeExecutableElement genBuilderCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), m.fdBuilderConstructor)); + genBuilderCtor.setSimpleName(CodeNames.of(simpleName)); + genBuilderCtor.getModifiers().clear(); + genBuilderCtor.getModifiers().add(Modifier.PRIVATE); } boolean doHookTti = ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements()).stream().anyMatch(x -> x.getSimpleName().toString().equals("__magic_LogInvalidations")); @@ -2220,7 +2231,7 @@ private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperat if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { b.startIf().string("isSerializing").end().startBlock(); - b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder(), buildIndex++)"); + b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++)"); b.statement("numLocals = 0"); b.statement("numLabels = 0"); b.statement("return result"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 4ab28f2bfb77..28f5b3b878e4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -47,6 +47,7 @@ import java.util.Set; import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; @@ -80,6 +81,9 @@ public class OperationsData extends Template { public boolean enableYield; + public ExecutableElement fdConstructor; + public ExecutableElement fdBuilderConstructor; + public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { super(context, templateType, annotation); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index dc9c7a8a76a8..50881b79ee84 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -93,10 +93,6 @@ protected OperationsData parse(Element element, List mirror) { data.addError(typeElement, "Operations class must be declared abstract."); } - if (ElementUtils.findParentEnclosingType(typeElement).isPresent()) { - data.addError(typeElement, "Operations class must be a top-level class."); - } - if (!ElementUtils.isAssignable(typeElement.asType(), types.RootNode)) { data.addError(typeElement, "Operation class must directly or indirectly subclass RootNode"); } @@ -105,13 +101,6 @@ protected OperationsData parse(Element element, List mirror) { data.addError(typeElement, "Operation class must directly or indirectly implement OperationRootNode"); } - if (data.hasErrors()) { - return data; - } - - boolean haveNonBuilderCtor = false; - boolean haveBuilderCtor = false; - for (ExecutableElement ctor : ElementFilter.constructorsIn(typeElement.getEnclosedElements())) { boolean isValid = ctor.getParameters().size() == 2; @@ -122,9 +111,9 @@ protected OperationsData parse(Element element, List mirror) { if (isValid) { TypeMirror paramType2 = ctor.getParameters().get(1).asType(); if (ElementUtils.isAssignable(paramType2, types.FrameDescriptor)) { - haveNonBuilderCtor = true; + data.fdConstructor = ctor; } else if (ElementUtils.isAssignable(paramType2, context.getDeclaredType(TruffleTypes.FrameDescriptor_Name + ".Builder"))) { - haveBuilderCtor = true; + data.fdBuilderConstructor = ctor; } else { isValid = false; } @@ -135,12 +124,8 @@ protected OperationsData parse(Element element, List mirror) { } } - if (!haveNonBuilderCtor) { - data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor) constructor"); - } - - if (!haveBuilderCtor) { - data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor.Builder) constructor"); + if (data.fdConstructor == null) { + data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor) constructor."); } if (data.hasErrors()) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index 6de963709761..f51c22559700 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -112,10 +112,6 @@ public abstract class SLOperationRootNode extends SLRootNode implements Operatio static final boolean __magic_LogInvalidations = true; - protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) { - super((SLLanguage) language, frameDescriptor.build()); - } - protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { super((SLLanguage) language, frameDescriptor); } From 292d2cc06a3de7165827abc08ffd34bfcec7b228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 10 Oct 2022 18:06:47 +0200 Subject: [PATCH 149/312] [wip] fix tests --- .../operation/test/bml/BenchmarkLanguage.java | 2 +- .../api/operation/test/bml/BenmarkSimple.java | 18 +- .../test/example/BoxingOperationsTest.java | 113 ++++++----- .../example/TestOperationsParserTest.java | 190 +++++++++--------- .../test/example/TestOperationsSerTest.java | 8 +- .../processor/generator/GeneratorUtils.java | 2 +- .../generator/TypeSystemCodeGenerator.java | 7 +- .../dsl/processor/operations/Operation.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 8 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 1 + .../operations/OperationsCodeGenerator.java | 5 +- .../ConditionalBranchInstruction.java | 1 + .../instructions/LoadLocalInstruction.java | 46 ++++- .../instructions/StoreLocalInstruction.java | 30 +++ .../sl/operations/SLOperationRootNode.java | 2 +- 15 files changed, 255 insertions(+), 180 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java index 61611b45df34..f6a789018051 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenchmarkLanguage.java @@ -63,7 +63,7 @@ protected Object createContext(Env env) { public static void registerName(String name, BiConsumer parser) { registerName2(name, l -> { - OperationNodes nodes = BMOperationRootNodeGen.create(OperationConfig.DEFAULT, b -> parser.accept(l, b)); + OperationNodes nodes = BMOperationRootNodeGen.create(OperationConfig.DEFAULT, b -> parser.accept(l, b)); return nodes.getNodes().get(nodes.getNodes().size() - 1).getCallTarget(); }); } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index a0dda8b45296..06c285c862bd 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -348,25 +348,25 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode // int i = 0; b.beginStoreLocal(iLoc); - b.emitConstObject(0); + b.emitLoadConstant(0); b.endStoreLocal(); // int sum = 0; b.beginStoreLocal(sumLoc); - b.emitConstObject(0); + b.emitLoadConstant(0); b.endStoreLocal(); // while (i < TOTAL_ITERATIONS) { b.beginWhile(); b.beginLess(); b.emitLoadLocal(iLoc); - b.emitConstObject(TOTAL_ITERATIONS); + b.emitLoadConstant(TOTAL_ITERATIONS); b.endLess(); b.beginBlock(); // int j = 0; b.beginStoreLocal(jLoc); - b.emitConstObject(0); + b.emitLoadConstant(0); b.endStoreLocal(); // while (j < i) { @@ -384,14 +384,14 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode b.beginLess(); beginMod(b, mode); b.emitLoadLocal(iLoc); - b.emitConstObject(3); + b.emitLoadConstant(3); endMod(b, mode); - b.emitConstObject(1); + b.emitLoadConstant(1); b.endLess(); // temp = 1; b.beginStoreLocal(tempLoc); - b.emitConstObject(1); + b.emitLoadConstant(1); b.endStoreLocal(); // } else { @@ -399,7 +399,7 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode b.beginStoreLocal(tempLoc); beginMod(b, mode); b.emitLoadLocal(iLoc); - b.emitConstObject(3); + b.emitLoadConstant(3); endMod(b, mode); b.endStoreLocal(); @@ -430,7 +430,7 @@ private static void createSimpleLoop(BenchmarkLanguage lang, Builder b, int mode b.beginStoreLocal(iLoc); beginAdd(b, mode); b.emitLoadLocal(iLoc); - b.emitConstObject(1); + b.emitLoadConstant(1); endAdd(b, mode); b.endStoreLocal(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 0e8d439bbd58..2dce811beac8 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -70,31 +70,22 @@ public class BoxingOperationsTest { private static final int NUM_ITERATIONS = 10_000; private static final int MAX_INVALIDATIONS = 20; - private static RootCallTarget parse(OperationParser parser) { - OperationRootNode node = parseNode(parser); - return ((RootNode) node).getCallTarget(); - } - - private static OperationRootNode parseNode(OperationParser parser) { - OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); - OperationRootNode node = nodes.getNodes().get(0); + private static BoxingOperations parse(OperationParser parser) { + OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); + BoxingOperations node = nodes.getNodes().get(0); // System.out.println(node.dump()); return node; } - private static void testInvalidations(Runnable r) { - int startInvalidations = BoxingOperations.__magic_CountInvalidations; - + private static void testInvalidations(BoxingOperations node, int invalidations, Runnable r) { r.run(); - - int totalInval = BoxingOperations.__magic_CountInvalidations - startInvalidations; - - Assert.assertTrue("too many invalidations: " + totalInval, totalInval <= MAX_INVALIDATIONS); + int totalInval = node.__magic_CountInvalidations; + Assert.assertEquals(invalidations, totalInval); } @Test public void testCastsPrimToPrim() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -106,16 +97,18 @@ public void testCastsPrimToPrim() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 1, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call()); + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, callTarget.call()); } }); } @Test public void testCastsRefToPrim() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -127,16 +120,18 @@ public void testCastsRefToPrim() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 1, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call()); + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, callTarget.call()); } }); } @Test public void testCastsPrimToRef() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -148,16 +143,18 @@ public void testCastsPrimToRef() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 1, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call()); + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, callTarget.call()); } }); } @Test public void testCastsRefToRef() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -169,16 +166,18 @@ public void testCastsRefToRef() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 1, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call()); + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, callTarget.call()); } }); } @Test public void testCastsChangePrim() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -192,15 +191,17 @@ public void testCastsChangePrim() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 4, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_INT)); } for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_B)); } try { - root.call(ObjectProducer.PRODUCE_BOOLEAN); + callTarget.call(ObjectProducer.PRODUCE_BOOLEAN); Assert.fail(); } catch (UnsupportedSpecializationException e) { } @@ -209,7 +210,7 @@ public void testCastsChangePrim() { @Test public void testCastsChangeRef() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -223,17 +224,19 @@ public void testCastsChangeRef() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 4, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, callTarget.call(ObjectProducer.PRODUCE_BOOLEAN)); } for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_A)); } try { - root.call(ObjectProducer.PRODUCE_INT); + callTarget.call(ObjectProducer.PRODUCE_INT); Assert.fail(); } catch (UnsupportedSpecializationException e) { } @@ -242,7 +245,7 @@ public void testCastsChangeRef() { @Test public void testCastsChangeSpecPrim() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -256,17 +259,19 @@ public void testCastsChangeSpecPrim() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 7, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_INT)); + Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_INT)); } for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, root.call(ObjectProducer.PRODUCE_REF_B)); + Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_B)); } try { - root.call(ObjectProducer.PRODUCE_BOOLEAN); + callTarget.call(ObjectProducer.PRODUCE_BOOLEAN); Assert.fail(); } catch (UnsupportedSpecializationException e) { } @@ -275,7 +280,7 @@ public void testCastsChangeSpecPrim() { @Test public void testCastsChangeSpecRef() { - RootCallTarget root = parse(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); b.beginReturn(); @@ -289,15 +294,17 @@ public void testCastsChangeSpecRef() { b.endRoot(); }); - testInvalidations(() -> { + RootCallTarget callTarget = root.getCallTarget(); + + testInvalidations(root, 6, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_BOOLEAN)); + Assert.assertEquals(BoxingTypeSystem.BOOLEAN_AS_STRING_VALUE, callTarget.call(ObjectProducer.PRODUCE_BOOLEAN)); } for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, root.call(ObjectProducer.PRODUCE_REF_A)); + Assert.assertEquals(BoxingTypeSystem.REF_A_AS_STRING_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_A)); } try { - root.call(ObjectProducer.PRODUCE_INT); + callTarget.call(ObjectProducer.PRODUCE_INT); Assert.fail(); } catch (UnsupportedSpecializationException e) { } @@ -306,13 +313,13 @@ public void testCastsChangeSpecRef() { @Test public void testLBEMultipleLoads() { - OperationRootNode node = parseNode(b -> { + BoxingOperations root = parse(b -> { b.beginRoot(LANGUAGE); OperationLocal local = b.createLocal(); b.beginStoreLocal(local); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endStoreLocal(); b.beginLongOperator(); @@ -326,11 +333,11 @@ public void testLBEMultipleLoads() { b.endRoot(); }); - RootCallTarget root = ((RootNode) node).getCallTarget(); + RootCallTarget callTarget = root.getCallTarget(); - testInvalidations(() -> { + testInvalidations(root, 3, () -> { for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(1L, root.call()); + Assert.assertEquals(1L, callTarget.call()); } }); } @@ -393,7 +400,7 @@ static long castLong(ReferenceTypeB b) { abstract class BoxingOperations extends RootNode implements OperationRootNode { static final boolean __magic_LogInvalidations = false; - static int __magic_CountInvalidations = 0; + int __magic_CountInvalidations = 0; protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) { super(language, frameDescriptor.build()); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 921a028c12b4..aeff8c110747 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -69,13 +69,7 @@ private static RootCallTarget parse(OperationParser b } private static OperationRootNode parseNode(OperationParser builder) { - OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, builder); - - for (OperationRootNode node : nodes.getNodes()) { - System.out.println("-------------------------------------"); - System.out.println(node.dump()); - } - + OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, builder); return nodes.getNodes().get(nodes.getNodes().size() - 1); } @@ -137,11 +131,11 @@ public void testIfThen() { b.beginLessThanOperation(); b.emitLoadArgument(0); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endLessThanOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.endIfThen(); @@ -173,11 +167,11 @@ public void testSumLoop() { OperationLocal locJ = b.createLocal(); b.beginStoreLocal(locI); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endStoreLocal(); b.beginStoreLocal(locJ); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endStoreLocal(); b.beginWhile(); @@ -197,7 +191,7 @@ public void testSumLoop() { b.beginStoreLocal(locI); b.beginAddOperation(); b.emitLoadLocal(locI); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAddOperation(); b.endStoreLocal(); b.endBlock(); @@ -225,7 +219,7 @@ public void testTryCatch() { b.beginIfThen(); b.beginLessThanOperation(); b.emitLoadArgument(0); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endLessThanOperation(); b.emitThrowOperation(); @@ -233,13 +227,13 @@ public void testTryCatch() { b.endIfThen(); b.beginReturn(); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endReturn(); b.endTryCatch(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.endRoot(); @@ -258,18 +252,18 @@ public void testVariableBoxingElim() { OperationLocal local1 = b.createLocal(); b.beginStoreLocal(local0); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endStoreLocal(); b.beginStoreLocal(local1); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endStoreLocal(); b.beginWhile(); b.beginLessThanOperation(); b.emitLoadLocal(local0); - b.emitConstObject(100L); + b.emitLoadConstant(100L); b.endLessThanOperation(); b.beginBlock(); @@ -286,7 +280,7 @@ public void testVariableBoxingElim() { b.beginStoreLocal(local0); b.beginAddOperation(); b.emitLoadLocal(local0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAddOperation(); b.endStoreLocal(); @@ -333,17 +327,17 @@ public void testFinallyTryBasic() { b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.endFinallyTry(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); @@ -364,26 +358,26 @@ public void testFinallyTryException() { b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.emitThrowOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); @@ -400,24 +394,24 @@ public void testFinallyTryReturn() { b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.endBlock(); b.endFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); @@ -440,38 +434,38 @@ public void testFinallyTryBranchOut() { b.beginFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.emitBranch(lbl); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.emitLabel(lbl); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(5L); + b.emitLoadConstant(5L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); @@ -495,7 +489,7 @@ public void testFinallyTryCancel() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.emitBranch(lbl); @@ -504,29 +498,29 @@ public void testFinallyTryCancel() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.endBlock(); b.endFinallyTry(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.emitLabel(lbl); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); @@ -550,37 +544,37 @@ public void testFinallyTryInnerCf() { b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.emitBranch(lbl); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.emitLabel(lbl); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(5L); + b.emitLoadConstant(5L); b.endAppenderOperation(); b.endBlock(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -604,7 +598,7 @@ public void testFinallyTryNestedTry() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.endBlock(); @@ -612,23 +606,23 @@ public void testFinallyTryNestedTry() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.endBlock(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -654,23 +648,23 @@ public void testFinallyTryNestedFinally() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(5L); + b.emitLoadConstant(5L); b.endAppenderOperation(); b.endBlock(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -678,16 +672,16 @@ public void testFinallyTryNestedFinally() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -711,7 +705,7 @@ public void testFinallyTryNestedTryThrow() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.endBlock(); @@ -719,21 +713,21 @@ public void testFinallyTryNestedTryThrow() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.endBlock(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.emitThrowOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -759,21 +753,21 @@ public void testFinallyTryNestedFinallyThrow() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(5L); + b.emitLoadConstant(5L); b.endAppenderOperation(); b.endBlock(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.emitThrowOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(4L); + b.emitLoadConstant(4L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -781,14 +775,14 @@ public void testFinallyTryNestedFinallyThrow() { b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.emitThrowOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTry(); @@ -812,22 +806,22 @@ public void testFinallyTryNoExceptReturn() { b.beginFinallyTryNoExcept(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.beginReturn(); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endReturn(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTryNoExcept(); @@ -851,20 +845,20 @@ public void testFinallyTryNoExceptException() { b.beginFinallyTryNoExcept(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endAppenderOperation(); b.beginBlock(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAppenderOperation(); b.emitThrowOperation(); b.beginAppenderOperation(); b.emitLoadArgument(0); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endAppenderOperation(); b.endBlock(); b.endFinallyTryNoExcept(); @@ -928,7 +922,7 @@ public void testTeeLocal() { OperationLocal local = b.createLocal(); b.beginTeeLocal(local); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endTeeLocal(); b.beginReturn(); @@ -948,15 +942,15 @@ public void testYield() { b.beginRoot(LANGUAGE); b.beginYield(); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endYield(); b.beginYield(); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endYield(); b.beginReturn(); - b.emitConstObject(3L); + b.emitLoadConstant(3L); b.endReturn(); b.endRoot(); @@ -987,7 +981,7 @@ public void testYieldLocal() { // return loc b.beginStoreLocal(loc); - b.emitConstObject(0L); + b.emitLoadConstant(0L); b.endStoreLocal(); b.beginYield(); @@ -997,7 +991,7 @@ public void testYieldLocal() { b.beginStoreLocal(loc); b.beginAddOperation(); b.emitLoadLocal(loc); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAddOperation(); b.endStoreLocal(); @@ -1008,7 +1002,7 @@ public void testYieldLocal() { b.beginStoreLocal(loc); b.beginAddOperation(); b.emitLoadLocal(loc); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endAddOperation(); b.endStoreLocal(); @@ -1032,18 +1026,16 @@ public void testYieldStack() { RootCallTarget root = parse(b -> { b.beginRoot(LANGUAGE); - OperationLocal loc = b.createLocal(); - // return (yield 1) + (yield 2) b.beginReturn(); b.beginAddOperation(); b.beginYield(); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endYield(); b.beginYield(); - b.emitConstObject(2L); + b.emitLoadConstant(2L); b.endYield(); b.endAddOperation(); @@ -1076,12 +1068,12 @@ public void testNestedFunctions() { b.beginRoot(LANGUAGE); b.beginReturn(); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endReturn(); TestOperations innerRoot = b.endRoot(); - b.emitConstObject(innerRoot); + b.emitLoadConstant(innerRoot); b.endInvoke(); b.endReturn(); @@ -1102,7 +1094,7 @@ public void testNonlocalRead() { OperationLocal xLoc = b.createLocal(); b.beginStoreLocal(xLoc); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endStoreLocal(); b.beginReturn(); @@ -1111,14 +1103,14 @@ public void testNonlocalRead() { b.beginRoot(LANGUAGE); b.beginReturn(); - b.beginLoadNonlocal(xLoc); + b.beginLoadLocalMaterialized(xLoc); b.emitLoadArgument(0); - b.endLoadNonlocal(); + b.endLoadLocalMaterialized(); b.endReturn(); TestOperations inner = b.endRoot(); b.beginCreateClosure(); - b.emitConstObject(inner); + b.emitLoadConstant(inner); b.endCreateClosure(); b.endInvoke(); @@ -1141,7 +1133,7 @@ public void testNonlocalWrite() { OperationLocal xLoc = b.createLocal(); b.beginStoreLocal(xLoc); - b.emitConstObject(1L); + b.emitLoadConstant(1L); b.endStoreLocal(); @@ -1149,19 +1141,19 @@ public void testNonlocalWrite() { b.beginRoot(LANGUAGE); - b.beginStoreNonlocal(xLoc); + b.beginStoreLocalMaterialized(xLoc); b.emitLoadArgument(0); - b.emitConstObject(2L); - b.endStoreNonlocal(); + b.emitLoadConstant(2L); + b.endStoreLocalMaterialized(); b.beginReturn(); - b.emitConstObject(null); + b.emitLoadConstant(null); b.endReturn(); TestOperations inner = b.endRoot(); b.beginCreateClosure(); - b.emitConstObject(inner); + b.emitLoadConstant(inner); b.endCreateClosure(); b.endInvoke(); diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index f2cd2b2c9f42..0f4b10ef1240 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -62,10 +62,10 @@ public void testSer() { } private static TestOperations deserialize(byte[] byteArray) { - OperationNodes nodes2 = null; + OperationNodes nodes2 = null; try { nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), (ctx, buf2) -> { - return buf2.getLong(); + return buf2.readLong(); }); } catch (IOException e) { Assert.fail(); @@ -81,8 +81,8 @@ private static byte[] createByteArray() { b.beginReturn(); b.beginAddOperation(); - b.emitConstObject(1L); - b.emitConstObject(2L); + b.emitLoadConstant(1L); + b.emitLoadConstant(2L); b.endAddOperation(); b.endReturn(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 78664f278331..6620e1e10f27 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -105,7 +105,7 @@ public static CodeTree createTransferToInterpreterAndInvalidate() { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); if (hookTransferToInterpreter.get()) { - builder.startCall("hook_transferToInterpreterAndInvalidate").end(); + builder.startCall("hook_transferToInterpreterAndInvalidate").string("$this").end(); } else { builder.startStaticCall(context.getTypes().CompilerDirectives, "transferToInterpreterAndInvalidate").end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index 6c43229a5b16..5785c607e1ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -137,7 +137,12 @@ static CodeTree expect(TypeSystemData typeSystem, TypeMirror type, CodeTree cont if (typeSystem.hasType(type)) { builder.startStaticCall(createTypeSystemGen(typeSystem), expectTypeMethodName(typeSystem, type, null)).tree(content).end(); } else { - builder.startCall(expectTypeMethodName(typeSystem, type, plugs)).tree(content).end(); + builder.startCall(expectTypeMethodName(typeSystem, type, plugs)); + if (plugs != null) { + // todo: Operations hack + builder.string("$this"); + } + builder.tree(content).end(); } return builder.build(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 62405b3aa2c5..cc5de1537e71 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -250,7 +250,7 @@ public static class LoadLocalMaterialized extends Operation { private final LoadLocalMaterializedInstruction instr; public LoadLocalMaterialized(OperationsContext context, int id, LoadLocalMaterializedInstruction instr) { - super(context, "MaterializedLoadLocal", id, 1); + super(context, "LoadLocalMaterialized", id, 1); this.instr = instr; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 7d376e0de3f3..396faeef8af3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -292,7 +292,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.sp)); - b.declaration("short", varCurOpcode.getName(), OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)); + b.declaration("int", varCurOpcode.getName(), CodeTreeBuilder.createBuilder().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).string(" & 0xffff").build()); b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); @@ -339,7 +339,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { if (ctx.hasBoxingElimination() && !isUncached) { if (op.splitOnBoxingElimination()) { for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); + b.startCase().variable(op.opcodeIdField).string(" | (", kind.toOrdinal(), " << 13)").end(); b.startBlock(); vars.specializedKind = kind; createBody.run(); @@ -347,7 +347,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); } if (op.hasGeneric()) { - b.startCase().variable(op.opcodeIdField).string(" | (short) (7 << 13)").end(); + b.startCase().variable(op.opcodeIdField).string(" | (7 << 13)").end(); b.startBlock(); createBody.run(); b.end(); @@ -359,7 +359,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); } else { for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().variable(op.opcodeIdField).string(" | (short) (", kind.toOrdinal(), " << 13)").end(); + b.startCase().variable(op.opcodeIdField).string(" | (", kind.toOrdinal(), " << 13)").end(); } b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 0f4be9be8648..8c38bf01f25b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -636,6 +636,7 @@ public String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror t OperationGeneratorUtils.createHelperMethod(m.getOperationsContext().outerType, name, () -> { CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), type, name); + el.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); el.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); el.addThrownType(types.UnexpectedResultException); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 55aacb53e7b5..57c36beb5b43 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -529,6 +529,7 @@ CodeTypeElement createOperationNodeImpl() { private CodeExecutableElement createHookTransferToInterpreterAndInvalidate() { CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "hook_transferToInterpreterAndInvalidate"); + el.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); CodeTreeBuilder b = el.createBuilder(); @@ -538,7 +539,7 @@ private CodeExecutableElement createHookTransferToInterpreterAndInvalidate() { for (VariableElement field : ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements())) { if (field.getSimpleName().toString().equals("__magic_CountInvalidations")) { - b.startStatement().staticReference(field).string(" += 1").end(); + b.startStatement().field("$this", field).string(" += 1").end(); } } @@ -826,6 +827,7 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.startIf().string("(result & 0xffff) == 0xffff").end().startBlock(); b.statement("break"); b.end().startElseBlock(); + b.declaration(m.getOperationsContext().outerType.asType(), "$this", "this"); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.end(); @@ -1289,6 +1291,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement private CodeExecutableElement createConditionProfile() { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "do_profileCondition"); + met.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); met.addParameter(new CodeVariableElement(context.getType(boolean.class), "value")); met.addParameter(new CodeVariableElement(context.getType(int[].class), "profiles")); met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index c60065d0197e..fb8902da5ff8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -75,6 +75,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startIf().startCall("do_profileCondition"); + b.string("$this"); b.string("cond"); b.string("$conditionProfiles"); b.tree(createBranchProfileIndex(vars, 0, false)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index 7d1fc1526e37..edb47cf26905 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -65,13 +65,52 @@ public LoadLocalInstruction(OperationsContext ctx, int id, boolean boxed) { addLocal("local"); } + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); + + if (ctx.getData().enableYield) { + b.startStatement().startCall("UFA", "unsafeCopyTo"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.variable(vars.stackFrame); + b.string("$sp"); + b.string("1"); + b.end(2); + } else { + b.startStatement().startCall("UFA", "unsafeCopyObject"); + b.variable(vars.stackFrame); + b.string("localIdx"); + b.string("$sp"); + b.end(2); + } + + b.statement("$sp += 1"); + + return b.build(); + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + if (boxed && vars.specializedKind == FrameKind.OBJECT) { + // load boxed object == load object + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalUnboxed.opcodeIdField.getName())); + b.statement("$bci -= LOAD_LOCAL_BOXED_LENGTH"); + + return b.build(); + } + String helperName = "do_loadLocal" + (boxed ? "Boxed" : "") + "_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), helperName); + res.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); res.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { res.addParameter(vars.localFrame); @@ -233,6 +272,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); b.startStatement().startCall(helperName); + b.string("$this"); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); @@ -268,11 +308,7 @@ public boolean splitOnBoxingElimination() { @Override public List getBoxingEliminationSplits() { - if (boxed) { - return ctx.getPrimitiveBoxingKinds(); - } else { - return ctx.getBoxingKinds(); - } + return ctx.getBoxingKinds(); } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index be12a0783fd1..74fd4a692b21 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -62,12 +62,39 @@ public StoreLocalInstruction(OperationsContext ctx, int id) { addLocal("target"); } + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); + if (ctx.getData().enableYield) { + b.startStatement().startCall("UFA", "unsafeCopyTo"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.variable(vars.localFrame); + b.string("localIdx"); + b.string("1"); + b.end(2); + } else { + b.startStatement().startCall("UFA", "unsafeCopyObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.string("localIdx"); + b.end(2); + } + + b.statement("$sp -= 1"); + + return b.build(); + } + @Override public CodeTree createExecuteCode(ExecutionVariables vars) { if (ctx.hasBoxingElimination()) { OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_storeLocalSpecialize", () -> { CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), "do_storeLocalSpecialize"); + ex.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); ex.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { ex.addParameter(vars.localFrame); @@ -158,6 +185,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), helperName); + ex.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); ex.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { ex.addParameter(vars.localFrame); @@ -252,6 +280,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); b.startStatement().startCall(helperName); + b.string("$this"); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); @@ -291,6 +320,7 @@ private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b, FrameKind kind) { b.startStatement().startCall("do_storeLocalSpecialize"); + b.string("$this"); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index f51c22559700..b0080e437172 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -110,7 +110,7 @@ @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) public abstract class SLOperationRootNode extends SLRootNode implements OperationRootNode { - static final boolean __magic_LogInvalidations = true; + static final boolean __magic_LogInvalidations = false; protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { super((SLLanguage) language, frameDescriptor); From 88ea8a1ab991f94e6d83b9cfc76aa49eb4f3841f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 11 Oct 2022 11:00:10 +0200 Subject: [PATCH 150/312] [wip] fix tests --- .../api/operation/test/example/TestOperationsSerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 0f4b10ef1240..37705345a117 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -71,12 +71,12 @@ private static TestOperations deserialize(byte[] byteArray) { Assert.fail(); } - return (TestOperations) nodes2.getNodes().get(0); + return nodes2.getNodes().get(0); } private static byte[] createByteArray() { - OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, b -> { + OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, b -> { b.beginRoot(null); b.beginReturn(); From dd82337f8f20dfa10142c4ddb879be2a1053e884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 11 Oct 2022 13:16:22 +0200 Subject: [PATCH 151/312] [wip] add error tests --- .../api/operation/test/ExpectError.java | 5 + .../operation/test/dsl_tests/ErrorTests.java | 216 ++++++++++++++++++ .../truffle/dsl/processor/ExpectError.java | 2 +- .../truffle/dsl/processor/TruffleTypes.java | 1 + .../operations/OperationsParser.java | 12 +- .../operations/SingleOperationParser.java | 23 +- 6 files changed, 241 insertions(+), 18 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ExpectError.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ExpectError.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ExpectError.java new file mode 100644 index 000000000000..143b26e2433f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ExpectError.java @@ -0,0 +1,5 @@ +package com.oracle.truffle.api.operation.test; + +public @interface ExpectError { + public String[] value() default {}; +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java new file mode 100644 index 000000000000..576fe7b7635c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java @@ -0,0 +1,216 @@ +package com.oracle.truffle.api.operation.test.dsl_tests; + +import java.io.Serializable; + +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystem; +import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.operation.GenerateOperations; +import com.oracle.truffle.api.operation.LocalSetter; +import com.oracle.truffle.api.operation.LocalSetterRange; +import com.oracle.truffle.api.operation.Operation; +import com.oracle.truffle.api.operation.OperationProxy; +import com.oracle.truffle.api.operation.OperationRootNode; +import com.oracle.truffle.api.operation.Variadic; +import com.oracle.truffle.api.operation.test.ExpectError; +import com.oracle.truffle.api.source.SourceSection; + +@SuppressWarnings("unused") +public class ErrorTests { + @ExpectError("Operations class must be declared abstract.") + @GenerateOperations(languageClass = ErrorLanguage.class) + public class MustBeDeclaredAbstract extends RootNode implements OperationRootNode { + protected MustBeDeclaredAbstract(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + public String dump() { + return null; + } + + @Override + public Object execute(VirtualFrame frame) { + return null; + } + + public SourceSection getSourceSectionAtBci(int bci) { + return null; + } + } + + @ExpectError("Operations class must directly or indirectly subclass RootNode.") + @GenerateOperations(languageClass = ErrorLanguage.class) + public abstract class MustBeSubclassOfRootNode implements OperationRootNode { + protected MustBeSubclassOfRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + } + } + + @ExpectError("Operations class must directly or indirectly implement OperationRootNode.") + @GenerateOperations(languageClass = ErrorLanguage.class) + public abstract class MustImplementOperationRootNode extends RootNode { + protected MustImplementOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + } + + @ExpectError("Operations class requires a (TruffleLanguage, FrameDescriptor) constructor.") + @GenerateOperations(languageClass = ErrorLanguage.class) + public abstract class MustHaveFDConstructor extends RootNode implements OperationRootNode { + protected MustHaveFDConstructor(TruffleLanguage language, FrameDescriptor.Builder builder) { + super(language, builder.build()); + } + } + + @ExpectError("Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder).") + @GenerateOperations(languageClass = ErrorLanguage.class) + public abstract class InvalidConstructor extends RootNode implements OperationRootNode { + protected InvalidConstructor(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + + protected InvalidConstructor(TruffleLanguage language) { + super(language); + } + } + + @ExpectError("The used type system 'com.oracle.truffle.api.operation.test.dsl_tests.ErrorTests.ErroredTypeSystem' is invalid. Fix errors in the type system first.") + @GenerateOperations(languageClass = ErrorLanguage.class) + @TypeSystemReference(ErroredTypeSystem.class) + public abstract class BadTypeSystem extends RootNode implements OperationRootNode { + protected BadTypeSystem(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + } + + @ExpectError({"Cannot perform boxing elimination on java.lang.String. Remove this type from the boxing eliminated types list.", "No operations found."}) + @GenerateOperations(languageClass = ErrorLanguage.class, boxingEliminationTypes = {String.class}) + public abstract class BadBoxingElimination extends RootNode implements OperationRootNode { + protected BadBoxingElimination(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + } + + @ExpectError("Could not parse invalid node: ErroredNode. Fix errors in the node first.") + @GenerateOperations(languageClass = ErrorLanguage.class) + @OperationProxy(ErroredNode.class) + public abstract class BadNodeProxy extends RootNode implements OperationRootNode { + protected BadNodeProxy(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + } + + @ExpectError({"@OperationProxy'ed type must be a class, not int.", "Could not proxy operation"}) + @GenerateOperations(languageClass = ErrorLanguage.class) + @OperationProxy(int.class) + public abstract class BadProxyType extends RootNode implements OperationRootNode { + protected BadProxyType(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + } + + @ExpectError("@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") + @GenerateOperations(languageClass = ErrorLanguage.class) + @OperationProxy(TestNode.class) + public static abstract class OperationErrorTests extends RootNode implements OperationRootNode { + protected OperationErrorTests(TruffleLanguage language, FrameDescriptor builder) { + super(language, builder); + } + + @ExpectError({"@Operation annotated class must be declared static and final.", "Operation contains no specializations."}) + @Operation + public class TestOperation1 { + } + + @ExpectError({"@Operation annotated class must not be declared private.", "Operation contains no specializations."}) + @Operation + private static final class TestOperation2 { + } + + @ExpectError({"@Operation annotated class must not extend/implement anything. Inheritance is not supported.", "Operation contains no specializations."}) + @Operation + public static final class TestOperation3 extends Exception { + private static final long serialVersionUID = 1L; + } + + @ExpectError({"@Operation annotated class must not contain non-static members.", "Operation contains no specializations."}) + @Operation + public static final class TestOperation4 { + public void doSomething() { + } + } + + @ExpectError("Multiple @Variadic arguments not allowed.") + @Operation + public static final class TestOperation5 { + @Specialization + public static void spec(@Variadic Object[] a, @Variadic Object[] b) { + } + } + + @ExpectError("Value arguments after LocalSetter not allowed.") + @Operation + public static final class TestOperation6 { + @Specialization + public static void spec(LocalSetter a, Object b) { + } + } + + @ExpectError("Mixing regular and range local setters not allowed.") + @Operation + public static final class TestOperation7 { + @Specialization + public static void spec(LocalSetter a, LocalSetterRange b) { + } + } + + @ExpectError("Value arguments after @Variadic not allowed.") + @Operation + public static final class TestOperation8 { + @Specialization + public static void spec(@Variadic Object[] a, Object b) { + } + } + + @ExpectError("Value arguments after LocalSetter not allowed.") + @Operation + public static final class TestOperation9 { + @Specialization + public static void spec(LocalSetter a, Object b) { + } + } + } + + @ExpectError("%") + @TypeSystem + private class ErroredTypeSystem { + } + + @ExpectError("%") + public static class ErroredNode { + @Specialization + public static void doStuff() { + } + } + + public static abstract class TestNode extends Node { + public abstract int execute(int x, int y); + + @Specialization + public int add(int x, int y) { + return x + y; + } + } + + public class ErrorLanguage extends TruffleLanguage { + @Override + protected Object createContext(Env env) { + return null; + } + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java index 7df98a68d682..43a68b0d2514 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java @@ -56,7 +56,7 @@ public class ExpectError { - private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2}; + private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2, TruffleTypes.EXPECT_ERROR_CLASS_NAME3}; public static void assertNoErrorExpected(ProcessingEnvironment processingEnv, Element element) { for (String errorType : EXPECT_ERROR_TYPES) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 907a8e5b196f..aa4e2eb4191d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -54,6 +54,7 @@ public class TruffleTypes { public static final String ALWAYS_SLOW_PATH_MODE_NAME = "com.oracle.truffle.api.dsl.test.AlwaysGenerateOnlySlowPath"; public static final String EXPECT_ERROR_CLASS_NAME1 = "com.oracle.truffle.api.dsl.test.ExpectError"; public static final String EXPECT_ERROR_CLASS_NAME2 = "com.oracle.truffle.api.test.ExpectError"; + public static final String EXPECT_ERROR_CLASS_NAME3 = "com.oracle.truffle.api.operation.test.ExpectError"; public static final List TEST_PACKAGES = List.of("com.oracle.truffle.api.test", "com.oracle.truffle.api.instrumentation.test"); public final DeclaredType AlwaysSlowPath = c.getDeclaredTypeOptional(ALWAYS_SLOW_PATH_MODE_NAME); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 50881b79ee84..5a90a824f978 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -94,11 +94,11 @@ protected OperationsData parse(Element element, List mirror) { } if (!ElementUtils.isAssignable(typeElement.asType(), types.RootNode)) { - data.addError(typeElement, "Operation class must directly or indirectly subclass RootNode"); + data.addError(typeElement, "Operations class must directly or indirectly subclass RootNode."); } if (!ElementUtils.isAssignable(typeElement.asType(), types.OperationRootNode)) { - data.addError(typeElement, "Operation class must directly or indirectly implement OperationRootNode"); + data.addError(typeElement, "Operations class must directly or indirectly implement OperationRootNode."); } for (ExecutableElement ctor : ElementFilter.constructorsIn(typeElement.getEnclosedElements())) { @@ -120,12 +120,12 @@ protected OperationsData parse(Element element, List mirror) { } if (!isValid) { - data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder)"); + data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder)."); } } if (data.fdConstructor == null) { - data.addError(typeElement, "Operation class requires a (TruffleLanguage, FrameDescriptor) constructor."); + data.addError(typeElement, "Operations class requires a (TruffleLanguage, FrameDescriptor) constructor."); } if (data.hasErrors()) { @@ -181,7 +181,7 @@ protected OperationsData parse(Element element, List mirror) { if (UNBOXABLE_TYPE_KINDS.contains(mir.getKind())) { beTypes.add(mir.getKind()); } else { - data.addError("Cannot perform boxing elimination on %s", mir); + data.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list.", mir); } } @@ -231,7 +231,7 @@ protected OperationsData parse(Element element, List mirror) { } if (opProxies.isEmpty() && operationTypes.isEmpty()) { - data.addWarning("No operations found"); + data.addWarning("No operations found."); } if (data.hasErrors()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index b61d348f56af..44060afcfdfd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -121,7 +121,8 @@ protected SingleOperationData parse(Element element, List mirr TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); if (proxyType.getKind() != TypeKind.DECLARED) { - parentData.addError(proxyMirror, proxyTypeValue, "@OperationProxy'ed type must be a class, not %s", proxyType); + parentData.addError(proxyMirror, proxyTypeValue, "@OperationProxy'ed type must be a class, not %s.", proxyType); + return null; } te = context.getTypeElement((DeclaredType) proxyType); @@ -172,11 +173,11 @@ protected SingleOperationData parse(Element element, List mirr // @Operation annotated type if (!te.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { - data.addError("@Operation annotated class must be declared static and final"); + data.addError("@Operation annotated class must be declared static and final."); } if (te.getModifiers().contains(Modifier.PRIVATE)) { - data.addError("@Operation annotated class must not be declared private"); + data.addError("@Operation annotated class must not be declared private."); } if (!ElementUtils.isObject(te.getSuperclass()) || !te.getInterfaces().isEmpty()) { @@ -190,7 +191,7 @@ protected SingleOperationData parse(Element element, List mirr } if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { - data.addError(el, "@Operation annotated class must not contain non-static members"); + data.addError(el, "@Operation annotated class must not contain non-static members."); } operationFunctions.addAll(findSpecializations(te.getEnclosedElements())); @@ -208,7 +209,7 @@ protected SingleOperationData parse(Element element, List mirr } if (operationFunctions.isEmpty()) { - data.addError("Operation contains no specializations"); + data.addError("Operation contains no specializations."); return data; } @@ -294,7 +295,7 @@ protected SingleOperationData parse(Element element, List mirr NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); if (nodeData == null) { - data.addError("Could not parse invalid node: " + te.getSimpleName()); + data.addError("Could not parse invalid node: " + te.getSimpleName() + ". Fix errors in the node first."); return data; } @@ -432,10 +433,10 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme for (VariableElement param : method.getParameters()) { if (isVariadicParameter(param)) { if (isVariadic) { - data.addError(method, "Multiple @Variadic arguments not allowed"); + data.addError(method, "Multiple @Variadic arguments not allowed."); } if (numLocalSetters != 0) { - data.addError(param, "Value arguments after LocalSetter not allowed"); + data.addError(param, "Value arguments after LocalSetter not allowed."); } isVariadic = true; parameters.add(ParameterKind.VARIADIC); @@ -445,15 +446,15 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRange)) { parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); if (numLocalSetters != 0) { - data.addError(param, "Mixing regular and array local setters not allowed"); + data.addError(param, "Mixing regular and range local setters not allowed."); } numLocalSetters = -1; } else if (!isIgnoredParameter(param)) { if (isVariadic) { - data.addError(method, "Value arguments after @Variadic not allowed"); + data.addError(method, "Value arguments after @Variadic not allowed."); } if (numLocalSetters > 0) { - data.addError(param, "Value arguments after LocalSetter not allowed"); + data.addError(param, "Value arguments after LocalSetter not allowed."); } if (ElementUtils.typeEquals(param.asType(), types.Frame) || ElementUtils.typeEquals(param.asType(), types.VirtualFrame)) { parameters.add(ParameterKind.VIRTUAL_FRAME); From 0623618309faca42b7f3b11affa7de464e566363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 13 Oct 2022 09:39:53 +0200 Subject: [PATCH 152/312] [wip] superinstruction detection --- .../operation/tracing/ExecutionTracer.java | 2 + .../tracing/OperationsStatistics.java | 165 ++++++++++++++++-- .../dsl/processor/operations/Operation.java | 60 ++++++- .../OperationsBytecodeCodeGenerator.java | 28 ++- .../operations/OperationsCodeGenerator.java | 18 ++ .../sl/operations/SLOperationRootNode.java | 2 +- .../truffle/sl/operations/decisions.json | 102 +++++++++-- 7 files changed, 346 insertions(+), 31 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index 9c1e7ee35e5f..d5608233153a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -76,4 +76,6 @@ public static void initialize(Class opsClass, String decisionsFile, String[] public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations); public abstract void traceSpecialization(int bci, int id, int specializationId, Object... values); + + public abstract void traceStartBasicBlock(int bci); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 43c1f3b520b5..a39ffdea32dd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -51,9 +51,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.nodes.Node; @@ -240,6 +242,10 @@ public void traceActiveSpecializations(int bci, int id, boolean[] activeSpeciali @Override public void traceSpecialization(int bci, int id, int specializationId, Object... values) { } + + @Override + public void traceStartBasicBlock(int bci) { + } } private static class EnabledExecutionTracer extends ExecutionTracer { @@ -351,30 +357,109 @@ public String toString() { } } + private static class InstructionSequenceKey { + final int[] instructions; + + InstructionSequenceKey(int[] instructions) { + this.instructions = instructions; + } + + @Override + public boolean equals(Object obj) { + return obj.getClass() == InstructionSequenceKey.class && Arrays.equals(((InstructionSequenceKey) obj).instructions, instructions); + } + + @Override + public int hashCode() { + return Arrays.hashCode(instructions); + } + + @Override + public String toString() { + return "InstructionSequenceKey " + Arrays.toString(instructions); + } + + public String toKey() { + return String.join(",", Arrays.stream(instructions).mapToObj(Integer::toString).toArray(String[]::new)); + } + + public static InstructionSequenceKey fromKey(String key) { + int[] instructions = Arrays.stream(key.split(",")).mapToInt(Integer::parseInt).toArray(); + return new InstructionSequenceKey(instructions); + } + + public Object toString(String[] instrNames) { + return String.join(",", Arrays.stream(instructions).mapToObj(x -> instrNames[x]).toArray(String[]::new)); + } + } + private Map activeSpecializationsMap = new HashMap<>(); + private Map instructionSequencesMap = new HashMap<>(); + private Map numNodesWithInstruction = new HashMap<>(); + private Map> nodesWithInstruction = new HashMap<>(); + + private List nodes = new ArrayList<>(); + private Node curNode; + + private static final int MAX_SUPERINSTR_LEN = 8; + private int[] instrHistory = new int[MAX_SUPERINSTR_LEN]; + private int instrHistoryLen = 0; @Override public void startFunction(Node node) { + if (curNode != null) { + nodes.add(curNode); + } + curNode = node; } @Override public void endFunction(Node node) { + if (nodes.size() > 0) { + curNode = nodes.remove(nodes.size() - 1); + } else { + curNode = null; + } } @Override public void traceInstruction(int bci, int id) { + nodesWithInstruction.computeIfAbsent(id, k -> new HashSet<>()).add(curNode); + + // SI finding + if (instrHistoryLen == MAX_SUPERINSTR_LEN) { + System.arraycopy(instrHistory, 1, instrHistory, 0, MAX_SUPERINSTR_LEN - 1); + instrHistory[MAX_SUPERINSTR_LEN - 1] = id; + } else { + instrHistory[instrHistoryLen++] = id; + } + + for (int i = 0; i < instrHistoryLen - 1; i++) { + int[] curHistory = Arrays.copyOfRange(instrHistory, i, instrHistoryLen); + InstructionSequenceKey key = new InstructionSequenceKey(curHistory); + instructionSequencesMap.merge(key, 1L, EnabledExecutionTracer::saturatingAdd); + } + + } + + private static long saturatingAdd(long x, long y) { + try { + return Math.addExact(x, y); + } catch (ArithmeticException e) { + return x; + } + } + + private static int saturatingAdd(int x, int y) { + try { + return Math.addExact(x, y); + } catch (ArithmeticException e) { + return x; + } } @Override public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { -// boolean anyTrue = false; -// for (int i = 0; i < activeSpecializations.length; i++) { -// anyTrue |= activeSpecializations[i]; -// } -// if (!anyTrue) { -// return; -// } - SpecializationKey key = new SpecializationKey(id, activeSpecializations); Long l = activeSpecializationsMap.get(key); if (l == null) { @@ -388,6 +473,11 @@ public void traceActiveSpecializations(int bci, int id, boolean[] activeSpeciali public void traceSpecialization(int bci, int id, int specializationId, Object... values) { } + @Override + public void traceStartBasicBlock(int bci) { + instrHistoryLen = 0; + } + private void merge(EnabledExecutionTracer other) { other.activeSpecializationsMap.forEach((k, v) -> { Long existing = this.activeSpecializationsMap.get(k); @@ -399,21 +489,50 @@ private void merge(EnabledExecutionTracer other) { this.activeSpecializationsMap.put(k, Long.MAX_VALUE); } }); + + other.nodesWithInstruction.forEach((k, v) -> { + nodesWithInstruction.computeIfAbsent(k, k2 -> new HashSet<>()).addAll(v); + }); + other.numNodesWithInstruction.forEach((k, v) -> { + numNodesWithInstruction.merge(k, v, EnabledExecutionTracer::saturatingAdd); + }); + + other.instructionSequencesMap.forEach((k, v) -> { + instructionSequencesMap.merge(k, v, EnabledExecutionTracer::saturatingAdd); + }); + } + + private void calcNumNodesWithInstruction() { + nodesWithInstruction.forEach((k, v) -> { + numNodesWithInstruction.put(k, v.size() + numNodesWithInstruction.getOrDefault(k, 0)); + }); + nodesWithInstruction.clear(); } private JSONObject serialize() { JSONObject result = new JSONObject(); JSONArray activeSpecializationsData = new JSONArray(); - activeSpecializationsMap.forEach((k, v) -> { JSONObject activeSpecData = k.serialize(); activeSpecData.put("c", v); activeSpecializationsData.put(activeSpecData); }); - result.put("as", activeSpecializationsData); + JSONObject ni = new JSONObject(); + calcNumNodesWithInstruction(); + numNodesWithInstruction.forEach((k, v) -> { + ni.put(k.toString(), v); + }); + result.put("ni", ni); + + JSONObject instructionSequences = new JSONObject(); + instructionSequencesMap.forEach((k, v) -> { + instructionSequences.put(k.toKey(), v); + }); + result.put("is", instructionSequences); + return result; } @@ -428,6 +547,16 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { inst.activeSpecializationsMap.put(key, count); } + JSONObject ni = obj.getJSONObject("ni"); + for (String key : ni.keySet()) { + inst.numNodesWithInstruction.put(Integer.parseInt(key), ni.getInt(key)); + } + + JSONObject instructionSequences = obj.getJSONObject("is"); + for (String key : instructionSequences.keySet()) { + inst.instructionSequencesMap.put(InstructionSequenceKey.fromKey(key), instructionSequences.getLong(key)); + } + return inst; } @@ -436,11 +565,27 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats) { result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); + int numDecisions = 100; activeSpecializationsMap.entrySet().stream().filter(e -> e.getKey().getCountActive() > 0).sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).limit(numDecisions).forEachOrdered( e -> { result.put(e.getKey().serializeDecision(stats)); }); + + calcNumNodesWithInstruction(); + + System.err.println("================================================"); + System.err.println("Common instructions: "); + numNodesWithInstruction.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).forEachOrdered(x -> { + System.err.printf("%30s: %d%n", stats.instrNames[x.getKey()], x.getValue()); + }); + System.err.println(); + System.err.println("Common superinstructions: "); + instructionSequencesMap.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).forEachOrdered(x -> { + System.err.printf("%60s: %d%n", x.getKey().toString(stats.instrNames), x.getValue()); + }); + System.err.println("================================================"); + return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index cc5de1537e71..1a118a763084 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -481,11 +481,20 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varEndLabel)); + + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + // } b.end().startElseBlock(); // { b.tree(createPopLastChildCode(vars)); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); // } b.end(); @@ -549,6 +558,10 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varElseLabel)); + + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } // } b.end(); b.startElseIf().variable(vars.childIndex).string(" == 1").end(); @@ -567,6 +580,11 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); b.tree(createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); + + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); // } b.end().startElseBlock(); @@ -578,6 +596,10 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createPopLastChildCode(vars)); } + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, createGetAux(vars, 1, context.labelType))); // } b.end(); @@ -611,6 +633,10 @@ public CodeTree createBeginCode(BuilderVariables vars) { CodeVariableElement varStartLabel = new CodeVariableElement(context.labelType, "startLabel"); b.declaration(context.labelType, varStartLabel.getName(), createCreateLabel()); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, varStartLabel)); b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); @@ -633,6 +659,11 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); + + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + // } b.end().startElseBlock(); // { @@ -640,6 +671,10 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_START_LABEL, context.labelType))); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); // } @@ -671,7 +706,15 @@ public CodeTree createPushCountCode(BuilderVariables vars) { @Override public CodeTree createEndCode(BuilderVariables vars) { - return createEmitLabel(vars, CodeTreeBuilder.singleString("arg0")); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + + b.tree(createEmitLabel(vars, CodeTreeBuilder.singleString("arg0"))); + + return b.build(); } @Override @@ -737,6 +780,10 @@ public CodeTree createAfterChildCode(BuilderVariables vars) { b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_END_LABEL, context.labelType))); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.end().startElseBlock(); b.end(); @@ -763,6 +810,10 @@ public CodeTree createBeforeChildCode(BuilderVariables vars) { public CodeTree createEndCode(BuilderVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); return b.build(); @@ -889,6 +940,10 @@ public CodeTree createBeginCode(BuilderVariables vars) { b.tree(createEmitBranchInstruction(vars, startInstruction, varCurInstrumentId)); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } + b.tree(super.createBeginCode(vars)); return b.build(); } @@ -1053,6 +1108,9 @@ public CodeTree createEndCode(BuilderVariables vars) { b.startBlock(); b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); + if (context.getData().isTracing()) { + b.statement("isBbStart[bci] = true"); + } b.end(); b.declaration(context.exceptionType, "beh", createGetAux(vars, AUX_BEH, context.exceptionType)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 396faeef8af3..da24862bef88 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -296,6 +296,14 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); + if (varTracer != null) { + b.startIf().string("$this.isBbStart[$bci]").end().startBlock(); + b.startStatement().startCall(varTracer, "traceStartBasicBlock"); + b.variable(vars.bci); + b.end(2); + b.end(); + } + b.startTryBlock(); b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); @@ -584,17 +592,19 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr cinstr.setPrepareAOTMethod(metPrepareForAOT); if (m.isTracing()) { - CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), - "doGetStateBits_" + cinstr.getUniqueName() + "_"); - metGetSpecBits.setEnclosingElement(typEnclosingElement); - typEnclosingElement.add(metGetSpecBits); + OperationGeneratorUtils.createHelperMethod(typEnclosingElement, "doGetStateBits_" + cinstr.getUniqueName() + "_", () -> { + CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), + "doGetStateBits_" + cinstr.getUniqueName() + "_"); + + metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "$bc")); + metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); + CodeTreeBuilder b = metGetSpecBits.createBuilder(); + b.tree(plugs.createGetSpecializationBits()); - metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "$bc")); - metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); - CodeTreeBuilder b = metGetSpecBits.createBuilder(); - b.tree(plugs.createGetSpecializationBits()); + cinstr.setGetSpecializationBits(metGetSpecBits); - cinstr.setGetSpecializationBits(metGetSpecBits); + return metGetSpecBits; + }); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 57c36beb5b43..0365896c9385 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -386,10 +386,15 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxLocals"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "sourceInfo"))); + if (m.enableYield) { typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationRoot")), "yieldEntries"))); } + if (m.isTracing()) { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart"))); + } + CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); @@ -738,6 +743,9 @@ private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperatio if (m.getOperationsContext().hasBoxingElimination()) { b.statement("result._localTags = Arrays.copyOf(_localTags, _localTags.length)"); } + if (m.isTracing()) { + b.statement("result.isBbStart = isBbStart"); + } b.statement("result._handlers = _handlers"); b.statement("result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length)"); b.statement("result._maxLocals = _maxLocals"); @@ -999,6 +1007,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "yieldCount")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationLocationImpl")), "yieldLocations = null")); } + if (m.isTracing()) { + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart = new boolean[65535]")); + } CodeVariableElement fldConstPool = typBuilderImpl.add( new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); @@ -1401,6 +1412,10 @@ private CodeExecutableElement createBuilderImplDoEmitLabel(CodeTypeElement typLa b.statement("lbl.hasValue = true"); b.statement("lbl.targetBci = bci"); + if (m.isTracing()) { + b.statement("isBbStart[bci] = true"); + } + return mDoEmitLabel; } @@ -2263,6 +2278,9 @@ private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperat if (m.getOperationsContext().hasBoxingElimination()) { b.statement("result._localTags = new byte[numLocals]"); } + if (m.isTracing()) { + b.statement("result.isBbStart = Arrays.copyOf(isBbStart, bci)"); + } b.statement("result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0])"); b.statement("result._conditionProfiles = new int[numConditionProfiles]"); b.statement("result._maxLocals = numLocals"); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index b0080e437172..ceae51e554df 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index c85ec019b894..03963c829f8a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -3,34 +3,47 @@ "Do not modify, as it will be overwritten when running with tracing support.", "Use the overrides file to alter the optimisation decisions.", { - "specializations": ["FromLong"], + "specializations": ["FromBigNumber"], "type": "Quicken", "operation": "SLUnbox" }, { - "specializations": ["AddLong"], + "specializations": [ + "FromLong", + "FromBigNumber" + ], "type": "Quicken", - "operation": "SLAdd" + "operation": "SLUnbox" }, { - "specializations": ["ReadSLObject0"], + "specializations": ["FromLong"], "type": "Quicken", - "operation": "SLReadProperty" + "operation": "SLUnbox" }, { "specializations": ["FromBoolean"], "type": "Quicken", "operation": "SLUnbox" }, + { + "specializations": ["Add0"], + "type": "Quicken", + "operation": "SLAdd" + }, + { + "specializations": ["ReadSLObject0"], + "type": "Quicken", + "operation": "SLReadProperty" + }, { "specializations": ["Boolean"], "type": "Quicken", "operation": "SLToBoolean" }, { - "specializations": ["LessOrEqual0"], + "specializations": ["Perform"], "type": "Quicken", - "operation": "SLLessOrEqual" + "operation": "SLFunctionLiteral" }, { "specializations": ["Direct"], @@ -38,9 +51,12 @@ "operation": "SLInvoke" }, { - "specializations": ["Perform"], + "specializations": [ + "LessOrEqual0", + "LessOrEqual1" + ], "type": "Quicken", - "operation": "SLFunctionLiteral" + "operation": "SLLessOrEqual" }, { "specializations": ["WriteSLObject0"], @@ -48,8 +64,74 @@ "operation": "SLWriteProperty" }, { - "specializations": ["LessThan0"], + "specializations": ["FromTruffleString"], + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": [ + "LessThan0", + "LessThan1" + ], + "type": "Quicken", + "operation": "SLLessThan" + }, + { + "specializations": ["LessOrEqual1"], + "type": "Quicken", + "operation": "SLLessOrEqual" + }, + { + "specializations": ["AddLong"], + "type": "Quicken", + "operation": "SLAdd" + }, + { + "specializations": ["LessThan1"], "type": "Quicken", "operation": "SLLessThan" + }, + { + "specializations": [ + "FromTruffleString", + "FromBigNumber" + ], + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": [ + "FromTruffleString", + "FromLong" + ], + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": [ + "Add0", + "Add1" + ], + "type": "Quicken", + "operation": "SLAdd" + }, + { + "specializations": [ + "FromTruffleString", + "FromLong", + "FromBigNumber" + ], + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": ["Boolean"], + "type": "Quicken", + "operation": "SLLogicalNot" + }, + { + "specializations": ["FromForeign0"], + "type": "Quicken", + "operation": "SLUnbox" } ] \ No newline at end of file From e285ca4d8f6041dc3384973f6084738df0de7290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 13 Oct 2022 10:10:55 +0200 Subject: [PATCH 153/312] [wip] add generated file --- .../sl/operations/SLOperationRootNode.java | 2 +- .../sl/operations/SLOperationRootNodeGen.java | 14855 ++++++++++++++++ 2 files changed, 14856 insertions(+), 1 deletion(-) create mode 100644 truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index ceae51e554df..b0080e437172 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java new file mode 100644 index 000000000000..d651d64b6aac --- /dev/null +++ b/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -0,0 +1,14855 @@ +// CheckStyle: start generated +package com.oracle.truffle.sl.operations; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; +import com.oracle.truffle.api.dsl.BoundaryCallFailedException; +import com.oracle.truffle.api.dsl.GeneratedBy; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.Frame; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.FrameSlotTypeException; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.impl.UnsafeFrameAccess; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.LibraryFactory; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.LoopNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.operation.OperationBuilder; +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; +import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationParser; +import com.oracle.truffle.api.operation.OperationRootNode; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer; +import com.oracle.truffle.api.operation.serialization.OperationSerializer; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; +import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleString.ConcatNode; +import com.oracle.truffle.api.strings.TruffleString.EqualNode; +import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; +import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.SLTypesGen; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; +import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLFunction; +import com.oracle.truffle.sl.runtime.SLNull; +import com.oracle.truffle.sl.runtime.SLObject; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.IOError; +import java.io.IOException; +import java.lang.invoke.VarHandle; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.locks.Lock; + +@GeneratedBy(SLOperationRootNode.class) +@SuppressWarnings({"unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"}) +public final class SLOperationRootNodeGen extends SLOperationRootNode implements BytecodeOSRNode { + + private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); + private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); + private static final BytecodeLoopBase COMMON_EXECUTE = new BytecodeNode(); + private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; + private static final short INSTR_POP = 1; + private static final int POP_LENGTH = 1; + private static final short INSTR_BRANCH = 2; + private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_LENGTH = 2; + private static final short INSTR_BRANCH_FALSE = 3; + private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; + private static final int BRANCH_FALSE_LENGTH = 3; + private static final short INSTR_THROW = 4; + private static final int THROW_LOCALS_OFFSET = 1; + private static final int THROW_LENGTH = 2; + private static final short INSTR_LOAD_CONSTANT = 5; + private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; + private static final int LOAD_CONSTANT_LENGTH = 2; + private static final short INSTR_LOAD_ARGUMENT = 6; + private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; + private static final int LOAD_ARGUMENT_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL = 7; + private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL_BOXED = 8; + private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_BOXED_LENGTH = 2; + private static final short INSTR_STORE_LOCAL = 9; + private static final int STORE_LOCAL_LOCALS_OFFSET = 1; + private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; + private static final int STORE_LOCAL_LENGTH = 3; + private static final short INSTR_RETURN = 10; + private static final int RETURN_LENGTH = 1; + private static final short INSTR_LOAD_LOCAL_MAT = 11; + private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int LOAD_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_STORE_LOCAL_MAT = 12; + private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int STORE_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_ENTER = 13; + private static final int INSTRUMENT_ENTER_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; + private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT = 15; + private static final int INSTRUMENT_EXIT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_LEAVE = 16; + private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; + private static final int INSTRUMENT_LEAVE_LENGTH = 4; + private static final short INSTR_C_SL_ADD = 17; + private static final int C_SL_ADD_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_LENGTH = 6; + private static final short INSTR_C_SL_DIV = 18; + private static final int C_SL_DIV_CONSTANT_OFFSET = 1; + private static final int C_SL_DIV_CHILDREN_OFFSET = 2; + private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; + private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; + private static final int C_SL_DIV_LENGTH = 6; + private static final short INSTR_C_SL_EQUAL = 19; + private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; + private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; + private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; + private static final int C_SL_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; + private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_THAN = 21; + private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_THAN_LENGTH = 5; + private static final short INSTR_C_SL_LOGICAL_NOT = 22; + private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; + private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; + private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; + private static final int C_SL_LOGICAL_NOT_LENGTH = 5; + private static final short INSTR_C_SL_MUL = 23; + private static final int C_SL_MUL_CONSTANT_OFFSET = 1; + private static final int C_SL_MUL_CHILDREN_OFFSET = 2; + private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; + private static final int C_SL_MUL_LENGTH = 6; + private static final short INSTR_C_SL_READ_PROPERTY = 24; + private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_LENGTH = 6; + private static final short INSTR_C_SL_SUB = 25; + private static final int C_SL_SUB_CONSTANT_OFFSET = 1; + private static final int C_SL_SUB_CHILDREN_OFFSET = 2; + private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; + private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; + private static final int C_SL_SUB_LENGTH = 6; + private static final short INSTR_C_SL_WRITE_PROPERTY = 26; + private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; + private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; + private static final short INSTR_C_SL_UNBOX = 27; + private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_LENGTH = 5; + private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; + private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; + private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; + private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; + private static final short INSTR_C_SL_TO_BOOLEAN = 29; + private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; + private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; + private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_TO_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_INVOKE = 30; + private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; + private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; + private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; + private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; + private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; + private static final int C_SL_INVOKE_LENGTH = 7; + private static final short INSTR_SC_SL_AND = 31; + private static final int SC_SL_AND_CONSTANT_OFFSET = 1; + private static final int SC_SL_AND_CHILDREN_OFFSET = 2; + private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; + private static final int SC_SL_AND_LENGTH = 6; + private static final short INSTR_SC_SL_OR = 32; + private static final int SC_SL_OR_CONSTANT_OFFSET = 1; + private static final int SC_SL_OR_CHILDREN_OFFSET = 2; + private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; + private static final int SC_SL_OR_LENGTH = 6; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 33; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 34; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 35; + private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_ADD_Q_ADD0 = 37; + private static final int C_SL_ADD_Q_ADD0_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD0_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD0_LENGTH = 6; + private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 38; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + private static final short INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 39; + private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; + private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; + private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 40; + private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; + private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; + private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; + private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; + private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; + private static final short INSTR_C_SL_INVOKE_Q_DIRECT = 41; + private static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; + private static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; + private static final int C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET = 3; + private static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 4; + private static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 5; + private static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 7; + private static final short INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 = 42; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH = 5; + private static final short INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 43; + private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; + private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; + private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; + private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; + private static final short INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING = 44; + private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH = 5; + private static final short INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 = 45; + private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH = 5; + private static final short INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 = 46; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH = 5; + private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 47; + private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; + private static final short INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 = 48; + private static final int C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_THAN_Q_LESS_THAN1_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING = 49; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING = 50; + private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH = 5; + private static final short INSTR_C_SL_ADD_Q_ADD0_ADD1 = 51; + private static final int C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD0_ADD1_LENGTH = 6; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING = 52; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH = 5; + private static final short INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN = 53; + private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET = 1; + private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_CHILDREN_OFFSET = 2; + private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 = 54; + private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH = 5; + + @CompilationFinal private OperationNodesImpl nodes; + @CompilationFinal(dimensions = 1) private short[] _bc; + @CompilationFinal(dimensions = 1) private Object[] _consts; + @Children private Node[] _children; + @CompilationFinal(dimensions = 1) private byte[] _localTags; + @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; + @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; + @CompilationFinal private int _maxLocals; + @CompilationFinal private int _maxStack; + @CompilationFinal(dimensions = 1) private int[] sourceInfo; + @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; + @CompilationFinal private int uncachedExecuteCount = 16; + @CompilationFinal private Object _osrMetadata; + private TruffleString _metadata_MethodName; + + private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { + this(language, builder.build()); + } + + static { + OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); + } + + @SuppressWarnings("unchecked") + private static RuntimeException sneakyThrow(Throwable e) throws E { //() { + throw (E) e; + } + + private T insertAccessor(T node) { // () { + return insert(node); + } + + private Object executeAt(VirtualFrame frame, int storedLocation) { + int result = storedLocation; + while (true) { + result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); + if ((result & 0xffff) == 0xffff) { + break; + } else { + SLOperationRootNodeGen $this = this; + hook_transferToInterpreterAndInvalidate($this); + } + } + return frame.getObject((result >> 16) & 0xffff); + } + + @Override + public SourceSection getSourceSection() { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; + } + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if (sourceInfo[i + 1] >= 0) { + int sourceIndex = sourceInfo[i + 0] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); + } + } + return null; + } + + @Override + public SourceSection getSourceSectionAtBci(int bci) { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; + } + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if ((sourceInfo[i + 0] & 0xffff) > bci) { + break; + } + } + if (i == 0) { + return null; + } else { + i -= 3; + int sourceIndex = sourceInfo[i + 0] >> 16; + if (sourceIndex < 0) { + return null; + } + int sourceStart = sourceInfo[i + 1]; + if (sourceStart < 0) { + return null; + } + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); + } + } + + @Override + public Object execute(VirtualFrame frame) { + Object returnValue = null; + Throwable throwable = null; + executeProlog(frame); + try { + returnValue = executeAt(frame, _maxLocals << 16); + return returnValue; + } catch (Throwable th) { + throw sneakyThrow(throwable = th); + } finally { + executeEpilog(frame, returnValue, throwable); + } + } + + @Override + public String dump() { + return switchImpl.dump(_bc, _handlers, _consts); + } + + private Lock getLockAccessor() { + return getLock(); + } + + @Override + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target); + } + + @Override + public Object getOSRMetadata() { + return _osrMetadata; + } + + @Override + public void setOSRMetadata(Object osrMetadata) { + _osrMetadata = osrMetadata; + } + + @Override + public Node deepCopy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = Arrays.copyOf(_bc, _bc.length); + result._consts = Arrays.copyOf(_consts, _consts.length); + result._children = Arrays.copyOf(_children, _children.length); + result._localTags = Arrays.copyOf(_localTags, _localTags.length); + result._handlers = _handlers; + result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + @Override + public Node copy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = _bc; + result._consts = _consts; + result._children = _children; + result._localTags = _localTags; + result._handlers = _handlers; + result._conditionProfiles = _conditionProfiles; + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + private void changeInterpreters(BytecodeLoopBase impl) { + this.switchImpl = impl; + } + + private static void hook_transferToInterpreterAndInvalidate(SLOperationRootNodeGen $this) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (__magic_LogInvalidations) { + System.err.printf("[ INV ] %s%s%n", "", StackWalker.getInstance().walk(s -> s.skip(1).findFirst().get().toStackTraceElement().toString())); + } + } + + private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + Object value; + switch (UFA.unsafeGetTag($frame, localIdx)) { + case 0 /* OBJECT */ : + value = UFA.unsafeUncheckedGetObject($frame, localIdx); + break; + case 5 /* BOOLEAN */ : + value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); + break; + case 1 /* LONG */ : + value = UFA.unsafeUncheckedGetLong($frame, localIdx); + break; + default : + throw CompilerDirectives.shouldNotReachHere(); + } + UFA.unsafeSetObject($frame, $sp, value); + return; + } + + private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13))); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13))); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13))); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13))); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { + CompilerAsserts.neverPartOfCompilation(); + Object value = $frame.getValue(sourceSlot); + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); + // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); + if (bciOffset != 0) { + if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { + if (value instanceof Boolean) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + unsafeWriteBytecode($bc, $bci, (short) ((5 /* BOOLEAN */ << 13) | INSTR_STORE_LOCAL)); + doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); + return; + } + } + if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { + if (value instanceof Long) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + unsafeWriteBytecode($bc, $bci, (short) ((1 /* LONG */ << 13) | INSTR_STORE_LOCAL)); + doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) value); + return; + } + } + doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); + } + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); + unsafeWriteBytecode($bc, $bci, (short) ((7 /* generic */ << 13) | INSTR_STORE_LOCAL)); + UFA.unsafeSetObject($frame, localIdx, value); + } + + private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + hook_transferToInterpreterAndInvalidate($this); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); + } + + private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 5 /* BOOLEAN */) { + try { + UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + hook_transferToInterpreterAndInvalidate($this); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); + } + + private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 1 /* LONG */) { + try { + UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + hook_transferToInterpreterAndInvalidate($this); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); + } + + private static void do_storeLocal_null(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + try { + UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); + } catch (FrameSlotTypeException ex) { + hook_transferToInterpreterAndInvalidate($this); + UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); + } + } + + private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLAdd_q_Add0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLAdd_q_Add0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLToBoolean_q_Boolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLToBoolean_q_Boolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_q_Boolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLFunctionLiteral_q_Perform_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLInvoke_q_Direct_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_q_Direct_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); + } + + private static void SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLWriteProperty_q_WriteSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + private static void SLUnbox_q_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLessThan_q_LessThan0_LessThan1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan0_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessThan_q_LessThan0_LessThan1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan0_LessThan1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLessOrEqual_q_LessOrEqual1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessOrEqual_q_LessOrEqual1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLessThan_q_LessThan1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLessThan_q_LessThan1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLAdd_q_Add0_Add1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_Add1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLAdd_q_Add0_Add1_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_Add1_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLLogicalNot_q_Boolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLLogicalNot_q_Boolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_q_Boolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromForeign0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromForeign0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromForeign0_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); + } + + private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { + if (bciOffset != 0) { + setResultBoxedImpl(bc, startBci - bciOffset, targetType); + } + } + + @ExplodeLoop + private static Object[] do_loadVariadicArguments(VirtualFrame $frame, int $sp, int numVariadics) { + CompilerAsserts.partialEvaluationConstant($sp); + CompilerAsserts.partialEvaluationConstant(numVariadics); + Object[] result = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex); + } + return result; + } + + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { + bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff)); + } + + private static short unsafeFromBytecode(short[] bc, int index) { + return UFA.unsafeShortArrayRead(bc, index); + } + + private static void unsafeWriteBytecode(short[] bc, int index, short value) { + UFA.unsafeShortArrayWrite(bc, index, value); + } + + private static boolean do_profileCondition(SLOperationRootNodeGen $this, boolean value, int[] profiles, int index) { + int t = UFA.unsafeIntArrayRead(profiles, index); + int f = UFA.unsafeIntArrayRead(profiles, index + 1); + boolean val = value; + if (val) { + if (t == 0) { + hook_transferToInterpreterAndInvalidate($this); + } + if (f == 0) { + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < 1073741823) { + UFA.unsafeIntArrayWrite(profiles, index, t + 1); + } + } + } else { + if (f == 0) { + hook_transferToInterpreterAndInvalidate($this); + } + if (t == 0) { + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < 1073741823) { + UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1); + } + } + } + if (CompilerDirectives.inInterpreter()) { + return val; + } else { + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } + + public static OperationNodes create(OperationConfig config, OperationParser generator) { + OperationNodesImpl nodes = new OperationNodesImpl(generator); + Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(nodes, false, config); + generator.parse(builder); + builder.finish(); + return nodes; + } + + public static OperationNodes deserialize(TruffleLanguage language, OperationConfig config, ByteBuffer input, OperationDeserializer callback) throws IOException { + try { + return create(config, b -> Builder.deserializeParser(language, input, callback, b)); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + } + + public static void serialize(OperationConfig config, DataOutput buffer, OperationSerializer callback, OperationParser generator) throws IOException { + Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(null, false, config); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + try { + generator.parse(builder); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + buffer.writeShort((short) -5); + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class ExceptionHandler { + + int startBci; + int startStack; + int endBci; + int exceptionIndex; + int handlerBci; + + ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { + this.startBci = startBci; + this.startStack = startStack; + this.endBci = endBci; + this.exceptionIndex = exceptionIndex; + this.handlerBci = handlerBci; + } + + ExceptionHandler() { + } + + ExceptionHandler offset(int offset, int stackOffset) { + return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); + } + + @Override + public String toString() { + return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private abstract static class BytecodeLoopBase { + + abstract int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); + + abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); + + abstract void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); + + protected static String formatConstant(Object obj) { + if (obj == null) { + return "null"; + } else { + Object repr = obj; + if (obj instanceof Object[]) { + repr = Arrays.deepToString((Object[]) obj); + } + return String.format("%s %s", obj.getClass().getSimpleName(), repr); + } + } + + protected static Object expectObject(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) { + if (bciOffset == 0 || UFA.unsafeIsObject(frame, slot)) { + return UFA.unsafeUncheckedGetObject(frame, slot); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + return frame.getValue(slot); + } + } + + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { + bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff)); + } + + protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + if (bciOffset == 0) { + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Boolean) { + return (boolean) value; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(value); + } + } else { + switch (UFA.unsafeGetTag(frame, slot)) { + case 5 /* BOOLEAN */ : + return UFA.unsafeUncheckedGetBoolean(frame, slot); + case 0 /* OBJECT */ : + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Boolean) { + setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); + return (boolean) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + if (bciOffset == 0) { + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Long) { + return (long) value; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(value); + } + } else { + switch (UFA.unsafeGetTag(frame, slot)) { + case 1 /* LONG */ : + return UFA.unsafeUncheckedGetLong(frame, slot); + case 0 /* OBJECT */ : + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Long) { + setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); + return (long) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationNodesImpl extends OperationNodes { + + OperationNodesImpl(OperationParser parse) { + super(parse); + } + + @Override + protected void reparseImpl(OperationConfig config, OperationParser parse, OperationRootNode[] nodes) { + Builder builder = new Builder(this, true, config); + ((OperationParser) parse).parse(builder); + builder.finish(); + } + + void setSources(Source[] sources) { + this.sources = sources; + } + + Source[] getSources() { + return sources; + } + + void setNodes(SLOperationRootNode[] nodes) { + this.nodes = nodes; + } + + @Override + public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { + Builder builder = new Builder(null, false, config); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + try { + ((OperationParser) parse).parse(builder); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + buffer.writeShort((short) -5); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class BytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_POP : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + continue loop; + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case INSTR_BRANCH : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case INSTR_BRANCH_FALSE : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case INSTR_THROW : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_CONSTANT : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + continue loop; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_ARGUMENT : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + continue loop; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case INSTR_LOAD_LOCAL | (0 /* OBJECT */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + continue loop; + } + case INSTR_LOAD_LOCAL | (5 /* BOOLEAN */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + continue loop; + } + case INSTR_LOAD_LOCAL | (1 /* LONG */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + continue loop; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_BOXED | (0 /* OBJECT */ << 13) : + { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_LOAD_LOCAL); + $bci -= LOAD_LOCAL_BOXED_LENGTH; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + continue loop; + } + case INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + continue loop; + } + case INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + continue loop; + } + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case INSTR_STORE_LOCAL | (0 /* OBJECT */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + continue loop; + } + case INSTR_STORE_LOCAL | (5 /* BOOLEAN */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + continue loop; + } + case INSTR_STORE_LOCAL | (1 /* LONG */ << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + continue loop; + } + case INSTR_STORE_LOCAL | (7 << 13) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + continue loop; + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_RETURN : + { + return (($sp - 1) << 16) | 0xffff; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + continue loop; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case INSTR_STORE_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + continue loop; + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD | (0 /* OBJECT */ << 13) : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + continue loop; + } + case INSTR_C_SL_ADD | (1 /* LONG */ << 13) : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + continue loop; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case INSTR_C_SL_DIV | (0 /* OBJECT */ << 13) : + { + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + continue loop; + } + case INSTR_C_SL_DIV | (1 /* LONG */ << 13) : + { + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + continue loop; + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case INSTR_C_SL_EQUAL | (0 /* OBJECT */ << 13) : + { + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + continue loop; + } + case INSTR_C_SL_EQUAL | (5 /* BOOLEAN */ << 13) : + { + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + continue loop; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL | (0 /* OBJECT */ << 13) : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_OR_EQUAL | (5 /* BOOLEAN */ << 13) : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + continue loop; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN | (0 /* OBJECT */ << 13) : + { + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_THAN | (5 /* BOOLEAN */ << 13) : + { + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + continue loop; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_LOGICAL_NOT | (0 /* OBJECT */ << 13) : + { + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + continue loop; + } + case INSTR_C_SL_LOGICAL_NOT | (5 /* BOOLEAN */ << 13) : + { + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + continue loop; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case INSTR_C_SL_MUL | (0 /* OBJECT */ << 13) : + { + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + continue loop; + } + case INSTR_C_SL_MUL | (1 /* LONG */ << 13) : + { + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + continue loop; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case INSTR_C_SL_READ_PROPERTY : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + continue loop; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case INSTR_C_SL_SUB | (0 /* OBJECT */ << 13) : + { + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + continue loop; + } + case INSTR_C_SL_SUB | (1 /* LONG */ << 13) : + { + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + continue loop; + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case INSTR_C_SL_WRITE_PROPERTY : + { + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + continue loop; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX | (0 /* OBJECT */ << 13) : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX | (1 /* LONG */ << 13) : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case INSTR_C_SL_FUNCTION_LITERAL : + { + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + continue loop; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_TO_BOOLEAN | (0 /* OBJECT */ << 13) : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + continue loop; + } + case INSTR_C_SL_TO_BOOLEAN | (5 /* BOOLEAN */ << 13) : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + continue loop; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case INSTR_C_SL_INVOKE : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + $bci = $bci + C_SL_INVOKE_LENGTH; + continue loop; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_AND | (0 /* OBJECT */ << 13) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case INSTR_SC_SL_AND | (5 /* BOOLEAN */ << 13) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_OR | (0 /* OBJECT */ << 13) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case INSTR_SC_SL_OR | (5 /* BOOLEAN */ << 13) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // c.SLUnbox.q.FromBigNumber + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromBigNumber.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_LONG | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + continue loop; + } + // c.SLAdd.q.Add0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD_Q_ADD0 | (0 /* OBJECT */ << 13) : + { + SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + continue loop; + } + case INSTR_C_SL_ADD_Q_ADD0 | (1 /* LONG */ << 13) : + { + SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + continue loop; + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + continue loop; + } + // c.SLToBoolean.q.Boolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | (0 /* OBJECT */ << 13) : + { + SLToBoolean_q_Boolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + continue loop; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | (5 /* BOOLEAN */ << 13) : + { + SLToBoolean_q_Boolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + continue loop; + } + // c.SLFunctionLiteral.q.Perform + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + SLFunctionLiteral_q_Perform_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + continue loop; + } + // c.SLInvoke.q.Direct + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0); + SLInvoke_q_Direct_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + continue loop; + } + // c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | (0 /* OBJECT */ << 13) : + { + SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | (5 /* BOOLEAN */ << 13) : + { + SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + continue loop; + } + // c.SLWriteProperty.q.WriteSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + SLWriteProperty_q_WriteSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromTruffleString + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + // c.SLLessThan.q.LessThan0.LessThan1 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | (0 /* OBJECT */ << 13) : + { + SLLessThan_q_LessThan0_LessThan1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | (5 /* BOOLEAN */ << 13) : + { + SLLessThan_q_LessThan0_LessThan1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + continue loop; + } + // c.SLLessOrEqual.q.LessOrEqual1 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | (0 /* OBJECT */ << 13) : + { + SLLessOrEqual_q_LessOrEqual1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | (5 /* BOOLEAN */ << 13) : + { + SLLessOrEqual_q_LessOrEqual1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + continue loop; + } + // c.SLAdd.q.AddLong + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD_Q_ADD_LONG | (0 /* OBJECT */ << 13) : + { + SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + continue loop; + } + case INSTR_C_SL_ADD_Q_ADD_LONG | (1 /* LONG */ << 13) : + { + SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + continue loop; + } + // c.SLLessThan.q.LessThan1 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | (0 /* OBJECT */ << 13) : + { + SLLessThan_q_LessThan1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + continue loop; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | (5 /* BOOLEAN */ << 13) : + { + SLLessThan_q_LessThan1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromBigNumber.FromTruffleString + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromLong.FromTruffleString + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromLong_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromLong_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromLong_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + // c.SLAdd.q.Add0.Add1 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD_Q_ADD0_ADD1 | (0 /* OBJECT */ << 13) : + { + SLAdd_q_Add0_Add1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + continue loop; + } + case INSTR_C_SL_ADD_Q_ADD0_ADD1 | (1 /* LONG */ << 13) : + { + SLAdd_q_Add0_Add1_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + continue loop; + } + // c.SLLogicalNot.q.Boolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | (0 /* OBJECT */ << 13) : + { + SLLogicalNot_q_Boolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + continue loop; + } + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | (5 /* BOOLEAN */ << 13) : + { + SLLogicalNot_q_Boolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + continue loop; + } + // c.SLUnbox.q.FromForeign0 + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (0 /* OBJECT */ << 13) : + { + SLUnbox_q_FromForeign0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (1 /* LONG */ << 13) : + { + SLUnbox_q_FromForeign0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + continue loop; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (5 /* BOOLEAN */ << 13) : + { + SLUnbox_q_FromForeign0_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + continue loop; + } + default : + hook_transferToInterpreterAndInvalidate($this); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : + { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : + { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0_ADD1 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : + { + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + break; + } + } + } + } + + @Override + String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + StringBuilder sb = new StringBuilder(); + while ($bci < $bc.length) { + sb.append(String.format(" [%04x]", $bci)); + switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { + default : + { + sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); + break; + } + case INSTR_POP : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("pop "); + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch "); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch.false "); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("throw "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0))); + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boxed "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.mat "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.mat "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLDiv "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEqual "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLMul "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLSub "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLInvoke "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0))); + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLAnd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLOr "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromLong"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBoolean "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.Add0 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty.q.ReadSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral.q.Perform "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLInvoke.q.Direct "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0))); + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty.q.WriteSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromTruffleString "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan0.LessThan1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.AddLong "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan1 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0_ADD1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.Add0.Add1 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromForeign0 "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < $handlers.length; i++) { + sb.append($handlers[i] + "\n"); + } + return sb.toString(); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLAddNode.addLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b1111) == 0b1/* is-exact-state_0 addLong(long, long) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD_LONG | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); + } + try { + lock.unlock(); + hasLock = false; + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0 | primitiveTagBits)); + } else if ((state_0 & 0b1111) == 0b110/* is-exact-state_0 add(SLBigNumber, SLBigNumber)&&add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0_ADD1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value_, $child1Value_); + } + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b1111) == 0b110/* is-exact-state_0 add(SLBigNumber, SLBigNumber)&&add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0_ADD1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLDivNode.divLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLDivNode.div($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLDivNode.div($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.leftInterop_.accepts($child0Value)); + // assert (s7_.rightInterop_.accepts($child1Value)); + if (count7_ < (4)) { + s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + } + } + { + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessOrEqual(long, long)&&lessOrEqual(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessOrEqual(long, long)&&lessOrEqual(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | primitiveTagBits)); + } else if ((state_0 & 0b111) == 0b10/* is-exact-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessThan(long, long)&&lessThan(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessThan(long, long)&&lessThan(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | primitiveTagBits)); + } else if ((state_0 & 0b111) == 0b10/* is-exact-state_0 lessThan(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); + } + + private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLLogicalNotNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { + return SLLogicalNotNode.doBoolean($child0Value_); + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b1/* is-exact-state_0 doBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLMulNode.mulLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLMulNode.mul($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @ExplodeLoop + private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { + Node node__2 = ($this); + int bci__2 = ($bci); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + try { + return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = ($this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + node__1 = ($this); + bci__1 = ($bci); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + } + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = ($this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); + } + } + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { + node__2 = ($this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (s4_.objects_.accepts($child0Value)); + InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); + node__2 = ($this); + bci__2 = ($bci); + s4_.objects_ = s4_.insertAccessor(objects__); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 8] = s4_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + } + } + { + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = ($this); + readObject1_bci__ = ($bci); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 8] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLSubNode.subLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLSubNode.sub($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); + if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + try { + return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + int writeArray1_bci__ = 0; + Node writeArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + writeArray1_node__ = ($this); + writeArray1_bci__ = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b100/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + } + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); + } + } + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (s4_.objectLibrary_.accepts($child0Value)); + s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); + node__1 = ($this); + bci__1 = ($bci); + s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 7] = s4_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = ($this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 7] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); + if (fromString_fromJavaStringNode__ != null) { + return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLUnboxNode.fromBoolean($child0Value__); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + try { + return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { + return SLUnboxNode.fromBoolean($child0Value_); + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { + return SLUnboxNode.fromLong($child0Value_); + } + hook_transferToInterpreterAndInvalidate($this); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111111111) == 0b10/* is-exact-state_0 fromTruffleString(TruffleString) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b10010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b1010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b1010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromLong($child0Value_); + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b10010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBigNumber($child0Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.interop_.accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if ((state_0 & 0b111111111) == 0b10000000/* is-exact-state_0 fromForeign(Object, InteropLibrary) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + } + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, s7_.interop_); + } + } + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); + if (result__ != null) { + return SLFunctionLiteralNode.perform($child0Value__, result__, node__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + node__ = ($this); + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b1/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_FUNCTION_LITERAL | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b1/* is-exact-state_0 doBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); + Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); + if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + hook_transferToInterpreterAndInvalidate($this); + SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); + } + if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); + if (indirect_callNode__ != null) { + return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = ($this); + int interop_bci__ = ($bci); + InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); + if (interop_library__ != null) { + return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); + } + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); + } + + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); + if (($child0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + s0_.callTargetStable_ = callTargetStable__; + s0_.cachedTarget_ = cachedTarget__; + s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + if (state_0 == 0b1/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE_Q_DIRECT | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); + } + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + } + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[childArrayOffset_ + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = ($this); + interop_bci__ = ($bci); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); + } + + private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + @ExplodeLoop + private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_READ_PROPERTY); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_TO_BOOLEAN); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLToBoolean_q_Boolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_TO_BOOLEAN); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static Object SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0) + 0)); + if (result__ != null) { + return SLFunctionLiteralNode.perform($child0Value__, result__, node__); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_FUNCTION_LITERAL); + return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + @ExplodeLoop + private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff)); + Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; + if ($child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + hook_transferToInterpreterAndInvalidate($this); + SLInvoke_q_Direct_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_INVOKE); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); + } + if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_INVOKE); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); + } + + private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0)); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + @ExplodeLoop + private static Object SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_WRITE_PROPERTY); + return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + } + + private static Object SLUnbox_q_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; + if ($child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static boolean SLLessThan_q_LessThan0_LessThan1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_q_LessThan0_LessThan1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static Object SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessThan_q_LessThan0_LessThan1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_q_LessThan0_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static boolean SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static boolean SLLessOrEqual_q_LessOrEqual1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessOrEqual_q_LessOrEqual1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_q_LessOrEqual1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessOrEqual_q_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_AddLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static long SLAdd_q_AddLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + hook_transferToInterpreterAndInvalidate($this); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + + private static boolean SLLessThan_q_LessThan1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_q_LessThan1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessThan_q_LessThan1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_q_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromLong_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromLong_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromLong_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static boolean SLAdd_q_Add0_Add1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_Add0_Add1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_q_Add0_Add1_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_Add0_Add1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLTypesGen.expectLong(SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); + } + } + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static boolean SLLogicalNot_q_Boolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLLogicalNot_q_Boolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LOGICAL_NOT); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); + } + + private static boolean SLLogicalNot_q_Boolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLogicalNot_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LOGICAL_NOT); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); + } + + @ExplodeLoop + private static Object SLUnbox_q_FromForeign0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + } + s7_ = s7_.next_; + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + @ExplodeLoop + private static boolean SLUnbox_q_FromForeign0_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLTypesGen.expectBoolean(SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); + } + s7_ = s7_.next_; + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + @ExplodeLoop + private static long SLUnbox_q_FromForeign0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLTypesGen.expectLong(SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); + } + s7_ = s7_.next_; + } + hook_transferToInterpreterAndInvalidate($this); + unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + hook_transferToInterpreterAndInvalidate($this); + int uncachedExecuteCount = $this.uncachedExecuteCount; + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_POP : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + continue loop; + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case INSTR_BRANCH : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + uncachedExecuteCount--; + if (uncachedExecuteCount <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case INSTR_BRANCH_FALSE : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case INSTR_THROW : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_CONSTANT : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + continue loop; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_ARGUMENT : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + continue loop; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case INSTR_LOAD_LOCAL : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + continue loop; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_BOXED : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + continue loop; + } + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case INSTR_STORE_LOCAL : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + continue loop; + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_RETURN : + { + uncachedExecuteCount--; + if (uncachedExecuteCount <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount; + } + return (($sp - 1) << 16) | 0xffff; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + continue loop; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case INSTR_STORE_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + continue loop; + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD : + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + continue loop; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case INSTR_C_SL_DIV : + { + SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + continue loop; + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case INSTR_C_SL_EQUAL : + { + SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + continue loop; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL : + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + continue loop; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN : + { + SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + continue loop; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_LOGICAL_NOT : + { + SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + continue loop; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case INSTR_C_SL_MUL : + { + SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + continue loop; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case INSTR_C_SL_READ_PROPERTY : + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + continue loop; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case INSTR_C_SL_SUB : + { + SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + continue loop; + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case INSTR_C_SL_WRITE_PROPERTY : + { + SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + continue loop; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX : + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + continue loop; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case INSTR_C_SL_FUNCTION_LITERAL : + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + continue loop; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_TO_BOOLEAN : + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + continue loop; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case INSTR_C_SL_INVOKE : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + $bci = $bci + C_SL_INVOKE_LENGTH; + continue loop; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_AND : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_OR : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + default : + hook_transferToInterpreterAndInvalidate($this); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : + { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : + { + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0_ADD1 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : + { + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + break; + } + } + } + } + + @Override + String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + StringBuilder sb = new StringBuilder(); + while ($bci < $bc.length) { + sb.append(String.format(" [%04x]", $bci)); + switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { + default : + { + sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); + break; + } + case INSTR_POP : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("pop "); + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch "); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("branch.false "); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("throw "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0))); + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.constant "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]))); + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.argument "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.boxed "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local "); + sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("return "); + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("load.local.mat "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("store.local.mat "); + sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLDiv "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLEqual "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLMul "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLSub "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLInvoke "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0))); + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLAnd "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("sc.SLOr "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0))); + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromLong"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBoolean "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.Add0 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLReadProperty.q.ReadSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLToBoolean.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLFunctionLiteral.q.Perform "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; + break; + } + case INSTR_C_SL_INVOKE_Q_DIRECT : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLInvoke.q.Direct "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0))); + $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(String.format(" %04x", $bc[$bci + 6])); + sb.append(" "); + sb.append("c.SLWriteProperty.q.WriteSLObject0"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff))); + $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromTruffleString "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan0.LessThan1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessOrEqual.q.LessOrEqual1"); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.AddLong "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLessThan.q.LessThan1 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromLong.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0_ADD1 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(String.format(" %04x", $bc[$bci + 5])); + sb.append(" "); + sb.append(" "); + sb.append("c.SLAdd.q.Add0.Add1 "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff))); + sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); + $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString"); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLLogicalNot.q.Boolean "); + sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : + { + sb.append(String.format(" %04x", $bc[$bci + 0])); + sb.append(String.format(" %04x", $bc[$bci + 1])); + sb.append(String.format(" %04x", $bc[$bci + 2])); + sb.append(String.format(" %04x", $bc[$bci + 3])); + sb.append(String.format(" %04x", $bc[$bci + 4])); + sb.append(" "); + sb.append(" "); + sb.append(" "); + sb.append("c.SLUnbox.q.FromForeign0 "); + sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff))); + $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; + break; + } + } + sb.append("\n"); + } + for (int i = 0; i < $handlers.length; i++) { + sb.append($handlers[i] + "\n"); + } + return sb.toString(); + } + + private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLDivNode.div($child0Value_, $child1Value_); + } + } + return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + + private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); + } + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); + } + + private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } + + private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } + + private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLAdd_q_Add0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } + + private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } + + private static Object SLUnbox_q_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLLessThan_q_LessThan0_LessThan1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLessOrEqual_q_LessOrEqual1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLessThan_q_LessThan1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromBigNumber_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromLong_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLAdd_q_Add0_Add1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLLogicalNot_q_Boolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); + } + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromForeign0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + hook_transferToInterpreterAndInvalidate($this); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + public static final class Builder extends OperationBuilder { + + private static final int OP_BLOCK = 1; + private static final int OP_ROOT = 2; + private static final int OP_IF_THEN = 3; + private static final int OP_IF_THEN_ELSE = 4; + private static final int OP_CONDITIONAL = 5; + private static final int OP_WHILE = 6; + private static final int OP_TRY_CATCH = 7; + private static final int OP_FINALLY_TRY = 8; + private static final int OP_FINALLY_TRY_NO_EXCEPT = 9; + private static final int OP_LABEL = 10; + private static final int OP_BRANCH = 11; + private static final int OP_LOAD_CONSTANT = 12; + private static final int OP_LOAD_ARGUMENT = 13; + private static final int OP_LOAD_LOCAL = 14; + private static final int OP_STORE_LOCAL = 15; + private static final int OP_RETURN = 16; + private static final int OP_LOAD_LOCAL_MATERIALIZED = 17; + private static final int OP_STORE_LOCAL_MATERIALIZED = 18; + private static final int OP_SOURCE = 19; + private static final int OP_SOURCE_SECTION = 20; + private static final int OP_TAG = 21; + private static final int OP_SL_ADD = 22; + private static final int OP_SL_DIV = 23; + private static final int OP_SL_EQUAL = 24; + private static final int OP_SL_LESS_OR_EQUAL = 25; + private static final int OP_SL_LESS_THAN = 26; + private static final int OP_SL_LOGICAL_NOT = 27; + private static final int OP_SL_MUL = 28; + private static final int OP_SL_READ_PROPERTY = 29; + private static final int OP_SL_SUB = 30; + private static final int OP_SL_WRITE_PROPERTY = 31; + private static final int OP_SL_UNBOX = 32; + private static final int OP_SL_FUNCTION_LITERAL = 33; + private static final int OP_SL_TO_BOOLEAN = 34; + private static final int OP_SL_INVOKE = 35; + private static final int OP_SL_AND = 36; + private static final int OP_SL_OR = 37; + + private final com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes; + private final boolean isReparse; + private final boolean withSource; + private final boolean withInstrumentation; + private final SourceInfoBuilder sourceBuilder; + private short[] bc = new short[65535]; + private int bci; + private int curStack; + private int maxStack; + private int numLocals; + private int numLabels; + private ArrayList constPool = new ArrayList<>(); + private BuilderOperationData operationData; + private ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private int numChildNodes; + private int numConditionProfiles; + private ArrayList exceptionHandlers = new ArrayList<>(); + private BuilderFinallyTryContext currentFinallyTry; + private int buildIndex; + private boolean isSerializing; + private DataOutput serBuffer; + private OperationSerializer serCallback; + private int[] stackSourceBci = new int[1024]; + private BuilderState parentData; + private SerializerContext SER_CONTEXT = new SerializerContext() { + @Override + public void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException { + buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); + } + } + ; + private final ArrayList builtNodes; + private int lastChildPush; + private TruffleString metadata_MethodName; + + private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { + this.nodes = nodes; + this.isReparse = isReparse; + builtNodes = new ArrayList<>(); + if (isReparse) { + builtNodes.addAll((java.util.Collection) nodes.getNodes()); + } + this.withSource = config.isWithSource(); + this.withInstrumentation = config.isWithInstrumentation(); + this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; + } + + private void finish() { + if (withSource) { + nodes.setSources(sourceBuilder.buildSource()); + } + if (!isReparse) { + nodes.setNodes(builtNodes.toArray(new SLOperationRootNode[0])); + } + } + + private void reset(TruffleLanguage language) { + bci = 0; + curStack = 0; + maxStack = 0; + numLocals = 0; + constPool.clear(); + operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language); + labelFills.clear(); + numChildNodes = 0; + numConditionProfiles = 0; + exceptionHandlers.clear(); + metadata_MethodName = null; + } + + private int[] doBeforeEmitInstruction(int numPops, boolean pushValue, boolean doBoxing) { + int[] result = new int[numPops]; + for (int i = numPops - 1; i >= 0; i--) { + curStack--; + int predBci = stackSourceBci[curStack]; + result[i] = predBci; + } + if (pushValue) { + if (curStack >= stackSourceBci.length) { + stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); + } + stackSourceBci[curStack] = doBoxing ? bci : -65535; + curStack++; + if (curStack > maxStack) { + maxStack = curStack; + } + } + return result; + } + + private void doLeaveFinallyTry(BuilderOperationData opData) { + BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; + if (context.handlerBc == null) { + return; + } + System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); + for (int offset : context.relocationOffsets) { + short oldOffset = bc[bci + offset]; + bc[bci + offset] = (short) (oldOffset + bci); + } + for (ExceptionHandler handler : context.handlerHandlers) { + exceptionHandlers.add(handler.offset(bci, curStack)); + } + for (LabelFill fill : context.handlerLabelFills) { + labelFills.add(fill.offset(bci)); + } + if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; + bci += context.handlerBc.length; + } + + private void doEmitLabel(OperationLabel label) { + OperationLabelImpl lbl = (OperationLabelImpl) label; + if (lbl.hasValue) { + throw new UnsupportedOperationException("label already emitted"); + } + if (operationData != lbl.data) { + throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); + } + lbl.hasValue = true; + lbl.targetBci = bci; + } + + private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { + if (toData != null && fromData.depth < toData.depth) { + throw new UnsupportedOperationException("illegal jump to deeper operation"); + } + if (fromData == toData) { + return; + } + BuilderOperationData cur = fromData; + while (true) { + doLeaveOperation(cur); + cur = cur.parent; + if (toData == null && cur == null) { + break; + } else if (toData != null && cur.depth <= toData.depth) break; + } + if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); + } + + private void calculateLeaves(BuilderOperationData fromData) { + calculateLeaves(fromData, (BuilderOperationData) null); + } + + private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { + calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); + } + + public OperationLocal createLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -3); + return new OperationLocalImpl(null, numLocals++); + } catch (IOException ex) { + throw new IOError(ex); + } + } + return new OperationLocalImpl(operationData, numLocals++); + } + + private OperationLocalImpl createParentLocal() { + return new OperationLocalImpl(operationData.parent, numLocals++); + } + + public OperationLabel createLabel() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -2); + return new OperationSerLabelImpl(numLabels++); + } catch (IOException ex) { + throw new IOError(ex); + } + } + OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); + labels.add(label); + return label; + } + + private short getLocalIndex(Object value) { + OperationLocalImpl local = (OperationLocalImpl) value; + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + return (short) local.id; + } + + private int[] getLocalIndices(Object value) { + OperationLocal[] locals = (OperationLocal[]) value; + int[] result = new int[locals.length]; + for (int i = 0; i < locals.length; i++) { + result[i] = getLocalIndex(locals[i]); + } + return result; + } + + private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { + BuilderOperationData cur = child; + while (cur.depth > parent.depth) { + cur = cur.parent; + } + return cur == parent; + } + + private SLOperationRootNode publish(TruffleLanguage language) { + if (isSerializing) { + SLOperationRootNode result = new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++); + numLocals = 0; + numLabels = 0; + return result; + } + if (operationData.depth != 0) { + throw new UnsupportedOperationException("Not all operations closed"); + } + SLOperationRootNodeGen result; + if (!isReparse) { + FrameDescriptor .Builder frameDescriptor; + frameDescriptor = FrameDescriptor.newBuilder(numLocals + maxStack); + frameDescriptor.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); + result = new SLOperationRootNodeGen(language, frameDescriptor); + result.nodes = nodes; + labelPass(null); + result._bc = Arrays.copyOf(bc, bci); + result._consts = constPool.toArray(); + result._children = new Node[numChildNodes]; + result._localTags = new byte[numLocals]; + result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); + result._conditionProfiles = new int[numConditionProfiles]; + result._maxLocals = numLocals; + result._maxStack = maxStack; + if (sourceBuilder != null) { + result.sourceInfo = sourceBuilder.build(); + } + result._metadata_MethodName = metadata_MethodName; + assert builtNodes.size() == buildIndex; + builtNodes.add(result); + } else { + result = builtNodes.get(buildIndex); + if (withSource && result.sourceInfo == null) { + result.sourceInfo = sourceBuilder.build(); + } + } + buildIndex++; + reset(language); + return result; + } + + private void labelPass(BuilderFinallyTryContext finallyTry) { + for (LabelFill fill : labelFills) { + if (finallyTry != null) { + if (fill.label.belongsTo(finallyTry)) { + assert fill.label.hasValue : "inner label should have been resolved by now"; + finallyTry.relocationOffsets.add(fill.locationBci); + } else { + finallyTry.handlerLabelFills.add(fill); + } + } + bc[fill.locationBci] = (short) fill.label.targetBci; + } + } + + private void doLeaveOperation(BuilderOperationData data) { + switch (data.operationId) { + case OP_FINALLY_TRY : + { + doLeaveFinallyTry(data); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + doLeaveFinallyTry(data); + break; + } + case OP_TAG : + { + break; + } + } + } + + @SuppressWarnings("unused") + private void doBeforeChild() { + int childIndex = operationData.numChildren; + switch (operationData.operationId) { + case OP_BLOCK : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_ROOT : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_TRY_CATCH : + { + if (childIndex == 1) { + curStack = ((ExceptionHandler) operationData.aux[0]).startStack; + ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; + } + break; + } + case OP_SOURCE : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_SOURCE_SECTION : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_TAG : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_SL_AND : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_SC_SL_AND); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + bci = bci + SC_SL_AND_LENGTH; + } + break; + } + case OP_SL_OR : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_SC_SL_OR); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + bci = bci + SC_SL_OR_LENGTH; + } + break; + } + } + } + + @SuppressWarnings("unused") + private void doAfterChild() { + int childIndex = operationData.numChildren++; + switch (operationData.operationId) { + case OP_IF_THEN : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = endLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + bci = bci + BRANCH_FALSE_LENGTH; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } + break; + } + case OP_IF_THEN_ELSE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + bci = bci + BRANCH_FALSE_LENGTH; + } else if (childIndex == 1) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_CONDITIONAL : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + bci = bci + BRANCH_FALSE_LENGTH; + } else if (childIndex == 1) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + assert lastChildPush == 1; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_WHILE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + bci = bci + BRANCH_FALSE_LENGTH; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_TRY_CATCH : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + ((ExceptionHandler) operationData.aux[0]).endBci = bci; + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); + bci = bci + BRANCH_LENGTH; + } else { + } + break; + } + case OP_FINALLY_TRY : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.aux[2]); + exceptionHandlers.add(beh); + operationData.aux[1] = beh; + } + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_POP); + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + } + break; + } + } + } + + @SuppressWarnings("unused") + public void beginBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BLOCK << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); + lastChildPush = 0; + } + + @SuppressWarnings("unused") + public void endBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_BLOCK) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); + } + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginRoot(TruffleLanguage arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_ROOT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + lastChildPush = 0; + this.parentData = new BuilderState(this); + this.bc = new short[65535]; + this.constPool = new ArrayList<>(); + this.labels = new ArrayList<>(); + this.labelFills = new ArrayList<>(); + this.exceptionHandlers = new ArrayList<>(); + this.stackSourceBci = new int[1024]; + reset(arg0); + } + + @SuppressWarnings("unused") + public SLOperationRootNode endRoot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_ROOT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return publish(null); + } + if (operationData.operationId != OP_ROOT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Root expected at least 0 children, got " + numChildren); + } + lastChildPush = 0; + SLOperationRootNode endCodeResult; + endCodeResult = publish((TruffleLanguage) operationData.arguments[0]); + this.bc = parentData.bc; + this.bci = parentData.bci; + this.curStack = parentData.curStack; + this.maxStack = parentData.maxStack; + this.numLocals = parentData.numLocals; + this.numLabels = parentData.numLabels; + this.constPool = parentData.constPool; + this.operationData = parentData.operationData; + this.labels = parentData.labels; + this.labelFills = parentData.labelFills; + this.numChildNodes = parentData.numChildNodes; + this.numConditionProfiles = parentData.numConditionProfiles; + this.exceptionHandlers = parentData.exceptionHandlers; + this.currentFinallyTry = parentData.currentFinallyTry; + this.stackSourceBci = parentData.stackSourceBci; + this.parentData = parentData.parentData; + return endCodeResult; + } + + @SuppressWarnings("unused") + public void beginIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); + } + + @SuppressWarnings("unused") + public void endIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_IF_THEN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); + } + + @SuppressWarnings("unused") + public void endIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_IF_THEN_ELSE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); + } + + @SuppressWarnings("unused") + public void endConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_CONDITIONAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); + } + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_WHILE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = startLabel; + } + + @SuppressWarnings("unused") + public void endWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_WHILE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("While expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginTryCatch(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); + exceptionHandlers.add(beh); + operationData.aux[0] = beh; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + } + + @SuppressWarnings("unused") + public void endTryCatch() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_TRY_CATCH) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); + operationData.aux[2] = createParentLocal(); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + public void endFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_FINALLY_TRY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); + } + int endBci = bci; + doLeaveFinallyTry(operationData); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + { + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bci = bci + BRANCH_LENGTH; + } + ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); + beh.endBci = endBci; + beh.handlerBci = bci; + doLeaveFinallyTry(operationData); + { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_THROW); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); + bci = bci + THROW_LENGTH; + } + doEmitLabel(endLabel); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + public void endFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); + } + doLeaveFinallyTry(operationData); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLabel(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LABEL << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + doEmitLabel(arg0); + lastChildPush = 0; + doAfterChild(); + } + + public void emitBranch(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BRANCH << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); + calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_BRANCH); + labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); + bci = bci + BRANCH_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadConstant(Object arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_LOAD_CONSTANT << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_CONSTANT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, false); + unsafeWriteBytecode(bc, bci, INSTR_LOAD_CONSTANT); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(operationData.arguments[0]); + bci = bci + LOAD_CONSTANT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadArgument(int arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); + serBuffer.writeInt(arg0); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, false); + unsafeWriteBytecode(bc, bci, INSTR_LOAD_ARGUMENT); + bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; + bci = bci + LOAD_ARGUMENT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, true); + unsafeWriteBytecode(bc, bci, INSTR_LOAD_LOCAL); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + bci = bci + LOAD_LOCAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginStoreLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endStoreLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_STORE_LOCAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_STORE_LOCAL); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bci = bci + STORE_LOCAL_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_RETURN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_RETURN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("Return expected 1 children, got " + numChildren); + } + calculateLeaves(operationData); + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, INSTR_RETURN); + bci = bci + RETURN_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginLoadLocalMaterialized(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_LOCAL_MATERIALIZED << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endLoadLocalMaterialized() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_LOAD_LOCAL_MATERIALIZED << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_LOAD_LOCAL_MATERIALIZED) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("LoadLocalMaterialized expected 1 children, got " + numChildren); + } + doBeforeEmitInstruction(1, true, false); + unsafeWriteBytecode(bc, bci, INSTR_LOAD_LOCAL_MAT); + bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; + bci = bci + LOAD_LOCAL_MAT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginStoreLocalMaterialized(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_STORE_LOCAL_MATERIALIZED << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endStoreLocalMaterialized() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_STORE_LOCAL_MATERIALIZED << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_STORE_LOCAL_MATERIALIZED) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("StoreLocalMaterialized expected 2 children, got " + numChildren); + } + doBeforeEmitInstruction(2, false, false); + unsafeWriteBytecode(bc, bci, INSTR_STORE_LOCAL_MAT); + bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; + bci = bci + STORE_LOCAL_MAT_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSource(Source arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_SOURCE << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); + sourceBuilder.beginSource(bci, arg0); + } + } + + @SuppressWarnings("unused") + public void endSource() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + if (operationData.operationId != OP_SOURCE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSource(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginSourceSection(int arg0, int arg1) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); + serBuffer.writeInt(arg0); + serBuffer.writeInt(arg1); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); + sourceBuilder.beginSourceSection(bci, arg0, arg1); + } + } + + @SuppressWarnings("unused") + public void endSourceSection() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + if (operationData.operationId != OP_SOURCE_SECTION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSourceSection(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginTag(Class arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_TAG << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withInstrumentation) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); + int curInstrumentId = 0; + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = curInstrumentId; + operationData.aux[1] = startLabel; + operationData.aux[2] = endLabel; + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_ENTER); + bci = bci + INSTRUMENT_ENTER_LENGTH; + lastChildPush = 0; + } + } + + @SuppressWarnings("unused") + public void endTag() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withInstrumentation) { + if (operationData.operationId != OP_TAG) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); + } + if (lastChildPush != 0) { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_EXIT_VOID); + bci = bci + INSTRUMENT_EXIT_VOID_LENGTH; + } else { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_EXIT); + bci = bci + INSTRUMENT_EXIT_LENGTH; + } + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_ADD << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_ADD) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_ADD); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 2; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + C_SL_ADD_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_DIV << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_DIV) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_DIV); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + C_SL_DIV_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_EQUAL); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 4; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + bci = bci + C_SL_EQUAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_LESS_OR_EQUAL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bci = bci + C_SL_LESS_OR_EQUAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LESS_THAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_LESS_THAN); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bci = bci + C_SL_LESS_THAN_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LOGICAL_NOT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_LOGICAL_NOT); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + C_SL_LOGICAL_NOT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_MUL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_MUL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_MUL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + C_SL_MUL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_READ_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, false); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_READ_PROPERTY); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 12; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + C_SL_READ_PROPERTY_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_SUB << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_SUB) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_SUB); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + bci = bci + C_SL_SUB_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_WRITE_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(3, true, false); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_WRITE_PROPERTY); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 11; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); + bc[bci + 5 + 0] = 0; + bc[bci + 5 + 1] = 0; + bci = bci + C_SL_WRITE_PROPERTY_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_UNBOX) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_UNBOX); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 3; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + bci = bci + C_SL_UNBOX_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLFunctionLiteral() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLFunctionLiteral() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, false); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_FUNCTION_LITERAL); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + C_SL_FUNCTION_LITERAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_TO_BOOLEAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_TO_BOOLEAN); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + bci = bci + C_SL_TO_BOOLEAN_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_INVOKE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(numChildren - 1 + 0, true, false); + unsafeWriteBytecode(bc, bci, INSTR_C_SL_INVOKE); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 5; + bc[bci + 4] = (short) (numChildren - 1); + bc[bci + 5 + 0] = 0; + bc[bci + 5 + 1] = 0; + bci = bci + C_SL_INVOKE_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_AND << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + public void endSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_AND) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_OR << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + public void endSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_OR) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void setMethodName(TruffleString value) { + if (isSerializing) { + try { + serBuffer.writeShort((short) -6); + serBuffer.writeShort(0); + serCallback.serialize(SER_CONTEXT, serBuffer, value); + return; + } catch (IOException ex) { + throw new IOError(ex); + } + } + metadata_MethodName = value; + } + + private static void deserializeParser(TruffleLanguage language, ByteBuffer buffer, OperationDeserializer callback, com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder builder) { + try { + ArrayList consts = new ArrayList<>(); + ArrayList locals = new ArrayList<>(); + ArrayList labels = new ArrayList<>(); + ArrayList builtNodes = new ArrayList<>(); + buffer.rewind(); + DataInput dataInput = com.oracle.truffle.api.operation.serialization.ByteBufferDataInput.createDataInput(buffer); + DeserializerContext context = new DeserializerContext(){ + @Override + public SLOperationRootNode deserializeOperationNode(DataInput buffer) throws IOException { + return builtNodes.get(buffer.readInt()); + } + } + ; + while (true) { + switch (buffer.getShort()) { + case -2 : + { + labels.add(builder.createLabel()); + break; + } + case -3 : + { + locals.add(builder.createLocal()); + break; + } + case -4 : + { + consts.add(callback.deserialize(context, dataInput)); + break; + } + case -5 : + { + return; + } + case -6 : + { + switch (buffer.getShort()) { + case 0 : + builder.setMethodName((TruffleString) callback.deserialize(context, dataInput)); + break; + } + break; + } + case OP_BLOCK << 1 : + { + builder.beginBlock(); + break; + } + case (OP_BLOCK << 1) | 1 : + { + builder.endBlock(); + break; + } + case OP_ROOT << 1 : + { + TruffleLanguage arg0 = language; + builder.beginRoot(arg0); + break; + } + case (OP_ROOT << 1) | 1 : + { + builtNodes.add(builder.endRoot()); + break; + } + case OP_IF_THEN << 1 : + { + builder.beginIfThen(); + break; + } + case (OP_IF_THEN << 1) | 1 : + { + builder.endIfThen(); + break; + } + case OP_IF_THEN_ELSE << 1 : + { + builder.beginIfThenElse(); + break; + } + case (OP_IF_THEN_ELSE << 1) | 1 : + { + builder.endIfThenElse(); + break; + } + case OP_CONDITIONAL << 1 : + { + builder.beginConditional(); + break; + } + case (OP_CONDITIONAL << 1) | 1 : + { + builder.endConditional(); + break; + } + case OP_WHILE << 1 : + { + builder.beginWhile(); + break; + } + case (OP_WHILE << 1) | 1 : + { + builder.endWhile(); + break; + } + case OP_TRY_CATCH << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginTryCatch(arg0); + break; + } + case (OP_TRY_CATCH << 1) | 1 : + { + builder.endTryCatch(); + break; + } + case OP_FINALLY_TRY << 1 : + { + builder.beginFinallyTry(); + break; + } + case (OP_FINALLY_TRY << 1) | 1 : + { + builder.endFinallyTry(); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT << 1 : + { + builder.beginFinallyTryNoExcept(); + break; + } + case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : + { + builder.endFinallyTryNoExcept(); + break; + } + case OP_LABEL << 1 : + { + OperationLabel arg0 = labels.get(buffer.getShort()); + builder.emitLabel(arg0); + break; + } + case OP_BRANCH << 1 : + { + OperationLabel arg0 = labels.get(buffer.getShort()); + builder.emitBranch(arg0); + break; + } + case OP_LOAD_CONSTANT << 1 : + { + Object arg0 = (Object) consts.get(buffer.getShort()); + builder.emitLoadConstant(arg0); + break; + } + case OP_LOAD_ARGUMENT << 1 : + { + int arg0 = buffer.getInt(); + builder.emitLoadArgument(arg0); + break; + } + case OP_LOAD_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.emitLoadLocal(arg0); + break; + } + case OP_STORE_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginStoreLocal(arg0); + break; + } + case (OP_STORE_LOCAL << 1) | 1 : + { + builder.endStoreLocal(); + break; + } + case OP_RETURN << 1 : + { + builder.beginReturn(); + break; + } + case (OP_RETURN << 1) | 1 : + { + builder.endReturn(); + break; + } + case OP_LOAD_LOCAL_MATERIALIZED << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginLoadLocalMaterialized(arg0); + break; + } + case (OP_LOAD_LOCAL_MATERIALIZED << 1) | 1 : + { + builder.endLoadLocalMaterialized(); + break; + } + case OP_STORE_LOCAL_MATERIALIZED << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginStoreLocalMaterialized(arg0); + break; + } + case (OP_STORE_LOCAL_MATERIALIZED << 1) | 1 : + { + builder.endStoreLocalMaterialized(); + break; + } + case OP_SOURCE << 1 : + { + Source arg0 = (Source) consts.get(buffer.getShort()); + builder.beginSource(arg0); + break; + } + case (OP_SOURCE << 1) | 1 : + { + builder.endSource(); + break; + } + case OP_SOURCE_SECTION << 1 : + { + int arg0 = buffer.getInt(); + int arg1 = buffer.getInt(); + builder.beginSourceSection(arg0, arg1); + break; + } + case (OP_SOURCE_SECTION << 1) | 1 : + { + builder.endSourceSection(); + break; + } + case OP_TAG << 1 : + { + Class arg0 = (Class) consts.get(buffer.getShort()); + builder.beginTag(arg0); + break; + } + case (OP_TAG << 1) | 1 : + { + builder.endTag(); + break; + } + case OP_SL_ADD << 1 : + { + builder.beginSLAdd(); + break; + } + case (OP_SL_ADD << 1) | 1 : + { + builder.endSLAdd(); + break; + } + case OP_SL_DIV << 1 : + { + builder.beginSLDiv(); + break; + } + case (OP_SL_DIV << 1) | 1 : + { + builder.endSLDiv(); + break; + } + case OP_SL_EQUAL << 1 : + { + builder.beginSLEqual(); + break; + } + case (OP_SL_EQUAL << 1) | 1 : + { + builder.endSLEqual(); + break; + } + case OP_SL_LESS_OR_EQUAL << 1 : + { + builder.beginSLLessOrEqual(); + break; + } + case (OP_SL_LESS_OR_EQUAL << 1) | 1 : + { + builder.endSLLessOrEqual(); + break; + } + case OP_SL_LESS_THAN << 1 : + { + builder.beginSLLessThan(); + break; + } + case (OP_SL_LESS_THAN << 1) | 1 : + { + builder.endSLLessThan(); + break; + } + case OP_SL_LOGICAL_NOT << 1 : + { + builder.beginSLLogicalNot(); + break; + } + case (OP_SL_LOGICAL_NOT << 1) | 1 : + { + builder.endSLLogicalNot(); + break; + } + case OP_SL_MUL << 1 : + { + builder.beginSLMul(); + break; + } + case (OP_SL_MUL << 1) | 1 : + { + builder.endSLMul(); + break; + } + case OP_SL_READ_PROPERTY << 1 : + { + builder.beginSLReadProperty(); + break; + } + case (OP_SL_READ_PROPERTY << 1) | 1 : + { + builder.endSLReadProperty(); + break; + } + case OP_SL_SUB << 1 : + { + builder.beginSLSub(); + break; + } + case (OP_SL_SUB << 1) | 1 : + { + builder.endSLSub(); + break; + } + case OP_SL_WRITE_PROPERTY << 1 : + { + builder.beginSLWriteProperty(); + break; + } + case (OP_SL_WRITE_PROPERTY << 1) | 1 : + { + builder.endSLWriteProperty(); + break; + } + case OP_SL_UNBOX << 1 : + { + builder.beginSLUnbox(); + break; + } + case (OP_SL_UNBOX << 1) | 1 : + { + builder.endSLUnbox(); + break; + } + case OP_SL_FUNCTION_LITERAL << 1 : + { + builder.beginSLFunctionLiteral(); + break; + } + case (OP_SL_FUNCTION_LITERAL << 1) | 1 : + { + builder.endSLFunctionLiteral(); + break; + } + case OP_SL_TO_BOOLEAN << 1 : + { + builder.beginSLToBoolean(); + break; + } + case (OP_SL_TO_BOOLEAN << 1) | 1 : + { + builder.endSLToBoolean(); + break; + } + case OP_SL_INVOKE << 1 : + { + builder.beginSLInvoke(); + break; + } + case (OP_SL_INVOKE << 1) | 1 : + { + builder.endSLInvoke(); + break; + } + case OP_SL_AND << 1 : + { + builder.beginSLAnd(); + break; + } + case (OP_SL_AND << 1) | 1 : + { + builder.endSLAnd(); + break; + } + case OP_SL_OR << 1 : + { + builder.beginSLOr(); + break; + } + case (OP_SL_OR << 1) | 1 : + { + builder.endSLOr(); + break; + } + } + } + } catch (IOException ex) { + throw new IOError(ex); + } + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class BuilderOperationData { + + final BuilderOperationData parent; + final int operationId; + final int stackDepth; + final boolean needsLeave; + final int depth; + final Object[] arguments; + final Object[] aux; + int numChildren; + + private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { + this.parent = parent; + this.operationId = operationId; + this.stackDepth = stackDepth; + this.depth = parent == null ? 0 : parent.depth + 1; + this.aux = numAux > 0 ? new Object[numAux] : null; + this.needsLeave = needsLeave || (parent != null && parent.needsLeave); + this.arguments = arguments; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationLabelImpl extends OperationLabel { + + BuilderOperationData data; + BuilderFinallyTryContext finallyTry; + int targetBci = 0; + boolean hasValue = false; + + OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { + this.data = data; + this.finallyTry = finallyTry; + } + + boolean belongsTo(BuilderFinallyTryContext context) { + BuilderFinallyTryContext cur = finallyTry; + while (cur != null) { + if (cur == context) { + return true; + } + cur = cur.prev; + } + return false; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationSerLabelImpl extends OperationLabel { + + int id; + + OperationSerLabelImpl(int id) { + this.id = id; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationLocalImpl extends OperationLocal { + + final BuilderOperationData owner; + final int id; + + OperationLocalImpl(BuilderOperationData owner, int id) { + this.owner = owner; + this.id = id; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class LabelFill { + + int locationBci; + OperationLabelImpl label; + + LabelFill(int locationBci, OperationLabelImpl label) { + this.locationBci = locationBci; + this.label = label; + } + + LabelFill offset(int offset) { + return new LabelFill(offset + locationBci, label); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SourceInfoBuilder { + + private final ArrayList sourceStack = new ArrayList<>(); + private final ArrayList sourceList = new ArrayList<>(); + private int currentSource = -1; + private final ArrayList bciList = new ArrayList<>(); + private final ArrayList sourceDataList = new ArrayList<>(); + private final ArrayList sourceDataStack = new ArrayList<>(); + + void reset() { + sourceStack.clear(); + sourceDataList.clear(); + sourceDataStack.clear(); + bciList.clear(); + } + + void beginSource(int bci, Source src) { + int idx = sourceList.indexOf(src); + if (idx == -1) { + idx = sourceList.size(); + sourceList.add(src); + } + sourceStack.add(currentSource); + currentSource = idx; + beginSourceSection(bci, -1, -1); + } + + void endSource(int bci) { + endSourceSection(bci); + currentSource = sourceStack.remove(sourceStack.size() - 1); + } + + void beginSourceSection(int bci, int start, int length) { + SourceData data = new SourceData(start, length, currentSource); + bciList.add(bci); + sourceDataList.add(data); + sourceDataStack.add(data); + } + + void endSourceSection(int bci) { + SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); + SourceData prev; + if (sourceDataStack.isEmpty()) { + prev = new SourceData(-1, -1, currentSource); + } else { + prev = sourceDataStack.get(sourceDataStack.size() - 1); + } + bciList.add(bci); + sourceDataList.add(prev); + } + + int[] build() { + if (!sourceStack.isEmpty()) { + throw new IllegalStateException("not all sources ended"); + } + if (!sourceDataStack.isEmpty()) { + throw new IllegalStateException("not all source sections ended"); + } + int size = bciList.size(); + int[] resultArray = new int[size * 3]; + int index = 0; + int lastBci = -1; + boolean isFirst = true; + for (int i = 0; i < size; i++) { + SourceData data = sourceDataList.get(i); + int curBci = bciList.get(i); + if (data.start == -1 && isFirst) { + continue; + } + isFirst = false; + if (curBci == lastBci && index > 1) { + index -= 3; + } + resultArray[index + 0] = curBci | (data.sourceIndex << 16); + resultArray[index + 1] = data.start; + resultArray[index + 2] = data.length; + index += 3; + lastBci = curBci; + } + return Arrays.copyOf(resultArray, index); + } + + Source[] buildSource() { + return sourceList.toArray(new Source[0]); + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class SourceData { + + final int start; + final int length; + final int sourceIndex; + + SourceData(int start, int length, int sourceIndex) { + this.start = start; + this.length = length; + this.sourceIndex = sourceIndex; + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class BuilderFinallyTryContext { + + final BuilderFinallyTryContext prev; + final short[] bc; + final ArrayList exceptionHandlers; + final ArrayList labelFills; + final ArrayList labels; + final int curStack; + final int maxStack; + short[] handlerBc; + ArrayList handlerHandlers; + ArrayList handlerLabelFills = new ArrayList<>(); + ArrayList relocationOffsets = new ArrayList<>(); + int handlerMaxStack; + + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { + this.prev = prev; + this.bc = bc; + this.exceptionHandlers = exceptionHandlers; + this.labelFills = labelFills; + this.labels = labels; + this.curStack = curStack; + this.maxStack = maxStack; + } + + } + private final class BuilderState { + + BuilderState parentData; + private short[] bc = new short[65535]; + private int bci; + private int curStack; + private int maxStack; + private int numLocals; + private int numLabels; + private ArrayList constPool; + private BuilderOperationData operationData; + private ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private int numChildNodes; + private int numConditionProfiles; + private ArrayList exceptionHandlers = new ArrayList<>(); + private BuilderFinallyTryContext currentFinallyTry; + private int[] stackSourceBci = new int[1024]; + + BuilderState(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder p) { + this.bc = p.bc; + this.bci = p.bci; + this.curStack = p.curStack; + this.maxStack = p.maxStack; + this.numLocals = p.numLocals; + this.numLabels = p.numLabels; + this.constPool = p.constPool; + this.operationData = p.operationData; + this.labels = p.labels; + this.labelFills = p.labelFills; + this.numChildNodes = p.numChildNodes; + this.numConditionProfiles = p.numConditionProfiles; + this.exceptionHandlers = p.exceptionHandlers; + this.currentFinallyTry = p.currentFinallyTry; + this.stackSourceBci = p.stackSourceBci; + this.parentData = p.parentData; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationSerNodeImpl extends SLOperationRootNode { + + @CompilationFinal int buildOrder; + + private OperationSerNodeImpl(TruffleLanguage language, FrameDescriptor frameDescriptor, int buildOrder) { + super(language, frameDescriptor); + this.buildOrder = buildOrder; + } + + @Override + public String dump() { + throw new UnsupportedOperationException(); + } + + @Override + public Object execute(VirtualFrame frame) { + throw new UnsupportedOperationException(); + } + + @Override + public SourceSection getSourceSectionAtBci(int bci) { + throw new UnsupportedOperationException(); + } + + } + } + private static final class Counter { + + int count; + + } +} From fb730c2ddd1ee18763f15856535ce5afb04fcdeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 17 Oct 2022 21:39:18 +0200 Subject: [PATCH 154/312] [wip] error and serialization changes --- .../operation/test/dsl_tests/ErrorTests.java | 14 +-- ...DataInput.java => SerializationUtils.java} | 93 +++++++++++-------- .../operations/SingleOperationParser.java | 14 +-- 3 files changed, 66 insertions(+), 55 deletions(-) rename truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/{ByteBufferDataInput.java => SerializationUtils.java} (61%) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java index 576fe7b7635c..c41233b304e5 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java @@ -105,7 +105,7 @@ protected BadNodeProxy(TruffleLanguage language, FrameDescriptor builder) { } } - @ExpectError({"@OperationProxy'ed type must be a class, not int.", "Could not proxy operation"}) + @ExpectError({"Type referenced by @OperationProxy must be a class, not int.", "Could not proxy operation"}) @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(int.class) public abstract class BadProxyType extends RootNode implements OperationRootNode { @@ -114,7 +114,7 @@ protected BadProxyType(TruffleLanguage language, FrameDescriptor builder) { } } - @ExpectError("@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") + @ExpectError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(TestNode.class) public static abstract class OperationErrorTests extends RootNode implements OperationRootNode { @@ -145,7 +145,7 @@ public void doSomething() { } } - @ExpectError("Multiple @Variadic arguments not allowed.") + @ExpectError("Multiple @Variadic arguments are not supported.") @Operation public static final class TestOperation5 { @Specialization @@ -153,7 +153,7 @@ public static void spec(@Variadic Object[] a, @Variadic Object[] b) { } } - @ExpectError("Value arguments after LocalSetter not allowed.") + @ExpectError("Value arguments after LocalSetter are not supported.") @Operation public static final class TestOperation6 { @Specialization @@ -161,7 +161,7 @@ public static void spec(LocalSetter a, Object b) { } } - @ExpectError("Mixing regular and range local setters not allowed.") + @ExpectError("Mixing regular and range local setters is not supported.") @Operation public static final class TestOperation7 { @Specialization @@ -169,7 +169,7 @@ public static void spec(LocalSetter a, LocalSetterRange b) { } } - @ExpectError("Value arguments after @Variadic not allowed.") + @ExpectError("Value arguments after @Variadic are not supported.") @Operation public static final class TestOperation8 { @Specialization @@ -177,7 +177,7 @@ public static void spec(@Variadic Object[] a, Object b) { } } - @ExpectError("Value arguments after LocalSetter not allowed.") + @ExpectError("Value arguments after LocalSetter are not supported.") @Operation public static final class TestOperation9 { @Specialization diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java similarity index 61% rename from truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java rename to truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java index 311746b2a2ab..e2f0e17f25ef 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java @@ -7,17 +7,21 @@ import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; -public class ByteBufferDataInput { +public class SerializationUtils { + + private SerializationUtils() { + } public static DataInput createDataInput(ByteBuffer buffer) { - return new Impl(buffer); + return new ByteBufferDataInput(buffer); } - private static class Impl implements DataInput { + private static class ByteBufferDataInput implements DataInput { private final ByteBuffer buffer; + private char[] lineBuffer; - private Impl(ByteBuffer buffer) { + private ByteBufferDataInput(ByteBuffer buffer) { this.buffer = buffer; } @@ -125,50 +129,57 @@ public double readDouble() throws IOException { } } + private static int get(ByteBuffer buf) { + if (buf.position() >= buf.limit()) { + return -1; + } else { + return buf.get(); + } + } + /** - * Reads the next line of text from the input stream. It reads successive bytes, converting - * each byte separately into a character, until it encounters a line terminator or end of - * file; the characters read are then returned as a {@code String}. Note that because this - * method processes bytes, it does not support input of the full Unicode character set. - *

- * If end of file is encountered before even one byte can be read, then {@code null} is - * returned. Otherwise, each byte that is read is converted to type {@code char} by - * zero-extension. If the character {@code '\n'} is encountered, it is discarded and reading - * ceases. If the character {@code '\r'} is encountered, it is discarded and, if the - * following byte converts to the character {@code '\n'}, then that is discarded also; - * reading then ceases. If end of file is encountered before either of the characters - * {@code '\n'} and {@code '\r'} is encountered, reading ceases. Once reading has ceased, a - * {@code String} is returned that contains all the characters read and not discarded, taken - * in order. Note that every character in this string will have a value less than - * {@code \u005Cu0100}, that is, {@code (char)256}. - * - * @return the next line of text from the input stream, or {@code null} if the end of file - * is encountered before a byte can be read. - * @exception IOException if an I/O error occurs. + * Modified from {@link DataInputStream#readLine()}. */ + @Deprecated public String readLine() throws IOException { - int remaining = buffer.remaining(); - if (remaining == 0) { - return null; + char[] buf = lineBuffer; + + if (buf == null) { + buf = lineBuffer = new char[128]; } - StringBuilder sb = new StringBuilder(); - while (remaining > 0) { - char c = (char) buffer.get(); - if (c == '\r') { - if (remaining > 1 && (char) buffer.get() != '\n') { - buffer.position(buffer.position() - 1); - } - break; - } else if (c == '\n') { - break; - } else { - sb.append(c); - remaining--; + int room = buf.length; + int offset = 0; + int c; + + loop: while (true) { + switch (c = get(buffer)) { + case -1: + case '\n': + break loop; + + case '\r': + int c2 = get(buffer); + if ((c2 != '\n') && (c2 != -1)) { + buffer.position(buffer.position() - 1); + } + break loop; + + default: + if (--room < 0) { + buf = new char[offset + 128]; + room = buf.length - offset - 1; + System.arraycopy(lineBuffer, 0, buf, 0, offset); + lineBuffer = buf; + } + buf[offset++] = (char) c; + break; } } - - return sb.toString(); + if ((c == -1) && (offset == 0)) { + return null; + } + return String.copyValueOf(buf, 0, offset); } public String readUTF() throws IOException { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 44060afcfdfd..2925ee4067c8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -121,7 +121,7 @@ protected SingleOperationData parse(Element element, List mirr TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); if (proxyType.getKind() != TypeKind.DECLARED) { - parentData.addError(proxyMirror, proxyTypeValue, "@OperationProxy'ed type must be a class, not %s.", proxyType); + parentData.addError(proxyMirror, proxyTypeValue, "Type referenced by @OperationProxy must be a class, not %s.", proxyType); return null; } @@ -201,7 +201,7 @@ protected SingleOperationData parse(Element element, List mirr for (ExecutableElement cel : findSpecializations(te.getEnclosedElements())) { if (!cel.getModifiers().contains(Modifier.STATIC)) { - data.addError("@OperationProxy'ed class must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); + data.addError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); } operationFunctions.add(cel); @@ -433,10 +433,10 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme for (VariableElement param : method.getParameters()) { if (isVariadicParameter(param)) { if (isVariadic) { - data.addError(method, "Multiple @Variadic arguments not allowed."); + data.addError(method, "Multiple @Variadic arguments are not supported."); } if (numLocalSetters != 0) { - data.addError(param, "Value arguments after LocalSetter not allowed."); + data.addError(param, "Value arguments after LocalSetter are not supported."); } isVariadic = true; parameters.add(ParameterKind.VARIADIC); @@ -446,15 +446,15 @@ private MethodProperties processMethod(SingleOperationData data, ExecutableEleme } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRange)) { parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); if (numLocalSetters != 0) { - data.addError(param, "Mixing regular and range local setters not allowed."); + data.addError(param, "Mixing regular and range local setters is not supported."); } numLocalSetters = -1; } else if (!isIgnoredParameter(param)) { if (isVariadic) { - data.addError(method, "Value arguments after @Variadic not allowed."); + data.addError(method, "Value arguments after @Variadic are not supported."); } if (numLocalSetters > 0) { - data.addError(param, "Value arguments after LocalSetter not allowed."); + data.addError(param, "Value arguments after LocalSetter are not supported."); } if (ElementUtils.typeEquals(param.asType(), types.Frame) || ElementUtils.typeEquals(param.asType(), types.VirtualFrame)) { parameters.add(ParameterKind.VIRTUAL_FRAME); From 52d464cafb86d57b7fe0ab2e298a697677288168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 19 Oct 2022 13:42:48 +0200 Subject: [PATCH 155/312] [wip] add introspection & change boxing bits --- .../test/example/BoxingOperationsTest.java | 1 - .../api/operation/OperationRootNode.java | 23 +++++- .../api/operation/introspection/Argument.java | 59 ++++++++++++++++ .../introspection/ExceptionHandler.java | 27 +++++++ .../operation/introspection/Instruction.java | 70 +++++++++++++++++++ .../introspection/OperationIntrospection.java | 36 ++++++++++ .../truffle/dsl/processor/TruffleTypes.java | 4 ++ .../processor/generator/GeneratorUtils.java | 1 + .../operations/OperationGeneratorFlags.java | 2 + .../operations/OperationGeneratorUtils.java | 58 ++++++++++++++- .../OperationsBytecodeCodeGenerator.java | 36 ++++++---- .../OperationsBytecodeNodeGeneratorPlugs.java | 13 ++-- .../operations/OperationsCodeGenerator.java | 14 ++-- .../operations/instructions/Instruction.java | 56 ++++++++------- .../instructions/LoadLocalInstruction.java | 9 +-- .../instructions/StoreLocalInstruction.java | 4 +- .../sl/operations/SLOperationRootNode.java | 2 - 17 files changed, 350 insertions(+), 65 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 2dce811beac8..3bba7ab4d9a3 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -68,7 +68,6 @@ public class BoxingOperationsTest { private static final BoxingLanguage LANGUAGE = null; private static final int NUM_ITERATIONS = 10_000; - private static final int MAX_INVALIDATIONS = 20; private static BoxingOperations parse(OperationParser parser) { OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index b26c73955b6d..ffcb0abe91d3 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -40,13 +40,17 @@ */ package com.oracle.truffle.api.operation; +import java.util.List; import java.util.function.Function; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInterface; +import com.oracle.truffle.api.operation.introspection.ExceptionHandler; +import com.oracle.truffle.api.operation.introspection.Instruction; +import com.oracle.truffle.api.operation.introspection.OperationIntrospection; import com.oracle.truffle.api.source.SourceSection; -public interface OperationRootNode extends NodeInterface { +public interface OperationRootNode extends NodeInterface, OperationIntrospection.Provider { default T getMetadata(MetadataKey key) { return key.getValue(this); } @@ -55,9 +59,22 @@ static void setMetadataAccessor(MetadataKey key, Function handlers = id.getExceptionHandlers(); + if (handlers.size() > 0) { + sb.append("Exception handlers:\n"); + for (ExceptionHandler eh : handlers) { + sb.append(" ").append(eh.toString()).append('\n'); + } + } - String dump(); + return sb.toString(); + } Object execute(VirtualFrame frame); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java new file mode 100644 index 000000000000..86b07de9eb80 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java @@ -0,0 +1,59 @@ +package com.oracle.truffle.api.operation.introspection; + +public final class Argument { + + private final Object[] data; + + Argument(Object[] data) { + this.data = data; + } + + public enum ArgumentKind { + LOCAL, + ARGUMENT, + BOXING, + CONSTANT, + CHILD_OFFSET, + VARIADIC, + BRANCH_OFFSET; + + public String toString(Object value) { + switch (this) { + case LOCAL: + return String.format("local(%d)", (int) value); + case ARGUMENT: + return String.format("arg(%d)", (int) value); + case BOXING: + return String.format("boxing(%s)", value); + case CONSTANT: + if (value == null) { + return "const(null)"; + } else { + return String.format("const(%s %s)", value.getClass().getSimpleName(), value); + } + case CHILD_OFFSET: + return String.format("child(-%d)", (int) value); + case VARIADIC: + return String.format("variadic(%d)", (int) value); + case BRANCH_OFFSET: + return String.format("branch(%04x)", (int) value); + default: + throw new UnsupportedOperationException("Unexpected value: " + this); + } + } + } + + public ArgumentKind getKind() { + return (ArgumentKind) data[0]; + } + + public Object getValue() { + return data[1]; + } + + @Override + public String toString() { + return getKind().toString(getValue()); + } + +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java new file mode 100644 index 000000000000..898dee2f3db7 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java @@ -0,0 +1,27 @@ +package com.oracle.truffle.api.operation.introspection; + +public final class ExceptionHandler { + + private final Object[] data; + + ExceptionHandler(Object[] data) { + this.data = data; + } + + public int getStartIndex() { + return (int) data[0]; + } + + public int getEndIndex() { + return (int) data[1]; + } + + public int getHandlerIndex() { + return (int) data[2]; + } + + @Override + public String toString() { + return String.format("[%04x : %04x] -> %04x", getStartIndex(), getEndIndex(), getHandlerIndex()); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java new file mode 100644 index 000000000000..aaa1e09901be --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java @@ -0,0 +1,70 @@ +package com.oracle.truffle.api.operation.introspection; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public final class Instruction { + + private final Object[] data; + + Instruction(Object[] data) { + this.data = data; + + } + + public int getIndex() { + return (int) data[0]; + } + + public String getName() { + return (String) data[1]; + } + + public byte[] getBytes() { + short[] shorts = (short[]) data[2]; + byte[] result = new byte[shorts.length * 2]; + for (int i = 0; i < shorts.length; i++) { + result[2 * i] = (byte) (shorts[i] & 0xff); + result[2 * i + 1] = (byte) ((shorts[i] >> 8) & 0xff); + } + + return result; + } + + public List getArgumentValues() { + if (data[3] == null) { + return List.of(); + } + return Arrays.stream((Object[]) data[3]).map(x -> new Argument((Object[]) x)).collect(Collectors.toUnmodifiableList()); + } + + private static final int REASONABLE_INSTRUCTION_LENGTH = 16; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(String.format("[%04x] ", getIndex())); + + byte[] bytes = getBytes(); + for (int i = 0; i < REASONABLE_INSTRUCTION_LENGTH; i++) { + if (i < bytes.length) { + sb.append(String.format("%02x ", bytes[i])); + } else { + sb.append(" "); + } + } + + for (int i = REASONABLE_INSTRUCTION_LENGTH; i < data.length; i++) { + sb.append(String.format("%02x ", bytes[i])); + } + + sb.append(String.format("%-20s", getName())); + + for (Argument a : getArgumentValues()) { + sb.append(' ').append(a.toString()); + } + + return sb.toString(); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java new file mode 100644 index 000000000000..c9bf4dec6954 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java @@ -0,0 +1,36 @@ +package com.oracle.truffle.api.operation.introspection; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class OperationIntrospection { + + public static interface Provider { + default OperationIntrospection getIntrospectionData() { + throw new UnsupportedOperationException(); + } + + static OperationIntrospection create(Object... data) { + return new OperationIntrospection(data); + } + } + + private final Object[] data; + + private OperationIntrospection(Object[] data) { + if (data.length == 0 || (int) data[0] != 0) { + throw new UnsupportedOperationException("Illegal operation introspection version"); + } + + this.data = data; + } + + public List getInstructions() { + return Arrays.stream((Object[]) data[1]).map(x -> new Instruction((Object[]) x)).collect(Collectors.toUnmodifiableList()); + } + + public List getExceptionHandlers() { + return Arrays.stream((Object[]) data[2]).map(x -> new ExceptionHandler((Object[]) x)).collect(Collectors.toUnmodifiableList()); + } +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index aa4e2eb4191d..def36141bfc8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -247,6 +247,8 @@ public class TruffleTypes { public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; + public static final String OperationIntrospection_Name = "com.oracle.truffle.api.operation.introspection.OperationIntrospection"; + public static final String OperationIntrospection_Provider_Name = "com.oracle.truffle.api.operation.introspection.OperationIntrospection.Provider"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; public static final String OperationLocal_Name = "com.oracle.truffle.api.operation.OperationLocal"; public static final String OperationRootNode_Name = "com.oracle.truffle.api.operation.OperationRootNode"; @@ -269,6 +271,8 @@ public class TruffleTypes { public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); public final DeclaredType OperationConfig = c.getDeclaredTypeOptional(OperationConfig_Name); + public final DeclaredType OperationIntrospection = c.getDeclaredTypeOptional(OperationIntrospection_Name); + public final DeclaredType OperationIntrospection_Provider = c.getDeclaredTypeOptional(OperationIntrospection_Provider_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); public final DeclaredType OperationLocal = c.getDeclaredTypeOptional(OperationLocal_Name); public final DeclaredType OperationRootNode = c.getDeclaredTypeOptional(OperationRootNode_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 6620e1e10f27..631746dff84d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -440,6 +440,7 @@ public static CodeExecutableElement overrideImplement(TypeElement typeElement, S } CodeExecutableElement result = CodeExecutableElement.clone(method); result.getModifiers().remove(Modifier.ABSTRACT); + result.getModifiers().remove(Modifier.DEFAULT); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index e44c0ba85532..950f83753ac4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -55,4 +55,6 @@ public class OperationGeneratorFlags { public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; public static final boolean ENABLE_SERIALIZATION = true; + + public static final int BOXING_ELIM_BITS = 3; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 533ba1434157..eb0e44462dd0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -51,6 +51,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; +import javax.lang.model.element.VariableElement; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; @@ -120,7 +121,7 @@ public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElem } public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("unsafeWriteBytecode").tree(bc).tree(bci).tree(value).end(2).build(); + return CodeTreeBuilder.createBuilder().startStatement().startCall("unsafeWriteBytecode").tree(bc).tree(bci).startGroup().string("(short) ").tree(value).end(3).build(); } public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { @@ -137,6 +138,13 @@ public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableEle CodeTreeBuilder.singleString(value)); } + public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeTree value) { + return createWriteOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleVariable(bci), + value); + } + public static CodeTree createWriteOpcode(CodeVariableElement bc, String bci, CodeVariableElement value) { return createWriteOpcode( CodeTreeBuilder.singleVariable(bc), @@ -213,7 +221,7 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar } - b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).string(" & 0x1fff").end().startBlock(); + b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().startBlock(); for (int i = 0; i < trees.size(); i++) { if (treeInstructions.get(i) == null) { b.caseDefault(); @@ -285,4 +293,50 @@ private static void checkAccessibility(Element el, String namePrefix) { throw new AssertionError(namePrefix + el.getSimpleName() + " must not be package-protected"); } + + public static CodeTree combineBoxingBits(OperationsContext ctx, CodeTree instr, CodeTree kind) { + if (ctx.hasBoxingElimination()) { + return CodeTreeBuilder.createBuilder().startParantheses().startParantheses().tree(instr).string(" << " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().string( + " | ").tree(kind).end().build(); + } else { + return instr; + } + } + + public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, CodeTree kind) { + return combineBoxingBits(ctx, CodeTreeBuilder.singleVariable(instr.opcodeIdField), kind); + } + + public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, String kind) { + return combineBoxingBits(ctx, instr, CodeTreeBuilder.singleString(kind)); + } + + public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, FrameKind kind) { + return combineBoxingBits(ctx, instr, kind.toOrdinal()); + } + + public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, int kind) { + return combineBoxingBits(ctx, instr, "" + kind); + } + + public static CodeTree extractInstruction(OperationsContext ctx, CodeTree instr) { + if (ctx.hasBoxingElimination()) { + return CodeTreeBuilder.createBuilder().startParantheses().tree(instr).string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().string( + " & " + (1 << (16 - OperationGeneratorFlags.BOXING_ELIM_BITS) - 1)).build(); + } else { + return instr; + } + } + + public static CodeTree extractInstruction(OperationsContext ctx, String instr) { + return extractInstruction(ctx, CodeTreeBuilder.singleString(instr)); + } + + public static CodeTree extractBoxingBits(OperationsContext ctx, CodeTree instr) { + if (ctx.hasBoxingElimination()) { + return CodeTreeBuilder.createBuilder().tree(instr).string(" & " + ((1 << OperationGeneratorFlags.BOXING_ELIM_BITS) - 1)).build(); + } else { + return CodeTreeBuilder.singleString("0"); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index da24862bef88..b12025c4f01a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor.operations; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -50,6 +52,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; @@ -166,7 +169,7 @@ private CodeExecutableElement createPrepareAot(CodeTypeElement baseType) { } private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { - CodeExecutableElement mDump = GeneratorUtils.overrideImplement(baseType, "dump"); + CodeExecutableElement mDump = GeneratorUtils.overrideImplement(baseType, "getIntrospectionData"); CodeTreeBuilder b = mDump.getBuilder(); ExecutionVariables vars = new ExecutionVariables(); @@ -175,34 +178,39 @@ private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); b.declaration("int", vars.bci.getName(), "0"); - b.declaration("StringBuilder", "sb", "new StringBuilder()"); + b.declaration("ArrayList", "target", "new ArrayList<>()"); b.startWhile().string("$bci < $bc.length").end().startBlock(); // while { - b.statement("sb.append(String.format(\" [%04x]\", $bci))"); - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); if (op == null) { - builder.statement("sb.append(String.format(\" unknown 0x%02x\", $bc[$bci++]))"); + builder.declaration("Object[]", "dec", "new Object[]{$bci, \"unknown\", Arrays.copyOfRange($bc, $bci, $bci + 1), null}"); + builder.statement("$bci++"); } else { builder.tree(op.createDumpCode(vars)); builder.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); } + builder.statement("target.add(dec)"); + builder.statement("break"); return builder.build(); })); - b.statement("sb.append(\"\\n\")"); - b.end(); // } + b.declaration("ArrayList", "ehTarget", "new ArrayList<>()"); + b.startFor().string("int i = 0; i < ").variable(varHandlers).string(".length; i++").end(); b.startBlock(); - b.startStatement().string("sb.append(").variable(varHandlers).string("[i] + \"\\n\")").end(); + b.startStatement().startCall("ehTarget.add").startNewArray((ArrayType) context.getType(Object[].class), null); + b.startGroup().variable(varHandlers).string("[i].startBci").end(); + b.startGroup().variable(varHandlers).string("[i].endBci").end(); + b.startGroup().variable(varHandlers).string("[i].handlerBci").end(); + b.end(3); b.end(); @@ -221,7 +229,7 @@ private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { // } // b.end(); - b.startReturn().string("sb.toString()").end(); + b.startReturn().string("OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()})").end(); vars.bci = null; @@ -347,7 +355,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { if (ctx.hasBoxingElimination() && !isUncached) { if (op.splitOnBoxingElimination()) { for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().variable(op.opcodeIdField).string(" | (", kind.toOrdinal(), " << 13)").end(); + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); b.startBlock(); vars.specializedKind = kind; createBody.run(); @@ -355,19 +363,19 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); } if (op.hasGeneric()) { - b.startCase().variable(op.opcodeIdField).string(" | (7 << 13)").end(); + b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); b.startBlock(); createBody.run(); b.end(); } } else if (op.numPushedValues == 0 || op.alwaysBoxed()) { - b.startCase().variable(op.opcodeIdField).end(); + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); b.startBlock(); createBody.run(); b.end(); } else { for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().variable(op.opcodeIdField).string(" | (", kind.toOrdinal(), " << 13)").end(); + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); } b.startBlock(); @@ -376,7 +384,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); } } else { - b.startCase().variable(op.opcodeIdField).end(); + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); b.startBlock(); if (ctx.hasBoxingElimination()) { vars.specializedKind = FrameKind.OBJECT; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 8c38bf01f25b..5489196f2698 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -41,6 +41,10 @@ package com.oracle.truffle.dsl.processor.operations; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadOpcode; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.extractBoxingBits; import java.util.ArrayList; import java.util.Arrays; @@ -445,7 +449,7 @@ public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBui QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; // unquicken call parent EAS - builder.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, qinstr.getOrig().opcodeIdField)); + builder.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), qinstr.getOrig(), 0))); easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; } @@ -528,7 +532,8 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ if (!quickened.isEmpty()) { - b.startAssign("short primitiveTagBits").string("(short) (").tree(OperationGeneratorUtils.createReadOpcode(dummyVariables.bc, dummyVariables.bci)).string(" & 0xe000)").end(); + b.startAssign("short primitiveTagBits").string("(short) (").tree( + extractBoxingBits(m.getOperationsContext(), createReadOpcode(dummyVariables.bc, dummyVariables.bci))).string(" & 0xe000)").end(); // only quicken/unquicken for instructions that have quickened versions boolean elseIf = false; @@ -538,7 +543,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); b.end().startBlock(); // { - b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, "(short) (" + qinstr.opcodeIdField.getName() + " | primitiveTagBits)")); + b.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), qinstr, "primitiveTagBits"))); // } b.end(); } @@ -549,7 +554,7 @@ public void createSpecialize(FrameState frameState, SpecializationData specializ } // quicken to generic - b.tree(OperationGeneratorUtils.createWriteOpcode(dummyVariables.bc, dummyVariables.bci, "(short) (" + cinstr.opcodeIdField.getName() + " | primitiveTagBits)")); + b.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), cinstr, "primitiveTagBits"))); if (elseIf) { b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 0365896c9385..e3ba747c3131 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -54,7 +54,6 @@ import java.util.concurrent.locks.Lock; import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; @@ -303,7 +302,7 @@ private CodeTypeElement createOperationSerNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl, m.fdConstructor)); - for (String methodName : new String[]{"dump", "execute", "getSourceSectionAtBci"}) { + for (String methodName : new String[]{"execute", "getSourceSectionAtBci"}) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, methodName); met.createBuilder().startThrow().startNew(context.getType(UnsupportedOperationException.class)).end(2); typOperationNodeImpl.add(met); @@ -443,9 +442,9 @@ CodeTypeElement createOperationNodeImpl() { CodeExecutableElement mExecute = createNodeExecute(); typOperationNodeImpl.add(mExecute); - CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationRootNode, "dump"); + CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationIntrospection_Provider, "getIntrospectionData"); typOperationNodeImpl.add(mDump); - mDump.createBuilder().startReturn().startCall("switchImpl.dump").string("_bc, _handlers, _consts").end(2); + mDump.createBuilder().startReturn().startCall("switchImpl.getIntrospectionData").string("_bc, _handlers, _consts").end(2); CodeExecutableElement mGetLockAccessor = new CodeExecutableElement(MOD_PRIVATE, context.getType(Lock.class), "getLockAccessor"); typOperationNodeImpl.add(mGetLockAccessor); @@ -1168,7 +1167,7 @@ private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement b.statement("ArrayList<" + m.getTemplateType().getSimpleName() + "> builtNodes = new ArrayList<>()"); b.statement("buffer.rewind()"); - b.declaration(context.getType(DATA_INPUT_WRAP_CLASS), "dataInput", "com.oracle.truffle.api.operation.serialization.ByteBufferDataInput.createDataInput(buffer)"); + b.declaration(context.getType(DATA_INPUT_WRAP_CLASS), "dataInput", "com.oracle.truffle.api.operation.serialization.SerializationUtils.createDataInput(buffer)"); TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext"); @@ -1815,7 +1814,7 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "maxLocals")); baseClass.add(loopMethod); - CodeExecutableElement dumpMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(String.class), "dump"); + CodeExecutableElement dumpMethod = new CodeExecutableElement(MOD_ABSTRACT, types.OperationIntrospection, "getIntrospectionData"); dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(context.getType(short.class)), "$bc")); dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); dumpMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); @@ -2663,7 +2662,8 @@ private CodeExecutableElement createSetResultBoxedImpl() { CodeTreeBuilder b = mSetResultBoxedImpl.createBuilder(); - b.statement("bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff))"); + int mask = (0xffff << OperationGeneratorFlags.BOXING_ELIM_BITS) & 0xffff; + b.statement("bc[bci] = (short) (targetType | (bc[bci] & " + String.format("0x%x", mask) + "))"); return mSetResultBoxedImpl; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index b55e30ef681d..1bdb2ef25cd1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -40,13 +40,15 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; + import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import javax.lang.model.element.Modifier; -import javax.lang.model.type.TypeKind; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -448,7 +450,7 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) b.end(2); // emit opcode - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, opcodeIdField)); + b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, this, 0))); if (!constants.isEmpty()) { b.startAssign("int constantsStart"); @@ -655,59 +657,59 @@ public int numPopStatic() { return popIndexed.size() + popSimple.size(); } - private static void sbAppend(CodeTreeBuilder b, String format, Runnable r) { - b.startStatement().startCall("sb", "append"); - b.startCall("String", "format"); - b.doubleQuote(format); - r.run(); - b.end(3); + private void createAddArgument(CodeTreeBuilder b, String kind, Runnable value) { + b.startIndention().newLine(); + b.startNewArray((ArrayType) context.getType(Object[].class), null); + b.staticReference(context.getDeclaredType("com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind"), kind); + b.startGroup(); + value.run(); + b.end(); // group + b.end(); // array + b.end(); } public CodeTree createDumpCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - for (int i = 0; i < length(); i++) { - int ic = i; - sbAppend(b, " %04x", () -> b.startGroup().variable(vars.bc).string("[").variable(vars.bci).string(" + " + ic + "]").end()); - } - - for (int i = length(); i < 8; i++) { - b.startStatement().startCall("sb", "append").doubleQuote(" ").end(2); - } - - b.startStatement().startCall("sb", "append").doubleQuote(name + " ".repeat(name.length() < 30 ? 30 - name.length() : 0)).end(2); - + b.startAssign("Object[] dec"); + b.startNewArray((ArrayType) context.getType(Object[].class), null); + b.string("$bci"); + b.doubleQuote(name); + b.string("Arrays.copyOfRange($bc, $bci, $bci + " + internalName + LENGTH_SUFFIX + ")"); + b.startNewArray((ArrayType) context.getType(Object[].class), null); for (int i = 0; i < constants.size(); i++) { int ci = i; - sbAppend(b, " const(%s)", () -> { - b.startCall("formatConstant").startGroup().variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]").end(2); + createAddArgument(b, "CONSTANT", () -> { + b.variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]"); }); } for (int i = 0; i < locals.size(); i++) { int ci = i; - sbAppend(b, " local(%s)", () -> b.startGroup().tree(createLocalIndex(vars, ci, false)).end()); + createAddArgument(b, "LOCAL", () -> b.cast(context.getType(int.class)).tree(createLocalIndex(vars, ci, false))); } for (int i = 0; i < arguments.size(); i++) { int ci = i; - sbAppend(b, " arg(%s)", () -> b.startGroup().tree(createArgumentIndex(vars, ci, false)).end()); + createAddArgument(b, "ARGUMENT", () -> b.cast(context.getType(int.class)).tree(createArgumentIndex(vars, ci, false))); } for (int i = 0; i < popIndexed.size(); i++) { int ci = i; - sbAppend(b, " pop(-%s)", () -> b.startGroup().tree(createPopIndexedIndex(vars, ci, false)).end()); + createAddArgument(b, "CHILD_OFFSET", () -> b.cast(context.getType(int.class)).tree(createPopIndexedIndex(vars, ci, false))); } if (isVariadic) { - sbAppend(b, " var(%s)", () -> b.startGroup().tree(createVariadicIndex(vars, false)).end()); + createAddArgument(b, "VARIADIC", () -> b.cast(context.getType(int.class)).tree(createVariadicIndex(vars, false))); } for (int i = 0; i < branchTargets.size(); i++) { int ci = i; - sbAppend(b, " branch(%04x)", () -> b.startGroup().tree(createBranchTargetIndex(vars, ci, false)).end()); + createAddArgument(b, "CHILD_OFFSET", () -> b.cast(context.getType(int.class)).tree(createBranchTargetIndex(vars, ci, false))); } + b.end(3); // arg array, instr array, stmt + return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index edb47cf26905..e7af00664c12 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -40,6 +40,9 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; + import java.util.List; import java.util.Set; @@ -100,7 +103,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, ctx.loadLocalUnboxed.opcodeIdField.getName())); + b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalUnboxed, 0))); b.statement("$bci -= LOAD_LOCAL_BOXED_LENGTH"); return b.build(); @@ -203,9 +206,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + " (boxed)%n\", localIdx, $frame.getValue(localIdx))"); } - b.tree(OperationGeneratorUtils.createWriteOpcode( - vars.bc, vars.bci, - "(short) (" + ctx.loadLocalBoxed.opcodeIdField.getName() + " | (" + kind.toOrdinal() + " << 13))")); + b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalBoxed, kind))); b.end().startElseBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java index 74fd4a692b21..b27c8ee92d88 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; + import java.util.Set; import javax.lang.model.element.Modifier; @@ -347,7 +349,7 @@ private static void createSetFrameDescriptorKind(ExecutionVariables vars, CodeTr } private void createSetPrimitiveTag(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.tree(OperationGeneratorUtils.createWriteOpcode(vars.bc, vars.bci, "(short) ((" + tag + " << 13) | " + opcodeIdField.getName() + ")")); + b.tree(createWriteOpcode(vars.bc, vars.bci, OperationGeneratorUtils.combineBoxingBits(ctx, this, tag))); } private static void createBoxingEliminateChild(ExecutionVariables vars, CodeTreeBuilder b, String tag) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index b0080e437172..e96c75f8c84a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -110,8 +110,6 @@ @ShortCircuitOperation(name = "SLOr", booleanConverter = SLToBooleanNode.class, continueWhen = false) public abstract class SLOperationRootNode extends SLRootNode implements OperationRootNode { - static final boolean __magic_LogInvalidations = false; - protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) { super((SLLanguage) language, frameDescriptor); } From bfb6ac21aef0fdf31f183551f940ee624450551c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 19 Oct 2022 19:20:00 +0200 Subject: [PATCH 156/312] [wip] decision ordering --- .../api/operation/tracing/Decision.java | 137 ++++++++++++++++++ .../tracing/OperationsStatistics.java | 118 ++++++++++----- .../dsl/processor/java/model/CodeElement.java | 9 ++ .../java/transform/AbstractCodeWriter.java | 46 +++++- .../OperationsBytecodeCodeGenerator.java | 12 ++ .../instructions/ReturnInstruction.java | 6 - .../sl/operations/SLOperationRootNode.java | 2 +- .../truffle/sl/operations/decisions.json | 134 +---------------- 8 files changed, 278 insertions(+), 186 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java new file mode 100644 index 000000000000..2e2d095e3994 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -0,0 +1,137 @@ +package com.oracle.truffle.api.operation.tracing; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.stream.Collectors; + +import com.oracle.truffle.api.operation.tracing.OperationsStatistics.GlobalOperationStatistics; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONObject; + +abstract class Decision { + static final Comparator COMPARATOR = (o1, o2) -> -Double.compare(o1.value(), o2.value()); + + private final String type; + int appliedSort; + + private Decision(String type) { + this.type = type; + } + + abstract double value(); + + abstract String id(GlobalOperationStatistics stats); + + @SuppressWarnings("unused") + boolean acceptedBefore(Decision decision) { + return false; + } + + JSONObject serialize(GlobalOperationStatistics stats) { + JSONObject obj = new JSONObject(); + obj.put("type", type); + obj.put("id", id(stats)); + return obj; + } + + static final class Quicken extends Decision { + private final int instruction; + private final int[] specializations; + private long executionCount; + + Quicken(int instruction, int[] specializations, long executionCount) { + super("Quicken"); + this.instruction = instruction; + this.specializations = specializations; + this.executionCount = executionCount; + } + + @Override + double value() { + return executionCount; + } + + @Override + String id(GlobalOperationStatistics stats) { + String s = Arrays.stream(specializations).mapToObj(x -> stats.specNames[instruction][x]).collect(Collectors.joining(",")); + return String.format("quicken:%s:%s", stats.instrNames[instruction], s); + } + + @Override + JSONObject serialize(GlobalOperationStatistics stats) { + JSONObject result = super.serialize(stats); + String instrName = stats.instrNames[instruction]; + String shortName; + if (instrName.startsWith("c.")) { + shortName = instrName.substring(2); + } else { + assert instrName.startsWith("sc."); + shortName = instrName.substring(3); + } + result.put("operation", shortName); + + JSONArray specsData = new JSONArray(); + result.put("specializations", specsData); + for (int i : specializations) { + specsData.put(stats.specNames[instruction][i]); + } + + return result; + } + } + + static final class SuperInstruction extends Decision { + private final int[] instructions; + private long executionCount; + + SuperInstruction(int[] instructions, long executionCount) { + super("SuperInstruction"); + this.instructions = instructions; + this.executionCount = executionCount; + } + + @Override + double value() { + return (instructions.length - 1) * executionCount; + } + + @Override + String id(GlobalOperationStatistics stats) { + return String.format("si:%s", Arrays.stream(instructions).mapToObj(x -> stats.instrNames[x]).collect(Collectors.joining(","))); + } + + @Override + boolean acceptedBefore(Decision decision) { + boolean changed = false; + if (decision instanceof SuperInstruction) { + SuperInstruction si = (SuperInstruction) decision; + + outer: for (int start = 0; start <= si.instructions.length - instructions.length; start++) { + for (int i = 0; i < instructions.length; i++) { + if (si.instructions[start + i] != instructions[i]) { + continue outer; + } + } + + executionCount -= si.executionCount; + changed = true; + } + } + + return changed; + } + + @Override + JSONObject serialize(GlobalOperationStatistics stats) { + JSONObject result = super.serialize(stats); + + JSONArray instrNames = new JSONArray(); + result.put("instructions", instrNames); + for (int i : instructions) { + instrNames.put(stats.instrNames[i]); + } + + return result; + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index a39ffdea32dd..6f94b10a1a7a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -151,10 +151,10 @@ static final class GlobalOperationStatistics { private final List allTracers = new ArrayList<>(); private final ThreadLocal currentTracer = new ThreadLocal<>(); - private Class opsClass; - private String decisionsFile; - private String[] instrNames; - private String[][] specNames; + Class opsClass; + String decisionsFile; + String[] instrNames; + String[][] specNames; GlobalOperationStatistics(Class opsClass) { this.opsClass = opsClass; @@ -298,6 +298,18 @@ public boolean equals(Object obj) { return Arrays.equals(activeSpecializations, other.activeSpecializations) && instructionId == other.instructionId; } + private int[] specializationIds() { + int[] result = new int[getCountActive()]; + int idx = 0; + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + result[idx++] = i; + } + } + + return result; + } + private JSONObject serialize() { JSONObject result = new JSONObject(); result.put("i", instructionId); @@ -327,30 +339,6 @@ private static SpecializationKey deserialize(JSONObject obj) { return new SpecializationKey(id, activeSpecializations); } - public JSONObject serializeDecision(GlobalOperationStatistics stats) { - JSONObject result = new JSONObject(); - result.put("type", "Quicken"); - String instrName = stats.instrNames[instructionId]; - String shortName; - if (instrName.startsWith("c.")) { - shortName = instrName.substring(2); - } else { - assert instrName.startsWith("sc."); - shortName = instrName.substring(3); - } - result.put("operation", shortName); - - JSONArray specsData = new JSONArray(); - result.put("specializations", specsData); - for (int i = 0; i < activeSpecializations.length; i++) { - if (activeSpecializations[i]) { - specsData.put(stats.specNames[instructionId][i]); - } - } - - return result; - } - @Override public String toString() { return "SpecializationKey [" + instructionId + ", " + Arrays.toString(activeSpecializations) + "]"; @@ -398,28 +386,51 @@ public Object toString(String[] instrNames) { private Map numNodesWithInstruction = new HashMap<>(); private Map> nodesWithInstruction = new HashMap<>(); - private List nodes = new ArrayList<>(); + private List nodeStack = new ArrayList<>(); private Node curNode; private static final int MAX_SUPERINSTR_LEN = 8; - private int[] instrHistory = new int[MAX_SUPERINSTR_LEN]; + List instrHistoryStack = new ArrayList<>(); + List instrHistoryLenStack = new ArrayList<>(); + private int[] instrHistory = null; private int instrHistoryLen = 0; @Override public void startFunction(Node node) { + System.err.println(" [[ STARTING FUNCTION " + node); if (curNode != null) { - nodes.add(curNode); + nodeStack.add(curNode); } curNode = node; + + if (instrHistory != null) { + instrHistoryStack.add(instrHistory); + instrHistoryLenStack.add(instrHistoryLen); + } + + instrHistory = new int[MAX_SUPERINSTR_LEN]; + instrHistoryLen = 0; } @Override public void endFunction(Node node) { - if (nodes.size() > 0) { - curNode = nodes.remove(nodes.size() - 1); + System.err.println(" ]] ENDING FUNCTION " + node); + if (curNode != node) { + throw new AssertionError("Tracer start/stop mismatch"); + } + + if (nodeStack.size() > 0) { + curNode = nodeStack.remove(nodeStack.size() - 1); } else { curNode = null; } + + if (instrHistoryStack.size() > 0) { + instrHistory = instrHistoryStack.remove(instrHistoryStack.size() - 1); + instrHistoryLen = instrHistoryLenStack.remove(instrHistoryLenStack.size() - 1); + } else { + instrHistory = null; + } } @Override @@ -560,22 +571,51 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { return inst; } + private static void orderDecisions(List output, List input, int expectedCount) { + int outputCount = input.size() < expectedCount ? input.size() : expectedCount; + + for (int i = 0; i < outputCount; i++) { + Decision next = input.get(i); + output.add(next); + + for (int j = i + 1; j < input.size(); j++) { + input.get(j).acceptedBefore(next); + } + input.subList(i, input.size()).sort(Decision.COMPARATOR); + } + } + public JSONArray serializeDecisions(GlobalOperationStatistics stats) { JSONArray result = new JSONArray(); result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); - int numDecisions = 100; - activeSpecializationsMap.entrySet().stream().filter(e -> e.getKey().getCountActive() > 0).sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).limit(numDecisions).forEachOrdered( - e -> { - result.put(e.getKey().serializeDecision(stats)); - }); + List decisions = new ArrayList<>(); + + activeSpecializationsMap.entrySet().forEach(e -> { + decisions.add(new Decision.Quicken(e.getKey().instructionId, e.getKey().specializationIds(), e.getValue())); + }); calcNumNodesWithInstruction(); + instructionSequencesMap.entrySet().forEach(e -> { + decisions.add(new Decision.SuperInstruction(e.getKey().instructions, e.getValue())); + }); + + decisions.sort(Decision.COMPARATOR); + System.err.println("================================================"); - System.err.println("Common instructions: "); + System.err.println("Decisions: "); + + List acceptedDecisions = new ArrayList<>(); + orderDecisions(acceptedDecisions, decisions, 100); + + for (Decision dec : acceptedDecisions) { + System.err.printf(" * %.0f %s%n", dec.value(), dec.id(stats)); + } + System.err.println(); + numNodesWithInstruction.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).forEachOrdered(x -> { System.err.printf("%30s: %d%n", stats.instrNames[x.getKey()], x.getValue()); }); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java index 7793ce233207..e37dff6236ef 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java @@ -69,6 +69,15 @@ public abstract class CodeElement implements Element, Generat private Element generatorElement; private AnnotationMirror generatorAnnotationMirror; + private boolean highPriority; + + public boolean isHighPriority() { + return highPriority; + } + + public void setHighPriority(boolean highPriority) { + this.highPriority = highPriority; + } public CodeElement(Set modifiers) { this.modifiers = new LinkedHashSet<>(modifiers); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java index 33c764cdc1df..192ce81fb594 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java @@ -72,6 +72,7 @@ import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeElementScanner; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeImport; @@ -241,11 +242,23 @@ protected void writeClassImpl(CodeTypeElement e) { writeEmptyLn(); indent(1); + writeClassImplElements(e, true); + writeClassImplElements(e, false); + + dedent(1); + write("}"); + writeEmptyLn(); + } + + private void writeClassImplElements(CodeTypeElement e, boolean highPriority) { List staticFields = getStaticFields(e); - List instanceFields = getInstanceFields(e); + boolean hasStaticFields = false; for (int i = 0; i < staticFields.size(); i++) { VariableElement field = staticFields.get(i); + if (highPriority != isHighPriority(field)) { + continue; + } field.accept(this, null); if (e.getKind() == ElementKind.ENUM && i < staticFields.size() - 1) { write(","); @@ -254,40 +267,59 @@ protected void writeClassImpl(CodeTypeElement e) { write(";"); writeLn(); } + hasStaticFields = true; } - if (staticFields.size() > 0) { + if (hasStaticFields) { writeEmptyLn(); } - for (VariableElement field : instanceFields) { + boolean hasInstanceFields = false; + for (VariableElement field : getInstanceFields(e)) { + if (highPriority != isHighPriority(field)) { + continue; + } field.accept(this, null); write(";"); writeLn(); + hasInstanceFields = true; } - if (instanceFields.size() > 0) { + + if (hasInstanceFields) { writeEmptyLn(); } for (ExecutableElement method : ElementFilter.constructorsIn(e.getEnclosedElements())) { + if (highPriority != isHighPriority(method)) { + continue; + } method.accept(this, null); } for (ExecutableElement method : getInstanceMethods(e)) { + if (highPriority != isHighPriority(method)) { + continue; + } method.accept(this, null); } for (ExecutableElement method : getStaticMethods(e)) { + if (highPriority != isHighPriority(method)) { + continue; + } method.accept(this, null); } for (TypeElement clazz : e.getInnerClasses()) { + if (highPriority != isHighPriority(clazz)) { + continue; + } clazz.accept(this, null); } + } - dedent(1); - write("}"); - writeEmptyLn(); + private static boolean isHighPriority(Element e) { + return e instanceof CodeElement && ((CodeElement) e).isHighPriority(); } private void writeTypeParameters(Element enclosedType, List parameters) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index b12025c4f01a..4aa45fcf3e0d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -122,6 +122,7 @@ public CodeTypeElement createBuilderBytecodeNode() { CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", baseClass.asType()); + builderBytecodeNodeType.setHighPriority(true); initializeInstructions(builderBytecodeNodeType); builderBytecodeNodeType.add(createBytecodeLoop(baseClass)); @@ -287,6 +288,9 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(2); b.startStatement().startCall(varTracer, "startFunction").string("$this").end(2); + + b.startTryBlock(); + } else { varTracer = null; } @@ -441,6 +445,14 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); // while loop + if (m.isTracing()) { + b.end().startFinallyBlock(); + + b.startStatement().startCall(varTracer, "endFunction").string("$this").end(2); + + b.end(); + } + return mContinueAt; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 3fb354922a48..8bde84b38ec0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -65,12 +65,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (ctx.getData().isTracing()) { - b.startStatement().startCall("tracer", "endFunction"); - b.string("$this"); - b.end(2); - } - if (uncached) { b.statement("uncachedExecuteCount--"); b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index e96c75f8c84a..dfa263a4b051 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 03963c829f8a..643b1bb2ee08 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -1,137 +1,5 @@ [ "This file is autogenerated by the Operations DSL.", "Do not modify, as it will be overwritten when running with tracing support.", - "Use the overrides file to alter the optimisation decisions.", - { - "specializations": ["FromBigNumber"], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "FromLong", - "FromBigNumber" - ], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": ["FromLong"], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": ["FromBoolean"], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": ["Add0"], - "type": "Quicken", - "operation": "SLAdd" - }, - { - "specializations": ["ReadSLObject0"], - "type": "Quicken", - "operation": "SLReadProperty" - }, - { - "specializations": ["Boolean"], - "type": "Quicken", - "operation": "SLToBoolean" - }, - { - "specializations": ["Perform"], - "type": "Quicken", - "operation": "SLFunctionLiteral" - }, - { - "specializations": ["Direct"], - "type": "Quicken", - "operation": "SLInvoke" - }, - { - "specializations": [ - "LessOrEqual0", - "LessOrEqual1" - ], - "type": "Quicken", - "operation": "SLLessOrEqual" - }, - { - "specializations": ["WriteSLObject0"], - "type": "Quicken", - "operation": "SLWriteProperty" - }, - { - "specializations": ["FromTruffleString"], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "LessThan0", - "LessThan1" - ], - "type": "Quicken", - "operation": "SLLessThan" - }, - { - "specializations": ["LessOrEqual1"], - "type": "Quicken", - "operation": "SLLessOrEqual" - }, - { - "specializations": ["AddLong"], - "type": "Quicken", - "operation": "SLAdd" - }, - { - "specializations": ["LessThan1"], - "type": "Quicken", - "operation": "SLLessThan" - }, - { - "specializations": [ - "FromTruffleString", - "FromBigNumber" - ], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "FromTruffleString", - "FromLong" - ], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "Add0", - "Add1" - ], - "type": "Quicken", - "operation": "SLAdd" - }, - { - "specializations": [ - "FromTruffleString", - "FromLong", - "FromBigNumber" - ], - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": ["Boolean"], - "type": "Quicken", - "operation": "SLLogicalNot" - }, - { - "specializations": ["FromForeign0"], - "type": "Quicken", - "operation": "SLUnbox" - } + "Use the overrides file to alter the optimisation decisions." ] \ No newline at end of file From 6a4283a0352fc57ad3bf19e7cebed73afc4e6e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 20 Oct 2022 09:20:48 +0200 Subject: [PATCH 157/312] [wip] serialize si --- .../tracing/OperationsStatistics.java | 31 +- .../operations/OperationDecisions.java | 59 ++- .../operations/OperationsContext.java | 7 + .../instructions/SuperInstruction.java | 5 + .../sl/operations/SLOperationRootNode.java | 2 +- .../truffle/sl/operations/decisions.json | 341 +++++++++++++++++- 6 files changed, 419 insertions(+), 26 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 6f94b10a1a7a..e5e96e90ee82 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -397,7 +397,6 @@ public Object toString(String[] instrNames) { @Override public void startFunction(Node node) { - System.err.println(" [[ STARTING FUNCTION " + node); if (curNode != null) { nodeStack.add(curNode); } @@ -414,7 +413,6 @@ public void startFunction(Node node) { @Override public void endFunction(Node node) { - System.err.println(" ]] ENDING FUNCTION " + node); if (curNode != node) { throw new AssertionError("Tracer start/stop mismatch"); } @@ -585,46 +583,33 @@ private static void orderDecisions(List output, List input, } } + private static final int NUM_DECISIONS = 30; + public JSONArray serializeDecisions(GlobalOperationStatistics stats) { JSONArray result = new JSONArray(); result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); + // create decisions + calcNumNodesWithInstruction(); List decisions = new ArrayList<>(); - activeSpecializationsMap.entrySet().forEach(e -> { decisions.add(new Decision.Quicken(e.getKey().instructionId, e.getKey().specializationIds(), e.getValue())); }); - - calcNumNodesWithInstruction(); - instructionSequencesMap.entrySet().forEach(e -> { decisions.add(new Decision.SuperInstruction(e.getKey().instructions, e.getValue())); }); + // sort and print decisions.sort(Decision.COMPARATOR); - - System.err.println("================================================"); - System.err.println("Decisions: "); - List acceptedDecisions = new ArrayList<>(); - orderDecisions(acceptedDecisions, decisions, 100); + orderDecisions(acceptedDecisions, decisions, NUM_DECISIONS); + // serialize for (Decision dec : acceptedDecisions) { - System.err.printf(" * %.0f %s%n", dec.value(), dec.id(stats)); + result.put(dec.serialize(stats)); } - System.err.println(); - - numNodesWithInstruction.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).forEachOrdered(x -> { - System.err.printf("%30s: %d%n", stats.instrNames[x.getKey()], x.getValue()); - }); - System.err.println(); - System.err.println("Common superinstructions: "); - instructionSequencesMap.entrySet().stream().sorted((a, b) -> Long.compare(b.getValue(), a.getValue())).forEachOrdered(x -> { - System.err.printf("%60s: %d%n", x.getKey().toString(stats.instrNames), x.getValue()); - }); - System.err.println("================================================"); return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 56e6e7f7b79e..59b3e39ed13c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -51,6 +51,7 @@ public class OperationDecisions { private final List quicken = new ArrayList<>(); + private final List superInstr = new ArrayList<>(); public OperationDecisions() { } @@ -59,6 +60,10 @@ public List getQuicken() { return quicken; } + public List getSuperInstructions() { + return superInstr; + } + public OperationDecisions merge(OperationDecisions other, MessageContainer messager) { for (Quicken q : other.quicken) { if (quicken.contains(q)) { @@ -133,6 +138,54 @@ public static Quicken deserialize(JSONObject o) { } } + public static final class SuperInstruction { + final String[] instructions; + + private SuperInstruction(String[] instructions) { + this.instructions = instructions; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(instructions); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SuperInstruction other = (SuperInstruction) obj; + return Arrays.equals(instructions, other.instructions); + } + + @Override + public String toString() { + return "SuperInstruction [" + Arrays.toString(instructions) + "]"; + } + + public static SuperInstruction deserialize(JSONObject o) { + + JSONArray instrs = o.getJSONArray("instructions"); + List instructions = new ArrayList<>(); + + for (int i = 0; i < instrs.length(); i++) { + instructions.add(instrs.getString(i)); + } + + return new SuperInstruction(instructions.toArray(new String[instructions.size()])); + } + } + public static OperationDecisions deserialize(JSONArray o, MessageContainer messager) { OperationDecisions decisions = new OperationDecisions(); @@ -149,6 +202,10 @@ public static OperationDecisions deserialize(JSONArray o, MessageContainer messa Quicken q = Quicken.deserialize(decision); decisions.quicken.add(q); break; + case "SuperInstruction": + SuperInstruction si = SuperInstruction.deserialize(decision); + decisions.superInstr.add(si); + break; default: messager.addWarning("Invalid optimization decision: '%s'", decision.getString("type")); break; @@ -160,6 +217,6 @@ public static OperationDecisions deserialize(JSONArray o, MessageContainer messa @Override public String toString() { - return "OperationDecisions [quicken=" + quicken + "]"; + return "OperationDecisions [quicken=" + quicken + ", superInstr=" + superInstr + "]"; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 210fd6da7ec1..58a9a12e158f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -41,6 +41,7 @@ package com.oracle.truffle.dsl.processor.operations; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -92,6 +93,7 @@ public class OperationsContext { public final ArrayList instructions = new ArrayList<>(); public final ArrayList operations = new ArrayList<>(); + private final Map instructionNameMap = new HashMap<>(); private final Map customInstructionNameMap = new HashMap<>(); private final Map opDataNameMap = new HashMap<>(); private final OperationsData data; @@ -165,6 +167,7 @@ private void createBuiltinOperations() { public T add(T elem) { instructions.add(elem); + instructionNameMap.put(elem.name, elem); return elem; } @@ -231,6 +234,10 @@ public void processDecisions(OperationDecisions decisions) { add(new QuickenedInstruction(this, cinstr, instructionId++, opData, List.of(quicken.specializations))); } + + for (OperationDecisions.SuperInstruction si : decisions.getSuperInstructions()) { + Instruction[] instrs = Arrays.stream(si.instructions).map(instructionNameMap::get).toArray(Instruction[]::new); + } } public boolean hasBoxingElimination() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java new file mode 100644 index 000000000000..538061d66436 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -0,0 +1,5 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +public class SuperInstruction { + +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index dfa263a4b051..e96c75f8c84a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 643b1bb2ee08..6ede86b89a7a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -1,5 +1,344 @@ [ "This file is autogenerated by the Operations DSL.", "Do not modify, as it will be overwritten when running with tracing support.", - "Use the overrides file to alter the optimisation decisions." + "Use the overrides file to alter the optimisation decisions.", + { + "specializations": ["FromBigNumber"], + "id": "quicken:c.SLUnbox:FromBigNumber", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": [ + "FromLong", + "FromBigNumber" + ], + "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "instructions": [ + "load.local", + "c.SLUnbox" + ], + "id": "si:load.local,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "c.SLUnbox", + "load.local", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.argument", + "store.local", + "load.argument", + "store.local", + "load.local", + "c.SLUnbox", + "load.local", + "c.SLUnbox" + ], + "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.argument", + "store.local", + "load.local", + "c.SLUnbox", + "load.local", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "store.local", + "load.argument", + "store.local", + "load.local", + "c.SLUnbox", + "load.local", + "c.SLUnbox", + "c.SLAdd" + ], + "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "c.SLUnbox", + "load.local.boxed", + "c.SLUnbox", + "c.SLLessOrEqual", + "c.SLUnbox" + ], + "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "specializations": ["FromLong"], + "id": "quicken:c.SLUnbox:FromLong", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "instructions": [ + "c.SLUnbox", + "load.constant", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "c.SLUnbox", + "load.local.boxed", + "c.SLUnbox", + "c.SLLessOrEqual", + "c.SLUnbox" + ], + "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.constant", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.constant", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.constant", + "c.SLUnbox", + "c.SLAdd" + ], + "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", + "type": "SuperInstruction" + }, + { + "specializations": ["FromBoolean"], + "id": "quicken:c.SLUnbox:FromBoolean", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant", + "c.SLReadProperty" + ], + "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "c.SLAdd" + ], + "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant" + ], + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant", + "type": "SuperInstruction" + }, + { + "instructions": [ + "pop", + "load.local", + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.constant" + ], + "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant", + "type": "SuperInstruction" + }, + { + "instructions": [ + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.constant", + "c.SLFunctionLiteral", + "load.local", + "c.SLUnbox" + ], + "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "specializations": ["Add0"], + "id": "quicken:c.SLAdd:Add0", + "type": "Quicken", + "operation": "SLAdd" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local.boxed", + "c.SLUnbox", + "c.SLLessOrEqual", + "c.SLUnbox" + ], + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "pop", + "load.local", + "c.SLUnbox", + "load.constant", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "specializations": ["ReadSLObject0"], + "id": "quicken:c.SLReadProperty:ReadSLObject0", + "type": "Quicken", + "operation": "SLReadProperty" + }, + { + "instructions": [ + "pop", + "load.constant", + "c.SLFunctionLiteral", + "load.local", + "c.SLUnbox" + ], + "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "c.SLToBoolean", + "branch.false" + ], + "id": "si:c.SLToBoolean,branch.false", + "type": "SuperInstruction" + } ] \ No newline at end of file From a65df1ce1d0b5ad8aae50993351a90909bd687b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 20 Oct 2022 11:56:27 +0200 Subject: [PATCH 158/312] [wip] remove variadics from si --- .../operation/tracing/ExecutionTracer.java | 2 +- .../tracing/OperationsStatistics.java | 30 ++++++++++++------- .../OperationsBytecodeCodeGenerator.java | 2 ++ .../instructions/SuperInstruction.java | 5 ---- .../sl/operations/SLOperationRootNode.java | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index d5608233153a..51ab65cf09c7 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -71,7 +71,7 @@ public static void initialize(Class opsClass, String decisionsFile, String[] public abstract void endFunction(Node node); - public abstract void traceInstruction(int bci, int id); + public abstract void traceInstruction(int bci, int id, int... arguments); public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index e5e96e90ee82..a7fc57a2c1c6 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -232,7 +232,7 @@ public void endFunction(Node node) { } @Override - public void traceInstruction(int bci, int id) { + public void traceInstruction(int bci, int id, int... arguments) { } @Override @@ -432,21 +432,29 @@ public void endFunction(Node node) { } @Override - public void traceInstruction(int bci, int id) { + public void traceInstruction(int bci, int id, int... arguments) { nodesWithInstruction.computeIfAbsent(id, k -> new HashSet<>()).add(curNode); + boolean isBranch = arguments[0] != 0; + boolean isVariadic = arguments[1] != 0; + // SI finding - if (instrHistoryLen == MAX_SUPERINSTR_LEN) { - System.arraycopy(instrHistory, 1, instrHistory, 0, MAX_SUPERINSTR_LEN - 1); - instrHistory[MAX_SUPERINSTR_LEN - 1] = id; + if (isVariadic) { + // we don't support variadic + instrHistoryLen = 0; } else { - instrHistory[instrHistoryLen++] = id; - } + if (instrHistoryLen == MAX_SUPERINSTR_LEN) { + System.arraycopy(instrHistory, 1, instrHistory, 0, MAX_SUPERINSTR_LEN - 1); + instrHistory[MAX_SUPERINSTR_LEN - 1] = id; + } else { + instrHistory[instrHistoryLen++] = id; + } - for (int i = 0; i < instrHistoryLen - 1; i++) { - int[] curHistory = Arrays.copyOfRange(instrHistory, i, instrHistoryLen); - InstructionSequenceKey key = new InstructionSequenceKey(curHistory); - instructionSequencesMap.merge(key, 1L, EnabledExecutionTracer::saturatingAdd); + for (int i = 0; i < instrHistoryLen - 1; i++) { + int[] curHistory = Arrays.copyOfRange(instrHistory, i, instrHistoryLen); + InstructionSequenceKey key = new InstructionSequenceKey(curHistory); + instructionSequencesMap.merge(key, 1L, EnabledExecutionTracer::saturatingAdd); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 4aa45fcf3e0d..926b5d937861 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -341,6 +341,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startStatement().startCall(varTracer, "traceInstruction"); b.variable(vars.bci); b.variable(op.opcodeIdField); + b.string(op.isBranchInstruction() ? "1" : "0"); + b.string(op.isVariadic() ? "1" : "0"); b.end(2); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java deleted file mode 100644 index 538061d66436..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations.instructions; - -public class SuperInstruction { - -} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index e96c75f8c84a..dfa263a4b051 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) From 57716be31809de8a75cee2a079c9046aac6ecedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 24 Oct 2022 15:11:26 +0200 Subject: [PATCH 159/312] [wip] first SI impl --- .../truffle/api/impl/FrameWithoutBoxing.java | 1 + .../truffle/api/impl/UnsafeFrameAccess.java | 163 ++++++++++++++++++ .../operations/OperationGeneratorUtils.java | 6 + .../OperationsBytecodeCodeGenerator.java | 13 +- .../operations/OperationsCodeGenerator.java | 7 +- .../operations/OperationsContext.java | 10 +- .../operations/instructions/Instruction.java | 37 +++- .../instructions/SuperInstruction.java | 141 +++++++++++++++ .../sl/operations/SLOperationRootNode.java | 2 +- 9 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index d8d3e2b14d4b..90d9c69a2776 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -626,6 +626,7 @@ private byte getIndexedTagChecked(int slot) { } private byte unsafeGetIndexedTag(int slot) { + assert getIndexedTags()[slot] >= 0; byte tag = UNSAFE.getByte(getIndexedTags(), Unsafe.ARRAY_BYTE_BASE_OFFSET + slot * Unsafe.ARRAY_BYTE_INDEX_SCALE); assert (tag & STATIC_TAG) == 0 : UNEXPECTED_NON_STATIC_READ; return tag; diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 14c9644e5209..11785fcce038 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -288,4 +288,167 @@ public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { } } + private static final class ImplSafe extends UnsafeFrameAccess { + + @Override + public short unsafeShortArrayRead(short[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeShortArrayWrite(short[] arr, int index, short value) { + arr[index] = value; + } + + @Override + public byte unsafeByteArrayRead(byte[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeByteArrayWrite(byte[] arr, int index, byte value) { + arr[index] = value; + } + + @Override + public int unsafeIntArrayRead(int[] arr, int index) { + return arr[index]; + } + + @Override + public void unsafeIntArrayWrite(int[] arr, int index, int value) { + arr[index] = value; + } + + @Override + public T unsafeObjectArrayRead(T[] arr, int index) { + return arr[index]; + } + + @Override + public byte unsafeGetTag(Frame frame, int slot) { + return frame.getTag(slot); + } + + @Override + public Object unsafeGetObject(Frame frame, int slot) { + return frame.getObject(slot); + } + + @Override + public boolean unsafeGetBoolean(Frame frame, int slot) { + return frame.getBoolean(slot); + } + + @Override + public int unsafeGetInt(Frame frame, int slot) { + return frame.getInt(slot); + } + + @Override + public long unsafeGetLong(Frame frame, int slot) { + return frame.getLong(slot); + } + + @Override + public double unsafeGetDouble(Frame frame, int slot) { + return frame.getDouble(slot); + } + + @Override + public Object unsafeUncheckedGetObject(Frame frame, int slot) { + return frame.getObject(slot); + } + + @Override + public boolean unsafeUncheckedGetBoolean(Frame frame, int slot) { + return frame.getBoolean(slot); + } + + @Override + public int unsafeUncheckedGetInt(Frame frame, int slot) { + return frame.getInt(slot); + } + + @Override + public long unsafeUncheckedGetLong(Frame frame, int slot) { + return frame.getLong(slot); + } + + @Override + public double unsafeUncheckedGetDouble(Frame frame, int slot) { + return frame.getDouble(slot); + } + + @Override + public void unsafeSetObject(Frame frame, int slot, Object value) { + frame.setObject(slot, value); + } + + @Override + public void unsafeSetBoolean(Frame frame, int slot, boolean value) { + frame.setBoolean(slot, value); + } + + @Override + public void unsafeSetInt(Frame frame, int slot, int value) { + frame.setInt(slot, value); + } + + @Override + public void unsafeSetLong(Frame frame, int slot, long value) { + frame.setLong(slot, value); + } + + @Override + public void unsafeSetDouble(Frame frame, int slot, double value) { + frame.setDouble(slot, value); + } + + @Override + public boolean unsafeIsObject(Frame frame, int slot) { + return frame.isObject(slot); + } + + @Override + public boolean unsafeIsBoolean(Frame frame, int slot) { + return frame.isBoolean(slot); + } + + @Override + public boolean unsafeIsInt(Frame frame, int slot) { + return frame.isInt(slot); + } + + @Override + public boolean unsafeIsLong(Frame frame, int slot) { + return frame.isLong(slot); + } + + @Override + public boolean unsafeIsDouble(Frame frame, int slot) { + return frame.isDouble(slot); + } + + @Override + public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { + frame.copy(srcSlot, dstSlot); + } + + @Override + public void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length) { + srcFrame.copyTo(srcOffset, dstFrame, dstOffset, length); + } + + @Override + public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { + frame.copyObject(srcSlot, dstSlot); + } + + @Override + public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { + frame.copyPrimitive(srcSlot, dstSlot); + } + + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index eb0e44462dd0..7990441ffde4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -120,6 +120,12 @@ public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElem CodeTreeBuilder.singleVariable(bci)); } + public static CodeTree createReadOpcode(CodeVariableElement bc, String bci) { + return createReadOpcode( + CodeTreeBuilder.singleVariable(bc), + CodeTreeBuilder.singleString(bci)); + } + public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { return CodeTreeBuilder.createBuilder().startStatement().startCall("unsafeWriteBytecode").tree(bc).tree(bci).startGroup().string("(short) ").tree(value).end(3).build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 926b5d937861..71e8fcaecff3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -320,7 +320,12 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); - b.startSwitch().string("curOpcode").end(); + b.startSwitch(); + b.string("curOpcode"); + if (isUncached) { + b.string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS); + } + b.end(); b.startBlock(); for (Instruction op : m.getInstructions()) { @@ -390,7 +395,11 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(); } } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + if (isUncached) { + b.startCase().variable(op.opcodeIdField).end(); + } else { + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + } b.startBlock(); if (ctx.hasBoxingElimination()) { vars.specializedKind = FrameKind.OBJECT; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index e3ba747c3131..01b41ed48d1e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -612,9 +612,6 @@ private CodeTypeElement createContinuationRoot(CodeTypeElement typOperationNodeI b.statement("parentFrame.copyTo(root._maxLocals, frame, root._maxLocals, sp - 1 - root._maxLocals)"); b.statement("frame.setObject(sp - 1, inputValue)"); - // b.statement("System.err.printf(\" continuing: %s %s %d%n\", frame, parentFrame, (target - // >> 16) + root._maxLocals)"); - b.statement("return root.executeAt(frame, parentFrame, (sp << 16) | (target & 0xffff))"); return cr; @@ -999,6 +996,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "curStack")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "maxStack")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLocals")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "instructionHistory = new int[8]")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "instructionHistoryIndex = 0")); if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLabels")); } @@ -2726,6 +2725,8 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("numChildNodes = 0"); b.statement("numConditionProfiles = 0"); b.statement("exceptionHandlers.clear()"); + b.statement("Arrays.fill(instructionHistory, -1)"); + b.statement("instructionHistoryIndex = 0"); if (m.enableYield) { b.statement("yieldCount = 0"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 58a9a12e158f..28dffccca275 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -72,6 +72,7 @@ import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalMaterializedInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.SuperInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; import com.oracle.truffle.dsl.processor.operations.instructions.YieldInstruction; @@ -145,7 +146,8 @@ private void createBuiltinOperations() { if (hasBoxingElimination()) { loadLocalBoxed = add(new LoadLocalInstruction(this, instructionId++, true)); } - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(this, instructionId++)))); + Instruction storeLocal; + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, storeLocal = add(new StoreLocalInstruction(this, instructionId++)))); add(new Operation.Simple(this, "Return", operationId++, 1, add(new ReturnInstruction(this, instructionId++)))); add(new Operation.LoadLocalMaterialized(this, operationId++, add(new LoadLocalMaterializedInstruction(this, instructionId++)))); @@ -163,6 +165,8 @@ private void createBuiltinOperations() { add(new InstrumentationExitInstruction(this, instructionId++)), add(new InstrumentationExitInstruction(this, instructionId++, true)), add(new InstrumentationLeaveInstruction(this, instructionId++)))); + + add(new SuperInstruction(this, instructionId++, storeLocal, loadLocalUnboxed)); } public T add(T elem) { @@ -240,6 +244,10 @@ public void processDecisions(OperationDecisions decisions) { } } + public List getSuperInstructions() { + return instructions.stream().filter(x -> x instanceof SuperInstruction).map(x -> (SuperInstruction) x).toList(); + } + public boolean hasBoxingElimination() { return data.getBoxingEliminatedTypes().size() > 0; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 1bdb2ef25cd1..0b075548314e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -53,6 +53,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; @@ -251,7 +252,7 @@ private int getInstrumentsOffset() { return getStateBitsOffset() + stateBits.size(); } - private int length() { + protected int length() { return getInstrumentsOffset() + instruments.size(); } @@ -548,6 +549,40 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) // todo: instruments + // superinstructions + + final int MAX_HISTORY = 8; + + b.startAssign("instructionHistory[++instructionHistoryIndex % " + MAX_HISTORY + "]").variable(opcodeIdField).end(); + + boolean elseIf = false; + for (SuperInstruction si : ctx.getSuperInstructions()) { + Instruction[] instrs = si.getInstructions(); + + if (instrs[instrs.length - 1].id == id) { + String lengthOffset = ""; + elseIf = b.startIf(elseIf); + for (int i = 1; i < instrs.length; i++) { + if (i != 1) { + b.string(" && "); + } + b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + MAX_HISTORY + ") % 8] == "); + b.variable(instrs[instrs.length - 1 - i].opcodeIdField); + } + b.end().startBlock(); + + b.startStatement().variable(vars.bc).string("["); + b.variable(vars.bci); + // skips the last since BCI is still not incremented for current instruction + for (int i = 0; i < instrs.length - 1; i++) { + b.string(" - ").tree(instrs[i].createLength()); + } + b.string("] = ").tree(OperationGeneratorUtils.combineBoxingBits(ctx, si, 0)).end(); + + b.end(); + } + } + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); b.tree(createCustomEmitCodeAfter(vars, args)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java new file mode 100644 index 000000000000..f986ce7e3c00 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -0,0 +1,141 @@ +package com.oracle.truffle.dsl.processor.operations.instructions; + +import java.util.List; +import java.util.function.Function; + +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationsContext; + +public class SuperInstruction extends Instruction { + + private final Instruction[] instructions; + + public Instruction[] getInstructions() { + return instructions; + } + + public SuperInstruction(OperationsContext ctx, int id, Instruction... instrs) { + super(ctx, makeName(instrs), id, 0); + this.instructions = instrs; + } + + private static String makeName(Instruction[] instrs) { + StringBuilder sb = new StringBuilder("si"); + for (Instruction i : instrs) { + sb.append("."); + sb.append(i.name); + } + + return sb.toString(); + } + + private static void createExecute(CodeTreeBuilder b, ExecutionVariables vars, Instruction instr, Function exec) { + // todo: merge this with OpByCoGe code, since now we have duplication (and probably bugs) + if (instr.splitOnBoxingElimination()) { + b.startSwitch().string("unsafeFromBytecode($bc, $bci) & 7").end().startBlock(); + + for (FrameKind kind : instr.getBoxingEliminationSplits()) { + b.startCase().string(kind.toOrdinal()).end().startBlock(); + vars.specializedKind = kind; + b.tree(exec.apply(vars)); + vars.specializedKind = null; + b.statement("break"); + b.end(); + } + + if (instr.hasGeneric()) { + b.startCase().string("7 /* generic */").end().startBlock(); + b.tree(exec.apply(vars)); + b.statement("break"); + b.end(); + } + + b.end(); + } else if (instr.numPushedValues == 0 || instr.alwaysBoxed()) { + b.tree(exec.apply(vars)); + } else { + b.startBlock(); + b.declaration("int", "primitiveTag", "unsafeFromBytecode($bc, $bci) & 7"); + b.tree(exec.apply(vars)); + b.end(); + } + } + + @Override + public CodeTree createExecuteCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + for (Instruction instr : instructions) { + createExecute(b, vars, instr, instr::createExecuteCode); + if (!instr.isBranchInstruction()) { + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); + } + } + + if (!instructions[instructions.length - 1].isBranchInstruction()) { + b.statement("continue loop"); + } + + return b.build(); + } + + @Override + public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + for (Instruction instr : instructions) { + b.startBlock(); + b.tree(instr.createExecuteUncachedCode(vars)); + if (!instr.isBranchInstruction()) { + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); + } + b.end(); + } + if (!instructions[instructions.length - 1].isBranchInstruction()) { + b.statement("continue loop"); + } + + return b.build(); + } + + @Override + public boolean isBranchInstruction() { + return true; + } + + @Override + protected int length() { + int len = 0; + for (Instruction i : instructions) { + len += i.length(); + } + + return len; + } + + @Override + public CodeTree createDumpCode(ExecutionVariables vars) { + // TODO Auto-generated method stub + return super.createDumpCode(vars); + } + + @Override + public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean alwaysBoxed() { + return instructions[0].alwaysBoxed(); + } + + @Override + public List getBoxingEliminationSplits() { + return instructions[0].getBoxingEliminationSplits(); + } + + @Override + public boolean splitOnBoxingElimination() { + return false; + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index dfa263a4b051..e96c75f8c84a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) From 027037123621b320082ea3ae96550b4b948e544a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 25 Oct 2022 09:50:09 +0200 Subject: [PATCH 160/312] [wip] si + decisions logging --- .../operation/introspection/Instruction.java | 22 +++- .../api/operation/tracing/Decision.java | 32 +++++ .../tracing/OperationsStatistics.java | 25 +++- .../OperationsBytecodeCodeGenerator.java | 2 +- .../operations/OperationsContext.java | 24 +++- .../operations/instructions/Instruction.java | 6 +- .../instructions/SuperInstruction.java | 31 ++++- .../truffle/polyglot/PolyglotEngineImpl.java | 2 +- .../polyglot/PolyglotEngineOptions.java | 6 +- .../sl/operations/SLOperationRootNode.java | 2 +- .../truffle/sl/operations/decisions.json | 118 +++++++++++------- 11 files changed, 204 insertions(+), 66 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java index aaa1e09901be..1a532ab808f6 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java @@ -6,11 +6,11 @@ public final class Instruction { + // [int index, String name, short[] bytes, Object[][] arguments, Object[][] subinstructions?] private final Object[] data; Instruction(Object[] data) { this.data = data; - } public int getIndex() { @@ -39,12 +39,24 @@ public List getArgumentValues() { return Arrays.stream((Object[]) data[3]).map(x -> new Argument((Object[]) x)).collect(Collectors.toUnmodifiableList()); } + public List getSubInstructions() { + if (data.length >= 5) { + return Arrays.stream((Object[]) data[4]).map(x -> new Instruction((Object[]) x)).collect(Collectors.toUnmodifiableList()); + } else { + return List.of(); + } + } + private static final int REASONABLE_INSTRUCTION_LENGTH = 16; @Override public String toString() { + return toString(""); + } + + private String toString(String prefix) { StringBuilder sb = new StringBuilder(); - sb.append(String.format("[%04x] ", getIndex())); + sb.append(String.format("%s[%04x] ", prefix, getIndex())); byte[] bytes = getBytes(); for (int i = 0; i < REASONABLE_INSTRUCTION_LENGTH; i++) { @@ -55,7 +67,7 @@ public String toString() { } } - for (int i = REASONABLE_INSTRUCTION_LENGTH; i < data.length; i++) { + for (int i = REASONABLE_INSTRUCTION_LENGTH; i < bytes.length; i++) { sb.append(String.format("%02x ", bytes[i])); } @@ -65,6 +77,10 @@ public String toString() { sb.append(' ').append(a.toString()); } + for (Instruction instr : getSubInstructions()) { + sb.append('\n').append(instr.toString(prefix + " ")); + } + return sb.toString(); } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java index 2e2d095e3994..45dda97f20ab 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -29,6 +29,7 @@ boolean acceptedBefore(Decision decision) { JSONObject serialize(GlobalOperationStatistics stats) { JSONObject obj = new JSONObject(); + obj.put("_comment", "value: " + value()); obj.put("type", type); obj.put("id", id(stats)); return obj; @@ -78,6 +79,21 @@ JSONObject serialize(GlobalOperationStatistics stats) { return result; } + + @Override + protected String prettyPrint(GlobalOperationStatistics stats) { + StringBuilder sb = new StringBuilder(); + + sb.append("Quicken ").append(id(stats)).append('\n'); + sb.append(" value: ").append(value()).append('\n'); + sb.append(" total execution count: ").append(executionCount).append('\n'); + sb.append(" instruction: ").append(stats.instrNames[instruction]).append('\n'); + for (int i = 0; i < specializations.length; i++) { + sb.append(" specialization[").append(i).append("]: ").append(stats.specNames[instruction][specializations[i]]).append('\n'); + } + + return sb.toString(); + } } static final class SuperInstruction extends Decision { @@ -133,5 +149,21 @@ JSONObject serialize(GlobalOperationStatistics stats) { return result; } + + @Override + protected String prettyPrint(GlobalOperationStatistics stats) { + StringBuilder sb = new StringBuilder(); + + sb.append("SuperInstruction ").append(id(stats)).append('\n'); + sb.append(" value: ").append(value()).append('\n'); + sb.append(" total execution count: ").append(executionCount).append('\n'); + for (int i = 0; i < instructions.length; i++) { + sb.append(" instruction[").append(i).append("]: ").append(stats.instrNames[instructions[i]]).append('\n'); + } + + return sb.toString(); + } } + + protected abstract String prettyPrint(GlobalOperationStatistics stats); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index a7fc57a2c1c6..3e909aa3263d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -113,7 +113,7 @@ private void read() { } } - public void write() { + public void write(boolean dumpInfo) { try { try { JSONArray result = new JSONArray(); @@ -135,7 +135,7 @@ public void write() { this.statisticsMap.forEach((k, v) -> { try { - v.writeDecisions(); + v.writeDecisions(dumpInfo); } catch (IOException e) { e.printStackTrace(); } @@ -160,11 +160,11 @@ static final class GlobalOperationStatistics { this.opsClass = opsClass; } - public void writeDecisions() throws IOException { + public void writeDecisions(boolean dumpInfo) throws IOException { setNames(); EnabledExecutionTracer tracer = collect(); try (FileChannel ch = FileChannel.open(Path.of(decisionsFile), StandardOpenOption.WRITE, StandardOpenOption.CREATE)) { - JSONArray result = tracer.serializeDecisions(this); + JSONArray result = tracer.serializeDecisions(this, dumpInfo); ch.truncate(0); ch.write(ByteBuffer.wrap(result.toString(4).getBytes(StandardCharsets.UTF_8))); } @@ -593,7 +593,7 @@ private static void orderDecisions(List output, List input, private static final int NUM_DECISIONS = 30; - public JSONArray serializeDecisions(GlobalOperationStatistics stats) { + public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dumpInfo) { JSONArray result = new JSONArray(); result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); @@ -609,16 +609,29 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats) { decisions.add(new Decision.SuperInstruction(e.getKey().instructions, e.getValue())); }); - // sort and print + // sort decisions.sort(Decision.COMPARATOR); List acceptedDecisions = new ArrayList<>(); orderDecisions(acceptedDecisions, decisions, NUM_DECISIONS); + if (dumpInfo) { + System.err.println("======================== OPERATION DSL TRACING DECISIONS ======================== "); + System.err.println("# For " + stats.opsClass.getSimpleName()); + System.err.println(); + } + // serialize for (Decision dec : acceptedDecisions) { + if (dumpInfo) { + System.err.println(dec.prettyPrint(stats)); + } result.put(dec.serialize(stats)); } + if (dumpInfo) { + System.err.println("================================================================================= "); + } + return result; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 71e8fcaecff3..56f58b1e62ec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -379,7 +379,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { createBody.run(); b.end(); } - } else if (op.numPushedValues == 0 || op.alwaysBoxed()) { + } else if (op.alwaysBoxed()) { b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); b.startBlock(); createBody.run(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index 28dffccca275..f507ee773bba 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -146,8 +146,7 @@ private void createBuiltinOperations() { if (hasBoxingElimination()) { loadLocalBoxed = add(new LoadLocalInstruction(this, instructionId++, true)); } - Instruction storeLocal; - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, storeLocal = add(new StoreLocalInstruction(this, instructionId++)))); + add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(this, instructionId++)))); add(new Operation.Simple(this, "Return", operationId++, 1, add(new ReturnInstruction(this, instructionId++)))); add(new Operation.LoadLocalMaterialized(this, operationId++, add(new LoadLocalMaterializedInstruction(this, instructionId++)))); @@ -165,8 +164,6 @@ private void createBuiltinOperations() { add(new InstrumentationExitInstruction(this, instructionId++)), add(new InstrumentationExitInstruction(this, instructionId++, true)), add(new InstrumentationLeaveInstruction(this, instructionId++)))); - - add(new SuperInstruction(this, instructionId++, storeLocal, loadLocalUnboxed)); } public T add(T elem) { @@ -239,8 +236,25 @@ public void processDecisions(OperationDecisions decisions) { add(new QuickenedInstruction(this, cinstr, instructionId++, opData, List.of(quicken.specializations))); } - for (OperationDecisions.SuperInstruction si : decisions.getSuperInstructions()) { + outer: for (OperationDecisions.SuperInstruction si : decisions.getSuperInstructions()) { Instruction[] instrs = Arrays.stream(si.instructions).map(instructionNameMap::get).toArray(Instruction[]::new); + + int i = -1; + for (Instruction instr : instrs) { + i++; + if (instr == null) { + data.addWarning("Invalid SuperInstruction decision: undefined instruction %s. Rerun the corpus with tracing to regenerate decisions.", si.instructions[i]); + continue outer; + } + + if (instr.isVariadic()) { + data.addWarning("Invalid SuperInstruction decision: unsuported variadic instruction %s. Remove this decision.", si.instructions[i]); + continue outer; + } + + } + + add(new SuperInstruction(this, instructionId++, instrs)); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 0b075548314e..7b7334da73e6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -383,7 +383,11 @@ public boolean splitOnBoxingElimination() { } public boolean alwaysBoxed() { - throw new AssertionError(name); + if (numPushedValues == 0) { + return true; + } else { + throw new AssertionError(name); + } } public List getBoxingEliminationSplits() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index f986ce7e3c00..17158f21fb61 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -3,6 +3,8 @@ import java.util.List; import java.util.function.Function; +import javax.lang.model.type.ArrayType; + import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -114,8 +116,33 @@ protected int length() { @Override public CodeTree createDumpCode(ExecutionVariables vars) { - // TODO Auto-generated method stub - return super.createDumpCode(vars); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.statement("int oldBci = $bci"); + + b.startAssign("Object[] decSuper"); + b.startNewArray((ArrayType) context.getType(Object[].class), null); + b.string("$bci"); + b.doubleQuote(name); + b.startGroup().string("Arrays.copyOfRange($bc, $bci, $bci + ").tree(createLength()).string(")").end(); + b.startNewArray((ArrayType) context.getType(Object[].class), null).end(); + b.startNewArray((ArrayType) context.getType(Object[].class), CodeTreeBuilder.singleString("" + instructions.length)).end(); + b.end(2); // outer array, assign + + for (int i = 0; i < instructions.length; i++) { + b.startBlock(); + b.tree(instructions[i].createDumpCode(vars)); + b.startAssign("((Object[]) decSuper[4])[" + i + "]").string("dec").end(); + b.end(); + + b.startStatement().string("$bci += ").tree(instructions[i].createLength()).end(); + } + + b.startAssign("Object[] dec").string("decSuper").end(); + + b.statement("$bci = oldBci"); + + return b.build(); } @Override diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java index a14b37858b35..1234916ba585 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java @@ -1217,7 +1217,7 @@ void ensureClosed(boolean force, boolean inShutdownHook, boolean initiatedByCont } if (operationStatistics != null) { - operationStatistics.write(); + operationStatistics.write(engineOptionValues.get(PolyglotEngineOptions.OperationsDumpDecisions)); } // don't commit changes to contexts if still running diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java index 1cf4c5617434..1095f1308e31 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineOptions.java @@ -121,9 +121,13 @@ final class PolyglotEngineOptions { static final OptionKey TraceCodeSharing = new OptionKey<>(false); @Option(category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL, help = "" + - "Enables and sets the state file path for Operations tracer") // + "Enables and sets the state file path for Operation DSL tracer") // static final OptionKey OperationsTracingState = new OptionKey<>(""); + @Option(category = OptionCategory.EXPERT, stability = OptionStability.EXPERIMENTAL, help = "" + + "Dumps the Operation DSL decisions. This option is indended for debugging corpus tracing decisions.") // + static final OptionKey OperationsDumpDecisions = new OptionKey<>(false); + enum StaticObjectStorageStrategies { DEFAULT, ARRAY_BASED, diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index e96c75f8c84a..dfa263a4b051 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 6ede86b89a7a..d8856d90b371 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -4,6 +4,7 @@ "Use the overrides file to alter the optimisation decisions.", { "specializations": ["FromBigNumber"], + "_comment": "value: 1.482583E7", "id": "quicken:c.SLUnbox:FromBigNumber", "type": "Quicken", "operation": "SLUnbox" @@ -13,6 +14,7 @@ "FromLong", "FromBigNumber" ], + "_comment": "value: 8795576.0", "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", "type": "Quicken", "operation": "SLUnbox" @@ -22,6 +24,7 @@ "load.local", "c.SLUnbox" ], + "_comment": "value: 7932511.0", "id": "si:load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -34,9 +37,31 @@ "c.SLAdd", "c.SLUnbox" ], + "_comment": "value: 6416860.0", "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, + { + "instructions": [ + "store.local", + "load.local", + "c.SLUnbox" + ], + "_comment": "value: 6010640.0", + "id": "si:store.local,load.local,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox" + ], + "_comment": "value: 6004146.0", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "type": "SuperInstruction" + }, { "instructions": [ "load.argument", @@ -48,6 +73,7 @@ "load.local", "c.SLUnbox" ], + "_comment": "value: 5902799.0", "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -62,6 +88,7 @@ "c.SLAdd", "c.SLUnbox" ], + "_comment": "value: 5902666.0", "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -76,17 +103,21 @@ "c.SLUnbox", "c.SLAdd" ], + "_comment": "value: 5902666.0", "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, { "instructions": [ + "load.local", + "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox" ], - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "_comment": "value: 5002950.0", + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, { @@ -97,23 +128,13 @@ "c.SLLessOrEqual", "c.SLUnbox" ], + "_comment": "value: 4997956.0", "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, - { - "instructions": [ - "load.local", - "load.constant", - "load.local", - "load.constant", - "c.SLReadProperty", - "c.SLUnbox" - ], - "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", - "type": "SuperInstruction" - }, { "specializations": ["FromLong"], + "_comment": "value: 4756490.0", "id": "quicken:c.SLUnbox:FromLong", "type": "Quicken", "operation": "SLUnbox" @@ -126,6 +147,7 @@ "c.SLAdd", "c.SLUnbox" ], + "_comment": "value: 4451184.0", "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -138,6 +160,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], + "_comment": "value: 4000780.0", "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -152,6 +175,7 @@ "load.constant", "c.SLUnbox" ], + "_comment": "value: 3649065.0", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", "type": "SuperInstruction" }, @@ -166,6 +190,7 @@ "c.SLAdd", "c.SLUnbox" ], + "_comment": "value: 3649065.0", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -180,15 +205,32 @@ "c.SLUnbox", "c.SLAdd" ], + "_comment": "value: 3649065.0", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, { "specializations": ["FromBoolean"], + "_comment": "value: 3404438.0", "id": "quicken:c.SLUnbox:FromBoolean", "type": "Quicken", "operation": "SLUnbox" }, + { + "instructions": [ + "c.SLReadProperty", + "c.SLUnbox", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "c.SLAdd", + "c.SLUnbox" + ], + "_comment": "value: 3355072.0", + "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", + "type": "SuperInstruction" + }, { "instructions": [ "load.local", @@ -200,6 +242,7 @@ "c.SLReadProperty", "c.SLUnbox" ], + "_comment": "value: 3355065.0", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, @@ -214,6 +257,7 @@ "load.constant", "c.SLReadProperty" ], + "_comment": "value: 3355065.0", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", "type": "SuperInstruction" }, @@ -228,6 +272,7 @@ "c.SLUnbox", "c.SLAdd" ], + "_comment": "value: 3355065.0", "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, @@ -242,6 +287,7 @@ "load.local", "load.constant" ], + "_comment": "value: 3355065.0", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant", "type": "SuperInstruction" }, @@ -256,51 +302,41 @@ "c.SLUnbox", "load.constant" ], + "_comment": "value: 3355065.0", "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant", "type": "SuperInstruction" }, { "instructions": [ - "c.SLReadProperty", - "c.SLUnbox", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", - "c.SLAdd", - "c.SLUnbox" - ], - "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", - "type": "SuperInstruction" - }, - { - "instructions": [ - "load.constant", - "c.SLFunctionLiteral", - "load.local", + "load.local.boxed", + "c.SLUnbox", + "c.SLLessOrEqual", "c.SLUnbox" ], - "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", + "_comment": "value: 3145338.0", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["Add0"], + "_comment": "value: 3056151.0", "id": "quicken:c.SLAdd:Add0", "type": "Quicken", "operation": "SLAdd" }, { "instructions": [ - "load.local", "load.constant", - "c.SLReadProperty", - "c.SLUnbox", - "load.local.boxed", - "c.SLUnbox", - "c.SLLessOrEqual", + "c.SLFunctionLiteral", + "load.local", "c.SLUnbox" ], - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "_comment": "value: 3024984.0", + "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, { @@ -313,31 +349,23 @@ "c.SLAdd", "c.SLUnbox" ], + "_comment": "value: 2763516.0", "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["ReadSLObject0"], + "_comment": "value: 2127101.0", "id": "quicken:c.SLReadProperty:ReadSLObject0", "type": "Quicken", "operation": "SLReadProperty" }, - { - "instructions": [ - "pop", - "load.constant", - "c.SLFunctionLiteral", - "load.local", - "c.SLUnbox" - ], - "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", - "type": "SuperInstruction" - }, { "instructions": [ "c.SLToBoolean", "branch.false" ], + "_comment": "value: 1703078.0", "id": "si:c.SLToBoolean,branch.false", "type": "SuperInstruction" } From c0b8e1de2104c269c44e107e85fd537463359acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 25 Oct 2022 11:26:57 +0200 Subject: [PATCH 161/312] [wip] wrap executions into methods --- .../operations/OperationGeneratorUtils.java | 69 +++++++++++++++++++ .../OperationsBytecodeCodeGenerator.java | 46 ++++++++----- .../instructions/BranchInstruction.java | 7 +- .../ConditionalBranchInstruction.java | 5 +- .../operations/instructions/Instruction.java | 6 +- .../instructions/ReturnInstruction.java | 11 ++- .../instructions/ShortCircuitInstruction.java | 6 +- .../instructions/SuperInstruction.java | 5 +- .../sl/operations/SLOperationRootNode.java | 2 +- 9 files changed, 127 insertions(+), 30 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 7990441ffde4..1271057dd704 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -60,6 +61,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; @@ -345,4 +347,71 @@ public static CodeTree extractBoxingBits(OperationsContext ctx, CodeTree instr) return CodeTreeBuilder.singleString("0"); } } + + public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVariables vars, String name, boolean isUncached, Consumer build) { + ProcessorContext context = ProcessorContext.getInstance(); + createHelperMethod(ctx.outerType, name, () -> { + CodeExecutableElement m = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(int.class), name); + + m.addParameter(vars.stackFrame); + if (ctx.getData().enableYield) { + m.addParameter(vars.localFrame); + } + m.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); + m.addParameter(vars.bc); + m.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); + m.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); + m.addParameter(vars.consts); + m.addParameter(vars.children); + m.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "loopCounter")); + m.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + if (ctx.getData().isTracing()) { + m.addParameter(vars.tracer); + } + if (isUncached) { + m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "uncachedExecuteCount")); + } + + CodeTreeBuilder b = m.createBuilder(); + b.statement("int $bci = $startBci"); + b.statement("int $sp = $startSp"); + build.accept(b); + + return m; + }); + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startAssign("int _enc").startCall(name); + + b.variable(vars.stackFrame); + if (ctx.getData().enableYield) { + b.variable(vars.localFrame); + } + b.string("$this"); + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); + b.string("$conditionProfiles"); + b.string("loopCounter"); + b.string("$localTags"); + if (ctx.getData().isTracing()) { + b.variable(vars.tracer); + } + if (isUncached) { + b.string("uncachedExecuteCount"); + } + b.end(2); + + b.startAssign(vars.bci).string("_enc & 0xffff").end(); + b.startAssign(vars.sp).string("(_enc >> 16) & 0xffff").end(); + + return b.build(); + } + + public static CodeTree encodeExecuteReturn() { + return CodeTreeBuilder.createBuilder().startReturn().string("($sp << 16) | $bci").end().build(); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 56f58b1e62ec..e69d7b3e38b9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -46,6 +46,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.stream.Collectors; import javax.lang.model.element.ExecutableElement; @@ -244,8 +245,8 @@ static void populateVariables(ExecutionVariables vars, OperationsData m) { vars.bc = new CodeVariableElement(context.getType(short[].class), "$bc"); vars.sp = new CodeVariableElement(context.getType(int.class), "$sp"); vars.bci = new CodeVariableElement(context.getType(int.class), "$bci"); - vars.stackFrame = new CodeVariableElement(types.Frame, m.enableYield ? "$stackFrame" : "$frame"); - vars.localFrame = new CodeVariableElement(types.Frame, m.enableYield ? "$localFrame" : "$frame"); + vars.stackFrame = new CodeVariableElement(types.VirtualFrame, m.enableYield ? "$stackFrame" : "$frame"); + vars.localFrame = new CodeVariableElement(types.VirtualFrame, m.enableYield ? "$localFrame" : "$frame"); vars.consts = new CodeVariableElement(context.getType(Object[].class), "$consts"); vars.children = new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children"); } @@ -276,7 +277,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { if (isUncached) { // todo: better signaling to compiler that the method is not ready for compilation b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.declaration("int", "uncachedExecuteCount", "$this.uncachedExecuteCount"); + b.declaration("Counter", "uncachedExecuteCount", "new Counter()"); + b.statement("uncachedExecuteCount.count = $this.uncachedExecuteCount"); } CodeVariableElement varTracer; @@ -341,7 +343,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.lineComment(line); } - Runnable createBody = () -> { + Consumer createBody = (String name) -> { if (m.isTracing()) { b.startStatement().startCall(varTracer, "traceInstruction"); b.variable(vars.bci); @@ -351,16 +353,29 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.end(2); } - if (isUncached) { - b.tree(op.createExecuteUncachedCode(vars)); + Consumer createBodyInner = b2 -> { + if (isUncached) { + b2.tree(op.createExecuteUncachedCode(vars)); + } else { + b2.tree(op.createExecuteCode(vars)); + } + + }; + + if (op.neverWrapInMethod()) { + createBodyInner.accept(b); } else { - b.tree(op.createExecuteCode(vars)); - } + b.tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, "execute" + (isUncached ? "Uncached" : "") + "_" + op.internalName + name, isUncached, b2 -> { + createBodyInner.accept(b2); - if (!op.isBranchInstruction()) { - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); + if (!op.isBranchInstruction()) { + b2.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); + b2.tree(OperationGeneratorUtils.encodeExecuteReturn()); + } + })); b.statement("continue loop"); } + }; if (ctx.hasBoxingElimination() && !isUncached) { @@ -369,20 +384,20 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); b.startBlock(); vars.specializedKind = kind; - createBody.run(); + createBody.accept("_" + kind); vars.specializedKind = null; b.end(); } if (op.hasGeneric()) { b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); b.startBlock(); - createBody.run(); + createBody.accept("_GENERIC"); b.end(); } } else if (op.alwaysBoxed()) { b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); b.startBlock(); - createBody.run(); + createBody.accept(""); b.end(); } else { for (FrameKind kind : op.getBoxingEliminationSplits()) { @@ -391,7 +406,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startBlock(); b.declaration("short", "primitiveTag", "(short) ((curOpcode >> 13) & 0x0007)"); - createBody.run(); + createBody.accept(""); b.end(); } } else { @@ -404,11 +419,10 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { if (ctx.hasBoxingElimination()) { vars.specializedKind = FrameKind.OBJECT; } - createBody.run(); + createBody.accept(""); vars.specializedKind = null; b.end(); } - vars.inputs = null; vars.results = null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 43bb70eb92a4..6f9a0e85c695 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -47,6 +47,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @SuppressWarnings("unused") @@ -137,8 +138,8 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } if (uncached) { - b.statement("uncachedExecuteCount--"); - b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); + b.statement("uncachedExecuteCount.count--"); + b.startIf().string("uncachedExecuteCount.count <= 0").end().startBlock(); b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); b.statement("return ($sp << 16) | targetBci"); @@ -151,7 +152,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.startAssign(vars.bci).string("targetBci").end(); - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index fb8902da5ff8..719c0a8f63cc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -45,6 +45,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { @@ -83,10 +84,10 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2).startBlock(); b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); b.end().startElseBlock(); b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 7b7334da73e6..a687deb85a66 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -99,7 +99,7 @@ public static class EmitArguments { public final int id; public final int numPushedValues; - private final String internalName; + public final String internalName; // --------------------- arguments ------------------------ @@ -804,4 +804,8 @@ public List createInstructionFields() { public boolean isVariadic() { return isVariadic; } + + public boolean neverWrapInMethod() { + return false; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index 8bde84b38ec0..eceb4ffa4dba 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -66,11 +66,11 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); if (uncached) { - b.statement("uncachedExecuteCount--"); - b.startIf().string("uncachedExecuteCount <= 0").end().startBlock(); + b.statement("uncachedExecuteCount.count--"); + b.startIf().string("uncachedExecuteCount.count <= 0").end().startBlock(); b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); b.end().startElseBlock(); - b.statement("$this.uncachedExecuteCount = uncachedExecuteCount"); + b.statement("$this.uncachedExecuteCount = uncachedExecuteCount.count"); b.end(); } @@ -99,4 +99,9 @@ public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments argume public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } + + @Override + public boolean neverWrapInMethod() { + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 7c9e34aee997..2272f54be287 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -42,6 +42,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -79,13 +80,14 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { // { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.statement("continue loop"); + + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); // } b.end().startElseBlock(); // { b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); // } b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 17158f21fb61..fe78890c8a64 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -7,6 +7,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class SuperInstruction extends Instruction { @@ -75,7 +76,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } if (!instructions[instructions.length - 1].isBranchInstruction()) { - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); } return b.build(); @@ -93,7 +94,7 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { b.end(); } if (!instructions[instructions.length - 1].isBranchInstruction()) { - b.statement("continue loop"); + b.tree(OperationGeneratorUtils.encodeExecuteReturn()); } return b.build(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index dfa263a4b051..e96c75f8c84a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) From 27e30e61a0d816f07c7537b9e51f90ecdb927cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 25 Oct 2022 11:45:07 +0200 Subject: [PATCH 162/312] [wip] fix everything last addition broke --- .../processor/operations/OperationGeneratorUtils.java | 10 +++++++--- .../operations/OperationsBytecodeCodeGenerator.java | 5 +++-- .../operations/instructions/CustomInstruction.java | 10 ++++++++++ .../operations/instructions/YieldInstruction.java | 4 ++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 1271057dd704..b0edf20f6184 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -229,7 +229,7 @@ public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVar } - b.startSwitch().tree(createReadOpcode(vars.bc, vars.bci)).string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().startBlock(); + b.startSwitch().tree(OperationGeneratorUtils.extractInstruction(data.getOperationsContext(), createReadOpcode(vars.bc, vars.bci))).end().startBlock(); for (int i = 0; i < trees.size(); i++) { if (treeInstructions.get(i) == null) { b.caseDefault(); @@ -365,7 +365,9 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria m.addParameter(vars.children); m.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "loopCounter")); - m.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + if (ctx.hasBoxingElimination()) { + m.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + } if (ctx.getData().isTracing()) { m.addParameter(vars.tracer); } @@ -396,7 +398,9 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria b.variable(vars.children); b.string("$conditionProfiles"); b.string("loopCounter"); - b.string("$localTags"); + if (ctx.hasBoxingElimination()) { + b.string("$localTags"); + } if (ctx.getData().isTracing()) { b.variable(vars.tracer); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index e69d7b3e38b9..609742d299b3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -323,9 +323,10 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); b.startSwitch(); - b.string("curOpcode"); if (isUncached) { - b.string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS); + b.tree(OperationGeneratorUtils.extractInstruction(ctx, CodeTreeBuilder.singleString("curOpcode"))); + } else { + b.string("curOpcode"); } b.end(); b.startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 113ee5c93da2..23acc82f2b5e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -333,6 +333,9 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.end(); } + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); + b.statement("continue loop"); + return b.build(); } @@ -419,4 +422,11 @@ public List getQuickenedVariants() { public void setUncachedExecuteMethod(ExecutableElement uncachedExecuteMethod) { this.uncachedExecuteMethod = uncachedExecuteMethod; } + + @Override + public boolean neverWrapInMethod() { + // there is no need to wrap custom instructions in methods, since they already + // have their own entry-point methods + return true; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index eeabe2aa84fc..fd05269de14a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -73,4 +73,8 @@ public boolean alwaysBoxed() { return true; } + @Override + public boolean neverWrapInMethod() { + return true; + } } From ec85232f3ae69e422db829c623a87e2df9fb13eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 25 Oct 2022 11:49:31 +0200 Subject: [PATCH 163/312] [wip] more fixes --- .../operations/instructions/CustomInstruction.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 23acc82f2b5e..4c931023733d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -46,15 +46,12 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; @@ -62,7 +59,6 @@ import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; public class CustomInstruction extends Instruction { @@ -333,9 +329,6 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { b.end(); } - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.statement("continue loop"); - return b.build(); } @@ -422,11 +415,4 @@ public List getQuickenedVariants() { public void setUncachedExecuteMethod(ExecutableElement uncachedExecuteMethod) { this.uncachedExecuteMethod = uncachedExecuteMethod; } - - @Override - public boolean neverWrapInMethod() { - // there is no need to wrap custom instructions in methods, since they already - // have their own entry-point methods - return true; - } } From 891f299f611b2c45bb50f98d5e71a743e5e73662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 26 Oct 2022 12:31:27 +0200 Subject: [PATCH 164/312] [wip] superinstructions & common instructions --- .../api/operation/tracing/Decision.java | 89 +++++++++- .../tracing/OperationsStatistics.java | 159 +++++++++++++++--- .../operations/OperationDecisions.java | 44 +++++ .../OperationsBytecodeCodeGenerator.java | 17 +- .../operations/OperationsCodeGenerator.java | 30 +++- .../operations/OperationsContext.java | 13 +- .../operations/instructions/Instruction.java | 2 + 7 files changed, 323 insertions(+), 31 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java index 45dda97f20ab..de1d0d4a3774 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -22,8 +22,14 @@ private Decision(String type) { abstract String id(GlobalOperationStatistics stats); + protected abstract String prettyPrint(GlobalOperationStatistics stats); + + protected String createsInstruction(GlobalOperationStatistics stats) { + return null; + } + @SuppressWarnings("unused") - boolean acceptedBefore(Decision decision) { + boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { return false; } @@ -94,6 +100,17 @@ protected String prettyPrint(GlobalOperationStatistics stats) { return sb.toString(); } + + @Override + protected String createsInstruction(GlobalOperationStatistics stats) { + String s = stats.instrNames[instruction] + ".q"; + + for (int spec : specializations) { + s += "." + stats.specNames[instruction][spec]; + } + + return s; + } } static final class SuperInstruction extends Decision { @@ -117,7 +134,7 @@ String id(GlobalOperationStatistics stats) { } @Override - boolean acceptedBefore(Decision decision) { + boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { boolean changed = false; if (decision instanceof SuperInstruction) { SuperInstruction si = (SuperInstruction) decision; @@ -163,7 +180,73 @@ protected String prettyPrint(GlobalOperationStatistics stats) { return sb.toString(); } + + @Override + protected String createsInstruction(GlobalOperationStatistics stats) { + String s = "si"; + + for (int i = 0; i < instructions.length; i++) { + s += "." + stats.instrNames[instructions[i]]; + } + + return s; + } } - protected abstract String prettyPrint(GlobalOperationStatistics stats); + static final class CommonInstruction extends Decision { + + private final String instruction; + private final long numNodes; + + // the decision has any value only if its a regular instr + // or a decision-based one that has been accepted + private boolean doCount; + + CommonInstruction(String instruction, long numNodes, boolean regular) { + super("CommonInstruction"); + this.instruction = instruction; + this.numNodes = numNodes; + doCount = regular; + } + + @Override + double value() { + return doCount ? numNodes : 0; + } + + @Override + boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { + if (instruction.equals(decision.createsInstruction(stats))) { + doCount = true; + return true; + } else { + return false; + } + } + + @Override + JSONObject serialize(GlobalOperationStatistics stats) { + JSONObject result = super.serialize(stats); + result.put("instruction", instruction); + return result; + } + + @Override + String id(GlobalOperationStatistics stats) { + return "c:" + instruction; + } + + @Override + protected String prettyPrint(GlobalOperationStatistics stats) { + StringBuilder sb = new StringBuilder(); + + sb.append("Common ").append(id(stats)).append('\n'); + sb.append(" value: ").append(value()).append('\n'); + sb.append(" instruction: ").append(instruction).append('\n'); + sb.append(" nodes with instruction: ").append(numNodes).append('\n'); + + return sb.toString(); + } + + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 3e909aa3263d..bfbffe69ae98 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -187,7 +187,8 @@ private EnabledExecutionTracer collect() { } private JSONObject serialize() { - JSONObject result = collect().serialize(); + setNames(); + JSONObject result = collect().serialize(this); result.put("key", opsClass.getName()); return result; } @@ -200,6 +201,10 @@ private void setNames() { this.decisionsFile = ExecutionTracer.DECISIONS_FILE_MAP.get(opsClass); this.instrNames = ExecutionTracer.INSTR_NAMES_MAP.get(opsClass); this.specNames = ExecutionTracer.SPECIALIZATION_NAMES_MAP.get(opsClass); + + if (decisionsFile == null || instrNames == null || specNames == null) { + throw new AssertionError(); + } } public EnabledExecutionTracer getTracer() { @@ -250,7 +255,75 @@ public void traceStartBasicBlock(int bci) { private static class EnabledExecutionTracer extends ExecutionTracer { - private static class SpecializationKey { + private interface PseudoInstruction { + String name(GlobalOperationStatistics stats); + + default boolean isRegular() { + return false; + } + + public static PseudoInstruction parse(String s) { + return new Key(s.substring(1), s.charAt(0) == 'R'); + } + + default String serialize(GlobalOperationStatistics stats) { + return (isRegular() ? 'R' : 'g') + name(stats); + } + + public static class Key implements PseudoInstruction { + private final String name; + private final boolean regular; + + Key(String name, boolean regular) { + this.name = name; + this.regular = regular; + } + + public String name(GlobalOperationStatistics stats) { + return name; + } + + public boolean isRegular() { + return regular; + } + } + } + + private static class RegularInstruction implements PseudoInstruction { + private final int instruction; + + RegularInstruction(int instruction) { + this.instruction = instruction; + } + + @Override + public int hashCode() { + return instruction; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + RegularInstruction other = (RegularInstruction) obj; + return instruction == other.instruction; + } + + public String name(GlobalOperationStatistics stats) { + return stats.instrNames[instruction]; + } + + public boolean isRegular() { + return true; + } + + } + + private static class SpecializationKey implements PseudoInstruction { final int instructionId; @CompilationFinal(dimensions = 1) final boolean[] activeSpecializations; int countActive = -1; @@ -343,9 +416,21 @@ private static SpecializationKey deserialize(JSONObject obj) { public String toString() { return "SpecializationKey [" + instructionId + ", " + Arrays.toString(activeSpecializations) + "]"; } + + public String name(GlobalOperationStatistics stats) { + String s = stats.instrNames[instructionId] + ".q"; + + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + s += "." + stats.specNames[instructionId][i]; + } + } + + return s; + } } - private static class InstructionSequenceKey { + private static class InstructionSequenceKey implements PseudoInstruction { final int[] instructions; InstructionSequenceKey(int[] instructions) { @@ -379,12 +464,27 @@ public static InstructionSequenceKey fromKey(String key) { public Object toString(String[] instrNames) { return String.join(",", Arrays.stream(instructions).mapToObj(x -> instrNames[x]).toArray(String[]::new)); } + + public String name(GlobalOperationStatistics stats) { + String s = "si"; + + for (int i = 0; i < instructions.length; i++) { + s += "." + stats.instrNames[instructions[i]]; + } + + return s; + } } + // quickening private Map activeSpecializationsMap = new HashMap<>(); + + // superinstructions private Map instructionSequencesMap = new HashMap<>(); - private Map numNodesWithInstruction = new HashMap<>(); - private Map> nodesWithInstruction = new HashMap<>(); + + // common / uncommon + private Map numNodesWithInstruction = new HashMap<>(); + private Map> nodesWithInstruction = new HashMap<>(); private List nodeStack = new ArrayList<>(); private Node curNode; @@ -431,9 +531,13 @@ public void endFunction(Node node) { } } + private void encounterPseudoInstruction(PseudoInstruction instr) { + nodesWithInstruction.computeIfAbsent(instr, k -> new HashSet<>()).add(curNode); + } + @Override public void traceInstruction(int bci, int id, int... arguments) { - nodesWithInstruction.computeIfAbsent(id, k -> new HashSet<>()).add(curNode); + encounterPseudoInstruction(new RegularInstruction(id)); boolean isBranch = arguments[0] != 0; boolean isVariadic = arguments[1] != 0; @@ -454,6 +558,7 @@ public void traceInstruction(int bci, int id, int... arguments) { int[] curHistory = Arrays.copyOfRange(instrHistory, i, instrHistoryLen); InstructionSequenceKey key = new InstructionSequenceKey(curHistory); instructionSequencesMap.merge(key, 1L, EnabledExecutionTracer::saturatingAdd); + encounterPseudoInstruction(key); } } @@ -463,7 +568,7 @@ private static long saturatingAdd(long x, long y) { try { return Math.addExact(x, y); } catch (ArithmeticException e) { - return x; + return Long.MAX_VALUE; } } @@ -471,7 +576,7 @@ private static int saturatingAdd(int x, int y) { try { return Math.addExact(x, y); } catch (ArithmeticException e) { - return x; + return Integer.MAX_VALUE; } } @@ -479,6 +584,7 @@ private static int saturatingAdd(int x, int y) { public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { SpecializationKey key = new SpecializationKey(id, activeSpecializations); Long l = activeSpecializationsMap.get(key); + encounterPseudoInstruction(key); if (l == null) { activeSpecializationsMap.put(key, 1L); } else if (l != Long.MAX_VALUE) { @@ -519,14 +625,15 @@ private void merge(EnabledExecutionTracer other) { }); } - private void calcNumNodesWithInstruction() { + private void calcNumNodesWithInstruction(GlobalOperationStatistics stats) { nodesWithInstruction.forEach((k, v) -> { - numNodesWithInstruction.put(k, v.size() + numNodesWithInstruction.getOrDefault(k, 0)); + long totalCount = v.size(); + numNodesWithInstruction.merge(k, totalCount, EnabledExecutionTracer::saturatingAdd); }); nodesWithInstruction.clear(); } - private JSONObject serialize() { + private JSONObject serialize(GlobalOperationStatistics stats) { JSONObject result = new JSONObject(); JSONArray activeSpecializationsData = new JSONArray(); @@ -538,9 +645,9 @@ private JSONObject serialize() { result.put("as", activeSpecializationsData); JSONObject ni = new JSONObject(); - calcNumNodesWithInstruction(); + calcNumNodesWithInstruction(stats); numNodesWithInstruction.forEach((k, v) -> { - ni.put(k.toString(), v); + ni.put(k.serialize(stats), v); }); result.put("ni", ni); @@ -566,7 +673,7 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { JSONObject ni = obj.getJSONObject("ni"); for (String key : ni.keySet()) { - inst.numNodesWithInstruction.put(Integer.parseInt(key), ni.getInt(key)); + inst.numNodesWithInstruction.put(PseudoInstruction.parse(key), ni.getLong(key)); } JSONObject instructionSequences = obj.getJSONObject("is"); @@ -577,7 +684,7 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { return inst; } - private static void orderDecisions(List output, List input, int expectedCount) { + private static void orderDecisions(List output, List input, int expectedCount, GlobalOperationStatistics stats) { int outputCount = input.size() < expectedCount ? input.size() : expectedCount; for (int i = 0; i < outputCount; i++) { @@ -585,7 +692,7 @@ private static void orderDecisions(List output, List input, output.add(next); for (int j = i + 1; j < input.size(); j++) { - input.get(j).acceptedBefore(next); + input.get(j).acceptedBefore(next, stats); } input.subList(i, input.size()).sort(Decision.COMPARATOR); } @@ -599,8 +706,8 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dum result.put("Do not modify, as it will be overwritten when running with tracing support."); result.put("Use the overrides file to alter the optimisation decisions."); - // create decisions - calcNumNodesWithInstruction(); + calcNumNodesWithInstruction(stats); + List decisions = new ArrayList<>(); activeSpecializationsMap.entrySet().forEach(e -> { decisions.add(new Decision.Quicken(e.getKey().instructionId, e.getKey().specializationIds(), e.getValue())); @@ -612,7 +719,21 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dum // sort decisions.sort(Decision.COMPARATOR); List acceptedDecisions = new ArrayList<>(); - orderDecisions(acceptedDecisions, decisions, NUM_DECISIONS); + orderDecisions(acceptedDecisions, decisions, NUM_DECISIONS, stats); + + // the common / uncommon instructions don't compete with other decisions, + // so we add them at the end + numNodesWithInstruction.entrySet().stream()// + .map(e -> { + Decision d = new Decision.CommonInstruction(e.getKey().name(stats), e.getValue(), e.getKey().isRegular()); + for (Decision pre : acceptedDecisions) { + d.acceptedBefore(pre, stats); + } + return d; + })// + .sorted(Decision.COMPARATOR)// + .limit(100)// + .forEach(acceptedDecisions::add); if (dumpInfo) { System.err.println("======================== OPERATION DSL TRACING DECISIONS ======================== "); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 59b3e39ed13c..533e1abbfb05 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -52,6 +52,7 @@ public class OperationDecisions { private final List quicken = new ArrayList<>(); private final List superInstr = new ArrayList<>(); + private final List commonInstr = new ArrayList<>(); public OperationDecisions() { } @@ -64,6 +65,10 @@ public List getSuperInstructions() { return superInstr; } + public List getCommonInstructions() { + return commonInstr; + } + public OperationDecisions merge(OperationDecisions other, MessageContainer messager) { for (Quicken q : other.quicken) { if (quicken.contains(q)) { @@ -186,6 +191,41 @@ public static SuperInstruction deserialize(JSONObject o) { } } + public static final class CommonInstruction { + final String instruction; + + @Override + public int hashCode() { + return Objects.hash(instruction); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CommonInstruction other = (CommonInstruction) obj; + return Objects.equals(instruction, other.instruction); + } + + private CommonInstruction(String instruction) { + this.instruction = instruction; + } + + @Override + public String toString() { + return "CommonInstruction [" + instruction + "]"; + } + + public static CommonInstruction deserialize(JSONObject o) { + String instruction = o.getString("instruction"); + return new CommonInstruction(instruction); + } + } + public static OperationDecisions deserialize(JSONArray o, MessageContainer messager) { OperationDecisions decisions = new OperationDecisions(); @@ -206,6 +246,10 @@ public static OperationDecisions deserialize(JSONArray o, MessageContainer messa SuperInstruction si = SuperInstruction.deserialize(decision); decisions.superInstr.add(si); break; + case "CommonInstruction": + CommonInstruction ci = CommonInstruction.deserialize(decision); + decisions.commonInstr.add(ci); + break; default: messager.addWarning("Invalid optimization decision: '%s'", decision.getString("type")); break; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 609742d299b3..3653bd7294b2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -102,9 +102,10 @@ public class OperationsBytecodeCodeGenerator { private final CodeTypeElement baseClass; private final CodeTypeElement opNodeImpl; private final CodeTypeElement typExceptionHandler; + private final boolean isCommonOnly; public OperationsBytecodeCodeGenerator(CodeTypeElement typEnclosingElement, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, - boolean withInstrumentation, boolean isUncached) { + boolean withInstrumentation, boolean isUncached, boolean isCommonOnly) { this.typEnclosingElement = typEnclosingElement; this.baseClass = baseClass; this.opNodeImpl = opNodeImpl; @@ -112,6 +113,7 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typEnclosingElement, Code this.m = m; this.withInstrumentation = withInstrumentation; this.isUncached = isUncached; + this.isCommonOnly = isCommonOnly; } /** @@ -119,7 +121,7 @@ public OperationsBytecodeCodeGenerator(CodeTypeElement typEnclosingElement, Code * executable Truffle node. */ public CodeTypeElement createBuilderBytecodeNode() { - String namePrefix = withInstrumentation ? "Instrumentable" : isUncached ? "Uncached" : ""; + String namePrefix = withInstrumentation ? "Instrumentable" : isUncached ? "Uncached" : isCommonOnly ? "Common" : ""; CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", baseClass.asType()); @@ -340,6 +342,10 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { continue; } + if (!op.isCommon && isCommonOnly) { + continue; + } + for (String line : op.dumpInfo().split("\n")) { b.lineComment(line); } @@ -430,7 +436,12 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.caseDefault().startCaseBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); + if (isCommonOnly) { + b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); + b.startReturn().string("($sp << 16) | $bci").end(); + } else { + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); + } b.end(); b.end(); // switch block diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 01b41ed48d1e..d2efcdc63b37 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -427,12 +427,23 @@ CodeTypeElement createOperationNodeImpl() { } } + String initialExecute = "UNCOMMON_EXECUTE"; + + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCOMMON_EXECUTE = new BytecodeNode()")); + + if (m.getDecisionsFilePath() != null) { + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new CommonBytecodeNode()")); + initialExecute = "COMMON_EXECUTE"; + } else { + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = UNCOMMON_EXECUTE")); + } + if (m.isGenerateUncached()) { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCACHED_EXECUTE = new UncachedBytecodeNode()")); + initialExecute = "UNCACHED_EXECUTE"; } - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new BytecodeNode()")); - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = " + (m.isGenerateUncached() ? "UNCACHED_EXECUTE" : "COMMON_EXECUTE"))); + typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = " + initialExecute)); typOperationNodeImpl.add(createNodeImplExecuteAt()); typOperationNodeImpl.add(createNodeImplGetSourceSection()); @@ -476,23 +487,32 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(typOpNodesImpl); CodeTypeElement builderBytecodeNodeType; + CodeTypeElement builderCommonBytecodeNodeType; CodeTypeElement builderUncachedBytecodeNodeType; CodeTypeElement builderInstrBytecodeNodeType; - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false); + bytecodeGenerator = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, false); builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); typOperationNodeImpl.add(builderBytecodeNodeType); if (m.isGenerateUncached()) { builderUncachedBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, - true).createBuilderBytecodeNode(); + true, false).createBuilderBytecodeNode(); typOperationNodeImpl.add(builderUncachedBytecodeNodeType); } else { builderUncachedBytecodeNodeType = null; } + if (m.getDecisionsFilePath() != null) { + builderCommonBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, + true).createBuilderBytecodeNode(); + typOperationNodeImpl.add(builderCommonBytecodeNodeType); + } else { + builderCommonBytecodeNodeType = null; + } + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, true, false); + OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, true, false, false); builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); typOperationNodeImpl.add(builderInstrBytecodeNodeType); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java index f507ee773bba..c01b2378c64e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java @@ -256,10 +256,21 @@ public void processDecisions(OperationDecisions decisions) { add(new SuperInstruction(this, instructionId++, instrs)); } + + for (OperationDecisions.CommonInstruction ci : decisions.getCommonInstructions()) { + Instruction instr = instructionNameMap.get(ci.instruction); + + if (instr == null) { + data.addWarning("Invalid CommonInstruction decision: undefined instruction %s. Rerun the corpus with tracing to regenerate decisions.", ci.instruction); + continue; + } + + instr.isCommon = true; + } } public List getSuperInstructions() { - return instructions.stream().filter(x -> x instanceof SuperInstruction).map(x -> (SuperInstruction) x).toList(); + return instructions.stream().filter(x -> x instanceof SuperInstruction).map(x -> (SuperInstruction) x).collect(Collectors.toList()); } public boolean hasBoxingElimination() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index a687deb85a66..69779fe82c65 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -117,6 +117,8 @@ public static class EmitArguments { private List stateBits = new ArrayList<>(); private List instruments = new ArrayList<>(); + public boolean isCommon; + private static final String CONSTANT_OFFSET_SUFFIX = "_CONSTANT_OFFSET"; private static final String CHILDREN_OFFSET_SUFFIX = "_CHILDREN_OFFSET"; private static final String LOCALS_OFFSET_SUFFIX = "_LOCALS_OFFSET"; From 48964c7513fb8fe1cbaf282024624e2730162e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 27 Oct 2022 09:09:35 +0200 Subject: [PATCH 165/312] [wip] decisions decisions --- .../api/operation/tracing/Decision.java | 8 +- .../tracing/OperationsStatistics.java | 144 ++--- .../operations/OperationGeneratorUtils.java | 2 +- .../OperationsBytecodeCodeGenerator.java | 1 + .../operations/OperationsCodeGenerator.java | 4 +- .../processor/operations/OperationsData.java | 4 + .../truffle/sl/operations/decisions.json | 550 +++++++++++++++--- 7 files changed, 542 insertions(+), 171 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java index de1d0d4a3774..f5290e3fdf0e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -2,6 +2,7 @@ import java.util.Arrays; import java.util.Comparator; +import java.util.List; import java.util.stream.Collectors; import com.oracle.truffle.api.operation.tracing.OperationsStatistics.GlobalOperationStatistics; @@ -105,8 +106,11 @@ protected String prettyPrint(GlobalOperationStatistics stats) { protected String createsInstruction(GlobalOperationStatistics stats) { String s = stats.instrNames[instruction] + ".q"; - for (int spec : specializations) { - s += "." + stats.specNames[instruction][spec]; + List specs = Arrays.stream(specializations).mapToObj(x -> stats.specNames[instruction][x]).collect(Collectors.toList()); + specs.sort(null); + + for (String spec : specs) { + s += "." + spec; } return s; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index bfbffe69ae98..4e2008f3b2b8 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -158,6 +158,7 @@ static final class GlobalOperationStatistics { GlobalOperationStatistics(Class opsClass) { this.opsClass = opsClass; + setNames(); } public void writeDecisions(boolean dumpInfo) throws IOException { @@ -173,12 +174,12 @@ public void writeDecisions(boolean dumpInfo) throws IOException { private static GlobalOperationStatistics deserialize(OperationsStatistics parent, JSONObject data) throws ClassNotFoundException { Class key = Class.forName(data.getString("key")); GlobalOperationStatistics result = parent.getStatsistics(key); - result.allTracers.add(EnabledExecutionTracer.deserialize(data)); + result.allTracers.add(EnabledExecutionTracer.deserialize(result, data)); return result; } private EnabledExecutionTracer collect() { - EnabledExecutionTracer tracer = new EnabledExecutionTracer(); + EnabledExecutionTracer tracer = new EnabledExecutionTracer(this); for (EnabledExecutionTracer other : allTracers) { tracer.merge(other); } @@ -217,7 +218,7 @@ public EnabledExecutionTracer getTracer() { private EnabledExecutionTracer createTracer() { assert currentTracer.get() == null; - EnabledExecutionTracer tracer = new EnabledExecutionTracer(); + EnabledExecutionTracer tracer = new EnabledExecutionTracer(this); currentTracer.set(tracer); allTracers.add(tracer); return tracer; @@ -255,80 +256,61 @@ public void traceStartBasicBlock(int bci) { private static class EnabledExecutionTracer extends ExecutionTracer { - private interface PseudoInstruction { - String name(GlobalOperationStatistics stats); + private final GlobalOperationStatistics stats; - default boolean isRegular() { - return false; - } + private static class PseudoInstruction { + private String name; + private boolean isRegular; - public static PseudoInstruction parse(String s) { - return new Key(s.substring(1), s.charAt(0) == 'R'); + public PseudoInstruction(String name, boolean isRegular) { + this.name = name; + this.isRegular = isRegular; } - default String serialize(GlobalOperationStatistics stats) { - return (isRegular() ? 'R' : 'g') + name(stats); + String name(GlobalOperationStatistics stats) { + return this.name; } - public static class Key implements PseudoInstruction { - private final String name; - private final boolean regular; - - Key(String name, boolean regular) { - this.name = name; - this.regular = regular; - } - - public String name(GlobalOperationStatistics stats) { - return name; - } - - public boolean isRegular() { - return regular; - } + boolean isRegular() { + return isRegular; } - } - private static class RegularInstruction implements PseudoInstruction { - private final int instruction; + public static PseudoInstruction parse(String s) { + return new PseudoInstruction(s.substring(1), s.charAt(0) == 'R'); + } - RegularInstruction(int instruction) { - this.instruction = instruction; + String serialize(GlobalOperationStatistics stats) { + return (isRegular() ? 'R' : 'g') + name(stats); } @Override public int hashCode() { - return instruction; + return name.hashCode(); } @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RegularInstruction other = (RegularInstruction) obj; - return instruction == other.instruction; + return obj instanceof PseudoInstruction && ((PseudoInstruction) obj).name.equals(name); } - public String name(GlobalOperationStatistics stats) { - return stats.instrNames[instruction]; - } + } - public boolean isRegular() { - return true; - } + private static class RegularInstruction extends PseudoInstruction { + private final int instruction; + RegularInstruction(GlobalOperationStatistics stats, int instruction) { + super(stats.instrNames[instruction], true); + this.instruction = instruction; + } } - private static class SpecializationKey implements PseudoInstruction { + private static class SpecializationKey extends PseudoInstruction { final int instructionId; @CompilationFinal(dimensions = 1) final boolean[] activeSpecializations; int countActive = -1; - SpecializationKey(int instructionId, boolean[] activeSpecializations) { + SpecializationKey(GlobalOperationStatistics stats, int instructionId, boolean[] activeSpecializations) { + super(makeName(stats, instructionId, activeSpecializations), false); this.instructionId = instructionId; this.activeSpecializations = activeSpecializations; } @@ -400,7 +382,7 @@ private JSONObject serialize() { return result; } - private static SpecializationKey deserialize(JSONObject obj) { + private static SpecializationKey deserialize(GlobalOperationStatistics stats, JSONObject obj) { int id = obj.getInt("i"); int count = obj.getInt("n"); boolean[] activeSpecializations = new boolean[count]; @@ -409,7 +391,7 @@ private static SpecializationKey deserialize(JSONObject obj) { activeSpecializations[activeSpecsData.getInt(i)] = true; } - return new SpecializationKey(id, activeSpecializations); + return new SpecializationKey(stats, id, activeSpecializations); } @Override @@ -417,7 +399,7 @@ public String toString() { return "SpecializationKey [" + instructionId + ", " + Arrays.toString(activeSpecializations) + "]"; } - public String name(GlobalOperationStatistics stats) { + private static String makeName(GlobalOperationStatistics stats, int instructionId, boolean[] activeSpecializations) { String s = stats.instrNames[instructionId] + ".q"; for (int i = 0; i < activeSpecializations.length; i++) { @@ -430,10 +412,11 @@ public String name(GlobalOperationStatistics stats) { } } - private static class InstructionSequenceKey implements PseudoInstruction { + private static class InstructionSequenceKey extends PseudoInstruction { final int[] instructions; - InstructionSequenceKey(int[] instructions) { + InstructionSequenceKey(GlobalOperationStatistics stats, int[] instructions) { + super(makeName(stats, instructions), false); this.instructions = instructions; } @@ -456,16 +439,16 @@ public String toKey() { return String.join(",", Arrays.stream(instructions).mapToObj(Integer::toString).toArray(String[]::new)); } - public static InstructionSequenceKey fromKey(String key) { + public static InstructionSequenceKey fromKey(GlobalOperationStatistics stats, String key) { int[] instructions = Arrays.stream(key.split(",")).mapToInt(Integer::parseInt).toArray(); - return new InstructionSequenceKey(instructions); + return new InstructionSequenceKey(stats, instructions); } public Object toString(String[] instrNames) { return String.join(",", Arrays.stream(instructions).mapToObj(x -> instrNames[x]).toArray(String[]::new)); } - public String name(GlobalOperationStatistics stats) { + static String makeName(GlobalOperationStatistics stats, int[] instructions) { String s = "si"; for (int i = 0; i < instructions.length; i++) { @@ -485,6 +468,7 @@ public String name(GlobalOperationStatistics stats) { // common / uncommon private Map numNodesWithInstruction = new HashMap<>(); private Map> nodesWithInstruction = new HashMap<>(); + private Map hitCount = new HashMap<>(); private List nodeStack = new ArrayList<>(); private Node curNode; @@ -495,6 +479,10 @@ public String name(GlobalOperationStatistics stats) { private int[] instrHistory = null; private int instrHistoryLen = 0; + public EnabledExecutionTracer(GlobalOperationStatistics stats) { + this.stats = stats; + } + @Override public void startFunction(Node node) { if (curNode != null) { @@ -537,7 +525,9 @@ private void encounterPseudoInstruction(PseudoInstruction instr) { @Override public void traceInstruction(int bci, int id, int... arguments) { - encounterPseudoInstruction(new RegularInstruction(id)); + hitCount.merge(curNode, 1L, EnabledExecutionTracer::saturatingAdd); + + encounterPseudoInstruction(new RegularInstruction(stats, id)); boolean isBranch = arguments[0] != 0; boolean isVariadic = arguments[1] != 0; @@ -556,7 +546,7 @@ public void traceInstruction(int bci, int id, int... arguments) { for (int i = 0; i < instrHistoryLen - 1; i++) { int[] curHistory = Arrays.copyOfRange(instrHistory, i, instrHistoryLen); - InstructionSequenceKey key = new InstructionSequenceKey(curHistory); + InstructionSequenceKey key = new InstructionSequenceKey(stats, curHistory); instructionSequencesMap.merge(key, 1L, EnabledExecutionTracer::saturatingAdd); encounterPseudoInstruction(key); } @@ -582,7 +572,19 @@ private static int saturatingAdd(int x, int y) { @Override public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { - SpecializationKey key = new SpecializationKey(id, activeSpecializations); + boolean anyActive = false; + for (int i = 0; i < activeSpecializations.length; i++) { + if (activeSpecializations[i]) { + anyActive = true; + break; + } + } + + if (!anyActive) { + return; + } + + SpecializationKey key = new SpecializationKey(stats, id, activeSpecializations); Long l = activeSpecializationsMap.get(key); encounterPseudoInstruction(key); if (l == null) { @@ -619,15 +621,18 @@ private void merge(EnabledExecutionTracer other) { other.numNodesWithInstruction.forEach((k, v) -> { numNodesWithInstruction.merge(k, v, EnabledExecutionTracer::saturatingAdd); }); - other.instructionSequencesMap.forEach((k, v) -> { instructionSequencesMap.merge(k, v, EnabledExecutionTracer::saturatingAdd); }); + other.hitCount.forEach((k, v) -> { + hitCount.merge(k, v, EnabledExecutionTracer::saturatingAdd); + }); } private void calcNumNodesWithInstruction(GlobalOperationStatistics stats) { + System.err.println("Hit count = " + hitCount); nodesWithInstruction.forEach((k, v) -> { - long totalCount = v.size(); + long totalCount = v.stream().map(hitCount::get).filter(x -> x != null).reduce(0L, EnabledExecutionTracer::saturatingAdd); numNodesWithInstruction.merge(k, totalCount, EnabledExecutionTracer::saturatingAdd); }); nodesWithInstruction.clear(); @@ -660,14 +665,14 @@ private JSONObject serialize(GlobalOperationStatistics stats) { return result; } - private static EnabledExecutionTracer deserialize(JSONObject obj) { - EnabledExecutionTracer inst = new EnabledExecutionTracer(); + private static EnabledExecutionTracer deserialize(GlobalOperationStatistics stats, JSONObject obj) { + EnabledExecutionTracer inst = new EnabledExecutionTracer(stats); JSONArray activeSpecializationsData = obj.getJSONArray("as"); for (int i = 0; i < activeSpecializationsData.length(); i++) { JSONObject activeSpecData = activeSpecializationsData.getJSONObject(i); long count = activeSpecData.getLong("c"); - SpecializationKey key = SpecializationKey.deserialize(activeSpecData); + SpecializationKey key = SpecializationKey.deserialize(stats, activeSpecData); inst.activeSpecializationsMap.put(key, count); } @@ -678,7 +683,7 @@ private static EnabledExecutionTracer deserialize(JSONObject obj) { JSONObject instructionSequences = obj.getJSONObject("is"); for (String key : instructionSequences.keySet()) { - inst.instructionSequencesMap.put(InstructionSequenceKey.fromKey(key), instructionSequences.getLong(key)); + inst.instructionSequencesMap.put(InstructionSequenceKey.fromKey(stats, key), instructionSequences.getLong(key)); } return inst; @@ -731,8 +736,9 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dum } return d; })// - .sorted(Decision.COMPARATOR)// - .limit(100)// + .filter(x -> x.value() > 0) // + .sorted(Decision.COMPARATOR) // + .limit(64)// .forEach(acceptedDecisions::add); if (dumpInfo) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index b0edf20f6184..bb517c8f141c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -330,7 +330,7 @@ public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction inst public static CodeTree extractInstruction(OperationsContext ctx, CodeTree instr) { if (ctx.hasBoxingElimination()) { return CodeTreeBuilder.createBuilder().startParantheses().tree(instr).string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().string( - " & " + (1 << (16 - OperationGeneratorFlags.BOXING_ELIM_BITS) - 1)).build(); + " & " + ((1 << (16 - OperationGeneratorFlags.BOXING_ELIM_BITS)) - 1)).build(); } else { return instr; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 3653bd7294b2..0f9ce865b282 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -437,6 +437,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.caseDefault().startCaseBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); if (isCommonOnly) { + b.statement("System.err.println(\" hit \" + curOpcode + \" @ \" + $bci)"); b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); b.startReturn().string("($sp << 16) | $bci").end(); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index d2efcdc63b37..718111c13292 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -431,7 +431,7 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCOMMON_EXECUTE = new BytecodeNode()")); - if (m.getDecisionsFilePath() != null) { + if (m.isOptimized()) { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new CommonBytecodeNode()")); initialExecute = "COMMON_EXECUTE"; } else { @@ -503,7 +503,7 @@ CodeTypeElement createOperationNodeImpl() { builderUncachedBytecodeNodeType = null; } - if (m.getDecisionsFilePath() != null) { + if (m.isOptimized()) { builderCommonBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, true).createBuilderBytecodeNode(); typOperationNodeImpl.add(builderCommonBytecodeNodeType); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java index 28f5b3b878e4..d3d08d2971f0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java @@ -209,4 +209,8 @@ public List getFrameKinds() { return kinds; } + public boolean isOptimized() { + return !isTracing() && getDecisionsFilePath() != null; + } + } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index d8856d90b371..06d77600b0b3 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -3,19 +3,9 @@ "Do not modify, as it will be overwritten when running with tracing support.", "Use the overrides file to alter the optimisation decisions.", { - "specializations": ["FromBigNumber"], - "_comment": "value: 1.482583E7", - "id": "quicken:c.SLUnbox:FromBigNumber", - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "FromLong", - "FromBigNumber" - ], - "_comment": "value: 8795576.0", - "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", + "specializations": ["FromLong"], + "_comment": "value: 7214274.0", + "id": "quicken:c.SLUnbox:FromLong", "type": "Quicken", "operation": "SLUnbox" }, @@ -24,7 +14,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 7932511.0", + "_comment": "value: 3831023.0", "id": "si:load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -37,31 +27,10 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 6416860.0", + "_comment": "value: 3205835.0", "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, - { - "instructions": [ - "store.local", - "load.local", - "c.SLUnbox" - ], - "_comment": "value: 6010640.0", - "id": "si:store.local,load.local,c.SLUnbox", - "type": "SuperInstruction" - }, - { - "instructions": [ - "load.local", - "load.constant", - "c.SLReadProperty", - "c.SLUnbox" - ], - "_comment": "value: 6004146.0", - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", - "type": "SuperInstruction" - }, { "instructions": [ "load.argument", @@ -73,7 +42,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 5902799.0", + "_comment": "value: 2947763.0", "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -88,7 +57,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 5902666.0", + "_comment": "value: 2947700.0", "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -103,23 +72,38 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 5902666.0", + "_comment": "value: 2947700.0", "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, + { + "specializations": ["FromBigNumber"], + "_comment": "value: 2827220.0", + "id": "quicken:c.SLUnbox:FromBigNumber", + "type": "Quicken", + "operation": "SLUnbox" + }, { "instructions": [ - "load.local", - "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 5002950.0", - "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "_comment": "value: 2646525.0", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, + { + "specializations": [ + "FromLong", + "FromBigNumber" + ], + "_comment": "value: 2459249.0", + "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", + "type": "Quicken", + "operation": "SLUnbox" + }, { "instructions": [ "c.SLUnbox", @@ -128,16 +112,22 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 4997956.0", + "_comment": "value: 2400444.0", "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, { - "specializations": ["FromLong"], - "_comment": "value: 4756490.0", - "id": "quicken:c.SLUnbox:FromLong", - "type": "Quicken", - "operation": "SLUnbox" + "instructions": [ + "load.local", + "load.constant", + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox" + ], + "_comment": "value: 2205210.0", + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "type": "SuperInstruction" }, { "instructions": [ @@ -147,7 +137,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 4451184.0", + "_comment": "value: 2020896.0", "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -160,7 +150,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 4000780.0", + "_comment": "value: 2000370.0", "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -175,7 +165,7 @@ "load.constant", "c.SLUnbox" ], - "_comment": "value: 3649065.0", + "_comment": "value: 1617147.0", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", "type": "SuperInstruction" }, @@ -190,7 +180,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 3649065.0", + "_comment": "value: 1617147.0", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -205,32 +195,10 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 3649065.0", + "_comment": "value: 1617147.0", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, - { - "specializations": ["FromBoolean"], - "_comment": "value: 3404438.0", - "id": "quicken:c.SLUnbox:FromBoolean", - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "instructions": [ - "c.SLReadProperty", - "c.SLUnbox", - "load.local", - "load.constant", - "c.SLReadProperty", - "c.SLUnbox", - "c.SLAdd", - "c.SLUnbox" - ], - "_comment": "value: 3355072.0", - "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", - "type": "SuperInstruction" - }, { "instructions": [ "load.local", @@ -242,7 +210,7 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 3355065.0", + "_comment": "value: 1470147.0", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, @@ -257,7 +225,7 @@ "load.constant", "c.SLReadProperty" ], - "_comment": "value: 3355065.0", + "_comment": "value: 1470147.0", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", "type": "SuperInstruction" }, @@ -272,7 +240,7 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 3355065.0", + "_comment": "value: 1470147.0", "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, @@ -287,7 +255,7 @@ "load.local", "load.constant" ], - "_comment": "value: 3355065.0", + "_comment": "value: 1470147.0", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant", "type": "SuperInstruction" }, @@ -302,32 +270,25 @@ "c.SLUnbox", "load.constant" ], - "_comment": "value: 3355065.0", + "_comment": "value: 1470147.0", "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant", "type": "SuperInstruction" }, { "instructions": [ + "c.SLReadProperty", + "c.SLUnbox", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", - "load.local.boxed", - "c.SLUnbox", - "c.SLLessOrEqual", + "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 3145338.0", - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "_comment": "value: 1470147.0", + "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, - { - "specializations": ["Add0"], - "_comment": "value: 3056151.0", - "id": "quicken:c.SLAdd:Add0", - "type": "Quicken", - "operation": "SLAdd" - }, { "instructions": [ "load.constant", @@ -335,10 +296,32 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 3024984.0", + "_comment": "value: 1449447.0", "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, + { + "specializations": ["FromBoolean"], + "_comment": "value: 1440534.0", + "id": "quicken:c.SLUnbox:FromBoolean", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "instructions": [ + "load.local", + "load.constant", + "c.SLReadProperty", + "c.SLUnbox", + "load.local.boxed", + "c.SLUnbox", + "c.SLLessOrEqual", + "c.SLUnbox" + ], + "_comment": "value: 1400259.0", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "type": "SuperInstruction" + }, { "instructions": [ "pop", @@ -349,24 +332,397 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 2763516.0", + "_comment": "value: 1381476.0", "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["ReadSLObject0"], - "_comment": "value: 2127101.0", + "_comment": "value: 880189.0", "id": "quicken:c.SLReadProperty:ReadSLObject0", "type": "Quicken", "operation": "SLReadProperty" }, + { + "specializations": ["AddLong"], + "_comment": "value: 880097.0", + "id": "quicken:c.SLAdd:AddLong", + "type": "Quicken", + "operation": "SLAdd" + }, + { + "instructions": [ + "pop", + "load.constant", + "c.SLFunctionLiteral", + "load.local", + "c.SLUnbox" + ], + "_comment": "value: 840152.0", + "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", + "type": "SuperInstruction" + }, { "instructions": [ "c.SLToBoolean", "branch.false" ], - "_comment": "value: 1703078.0", + "_comment": "value: 779349.0", "id": "si:c.SLToBoolean,branch.false", "type": "SuperInstruction" + }, + { + "_comment": "value: 3.5962172E7", + "instruction": "c.SLUnbox", + "id": "c:c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3.596081E7", + "instruction": "return", + "id": "c:return", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3.5130024E7", + "instruction": "store.local", + "id": "c:store.local", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3.5130008E7", + "instruction": "load.local", + "id": "c:load.local", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3.4369648E7", + "instruction": "load.argument", + "id": "c:load.argument", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3.0165153E7", + "instruction": "load.constant", + "id": "c:load.constant", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.933489E7", + "instruction": "pop", + "id": "c:pop", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.9330988E7", + "instruction": "c.SLToBoolean", + "id": "c:c.SLToBoolean", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.9330984E7", + "instruction": "branch.false", + "id": "c:branch.false", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.9330936E7", + "instruction": "branch", + "id": "c:branch", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.9324362E7", + "instruction": "load.local.boxed", + "id": "c:load.local.boxed", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.5546216E7", + "instruction": "c.SLLessOrEqual", + "id": "c:c.SLLessOrEqual", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.4836825E7", + "instruction": "c.SLAdd", + "id": "c:c.SLAdd", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.1352306E7", + "instruction": "c.SLInvoke", + "id": "c:c.SLInvoke", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2.1352158E7", + "instruction": "c.SLFunctionLiteral", + "id": "c:c.SLFunctionLiteral", + "type": "CommonInstruction" + }, + { + "_comment": "value: 1.0504953E7", + "instruction": "c.SLWriteProperty", + "id": "c:c.SLWriteProperty", + "type": "CommonInstruction" + }, + { + "_comment": "value: 1.0504791E7", + "instruction": "c.SLReadProperty", + "id": "c:c.SLReadProperty", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", + "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", + "id": "c:si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", + "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", + "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", + "id": "c:si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 9241911.0", + "instruction": "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 8821533.0", + "instruction": "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "id": "c:si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 8821533.0", + "instruction": "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 3786254.0", + "instruction": "c.SLLessThan", + "id": "c:c.SLLessThan", + "type": "CommonInstruction" + }, + { + "_comment": "value: 799136.0", + "instruction": "si.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 798495.0", + "instruction": "c.SLUnbox.q.FromLong", + "id": "c:c.SLUnbox.q.FromLong", + "type": "CommonInstruction" + }, + { + "_comment": "value: 798495.0", + "instruction": "c.SLUnbox.q.FromBigNumber", + "id": "c:c.SLUnbox.q.FromBigNumber", + "type": "CommonInstruction" + }, + { + "_comment": "value: 567798.0", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 567798.0", + "instruction": "c.SLReadProperty.q.ReadSLObject0", + "id": "c:c.SLReadProperty.q.ReadSLObject0", + "type": "CommonInstruction" + }, + { + "_comment": "value: 567798.0", + "instruction": "c.SLAdd.q.AddLong", + "id": "c:c.SLAdd.q.AddLong", + "type": "CommonInstruction" + }, + { + "_comment": "value: 567798.0", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 567798.0", + "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", + "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", + "type": "CommonInstruction" + }, + { + "_comment": "value: 547148.0", + "instruction": "si.c.SLToBoolean.branch.false", + "id": "c:si.c.SLToBoolean.branch.false", + "type": "CommonInstruction" + }, + { + "_comment": "value: 546483.0", + "instruction": "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "id": "c:si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 546483.0", + "instruction": "c.SLUnbox.q.FromBoolean", + "id": "c:c.SLUnbox.q.FromBoolean", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "si.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "si.c.SLToBoolean.branch.false", + "id": "c:si.c.SLToBoolean.branch.false", + "type": "CommonInstruction" + }, + { + "_comment": "value: 252012.0", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 252012.0", + "instruction": "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 252012.0", + "instruction": "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", + "id": "c:si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 252000.0", + "instruction": "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", + "id": "c:si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", + "type": "CommonInstruction" + }, + { + "_comment": "value: 31367.0", + "instruction": "c.SLLogicalNot", + "id": "c:c.SLLogicalNot", + "type": "CommonInstruction" + }, + { + "_comment": "value: 2317.0", + "instruction": "c.SLEqual", + "id": "c:c.SLEqual", + "type": "CommonInstruction" + }, + { + "_comment": "value: 1344.0", + "instruction": "c.SLSub", + "id": "c:c.SLSub", + "type": "CommonInstruction" + }, + { + "_comment": "value: 1141.0", + "instruction": "c.SLMul", + "id": "c:c.SLMul", + "type": "CommonInstruction" + }, + { + "_comment": "value: 665.0", + "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 203.0", + "instruction": "sc.SLOr", + "id": "c:sc.SLOr", + "type": "CommonInstruction" + }, + { + "_comment": "value: 189.0", + "instruction": "sc.SLAnd", + "id": "c:sc.SLAnd", + "type": "CommonInstruction" + }, + { + "_comment": "value: 93.0", + "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 54.0", + "instruction": "c.SLDiv", + "id": "c:c.SLDiv", + "type": "CommonInstruction" } ] \ No newline at end of file From e1e06204eab2bd4b1326c5099a24e214c3d1102b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 27 Oct 2022 10:17:00 +0200 Subject: [PATCH 166/312] [wip] place common behind a feature flag --- .../truffle/api/operation/tracing/OperationsStatistics.java | 1 - .../dsl/processor/operations/OperationGeneratorFlags.java | 2 ++ .../processor/operations/OperationsBytecodeCodeGenerator.java | 1 - .../dsl/processor/operations/OperationsCodeGenerator.java | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 4e2008f3b2b8..a1e0881074c3 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -630,7 +630,6 @@ private void merge(EnabledExecutionTracer other) { } private void calcNumNodesWithInstruction(GlobalOperationStatistics stats) { - System.err.println("Hit count = " + hitCount); nodesWithInstruction.forEach((k, v) -> { long totalCount = v.stream().map(hitCount::get).filter(x -> x != null).reduce(0L, EnabledExecutionTracer::saturatingAdd); numNodesWithInstruction.merge(k, totalCount, EnabledExecutionTracer::saturatingAdd); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index 950f83753ac4..ee1e8cebf4fc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -57,4 +57,6 @@ public class OperationGeneratorFlags { public static final boolean ENABLE_SERIALIZATION = true; public static final int BOXING_ELIM_BITS = 3; + + public static final boolean CREATE_COMMON_EXECUTE = false; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 0f9ce865b282..3653bd7294b2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -437,7 +437,6 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.caseDefault().startCaseBlock(); b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); if (isCommonOnly) { - b.statement("System.err.println(\" hit \" + curOpcode + \" @ \" + $bci)"); b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); b.startReturn().string("($sp << 16) | $bci").end(); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 718111c13292..e5129782b056 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -431,7 +431,7 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCOMMON_EXECUTE = new BytecodeNode()")); - if (m.isOptimized()) { + if (OperationGeneratorFlags.CREATE_COMMON_EXECUTE && m.isOptimized()) { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new CommonBytecodeNode()")); initialExecute = "COMMON_EXECUTE"; } else { @@ -503,7 +503,7 @@ CodeTypeElement createOperationNodeImpl() { builderUncachedBytecodeNodeType = null; } - if (m.isOptimized()) { + if (OperationGeneratorFlags.CREATE_COMMON_EXECUTE && m.isOptimized()) { builderCommonBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, true).createBuilderBytecodeNode(); typOperationNodeImpl.add(builderCommonBytecodeNodeType); From 91579b7904a0eec359d498f8cae6d27819cae989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 27 Oct 2022 10:59:53 +0200 Subject: [PATCH 167/312] [wip] separate out even more --- .../dsl/processor/ProcessorContext.java | 6 + .../operations/OperationGeneratorUtils.java | 24 +- .../OperationsBytecodeCodeGenerator.java | 218 ++++++++++-------- 3 files changed, 150 insertions(+), 98 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java index 08da04ad00e9..0c415dc27e6d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java @@ -268,4 +268,10 @@ public Map getCacheMap(Class key) { } return (Map) cacheMap; } + + int nameCounter; + + public String makeName() { + return "__helper" + (nameCounter++); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index bb517c8f141c..2256548ee7b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -52,10 +52,10 @@ import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; -import javax.lang.model.element.VariableElement; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; @@ -349,10 +349,14 @@ public static CodeTree extractBoxingBits(OperationsContext ctx, CodeTree instr) } public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVariables vars, String name, boolean isUncached, Consumer build) { + return wrapExecuteInMethod(ctx, vars, name, isUncached, build, true); + } + + public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVariables vars, String name, boolean isUncached, Consumer build, boolean doDecode) { ProcessorContext context = ProcessorContext.getInstance(); createHelperMethod(ctx.outerType, name, () -> { CodeExecutableElement m = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(int.class), name); - + m.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); m.addParameter(vars.stackFrame); if (ctx.getData().enableYield) { m.addParameter(vars.localFrame); @@ -365,6 +369,7 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria m.addParameter(vars.children); m.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "loopCounter")); + m.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); if (ctx.hasBoxingElimination()) { m.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); } @@ -384,7 +389,10 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria }); CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startAssign("int _enc").startCall(name); + if (doDecode) { + b.startAssign("int _enc"); + } + b.startCall(name); b.variable(vars.stackFrame); if (ctx.getData().enableYield) { @@ -398,6 +406,7 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria b.variable(vars.children); b.string("$conditionProfiles"); b.string("loopCounter"); + b.string("curOpcode"); if (ctx.hasBoxingElimination()) { b.string("$localTags"); } @@ -407,10 +416,13 @@ public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVaria if (isUncached) { b.string("uncachedExecuteCount"); } - b.end(2); + b.end(); - b.startAssign(vars.bci).string("_enc & 0xffff").end(); - b.startAssign(vars.sp).string("(_enc >> 16) & 0xffff").end(); + if (doDecode) { + b.end(); + b.startAssign(vars.bci).string("_enc & 0xffff").end(); + b.startAssign(vars.sp).string("(_enc >> 16) & 0xffff").end(); + } return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 3653bd7294b2..ef98d1a97d0d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -45,6 +45,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Random; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -310,6 +311,12 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.declaration("int", varCurOpcode.getName(), CodeTreeBuilder.createBuilder().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).string(" & 0xffff").build()); + if (isUncached) { + b.startAssign("curOpcode"); + b.tree(OperationGeneratorUtils.extractInstruction(ctx, CodeTreeBuilder.singleString("curOpcode"))); + b.end(); + } + b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); if (varTracer != null) { @@ -325,14 +332,13 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); b.startSwitch(); - if (isUncached) { - b.tree(OperationGeneratorUtils.extractInstruction(ctx, CodeTreeBuilder.singleString("curOpcode"))); - } else { - b.string("curOpcode"); - } + b.string("curOpcode"); b.end(); b.startBlock(); + List outerInstructions = new ArrayList<>(); + List innerInstructions = new ArrayList<>(); + for (Instruction op : m.getInstructions()) { if (op.isInstrumentationOnly() && !withInstrumentation) { continue; @@ -346,102 +352,42 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { continue; } - for (String line : op.dumpInfo().split("\n")) { - b.lineComment(line); + if (op.neverWrapInMethod()) { + outerInstructions.add(op); + } else { + innerInstructions.add(op); } + } - Consumer createBody = (String name) -> { - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "traceInstruction"); - b.variable(vars.bci); - b.variable(op.opcodeIdField); - b.string(op.isBranchInstruction() ? "1" : "0"); - b.string(op.isVariadic() ? "1" : "0"); - b.end(2); - } - - Consumer createBodyInner = b2 -> { - if (isUncached) { - b2.tree(op.createExecuteUncachedCode(vars)); - } else { - b2.tree(op.createExecuteCode(vars)); - } - - }; + for (Instruction op : outerInstructions) { + generateExecuteCase(ctx, vars, b, varTracer, op); + } - if (op.neverWrapInMethod()) { - createBodyInner.accept(b); - } else { - b.tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, "execute" + (isUncached ? "Uncached" : "") + "_" + op.internalName + name, isUncached, b2 -> { - createBodyInner.accept(b2); + b.caseDefault().startCaseBlock(); + b.tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, context.makeName(), isUncached, bInner -> { - if (!op.isBranchInstruction()) { - b2.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); - b2.tree(OperationGeneratorUtils.encodeExecuteReturn()); - } - })); - b.statement("continue loop"); - } + bInner.startSwitch(); + bInner.string("curOpcode"); + bInner.end(); + bInner.startBlock(); - }; - - if (ctx.hasBoxingElimination() && !isUncached) { - if (op.splitOnBoxingElimination()) { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - b.startBlock(); - vars.specializedKind = kind; - createBody.accept("_" + kind); - vars.specializedKind = null; - b.end(); - } - if (op.hasGeneric()) { - b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); - b.startBlock(); - createBody.accept("_GENERIC"); - b.end(); - } - } else if (op.alwaysBoxed()) { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - b.startBlock(); - createBody.accept(""); - b.end(); - } else { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - } + for (Instruction op : innerInstructions) { + generateExecuteCase(ctx, vars, bInner, varTracer, op); + } - b.startBlock(); - b.declaration("short", "primitiveTag", "(short) ((curOpcode >> 13) & 0x0007)"); - createBody.accept(""); - b.end(); - } + bInner.caseDefault().startCaseBlock(); + bInner.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + if (isCommonOnly) { + bInner.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); + bInner.startReturn().string("($sp << 16) | $bci").end(); } else { - if (isUncached) { - b.startCase().variable(op.opcodeIdField).end(); - } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - } - b.startBlock(); - if (ctx.hasBoxingElimination()) { - vars.specializedKind = FrameKind.OBJECT; - } - createBody.accept(""); - vars.specializedKind = null; - b.end(); + bInner.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); } - vars.inputs = null; - vars.results = null; - } + bInner.end(); - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (isCommonOnly) { - b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); - b.startReturn().string("($sp << 16) | $bci").end(); - } else { - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); - } + bInner.end(); // switch block + })); + b.statement("continue loop"); b.end(); b.end(); // switch block @@ -493,6 +439,94 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { return mContinueAt; } + private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, CodeTreeBuilder b, CodeVariableElement varTracer, Instruction op) { + for (String line : op.dumpInfo().split("\n")) { + b.lineComment(line); + } + + Consumer createBody = (String name) -> { + if (m.isTracing()) { + b.startStatement().startCall(varTracer, "traceInstruction"); + b.variable(vars.bci); + b.variable(op.opcodeIdField); + b.string(op.isBranchInstruction() ? "1" : "0"); + b.string(op.isVariadic() ? "1" : "0"); + b.end(2); + } + + Consumer createBodyInner = b2 -> { + if (isUncached) { + b2.tree(op.createExecuteUncachedCode(vars)); + } else { + b2.tree(op.createExecuteCode(vars)); + } + + }; + + if (op.neverWrapInMethod()) { + createBodyInner.accept(b); + } else { + b.startReturn().tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, "execute" + (isUncached ? "Uncached" : "") + "_" + op.internalName + name, isUncached, b2 -> { + createBodyInner.accept(b2); + + if (!op.isBranchInstruction()) { + b2.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); + b2.tree(OperationGeneratorUtils.encodeExecuteReturn()); + } + }, false)).end(); + } + + }; + + if (ctx.hasBoxingElimination() && !isUncached) { + if (op.splitOnBoxingElimination()) { + for (FrameKind kind : op.getBoxingEliminationSplits()) { + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); + b.startBlock(); + vars.specializedKind = kind; + createBody.accept("_" + kind); + vars.specializedKind = null; + b.end(); + } + if (op.hasGeneric()) { + b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); + b.startBlock(); + createBody.accept("_GENERIC"); + b.end(); + } + } else if (op.alwaysBoxed()) { + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + b.startBlock(); + createBody.accept(""); + b.end(); + } else { + for (FrameKind kind : op.getBoxingEliminationSplits()) { + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); + } + + b.startBlock(); + b.declaration("short", "primitiveTag", "(short) ((curOpcode >> 13) & 0x0007)"); + createBody.accept(""); + b.end(); + } + } else { + if (isUncached) { + b.startCase().variable(op.opcodeIdField).end(); + } else { + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + } + b.startBlock(); + if (ctx.hasBoxingElimination()) { + vars.specializedKind = FrameKind.OBJECT; + } + createBody.accept(""); + vars.specializedKind = null; + b.end(); + } + vars.inputs = null; + vars.results = null; + } + private void createExplodeLoop(CodeExecutableElement mContinueAt) { CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); mContinueAt.addAnnotationMirror(annExplodeLoop); From 266bf25b9b94259aef83b4dde83382b161e95800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 27 Oct 2022 11:13:19 +0200 Subject: [PATCH 168/312] [wip] new generated file location --- .../sl/operations/SLOperationRootNodeGen.java | 18560 ++++++++++++++++ .../sl/operations/SLOperationRootNodeGen.java | 14855 ------------- 2 files changed, 18560 insertions(+), 14855 deletions(-) create mode 100644 truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java delete mode 100644 truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java new file mode 100644 index 000000000000..cfab78f47cd3 --- /dev/null +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -0,0 +1,18560 @@ +// CheckStyle: start generated +package com.oracle.truffle.sl.operations; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; +import com.oracle.truffle.api.dsl.BoundaryCallFailedException; +import com.oracle.truffle.api.dsl.GeneratedBy; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.Frame; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameSlotKind; +import com.oracle.truffle.api.frame.FrameSlotTypeException; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.impl.UnsafeFrameAccess; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.LibraryFactory; +import com.oracle.truffle.api.nodes.BytecodeOSRNode; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.LoopNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.operation.OperationBuilder; +import com.oracle.truffle.api.operation.OperationConfig; +import com.oracle.truffle.api.operation.OperationLabel; +import com.oracle.truffle.api.operation.OperationLocal; +import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.OperationParser; +import com.oracle.truffle.api.operation.OperationRootNode; +import com.oracle.truffle.api.operation.introspection.OperationIntrospection; +import com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer; +import com.oracle.truffle.api.operation.serialization.OperationSerializer; +import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; +import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleString.ConcatNode; +import com.oracle.truffle.api.strings.TruffleString.EqualNode; +import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; +import com.oracle.truffle.sl.nodes.SLTypes; +import com.oracle.truffle.sl.nodes.SLTypesGen; +import com.oracle.truffle.sl.nodes.expression.SLAddNode; +import com.oracle.truffle.sl.nodes.expression.SLDivNode; +import com.oracle.truffle.sl.nodes.expression.SLEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; +import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; +import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; +import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; +import com.oracle.truffle.sl.nodes.expression.SLMulNode; +import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; +import com.oracle.truffle.sl.nodes.expression.SLSubNode; +import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; +import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNode; +import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; +import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; +import com.oracle.truffle.sl.nodes.util.SLUnboxNode; +import com.oracle.truffle.sl.runtime.SLBigNumber; +import com.oracle.truffle.sl.runtime.SLFunction; +import com.oracle.truffle.sl.runtime.SLNull; +import com.oracle.truffle.sl.runtime.SLObject; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.IOError; +import java.io.IOException; +import java.lang.invoke.VarHandle; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.concurrent.locks.Lock; + +@GeneratedBy(SLOperationRootNode.class) +@SuppressWarnings({"unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"}) +public final class SLOperationRootNodeGen extends SLOperationRootNode implements BytecodeOSRNode { + + @GeneratedBy(SLOperationRootNode.class) + private static final class BytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + return (($sp - 1) << 16) | 0xffff; + } + default : + int _enc = __helper0($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + $bci = _enc & 0xffff; + $sp = (_enc >> 16) & 0xffff; + continue loop; + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; + } + } + } + } + + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; + } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_CONSTANT : + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + $bci = $bci + LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_ARGUMENT : + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL : + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL : + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_RETURN : + { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; + $bci = $bci + RETURN_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD : + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_DIV : + { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_THAN : + { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_MUL : + { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_SUB : + { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_INVOKE : + { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; + $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_AND : + { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_AND_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + } + } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()}); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLAddNode.addLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b1111) == 0b1/* is-exact-state_0 addLong(long, long) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + } + try { + lock.unlock(); + hasLock = false; + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value_, $child1Value_); + } + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLDivNode.divLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLDivNode.div($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLDivNode.div($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.leftInterop_.accepts($child0Value)); + // assert (s7_.rightInterop_.accepts($child1Value)); + if (count7_ < (4)) { + s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + } + } + { + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); + } + + private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLLogicalNotNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { + return SLLogicalNotNode.doBoolean($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLMulNode.mulLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLMulNode.mul($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @ExplodeLoop + private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { + Node node__2 = ($this); + int bci__2 = ($bci); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + try { + return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = ($this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + node__1 = ($this); + bci__1 = ($bci); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = ($this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); + } + } + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { + node__2 = ($this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (s4_.objects_.accepts($child0Value)); + InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); + node__2 = ($this); + bci__2 = ($bci); + s4_.objects_ = s4_.insertAccessor(objects__); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 8] = s4_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + } + } + { + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = ($this); + readObject1_bci__ = ($bci); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 8] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLSubNode.subLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLSubNode.sub($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); + if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + try { + return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + int writeArray1_bci__ = 0; + Node writeArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + writeArray1_node__ = ($this); + writeArray1_bci__ = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); + } + } + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (s4_.objectLibrary_.accepts($child0Value)); + s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); + node__1 = ($this); + bci__1 = ($bci); + s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 7] = s4_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = ($this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 7] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); + if (fromString_fromJavaStringNode__ != null) { + return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLUnboxNode.fromBoolean($child0Value__); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + try { + return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { + return SLUnboxNode.fromBoolean($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { + return SLUnboxNode.fromLong($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromLong($child0Value_); + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBigNumber($child0Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.interop_.accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, s7_.interop_); + } + } + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); + if (result__ != null) { + return SLFunctionLiteralNode.perform($child0Value__, result__, node__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + node__ = ($this); + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + lock.unlock(); + hasLock = false; + return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); + Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); + if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); + } + if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); + if (indirect_callNode__ != null) { + return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = ($this); + int interop_bci__ = ($bci); + InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); + if (interop_library__ != null) { + return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); + } + + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); + if (($child0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + s0_.callTargetStable_ = callTargetStable__; + s0_.cachedTarget_ = cachedTarget__; + s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + } + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[childArrayOffset_ + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = ($this); + interop_bci__ = ($bci); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); + } + + @ExplodeLoop + private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_AddLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static long SLAdd_q_AddLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + CompilerDirectives.transferToInterpreterAndInvalidate(); + Counter uncachedExecuteCount = new Counter(); + uncachedExecuteCount.count = $this.uncachedExecuteCount; + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + curOpcode = (curOpcode >> 3) & 8191; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_RETURN : + { + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount.count; + } + return (($sp - 1) << 16) | 0xffff; + } + default : + int _enc = __helper1($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + $bci = _enc & 0xffff; + $sp = (_enc >> 16) & 0xffff; + continue loop; + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; + } + } + } + } + + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; + } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_CONSTANT : + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + $bci = $bci + LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_ARGUMENT : + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL : + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL : + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_RETURN : + { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; + $bci = $bci + RETURN_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD : + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_DIV : + { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_THAN : + { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_MUL : + { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_SUB : + { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_INVOKE : + { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; + $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_AND : + { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_AND_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + } + } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()}); + } + + private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLDivNode.div($child0Value_, $child1Value_); + } + } + return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + + private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); + } + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); + } + + private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } + + private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } + + private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); + private static final BytecodeLoopBase UNCOMMON_EXECUTE = new BytecodeNode(); + private static final BytecodeLoopBase COMMON_EXECUTE = UNCOMMON_EXECUTE; + private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); + private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; + private static final short INSTR_POP = 1; + private static final int POP_LENGTH = 1; + private static final short INSTR_BRANCH = 2; + private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_LENGTH = 2; + private static final short INSTR_BRANCH_FALSE = 3; + private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; + private static final int BRANCH_FALSE_LENGTH = 3; + private static final short INSTR_THROW = 4; + private static final int THROW_LOCALS_OFFSET = 1; + private static final int THROW_LENGTH = 2; + private static final short INSTR_LOAD_CONSTANT = 5; + private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; + private static final int LOAD_CONSTANT_LENGTH = 2; + private static final short INSTR_LOAD_ARGUMENT = 6; + private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; + private static final int LOAD_ARGUMENT_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL = 7; + private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL_BOXED = 8; + private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_BOXED_LENGTH = 2; + private static final short INSTR_STORE_LOCAL = 9; + private static final int STORE_LOCAL_LOCALS_OFFSET = 1; + private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; + private static final int STORE_LOCAL_LENGTH = 3; + private static final short INSTR_RETURN = 10; + private static final int RETURN_LENGTH = 1; + private static final short INSTR_LOAD_LOCAL_MAT = 11; + private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int LOAD_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_STORE_LOCAL_MAT = 12; + private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int STORE_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_ENTER = 13; + private static final int INSTRUMENT_ENTER_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; + private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT = 15; + private static final int INSTRUMENT_EXIT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_LEAVE = 16; + private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; + private static final int INSTRUMENT_LEAVE_LENGTH = 4; + private static final short INSTR_C_SL_ADD = 17; + private static final int C_SL_ADD_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_LENGTH = 6; + private static final short INSTR_C_SL_DIV = 18; + private static final int C_SL_DIV_CONSTANT_OFFSET = 1; + private static final int C_SL_DIV_CHILDREN_OFFSET = 2; + private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; + private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; + private static final int C_SL_DIV_LENGTH = 6; + private static final short INSTR_C_SL_EQUAL = 19; + private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; + private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; + private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; + private static final int C_SL_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; + private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_THAN = 21; + private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_THAN_LENGTH = 5; + private static final short INSTR_C_SL_LOGICAL_NOT = 22; + private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; + private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; + private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; + private static final int C_SL_LOGICAL_NOT_LENGTH = 5; + private static final short INSTR_C_SL_MUL = 23; + private static final int C_SL_MUL_CONSTANT_OFFSET = 1; + private static final int C_SL_MUL_CHILDREN_OFFSET = 2; + private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; + private static final int C_SL_MUL_LENGTH = 6; + private static final short INSTR_C_SL_READ_PROPERTY = 24; + private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_LENGTH = 6; + private static final short INSTR_C_SL_SUB = 25; + private static final int C_SL_SUB_CONSTANT_OFFSET = 1; + private static final int C_SL_SUB_CHILDREN_OFFSET = 2; + private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; + private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; + private static final int C_SL_SUB_LENGTH = 6; + private static final short INSTR_C_SL_WRITE_PROPERTY = 26; + private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; + private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; + private static final short INSTR_C_SL_UNBOX = 27; + private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_LENGTH = 5; + private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; + private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; + private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; + private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; + private static final short INSTR_C_SL_TO_BOOLEAN = 29; + private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; + private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; + private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_TO_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_INVOKE = 30; + private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; + private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; + private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; + private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; + private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; + private static final int C_SL_INVOKE_LENGTH = 7; + private static final short INSTR_SC_SL_AND = 31; + private static final int SC_SL_AND_CONSTANT_OFFSET = 1; + private static final int SC_SL_AND_CHILDREN_OFFSET = 2; + private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; + private static final int SC_SL_AND_LENGTH = 6; + private static final short INSTR_SC_SL_OR = 32; + private static final int SC_SL_OR_CONSTANT_OFFSET = 1; + private static final int SC_SL_OR_CHILDREN_OFFSET = 2; + private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; + private static final int SC_SL_OR_LENGTH = 6; + private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 33; + private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 34; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 35; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 37; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 38; + private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; + private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; + private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; + private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; + private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; + private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; + private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; + private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; + private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; + private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; + private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; + private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; + private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; + private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; + + @CompilationFinal private OperationNodesImpl nodes; + @CompilationFinal(dimensions = 1) private short[] _bc; + @CompilationFinal(dimensions = 1) private Object[] _consts; + @Children private Node[] _children; + @CompilationFinal(dimensions = 1) private byte[] _localTags; + @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; + @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; + @CompilationFinal private int _maxLocals; + @CompilationFinal private int _maxStack; + @CompilationFinal(dimensions = 1) private int[] sourceInfo; + @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; + @CompilationFinal private int uncachedExecuteCount = 16; + @CompilationFinal private Object _osrMetadata; + private TruffleString _metadata_MethodName; + + private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); + } + + private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { + this(language, builder.build()); + } + + static { + OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); + } + + @SuppressWarnings("unchecked") + private static RuntimeException sneakyThrow(Throwable e) throws E { //() { + throw (E) e; + } + + private T insertAccessor(T node) { // () { + return insert(node); + } + + private Object executeAt(VirtualFrame frame, int storedLocation) { + int result = storedLocation; + while (true) { + result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); + if ((result & 0xffff) == 0xffff) { + break; + } else { + SLOperationRootNodeGen $this = this; + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + } + return frame.getObject((result >> 16) & 0xffff); + } + + @Override + public SourceSection getSourceSection() { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; + } + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if (sourceInfo[i + 1] >= 0) { + int sourceIndex = sourceInfo[i + 0] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); + } + } + return null; + } + + @Override + public SourceSection getSourceSectionAtBci(int bci) { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; + } + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if ((sourceInfo[i + 0] & 0xffff) > bci) { + break; + } + } + if (i == 0) { + return null; + } else { + i -= 3; + int sourceIndex = sourceInfo[i + 0] >> 16; + if (sourceIndex < 0) { + return null; + } + int sourceStart = sourceInfo[i + 1]; + if (sourceStart < 0) { + return null; + } + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); + } + } + + @Override + public Object execute(VirtualFrame frame) { + Object returnValue = null; + Throwable throwable = null; + executeProlog(frame); + try { + returnValue = executeAt(frame, _maxLocals << 16); + return returnValue; + } catch (Throwable th) { + throw sneakyThrow(throwable = th); + } finally { + executeEpilog(frame, returnValue, throwable); + } + } + + @Override + public OperationIntrospection getIntrospectionData() { + return switchImpl.getIntrospectionData(_bc, _handlers, _consts); + } + + private Lock getLockAccessor() { + return getLock(); + } + + @Override + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target); + } + + @Override + public Object getOSRMetadata() { + return _osrMetadata; + } + + @Override + public void setOSRMetadata(Object osrMetadata) { + _osrMetadata = osrMetadata; + } + + @Override + public Node deepCopy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = Arrays.copyOf(_bc, _bc.length); + result._consts = Arrays.copyOf(_consts, _consts.length); + result._children = Arrays.copyOf(_children, _children.length); + result._localTags = Arrays.copyOf(_localTags, _localTags.length); + result._handlers = _handlers; + result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + @Override + public Node copy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = _bc; + result._consts = _consts; + result._children = _children; + result._localTags = _localTags; + result._handlers = _handlers; + result._conditionProfiles = _conditionProfiles; + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + private void changeInterpreters(BytecodeLoopBase impl) { + this.switchImpl = impl; + } + + @BytecodeInterpreterSwitch + private static int execute_POP(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_BRANCH(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + } + $bci = targetBci; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int execute_THROW(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_ARGUMENT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + Object value; + switch (UFA.unsafeGetTag($frame, localIdx)) { + case 0 /* OBJECT */ : + value = UFA.unsafeUncheckedGetObject($frame, localIdx); + break; + case 5 /* BOOLEAN */ : + value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); + break; + case 1 /* LONG */ : + value = UFA.unsafeUncheckedGetLong($frame, localIdx); + break; + default : + throw CompilerDirectives.shouldNotReachHere(); + } + UFA.unsafeSetObject($frame, $sp, value); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_BOXED_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + $bci -= LOAD_LOCAL_BOXED_LENGTH; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_BOXED_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } + } + } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_BOXED_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { + CompilerAsserts.neverPartOfCompilation(); + Object value = $frame.getValue(sourceSlot); + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); + // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); + if (bciOffset != 0) { + if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { + if (value instanceof Boolean) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */)); + doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); + return; + } + } + if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { + if (value instanceof Long) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */)); + doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) value); + return; + } + } + doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); + } + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 7 /* generic */)); + UFA.unsafeSetObject($frame, localIdx, value); + } + + private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); + } + + @BytecodeInterpreterSwitch + private static int execute_STORE_LOCAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 5 /* BOOLEAN */) { + try { + UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); + } + + @BytecodeInterpreterSwitch + private static int execute_STORE_LOCAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 1 /* LONG */) { + try { + UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); + } + + @BytecodeInterpreterSwitch + private static int execute_STORE_LOCAL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void do_storeLocal_null(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + try { + UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); + } + } + + @BytecodeInterpreterSwitch + private static int execute_STORE_LOCAL_GENERIC(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + $bci = $bci + STORE_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_LOAD_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_STORE_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_ADD_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_ADD_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_DIV_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_DIV_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_EQUAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_EQUAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LESS_OR_EQUAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LESS_OR_EQUAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LESS_THAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LESS_THAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LOGICAL_NOT_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_LOGICAL_NOT_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_MUL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_MUL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_SUB_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_SUB_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_WRITE_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_FUNCTION_LITERAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_TO_BOOLEAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_TO_BOOLEAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_INVOKE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + $bci = $bci + C_SL_INVOKE_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SC_SL_AND_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int execute_SC_SL_AND_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int execute_SC_SL_OR_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int execute_SC_SL_OR_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_LONG_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_ADD_Q_ADD_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + @BytecodeInterpreterSwitch + private static int execute_C_SL_ADD_Q_ADD_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + $bci -= LOAD_LOCAL_BOXED_LENGTH; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + $bci -= LOAD_LOCAL_BOXED_LENGTH; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + $bci -= LOAD_LOCAL_BOXED_LENGTH; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int execute_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int __helper0(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + return execute_POP($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + return execute_BRANCH($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + return execute_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + return execute_THROW($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + return execute_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + return execute_LOAD_ARGUMENT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + { + return execute_LOAD_LOCAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + { + return execute_LOAD_LOCAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + { + return execute_LOAD_LOCAL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + { + return execute_LOAD_LOCAL_BOXED_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + { + return execute_LOAD_LOCAL_BOXED_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + { + return execute_LOAD_LOCAL_BOXED_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + { + return execute_STORE_LOCAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + { + return execute_STORE_LOCAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + { + return execute_STORE_LOCAL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_STORE_LOCAL << 3) | 7) : + { + return execute_STORE_LOCAL_GENERIC($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + return execute_LOAD_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + return execute_STORE_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_ADD_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + { + return execute_C_SL_ADD_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_DIV_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + { + return execute_C_SL_DIV_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_EQUAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_EQUAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_LESS_OR_EQUAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_LESS_OR_EQUAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_LESS_THAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_LESS_THAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_LOGICAL_NOT_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_LOGICAL_NOT_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_MUL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + { + return execute_C_SL_MUL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + return execute_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_SUB_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + { + return execute_C_SL_SUB_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + return execute_C_SL_WRITE_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_UNBOX_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + return execute_C_SL_UNBOX_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_UNBOX_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + return execute_C_SL_FUNCTION_LITERAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_TO_BOOLEAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_TO_BOOLEAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : + { + return execute_C_SL_INVOKE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : + { + return execute_SC_SL_AND_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : + { + return execute_SC_SL_AND_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : + { + return execute_SC_SL_OR_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : + { + return execute_SC_SL_OR_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_UNBOX_Q_FROM_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + { + return execute_C_SL_UNBOX_Q_FROM_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_UNBOX_Q_FROM_LONG_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLUnbox.q.FromBigNumber + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLUnbox.q.FromBigNumber.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + { + return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + { + return execute_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // c.SLAdd.q.AddLong + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : + { + return execute_C_SL_ADD_Q_ADD_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : + { + return execute_C_SL_ADD_Q_ADD_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + return execute_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + return execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + { + return execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + return execute_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + { + return execute_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + return execute_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + return execute_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + } + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } + + @BytecodeInterpreterSwitch + private static int executeUncached_POP(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_BRANCH(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int executeUncached_THROW(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_LOAD_ARGUMENT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_LOAD_LOCAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_LOAD_LOCAL_BOXED(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_STORE_LOCAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_LOAD_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_STORE_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_DIV(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_DIV_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_EQUAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_LESS_OR_EQUAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_LESS_THAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_LOGICAL_NOT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_MUL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_MUL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_SUB(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_SUB_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_WRITE_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_FUNCTION_LITERAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_TO_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + return ($sp << 16) | $bci; + } + + private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); + } + + @BytecodeInterpreterSwitch + private static int executeUncached_C_SL_INVOKE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + $bci = $bci + C_SL_INVOKE_LENGTH; + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SC_SL_AND(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SC_SL_OR(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return ($sp << 16) | $bci; + } + + @BytecodeInterpreterSwitch + private static int executeUncached_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + } + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + return ($sp << 16) | $bci; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + return ($sp << 16) | $bci; + } + } + } + + @BytecodeInterpreterSwitch + private static int __helper1(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_POP : + { + return executeUncached_POP($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case INSTR_BRANCH : + { + return executeUncached_BRANCH($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case INSTR_BRANCH_FALSE : + { + return executeUncached_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case INSTR_THROW : + { + return executeUncached_THROW($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_CONSTANT : + { + return executeUncached_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_ARGUMENT : + { + return executeUncached_LOAD_ARGUMENT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case INSTR_LOAD_LOCAL : + { + return executeUncached_LOAD_LOCAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_BOXED : + { + return executeUncached_LOAD_LOCAL_BOXED($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case INSTR_STORE_LOCAL : + { + return executeUncached_STORE_LOCAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_MAT : + { + return executeUncached_LOAD_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case INSTR_STORE_LOCAL_MAT : + { + return executeUncached_STORE_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD : + { + return executeUncached_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case INSTR_C_SL_DIV : + { + return executeUncached_C_SL_DIV($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case INSTR_C_SL_EQUAL : + { + return executeUncached_C_SL_EQUAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL : + { + return executeUncached_C_SL_LESS_OR_EQUAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN : + { + return executeUncached_C_SL_LESS_THAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_LOGICAL_NOT : + { + return executeUncached_C_SL_LOGICAL_NOT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case INSTR_C_SL_MUL : + { + return executeUncached_C_SL_MUL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case INSTR_C_SL_READ_PROPERTY : + { + return executeUncached_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case INSTR_C_SL_SUB : + { + return executeUncached_C_SL_SUB($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case INSTR_C_SL_WRITE_PROPERTY : + { + return executeUncached_C_SL_WRITE_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX : + { + return executeUncached_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case INSTR_C_SL_FUNCTION_LITERAL : + { + return executeUncached_C_SL_FUNCTION_LITERAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_TO_BOOLEAN : + { + return executeUncached_C_SL_TO_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case INSTR_C_SL_INVOKE : + { + return executeUncached_C_SL_INVOKE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_AND : + { + return executeUncached_SC_SL_AND($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_OR : + { + return executeUncached_SC_SL_OR($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + return executeUncached_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + return executeUncached_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + return executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + return executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + return executeUncached_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + return executeUncached_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + return executeUncached_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + return executeUncached_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + return executeUncached_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); + } + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } + + private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { + if (bciOffset != 0) { + setResultBoxedImpl(bc, startBci - bciOffset, targetType); + } + } + + @ExplodeLoop + private static Object[] do_loadVariadicArguments(VirtualFrame $frame, int $sp, int numVariadics) { + CompilerAsserts.partialEvaluationConstant($sp); + CompilerAsserts.partialEvaluationConstant(numVariadics); + Object[] result = new Object[numVariadics]; + for (int varIndex = 0; varIndex < numVariadics; varIndex++) { + result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex); + } + return result; + } + + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { + bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); + } + + private static short unsafeFromBytecode(short[] bc, int index) { + return UFA.unsafeShortArrayRead(bc, index); + } + + private static void unsafeWriteBytecode(short[] bc, int index, short value) { + UFA.unsafeShortArrayWrite(bc, index, value); + } + + private static boolean do_profileCondition(SLOperationRootNodeGen $this, boolean value, int[] profiles, int index) { + int t = UFA.unsafeIntArrayRead(profiles, index); + int f = UFA.unsafeIntArrayRead(profiles, index + 1); + boolean val = value; + if (val) { + if (t == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (f == 0) { + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < 1073741823) { + UFA.unsafeIntArrayWrite(profiles, index, t + 1); + } + } + } else { + if (f == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (t == 0) { + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < 1073741823) { + UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1); + } + } + } + if (CompilerDirectives.inInterpreter()) { + return val; + } else { + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } + + public static OperationNodes create(OperationConfig config, OperationParser generator) { + OperationNodesImpl nodes = new OperationNodesImpl(generator); + Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(nodes, false, config); + generator.parse(builder); + builder.finish(); + return nodes; + } + + public static OperationNodes deserialize(TruffleLanguage language, OperationConfig config, ByteBuffer input, OperationDeserializer callback) throws IOException { + try { + return create(config, b -> Builder.deserializeParser(language, input, callback, b)); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + } + + public static void serialize(OperationConfig config, DataOutput buffer, OperationSerializer callback, OperationParser generator) throws IOException { + Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(null, false, config); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + try { + generator.parse(builder); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + buffer.writeShort((short) -5); + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class ExceptionHandler { + + int startBci; + int startStack; + int endBci; + int exceptionIndex; + int handlerBci; + + ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { + this.startBci = startBci; + this.startStack = startStack; + this.endBci = endBci; + this.exceptionIndex = exceptionIndex; + this.handlerBci = handlerBci; + } + + ExceptionHandler() { + } + + ExceptionHandler offset(int offset, int stackOffset) { + return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); + } + + @Override + public String toString() { + return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private abstract static class BytecodeLoopBase { + + abstract int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); + + abstract OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); + + abstract void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); + + protected static String formatConstant(Object obj) { + if (obj == null) { + return "null"; + } else { + Object repr = obj; + if (obj instanceof Object[]) { + repr = Arrays.deepToString((Object[]) obj); + } + return String.format("%s %s", obj.getClass().getSimpleName(), repr); + } + } + + protected static Object expectObject(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) { + if (bciOffset == 0 || UFA.unsafeIsObject(frame, slot)) { + return UFA.unsafeUncheckedGetObject(frame, slot); + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + return frame.getValue(slot); + } + } + + protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { + bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); + } + + protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + if (bciOffset == 0) { + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Boolean) { + return (boolean) value; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(value); + } + } else { + switch (UFA.unsafeGetTag(frame, slot)) { + case 5 /* BOOLEAN */ : + return UFA.unsafeUncheckedGetBoolean(frame, slot); + case 0 /* OBJECT */ : + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Boolean) { + setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); + return (boolean) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + if (bciOffset == 0) { + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Long) { + return (long) value; + } else { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw new UnexpectedResultException(value); + } + } else { + switch (UFA.unsafeGetTag(frame, slot)) { + case 1 /* LONG */ : + return UFA.unsafeUncheckedGetLong(frame, slot); + case 0 /* OBJECT */ : + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object value = UFA.unsafeUncheckedGetObject(frame, slot); + if (value instanceof Long) { + setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); + return (long) value; + } + break; + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + setResultBoxedImpl(bc, bci - bciOffset, 0); + throw new UnexpectedResultException(frame.getValue(slot)); + } + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationNodesImpl extends OperationNodes { + + OperationNodesImpl(OperationParser parse) { + super(parse); + } + + @Override + protected void reparseImpl(OperationConfig config, OperationParser parse, OperationRootNode[] nodes) { + Builder builder = new Builder(this, true, config); + ((OperationParser) parse).parse(builder); + builder.finish(); + } + + void setSources(Source[] sources) { + this.sources = sources; + } + + Source[] getSources() { + return sources; + } + + void setNodes(SLOperationRootNode[] nodes) { + this.nodes = nodes; + } + + @Override + public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { + Builder builder = new Builder(null, false, config); + builder.isSerializing = true; + builder.serBuffer = buffer; + builder.serCallback = callback; + try { + ((OperationParser) parse).parse(builder); + } catch (IOError ex) { + throw (IOException) ex.getCause(); + } + buffer.writeShort((short) -5); + } + + } + @GeneratedBy(SLOperationRootNode.class) + public static final class Builder extends OperationBuilder { + + private static final int OP_BLOCK = 1; + private static final int OP_ROOT = 2; + private static final int OP_IF_THEN = 3; + private static final int OP_IF_THEN_ELSE = 4; + private static final int OP_CONDITIONAL = 5; + private static final int OP_WHILE = 6; + private static final int OP_TRY_CATCH = 7; + private static final int OP_FINALLY_TRY = 8; + private static final int OP_FINALLY_TRY_NO_EXCEPT = 9; + private static final int OP_LABEL = 10; + private static final int OP_BRANCH = 11; + private static final int OP_LOAD_CONSTANT = 12; + private static final int OP_LOAD_ARGUMENT = 13; + private static final int OP_LOAD_LOCAL = 14; + private static final int OP_STORE_LOCAL = 15; + private static final int OP_RETURN = 16; + private static final int OP_LOAD_LOCAL_MATERIALIZED = 17; + private static final int OP_STORE_LOCAL_MATERIALIZED = 18; + private static final int OP_SOURCE = 19; + private static final int OP_SOURCE_SECTION = 20; + private static final int OP_TAG = 21; + private static final int OP_SL_ADD = 22; + private static final int OP_SL_DIV = 23; + private static final int OP_SL_EQUAL = 24; + private static final int OP_SL_LESS_OR_EQUAL = 25; + private static final int OP_SL_LESS_THAN = 26; + private static final int OP_SL_LOGICAL_NOT = 27; + private static final int OP_SL_MUL = 28; + private static final int OP_SL_READ_PROPERTY = 29; + private static final int OP_SL_SUB = 30; + private static final int OP_SL_WRITE_PROPERTY = 31; + private static final int OP_SL_UNBOX = 32; + private static final int OP_SL_FUNCTION_LITERAL = 33; + private static final int OP_SL_TO_BOOLEAN = 34; + private static final int OP_SL_INVOKE = 35; + private static final int OP_SL_AND = 36; + private static final int OP_SL_OR = 37; + + private final com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes; + private final boolean isReparse; + private final boolean withSource; + private final boolean withInstrumentation; + private final SourceInfoBuilder sourceBuilder; + private short[] bc = new short[65535]; + private int bci; + private int curStack; + private int maxStack; + private int numLocals; + private int[] instructionHistory = new int[8]; + private int instructionHistoryIndex = 0; + private int numLabels; + private ArrayList constPool = new ArrayList<>(); + private BuilderOperationData operationData; + private ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private int numChildNodes; + private int numConditionProfiles; + private ArrayList exceptionHandlers = new ArrayList<>(); + private BuilderFinallyTryContext currentFinallyTry; + private int buildIndex; + private boolean isSerializing; + private DataOutput serBuffer; + private OperationSerializer serCallback; + private int[] stackSourceBci = new int[1024]; + private BuilderState parentData; + private SerializerContext SER_CONTEXT = new SerializerContext() { + @Override + public void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException { + buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); + } + } + ; + private final ArrayList builtNodes; + private int lastChildPush; + private TruffleString metadata_MethodName; + + private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { + this.nodes = nodes; + this.isReparse = isReparse; + builtNodes = new ArrayList<>(); + if (isReparse) { + builtNodes.addAll((java.util.Collection) nodes.getNodes()); + } + this.withSource = config.isWithSource(); + this.withInstrumentation = config.isWithInstrumentation(); + this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; + } + + private void finish() { + if (withSource) { + nodes.setSources(sourceBuilder.buildSource()); + } + if (!isReparse) { + nodes.setNodes(builtNodes.toArray(new SLOperationRootNode[0])); + } + } + + private void reset(TruffleLanguage language) { + bci = 0; + curStack = 0; + maxStack = 0; + numLocals = 0; + constPool.clear(); + operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language); + labelFills.clear(); + numChildNodes = 0; + numConditionProfiles = 0; + exceptionHandlers.clear(); + Arrays.fill(instructionHistory, -1); + instructionHistoryIndex = 0; + metadata_MethodName = null; + } + + private int[] doBeforeEmitInstruction(int numPops, boolean pushValue, boolean doBoxing) { + int[] result = new int[numPops]; + for (int i = numPops - 1; i >= 0; i--) { + curStack--; + int predBci = stackSourceBci[curStack]; + result[i] = predBci; + } + if (pushValue) { + if (curStack >= stackSourceBci.length) { + stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); + } + stackSourceBci[curStack] = doBoxing ? bci : -65535; + curStack++; + if (curStack > maxStack) { + maxStack = curStack; + } + } + return result; + } + + private void doLeaveFinallyTry(BuilderOperationData opData) { + BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; + if (context.handlerBc == null) { + return; + } + System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); + for (int offset : context.relocationOffsets) { + short oldOffset = bc[bci + offset]; + bc[bci + offset] = (short) (oldOffset + bci); + } + for (ExceptionHandler handler : context.handlerHandlers) { + exceptionHandlers.add(handler.offset(bci, curStack)); + } + for (LabelFill fill : context.handlerLabelFills) { + labelFills.add(fill.offset(bci)); + } + if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; + bci += context.handlerBc.length; + } + + private void doEmitLabel(OperationLabel label) { + OperationLabelImpl lbl = (OperationLabelImpl) label; + if (lbl.hasValue) { + throw new UnsupportedOperationException("label already emitted"); + } + if (operationData != lbl.data) { + throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); + } + lbl.hasValue = true; + lbl.targetBci = bci; + } + + private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { + if (toData != null && fromData.depth < toData.depth) { + throw new UnsupportedOperationException("illegal jump to deeper operation"); + } + if (fromData == toData) { + return; + } + BuilderOperationData cur = fromData; + while (true) { + doLeaveOperation(cur); + cur = cur.parent; + if (toData == null && cur == null) { + break; + } else if (toData != null && cur.depth <= toData.depth) break; + } + if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); + } + + private void calculateLeaves(BuilderOperationData fromData) { + calculateLeaves(fromData, (BuilderOperationData) null); + } + + private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { + calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); + } + + public OperationLocal createLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -3); + return new OperationLocalImpl(null, numLocals++); + } catch (IOException ex) { + throw new IOError(ex); + } + } + return new OperationLocalImpl(operationData, numLocals++); + } + + private OperationLocalImpl createParentLocal() { + return new OperationLocalImpl(operationData.parent, numLocals++); + } + + public OperationLabel createLabel() { + if (isSerializing) { + try { + serBuffer.writeShort((short) -2); + return new OperationSerLabelImpl(numLabels++); + } catch (IOException ex) { + throw new IOError(ex); + } + } + OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); + labels.add(label); + return label; + } + + private short getLocalIndex(Object value) { + OperationLocalImpl local = (OperationLocalImpl) value; + assert verifyNesting(local.owner, operationData) : "local access not nested properly"; + return (short) local.id; + } + + private int[] getLocalIndices(Object value) { + OperationLocal[] locals = (OperationLocal[]) value; + int[] result = new int[locals.length]; + for (int i = 0; i < locals.length; i++) { + result[i] = getLocalIndex(locals[i]); + } + return result; + } + + private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { + BuilderOperationData cur = child; + while (cur.depth > parent.depth) { + cur = cur.parent; + } + return cur == parent; + } + + private SLOperationRootNode publish(TruffleLanguage language) { + if (isSerializing) { + SLOperationRootNode result = new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++); + numLocals = 0; + numLabels = 0; + return result; + } + if (operationData.depth != 0) { + throw new UnsupportedOperationException("Not all operations closed"); + } + SLOperationRootNodeGen result; + if (!isReparse) { + FrameDescriptor .Builder frameDescriptor; + frameDescriptor = FrameDescriptor.newBuilder(numLocals + maxStack); + frameDescriptor.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); + result = new SLOperationRootNodeGen(language, frameDescriptor); + result.nodes = nodes; + labelPass(null); + result._bc = Arrays.copyOf(bc, bci); + result._consts = constPool.toArray(); + result._children = new Node[numChildNodes]; + result._localTags = new byte[numLocals]; + result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); + result._conditionProfiles = new int[numConditionProfiles]; + result._maxLocals = numLocals; + result._maxStack = maxStack; + if (sourceBuilder != null) { + result.sourceInfo = sourceBuilder.build(); + } + result._metadata_MethodName = metadata_MethodName; + assert builtNodes.size() == buildIndex; + builtNodes.add(result); + } else { + result = builtNodes.get(buildIndex); + if (withSource && result.sourceInfo == null) { + result.sourceInfo = sourceBuilder.build(); + } + } + buildIndex++; + reset(language); + return result; + } + + private void labelPass(BuilderFinallyTryContext finallyTry) { + for (LabelFill fill : labelFills) { + if (finallyTry != null) { + if (fill.label.belongsTo(finallyTry)) { + assert fill.label.hasValue : "inner label should have been resolved by now"; + finallyTry.relocationOffsets.add(fill.locationBci); + } else { + finallyTry.handlerLabelFills.add(fill); + } + } + bc[fill.locationBci] = (short) fill.label.targetBci; + } + } + + private void doLeaveOperation(BuilderOperationData data) { + switch (data.operationId) { + case OP_FINALLY_TRY : + { + doLeaveFinallyTry(data); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + doLeaveFinallyTry(data); + break; + } + case OP_TAG : + { + break; + } + } + } + + @SuppressWarnings("unused") + private void doBeforeChild() { + int childIndex = operationData.numChildren; + switch (operationData.operationId) { + case OP_BLOCK : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_ROOT : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_TRY_CATCH : + { + if (childIndex == 1) { + curStack = ((ExceptionHandler) operationData.aux[0]).startStack; + ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; + } + break; + } + case OP_SOURCE : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_SOURCE_SECTION : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_TAG : + { + if (childIndex != 0) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + } + break; + } + case OP_SL_AND : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_SC_SL_AND << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_SC_SL_AND; + bci = bci + SC_SL_AND_LENGTH; + } + break; + } + case OP_SL_OR : + { + if (childIndex > 0) { + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_SC_SL_OR << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); + bc[bci + 5 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_SC_SL_OR; + bci = bci + SC_SL_OR_LENGTH; + } + break; + } + } + } + + @SuppressWarnings("unused") + private void doAfterChild() { + int childIndex = operationData.numChildren++; + switch (operationData.operationId) { + case OP_IF_THEN : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = endLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } + bci = bci + BRANCH_FALSE_LENGTH; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } + break; + } + case OP_IF_THEN_ELSE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } + bci = bci + BRANCH_FALSE_LENGTH; + } else if (childIndex == 1) { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_CONDITIONAL : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); + operationData.aux[0] = elseLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } + bci = bci + BRANCH_FALSE_LENGTH; + } else if (childIndex == 1) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + } else { + assert lastChildPush == 1; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_WHILE : + { + if (childIndex == 0) { + assert lastChildPush == 1; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + bc[bci + 2] = (short) numConditionProfiles; + numConditionProfiles += 2; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } + bci = bci + BRANCH_FALSE_LENGTH; + } else { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + } + break; + } + case OP_TRY_CATCH : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + ((ExceptionHandler) operationData.aux[0]).endBci = bci; + calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + } else { + } + break; + } + case OP_FINALLY_TRY : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.aux[2]); + exceptionHandlers.add(beh); + operationData.aux[1] = beh; + } + break; + } + case OP_FINALLY_TRY_NO_EXCEPT : + { + for (int i = 0; i < lastChildPush; i++) { + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; + bci = bci + POP_LENGTH; + } + if (childIndex == 0) { + labelPass(currentFinallyTry); + currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); + currentFinallyTry.handlerHandlers = exceptionHandlers; + currentFinallyTry.handlerMaxStack = maxStack; + System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); + bci = currentFinallyTry.bc.length; + exceptionHandlers = currentFinallyTry.exceptionHandlers; + labelFills = currentFinallyTry.labelFills; + labels = currentFinallyTry.labels; + curStack = currentFinallyTry.curStack; + maxStack = currentFinallyTry.maxStack; + currentFinallyTry = currentFinallyTry.prev; + } + break; + } + } + } + + @SuppressWarnings("unused") + public void beginBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BLOCK << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); + lastChildPush = 0; + } + + @SuppressWarnings("unused") + public void endBlock() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_BLOCK) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); + } + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginRoot(TruffleLanguage arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_ROOT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + lastChildPush = 0; + this.parentData = new BuilderState(this); + this.bc = new short[65535]; + this.constPool = new ArrayList<>(); + this.labels = new ArrayList<>(); + this.labelFills = new ArrayList<>(); + this.exceptionHandlers = new ArrayList<>(); + this.stackSourceBci = new int[1024]; + reset(arg0); + } + + @SuppressWarnings("unused") + public SLOperationRootNode endRoot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_ROOT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return publish(null); + } + if (operationData.operationId != OP_ROOT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Root expected at least 0 children, got " + numChildren); + } + lastChildPush = 0; + SLOperationRootNode endCodeResult; + endCodeResult = publish((TruffleLanguage) operationData.arguments[0]); + this.bc = parentData.bc; + this.bci = parentData.bci; + this.curStack = parentData.curStack; + this.maxStack = parentData.maxStack; + this.numLocals = parentData.numLocals; + this.numLabels = parentData.numLabels; + this.constPool = parentData.constPool; + this.operationData = parentData.operationData; + this.labels = parentData.labels; + this.labelFills = parentData.labelFills; + this.numChildNodes = parentData.numChildNodes; + this.numConditionProfiles = parentData.numConditionProfiles; + this.exceptionHandlers = parentData.exceptionHandlers; + this.currentFinallyTry = parentData.currentFinallyTry; + this.stackSourceBci = parentData.stackSourceBci; + this.parentData = parentData.parentData; + return endCodeResult; + } + + @SuppressWarnings("unused") + public void beginIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); + } + + @SuppressWarnings("unused") + public void endIfThen() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_IF_THEN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); + } + + @SuppressWarnings("unused") + public void endIfThenElse() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_IF_THEN_ELSE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); + } + + @SuppressWarnings("unused") + public void endConditional() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_CONDITIONAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); + } + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_WHILE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = startLabel; + } + + @SuppressWarnings("unused") + public void endWhile() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_WHILE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("While expected 2 children, got " + numChildren); + } + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginTryCatch(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); + ExceptionHandler beh = new ExceptionHandler(); + beh.startBci = bci; + beh.startStack = curStack; + beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); + exceptionHandlers.add(beh); + operationData.aux[0] = beh; + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + operationData.aux[1] = endLabel; + } + + @SuppressWarnings("unused") + public void endTryCatch() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_TRY_CATCH) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[1])); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); + operationData.aux[2] = createParentLocal(); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + public void endFinallyTry() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_FINALLY_TRY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); + } + int endBci = bci; + doLeaveFinallyTry(operationData); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + { + calculateLeaves(operationData, endLabel); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + } + ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); + beh.endBci = endBci; + beh.handlerBci = bci; + doLeaveFinallyTry(operationData); + { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_THROW << 3) | 0)); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_THROW; + bci = bci + THROW_LENGTH; + } + doEmitLabel(endLabel); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); + currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); + bci = 0; + exceptionHandlers = new ArrayList<>(); + labelFills = new ArrayList<>(); + labels = new ArrayList<>(); + curStack = 0; + maxStack = 0; + operationData.aux[0] = currentFinallyTry; + } + + @SuppressWarnings("unused") + public void endFinallyTryNoExcept() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); + } + doLeaveFinallyTry(operationData); + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLabel(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LABEL << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + doEmitLabel(arg0); + lastChildPush = 0; + doAfterChild(); + } + + public void emitBranch(OperationLabel arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_BRANCH << 1)); + serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); + calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); + labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; + bci = bci + BRANCH_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadConstant(Object arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_LOAD_CONSTANT << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_CONSTANT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_CONSTANT << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(operationData.arguments[0]); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_CONSTANT; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0); + } + bci = bci + LOAD_CONSTANT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadArgument(int arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); + serBuffer.writeInt(arg0); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_ARGUMENT << 3) | 0)); + bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_ARGUMENT; + bci = bci + LOAD_ARGUMENT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void emitLoadLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); + doBeforeEmitInstruction(0, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_LOCAL; + bci = bci + LOAD_LOCAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginStoreLocal(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endStoreLocal() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_STORE_LOCAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_STORE_LOCAL << 3) | 0)); + bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_STORE_LOCAL; + bci = bci + STORE_LOCAL_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_RETURN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endReturn() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_RETURN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("Return expected 1 children, got " + numChildren); + } + calculateLeaves(operationData); + doBeforeEmitInstruction(1, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_RETURN << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_RETURN; + bci = bci + RETURN_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginLoadLocalMaterialized(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_LOAD_LOCAL_MATERIALIZED << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endLoadLocalMaterialized() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_LOAD_LOCAL_MATERIALIZED << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_LOAD_LOCAL_MATERIALIZED) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("LoadLocalMaterialized expected 1 children, got " + numChildren); + } + doBeforeEmitInstruction(1, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_LOCAL_MAT << 3) | 0)); + bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_LOCAL_MAT; + bci = bci + LOAD_LOCAL_MAT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginStoreLocalMaterialized(OperationLocal arg0) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_STORE_LOCAL_MATERIALIZED << 1)); + serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); + } + + @SuppressWarnings("unused") + public void endStoreLocalMaterialized() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_STORE_LOCAL_MATERIALIZED << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_STORE_LOCAL_MATERIALIZED) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("StoreLocalMaterialized expected 2 children, got " + numChildren); + } + doBeforeEmitInstruction(2, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_STORE_LOCAL_MAT << 3) | 0)); + bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_STORE_LOCAL_MAT; + bci = bci + STORE_LOCAL_MAT_LENGTH; + lastChildPush = 0; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSource(Source arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_SOURCE << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); + sourceBuilder.beginSource(bci, arg0); + } + } + + @SuppressWarnings("unused") + public void endSource() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + if (operationData.operationId != OP_SOURCE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSource(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginSourceSection(int arg0, int arg1) { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); + serBuffer.writeInt(arg0); + serBuffer.writeInt(arg1); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); + sourceBuilder.beginSourceSection(bci, arg0, arg1); + } + } + + @SuppressWarnings("unused") + public void endSourceSection() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withSource) { + if (operationData.operationId != OP_SOURCE_SECTION) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); + } + sourceBuilder.endSourceSection(bci); + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginTag(Class arg0) { + if (isSerializing) { + try { + int arg0_index = constPool.indexOf(arg0); + if (arg0_index == -1) { + arg0_index = constPool.size(); + constPool.add(arg0); + serBuffer.writeShort((short) -4); + serCallback.serialize(SER_CONTEXT, serBuffer, arg0); + } + serBuffer.writeShort((short) (OP_TAG << 1)); + serBuffer.writeShort((short) arg0_index); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withInstrumentation) { + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); + int curInstrumentId = 0; + OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); + doEmitLabel(startLabel); + operationData.aux[0] = curInstrumentId; + operationData.aux[1] = startLabel; + operationData.aux[2] = endLabel; + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_ENTER << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_ENTER; + bci = bci + INSTRUMENT_ENTER_LENGTH; + lastChildPush = 0; + } + } + + @SuppressWarnings("unused") + public void endTag() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (withInstrumentation) { + if (operationData.operationId != OP_TAG) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); + } + if (lastChildPush != 0) { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT_VOID; + bci = bci + INSTRUMENT_EXIT_VOID_LENGTH; + } else { + doBeforeEmitInstruction(0, false, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT << 3) | 0)); + instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT; + bci = bci + INSTRUMENT_EXIT_LENGTH; + } + operationData = operationData.parent; + doAfterChild(); + } + } + + @SuppressWarnings("unused") + public void beginSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_ADD << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLAdd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_ADD) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 2; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_ADD; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_STORE_LOCAL) { + bc[bci - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } + bci = bci + C_SL_ADD_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_DIV << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLDiv() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_DIV) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_DIV << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_DIV; + bci = bci + C_SL_DIV_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_EQUAL << 3) | 0)); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 4; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_EQUAL; + bci = bci + C_SL_EQUAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLessOrEqual() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LESS_OR_EQUAL; + bci = bci + C_SL_LESS_OR_EQUAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLessThan() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LESS_THAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LESS_THAN << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LESS_THAN; + bci = bci + C_SL_LESS_THAN_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLLogicalNot() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_LOGICAL_NOT) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LOGICAL_NOT << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LOGICAL_NOT; + bci = bci + C_SL_LOGICAL_NOT_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_MUL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLMul() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_MUL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_MUL << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_MUL; + bci = bci + C_SL_MUL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLReadProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_READ_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 12; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_READ_PROPERTY; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0); + } + bci = bci + C_SL_READ_PROPERTY_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_SUB << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLSub() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_SUB) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 2) { + throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_SUB << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 4 + 0] = 0; + bc[bci + 4 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_SUB; + bci = bci + C_SL_SUB_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLWriteProperty() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_WRITE_PROPERTY) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 3) { + throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(3, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 11; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); + bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); + bc[bci + 5 + 0] = 0; + bc[bci + 5 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_WRITE_PROPERTY; + bci = bci + C_SL_WRITE_PROPERTY_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLUnbox() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_UNBOX) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + bc[bci + 1] = (short) numChildNodes; + numChildNodes += 3; + bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 3 + 0] = 0; + bc[bci + 3 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_UNBOX; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { + bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { + bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { + bc[bci - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { + bc[bci - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_C_SL_READ_PROPERTY) { + bc[bci - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } + bci = bci + C_SL_UNBOX_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLFunctionLiteral() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLFunctionLiteral() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_FUNCTION_LITERAL; + bci = bci + C_SL_FUNCTION_LITERAL_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLToBoolean() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_TO_BOOLEAN) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren != 1) { + throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_TO_BOOLEAN << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 1; + bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 4 + 0] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_TO_BOOLEAN; + bci = bci + C_SL_TO_BOOLEAN_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); + } + + @SuppressWarnings("unused") + public void endSLInvoke() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_INVOKE) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 0) { + throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); + } + int[] predecessorBcis = doBeforeEmitInstruction(numChildren - 1 + 0, true, false); + unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_INVOKE << 3) | 0)); + int constantsStart = constPool.size(); + bc[bci + 1] = (short) constantsStart; + constPool.add(null); + bc[bci + 2] = (short) numChildNodes; + numChildNodes += 5; + bc[bci + 4] = (short) (numChildren - 1); + bc[bci + 5 + 0] = 0; + bc[bci + 5 + 1] = 0; + instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_INVOKE; + bci = bci + C_SL_INVOKE_LENGTH; + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_AND << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + public void endSLAnd() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_AND) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + @SuppressWarnings("unused") + public void beginSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) (OP_SL_OR << 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + doBeforeChild(); + operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); + operationData.aux[0] = (OperationLabelImpl) createLabel(); + } + + @SuppressWarnings("unused") + public void endSLOr() { + if (isSerializing) { + try { + serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); + } catch (IOException ex) { + throw new IOError(ex); + } + return; + } + if (operationData.operationId != OP_SL_OR) { + throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + } + int numChildren = operationData.numChildren; + if (numChildren < 1) { + throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); + } + doEmitLabel(((OperationLabelImpl) operationData.aux[0])); + lastChildPush = 1; + operationData = operationData.parent; + doAfterChild(); + } + + public void setMethodName(TruffleString value) { + if (isSerializing) { + try { + serBuffer.writeShort((short) -6); + serBuffer.writeShort(0); + serCallback.serialize(SER_CONTEXT, serBuffer, value); + return; + } catch (IOException ex) { + throw new IOError(ex); + } + } + metadata_MethodName = value; + } + + private static void deserializeParser(TruffleLanguage language, ByteBuffer buffer, OperationDeserializer callback, com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder builder) { + try { + ArrayList consts = new ArrayList<>(); + ArrayList locals = new ArrayList<>(); + ArrayList labels = new ArrayList<>(); + ArrayList builtNodes = new ArrayList<>(); + buffer.rewind(); + DataInput dataInput = com.oracle.truffle.api.operation.serialization.SerializationUtils.createDataInput(buffer); + DeserializerContext context = new DeserializerContext(){ + @Override + public SLOperationRootNode deserializeOperationNode(DataInput buffer) throws IOException { + return builtNodes.get(buffer.readInt()); + } + } + ; + while (true) { + switch (buffer.getShort()) { + case -2 : + { + labels.add(builder.createLabel()); + break; + } + case -3 : + { + locals.add(builder.createLocal()); + break; + } + case -4 : + { + consts.add(callback.deserialize(context, dataInput)); + break; + } + case -5 : + { + return; + } + case -6 : + { + switch (buffer.getShort()) { + case 0 : + builder.setMethodName((TruffleString) callback.deserialize(context, dataInput)); + break; + } + break; + } + case OP_BLOCK << 1 : + { + builder.beginBlock(); + break; + } + case (OP_BLOCK << 1) | 1 : + { + builder.endBlock(); + break; + } + case OP_ROOT << 1 : + { + TruffleLanguage arg0 = language; + builder.beginRoot(arg0); + break; + } + case (OP_ROOT << 1) | 1 : + { + builtNodes.add(builder.endRoot()); + break; + } + case OP_IF_THEN << 1 : + { + builder.beginIfThen(); + break; + } + case (OP_IF_THEN << 1) | 1 : + { + builder.endIfThen(); + break; + } + case OP_IF_THEN_ELSE << 1 : + { + builder.beginIfThenElse(); + break; + } + case (OP_IF_THEN_ELSE << 1) | 1 : + { + builder.endIfThenElse(); + break; + } + case OP_CONDITIONAL << 1 : + { + builder.beginConditional(); + break; + } + case (OP_CONDITIONAL << 1) | 1 : + { + builder.endConditional(); + break; + } + case OP_WHILE << 1 : + { + builder.beginWhile(); + break; + } + case (OP_WHILE << 1) | 1 : + { + builder.endWhile(); + break; + } + case OP_TRY_CATCH << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginTryCatch(arg0); + break; + } + case (OP_TRY_CATCH << 1) | 1 : + { + builder.endTryCatch(); + break; + } + case OP_FINALLY_TRY << 1 : + { + builder.beginFinallyTry(); + break; + } + case (OP_FINALLY_TRY << 1) | 1 : + { + builder.endFinallyTry(); + break; + } + case OP_FINALLY_TRY_NO_EXCEPT << 1 : + { + builder.beginFinallyTryNoExcept(); + break; + } + case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : + { + builder.endFinallyTryNoExcept(); + break; + } + case OP_LABEL << 1 : + { + OperationLabel arg0 = labels.get(buffer.getShort()); + builder.emitLabel(arg0); + break; + } + case OP_BRANCH << 1 : + { + OperationLabel arg0 = labels.get(buffer.getShort()); + builder.emitBranch(arg0); + break; + } + case OP_LOAD_CONSTANT << 1 : + { + Object arg0 = (Object) consts.get(buffer.getShort()); + builder.emitLoadConstant(arg0); + break; + } + case OP_LOAD_ARGUMENT << 1 : + { + int arg0 = buffer.getInt(); + builder.emitLoadArgument(arg0); + break; + } + case OP_LOAD_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.emitLoadLocal(arg0); + break; + } + case OP_STORE_LOCAL << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginStoreLocal(arg0); + break; + } + case (OP_STORE_LOCAL << 1) | 1 : + { + builder.endStoreLocal(); + break; + } + case OP_RETURN << 1 : + { + builder.beginReturn(); + break; + } + case (OP_RETURN << 1) | 1 : + { + builder.endReturn(); + break; + } + case OP_LOAD_LOCAL_MATERIALIZED << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginLoadLocalMaterialized(arg0); + break; + } + case (OP_LOAD_LOCAL_MATERIALIZED << 1) | 1 : + { + builder.endLoadLocalMaterialized(); + break; + } + case OP_STORE_LOCAL_MATERIALIZED << 1 : + { + OperationLocal arg0 = locals.get(buffer.getShort()); + builder.beginStoreLocalMaterialized(arg0); + break; + } + case (OP_STORE_LOCAL_MATERIALIZED << 1) | 1 : + { + builder.endStoreLocalMaterialized(); + break; + } + case OP_SOURCE << 1 : + { + Source arg0 = (Source) consts.get(buffer.getShort()); + builder.beginSource(arg0); + break; + } + case (OP_SOURCE << 1) | 1 : + { + builder.endSource(); + break; + } + case OP_SOURCE_SECTION << 1 : + { + int arg0 = buffer.getInt(); + int arg1 = buffer.getInt(); + builder.beginSourceSection(arg0, arg1); + break; + } + case (OP_SOURCE_SECTION << 1) | 1 : + { + builder.endSourceSection(); + break; + } + case OP_TAG << 1 : + { + Class arg0 = (Class) consts.get(buffer.getShort()); + builder.beginTag(arg0); + break; + } + case (OP_TAG << 1) | 1 : + { + builder.endTag(); + break; + } + case OP_SL_ADD << 1 : + { + builder.beginSLAdd(); + break; + } + case (OP_SL_ADD << 1) | 1 : + { + builder.endSLAdd(); + break; + } + case OP_SL_DIV << 1 : + { + builder.beginSLDiv(); + break; + } + case (OP_SL_DIV << 1) | 1 : + { + builder.endSLDiv(); + break; + } + case OP_SL_EQUAL << 1 : + { + builder.beginSLEqual(); + break; + } + case (OP_SL_EQUAL << 1) | 1 : + { + builder.endSLEqual(); + break; + } + case OP_SL_LESS_OR_EQUAL << 1 : + { + builder.beginSLLessOrEqual(); + break; + } + case (OP_SL_LESS_OR_EQUAL << 1) | 1 : + { + builder.endSLLessOrEqual(); + break; + } + case OP_SL_LESS_THAN << 1 : + { + builder.beginSLLessThan(); + break; + } + case (OP_SL_LESS_THAN << 1) | 1 : + { + builder.endSLLessThan(); + break; + } + case OP_SL_LOGICAL_NOT << 1 : + { + builder.beginSLLogicalNot(); + break; + } + case (OP_SL_LOGICAL_NOT << 1) | 1 : + { + builder.endSLLogicalNot(); + break; + } + case OP_SL_MUL << 1 : + { + builder.beginSLMul(); + break; + } + case (OP_SL_MUL << 1) | 1 : + { + builder.endSLMul(); + break; + } + case OP_SL_READ_PROPERTY << 1 : + { + builder.beginSLReadProperty(); + break; + } + case (OP_SL_READ_PROPERTY << 1) | 1 : + { + builder.endSLReadProperty(); + break; + } + case OP_SL_SUB << 1 : + { + builder.beginSLSub(); + break; + } + case (OP_SL_SUB << 1) | 1 : + { + builder.endSLSub(); + break; + } + case OP_SL_WRITE_PROPERTY << 1 : + { + builder.beginSLWriteProperty(); + break; + } + case (OP_SL_WRITE_PROPERTY << 1) | 1 : + { + builder.endSLWriteProperty(); + break; + } + case OP_SL_UNBOX << 1 : + { + builder.beginSLUnbox(); + break; + } + case (OP_SL_UNBOX << 1) | 1 : + { + builder.endSLUnbox(); + break; + } + case OP_SL_FUNCTION_LITERAL << 1 : + { + builder.beginSLFunctionLiteral(); + break; + } + case (OP_SL_FUNCTION_LITERAL << 1) | 1 : + { + builder.endSLFunctionLiteral(); + break; + } + case OP_SL_TO_BOOLEAN << 1 : + { + builder.beginSLToBoolean(); + break; + } + case (OP_SL_TO_BOOLEAN << 1) | 1 : + { + builder.endSLToBoolean(); + break; + } + case OP_SL_INVOKE << 1 : + { + builder.beginSLInvoke(); + break; + } + case (OP_SL_INVOKE << 1) | 1 : + { + builder.endSLInvoke(); + break; + } + case OP_SL_AND << 1 : + { + builder.beginSLAnd(); + break; + } + case (OP_SL_AND << 1) | 1 : + { + builder.endSLAnd(); + break; + } + case OP_SL_OR << 1 : + { + builder.beginSLOr(); + break; + } + case (OP_SL_OR << 1) | 1 : + { + builder.endSLOr(); + break; + } + } + } + } catch (IOException ex) { + throw new IOError(ex); + } + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class BuilderOperationData { + + final BuilderOperationData parent; + final int operationId; + final int stackDepth; + final boolean needsLeave; + final int depth; + final Object[] arguments; + final Object[] aux; + int numChildren; + + private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { + this.parent = parent; + this.operationId = operationId; + this.stackDepth = stackDepth; + this.depth = parent == null ? 0 : parent.depth + 1; + this.aux = numAux > 0 ? new Object[numAux] : null; + this.needsLeave = needsLeave || (parent != null && parent.needsLeave); + this.arguments = arguments; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationLabelImpl extends OperationLabel { + + BuilderOperationData data; + BuilderFinallyTryContext finallyTry; + int targetBci = 0; + boolean hasValue = false; + + OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { + this.data = data; + this.finallyTry = finallyTry; + } + + boolean belongsTo(BuilderFinallyTryContext context) { + BuilderFinallyTryContext cur = finallyTry; + while (cur != null) { + if (cur == context) { + return true; + } + cur = cur.prev; + } + return false; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationSerLabelImpl extends OperationLabel { + + int id; + + OperationSerLabelImpl(int id) { + this.id = id; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationLocalImpl extends OperationLocal { + + final BuilderOperationData owner; + final int id; + + OperationLocalImpl(BuilderOperationData owner, int id) { + this.owner = owner; + this.id = id; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class LabelFill { + + int locationBci; + OperationLabelImpl label; + + LabelFill(int locationBci, OperationLabelImpl label) { + this.locationBci = locationBci; + this.label = label; + } + + LabelFill offset(int offset) { + return new LabelFill(offset + locationBci, label); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SourceInfoBuilder { + + private final ArrayList sourceStack = new ArrayList<>(); + private final ArrayList sourceList = new ArrayList<>(); + private int currentSource = -1; + private final ArrayList bciList = new ArrayList<>(); + private final ArrayList sourceDataList = new ArrayList<>(); + private final ArrayList sourceDataStack = new ArrayList<>(); + + void reset() { + sourceStack.clear(); + sourceDataList.clear(); + sourceDataStack.clear(); + bciList.clear(); + } + + void beginSource(int bci, Source src) { + int idx = sourceList.indexOf(src); + if (idx == -1) { + idx = sourceList.size(); + sourceList.add(src); + } + sourceStack.add(currentSource); + currentSource = idx; + beginSourceSection(bci, -1, -1); + } + + void endSource(int bci) { + endSourceSection(bci); + currentSource = sourceStack.remove(sourceStack.size() - 1); + } + + void beginSourceSection(int bci, int start, int length) { + SourceData data = new SourceData(start, length, currentSource); + bciList.add(bci); + sourceDataList.add(data); + sourceDataStack.add(data); + } + + void endSourceSection(int bci) { + SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); + SourceData prev; + if (sourceDataStack.isEmpty()) { + prev = new SourceData(-1, -1, currentSource); + } else { + prev = sourceDataStack.get(sourceDataStack.size() - 1); + } + bciList.add(bci); + sourceDataList.add(prev); + } + + int[] build() { + if (!sourceStack.isEmpty()) { + throw new IllegalStateException("not all sources ended"); + } + if (!sourceDataStack.isEmpty()) { + throw new IllegalStateException("not all source sections ended"); + } + int size = bciList.size(); + int[] resultArray = new int[size * 3]; + int index = 0; + int lastBci = -1; + boolean isFirst = true; + for (int i = 0; i < size; i++) { + SourceData data = sourceDataList.get(i); + int curBci = bciList.get(i); + if (data.start == -1 && isFirst) { + continue; + } + isFirst = false; + if (curBci == lastBci && index > 1) { + index -= 3; + } + resultArray[index + 0] = curBci | (data.sourceIndex << 16); + resultArray[index + 1] = data.start; + resultArray[index + 2] = data.length; + index += 3; + lastBci = curBci; + } + return Arrays.copyOf(resultArray, index); + } + + Source[] buildSource() { + return sourceList.toArray(new Source[0]); + } + + @GeneratedBy(SLOperationRootNode.class) + private static final class SourceData { + + final int start; + final int length; + final int sourceIndex; + + SourceData(int start, int length, int sourceIndex) { + this.start = start; + this.length = length; + this.sourceIndex = sourceIndex; + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class BuilderFinallyTryContext { + + final BuilderFinallyTryContext prev; + final short[] bc; + final ArrayList exceptionHandlers; + final ArrayList labelFills; + final ArrayList labels; + final int curStack; + final int maxStack; + short[] handlerBc; + ArrayList handlerHandlers; + ArrayList handlerLabelFills = new ArrayList<>(); + ArrayList relocationOffsets = new ArrayList<>(); + int handlerMaxStack; + + BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { + this.prev = prev; + this.bc = bc; + this.exceptionHandlers = exceptionHandlers; + this.labelFills = labelFills; + this.labels = labels; + this.curStack = curStack; + this.maxStack = maxStack; + } + + } + private final class BuilderState { + + BuilderState parentData; + private short[] bc = new short[65535]; + private int bci; + private int curStack; + private int maxStack; + private int numLocals; + private int numLabels; + private ArrayList constPool; + private BuilderOperationData operationData; + private ArrayList labels = new ArrayList<>(); + private ArrayList labelFills = new ArrayList<>(); + private int numChildNodes; + private int numConditionProfiles; + private ArrayList exceptionHandlers = new ArrayList<>(); + private BuilderFinallyTryContext currentFinallyTry; + private int[] stackSourceBci = new int[1024]; + + BuilderState(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder p) { + this.bc = p.bc; + this.bci = p.bci; + this.curStack = p.curStack; + this.maxStack = p.maxStack; + this.numLocals = p.numLocals; + this.numLabels = p.numLabels; + this.constPool = p.constPool; + this.operationData = p.operationData; + this.labels = p.labels; + this.labelFills = p.labelFills; + this.numChildNodes = p.numChildNodes; + this.numConditionProfiles = p.numConditionProfiles; + this.exceptionHandlers = p.exceptionHandlers; + this.currentFinallyTry = p.currentFinallyTry; + this.stackSourceBci = p.stackSourceBci; + this.parentData = p.parentData; + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class OperationSerNodeImpl extends SLOperationRootNode { + + @CompilationFinal int buildOrder; + + private OperationSerNodeImpl(TruffleLanguage language, FrameDescriptor frameDescriptor, int buildOrder) { + super(language, frameDescriptor); + this.buildOrder = buildOrder; + } + + @Override + public Object execute(VirtualFrame frame) { + throw new UnsupportedOperationException(); + } + + @Override + public SourceSection getSourceSectionAtBci(int bci) { + throw new UnsupportedOperationException(); + } + + } + } + private static final class Counter { + + int count; + + } +} diff --git a/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java deleted file mode 100644 index d651d64b6aac..000000000000 --- a/truffle/src/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ /dev/null @@ -1,14855 +0,0 @@ -// CheckStyle: start generated -package com.oracle.truffle.sl.operations; - -import com.oracle.truffle.api.Assumption; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleSafepoint; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; -import com.oracle.truffle.api.dsl.BoundaryCallFailedException; -import com.oracle.truffle.api.dsl.GeneratedBy; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.exception.AbstractTruffleException; -import com.oracle.truffle.api.frame.Frame; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.FrameSlotTypeException; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.impl.UnsafeFrameAccess; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.LibraryFactory; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.DirectCallNode; -import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.IndirectCallNode; -import com.oracle.truffle.api.nodes.LoopNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; -import com.oracle.truffle.api.object.DynamicObjectLibrary; -import com.oracle.truffle.api.operation.OperationBuilder; -import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.OperationParser; -import com.oracle.truffle.api.operation.OperationRootNode; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer; -import com.oracle.truffle.api.operation.serialization.OperationSerializer; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; -import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.ConcatNode; -import com.oracle.truffle.api.strings.TruffleString.EqualNode; -import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; -import com.oracle.truffle.sl.nodes.SLTypes; -import com.oracle.truffle.sl.nodes.SLTypesGen; -import com.oracle.truffle.sl.nodes.expression.SLAddNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNode; -import com.oracle.truffle.sl.nodes.expression.SLEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; -import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.runtime.SLBigNumber; -import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLNull; -import com.oracle.truffle.sl.runtime.SLObject; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.IOError; -import java.io.IOException; -import java.lang.invoke.VarHandle; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.locks.Lock; - -@GeneratedBy(SLOperationRootNode.class) -@SuppressWarnings({"unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"}) -public final class SLOperationRootNodeGen extends SLOperationRootNode implements BytecodeOSRNode { - - private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); - private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); - private static final BytecodeLoopBase COMMON_EXECUTE = new BytecodeNode(); - private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; - private static final short INSTR_POP = 1; - private static final int POP_LENGTH = 1; - private static final short INSTR_BRANCH = 2; - private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_LENGTH = 2; - private static final short INSTR_BRANCH_FALSE = 3; - private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; - private static final int BRANCH_FALSE_LENGTH = 3; - private static final short INSTR_THROW = 4; - private static final int THROW_LOCALS_OFFSET = 1; - private static final int THROW_LENGTH = 2; - private static final short INSTR_LOAD_CONSTANT = 5; - private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; - private static final int LOAD_CONSTANT_LENGTH = 2; - private static final short INSTR_LOAD_ARGUMENT = 6; - private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; - private static final int LOAD_ARGUMENT_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL = 7; - private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL_BOXED = 8; - private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_BOXED_LENGTH = 2; - private static final short INSTR_STORE_LOCAL = 9; - private static final int STORE_LOCAL_LOCALS_OFFSET = 1; - private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; - private static final int STORE_LOCAL_LENGTH = 3; - private static final short INSTR_RETURN = 10; - private static final int RETURN_LENGTH = 1; - private static final short INSTR_LOAD_LOCAL_MAT = 11; - private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int LOAD_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_STORE_LOCAL_MAT = 12; - private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int STORE_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_INSTRUMENT_ENTER = 13; - private static final int INSTRUMENT_ENTER_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; - private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT = 15; - private static final int INSTRUMENT_EXIT_LENGTH = 2; - private static final short INSTR_INSTRUMENT_LEAVE = 16; - private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; - private static final int INSTRUMENT_LEAVE_LENGTH = 4; - private static final short INSTR_C_SL_ADD = 17; - private static final int C_SL_ADD_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_LENGTH = 6; - private static final short INSTR_C_SL_DIV = 18; - private static final int C_SL_DIV_CONSTANT_OFFSET = 1; - private static final int C_SL_DIV_CHILDREN_OFFSET = 2; - private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; - private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - private static final int C_SL_DIV_LENGTH = 6; - private static final short INSTR_C_SL_EQUAL = 19; - private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; - private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; - private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - private static final int C_SL_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; - private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_THAN = 21; - private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_THAN_LENGTH = 5; - private static final short INSTR_C_SL_LOGICAL_NOT = 22; - private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; - private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; - private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - private static final int C_SL_LOGICAL_NOT_LENGTH = 5; - private static final short INSTR_C_SL_MUL = 23; - private static final int C_SL_MUL_CONSTANT_OFFSET = 1; - private static final int C_SL_MUL_CHILDREN_OFFSET = 2; - private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - private static final int C_SL_MUL_LENGTH = 6; - private static final short INSTR_C_SL_READ_PROPERTY = 24; - private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_LENGTH = 6; - private static final short INSTR_C_SL_SUB = 25; - private static final int C_SL_SUB_CONSTANT_OFFSET = 1; - private static final int C_SL_SUB_CHILDREN_OFFSET = 2; - private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; - private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - private static final int C_SL_SUB_LENGTH = 6; - private static final short INSTR_C_SL_WRITE_PROPERTY = 26; - private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; - private static final short INSTR_C_SL_UNBOX = 27; - private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_LENGTH = 5; - private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; - private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; - private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; - private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; - private static final short INSTR_C_SL_TO_BOOLEAN = 29; - private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; - private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; - private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_TO_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_INVOKE = 30; - private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; - private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; - private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; - private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; - private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; - private static final int C_SL_INVOKE_LENGTH = 7; - private static final short INSTR_SC_SL_AND = 31; - private static final int SC_SL_AND_CONSTANT_OFFSET = 1; - private static final int SC_SL_AND_CHILDREN_OFFSET = 2; - private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - private static final int SC_SL_AND_LENGTH = 6; - private static final short INSTR_SC_SL_OR = 32; - private static final int SC_SL_OR_CONSTANT_OFFSET = 1; - private static final int SC_SL_OR_CHILDREN_OFFSET = 2; - private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - private static final int SC_SL_OR_LENGTH = 6; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 33; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 34; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 35; - private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_ADD_Q_ADD0 = 37; - private static final int C_SL_ADD_Q_ADD0_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD0_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD0_LENGTH = 6; - private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 38; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; - private static final short INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN = 39; - private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET = 1; - private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_CHILDREN_OFFSET = 2; - private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM = 40; - private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET = 1; - private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_CHILDREN_OFFSET = 2; - private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET = 3; - private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET = 4; - private static final int C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH = 5; - private static final short INSTR_C_SL_INVOKE_Q_DIRECT = 41; - private static final int C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET = 1; - private static final int C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET = 2; - private static final int C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET = 3; - private static final int C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET = 4; - private static final int C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET = 5; - private static final int C_SL_INVOKE_Q_DIRECT_LENGTH = 7; - private static final short INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 = 42; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH = 5; - private static final short INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 = 43; - private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET = 1; - private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET = 2; - private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET = 5; - private static final int C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH = 7; - private static final short INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING = 44; - private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH = 5; - private static final short INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 = 45; - private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH = 5; - private static final short INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 = 46; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH = 5; - private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 47; - private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; - private static final short INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 = 48; - private static final int C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_THAN_Q_LESS_THAN1_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING = 49; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING = 50; - private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH = 5; - private static final short INSTR_C_SL_ADD_Q_ADD0_ADD1 = 51; - private static final int C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD0_ADD1_LENGTH = 6; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING = 52; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH = 5; - private static final short INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN = 53; - private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET = 1; - private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_CHILDREN_OFFSET = 2; - private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 = 54; - private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH = 5; - - @CompilationFinal private OperationNodesImpl nodes; - @CompilationFinal(dimensions = 1) private short[] _bc; - @CompilationFinal(dimensions = 1) private Object[] _consts; - @Children private Node[] _children; - @CompilationFinal(dimensions = 1) private byte[] _localTags; - @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; - @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; - @CompilationFinal private int _maxLocals; - @CompilationFinal private int _maxStack; - @CompilationFinal(dimensions = 1) private int[] sourceInfo; - @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; - @CompilationFinal private int uncachedExecuteCount = 16; - @CompilationFinal private Object _osrMetadata; - private TruffleString _metadata_MethodName; - - private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); - } - - private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { - this(language, builder.build()); - } - - static { - OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); - } - - @SuppressWarnings("unchecked") - private static RuntimeException sneakyThrow(Throwable e) throws E { //() { - throw (E) e; - } - - private T insertAccessor(T node) { // () { - return insert(node); - } - - private Object executeAt(VirtualFrame frame, int storedLocation) { - int result = storedLocation; - while (true) { - result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); - if ((result & 0xffff) == 0xffff) { - break; - } else { - SLOperationRootNodeGen $this = this; - hook_transferToInterpreterAndInvalidate($this); - } - } - return frame.getObject((result >> 16) & 0xffff); - } - - @Override - public SourceSection getSourceSection() { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if (sourceInfo[i + 1] >= 0) { - int sourceIndex = sourceInfo[i + 0] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - return null; - } - - @Override - public SourceSection getSourceSectionAtBci(int bci) { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if ((sourceInfo[i + 0] & 0xffff) > bci) { - break; - } - } - if (i == 0) { - return null; - } else { - i -= 3; - int sourceIndex = sourceInfo[i + 0] >> 16; - if (sourceIndex < 0) { - return null; - } - int sourceStart = sourceInfo[i + 1]; - if (sourceStart < 0) { - return null; - } - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - - @Override - public Object execute(VirtualFrame frame) { - Object returnValue = null; - Throwable throwable = null; - executeProlog(frame); - try { - returnValue = executeAt(frame, _maxLocals << 16); - return returnValue; - } catch (Throwable th) { - throw sneakyThrow(throwable = th); - } finally { - executeEpilog(frame, returnValue, throwable); - } - } - - @Override - public String dump() { - return switchImpl.dump(_bc, _handlers, _consts); - } - - private Lock getLockAccessor() { - return getLock(); - } - - @Override - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return executeAt(osrFrame, target); - } - - @Override - public Object getOSRMetadata() { - return _osrMetadata; - } - - @Override - public void setOSRMetadata(Object osrMetadata) { - _osrMetadata = osrMetadata; - } - - @Override - public Node deepCopy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = Arrays.copyOf(_bc, _bc.length); - result._consts = Arrays.copyOf(_consts, _consts.length); - result._children = Arrays.copyOf(_children, _children.length); - result._localTags = Arrays.copyOf(_localTags, _localTags.length); - result._handlers = _handlers; - result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - @Override - public Node copy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = _bc; - result._consts = _consts; - result._children = _children; - result._localTags = _localTags; - result._handlers = _handlers; - result._conditionProfiles = _conditionProfiles; - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - private void changeInterpreters(BytecodeLoopBase impl) { - this.switchImpl = impl; - } - - private static void hook_transferToInterpreterAndInvalidate(SLOperationRootNodeGen $this) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (__magic_LogInvalidations) { - System.err.printf("[ INV ] %s%s%n", "", StackWalker.getInstance().walk(s -> s.skip(1).findFirst().get().toStackTraceElement().toString())); - } - } - - private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - Object value; - switch (UFA.unsafeGetTag($frame, localIdx)) { - case 0 /* OBJECT */ : - value = UFA.unsafeUncheckedGetObject($frame, localIdx); - break; - case 5 /* BOOLEAN */ : - value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); - break; - case 1 /* LONG */ : - value = UFA.unsafeUncheckedGetLong($frame, localIdx); - break; - default : - throw CompilerDirectives.shouldNotReachHere(); - } - UFA.unsafeSetObject($frame, $sp, value); - return; - } - - private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13))); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13))); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13))); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13))); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { - CompilerAsserts.neverPartOfCompilation(); - Object value = $frame.getValue(sourceSlot); - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); - // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); - if (bciOffset != 0) { - if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { - if (value instanceof Boolean) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - unsafeWriteBytecode($bc, $bci, (short) ((5 /* BOOLEAN */ << 13) | INSTR_STORE_LOCAL)); - doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); - return; - } - } - if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { - if (value instanceof Long) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - unsafeWriteBytecode($bc, $bci, (short) ((1 /* LONG */ << 13) | INSTR_STORE_LOCAL)); - doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) value); - return; - } - } - doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); - } - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); - unsafeWriteBytecode($bc, $bci, (short) ((7 /* generic */ << 13) | INSTR_STORE_LOCAL)); - UFA.unsafeSetObject($frame, localIdx, value); - } - - private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - hook_transferToInterpreterAndInvalidate($this); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); - } - - private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 5 /* BOOLEAN */) { - try { - UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - hook_transferToInterpreterAndInvalidate($this); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); - } - - private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 1 /* LONG */) { - try { - UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - hook_transferToInterpreterAndInvalidate($this); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); - } - - private static void do_storeLocal_null(SLOperationRootNodeGen $this, Frame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - try { - UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); - } catch (FrameSlotTypeException ex) { - hook_transferToInterpreterAndInvalidate($this); - UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); - } - } - - private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_q_Add0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_q_Add0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLToBoolean_q_Boolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLToBoolean_q_Boolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_q_Boolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLFunctionLiteral_q_Perform_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_q_Perform_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLInvoke_q_Direct_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_q_Direct_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); - } - - private static void SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLWriteProperty_q_WriteSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_q_WriteSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLUnbox_q_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLessThan_q_LessThan0_LessThan1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan0_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessThan_q_LessThan0_LessThan1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan0_LessThan1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLessOrEqual_q_LessOrEqual1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_q_LessOrEqual1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_q_LessOrEqual1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLessThan_q_LessThan1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessThan_q_LessThan1_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_q_LessThan1_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_q_Add0_Add1_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_Add1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_q_Add0_Add1_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_Add1_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLogicalNot_q_Boolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLogicalNot_q_Boolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_q_Boolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromForeign0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromForeign0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromForeign0_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromForeign0_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); - } - - private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { - if (bciOffset != 0) { - setResultBoxedImpl(bc, startBci - bciOffset, targetType); - } - } - - @ExplodeLoop - private static Object[] do_loadVariadicArguments(VirtualFrame $frame, int $sp, int numVariadics) { - CompilerAsserts.partialEvaluationConstant($sp); - CompilerAsserts.partialEvaluationConstant(numVariadics); - Object[] result = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex); - } - return result; - } - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { - bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff)); - } - - private static short unsafeFromBytecode(short[] bc, int index) { - return UFA.unsafeShortArrayRead(bc, index); - } - - private static void unsafeWriteBytecode(short[] bc, int index, short value) { - UFA.unsafeShortArrayWrite(bc, index, value); - } - - private static boolean do_profileCondition(SLOperationRootNodeGen $this, boolean value, int[] profiles, int index) { - int t = UFA.unsafeIntArrayRead(profiles, index); - int f = UFA.unsafeIntArrayRead(profiles, index + 1); - boolean val = value; - if (val) { - if (t == 0) { - hook_transferToInterpreterAndInvalidate($this); - } - if (f == 0) { - val = true; - } - if (CompilerDirectives.inInterpreter()) { - if (t < 1073741823) { - UFA.unsafeIntArrayWrite(profiles, index, t + 1); - } - } - } else { - if (f == 0) { - hook_transferToInterpreterAndInvalidate($this); - } - if (t == 0) { - val = false; - } - if (CompilerDirectives.inInterpreter()) { - if (f < 1073741823) { - UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1); - } - } - } - if (CompilerDirectives.inInterpreter()) { - return val; - } else { - int sum = t + f; - return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); - } - } - - public static OperationNodes create(OperationConfig config, OperationParser generator) { - OperationNodesImpl nodes = new OperationNodesImpl(generator); - Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(nodes, false, config); - generator.parse(builder); - builder.finish(); - return nodes; - } - - public static OperationNodes deserialize(TruffleLanguage language, OperationConfig config, ByteBuffer input, OperationDeserializer callback) throws IOException { - try { - return create(config, b -> Builder.deserializeParser(language, input, callback, b)); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - } - - public static void serialize(OperationConfig config, DataOutput buffer, OperationSerializer callback, OperationParser generator) throws IOException { - Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - generator.parse(builder); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class ExceptionHandler { - - int startBci; - int startStack; - int endBci; - int exceptionIndex; - int handlerBci; - - ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { - this.startBci = startBci; - this.startStack = startStack; - this.endBci = endBci; - this.exceptionIndex = exceptionIndex; - this.handlerBci = handlerBci; - } - - ExceptionHandler() { - } - - ExceptionHandler offset(int offset, int stackOffset) { - return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); - } - - @Override - public String toString() { - return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private abstract static class BytecodeLoopBase { - - abstract int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); - - abstract String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); - - abstract void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); - - protected static String formatConstant(Object obj) { - if (obj == null) { - return "null"; - } else { - Object repr = obj; - if (obj instanceof Object[]) { - repr = Arrays.deepToString((Object[]) obj); - } - return String.format("%s %s", obj.getClass().getSimpleName(), repr); - } - } - - protected static Object expectObject(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) { - if (bciOffset == 0 || UFA.unsafeIsObject(frame, slot)) { - return UFA.unsafeUncheckedGetObject(frame, slot); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - return frame.getValue(slot); - } - } - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { - bc[bci] = (short) ((targetType << 13) | (bc[bci] & 0x1fff)); - } - - protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { - if (bciOffset == 0) { - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - return (boolean) value; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(value); - } - } else { - switch (UFA.unsafeGetTag(frame, slot)) { - case 5 /* BOOLEAN */ : - return UFA.unsafeUncheckedGetBoolean(frame, slot); - case 0 /* OBJECT */ : - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); - return (boolean) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - throw new UnexpectedResultException(frame.getValue(slot)); - } - } - - protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { - if (bciOffset == 0) { - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - return (long) value; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(value); - } - } else { - switch (UFA.unsafeGetTag(frame, slot)) { - case 1 /* LONG */ : - return UFA.unsafeUncheckedGetLong(frame, slot); - case 0 /* OBJECT */ : - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); - return (long) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - throw new UnexpectedResultException(frame.getValue(slot)); - } - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationNodesImpl extends OperationNodes { - - OperationNodesImpl(OperationParser parse) { - super(parse); - } - - @Override - protected void reparseImpl(OperationConfig config, OperationParser parse, OperationRootNode[] nodes) { - Builder builder = new Builder(this, true, config); - ((OperationParser) parse).parse(builder); - builder.finish(); - } - - void setSources(Source[] sources) { - this.sources = sources; - } - - Source[] getSources() { - return sources; - } - - void setNodes(SLOperationRootNode[] nodes) { - this.nodes = nodes; - } - - @Override - public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { - Builder builder = new Builder(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - ((OperationParser) parse).parse(builder); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class BytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_POP : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - continue loop; - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case INSTR_BRANCH : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case INSTR_BRANCH_FALSE : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case INSTR_THROW : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_CONSTANT : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - continue loop; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_ARGUMENT : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - continue loop; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case INSTR_LOAD_LOCAL | (0 /* OBJECT */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - continue loop; - } - case INSTR_LOAD_LOCAL | (5 /* BOOLEAN */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - continue loop; - } - case INSTR_LOAD_LOCAL | (1 /* LONG */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - continue loop; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_BOXED | (0 /* OBJECT */ << 13) : - { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_LOAD_LOCAL); - $bci -= LOAD_LOCAL_BOXED_LENGTH; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - continue loop; - } - case INSTR_LOAD_LOCAL_BOXED | (5 /* BOOLEAN */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - continue loop; - } - case INSTR_LOAD_LOCAL_BOXED | (1 /* LONG */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - continue loop; - } - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case INSTR_STORE_LOCAL | (0 /* OBJECT */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - continue loop; - } - case INSTR_STORE_LOCAL | (5 /* BOOLEAN */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - continue loop; - } - case INSTR_STORE_LOCAL | (1 /* LONG */ << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - continue loop; - } - case INSTR_STORE_LOCAL | (7 << 13) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - continue loop; - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_RETURN : - { - return (($sp - 1) << 16) | 0xffff; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - continue loop; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case INSTR_STORE_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - continue loop; - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD | (0 /* OBJECT */ << 13) : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - continue loop; - } - case INSTR_C_SL_ADD | (1 /* LONG */ << 13) : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - continue loop; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case INSTR_C_SL_DIV | (0 /* OBJECT */ << 13) : - { - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - continue loop; - } - case INSTR_C_SL_DIV | (1 /* LONG */ << 13) : - { - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - continue loop; - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case INSTR_C_SL_EQUAL | (0 /* OBJECT */ << 13) : - { - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - continue loop; - } - case INSTR_C_SL_EQUAL | (5 /* BOOLEAN */ << 13) : - { - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - continue loop; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL | (0 /* OBJECT */ << 13) : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_OR_EQUAL | (5 /* BOOLEAN */ << 13) : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - continue loop; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN | (0 /* OBJECT */ << 13) : - { - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_THAN | (5 /* BOOLEAN */ << 13) : - { - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - continue loop; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_LOGICAL_NOT | (0 /* OBJECT */ << 13) : - { - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - continue loop; - } - case INSTR_C_SL_LOGICAL_NOT | (5 /* BOOLEAN */ << 13) : - { - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - continue loop; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case INSTR_C_SL_MUL | (0 /* OBJECT */ << 13) : - { - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - continue loop; - } - case INSTR_C_SL_MUL | (1 /* LONG */ << 13) : - { - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - continue loop; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case INSTR_C_SL_READ_PROPERTY : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - continue loop; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case INSTR_C_SL_SUB | (0 /* OBJECT */ << 13) : - { - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - continue loop; - } - case INSTR_C_SL_SUB | (1 /* LONG */ << 13) : - { - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - continue loop; - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case INSTR_C_SL_WRITE_PROPERTY : - { - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - continue loop; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX | (0 /* OBJECT */ << 13) : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX | (1 /* LONG */ << 13) : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case INSTR_C_SL_FUNCTION_LITERAL : - { - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - continue loop; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_TO_BOOLEAN | (0 /* OBJECT */ << 13) : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - continue loop; - } - case INSTR_C_SL_TO_BOOLEAN | (5 /* BOOLEAN */ << 13) : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - continue loop; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case INSTR_C_SL_INVOKE : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - $bci = $bci + C_SL_INVOKE_LENGTH; - continue loop; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_AND | (0 /* OBJECT */ << 13) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case INSTR_SC_SL_AND | (5 /* BOOLEAN */ << 13) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_OR | (0 /* OBJECT */ << 13) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case INSTR_SC_SL_OR | (5 /* BOOLEAN */ << 13) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // c.SLUnbox.q.FromBigNumber - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromBigNumber.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_LONG | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - continue loop; - } - // c.SLAdd.q.Add0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD_Q_ADD0 | (0 /* OBJECT */ << 13) : - { - SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - continue loop; - } - case INSTR_C_SL_ADD_Q_ADD0 | (1 /* LONG */ << 13) : - { - SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - continue loop; - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - continue loop; - } - // c.SLToBoolean.q.Boolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | (0 /* OBJECT */ << 13) : - { - SLToBoolean_q_Boolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - continue loop; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | (5 /* BOOLEAN */ << 13) : - { - SLToBoolean_q_Boolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - continue loop; - } - // c.SLFunctionLiteral.q.Perform - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - SLFunctionLiteral_q_Perform_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - continue loop; - } - // c.SLInvoke.q.Direct - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0); - SLInvoke_q_Direct_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - continue loop; - } - // c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | (0 /* OBJECT */ << 13) : - { - SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | (5 /* BOOLEAN */ << 13) : - { - SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - continue loop; - } - // c.SLWriteProperty.q.WriteSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - SLWriteProperty_q_WriteSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromTruffleString - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - // c.SLLessThan.q.LessThan0.LessThan1 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | (0 /* OBJECT */ << 13) : - { - SLLessThan_q_LessThan0_LessThan1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | (5 /* BOOLEAN */ << 13) : - { - SLLessThan_q_LessThan0_LessThan1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - continue loop; - } - // c.SLLessOrEqual.q.LessOrEqual1 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | (0 /* OBJECT */ << 13) : - { - SLLessOrEqual_q_LessOrEqual1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | (5 /* BOOLEAN */ << 13) : - { - SLLessOrEqual_q_LessOrEqual1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - continue loop; - } - // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD_Q_ADD_LONG | (0 /* OBJECT */ << 13) : - { - SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - continue loop; - } - case INSTR_C_SL_ADD_Q_ADD_LONG | (1 /* LONG */ << 13) : - { - SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - continue loop; - } - // c.SLLessThan.q.LessThan1 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | (0 /* OBJECT */ << 13) : - { - SLLessThan_q_LessThan1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - continue loop; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | (5 /* BOOLEAN */ << 13) : - { - SLLessThan_q_LessThan1_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromBigNumber.FromTruffleString - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromBigNumber_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromLong.FromTruffleString - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromLong_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromLong_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromLong_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - // c.SLAdd.q.Add0.Add1 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD_Q_ADD0_ADD1 | (0 /* OBJECT */ << 13) : - { - SLAdd_q_Add0_Add1_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - continue loop; - } - case INSTR_C_SL_ADD_Q_ADD0_ADD1 | (1 /* LONG */ << 13) : - { - SLAdd_q_Add0_Add1_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - continue loop; - } - // c.SLLogicalNot.q.Boolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | (0 /* OBJECT */ << 13) : - { - SLLogicalNot_q_Boolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - continue loop; - } - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | (5 /* BOOLEAN */ << 13) : - { - SLLogicalNot_q_Boolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - continue loop; - } - // c.SLUnbox.q.FromForeign0 - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (0 /* OBJECT */ << 13) : - { - SLUnbox_q_FromForeign0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (1 /* LONG */ << 13) : - { - SLUnbox_q_FromForeign0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - continue loop; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | (5 /* BOOLEAN */ << 13) : - { - SLUnbox_q_FromForeign0_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - continue loop; - } - default : - hook_transferToInterpreterAndInvalidate($this); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0_ADD1 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : - { - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - break; - } - } - } - } - - @Override - String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { - int $bci = 0; - StringBuilder sb = new StringBuilder(); - while ($bci < $bc.length) { - sb.append(String.format(" [%04x]", $bci)); - switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { - default : - { - sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); - break; - } - case INSTR_POP : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("pop "); - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch "); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch.false "); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("throw "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0))); - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boxed "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.mat "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.mat "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDiv "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqual "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLMul "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLSub "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLInvoke "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0))); - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLOr "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromLong"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBoolean "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.Add0 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty.q.ReadSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0))); - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty.q.WriteSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromTruffleString "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan0.LessThan1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan1 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0_ADD1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.Add0.Add1 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromForeign0 "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - break; - } - } - sb.append("\n"); - } - for (int i = 0; i < $handlers.length; i++) { - sb.append($handlers[i] + "\n"); - } - return sb.toString(); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLAddNode.addLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b1111) == 0b1/* is-exact-state_0 addLong(long, long) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD_LONG | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); - } - try { - lock.unlock(); - hasLock = false; - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0 | primitiveTagBits)); - } else if ((state_0 & 0b1111) == 0b110/* is-exact-state_0 add(SLBigNumber, SLBigNumber)&&add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0_ADD1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value_, $child1Value_); - } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b1111) == 0b110/* is-exact-state_0 add(SLBigNumber, SLBigNumber)&&add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD_Q_ADD0_ADD1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_ADD | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLDivNode.divLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLDivNode.div($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLDivNode.div($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.leftInterop_.accepts($child0Value)); - // assert (s7_.rightInterop_.accepts($child1Value)); - if (count7_ < (4)) { - s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); - } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessOrEqual(long, long)&&lessOrEqual(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessOrEqual(long, long)&&lessOrEqual(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 | primitiveTagBits)); - } else if ((state_0 & 0b111) == 0b10/* is-exact-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_OR_EQUAL | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessThan(long, long)&&lessThan(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111) == 0b11/* is-exact-state_0 lessThan(long, long)&&lessThan(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 | primitiveTagBits)); - } else if ((state_0 & 0b111) == 0b10/* is-exact-state_0 lessThan(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LESS_THAN | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); - } - - private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLLogicalNotNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { - return SLLogicalNotNode.doBoolean($child0Value_); - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b1/* is-exact-state_0 doBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_LOGICAL_NOT | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLMulNode.mulLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLMulNode.mul($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @ExplodeLoop - private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { - Node node__2 = ($this); - int bci__2 = ($bci); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - try { - return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = ($this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - node__1 = ($this); - bci__1 = ($bci); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - } - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = ($this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); - } - } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { - node__2 = ($this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (s4_.objects_.accepts($child0Value)); - InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); - node__2 = ($this); - bci__2 = ($bci); - s4_.objects_ = s4_.insertAccessor(objects__); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - } - } - { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = ($this); - readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_READ_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLSubNode.subLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLSubNode.sub($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); - if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - try { - return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - int writeArray1_bci__ = 0; - Node writeArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - writeArray1_node__ = ($this); - writeArray1_bci__ = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b100/* is-exact-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - } - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); - } - } - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (s4_.objectLibrary_.accepts($child0Value)); - s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); - node__1 = ($this); - bci__1 = ($bci); - s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = ($this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_WRITE_PROPERTY | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); - if (fromString_fromJavaStringNode__ != null) { - return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLUnboxNode.fromBoolean($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - try { - return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { - return SLUnboxNode.fromBoolean($child0Value_); - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { - return SLUnboxNode.fromLong($child0Value_); - } - hook_transferToInterpreterAndInvalidate($this); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111111111) == 0b10/* is-exact-state_0 fromTruffleString(TruffleString) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b10010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b1010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b1010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromLong($child0Value_); - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b10010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11010/* is-exact-state_0 fromTruffleString(TruffleString)&&fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBigNumber($child0Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.interop_.accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if ((state_0 & 0b111111111) == 0b10000000/* is-exact-state_0 fromForeign(Object, InteropLibrary) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - } - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, s7_.interop_); - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_UNBOX | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); - if (result__ != null) { - return SLFunctionLiteralNode.perform($child0Value__, result__, node__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); - node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b1/* is-exact-state_0 perform(TruffleString, SLFunction, Node) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_FUNCTION_LITERAL | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b1/* is-exact-state_0 doBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_TO_BOOLEAN | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); - Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); - if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - hook_transferToInterpreterAndInvalidate($this); - SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); - } - if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); - if (indirect_callNode__ != null) { - return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = ($this); - int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); - if (interop_library__ != null) { - return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); - } - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); - } - - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); - if (($child0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - s0_.callTargetStable_ = callTargetStable__; - s0_.cachedTarget_ = cachedTarget__; - s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - if (state_0 == 0b1/* is-exact-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE_Q_DIRECT | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); - } - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - } - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = ($this); - interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) (INSTR_C_SL_INVOKE | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); - } - - private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - @ExplodeLoop - private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_READ_PROPERTY); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLToBoolean_q_Boolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLToBoolean_q_Boolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_TO_BOOLEAN); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLToBoolean_q_Boolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_TO_BOOLEAN); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static Object SLFunctionLiteral_q_Perform_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0) + 0)); - if (result__ != null) { - return SLFunctionLiteralNode.perform($child0Value__, result__, node__); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_FUNCTION_LITERAL); - return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - @ExplodeLoop - private static Object SLInvoke_q_Direct_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff)); - Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */; - if ($child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - hook_transferToInterpreterAndInvalidate($this); - SLInvoke_q_Direct_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_INVOKE); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); - } - if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_INVOKE); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); - } - - private static void SLInvoke_q_Direct_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CHILDREN_OFFSET) + 0) + 0)); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_Q_DIRECT_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - @ExplodeLoop - private static Object SLWriteProperty_q_WriteSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_WRITE_PROPERTY); - return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - } - - private static Object SLUnbox_q_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; - if ($child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static boolean SLLessThan_q_LessThan0_LessThan1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessThan_q_LessThan0_LessThan1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static Object SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessThan_q_LessThan0_LessThan1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_q_LessThan0_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static boolean SLLessThan_q_LessThan0_LessThan1_SLLessThan_q_LessThan0_LessThan1_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static boolean SLLessOrEqual_q_LessOrEqual1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessOrEqual_q_LessOrEqual1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_q_LessOrEqual1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_q_LessOrEqual1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_OR_EQUAL); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_AddLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static long SLAdd_q_AddLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - hook_transferToInterpreterAndInvalidate($this); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - - private static boolean SLLessThan_q_LessThan1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessThan_q_LessThan1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessThan_q_LessThan1_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_q_LessThan1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LESS_THAN); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromLong_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromLong_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static boolean SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromLong_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b1010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) */)) { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromLong_FromTruffleString_SLUnbox_q_FromLong_FromTruffleString_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static boolean SLAdd_q_Add0_Add1_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_Add0_Add1_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_q_Add0_Add1_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_Add0_Add1_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLTypesGen.expectLong(SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_)); - } - } - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_ADD); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10010) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11010) != 0 /* is-not fromTruffleString(TruffleString) && fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLTypesGen.expectLong(SLUnboxNode.fromTruffleString($child0Value__)); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static boolean SLLogicalNot_q_Boolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLLogicalNot_q_Boolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LOGICAL_NOT); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); - } - - private static boolean SLLogicalNot_q_Boolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLogicalNot_q_Boolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_LOGICAL_NOT); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); - } - - @ExplodeLoop - private static Object SLUnbox_q_FromForeign0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); - } - s7_ = s7_.next_; - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - @ExplodeLoop - private static boolean SLUnbox_q_FromForeign0_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLTypesGen.expectBoolean(SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); - } - s7_ = s7_.next_; - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - @ExplodeLoop - private static long SLUnbox_q_FromForeign0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromForeign0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLTypesGen.expectLong(SLUnboxNode.fromForeign($child0Value_, s7_.interop_)); - } - s7_ = s7_.next_; - } - hook_transferToInterpreterAndInvalidate($this); - unsafeWriteBytecode($bc, $bci, INSTR_C_SL_UNBOX); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - hook_transferToInterpreterAndInvalidate($this); - int uncachedExecuteCount = $this.uncachedExecuteCount; - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_POP : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - continue loop; - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case INSTR_BRANCH : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - uncachedExecuteCount--; - if (uncachedExecuteCount <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case INSTR_BRANCH_FALSE : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case INSTR_THROW : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_CONSTANT : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - continue loop; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_ARGUMENT : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - continue loop; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case INSTR_LOAD_LOCAL : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - continue loop; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_BOXED : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - continue loop; - } - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case INSTR_STORE_LOCAL : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - continue loop; - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_RETURN : - { - uncachedExecuteCount--; - if (uncachedExecuteCount <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount; - } - return (($sp - 1) << 16) | 0xffff; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - continue loop; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case INSTR_STORE_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - continue loop; - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD : - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - continue loop; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case INSTR_C_SL_DIV : - { - SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - continue loop; - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case INSTR_C_SL_EQUAL : - { - SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - continue loop; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL : - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - continue loop; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN : - { - SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - continue loop; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_LOGICAL_NOT : - { - SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - continue loop; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case INSTR_C_SL_MUL : - { - SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - continue loop; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case INSTR_C_SL_READ_PROPERTY : - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - continue loop; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case INSTR_C_SL_SUB : - { - SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - continue loop; - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case INSTR_C_SL_WRITE_PROPERTY : - { - SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - continue loop; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX : - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - continue loop; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case INSTR_C_SL_FUNCTION_LITERAL : - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - continue loop; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_TO_BOOLEAN : - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - continue loop; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case INSTR_C_SL_INVOKE : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - $bci = $bci + C_SL_INVOKE_LENGTH; - continue loop; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_AND : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_OR : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - default : - hook_transferToInterpreterAndInvalidate($this); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : - { - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0_ADD1 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : - { - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - break; - } - } - } - } - - @Override - String dump(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { - int $bci = 0; - StringBuilder sb = new StringBuilder(); - while ($bci < $bc.length) { - sb.append(String.format(" [%04x]", $bci)); - switch (unsafeFromBytecode($bc, $bci) & 0x1fff) { - default : - { - sb.append(String.format(" unknown 0x%02x", $bc[$bci++])); - break; - } - case INSTR_POP : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("pop "); - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch "); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("branch.false "); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("throw "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0))); - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.constant "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]))); - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.argument "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.boxed "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local "); - sb.append(String.format(" local(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("return "); - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("load.local.mat "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("store.local.mat "); - sb.append(String.format(" arg(%s)", unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLDiv "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLEqual "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLMul "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLSub "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLInvoke "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0))); - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLAnd "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("sc.SLOr "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" branch(%04x)", unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0))); - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromLong"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBoolean "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.Add0 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLReadProperty.q.ReadSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLToBoolean.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_TO_BOOLEAN_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL_Q_PERFORM : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLFunctionLiteral.q.Perform "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_FUNCTION_LITERAL_Q_PERFORM_LENGTH; - break; - } - case INSTR_C_SL_INVOKE_Q_DIRECT : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLInvoke.q.Direct "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" var(%s)", unsafeFromBytecode($bc, $bci + C_SL_INVOKE_Q_DIRECT_VARIADIC_OFFSET + 0))); - $bci = $bci + C_SL_INVOKE_Q_DIRECT_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual0.LessOrEqual1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL0_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(String.format(" %04x", $bc[$bci + 6])); - sb.append(" "); - sb.append("c.SLWriteProperty.q.WriteSLObject0"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_CONSTANT_OFFSET) + 1]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_POP_INDEXED_OFFSET + 1) & 0xff))); - $bci = $bci + C_SL_WRITE_PROPERTY_Q_WRITE_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromTruffleString "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan0.LessThan1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN0_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessOrEqual.q.LessOrEqual1"); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_OR_EQUAL_Q_LESS_OR_EQUAL1_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.AddLong "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN_Q_LESS_THAN1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLessThan.q.LessThan1 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_Q_LESS_THAN1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_LESS_THAN_Q_LESS_THAN1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromLong.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0_ADD1 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(String.format(" %04x", $bc[$bci + 5])); - sb.append(" "); - sb.append(" "); - sb.append("c.SLAdd.q.Add0.Add1 "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) & 0xff))); - sb.append(String.format(" pop(-%s)", ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_ADD1_POP_INDEXED_OFFSET + 0) >> 8) & 0xff))); - $bci = $bci + C_SL_ADD_Q_ADD0_ADD1_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromBigNumber.FromLong.FromTruffleString"); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_FROM_TRUFFLE_STRING_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT_Q_BOOLEAN : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLLogicalNot.q.Boolean "); - sb.append(String.format(" const(%s)", formatConstant($consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_CONSTANT_OFFSET) + 0]))); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_LOGICAL_NOT_Q_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_FOREIGN0 : - { - sb.append(String.format(" %04x", $bc[$bci + 0])); - sb.append(String.format(" %04x", $bc[$bci + 1])); - sb.append(String.format(" %04x", $bc[$bci + 2])); - sb.append(String.format(" %04x", $bc[$bci + 3])); - sb.append(String.format(" %04x", $bc[$bci + 4])); - sb.append(" "); - sb.append(" "); - sb.append(" "); - sb.append("c.SLUnbox.q.FromForeign0 "); - sb.append(String.format(" pop(-%s)", (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_POP_INDEXED_OFFSET + 0) & 0xff))); - $bci = $bci + C_SL_UNBOX_Q_FROM_FOREIGN0_LENGTH; - break; - } - } - sb.append("\n"); - } - for (int i = 0; i < $handlers.length; i++) { - sb.append($handlers[i] + "\n"); - } - return sb.toString(); - } - - private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLDivNode.div($child0Value_, $child1Value_); - } - } - return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - - private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLAdd_q_Add0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLToBoolean_q_Boolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLFunctionLiteral_q_Perform_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLInvoke_q_Direct_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static Object SLLessOrEqual_q_LessOrEqual0_LessOrEqual1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_q_WriteSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_q_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLLessThan_q_LessThan0_LessThan1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessOrEqual_q_LessOrEqual1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessThan_q_LessThan1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromBigNumber_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromLong_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLAdd_q_Add0_Add1_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_FromTruffleString_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLLogicalNot_q_Boolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromForeign0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - hook_transferToInterpreterAndInvalidate($this); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - public static final class Builder extends OperationBuilder { - - private static final int OP_BLOCK = 1; - private static final int OP_ROOT = 2; - private static final int OP_IF_THEN = 3; - private static final int OP_IF_THEN_ELSE = 4; - private static final int OP_CONDITIONAL = 5; - private static final int OP_WHILE = 6; - private static final int OP_TRY_CATCH = 7; - private static final int OP_FINALLY_TRY = 8; - private static final int OP_FINALLY_TRY_NO_EXCEPT = 9; - private static final int OP_LABEL = 10; - private static final int OP_BRANCH = 11; - private static final int OP_LOAD_CONSTANT = 12; - private static final int OP_LOAD_ARGUMENT = 13; - private static final int OP_LOAD_LOCAL = 14; - private static final int OP_STORE_LOCAL = 15; - private static final int OP_RETURN = 16; - private static final int OP_LOAD_LOCAL_MATERIALIZED = 17; - private static final int OP_STORE_LOCAL_MATERIALIZED = 18; - private static final int OP_SOURCE = 19; - private static final int OP_SOURCE_SECTION = 20; - private static final int OP_TAG = 21; - private static final int OP_SL_ADD = 22; - private static final int OP_SL_DIV = 23; - private static final int OP_SL_EQUAL = 24; - private static final int OP_SL_LESS_OR_EQUAL = 25; - private static final int OP_SL_LESS_THAN = 26; - private static final int OP_SL_LOGICAL_NOT = 27; - private static final int OP_SL_MUL = 28; - private static final int OP_SL_READ_PROPERTY = 29; - private static final int OP_SL_SUB = 30; - private static final int OP_SL_WRITE_PROPERTY = 31; - private static final int OP_SL_UNBOX = 32; - private static final int OP_SL_FUNCTION_LITERAL = 33; - private static final int OP_SL_TO_BOOLEAN = 34; - private static final int OP_SL_INVOKE = 35; - private static final int OP_SL_AND = 36; - private static final int OP_SL_OR = 37; - - private final com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes; - private final boolean isReparse; - private final boolean withSource; - private final boolean withInstrumentation; - private final SourceInfoBuilder sourceBuilder; - private short[] bc = new short[65535]; - private int bci; - private int curStack; - private int maxStack; - private int numLocals; - private int numLabels; - private ArrayList constPool = new ArrayList<>(); - private BuilderOperationData operationData; - private ArrayList labels = new ArrayList<>(); - private ArrayList labelFills = new ArrayList<>(); - private int numChildNodes; - private int numConditionProfiles; - private ArrayList exceptionHandlers = new ArrayList<>(); - private BuilderFinallyTryContext currentFinallyTry; - private int buildIndex; - private boolean isSerializing; - private DataOutput serBuffer; - private OperationSerializer serCallback; - private int[] stackSourceBci = new int[1024]; - private BuilderState parentData; - private SerializerContext SER_CONTEXT = new SerializerContext() { - @Override - public void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException { - buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); - } - } - ; - private final ArrayList builtNodes; - private int lastChildPush; - private TruffleString metadata_MethodName; - - private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { - this.nodes = nodes; - this.isReparse = isReparse; - builtNodes = new ArrayList<>(); - if (isReparse) { - builtNodes.addAll((java.util.Collection) nodes.getNodes()); - } - this.withSource = config.isWithSource(); - this.withInstrumentation = config.isWithInstrumentation(); - this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; - } - - private void finish() { - if (withSource) { - nodes.setSources(sourceBuilder.buildSource()); - } - if (!isReparse) { - nodes.setNodes(builtNodes.toArray(new SLOperationRootNode[0])); - } - } - - private void reset(TruffleLanguage language) { - bci = 0; - curStack = 0; - maxStack = 0; - numLocals = 0; - constPool.clear(); - operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language); - labelFills.clear(); - numChildNodes = 0; - numConditionProfiles = 0; - exceptionHandlers.clear(); - metadata_MethodName = null; - } - - private int[] doBeforeEmitInstruction(int numPops, boolean pushValue, boolean doBoxing) { - int[] result = new int[numPops]; - for (int i = numPops - 1; i >= 0; i--) { - curStack--; - int predBci = stackSourceBci[curStack]; - result[i] = predBci; - } - if (pushValue) { - if (curStack >= stackSourceBci.length) { - stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); - } - stackSourceBci[curStack] = doBoxing ? bci : -65535; - curStack++; - if (curStack > maxStack) { - maxStack = curStack; - } - } - return result; - } - - private void doLeaveFinallyTry(BuilderOperationData opData) { - BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; - if (context.handlerBc == null) { - return; - } - System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); - for (int offset : context.relocationOffsets) { - short oldOffset = bc[bci + offset]; - bc[bci + offset] = (short) (oldOffset + bci); - } - for (ExceptionHandler handler : context.handlerHandlers) { - exceptionHandlers.add(handler.offset(bci, curStack)); - } - for (LabelFill fill : context.handlerLabelFills) { - labelFills.add(fill.offset(bci)); - } - if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; - bci += context.handlerBc.length; - } - - private void doEmitLabel(OperationLabel label) { - OperationLabelImpl lbl = (OperationLabelImpl) label; - if (lbl.hasValue) { - throw new UnsupportedOperationException("label already emitted"); - } - if (operationData != lbl.data) { - throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); - } - lbl.hasValue = true; - lbl.targetBci = bci; - } - - private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { - if (toData != null && fromData.depth < toData.depth) { - throw new UnsupportedOperationException("illegal jump to deeper operation"); - } - if (fromData == toData) { - return; - } - BuilderOperationData cur = fromData; - while (true) { - doLeaveOperation(cur); - cur = cur.parent; - if (toData == null && cur == null) { - break; - } else if (toData != null && cur.depth <= toData.depth) break; - } - if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); - } - - private void calculateLeaves(BuilderOperationData fromData) { - calculateLeaves(fromData, (BuilderOperationData) null); - } - - private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { - calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); - } - - public OperationLocal createLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -3); - return new OperationLocalImpl(null, numLocals++); - } catch (IOException ex) { - throw new IOError(ex); - } - } - return new OperationLocalImpl(operationData, numLocals++); - } - - private OperationLocalImpl createParentLocal() { - return new OperationLocalImpl(operationData.parent, numLocals++); - } - - public OperationLabel createLabel() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -2); - return new OperationSerLabelImpl(numLabels++); - } catch (IOException ex) { - throw new IOError(ex); - } - } - OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); - labels.add(label); - return label; - } - - private short getLocalIndex(Object value) { - OperationLocalImpl local = (OperationLocalImpl) value; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return (short) local.id; - } - - private int[] getLocalIndices(Object value) { - OperationLocal[] locals = (OperationLocal[]) value; - int[] result = new int[locals.length]; - for (int i = 0; i < locals.length; i++) { - result[i] = getLocalIndex(locals[i]); - } - return result; - } - - private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { - BuilderOperationData cur = child; - while (cur.depth > parent.depth) { - cur = cur.parent; - } - return cur == parent; - } - - private SLOperationRootNode publish(TruffleLanguage language) { - if (isSerializing) { - SLOperationRootNode result = new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++); - numLocals = 0; - numLabels = 0; - return result; - } - if (operationData.depth != 0) { - throw new UnsupportedOperationException("Not all operations closed"); - } - SLOperationRootNodeGen result; - if (!isReparse) { - FrameDescriptor .Builder frameDescriptor; - frameDescriptor = FrameDescriptor.newBuilder(numLocals + maxStack); - frameDescriptor.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); - result = new SLOperationRootNodeGen(language, frameDescriptor); - result.nodes = nodes; - labelPass(null); - result._bc = Arrays.copyOf(bc, bci); - result._consts = constPool.toArray(); - result._children = new Node[numChildNodes]; - result._localTags = new byte[numLocals]; - result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); - result._conditionProfiles = new int[numConditionProfiles]; - result._maxLocals = numLocals; - result._maxStack = maxStack; - if (sourceBuilder != null) { - result.sourceInfo = sourceBuilder.build(); - } - result._metadata_MethodName = metadata_MethodName; - assert builtNodes.size() == buildIndex; - builtNodes.add(result); - } else { - result = builtNodes.get(buildIndex); - if (withSource && result.sourceInfo == null) { - result.sourceInfo = sourceBuilder.build(); - } - } - buildIndex++; - reset(language); - return result; - } - - private void labelPass(BuilderFinallyTryContext finallyTry) { - for (LabelFill fill : labelFills) { - if (finallyTry != null) { - if (fill.label.belongsTo(finallyTry)) { - assert fill.label.hasValue : "inner label should have been resolved by now"; - finallyTry.relocationOffsets.add(fill.locationBci); - } else { - finallyTry.handlerLabelFills.add(fill); - } - } - bc[fill.locationBci] = (short) fill.label.targetBci; - } - } - - private void doLeaveOperation(BuilderOperationData data) { - switch (data.operationId) { - case OP_FINALLY_TRY : - { - doLeaveFinallyTry(data); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - doLeaveFinallyTry(data); - break; - } - case OP_TAG : - { - break; - } - } - } - - @SuppressWarnings("unused") - private void doBeforeChild() { - int childIndex = operationData.numChildren; - switch (operationData.operationId) { - case OP_BLOCK : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_ROOT : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_TRY_CATCH : - { - if (childIndex == 1) { - curStack = ((ExceptionHandler) operationData.aux[0]).startStack; - ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; - } - break; - } - case OP_SOURCE : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_SOURCE_SECTION : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_TAG : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_SL_AND : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_SC_SL_AND); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - bci = bci + SC_SL_AND_LENGTH; - } - break; - } - case OP_SL_OR : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_SC_SL_OR); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - bci = bci + SC_SL_OR_LENGTH; - } - break; - } - } - } - - @SuppressWarnings("unused") - private void doAfterChild() { - int childIndex = operationData.numChildren++; - switch (operationData.operationId) { - case OP_IF_THEN : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = endLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + BRANCH_FALSE_LENGTH; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } - break; - } - case OP_IF_THEN_ELSE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + BRANCH_FALSE_LENGTH; - } else if (childIndex == 1) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_CONDITIONAL : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + BRANCH_FALSE_LENGTH; - } else if (childIndex == 1) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - assert lastChildPush == 1; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_WHILE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH_FALSE); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - bci = bci + BRANCH_FALSE_LENGTH; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_TRY_CATCH : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - ((ExceptionHandler) operationData.aux[0]).endBci = bci; - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); - bci = bci + BRANCH_LENGTH; - } else { - } - break; - } - case OP_FINALLY_TRY : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.aux[2]); - exceptionHandlers.add(beh); - operationData.aux[1] = beh; - } - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_POP); - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - } - break; - } - } - } - - @SuppressWarnings("unused") - public void beginBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BLOCK << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); - lastChildPush = 0; - } - - @SuppressWarnings("unused") - public void endBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_BLOCK) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); - } - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginRoot(TruffleLanguage arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_ROOT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - lastChildPush = 0; - this.parentData = new BuilderState(this); - this.bc = new short[65535]; - this.constPool = new ArrayList<>(); - this.labels = new ArrayList<>(); - this.labelFills = new ArrayList<>(); - this.exceptionHandlers = new ArrayList<>(); - this.stackSourceBci = new int[1024]; - reset(arg0); - } - - @SuppressWarnings("unused") - public SLOperationRootNode endRoot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_ROOT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return publish(null); - } - if (operationData.operationId != OP_ROOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Root expected at least 0 children, got " + numChildren); - } - lastChildPush = 0; - SLOperationRootNode endCodeResult; - endCodeResult = publish((TruffleLanguage) operationData.arguments[0]); - this.bc = parentData.bc; - this.bci = parentData.bci; - this.curStack = parentData.curStack; - this.maxStack = parentData.maxStack; - this.numLocals = parentData.numLocals; - this.numLabels = parentData.numLabels; - this.constPool = parentData.constPool; - this.operationData = parentData.operationData; - this.labels = parentData.labels; - this.labelFills = parentData.labelFills; - this.numChildNodes = parentData.numChildNodes; - this.numConditionProfiles = parentData.numConditionProfiles; - this.exceptionHandlers = parentData.exceptionHandlers; - this.currentFinallyTry = parentData.currentFinallyTry; - this.stackSourceBci = parentData.stackSourceBci; - this.parentData = parentData.parentData; - return endCodeResult; - } - - @SuppressWarnings("unused") - public void beginIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); - } - - @SuppressWarnings("unused") - public void endIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); - } - - @SuppressWarnings("unused") - public void endIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN_ELSE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); - } - - @SuppressWarnings("unused") - public void endConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_CONDITIONAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); - } - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_WHILE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = startLabel; - } - - @SuppressWarnings("unused") - public void endWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_WHILE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("While expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginTryCatch(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); - exceptionHandlers.add(beh); - operationData.aux[0] = beh; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - } - - @SuppressWarnings("unused") - public void endTryCatch() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_TRY_CATCH) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); - operationData.aux[2] = createParentLocal(); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - public void endFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); - } - int endBci = bci; - doLeaveFinallyTry(operationData); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - { - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bci = bci + BRANCH_LENGTH; - } - ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); - beh.endBci = endBci; - beh.handlerBci = bci; - doLeaveFinallyTry(operationData); - { - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_THROW); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); - bci = bci + THROW_LENGTH; - } - doEmitLabel(endLabel); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - public void endFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); - } - doLeaveFinallyTry(operationData); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLabel(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LABEL << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - doEmitLabel(arg0); - lastChildPush = 0; - doAfterChild(); - } - - public void emitBranch(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BRANCH << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); - calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_BRANCH); - labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); - bci = bci + BRANCH_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadConstant(Object arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_LOAD_CONSTANT << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_CONSTANT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, false); - unsafeWriteBytecode(bc, bci, INSTR_LOAD_CONSTANT); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(operationData.arguments[0]); - bci = bci + LOAD_CONSTANT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadArgument(int arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); - serBuffer.writeInt(arg0); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, false); - unsafeWriteBytecode(bc, bci, INSTR_LOAD_ARGUMENT); - bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; - bci = bci + LOAD_ARGUMENT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, true); - unsafeWriteBytecode(bc, bci, INSTR_LOAD_LOCAL); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - bci = bci + LOAD_LOCAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginStoreLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endStoreLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_STORE_LOCAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_STORE_LOCAL); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bci = bci + STORE_LOCAL_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_RETURN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_RETURN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("Return expected 1 children, got " + numChildren); - } - calculateLeaves(operationData); - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, INSTR_RETURN); - bci = bci + RETURN_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginLoadLocalMaterialized(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_LOCAL_MATERIALIZED << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endLoadLocalMaterialized() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_LOAD_LOCAL_MATERIALIZED << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_LOAD_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("LoadLocalMaterialized expected 1 children, got " + numChildren); - } - doBeforeEmitInstruction(1, true, false); - unsafeWriteBytecode(bc, bci, INSTR_LOAD_LOCAL_MAT); - bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; - bci = bci + LOAD_LOCAL_MAT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginStoreLocalMaterialized(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_STORE_LOCAL_MATERIALIZED << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endStoreLocalMaterialized() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_STORE_LOCAL_MATERIALIZED << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_STORE_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("StoreLocalMaterialized expected 2 children, got " + numChildren); - } - doBeforeEmitInstruction(2, false, false); - unsafeWriteBytecode(bc, bci, INSTR_STORE_LOCAL_MAT); - bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; - bci = bci + STORE_LOCAL_MAT_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSource(Source arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_SOURCE << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); - sourceBuilder.beginSource(bci, arg0); - } - } - - @SuppressWarnings("unused") - public void endSource() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSource(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginSourceSection(int arg0, int arg1) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); - serBuffer.writeInt(arg0); - serBuffer.writeInt(arg1); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); - sourceBuilder.beginSourceSection(bci, arg0, arg1); - } - } - - @SuppressWarnings("unused") - public void endSourceSection() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE_SECTION) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSourceSection(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginTag(Class arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_TAG << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withInstrumentation) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); - int curInstrumentId = 0; - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = curInstrumentId; - operationData.aux[1] = startLabel; - operationData.aux[2] = endLabel; - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_ENTER); - bci = bci + INSTRUMENT_ENTER_LENGTH; - lastChildPush = 0; - } - } - - @SuppressWarnings("unused") - public void endTag() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withInstrumentation) { - if (operationData.operationId != OP_TAG) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); - } - if (lastChildPush != 0) { - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_EXIT_VOID); - bci = bci + INSTRUMENT_EXIT_VOID_LENGTH; - } else { - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, INSTR_INSTRUMENT_EXIT); - bci = bci + INSTRUMENT_EXIT_LENGTH; - } - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_ADD << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_ADD) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_ADD); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 2; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + C_SL_ADD_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_DIV << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_DIV) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_DIV); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + C_SL_DIV_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_EQUAL); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 4; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - bci = bci + C_SL_EQUAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_LESS_OR_EQUAL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bci = bci + C_SL_LESS_OR_EQUAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_THAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_LESS_THAN); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bci = bci + C_SL_LESS_THAN_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LOGICAL_NOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_LOGICAL_NOT); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + C_SL_LOGICAL_NOT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_MUL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_MUL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_MUL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + C_SL_MUL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_READ_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, false); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_READ_PROPERTY); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 12; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + C_SL_READ_PROPERTY_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_SUB << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_SUB) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_SUB); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - bci = bci + C_SL_SUB_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_WRITE_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(3, true, false); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_WRITE_PROPERTY); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 11; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); - bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - bci = bci + C_SL_WRITE_PROPERTY_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_UNBOX) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_UNBOX); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 3; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - bci = bci + C_SL_UNBOX_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, false); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_FUNCTION_LITERAL); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + C_SL_FUNCTION_LITERAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_TO_BOOLEAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_TO_BOOLEAN); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - bci = bci + C_SL_TO_BOOLEAN_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_INVOKE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(numChildren - 1 + 0, true, false); - unsafeWriteBytecode(bc, bci, INSTR_C_SL_INVOKE); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 5; - bc[bci + 4] = (short) (numChildren - 1); - bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - bci = bci + C_SL_INVOKE_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_AND << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - public void endSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_AND) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_OR << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - public void endSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_OR) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void setMethodName(TruffleString value) { - if (isSerializing) { - try { - serBuffer.writeShort((short) -6); - serBuffer.writeShort(0); - serCallback.serialize(SER_CONTEXT, serBuffer, value); - return; - } catch (IOException ex) { - throw new IOError(ex); - } - } - metadata_MethodName = value; - } - - private static void deserializeParser(TruffleLanguage language, ByteBuffer buffer, OperationDeserializer callback, com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder builder) { - try { - ArrayList consts = new ArrayList<>(); - ArrayList locals = new ArrayList<>(); - ArrayList labels = new ArrayList<>(); - ArrayList builtNodes = new ArrayList<>(); - buffer.rewind(); - DataInput dataInput = com.oracle.truffle.api.operation.serialization.ByteBufferDataInput.createDataInput(buffer); - DeserializerContext context = new DeserializerContext(){ - @Override - public SLOperationRootNode deserializeOperationNode(DataInput buffer) throws IOException { - return builtNodes.get(buffer.readInt()); - } - } - ; - while (true) { - switch (buffer.getShort()) { - case -2 : - { - labels.add(builder.createLabel()); - break; - } - case -3 : - { - locals.add(builder.createLocal()); - break; - } - case -4 : - { - consts.add(callback.deserialize(context, dataInput)); - break; - } - case -5 : - { - return; - } - case -6 : - { - switch (buffer.getShort()) { - case 0 : - builder.setMethodName((TruffleString) callback.deserialize(context, dataInput)); - break; - } - break; - } - case OP_BLOCK << 1 : - { - builder.beginBlock(); - break; - } - case (OP_BLOCK << 1) | 1 : - { - builder.endBlock(); - break; - } - case OP_ROOT << 1 : - { - TruffleLanguage arg0 = language; - builder.beginRoot(arg0); - break; - } - case (OP_ROOT << 1) | 1 : - { - builtNodes.add(builder.endRoot()); - break; - } - case OP_IF_THEN << 1 : - { - builder.beginIfThen(); - break; - } - case (OP_IF_THEN << 1) | 1 : - { - builder.endIfThen(); - break; - } - case OP_IF_THEN_ELSE << 1 : - { - builder.beginIfThenElse(); - break; - } - case (OP_IF_THEN_ELSE << 1) | 1 : - { - builder.endIfThenElse(); - break; - } - case OP_CONDITIONAL << 1 : - { - builder.beginConditional(); - break; - } - case (OP_CONDITIONAL << 1) | 1 : - { - builder.endConditional(); - break; - } - case OP_WHILE << 1 : - { - builder.beginWhile(); - break; - } - case (OP_WHILE << 1) | 1 : - { - builder.endWhile(); - break; - } - case OP_TRY_CATCH << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginTryCatch(arg0); - break; - } - case (OP_TRY_CATCH << 1) | 1 : - { - builder.endTryCatch(); - break; - } - case OP_FINALLY_TRY << 1 : - { - builder.beginFinallyTry(); - break; - } - case (OP_FINALLY_TRY << 1) | 1 : - { - builder.endFinallyTry(); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT << 1 : - { - builder.beginFinallyTryNoExcept(); - break; - } - case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : - { - builder.endFinallyTryNoExcept(); - break; - } - case OP_LABEL << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitLabel(arg0); - break; - } - case OP_BRANCH << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitBranch(arg0); - break; - } - case OP_LOAD_CONSTANT << 1 : - { - Object arg0 = (Object) consts.get(buffer.getShort()); - builder.emitLoadConstant(arg0); - break; - } - case OP_LOAD_ARGUMENT << 1 : - { - int arg0 = buffer.getInt(); - builder.emitLoadArgument(arg0); - break; - } - case OP_LOAD_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.emitLoadLocal(arg0); - break; - } - case OP_STORE_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginStoreLocal(arg0); - break; - } - case (OP_STORE_LOCAL << 1) | 1 : - { - builder.endStoreLocal(); - break; - } - case OP_RETURN << 1 : - { - builder.beginReturn(); - break; - } - case (OP_RETURN << 1) | 1 : - { - builder.endReturn(); - break; - } - case OP_LOAD_LOCAL_MATERIALIZED << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginLoadLocalMaterialized(arg0); - break; - } - case (OP_LOAD_LOCAL_MATERIALIZED << 1) | 1 : - { - builder.endLoadLocalMaterialized(); - break; - } - case OP_STORE_LOCAL_MATERIALIZED << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginStoreLocalMaterialized(arg0); - break; - } - case (OP_STORE_LOCAL_MATERIALIZED << 1) | 1 : - { - builder.endStoreLocalMaterialized(); - break; - } - case OP_SOURCE << 1 : - { - Source arg0 = (Source) consts.get(buffer.getShort()); - builder.beginSource(arg0); - break; - } - case (OP_SOURCE << 1) | 1 : - { - builder.endSource(); - break; - } - case OP_SOURCE_SECTION << 1 : - { - int arg0 = buffer.getInt(); - int arg1 = buffer.getInt(); - builder.beginSourceSection(arg0, arg1); - break; - } - case (OP_SOURCE_SECTION << 1) | 1 : - { - builder.endSourceSection(); - break; - } - case OP_TAG << 1 : - { - Class arg0 = (Class) consts.get(buffer.getShort()); - builder.beginTag(arg0); - break; - } - case (OP_TAG << 1) | 1 : - { - builder.endTag(); - break; - } - case OP_SL_ADD << 1 : - { - builder.beginSLAdd(); - break; - } - case (OP_SL_ADD << 1) | 1 : - { - builder.endSLAdd(); - break; - } - case OP_SL_DIV << 1 : - { - builder.beginSLDiv(); - break; - } - case (OP_SL_DIV << 1) | 1 : - { - builder.endSLDiv(); - break; - } - case OP_SL_EQUAL << 1 : - { - builder.beginSLEqual(); - break; - } - case (OP_SL_EQUAL << 1) | 1 : - { - builder.endSLEqual(); - break; - } - case OP_SL_LESS_OR_EQUAL << 1 : - { - builder.beginSLLessOrEqual(); - break; - } - case (OP_SL_LESS_OR_EQUAL << 1) | 1 : - { - builder.endSLLessOrEqual(); - break; - } - case OP_SL_LESS_THAN << 1 : - { - builder.beginSLLessThan(); - break; - } - case (OP_SL_LESS_THAN << 1) | 1 : - { - builder.endSLLessThan(); - break; - } - case OP_SL_LOGICAL_NOT << 1 : - { - builder.beginSLLogicalNot(); - break; - } - case (OP_SL_LOGICAL_NOT << 1) | 1 : - { - builder.endSLLogicalNot(); - break; - } - case OP_SL_MUL << 1 : - { - builder.beginSLMul(); - break; - } - case (OP_SL_MUL << 1) | 1 : - { - builder.endSLMul(); - break; - } - case OP_SL_READ_PROPERTY << 1 : - { - builder.beginSLReadProperty(); - break; - } - case (OP_SL_READ_PROPERTY << 1) | 1 : - { - builder.endSLReadProperty(); - break; - } - case OP_SL_SUB << 1 : - { - builder.beginSLSub(); - break; - } - case (OP_SL_SUB << 1) | 1 : - { - builder.endSLSub(); - break; - } - case OP_SL_WRITE_PROPERTY << 1 : - { - builder.beginSLWriteProperty(); - break; - } - case (OP_SL_WRITE_PROPERTY << 1) | 1 : - { - builder.endSLWriteProperty(); - break; - } - case OP_SL_UNBOX << 1 : - { - builder.beginSLUnbox(); - break; - } - case (OP_SL_UNBOX << 1) | 1 : - { - builder.endSLUnbox(); - break; - } - case OP_SL_FUNCTION_LITERAL << 1 : - { - builder.beginSLFunctionLiteral(); - break; - } - case (OP_SL_FUNCTION_LITERAL << 1) | 1 : - { - builder.endSLFunctionLiteral(); - break; - } - case OP_SL_TO_BOOLEAN << 1 : - { - builder.beginSLToBoolean(); - break; - } - case (OP_SL_TO_BOOLEAN << 1) | 1 : - { - builder.endSLToBoolean(); - break; - } - case OP_SL_INVOKE << 1 : - { - builder.beginSLInvoke(); - break; - } - case (OP_SL_INVOKE << 1) | 1 : - { - builder.endSLInvoke(); - break; - } - case OP_SL_AND << 1 : - { - builder.beginSLAnd(); - break; - } - case (OP_SL_AND << 1) | 1 : - { - builder.endSLAnd(); - break; - } - case OP_SL_OR << 1 : - { - builder.beginSLOr(); - break; - } - case (OP_SL_OR << 1) | 1 : - { - builder.endSLOr(); - break; - } - } - } - } catch (IOException ex) { - throw new IOError(ex); - } - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class BuilderOperationData { - - final BuilderOperationData parent; - final int operationId; - final int stackDepth; - final boolean needsLeave; - final int depth; - final Object[] arguments; - final Object[] aux; - int numChildren; - - private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { - this.parent = parent; - this.operationId = operationId; - this.stackDepth = stackDepth; - this.depth = parent == null ? 0 : parent.depth + 1; - this.aux = numAux > 0 ? new Object[numAux] : null; - this.needsLeave = needsLeave || (parent != null && parent.needsLeave); - this.arguments = arguments; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationLabelImpl extends OperationLabel { - - BuilderOperationData data; - BuilderFinallyTryContext finallyTry; - int targetBci = 0; - boolean hasValue = false; - - OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { - this.data = data; - this.finallyTry = finallyTry; - } - - boolean belongsTo(BuilderFinallyTryContext context) { - BuilderFinallyTryContext cur = finallyTry; - while (cur != null) { - if (cur == context) { - return true; - } - cur = cur.prev; - } - return false; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationSerLabelImpl extends OperationLabel { - - int id; - - OperationSerLabelImpl(int id) { - this.id = id; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationLocalImpl extends OperationLocal { - - final BuilderOperationData owner; - final int id; - - OperationLocalImpl(BuilderOperationData owner, int id) { - this.owner = owner; - this.id = id; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class LabelFill { - - int locationBci; - OperationLabelImpl label; - - LabelFill(int locationBci, OperationLabelImpl label) { - this.locationBci = locationBci; - this.label = label; - } - - LabelFill offset(int offset) { - return new LabelFill(offset + locationBci, label); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SourceInfoBuilder { - - private final ArrayList sourceStack = new ArrayList<>(); - private final ArrayList sourceList = new ArrayList<>(); - private int currentSource = -1; - private final ArrayList bciList = new ArrayList<>(); - private final ArrayList sourceDataList = new ArrayList<>(); - private final ArrayList sourceDataStack = new ArrayList<>(); - - void reset() { - sourceStack.clear(); - sourceDataList.clear(); - sourceDataStack.clear(); - bciList.clear(); - } - - void beginSource(int bci, Source src) { - int idx = sourceList.indexOf(src); - if (idx == -1) { - idx = sourceList.size(); - sourceList.add(src); - } - sourceStack.add(currentSource); - currentSource = idx; - beginSourceSection(bci, -1, -1); - } - - void endSource(int bci) { - endSourceSection(bci); - currentSource = sourceStack.remove(sourceStack.size() - 1); - } - - void beginSourceSection(int bci, int start, int length) { - SourceData data = new SourceData(start, length, currentSource); - bciList.add(bci); - sourceDataList.add(data); - sourceDataStack.add(data); - } - - void endSourceSection(int bci) { - SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); - SourceData prev; - if (sourceDataStack.isEmpty()) { - prev = new SourceData(-1, -1, currentSource); - } else { - prev = sourceDataStack.get(sourceDataStack.size() - 1); - } - bciList.add(bci); - sourceDataList.add(prev); - } - - int[] build() { - if (!sourceStack.isEmpty()) { - throw new IllegalStateException("not all sources ended"); - } - if (!sourceDataStack.isEmpty()) { - throw new IllegalStateException("not all source sections ended"); - } - int size = bciList.size(); - int[] resultArray = new int[size * 3]; - int index = 0; - int lastBci = -1; - boolean isFirst = true; - for (int i = 0; i < size; i++) { - SourceData data = sourceDataList.get(i); - int curBci = bciList.get(i); - if (data.start == -1 && isFirst) { - continue; - } - isFirst = false; - if (curBci == lastBci && index > 1) { - index -= 3; - } - resultArray[index + 0] = curBci | (data.sourceIndex << 16); - resultArray[index + 1] = data.start; - resultArray[index + 2] = data.length; - index += 3; - lastBci = curBci; - } - return Arrays.copyOf(resultArray, index); - } - - Source[] buildSource() { - return sourceList.toArray(new Source[0]); - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class SourceData { - - final int start; - final int length; - final int sourceIndex; - - SourceData(int start, int length, int sourceIndex) { - this.start = start; - this.length = length; - this.sourceIndex = sourceIndex; - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class BuilderFinallyTryContext { - - final BuilderFinallyTryContext prev; - final short[] bc; - final ArrayList exceptionHandlers; - final ArrayList labelFills; - final ArrayList labels; - final int curStack; - final int maxStack; - short[] handlerBc; - ArrayList handlerHandlers; - ArrayList handlerLabelFills = new ArrayList<>(); - ArrayList relocationOffsets = new ArrayList<>(); - int handlerMaxStack; - - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { - this.prev = prev; - this.bc = bc; - this.exceptionHandlers = exceptionHandlers; - this.labelFills = labelFills; - this.labels = labels; - this.curStack = curStack; - this.maxStack = maxStack; - } - - } - private final class BuilderState { - - BuilderState parentData; - private short[] bc = new short[65535]; - private int bci; - private int curStack; - private int maxStack; - private int numLocals; - private int numLabels; - private ArrayList constPool; - private BuilderOperationData operationData; - private ArrayList labels = new ArrayList<>(); - private ArrayList labelFills = new ArrayList<>(); - private int numChildNodes; - private int numConditionProfiles; - private ArrayList exceptionHandlers = new ArrayList<>(); - private BuilderFinallyTryContext currentFinallyTry; - private int[] stackSourceBci = new int[1024]; - - BuilderState(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder p) { - this.bc = p.bc; - this.bci = p.bci; - this.curStack = p.curStack; - this.maxStack = p.maxStack; - this.numLocals = p.numLocals; - this.numLabels = p.numLabels; - this.constPool = p.constPool; - this.operationData = p.operationData; - this.labels = p.labels; - this.labelFills = p.labelFills; - this.numChildNodes = p.numChildNodes; - this.numConditionProfiles = p.numConditionProfiles; - this.exceptionHandlers = p.exceptionHandlers; - this.currentFinallyTry = p.currentFinallyTry; - this.stackSourceBci = p.stackSourceBci; - this.parentData = p.parentData; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationSerNodeImpl extends SLOperationRootNode { - - @CompilationFinal int buildOrder; - - private OperationSerNodeImpl(TruffleLanguage language, FrameDescriptor frameDescriptor, int buildOrder) { - super(language, frameDescriptor); - this.buildOrder = buildOrder; - } - - @Override - public String dump() { - throw new UnsupportedOperationException(); - } - - @Override - public Object execute(VirtualFrame frame) { - throw new UnsupportedOperationException(); - } - - @Override - public SourceSection getSourceSectionAtBci(int bci) { - throw new UnsupportedOperationException(); - } - - } - } - private static final class Counter { - - int count; - - } -} From 3af56e181467d930525a689ba15583ed6f03c753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 16 Nov 2022 09:52:22 +0100 Subject: [PATCH 169/312] [wip] bunch --- .../sl/operations/SLOperationRootNodeGen.java | 67 ++++++++++++----- .../example/TestOperationsParserTest.java | 3 +- .../api/operation/ContinuationLocation.java | 40 +++++++++++ .../api/operation/ContinuationResult.java | 40 +++++++++++ .../api/operation/OperationConfig.java | 3 +- .../api/operation/OperationRootNode.java | 11 +++ .../api/operation/introspection/Argument.java | 42 ++++++++++- .../introspection/ExceptionHandler.java | 40 +++++++++++ .../operation/introspection/Instruction.java | 42 ++++++++++- .../introspection/OperationIntrospection.java | 53 +++++++++++++- .../introspection/SourceInformation.java | 72 +++++++++++++++++++ .../serialization/SerializationUtils.java | 44 +++++++++++- .../api/operation/tracing/Decision.java | 40 +++++++++++ .../tracing/OperationsStatistics.java | 54 +++++++------- .../generator/NodeGeneratorPlugs.java | 2 - .../dsl/processor/operations/Operation.java | 5 +- .../operations/OperationDecisions.java | 9 ++- .../OperationsBytecodeCodeGenerator.java | 46 +++++++----- .../OperationsBytecodeNodeGeneratorPlugs.java | 7 +- .../operations/OperationsCodeGenerator.java | 20 ++++-- .../operations/SingleOperationParser.java | 1 - .../operations/instructions/Instruction.java | 10 ++- .../instructions/LoadArgumentInstruction.java | 1 - .../LoadLocalMaterializedInstruction.java | 40 +++++++++++ .../StoreLocalMaterializedInstruction.java | 40 +++++++++++ .../instructions/SuperInstruction.java | 42 ++++++++++- .../instructions/YieldInstruction.java | 40 +++++++++++ .../truffle/polyglot/PolyglotEngineImpl.java | 11 ++- .../oracle/truffle/sl/test/SLTestRunner.java | 9 +-- .../com/oracle/truffle/sl/SLException.java | 23 +++--- .../sl/nodes/expression/SLAddNode.java | 2 +- .../sl/nodes/expression/SLDivNode.java | 2 +- .../nodes/expression/SLLessOrEqualNode.java | 2 +- .../sl/nodes/expression/SLLessThanNode.java | 2 +- .../sl/nodes/expression/SLLogicalNotNode.java | 2 +- .../sl/nodes/expression/SLMulNode.java | 2 +- .../sl/nodes/expression/SLSubNode.java | 2 +- .../sl/nodes/util/SLToBooleanNode.java | 2 +- .../sl/parser/SLOperationsVisitor.java | 54 +++++++++----- 39 files changed, 786 insertions(+), 141 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/SourceInformation.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index cfab78f47cd3..532f93da10c9 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -443,7 +443,7 @@ void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, } @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { int $bci = 0; ArrayList target = new ArrayList<>(); while ($bci < $bc.length) { @@ -465,7 +465,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han case INSTR_BRANCH : { Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + BRANCH_LENGTH; target.add(dec); break; @@ -473,7 +473,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han case INSTR_BRANCH_FALSE : { Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + BRANCH_FALSE_LENGTH; target.add(dec); break; @@ -693,7 +693,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + SC_SL_AND_LENGTH; target.add(dec); break; @@ -703,7 +703,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + SC_SL_OR_LENGTH; target.add(dec); break; @@ -2021,7 +2021,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han $bci += C_SL_TO_BOOLEAN_LENGTH; { Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; ((Object[]) decSuper[4])[1] = dec; } $bci += BRANCH_FALSE_LENGTH; @@ -2037,7 +2037,23 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han for (int i = 0; i < $handlers.length; i++) { ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()}); + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); } private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { @@ -6433,7 +6449,7 @@ void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, } @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts) { + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { int $bci = 0; ArrayList target = new ArrayList<>(); while ($bci < $bc.length) { @@ -6455,7 +6471,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han case INSTR_BRANCH : { Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + BRANCH_LENGTH; target.add(dec); break; @@ -6463,7 +6479,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han case INSTR_BRANCH_FALSE : { Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + BRANCH_FALSE_LENGTH; target.add(dec); break; @@ -6683,7 +6699,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + SC_SL_AND_LENGTH; target.add(dec); break; @@ -6693,7 +6709,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + SC_SL_OR_LENGTH; target.add(dec); break; @@ -8011,7 +8027,7 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han $bci += C_SL_TO_BOOLEAN_LENGTH; { Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; ((Object[]) decSuper[4])[1] = dec; } $bci += BRANCH_FALSE_LENGTH; @@ -8027,7 +8043,23 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han for (int i = 0; i < $handlers.length; i++) { ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()}); + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); } private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { @@ -9040,7 +9072,7 @@ public Object execute(VirtualFrame frame) { @Override public OperationIntrospection getIntrospectionData() { - return switchImpl.getIntrospectionData(_bc, _handlers, _consts); + return switchImpl.getIntrospectionData(_bc, _handlers, _consts, nodes, sourceInfo); } private Lock getLockAccessor() { @@ -15426,7 +15458,7 @@ private abstract static class BytecodeLoopBase { abstract int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); - abstract OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts); + abstract OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo); abstract void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); @@ -15667,6 +15699,9 @@ private void reset(TruffleLanguage language) { exceptionHandlers.clear(); Arrays.fill(instructionHistory, -1); instructionHistoryIndex = 0; + if (sourceBuilder != null) { + sourceBuilder.reset(); + } metadata_MethodName = null; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index aeff8c110747..8bcfbc07c3de 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -917,7 +917,8 @@ public void testMetadataDefaultValue() { @Test public void testTeeLocal() { - RootCallTarget root = parse(b -> { b.beginRoot(LANGUAGE); + RootCallTarget root = parse(b -> { + b.beginRoot(LANGUAGE); OperationLocal local = b.createLocal(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java index a3007dbef78a..1faf2b488681 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.frame.VirtualFrame; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java index 917013a6aa76..ef3fd0326547 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation; import com.oracle.truffle.api.frame.MaterializedFrame; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java index 3fcccccaa3f7..d55eeea32c7e 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationConfig.java @@ -44,13 +44,12 @@ public final class OperationConfig { public static final OperationConfig DEFAULT = new OperationConfig(false, false); public static final OperationConfig WITH_SOURCE = new OperationConfig(true, false); - public static final OperationConfig COMPLETE = new OperationConfig(true, true); private final boolean withSource; private final boolean withInstrumentation; - public OperationConfig(boolean withSource, boolean withInstrumentation) { + private OperationConfig(boolean withSource, boolean withInstrumentation) { this.withSource = withSource; this.withInstrumentation = withInstrumentation; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index ffcb0abe91d3..0d9ccff3c8eb 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.operation.introspection.ExceptionHandler; import com.oracle.truffle.api.operation.introspection.Instruction; import com.oracle.truffle.api.operation.introspection.OperationIntrospection; +import com.oracle.truffle.api.operation.introspection.SourceInformation; import com.oracle.truffle.api.source.SourceSection; public interface OperationRootNode extends NodeInterface, OperationIntrospection.Provider { @@ -62,9 +63,11 @@ static void setMetadataAccessor(MetadataKey key, Function handlers = id.getExceptionHandlers(); if (handlers.size() > 0) { sb.append("Exception handlers:\n"); @@ -73,6 +76,14 @@ default String dump() { } } + List sourceInfo = id.getSourceInformation(); + if (sourceInfo != null) { + sb.append("Source Information:\n"); + for (SourceInformation si : sourceInfo) { + sb.append(" ").append(si.toString()).append('\n'); + } + } + return sb.toString(); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java index 86b07de9eb80..51f5bb0b3512 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Argument.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.introspection; public final class Argument { @@ -56,4 +96,4 @@ public String toString() { return getKind().toString(getValue()); } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java index 898dee2f3db7..6876debfd454 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.introspection; public final class ExceptionHandler { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java index 1a532ab808f6..960810aff913 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.introspection; import java.util.Arrays; @@ -83,4 +123,4 @@ private String toString(String prefix) { return sb.toString(); } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java index c9bf4dec6954..3117c6417f26 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java @@ -1,12 +1,52 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.introspection; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -public class OperationIntrospection { +public final class OperationIntrospection { - public static interface Provider { + public interface Provider { default OperationIntrospection getIntrospectionData() { throw new UnsupportedOperationException(); } @@ -33,4 +73,11 @@ public List getInstructions() { public List getExceptionHandlers() { return Arrays.stream((Object[]) data[2]).map(x -> new ExceptionHandler((Object[]) x)).collect(Collectors.toUnmodifiableList()); } -} \ No newline at end of file + + public List getSourceInformation() { + if (data[3] == null) { + return null; + } + return Arrays.stream((Object[]) data[3]).map(x -> new SourceInformation((Object[]) x)).collect(Collectors.toUnmodifiableList()); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/SourceInformation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/SourceInformation.java new file mode 100644 index 000000000000..bc49a55ffc2e --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/SourceInformation.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.introspection; + +import com.oracle.truffle.api.source.SourceSection; + +public final class SourceInformation { + private final Object[] data; + + SourceInformation(Object[] data) { + this.data = data; + } + + public int getStartBci() { + return (int) data[0]; + } + + public int getEndBci() { + return (int) data[1]; + } + + public SourceSection getSourceSection() { + return (SourceSection) data[2]; + } + + @Override + public String toString() { + Object sourceSection = getSourceSection(); + if (sourceSection == null) { + sourceSection = ""; + } + return String.format("[%04x .. %04x] %s", getStartBci(), getEndBci(), sourceSection); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java index e2f0e17f25ef..ab7ee381d6e3 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.serialization; import java.io.DataInput; @@ -7,7 +47,7 @@ import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; -public class SerializationUtils { +public final class SerializationUtils { private SerializationUtils() { } @@ -16,7 +56,7 @@ public static DataInput createDataInput(ByteBuffer buffer) { return new ByteBufferDataInput(buffer); } - private static class ByteBufferDataInput implements DataInput { + private static final class ByteBufferDataInput implements DataInput { private final ByteBuffer buffer; private char[] lineBuffer; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java index f5290e3fdf0e..f2aed1abb53f 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.tracing; import java.util.Arrays; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index a1e0881074c3..6503abc06ee2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -41,6 +41,7 @@ package com.oracle.truffle.api.operation.tracing; import java.io.IOException; +import java.io.PrintWriter; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.FileChannel; @@ -113,7 +114,7 @@ private void read() { } } - public void write(boolean dumpInfo) { + public void write(PrintWriter dumpWriter) { try { try { JSONArray result = new JSONArray(); @@ -135,7 +136,7 @@ public void write(boolean dumpInfo) { this.statisticsMap.forEach((k, v) -> { try { - v.writeDecisions(dumpInfo); + v.writeDecisions(dumpWriter); } catch (IOException e) { e.printStackTrace(); } @@ -161,11 +162,11 @@ static final class GlobalOperationStatistics { setNames(); } - public void writeDecisions(boolean dumpInfo) throws IOException { + public void writeDecisions(PrintWriter dumpWriter) throws IOException { setNames(); EnabledExecutionTracer tracer = collect(); try (FileChannel ch = FileChannel.open(Path.of(decisionsFile), StandardOpenOption.WRITE, StandardOpenOption.CREATE)) { - JSONArray result = tracer.serializeDecisions(this, dumpInfo); + JSONArray result = tracer.serializeDecisions(this, dumpWriter); ch.truncate(0); ch.write(ByteBuffer.wrap(result.toString(4).getBytes(StandardCharsets.UTF_8))); } @@ -254,7 +255,7 @@ public void traceStartBasicBlock(int bci) { } } - private static class EnabledExecutionTracer extends ExecutionTracer { + private static final class EnabledExecutionTracer extends ExecutionTracer { private final GlobalOperationStatistics stats; @@ -262,7 +263,7 @@ private static class PseudoInstruction { private String name; private boolean isRegular; - public PseudoInstruction(String name, boolean isRegular) { + private PseudoInstruction(String name, boolean isRegular) { this.name = name; this.isRegular = isRegular; } @@ -479,7 +480,7 @@ static String makeName(GlobalOperationStatistics stats, int[] instructions) { private int[] instrHistory = null; private int instrHistoryLen = 0; - public EnabledExecutionTracer(GlobalOperationStatistics stats) { + private EnabledExecutionTracer(GlobalOperationStatistics stats) { this.stats = stats; } @@ -704,7 +705,7 @@ private static void orderDecisions(List output, List input, private static final int NUM_DECISIONS = 30; - public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dumpInfo) { + public JSONArray serializeDecisions(GlobalOperationStatistics stats, PrintWriter dumpWriter) { JSONArray result = new JSONArray(); result.put("This file is autogenerated by the Operations DSL."); result.put("Do not modify, as it will be overwritten when running with tracing support."); @@ -727,35 +728,30 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, boolean dum // the common / uncommon instructions don't compete with other decisions, // so we add them at the end - numNodesWithInstruction.entrySet().stream()// - .map(e -> { - Decision d = new Decision.CommonInstruction(e.getKey().name(stats), e.getValue(), e.getKey().isRegular()); - for (Decision pre : acceptedDecisions) { - d.acceptedBefore(pre, stats); - } - return d; - })// - .filter(x -> x.value() > 0) // - .sorted(Decision.COMPARATOR) // - .limit(64)// - .forEach(acceptedDecisions::add); - - if (dumpInfo) { - System.err.println("======================== OPERATION DSL TRACING DECISIONS ======================== "); - System.err.println("# For " + stats.opsClass.getSimpleName()); - System.err.println(); + numNodesWithInstruction.entrySet().stream().map(e -> { + Decision d = new Decision.CommonInstruction(e.getKey().name(stats), e.getValue(), e.getKey().isRegular()); + for (Decision pre : acceptedDecisions) { + d.acceptedBefore(pre, stats); + } + return d; + }).filter(x -> x.value() > 0).sorted(Decision.COMPARATOR).limit(64).forEach(acceptedDecisions::add); + + if (dumpWriter != null) { + dumpWriter.println("======================== OPERATION DSL TRACING DECISIONS ======================== "); + dumpWriter.println("# For " + stats.opsClass.getSimpleName()); + dumpWriter.println(); } // serialize for (Decision dec : acceptedDecisions) { - if (dumpInfo) { - System.err.println(dec.prettyPrint(stats)); + if (dumpWriter != null) { + dumpWriter.println(dec.prettyPrint(stats)); } result.put(dec.serialize(stats)); } - if (dumpInfo) { - System.err.println("================================================================================= "); + if (dumpWriter != null) { + dumpWriter.println("================================================================================= "); } return result; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 44f82689ae7c..89aa4a8a4936 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -41,7 +41,6 @@ package com.oracle.truffle.dsl.processor.generator; import java.util.List; -import java.util.function.Consumer; import java.util.function.Predicate; import javax.lang.model.element.ExecutableElement; @@ -51,7 +50,6 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.model.CacheExpression; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 1a118a763084..90c152ddb9ae 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -45,7 +45,6 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; -import java.util.Arrays; import java.util.List; import javax.lang.model.type.TypeKind; @@ -266,7 +265,7 @@ public CodeTree createEndCode(BuilderVariables vars) { args.arguments = new CodeTree[1]; args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); - // TODO validate the local is nested properly + // todo: validate the local is nested properly // (not security critical since non-local accesses use safe API) return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); } @@ -297,7 +296,7 @@ public CodeTree createEndCode(BuilderVariables vars) { args.arguments = new CodeTree[1]; args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); - // TODO validate the local is nested properly + // todo: validate the local is nested properly // (not security critical since non-local accesses use safe API) return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java index 533e1abbfb05..e9571340a03f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java @@ -201,12 +201,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } CommonInstruction other = (CommonInstruction) obj; return Objects.equals(instruction, other.instruction); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index ef98d1a97d0d..836c249a9e53 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -45,7 +45,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import java.util.Random; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -219,22 +218,37 @@ private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { b.end(); - // b.startIf().string("sourceInfo != null").end(); - // b.startBlock(); - // { - // b.statement("sb.append(\"Source info:\\n\")"); - // b.startFor().string("int i = 0; i < sourceInfo[0].length; i++").end(); - // b.startBlock(); - // - // b.statement("sb.append(String.format(\" bci=%04x, offset=%d, length=%d\\n\", - // sourceInfo[0][i], - // sourceInfo[1][i], sourceInfo[2][i]))"); - // - // b.end(); - // } - // b.end(); + b.declaration("Object[]", "si", "null"); + + // nodes.getSources() is null until we finish parsing everything + b.startIf().string("nodes != null && nodes.getSources() != null && sourceInfo != null").end().startBlock(); // { + + b.declaration("ArrayList", "siTarget", "new ArrayList<>()"); + + b.startFor().string("int i = 0; i < sourceInfo.length; i += 3").end().startBlock(); // { + + b.declaration("int", "startBci", "sourceInfo[i] & 0xffff"); + b.declaration("int", "endBci", "i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff"); + + b.startIf().string("startBci == endBci").end().startBlock().statement("continue").end(); + + b.declaration("int", "sourceIndex", "sourceInfo[i] >> 16"); + b.declaration("int", "sourceStart", "sourceInfo[i + 1]"); + b.declaration("int", "sourceLength", "sourceInfo[i + 2]"); + + b.startStatement().startCall("siTarget.add").startNewArray((ArrayType) context.getType(Object[].class), null); + b.string("startBci"); + b.string("endBci"); + b.string("sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)"); + b.end(3); + + b.end(); // } + + b.statement("si = siTarget.toArray()"); + + b.end(); // } - b.startReturn().string("OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray()})").end(); + b.startReturn().string("OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si})").end(); vars.bci = null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index 5489196f2698..e8042d32e32f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -46,11 +46,9 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.extractBoxingBits; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -65,16 +63,14 @@ import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.generator.BitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.StateBitSet; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; @@ -92,7 +88,6 @@ import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; -import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { private final Set innerTypeNames; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index e5129782b056..76e32691f49b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -331,6 +331,8 @@ private CodeVariableElement createSerializationContext() { } CodeTypeElement createOperationNodeImpl() { + GeneratedTypeMirror typOperationNodes = new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME); + String simpleName = m.getTemplateType().getSimpleName().toString() + "Gen"; CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PUBLIC_FINAL, simpleName, m.getTemplateType().asType()); GeneratorUtils.addSuppressWarnings(context, typOperationNodeImpl, "unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"); @@ -342,7 +344,7 @@ CodeTypeElement createOperationNodeImpl() { CodeTypeElement typExceptionHandler = typOperationNodeImpl.add(createExceptionHandler()); CodeTypeElement typBytecodeBase = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); - typOperationNodeImpl.add(createBytecodeBaseClass(typBytecodeBase, typOperationNodeImpl, typExceptionHandler)); + typOperationNodeImpl.add(createBytecodeBaseClass(typBytecodeBase, typOperationNodeImpl, typOperationNodes, typExceptionHandler)); CodeExecutableElement genCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), m.fdConstructor)); genCtor.setSimpleName(CodeNames.of(simpleName)); @@ -373,7 +375,7 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getDeclaredType("com.oracle.truffle.api.impl.UnsafeFrameAccess"), "UFA = UnsafeFrameAccess.lookup()")); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME), "nodes"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, typOperationNodes, "nodes"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "_bc"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_consts"))); typOperationNodeImpl.add(children(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.Node), "_children"))); @@ -455,7 +457,7 @@ CodeTypeElement createOperationNodeImpl() { CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationIntrospection_Provider, "getIntrospectionData"); typOperationNodeImpl.add(mDump); - mDump.createBuilder().startReturn().startCall("switchImpl.getIntrospectionData").string("_bc, _handlers, _consts").end(2); + mDump.createBuilder().startReturn().startCall("switchImpl.getIntrospectionData").string("_bc, _handlers, _consts, nodes, sourceInfo").end(2); CodeExecutableElement mGetLockAccessor = new CodeExecutableElement(MOD_PRIVATE, context.getType(Lock.class), "getLockAccessor"); typOperationNodeImpl.add(mGetLockAccessor); @@ -1810,7 +1812,7 @@ private CodeTypeElement createOperationDataImpl() { return opDataImpl; } - private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler) { + private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeTypeElement opNodeImpl, TypeMirror typOperationNodes, CodeTypeElement typExceptionHandler) { CodeExecutableElement loopMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(int.class), "continueAt"); loopMethod.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); @@ -1837,6 +1839,8 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(context.getType(short.class)), "$bc")); dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); dumpMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); + dumpMethod.addParameter(new CodeVariableElement(typOperationNodes, "nodes")); + dumpMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "sourceInfo")); baseClass.add(dumpMethod); if (m.isGenerateAOT()) { @@ -2608,14 +2612,14 @@ private CodeExecutableElement createExpectPrimitive(FrameKind kind) { b.statement("break"); b.end(); // case - b.end();// switch + b.end(); // switch b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string("0").end(2); b.startThrow().startNew(types.UnexpectedResultException).string("frame.getValue(slot)").end(2); - b.end();// else + b.end(); // else return mExpectPrimitive; } @@ -2748,6 +2752,10 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("Arrays.fill(instructionHistory, -1)"); b.statement("instructionHistoryIndex = 0"); + b.startIf().string("sourceBuilder != null").end().startBlock(); + b.statement("sourceBuilder.reset()"); + b.end(); + if (m.enableYield) { b.statement("yieldCount = 0"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 2925ee4067c8..48c81892ee21 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.dsl.processor.operations; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 69779fe82c65..37fd0837c843 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -53,7 +53,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; @@ -557,22 +556,21 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) // superinstructions - final int MAX_HISTORY = 8; + final int maxHistory = 8; - b.startAssign("instructionHistory[++instructionHistoryIndex % " + MAX_HISTORY + "]").variable(opcodeIdField).end(); + b.startAssign("instructionHistory[++instructionHistoryIndex % " + maxHistory + "]").variable(opcodeIdField).end(); boolean elseIf = false; for (SuperInstruction si : ctx.getSuperInstructions()) { Instruction[] instrs = si.getInstructions(); if (instrs[instrs.length - 1].id == id) { - String lengthOffset = ""; elseIf = b.startIf(elseIf); for (int i = 1; i < instrs.length; i++) { if (i != 1) { b.string(" && "); } - b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + MAX_HISTORY + ") % 8] == "); + b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + maxHistory + ") % 8] == "); b.variable(instrs[instrs.length - 1 - i].opcodeIdField); } b.end().startBlock(); @@ -746,7 +744,7 @@ public CodeTree createDumpCode(ExecutionVariables vars) { for (int i = 0; i < branchTargets.size(); i++) { int ci = i; - createAddArgument(b, "CHILD_OFFSET", () -> b.cast(context.getType(int.class)).tree(createBranchTargetIndex(vars, ci, false))); + createAddArgument(b, "BRANCH_OFFSET", () -> b.cast(context.getType(int.class)).tree(createBranchTargetIndex(vars, ci, false))); } b.end(3); // arg array, instr array, stmt diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java index 432fb9e6fc56..32387514d275 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.dsl.processor.operations.instructions; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationsContext; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java index 7f4411951063..82d6ee2e8516 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java index 5e722aea87f3..c55c20b4c5e0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index fe78890c8a64..01343f206b86 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import java.util.List; @@ -148,7 +188,7 @@ public CodeTree createDumpCode(ExecutionVariables vars) { @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - // TODO Auto-generated method stub + // todo: implement return null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index fd05269de14a..b97cd729684b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java index 35653159a92d..093e6548095d 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotEngineImpl.java @@ -1219,7 +1219,16 @@ void ensureClosed(boolean force, boolean inShutdownHook, boolean initiatedByCont } if (operationStatistics != null) { - operationStatistics.write(engineOptionValues.get(PolyglotEngineOptions.OperationsDumpDecisions)); + boolean dumpStatistics = engineOptionValues.get(PolyglotEngineOptions.OperationsDumpDecisions); + + StringWriter stringDumpWriter = dumpStatistics ? new StringWriter() : null; + PrintWriter dumpWriter = dumpStatistics ? new PrintWriter(stringDumpWriter) : null; + + operationStatistics.write(dumpWriter); + + if (dumpStatistics) { + getEngineLogger().log(Level.INFO, stringDumpWriter.toString()); + } } // don't commit changes to contexts if still running diff --git a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java index 592e7e4a998a..cf368c0f103e 100644 --- a/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java +++ b/truffle/src/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @@ -82,7 +82,6 @@ import org.junit.runners.model.InitializationError; import com.oracle.truffle.api.dsl.NodeFactory; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.sl.SLLanguage; import com.oracle.truffle.sl.builtins.SLBuiltinNode; import com.oracle.truffle.sl.test.SLTestRunner.TestCase; @@ -303,12 +302,8 @@ protected void runChild(TestCase testCase, RunNotifier notifier) { SLLanguage.installBuiltin(builtin); } - Context.Builder builder = Context.newBuilder() // - .allowExperimentalOptions(true) // - .allowHostClassLookup((s) -> true) // - .allowHostAccess(HostAccess.ALL) // - .in(new ByteArrayInputStream(testCase.testInput.getBytes("UTF-8"))) // - .out(out); + Context.Builder builder = Context.newBuilder().allowExperimentalOptions(true).allowHostClassLookup((s) -> true).allowHostAccess(HostAccess.ALL).in( + new ByteArrayInputStream(testCase.testInput.getBytes("UTF-8"))).out(out); for (Map.Entry e : testCase.options.entrySet()) { builder.option(e.getKey(), e.getValue()); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java index 0c014ba1d350..06945a82d2dc 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLException.java @@ -71,13 +71,26 @@ public SLException(String message, Node location) { super(message, location, -1); } + @TruffleBoundary + public static SLException typeError(Node operation, int bci, Object... values) { + String operationName = null; + if (operation != null) { + NodeInfo nodeInfo = SLLanguage.lookupNodeInfo(operation.getClass()); + if (nodeInfo != null) { + operationName = nodeInfo.shortName(); + } + } + + return typeError(operation, operationName, bci, values); + } + /** * Provides a user-readable message for run-time type errors. SL is strongly typed, i.e., there * are no automatic type conversions of values. */ @TruffleBoundary @SuppressWarnings("deprecation") - public static SLException typeError(Node operation, int bci, Object... values) { + public static SLException typeError(Node operation, String operationName, int bci, Object... values) { StringBuilder result = new StringBuilder(); result.append("Type error"); @@ -88,17 +101,11 @@ public static SLException typeError(Node operation, int bci, Object... values) { if (ss != null && ss.isAvailable()) { result.append(" at ").append(ss.getSource().getName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn()); } - if (bci != -1) { - result.append(String.format(" @%04x", bci)); - } } result.append(": operation"); if (operation != null) { - NodeInfo nodeInfo = SLLanguage.lookupNodeInfo(operation.getClass()); - if (nodeInfo != null) { - result.append(" \"").append(nodeInfo.shortName()).append("\""); - } + result.append(" \"").append(operationName).append("\""); } result.append(" not defined for"); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index b19d45f04fa1..7224de414784 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -134,6 +134,6 @@ public static boolean isString(Object a, Object b) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "+", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java index 89ab2d851a3b..e64b5fc4b904 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java @@ -78,6 +78,6 @@ public static SLBigNumber div(SLBigNumber left, SLBigNumber right) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "/", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java index ea9cc5fc0a5a..ca307bb9b041 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessOrEqualNode.java @@ -69,6 +69,6 @@ public static boolean lessOrEqual(SLBigNumber left, SLBigNumber right) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "<=", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index d111bb219b85..29e92c78967e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -70,7 +70,7 @@ public static boolean lessThan(SLBigNumber left, SLBigNumber right) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "<", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java index 34869c17f6c3..31fafdd7fe6e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLogicalNotNode.java @@ -64,7 +64,7 @@ public static boolean doBoolean(boolean value) { @Fallback public static Object typeError(Object value, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, value); + throw SLException.typeError(node, "!", bci, value); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java index 9ffb5c923246..a6d2cb6a06d1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLMulNode.java @@ -69,7 +69,7 @@ public static SLBigNumber mul(SLBigNumber left, SLBigNumber right) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "*", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index 7fbaf2935395..4c40e1737da4 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -69,7 +69,7 @@ public static SLBigNumber sub(SLBigNumber left, SLBigNumber right) { @Fallback public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, left, right); + throw SLException.typeError(node, "-", bci, left, right); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java index 05988ef662c5..5355fef945fb 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java @@ -63,6 +63,6 @@ public static boolean doBoolean(boolean value) { @Fallback public static boolean doFallback(Object value, @Bind("this") Node node, @Bind("$bci") int bci) { - throw SLException.typeError(node, bci, value); + throw SLException.typeError(node, "toBoolean", bci, value); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index f0ad6983be79..fbcb002564cc 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -47,9 +47,10 @@ import java.util.List; import java.util.Map; +import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.misc.Interval; import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.TerminalNode; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.debug.DebuggerTags; @@ -82,6 +83,7 @@ import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NameAccessContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.NumericLiteralContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.Return_statementContext; +import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.StatementContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.StringLiteralContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.TermContext; import com.oracle.truffle.sl.parser.SimpleLanguageOperationsParser.While_statementContext; @@ -97,7 +99,7 @@ public final class SLOperationsVisitor extends SLBaseVisitor { private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { - var nodes = SLOperationRootNodeGen.create(OperationConfig.DEFAULT, builder -> { + var nodes = SLOperationRootNodeGen.create(OperationConfig.WITH_SOURCE, builder -> { SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, builder); parseSLImpl(source, visitor); }); @@ -115,6 +117,18 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Thu, 17 Nov 2022 14:38:57 +0100 Subject: [PATCH 170/312] [wip] do the split thing --- .../expression/DSLExpressionResolver.java | 16 +- .../dsl/processor/library/ExportsParser.java | 2 +- .../operations/OperationGeneratorUtils.java | 86 --------- .../OperationsBytecodeCodeGenerator.java | 169 +++++++++++++----- .../operations/SingleOperationParser.java | 2 +- .../instructions/BranchInstruction.java | 6 +- .../ConditionalBranchInstruction.java | 9 +- .../operations/instructions/Instruction.java | 16 +- .../instructions/LoadLocalInstruction.java | 18 +- .../instructions/ReturnInstruction.java | 7 +- .../instructions/ShortCircuitInstruction.java | 7 +- .../instructions/SuperInstruction.java | 17 +- .../instructions/ThrowInstruction.java | 2 +- .../instructions/YieldInstruction.java | 12 +- .../dsl/processor/parser/NodeParser.java | 12 +- 15 files changed, 181 insertions(+), 200 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index 3aaa0986929f..c119039aec25 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -87,17 +87,19 @@ public class DSLExpressionResolver implements DSLExpressionVisitor { private final List unprocessedElements; private boolean processed; private final ParseMode parseMode; + TypeMirror thisType; - private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements, ParseMode parseMode) { + private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements, ParseMode parseMode, TypeMirror thisType) { this.context = context; this.parent = parent; this.accessType = accessType; this.unprocessedElements = new ArrayList<>(lookupElements); this.parseMode = parseMode; + this.thisType = thisType; } - public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements, ParseMode parseMode) { - this(context, accessType, null, lookupElements, parseMode); + public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements, ParseMode parseMode, TypeMirror thisType) { + this(context, accessType, null, lookupElements, parseMode, thisType); } public TypeElement getAccessType() { @@ -135,7 +137,7 @@ private void processElements(List lookupElements) { } public DSLExpressionResolver copy(List prefixElements) { - return new DSLExpressionResolver(context, accessType, this, prefixElements, parseMode); + return new DSLExpressionResolver(context, accessType, this, prefixElements, parseMode, thisType); } private static String getMethodName(ExecutableElement method) { @@ -233,7 +235,7 @@ private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); if (parseMode == ParseMode.OPERATION && "this".equals(name)) { - return new CodeVariableElement(ProcessorContext.getInstance().getTypes().Node, "$this"); + return new CodeVariableElement(thisType, "$this"); } switch (name) { @@ -286,7 +288,7 @@ public void visitCall(Call call) { } } } - resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode); + resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode, thisType); } ExecutableElement resolvedMethod = resolver.resolveCall(call); @@ -330,7 +332,7 @@ public void visitVariable(Variable variable) { } else if (type.getKind() == TypeKind.ARRAY) { elements.add(new CodeVariableElement(context.getType(int.class), "length")); } - resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode); + resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode, thisType); } VariableElement var = resolver.resolveVariable(variable); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java index b428612cd140..0329759f519e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java @@ -697,7 +697,7 @@ private ExportsData parseExports(TypeElement type, List elemen String transitionLimit = ElementUtils.getAnnotationValue(String.class, annotationMirror, "transitionLimit", false); if (transitionLimit != null) { DSLExpressionResolver resolver = new DSLExpressionResolver(context, model.getTemplateType(), - NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false), ParseMode.EXPORTED_MESSAGE); + NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false), ParseMode.EXPORTED_MESSAGE, types.Node); try { DSLExpression expression = DSLExpression.parse(transitionLimit); expression.accept(resolver); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java index 2256548ee7b5..d51ddf12a9c2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java @@ -46,7 +46,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -55,13 +54,11 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; @@ -347,87 +344,4 @@ public static CodeTree extractBoxingBits(OperationsContext ctx, CodeTree instr) return CodeTreeBuilder.singleString("0"); } } - - public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVariables vars, String name, boolean isUncached, Consumer build) { - return wrapExecuteInMethod(ctx, vars, name, isUncached, build, true); - } - - public static CodeTree wrapExecuteInMethod(OperationsContext ctx, ExecutionVariables vars, String name, boolean isUncached, Consumer build, boolean doDecode) { - ProcessorContext context = ProcessorContext.getInstance(); - createHelperMethod(ctx.outerType, name, () -> { - CodeExecutableElement m = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(int.class), name); - m.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); - m.addParameter(vars.stackFrame); - if (ctx.getData().enableYield) { - m.addParameter(vars.localFrame); - } - m.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); - m.addParameter(vars.bc); - m.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); - m.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); - m.addParameter(vars.consts); - m.addParameter(vars.children); - m.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); - m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "loopCounter")); - m.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); - if (ctx.hasBoxingElimination()) { - m.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); - } - if (ctx.getData().isTracing()) { - m.addParameter(vars.tracer); - } - if (isUncached) { - m.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "Counter"), "uncachedExecuteCount")); - } - - CodeTreeBuilder b = m.createBuilder(); - b.statement("int $bci = $startBci"); - b.statement("int $sp = $startSp"); - build.accept(b); - - return m; - }); - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (doDecode) { - b.startAssign("int _enc"); - } - b.startCall(name); - - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.string("$this"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); - b.string("$conditionProfiles"); - b.string("loopCounter"); - b.string("curOpcode"); - if (ctx.hasBoxingElimination()) { - b.string("$localTags"); - } - if (ctx.getData().isTracing()) { - b.variable(vars.tracer); - } - if (isUncached) { - b.string("uncachedExecuteCount"); - } - b.end(); - - if (doDecode) { - b.end(); - b.startAssign(vars.bci).string("_enc & 0xffff").end(); - b.startAssign(vars.sp).string("(_enc >> 16) & 0xffff").end(); - } - - return b.build(); - } - - public static CodeTree encodeExecuteReturn() { - return CodeTreeBuilder.createBuilder().startReturn().string("($sp << 16) | $bci").end().build(); - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 836c249a9e53..46e3b9c3e045 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -43,8 +43,10 @@ import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -128,7 +130,7 @@ public CodeTypeElement createBuilderBytecodeNode() { builderBytecodeNodeType.setHighPriority(true); initializeInstructions(builderBytecodeNodeType); - builderBytecodeNodeType.add(createBytecodeLoop(baseClass)); + builderBytecodeNodeType.add(createBytecodeLoop(builderBytecodeNodeType, baseClass)); if (m.isGenerateAOT()) { builderBytecodeNodeType.add(createPrepareAot(baseClass)); @@ -268,7 +270,7 @@ static void populateVariables(ExecutionVariables vars, OperationsData m) { vars.children = new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children"); } - private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { + private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, CodeTypeElement baseType) { CodeExecutableElement mContinueAt = GeneratorUtils.overrideImplement(baseType, "continueAt"); createExplodeLoop(mContinueAt); @@ -351,7 +353,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { b.startBlock(); List outerInstructions = new ArrayList<>(); - List innerInstructions = new ArrayList<>(); + Map> wrappedInstructions = new HashMap<>(); for (Instruction op : m.getInstructions()) { if (op.isInstrumentationOnly() && !withInstrumentation) { @@ -366,42 +368,102 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { continue; } - if (op.neverWrapInMethod()) { + if (op.isExplicitFlowControl()) { outerInstructions.add(op); } else { - innerInstructions.add(op); + wrappedInstructions.computeIfAbsent(op.length(), l -> new ArrayList<>()).add(op); } } for (Instruction op : outerInstructions) { - generateExecuteCase(ctx, vars, b, varTracer, op); + generateExecuteCase(ctx, vars, b, varTracer, op, true); } - b.caseDefault().startCaseBlock(); - b.tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, context.makeName(), isUncached, bInner -> { + for (Map.Entry> lenGroup : wrappedInstructions.entrySet()) { + int instructionLength = lenGroup.getKey(); - bInner.startSwitch(); - bInner.string("curOpcode"); - bInner.end(); - bInner.startBlock(); + b.lineComment("length group " + instructionLength); - for (Instruction op : innerInstructions) { - generateExecuteCase(ctx, vars, bInner, varTracer, op); + for (Instruction instr : lenGroup.getValue()) { + generateAllCasesForInstruction(ctx, b, instr); } - bInner.caseDefault().startCaseBlock(); - bInner.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (isCommonOnly) { - bInner.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); - bInner.startReturn().string("($sp << 16) | $bci").end(); - } else { - bInner.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); + b.startCaseBlock(); + + String groupMethodName = "instructionGroup_" + instructionLength; + OperationGeneratorUtils.createHelperMethod(bytecodeType, groupMethodName, () -> { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(int.class), groupMethodName); + met.addParameter(mContinueAt.getParameters().get(0)); // $this + met.addParameter(vars.stackFrame); + if (m.enableYield) { + met.addParameter(vars.localFrame); + } + met.addParameter(vars.bc); + met.addParameter(vars.bci); + met.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); + met.addParameter(vars.consts); + met.addParameter(vars.children); + if (ctx.hasBoxingElimination()) { + met.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + } + met.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + met.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); + + CodeTreeBuilder b2 = met.createBuilder(); + + b2.statement("int $sp = $startSp"); + + b2.startSwitch().string("curOpcode").end().startBlock(); + + for (Instruction instr : lenGroup.getValue()) { + generateExecuteCase(ctx, vars, b2, varTracer, instr, false); + } + + b2.caseDefault().startCaseBlock(); + b2.tree(GeneratorUtils.createShouldNotReachHere()); + b2.end(); + + b2.end(); + + return met; + }); + + b.startAssign(vars.sp).startCall(groupMethodName); + + b.string("$this"); + b.variable(vars.stackFrame); + if (m.enableYield) { + b.variable(vars.localFrame); + } + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); + if (ctx.hasBoxingElimination()) { + b.string("$localTags"); } - bInner.end(); + b.string("$conditionProfiles"); + b.string("curOpcode"); - bInner.end(); // switch block - })); - b.statement("continue loop"); + b.end(2); // assign, call + + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instructionLength).end(); + + b.statement("continue loop"); + + b.end(); + + } + + b.caseDefault().startCaseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + if (isCommonOnly) { + b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); + b.startReturn().string("($sp << 16) | $bci").end(); + } else { + b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); + } b.end(); b.end(); // switch block @@ -453,7 +515,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement baseType) { return mContinueAt; } - private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, CodeTreeBuilder b, CodeVariableElement varTracer, Instruction op) { + private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, CodeTreeBuilder b, CodeVariableElement varTracer, Instruction op, boolean outer) { for (String line : op.dumpInfo().split("\n")) { b.lineComment(line); } @@ -463,31 +525,23 @@ private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, b.startStatement().startCall(varTracer, "traceInstruction"); b.variable(vars.bci); b.variable(op.opcodeIdField); - b.string(op.isBranchInstruction() ? "1" : "0"); + b.string(op.isExplicitFlowControl() ? "1" : "0"); b.string(op.isVariadic() ? "1" : "0"); b.end(2); } - Consumer createBodyInner = b2 -> { - if (isUncached) { - b2.tree(op.createExecuteUncachedCode(vars)); - } else { - b2.tree(op.createExecuteCode(vars)); - } - - }; - - if (op.neverWrapInMethod()) { - createBodyInner.accept(b); + if (isUncached) { + b.tree(op.createExecuteUncachedCode(vars)); } else { - b.startReturn().tree(OperationGeneratorUtils.wrapExecuteInMethod(ctx, vars, "execute" + (isUncached ? "Uncached" : "") + "_" + op.internalName + name, isUncached, b2 -> { - createBodyInner.accept(b2); + b.tree(op.createExecuteCode(vars)); + } - if (!op.isBranchInstruction()) { - b2.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); - b2.tree(OperationGeneratorUtils.encodeExecuteReturn()); - } - }, false)).end(); + if (outer != op.isExplicitFlowControl()) { + throw new AssertionError(); + } + + if (!op.isExplicitFlowControl()) { + b.statement("return $sp"); } }; @@ -541,6 +595,31 @@ private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, vars.results = null; } + private void generateAllCasesForInstruction(OperationsContext ctx, CodeTreeBuilder b, Instruction op) { + if (ctx.hasBoxingElimination() && !isUncached) { + if (op.splitOnBoxingElimination()) { + for (FrameKind kind : op.getBoxingEliminationSplits()) { + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); + } + if (op.hasGeneric()) { + b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); + } + } else if (op.alwaysBoxed()) { + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + } else { + for (FrameKind kind : op.getBoxingEliminationSplits()) { + b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); + } + } + } else { + if (isUncached) { + b.startCase().variable(op.opcodeIdField).end(); + } else { + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); + } + } + } + private void createExplodeLoop(CodeExecutableElement mContinueAt) { CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); mContinueAt.addAnnotationMirror(annExplodeLoop); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 48c81892ee21..283388005e07 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -291,7 +291,7 @@ protected SingleOperationData parse(Element element, List mirr } } - NodeData nodeData = NodeParser.createOperationParser().parse(clonedType, false); + NodeData nodeData = NodeParser.createOperationParser(parentData.getTemplateType()).parse(clonedType, false); if (nodeData == null) { data.addError("Could not parse invalid node: " + te.getSimpleName() + ". Fix errors in the node first."); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 6f9a0e85c695..35ba57aa5aa9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -47,7 +47,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @SuppressWarnings("unused") @@ -151,8 +150,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { } b.startAssign(vars.bci).string("targetBci").end(); - - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + b.statement("continue loop"); return b.build(); } @@ -170,7 +168,7 @@ public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments argume } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index 719c0a8f63cc..ebe797dc9e47 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -45,7 +45,6 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class ConditionalBranchInstruction extends Instruction { @@ -61,7 +60,7 @@ public ConditionalBranchInstruction(OperationsContext ctx, int id) { } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } @@ -84,10 +83,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(2).startBlock(); b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + b.statement("continue loop"); + b.end().startElseBlock(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + b.statement("continue loop"); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index 37fd0837c843..fd66c92695a8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -117,6 +117,7 @@ public static class EmitArguments { private List instruments = new ArrayList<>(); public boolean isCommon; + private boolean frozen; private static final String CONSTANT_OFFSET_SUFFIX = "_CONSTANT_OFFSET"; private static final String CHILDREN_OFFSET_SUFFIX = "_CHILDREN_OFFSET"; @@ -130,7 +131,11 @@ public static class EmitArguments { private static final String STATE_BITS_OFFSET_SUFFIX = "_STATE_BITS_OFFSET"; private static final String LENGTH_SUFFIX = "_LENGTH"; - private static int addInstructionArgument(List holder, Object marker) { + private int addInstructionArgument(List holder, Object marker) { + if (frozen) { + throw new AssertionError(); + } + int index = -1; if (marker != null) { index = holder.indexOf(marker); @@ -253,7 +258,8 @@ private int getInstrumentsOffset() { return getStateBitsOffset() + stateBits.size(); } - protected int length() { + public int length() { + frozen = true; return getInstrumentsOffset() + instruments.size(); } @@ -652,7 +658,7 @@ public CodeVariableElement boxingEliminationReplacement(FrameKind kind) { public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return false; } @@ -804,8 +810,4 @@ public List createInstructionFields() { public boolean isVariadic() { return isVariadic; } - - public boolean neverWrapInMethod() { - return false; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java index e7af00664c12..f0f73cbd0ca6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java @@ -98,18 +98,9 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { @Override public CodeTree createExecuteCode(ExecutionVariables vars) { - if (boxed && vars.specializedKind == FrameKind.OBJECT) { - // load boxed object == load object - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalUnboxed, 0))); - b.statement("$bci -= LOAD_LOCAL_BOXED_LENGTH"); - - return b.build(); - } + boolean useBoxed = vars.specializedKind != FrameKind.OBJECT && boxed; - String helperName = "do_loadLocal" + (boxed ? "Boxed" : "") + "_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); + String helperName = "do_loadLocal" + (useBoxed ? "Boxed" : "") + "_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), helperName); @@ -268,6 +259,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + if (boxed && vars.specializedKind == FrameKind.OBJECT) { + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalUnboxed, 0))); + } + b.startAssign("int localIdx"); b.tree(createLocalIndex(vars, 0, false)); b.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java index eceb4ffa4dba..765fe0e80951 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java @@ -53,7 +53,7 @@ public ReturnInstruction(OperationsContext ctx, int id) { } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } @@ -99,9 +99,4 @@ public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments argume public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; } - - @Override - public boolean neverWrapInMethod() { - return true; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 2272f54be287..56d4fa934731 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -42,7 +42,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -81,13 +80,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + b.statement("continue loop"); // } b.end().startElseBlock(); // { b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + b.statement("continue loop"); // } b.end(); @@ -100,7 +99,7 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index 01343f206b86..c0b74068d4dd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -47,7 +47,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class SuperInstruction extends Instruction { @@ -110,13 +109,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); for (Instruction instr : instructions) { createExecute(b, vars, instr, instr::createExecuteCode); - if (!instr.isBranchInstruction()) { + if (!instr.isExplicitFlowControl()) { b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); } } - if (!instructions[instructions.length - 1].isBranchInstruction()) { - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + if (!instructions[instructions.length - 1].isExplicitFlowControl()) { + b.statement("continue loop"); } return b.build(); @@ -128,25 +127,25 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { for (Instruction instr : instructions) { b.startBlock(); b.tree(instr.createExecuteUncachedCode(vars)); - if (!instr.isBranchInstruction()) { + if (!instr.isExplicitFlowControl()) { b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); } b.end(); } - if (!instructions[instructions.length - 1].isBranchInstruction()) { - b.tree(OperationGeneratorUtils.encodeExecuteReturn()); + if (!instructions[instructions.length - 1].isExplicitFlowControl()) { + b.statement("continue loop"); } return b.build(); } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } @Override - protected int length() { + public int length() { int len = 0; for (Instruction i : instructions) { len += i.length(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java index de4a8f5f598f..13f8971a478a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java @@ -70,7 +70,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java index b97cd729684b..be3993cc3e73 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java @@ -69,7 +69,7 @@ protected CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arg @Override protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { if (!CONTINUATION_POINT.equals(marker) && index != 0) { - throw new AssertionError("what constant?"); + throw new AssertionError(); } CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); @@ -90,16 +90,13 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.statement("$stackFrame.copyTo($this._maxLocals, $localFrame, $this._maxLocals, ($sp - 1 - $this._maxLocals))"); b.statement("$stackFrame.setObject($sp - 1, cont.createResult($localFrame, $stackFrame.getObject($sp - 1)))"); - // b.statement("System.err.printf(\" yielding: %s %s %d%n\", $stackFrame, $localFrame, - // $sp)"); - b.startReturn().string("(($sp - 1) << 16) | 0xffff").end(); return b.build(); } @Override - public boolean isBranchInstruction() { + public boolean isExplicitFlowControl() { return true; } @@ -112,9 +109,4 @@ public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, Cod public boolean alwaysBoxed() { return true; } - - @Override - public boolean neverWrapInMethod() { - return true; - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 9dd503cdecc6..05e57710199c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -169,6 +169,7 @@ public enum ParseMode { private final boolean substituteThisToParent; private final List cachedAnnotations; + private TypeElement operationType; private NodeParser(ParseMode mode, TypeMirror exportLibraryType, TypeElement exportDeclarationType, boolean substituteThisToParent) { this.mode = mode; @@ -194,8 +195,10 @@ public static NodeParser createDefaultParser() { return new NodeParser(ParseMode.DEFAULT, null, null, false); } - public static NodeParser createOperationParser() { - return new NodeParser(ParseMode.OPERATION, null, null, true); + public static NodeParser createOperationParser(TypeElement operationType) { + NodeParser nodeParser = new NodeParser(ParseMode.OPERATION, null, null, true); + nodeParser.operationType = operationType; + return nodeParser; } @Override @@ -1807,7 +1810,8 @@ private void initializeChildren(NodeData node) { child.addError("Node type '%s' is invalid or not a subclass of Node.", getQualifiedName(nodeType)); } else { if (child.isImplicit() || child.isAllowUncached()) { - DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList(), mode); + DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList(), mode, + operationType == null ? types.Node : operationType.asType()); resolver = importStatics(resolver, node.getNodeType()); if (NodeCodeGenerator.isSpecializedNode(nodeType)) { List executables = parseNodeFactoryMethods(nodeType); @@ -2189,7 +2193,7 @@ private void initializeExpressions(List elements, NodeData no if (mode == ParseMode.OPERATION) { globalMembers.add(new CodeVariableElement(context.getType(int.class), "$bci")); } - DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers, mode); + DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers, mode, operationType == null ? types.Node : operationType.asType()); // the number of specializations might grow while expressions are initialized. List specializations = node.getSpecializations(); From 69d1c3991f8dbfb1d89c050f96687411db98c417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 17 Nov 2022 15:15:21 +0100 Subject: [PATCH 171/312] asdf --- .../sl/operations/SLOperationRootNodeGen.java | 17291 ++++++++-------- .../OperationsBytecodeCodeGenerator.java | 2 +- .../operations/instructions/Instruction.java | 8 +- .../instructions/SuperInstruction.java | 14 +- 4 files changed, 8455 insertions(+), 8860 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index 532f93da10c9..b3155f3f329d 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -113,6 +113,59 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i try { assert $sp >= maxLocals : "stack underflow @ " + $bci; switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } // return // Simple Pops: // [ 0] value @@ -121,11 +174,294 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i { return (($sp - 1) << 16) | 0xffff; } - default : - int _enc = __helper0($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - $bci = _enc & 0xffff; - $sp = (_enc >> 16) & 0xffff; + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // length group 1 + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 1; + continue loop; + // length group 2 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 2; + continue loop; + // length group 3 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_STORE_LOCAL << 3) | 7) : + $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 3; + continue loop; + // length group 5 + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 5; + continue loop; + // length group 6 + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : + $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 6; + continue loop; + // length group 7 + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 7; continue loop; + // length group 14 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_14($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 14; + continue loop; + // length group 15 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_15($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 15; + continue loop; + // length group 19 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_19($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 19; + continue loop; + // length group 22 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + $sp = instructionGroup_22($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 22; + continue loop; + // length group 23 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + $sp = instructionGroup_23($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 23; + continue loop; + // length group 24 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_24($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 24; + continue loop; + // length group 25 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_25($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 25; + continue loop; + // length group 26 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_26($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 26; + continue loop; + // length group 27 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + $sp = instructionGroup_27($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 27; + continue loop; + // length group 28 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_28($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 28; + continue loop; + // length group 30 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_30($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 30; + continue loop; + // length group 32 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_32($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 32; + continue loop; + // length group 33 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_33($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 33; + continue loop; + // length group 34 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_34($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 34; + continue loop; + // length group 37 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_37($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 37; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); } } catch (AbstractTruffleException ex) { CompilerAsserts.partialEvaluationConstant($bci); @@ -5882,9450 +6218,8711 @@ private static long SLAdd_q_AddLong_executeLong_(VirtualFrame $frame, SLOperatio } } - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); + private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; + private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } + } - @Override - public NodeCost getCost() { - return NodeCost.NONE; + private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 7) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } + } - T insertAccessor(T node) { - return super.insert(node); + private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + { + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + { + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + { + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + { + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + { + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; + private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + { + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + { + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + { + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + { + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + { + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + { + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + { + SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLAdd.q.AddLong + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : + { + SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : + { + SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } + } - @Override - public NodeCost getCost() { - return NodeCost.NONE; + private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + return $sp; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + return $sp; + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } + } - T insertAccessor(T node) { - return super.insert(node); + private static int instructionGroup_14(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + private static int instructionGroup_15(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - CompilerDirectives.transferToInterpreterAndInvalidate(); - Counter uncachedExecuteCount = new Counter(); - uncachedExecuteCount.count = $this.uncachedExecuteCount; - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - curOpcode = (curOpcode >> 3) & 8191; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_RETURN : + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount.count; - } - return (($sp - 1) << 16) | 0xffff; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - default : - int _enc = __helper1($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - $bci = _enc & 0xffff; - $sp = (_enc >> 16) & 0xffff; - continue loop; } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - throw ex; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; + private static int instructionGroup_19(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_22(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_23(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_24(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_25(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_26(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_27(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_28(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; - } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); - break; + private static int instructionGroup_30(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_LOAD_CONSTANT : - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - $bci = $bci + LOAD_CONSTANT_LENGTH; - target.add(dec); - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_LOAD_ARGUMENT : - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_LOAD_LOCAL : - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_LOAD_LOCAL_BOXED : - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_STORE_LOCAL : - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; - target.add(dec); - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_RETURN : - { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_LOAD_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } } - case INSTR_STORE_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_ADD : - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; - target.add(dec); - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_DIV : - { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; - target.add(dec); - break; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } } - case INSTR_C_SL_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; - target.add(dec); - break; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } } - case INSTR_C_SL_LESS_OR_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_THAN : - { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_MUL : - { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_SUB : - { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_INVOKE : - { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_AND : - { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_OR : - { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_32(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += LOAD_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_UNBOX_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_ADD_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_ARGUMENT_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += STORE_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_ARGUMENT_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += STORE_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += LOAD_LOCAL_LENGTH; + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_33(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += LOAD_ARGUMENT_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += STORE_LOCAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += LOAD_LOCAL_LENGTH; + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_ADD_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += STORE_LOCAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += LOAD_ARGUMENT_LENGTH; + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += STORE_LOCAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_34(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_CONSTANT_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_READ_PROPERTY_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_37(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_LOCAL_BOXED_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_ADD_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; + case 1 /* LONG */ : { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += LOAD_CONSTANT_LENGTH; + case 5 /* BOOLEAN */ : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + CompilerDirectives.transferToInterpreterAndInvalidate(); + Counter uncachedExecuteCount = new Counter(); + uncachedExecuteCount.count = $this.uncachedExecuteCount; + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + curOpcode = (curOpcode >> 3) & 8191; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case INSTR_BRANCH : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + continue loop; } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case INSTR_BRANCH_FALSE : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } } - $bci += LOAD_CONSTANT_LENGTH; + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case INSTR_THROW : { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); } - $bci += C_SL_READ_PROPERTY_LENGTH; + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_RETURN : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount.count; + } + return (($sp - 1) << 16) | 0xffff; } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_AND : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_SC_SL_OR : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } } - $bci += C_SL_UNBOX_LENGTH; + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + } + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); + // length group 1 + case INSTR_POP : + $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 1; + continue loop; + // length group 2 + case INSTR_LOAD_CONSTANT : + case INSTR_LOAD_ARGUMENT : + case INSTR_LOAD_LOCAL : + case INSTR_LOAD_LOCAL_BOXED : + case INSTR_LOAD_LOCAL_MAT : + case INSTR_STORE_LOCAL_MAT : + $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 2; + continue loop; + // length group 3 + case INSTR_STORE_LOCAL : + $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 3; + continue loop; + // length group 5 + case INSTR_C_SL_EQUAL : + case INSTR_C_SL_LESS_OR_EQUAL : + case INSTR_C_SL_LESS_THAN : + case INSTR_C_SL_LOGICAL_NOT : + case INSTR_C_SL_UNBOX : + case INSTR_C_SL_FUNCTION_LITERAL : + case INSTR_C_SL_TO_BOOLEAN : + $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 5; + continue loop; + // length group 6 + case INSTR_C_SL_ADD : + case INSTR_C_SL_DIV : + case INSTR_C_SL_MUL : + case INSTR_C_SL_READ_PROPERTY : + case INSTR_C_SL_SUB : + $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 6; + continue loop; + // length group 7 + case INSTR_C_SL_WRITE_PROPERTY : + case INSTR_C_SL_INVOKE : + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 7; + continue loop; + // length group 14 + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + $sp = instructionGroup_14($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 14; + continue loop; + // length group 15 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + $sp = instructionGroup_15($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 15; + continue loop; + // length group 19 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + $sp = instructionGroup_19($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 19; + continue loop; + // length group 22 + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + $sp = instructionGroup_22($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 22; + continue loop; + // length group 23 + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + $sp = instructionGroup_23($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 23; + continue loop; + // length group 24 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + $sp = instructionGroup_24($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 24; + continue loop; + // length group 25 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + $sp = instructionGroup_25($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 25; + continue loop; + // length group 26 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + $sp = instructionGroup_26($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 26; + continue loop; + // length group 27 + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + $sp = instructionGroup_27($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 27; + continue loop; + // length group 28 + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + $sp = instructionGroup_28($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 28; + continue loop; + // length group 30 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + $sp = instructionGroup_30($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 30; + continue loop; + // length group 32 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + $sp = instructionGroup_32($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 32; + continue loop; + // length group 33 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + $sp = instructionGroup_33($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 33; + continue loop; + // length group 34 + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + $sp = instructionGroup_34($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 34; + continue loop; + // length group 37 + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + $sp = instructionGroup_37($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 37; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + case INSTR_BRANCH : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + BRANCH_LENGTH; break; } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + case INSTR_BRANCH_FALSE : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); + $bci = $bci + BRANCH_FALSE_LENGTH; break; } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + case INSTR_THROW : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); + $bci = $bci + THROW_LENGTH; break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + case INSTR_LOAD_CONSTANT : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); + $bci = $bci + LOAD_CONSTANT_LENGTH; break; } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + case INSTR_LOAD_ARGUMENT : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); + $bci = $bci + LOAD_ARGUMENT_LENGTH; break; } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + case INSTR_LOAD_LOCAL : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + LOAD_LOCAL_LENGTH; break; } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + case INSTR_LOAD_LOCAL_BOXED : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + case INSTR_STORE_LOCAL : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + STORE_LOCAL_LENGTH; break; } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + case INSTR_RETURN : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + RETURN_LENGTH; break; } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + case INSTR_LOAD_LOCAL_MAT : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; break; } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + case INSTR_STORE_LOCAL_MAT : { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); + $bci = $bci + STORE_LOCAL_MAT_LENGTH; break; } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLDivNode.div($child0Value_, $child1Value_); } } - return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - - private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); - private static final BytecodeLoopBase UNCOMMON_EXECUTE = new BytecodeNode(); - private static final BytecodeLoopBase COMMON_EXECUTE = UNCOMMON_EXECUTE; - private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); - private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; - private static final short INSTR_POP = 1; - private static final int POP_LENGTH = 1; - private static final short INSTR_BRANCH = 2; - private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_LENGTH = 2; - private static final short INSTR_BRANCH_FALSE = 3; - private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; - private static final int BRANCH_FALSE_LENGTH = 3; - private static final short INSTR_THROW = 4; - private static final int THROW_LOCALS_OFFSET = 1; - private static final int THROW_LENGTH = 2; - private static final short INSTR_LOAD_CONSTANT = 5; - private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; - private static final int LOAD_CONSTANT_LENGTH = 2; - private static final short INSTR_LOAD_ARGUMENT = 6; - private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; - private static final int LOAD_ARGUMENT_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL = 7; - private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL_BOXED = 8; - private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_BOXED_LENGTH = 2; - private static final short INSTR_STORE_LOCAL = 9; - private static final int STORE_LOCAL_LOCALS_OFFSET = 1; - private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; - private static final int STORE_LOCAL_LENGTH = 3; - private static final short INSTR_RETURN = 10; - private static final int RETURN_LENGTH = 1; - private static final short INSTR_LOAD_LOCAL_MAT = 11; - private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int LOAD_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_STORE_LOCAL_MAT = 12; - private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int STORE_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_INSTRUMENT_ENTER = 13; - private static final int INSTRUMENT_ENTER_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; - private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT = 15; - private static final int INSTRUMENT_EXIT_LENGTH = 2; - private static final short INSTR_INSTRUMENT_LEAVE = 16; - private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; - private static final int INSTRUMENT_LEAVE_LENGTH = 4; - private static final short INSTR_C_SL_ADD = 17; - private static final int C_SL_ADD_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_LENGTH = 6; - private static final short INSTR_C_SL_DIV = 18; - private static final int C_SL_DIV_CONSTANT_OFFSET = 1; - private static final int C_SL_DIV_CHILDREN_OFFSET = 2; - private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; - private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - private static final int C_SL_DIV_LENGTH = 6; - private static final short INSTR_C_SL_EQUAL = 19; - private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; - private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; - private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - private static final int C_SL_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; - private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_THAN = 21; - private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_THAN_LENGTH = 5; - private static final short INSTR_C_SL_LOGICAL_NOT = 22; - private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; - private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; - private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - private static final int C_SL_LOGICAL_NOT_LENGTH = 5; - private static final short INSTR_C_SL_MUL = 23; - private static final int C_SL_MUL_CONSTANT_OFFSET = 1; - private static final int C_SL_MUL_CHILDREN_OFFSET = 2; - private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - private static final int C_SL_MUL_LENGTH = 6; - private static final short INSTR_C_SL_READ_PROPERTY = 24; - private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_LENGTH = 6; - private static final short INSTR_C_SL_SUB = 25; - private static final int C_SL_SUB_CONSTANT_OFFSET = 1; - private static final int C_SL_SUB_CHILDREN_OFFSET = 2; - private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; - private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - private static final int C_SL_SUB_LENGTH = 6; - private static final short INSTR_C_SL_WRITE_PROPERTY = 26; - private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; - private static final short INSTR_C_SL_UNBOX = 27; - private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_LENGTH = 5; - private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; - private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; - private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; - private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; - private static final short INSTR_C_SL_TO_BOOLEAN = 29; - private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; - private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; - private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_TO_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_INVOKE = 30; - private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; - private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; - private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; - private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; - private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; - private static final int C_SL_INVOKE_LENGTH = 7; - private static final short INSTR_SC_SL_AND = 31; - private static final int SC_SL_AND_CONSTANT_OFFSET = 1; - private static final int SC_SL_AND_CHILDREN_OFFSET = 2; - private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - private static final int SC_SL_AND_LENGTH = 6; - private static final short INSTR_SC_SL_OR = 32; - private static final int SC_SL_OR_CONSTANT_OFFSET = 1; - private static final int SC_SL_OR_CHILDREN_OFFSET = 2; - private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - private static final int SC_SL_OR_LENGTH = 6; - private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 33; - private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 34; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 35; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 37; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; - private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 38; - private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; - private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; - private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; - private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; - private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; - private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; - private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; - private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; - private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; - private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; - private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; - private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; - private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; - private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; - - @CompilationFinal private OperationNodesImpl nodes; - @CompilationFinal(dimensions = 1) private short[] _bc; - @CompilationFinal(dimensions = 1) private Object[] _consts; - @Children private Node[] _children; - @CompilationFinal(dimensions = 1) private byte[] _localTags; - @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; - @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; - @CompilationFinal private int _maxLocals; - @CompilationFinal private int _maxStack; - @CompilationFinal(dimensions = 1) private int[] sourceInfo; - @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; - @CompilationFinal private int uncachedExecuteCount = 16; - @CompilationFinal private Object _osrMetadata; - private TruffleString _metadata_MethodName; - - private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); - } - - private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { - this(language, builder.build()); - } - - static { - OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); - } - - @SuppressWarnings("unchecked") - private static RuntimeException sneakyThrow(Throwable e) throws E { //() { - throw (E) e; - } - - private T insertAccessor(T node) { // () { - return insert(node); - } - - private Object executeAt(VirtualFrame frame, int storedLocation) { - int result = storedLocation; - while (true) { - result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); - if ((result & 0xffff) == 0xffff) { - break; - } else { - SLOperationRootNodeGen $this = this; - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - } - return frame.getObject((result >> 16) & 0xffff); - } - - @Override - public SourceSection getSourceSection() { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if (sourceInfo[i + 1] >= 0) { - int sourceIndex = sourceInfo[i + 0] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - return null; - } - - @Override - public SourceSection getSourceSectionAtBci(int bci) { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if ((sourceInfo[i + 0] & 0xffff) > bci) { - break; - } - } - if (i == 0) { - return null; - } else { - i -= 3; - int sourceIndex = sourceInfo[i + 0] >> 16; - if (sourceIndex < 0) { - return null; - } - int sourceStart = sourceInfo[i + 1]; - if (sourceStart < 0) { - return null; - } - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - - @Override - public Object execute(VirtualFrame frame) { - Object returnValue = null; - Throwable throwable = null; - executeProlog(frame); - try { - returnValue = executeAt(frame, _maxLocals << 16); - return returnValue; - } catch (Throwable th) { - throw sneakyThrow(throwable = th); - } finally { - executeEpilog(frame, returnValue, throwable); - } - } - - @Override - public OperationIntrospection getIntrospectionData() { - return switchImpl.getIntrospectionData(_bc, _handlers, _consts, nodes, sourceInfo); - } - - private Lock getLockAccessor() { - return getLock(); - } - - @Override - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return executeAt(osrFrame, target); - } - - @Override - public Object getOSRMetadata() { - return _osrMetadata; - } - - @Override - public void setOSRMetadata(Object osrMetadata) { - _osrMetadata = osrMetadata; - } - - @Override - public Node deepCopy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = Arrays.copyOf(_bc, _bc.length); - result._consts = Arrays.copyOf(_consts, _consts.length); - result._children = Arrays.copyOf(_children, _children.length); - result._localTags = Arrays.copyOf(_localTags, _localTags.length); - result._handlers = _handlers; - result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - @Override - public Node copy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = _bc; - result._consts = _consts; - result._children = _children; - result._localTags = _localTags; - result._handlers = _handlers; - result._conditionProfiles = _conditionProfiles; - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - private void changeInterpreters(BytecodeLoopBase impl) { - this.switchImpl = impl; - } - - @BytecodeInterpreterSwitch - private static int execute_POP(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_BRANCH(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - } - $bci = targetBci; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } - - @BytecodeInterpreterSwitch - private static int execute_THROW(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_ARGUMENT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - Object value; - switch (UFA.unsafeGetTag($frame, localIdx)) { - case 0 /* OBJECT */ : - value = UFA.unsafeUncheckedGetObject($frame, localIdx); - break; - case 5 /* BOOLEAN */ : - value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); - break; - case 1 /* LONG */ : - value = UFA.unsafeUncheckedGetLong($frame, localIdx); - break; - default : - throw CompilerDirectives.shouldNotReachHere(); - } - UFA.unsafeSetObject($frame, $sp, value); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_BOXED_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - $bci -= LOAD_LOCAL_BOXED_LENGTH; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_BOXED_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_BOXED_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { - CompilerAsserts.neverPartOfCompilation(); - Object value = $frame.getValue(sourceSlot); - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); - // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); - if (bciOffset != 0) { - if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { - if (value instanceof Boolean) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */)); - doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); - return; - } - } - if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { - if (value instanceof Long) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */)); - doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) value); - return; - } - } - doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); - } - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 7 /* generic */)); - UFA.unsafeSetObject($frame, localIdx, value); - } - - private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); - } - - @BytecodeInterpreterSwitch - private static int execute_STORE_LOCAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 5 /* BOOLEAN */) { - try { - UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); - } - - @BytecodeInterpreterSwitch - private static int execute_STORE_LOCAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 1 /* LONG */) { - try { - UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); - } - - @BytecodeInterpreterSwitch - private static int execute_STORE_LOCAL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void do_storeLocal_null(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - try { - UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); - } - } - - @BytecodeInterpreterSwitch - private static int execute_STORE_LOCAL_GENERIC(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - $bci = $bci + STORE_LOCAL_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_LOAD_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_STORE_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_ADD_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_ADD_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_DIV_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_DIV_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_EQUAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_EQUAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LESS_OR_EQUAL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LESS_OR_EQUAL_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LESS_THAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LESS_THAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LOGICAL_NOT_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_LOGICAL_NOT_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_MUL_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_MUL_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_SUB_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_SUB_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_WRITE_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_FUNCTION_LITERAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_TO_BOOLEAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_TO_BOOLEAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_INVOKE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - $bci = $bci + C_SL_INVOKE_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SC_SL_AND_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } - - @BytecodeInterpreterSwitch - private static int execute_SC_SL_AND_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } - - @BytecodeInterpreterSwitch - private static int execute_SC_SL_OR_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } - - @BytecodeInterpreterSwitch - private static int execute_SC_SL_OR_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } - - private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_LONG_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_UNBOX_Q_FROM_BOOLEAN_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_ADD_Q_ADD_LONG_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - @BytecodeInterpreterSwitch - private static int execute_C_SL_ADD_Q_ADD_LONG_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; + } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_CONSTANT : + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + $bci = $bci + LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_ARGUMENT : + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL : + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL : + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_RETURN : + { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; + $bci = $bci + RETURN_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD : + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_DIV : + { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_THAN : + { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_MUL : + { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_SUB : + { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_INVOKE : + { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; + $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_AND : + { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_AND_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + } } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - $bci -= LOAD_LOCAL_BOXED_LENGTH; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLDivNode.div($child0Value_, $child1Value_); + } } + return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + return SLEqualNode.doString($child0Value_, $child1Value_); + } } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + } } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLEqualNode.doFunction($child0Value_, $child1Value); } + return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); + } + + private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLMulNode.mul($child0Value_, $child1Value_); + } } + return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLSubNode.sub($child0Value_, $child1Value_); + } } + return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - $bci -= LOAD_LOCAL_BOXED_LENGTH; - break; + + private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } + + private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case INSTR_POP : + { + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + } + + private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_CONSTANT : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_ARGUMENT : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case INSTR_LOAD_LOCAL : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_BOXED : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case INSTR_LOAD_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case INSTR_STORE_LOCAL_MAT : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case INSTR_STORE_LOCAL : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + } + + private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case INSTR_C_SL_EQUAL : + { + SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_OR_EQUAL : + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case INSTR_C_SL_LESS_THAN : + { + SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_LOGICAL_NOT : + { + SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case INSTR_C_SL_UNBOX : + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case INSTR_C_SL_FUNCTION_LITERAL : + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case INSTR_C_SL_TO_BOOLEAN : + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case INSTR_C_SL_ADD : + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case INSTR_C_SL_DIV : + { + SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case INSTR_C_SL_MUL : + { + SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case INSTR_C_SL_READ_PROPERTY : + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case INSTR_C_SL_SUB : + { + SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + } + + private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case INSTR_C_SL_WRITE_PROPERTY : + { + SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + return $sp; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case INSTR_C_SL_INVOKE : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + return $sp; + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + } + + private static int instructionGroup_14(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static int instructionGroup_15(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + } + + private static int instructionGroup_19(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + } + + private static int instructionGroup_22(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + private static int instructionGroup_23(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static int instructionGroup_24(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static int instructionGroup_25(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static int instructionGroup_26(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + private static int instructionGroup_27(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static int instructionGroup_28(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + private static int instructionGroup_30(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return $sp; + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + private static int instructionGroup_32(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + } + + private static int instructionGroup_33(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + private static int instructionGroup_34(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + } + + private static int instructionGroup_37(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; - } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + private static boolean isAdoptable() { + return true; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return ($sp << 16) | $bci; - } + private static final class SLReadProperty_ReadSLObject0Data extends Node { - @BytecodeInterpreterSwitch - private static int execute_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return ($sp << 16) | $bci; - } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { - @BytecodeInterpreterSwitch - private static int execute_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + + T insertAccessor(T node) { + return super.insert(node); } + } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; + } + private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); + private static final BytecodeLoopBase UNCOMMON_EXECUTE = new BytecodeNode(); + private static final BytecodeLoopBase COMMON_EXECUTE = UNCOMMON_EXECUTE; + private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); + private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; + private static final short INSTR_POP = 1; + private static final int POP_LENGTH = 1; + private static final short INSTR_BRANCH = 2; + private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_LENGTH = 2; + private static final short INSTR_BRANCH_FALSE = 3; + private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; + private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; + private static final int BRANCH_FALSE_LENGTH = 3; + private static final short INSTR_THROW = 4; + private static final int THROW_LOCALS_OFFSET = 1; + private static final int THROW_LENGTH = 2; + private static final short INSTR_LOAD_CONSTANT = 5; + private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; + private static final int LOAD_CONSTANT_LENGTH = 2; + private static final short INSTR_LOAD_ARGUMENT = 6; + private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; + private static final int LOAD_ARGUMENT_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL = 7; + private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_LENGTH = 2; + private static final short INSTR_LOAD_LOCAL_BOXED = 8; + private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; + private static final int LOAD_LOCAL_BOXED_LENGTH = 2; + private static final short INSTR_STORE_LOCAL = 9; + private static final int STORE_LOCAL_LOCALS_OFFSET = 1; + private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; + private static final int STORE_LOCAL_LENGTH = 3; + private static final short INSTR_RETURN = 10; + private static final int RETURN_LENGTH = 1; + private static final short INSTR_LOAD_LOCAL_MAT = 11; + private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int LOAD_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_STORE_LOCAL_MAT = 12; + private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; + private static final int STORE_LOCAL_MAT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_ENTER = 13; + private static final int INSTRUMENT_ENTER_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; + private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; + private static final short INSTR_INSTRUMENT_EXIT = 15; + private static final int INSTRUMENT_EXIT_LENGTH = 2; + private static final short INSTR_INSTRUMENT_LEAVE = 16; + private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; + private static final int INSTRUMENT_LEAVE_LENGTH = 4; + private static final short INSTR_C_SL_ADD = 17; + private static final int C_SL_ADD_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_LENGTH = 6; + private static final short INSTR_C_SL_DIV = 18; + private static final int C_SL_DIV_CONSTANT_OFFSET = 1; + private static final int C_SL_DIV_CHILDREN_OFFSET = 2; + private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; + private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; + private static final int C_SL_DIV_LENGTH = 6; + private static final short INSTR_C_SL_EQUAL = 19; + private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; + private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; + private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; + private static final int C_SL_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; + private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; + private static final short INSTR_C_SL_LESS_THAN = 21; + private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; + private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; + private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_LESS_THAN_LENGTH = 5; + private static final short INSTR_C_SL_LOGICAL_NOT = 22; + private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; + private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; + private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; + private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; + private static final int C_SL_LOGICAL_NOT_LENGTH = 5; + private static final short INSTR_C_SL_MUL = 23; + private static final int C_SL_MUL_CONSTANT_OFFSET = 1; + private static final int C_SL_MUL_CHILDREN_OFFSET = 2; + private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; + private static final int C_SL_MUL_LENGTH = 6; + private static final short INSTR_C_SL_READ_PROPERTY = 24; + private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_LENGTH = 6; + private static final short INSTR_C_SL_SUB = 25; + private static final int C_SL_SUB_CONSTANT_OFFSET = 1; + private static final int C_SL_SUB_CHILDREN_OFFSET = 2; + private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; + private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; + private static final int C_SL_SUB_LENGTH = 6; + private static final short INSTR_C_SL_WRITE_PROPERTY = 26; + private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; + private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; + private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; + private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; + private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; + private static final short INSTR_C_SL_UNBOX = 27; + private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_LENGTH = 5; + private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; + private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; + private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; + private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; + private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; + private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; + private static final short INSTR_C_SL_TO_BOOLEAN = 29; + private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; + private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; + private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; + private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; + private static final int C_SL_TO_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_INVOKE = 30; + private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; + private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; + private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; + private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; + private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; + private static final int C_SL_INVOKE_LENGTH = 7; + private static final short INSTR_SC_SL_AND = 31; + private static final int SC_SL_AND_CONSTANT_OFFSET = 1; + private static final int SC_SL_AND_CHILDREN_OFFSET = 2; + private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; + private static final int SC_SL_AND_LENGTH = 6; + private static final short INSTR_SC_SL_OR = 32; + private static final int SC_SL_OR_CONSTANT_OFFSET = 1; + private static final int SC_SL_OR_CHILDREN_OFFSET = 2; + private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; + private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; + private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; + private static final int SC_SL_OR_LENGTH = 6; + private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 33; + private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 34; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 35; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 37; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 38; + private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; + private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; + private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; + private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; + private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; + private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; + private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; + private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; + private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; + private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; + private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; + private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; + private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; + private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; + + @CompilationFinal private OperationNodesImpl nodes; + @CompilationFinal(dimensions = 1) private short[] _bc; + @CompilationFinal(dimensions = 1) private Object[] _consts; + @Children private Node[] _children; + @CompilationFinal(dimensions = 1) private byte[] _localTags; + @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; + @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; + @CompilationFinal private int _maxLocals; + @CompilationFinal private int _maxStack; + @CompilationFinal(dimensions = 1) private int[] sourceInfo; + @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; + @CompilationFinal private int uncachedExecuteCount = 16; + @CompilationFinal private Object _osrMetadata; + private TruffleString _metadata_MethodName; + + private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { + super(language, frameDescriptor); } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; + private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { + this(language, builder.build()); } - @BytecodeInterpreterSwitch - private static int execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + static { + OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); + } + + @SuppressWarnings("unchecked") + private static RuntimeException sneakyThrow(Throwable e) throws E { //() { + throw (E) e; + } + + private T insertAccessor(T node) { // () { + return insert(node); + } + + private Object executeAt(VirtualFrame frame, int storedLocation) { + int result = storedLocation; + while (true) { + result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); + if ((result & 0xffff) == 0xffff) { break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { + } else { + SLOperationRootNodeGen $this = this; CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - $bci -= LOAD_LOCAL_BOXED_LENGTH; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + return frame.getObject((result >> 16) & 0xffff); + } + + @Override + public SourceSection getSourceSection() { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if (sourceInfo[i + 1] >= 0) { + int sourceIndex = sourceInfo[i + 0] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); } } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; + return null; } - @BytecodeInterpreterSwitch - private static int execute_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + @Override + public SourceSection getSourceSectionAtBci(int bci) { + int[] sourceInfo = this.sourceInfo; + if (sourceInfo == null) { + return null; } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + int i; + for (i = 0; i < sourceInfo.length; i += 3) { + if ((sourceInfo[i + 0] & 0xffff) > bci) { break; } } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + if (i == 0) { + return null; + } else { + i -= 3; + int sourceIndex = sourceInfo[i + 0] >> 16; + if (sourceIndex < 0) { + return null; } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; + int sourceStart = sourceInfo[i + 1]; + if (sourceStart < 0) { + return null; } + int sourceLength = sourceInfo[i + 2]; + return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + } + + @Override + public Object execute(VirtualFrame frame) { + Object returnValue = null; + Throwable throwable = null; + executeProlog(frame); + try { + returnValue = executeAt(frame, _maxLocals << 16); + return returnValue; + } catch (Throwable th) { + throw sneakyThrow(throwable = th); + } finally { + executeEpilog(frame, returnValue, throwable); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; } - @BytecodeInterpreterSwitch - private static int execute_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { + @Override + public OperationIntrospection getIntrospectionData() { + return switchImpl.getIntrospectionData(_bc, _handlers, _consts, nodes, sourceInfo); + } + + private Lock getLockAccessor() { + return getLock(); + } + + @Override + public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { + return executeAt(osrFrame, target); + } + + @Override + public Object getOSRMetadata() { + return _osrMetadata; + } + + @Override + public void setOSRMetadata(Object osrMetadata) { + _osrMetadata = osrMetadata; + } + + @Override + public Node deepCopy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = Arrays.copyOf(_bc, _bc.length); + result._consts = Arrays.copyOf(_consts, _consts.length); + result._children = Arrays.copyOf(_children, _children.length); + result._localTags = Arrays.copyOf(_localTags, _localTags.length); + result._handlers = _handlers; + result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + @Override + public Node copy() { + SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); + result.nodes = nodes; + result._bc = _bc; + result._consts = _consts; + result._children = _children; + result._localTags = _localTags; + result._handlers = _handlers; + result._conditionProfiles = _conditionProfiles; + result._maxLocals = _maxLocals; + result._maxStack = _maxStack; + result.sourceInfo = sourceInfo; + result._metadata_MethodName = _metadata_MethodName; + return result; + } + + private void changeInterpreters(BytecodeLoopBase impl) { + this.switchImpl = impl; + } + + private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + Object value; + switch (UFA.unsafeGetTag($frame, localIdx)) { case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + value = UFA.unsafeUncheckedGetObject($frame, localIdx); break; - } case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); break; - } case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + value = UFA.unsafeUncheckedGetLong($frame, localIdx); break; - } + default : + throw CompilerDirectives.shouldNotReachHere(); } - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; + UFA.unsafeSetObject($frame, $sp, value); + return; } - @BytecodeInterpreterSwitch - private static int execute_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; + } } } - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); } - @BytecodeInterpreterSwitch - private static int __helper0(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : - { - return execute_POP($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - return execute_BRANCH($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - return execute_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - return execute_THROW($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - { - return execute_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - { - return execute_LOAD_ARGUMENT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - { - return execute_LOAD_LOCAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - { - return execute_LOAD_LOCAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - { - return execute_LOAD_LOCAL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - { - return execute_LOAD_LOCAL_BOXED_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - { - return execute_LOAD_LOCAL_BOXED_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - { - return execute_LOAD_LOCAL_BOXED_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - { - return execute_STORE_LOCAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - { - return execute_STORE_LOCAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - { - return execute_STORE_LOCAL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_STORE_LOCAL << 3) | 7) : - { - return execute_STORE_LOCAL_GENERIC($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - { - return execute_LOAD_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - { - return execute_STORE_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_ADD_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - { - return execute_C_SL_ADD_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_DIV_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - { - return execute_C_SL_DIV_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_EQUAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_EQUAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_LESS_OR_EQUAL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_LESS_OR_EQUAL_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_LESS_THAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_LESS_THAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_LOGICAL_NOT_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_LOGICAL_NOT_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_MUL_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - { - return execute_C_SL_MUL_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - return execute_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_SUB_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - { - return execute_C_SL_SUB_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - return execute_C_SL_WRITE_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_UNBOX_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - return execute_C_SL_UNBOX_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_UNBOX_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - { - return execute_C_SL_FUNCTION_LITERAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_TO_BOOLEAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_TO_BOOLEAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - return execute_C_SL_INVOKE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : - { - return execute_SC_SL_AND_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : - { - return execute_SC_SL_AND_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : - { - return execute_SC_SL_OR_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : - { - return execute_SC_SL_OR_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_UNBOX_Q_FROM_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - { - return execute_C_SL_UNBOX_Q_FROM_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_UNBOX_Q_FROM_LONG_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLUnbox.q.FromBigNumber - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLUnbox.q.FromBigNumber.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - { - return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - return execute_C_SL_UNBOX_Q_FROM_BOOLEAN_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - { - return execute_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : - { - return execute_C_SL_ADD_Q_ADD_LONG_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : - { - return execute_C_SL_ADD_Q_ADD_LONG_LONG($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - return execute_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - return execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - { - return execute_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - return execute_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - { - return execute_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - return execute_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - return execute_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags); + private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); + return; + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); } - @BytecodeInterpreterSwitch - private static int executeUncached_POP(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int executeUncached_BRANCH(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } + private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Boolean) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); + UFA.unsafeSetBoolean($frame, $sp, (boolean) result); + return; } } - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } } - $bci = targetBci; - return ($sp << 16) | $bci; + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); } - @BytecodeInterpreterSwitch - private static int executeUncached_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; + private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + try { + UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); + return; + } catch (FrameSlotTypeException | ClassCastException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object result = $frame.getValue(localIdx); + if (result instanceof Long) { + if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); + } else { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) result); + UFA.unsafeSetLong($frame, $sp, (long) result); + return; + } + } } + Object result = $frame.getValue(localIdx); + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); + UFA.unsafeSetObject($frame, localIdx, result); + UFA.unsafeSetObject($frame, $sp, result); } - @BytecodeInterpreterSwitch - private static int executeUncached_THROW(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - - @BytecodeInterpreterSwitch - private static int executeUncached_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int executeUncached_LOAD_ARGUMENT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - return ($sp << 16) | $bci; - } - - @BytecodeInterpreterSwitch - private static int executeUncached_LOAD_LOCAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - return ($sp << 16) | $bci; + private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { + CompilerAsserts.neverPartOfCompilation(); + Object value = $frame.getValue(sourceSlot); + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); + // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); + if (bciOffset != 0) { + if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { + if (value instanceof Boolean) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */)); + doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); + UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); + return; + } + } + if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { + if (value instanceof Long) { + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */)); + doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); + UFA.unsafeSetLong($frame, localIdx, (long) value); + return; + } + } + doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); + } + UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 7 /* generic */)); + UFA.unsafeSetObject($frame, localIdx, value); } - @BytecodeInterpreterSwitch - private static int executeUncached_LOAD_LOCAL_BOXED(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - return ($sp << 16) | $bci; + private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); } - @BytecodeInterpreterSwitch - private static int executeUncached_STORE_LOCAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - return ($sp << 16) | $bci; + private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 5 /* BOOLEAN */) { + try { + UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); } - @BytecodeInterpreterSwitch - private static int executeUncached_LOAD_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - return ($sp << 16) | $bci; + private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + if (curKind == 1 /* LONG */) { + try { + UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); + return; + } catch (FrameSlotTypeException ex) { + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); } - @BytecodeInterpreterSwitch - private static int executeUncached_STORE_LOCAL_MAT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - return ($sp << 16) | $bci; + private static void do_storeLocal_null(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { + int sourceSlot = $sp - 1; + byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); + try { + UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); + } catch (FrameSlotTypeException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); + } } - private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - return ($sp << 16) | $bci; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_DIV(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_DIV_LENGTH; - return ($sp << 16) | $bci; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_EQUAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_EQUAL_LENGTH; - return ($sp << 16) | $bci; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_LESS_OR_EQUAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - return ($sp << 16) | $bci; + private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_LESS_THAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - return ($sp << 16) | $bci; + private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_LOGICAL_NOT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_MUL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_MUL_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_SUB(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_SUB_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_WRITE_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_FUNCTION_LITERAL(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_TO_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - return ($sp << 16) | $bci; + private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); + private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_C_SL_INVOKE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - $bci = $bci + C_SL_INVOKE_LENGTH; - return ($sp << 16) | $bci; + private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_SC_SL_AND(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; + private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); } } - @BytecodeInterpreterSwitch - private static int executeUncached_SC_SL_OR(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } + private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return ($sp << 16) | $bci; + private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int executeUncached_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - } - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - return ($sp << 16) | $bci; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - return ($sp << 16) | $bci; - } - } + private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 3; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - @BytecodeInterpreterSwitch - private static int __helper1(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, int[] $conditionProfiles, Counter loopCounter, int curOpcode, byte[] $localTags, Counter uncachedExecuteCount) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_POP : - { - return executeUncached_POP($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case INSTR_BRANCH : - { - return executeUncached_BRANCH($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case INSTR_BRANCH_FALSE : - { - return executeUncached_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case INSTR_THROW : - { - return executeUncached_THROW($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_CONSTANT : - { - return executeUncached_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_ARGUMENT : - { - return executeUncached_LOAD_ARGUMENT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case INSTR_LOAD_LOCAL : - { - return executeUncached_LOAD_LOCAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_BOXED : - { - return executeUncached_LOAD_LOCAL_BOXED($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case INSTR_STORE_LOCAL : - { - return executeUncached_STORE_LOCAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_MAT : - { - return executeUncached_LOAD_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case INSTR_STORE_LOCAL_MAT : - { - return executeUncached_STORE_LOCAL_MAT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD : - { - return executeUncached_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case INSTR_C_SL_DIV : - { - return executeUncached_C_SL_DIV($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case INSTR_C_SL_EQUAL : - { - return executeUncached_C_SL_EQUAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL : - { - return executeUncached_C_SL_LESS_OR_EQUAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN : - { - return executeUncached_C_SL_LESS_THAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_LOGICAL_NOT : - { - return executeUncached_C_SL_LOGICAL_NOT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case INSTR_C_SL_MUL : - { - return executeUncached_C_SL_MUL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case INSTR_C_SL_READ_PROPERTY : - { - return executeUncached_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case INSTR_C_SL_SUB : - { - return executeUncached_C_SL_SUB($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case INSTR_C_SL_WRITE_PROPERTY : - { - return executeUncached_C_SL_WRITE_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX : - { - return executeUncached_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case INSTR_C_SL_FUNCTION_LITERAL : - { - return executeUncached_C_SL_FUNCTION_LITERAL($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_TO_BOOLEAN : - { - return executeUncached_C_SL_TO_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case INSTR_C_SL_INVOKE : - { - return executeUncached_C_SL_INVOKE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_AND : - { - return executeUncached_SC_SL_AND($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_OR : - { - return executeUncached_SC_SL_OR($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - return executeUncached_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - return executeUncached_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - return executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - return executeUncached_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - return executeUncached_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - return executeUncached_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - return executeUncached_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - return executeUncached_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - return executeUncached_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - return executeUncached_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE($frame, $this, $bc, $bci, $sp, $consts, $children, $conditionProfiles, loopCounter, curOpcode, $localTags, uncachedExecuteCount); - } - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } + private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + int destSlot = $sp - 1 - $numVariadics; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); } private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 46e3b9c3e045..45ca6c87aaa9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -379,7 +379,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C generateExecuteCase(ctx, vars, b, varTracer, op, true); } - for (Map.Entry> lenGroup : wrappedInstructions.entrySet()) { + for (Map.Entry> lenGroup : wrappedInstructions.entrySet().stream().sorted((x, y) -> Integer.compare(x.getKey(), y.getKey())).collect(Collectors.toList())) { int instructionLength = lenGroup.getKey(); b.lineComment("length group " + instructionLength); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index fd66c92695a8..cae9dd5248d2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -132,16 +132,16 @@ public static class EmitArguments { private static final String LENGTH_SUFFIX = "_LENGTH"; private int addInstructionArgument(List holder, Object marker) { - if (frozen) { - throw new AssertionError(); - } - int index = -1; if (marker != null) { index = holder.indexOf(marker); } if (index == -1) { + if (frozen) { + throw new AssertionError(); + } + index = holder.size(); holder.add(marker); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java index c0b74068d4dd..bef81efe5ee6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java @@ -114,10 +114,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } } - if (!instructions[instructions.length - 1].isExplicitFlowControl()) { - b.statement("continue loop"); - } - return b.build(); } @@ -132,16 +128,18 @@ public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { } b.end(); } - if (!instructions[instructions.length - 1].isExplicitFlowControl()) { - b.statement("continue loop"); - } return b.build(); } @Override public boolean isExplicitFlowControl() { - return true; + for (Instruction i : instructions) { + if (i.isExplicitFlowControl()) { + return true; + } + } + return false; } @Override From c6ba6d9dd0d1f636e9376c4810cc3530bb6ea302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 21 Nov 2022 09:50:16 +0100 Subject: [PATCH 172/312] [wip] changes --- .../sl/operations/SLOperationRootNodeGen.java | 12735 ++++------------ .../tracing/OperationsStatistics.java | 5 + .../processor/java/model/CodeTreeBuilder.java | 4 + .../OperationsBytecodeCodeGenerator.java | 153 +- .../instructions/BranchInstruction.java | 2 +- .../instructions/ShortCircuitInstruction.java | 18 +- .../sl/operations/SLOperationRootNode.java | 2 +- .../truffle/sl/operations/decisions.json | 156 +- .../sl/parser/SLOperationsVisitor.java | 4 +- 9 files changed, 2828 insertions(+), 10251 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index b3155f3f329d..8b9666b55c0f 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; +import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; @@ -105,377 +106,247 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i int $bci = $startBci; Counter loopCounter = new Counter(); $frame.getArguments(); - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; + ExecutionTracer tracer = ExecutionTracer.get(SLOperationRootNode.class); + tracer.startFunction($this); + try { + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + if ($this.isBbStart[$bci]) { + tracer.traceStartBasicBlock($bci); + } + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_BRANCH, 1, 0); + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } } } } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + $bci = targetBci; continue loop; } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - return (($sp - 1) << 16) | 0xffff; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_BRANCH_FALSE, 1, 0); + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } } - } - case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_THROW, 1, 0); + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_RETURN, 1, 0); + return (($sp - 1) << 16) | 0xffff; } - } - case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } } - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; } - case 5 /* BOOLEAN */ : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; } } - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; + case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // length group 1 + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 1; continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + // length group 2 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 2; continue loop; - } - } - // length group 1 - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 1; - continue loop; - // length group 2 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 2; - continue loop; - // length group 3 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_STORE_LOCAL << 3) | 7) : - $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 3; - continue loop; - // length group 5 - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 5; - continue loop; - // length group 6 - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : - $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 6; - continue loop; - // length group 7 - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 7; - continue loop; - // length group 14 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_14($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 14; - continue loop; - // length group 15 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_15($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 15; - continue loop; - // length group 19 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_19($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 19; - continue loop; - // length group 22 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - $sp = instructionGroup_22($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 22; - continue loop; - // length group 23 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - $sp = instructionGroup_23($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 23; - continue loop; - // length group 24 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_24($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 24; - continue loop; - // length group 25 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_25($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 25; - continue loop; - // length group 26 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_26($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 26; - continue loop; - // length group 27 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - $sp = instructionGroup_27($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 27; - continue loop; - // length group 28 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_28($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 28; - continue loop; - // length group 30 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_30($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 30; - continue loop; - // length group 32 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_32($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 32; - continue loop; - // length group 33 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_33($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 33; - continue loop; - // length group 34 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_34($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 34; - continue loop; - // length group 37 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_37($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 37; + // length group 3 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_STORE_LOCAL << 3) | 7) : + $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 3; + continue loop; + // length group 5 + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 5; + continue loop; + // length group 6 + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 6; + continue loop; + // length group 7 + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 7; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; + } + throw ex; } - throw ex; } + } finally { + tracer.endFunction($this); } } @@ -624,156 +495,6 @@ void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, $bci = $bci + SC_SL_OR_LENGTH; break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; - } } } } @@ -1044,1541 +765,430 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han target.add(dec); break; } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + } + } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLAddNode.addLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value_, $child1Value_); } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLDivNode.divLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLDivNode.div($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; } - return true; + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLAddNode.addLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b1111) == 0b1/* is-exact-state_0 addLong(long, long) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - } + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); try { lock.unlock(); hasLock = false; - return SLAddNode.addLong($child0Value_, $child1Value_); + return SLDivNode.divLong($child0Value_, $child1Value_); } catch (ArithmeticException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); lock.lock(); try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); } finally { lock.unlock(); } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } } } @@ -2589,44 +1199,26 @@ private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperati int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); lock.unlock(); hasLock = false; - return SLAddNode.add($child0Value_, $child1Value_); + return SLDivNode.div($child0Value_, $child1Value_); } } } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } { int fallback_bci__ = 0; Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); lock.unlock(); hasLock = false; - return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } } finally { if (hasLock) { @@ -2635,285 +1227,79 @@ private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperati } } - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); } - return true; } - private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } - assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } - } - - private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLDivNode.divLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLDivNode.div($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLDivNode.div($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); } @SuppressWarnings("static-method") @@ -4211,8 +2597,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); $children[childArrayOffset_ + 0] = s0_; $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); } } } @@ -4242,8 +2626,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); @@ -4284,12 +2666,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); $children[childArrayOffset_ + 4] = s2_; $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } } } if (s2_ != null) { @@ -4311,8 +2687,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, $children[childArrayOffset_ + 4] = null; state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); @@ -4348,8 +2722,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, VarHandle.storeStoreFence(); $children[childArrayOffset_ + 8] = s4_; $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); } } } @@ -4378,8 +2750,6 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, $children[childArrayOffset_ + 8] = null; state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); @@ -5172,8 +3542,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera String $child0Value_ = (String) $child0Value; $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); @@ -5181,8 +3549,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera if ($child0Value instanceof TruffleString) { TruffleString $child0Value_ = (TruffleString) $child0Value; $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLUnboxNode.fromTruffleString($child0Value_); @@ -5190,12 +3556,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera if ($child0Value instanceof Boolean) { boolean $child0Value_ = (boolean) $child0Value; $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } lock.unlock(); hasLock = false; return SLUnboxNode.fromBoolean($child0Value_); @@ -5203,14 +3563,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } lock.unlock(); hasLock = false; return SLUnboxNode.fromLong($child0Value_); @@ -5221,14 +3573,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } lock.unlock(); hasLock = false; return SLUnboxNode.fromBigNumber($child0Value_); @@ -5237,8 +3581,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera if ($child0Value instanceof SLFunction) { SLFunction $child0Value_ = (SLFunction) $child0Value; $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLUnboxNode.fromFunction($child0Value_); @@ -5246,8 +3588,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera if (SLTypes.isSLNull($child0Value)) { SLNull $child0Value_ = SLTypes.asSLNull($child0Value); $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLUnboxNode.fromFunction($child0Value_); @@ -5272,8 +3612,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera VarHandle.storeStoreFence(); $children[childArrayOffset_ + 1] = s7_; $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); } } if (s7_ != null) { @@ -5293,8 +3631,6 @@ private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOpera $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); @@ -5808,577 +4144,377 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperati } } - private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_POP, 0, 0); + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_CONSTANT, 0, 0); + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_ARGUMENT, 0, 0); + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_MAT, 0, 0); + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_STORE_LOCAL_MAT, 0, 0); + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } } - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + { + tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + { + tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 7) : + { + tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); } - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); - } - - @ExplodeLoop - private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLAdd_q_AddLong_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_AddLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static long SLAdd_q_AddLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - - private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : { - $sp = $sp - 1; - $frame.clear($sp); + tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // load.constant + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + { + tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessOrEqual // Constants: - // [ 0] constant - // Always Boxed + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; + tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; + tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - // load.local - // Locals: - // [ 0] local + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 // Split on Boxing Elimination // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; + tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; + tracer.traceInstruction($bci, INSTR_C_SL_FUNCTION_LITERAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_FUNCTION_LITERAL, SLOperationRootNodeGen.doGetStateBits_SLFunctionLiteral_($bc, $bci)); + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] // Indexed Pops: - // [ 0] value + // [ 0] arg0 // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; + tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_STORE_LOCAL << 3) | 7) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; + tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } default : @@ -6386,36 +4522,40 @@ private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // c.SLEqual + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 // [ 1] arg1 // Split on Boxing Elimination // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : { - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : { - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - // c.SLLessOrEqual + // c.SLDiv // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: @@ -6426,20 +4566,25 @@ private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame // Split on Boxing Elimination // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - // c.SLLessThan + // c.SLMul // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: @@ -6450,210 +4595,152 @@ private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame // Split on Boxing Elimination // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : { - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : { - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); $sp += -1; return $sp; } - // c.SLLogicalNot + // c.SLReadProperty // Constants: // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] // Children: - // [ 0] CacheExpression [sourceParameter = node] + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] // Indexed Pops: // [ 0] arg0 - // Split on Boxing Elimination + // [ 1] arg1 + // Always Boxed // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - { - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : { - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_READ_PROPERTY, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_READ_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLReadProperty_($bc, $bci)); + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - // c.SLUnbox + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] + // [ 0] CacheExpression [sourceParameter = node] // Indexed Pops: // [ 0] arg0 + // [ 1] arg1 // Split on Boxing Elimination // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - // c.SLFunctionLiteral + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty // Constants: - // [ 0] CacheExpression [sourceParameter = result] + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] // Children: - // [ 0] CacheExpression [sourceParameter = node] + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] // Indexed Pops: // [ 0] arg0 - // Always Boxed + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : { - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_WRITE_PROPERTY, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_WRITE_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLWriteProperty_($bc, $bci)); + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; return $sp; } - // c.SLToBoolean + // c.SLInvoke // Constants: // [ 0] CacheExpression [sourceParameter = bci] // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] // Indexed Pops: // [ 0] arg0 - // Split on Boxing Elimination + // Variadic + // Always Boxed // Pushed Values: 1 // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : { - SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + tracer.traceInstruction($bci, INSTR_C_SL_INVOKE, 0, 1); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_INVOKE, SLOperationRootNodeGen.doGetStateBits_SLInvoke_($bc, $bci)); + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; return $sp; } default : @@ -6661,6620 +4748,1166 @@ private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - { - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - { - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - { - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - { - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - { - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - { - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - { - SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLAdd.q.AddLong - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 0 /* OBJECT */) : - { - SLAdd_q_AddLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD_Q_ADD_LONG << 3) | 1 /* LONG */) : - { - SLAdd_q_AddLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } + private static boolean isAdoptable() { + return true; } - private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { } - } - private static int instructionGroup_14(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - } - private static int instructionGroup_15(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLEqual_Generic0Data extends Node { - private static int instructionGroup_19(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; } - } - private static int instructionGroup_22(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Override + public NodeCost getCost() { + return NodeCost.NONE; } - } - private static int instructionGroup_23(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLReadProperty_ReadArray0Data extends Node { - private static int instructionGroup_24(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { - private static int instructionGroup_25(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLReadProperty_ReadObject0Data extends Node { - private static int instructionGroup_26(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; } - } - private static int instructionGroup_27(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLWriteProperty_WriteArray0Data extends Node { - private static int instructionGroup_28(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); } + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { - private static int instructionGroup_30(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + $frame.getArguments(); + Counter uncachedExecuteCount = new Counter(); + uncachedExecuteCount.count = $this.uncachedExecuteCount; + ExecutionTracer tracer = ExecutionTracer.get(SLOperationRootNode.class); + tracer.startFunction($this); + try { + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + if ($this.isBbStart[$bci]) { + tracer.traceStartBasicBlock($bci); } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_BRANCH, 1, 0); + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_BRANCH_FALSE, 1, 0); + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_THROW, 1, 0); + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_RETURN, 1, 0); + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount.count; + } + return (($sp - 1) << 16) | 0xffff; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); + if (UncachedBytecodeNode.SLAnd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); + tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); + if (!UncachedBytecodeNode.SLOr_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // length group 1 + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 1; + continue loop; + // length group 2 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + $sp = instructionGroup_2_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 2; + continue loop; + // length group 3 + case ((INSTR_STORE_LOCAL << 3) | 0) : + $sp = instructionGroup_3_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 3; + continue loop; + // length group 5 + case ((INSTR_C_SL_EQUAL << 3) | 0) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : + case ((INSTR_C_SL_UNBOX << 3) | 0) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : + $sp = instructionGroup_5_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 5; + continue loop; + // length group 6 + case ((INSTR_C_SL_ADD << 3) | 0) : + case ((INSTR_C_SL_DIV << 3) | 0) : + case ((INSTR_C_SL_MUL << 3) | 0) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0) : + $sp = instructionGroup_6_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 6; + continue loop; + // length group 7 + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + $sp = instructionGroup_7_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $bci = $bci + 7; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; } + throw ex; } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + } + } finally { + tracer.endFunction($this); + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_32(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_33(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_34(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; } - default : - throw CompilerDirectives.shouldNotReachHere(); } } - private static int instructionGroup_37(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); + break; } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - CompilerDirectives.transferToInterpreterAndInvalidate(); - Counter uncachedExecuteCount = new Counter(); - uncachedExecuteCount.count = $this.uncachedExecuteCount; - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - curOpcode = (curOpcode >> 3) & 8191; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case INSTR_BRANCH : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case INSTR_BRANCH_FALSE : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case INSTR_THROW : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_RETURN : - { - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount.count; - } - return (($sp - 1) << 16) | 0xffff; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_AND : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_SC_SL_OR : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - } - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - } - // length group 1 - case INSTR_POP : - $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 1; - continue loop; - // length group 2 - case INSTR_LOAD_CONSTANT : - case INSTR_LOAD_ARGUMENT : - case INSTR_LOAD_LOCAL : - case INSTR_LOAD_LOCAL_BOXED : - case INSTR_LOAD_LOCAL_MAT : - case INSTR_STORE_LOCAL_MAT : - $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 2; - continue loop; - // length group 3 - case INSTR_STORE_LOCAL : - $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 3; - continue loop; - // length group 5 - case INSTR_C_SL_EQUAL : - case INSTR_C_SL_LESS_OR_EQUAL : - case INSTR_C_SL_LESS_THAN : - case INSTR_C_SL_LOGICAL_NOT : - case INSTR_C_SL_UNBOX : - case INSTR_C_SL_FUNCTION_LITERAL : - case INSTR_C_SL_TO_BOOLEAN : - $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 5; - continue loop; - // length group 6 - case INSTR_C_SL_ADD : - case INSTR_C_SL_DIV : - case INSTR_C_SL_MUL : - case INSTR_C_SL_READ_PROPERTY : - case INSTR_C_SL_SUB : - $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 6; - continue loop; - // length group 7 - case INSTR_C_SL_WRITE_PROPERTY : - case INSTR_C_SL_INVOKE : - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 7; - continue loop; - // length group 14 - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - $sp = instructionGroup_14($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 14; - continue loop; - // length group 15 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - $sp = instructionGroup_15($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 15; - continue loop; - // length group 19 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - $sp = instructionGroup_19($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 19; - continue loop; - // length group 22 - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - $sp = instructionGroup_22($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 22; - continue loop; - // length group 23 - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - $sp = instructionGroup_23($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 23; - continue loop; - // length group 24 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - $sp = instructionGroup_24($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 24; - continue loop; - // length group 25 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - $sp = instructionGroup_25($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 25; - continue loop; - // length group 26 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - $sp = instructionGroup_26($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 26; - continue loop; - // length group 27 - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - $sp = instructionGroup_27($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 27; - continue loop; - // length group 28 - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - $sp = instructionGroup_28($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 28; - continue loop; - // length group 30 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - $sp = instructionGroup_30($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 30; - continue loop; - // length group 32 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - $sp = instructionGroup_32($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 32; - continue loop; - // length group 33 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - $sp = instructionGroup_33($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 33; - continue loop; - // length group 34 - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - $sp = instructionGroup_34($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 34; - continue loop; - // length group 37 - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - $sp = instructionGroup_37($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 37; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : + case INSTR_LOAD_CONSTANT : { - $bci = $bci + POP_LENGTH; + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + $bci = $bci + LOAD_CONSTANT_LENGTH; + target.add(dec); break; } - case INSTR_BRANCH : + case INSTR_LOAD_ARGUMENT : { - $bci = $bci + BRANCH_LENGTH; + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + target.add(dec); break; } - case INSTR_BRANCH_FALSE : + case INSTR_LOAD_LOCAL : { - $bci = $bci + BRANCH_FALSE_LENGTH; + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_LENGTH; + target.add(dec); break; } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : + case INSTR_LOAD_LOCAL_BOXED : { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); break; } case INSTR_STORE_LOCAL : { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); break; } case INSTR_RETURN : { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; $bci = $bci + RETURN_LENGTH; + target.add(dec); break; } case INSTR_LOAD_LOCAL_MAT : { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); break; } case INSTR_STORE_LOCAL_MAT : { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); break; } case INSTR_C_SL_ADD : { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); break; } case INSTR_C_SL_DIV : { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); break; } case INSTR_C_SL_EQUAL : { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); break; } case INSTR_C_SL_LESS_OR_EQUAL : { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); break; } case INSTR_C_SL_LESS_THAN : { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); break; } case INSTR_C_SL_LOGICAL_NOT : { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); break; } case INSTR_C_SL_MUL : { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); break; } case INSTR_C_SL_READ_PROPERTY : { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); break; } case INSTR_C_SL_SUB : { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); break; } case INSTR_C_SL_WRITE_PROPERTY : { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); break; } case INSTR_C_SL_UNBOX : { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); break; } case INSTR_C_SL_FUNCTION_LITERAL : { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); break; } case INSTR_C_SL_TO_BOOLEAN : { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); break; } case INSTR_C_SL_INVOKE : { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); break; } case INSTR_SC_SL_AND : { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; - } - } - } - } - - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; - } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_CONSTANT : - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - $bci = $bci + LOAD_CONSTANT_LENGTH; target.add(dec); break; } - case INSTR_LOAD_ARGUMENT : - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL : - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL : - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_RETURN : - { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD : - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_DIV : - { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_THAN : - { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_MUL : - { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_SUB : - { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_INVOKE : - { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_AND : - { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_OR : - { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.AddLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLDivNode.div($child0Value_, $child1Value_); - } - } - return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - - private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLAdd_q_AddLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case INSTR_POP : - { - $sp = $sp - 1; - $frame.clear($sp); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_CONSTANT : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - return $sp; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_ARGUMENT : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - return $sp; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case INSTR_LOAD_LOCAL : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - return $sp; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_BOXED : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - return $sp; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case INSTR_LOAD_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - return $sp; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case INSTR_STORE_LOCAL_MAT : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case INSTR_STORE_LOCAL : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case INSTR_C_SL_EQUAL : - { - SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_OR_EQUAL : - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case INSTR_C_SL_LESS_THAN : - { - SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_LOGICAL_NOT : - { - SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case INSTR_C_SL_UNBOX : - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case INSTR_C_SL_FUNCTION_LITERAL : - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case INSTR_C_SL_TO_BOOLEAN : - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } } - default : - throw CompilerDirectives.shouldNotReachHere(); } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); } - private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case INSTR_C_SL_ADD : - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case INSTR_C_SL_DIV : - { - SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case INSTR_C_SL_MUL : - { - SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case INSTR_C_SL_READ_PROPERTY : - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; + private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case INSTR_C_SL_SUB : - { - SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLDivNode.div($child0Value_, $child1Value_); } - default : - throw CompilerDirectives.shouldNotReachHere(); } + return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case INSTR_C_SL_WRITE_PROPERTY : - { - SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; + private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLEqualNode.doLong($child0Value_, $child1Value_); } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case INSTR_C_SL_INVOKE : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); } - default : - throw CompilerDirectives.shouldNotReachHere(); } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - private static int instructionGroup_14(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; + private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); } - default : - throw CompilerDirectives.shouldNotReachHere(); } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static int instructionGroup_15(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; + private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); } - default : - throw CompilerDirectives.shouldNotReachHere(); } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static int instructionGroup_19(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); } + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); } - private static int instructionGroup_22(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; + private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLMulNode.mul($child0Value_, $child1Value_); } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return $sp; + } + return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLSubNode.sub($child0Value_, $child1Value_); } - default : - throw CompilerDirectives.shouldNotReachHere(); } + return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } + + private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - private static int instructionGroup_23(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); } - private static int instructionGroup_24(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static int instructionGroup_25(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static int instructionGroup_26(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_1_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_POP, 0, 0); + $sp = $sp - 1; + $frame.clear($sp); return $sp; } default : @@ -13282,54 +5915,82 @@ private static int instructionGroup_26(SLOperationRootNodeGen $this, VirtualFram } } - private static int instructionGroup_27(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_2_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_CONSTANT, 0, 0); + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_ARGUMENT, 0, 0); + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_MAT, 0, 0); + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } + tracer.traceInstruction($bci, INSTR_STORE_LOCAL_MAT, 0, 0); + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; return $sp; } default : @@ -13337,55 +5998,22 @@ private static int instructionGroup_27(SLOperationRootNodeGen $this, VirtualFram } } - private static int instructionGroup_28(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_3_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination // Pushed Values: 0 - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + case ((INSTR_STORE_LOCAL << 3) | 0) : { - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } + tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; return $sp; } default : @@ -13393,197 +6021,142 @@ private static int instructionGroup_28(SLOperationRootNodeGen $this, VirtualFram } } - private static int instructionGroup_30(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_5_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0) : { - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); + SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); + SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); + SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_FUNCTION_LITERAL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_FUNCTION_LITERAL, SLOperationRootNodeGen.doGetStateBits_SLFunctionLiteral_($bc, $bci)); + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_32(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } default : @@ -13591,51 +6164,126 @@ private static int instructionGroup_32(SLOperationRootNodeGen $this, VirtualFram } } - private static int instructionGroup_33(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_6_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0) : { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); + SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); + SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_READ_PROPERTY, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_READ_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLReadProperty_($bc, $bci)); + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); + SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; return $sp; } default : @@ -13643,104 +6291,66 @@ private static int instructionGroup_33(SLOperationRootNodeGen $this, VirtualFram } } - private static int instructionGroup_34(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_7_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + tracer.traceInstruction($bci, INSTR_C_SL_WRITE_PROPERTY, 0, 0); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_WRITE_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLWriteProperty_($bc, $bci)); + SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; return $sp; } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static int instructionGroup_37(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : { - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } + tracer.traceInstruction($bci, INSTR_C_SL_INVOKE, 0, 1); + tracer.traceActiveSpecializations($bci, INSTR_C_SL_INVOKE, SLOperationRootNodeGen.doGetStateBits_SLInvoke_($bc, $bci)); + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; return $sp; } default : @@ -14100,86 +6710,6 @@ T insertAccessor(T node) { private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; private static final int SC_SL_OR_LENGTH = 6; - private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 33; - private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 34; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 35; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 37; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; - private static final short INSTR_C_SL_ADD_Q_ADD_LONG = 38; - private static final int C_SL_ADD_Q_ADD_LONG_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD_LONG_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD_LONG_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD_LONG_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD_LONG_LENGTH = 6; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; - private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; - private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; - private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; - private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; - private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; - private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; - private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; - private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; - private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; - private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; - private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; - private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; - private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; @CompilationFinal private OperationNodesImpl nodes; @CompilationFinal(dimensions = 1) private short[] _bc; @@ -14191,6 +6721,7 @@ T insertAccessor(T node) { @CompilationFinal private int _maxLocals; @CompilationFinal private int _maxStack; @CompilationFinal(dimensions = 1) private int[] sourceInfo; + @CompilationFinal(dimensions = 1) private boolean[] isBbStart; @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; @CompilationFinal private int uncachedExecuteCount = 16; @CompilationFinal private Object _osrMetadata; @@ -14325,6 +6856,7 @@ public Node deepCopy() { result._consts = Arrays.copyOf(_consts, _consts.length); result._children = Arrays.copyOf(_children, _children.length); result._localTags = Arrays.copyOf(_localTags, _localTags.length); + result.isBbStart = isBbStart; result._handlers = _handlers; result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); result._maxLocals = _maxLocals; @@ -14355,16 +6887,161 @@ private void changeInterpreters(BytecodeLoopBase impl) { this.switchImpl = impl; } - private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; + private static boolean[] doGetStateBits_SLAdd_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[4]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 add(SLBigNumber, SLBigNumber) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */; + result[3] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; } - private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; + private static boolean[] doGetStateBits_SLDiv_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 div(SLBigNumber, SLBigNumber) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLEqual_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[9]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + result[3] = (state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */; + result[4] = (state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */; + result[5] = (state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */; + result[6] = (state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */; + result[7] = (state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b100000000)) == 0 /* is-not-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */; + result[8] = (state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */; + return result; + } + + private static boolean[] doGetStateBits_SLLessOrEqual_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLLessThan_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLLogicalNot_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLMul_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 mul(SLBigNumber, SLBigNumber) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLReadProperty_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[6]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && ((state_0 & 0b1000)) == 0 /* is-not-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[3] = (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[4] = (state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */ && ((state_0 & 0b100000)) == 0 /* is-not-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + result[5] = (state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + return result; + } + + private static boolean[] doGetStateBits_SLSub_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 sub(SLBigNumber, SLBigNumber) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLWriteProperty_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[6]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && ((state_0 & 0b1000)) == 0 /* is-not-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[3] = (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; + result[4] = (state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */ && ((state_0 & 0b100000)) == 0 /* is-not-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + result[5] = (state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; + return result; + } + + private static boolean[] doGetStateBits_SLUnbox_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[9]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + result[3] = (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + result[4] = (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + result[5] = (state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */; + result[6] = (state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */; + result[7] = (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */ && ((state_0 & 0b100000000)) == 0 /* is-not-state_0 fromForeign(Object, InteropLibrary) */; + result[8] = (state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; + return result; + } + + private static boolean[] doGetStateBits_SLFunctionLiteral_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[1]; + result[0] = state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; + return result; + } + + private static boolean[] doGetStateBits_SLToBoolean_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLInvoke_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[3]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; + result[2] = (state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLAnd_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; + return result; + } + + private static boolean[] doGetStateBits_SLOr_(short[] $bc, int $bci) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + boolean[] result = new boolean[2]; + result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; + return result; } private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { @@ -14651,110 +7328,18 @@ private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperati UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } - private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); @@ -14824,27 +7409,6 @@ private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNo } } - private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLAdd_q_AddLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_q_AddLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_AddLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 3; UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); @@ -14855,11 +7419,6 @@ private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNod UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); } - private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); @@ -14890,6 +7449,11 @@ private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, S UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } + private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); @@ -15085,25 +7649,25 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); } - protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 5 /* BOOLEAN */ : - return UFA.unsafeUncheckedGetBoolean(frame, slot); + case 1 /* LONG */ : + return UFA.unsafeUncheckedGetLong(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); - return (boolean) value; + if (value instanceof Long) { + setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); + return (long) value; } break; } @@ -15113,25 +7677,25 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, } } - protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 1 /* LONG */ : - return UFA.unsafeUncheckedGetLong(frame, slot); + case 5 /* BOOLEAN */ : + return UFA.unsafeUncheckedGetBoolean(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); - return (long) value; + if (value instanceof Boolean) { + setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); + return (boolean) value; } break; } @@ -15237,6 +7801,7 @@ public static final class Builder extends OperationBuilder { private int[] instructionHistory = new int[8]; private int instructionHistoryIndex = 0; private int numLabels; + private boolean[] isBbStart = new boolean[65535]; private ArrayList constPool = new ArrayList<>(); private BuilderOperationData operationData; private ArrayList labels = new ArrayList<>(); @@ -15262,6 +7827,10 @@ public void serializeOperationNode(DataOutput buffer, OperationRootNode node) th private int lastChildPush; private TruffleString metadata_MethodName; + static { + ExecutionTracer.initialize(SLOperationRootNode.class, "/home/prof/ec/ws1/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json", new String[] {null, "pop", "branch", "branch.false", "throw", "load.constant", "load.argument", "load.local", "load.local.boxed", "store.local", "return", "load.local.mat", "store.local.mat", "instrument.enter", "instrument.exit.void", "instrument.exit", "instrument.leave", "c.SLAdd", "c.SLDiv", "c.SLEqual", "c.SLLessOrEqual", "c.SLLessThan", "c.SLLogicalNot", "c.SLMul", "c.SLReadProperty", "c.SLSub", "c.SLWriteProperty", "c.SLUnbox", "c.SLFunctionLiteral", "c.SLToBoolean", "c.SLInvoke", "sc.SLAnd", "sc.SLOr"}, new String[][] {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, new String[] {"AddLong", "Add0", "Add1", "Fallback"}, new String[] {"DivLong", "Div", "Fallback"}, new String[] {"Long", "BigNumber", "Boolean", "String", "TruffleString", "Null", "Function", "Generic0", "Generic1", "Fallback"}, new String[] {"LessOrEqual0", "LessOrEqual1", "Fallback"}, new String[] {"LessThan0", "LessThan1", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"MulLong", "Mul", "Fallback"}, new String[] {"ReadArray0", "ReadArray1", "ReadSLObject0", "ReadSLObject1", "ReadObject0", "ReadObject1", "Fallback"}, new String[] {"SubLong", "Sub", "Fallback"}, new String[] {"WriteArray0", "WriteArray1", "WriteSLObject0", "WriteSLObject1", "WriteObject0", "WriteObject1", "Fallback"}, new String[] {"FromString", "FromTruffleString", "FromBoolean", "FromLong", "FromBigNumber", "FromFunction0", "FromFunction1", "FromForeign0", "FromForeign1", "Fallback"}, new String[] {"Perform", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Direct", "Indirect", "Interop", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Boolean", "Fallback"}}); + } + private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { this.nodes = nodes; this.isReparse = isReparse; @@ -15352,6 +7921,7 @@ private void doEmitLabel(OperationLabel label) { } lbl.hasValue = true; lbl.targetBci = bci; + isBbStart[bci] = true; } private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { @@ -15455,6 +8025,7 @@ private SLOperationRootNode publish(TruffleLanguage language) { result._consts = constPool.toArray(); result._children = new Node[numChildNodes]; result._localTags = new byte[numLocals]; + result.isBbStart = Arrays.copyOf(isBbStart, bci); result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); result._conditionProfiles = new int[numConditionProfiles]; result._maxLocals = numLocals; @@ -15636,10 +8207,8 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } bci = bci + BRANCH_FALSE_LENGTH; + isBbStart[bci] = true; } else { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -15647,6 +8216,7 @@ private void doAfterChild() { instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; bci = bci + POP_LENGTH; } + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } break; @@ -15663,10 +8233,8 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } bci = bci + BRANCH_FALSE_LENGTH; + isBbStart[bci] = true; } else if (childIndex == 1) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -15682,6 +8250,7 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } else { for (int i = 0; i < lastChildPush; i++) { @@ -15690,6 +8259,7 @@ private void doAfterChild() { instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; bci = bci + POP_LENGTH; } + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -15706,10 +8276,8 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } bci = bci + BRANCH_FALSE_LENGTH; + isBbStart[bci] = true; } else if (childIndex == 1) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -15720,9 +8288,11 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } else { assert lastChildPush == 1; + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -15739,10 +8309,8 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } bci = bci + BRANCH_FALSE_LENGTH; + isBbStart[bci] = true; } else { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -15756,6 +8324,7 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -15776,6 +8345,7 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; + isBbStart[bci] = true; } else { } break; @@ -16054,6 +8624,7 @@ public void beginWhile() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); + isBbStart[bci] = true; doEmitLabel(startLabel); operationData.aux[0] = startLabel; } @@ -16120,6 +8691,7 @@ public void endTryCatch() { if (numChildren != 2) { throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); } + isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); lastChildPush = 0; operationData = operationData.parent; @@ -16176,6 +8748,7 @@ public void endFinallyTry() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; + isBbStart[bci] = true; } ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); beh.endBci = endBci; @@ -16250,6 +8823,7 @@ public void emitLabel(OperationLabel arg0) { return; } doBeforeChild(); + isBbStart[bci] = true; doEmitLabel(arg0); lastChildPush = 0; doAfterChild(); @@ -16303,11 +8877,6 @@ public void emitLoadConstant(Object arg0) { bc[bci + 1] = (short) constantsStart; constPool.add(operationData.arguments[0]); instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_CONSTANT; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0); - } bci = bci + LOAD_CONSTANT_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -16650,6 +9219,7 @@ public void beginTag(Class arg0) { unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_ENTER << 3) | 0)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_ENTER; bci = bci + INSTRUMENT_ENTER_LENGTH; + isBbStart[bci] = true; lastChildPush = 0; } } @@ -16731,13 +9301,6 @@ public void endSLAdd() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_ADD; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_STORE_LOCAL) { - bc[bci - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } bci = bci + C_SL_ADD_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -17076,9 +9639,6 @@ public void endSLReadProperty() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_READ_PROPERTY; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0); - } bci = bci + C_SL_READ_PROPERTY_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -17224,41 +9784,6 @@ public void endSLUnbox() { bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_UNBOX; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { - bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { - bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { - bc[bci - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { - bc[bci - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_C_SL_READ_PROPERTY) { - bc[bci - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } bci = bci + C_SL_UNBOX_LENGTH; lastChildPush = 1; operationData = operationData.parent; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 6503abc06ee2..a58a49cd5327 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -573,6 +573,11 @@ private static int saturatingAdd(int x, int y) { @Override public void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations) { + if (activeSpecializations.length < 2) { + // we do not care for single specialisation instructions + return; + } + boolean anyActive = false; for (int i = 0; i < activeSpecializations.length; i++) { if (activeSpecializations[i]) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index e85ff2c1b55e..677c57aa1cfe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -556,6 +556,10 @@ public CodeTreeBuilder lineComment(String text) { return string("// ").string(text).newLine(); } + public CodeTreeBuilder lineCommentf(String text, Object... args) { + return lineComment(String.format(text, args)); + } + public CodeTreeBuilder startComment() { string("/*"); startGroup(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 45ca6c87aaa9..200b75c7ecce 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -89,6 +89,8 @@ public class OperationsBytecodeCodeGenerator { static final Object MARKER_CHILD = new Object(); static final Object MARKER_CONST = new Object(); + private static final int INSTRUCTIONS_PER_GROUP = 21; + static final boolean DO_STACK_LOGGING = false; final ProcessorContext context = ProcessorContext.getInstance(); @@ -288,14 +290,14 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C b.declaration("int", vars.sp.getName(), CodeTreeBuilder.singleString("$startSp")); b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); - b.declaration("Counter", "loopCounter", "new Counter()"); + if (!isUncached) { + b.declaration("Counter", "loopCounter", "new Counter()"); + } // this moves the frame null check out of the loop b.startStatement().startCall(vars.stackFrame, "getArguments").end(2); if (isUncached) { - // todo: better signaling to compiler that the method is not ready for compilation - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); b.declaration("Counter", "uncachedExecuteCount", "new Counter()"); b.statement("uncachedExecuteCount.count = $this.uncachedExecuteCount"); } @@ -327,12 +329,6 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C b.declaration("int", varCurOpcode.getName(), CodeTreeBuilder.createBuilder().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).string(" & 0xffff").build()); - if (isUncached) { - b.startAssign("curOpcode"); - b.tree(OperationGeneratorUtils.extractInstruction(ctx, CodeTreeBuilder.singleString("curOpcode"))); - b.end(); - } - b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); if (varTracer != null) { @@ -382,77 +378,96 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C for (Map.Entry> lenGroup : wrappedInstructions.entrySet().stream().sorted((x, y) -> Integer.compare(x.getKey(), y.getKey())).collect(Collectors.toList())) { int instructionLength = lenGroup.getKey(); - b.lineComment("length group " + instructionLength); + int doneInstructions = 0; + int numInstructions = lenGroup.getValue().size(); + int numSubgroups = (int) Math.round((double) numInstructions / INSTRUCTIONS_PER_GROUP); - for (Instruction instr : lenGroup.getValue()) { - generateAllCasesForInstruction(ctx, b, instr); - } + for (int subgroup = 0; subgroup < numSubgroups; subgroup++) { - b.startCaseBlock(); + b.lineCommentf("length group %d (%d / %d)", instructionLength, subgroup + 1, numSubgroups); - String groupMethodName = "instructionGroup_" + instructionLength; - OperationGeneratorUtils.createHelperMethod(bytecodeType, groupMethodName, () -> { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(int.class), groupMethodName); - met.addParameter(mContinueAt.getParameters().get(0)); // $this - met.addParameter(vars.stackFrame); - if (m.enableYield) { - met.addParameter(vars.localFrame); - } - met.addParameter(vars.bc); - met.addParameter(vars.bci); - met.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); - met.addParameter(vars.consts); - met.addParameter(vars.children); - if (ctx.hasBoxingElimination()) { - met.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + int instrsInGroup = (numInstructions - doneInstructions) / (numSubgroups - subgroup); + List instructionsInGroup = lenGroup.getValue().subList(doneInstructions, doneInstructions + instrsInGroup); + + doneInstructions += instrsInGroup; + + for (Instruction instr : instructionsInGroup) { + generateAllCasesForInstruction(ctx, b, instr); } - met.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); - CodeTreeBuilder b2 = met.createBuilder(); + b.startCaseBlock(); - b2.statement("int $sp = $startSp"); + String groupMethodName = String.format("instructionGroup_%d_%d%s", instructionLength, subgroup, (isUncached ? "_uncached" : "")); - b2.startSwitch().string("curOpcode").end().startBlock(); + OperationGeneratorUtils.createHelperMethod(bytecodeType, groupMethodName, () -> { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(int.class), groupMethodName); + met.addParameter(mContinueAt.getParameters().get(0)); // $this + met.addParameter(vars.stackFrame); + if (m.enableYield) { + met.addParameter(vars.localFrame); + } + met.addParameter(vars.bc); + met.addParameter(vars.bci); + met.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); + met.addParameter(vars.consts); + met.addParameter(vars.children); + if (ctx.hasBoxingElimination()) { + met.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); + } + met.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + met.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); + if (ctx.getData().isTracing()) { + met.addParameter(new CodeVariableElement(types.ExecutionTracer, "tracer")); + } - for (Instruction instr : lenGroup.getValue()) { - generateExecuteCase(ctx, vars, b2, varTracer, instr, false); - } + CodeTreeBuilder b2 = met.createBuilder(); - b2.caseDefault().startCaseBlock(); - b2.tree(GeneratorUtils.createShouldNotReachHere()); - b2.end(); + b2.statement("int $sp = $startSp"); - b2.end(); + b2.startSwitch().string("curOpcode").end().startBlock(); - return met; - }); + for (Instruction instr : instructionsInGroup) { + generateExecuteCase(ctx, vars, b2, varTracer, instr, false); + } - b.startAssign(vars.sp).startCall(groupMethodName); + b2.caseDefault().startCaseBlock(); + b2.tree(GeneratorUtils.createShouldNotReachHere()); + b2.end(); - b.string("$this"); - b.variable(vars.stackFrame); - if (m.enableYield) { - b.variable(vars.localFrame); - } - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); - if (ctx.hasBoxingElimination()) { - b.string("$localTags"); - } - b.string("$conditionProfiles"); - b.string("curOpcode"); + b2.end(); - b.end(2); // assign, call + return met; + }); - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instructionLength).end(); + b.startAssign(vars.sp).startCall(groupMethodName); - b.statement("continue loop"); + b.string("$this"); + b.variable(vars.stackFrame); + if (m.enableYield) { + b.variable(vars.localFrame); + } + b.variable(vars.bc); + b.variable(vars.bci); + b.variable(vars.sp); + b.variable(vars.consts); + b.variable(vars.children); + if (ctx.hasBoxingElimination()) { + b.string("$localTags"); + } + b.string("$conditionProfiles"); + b.string("curOpcode"); + if (ctx.getData().isTracing()) { + b.string("tracer"); + } - b.end(); + b.end(2); // assign, call + + b.startAssign(vars.bci).variable(vars.bci).string(" + " + instructionLength).end(); + + b.statement("continue loop"); + + b.end(); + } } @@ -578,11 +593,7 @@ private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, b.end(); } } else { - if (isUncached) { - b.startCase().variable(op.opcodeIdField).end(); - } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - } + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); b.startBlock(); if (ctx.hasBoxingElimination()) { vars.specializedKind = FrameKind.OBJECT; @@ -612,11 +623,7 @@ private void generateAllCasesForInstruction(OperationsContext ctx, CodeTreeBuild } } } else { - if (isUncached) { - b.startCase().variable(op.opcodeIdField).end(); - } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - } + b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index 35ba57aa5aa9..cbe510814bf1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -86,7 +86,7 @@ private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR || uncached) { b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { - if (LOOP_COUNTING || SAFEPOINT_POLL) { + if (!uncached && (LOOP_COUNTING || SAFEPOINT_POLL)) { b.startIf(); b.tree(GeneratorUtils.createHasNextTier()); if (LOOP_COUNTING) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 56d4fa934731..0945b1e83313 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -55,6 +55,10 @@ public ShortCircuitInstruction(OperationsContext ctx, String name, int id, Singl @Override public CodeTree createExecuteCode(ExecutionVariables vars) { + return createExecuteCode(vars, false); + } + + public CodeTree createExecuteCode(ExecutionVariables vars, boolean uncached) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); createTracerCode(vars, b); @@ -64,7 +68,11 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("!"); } - b.startStaticCall(executeMethods[0]); + if (uncached) { + b.startStaticCall(uncachedExecuteMethod); + } else { + b.startStaticCall(executeMethods[0]); + } b.variable(vars.stackFrame); if (ctx.getData().enableYield) { b.variable(vars.localFrame); @@ -75,6 +83,12 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.variable(vars.sp); b.variable(vars.consts); b.variable(vars.children); + if (uncached) { + b.startCall("UFA", "unsafeUncheckedGetObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.end(); + } b.end(2).startBlock(); // { b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); @@ -95,7 +109,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { @Override public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteCode(vars); + return createExecuteCode(vars, true); } @Override diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index e96c75f8c84a..dfa263a4b051 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 06d77600b0b3..c0cced49df10 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -3,9 +3,19 @@ "Do not modify, as it will be overwritten when running with tracing support.", "Use the overrides file to alter the optimisation decisions.", { - "specializations": ["FromLong"], - "_comment": "value: 7214274.0", - "id": "quicken:c.SLUnbox:FromLong", + "specializations": ["FromBigNumber"], + "_comment": "value: 6938182.0", + "id": "quicken:c.SLUnbox:FromBigNumber", + "type": "Quicken", + "operation": "SLUnbox" + }, + { + "specializations": [ + "FromLong", + "FromBigNumber" + ], + "_comment": "value: 4179750.0", + "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", "type": "Quicken", "operation": "SLUnbox" }, @@ -14,7 +24,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 3831023.0", + "_comment": "value: 3830950.0", "id": "si:load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -76,13 +86,6 @@ "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, - { - "specializations": ["FromBigNumber"], - "_comment": "value: 2827220.0", - "id": "quicken:c.SLUnbox:FromBigNumber", - "type": "Quicken", - "operation": "SLUnbox" - }, { "instructions": [ "load.local", @@ -94,16 +97,6 @@ "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, - { - "specializations": [ - "FromLong", - "FromBigNumber" - ], - "_comment": "value: 2459249.0", - "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", - "type": "Quicken", - "operation": "SLUnbox" - }, { "instructions": [ "c.SLUnbox", @@ -112,7 +105,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 2400444.0", + "_comment": "value: 2400468.0", "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -129,6 +122,13 @@ "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, + { + "specializations": ["FromLong"], + "_comment": "value: 2192389.0", + "id": "quicken:c.SLUnbox:FromLong", + "type": "Quicken", + "operation": "SLUnbox" + }, { "instructions": [ "c.SLUnbox", @@ -150,7 +150,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 2000370.0", + "_comment": "value: 2000390.0", "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -199,6 +199,13 @@ "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, + { + "specializations": ["FromBoolean"], + "_comment": "value: 1557962.0", + "id": "quicken:c.SLUnbox:FromBoolean", + "type": "Quicken", + "operation": "SLUnbox" + }, { "instructions": [ "load.local", @@ -301,11 +308,11 @@ "type": "SuperInstruction" }, { - "specializations": ["FromBoolean"], - "_comment": "value: 1440534.0", - "id": "quicken:c.SLUnbox:FromBoolean", + "specializations": ["Add0"], + "_comment": "value: 1426876.0", + "id": "quicken:c.SLAdd:Add0", "type": "Quicken", - "operation": "SLUnbox" + "operation": "SLAdd" }, { "instructions": [ @@ -318,7 +325,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 1400259.0", + "_comment": "value: 1400273.0", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -338,18 +345,11 @@ }, { "specializations": ["ReadSLObject0"], - "_comment": "value: 880189.0", + "_comment": "value: 924071.0", "id": "quicken:c.SLReadProperty:ReadSLObject0", "type": "Quicken", "operation": "SLReadProperty" }, - { - "specializations": ["AddLong"], - "_comment": "value: 880097.0", - "id": "quicken:c.SLAdd:AddLong", - "type": "Quicken", - "operation": "SLAdd" - }, { "instructions": [ "pop", @@ -372,43 +372,43 @@ "type": "SuperInstruction" }, { - "_comment": "value: 3.5962172E7", + "_comment": "value: 3.596216E7", "instruction": "c.SLUnbox", "id": "c:c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 3.596081E7", + "_comment": "value: 3.5960798E7", "instruction": "return", "id": "c:return", "type": "CommonInstruction" }, { - "_comment": "value: 3.5130024E7", + "_comment": "value: 3.5130023E7", "instruction": "store.local", "id": "c:store.local", "type": "CommonInstruction" }, { - "_comment": "value: 3.5130008E7", + "_comment": "value: 3.5130007E7", "instruction": "load.local", "id": "c:load.local", "type": "CommonInstruction" }, { - "_comment": "value: 3.4369648E7", + "_comment": "value: 3.4369647E7", "instruction": "load.argument", "id": "c:load.argument", "type": "CommonInstruction" }, { - "_comment": "value: 3.0165153E7", + "_comment": "value: 3.0165142E7", "instruction": "load.constant", "id": "c:load.constant", "type": "CommonInstruction" }, { - "_comment": "value: 2.933489E7", + "_comment": "value: 2.9334879E7", "instruction": "pop", "id": "c:pop", "type": "CommonInstruction" @@ -432,7 +432,7 @@ "type": "CommonInstruction" }, { - "_comment": "value: 2.9324362E7", + "_comment": "value: 2.9327091E7", "instruction": "load.local.boxed", "id": "c:load.local.boxed", "type": "CommonInstruction" @@ -444,19 +444,19 @@ "type": "CommonInstruction" }, { - "_comment": "value: 2.4836825E7", + "_comment": "value: 2.4836824E7", "instruction": "c.SLAdd", "id": "c:c.SLAdd", "type": "CommonInstruction" }, { - "_comment": "value: 2.1352306E7", + "_comment": "value: 2.1352295E7", "instruction": "c.SLInvoke", "id": "c:c.SLInvoke", "type": "CommonInstruction" }, { - "_comment": "value: 2.1352158E7", + "_comment": "value: 2.1352147E7", "instruction": "c.SLFunctionLiteral", "id": "c:c.SLFunctionLiteral", "type": "CommonInstruction" @@ -552,23 +552,23 @@ "type": "CommonInstruction" }, { - "_comment": "value: 799136.0", - "instruction": "si.load.local.c.SLUnbox", - "id": "c:si.load.local.c.SLUnbox", - "type": "CommonInstruction" - }, - { - "_comment": "value: 798495.0", + "_comment": "value: 799160.0", "instruction": "c.SLUnbox.q.FromLong", "id": "c:c.SLUnbox.q.FromLong", "type": "CommonInstruction" }, { - "_comment": "value: 798495.0", + "_comment": "value: 799160.0", "instruction": "c.SLUnbox.q.FromBigNumber", "id": "c:c.SLUnbox.q.FromBigNumber", "type": "CommonInstruction" }, + { + "_comment": "value: 799136.0", + "instruction": "si.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, { "_comment": "value: 567798.0", "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", @@ -581,12 +581,6 @@ "id": "c:c.SLReadProperty.q.ReadSLObject0", "type": "CommonInstruction" }, - { - "_comment": "value: 567798.0", - "instruction": "c.SLAdd.q.AddLong", - "id": "c:c.SLAdd.q.AddLong", - "type": "CommonInstruction" - }, { "_comment": "value: 567798.0", "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", @@ -606,15 +600,15 @@ "type": "CommonInstruction" }, { - "_comment": "value: 546483.0", - "instruction": "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", - "id": "c:si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "_comment": "value: 547136.0", + "instruction": "c.SLUnbox.q.FromBoolean", + "id": "c:c.SLUnbox.q.FromBoolean", "type": "CommonInstruction" }, { "_comment": "value: 546483.0", - "instruction": "c.SLUnbox.q.FromBoolean", - "id": "c:c.SLUnbox.q.FromBoolean", + "instruction": "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "id": "c:si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", "type": "CommonInstruction" }, { @@ -623,6 +617,12 @@ "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", "type": "CommonInstruction" }, + { + "_comment": "value: 340063.0", + "instruction": "c.SLUnbox.q.FromLong", + "id": "c:c.SLUnbox.q.FromLong", + "type": "CommonInstruction" + }, { "_comment": "value: 340063.0", "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", @@ -635,6 +635,18 @@ "id": "c:si.load.local.c.SLUnbox", "type": "CommonInstruction" }, + { + "_comment": "value: 340063.0", + "instruction": "c.SLAdd.q.Add0", + "id": "c:c.SLAdd.q.Add0", + "type": "CommonInstruction" + }, + { + "_comment": "value: 340063.0", + "instruction": "c.SLUnbox.q.FromBoolean", + "id": "c:c.SLUnbox.q.FromBoolean", + "type": "CommonInstruction" + }, { "_comment": "value: 340063.0", "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", @@ -647,6 +659,18 @@ "id": "c:si.c.SLToBoolean.branch.false", "type": "CommonInstruction" }, + { + "_comment": "value: 340063.0", + "instruction": "c.SLUnbox.q.FromBigNumber", + "id": "c:c.SLUnbox.q.FromBigNumber", + "type": "CommonInstruction" + }, + { + "_comment": "value: 252677.0", + "instruction": "c.SLAdd.q.Add0", + "id": "c:c.SLAdd.q.Add0", + "type": "CommonInstruction" + }, { "_comment": "value: 252012.0", "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index fbcb002564cc..3f4708ac66c1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -95,7 +95,7 @@ */ public final class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = true; + private static final boolean DO_LOG_NODE_CREATION = false; private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { @@ -167,8 +167,6 @@ public Void visit(ParseTree tree) { throw new AssertionError("unknown tree type: " + tree); } - System./**/out.println(" visiting " + tree.toStringTree(new SimpleLanguageOperationsParser(null))); - b.beginSourceSection(sourceStart, sourceEnd - sourceStart); super.visit(tree); b.endSourceSection(); From 2aa3abe38ff6019d5411c6958f1feaec726d9866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 21 Nov 2022 10:21:21 +0100 Subject: [PATCH 173/312] [wip] separate instrs and normalize stats --- .../sl/operations/SLOperationRootNodeGen.java | 90 +++++++++---------- .../api/operation/tracing/Decision.java | 28 +++--- .../tracing/OperationsStatistics.java | 6 +- .../OperationsBytecodeCodeGenerator.java | 2 +- .../truffle/sl/operations/decisions.json | 60 ++++++------- 5 files changed, 94 insertions(+), 92 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index 8b9666b55c0f..df01eccea9a9 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -263,12 +263,12 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i continue loop; } } - // length group 1 + // length group 1 (1 / 1) case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 1; continue loop; - // length group 2 + // length group 2 (1 / 1) case ((INSTR_LOAD_CONSTANT << 3) | 0) : case ((INSTR_LOAD_ARGUMENT << 3) | 0) : case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : @@ -279,18 +279,18 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 2; continue loop; - // length group 3 + // length group 3 (1 / 1) case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : case ((INSTR_STORE_LOCAL << 3) | 7) : - $sp = instructionGroup_3($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 3; continue loop; - // length group 5 + // length group 5 (1 / 1) case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : @@ -300,15 +300,15 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - $sp = instructionGroup_5($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 5; continue loop; - // length group 6 + // length group 6 (1 / 1) case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : @@ -318,13 +318,13 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - $sp = instructionGroup_6($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 6; continue loop; - // length group 7 + // length group 7 (1 / 1) case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : case ((INSTR_C_SL_INVOKE << 3) | 0) : - $sp = instructionGroup_7($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 7; continue loop; default : @@ -4144,7 +4144,7 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperati } } - private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // pop @@ -4163,7 +4163,7 @@ private static int instructionGroup_1(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // load.constant @@ -4280,7 +4280,7 @@ private static int instructionGroup_2(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // store.local @@ -4327,7 +4327,7 @@ private static int instructionGroup_3(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLEqual @@ -4460,18 +4460,18 @@ private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : { tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : { tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } // c.SLFunctionLiteral @@ -4522,7 +4522,7 @@ private static int instructionGroup_5(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLAdd @@ -4681,7 +4681,7 @@ private static int instructionGroup_6(SLOperationRootNodeGen $this, VirtualFrame } } - private static int instructionGroup_7(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLWriteProperty @@ -5098,27 +5098,27 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i continue loop; } } - // length group 1 + // length group 1 (1 / 1) case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_1_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 1; continue loop; - // length group 2 + // length group 2 (1 / 1) case ((INSTR_LOAD_CONSTANT << 3) | 0) : case ((INSTR_LOAD_ARGUMENT << 3) | 0) : case ((INSTR_LOAD_LOCAL << 3) | 0) : case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_2_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 2; continue loop; - // length group 3 + // length group 3 (1 / 1) case ((INSTR_STORE_LOCAL << 3) | 0) : - $sp = instructionGroup_3_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_3_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 3; continue loop; - // length group 5 + // length group 5 (1 / 1) case ((INSTR_C_SL_EQUAL << 3) | 0) : case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : case ((INSTR_C_SL_LESS_THAN << 3) | 0) : @@ -5126,22 +5126,22 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i case ((INSTR_C_SL_UNBOX << 3) | 0) : case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : - $sp = instructionGroup_5_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_5_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 5; continue loop; - // length group 6 + // length group 6 (1 / 1) case ((INSTR_C_SL_ADD << 3) | 0) : case ((INSTR_C_SL_DIV << 3) | 0) : case ((INSTR_C_SL_MUL << 3) | 0) : case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : case ((INSTR_C_SL_SUB << 3) | 0) : - $sp = instructionGroup_6_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_6_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 6; continue loop; - // length group 7 + // length group 7 (1 / 1) case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : case ((INSTR_C_SL_INVOKE << 3) | 0) : - $sp = instructionGroup_7_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); + $sp = instructionGroup_7_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); $bci = $bci + 7; continue loop; default : @@ -5896,7 +5896,7 @@ private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRoo return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static int instructionGroup_1_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // pop @@ -5915,7 +5915,7 @@ private static int instructionGroup_1_uncached(SLOperationRootNodeGen $this, Vir } } - private static int instructionGroup_2_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // load.constant @@ -5998,7 +5998,7 @@ private static int instructionGroup_2_uncached(SLOperationRootNodeGen $this, Vir } } - private static int instructionGroup_3_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // store.local @@ -6021,7 +6021,7 @@ private static int instructionGroup_3_uncached(SLOperationRootNodeGen $this, Vir } } - private static int instructionGroup_5_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLEqual @@ -6164,7 +6164,7 @@ private static int instructionGroup_5_uncached(SLOperationRootNodeGen $this, Vir } } - private static int instructionGroup_6_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLAdd @@ -6291,7 +6291,7 @@ private static int instructionGroup_6_uncached(SLOperationRootNodeGen $this, Vir } } - private static int instructionGroup_7_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { int $sp = $startSp; switch (curOpcode) { // c.SLWriteProperty @@ -7303,20 +7303,20 @@ private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRo return; } - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); } } - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java index f2aed1abb53f..38785877e72a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/Decision.java @@ -63,7 +63,7 @@ private Decision(String type) { abstract String id(GlobalOperationStatistics stats); - protected abstract String prettyPrint(GlobalOperationStatistics stats); + protected abstract String prettyPrint(GlobalOperationStatistics stats, double normalizationValue); protected String createsInstruction(GlobalOperationStatistics stats) { return null; @@ -74,9 +74,9 @@ boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { return false; } - JSONObject serialize(GlobalOperationStatistics stats) { + JSONObject serialize(GlobalOperationStatistics stats, double normalizationValue) { JSONObject obj = new JSONObject(); - obj.put("_comment", "value: " + value()); + obj.put("_comment", "value: " + value() / normalizationValue); obj.put("type", type); obj.put("id", id(stats)); return obj; @@ -106,8 +106,8 @@ String id(GlobalOperationStatistics stats) { } @Override - JSONObject serialize(GlobalOperationStatistics stats) { - JSONObject result = super.serialize(stats); + JSONObject serialize(GlobalOperationStatistics stats, double norm) { + JSONObject result = super.serialize(stats, norm); String instrName = stats.instrNames[instruction]; String shortName; if (instrName.startsWith("c.")) { @@ -128,11 +128,11 @@ JSONObject serialize(GlobalOperationStatistics stats) { } @Override - protected String prettyPrint(GlobalOperationStatistics stats) { + protected String prettyPrint(GlobalOperationStatistics stats, double normalizationValue) { StringBuilder sb = new StringBuilder(); sb.append("Quicken ").append(id(stats)).append('\n'); - sb.append(" value: ").append(value()).append('\n'); + sb.append(" value: ").append(value() / normalizationValue).append('\n'); sb.append(" total execution count: ").append(executionCount).append('\n'); sb.append(" instruction: ").append(stats.instrNames[instruction]).append('\n'); for (int i = 0; i < specializations.length; i++) { @@ -199,8 +199,8 @@ boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { } @Override - JSONObject serialize(GlobalOperationStatistics stats) { - JSONObject result = super.serialize(stats); + JSONObject serialize(GlobalOperationStatistics stats, double norm) { + JSONObject result = super.serialize(stats, norm); JSONArray instrNames = new JSONArray(); result.put("instructions", instrNames); @@ -212,11 +212,11 @@ JSONObject serialize(GlobalOperationStatistics stats) { } @Override - protected String prettyPrint(GlobalOperationStatistics stats) { + protected String prettyPrint(GlobalOperationStatistics stats, double normalizationValue) { StringBuilder sb = new StringBuilder(); sb.append("SuperInstruction ").append(id(stats)).append('\n'); - sb.append(" value: ").append(value()).append('\n'); + sb.append(" value: ").append(value() / normalizationValue).append('\n'); sb.append(" total execution count: ").append(executionCount).append('\n'); for (int i = 0; i < instructions.length; i++) { sb.append(" instruction[").append(i).append("]: ").append(stats.instrNames[instructions[i]]).append('\n'); @@ -269,8 +269,8 @@ boolean acceptedBefore(Decision decision, GlobalOperationStatistics stats) { } @Override - JSONObject serialize(GlobalOperationStatistics stats) { - JSONObject result = super.serialize(stats); + JSONObject serialize(GlobalOperationStatistics stats, double norm) { + JSONObject result = super.serialize(stats, 1.0); result.put("instruction", instruction); return result; } @@ -281,7 +281,7 @@ String id(GlobalOperationStatistics stats) { } @Override - protected String prettyPrint(GlobalOperationStatistics stats) { + protected String prettyPrint(GlobalOperationStatistics stats, double normalizationValue) { StringBuilder sb = new StringBuilder(); sb.append("Common ").append(id(stats)).append('\n'); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index a58a49cd5327..234017c9239a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -747,12 +747,14 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, PrintWriter dumpWriter.println(); } + double normValue = acceptedDecisions.size() == 0 ? 1.0 : acceptedDecisions.get(0).value(); + // serialize for (Decision dec : acceptedDecisions) { if (dumpWriter != null) { - dumpWriter.println(dec.prettyPrint(stats)); + dumpWriter.println(dec.prettyPrint(stats, normValue)); } - result.put(dec.serialize(stats)); + result.put(dec.serialize(stats, normValue)); } if (dumpWriter != null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 200b75c7ecce..1b47b4e30ce2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -380,7 +380,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C int doneInstructions = 0; int numInstructions = lenGroup.getValue().size(); - int numSubgroups = (int) Math.round((double) numInstructions / INSTRUCTIONS_PER_GROUP); + int numSubgroups = (int) Math.max(1.0, Math.round((double) numInstructions / INSTRUCTIONS_PER_GROUP)); for (int subgroup = 0; subgroup < numSubgroups; subgroup++) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index c0cced49df10..99f39281b7cc 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -4,7 +4,7 @@ "Use the overrides file to alter the optimisation decisions.", { "specializations": ["FromBigNumber"], - "_comment": "value: 6938182.0", + "_comment": "value: 1.0", "id": "quicken:c.SLUnbox:FromBigNumber", "type": "Quicken", "operation": "SLUnbox" @@ -14,7 +14,7 @@ "FromLong", "FromBigNumber" ], - "_comment": "value: 4179750.0", + "_comment": "value: 0.6024272640873358", "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", "type": "Quicken", "operation": "SLUnbox" @@ -24,7 +24,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 3830950.0", + "_comment": "value: 0.5521547287171192", "id": "si:load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -37,7 +37,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 3205835.0", + "_comment": "value: 0.46205691923330927", "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -52,7 +52,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 2947763.0", + "_comment": "value: 0.4248610082583593", "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -67,7 +67,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 2947700.0", + "_comment": "value: 0.424851928069918", "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -82,7 +82,7 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 2947700.0", + "_comment": "value: 0.424851928069918", "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, @@ -93,7 +93,7 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 2646525.0", + "_comment": "value: 0.38144358277139456", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, @@ -105,7 +105,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 2400468.0", + "_comment": "value: 0.34597939344917733", "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -118,13 +118,13 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 2205210.0", + "_comment": "value: 0.3178368627401241", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["FromLong"], - "_comment": "value: 2192389.0", + "_comment": "value: 0.31598897232733303", "id": "quicken:c.SLUnbox:FromLong", "type": "Quicken", "operation": "SLUnbox" @@ -137,7 +137,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 2020896.0", + "_comment": "value: 0.2912716904803016", "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -150,7 +150,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 2000390.0", + "_comment": "value: 0.28831616120764775", "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -165,7 +165,7 @@ "load.constant", "c.SLUnbox" ], - "_comment": "value: 1617147.0", + "_comment": "value: 0.23307935709959757", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", "type": "SuperInstruction" }, @@ -180,7 +180,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 1617147.0", + "_comment": "value: 0.23307935709959757", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -195,13 +195,13 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 1617147.0", + "_comment": "value: 0.23307935709959757", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, { "specializations": ["FromBoolean"], - "_comment": "value: 1557962.0", + "_comment": "value: 0.22454902451391445", "id": "quicken:c.SLUnbox:FromBoolean", "type": "Quicken", "operation": "SLUnbox" @@ -217,7 +217,7 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, @@ -232,7 +232,7 @@ "load.constant", "c.SLReadProperty" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", "type": "SuperInstruction" }, @@ -247,7 +247,7 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, @@ -262,7 +262,7 @@ "load.local", "load.constant" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant", "type": "SuperInstruction" }, @@ -277,7 +277,7 @@ "c.SLUnbox", "load.constant" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant", "type": "SuperInstruction" }, @@ -292,7 +292,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 1470147.0", + "_comment": "value: 0.21189225073657625", "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -303,13 +303,13 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 1449447.0", + "_comment": "value: 0.2089087602487222", "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["Add0"], - "_comment": "value: 1426876.0", + "_comment": "value: 0.20565560257715926", "id": "quicken:c.SLAdd:Add0", "type": "Quicken", "operation": "SLAdd" @@ -325,7 +325,7 @@ "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 1400273.0", + "_comment": "value: 0.20182131284535343", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, @@ -339,13 +339,13 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 1381476.0", + "_comment": "value: 0.19911210170041663", "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "specializations": ["ReadSLObject0"], - "_comment": "value: 924071.0", + "_comment": "value: 0.13318633036723454", "id": "quicken:c.SLReadProperty:ReadSLObject0", "type": "Quicken", "operation": "SLReadProperty" @@ -358,7 +358,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 840152.0", + "_comment": "value: 0.12109108697350401", "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -367,7 +367,7 @@ "c.SLToBoolean", "branch.false" ], - "_comment": "value: 779349.0", + "_comment": "value: 0.1123275520878524", "id": "si:c.SLToBoolean,branch.false", "type": "SuperInstruction" }, From 5c05a4fba50a6cd701a75617ab9c5a5362fc92d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 22 Nov 2022 13:11:45 +0100 Subject: [PATCH 174/312] [wip] --- .../sl/operations/SLOperationRootNodeGen.java | 18 +++++++++--------- .../api/operation/OperationRootNode.java | 15 +++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index df01eccea9a9..231e8ab11984 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -300,8 +300,8 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : @@ -4460,18 +4460,18 @@ private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFra SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : { tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : { tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); return $sp; } // c.SLFunctionLiteral @@ -7303,20 +7303,20 @@ private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRo return; } - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); } } - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index 0d9ccff3c8eb..b0cf911ce0da 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -48,7 +48,6 @@ import com.oracle.truffle.api.operation.introspection.ExceptionHandler; import com.oracle.truffle.api.operation.introspection.Instruction; import com.oracle.truffle.api.operation.introspection.OperationIntrospection; -import com.oracle.truffle.api.operation.introspection.SourceInformation; import com.oracle.truffle.api.source.SourceSection; public interface OperationRootNode extends NodeInterface, OperationIntrospection.Provider { @@ -76,13 +75,13 @@ default String dump() { } } - List sourceInfo = id.getSourceInformation(); - if (sourceInfo != null) { - sb.append("Source Information:\n"); - for (SourceInformation si : sourceInfo) { - sb.append(" ").append(si.toString()).append('\n'); - } - } +// List sourceInfo = id.getSourceInformation(); +// if (sourceInfo != null) { +// sb.append("Source Information:\n"); +// for (SourceInformation si : sourceInfo) { +// sb.append(" ").append(si.toString()).append('\n'); +// } +// } return sb.toString(); } From 953c15c430b019333b2935da07f20b156a70ddbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 23 Nov 2022 11:34:00 +0100 Subject: [PATCH 175/312] [wip] Fix parsing proxied descriptions --- .../sl/operations/SLOperationRootNodeGen.java | 17208 +++++++++++----- .../operations/OperationsParser.java | 13 +- .../operations/SingleOperationParser.java | 59 +- .../sl/operations/SLOperationRootNode.java | 2 +- 4 files changed, 12369 insertions(+), 4913 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index 231e8ab11984..fc28567f1bde 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -47,7 +47,6 @@ import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; -import com.oracle.truffle.api.operation.tracing.ExecutionTracer; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; @@ -106,247 +105,377 @@ int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, i int $bci = $startBci; Counter loopCounter = new Counter(); $frame.getArguments(); - ExecutionTracer tracer = ExecutionTracer.get(SLOperationRootNode.class); - tracer.startFunction($this); - try { - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - if ($this.isBbStart[$bci]) { - tracer.traceStartBasicBlock($bci); - } - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_BRANCH, 1, 0); - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; } } } - $bci = targetBci; + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); continue loop; } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_BRANCH_FALSE, 1, 0); - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + return (($sp - 1) << 16) | 0xffff; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_THROW, 1, 0); - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_RETURN, 1, 0); - return (($sp - 1) << 16) | 0xffff; + } + case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : + { + if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; } - case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } + } + case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : + { + if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } - } - case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; + case 5 /* BOOLEAN */ : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; } } - // length group 1 (1 / 1) - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 1; - continue loop; - // length group 2 (1 / 1) - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 2; - continue loop; - // length group 3 (1 / 1) - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_STORE_LOCAL << 3) | 7) : - $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 3; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; continue loop; - // length group 5 (1 / 1) - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 5; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); continue loop; - // length group 6 (1 / 1) - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 6; - continue loop; - // length group 7 (1 / 1) - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 7; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; + } } - throw ex; + // length group 1 (1 / 1) + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 1; + continue loop; + // length group 2 (1 / 1) + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 2; + continue loop; + // length group 3 (1 / 1) + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_STORE_LOCAL << 3) | 7) : + $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 3; + continue loop; + // length group 5 (1 / 1) + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 5; + continue loop; + // length group 6 (1 / 1) + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 6; + continue loop; + // length group 7 (1 / 1) + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 7; + continue loop; + // length group 14 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_14_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 14; + continue loop; + // length group 15 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_15_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 15; + continue loop; + // length group 19 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_19_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 19; + continue loop; + // length group 22 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + $sp = instructionGroup_22_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 22; + continue loop; + // length group 23 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + $sp = instructionGroup_23_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 23; + continue loop; + // length group 24 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_24_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 24; + continue loop; + // length group 25 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_25_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 25; + continue loop; + // length group 26 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_26_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 26; + continue loop; + // length group 27 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + $sp = instructionGroup_27_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 27; + continue loop; + // length group 28 (1 / 1) + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_28_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 28; + continue loop; + // length group 30 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_30_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 30; + continue loop; + // length group 32 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_32_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 32; + continue loop; + // length group 33 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_33_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 33; + continue loop; + // length group 34 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_34_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 34; + continue loop; + // length group 37 (1 / 1) + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_37_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 37; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; } + throw ex; } - } finally { - tracer.endFunction($this); } } @@ -495,6 +624,156 @@ void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, $bci = $bci + SC_SL_OR_LENGTH; break; } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; + } } } } @@ -765,1080 +1044,1538 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han target.add(dec); break; } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLAddNode.addLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value_, $child1Value_); + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLDivNode.divLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLDivNode.div($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLDivNode.div($child0Value_, $child1Value_); + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doLong($child0Value_, $child1Value_); + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doString($child0Value_, $child1Value_); + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doNull($child0Value_, $child1Value_); + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - if (s7_ == null) { - // assert (s7_.leftInterop_.accepts($child0Value)); - // assert (s7_.rightInterop_.accepts($child1Value)); - if (count7_ < (4)) { - s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } finally { - encapsulating_.set(prev_); + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + target.add(dec); + break; } } - } finally { - if (hasLock) { - lock.unlock(); + } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); } + si = siTarget.toArray(); } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); } - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } return true; } - private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); } - private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + try { + return SLAddNode.addLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } } } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + try { + lock.unlock(); + hasLock = false; + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } } } { @@ -1848,24 +2585,48 @@ private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, S int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD0 << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + } lock.unlock(); hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + return SLAddNode.add($child0Value_, $child1Value_); } } } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } { int fallback_bci__ = 0; Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); lock.unlock(); hasLock = false; - return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } } finally { if (hasLock) { @@ -1874,153 +2635,175 @@ private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, S } } - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); } - private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); + try { + return SLDivNode.divLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } } } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); + return SLDivNode.div($child0Value__, $child1Value__); } } if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { Node fallback_node__ = ($this); int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } } } { @@ -2030,12 +2813,14 @@ private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOp int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); lock.unlock(); hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); + return SLDivNode.div($child0Value_, $child1Value_); } } } @@ -2044,10 +2829,10 @@ private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOp Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); lock.unlock(); hasLock = false; - return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } } finally { if (hasLock) { @@ -2056,711 +2841,464 @@ private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOp } } - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); } - return true; } - private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; + long $child0Value_; try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); } - private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLLogicalNotNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } boolean $child0Value_; try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { - return SLLogicalNotNode.doBoolean($child0Value_); + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); } - private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { int childArrayOffset_; int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.doBoolean($child0Value_); - } { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); } } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; + encapsulating_.set(prev_); } - return true; } - private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + @ExplodeLoop + private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } } - } - - private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } } - assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - } - - private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLMulNode.mulLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); } } } - if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLMulNode.mul($child0Value__, $child1Value__); + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); } } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } + } + + private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); } - private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); + boolean $child0Value_; try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); } @SuppressWarnings("static-method") @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { + private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { int childArrayOffset_; int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); } - throw BoundaryCallFailedException.INSTANCE; + } finally { + encapsulating_.set(prev_); } } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + @ExplodeLoop + private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); } - throw BoundaryCallFailedException.INSTANCE; } - } - - @ExplodeLoop - private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); } - if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); } } - if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { - Node node__2 = ($this); - int bci__2 = ($bci); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); } - s4_ = s4_.next_; + s7_ = s7_.next_; } } - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - try { - return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); + return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doLong($child0Value_, $child1Value_); } } { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = ($this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); } } } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - node__1 = ($this); - bci__1 = ($bci); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = ($this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); lock.unlock(); hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); + return SLEqualNode.doString($child0Value_, $child1Value_); } } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { - node__2 = ($this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (s4_.objects_.accepts($child0Value)); - InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); - node__2 = ($this); - bci__2 = ($bci); - s4_.objects_ = s4_.insertAccessor(objects__); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { + break; } + s7_ = s7_.next_; + count7_++; } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + if (s7_ == null) { + // assert (s7_.leftInterop_.accepts($child0Value)); + // assert (s7_.rightInterop_.accepts($child1Value)); + if (count7_ < (4)) { + s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); } } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + } } { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set($this); try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = ($this); - readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); - } - } + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); } finally { encapsulating_.set(prev_); } } } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } finally { if (hasLock) { lock.unlock(); @@ -2768,175 +3306,153 @@ private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, } } - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); } - private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; if ($child1Value_ instanceof Long) { long $child1Value__ = (long) $child1Value_; - try { - return SLSubNode.subLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); } } - if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLSubNode.sub($child0Value__, $child1Value__); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); } } if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { Node fallback_node__ = ($this); int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; long $child0Value_; try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); } long $child1Value_; try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; if ($child1Value instanceof Long) { long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); } } { @@ -2946,14 +3462,12 @@ private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperati int sLBigNumberCast1; if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); lock.unlock(); hasLock = false; - return SLSubNode.sub($child0Value_, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); } } } @@ -2962,10 +3476,10 @@ private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperati Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); lock.unlock(); hasLock = false; - return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } } finally { if (hasLock) { @@ -2974,380 +3488,287 @@ private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperati } } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { + private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } - throw BoundaryCallFailedException.INSTANCE; } - } finally { - encapsulating_.set(prev_); } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - @ExplodeLoop - private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); - if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); } - if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); } - if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - s4_ = s4_.next_; - } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); } - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - try { - return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); } } } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLLogicalNotNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); } - throw BoundaryCallFailedException.INSTANCE; } - } finally { - encapsulating_.set(prev_); } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); } - private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { + return SLLogicalNotNode.doBoolean($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.doBoolean($child0Value_); + } { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - int writeArray1_bci__ = 0; - Node writeArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - writeArray1_node__ = ($this); - writeArray1_bci__ = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); - } - } - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (s4_.objectLibrary_.accepts($child0Value)); - s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); - node__1 = ($this); - bci__1 = ($bci); - s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = ($this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); - } - } finally { - encapsulating_.set(prev_); - } - } + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); } finally { if (hasLock) { lock.unlock(); @@ -3355,538 +3776,421 @@ private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, } } - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; } + return true; } - private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; + long $child0Value_; try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); } - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; + long $child1Value_; try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); + assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); } - } finally { - encapsulating_.set(prev_); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } } - @ExplodeLoop - private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); - if (fromString_fromJavaStringNode__ != null) { - return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLUnboxNode.fromBoolean($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLMulNode.mulLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); } - s7_ = s7_.next_; + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); } } - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - try { - return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); - } catch (BoundaryCallFailedException ex) { + } + if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLMulNode.mul($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - boolean $child0Value_; + long $child0Value_; try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { - return SLUnboxNode.fromBoolean($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); } - long $child0Value_; + long $child1Value_; try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); } int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { - return SLUnboxNode.fromLong($child0Value_); + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); } - private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromLong($child0Value_); + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } } { int sLBigNumberCast0; if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBigNumber($child0Value_); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLMulNode.mul($child0Value_, $child1Value_); + } } } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); lock.unlock(); hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); + return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.interop_.accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, s7_.interop_); - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { + } finally { + if (hasLock) { lock.unlock(); } } } - private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; - if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); - if (result__ != null) { - return SLFunctionLiteralNode.perform($child0Value__, result__, node__); - } - } + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); } - private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); - node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - lock.unlock(); - hasLock = false; - return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } finally { - if (hasLock) { - lock.unlock(); + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); } + throw BoundaryCallFailedException.INSTANCE; } } - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; } } - private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + @ExplodeLoop + private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { + Node node__2 = ($this); + int bci__2 = ($bci); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + try { + return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); } - private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; } } - private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); } - private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; Lock lock = $this.getLockAccessor(); boolean hasLock = true; lock.lock(); try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); - Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); - if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); - } - if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); - if (indirect_callNode__ != null) { - return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = ($this); - int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); - if (interop_library__ != null) { - return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); - } - - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { while (s0_ != null) { - if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); break; } s0_ = s0_.next_; @@ -3895,163 +4199,198 @@ private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOper } if (s0_ == null) { { - RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); - if (($child0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - s0_.callTargetStable_ = callTargetStable__; - s0_.cachedTarget_ = cachedTarget__; - s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); } } } if (s0_ != null) { lock.unlock(); hasLock = false; - return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); } } - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); } { - int interop_bci__ = 0; - Node interop_node__ = null; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = ($this); - interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = ($this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); } - break; } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); } - } finally { - lock.unlock(); - } - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + node__1 = ($this); + bci__1 = ($bci); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = ($this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); } } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { + node__2 = ($this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (s4_.objects_.accepts($child0Value)); + InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); + node__2 = ($this); + bci__2 = ($bci); + s4_.objects_ = s4_.insertAccessor(objects__); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 8] = s4_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + } } { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = ($this); + readObject1_bci__ = ($bci); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 8] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); + } + } + } finally { + encapsulating_.set(prev_); + } + } } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } finally { if (hasLock) { lock.unlock(); @@ -4059,83 +4398,204 @@ private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperat } } - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { return false; } return true; } - private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); int childArrayOffset_; int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } else { - return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - boolean $child0Value_; + long $child0Value_; try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); } - private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { int childArrayOffset_; int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLSubNode.subLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLSubNode.sub($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { { Node fallback_node__ = ($this); int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); + private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLSubNode.sub($child0Value_, $child1Value_); + } + } } { int fallback_bci__ = 0; Node fallback_node__ = null; fallback_node__ = ($this); fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); lock.unlock(); hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); } } finally { if (hasLock) { @@ -4144,1220 +4604,5615 @@ private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperati } } - private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_POP, 0, 0); - $sp = $sp - 1; - $frame.clear($sp); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); } } - private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_LOAD_CONSTANT, 0, 0); - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - return $sp; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_LOAD_ARGUMENT, 0, 0); - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - return $sp; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_MAT, 0, 0); - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - return $sp; + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL_MAT, 0, 0); - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - return $sp; + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; } - default : - throw CompilerDirectives.shouldNotReachHere(); + } finally { + encapsulating_.set(prev_); } } - private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; + @ExplodeLoop + private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); + if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } } - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; + if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } } - case ((INSTR_STORE_LOCAL << 3) | 7) : - { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; + if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + try { + return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } } - default : - throw CompilerDirectives.shouldNotReachHere(); } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); } - private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); } - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { { - tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } } - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + int writeArray1_bci__ = 0; + Node writeArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + writeArray1_node__ = ($this); + writeArray1_bci__ = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); + } } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : { - tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (s4_.objectLibrary_.accepts($child0Value)); + s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); + node__1 = ($this); + bci__1 = ($bci); + s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 7] = s4_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + } } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_FUNCTION_LITERAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_FUNCTION_LITERAL, SLOperationRootNodeGen.doGetStateBits_SLFunctionLiteral_($bc, $bci)); - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = ($this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 7] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); + } + } finally { + encapsulating_.set(prev_); + } + } } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } finally { + if (hasLock) { + lock.unlock(); } - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { { - tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); } - default : - throw CompilerDirectives.shouldNotReachHere(); + } finally { + encapsulating_.set(prev_); } } - private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_READ_PROPERTY, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_READ_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLReadProperty_($bc, $bci)); - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - { - tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); } } - private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_WRITE_PROPERTY, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_WRITE_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLWriteProperty_($bc, $bci)); - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_INVOKE, 0, 1); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_INVOKE, SLOperationRootNodeGen.doGetStateBits_SLInvoke_($bc, $bci)); - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); + private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); } + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); } - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } - T insertAccessor(T node) { - return super.insert(node); + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); } - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + @ExplodeLoop + private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); + if (fromString_fromJavaStringNode__ != null) { + return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); + } } - - T insertAccessor(T node) { - return super.insert(node); + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLUnboxNode.fromBoolean($child0Value__); } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); } - - T insertAccessor(T node) { - return super.insert(node); + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; + if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLUnboxNode.fromFunction($child0Value__); } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + return SLUnboxNode.fromFunction($child0Value__); } - - T insertAccessor(T node) { - return super.insert(node); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + try { + return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); + } catch (BoundaryCallFailedException ex) { + } + } } - + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; + private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); } - - T insertAccessor(T node) { - return super.insert(node); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { + return SLUnboxNode.fromBoolean($child0Value_); } - + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; + private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); } - - T insertAccessor(T node) { - return super.insert(node); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { + return SLUnboxNode.fromLong($child0Value_); } - + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - $frame.getArguments(); - Counter uncachedExecuteCount = new Counter(); - uncachedExecuteCount.count = $this.uncachedExecuteCount; - ExecutionTracer tracer = ExecutionTracer.get(SLOperationRootNode.class); - tracer.startFunction($this); + private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); try { - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - if ($this.isBbStart[$bci]) { - tracer.traceStartBasicBlock($bci); - } - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_BRANCH, 1, 0); - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_BRANCH_FALSE, 1, 0); - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_THROW, 1, 0); - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_RETURN, 1, 0); - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount.count; - } - return (($sp - 1) << 16) | 0xffff; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_AND, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_AND, SLOperationRootNodeGen.doGetStateBits_SLAnd_($bc, $bci)); - if (UncachedBytecodeNode.SLAnd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_SC_SL_OR, 1, 0); - tracer.traceActiveSpecializations($bci, INSTR_SC_SL_OR, SLOperationRootNodeGen.doGetStateBits_SLOr_($bc, $bci)); - if (!UncachedBytecodeNode.SLOr_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // length group 1 (1 / 1) - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 1; - continue loop; - // length group 2 (1 / 1) - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 2; - continue loop; - // length group 3 (1 / 1) - case ((INSTR_STORE_LOCAL << 3) | 0) : - $sp = instructionGroup_3_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 3; - continue loop; - // length group 5 (1 / 1) - case ((INSTR_C_SL_EQUAL << 3) | 0) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : - case ((INSTR_C_SL_UNBOX << 3) | 0) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : - $sp = instructionGroup_5_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 5; - continue loop; - // length group 6 (1 / 1) - case ((INSTR_C_SL_ADD << 3) | 0) : - case ((INSTR_C_SL_DIV << 3) | 0) : - case ((INSTR_C_SL_MUL << 3) | 0) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0) : - $sp = instructionGroup_6_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 6; - continue loop; - // length group 7 (1 / 1) - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - $sp = instructionGroup_7_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode, tracer); - $bci = $bci + 7; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); } - } finally { - tracer.endFunction($this); - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromLong($child0Value_); + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBigNumber($child0Value_); } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; + if (s7_ == null) { + // assert (s7_.interop_.accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, s7_.interop_); } - case INSTR_LOAD_LOCAL_MAT : + } + { + InteropLibrary fromForeign1_interop__ = null; { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } finally { + encapsulating_.set(prev_); + } } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); + if (result__ != null) { + return SLFunctionLiteralNode.perform($child0Value__, result__, node__); } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + node__ = ($this); + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + lock.unlock(); + hasLock = false; + return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); + Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); + if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); + } + if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; + if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); + if (indirect_callNode__ != null) { + return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); + } } - case INSTR_SC_SL_OR : + } + if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { { - $bci = $bci + SC_SL_OR_LENGTH; - break; + Node interop_node__ = ($this); + int interop_bci__ = ($bci); + InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); + if (interop_library__ != null) { + return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); + } } } } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); } - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); + if (($child0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + s0_.callTargetStable_ = callTargetStable__; + s0_.cachedTarget_ = cachedTarget__; + s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[childArrayOffset_ + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = ($this); + interop_bci__ = ($bci); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } break; } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); + } + + private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + @ExplodeLoop + private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 7) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + { + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + { + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + { + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + { + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + { + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + { + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + { + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + { + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + { + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + { + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + { + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLAdd.q.Add0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : + { + SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : + { + SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + { + SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + return $sp; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + return $sp; + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } + @GeneratedBy(SLOperationRootNode.class) + private static final class UncachedBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + $frame.getArguments(); + Counter uncachedExecuteCount = new Counter(); + uncachedExecuteCount.count = $this.uncachedExecuteCount; + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + return ($sp << 16) | targetBci; + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + uncachedExecuteCount.count--; + if (uncachedExecuteCount.count <= 0) { + $this.changeInterpreters(COMMON_EXECUTE); + } else { + $this.uncachedExecuteCount = uncachedExecuteCount.count; + } + return (($sp - 1) << 16) | 0xffff; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0) : + { + if (UncachedBytecodeNode.SLAnd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0) : + { + if (!UncachedBytecodeNode.SLOr_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0) : + { + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + } + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + } + // length group 1 (1 / 1) + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 1; + continue loop; + // length group 2 (1 / 1) + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + $sp = instructionGroup_2_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 2; + continue loop; + // length group 3 (1 / 1) + case ((INSTR_STORE_LOCAL << 3) | 0) : + $sp = instructionGroup_3_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 3; + continue loop; + // length group 5 (1 / 1) + case ((INSTR_C_SL_EQUAL << 3) | 0) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : + case ((INSTR_C_SL_UNBOX << 3) | 0) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : + $sp = instructionGroup_5_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 5; + continue loop; + // length group 6 (1 / 1) + case ((INSTR_C_SL_ADD << 3) | 0) : + case ((INSTR_C_SL_DIV << 3) | 0) : + case ((INSTR_C_SL_MUL << 3) | 0) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0) : + $sp = instructionGroup_6_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 6; + continue loop; + // length group 7 (1 / 1) + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_7_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 7; + continue loop; + // length group 14 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_14_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 14; + continue loop; + // length group 15 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_15_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 15; + continue loop; + // length group 19 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_19_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 19; + continue loop; + // length group 22 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + $sp = instructionGroup_22_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 22; + continue loop; + // length group 23 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0) : + $sp = instructionGroup_23_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 23; + continue loop; + // length group 24 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_24_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 24; + continue loop; + // length group 25 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_25_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 25; + continue loop; + // length group 26 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_26_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 26; + continue loop; + // length group 27 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + $sp = instructionGroup_27_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 27; + continue loop; + // length group 28 (1 / 1) + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_28_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 28; + continue loop; + // length group 30 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_30_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 30; + continue loop; + // length group 32 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_32_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 32; + continue loop; + // length group 33 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_33_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 33; + continue loop; + // length group 34 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_34_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 34; + continue loop; + // length group 37 (1 / 1) + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_37_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 37; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; + } + } + } + } + + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; + } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); break; } case INSTR_LOAD_CONSTANT : @@ -5384,247 +10239,1982 @@ OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $han target.add(dec); break; } - case INSTR_LOAD_LOCAL_BOXED : + case INSTR_LOAD_LOCAL_BOXED : + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL : + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_RETURN : + { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; + $bci = $bci + RETURN_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD : + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_DIV : + { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_THAN : + { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_MUL : + { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_SUB : + { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_INVOKE : + { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; + $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_AND : + { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_AND_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_STORE_LOCAL : + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; target.add(dec); break; } - case INSTR_RETURN : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_LOAD_LOCAL_MAT : + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_STORE_LOCAL_MAT : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_ADD : + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_DIV : + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_EQUAL : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_LESS_OR_EQUAL : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_LESS_THAN : + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; target.add(dec); break; } - case INSTR_C_SL_LOGICAL_NOT : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_MUL : + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; target.add(dec); break; } - case INSTR_C_SL_READ_PROPERTY : + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; target.add(dec); break; } - case INSTR_C_SL_SUB : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; target.add(dec); break; } - case INSTR_C_SL_WRITE_PROPERTY : + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; target.add(dec); break; } - case INSTR_C_SL_UNBOX : + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_FUNCTION_LITERAL : + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_TO_BOOLEAN : + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_C_SL_INVOKE : + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_SC_SL_AND : + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; target.add(dec); break; } - case INSTR_SC_SL_OR : + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; target.add(dec); break; } } } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); + } + + private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLAddNode.add($child0Value_, $child1Value_); + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLDivNode.div($child0Value_, $child1Value_); + } + } + return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + + private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLLogicalNotNode.doBoolean($child0Value_); + } + return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); + } + + private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); + } + + private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } + + private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } + + private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); + } + return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); + } + + private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLToBooleanNode.doBoolean($child0Value_); + } + return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); + } + + private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { int childArrayOffset_; int constArrayOffset_; CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } + return SLUnboxNode.fromBigNumber($child0Value_); } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); } - private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + CompilerDirectives.transferToInterpreterAndInvalidate(); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + return SLUnboxNode.fromLong($child0Value_); + } + if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); + return SLUnboxNode.fromBigNumber($child0Value_); + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + return SLUnboxNode.fromFunction($child0Value_); + } + return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); + } + + private static Object SLAdd_q_Add0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -5632,282 +12222,609 @@ private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRoo SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLDivNode.div($child0Value_, $child1Value_); + return SLAddNode.add($child0Value_, $child1Value_); } } - return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); + if ((SLAddNode.isString($child0Value, $child1Value))) { + return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); + } + return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { int childArrayOffset_; int constArrayOffset_; CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLEqualNode.doLong($child0Value_, $child1Value_); + if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { + return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); + } + if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } + + private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0) : + { + SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0) : + { + SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - return SLEqualNode.doString($child0Value_, $child1Value_); + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : + { + SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0) : + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - return SLEqualNode.doNull($child0Value_, $child1Value_); + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : + { + SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); } - private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0) : + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0) : + { + SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0) : + { + SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0) : + { + SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; } + default : + throw CompilerDirectives.shouldNotReachHere(); } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); } - private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); + private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + return $sp; } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + return $sp; } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLMulNode.mul($child0Value_, $child1Value_); + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; } + default : + throw CompilerDirectives.shouldNotReachHere(); } - return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } - private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLSubNode.sub($child0Value_, $child1Value_); + private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; } + default : + throw CompilerDirectives.shouldNotReachHere(); } - return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); + private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : + { + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); } - private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_POP, 0, 0); - $sp = $sp - 1; - $frame.clear($sp); + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } default : @@ -5915,82 +12832,258 @@ private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_LOAD_CONSTANT, 0, 0); - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_LOAD_ARGUMENT, 0, 0); - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } return $sp; } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_BOXED, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } return $sp; } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_LOAD_LOCAL_MAT, 0, 0); - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL_MAT, 0, 0); - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } default : @@ -5998,22 +13091,42 @@ private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_STORE_LOCAL, 0, 0); - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } default : @@ -6021,142 +13134,348 @@ private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0) : + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLEqual_($bc, $bci)); - SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_OR_EQUAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_OR_EQUAL, SLOperationRootNodeGen.doGetStateBits_SLLessOrEqual_($bc, $bci)); - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_LESS_THAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LESS_THAN, SLOperationRootNodeGen.doGetStateBits_SLLessThan_($bc, $bci)); - SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } return $sp; } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_LOGICAL_NOT, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_LOGICAL_NOT, SLOperationRootNodeGen.doGetStateBits_SLLogicalNot_($bc, $bci)); - SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } return $sp; } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_UNBOX, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_UNBOX, SLOperationRootNodeGen.doGetStateBits_SLUnbox_($bc, $bci)); - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, $sp - 1, localIdx); + $sp -= 1; + $bci = $bci + STORE_LOCAL_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + return $sp; + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_FUNCTION_LITERAL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_FUNCTION_LITERAL, SLOperationRootNodeGen.doGetStateBits_SLFunctionLiteral_($bc, $bci)); - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } return $sp; } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_TO_BOOLEAN, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_TO_BOOLEAN, SLOperationRootNodeGen.doGetStateBits_SLToBoolean_($bc, $bci)); - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } default : @@ -6164,126 +13483,157 @@ private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_ADD, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_ADD, SLOperationRootNodeGen.doGetStateBits_SLAdd_($bc, $bci)); - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_DIV, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_DIV, SLOperationRootNodeGen.doGetStateBits_SLDiv_($bc, $bci)); - SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0) : + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_MUL, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_MUL, SLOperationRootNodeGen.doGetStateBits_SLMul_($bc, $bci)); - SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_READ_PROPERTY, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_READ_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLReadProperty_($bc, $bci)); - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0) : + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_SUB, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_SUB, SLOperationRootNodeGen.doGetStateBits_SLSub_($bc, $bci)); - SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } return $sp; } default : @@ -6291,66 +13641,51 @@ private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode, ExecutionTracer tracer) { + private static int instructionGroup_37_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $sp = $startSp; switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - tracer.traceInstruction($bci, INSTR_C_SL_WRITE_PROPERTY, 0, 0); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_WRITE_PROPERTY, SLOperationRootNodeGen.doGetStateBits_SLWriteProperty_($bc, $bci)); - SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : { - tracer.traceInstruction($bci, INSTR_C_SL_INVOKE, 0, 1); - tracer.traceActiveSpecializations($bci, INSTR_C_SL_INVOKE, SLOperationRootNodeGen.doGetStateBits_SLInvoke_($bc, $bci)); - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + UFA.unsafeCopyObject($frame, localIdx, $sp); + $sp += 1; + $bci = $bci + LOAD_LOCAL_LENGTH; + } + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + } + { + SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } + { + SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_ADD_LENGTH; + } + { + SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_UNBOX_LENGTH; + } return $sp; } default : @@ -6710,6 +14045,86 @@ T insertAccessor(T node) { private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; private static final int SC_SL_OR_LENGTH = 6; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 33; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 34; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 35; + private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; + private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; + private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; + private static final short INSTR_C_SL_ADD_Q_ADD0 = 37; + private static final int C_SL_ADD_Q_ADD0_CONSTANT_OFFSET = 1; + private static final int C_SL_ADD_Q_ADD0_CHILDREN_OFFSET = 2; + private static final int C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET = 4; + private static final int C_SL_ADD_Q_ADD0_LENGTH = 6; + private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 38; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; + private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; + private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; + private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; + private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; + private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; + private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; + private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; + private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; + private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; + private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; + private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; + private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; + private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; + private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; + private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; + private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; + private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; + private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; + private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; + private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; + private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; + private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; + private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; + private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; + private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; @CompilationFinal private OperationNodesImpl nodes; @CompilationFinal(dimensions = 1) private short[] _bc; @@ -6721,7 +14136,6 @@ T insertAccessor(T node) { @CompilationFinal private int _maxLocals; @CompilationFinal private int _maxStack; @CompilationFinal(dimensions = 1) private int[] sourceInfo; - @CompilationFinal(dimensions = 1) private boolean[] isBbStart; @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; @CompilationFinal private int uncachedExecuteCount = 16; @CompilationFinal private Object _osrMetadata; @@ -6856,7 +14270,6 @@ public Node deepCopy() { result._consts = Arrays.copyOf(_consts, _consts.length); result._children = Arrays.copyOf(_children, _children.length); result._localTags = Arrays.copyOf(_localTags, _localTags.length); - result.isBbStart = isBbStart; result._handlers = _handlers; result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); result._maxLocals = _maxLocals; @@ -6887,161 +14300,16 @@ private void changeInterpreters(BytecodeLoopBase impl) { this.switchImpl = impl; } - private static boolean[] doGetStateBits_SLAdd_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[4]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 add(SLBigNumber, SLBigNumber) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */; - result[3] = (state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLDiv_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 div(SLBigNumber, SLBigNumber) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLEqual_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[9]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - result[3] = (state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */; - result[4] = (state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */; - result[5] = (state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */; - result[6] = (state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */; - result[7] = (state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b100000000)) == 0 /* is-not-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */; - result[8] = (state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */; - return result; - } - - private static boolean[] doGetStateBits_SLLessOrEqual_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLLessThan_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLLogicalNot_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLMul_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 mul(SLBigNumber, SLBigNumber) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLReadProperty_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[6]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && ((state_0 & 0b1000)) == 0 /* is-not-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[3] = (state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[4] = (state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */ && ((state_0 & 0b100000)) == 0 /* is-not-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - result[5] = (state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - return result; - } - - private static boolean[] doGetStateBits_SLSub_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 sub(SLBigNumber, SLBigNumber) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLWriteProperty_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[6]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && ((state_0 & 0b1000)) == 0 /* is-not-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[3] = (state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */; - result[4] = (state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */ && ((state_0 & 0b100000)) == 0 /* is-not-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - result[5] = (state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */; - return result; - } - - private static boolean[] doGetStateBits_SLUnbox_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[9]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - result[3] = (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - result[4] = (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - result[5] = (state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */; - result[6] = (state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */; - result[7] = (state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */ && ((state_0 & 0b100000000)) == 0 /* is-not-state_0 fromForeign(Object, InteropLibrary) */; - result[8] = (state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */; - return result; - } - - private static boolean[] doGetStateBits_SLFunctionLiteral_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[1]; - result[0] = state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */; - return result; - } - - private static boolean[] doGetStateBits_SLToBoolean_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLInvoke_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[3]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */ && ((state_0 & 0b10)) == 0 /* is-not-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */; - result[2] = (state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */; - return result; - } - - private static boolean[] doGetStateBits_SLAnd_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; - return result; + private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } - private static boolean[] doGetStateBits_SLOr_(short[] $bc, int $bci) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - boolean[] result = new boolean[2]; - result[0] = (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - result[1] = (state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */; - return result; + private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; } private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { @@ -7303,20 +14571,20 @@ private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRo return; } - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); } } - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } catch (UnexpectedResultException ex) { UFA.unsafeSetObject($frame, destSlot, ex.getResult()); @@ -7328,18 +14596,110 @@ private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperati UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); } - private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } - private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); return; } + private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); @@ -7409,6 +14769,27 @@ private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNo } } + private static void SLAdd_q_Add0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } + + private static void SLAdd_q_Add0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + try { + UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); + return; + } catch (UnexpectedResultException ex) { + UFA.unsafeSetObject($frame, destSlot, ex.getResult()); + } + } + + private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 2; + UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 3; UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); @@ -7419,6 +14800,11 @@ private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNod UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); } + private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + int destSlot = $sp - 1; + UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); + } + private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); @@ -7449,11 +14835,6 @@ private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, S UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); } - private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { int destSlot = $sp - 2; UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); @@ -7801,7 +15182,6 @@ public static final class Builder extends OperationBuilder { private int[] instructionHistory = new int[8]; private int instructionHistoryIndex = 0; private int numLabels; - private boolean[] isBbStart = new boolean[65535]; private ArrayList constPool = new ArrayList<>(); private BuilderOperationData operationData; private ArrayList labels = new ArrayList<>(); @@ -7827,10 +15207,6 @@ public void serializeOperationNode(DataOutput buffer, OperationRootNode node) th private int lastChildPush; private TruffleString metadata_MethodName; - static { - ExecutionTracer.initialize(SLOperationRootNode.class, "/home/prof/ec/ws1/graal/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json", new String[] {null, "pop", "branch", "branch.false", "throw", "load.constant", "load.argument", "load.local", "load.local.boxed", "store.local", "return", "load.local.mat", "store.local.mat", "instrument.enter", "instrument.exit.void", "instrument.exit", "instrument.leave", "c.SLAdd", "c.SLDiv", "c.SLEqual", "c.SLLessOrEqual", "c.SLLessThan", "c.SLLogicalNot", "c.SLMul", "c.SLReadProperty", "c.SLSub", "c.SLWriteProperty", "c.SLUnbox", "c.SLFunctionLiteral", "c.SLToBoolean", "c.SLInvoke", "sc.SLAnd", "sc.SLOr"}, new String[][] {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, new String[] {"AddLong", "Add0", "Add1", "Fallback"}, new String[] {"DivLong", "Div", "Fallback"}, new String[] {"Long", "BigNumber", "Boolean", "String", "TruffleString", "Null", "Function", "Generic0", "Generic1", "Fallback"}, new String[] {"LessOrEqual0", "LessOrEqual1", "Fallback"}, new String[] {"LessThan0", "LessThan1", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"MulLong", "Mul", "Fallback"}, new String[] {"ReadArray0", "ReadArray1", "ReadSLObject0", "ReadSLObject1", "ReadObject0", "ReadObject1", "Fallback"}, new String[] {"SubLong", "Sub", "Fallback"}, new String[] {"WriteArray0", "WriteArray1", "WriteSLObject0", "WriteSLObject1", "WriteObject0", "WriteObject1", "Fallback"}, new String[] {"FromString", "FromTruffleString", "FromBoolean", "FromLong", "FromBigNumber", "FromFunction0", "FromFunction1", "FromForeign0", "FromForeign1", "Fallback"}, new String[] {"Perform", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Direct", "Indirect", "Interop", "Fallback"}, new String[] {"Boolean", "Fallback"}, new String[] {"Boolean", "Fallback"}}); - } - private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { this.nodes = nodes; this.isReparse = isReparse; @@ -7921,7 +15297,6 @@ private void doEmitLabel(OperationLabel label) { } lbl.hasValue = true; lbl.targetBci = bci; - isBbStart[bci] = true; } private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { @@ -8025,7 +15400,6 @@ private SLOperationRootNode publish(TruffleLanguage language) { result._consts = constPool.toArray(); result._children = new Node[numChildNodes]; result._localTags = new byte[numLocals]; - result.isBbStart = Arrays.copyOf(isBbStart, bci); result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); result._conditionProfiles = new int[numConditionProfiles]; result._maxLocals = numLocals; @@ -8207,8 +15581,10 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } bci = bci + BRANCH_FALSE_LENGTH; - isBbStart[bci] = true; } else { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -8216,7 +15592,6 @@ private void doAfterChild() { instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; bci = bci + POP_LENGTH; } - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } break; @@ -8233,8 +15608,10 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } bci = bci + BRANCH_FALSE_LENGTH; - isBbStart[bci] = true; } else if (childIndex == 1) { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -8250,7 +15627,6 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } else { for (int i = 0; i < lastChildPush; i++) { @@ -8259,7 +15635,6 @@ private void doAfterChild() { instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; bci = bci + POP_LENGTH; } - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -8276,8 +15651,10 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } bci = bci + BRANCH_FALSE_LENGTH; - isBbStart[bci] = true; } else if (childIndex == 1) { assert lastChildPush == 1; OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); @@ -8288,11 +15665,9 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[0])); } else { assert lastChildPush == 1; - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -8309,8 +15684,10 @@ private void doAfterChild() { bc[bci + 2] = (short) numConditionProfiles; numConditionProfiles += 2; instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { + bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); + } bci = bci + BRANCH_FALSE_LENGTH; - isBbStart[bci] = true; } else { for (int i = 0; i < lastChildPush; i++) { doBeforeEmitInstruction(1, false, false); @@ -8324,7 +15701,6 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); } break; @@ -8345,7 +15721,6 @@ private void doAfterChild() { labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; - isBbStart[bci] = true; } else { } break; @@ -8624,7 +15999,6 @@ public void beginWhile() { doBeforeChild(); operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - isBbStart[bci] = true; doEmitLabel(startLabel); operationData.aux[0] = startLabel; } @@ -8691,7 +16065,6 @@ public void endTryCatch() { if (numChildren != 2) { throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); } - isBbStart[bci] = true; doEmitLabel(((OperationLabelImpl) operationData.aux[1])); lastChildPush = 0; operationData = operationData.parent; @@ -8748,7 +16121,6 @@ public void endFinallyTry() { labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; bci = bci + BRANCH_LENGTH; - isBbStart[bci] = true; } ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); beh.endBci = endBci; @@ -8823,7 +16195,6 @@ public void emitLabel(OperationLabel arg0) { return; } doBeforeChild(); - isBbStart[bci] = true; doEmitLabel(arg0); lastChildPush = 0; doAfterChild(); @@ -8877,6 +16248,11 @@ public void emitLoadConstant(Object arg0) { bc[bci + 1] = (short) constantsStart; constPool.add(operationData.arguments[0]); instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_CONSTANT; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0); + } bci = bci + LOAD_CONSTANT_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -9219,7 +16595,6 @@ public void beginTag(Class arg0) { unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_ENTER << 3) | 0)); instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_ENTER; bci = bci + INSTRUMENT_ENTER_LENGTH; - isBbStart[bci] = true; lastChildPush = 0; } } @@ -9301,6 +16676,13 @@ public void endSLAdd() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_ADD; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_STORE_LOCAL) { + bc[bci - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0); + } bci = bci + C_SL_ADD_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -9639,6 +17021,9 @@ public void endSLReadProperty() { bc[bci + 4 + 0] = 0; bc[bci + 4 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_READ_PROPERTY; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0); + } bci = bci + C_SL_READ_PROPERTY_LENGTH; lastChildPush = 1; operationData = operationData.parent; @@ -9784,6 +17169,41 @@ public void endSLUnbox() { bc[bci + 3 + 0] = 0; bc[bci + 3 + 1] = 0; instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_UNBOX; + if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { + bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { + bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { + bc[bci - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { + bc[bci - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_C_SL_READ_PROPERTY) { + bc[bci - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT) { + bc[bci - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { + bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); + } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_POP) { + bc[bci - POP_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); + } bci = bci + C_SL_UNBOX_LENGTH; lastChildPush = 1; operationData = operationData.parent; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 5a90a824f978..0ecfd9f50c44 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -120,7 +120,7 @@ protected OperationsData parse(Element element, List mirror) { } if (!isValid) { - data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder)."); + data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder). Remove this constructor."); } } @@ -181,7 +181,8 @@ protected OperationsData parse(Element element, List mirror) { if (UNBOXABLE_TYPE_KINDS.contains(mir.getKind())) { beTypes.add(mir.getKind()); } else { - data.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list.", mir); + data.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", + mir); } } @@ -193,7 +194,7 @@ protected OperationsData parse(Element element, List mirror) { SingleOperationData opData = new SingleOperationParser(data, mir).parse(null, null); if (opData == null) { - data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Could not proxy operation"); + data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Error generating operation. Fix issues on the referenced class first."); continue; } @@ -211,7 +212,7 @@ protected OperationsData parse(Element element, List mirror) { if (opData != null) { data.addOperationData(opData); } else { - data.addError("Could not generate operation: " + inner.getSimpleName()); + data.addError("Error generating operation %s. Fix issues with the operation class fist.", inner.getSimpleName()); } opData.redirectMessagesOnGeneratedElements(data); @@ -222,7 +223,7 @@ protected OperationsData parse(Element element, List mirror) { for (AnnotationMirror mir : scOperations) { SingleOperationData opData = new SingleOperationParser(data, mir, true).parse(null, null); if (opData == null) { - data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Clould not proxy short circuit operation"); + data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Error generating operation. Fix issues on the referenced boolean converter class first."); continue; } @@ -248,7 +249,7 @@ protected OperationsData parse(Element element, List mirror) { isTracing = true; data.addWarning("Tracing compilation is forced. This should only be used during development."); if (decisionsFilePath == null) { - data.addError("Tracing forced, but no decisions file specified! Specify the tracing decisions file."); + data.addError("Tracing forced, but no decisions file specified. Specify the tracing decisions file."); } } else if (decisionsFilePath == null) { // decisions file not specified, can't trace no matter the options diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index 283388005e07..cc9a612c0c65 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -107,6 +107,7 @@ protected SingleOperationData parse(Element element, List mirr SingleOperationData data; if (element == null) { + // proxied type or short-circuiting if (proxyMirror == null) { throw new AssertionError(); } @@ -120,7 +121,9 @@ protected SingleOperationData parse(Element element, List mirr TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); if (proxyType.getKind() != TypeKind.DECLARED) { - parentData.addError(proxyMirror, proxyTypeValue, "Type referenced by @OperationProxy must be a class, not %s.", proxyType); + parentData.addError(proxyMirror, proxyTypeValue, "Type referenced by @%s must be a class, not %s.", + isShortCircuit ? "ShortCircuitOperation" : "OperationProxy", + proxyType); return null; } @@ -168,19 +171,25 @@ protected SingleOperationData parse(Element element, List mirr List operationFunctions = new ArrayList<>(); - if (proxyMirror == null) { - // @Operation annotated type + if (!ElementUtils.isAssignable(te.asType(), types.NodeInterface)) { + // operation specification - if (!te.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { - data.addError("@Operation annotated class must be declared static and final."); + if (!te.getModifiers().contains(Modifier.FINAL)) { + data.addError("Operation class must be declared final. Inheritance in operation specifications is not supported."); + } + + if (te.getEnclosingElement() != null && !te.getModifiers().contains(Modifier.STATIC)) { + data.addError("Operation class must not be an inner class (non-static nested class). Declare the class as static."); } if (te.getModifiers().contains(Modifier.PRIVATE)) { - data.addError("@Operation annotated class must not be declared private."); + data.addError("Operation class must not be declared private. Remove the private modifier to make it visible."); } + // TODO: Add cross-package visibility check + if (!ElementUtils.isObject(te.getSuperclass()) || !te.getInterfaces().isEmpty()) { - data.addError("@Operation annotated class must not extend/implement anything. Inheritance is not supported."); + data.addError("Operation class must not extend any classes or implement any interfaces. Inheritance in operation specifications is not supported."); } for (Element el : te.getEnclosedElements()) { @@ -189,16 +198,22 @@ protected SingleOperationData parse(Element element, List mirr continue; } - if (el.getKind() != ElementKind.CONSTRUCTOR && !el.getModifiers().contains(Modifier.STATIC)) { + if (!el.getModifiers().contains(Modifier.STATIC)) { + if (el.getKind() == ElementKind.CONSTRUCTOR && ((ExecutableElement) el).getParameters().size() == 0) { + // we need to explicitly allow the implicit 0-argument non-static + // constructor. + continue; + } data.addError(el, "@Operation annotated class must not contain non-static members."); } - - operationFunctions.addAll(findSpecializations(te.getEnclosedElements())); } + + operationFunctions.addAll(findSpecializations(te.getEnclosedElements())); } else { // proxied node - for (ExecutableElement cel : findSpecializations(te.getEnclosedElements())) { + for (ExecutableElement cel : findSpecializations(te)) { + // todo: also check supertypes if (!cel.getModifiers().contains(Modifier.STATIC)) { data.addError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); } @@ -207,6 +222,10 @@ protected SingleOperationData parse(Element element, List mirr } } + if (data.hasErrors()) { + return data; + } + if (operationFunctions.isEmpty()) { data.addError("Operation contains no specializations."); return data; @@ -546,7 +565,23 @@ private CodeTypeElement cloneTypeHierarchy(TypeElement element, Consumer findSpecializations(TypeElement te) { + if (ElementUtils.isObject(te.asType())) { + return new ArrayList<>(); + } + + List els = findSpecializations(context.getTypeElement((DeclaredType) te.getSuperclass())); + els.addAll(findSpecializations(te.getEnclosedElements())); + return els; + } + private List findSpecializations(Collection elements) { - return elements.stream().filter(x -> x instanceof ExecutableElement).map(x -> (ExecutableElement) x).filter(this::isSpecializationFunction).collect(Collectors.toUnmodifiableList()); + // @formatter:off + return elements.stream(). + filter(x -> x instanceof ExecutableElement). + map(x -> (ExecutableElement) x). + filter(this::isSpecializationFunction). + collect(Collectors.toUnmodifiableList()); + // @formatter:on } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index dfa263a4b051..e96c75f8c84a 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -90,7 +90,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}, forceTracing = true) + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) From 6aa6937c206cfc8b78ffc1b8733dcec59ae2ce99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 23 Nov 2022 13:01:35 +0100 Subject: [PATCH 176/312] [wip] Fix some issues --- .../sl/operations/SLOperationRootNodeGen.java | 158 +++++++++++------- .../operation/test/dsl_tests/ErrorTests.java | 82 ++++++--- .../api/operation/ContinuationResult.java | 30 +++- .../OperationsBytecodeCodeGenerator.java | 3 +- .../operations/OperationsParser.java | 8 +- 5 files changed, 191 insertions(+), 90 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index fc28567f1bde..a57b544a3576 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -6178,7 +6178,8 @@ private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $fram return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } - private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // pop @@ -6196,7 +6197,8 @@ private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // load.constant @@ -6303,7 +6305,8 @@ private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // store.local @@ -6346,7 +6349,8 @@ private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLEqual @@ -6621,7 +6625,8 @@ private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLAdd @@ -6820,7 +6825,8 @@ private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLWriteProperty @@ -6934,7 +6940,8 @@ private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFra } } - private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox @@ -6995,7 +7002,8 @@ private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox @@ -7116,7 +7124,8 @@ private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox @@ -7208,7 +7217,8 @@ private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox @@ -7407,7 +7417,8 @@ private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -7607,7 +7618,8 @@ private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox @@ -7901,7 +7913,8 @@ private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -8035,7 +8048,8 @@ private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox @@ -8253,7 +8267,8 @@ private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty @@ -8348,7 +8363,8 @@ private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd @@ -8526,7 +8542,8 @@ private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -8889,7 +8906,8 @@ private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox @@ -9031,7 +9049,8 @@ private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -9150,7 +9169,8 @@ private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd @@ -9251,7 +9271,8 @@ private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFr } } - private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -12248,7 +12269,8 @@ private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFra throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } - private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // pop @@ -12266,7 +12288,8 @@ private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // load.constant @@ -12343,7 +12366,8 @@ private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // store.local @@ -12365,7 +12389,8 @@ private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLEqual @@ -12494,7 +12519,8 @@ private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLAdd @@ -12611,7 +12637,8 @@ private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // c.SLWriteProperty @@ -12690,7 +12717,8 @@ private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, V } } - private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox @@ -12723,7 +12751,8 @@ private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox @@ -12787,7 +12816,8 @@ private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox @@ -12832,7 +12862,8 @@ private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox @@ -12916,7 +12947,8 @@ private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -13000,7 +13032,8 @@ private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox @@ -13091,7 +13124,8 @@ private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -13134,7 +13168,8 @@ private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox @@ -13227,7 +13262,8 @@ private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty @@ -13282,7 +13318,8 @@ private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd @@ -13338,7 +13375,8 @@ private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -13483,7 +13521,8 @@ private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox @@ -13536,7 +13575,8 @@ private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -13588,7 +13628,8 @@ private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd @@ -13641,7 +13682,8 @@ private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, } } - private static int instructionGroup_37_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + private static int instructionGroup_37_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; int $sp = $startSp; switch (curOpcode) { // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox @@ -15030,25 +15072,25 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); } - protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 1 /* LONG */ : - return UFA.unsafeUncheckedGetLong(frame, slot); + case 5 /* BOOLEAN */ : + return UFA.unsafeUncheckedGetBoolean(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); - return (long) value; + if (value instanceof Boolean) { + setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); + return (boolean) value; } break; } @@ -15058,25 +15100,25 @@ protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int b } } - protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 5 /* BOOLEAN */ : - return UFA.unsafeUncheckedGetBoolean(frame, slot); + case 1 /* LONG */ : + return UFA.unsafeUncheckedGetLong(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); - return (boolean) value; + if (value instanceof Long) { + setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); + return (long) value; } break; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java index c41233b304e5..73d481947262 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java @@ -1,9 +1,46 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.api.operation.test.dsl_tests; -import java.io.Serializable; - import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystem; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -67,7 +104,7 @@ protected MustHaveFDConstructor(TruffleLanguage language, FrameDescriptor.Bui } } - @ExpectError("Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder).") + @ExpectError("Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder). Remove this constructor.") @GenerateOperations(languageClass = ErrorLanguage.class) public abstract class InvalidConstructor extends RootNode implements OperationRootNode { protected InvalidConstructor(TruffleLanguage language, FrameDescriptor builder) { @@ -88,7 +125,7 @@ protected BadTypeSystem(TruffleLanguage language, FrameDescriptor builder) { } } - @ExpectError({"Cannot perform boxing elimination on java.lang.String. Remove this type from the boxing eliminated types list.", "No operations found."}) + @ExpectError("Cannot perform boxing elimination on java.lang.String. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.") @GenerateOperations(languageClass = ErrorLanguage.class, boxingEliminationTypes = {String.class}) public abstract class BadBoxingElimination extends RootNode implements OperationRootNode { protected BadBoxingElimination(TruffleLanguage language, FrameDescriptor builder) { @@ -96,16 +133,7 @@ protected BadBoxingElimination(TruffleLanguage language, FrameDescriptor buil } } - @ExpectError("Could not parse invalid node: ErroredNode. Fix errors in the node first.") - @GenerateOperations(languageClass = ErrorLanguage.class) - @OperationProxy(ErroredNode.class) - public abstract class BadNodeProxy extends RootNode implements OperationRootNode { - protected BadNodeProxy(TruffleLanguage language, FrameDescriptor builder) { - super(language, builder); - } - } - - @ExpectError({"Type referenced by @OperationProxy must be a class, not int.", "Could not proxy operation"}) + @ExpectError({"Type referenced by @OperationProxy must be a class, not int.", "Error generating operation. Fix issues on the referenced class first."}) @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(int.class) public abstract class BadProxyType extends RootNode implements OperationRootNode { @@ -117,28 +145,32 @@ protected BadProxyType(TruffleLanguage language, FrameDescriptor builder) { @ExpectError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(TestNode.class) - public static abstract class OperationErrorTests extends RootNode implements OperationRootNode { + public abstract static class OperationErrorTests extends RootNode implements OperationRootNode { protected OperationErrorTests(TruffleLanguage language, FrameDescriptor builder) { super(language, builder); } - @ExpectError({"@Operation annotated class must be declared static and final.", "Operation contains no specializations."}) + @ExpectError("Operation class must be declared final. Inheritance in operation specifications is not supported.") + @Operation + public static class TestOperation1 { + } + + @ExpectError("Operation class must not be an inner class (non-static nested class). Declare the class as static.") @Operation - public class TestOperation1 { + public final class TestOperation1a { } - @ExpectError({"@Operation annotated class must not be declared private.", "Operation contains no specializations."}) + @ExpectError("Operation class must not be declared private. Remove the private modifier to make it visible.") @Operation private static final class TestOperation2 { } - @ExpectError({"@Operation annotated class must not extend/implement anything. Inheritance is not supported.", "Operation contains no specializations."}) + @ExpectError("Operation class must not extend any classes or implement any interfaces. Inheritance in operation specifications is not supported.") @Operation - public static final class TestOperation3 extends Exception { - private static final long serialVersionUID = 1L; + public static final class TestOperation3 implements Cloneable { } - @ExpectError({"@Operation annotated class must not contain non-static members.", "Operation contains no specializations."}) + @ExpectError("@Operation annotated class must not contain non-static members.") @Operation public static final class TestOperation4 { public void doSomething() { @@ -198,7 +230,7 @@ public static void doStuff() { } } - public static abstract class TestNode extends Node { + public abstract static class TestNode extends Node { public abstract int execute(int x, int y); @Specialization @@ -213,4 +245,4 @@ protected Object createContext(Env env) { return null; } } -} \ No newline at end of file +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java index ef3fd0326547..6aa92363892c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java @@ -40,11 +40,17 @@ */ package com.oracle.truffle.api.operation; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; public final class ContinuationResult { - private final ContinuationLocation location; - private final MaterializedFrame frame; + final ContinuationLocation location; + final MaterializedFrame frame; private final Object result; ContinuationResult(ContinuationLocation location, MaterializedFrame frame, Object result) { @@ -60,4 +66,24 @@ public Object continueWith(Object value) { public Object getResult() { return result; } + + public abstract static class ContinueNode extends Node { + public abstract Object execute(ContinuationResult result, Object value); + + public static final int LIMIT = 3; + + @SuppressWarnings("unused") + @Specialization(guards = {"result.location.getRootNode() == rootNode"}, limit = "LIMIT") + public static Object invokeDirect(ContinuationResult result, Object value, + @Cached("result.location.getRootNode()") RootNode rootNode, + @Cached("create(rootNode.getCallTarget())") DirectCallNode callNode) { + return callNode.call(result.frame, value); + } + + @Specialization(replaces = "invokeDirect") + public static Object invokeIndirect(ContinuationResult result, Object value, + @Cached IndirectCallNode callNode) { + return callNode.call(result.location.getRootNode().getCallTarget(), result.frame, value); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 1b47b4e30ce2..a791be3c7a5a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -407,7 +407,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C met.addParameter(vars.localFrame); } met.addParameter(vars.bc); - met.addParameter(vars.bci); + met.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); met.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); met.addParameter(vars.consts); met.addParameter(vars.children); @@ -422,6 +422,7 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C CodeTreeBuilder b2 = met.createBuilder(); + b2.statement("int $bci = $startBci"); b2.statement("int $sp = $startSp"); b2.startSwitch().string("curOpcode").end().startBlock(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java index 0ecfd9f50c44..05015ef222aa 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java @@ -231,14 +231,14 @@ protected OperationsData parse(Element element, List mirror) { opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); } - if (opProxies.isEmpty() && operationTypes.isEmpty()) { - data.addWarning("No operations found."); - } - if (data.hasErrors()) { return data; } + if (opProxies.isEmpty() && operationTypes.isEmpty()) { + data.addWarning("No operations found."); + } + String decisionsFilePath = getMainDecisionsFilePath(typeElement, generateOperationsMirror); data.setDecisionsFilePath(decisionsFilePath); From 5659313e2f3092413e20ae991ee31c1b64fd361b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 23 Nov 2022 16:13:13 +0100 Subject: [PATCH 177/312] [wip] stuff --- .../sl/operations/SLOperationRootNodeGen.java | 80 ++++++++++--------- .../dsl/processor/operations/Operation.java | 1 + .../operations/OperationsCodeGenerator.java | 41 ++++++++-- .../operations/SingleOperationParser.java | 4 +- 4 files changed, 83 insertions(+), 43 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index a57b544a3576..75f2454fc489 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -15173,6 +15173,7 @@ public void serialize(OperationConfig config, DataOutputStream buffer, Operation @GeneratedBy(SLOperationRootNode.class) public static final class Builder extends OperationBuilder { + private static final String[] OPERATION_NAMES = new String[] {null, "Block", "Root", "IfThen", "IfThenElse", "Conditional", "While", "TryCatch", "FinallyTry", "FinallyTryNoExcept", "Label", "Branch", "LoadConstant", "LoadArgument", "LoadLocal", "StoreLocal", "Return", "LoadLocalMaterialized", "StoreLocalMaterialized", "Source", "SourceSection", "Tag", "SLAdd", "SLDiv", "SLEqual", "SLLessOrEqual", "SLLessThan", "SLLogicalNot", "SLMul", "SLReadProperty", "SLSub", "SLWriteProperty", "SLUnbox", "SLFunctionLiteral", "SLToBoolean", "SLInvoke", "SLAnd", "SLOr"}; private static final int OP_BLOCK = 1; private static final int OP_ROOT = 2; private static final int OP_IF_THEN = 3; @@ -15215,7 +15216,7 @@ public static final class Builder extends OperationBuilder { private final boolean isReparse; private final boolean withSource; private final boolean withInstrumentation; - private final SourceInfoBuilder sourceBuilder; + private SourceInfoBuilder sourceBuilder; private short[] bc = new short[65535]; private int bci; private int curStack; @@ -15258,7 +15259,7 @@ private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Operatio } this.withSource = config.isWithSource(); this.withInstrumentation = config.isWithInstrumentation(); - this.sourceBuilder = withSource ? new SourceInfoBuilder() : null; + this.sourceBuilder = withSource ? new SourceInfoBuilder(new ArrayList<>()) : null; } private void finish() { @@ -15284,7 +15285,7 @@ private void reset(TruffleLanguage language) { Arrays.fill(instructionHistory, -1); instructionHistoryIndex = 0; if (sourceBuilder != null) { - sourceBuilder.reset(); + sourceBuilder = new SourceInfoBuilder(sourceBuilder.sourceList); } metadata_MethodName = null; } @@ -15850,7 +15851,7 @@ public void endBlock() { return; } if (operationData.operationId != OP_BLOCK) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endBlock"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -15892,7 +15893,7 @@ public SLOperationRootNode endRoot() { return publish(null); } if (operationData.operationId != OP_ROOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endRoot"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -15916,6 +15917,7 @@ public SLOperationRootNode endRoot() { this.exceptionHandlers = parentData.exceptionHandlers; this.currentFinallyTry = parentData.currentFinallyTry; this.stackSourceBci = parentData.stackSourceBci; + this.sourceBuilder = parentData.sourceBuilder; this.parentData = parentData.parentData; return endCodeResult; } @@ -15945,7 +15947,7 @@ public void endIfThen() { return; } if (operationData.operationId != OP_IF_THEN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endIfThen"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -15981,7 +15983,7 @@ public void endIfThenElse() { return; } if (operationData.operationId != OP_IF_THEN_ELSE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endIfThenElse"); } int numChildren = operationData.numChildren; if (numChildren != 3) { @@ -16017,7 +16019,7 @@ public void endConditional() { return; } if (operationData.operationId != OP_CONDITIONAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endConditional"); } int numChildren = operationData.numChildren; if (numChildren != 3) { @@ -16056,7 +16058,7 @@ public void endWhile() { return; } if (operationData.operationId != OP_WHILE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endWhile"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16101,7 +16103,7 @@ public void endTryCatch() { return; } if (operationData.operationId != OP_TRY_CATCH) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endTryCatch"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16147,7 +16149,7 @@ public void endFinallyTry() { return; } if (operationData.operationId != OP_FINALLY_TRY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endFinallyTry"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16214,7 +16216,7 @@ public void endFinallyTryNoExcept() { return; } if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endFinallyTryNoExcept"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16371,7 +16373,7 @@ public void endStoreLocal() { return; } if (operationData.operationId != OP_STORE_LOCAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endStoreLocal"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -16413,7 +16415,7 @@ public void endReturn() { return; } if (operationData.operationId != OP_RETURN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endReturn"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -16455,7 +16457,7 @@ public void endLoadLocalMaterialized() { return; } if (operationData.operationId != OP_LOAD_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endLoadLocalMaterialized"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -16497,7 +16499,7 @@ public void endStoreLocalMaterialized() { return; } if (operationData.operationId != OP_STORE_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endStoreLocalMaterialized"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16550,7 +16552,7 @@ public void endSource() { } if (withSource) { if (operationData.operationId != OP_SOURCE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSource"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -16593,7 +16595,7 @@ public void endSourceSection() { } if (withSource) { if (operationData.operationId != OP_SOURCE_SECTION) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSourceSection"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -16653,7 +16655,7 @@ public void endTag() { } if (withInstrumentation) { if (operationData.operationId != OP_TAG) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endTag"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -16700,7 +16702,7 @@ public void endSLAdd() { return; } if (operationData.operationId != OP_SL_ADD) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLAdd"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16756,7 +16758,7 @@ public void endSLDiv() { return; } if (operationData.operationId != OP_SL_DIV) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLDiv"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16805,7 +16807,7 @@ public void endSLEqual() { return; } if (operationData.operationId != OP_SL_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLEqual"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16851,7 +16853,7 @@ public void endSLLessOrEqual() { return; } if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLessOrEqual"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16899,7 +16901,7 @@ public void endSLLessThan() { return; } if (operationData.operationId != OP_SL_LESS_THAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLessThan"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -16947,7 +16949,7 @@ public void endSLLogicalNot() { return; } if (operationData.operationId != OP_SL_LOGICAL_NOT) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLogicalNot"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -16994,7 +16996,7 @@ public void endSLMul() { return; } if (operationData.operationId != OP_SL_MUL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLMul"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -17043,7 +17045,7 @@ public void endSLReadProperty() { return; } if (operationData.operationId != OP_SL_READ_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLReadProperty"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -17097,7 +17099,7 @@ public void endSLSub() { return; } if (operationData.operationId != OP_SL_SUB) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLSub"); } int numChildren = operationData.numChildren; if (numChildren != 2) { @@ -17146,7 +17148,7 @@ public void endSLWriteProperty() { return; } if (operationData.operationId != OP_SL_WRITE_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLWriteProperty"); } int numChildren = operationData.numChildren; if (numChildren != 3) { @@ -17197,7 +17199,7 @@ public void endSLUnbox() { return; } if (operationData.operationId != OP_SL_UNBOX) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLUnbox"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -17277,7 +17279,7 @@ public void endSLFunctionLiteral() { return; } if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLFunctionLiteral"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -17324,7 +17326,7 @@ public void endSLToBoolean() { return; } if (operationData.operationId != OP_SL_TO_BOOLEAN) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLToBoolean"); } int numChildren = operationData.numChildren; if (numChildren != 1) { @@ -17371,7 +17373,7 @@ public void endSLInvoke() { return; } if (operationData.operationId != OP_SL_INVOKE) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLInvoke"); } int numChildren = operationData.numChildren; if (numChildren < 0) { @@ -17420,7 +17422,7 @@ public void endSLAnd() { return; } if (operationData.operationId != OP_SL_AND) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLAnd"); } int numChildren = operationData.numChildren; if (numChildren < 1) { @@ -17458,7 +17460,7 @@ public void endSLOr() { return; } if (operationData.operationId != OP_SL_OR) { - throw new IllegalStateException("Mismatched begin/end, expected " + operationData.operationId); + throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLOr"); } int numChildren = operationData.numChildren; if (numChildren < 1) { @@ -17984,13 +17986,17 @@ LabelFill offset(int offset) { @GeneratedBy(SLOperationRootNode.class) private static final class SourceInfoBuilder { + private final ArrayList sourceList; private final ArrayList sourceStack = new ArrayList<>(); - private final ArrayList sourceList = new ArrayList<>(); private int currentSource = -1; private final ArrayList bciList = new ArrayList<>(); private final ArrayList sourceDataList = new ArrayList<>(); private final ArrayList sourceDataStack = new ArrayList<>(); + SourceInfoBuilder(ArrayList sourceList) { + this.sourceList = sourceList; + } + void reset() { sourceStack.clear(); sourceDataList.clear(); @@ -18128,6 +18134,7 @@ private final class BuilderState { private ArrayList exceptionHandlers = new ArrayList<>(); private BuilderFinallyTryContext currentFinallyTry; private int[] stackSourceBci = new int[1024]; + private SourceInfoBuilder sourceBuilder; BuilderState(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder p) { this.bc = p.bc; @@ -18145,6 +18152,7 @@ private final class BuilderState { this.exceptionHandlers = p.exceptionHandlers; this.currentFinallyTry = p.currentFinallyTry; this.stackSourceBci = p.stackSourceBci; + this.sourceBuilder = p.sourceBuilder; this.parentData = p.parentData; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java index 90c152ddb9ae..308e3a695458 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java @@ -448,6 +448,7 @@ public CodeTree createEndCode(BuilderVariables vars) { b.statement("this.exceptionHandlers = parentData.exceptionHandlers"); b.statement("this.currentFinallyTry = parentData.currentFinallyTry"); b.statement("this.stackSourceBci = parentData.stackSourceBci"); + b.statement("this.sourceBuilder = parentData.sourceBuilder"); b.statement("this.parentData = parentData.parentData"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 76e32691f49b..5517def58fd4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -57,6 +57,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -1011,7 +1012,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "isReparse")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withSource")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withInstrumentation")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, typSourceBuilder.asType(), "sourceBuilder")); + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typSourceBuilder.asType(), "sourceBuilder")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "bc = new short[65535]")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "bci")); @@ -1058,7 +1059,7 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(createBuilderImplDoBeforeEmitInstruction()); CodeTypeElement typBuilderState = typBuilderImpl.add(createBuilderState(typBuilderImpl, "bc", "bci", "curStack", "maxStack", "numLocals", "numLabels", "yieldCount", "yieldLocations", - "constPool", "operationData", "labels", "labelFills", "numChildNodes", "numConditionProfiles", "exceptionHandlers", "currentFinallyTry", "stackSourceBci")); + "constPool", "operationData", "labels", "labelFills", "numChildNodes", "numConditionProfiles", "exceptionHandlers", "currentFinallyTry", "stackSourceBci", "sourceBuilder")); typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typBuilderState.asType(), "parentData")); typBuilderImpl.add(createDoLeaveFinallyTry(opDataImpl)); @@ -1073,6 +1074,8 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, typBuilderImpl.add(createBuilderImplPublish(typOperationNodeImpl)); typBuilderImpl.add(createBuilderImplLabelPass(typFinallyTryContext)); + typBuilderImpl.add(createBuilderImplOperationNames()); + // operation IDs for (Operation op : m.getOperationsContext().operations) { CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); @@ -1144,6 +1147,28 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, return typBuilderImpl; } + private CodeVariableElement createBuilderImplOperationNames() { + CodeVariableElement el = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(String[].class), "OPERATION_NAMES"); + CodeTreeBuilder b = el.createInitBuilder(); + + b.startNewArray((ArrayType) context.getType(String[].class), null); + + b.string("null"); + + int idx = 1; + for (Operation data : m.getOperations()) { + if (idx != data.id) { + throw new AssertionError(); + } + b.doubleQuote(data.name); + idx++; + } + + b.end(); + + return el; + } + private CodeTypeElement createBuilderState(CodeTypeElement typBuilder, String... fields) { CodeTypeElement typ = new CodeTypeElement(MOD_PRIVATE_FINAL, ElementKind.CLASS, null, "BuilderState"); typ.add(new CodeVariableElement(typ.asType(), "parentData")); @@ -1629,6 +1654,10 @@ private CodeTypeElement createSourceBuilder(CodeTypeElement typBuilderImpl) { CodeTypeElement typSourceBuilder = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceInfoBuilder", null); typSourceBuilder.setEnclosingElement(typBuilderImpl); + typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, types.Source), "sourceList")); + + typSourceBuilder.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typSourceBuilder)); + CodeTypeElement typSourceData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceData", null); typSourceBuilder.add(typSourceData); typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "start")); @@ -1637,7 +1666,6 @@ private CodeTypeElement createSourceBuilder(CodeTypeElement typBuilderImpl) { typSourceData.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typSourceData)); typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "sourceStack = new ArrayList<>()")); - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, types.Source), "sourceList = new ArrayList<>()")); typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "currentSource = -1")); typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "bciList = new ArrayList<>()")); typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, typSourceData.asType()), "sourceDataList = new ArrayList<>()")); @@ -2083,7 +2111,8 @@ private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, Bui b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote("Mismatched begin/end, expected ").string(" + operationData.operationId").end(3); + b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote("Mismatched begin/end, expected end").string( + " + OPERATION_NAMES[operationData.operationId] + ").doubleQuote(", got end" + op.name).end(3); b.end(); vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); @@ -2712,7 +2741,7 @@ private CodeExecutableElement createBuilderImplCtor(CodeTypeElement opNodesImpl) b.statement("this.withSource = config.isWithSource()"); b.statement("this.withInstrumentation = config.isWithInstrumentation()"); - b.statement("this.sourceBuilder = withSource ? new SourceInfoBuilder() : null"); + b.statement("this.sourceBuilder = withSource ? new SourceInfoBuilder(new ArrayList<>()) : null"); return ctor; } @@ -2753,7 +2782,7 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("instructionHistoryIndex = 0"); b.startIf().string("sourceBuilder != null").end().startBlock(); - b.statement("sourceBuilder.reset()"); + b.statement("sourceBuilder = new SourceInfoBuilder(sourceBuilder.sourceList)"); b.end(); if (m.enableYield) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index cc9a612c0c65..a52740ee43d7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -570,7 +570,9 @@ private List findSpecializations(TypeElement te) { return new ArrayList<>(); } - List els = findSpecializations(context.getTypeElement((DeclaredType) te.getSuperclass())); + List els = te.getSuperclass() == null + ? new ArrayList<>() + : findSpecializations(context.getTypeElement((DeclaredType) te.getSuperclass())); els.addAll(findSpecializations(te.getEnclosedElements())); return els; } From bd7999d8b35cc94b18559666a5ad5defd290646c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 24 Nov 2022 13:25:53 +0100 Subject: [PATCH 178/312] [wip] Instrumentation --- .../sl/operations/SLOperationRootNodeGen.java | 9696 ++++++++++++++++- .../truffle/api/operation/OperationNodes.java | 9 +- .../api/operation/OperationRootNode.java | 13 +- .../instrumentation/InstrumentRootNode.java | 108 + .../instrumentation/InstrumentTreeNode.java | 98 + .../truffle/dsl/processor/TruffleTypes.java | 4 + .../operations/OperationGeneratorFlags.java | 3 +- .../OperationsBytecodeCodeGenerator.java | 2 - .../operations/OperationsCodeGenerator.java | 55 +- .../operations/instructions/Instruction.java | 25 +- .../InstrumentationEnterInstruction.java | 5 +- .../InstrumentationExitInstruction.java | 23 +- .../InstrumentationLeaveInstruction.java | 39 +- 13 files changed, 10017 insertions(+), 63 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentRootNode.java create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentTreeNode.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index 75f2454fc489..6652adbf1489 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -20,6 +20,10 @@ import com.oracle.truffle.api.frame.FrameSlotTypeException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.impl.UnsafeFrameAccess; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.instrumentation.Tag; +import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.LibraryFactory; import com.oracle.truffle.api.nodes.BytecodeOSRNode; @@ -41,6 +45,8 @@ import com.oracle.truffle.api.operation.OperationNodes; import com.oracle.truffle.api.operation.OperationParser; import com.oracle.truffle.api.operation.OperationRootNode; +import com.oracle.truffle.api.operation.instrumentation.InstrumentRootNode; +import com.oracle.truffle.api.operation.instrumentation.InstrumentTreeNode; import com.oracle.truffle.api.operation.introspection.OperationIntrospection; import com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind; import com.oracle.truffle.api.operation.serialization.OperationDeserializer; @@ -85,6 +91,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; +import java.util.Set; import java.util.concurrent.locks.Lock; @GeneratedBy(SLOperationRootNode.class) @@ -13940,6 +13947,9616 @@ T insertAccessor(T node) { } } + @GeneratedBy(SLOperationRootNode.class) + private static final class InstrumentableBytecodeNode extends BytecodeLoopBase { + + private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); + private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); + + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + @BytecodeInterpreterSwitch + @Override + int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { + int $sp = $startSp; + int $bci = $startBci; + Counter loopCounter = new Counter(); + $frame.getArguments(); + loop: while (true) { + CompilerAsserts.partialEvaluationConstant($bci); + CompilerAsserts.partialEvaluationConstant($sp); + int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; + CompilerAsserts.partialEvaluationConstant(curOpcode); + try { + assert $sp >= maxLocals : "stack underflow @ " + $bci; + switch (curOpcode) { + // branch + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + case ((INSTR_BRANCH << 3) | 0) : + { + int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); + if (targetBci <= $bci) { + if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { + TruffleSafepoint.poll($this); + LoopNode.reportLoopCount($this, 256); + loopCounter.count = 0; + if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { + Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); + if (osrResult != null) { + $frame.setObject(0, osrResult); + return 0x0000ffff; + } + } + } + } + $bci = targetBci; + continue loop; + } + // branch.false + // Simple Pops: + // [ 0] condition + // Pushed Values: 0 + // Branch Targets: + // [ 0] target + // Branch Profiles: + // [ 0] profile + case ((INSTR_BRANCH_FALSE << 3) | 0) : + { + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // throw + // Locals: + // [ 0] exception + // Pushed Values: 0 + case ((INSTR_THROW << 3) | 0) : + { + int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); + throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); + } + // return + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_RETURN << 3) | 0) : + { + return (($sp - 1) << 16) | 0xffff; + } + // instrument.leave + // Pushed Values: 0 + // Branch Targets: + // [ 0] startBranch + // [ 1] endBranch + case ((INSTR_INSTRUMENT_LEAVE << 3) | 0) : + { + ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_INSTRUMENT_OFFSET) + 0); + if (probe != null) { + Object result = probe.onReturnExceptionalOrUnwind($frame, null, false); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + $bci = unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } else if (result != null) { + UFA.unsafeSetObject($frame, $sp - 1, result); + $bci = unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 1); + continue loop; + } + } + $bci = $bci + INSTRUMENT_LEAVE_LENGTH; + continue loop; + } + // sc.SLAnd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : + { + if (InstrumentableBytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : + { + if (InstrumentableBytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_AND_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // sc.SLOr + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + // Branch Targets: + // [ 0] end + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : + { + if (!InstrumentableBytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : + { + if (!InstrumentableBytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { + $sp = $sp - 1; + $bci = $bci + SC_SL_OR_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // si.c.SLToBoolean.branch.false + // Pushed Values: 0 + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; + $sp = $sp - 1; + if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { + $bci = $bci + BRANCH_FALSE_LENGTH; + continue loop; + } else { + $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); + continue loop; + } + } + // length group 1 (1 / 1) + case ((INSTR_POP << 3) | 0) : + $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 1; + continue loop; + // length group 2 (1 / 1) + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + case ((INSTR_INSTRUMENT_ENTER << 3) | 0) : + case ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0) : + $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 2; + continue loop; + // length group 3 (1 / 1) + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + case ((INSTR_STORE_LOCAL << 3) | 7) : + case ((INSTR_INSTRUMENT_EXIT << 3) | 0) : + $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 3; + continue loop; + // length group 5 (1 / 1) + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 5; + continue loop; + // length group 6 (1 / 1) + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 6; + continue loop; + // length group 7 (1 / 1) + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + case ((INSTR_C_SL_INVOKE << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 7; + continue loop; + // length group 14 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_14_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 14; + continue loop; + // length group 15 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_15_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 15; + continue loop; + // length group 19 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_19_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 19; + continue loop; + // length group 22 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + $sp = instructionGroup_22_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 22; + continue loop; + // length group 23 (1 / 1) + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + $sp = instructionGroup_23_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 23; + continue loop; + // length group 24 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_24_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 24; + continue loop; + // length group 25 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_25_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 25; + continue loop; + // length group 26 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_26_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 26; + continue loop; + // length group 27 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + $sp = instructionGroup_27_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 27; + continue loop; + // length group 28 (1 / 1) + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_28_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 28; + continue loop; + // length group 30 (1 / 1) + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_30_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 30; + continue loop; + // length group 32 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_32_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 32; + continue loop; + // length group 33 (1 / 1) + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + $sp = instructionGroup_33_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 33; + continue loop; + // length group 34 (1 / 1) + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + $sp = instructionGroup_34_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 34; + continue loop; + // length group 37 (1 / 1) + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + $sp = instructionGroup_37_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); + $bci = $bci + 37; + continue loop; + default : + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); + } + } catch (AbstractTruffleException ex) { + CompilerAsserts.partialEvaluationConstant($bci); + for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { + CompilerAsserts.partialEvaluationConstant(handlerIndex); + ExceptionHandler handler = $handlers[handlerIndex]; + if (handler.startBci > $bci || handler.endBci <= $bci) continue; + $sp = handler.startStack + maxLocals; + $frame.setObject(handler.exceptionIndex, ex); + $bci = handler.handlerBci; + continue loop; + } + throw ex; + } + } + } + + @Override + void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { + int $bci = 0; + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + case INSTR_POP : + { + $bci = $bci + POP_LENGTH; + break; + } + case INSTR_BRANCH : + { + $bci = $bci + BRANCH_LENGTH; + break; + } + case INSTR_BRANCH_FALSE : + { + $bci = $bci + BRANCH_FALSE_LENGTH; + break; + } + case INSTR_THROW : + { + $bci = $bci + THROW_LENGTH; + break; + } + case INSTR_LOAD_CONSTANT : + { + $bci = $bci + LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_LOAD_ARGUMENT : + { + $bci = $bci + LOAD_ARGUMENT_LENGTH; + break; + } + case INSTR_LOAD_LOCAL : + { + $bci = $bci + LOAD_LOCAL_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + break; + } + case INSTR_STORE_LOCAL : + { + $bci = $bci + STORE_LOCAL_LENGTH; + break; + } + case INSTR_RETURN : + { + $bci = $bci + RETURN_LENGTH; + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + break; + } + case INSTR_STORE_LOCAL_MAT : + { + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + break; + } + case INSTR_INSTRUMENT_ENTER : + { + $bci = $bci + INSTRUMENT_ENTER_LENGTH; + break; + } + case INSTR_INSTRUMENT_EXIT_VOID : + { + $bci = $bci + INSTRUMENT_EXIT_VOID_LENGTH; + break; + } + case INSTR_INSTRUMENT_EXIT : + { + $bci = $bci + INSTRUMENT_EXIT_LENGTH; + break; + } + case INSTR_INSTRUMENT_LEAVE : + { + $bci = $bci + INSTRUMENT_LEAVE_LENGTH; + break; + } + case INSTR_C_SL_ADD : + { + $bci = $bci + C_SL_ADD_LENGTH; + break; + } + case INSTR_C_SL_DIV : + { + $bci = $bci + C_SL_DIV_LENGTH; + break; + } + case INSTR_C_SL_EQUAL : + { + $bci = $bci + C_SL_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + break; + } + case INSTR_C_SL_LESS_THAN : + { + $bci = $bci + C_SL_LESS_THAN_LENGTH; + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + break; + } + case INSTR_C_SL_MUL : + { + $bci = $bci + C_SL_MUL_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_SUB : + { + $bci = $bci + C_SL_SUB_LENGTH; + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + break; + } + case INSTR_C_SL_UNBOX : + { + $bci = $bci + C_SL_UNBOX_LENGTH; + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_INVOKE : + { + $bci = $bci + C_SL_INVOKE_LENGTH; + break; + } + case INSTR_SC_SL_AND : + { + $bci = $bci + SC_SL_AND_LENGTH; + break; + } + case INSTR_SC_SL_OR : + { + $bci = $bci + SC_SL_OR_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + break; + } + } + } + } + + @Override + OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { + int $bci = 0; + ArrayList target = new ArrayList<>(); + while ($bci < $bc.length) { + switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { + default : + { + Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; + $bci++; + target.add(dec); + break; + } + case INSTR_POP : + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + $bci = $bci + POP_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH : + { + Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_LENGTH; + target.add(dec); + break; + } + case INSTR_BRANCH_FALSE : + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + case INSTR_THROW : + { + Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; + $bci = $bci + THROW_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_CONSTANT : + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + $bci = $bci + LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_ARGUMENT : + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL : + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_BOXED : + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL : + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + STORE_LOCAL_LENGTH; + target.add(dec); + break; + } + case INSTR_RETURN : + { + Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; + $bci = $bci + RETURN_LENGTH; + target.add(dec); + break; + } + case INSTR_LOAD_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + LOAD_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_STORE_LOCAL_MAT : + { + Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; + $bci = $bci + STORE_LOCAL_MAT_LENGTH; + target.add(dec); + break; + } + case INSTR_INSTRUMENT_ENTER : + { + Object[] dec = new Object[] {$bci, "instrument.enter", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_ENTER_LENGTH), new Object[] {}}; + $bci = $bci + INSTRUMENT_ENTER_LENGTH; + target.add(dec); + break; + } + case INSTR_INSTRUMENT_EXIT_VOID : + { + Object[] dec = new Object[] {$bci, "instrument.exit.void", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_EXIT_VOID_LENGTH), new Object[] {}}; + $bci = $bci + INSTRUMENT_EXIT_VOID_LENGTH; + target.add(dec); + break; + } + case INSTR_INSTRUMENT_EXIT : + { + Object[] dec = new Object[] {$bci, "instrument.exit", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_EXIT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + INSTRUMENT_EXIT_LENGTH; + target.add(dec); + break; + } + case INSTR_INSTRUMENT_LEAVE : + { + Object[] dec = new Object[] {$bci, "instrument.leave", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_LEAVE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 0)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 1)}}}; + $bci = $bci + INSTRUMENT_LEAVE_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD : + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_DIV : + { + Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_DIV_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_OR_EQUAL : + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LESS_THAN : + { + Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_LESS_THAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_LOGICAL_NOT : + { + Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_MUL : + { + Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_MUL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_SUB : + { + Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_SUB_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_WRITE_PROPERTY : + { + Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; + $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_FUNCTION_LITERAL : + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_TO_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_INVOKE : + { + Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; + $bci = $bci + C_SL_INVOKE_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_AND : + { + Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_AND_LENGTH; + target.add(dec); + break; + } + case INSTR_SC_SL_OR : + { + Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; + $bci = $bci + SC_SL_OR_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_LONG : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : + { + Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_ADD_Q_ADD0 : + { + Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; + target.add(dec); + break; + } + case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { + new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_ARGUMENT_LENGTH; + { + Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += STORE_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_ADD_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_READ_PROPERTY_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += LOAD_LOCAL_BOXED_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_LESS_OR_EQUAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[7] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; + ((Object[]) decSuper[4])[5] = dec; + } + $bci += C_SL_ADD_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[6] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; + { + Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += POP_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += LOAD_CONSTANT_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[2] = dec; + } + $bci += C_SL_FUNCTION_LITERAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { + new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[3] = dec; + } + $bci += LOAD_LOCAL_LENGTH; + { + Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[4] = dec; + } + $bci += C_SL_UNBOX_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; + target.add(dec); + break; + } + case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : + { + int oldBci = $bci; + Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; + { + Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { + new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, + new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; + ((Object[]) decSuper[4])[0] = dec; + } + $bci += C_SL_TO_BOOLEAN_LENGTH; + { + Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { + new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; + ((Object[]) decSuper[4])[1] = dec; + } + $bci += BRANCH_FALSE_LENGTH; + Object[] dec = decSuper; + $bci = oldBci; + $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; + target.add(dec); + break; + } + } + } + ArrayList ehTarget = new ArrayList<>(); + for (int i = 0; i < $handlers.length; i++) { + ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); + } + Object[] si = null; + if (nodes != null && nodes.getSources() != null && sourceInfo != null) { + ArrayList siTarget = new ArrayList<>(); + for (int i = 0; i < sourceInfo.length; i += 3) { + int startBci = sourceInfo[i] & 0xffff; + int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; + if (startBci == endBci) { + continue; + } + int sourceIndex = sourceInfo[i] >> 16; + int sourceStart = sourceInfo[i + 1]; + int sourceLength = sourceInfo[i + 2]; + siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); + } + si = siTarget.toArray(); + } + return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); + } + + private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { + return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLAddNode.addLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { + if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { + SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); + if (s2_ != null) { + if ((SLAddNode.isString($child0Value_, $child1Value_))) { + return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { + return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { + try { + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + try { + lock.unlock(); + hasLock = false; + return SLAddNode.addLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); + } finally { + lock.unlock(); + } + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD0 << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value_, $child1Value_); + } + } + } + if ((SLAddNode.isString($child0Value, $child1Value))) { + SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); + s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); + VarHandle.storeStoreFence(); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLDivNode.divLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLDivNode.div($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { + try { + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLDivNode.divLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); + } finally { + lock.unlock(); + } + return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLDivNode.div($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { + return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + + private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + boolean $child1Value_; + try { + $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); + return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLEqualNode.doLong($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLEqualNode.doBigNumber($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + if ($child1Value_ instanceof Boolean) { + boolean $child1Value__ = (boolean) $child1Value_; + return SLEqualNode.doBoolean($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + if ($child1Value_ instanceof String) { + String $child1Value__ = (String) $child1Value_; + return SLEqualNode.doString($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + if ($child1Value_ instanceof TruffleString) { + TruffleString $child1Value__ = (TruffleString) $child1Value_; + EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); + if (truffleString_equalNode__ != null) { + return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); + } + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + if (SLTypes.isSLNull($child1Value_)) { + SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); + return SLEqualNode.doNull($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLEqualNode.doFunction($child0Value__, $child1Value_); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { + return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + try { + return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doLong($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBigNumber($child0Value_, $child1Value_); + } + } + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + if ($child1Value instanceof Boolean) { + boolean $child1Value_ = (boolean) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doBoolean($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + if ($child1Value instanceof String) { + String $child1Value_ = (String) $child1Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doString($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + if ($child1Value instanceof TruffleString) { + TruffleString $child1Value_ = (TruffleString) $child1Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + if (SLTypes.isSLNull($child1Value)) { + SLNull $child1Value_ = SLTypes.asSLNull($child1Value); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doNull($child0Value_, $child1Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doFunction($child0Value_, $child1Value); + } + if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + int count7_ = 0; + SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.leftInterop_.accepts($child0Value)); + // assert (s7_.rightInterop_.accepts($child1Value)); + if (count7_ < (4)) { + s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); + } + } + { + InteropLibrary generic1_rightInterop__ = null; + InteropLibrary generic1_leftInterop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + + private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { + return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + + private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLLessThanNode.lessThan($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.lessThan($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { + return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLLogicalNotNode.doBoolean($child0Value_); + } + + private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLLogicalNotNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { + return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { + return SLLogicalNotNode.doBoolean($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLMulNode.mulLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLMulNode.mul($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { + try { + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLMulNode.mulLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + } finally { + lock.unlock(); + } + return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLMulNode.mul($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @ExplodeLoop + private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { + Node node__2 = ($this); + int bci__2 = ($bci); + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value_))) { + try { + return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readArray1_node__ = ($this); + int readArray1_bci__ = ($bci); + InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readSLObject1_node__ = ($this); + int readSLObject1_bci__ = ($bci); + DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if (readSLObject1_toTruffleStringNode__ != null) { + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node readObject1_node__ = ($this); + int readObject1_bci__ = ($bci); + InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); + if (readObject1_asMember__ != null) { + return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary readArray1_numbers__ = null; + InteropLibrary readArray1_arrays__ = null; + int readArray1_bci__ = 0; + Node readArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((readArray1_arrays__.hasArrayElements($child0Value))) { + readArray1_node__ = ($this); + readArray1_bci__ = ($bci); + readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + node__1 = ($this); + bci__1 = ($bci); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + } + { + DynamicObjectLibrary readSLObject1_objectLibrary__ = null; + int readSLObject1_bci__ = 0; + Node readSLObject1_node__ = null; + readSLObject1_node__ = ($this); + readSLObject1_bci__ = ($bci); + readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); + } + } + { + int bci__2 = 0; + Node node__2 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); + if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { + node__2 = ($this); + bci__2 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + // assert (s4_.objects_.accepts($child0Value)); + InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { + s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); + node__2 = ($this); + bci__2 = ($bci); + s4_.objects_ = s4_.insertAccessor(objects__); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 8] = s4_; + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + } + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); + } + } + } + { + InteropLibrary readObject1_objects__ = null; + int readObject1_bci__ = 0; + Node readObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { + readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); + if ((readObject1_objects__.hasMembers($child0Value))) { + readObject1_node__ = ($this); + readObject1_bci__ = ($bci); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 8] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + return true; + } + + private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { + return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + + private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + if ($child1Value_ instanceof Long) { + long $child1Value__ = (long) $child1Value_; + try { + return SLSubNode.subLong($child0Value__, $child1Value__); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); + } + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLSubNode.sub($child0Value__, $child1Value__); + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { + return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); + } + long $child1Value_; + try { + $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { + try { + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); + if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + if ($child1Value instanceof Long) { + long $child1Value_ = (long) $child1Value; + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); + try { + lock.unlock(); + hasLock = false; + return SLSubNode.subLong($child0Value_, $child1Value_); + } catch (ArithmeticException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + lock.lock(); + try { + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); + } finally { + lock.unlock(); + } + return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + } + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + int sLBigNumberCast1; + if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { + SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); + state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); + lock.unlock(); + hasLock = false; + return SLSubNode.sub($child0Value_, $child1Value_); + } + } + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); + if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { + try { + return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + try { + return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { + Node node__1 = ($this); + int bci__1 = ($bci); + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + s4_ = s4_.next_; + } + } + if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { + try { + return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + Node writeArray1_node__ = ($this); + int writeArray1_bci__ = ($bci); + InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); + SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); + if (writeSLObject1_toTruffleStringNode__ != null) { + return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + Node writeObject1_node__ = ($this); + int writeObject1_bci__ = ($bci); + InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); + if (writeObject1_asMember__ != null) { + return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); + } + throw BoundaryCallFailedException.INSTANCE; + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); + { + int bci__ = 0; + Node node__ = null; + if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + int count0_ = 0; + SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { + while (s0_ != null) { + if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { + node__ = ($this); + bci__ = ($bci); + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + // assert (s0_.arrays_.accepts($child0Value)); + // assert (s0_.numbers_.accepts($child1Value)); + if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + node__ = ($this); + bci__ = ($bci); + s0_.arrays_ = s0_.insertAccessor(arrays__); + s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); + } + } + } + { + InteropLibrary writeArray1_numbers__ = null; + InteropLibrary writeArray1_arrays__ = null; + int writeArray1_bci__ = 0; + Node writeArray1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); + if ((writeArray1_arrays__.hasArrayElements($child0Value))) { + writeArray1_node__ = ($this); + writeArray1_bci__ = ($bci); + writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); + } + } + } finally { + encapsulating_.set(prev_); + } + } + } + if ($child0Value instanceof SLObject) { + SLObject $child0Value_ = (SLObject) $child0Value; + if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + int count2_ = 0; + SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); + if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value_))) { + break; + } + s2_ = s2_.next_; + count2_++; + } + } + if (s2_ == null) { + // assert (s2_.objectLibrary_.accepts($child0Value_)); + if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); + s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); + s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 4] = s2_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + } + } + if (s2_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + } + { + DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; + writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $children[childArrayOffset_ + 4] = null; + state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); + } + } + { + int bci__1 = 0; + Node node__1 = null; + if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + int count4_ = 0; + SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); + if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { + while (s4_ != null) { + if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { + node__1 = ($this); + bci__1 = ($bci); + break; + } + s4_ = s4_.next_; + count4_++; + } + } + if (s4_ == null) { + if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { + // assert (s4_.objectLibrary_.accepts($child0Value)); + s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); + node__1 = ($this); + bci__1 = ($bci); + s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 7] = s4_; + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + } + } + if (s4_ != null) { + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); + } + } + } + { + InteropLibrary writeObject1_objectLibrary__ = null; + int writeObject1_bci__ = 0; + Node writeObject1_node__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { + writeObject1_node__ = ($this); + writeObject1_bci__ = ($bci); + writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $children[childArrayOffset_ + 7] = null; + state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); + lock.unlock(); + hasLock = false; + return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); + } + } finally { + encapsulating_.set(prev_); + } + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { + return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + @SuppressWarnings("static-method") + @TruffleBoundary + private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { + int childArrayOffset_; + int constArrayOffset_; + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + { + InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); + return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); + } + } finally { + encapsulating_.set(prev_); + } + } + + @ExplodeLoop + private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { + String $child0Value__ = (String) $child0Value_; + FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); + if (fromString_fromJavaStringNode__ != null) { + return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + return SLUnboxNode.fromTruffleString($child0Value__); + } + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLUnboxNode.fromBoolean($child0Value__); + } + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { + SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); + return SLUnboxNode.fromFunction($child0Value__); + } + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value_))) { + return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); + } + s7_ = s7_.next_; + } + } + if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + try { + return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); + } catch (BoundaryCallFailedException ex) { + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { + return SLUnboxNode.fromBoolean($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { + return SLUnboxNode.fromLong($child0Value_); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof String) { + String $child0Value_ = (String) $child0Value; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); + } + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromTruffleString($child0Value_); + } + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBoolean($child0Value_); + } + if ($child0Value instanceof Long) { + long $child0Value_ = (long) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromLong($child0Value_); + } + { + int sLBigNumberCast0; + if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { + SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); + state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); + } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); + } else { + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromBigNumber($child0Value_); + } + } + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if (SLTypes.isSLNull($child0Value)) { + SLNull $child0Value_ = SLTypes.asSLNull($child0Value); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromFunction($child0Value_); + } + if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { + int count7_ = 0; + SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); + if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { + while (s7_ != null) { + if ((s7_.interop_.accepts($child0Value))) { + break; + } + s7_ = s7_.next_; + count7_++; + } + } + if (s7_ == null) { + // assert (s7_.interop_.accepts($child0Value)); + if (count7_ < (SLUnboxNode.LIMIT)) { + s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); + s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 1] = s7_; + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + } + } + if (s7_ != null) { + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, s7_.interop_); + } + } + { + InteropLibrary fromForeign1_interop__ = null; + { + EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); + Node prev_ = encapsulating_.set($this); + try { + fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; + state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); + $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); + short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); + lock.unlock(); + hasLock = false; + return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); + } finally { + encapsulating_.set(prev_); + } + } + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { + TruffleString $child0Value__ = (TruffleString) $child0Value_; + { + Node node__ = ($this); + SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); + if (result__ != null) { + return SLFunctionLiteralNode.perform($child0Value__, result__, node__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); + { + Node node__ = null; + if ($child0Value instanceof TruffleString) { + TruffleString $child0Value_ = (TruffleString) $child0Value; + $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); + node__ = ($this); + $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); + lock.unlock(); + hasLock = false; + return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); + } + } + throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + @ExplodeLoop + private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); + Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); + if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { + if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { + SLFunction $child0Value__ = (SLFunction) $child0Value_; + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (s0_ != null) { + if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); + } + if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { + return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + s0_ = s0_.next_; + } + } + if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { + IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); + if (indirect_callNode__ != null) { + return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); + } + } + } + if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { + { + Node interop_node__ = ($this); + int interop_bci__ = ($bci); + InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); + if (interop_library__ != null) { + return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); + } + + private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); + short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); + if ($child0Value instanceof SLFunction) { + SLFunction $child0Value_ = (SLFunction) $child0Value; + if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + int count0_ = 0; + SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { + while (s0_ != null) { + if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { + break; + } + s0_ = s0_.next_; + count0_++; + } + } + if (s0_ == null) { + { + RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); + if (($child0Value_.getCallTarget() == cachedTarget__)) { + Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); + Assumption assumption0 = (callTargetStable__); + if (Assumption.isValidAssumption(assumption0)) { + if (count0_ < (3)) { + s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); + s0_.callTargetStable_ = callTargetStable__; + s0_.cachedTarget_ = cachedTarget__; + s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); + VarHandle.storeStoreFence(); + $children[childArrayOffset_ + 0] = s0_; + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } + } + } + } + if (s0_ != null) { + lock.unlock(); + hasLock = false; + return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); + } + } + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $children[childArrayOffset_ + 0] = null; + state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); + } + { + int interop_bci__ = 0; + Node interop_node__ = null; + $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); + interop_node__ = ($this); + interop_bci__ = ($bci); + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); + lock.unlock(); + hasLock = false; + return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + lock.lock(); + try { + SLInvoke_DirectData prev = null; + SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); + while (cur != null) { + if (cur == s0_) { + if (prev == null) { + $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); + } else { + prev.next_ = prev.insertAccessor(cur.next_); + } + break; + } + prev = cur; + cur = cur.next_; + } + if ($children[childArrayOffset_ + 0] == null) { + $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); + } + } finally { + lock.unlock(); + } + } + + private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { + if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { + return false; + } + return true; + } + + private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { + return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; + return SLToBooleanNode.doBoolean($child0Value_); + } + + private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { + boolean $child0Value__ = (boolean) $child0Value_; + return SLToBooleanNode.doBoolean($child0Value__); + } + if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { + { + Node fallback_node__ = ($this); + int fallback_bci__ = ($bci); + if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { + return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { + int childArrayOffset_; + int constArrayOffset_; + Lock lock = $this.getLockAccessor(); + boolean hasLock = true; + lock.lock(); + try { + short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); + if ($child0Value instanceof Boolean) { + boolean $child0Value_ = (boolean) $child0Value; + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doBoolean($child0Value_); + } + { + int fallback_bci__ = 0; + Node fallback_node__ = null; + fallback_node__ = ($this); + fallback_bci__ = ($bci); + $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); + lock.unlock(); + hasLock = false; + return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); + } + } finally { + if (hasLock) { + lock.unlock(); + } + } + } + + private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLUnboxNode.fromBigNumber($child0Value__); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + int childArrayOffset_; + int constArrayOffset_; + if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } else { + return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); + } + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { + int childArrayOffset_; + int constArrayOffset_; + Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { + long $child0Value__ = (long) $child0Value_; + return SLUnboxNode.fromLong($child0Value__); + } + if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); + } + + private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); + } + + private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + long $child0Value_; + try { + $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; + return SLUnboxNode.fromLong($child0Value_); + } + + private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLUnboxNode.fromBoolean($child0Value_); + } + + private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { + return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + boolean $child0Value_; + try { + $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); + } catch (UnexpectedResultException ex) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); + return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); + } + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; + return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); + } + + private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { + if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { + return false; + } + if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { + return false; + } + return true; + } + + private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLAddNode.add($child0Value__, $child1Value__); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); + if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { + return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); + } + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { + SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); + if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { + SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); + return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); + return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); + } + + @ExplodeLoop + private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { + short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); + Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); + Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); + int childArrayOffset_; + int constArrayOffset_; + assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; + if ($child0Value_ instanceof SLObject) { + SLObject $child0Value__ = (SLObject) $child0Value_; + SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); + while (s2_ != null) { + if ((s2_.objectLibrary_.accepts($child0Value__))) { + Node node__ = ($this); + int bci__ = ($bci); + return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); + } + s2_ = s2_.next_; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); + return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); + } + + private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // pop + // Simple Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_POP << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // load.constant + // Constants: + // [ 0] constant + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_CONSTANT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + return $sp; + } + // load.argument + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_ARGUMENT << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + return $sp; + } + // load.local + // Locals: + // [ 0] local + // Split on Boxing Elimination + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.boxed + // Locals: + // [ 0] local + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + return $sp; + } + // load.local.mat + // Simple Pops: + // [ 0] frame + // Always Boxed + // Pushed Values: 1 + case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); + UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); + return $sp; + } + // store.local.mat + // Simple Pops: + // [ 0] frame + // [ 1] value + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : + { + Frame outerFrame; + outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); + outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); + $sp -= 2; + return $sp; + } + // instrument.enter + // Pushed Values: 0 + case ((INSTR_INSTRUMENT_ENTER << 3) | 0) : + { + ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_ENTER_INSTRUMENT_OFFSET) + 0); + if (probe != null) { + probe.onEnter($frame); + } + return $sp; + } + // instrument.exit.void + // Pushed Values: 0 + case ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0) : + { + ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_VOID_INSTRUMENT_OFFSET) + 0); + if (probe != null) { + probe.onReturnValue($frame, null); + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // store.local + // Locals: + // [ 0] target + // Indexed Pops: + // [ 0] value + // Split on Boxing Elimination + // Pushed Values: 0 + case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + case ((INSTR_STORE_LOCAL << 3) | 7) : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + return $sp; + } + // instrument.exit + // Indexed Pops: + // [ 0] value + // Pushed Values: 0 + case ((INSTR_INSTRUMENT_EXIT << 3) | 0) : + { + ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_INSTRUMENT_OFFSET) + 0); + if (probe != null) { + probe.onReturnValue($frame, expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_POP_INDEXED_OFFSET + 0) & 0xff))); + } + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // c.SLEqual + // Children: + // [ 0] CacheExpression [sourceParameter = equalNode] + // [ 1] SpecializationData [id = Generic0] + // [ 2] CacheExpression [sourceParameter = leftInterop] + // [ 3] CacheExpression [sourceParameter = rightInterop] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] + case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : + { + SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessOrEqual + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLessThan + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : + { + SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : + { + SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLLogicalNot + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : + { + SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : + { + SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLFunctionLiteral + // Constants: + // [ 0] CacheExpression [sourceParameter = result] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] + case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : + { + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLToBoolean + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBigNumber.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromLong + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + // c.SLUnbox.q.FromBoolean + // Children: + // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] + // [ 1] SpecializationData [id = FromForeign0] + // [ 2] CacheExpression [sourceParameter = interop] + // Indexed Pops: + // [ 0] arg0 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : + { + SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : + { + SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : + { + SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // c.SLAdd + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLDiv + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : + { + SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : + { + SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLMul + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : + { + SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : + { + SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLSub + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : + { + SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : + { + SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLAdd.q.Add0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Add1] + // [ 1] CacheExpression [sourceParameter = node] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Split on Boxing Elimination + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : + { + SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : + { + SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + // c.SLReadProperty.q.ReadSLObject0 + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // [ 2] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = ReadArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = ReadSLObject0] + // [ 5] CacheExpression [sourceParameter = node] + // [ 6] CacheExpression [sourceParameter = objectLibrary] + // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 8] SpecializationData [id = ReadObject0] + // [ 9] CacheExpression [sourceParameter = node] + // [10] CacheExpression [sourceParameter = objects] + // [11] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] + case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : + { + SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // c.SLWriteProperty + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // [ 1] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = WriteArray0] + // [ 1] CacheExpression [sourceParameter = node] + // [ 2] CacheExpression [sourceParameter = arrays] + // [ 3] CacheExpression [sourceParameter = numbers] + // [ 4] SpecializationData [id = WriteSLObject0] + // [ 5] CacheExpression [sourceParameter = objectLibrary] + // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] + // [ 7] SpecializationData [id = WriteObject0] + // [ 8] CacheExpression [sourceParameter = node] + // [ 9] CacheExpression [sourceParameter = objectLibrary] + // [10] CacheExpression [sourceParameter = asMember] + // Indexed Pops: + // [ 0] arg0 + // [ 1] arg1 + // [ 2] arg2 + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] + case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : + { + SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -2; + return $sp; + } + // c.SLInvoke + // Constants: + // [ 0] CacheExpression [sourceParameter = bci] + // Children: + // [ 0] SpecializationData [id = Direct] + // [ 1] CacheExpression [sourceParameter = callNode] + // [ 2] CacheExpression [sourceParameter = library] + // [ 3] CacheExpression [sourceParameter = node] + // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] + // Indexed Pops: + // [ 0] arg0 + // Variadic + // Always Boxed + // Pushed Values: 1 + // State Bitsets: + // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] + case ((INSTR_C_SL_INVOKE << 3) | 0) : + { + int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); + SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); + $sp += - numVariadics; + return $sp; + } + // si.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + $sp = $sp - 1; + $frame.clear($sp); + $bci = $bci + POP_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); + $sp = $sp + 1; + $bci = $bci + LOAD_ARGUMENT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + case 7 /* generic */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); + do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp--; + break; + } + } + $bci = $bci + STORE_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + CompilerDirectives.transferToInterpreterAndInvalidate(); + unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); + do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 5 /* BOOLEAN */ : + { + SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : + case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : + { + short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd + // Pushed Values: 0 + case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : + { + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { + int $bci = $startBci; + int $sp = $startSp; + switch (curOpcode) { + // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox + // Pushed Values: 0 + case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : + { + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 5 /* BOOLEAN */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + case 1 /* LONG */ : + { + int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); + do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); + $sp++; + break; + } + } + $bci = $bci + LOAD_LOCAL_LENGTH; + UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); + $sp = $sp + 1; + $bci = $bci + LOAD_CONSTANT_LENGTH; + SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + $bci = $bci + C_SL_READ_PROPERTY_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + case 1 /* LONG */ : + { + SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + $sp += -1; + break; + } + } + $bci = $bci + C_SL_ADD_LENGTH; + switch (unsafeFromBytecode($bc, $bci) & 7) { + case 0 /* OBJECT */ : + { + SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 5 /* BOOLEAN */ : + { + SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + case 1 /* LONG */ : + { + SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); + break; + } + } + $bci = $bci + C_SL_UNBOX_LENGTH; + return $sp; + } + default : + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private static boolean isAdoptable() { + return true; + } + + private static final class SLAdd_Add1Data extends Node { + + @Child SLToTruffleStringNode toTruffleStringNodeLeft_; + @Child SLToTruffleStringNode toTruffleStringNodeRight_; + @Child ConcatNode concatNode_; + + SLAdd_Add1Data() { + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLEqual_Generic0Data extends Node { + + @Child SLEqual_Generic0Data next_; + @Child InteropLibrary leftInterop_; + @Child InteropLibrary rightInterop_; + + SLEqual_Generic0Data(SLEqual_Generic0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadArray0Data extends Node { + + @Child SLReadProperty_ReadArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadSLObject0Data extends Node { + + @Child SLReadProperty_ReadSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLReadProperty_ReadObject0Data extends Node { + + @Child SLReadProperty_ReadObject0Data next_; + @Child InteropLibrary objects_; + @Child SLToMemberNode asMember_; + + SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteArray0Data extends Node { + + @Child SLWriteProperty_WriteArray0Data next_; + @Child InteropLibrary arrays_; + @Child InteropLibrary numbers_; + + SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteSLObject0Data extends Node { + + @Child SLWriteProperty_WriteSLObject0Data next_; + @Child DynamicObjectLibrary objectLibrary_; + @Child SLToTruffleStringNode toTruffleStringNode_; + + SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLWriteProperty_WriteObject0Data extends Node { + + @Child SLWriteProperty_WriteObject0Data next_; + @Child InteropLibrary objectLibrary_; + @Child SLToMemberNode asMember_; + + SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + private static final class SLUnbox_FromForeign0Data extends Node { + + @Child SLUnbox_FromForeign0Data next_; + @Child InteropLibrary interop_; + + SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + @GeneratedBy(SLOperationRootNode.class) + private static final class SLInvoke_DirectData extends Node { + + @Child SLInvoke_DirectData next_; + @CompilationFinal Assumption callTargetStable_; + @CompilationFinal RootCallTarget cachedTarget_; + @Child DirectCallNode callNode_; + + SLInvoke_DirectData(SLInvoke_DirectData next_) { + this.next_ = next_; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + + T insertAccessor(T node) { + return super.insert(node); + } + + } + } private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); private static final BytecodeLoopBase UNCOMMON_EXECUTE = new BytecodeNode(); private static final BytecodeLoopBase COMMON_EXECUTE = UNCOMMON_EXECUTE; @@ -13982,13 +23599,18 @@ T insertAccessor(T node) { private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; private static final int STORE_LOCAL_MAT_LENGTH = 2; private static final short INSTR_INSTRUMENT_ENTER = 13; + private static final int INSTRUMENT_ENTER_INSTRUMENT_OFFSET = 1; private static final int INSTRUMENT_ENTER_LENGTH = 2; private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; + private static final int INSTRUMENT_EXIT_VOID_INSTRUMENT_OFFSET = 1; private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; private static final short INSTR_INSTRUMENT_EXIT = 15; - private static final int INSTRUMENT_EXIT_LENGTH = 2; + private static final int INSTRUMENT_EXIT_POP_INDEXED_OFFSET = 1; + private static final int INSTRUMENT_EXIT_INSTRUMENT_OFFSET = 2; + private static final int INSTRUMENT_EXIT_LENGTH = 3; private static final short INSTR_INSTRUMENT_LEAVE = 16; private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; + private static final int INSTRUMENT_LEAVE_INSTRUMENT_OFFSET = 3; private static final int INSTRUMENT_LEAVE_LENGTH = 4; private static final short INSTR_C_SL_ADD = 17; private static final int C_SL_ADD_CONSTANT_OFFSET = 1; @@ -14178,6 +23800,8 @@ T insertAccessor(T node) { @CompilationFinal private int _maxLocals; @CompilationFinal private int _maxStack; @CompilationFinal(dimensions = 1) private int[] sourceInfo; + @CompilationFinal private InstrumentRootNode instrumentRoot; + @CompilationFinal(dimensions = 1) private InstrumentTreeNode[] instruments; @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; @CompilationFinal private int uncachedExecuteCount = 16; @CompilationFinal private Object _osrMetadata; @@ -14338,6 +23962,12 @@ public Node copy() { return result; } + @Override + public InstrumentableNode materializeInstrumentTree(Set> materializedTags) { + nodes.ensureInstrumentationAccessor(); + return instrumentRoot; + } + private void changeInterpreters(BytecodeLoopBase impl) { this.switchImpl = impl; } @@ -14978,6 +24608,14 @@ private static boolean do_profileCondition(SLOperationRootNodeGen $this, boolean } } + private static ProbeNode getProbeNodeImpl(SLOperationRootNodeGen $this, int index) { + InstrumentTreeNode node = $this.instruments[index]; + if (!(node instanceof WrapperNode)) { + return null; + } + return ((WrapperNode) node).getProbeNode(); + } + public static OperationNodes create(OperationConfig config, OperationParser generator) { OperationNodesImpl nodes = new OperationNodesImpl(generator); Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(nodes, false, config); @@ -15072,25 +24710,25 @@ protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); } - protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - return (boolean) value; + if (value instanceof Long) { + return (long) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 5 /* BOOLEAN */ : - return UFA.unsafeUncheckedGetBoolean(frame, slot); + case 1 /* LONG */ : + return UFA.unsafeUncheckedGetLong(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); - return (boolean) value; + if (value instanceof Long) { + setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); + return (long) value; } break; } @@ -15100,25 +24738,25 @@ protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, } } - protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { + protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { if (bciOffset == 0) { Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - return (long) value; + if (value instanceof Boolean) { + return (boolean) value; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnexpectedResultException(value); } } else { switch (UFA.unsafeGetTag(frame, slot)) { - case 1 /* LONG */ : - return UFA.unsafeUncheckedGetLong(frame, slot); + case 5 /* BOOLEAN */ : + return UFA.unsafeUncheckedGetBoolean(frame, slot); case 0 /* OBJECT */ : CompilerDirectives.transferToInterpreterAndInvalidate(); Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); - return (long) value; + if (value instanceof Boolean) { + setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); + return (boolean) value; } break; } @@ -15155,6 +24793,14 @@ void setNodes(SLOperationRootNode[] nodes) { this.nodes = nodes; } + protected void ensureSourcesAccessor() { + ensureSources(); + } + + protected void ensureInstrumentationAccessor() { + ensureInstrumentation(); + } + @Override public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { Builder builder = new Builder(null, false, config); @@ -15225,6 +24871,7 @@ public static final class Builder extends OperationBuilder { private int[] instructionHistory = new int[8]; private int instructionHistoryIndex = 0; private int numLabels; + private int numInstrumentNodes; private ArrayList constPool = new ArrayList<>(); private BuilderOperationData operationData; private ArrayList labels = new ArrayList<>(); @@ -15287,6 +24934,7 @@ private void reset(TruffleLanguage language) { if (sourceBuilder != null) { sourceBuilder = new SourceInfoBuilder(sourceBuilder.sourceList); } + numInstrumentNodes = 0; metadata_MethodName = null; } @@ -16637,6 +26285,8 @@ public void beginTag(Class arg0) { operationData.aux[2] = endLabel; doBeforeEmitInstruction(0, false, false); unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_ENTER << 3) | 0)); + bc[bci + 1] = (short) numInstrumentNodes; + numInstrumentNodes += 1; instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_ENTER; bci = bci + INSTRUMENT_ENTER_LENGTH; lastChildPush = 0; @@ -16664,11 +26314,16 @@ public void endTag() { if (lastChildPush != 0) { doBeforeEmitInstruction(0, false, false); unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0)); + bc[bci + 1] = (short) numInstrumentNodes; + numInstrumentNodes += 1; instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT_VOID; bci = bci + INSTRUMENT_EXIT_VOID_LENGTH; } else { - doBeforeEmitInstruction(0, false, false); + int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT << 3) | 0)); + bc[bci + 1 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); + bc[bci + 1] = (short) numInstrumentNodes; + numInstrumentNodes += 1; instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT; bci = bci + INSTRUMENT_EXIT_LENGTH; } @@ -18177,6 +27832,11 @@ public SourceSection getSourceSectionAtBci(int bci) { throw new UnsupportedOperationException(); } + @Override + public InstrumentableNode materializeInstrumentTree(Set> materializedTags) { + throw new UnsupportedOperationException(); + } + } } private static final class Counter { diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 4942d461820c..61baa07ef202 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -111,13 +111,20 @@ void reparse(OperationConfig config) { /** * Checks if the sources are present, and if not tries to reparse to get them. */ - final void ensureSources() { + protected final void ensureSources() { if (sources == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); reparse(OperationConfig.WITH_SOURCE); } } + protected final void ensureInstrumentation() { + if (!hasInstrumentation) { + CompilerDirectives.transferToInterpreter(); + reparse(OperationConfig.COMPLETE); + } + } + @SuppressWarnings("unused") public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { throw new UnsupportedOperationException("Serialization not supported"); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index b0cf911ce0da..d31687b1206d 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -41,9 +41,12 @@ package com.oracle.truffle.api.operation; import java.util.List; +import java.util.Set; import java.util.function.Function; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.nodes.NodeInterface; import com.oracle.truffle.api.operation.introspection.ExceptionHandler; import com.oracle.truffle.api.operation.introspection.Instruction; @@ -75,14 +78,6 @@ default String dump() { } } -// List sourceInfo = id.getSourceInformation(); -// if (sourceInfo != null) { -// sb.append("Source Information:\n"); -// for (SourceInformation si : sourceInfo) { -// sb.append(" ").append(si.toString()).append('\n'); -// } -// } - return sb.toString(); } @@ -97,4 +92,6 @@ default void executeProlog(VirtualFrame frame) { @SuppressWarnings("unused") default void executeEpilog(VirtualFrame frame, Object returnValue, Throwable throwable) { } + + InstrumentableNode materializeInstrumentTree(Set> materializedTags); } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentRootNode.java new file mode 100644 index 000000000000..2a1939d95dd5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentRootNode.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.instrumentation; + +import java.util.Set; + +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.instrumentation.Tag; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.operation.OperationRootNode; + +public class InstrumentRootNode extends Node implements InstrumentableNode { + + private static final InstrumentTreeNode[] EMPTY_NODE_ARRAY = new InstrumentTreeNode[0]; + + public static InstrumentRootNode create() { + return new InstrumentRootNode(EMPTY_NODE_ARRAY); + } + + public static InstrumentRootNode create(InstrumentTreeNode... nodes) { + return new InstrumentRootNode(nodes); + } + + @Children private final InstrumentTreeNode[] children; + + private InstrumentRootNode(InstrumentTreeNode[] children) { + this.children = children; + } + + public boolean isInstrumentable() { + return true; + } + + public WrapperNode createWrapper(ProbeNode probe) { + return new Wrapper(this, probe); + } + + public InstrumentableNode materializeInstrumentableNodes(Set> materializedTags) { + return ((OperationRootNode) getParent()).materializeInstrumentTree(materializedTags); + } + + static final class Wrapper extends InstrumentRootNode implements WrapperNode { + @Child private InstrumentRootNode delegateNode; + @Child private ProbeNode probeNode; + + Wrapper(InstrumentRootNode delegateNode, ProbeNode probeNode) { + super(EMPTY_NODE_ARRAY); + this.delegateNode = delegateNode; + this.probeNode = probeNode; + } + + @Override + public InstrumentRootNode getDelegateNode() { + return delegateNode; + } + + @Override + public ProbeNode getProbeNode() { + return probeNode; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + } + +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentTreeNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentTreeNode.java new file mode 100644 index 000000000000..6dfb7c1a1902 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/instrumentation/InstrumentTreeNode.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.instrumentation; + +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.instrumentation.Tag; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; + +public class InstrumentTreeNode extends Node implements InstrumentableNode { + + private static final InstrumentTreeNode[] EMPTY_NODE_ARRAY = new InstrumentTreeNode[0]; + + private final Class tag; + @Children private final InstrumentTreeNode[] children; + + public InstrumentTreeNode(Class tag, InstrumentTreeNode[] children) { + this.tag = tag; + this.children = children; + } + + public boolean hasTag(Class which) { + return tag == which; + } + + public boolean isInstrumentable() { + return true; + } + + public WrapperNode createWrapper(ProbeNode probe) { + return new Wrapper(this, probe); + } + + static final class Wrapper extends InstrumentTreeNode implements WrapperNode { + @Child private InstrumentTreeNode delegateNode; + @Child private ProbeNode probeNode; + + Wrapper(InstrumentTreeNode delegateNode, ProbeNode probeNode) { + super(delegateNode.tag, EMPTY_NODE_ARRAY); + this.delegateNode = delegateNode; + this.probeNode = probeNode; + } + + @Override + public InstrumentTreeNode getDelegateNode() { + return delegateNode; + } + + @Override + public ProbeNode getProbeNode() { + return probeNode; + } + + @Override + public NodeCost getCost() { + return NodeCost.NONE; + } + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index def36141bfc8..8932dd14639b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -259,6 +259,8 @@ public class TruffleTypes { public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode"; public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic"; public static final String ShortCircuitOperation_Name = "com.oracle.truffle.api.operation.ShortCircuitOperation"; + public static final String InstrumentRootNode_Name = "com.oracle.truffle.api.operation.instrumentation.InstrumentRootNode"; + public static final String InstrumentTreeNode_Name = "com.oracle.truffle.api.operation.instrumentation.InstrumentTreeNode"; public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer"; public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name); @@ -283,6 +285,8 @@ public class TruffleTypes { public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name); public final DeclaredType ShortCircuitOperation = c.getDeclaredTypeOptional(ShortCircuitOperation_Name); public final DeclaredType Variadic = c.getDeclaredTypeOptional(Variadic_Name); + public final DeclaredType InstrumentRootNode = c.getDeclaredTypeOptional(InstrumentRootNode_Name); + public final DeclaredType InstrumentTreeNode = c.getDeclaredTypeOptional(InstrumentTreeNode_Name); public final DeclaredType ExecutionTracer = c.getDeclaredTypeOptional(ExecutionTracer_Name); // Library API diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java index ee1e8cebf4fc..967cde4d3426 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java @@ -50,8 +50,9 @@ public class OperationGeneratorFlags { public static final boolean LOG_EXECUTE_AND_SPECIALIZE_CALLS = false; public static final boolean LOG_STACK_READS = false; + public static final boolean ENABLE_INSTRUMENTATION = true; + public static final boolean FLAG_NODE_AST_PRINTING = false; - public static final boolean ENABLE_INSTRUMENTATION = false; public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; public static final boolean ENABLE_SERIALIZATION = true; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index a791be3c7a5a..79589766504e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -603,8 +603,6 @@ private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, vars.specializedKind = null; b.end(); } - vars.inputs = null; - vars.results = null; } private void generateAllCasesForInstruction(OperationsContext ctx, CodeTreeBuilder b, Instruction op) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 5517def58fd4..0badea91384f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -145,6 +145,13 @@ CodeTypeElement createOperationNodes() { mSetNodes.createBuilder().statement("this.nodes = nodes"); typOperationNodes.add(mSetNodes); + for (String name : new String[]{"ensureSources", "ensureInstrumentation"}) { + CodeExecutableElement m = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.OperationNodes, name)); + m.setSimpleName(CodeNames.of(name + "Accessor")); + m.createBuilder().startStatement().startCall(name).variables(m.getParameters()).end(2); + typOperationNodes.add(m); + } + if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { typOperationNodes.add(createOperationNodesSerialize()); } @@ -303,7 +310,7 @@ private CodeTypeElement createOperationSerNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl, m.fdConstructor)); - for (String methodName : new String[]{"execute", "getSourceSectionAtBci"}) { + for (String methodName : new String[]{"execute", "getSourceSectionAtBci", "materializeInstrumentTree"}) { CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, methodName); met.createBuilder().startThrow().startNew(context.getType(UnsupportedOperationException.class)).end(2); typOperationNodeImpl.add(met); @@ -397,6 +404,11 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart"))); } + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, types.InstrumentRootNode, "instrumentRoot"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.InstrumentTreeNode), "instruments"))); + } + CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); @@ -522,6 +534,8 @@ CodeTypeElement createOperationNodeImpl() { builderInstrBytecodeNodeType = null; } + typOperationNodeImpl.add(createMaterializeInstrumentTree()); + CodeTypeElement typBuilderImpl = createBuilderImpl(typOperationNodeImpl, typOpNodesImpl, typExceptionHandler); typOperationNodeImpl.add(typBuilderImpl); typOperationNodeImpl.add(createChangeInterpreter(typBytecodeBase)); @@ -543,6 +557,10 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(createUnsafeWriteBytecode()); typOperationNodeImpl.add(createConditionProfile()); + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + typOperationNodeImpl.add(createGetTreeProbeNode(typOperationNodeImpl.asType())); + } + typOperationNodeImpl.add(createCreateMethod(typBuilderImpl, typBuilderImpl)); typOperationNodeImpl.add(createDeserializeMethod()); typOperationNodeImpl.add(createSerializeMethod(typBuilderImpl, typBuilderImpl)); @@ -554,6 +572,34 @@ CodeTypeElement createOperationNodeImpl() { return typOperationNodeImpl; } + private CodeExecutableElement createGetTreeProbeNode(TypeMirror thisType) { + CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, types.ProbeNode, "getProbeNodeImpl"); + met.addParameter(new CodeVariableElement(thisType, "$this")); + met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); + CodeTreeBuilder b = met.createBuilder(); + + b.statement("InstrumentTreeNode node = $this.instruments[index]"); + b.startIf().string("!(node").instanceOf(types.InstrumentableNode_WrapperNode).string(")").end().startBlock(); + b.returnNull(); + b.end(); + + b.startReturn().string("(").cast(types.InstrumentableNode_WrapperNode).string(" node).getProbeNode()").end(); + + return met; + } + + private CodeExecutableElement createMaterializeInstrumentTree() { + CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, "materializeInstrumentTree"); + CodeTreeBuilder b = met.createBuilder(); + + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + b.statement("nodes.ensureInstrumentationAccessor()"); + } + + b.startReturn().string("instrumentRoot").end(); + return met; + } + private CodeExecutableElement createHookTransferToInterpreterAndInvalidate() { CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "hook_transferToInterpreterAndInvalidate"); el.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); @@ -1031,6 +1077,9 @@ private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, if (m.isTracing()) { typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart = new boolean[65535]")); } + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numInstrumentNodes")); + } CodeVariableElement fldConstPool = typBuilderImpl.add( new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); @@ -2789,6 +2838,10 @@ private CodeExecutableElement createBuilderImplReset() { b.statement("yieldCount = 0"); } + if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { + b.statement("numInstrumentNodes = 0"); + } + for (OperationMetadataData metadata : m.getMetadatas()) { b.startAssign("metadata_" + metadata.getName()).string("null").end(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index cae9dd5248d2..ec5587431e66 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -71,10 +71,6 @@ public static class ExecutionVariables { public CodeVariableElement sp; public CodeVariableElement consts; public CodeVariableElement children; - public CodeVariableElement[] inputs; - public CodeVariableElement[] results; - - public CodeVariableElement probeNodes; public CodeVariableElement tracer; public FrameKind specializedKind; @@ -129,6 +125,7 @@ public static class EmitArguments { private static final String BRANCH_TARGET_OFFSET_SUFFIX = "_BRANCH_TARGET_OFFSET"; private static final String BRANCH_PROFILE_OFFSET_SUFFIX = "_BRANCH_PROFILE_OFFSET"; private static final String STATE_BITS_OFFSET_SUFFIX = "_STATE_BITS_OFFSET"; + private static final String INSTRUMENT_OFFSET_SUFFIX = "_INSTRUMENT_OFFSET"; private static final String LENGTH_SUFFIX = "_LENGTH"; private int addInstructionArgument(List holder, Object marker) { @@ -318,6 +315,9 @@ public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index, boolea throw new AssertionError("there is no boxing elimination"); // return CodeTreeBuilder.singleString("0 /* XXXXXXXXXXX */"); } + if (write) { + throw new AssertionError("cannot write to indexed pops"); + } CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startParantheses(); @@ -325,7 +325,7 @@ public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index, boolea b.startParantheses(); } - b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2, write)); + b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2, false)); if (index % 2 == 1) { b.string(" >> 8").end(); @@ -352,6 +352,10 @@ public CodeTree createStateBitsIndex(ExecutionVariables vars, int index, boolean return createDirectIndex(vars, STATE_BITS_OFFSET_SUFFIX, index, write); } + public CodeTree createInstrument(ExecutionVariables vars, int index) { + return createIndirectIndex(vars, INSTRUMENT_OFFSET_SUFFIX, index); + } + public CodeTree createLength() { return CodeTreeBuilder.singleString(internalName + LENGTH_SUFFIX); } @@ -558,7 +562,13 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) b.end(); } - // todo: instruments + if (!instruments.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); + b.string("numInstrumentNodes"); + b.end(); + + b.statement("numInstrumentNodes += " + instruments.size()); + } // superinstructions @@ -802,6 +812,9 @@ public List createInstructionFields() { if (!stateBits.isEmpty()) { result.add(createConstant(internalName + STATE_BITS_OFFSET_SUFFIX, getStateBitsOffset())); } + if (!instruments.isEmpty()) { + result.add(createConstant(internalName + INSTRUMENT_OFFSET_SUFFIX, getInstrumentsOffset())); + } result.add(createConstant(internalName + LENGTH_SUFFIX, length())); return result; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java index 25d653628393..8eed70469eed 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java @@ -56,8 +56,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("ProbeNode probe"); - b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); - b.startCall("getTreeProbeNode"); + b.startCall("getProbeNodeImpl"); + b.string("$this"); + b.tree(createInstrument(vars, 0)); b.end(2); b.startIf().string("probe != null").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java index 00e94713822f..76ddf74dfb1e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java @@ -42,7 +42,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class InstrumentationExitInstruction extends Instruction { @@ -59,14 +58,18 @@ public InstrumentationExitInstruction(OperationsContext ctx, int id, boolean ret assert returnsValue; this.returnsValue = true; addInstrument("instrument"); + addPopIndexed("value"); } @Override public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.declaration(OperationGeneratorUtils.getTypes().ProbeNode, "probe", - CodeTreeBuilder.createBuilder().variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("].").startCall("getTreeProbeNode").end(2).build()); + b.startAssign("ProbeNode probe"); + b.startCall("getProbeNodeImpl"); + b.string("$this"); + b.tree(createInstrument(vars, 0)); + b.end(2); b.startIf().string("probe != null").end(); b.startBlock(); @@ -75,7 +78,15 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.startCall("probe", "onReturnValue"); b.variable(vars.localFrame); if (returnsValue) { - b.variable(vars.inputs[1]); + b.startCall("expectObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + if (ctx.hasBoxingElimination()) { + b.variable(vars.bc); + b.variable(vars.bci); + b.tree(createPopIndexedIndex(vars, 0, false)); + } + b.end(); } else { b.string("null"); } @@ -83,10 +94,6 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.end(); - if (returnsValue) { - b.startAssign(vars.results[0]).variable(vars.inputs[1]).end(); - } - return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java index de03408a5d5f..9b4428916ae5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java @@ -57,8 +57,9 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); b.startAssign("ProbeNode probe"); - b.variable(vars.probeNodes).string("[").variable(vars.inputs[0]).string("]."); - b.startCall("getTreeProbeNode"); + b.startCall("getProbeNodeImpl"); + b.string("$this"); + b.tree(createInstrument(vars, 0)); b.end(2); b.startIf().string("probe != null").end(); @@ -71,28 +72,29 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { b.string("false"); b.end(2); - b.startIf().string("result == ProbeNode.UNWIND_ACTION_REENTER").end(); - b.startBlock(); + b.startIf().string("result == ProbeNode.UNWIND_ACTION_REENTER").end().startBlock(); - b.startAssign(vars.results[0]).variable(vars.inputs[1]).end(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); + b.statement("continue loop"); - b.end().startElseIf().string("result != null").end(); - b.startBlock(); + b.end().startElseIf().string("result != null").end().startBlock(); - // HACK, refactor this push somehow - b.startStatement().startCall(vars.stackFrame, "setObject").string("sp++").string("result").end(2); - b.startAssign(vars.results[0]).variable(vars.inputs[2]).end(); + b.startStatement().startCall("UFA", "unsafeSetObject"); + b.variable(vars.stackFrame); + b.string("$sp - 1"); + b.string("result"); + b.end(2); - b.end().startElseBlock(); + b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 1, false)).end(); - b.startAssign(vars.results[0]).variable(vars.bci).string(" + ").tree(createLength()).end(); + b.statement("continue loop"); - b.end(); - b.end().startElseBlock(); + b.end(); // result != null - b.startAssign(vars.results[0]).variable(vars.bci).string(" + ").tree(createLength()).end(); + b.end(); // probe != null - b.end(); + b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); + b.statement("continue loop"); return b.build(); } @@ -102,6 +104,11 @@ public boolean isInstrumentationOnly() { return true; } + @Override + public boolean isExplicitFlowControl() { + return true; + } + @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; From 13ecfb9b611e09d5369a906037828f17cc1d2286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 24 Nov 2022 15:33:18 +0100 Subject: [PATCH 179/312] [wip] fixes --- .../sl/operations/SLOperationRootNodeGen.java | 63 +++++++++++++++++++ .../operation/test/dsl_tests/ErrorTests.java | 14 ++++- .../truffle/api/impl/UnsafeFrameAccess.java | 55 ++++++++-------- .../OperationsBytecodeCodeGenerator.java | 2 + 4 files changed, 101 insertions(+), 33 deletions(-) diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java index 6652adbf1489..dd87cc296965 100644 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java @@ -6185,6 +6185,7 @@ private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $fram return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } + @BytecodeInterpreterSwitch private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6204,6 +6205,7 @@ private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6312,6 +6314,7 @@ private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6356,6 +6359,7 @@ private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6632,6 +6636,7 @@ private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6832,6 +6837,7 @@ private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -6947,6 +6953,7 @@ private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7009,6 +7016,7 @@ private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7131,6 +7139,7 @@ private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7224,6 +7233,7 @@ private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7424,6 +7434,7 @@ private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7625,6 +7636,7 @@ private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -7920,6 +7932,7 @@ private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -8055,6 +8068,7 @@ private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -8274,6 +8288,7 @@ private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -8370,6 +8385,7 @@ private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -8549,6 +8565,7 @@ private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -8913,6 +8930,7 @@ private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -9056,6 +9074,7 @@ private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -9176,6 +9195,7 @@ private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -9278,6 +9298,7 @@ private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12276,6 +12297,7 @@ private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFra throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); } + @BytecodeInterpreterSwitch private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12295,6 +12317,7 @@ private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12373,6 +12396,7 @@ private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12396,6 +12420,7 @@ private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12526,6 +12551,7 @@ private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12644,6 +12670,7 @@ private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12724,6 +12751,7 @@ private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, V } } + @BytecodeInterpreterSwitch private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12758,6 +12786,7 @@ private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12823,6 +12852,7 @@ private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12869,6 +12899,7 @@ private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -12954,6 +12985,7 @@ private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13039,6 +13071,7 @@ private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13131,6 +13164,7 @@ private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13175,6 +13209,7 @@ private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13269,6 +13304,7 @@ private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13325,6 +13361,7 @@ private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13382,6 +13419,7 @@ private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13528,6 +13566,7 @@ private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13582,6 +13621,7 @@ private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13635,6 +13675,7 @@ private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -13689,6 +13730,7 @@ private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, } } + @BytecodeInterpreterSwitch private static int instructionGroup_37_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20110,6 +20152,7 @@ private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $fram return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); } + @BytecodeInterpreterSwitch private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20129,6 +20172,7 @@ private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20257,6 +20301,7 @@ private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20313,6 +20358,7 @@ private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20589,6 +20635,7 @@ private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20789,6 +20836,7 @@ private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20904,6 +20952,7 @@ private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFra } } + @BytecodeInterpreterSwitch private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -20966,6 +21015,7 @@ private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -21088,6 +21138,7 @@ private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -21181,6 +21232,7 @@ private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -21381,6 +21433,7 @@ private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -21582,6 +21635,7 @@ private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -21877,6 +21931,7 @@ private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -22012,6 +22067,7 @@ private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -22231,6 +22287,7 @@ private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -22327,6 +22384,7 @@ private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -22506,6 +22564,7 @@ private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -22870,6 +22929,7 @@ private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -23013,6 +23073,7 @@ private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -23133,6 +23194,7 @@ private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; @@ -23235,6 +23297,7 @@ private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFr } } + @BytecodeInterpreterSwitch private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { int $bci = $startBci; int $sp = $startSp; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java index 73d481947262..c2c7265be8ad 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java @@ -40,12 +40,16 @@ */ package com.oracle.truffle.api.operation.test.dsl_tests; +import java.util.Set; + import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystem; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.Tag; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.GenerateOperations; @@ -67,18 +71,22 @@ protected MustBeDeclaredAbstract(TruffleLanguage language, FrameDescriptor fr super(language, frameDescriptor); } - public String dump() { + @Override + public Object execute(VirtualFrame frame) { return null; } - @Override - public Object execute(VirtualFrame frame) { + public String dump() { return null; } public SourceSection getSourceSectionAtBci(int bci) { return null; } + + public InstrumentableNode materializeInstrumentTree(Set> materializedTags) { + return null; + } } @ExpectError("Operations class must directly or indirectly subclass RootNode.") diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 11785fcce038..6c89dbc1069b 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.api.impl; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.Frame; import sun.misc.Unsafe; @@ -158,133 +157,129 @@ public T unsafeObjectArrayRead(T[] arr, int index) { return (T) FrameWithoutBoxing.UNSAFE.getObject(arr, Unsafe.ARRAY_OBJECT_BASE_OFFSET + index * Unsafe.ARRAY_OBJECT_INDEX_SCALE); } - private static FrameWithoutBoxing castFrame(Frame frame) { - return CompilerDirectives.castExact(frame, FrameWithoutBoxing.class); - } - @Override public byte unsafeGetTag(Frame frame, int slot) { - return castFrame(frame).unsafeGetTag(slot); + return ((FrameWithoutBoxing) frame).unsafeGetTag(slot); } @Override public Object unsafeGetObject(Frame frame, int slot) { - return castFrame(frame).unsafeGetObject(slot); + return ((FrameWithoutBoxing) frame).unsafeGetObject(slot); } @Override public int unsafeGetInt(Frame frame, int slot) { - return castFrame(frame).unsafeGetInt(slot); + return ((FrameWithoutBoxing) frame).unsafeGetInt(slot); } @Override public boolean unsafeGetBoolean(Frame frame, int slot) { - return castFrame(frame).unsafeGetBoolean(slot); + return ((FrameWithoutBoxing) frame).unsafeGetBoolean(slot); } @Override public long unsafeGetLong(Frame frame, int slot) { - return castFrame(frame).unsafeGetLong(slot); + return ((FrameWithoutBoxing) frame).unsafeGetLong(slot); } @Override public double unsafeGetDouble(Frame frame, int slot) { - return castFrame(frame).unsafeGetDouble(slot); + return ((FrameWithoutBoxing) frame).unsafeGetDouble(slot); } @Override public Object unsafeUncheckedGetObject(Frame frame, int slot) { - return castFrame(frame).unsafeUncheckedGetObject(slot); + return ((FrameWithoutBoxing) frame).unsafeUncheckedGetObject(slot); } @Override public int unsafeUncheckedGetInt(Frame frame, int slot) { - return castFrame(frame).unsafeUncheckedGetInt(slot); + return ((FrameWithoutBoxing) frame).unsafeUncheckedGetInt(slot); } @Override public boolean unsafeUncheckedGetBoolean(Frame frame, int slot) { - return castFrame(frame).unsafeUncheckedGetBoolean(slot); + return ((FrameWithoutBoxing) frame).unsafeUncheckedGetBoolean(slot); } @Override public long unsafeUncheckedGetLong(Frame frame, int slot) { - return castFrame(frame).unsafeUncheckedGetLong(slot); + return ((FrameWithoutBoxing) frame).unsafeUncheckedGetLong(slot); } @Override public double unsafeUncheckedGetDouble(Frame frame, int slot) { - return castFrame(frame).unsafeUncheckedGetDouble(slot); + return ((FrameWithoutBoxing) frame).unsafeUncheckedGetDouble(slot); } @Override public void unsafeSetObject(Frame frame, int slot, Object value) { - castFrame(frame).unsafeSetObject(slot, value); + ((FrameWithoutBoxing) frame).unsafeSetObject(slot, value); } @Override public void unsafeSetInt(Frame frame, int slot, int value) { - castFrame(frame).unsafeSetInt(slot, value); + ((FrameWithoutBoxing) frame).unsafeSetInt(slot, value); } @Override public void unsafeSetBoolean(Frame frame, int slot, boolean value) { - castFrame(frame).unsafeSetBoolean(slot, value); + ((FrameWithoutBoxing) frame).unsafeSetBoolean(slot, value); } @Override public void unsafeSetLong(Frame frame, int slot, long value) { - castFrame(frame).unsafeSetLong(slot, value); + ((FrameWithoutBoxing) frame).unsafeSetLong(slot, value); } @Override public void unsafeSetDouble(Frame frame, int slot, double value) { - castFrame(frame).unsafeSetDouble(slot, value); + ((FrameWithoutBoxing) frame).unsafeSetDouble(slot, value); } @Override public boolean unsafeIsObject(Frame frame, int slot) { - return castFrame(frame).unsafeIsObject(slot); + return ((FrameWithoutBoxing) frame).unsafeIsObject(slot); } @Override public boolean unsafeIsBoolean(Frame frame, int slot) { - return castFrame(frame).unsafeIsBoolean(slot); + return ((FrameWithoutBoxing) frame).unsafeIsBoolean(slot); } @Override public boolean unsafeIsInt(Frame frame, int slot) { - return castFrame(frame).unsafeIsInt(slot); + return ((FrameWithoutBoxing) frame).unsafeIsInt(slot); } @Override public boolean unsafeIsLong(Frame frame, int slot) { - return castFrame(frame).unsafeIsLong(slot); + return ((FrameWithoutBoxing) frame).unsafeIsLong(slot); } @Override public boolean unsafeIsDouble(Frame frame, int slot) { - return castFrame(frame).unsafeIsDouble(slot); + return ((FrameWithoutBoxing) frame).unsafeIsDouble(slot); } @Override public void unsafeCopy(Frame frame, int srcSlot, int dstSlot) { - castFrame(frame).unsafeCopy(srcSlot, dstSlot); + ((FrameWithoutBoxing) frame).unsafeCopy(srcSlot, dstSlot); } @Override public void unsafeCopyTo(Frame srcFrame, int srcOffset, Frame dstFrame, int dstOffset, int length) { - castFrame(srcFrame).unsafeCopyTo(srcOffset, castFrame(dstFrame), dstOffset, length); + ((FrameWithoutBoxing) srcFrame).unsafeCopyTo(srcOffset, ((FrameWithoutBoxing) dstFrame), dstOffset, length); } @Override public void unsafeCopyObject(Frame frame, int srcSlot, int dstSlot) { - castFrame(frame).unsafeCopyObject(srcSlot, dstSlot); + ((FrameWithoutBoxing) frame).unsafeCopyObject(srcSlot, dstSlot); } @Override public void unsafeCopyPrimitive(Frame frame, int srcSlot, int dstSlot) { - castFrame(frame).unsafeCopyPrimitive(srcSlot, dstSlot); + ((FrameWithoutBoxing) frame).unsafeCopyPrimitive(srcSlot, dstSlot); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java index 79589766504e..b61f4576fd60 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java @@ -401,6 +401,8 @@ private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, C OperationGeneratorUtils.createHelperMethod(bytecodeType, groupMethodName, () -> { CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(int.class), groupMethodName); + met.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); + met.addParameter(mContinueAt.getParameters().get(0)); // $this met.addParameter(vars.stackFrame); if (m.enableYield) { From 95fd8b1e1085afc02716f66736ff6aa911a143af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 20 Dec 2022 12:16:39 +0100 Subject: [PATCH 180/312] [wip] new parser & generator --- .../sl/operations/SLOperationRootNodeGen.java | 27910 ---------------- .../api/operation/test/bml/BaseBenchmark.java | 15 + .../api/operation/test/bml/BenmarkSimple.java | 198 +- .../test/bml/ManualBytecodeNode.java | 146 +- .../example/TestOperationsParserTest.java | 10 +- .../api/operation/OperationRootNode.java | 8 +- .../introspection/OperationIntrospection.java | 6 + .../truffle/api/impl/UnsafeFrameAccess.java | 15 + .../.checkstyle_checks.xml | 1 + .../dsl/processor/TruffleProcessor.java | 4 +- .../truffle/dsl/processor/TruffleTypes.java | 2 + .../expression/DSLExpressionResolver.java | 2 +- .../dsl/processor/generator/BitSet.java | 97 +- .../generator/FlatNodeGenFactory.java | 593 +- .../processor/generator/GeneratorUtils.java | 24 +- .../dsl/processor/generator/MultiBitSet.java | 11 - .../generator/NodeCodeGenerator.java | 19 +- .../generator/NodeGeneratorPlugs.java | 90 +- .../generator/TypeSystemCodeGenerator.java | 35 +- .../dsl/processor/java/ElementUtils.java | 4 + .../java/model/CodeElementScanner.java | 2 +- .../processor/java/model/CodeTreeBuilder.java | 11 + .../java/transform/OrganizedImports.java | 6 +- .../processor/library/ExportsGenerator.java | 6 +- .../operations/OperationGeneratorFlags.java | 2 + .../OperationsBytecodeCodeGenerator.java | 217 +- .../OperationsBytecodeNodeGeneratorPlugs.java | 21 +- .../operations/OperationsCodeGenerator.java | 36 +- .../SimpleBytecodeNodeGeneratorPlugs.java | 237 + .../operations/SingleOperationData.java | 9 + .../operations/SingleOperationParser.java | 8 +- .../generator/OperationsCodeGenerator.java | 58 + .../generator/OperationsNodeFactory.java | 933 + .../instructions/BranchInstruction.java | 5 + .../ConditionalBranchInstruction.java | 1 - .../instructions/CustomInstruction.java | 171 +- .../operations/instructions/Instruction.java | 222 +- .../instructions/LoadConstantInstruction.java | 13 +- .../instructions/ShortCircuitInstruction.java | 48 +- .../operations/model/InfoDumpable.java | 119 + .../operations/model/InstructionModel.java | 93 + .../operations/model/OperationModel.java | 222 + .../operations/model/OperationsModel.java | 251 + .../parser/CustomOperationParser.java | 569 + .../operations/parser/OperationsParser.java | 215 + .../dsl/processor/parser/NodeParser.java | 4 - .../sl/operations/SLOperationRootNode.java | 3 +- 47 files changed, 3593 insertions(+), 29079 deletions(-) delete mode 100644 truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BaseBenchmark.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InfoDumpable.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java diff --git a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java b/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java deleted file mode 100644 index dd87cc296965..000000000000 --- a/truffle/mxbuild/jdk11/com.oracle.truffle.sl/src_gen/com/oracle/truffle/sl/operations/SLOperationRootNodeGen.java +++ /dev/null @@ -1,27910 +0,0 @@ -// CheckStyle: start generated -package com.oracle.truffle.sl.operations; - -import com.oracle.truffle.api.Assumption; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.TruffleSafepoint; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; -import com.oracle.truffle.api.dsl.BoundaryCallFailedException; -import com.oracle.truffle.api.dsl.GeneratedBy; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.exception.AbstractTruffleException; -import com.oracle.truffle.api.frame.Frame; -import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameSlotKind; -import com.oracle.truffle.api.frame.FrameSlotTypeException; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.impl.UnsafeFrameAccess; -import com.oracle.truffle.api.instrumentation.InstrumentableNode; -import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.api.instrumentation.Tag; -import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.LibraryFactory; -import com.oracle.truffle.api.nodes.BytecodeOSRNode; -import com.oracle.truffle.api.nodes.DirectCallNode; -import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.IndirectCallNode; -import com.oracle.truffle.api.nodes.LoopNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; -import com.oracle.truffle.api.object.DynamicObjectLibrary; -import com.oracle.truffle.api.operation.OperationBuilder; -import com.oracle.truffle.api.operation.OperationConfig; -import com.oracle.truffle.api.operation.OperationLabel; -import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationNodes; -import com.oracle.truffle.api.operation.OperationParser; -import com.oracle.truffle.api.operation.OperationRootNode; -import com.oracle.truffle.api.operation.instrumentation.InstrumentRootNode; -import com.oracle.truffle.api.operation.instrumentation.InstrumentTreeNode; -import com.oracle.truffle.api.operation.introspection.OperationIntrospection; -import com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer; -import com.oracle.truffle.api.operation.serialization.OperationSerializer; -import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext; -import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.ConcatNode; -import com.oracle.truffle.api.strings.TruffleString.EqualNode; -import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; -import com.oracle.truffle.sl.nodes.SLTypes; -import com.oracle.truffle.sl.nodes.SLTypesGen; -import com.oracle.truffle.sl.nodes.expression.SLAddNode; -import com.oracle.truffle.sl.nodes.expression.SLDivNode; -import com.oracle.truffle.sl.nodes.expression.SLEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode; -import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode; -import com.oracle.truffle.sl.nodes.expression.SLLessThanNode; -import com.oracle.truffle.sl.nodes.expression.SLLogicalNotNode; -import com.oracle.truffle.sl.nodes.expression.SLMulNode; -import com.oracle.truffle.sl.nodes.expression.SLReadPropertyNode; -import com.oracle.truffle.sl.nodes.expression.SLSubNode; -import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode; -import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNode; -import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNode; -import com.oracle.truffle.sl.nodes.util.SLToTruffleStringNodeGen; -import com.oracle.truffle.sl.nodes.util.SLUnboxNode; -import com.oracle.truffle.sl.runtime.SLBigNumber; -import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLNull; -import com.oracle.truffle.sl.runtime.SLObject; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.IOError; -import java.io.IOException; -import java.lang.invoke.VarHandle; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Set; -import java.util.concurrent.locks.Lock; - -@GeneratedBy(SLOperationRootNode.class) -@SuppressWarnings({"unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"}) -public final class SLOperationRootNodeGen extends SLOperationRootNode implements BytecodeOSRNode { - - @GeneratedBy(SLOperationRootNode.class) - private static final class BytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - return (($sp - 1) << 16) | 0xffff; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : - { - if (BytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : - { - if (!BytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // length group 1 (1 / 1) - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 1; - continue loop; - // length group 2 (1 / 1) - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 2; - continue loop; - // length group 3 (1 / 1) - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_STORE_LOCAL << 3) | 7) : - $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 3; - continue loop; - // length group 5 (1 / 1) - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 5; - continue loop; - // length group 6 (1 / 1) - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 6; - continue loop; - // length group 7 (1 / 1) - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 7; - continue loop; - // length group 14 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_14_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 14; - continue loop; - // length group 15 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_15_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 15; - continue loop; - // length group 19 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_19_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 19; - continue loop; - // length group 22 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - $sp = instructionGroup_22_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 22; - continue loop; - // length group 23 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - $sp = instructionGroup_23_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 23; - continue loop; - // length group 24 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_24_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 24; - continue loop; - // length group 25 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_25_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 25; - continue loop; - // length group 26 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_26_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 26; - continue loop; - // length group 27 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - $sp = instructionGroup_27_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 27; - continue loop; - // length group 28 (1 / 1) - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_28_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 28; - continue loop; - // length group 30 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_30_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 30; - continue loop; - // length group 32 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_32_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 32; - continue loop; - // length group 33 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_33_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 33; - continue loop; - // length group 34 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_34_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 34; - continue loop; - // length group 37 (1 / 1) - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_37_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 37; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; - } - } - } - } - - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; - } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_CONSTANT : - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - $bci = $bci + LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_ARGUMENT : - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL : - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL : - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_RETURN : - { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD : - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_DIV : - { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_THAN : - { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_MUL : - { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_SUB : - { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_INVOKE : - { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_AND : - { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_OR : - { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLAddNode.addLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - try { - lock.unlock(); - hasLock = false; - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD0 << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value_, $child1Value_); - } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLDivNode.divLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLDivNode.div($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLDivNode.div($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.leftInterop_.accepts($child0Value)); - // assert (s7_.rightInterop_.accepts($child1Value)); - if (count7_ < (4)) { - s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); - } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); - } - - private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLLogicalNotNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { - return SLLogicalNotNode.doBoolean($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLMulNode.mulLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLMulNode.mul($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @ExplodeLoop - private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { - Node node__2 = ($this); - int bci__2 = ($bci); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - try { - return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = ($this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - node__1 = ($this); - bci__1 = ($bci); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = ($this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); - } - } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { - node__2 = ($this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (s4_.objects_.accepts($child0Value)); - InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); - node__2 = ($this); - bci__2 = ($bci); - s4_.objects_ = s4_.insertAccessor(objects__); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - } - } - { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = ($this); - readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLSubNode.subLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLSubNode.sub($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); - if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - try { - return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - int writeArray1_bci__ = 0; - Node writeArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - writeArray1_node__ = ($this); - writeArray1_bci__ = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); - } - } - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (s4_.objectLibrary_.accepts($child0Value)); - s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); - node__1 = ($this); - bci__1 = ($bci); - s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = ($this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); - if (fromString_fromJavaStringNode__ != null) { - return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLUnboxNode.fromBoolean($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - try { - return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { - return SLUnboxNode.fromBoolean($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { - return SLUnboxNode.fromLong($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromLong($child0Value_); - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBigNumber($child0Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.interop_.accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, s7_.interop_); - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); - if (result__ != null) { - return SLFunctionLiteralNode.perform($child0Value__, result__, node__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); - node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - lock.unlock(); - hasLock = false; - return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); - Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); - if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); - } - if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); - if (indirect_callNode__ != null) { - return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = ($this); - int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); - if (interop_library__ != null) { - return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); - } - - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); - if (($child0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - s0_.callTargetStable_ = callTargetStable__; - s0_.cachedTarget_ = cachedTarget__; - s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - } - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = ($this); - interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); - } - - private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - @ExplodeLoop - private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - return $sp; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - return $sp; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - return $sp; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 7) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - { - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - { - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - { - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - { - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - { - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - { - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - { - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - { - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - { - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - { - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - { - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - { - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - { - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLAdd.q.Add0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : - { - SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : - { - SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - { - SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class UncachedBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - $frame.getArguments(); - Counter uncachedExecuteCount = new Counter(); - uncachedExecuteCount.count = $this.uncachedExecuteCount; - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - return ($sp << 16) | targetBci; - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - uncachedExecuteCount.count--; - if (uncachedExecuteCount.count <= 0) { - $this.changeInterpreters(COMMON_EXECUTE); - } else { - $this.uncachedExecuteCount = uncachedExecuteCount.count; - } - return (($sp - 1) << 16) | 0xffff; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0) : - { - if (UncachedBytecodeNode.SLAnd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0) : - { - if (!UncachedBytecodeNode.SLOr_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0) : - { - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - } - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - } - // length group 1 (1 / 1) - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 1; - continue loop; - // length group 2 (1 / 1) - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - $sp = instructionGroup_2_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 2; - continue loop; - // length group 3 (1 / 1) - case ((INSTR_STORE_LOCAL << 3) | 0) : - $sp = instructionGroup_3_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 3; - continue loop; - // length group 5 (1 / 1) - case ((INSTR_C_SL_EQUAL << 3) | 0) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : - case ((INSTR_C_SL_UNBOX << 3) | 0) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : - $sp = instructionGroup_5_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 5; - continue loop; - // length group 6 (1 / 1) - case ((INSTR_C_SL_ADD << 3) | 0) : - case ((INSTR_C_SL_DIV << 3) | 0) : - case ((INSTR_C_SL_MUL << 3) | 0) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0) : - $sp = instructionGroup_6_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 6; - continue loop; - // length group 7 (1 / 1) - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_7_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 7; - continue loop; - // length group 14 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_14_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 14; - continue loop; - // length group 15 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_15_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 15; - continue loop; - // length group 19 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_19_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 19; - continue loop; - // length group 22 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - $sp = instructionGroup_22_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 22; - continue loop; - // length group 23 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0) : - $sp = instructionGroup_23_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 23; - continue loop; - // length group 24 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_24_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 24; - continue loop; - // length group 25 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_25_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 25; - continue loop; - // length group 26 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_26_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 26; - continue loop; - // length group 27 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - $sp = instructionGroup_27_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 27; - continue loop; - // length group 28 (1 / 1) - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_28_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 28; - continue loop; - // length group 30 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_30_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 30; - continue loop; - // length group 32 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_32_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 32; - continue loop; - // length group 33 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_33_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 33; - continue loop; - // length group 34 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_34_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 34; - continue loop; - // length group 37 (1 / 1) - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_37_0_uncached($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 37; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; - } - } - } - } - - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; - } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_CONSTANT : - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - $bci = $bci + LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_ARGUMENT : - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL : - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL : - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_RETURN : - { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD : - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_DIV : - { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_THAN : - { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_MUL : - { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_SUB : - { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_INVOKE : - { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_AND : - { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_OR : - { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static Object SLAdd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLDiv_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLDivNode.div($child0Value_, $child1Value_); - } - } - return SLDivNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, (EqualNode.getUncached())); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - return SLEqualNode.doGeneric($child0Value, $child1Value, (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - - private static Object SLLessOrEqual_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - return SLLessOrEqualNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLessThan_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - return SLLessThanNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLLogicalNot_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLLogicalNotNode.doBoolean($child0Value_); - } - return SLLogicalNotNode.typeError($child0Value, ($this), ($bci)); - } - - private static Object SLMul_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - return SLMulNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - private static Object SLSub_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - return SLSubNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLWriteProperty_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } - - private static Object SLUnbox_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLFunctionLiteral_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLFunctionLiteralNode.perform($child0Value_, (SLFunctionLiteralNode.lookupFunction($child0Value_, $this)), ($this)); - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } - - private static Object SLToBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLInvoke_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, (IndirectCallNode.getUncached())); - } - return SLInvoke.doInterop($child0Value, $variadicChildValue, (INTEROP_LIBRARY_.getUncached()), ($this), ($bci)); - } - - private static boolean SLAnd_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static boolean SLOr_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLToBooleanNode.doBoolean($child0Value_); - } - return SLToBooleanNode.doFallback($child0Value, ($this), ($bci)); - } - - private static Object SLUnbox_q_FromBigNumber_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromLong_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLUnbox_q_FromBoolean_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - return SLUnboxNode.fromString($child0Value_, (FromJavaStringNode.getUncached())); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - return SLUnboxNode.fromLong($child0Value_); - } - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - return SLUnboxNode.fromBigNumber($child0Value_); - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - return SLUnboxNode.fromFunction($child0Value_); - } - return SLUnboxNode.fromForeign($child0Value, (INTEROP_LIBRARY_.getUncached($child0Value))); - } - - private static Object SLAdd_q_Add0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (SLTypesGen.isImplicitSLBigNumber($child0Value)) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber($child0Value); - if (SLTypesGen.isImplicitSLBigNumber($child1Value)) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber($child1Value); - return SLAddNode.add($child0Value_, $child1Value_); - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - return SLAddNode.add($child0Value, $child1Value, (SLToTruffleStringNodeGen.getUncached()), (SLToTruffleStringNodeGen.getUncached()), (ConcatNode.getUncached())); - } - return SLAddNode.typeError($child0Value, $child1Value, ($this), ($bci)); - } - - private static Object SLReadProperty_q_ReadSLObject0_executeUncached_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (((INTEROP_LIBRARY_.getUncached($child0Value)).hasArrayElements($child0Value))) { - return SLReadPropertyNode.readArray($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (INTEROP_LIBRARY_.getUncached($child1Value))); - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, ($this), ($bci), (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)), (SLToTruffleStringNodeGen.getUncached())); - } - if ((!(SLReadPropertyNode.isSLObject($child0Value))) && ((INTEROP_LIBRARY_.getUncached($child0Value)).hasMembers($child0Value))) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, ($this), ($bci), (INTEROP_LIBRARY_.getUncached($child0Value)), (SLToMemberNodeGen.getUncached())); - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_1_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_2_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - return $sp; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - return $sp; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - return $sp; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - return $sp; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - return $sp; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_3_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_5_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0) : - { - SLEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0) : - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0) : - { - SLLessThan_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0) : - { - SLLogicalNot_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0) : - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0) : - { - SLToBoolean_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_6_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0) : - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0) : - { - SLDiv_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0) : - { - SLMul_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0) : - { - SLSub_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_7_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - SLWriteProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_14_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_15_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLFunctionLiteral_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_19_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_22_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - { - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_23_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_24_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_25_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_26_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_27_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_28_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_30_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, $sp - 1, localIdx); - $sp -= 1; - $bci = $bci + STORE_LOCAL_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return $sp; - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_32_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLLessOrEqual_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_33_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_34_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_37_0_uncached(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - UFA.unsafeCopyObject($frame, localIdx, $sp); - $sp += 1; - $bci = $bci + LOAD_LOCAL_LENGTH; - } - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - } - { - SLReadProperty_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - { - SLAdd_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_ADD_LENGTH; - } - { - SLUnbox_entryPoint_uncached($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_UNBOX_LENGTH; - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class InstrumentableBytecodeNode extends BytecodeLoopBase { - - private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); - private static final LibraryFactory DYNAMIC_OBJECT_LIBRARY_ = LibraryFactory.resolve(DynamicObjectLibrary.class); - - @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - @BytecodeInterpreterSwitch - @Override - int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals) { - int $sp = $startSp; - int $bci = $startBci; - Counter loopCounter = new Counter(); - $frame.getArguments(); - loop: while (true) { - CompilerAsserts.partialEvaluationConstant($bci); - CompilerAsserts.partialEvaluationConstant($sp); - int curOpcode = unsafeFromBytecode($bc, $bci) & 0xffff; - CompilerAsserts.partialEvaluationConstant(curOpcode); - try { - assert $sp >= maxLocals : "stack underflow @ " + $bci; - switch (curOpcode) { - // branch - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - case ((INSTR_BRANCH << 3) | 0) : - { - int targetBci = unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0); - if (targetBci <= $bci) { - if (CompilerDirectives.hasNextTier() && ++loopCounter.count >= 256) { - TruffleSafepoint.poll($this); - LoopNode.reportLoopCount($this, 256); - loopCounter.count = 0; - if (CompilerDirectives.inInterpreter() && BytecodeOSRNode.pollOSRBackEdge($this)) { - Object osrResult = BytecodeOSRNode.tryOSR($this, ($sp << 16) | targetBci, $frame, null, $frame); - if (osrResult != null) { - $frame.setObject(0, osrResult); - return 0x0000ffff; - } - } - } - } - $bci = targetBci; - continue loop; - } - // branch.false - // Simple Pops: - // [ 0] condition - // Pushed Values: 0 - // Branch Targets: - // [ 0] target - // Branch Profiles: - // [ 0] profile - case ((INSTR_BRANCH_FALSE << 3) | 0) : - { - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // throw - // Locals: - // [ 0] exception - // Pushed Values: 0 - case ((INSTR_THROW << 3) | 0) : - { - int slot = unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0); - throw (AbstractTruffleException) UFA.unsafeUncheckedGetObject($frame, slot); - } - // return - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_RETURN << 3) | 0) : - { - return (($sp - 1) << 16) | 0xffff; - } - // instrument.leave - // Pushed Values: 0 - // Branch Targets: - // [ 0] startBranch - // [ 1] endBranch - case ((INSTR_INSTRUMENT_LEAVE << 3) | 0) : - { - ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_INSTRUMENT_OFFSET) + 0); - if (probe != null) { - Object result = probe.onReturnExceptionalOrUnwind($frame, null, false); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - $bci = unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } else if (result != null) { - UFA.unsafeSetObject($frame, $sp - 1, result); - $bci = unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 1); - continue loop; - } - } - $bci = $bci + INSTRUMENT_LEAVE_LENGTH; - continue loop; - } - // sc.SLAnd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_AND << 3) | 0 /* OBJECT */) : - { - if (InstrumentableBytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case ((INSTR_SC_SL_AND << 3) | 5 /* BOOLEAN */) : - { - if (InstrumentableBytecodeNode.SLAnd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_AND_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // sc.SLOr - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - // Branch Targets: - // [ 0] end - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_SC_SL_OR << 3) | 0 /* OBJECT */) : - { - if (!InstrumentableBytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - case ((INSTR_SC_SL_OR << 3) | 5 /* BOOLEAN */) : - { - if (!InstrumentableBytecodeNode.SLOr_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)) { - $sp = $sp - 1; - $bci = $bci + SC_SL_OR_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // si.c.SLToBoolean.branch.false - // Pushed Values: 0 - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 5 /* BOOLEAN */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - boolean cond = UFA.unsafeGetObject($frame, $sp - 1) == Boolean.TRUE; - $sp = $sp - 1; - if (do_profileCondition($this, cond, $conditionProfiles, unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_PROFILE_OFFSET + 0))) { - $bci = $bci + BRANCH_FALSE_LENGTH; - continue loop; - } else { - $bci = unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0); - continue loop; - } - } - // length group 1 (1 / 1) - case ((INSTR_POP << 3) | 0) : - $sp = instructionGroup_1_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 1; - continue loop; - // length group 2 (1 / 1) - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - case ((INSTR_INSTRUMENT_ENTER << 3) | 0) : - case ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0) : - $sp = instructionGroup_2_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 2; - continue loop; - // length group 3 (1 / 1) - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - case ((INSTR_STORE_LOCAL << 3) | 7) : - case ((INSTR_INSTRUMENT_EXIT << 3) | 0) : - $sp = instructionGroup_3_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 3; - continue loop; - // length group 5 (1 / 1) - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - $sp = instructionGroup_5_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 5; - continue loop; - // length group 6 (1 / 1) - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - $sp = instructionGroup_6_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 6; - continue loop; - // length group 7 (1 / 1) - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - case ((INSTR_C_SL_INVOKE << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_7_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 7; - continue loop; - // length group 14 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_14_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 14; - continue loop; - // length group 15 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_15_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 15; - continue loop; - // length group 19 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_19_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 19; - continue loop; - // length group 22 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - $sp = instructionGroup_22_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 22; - continue loop; - // length group 23 (1 / 1) - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - $sp = instructionGroup_23_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 23; - continue loop; - // length group 24 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_24_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 24; - continue loop; - // length group 25 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_25_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 25; - continue loop; - // length group 26 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_26_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 26; - continue loop; - // length group 27 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - $sp = instructionGroup_27_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 27; - continue loop; - // length group 28 (1 / 1) - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_28_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 28; - continue loop; - // length group 30 (1 / 1) - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_30_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 30; - continue loop; - // length group 32 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_32_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 32; - continue loop; - // length group 33 (1 / 1) - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - $sp = instructionGroup_33_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 33; - continue loop; - // length group 34 (1 / 1) - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - $sp = instructionGroup_34_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 34; - continue loop; - // length group 37 (1 / 1) - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - $sp = instructionGroup_37_0($this, $frame, $bc, $bci, $sp, $consts, $children, $localTags, $conditionProfiles, curOpcode); - $bci = $bci + 37; - continue loop; - default : - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("unknown opcode encountered: " + curOpcode + " @ " + $bci + ""); - } - } catch (AbstractTruffleException ex) { - CompilerAsserts.partialEvaluationConstant($bci); - for (int handlerIndex = $handlers.length - 1; handlerIndex >= 0; handlerIndex--) { - CompilerAsserts.partialEvaluationConstant(handlerIndex); - ExceptionHandler handler = $handlers[handlerIndex]; - if (handler.startBci > $bci || handler.endBci <= $bci) continue; - $sp = handler.startStack + maxLocals; - $frame.setObject(handler.exceptionIndex, ex); - $bci = handler.handlerBci; - continue loop; - } - throw ex; - } - } - } - - @Override - void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root) { - int $bci = 0; - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - case INSTR_POP : - { - $bci = $bci + POP_LENGTH; - break; - } - case INSTR_BRANCH : - { - $bci = $bci + BRANCH_LENGTH; - break; - } - case INSTR_BRANCH_FALSE : - { - $bci = $bci + BRANCH_FALSE_LENGTH; - break; - } - case INSTR_THROW : - { - $bci = $bci + THROW_LENGTH; - break; - } - case INSTR_LOAD_CONSTANT : - { - $bci = $bci + LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_LOAD_ARGUMENT : - { - $bci = $bci + LOAD_ARGUMENT_LENGTH; - break; - } - case INSTR_LOAD_LOCAL : - { - $bci = $bci + LOAD_LOCAL_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - break; - } - case INSTR_STORE_LOCAL : - { - $bci = $bci + STORE_LOCAL_LENGTH; - break; - } - case INSTR_RETURN : - { - $bci = $bci + RETURN_LENGTH; - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - break; - } - case INSTR_STORE_LOCAL_MAT : - { - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - break; - } - case INSTR_INSTRUMENT_ENTER : - { - $bci = $bci + INSTRUMENT_ENTER_LENGTH; - break; - } - case INSTR_INSTRUMENT_EXIT_VOID : - { - $bci = $bci + INSTRUMENT_EXIT_VOID_LENGTH; - break; - } - case INSTR_INSTRUMENT_EXIT : - { - $bci = $bci + INSTRUMENT_EXIT_LENGTH; - break; - } - case INSTR_INSTRUMENT_LEAVE : - { - $bci = $bci + INSTRUMENT_LEAVE_LENGTH; - break; - } - case INSTR_C_SL_ADD : - { - $bci = $bci + C_SL_ADD_LENGTH; - break; - } - case INSTR_C_SL_DIV : - { - $bci = $bci + C_SL_DIV_LENGTH; - break; - } - case INSTR_C_SL_EQUAL : - { - $bci = $bci + C_SL_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - break; - } - case INSTR_C_SL_LESS_THAN : - { - $bci = $bci + C_SL_LESS_THAN_LENGTH; - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - break; - } - case INSTR_C_SL_MUL : - { - $bci = $bci + C_SL_MUL_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_SUB : - { - $bci = $bci + C_SL_SUB_LENGTH; - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - break; - } - case INSTR_C_SL_UNBOX : - { - $bci = $bci + C_SL_UNBOX_LENGTH; - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_INVOKE : - { - $bci = $bci + C_SL_INVOKE_LENGTH; - break; - } - case INSTR_SC_SL_AND : - { - $bci = $bci + SC_SL_AND_LENGTH; - break; - } - case INSTR_SC_SL_OR : - { - $bci = $bci + SC_SL_OR_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - break; - } - } - } - } - - @Override - OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo) { - int $bci = 0; - ArrayList target = new ArrayList<>(); - while ($bci < $bc.length) { - switch ((unsafeFromBytecode($bc, $bci) >> 3) & 8191) { - default : - { - Object[] dec = new Object[]{$bci, "unknown", Arrays.copyOfRange($bc, $bci, $bci + 1), null}; - $bci++; - target.add(dec); - break; - } - case INSTR_POP : - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - $bci = $bci + POP_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH : - { - Object[] dec = new Object[] {$bci, "branch", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_LENGTH; - target.add(dec); - break; - } - case INSTR_BRANCH_FALSE : - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - case INSTR_THROW : - { - Object[] dec = new Object[] {$bci, "throw", Arrays.copyOfRange($bc, $bci, $bci + THROW_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + THROW_LOCALS_OFFSET + 0)}}}; - $bci = $bci + THROW_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_CONSTANT : - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - $bci = $bci + LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_ARGUMENT : - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL : - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_BOXED : - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL : - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + STORE_LOCAL_LENGTH; - target.add(dec); - break; - } - case INSTR_RETURN : - { - Object[] dec = new Object[] {$bci, "return", Arrays.copyOfRange($bc, $bci, $bci + RETURN_LENGTH), new Object[] {}}; - $bci = $bci + RETURN_LENGTH; - target.add(dec); - break; - } - case INSTR_LOAD_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "load.local.mat", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + LOAD_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_STORE_LOCAL_MAT : - { - Object[] dec = new Object[] {$bci, "store.local.mat", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_MAT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0)}}}; - $bci = $bci + STORE_LOCAL_MAT_LENGTH; - target.add(dec); - break; - } - case INSTR_INSTRUMENT_ENTER : - { - Object[] dec = new Object[] {$bci, "instrument.enter", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_ENTER_LENGTH), new Object[] {}}; - $bci = $bci + INSTRUMENT_ENTER_LENGTH; - target.add(dec); - break; - } - case INSTR_INSTRUMENT_EXIT_VOID : - { - Object[] dec = new Object[] {$bci, "instrument.exit.void", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_EXIT_VOID_LENGTH), new Object[] {}}; - $bci = $bci + INSTRUMENT_EXIT_VOID_LENGTH; - target.add(dec); - break; - } - case INSTR_INSTRUMENT_EXIT : - { - Object[] dec = new Object[] {$bci, "instrument.exit", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_EXIT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + INSTRUMENT_EXIT_LENGTH; - target.add(dec); - break; - } - case INSTR_INSTRUMENT_LEAVE : - { - Object[] dec = new Object[] {$bci, "instrument.leave", Arrays.copyOfRange($bc, $bci, $bci + INSTRUMENT_LEAVE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 0)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET + 1)}}}; - $bci = $bci + INSTRUMENT_LEAVE_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD : - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_DIV : - { - Object[] dec = new Object[] {$bci, "c.SLDiv", Arrays.copyOfRange($bc, $bci, $bci + C_SL_DIV_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_DIV_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_DIV_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_OR_EQUAL : - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LESS_THAN : - { - Object[] dec = new Object[] {$bci, "c.SLLessThan", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_THAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_LESS_THAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_LOGICAL_NOT : - { - Object[] dec = new Object[] {$bci, "c.SLLogicalNot", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LOGICAL_NOT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_LOGICAL_NOT_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_MUL : - { - Object[] dec = new Object[] {$bci, "c.SLMul", Arrays.copyOfRange($bc, $bci, $bci + C_SL_MUL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_MUL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_MUL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_SUB : - { - Object[] dec = new Object[] {$bci, "c.SLSub", Arrays.copyOfRange($bc, $bci, $bci + C_SL_SUB_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_SUB_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_SUB_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_WRITE_PROPERTY : - { - Object[] dec = new Object[] {$bci, "c.SLWriteProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_WRITE_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)}}}; - $bci = $bci + C_SL_WRITE_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_FUNCTION_LITERAL : - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_TO_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_TO_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_INVOKE : - { - Object[] dec = new Object[] {$bci, "c.SLInvoke", Arrays.copyOfRange($bc, $bci, $bci + C_SL_INVOKE_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.VARIADIC, (int) unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0)}}}; - $bci = $bci + C_SL_INVOKE_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_AND : - { - Object[] dec = new Object[] {$bci, "sc.SLAnd", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_AND_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_AND_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_AND_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_AND_LENGTH; - target.add(dec); - break; - } - case INSTR_SC_SL_OR : - { - Object[] dec = new Object[] {$bci, "sc.SLOr", Arrays.copyOfRange($bc, $bci, $bci + SC_SL_OR_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + SC_SL_OR_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + SC_SL_OR_BRANCH_TARGET_OFFSET + 0)}}}; - $bci = $bci + SC_SL_OR_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBigNumber.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_LONG : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromLong", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_LONG_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN : - { - Object[] dec = new Object[] {$bci, "c.SLUnbox.q.FromBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - $bci = $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_ADD_Q_ADD0 : - { - Object[] dec = new Object[] {$bci, "c.SLAdd.q.Add0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_Q_ADD0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_ADD_Q_ADD0_LENGTH; - target.add(dec); - break; - } - case INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 : - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty.q.ReadSLObject0", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - $bci = $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.argument", Arrays.copyOfRange($bc, $bci, $bci + LOAD_ARGUMENT_LENGTH), new Object[] { - new Object[] {ArgumentKind.ARGUMENT, (int) unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_ARGUMENT_LENGTH; - { - Object[] dec = new Object[] {$bci, "store.local", Arrays.copyOfRange($bc, $bci, $bci + STORE_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += STORE_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[6]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_ADD_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[4]}; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[8]}; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLReadProperty", Arrays.copyOfRange($bc, $bci, $bci + C_SL_READ_PROPERTY_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 1]}, - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CONSTANT_OFFSET) + 2]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_READ_PROPERTY_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local.boxed", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_BOXED_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += LOAD_LOCAL_BOXED_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLLessOrEqual", Arrays.copyOfRange($bc, $bci, $bci + C_SL_LESS_OR_EQUAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_LESS_OR_EQUAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[7] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[7]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLAdd", Arrays.copyOfRange($bc, $bci, $bci + C_SL_ADD_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_ADD_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)}}}; - ((Object[]) decSuper[4])[5] = dec; - } - $bci += C_SL_ADD_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[6] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH), new Object[] {}, new Object[5]}; - { - Object[] dec = new Object[] {$bci, "pop", Arrays.copyOfRange($bc, $bci, $bci + POP_LENGTH), new Object[] {}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += POP_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.constant", Arrays.copyOfRange($bc, $bci, $bci + LOAD_CONSTANT_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0]}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += LOAD_CONSTANT_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLFunctionLiteral", Arrays.copyOfRange($bc, $bci, $bci + C_SL_FUNCTION_LITERAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[2] = dec; - } - $bci += C_SL_FUNCTION_LITERAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "load.local", Arrays.copyOfRange($bc, $bci, $bci + LOAD_LOCAL_LENGTH), new Object[] { - new Object[] {ArgumentKind.LOCAL, (int) unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[3] = dec; - } - $bci += LOAD_LOCAL_LENGTH; - { - Object[] dec = new Object[] {$bci, "c.SLUnbox", Arrays.copyOfRange($bc, $bci, $bci + C_SL_UNBOX_LENGTH), new Object[] { - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[4] = dec; - } - $bci += C_SL_UNBOX_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH; - target.add(dec); - break; - } - case INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE : - { - int oldBci = $bci; - Object[] decSuper = new Object[] {$bci, "si.c.SLToBoolean.branch.false", Arrays.copyOfRange($bc, $bci, $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH), new Object[] {}, new Object[2]}; - { - Object[] dec = new Object[] {$bci, "c.SLToBoolean", Arrays.copyOfRange($bc, $bci, $bci + C_SL_TO_BOOLEAN_LENGTH), new Object[] { - new Object[] {ArgumentKind.CONSTANT, $consts[unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_CONSTANT_OFFSET) + 0]}, - new Object[] {ArgumentKind.CHILD_OFFSET, (int) (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)}}}; - ((Object[]) decSuper[4])[0] = dec; - } - $bci += C_SL_TO_BOOLEAN_LENGTH; - { - Object[] dec = new Object[] {$bci, "branch.false", Arrays.copyOfRange($bc, $bci, $bci + BRANCH_FALSE_LENGTH), new Object[] { - new Object[] {ArgumentKind.BRANCH_OFFSET, (int) unsafeFromBytecode($bc, $bci + BRANCH_FALSE_BRANCH_TARGET_OFFSET + 0)}}}; - ((Object[]) decSuper[4])[1] = dec; - } - $bci += BRANCH_FALSE_LENGTH; - Object[] dec = decSuper; - $bci = oldBci; - $bci = $bci + SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH; - target.add(dec); - break; - } - } - } - ArrayList ehTarget = new ArrayList<>(); - for (int i = 0; i < $handlers.length; i++) { - ehTarget.add(new Object[] {$handlers[i].startBci, $handlers[i].endBci, $handlers[i].handlerBci}); - } - Object[] si = null; - if (nodes != null && nodes.getSources() != null && sourceInfo != null) { - ArrayList siTarget = new ArrayList<>(); - for (int i = 0; i < sourceInfo.length; i += 3) { - int startBci = sourceInfo[i] & 0xffff; - int endBci = i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff; - if (startBci == endBci) { - continue; - } - int sourceIndex = sourceInfo[i] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - siTarget.add(new Object[] {startBci, endBci, sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)}); - } - si = siTarget.toArray(); - } - return OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si}); - } - - private static boolean SLAdd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1110) == 0 /* only-active addLong(long, long) */ && ((state_0 & 0b1111) != 0 /* is-not addLong(long, long) && add(SLBigNumber, SLBigNumber) && add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) && typeError(Object, Object, Node, int) */)) { - return SLAdd_SLAdd_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAdd_SLAdd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLAdd_SLAdd_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */; - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLAdd_SLAdd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLAddNode.addLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) || typeError(Object, Object, Node, int) */) { - if ((state_0 & 0b100) != 0 /* is-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */) { - SLAdd_Add1Data s2_ = ((SLAdd_Add1Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0)); - if (s2_ != null) { - if ((SLAddNode.isString($child0Value_, $child1Value_))) { - return SLAddNode.add($child0Value_, $child1Value_, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAdd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_)) { - return SLAddNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 addLong(long, long) */) { - try { - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLAdd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_ADD_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude addLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 addLong(long, long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - try { - lock.unlock(); - hasLock = false; - return SLAddNode.addLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude addLong(long, long) */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 addLong(long, long) */); - } finally { - lock.unlock(); - } - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude addLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 addLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 4) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 6) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 add(SLBigNumber, SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b1111) == 0b10/* is-exact-state_0 add(SLBigNumber, SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD_Q_ADD0 << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value_, $child1Value_); - } - } - } - if ((SLAddNode.isString($child0Value, $child1Value))) { - SLAdd_Add1Data s2_ = $this.insertAccessor(new SLAdd_Add1Data()); - s2_.toTruffleStringNodeLeft_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.toTruffleStringNodeRight_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - s2_.concatNode_ = s2_.insertAccessor((ConcatNode.create())); - VarHandle.storeStoreFence(); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_ADD_CHILDREN_OFFSET) + 0) + 0] = s2_; - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.add($child0Value, $child1Value, s2_.toTruffleStringNodeLeft_, s2_.toTruffleStringNodeRight_, s2_.concatNode_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_ADD_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 typeError(Object, Object, Node, int) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLAddNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLDiv_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLDiv_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active divLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not divLong(long, long) && div(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLDiv_SLDiv_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLDiv_SLDiv_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLDiv_SLDiv_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */; - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLDiv_SLDiv_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLDivNode.divLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 div(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLDivNode.div($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLDiv_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLDivNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLDiv_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_DIV_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 divLong(long, long) */) { - try { - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLDiv_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_DIV_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude divLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 divLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLDivNode.divLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude divLong(long, long) */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 divLong(long, long) */); - } finally { - lock.unlock(); - } - return SLDiv_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude divLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 divLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 div(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLDivNode.div($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_DIV_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLDivNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_execute__boolean_boolean1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLEqual_SLEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static Object SLEqual_SLEqual_execute__boolean_boolean1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLEqual_generic1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLEqual_SLEqual_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111110) == 0 /* only-active doLong(long, long) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__long_long3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111111011) == 0 /* only-active doBoolean(boolean, boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not doLong(long, long) && doBigNumber(SLBigNumber, SLBigNumber) && doBoolean(boolean, boolean) && doString(String, String) && doTruffleString(TruffleString, TruffleString, EqualNode) && doNull(SLNull, SLNull) && doFunction(SLFunction, Object) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) && doGeneric(Object, Object, InteropLibrary, InteropLibrary) */)) { - return SLEqual_SLEqual_executeBoolean__boolean_boolean4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLEqual_SLEqual_executeBoolean__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLEqual_SLEqual_executeBoolean__long_long3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - - private static boolean SLEqual_SLEqual_executeBoolean__boolean_boolean4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - boolean $child1Value_; - try { - $child1Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static boolean SLEqual_generic1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - InteropLibrary generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value_)); - return SLEqualNode.doGeneric($child0Value_, $child1Value_, generic1_leftInterop__, generic1_rightInterop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static boolean SLEqual_SLEqual_executeBoolean__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLEqualNode.doLong($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doBigNumber(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000000000) >>> 11 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLEqualNode.doBigNumber($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doBoolean(boolean, boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - if ($child1Value_ instanceof Boolean) { - boolean $child1Value__ = (boolean) $child1Value_; - return SLEqualNode.doBoolean($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 doString(String, String) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - if ($child1Value_ instanceof String) { - String $child1Value__ = (String) $child1Value_; - return SLEqualNode.doString($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10000) != 0 /* is-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - if ($child1Value_ instanceof TruffleString) { - TruffleString $child1Value__ = (TruffleString) $child1Value_; - EqualNode truffleString_equalNode__ = ((EqualNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0)); - if (truffleString_equalNode__ != null) { - return SLEqualNode.doTruffleString($child0Value__, $child1Value__, truffleString_equalNode__); - } - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 doNull(SLNull, SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - if (SLTypes.isSLNull($child1Value_)) { - SLNull $child1Value__ = SLTypes.asSLNull($child1Value_); - return SLEqualNode.doNull($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b111000000) != 0 /* is-state_0 doFunction(SLFunction, Object) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1000000) != 0 /* is-state_0 doFunction(SLFunction, Object) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLEqualNode.doFunction($child0Value__, $child1Value_); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) || doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value_)) && (s7_.rightInterop_.accepts($child1Value_))) { - return SLEqualNode.doGeneric($child0Value_, $child1Value_, s7_.leftInterop_, s7_.rightInterop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - try { - return SLEqual_generic1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doLong(long, long) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doLong($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 11) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doBigNumber(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBigNumber($child0Value_, $child1Value_); - } - } - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - if ($child1Value instanceof Boolean) { - boolean $child1Value_ = (boolean) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doBoolean(boolean, boolean) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doBoolean($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - if ($child1Value instanceof String) { - String $child1Value_ = (String) $child1Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 doString(String, String) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doString($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - if ($child1Value instanceof TruffleString) { - TruffleString $child1Value_ = (TruffleString) $child1Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((EqualNode.create())); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 doTruffleString(TruffleString, TruffleString, EqualNode) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doTruffleString($child0Value_, $child1Value_, ((EqualNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - if (SLTypes.isSLNull($child1Value)) { - SLNull $child1Value_ = SLTypes.asSLNull($child1Value); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 doNull(SLNull, SLNull) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doNull($child0Value_, $child1Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 doFunction(SLFunction, Object) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doFunction($child0Value_, $child1Value); - } - if ((exclude) == 0 /* is-not-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - int count7_ = 0; - SLEqual_Generic0Data s7_ = ((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.leftInterop_.accepts($child0Value)) && (s7_.rightInterop_.accepts($child1Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.leftInterop_.accepts($child0Value)); - // assert (s7_.rightInterop_.accepts($child1Value)); - if (count7_ < (4)) { - s7_ = $this.insertAccessor(new SLEqual_Generic0Data(((SLEqual_Generic0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.leftInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s7_.rightInterop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, s7_.leftInterop_, s7_.rightInterop_); - } - } - { - InteropLibrary generic1_rightInterop__ = null; - InteropLibrary generic1_leftInterop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - generic1_leftInterop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - generic1_rightInterop__ = (INTEROP_LIBRARY_.getUncached($child1Value)); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_EQUAL_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 doGeneric(Object, Object, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLEqualNode.doGeneric($child0Value, $child1Value, generic1_leftInterop__, generic1_rightInterop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessOrEqual_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessOrEqual_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessOrEqual_SLLessOrEqual_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static Object SLLessOrEqual_SLLessOrEqual_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessOrEqual_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessOrEqualNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessOrEqual(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessOrEqual(long, long) && lessOrEqual(SLBigNumber, SLBigNumber) */)) { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - - private static boolean SLLessOrEqual_SLLessOrEqual_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessOrEqual(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessOrEqualNode.lessOrEqual($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessOrEqual_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessOrEqual_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessOrEqual(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessOrEqual(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.lessOrEqual($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLessOrEqualNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLessThan_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLLessThan_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b111) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLLessThan_SLLessThan_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLessThan_SLLessThan_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static Object SLLessThan_SLLessThan_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLessThan_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLLessThanNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static boolean SLLessThan_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active lessThan(long, long) */ && ((state_0 & 0b11) != 0 /* is-not lessThan(long, long) && lessThan(SLBigNumber, SLBigNumber) */)) { - return SLLessThan_SLLessThan_executeBoolean__long_long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLessThan_SLLessThan_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__long_long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - assert (state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - - private static boolean SLLessThan_SLLessThan_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 lessThan(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 lessThan(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLLessThanNode.lessThan($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLessThan_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLLessThan_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 lessThan(long, long) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 lessThan(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.lessThan($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LESS_THAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLessThanNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLLogicalNot_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLLogicalNot_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && typeError(Object, Node, int) */)) { - return SLLogicalNot_SLLogicalNot_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLLogicalNot_SLLogicalNot_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLLogicalNot_SLLogicalNot_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLLogicalNotNode.doBoolean($child0Value_); - } - - private static Object SLLogicalNot_SLLogicalNot_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLLogicalNotNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLLogicalNot_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLLogicalNotNode.typeError($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLLogicalNot_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b10) != 0 /* is-state_0 typeError(Object, Node, int) */) { - return SLTypesGen.expectBoolean(SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */) { - return SLLogicalNotNode.doBoolean($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLLogicalNot_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLLogicalNot_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_LOGICAL_NOT_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 typeError(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLLogicalNotNode.typeError($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLMul_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLMul_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active mulLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not mulLong(long, long) && mul(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLMul_SLMul_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLMul_SLMul_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLMul_SLMul_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */; - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLMul_SLMul_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLMulNode.mulLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 mul(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLMulNode.mul($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLMul_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLMulNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLMul_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_MUL_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 mulLong(long, long) */) { - try { - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLMul_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_MUL_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude mulLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 mulLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLMulNode.mulLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude mulLong(long, long) */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - } finally { - lock.unlock(); - } - return SLMul_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude mulLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 mulLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 mul(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLMulNode.mul($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_MUL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLMulNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @ExplodeLoop - private static Object SLReadProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if (state_0 != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) || readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLReadProperty_readArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) || readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLReadProperty_readSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) || readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value_)) && (!(SLReadPropertyNode.isSLObject($child0Value_))) && (s4_.objects_.hasMembers($child0Value_))) { - Node node__2 = ($this); - int bci__2 = ($bci); - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value_)))) { - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value_))) { - try { - return SLReadProperty_readObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readArray1_node__ = ($this); - int readArray1_bci__ = ($bci); - InteropLibrary readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLReadPropertyNode.readArray($child0Value_, $child1Value_, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readSLObject1_node__ = ($this); - int readSLObject1_bci__ = ($bci); - DynamicObjectLibrary readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode readSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if (readSLObject1_toTruffleStringNode__ != null) { - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, readSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLReadProperty_readObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node readObject1_node__ = ($this); - int readObject1_bci__ = ($bci); - InteropLibrary readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - SLToMemberNode readObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11)); - if (readObject1_asMember__ != null) { - return SLReadPropertyNode.readObject($child0Value_, $child1Value_, readObject1_node__, readObject1_bci__, readObject1_objects__, readObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - private static Object SLReadProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLReadProperty_ReadArray0Data s0_ = ((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLReadProperty_ReadArray0Data(((SLReadProperty_ReadArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary readArray1_numbers__ = null; - InteropLibrary readArray1_arrays__ = null; - int readArray1_bci__ = 0; - Node readArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - readArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((readArray1_arrays__.hasArrayElements($child0Value))) { - readArray1_node__ = ($this); - readArray1_bci__ = ($bci); - readArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 readArray(Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readArray($child0Value, $child1Value, readArray1_node__, readArray1_bci__, readArray1_arrays__, readArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b10)) == 0 /* is-not-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLReadProperty_ReadSLObject0Data(((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - node__1 = ($this); - bci__1 = ($bci); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if (state_0 == 0b100/* is-exact-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, node__1, bci__1, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - } - { - DynamicObjectLibrary readSLObject1_objectLibrary__ = null; - int readSLObject1_bci__ = 0; - Node readSLObject1_node__ = null; - readSLObject1_node__ = ($this); - readSLObject1_bci__ = ($bci); - readSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 7] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readSLObject($child0Value_, $child1Value, readSLObject1_node__, readSLObject1_bci__, readSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7))); - } - } - { - int bci__2 = 0; - Node node__2 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLReadProperty_ReadObject0Data s4_ = ((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 8)); - if ((state_0 & 0b10000) != 0 /* is-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objects_.accepts($child0Value)) && (!(SLReadPropertyNode.isSLObject($child0Value))) && (s4_.objects_.hasMembers($child0Value))) { - node__2 = ($this); - bci__2 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - // assert (s4_.objects_.accepts($child0Value)); - InteropLibrary objects__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - if ((objects__.hasMembers($child0Value)) && count4_ < (SLReadPropertyNode.LIBRARY_LIMIT)) { - s4_ = $this.insertAccessor(new SLReadProperty_ReadObject0Data(((SLReadProperty_ReadObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 8)))); - node__2 = ($this); - bci__2 = ($bci); - s4_.objects_ = s4_.insertAccessor(objects__); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 8] = s4_; - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - } - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, node__2, bci__2, s4_.objects_, s4_.asMember_); - } - } - } - { - InteropLibrary readObject1_objects__ = null; - int readObject1_bci__ = 0; - Node readObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLReadPropertyNode.isSLObject($child0Value)))) { - readObject1_objects__ = (INTEROP_LIBRARY_.getUncached()); - if ((readObject1_objects__.hasMembers($child0Value))) { - readObject1_node__ = ($this); - readObject1_bci__ = ($bci); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_CHILDREN_OFFSET) + 0) + 11] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 8] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_READ_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 readObject(Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLReadPropertyNode.readObject($child0Value, $child1Value, readObject1_node__, readObject1_bci__, readObject1_objects__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 11))); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null}, $child0Value, $child1Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLSub_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - return true; - } - - private static Object SLSub_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b110) == 0 /* only-active subLong(long, long) */ && ((state_0 & 0b111) != 0 /* is-not subLong(long, long) && sub(SLBigNumber, SLBigNumber) && typeError(Object, Object, Node, int) */)) { - return SLSub_SLSub_execute__long_long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLSub_SLSub_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLSub_SLSub_execute__long_long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */; - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - - private static Object SLSub_SLSub_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - if ($child1Value_ instanceof Long) { - long $child1Value__ = (long) $child1Value_; - try { - return SLSubNode.subLong($child0Value__, $child1Value__); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value__, $child1Value__); - } - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 sub(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000) >>> 3 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b1100000) >>> 5 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLSubNode.sub($child0Value__, $child1Value__); - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLSub_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)) { - return SLSubNode.typeError($child0Value_, $child1Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLSub_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b100) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object $child1Value = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult(), $child1Value)); - } - long $child1Value_; - try { - $child1Value_ = expectLong($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_SUB_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1) != 0 /* is-state_0 subLong(long, long) */) { - try { - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - private static Object SLSub_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_SUB_STATE_BITS_OFFSET + 1); - if ((exclude) == 0 /* is-not-exclude subLong(long, long) */ && $child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - if ($child1Value instanceof Long) { - long $child1Value_ = (long) $child1Value; - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 subLong(long, long) */); - try { - lock.unlock(); - hasLock = false; - return SLSubNode.subLong($child0Value_, $child1Value_); - } catch (ArithmeticException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lock.lock(); - try { - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] | 0b1 /* add-exclude subLong(long, long) */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 subLong(long, long) */); - } finally { - lock.unlock(); - } - return SLSub_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - } - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - int sLBigNumberCast1; - if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber($child1Value)) != 0) { - SLBigNumber $child1Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, $child1Value); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude subLong(long, long) */); - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 subLong(long, long) */); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 3) /* set-implicit-state_0 0:SLBigNumber */); - state_0 = (short) (state_0 | (sLBigNumberCast1 << 5) /* set-implicit-state_0 1:SLBigNumber */); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 sub(SLBigNumber, SLBigNumber) */); - lock.unlock(); - hasLock = false; - return SLSubNode.sub($child0Value_, $child1Value_); - } - } - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_SUB_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 typeError(Object, Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLSubNode.typeError($child0Value, $child1Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value_, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLWriteProperty_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 3, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 2, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - Object $child2Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET + 1) & 0xff)); - if (state_0 != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) || writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value_)) && (s0_.numbers_.accepts($child1Value_)) && (s0_.arrays_.hasArrayElements($child0Value_))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, node__, bci__, s0_.arrays_, s0_.numbers_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value_))) { - try { - return SLWriteProperty_writeArray1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ((state_0 & 0b1100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) || writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */ && $child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - if ((state_0 & 0b1000) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - try { - return SLWriteProperty_writeSLObject1Boundary1_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value__, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - if ((state_0 & 0b110000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) || writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value_)) && (!(SLWritePropertyNode.isSLObject($child0Value_)))) { - Node node__1 = ($this); - int bci__1 = ($bci); - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - s4_ = s4_.next_; - } - } - if ((state_0 & 0b100000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - if ((!(SLWritePropertyNode.isSLObject($child0Value_)))) { - try { - return SLWriteProperty_writeObject1Boundary2_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_, $child1Value_, $child2Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLWriteProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_, $child2Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeArray1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - Node writeArray1_node__ = ($this); - int writeArray1_bci__ = ($bci); - InteropLibrary writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - InteropLibrary writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - return SLWritePropertyNode.writeArray($child0Value_, $child1Value_, $child2Value_, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeSLObject1Boundary1_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, SLObject $child0Value__, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value__)); - SLToTruffleStringNode writeSLObject1_toTruffleStringNode__ = ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6)); - if (writeSLObject1_toTruffleStringNode__ != null) { - return SLWritePropertyNode.writeSLObject($child0Value__, $child1Value_, $child2Value_, writeSLObject1_objectLibrary__, writeSLObject1_toTruffleStringNode__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLWriteProperty_writeObject1Boundary2_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_, Object $child1Value_, Object $child2Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - Node writeObject1_node__ = ($this); - int writeObject1_bci__ = ($bci); - InteropLibrary writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - SLToMemberNode writeObject1_asMember__ = ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10)); - if (writeObject1_asMember__ != null) { - return SLWritePropertyNode.writeObject($child0Value_, $child1Value_, $child2Value_, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, writeObject1_asMember__); - } - throw BoundaryCallFailedException.INSTANCE; - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLWriteProperty_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value, Object $child1Value, Object $child2Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1); - { - int bci__ = 0; - Node node__ = null; - if (((exclude & 0b1)) == 0 /* is-not-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - int count0_ = 0; - SLWriteProperty_WriteArray0Data s0_ = ((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */) { - while (s0_ != null) { - if ((s0_.arrays_.accepts($child0Value)) && (s0_.numbers_.accepts($child1Value)) && (s0_.arrays_.hasArrayElements($child0Value))) { - node__ = ($this); - bci__ = ($bci); - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - InteropLibrary arrays__ = $this.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - // assert (s0_.arrays_.accepts($child0Value)); - // assert (s0_.numbers_.accepts($child1Value)); - if ((arrays__.hasArrayElements($child0Value)) && count0_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s0_ = $this.insertAccessor(new SLWriteProperty_WriteArray0Data(((SLWriteProperty_WriteArray0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - node__ = ($this); - bci__ = ($bci); - s0_.arrays_ = s0_.insertAccessor(arrays__); - s0_.numbers_ = s0_.insertAccessor((INTEROP_LIBRARY_.create($child1Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, node__, bci__, s0_.arrays_, s0_.numbers_); - } - } - } - { - InteropLibrary writeArray1_numbers__ = null; - InteropLibrary writeArray1_arrays__ = null; - int writeArray1_bci__ = 0; - Node writeArray1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - writeArray1_arrays__ = (INTEROP_LIBRARY_.getUncached()); - if ((writeArray1_arrays__.hasArrayElements($child0Value))) { - writeArray1_node__ = ($this); - writeArray1_bci__ = ($bci); - writeArray1_numbers__ = (INTEROP_LIBRARY_.getUncached()); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 writeArray(Object, Object, Object, Node, int, InteropLibrary, InteropLibrary) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeArray($child0Value, $child1Value, $child2Value, writeArray1_node__, writeArray1_bci__, writeArray1_arrays__, writeArray1_numbers__); - } - } - } finally { - encapsulating_.set(prev_); - } - } - } - if ($child0Value instanceof SLObject) { - SLObject $child0Value_ = (SLObject) $child0Value; - if (((exclude & 0b10)) == 0 /* is-not-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - int count2_ = 0; - SLWriteProperty_WriteSLObject0Data s2_ = ((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 4)); - if ((state_0 & 0b100) != 0 /* is-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */) { - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value_))) { - break; - } - s2_ = s2_.next_; - count2_++; - } - } - if (s2_ == null) { - // assert (s2_.objectLibrary_.accepts($child0Value_)); - if (count2_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - s2_ = $this.insertAccessor(new SLWriteProperty_WriteSLObject0Data(((SLWriteProperty_WriteSLObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 4)))); - s2_.objectLibrary_ = s2_.insertAccessor((DYNAMIC_OBJECT_LIBRARY_.create($child0Value_))); - s2_.toTruffleStringNode_ = s2_.insertAccessor((SLToTruffleStringNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 4] = s2_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - } - } - if (s2_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - } - { - DynamicObjectLibrary writeSLObject1_objectLibrary__ = null; - writeSLObject1_objectLibrary__ = (DYNAMIC_OBJECT_LIBRARY_.getUncached($child0Value_)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 6] = $this.insertAccessor((SLToTruffleStringNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b10 /* add-exclude writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $children[childArrayOffset_ + 4] = null; - state_0 = (short) (state_0 & 0xfffffffb /* remove-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 writeSLObject(SLObject, Object, Object, DynamicObjectLibrary, SLToTruffleStringNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeSLObject($child0Value_, $child1Value, $child2Value, writeSLObject1_objectLibrary__, ((SLToTruffleStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 6))); - } - } - { - int bci__1 = 0; - Node node__1 = null; - if (((exclude & 0b100)) == 0 /* is-not-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - int count4_ = 0; - SLWriteProperty_WriteObject0Data s4_ = ((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 7)); - if ((state_0 & 0b10000) != 0 /* is-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */) { - while (s4_ != null) { - if ((s4_.objectLibrary_.accepts($child0Value)) && (!(SLWritePropertyNode.isSLObject($child0Value)))) { - node__1 = ($this); - bci__1 = ($bci); - break; - } - s4_ = s4_.next_; - count4_++; - } - } - if (s4_ == null) { - if ((!(SLWritePropertyNode.isSLObject($child0Value))) && count4_ < (SLWritePropertyNode.LIBRARY_LIMIT)) { - // assert (s4_.objectLibrary_.accepts($child0Value)); - s4_ = $this.insertAccessor(new SLWriteProperty_WriteObject0Data(((SLWriteProperty_WriteObject0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 7)))); - node__1 = ($this); - bci__1 = ($bci); - s4_.objectLibrary_ = s4_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - s4_.asMember_ = s4_.insertAccessor((SLToMemberNodeGen.create())); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 7] = s4_; - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - } - } - if (s4_ != null) { - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, node__1, bci__1, s4_.objectLibrary_, s4_.asMember_); - } - } - } - { - InteropLibrary writeObject1_objectLibrary__ = null; - int writeObject1_bci__ = 0; - Node writeObject1_node__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - if ((!(SLWritePropertyNode.isSLObject($child0Value)))) { - writeObject1_node__ = ($this); - writeObject1_bci__ = ($bci); - writeObject1_objectLibrary__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_WRITE_PROPERTY_CHILDREN_OFFSET) + 0) + 10] = $this.insertAccessor((SLToMemberNodeGen.create())); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b100 /* add-exclude writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $children[childArrayOffset_ + 7] = null; - state_0 = (short) (state_0 & 0xffffffef /* remove-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - $bc[$bci + C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 writeObject(Object, Object, Object, Node, int, InteropLibrary, SLToMemberNode) */); - lock.unlock(); - hasLock = false; - return SLWritePropertyNode.writeObject($child0Value, $child1Value, $child2Value, writeObject1_node__, writeObject1_bci__, writeObject1_objectLibrary__, ((SLToMemberNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 10))); - } - } finally { - encapsulating_.set(prev_); - } - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null, null, null}, $child0Value, $child1Value, $child2Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - private static Object SLUnbox_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b111111011) == 0 /* only-active fromBoolean(boolean) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else if ((state_0 & 0b111110111) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b111111111) != 0 /* is-not fromString(String, FromJavaStringNode) && fromTruffleString(TruffleString) && fromBoolean(boolean) && fromLong(long) && fromBigNumber(SLBigNumber) && fromFunction(SLFunction) && fromFunction(SLNull) && fromForeign(Object, InteropLibrary) && fromForeign(Object, InteropLibrary) */)) { - return SLUnbox_SLUnbox_execute__long1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_SLUnbox_execute__generic2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_SLUnbox_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static Object SLUnbox_SLUnbox_execute__long1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - @SuppressWarnings("static-method") - @TruffleBoundary - private static Object SLUnbox_fromForeign1Boundary0_(SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value_) { - int childArrayOffset_; - int constArrayOffset_; - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - { - InteropLibrary fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value_)); - return SLUnboxNode.fromForeign($child0Value_, fromForeign1_interop__); - } - } finally { - encapsulating_.set(prev_); - } - } - - @ExplodeLoop - private static Object SLUnbox_SLUnbox_execute__generic2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 fromString(String, FromJavaStringNode) */ && $child0Value_ instanceof String) { - String $child0Value__ = (String) $child0Value_; - FromJavaStringNode fromString_fromJavaStringNode__ = ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0)); - if (fromString_fromJavaStringNode__ != null) { - return SLUnboxNode.fromString($child0Value__, fromString_fromJavaStringNode__); - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 fromTruffleString(TruffleString) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - return SLUnboxNode.fromTruffleString($child0Value__); - } - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLUnboxNode.fromBoolean($child0Value__); - } - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - if ((state_0 & 0b100000) != 0 /* is-state_0 fromFunction(SLFunction) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b1000000) != 0 /* is-state_0 fromFunction(SLNull) */ && SLTypes.isSLNull($child0Value_)) { - SLNull $child0Value__ = SLTypes.asSLNull($child0Value_); - return SLUnboxNode.fromFunction($child0Value__); - } - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value_))) { - return SLUnboxNode.fromForeign($child0Value_, s7_.interop_); - } - s7_ = s7_.next_; - } - } - if ((state_0 & 0b100000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - try { - return SLUnbox_fromForeign1Boundary0_($this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_); - } catch (BoundaryCallFailedException ex) { - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */) { - return SLUnboxNode.fromBoolean($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */) { - return SLUnboxNode.fromLong($child0Value_); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof String) { - String $child0Value_ = (String) $child0Value; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 0] = $this.insertAccessor((FromJavaStringNode.create())); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 fromString(String, FromJavaStringNode) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromString($child0Value_, ((FromJavaStringNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0))); - } - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 fromTruffleString(TruffleString) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromTruffleString($child0Value_); - } - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 fromBoolean(boolean) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b100/* is-exact-state_0 fromBoolean(boolean) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBoolean($child0Value_); - } - if ($child0Value instanceof Long) { - long $child0Value_ = (long) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000 /* add-state_0 fromLong(long) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b1000/* is-exact-state_0 fromLong(long) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromLong($child0Value_); - } - { - int sLBigNumberCast0; - if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber($child0Value)) != 0) { - SLBigNumber $child0Value_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, $child0Value); - state_0 = (short) (state_0 | (sLBigNumberCast0 << 9) /* set-implicit-state_0 0:SLBigNumber */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000 /* add-state_0 fromBigNumber(SLBigNumber) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - if ((state_0 & 0b111111111) == 0b10000/* is-exact-state_0 fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | primitiveTagBits)); - } else if ((state_0 & 0b111111111) == 0b11000/* is-exact-state_0 fromLong(long)&&fromBigNumber(SLBigNumber) */) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | primitiveTagBits)); - } else { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromBigNumber($child0Value_); - } - } - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000 /* add-state_0 fromFunction(SLFunction) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if (SLTypes.isSLNull($child0Value)) { - SLNull $child0Value_ = SLTypes.asSLNull($child0Value); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1000000 /* add-state_0 fromFunction(SLNull) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromFunction($child0Value_); - } - if ((exclude) == 0 /* is-not-exclude fromForeign(Object, InteropLibrary) */) { - int count7_ = 0; - SLUnbox_FromForeign0Data s7_ = ((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1)); - if ((state_0 & 0b10000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) */) { - while (s7_ != null) { - if ((s7_.interop_.accepts($child0Value))) { - break; - } - s7_ = s7_.next_; - count7_++; - } - } - if (s7_ == null) { - // assert (s7_.interop_.accepts($child0Value)); - if (count7_ < (SLUnboxNode.LIMIT)) { - s7_ = $this.insertAccessor(new SLUnbox_FromForeign0Data(((SLUnbox_FromForeign0Data) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1)))); - s7_.interop_ = s7_.insertAccessor((INTEROP_LIBRARY_.create($child0Value))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 1] = s7_; - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - } - } - if (s7_ != null) { - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, s7_.interop_); - } - } - { - InteropLibrary fromForeign1_interop__ = null; - { - EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); - Node prev_ = encapsulating_.set($this); - try { - fromForeign1_interop__ = (INTEROP_LIBRARY_.getUncached($child0Value)); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude fromForeign(Object, InteropLibrary) */); - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_CHILDREN_OFFSET) + 0) + 1] = null; - state_0 = (short) (state_0 & 0xffffff7f /* remove-state_0 fromForeign(Object, InteropLibrary) */); - $bc[$bci + C_SL_UNBOX_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100000000 /* add-state_0 fromForeign(Object, InteropLibrary) */); - short primitiveTagBits = (short) (unsafeFromBytecode($bc, $bci) & 7 & 0xe000); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | primitiveTagBits)); - lock.unlock(); - hasLock = false; - return SLUnboxNode.fromForeign($child0Value, fromForeign1_interop__); - } finally { - encapsulating_.set(prev_); - } - } - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLFunctionLiteral_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - if (state_0 != 0 /* is-state_0 perform(TruffleString, SLFunction, Node) */ && $child0Value_ instanceof TruffleString) { - TruffleString $child0Value__ = (TruffleString) $child0Value_; - { - Node node__ = ($this); - SLFunction result__ = ((SLFunction) UFA.unsafeObjectArrayRead($consts, (constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0)); - if (result__ != null) { - return SLFunctionLiteralNode.perform($child0Value__, result__, node__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLFunctionLiteral_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static SLFunction SLFunctionLiteral_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0); - { - Node node__ = null; - if ($child0Value instanceof TruffleString) { - TruffleString $child0Value_ = (TruffleString) $child0Value; - $consts[(constArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET) + 0) + 0] = (SLFunctionLiteralNode.lookupFunctionCached($child0Value_, $this)); - node__ = ($this); - $bc[$bci + C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 perform(TruffleString, SLFunction, Node) */); - lock.unlock(); - hasLock = false; - return SLFunctionLiteralNode.perform($child0Value_, ((SLFunction) UFA.unsafeObjectArrayRead($consts, constArrayOffset_ + 0)), node__); - } - } - throw new UnsupportedSpecializationException($this, new Node[] {null}, $child0Value); - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLToBoolean_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static Object SLToBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLToBoolean_SLToBoolean_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static Object SLToBoolean_SLToBoolean_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLToBoolean_SLToBoolean_executeBoolean__boolean2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLToBoolean_SLToBoolean_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__boolean2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLToBoolean_SLToBoolean_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLToBoolean_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLToBoolean_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLToBoolean_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + C_SL_TO_BOOLEAN_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - @ExplodeLoop - private static Object SLInvoke_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1 - $numVariadics, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_INVOKE_POP_INDEXED_OFFSET + 0) & 0xff)); - Object[] $variadicChildValue_ = do_loadVariadicArguments($frame, $sp, $numVariadics); - if (state_0 != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) || doInterop(Object, Object[], InteropLibrary, Node, int) */) { - if ((state_0 & 0b11) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) || doIndirect(SLFunction, Object[], IndirectCallNode) */ && $child0Value_ instanceof SLFunction) { - SLFunction $child0Value__ = (SLFunction) $child0Value_; - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (s0_ != null) { - if (!Assumption.isValidAssumption((s0_.callTargetStable_))) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - SLInvoke_removeDirect__($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, s0_); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value__, $variadicChildValue_); - } - if (($child0Value__.getCallTarget() == s0_.cachedTarget_)) { - return SLInvoke.doDirect($child0Value__, $variadicChildValue_, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - s0_ = s0_.next_; - } - } - if ((state_0 & 0b10) != 0 /* is-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */) { - IndirectCallNode indirect_callNode__ = ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1)); - if (indirect_callNode__ != null) { - return SLInvoke.doIndirect($child0Value__, $variadicChildValue_, indirect_callNode__); - } - } - } - if ((state_0 & 0b100) != 0 /* is-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */) { - { - Node interop_node__ = ($this); - int interop_bci__ = ($bci); - InteropLibrary interop_library__ = ((InteropLibrary) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2)); - if (interop_library__ != null) { - return SLInvoke.doInterop($child0Value_, $variadicChildValue_, interop_library__, interop_node__, interop_bci__); - } - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLInvoke_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, $child0Value_, $variadicChildValue_); - } - - private static Object SLInvoke_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object $child0Value, Object[] $variadicChildValue) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0); - short exclude = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1); - if ($child0Value instanceof SLFunction) { - SLFunction $child0Value_ = (SLFunction) $child0Value; - if ((exclude) == 0 /* is-not-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - int count0_ = 0; - SLInvoke_DirectData s0_ = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - if ((state_0 & 0b1) != 0 /* is-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */) { - while (s0_ != null) { - if (($child0Value_.getCallTarget() == s0_.cachedTarget_) && Assumption.isValidAssumption((s0_.callTargetStable_))) { - break; - } - s0_ = s0_.next_; - count0_++; - } - } - if (s0_ == null) { - { - RootCallTarget cachedTarget__ = ($child0Value_.getCallTarget()); - if (($child0Value_.getCallTarget() == cachedTarget__)) { - Assumption callTargetStable__ = ($child0Value_.getCallTargetStable()); - Assumption assumption0 = (callTargetStable__); - if (Assumption.isValidAssumption(assumption0)) { - if (count0_ < (3)) { - s0_ = $this.insertAccessor(new SLInvoke_DirectData(((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 0)))); - s0_.callTargetStable_ = callTargetStable__; - s0_.cachedTarget_ = cachedTarget__; - s0_.callNode_ = s0_.insertAccessor((DirectCallNode.create(cachedTarget__))); - VarHandle.storeStoreFence(); - $children[childArrayOffset_ + 0] = s0_; - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } - } - } - } - if (s0_ != null) { - lock.unlock(); - hasLock = false; - return SLInvoke.doDirect($child0Value_, $variadicChildValue, s0_.callTargetStable_, s0_.cachedTarget_, s0_.callNode_); - } - } - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 1] = $this.insertAccessor((IndirectCallNode.create())); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 1] = exclude = (short) (exclude | 0b1 /* add-exclude doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $children[childArrayOffset_ + 0] = null; - state_0 = (short) (state_0 & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doIndirect(SLFunction, Object[], IndirectCallNode) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doIndirect($child0Value_, $variadicChildValue, ((IndirectCallNode) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 1))); - } - { - int interop_bci__ = 0; - Node interop_node__ = null; - $children[(childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 2] = $this.insertAccessor((INTEROP_LIBRARY_.createDispatched(3))); - interop_node__ = ($this); - interop_bci__ = ($bci); - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b100 /* add-state_0 doInterop(Object, Object[], InteropLibrary, Node, int) */); - lock.unlock(); - hasLock = false; - return SLInvoke.doInterop($child0Value, $variadicChildValue, ((InteropLibrary) UFA.unsafeObjectArrayRead($children, childArrayOffset_ + 2)), interop_node__, interop_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static void SLInvoke_removeDirect__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics, Object s0_) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - lock.lock(); - try { - SLInvoke_DirectData prev = null; - SLInvoke_DirectData cur = ((SLInvoke_DirectData) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_CHILDREN_OFFSET) + 0) + 0)); - while (cur != null) { - if (cur == s0_) { - if (prev == null) { - $children[childArrayOffset_ + 0] = $this.insertAccessor(cur.next_); - } else { - prev.next_ = prev.insertAccessor(cur.next_); - } - break; - } - prev = cur; - cur = cur.next_; - } - if ($children[childArrayOffset_ + 0] == null) { - $bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] = (short) ($bc[$bci + C_SL_INVOKE_STATE_BITS_OFFSET + 0] & 0xfffffffe /* remove-state_0 doDirect(SLFunction, Object[], Assumption, RootCallTarget, DirectCallNode) */); - } - } finally { - lock.unlock(); - } - } - - private static boolean SLAnd_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLAnd_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLAnd_SLAnd_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLAnd_SLAnd_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLAnd_SLAnd_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLAnd_SLAnd_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_AND_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLAnd_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLAnd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLAnd_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_AND_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_AND_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static boolean SLOr_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value) { - if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBoolean(boolean) */ && $child0Value instanceof Boolean) { - return false; - } - return true; - } - - private static boolean SLOr_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10) == 0 /* only-active doBoolean(boolean) */ && (state_0 != 0 /* is-not doBoolean(boolean) && doFallback(Object, Node, int) */)) { - return SLOr_SLOr_execute__boolean0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLOr_SLOr_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLOr_SLOr_execute__boolean0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */; - return SLToBooleanNode.doBoolean($child0Value_); - } - - private static boolean SLOr_SLOr_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + SC_SL_OR_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1) != 0 /* is-state_0 doBoolean(boolean) */ && $child0Value_ instanceof Boolean) { - boolean $child0Value__ = (boolean) $child0Value_; - return SLToBooleanNode.doBoolean($child0Value__); - } - if ((state_0 & 0b10) != 0 /* is-state_0 doFallback(Object, Node, int) */) { - { - Node fallback_node__ = ($this); - int fallback_bci__ = ($bci); - if (SLOr_fallbackGuard__($frame, $this, $bc, $bci, $sp, $consts, $children, state_0, $child0Value_)) { - return SLToBooleanNode.doFallback($child0Value_, fallback_node__, fallback_bci__); - } - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - return SLOr_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLOr_executeAndSpecialize_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, Object $child0Value) { - int childArrayOffset_; - int constArrayOffset_; - Lock lock = $this.getLockAccessor(); - boolean hasLock = true; - lock.lock(); - try { - short state_0 = unsafeFromBytecode($bc, $bci + SC_SL_OR_STATE_BITS_OFFSET + 0); - if ($child0Value instanceof Boolean) { - boolean $child0Value_ = (boolean) $child0Value; - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b1 /* add-state_0 doBoolean(boolean) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doBoolean($child0Value_); - } - { - int fallback_bci__ = 0; - Node fallback_node__ = null; - fallback_node__ = ($this); - fallback_bci__ = ($bci); - $bc[$bci + SC_SL_OR_STATE_BITS_OFFSET + 0] = state_0 = (short) (state_0 | 0b10 /* add-state_0 doFallback(Object, Node, int) */); - lock.unlock(); - hasLock = false; - return SLToBooleanNode.doFallback($child0Value, fallback_node__, fallback_bci__); - } - } finally { - if (hasLock) { - lock.unlock(); - } - } - } - - private static Object SLUnbox_q_FromBigNumber_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET + 0) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__long0_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_execute__generic1_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLUnboxNode.fromBigNumber($child0Value__); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__long2_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static boolean SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeBoolean__generic3_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value__)); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectBoolean(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - int childArrayOffset_; - int constArrayOffset_; - if ((state_0 & 0b10000) == 0 /* only-active fromLong(long) */ && ((state_0 & 0b11000) != 0 /* is-not fromLong(long) && fromBigNumber(SLBigNumber) */)) { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } else { - return SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_($frame, $this, $bc, $bci, $sp, $consts, $children, state_0); - } - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__long4_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static long SLUnbox_q_FromBigNumber_FromLong_SLUnbox_q_FromBigNumber_FromLong_executeLong__generic5_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0) throws UnexpectedResultException { - int childArrayOffset_; - int constArrayOffset_; - Object $child0Value_ = expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - if ((state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */ && $child0Value_ instanceof Long) { - long $child0Value__ = (long) $child0Value_; - return SLUnboxNode.fromLong($child0Value__); - } - if ((state_0 & 0b10000) != 0 /* is-state_0 fromBigNumber(SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000000) >>> 9 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - return SLTypesGen.expectLong(SLUnboxNode.fromBigNumber($child0Value__)); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_)); - } - - private static Object SLUnbox_q_FromLong_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static boolean SLUnbox_q_FromLong_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLTypesGen.expectBoolean(SLUnboxNode.fromLong($child0Value_)); - } - - private static long SLUnbox_q_FromLong_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - long $child0Value_; - try { - $child0Value_ = expectLong($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b1000) != 0 /* is-state_0 fromLong(long) */; - return SLUnboxNode.fromLong($child0Value_); - } - - private static Object SLUnbox_q_FromBoolean_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult()); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static boolean SLUnbox_q_FromBoolean_executeBoolean_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectBoolean(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectBoolean(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLUnboxNode.fromBoolean($child0Value_); - } - - private static long SLUnbox_q_FromBoolean_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b110000000) != 0 /* is-state_0 fromForeign(Object, InteropLibrary) || fromForeign(Object, InteropLibrary) */) { - return SLTypesGen.expectLong(SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - boolean $child0Value_; - try { - $child0Value_ = expectBoolean($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET + 0) & 0xff)); - } catch (UnexpectedResultException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - return SLTypesGen.expectLong(SLUnbox_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, ex.getResult())); - } - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 fromBoolean(boolean) */; - return SLTypesGen.expectLong(SLUnboxNode.fromBoolean($child0Value_)); - } - - private static boolean SLAdd_q_Add0_fallbackGuard__(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, short state_0, Object $child0Value, Object $child1Value) { - if (SLTypesGen.isImplicitSLBigNumber($child0Value) && SLTypesGen.isImplicitSLBigNumber($child1Value)) { - return false; - } - if (((state_0 & 0b100)) == 0 /* is-not-state_0 add(Object, Object, SLToTruffleStringNode, SLToTruffleStringNode, ConcatNode) */ && (SLAddNode.isString($child0Value, $child1Value))) { - return false; - } - return true; - } - - private static Object SLAdd_q_Add0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLAddNode.add($child0Value__, $child1Value__); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - private static long SLAdd_q_Add0_executeLong_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) throws UnexpectedResultException { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET + 0); - if ((state_0 & 0b1000) != 0 /* is-state_0 typeError(Object, Object, Node, int) */) { - return SLTypesGen.expectLong(SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b10) != 0 /* is-state_0 add(SLBigNumber, SLBigNumber) */; - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_)) { - SLBigNumber $child0Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b110000) >>> 4 /* extract-implicit-state_0 0:SLBigNumber */, $child0Value_); - if (SLTypesGen.isImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_)) { - SLBigNumber $child1Value__ = SLTypesGen.asImplicitSLBigNumber((state_0 & 0b11000000) >>> 6 /* extract-implicit-state_0 1:SLBigNumber */, $child1Value_); - return SLTypesGen.expectLong(SLAddNode.add($child0Value__, $child1Value__)); - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - return SLTypesGen.expectLong(SLAdd_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_)); - } - - @ExplodeLoop - private static Object SLReadProperty_q_ReadSLObject0_execute_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - short state_0 = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET + 0); - Object $child0Value_ = expectObject($frame, $sp - 2, $bc, $bci, (unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) & 0xff)); - Object $child1Value_ = expectObject($frame, $sp - 1, $bc, $bci, ((unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET + 0) >> 8) & 0xff)); - int childArrayOffset_; - int constArrayOffset_; - assert (state_0 & 0b100) != 0 /* is-state_0 readSLObject(SLObject, Object, Node, int, DynamicObjectLibrary, SLToTruffleStringNode) */; - if ($child0Value_ instanceof SLObject) { - SLObject $child0Value__ = (SLObject) $child0Value_; - SLReadProperty_ReadSLObject0Data s2_ = ((SLReadProperty_ReadSLObject0Data) UFA.unsafeObjectArrayRead($children, (childArrayOffset_ = unsafeFromBytecode($bc, $bci + C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET) + 0) + 4)); - while (s2_ != null) { - if ((s2_.objectLibrary_.accepts($child0Value__))) { - Node node__ = ($this); - int bci__ = ($bci); - return SLReadPropertyNode.readSLObject($child0Value__, $child1Value_, node__, bci__, s2_.objectLibrary_, s2_.toTruffleStringNode_); - } - s2_ = s2_.next_; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); - return SLReadProperty_executeAndSpecialize_($frame, $this, $bc, $bci, $sp, $consts, $children, $child0Value_, $child1Value_); - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_1_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // pop - // Simple Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_POP << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_2_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // load.constant - // Constants: - // [ 0] constant - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_CONSTANT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - return $sp; - } - // load.argument - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_ARGUMENT << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - return $sp; - } - // load.local - // Locals: - // [ 0] local - // Split on Boxing Elimination - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL << 3) | 0 /* OBJECT */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.boxed - // Locals: - // [ 0] local - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 0 /* OBJECT */) : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - case ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - return $sp; - } - // load.local.mat - // Simple Pops: - // [ 0] frame - // Always Boxed - // Pushed Values: 1 - case ((INSTR_LOAD_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 1); - UFA.unsafeSetObject($frame, $sp - 1, outerFrame.getObject(unsafeFromBytecode($bc, $bci + LOAD_LOCAL_MAT_ARGUMENT_OFFSET + 0))); - return $sp; - } - // store.local.mat - // Simple Pops: - // [ 0] frame - // [ 1] value - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL_MAT << 3) | 0) : - { - Frame outerFrame; - outerFrame = (Frame) UFA.unsafeGetObject($frame, $sp - 2); - outerFrame.setObject(unsafeFromBytecode($bc, $bci + STORE_LOCAL_MAT_ARGUMENT_OFFSET + 0), UFA.unsafeGetObject($frame, $sp - 1)); - $sp -= 2; - return $sp; - } - // instrument.enter - // Pushed Values: 0 - case ((INSTR_INSTRUMENT_ENTER << 3) | 0) : - { - ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_ENTER_INSTRUMENT_OFFSET) + 0); - if (probe != null) { - probe.onEnter($frame); - } - return $sp; - } - // instrument.exit.void - // Pushed Values: 0 - case ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0) : - { - ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_VOID_INSTRUMENT_OFFSET) + 0); - if (probe != null) { - probe.onReturnValue($frame, null); - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_3_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // store.local - // Locals: - // [ 0] target - // Indexed Pops: - // [ 0] value - // Split on Boxing Elimination - // Pushed Values: 0 - case ((INSTR_STORE_LOCAL << 3) | 0 /* OBJECT */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - case ((INSTR_STORE_LOCAL << 3) | 7) : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - return $sp; - } - // instrument.exit - // Indexed Pops: - // [ 0] value - // Pushed Values: 0 - case ((INSTR_INSTRUMENT_EXIT << 3) | 0) : - { - ProbeNode probe = getProbeNodeImpl($this, unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_INSTRUMENT_OFFSET) + 0); - if (probe != null) { - probe.onReturnValue($frame, expectObject($frame, $sp - 1, $bc, $bci, (unsafeFromBytecode($bc, $bci + INSTRUMENT_EXIT_POP_INDEXED_OFFSET + 0) & 0xff))); - } - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_5_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLEqual - // Children: - // [ 0] CacheExpression [sourceParameter = equalNode] - // [ 1] SpecializationData [id = Generic0] - // [ 2] CacheExpression [sourceParameter = leftInterop] - // [ 3] CacheExpression [sourceParameter = rightInterop] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Long], SpecializationData [id = BigNumber], SpecializationData [id = Boolean], SpecializationData [id = String], SpecializationData [id = TruffleString], SpecializationData [id = Null], SpecializationData [id = Function], SpecializationData [id = Generic0], SpecializationData [id = Generic1]] - case ((INSTR_C_SL_EQUAL << 3) | 0 /* OBJECT */) : - { - SLEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_EQUAL << 3) | 5 /* BOOLEAN */) : - { - SLEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessOrEqual - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessOrEqual0], SpecializationData [id = LessOrEqual1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0 /* OBJECT */) : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 5 /* BOOLEAN */) : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLessThan - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = LessThan0], SpecializationData [id = LessThan1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - case ((INSTR_C_SL_LESS_THAN << 3) | 0 /* OBJECT */) : - { - SLLessThan_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_LESS_THAN << 3) | 5 /* BOOLEAN */) : - { - SLLessThan_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLLogicalNot - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 0 /* OBJECT */) : - { - SLLogicalNot_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_LOGICAL_NOT << 3) | 5 /* BOOLEAN */) : - { - SLLogicalNot_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLFunctionLiteral - // Constants: - // [ 0] CacheExpression [sourceParameter = result] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Perform]] - case ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0) : - { - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLToBoolean - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Boolean], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLToBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_TO_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - SLToBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBigNumber.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromLong - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromLong_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromLong_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_LONG << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromLong_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - // c.SLUnbox.q.FromBoolean - // Children: - // [ 0] CacheExpression [sourceParameter = fromJavaStringNode] - // [ 1] SpecializationData [id = FromForeign0] - // [ 2] CacheExpression [sourceParameter = interop] - // Indexed Pops: - // [ 0] arg0 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = FromString], SpecializationData [id = FromTruffleString], SpecializationData [id = FromBoolean], SpecializationData [id = FromLong], SpecializationData [id = FromBigNumber], SpecializationData [id = FromFunction0], SpecializationData [id = FromFunction1], SpecializationData [id = FromForeign0], SpecializationData [id = FromForeign1]] - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 0 /* OBJECT */) : - { - SLUnbox_q_FromBoolean_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 5 /* BOOLEAN */) : - { - SLUnbox_q_FromBoolean_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - case ((INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN << 3) | 1 /* LONG */) : - { - SLUnbox_q_FromBoolean_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_6_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLAdd - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD << 3) | 0 /* OBJECT */) : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD << 3) | 1 /* LONG */) : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLDiv - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = DivLong], SpecializationData [id = Div], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_DIV << 3) | 0 /* OBJECT */) : - { - SLDiv_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_DIV << 3) | 1 /* LONG */) : - { - SLDiv_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLMul - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = MulLong], SpecializationData [id = Mul], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_MUL << 3) | 0 /* OBJECT */) : - { - SLMul_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_MUL << 3) | 1 /* LONG */) : - { - SLMul_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLSub - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = SubLong], SpecializationData [id = Sub], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_SUB << 3) | 0 /* OBJECT */) : - { - SLSub_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_SUB << 3) | 1 /* LONG */) : - { - SLSub_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLAdd.q.Add0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Add1] - // [ 1] CacheExpression [sourceParameter = node] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Split on Boxing Elimination - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback], com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d74f, com.oracle.truffle.dsl.processor.parser.SpecializationGroup$TypeGuard@7d04d76e] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = AddLong], SpecializationData [id = Add0], SpecializationData [id = Add1], SpecializationData [id = Fallback]] - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 0 /* OBJECT */) : - { - SLAdd_q_Add0_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - case ((INSTR_C_SL_ADD_Q_ADD0 << 3) | 1 /* LONG */) : - { - SLAdd_q_Add0_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - // c.SLReadProperty.q.ReadSLObject0 - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // [ 2] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = ReadArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = ReadSLObject0] - // [ 5] CacheExpression [sourceParameter = node] - // [ 6] CacheExpression [sourceParameter = objectLibrary] - // [ 7] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 8] SpecializationData [id = ReadObject0] - // [ 9] CacheExpression [sourceParameter = node] - // [10] CacheExpression [sourceParameter = objects] - // [11] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = ReadArray0], SpecializationData [id = ReadArray1], SpecializationData [id = ReadSLObject0], SpecializationData [id = ReadSLObject1], SpecializationData [id = ReadObject0], SpecializationData [id = ReadObject1]] - case ((INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 << 3) | 0) : - { - SLReadProperty_q_ReadSLObject0_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_7_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // c.SLWriteProperty - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // [ 1] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = WriteArray0] - // [ 1] CacheExpression [sourceParameter = node] - // [ 2] CacheExpression [sourceParameter = arrays] - // [ 3] CacheExpression [sourceParameter = numbers] - // [ 4] SpecializationData [id = WriteSLObject0] - // [ 5] CacheExpression [sourceParameter = objectLibrary] - // [ 6] CacheExpression [sourceParameter = toTruffleStringNode] - // [ 7] SpecializationData [id = WriteObject0] - // [ 8] CacheExpression [sourceParameter = node] - // [ 9] CacheExpression [sourceParameter = objectLibrary] - // [10] CacheExpression [sourceParameter = asMember] - // Indexed Pops: - // [ 0] arg0 - // [ 1] arg1 - // [ 2] arg2 - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = WriteArray0], SpecializationData [id = WriteArray1], SpecializationData [id = WriteSLObject0], SpecializationData [id = WriteSLObject1], SpecializationData [id = WriteObject0], SpecializationData [id = WriteObject1]] - case ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0) : - { - SLWriteProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -2; - return $sp; - } - // c.SLInvoke - // Constants: - // [ 0] CacheExpression [sourceParameter = bci] - // Children: - // [ 0] SpecializationData [id = Direct] - // [ 1] CacheExpression [sourceParameter = callNode] - // [ 2] CacheExpression [sourceParameter = library] - // [ 3] CacheExpression [sourceParameter = node] - // [ 4] NodeExecutionData[child=NodeFieldData[name=$variadicChild, kind=ONE, node=NodeData[C]], name=$variadicChild, index=1] - // Indexed Pops: - // [ 0] arg0 - // Variadic - // Always Boxed - // Pushed Values: 1 - // State Bitsets: - // [ 0] StateBitSet state_0 [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - // [ 1] ExcludeBitSet exclude [SpecializationData [id = Direct], SpecializationData [id = Indirect], SpecializationData [id = Interop]] - case ((INSTR_C_SL_INVOKE << 3) | 0) : - { - int numVariadics = unsafeFromBytecode($bc, $bci + C_SL_INVOKE_VARIADIC_OFFSET + 0); - SLInvoke_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children, numVariadics); - $sp += - numVariadics; - return $sp; - } - // si.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_14_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_15_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLFunctionLiteral_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $bci = $bci + C_SL_FUNCTION_LITERAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_19_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_22_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_23_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_24_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_25_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_26_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - $sp = $sp - 1; - $frame.clear($sp); - $bci = $bci + POP_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_27_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_28_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_30_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, $frame.getArguments()[unsafeFromBytecode($bc, $bci + LOAD_ARGUMENT_ARGUMENT_OFFSET + 0)]); - $sp = $sp + 1; - $bci = $bci + LOAD_ARGUMENT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - case 7 /* generic */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + STORE_LOCAL_LOCALS_OFFSET + 0); - do_storeLocal_null($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp--; - break; - } - } - $bci = $bci + STORE_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - // si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_32_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - CompilerDirectives.transferToInterpreterAndInvalidate(); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_BOXED_LOCALS_OFFSET + 0); - do_loadLocalBoxed_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_BOXED_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLLessOrEqual_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 5 /* BOOLEAN */ : - { - SLLessOrEqual_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_LESS_OR_EQUAL_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_33_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0 /* OBJECT */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 5 /* BOOLEAN */) : - case ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 1 /* LONG */) : - { - short primitiveTag = (short) ((curOpcode >> 13) & 0x0007); - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_34_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd - // Pushed Values: 0 - case ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0) : - { - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @BytecodeInterpreterSwitch - private static int instructionGroup_37_0(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, int[] $conditionProfiles, int curOpcode) { - int $bci = $startBci; - int $sp = $startSp; - switch (curOpcode) { - // si.c.SLReadProperty.c.SLUnbox.load.local.load.constant.c.SLReadProperty.c.SLUnbox.c.SLAdd.c.SLUnbox - // Pushed Values: 0 - case ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0) : - { - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_OBJECT($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 5 /* BOOLEAN */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_BOOLEAN($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - case 1 /* LONG */ : - { - int localIdx = unsafeFromBytecode($bc, $bci + LOAD_LOCAL_LOCALS_OFFSET + 0); - do_loadLocal_LONG($this, $frame, $bc, $bci, $sp, $localTags, localIdx); - $sp++; - break; - } - } - $bci = $bci + LOAD_LOCAL_LENGTH; - UFA.unsafeSetObject($frame, $sp, UFA.unsafeObjectArrayRead($consts, unsafeFromBytecode($bc, $bci + LOAD_CONSTANT_CONSTANT_OFFSET) + 0)); - $sp = $sp + 1; - $bci = $bci + LOAD_CONSTANT_LENGTH; - SLReadProperty_entryPoint_($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - $bci = $bci + C_SL_READ_PROPERTY_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLAdd_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - case 1 /* LONG */ : - { - SLAdd_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - $sp += -1; - break; - } - } - $bci = $bci + C_SL_ADD_LENGTH; - switch (unsafeFromBytecode($bc, $bci) & 7) { - case 0 /* OBJECT */ : - { - SLUnbox_entryPoint_OBJECT($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 5 /* BOOLEAN */ : - { - SLUnbox_entryPoint_BOOLEAN($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - case 1 /* LONG */ : - { - SLUnbox_entryPoint_LONG($frame, $this, $bc, $bci, $sp, $consts, $children); - break; - } - } - $bci = $bci + C_SL_UNBOX_LENGTH; - return $sp; - } - default : - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static boolean isAdoptable() { - return true; - } - - private static final class SLAdd_Add1Data extends Node { - - @Child SLToTruffleStringNode toTruffleStringNodeLeft_; - @Child SLToTruffleStringNode toTruffleStringNodeRight_; - @Child ConcatNode concatNode_; - - SLAdd_Add1Data() { - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLEqual_Generic0Data extends Node { - - @Child SLEqual_Generic0Data next_; - @Child InteropLibrary leftInterop_; - @Child InteropLibrary rightInterop_; - - SLEqual_Generic0Data(SLEqual_Generic0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadArray0Data extends Node { - - @Child SLReadProperty_ReadArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLReadProperty_ReadArray0Data(SLReadProperty_ReadArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadSLObject0Data extends Node { - - @Child SLReadProperty_ReadSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLReadProperty_ReadSLObject0Data(SLReadProperty_ReadSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLReadProperty_ReadObject0Data extends Node { - - @Child SLReadProperty_ReadObject0Data next_; - @Child InteropLibrary objects_; - @Child SLToMemberNode asMember_; - - SLReadProperty_ReadObject0Data(SLReadProperty_ReadObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteArray0Data extends Node { - - @Child SLWriteProperty_WriteArray0Data next_; - @Child InteropLibrary arrays_; - @Child InteropLibrary numbers_; - - SLWriteProperty_WriteArray0Data(SLWriteProperty_WriteArray0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteSLObject0Data extends Node { - - @Child SLWriteProperty_WriteSLObject0Data next_; - @Child DynamicObjectLibrary objectLibrary_; - @Child SLToTruffleStringNode toTruffleStringNode_; - - SLWriteProperty_WriteSLObject0Data(SLWriteProperty_WriteSLObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLWriteProperty_WriteObject0Data extends Node { - - @Child SLWriteProperty_WriteObject0Data next_; - @Child InteropLibrary objectLibrary_; - @Child SLToMemberNode asMember_; - - SLWriteProperty_WriteObject0Data(SLWriteProperty_WriteObject0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - private static final class SLUnbox_FromForeign0Data extends Node { - - @Child SLUnbox_FromForeign0Data next_; - @Child InteropLibrary interop_; - - SLUnbox_FromForeign0Data(SLUnbox_FromForeign0Data next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SLInvoke_DirectData extends Node { - - @Child SLInvoke_DirectData next_; - @CompilationFinal Assumption callTargetStable_; - @CompilationFinal RootCallTarget cachedTarget_; - @Child DirectCallNode callNode_; - - SLInvoke_DirectData(SLInvoke_DirectData next_) { - this.next_ = next_; - } - - @Override - public NodeCost getCost() { - return NodeCost.NONE; - } - - T insertAccessor(T node) { - return super.insert(node); - } - - } - } - private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); - private static final BytecodeLoopBase UNCOMMON_EXECUTE = new BytecodeNode(); - private static final BytecodeLoopBase COMMON_EXECUTE = UNCOMMON_EXECUTE; - private static final BytecodeLoopBase UNCACHED_EXECUTE = new UncachedBytecodeNode(); - private static final BytecodeLoopBase INITIAL_EXECUTE = UNCACHED_EXECUTE; - private static final short INSTR_POP = 1; - private static final int POP_LENGTH = 1; - private static final short INSTR_BRANCH = 2; - private static final int BRANCH_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_LENGTH = 2; - private static final short INSTR_BRANCH_FALSE = 3; - private static final int BRANCH_FALSE_BRANCH_TARGET_OFFSET = 1; - private static final int BRANCH_FALSE_BRANCH_PROFILE_OFFSET = 2; - private static final int BRANCH_FALSE_LENGTH = 3; - private static final short INSTR_THROW = 4; - private static final int THROW_LOCALS_OFFSET = 1; - private static final int THROW_LENGTH = 2; - private static final short INSTR_LOAD_CONSTANT = 5; - private static final int LOAD_CONSTANT_CONSTANT_OFFSET = 1; - private static final int LOAD_CONSTANT_LENGTH = 2; - private static final short INSTR_LOAD_ARGUMENT = 6; - private static final int LOAD_ARGUMENT_ARGUMENT_OFFSET = 1; - private static final int LOAD_ARGUMENT_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL = 7; - private static final int LOAD_LOCAL_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_LENGTH = 2; - private static final short INSTR_LOAD_LOCAL_BOXED = 8; - private static final int LOAD_LOCAL_BOXED_LOCALS_OFFSET = 1; - private static final int LOAD_LOCAL_BOXED_LENGTH = 2; - private static final short INSTR_STORE_LOCAL = 9; - private static final int STORE_LOCAL_LOCALS_OFFSET = 1; - private static final int STORE_LOCAL_POP_INDEXED_OFFSET = 2; - private static final int STORE_LOCAL_LENGTH = 3; - private static final short INSTR_RETURN = 10; - private static final int RETURN_LENGTH = 1; - private static final short INSTR_LOAD_LOCAL_MAT = 11; - private static final int LOAD_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int LOAD_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_STORE_LOCAL_MAT = 12; - private static final int STORE_LOCAL_MAT_ARGUMENT_OFFSET = 1; - private static final int STORE_LOCAL_MAT_LENGTH = 2; - private static final short INSTR_INSTRUMENT_ENTER = 13; - private static final int INSTRUMENT_ENTER_INSTRUMENT_OFFSET = 1; - private static final int INSTRUMENT_ENTER_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT_VOID = 14; - private static final int INSTRUMENT_EXIT_VOID_INSTRUMENT_OFFSET = 1; - private static final int INSTRUMENT_EXIT_VOID_LENGTH = 2; - private static final short INSTR_INSTRUMENT_EXIT = 15; - private static final int INSTRUMENT_EXIT_POP_INDEXED_OFFSET = 1; - private static final int INSTRUMENT_EXIT_INSTRUMENT_OFFSET = 2; - private static final int INSTRUMENT_EXIT_LENGTH = 3; - private static final short INSTR_INSTRUMENT_LEAVE = 16; - private static final int INSTRUMENT_LEAVE_BRANCH_TARGET_OFFSET = 1; - private static final int INSTRUMENT_LEAVE_INSTRUMENT_OFFSET = 3; - private static final int INSTRUMENT_LEAVE_LENGTH = 4; - private static final short INSTR_C_SL_ADD = 17; - private static final int C_SL_ADD_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_LENGTH = 6; - private static final short INSTR_C_SL_DIV = 18; - private static final int C_SL_DIV_CONSTANT_OFFSET = 1; - private static final int C_SL_DIV_CHILDREN_OFFSET = 2; - private static final int C_SL_DIV_POP_INDEXED_OFFSET = 3; - private static final int C_SL_DIV_STATE_BITS_OFFSET = 4; - private static final int C_SL_DIV_LENGTH = 6; - private static final short INSTR_C_SL_EQUAL = 19; - private static final int C_SL_EQUAL_CHILDREN_OFFSET = 1; - private static final int C_SL_EQUAL_POP_INDEXED_OFFSET = 2; - private static final int C_SL_EQUAL_STATE_BITS_OFFSET = 3; - private static final int C_SL_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_OR_EQUAL = 20; - private static final int C_SL_LESS_OR_EQUAL_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_OR_EQUAL_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_OR_EQUAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_OR_EQUAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_OR_EQUAL_LENGTH = 5; - private static final short INSTR_C_SL_LESS_THAN = 21; - private static final int C_SL_LESS_THAN_CONSTANT_OFFSET = 1; - private static final int C_SL_LESS_THAN_CHILDREN_OFFSET = 2; - private static final int C_SL_LESS_THAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LESS_THAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_LESS_THAN_LENGTH = 5; - private static final short INSTR_C_SL_LOGICAL_NOT = 22; - private static final int C_SL_LOGICAL_NOT_CONSTANT_OFFSET = 1; - private static final int C_SL_LOGICAL_NOT_CHILDREN_OFFSET = 2; - private static final int C_SL_LOGICAL_NOT_POP_INDEXED_OFFSET = 3; - private static final int C_SL_LOGICAL_NOT_STATE_BITS_OFFSET = 4; - private static final int C_SL_LOGICAL_NOT_LENGTH = 5; - private static final short INSTR_C_SL_MUL = 23; - private static final int C_SL_MUL_CONSTANT_OFFSET = 1; - private static final int C_SL_MUL_CHILDREN_OFFSET = 2; - private static final int C_SL_MUL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_MUL_STATE_BITS_OFFSET = 4; - private static final int C_SL_MUL_LENGTH = 6; - private static final short INSTR_C_SL_READ_PROPERTY = 24; - private static final int C_SL_READ_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_LENGTH = 6; - private static final short INSTR_C_SL_SUB = 25; - private static final int C_SL_SUB_CONSTANT_OFFSET = 1; - private static final int C_SL_SUB_CHILDREN_OFFSET = 2; - private static final int C_SL_SUB_POP_INDEXED_OFFSET = 3; - private static final int C_SL_SUB_STATE_BITS_OFFSET = 4; - private static final int C_SL_SUB_LENGTH = 6; - private static final short INSTR_C_SL_WRITE_PROPERTY = 26; - private static final int C_SL_WRITE_PROPERTY_CONSTANT_OFFSET = 1; - private static final int C_SL_WRITE_PROPERTY_CHILDREN_OFFSET = 2; - private static final int C_SL_WRITE_PROPERTY_POP_INDEXED_OFFSET = 3; - private static final int C_SL_WRITE_PROPERTY_STATE_BITS_OFFSET = 5; - private static final int C_SL_WRITE_PROPERTY_LENGTH = 7; - private static final short INSTR_C_SL_UNBOX = 27; - private static final int C_SL_UNBOX_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_LENGTH = 5; - private static final short INSTR_C_SL_FUNCTION_LITERAL = 28; - private static final int C_SL_FUNCTION_LITERAL_CONSTANT_OFFSET = 1; - private static final int C_SL_FUNCTION_LITERAL_CHILDREN_OFFSET = 2; - private static final int C_SL_FUNCTION_LITERAL_POP_INDEXED_OFFSET = 3; - private static final int C_SL_FUNCTION_LITERAL_STATE_BITS_OFFSET = 4; - private static final int C_SL_FUNCTION_LITERAL_LENGTH = 5; - private static final short INSTR_C_SL_TO_BOOLEAN = 29; - private static final int C_SL_TO_BOOLEAN_CONSTANT_OFFSET = 1; - private static final int C_SL_TO_BOOLEAN_CHILDREN_OFFSET = 2; - private static final int C_SL_TO_BOOLEAN_POP_INDEXED_OFFSET = 3; - private static final int C_SL_TO_BOOLEAN_STATE_BITS_OFFSET = 4; - private static final int C_SL_TO_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_INVOKE = 30; - private static final int C_SL_INVOKE_CONSTANT_OFFSET = 1; - private static final int C_SL_INVOKE_CHILDREN_OFFSET = 2; - private static final int C_SL_INVOKE_POP_INDEXED_OFFSET = 3; - private static final int C_SL_INVOKE_VARIADIC_OFFSET = 4; - private static final int C_SL_INVOKE_STATE_BITS_OFFSET = 5; - private static final int C_SL_INVOKE_LENGTH = 7; - private static final short INSTR_SC_SL_AND = 31; - private static final int SC_SL_AND_CONSTANT_OFFSET = 1; - private static final int SC_SL_AND_CHILDREN_OFFSET = 2; - private static final int SC_SL_AND_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_AND_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_AND_STATE_BITS_OFFSET = 5; - private static final int SC_SL_AND_LENGTH = 6; - private static final short INSTR_SC_SL_OR = 32; - private static final int SC_SL_OR_CONSTANT_OFFSET = 1; - private static final int SC_SL_OR_CHILDREN_OFFSET = 2; - private static final int SC_SL_OR_POP_INDEXED_OFFSET = 3; - private static final int SC_SL_OR_BRANCH_TARGET_OFFSET = 4; - private static final int SC_SL_OR_STATE_BITS_OFFSET = 5; - private static final int SC_SL_OR_LENGTH = 6; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER = 33; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG = 34; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BIG_NUMBER_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_LONG = 35; - private static final int C_SL_UNBOX_Q_FROM_LONG_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_LONG_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_LONG_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_LONG_LENGTH = 5; - private static final short INSTR_C_SL_UNBOX_Q_FROM_BOOLEAN = 36; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_CHILDREN_OFFSET = 1; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_POP_INDEXED_OFFSET = 2; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_STATE_BITS_OFFSET = 3; - private static final int C_SL_UNBOX_Q_FROM_BOOLEAN_LENGTH = 5; - private static final short INSTR_C_SL_ADD_Q_ADD0 = 37; - private static final int C_SL_ADD_Q_ADD0_CONSTANT_OFFSET = 1; - private static final int C_SL_ADD_Q_ADD0_CHILDREN_OFFSET = 2; - private static final int C_SL_ADD_Q_ADD0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_ADD_Q_ADD0_STATE_BITS_OFFSET = 4; - private static final int C_SL_ADD_Q_ADD0_LENGTH = 6; - private static final short INSTR_C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0 = 38; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CONSTANT_OFFSET = 1; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_CHILDREN_OFFSET = 2; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_POP_INDEXED_OFFSET = 3; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_STATE_BITS_OFFSET = 4; - private static final int C_SL_READ_PROPERTY_Q_READ_SL_OBJECT0_LENGTH = 6; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX = 39; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 7; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 40; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 25; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX = 41; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 42; - private static final int SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD = 43; - private static final int SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_LENGTH = 28; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 44; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 45; - private static final int SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 22; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 46; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 19; - private static final short INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 47; - private static final int SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 23; - private static final short INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 48; - private static final int SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 24; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX = 49; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 50; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 33; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD = 51; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_LENGTH = 30; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX = 52; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LENGTH = 30; - private static final short INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY = 53; - private static final int SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_LENGTH = 27; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD = 54; - private static final int SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_LENGTH = 34; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT = 55; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_LENGTH = 23; - private static final short INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT = 56; - private static final int SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_LENGTH = 22; - private static final short INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 57; - private static final int SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 37; - private static final short INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 58; - private static final int SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 14; - private static final short INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX = 59; - private static final int SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX_LENGTH = 32; - private static final short INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX = 60; - private static final int SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX_LENGTH = 26; - private static final short INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX = 61; - private static final int SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX_LENGTH = 15; - private static final short INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE = 62; - private static final int SI_C_SL_TO_BOOLEAN_BRANCH_FALSE_LENGTH = 8; - - @CompilationFinal private OperationNodesImpl nodes; - @CompilationFinal(dimensions = 1) private short[] _bc; - @CompilationFinal(dimensions = 1) private Object[] _consts; - @Children private Node[] _children; - @CompilationFinal(dimensions = 1) private byte[] _localTags; - @CompilationFinal(dimensions = 1) private ExceptionHandler[] _handlers; - @CompilationFinal(dimensions = 1) private int[] _conditionProfiles; - @CompilationFinal private int _maxLocals; - @CompilationFinal private int _maxStack; - @CompilationFinal(dimensions = 1) private int[] sourceInfo; - @CompilationFinal private InstrumentRootNode instrumentRoot; - @CompilationFinal(dimensions = 1) private InstrumentTreeNode[] instruments; - @CompilationFinal private BytecodeLoopBase switchImpl = INITIAL_EXECUTE; - @CompilationFinal private int uncachedExecuteCount = 16; - @CompilationFinal private Object _osrMetadata; - private TruffleString _metadata_MethodName; - - private SLOperationRootNodeGen(TruffleLanguage language, FrameDescriptor frameDescriptor) { - super(language, frameDescriptor); - } - - private SLOperationRootNodeGen(TruffleLanguage language, com.oracle.truffle.api.frame.FrameDescriptor.Builder builder) { - this(language, builder.build()); - } - - static { - OperationRootNode.setMetadataAccessor(SLOperationRootNode.MethodName, n -> ((SLOperationRootNodeGen) n)._metadata_MethodName); - } - - @SuppressWarnings("unchecked") - private static RuntimeException sneakyThrow(Throwable e) throws E { //() { - throw (E) e; - } - - private T insertAccessor(T node) { // () { - return insert(node); - } - - private Object executeAt(VirtualFrame frame, int storedLocation) { - int result = storedLocation; - while (true) { - result = switchImpl.continueAt(this, frame, _bc, result & 0xffff, (result >> 16) & 0xffff, _consts, _children, _localTags, _handlers, _conditionProfiles, _maxLocals); - if ((result & 0xffff) == 0xffff) { - break; - } else { - SLOperationRootNodeGen $this = this; - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - } - return frame.getObject((result >> 16) & 0xffff); - } - - @Override - public SourceSection getSourceSection() { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if (sourceInfo[i + 1] >= 0) { - int sourceIndex = sourceInfo[i + 0] >> 16; - int sourceStart = sourceInfo[i + 1]; - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - return null; - } - - @Override - public SourceSection getSourceSectionAtBci(int bci) { - int[] sourceInfo = this.sourceInfo; - if (sourceInfo == null) { - return null; - } - int i; - for (i = 0; i < sourceInfo.length; i += 3) { - if ((sourceInfo[i + 0] & 0xffff) > bci) { - break; - } - } - if (i == 0) { - return null; - } else { - i -= 3; - int sourceIndex = sourceInfo[i + 0] >> 16; - if (sourceIndex < 0) { - return null; - } - int sourceStart = sourceInfo[i + 1]; - if (sourceStart < 0) { - return null; - } - int sourceLength = sourceInfo[i + 2]; - return nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength); - } - } - - @Override - public Object execute(VirtualFrame frame) { - Object returnValue = null; - Throwable throwable = null; - executeProlog(frame); - try { - returnValue = executeAt(frame, _maxLocals << 16); - return returnValue; - } catch (Throwable th) { - throw sneakyThrow(throwable = th); - } finally { - executeEpilog(frame, returnValue, throwable); - } - } - - @Override - public OperationIntrospection getIntrospectionData() { - return switchImpl.getIntrospectionData(_bc, _handlers, _consts, nodes, sourceInfo); - } - - private Lock getLockAccessor() { - return getLock(); - } - - @Override - public Object executeOSR(VirtualFrame osrFrame, int target, Object interpreterState) { - return executeAt(osrFrame, target); - } - - @Override - public Object getOSRMetadata() { - return _osrMetadata; - } - - @Override - public void setOSRMetadata(Object osrMetadata) { - _osrMetadata = osrMetadata; - } - - @Override - public Node deepCopy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = Arrays.copyOf(_bc, _bc.length); - result._consts = Arrays.copyOf(_consts, _consts.length); - result._children = Arrays.copyOf(_children, _children.length); - result._localTags = Arrays.copyOf(_localTags, _localTags.length); - result._handlers = _handlers; - result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length); - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - @Override - public Node copy() { - SLOperationRootNodeGen result = new SLOperationRootNodeGen(getLanguage(), getFrameDescriptor().copy()); - result.nodes = nodes; - result._bc = _bc; - result._consts = _consts; - result._children = _children; - result._localTags = _localTags; - result._handlers = _handlers; - result._conditionProfiles = _conditionProfiles; - result._maxLocals = _maxLocals; - result._maxStack = _maxStack; - result.sourceInfo = sourceInfo; - result._metadata_MethodName = _metadata_MethodName; - return result; - } - - @Override - public InstrumentableNode materializeInstrumentTree(Set> materializedTags) { - nodes.ensureInstrumentationAccessor(); - return instrumentRoot; - } - - private void changeInterpreters(BytecodeLoopBase impl) { - this.switchImpl = impl; - } - - private static void SLToBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLToBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLToBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLToBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void do_loadLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - Object value; - switch (UFA.unsafeGetTag($frame, localIdx)) { - case 0 /* OBJECT */ : - value = UFA.unsafeUncheckedGetObject($frame, localIdx); - break; - case 5 /* BOOLEAN */ : - value = UFA.unsafeUncheckedGetBoolean($frame, localIdx); - break; - case 1 /* LONG */ : - value = UFA.unsafeUncheckedGetLong($frame, localIdx); - break; - default : - throw CompilerDirectives.shouldNotReachHere(); - } - UFA.unsafeSetObject($frame, $sp, value); - return; - } - - private static void do_loadLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, UFA.unsafeGetBoolean($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, UFA.unsafeGetLong($frame, localIdx)); - return; - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocalBoxed_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetBoolean($frame, $sp, (boolean) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Boolean) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 5 /* BOOLEAN */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) result); - UFA.unsafeSetBoolean($frame, $sp, (boolean) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_loadLocalBoxed_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - try { - UFA.unsafeSetLong($frame, $sp, (long) UFA.unsafeGetObject($frame, localIdx)); - return; - } catch (FrameSlotTypeException | ClassCastException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object result = $frame.getValue(localIdx); - if (result instanceof Long) { - if (UFA.unsafeByteArrayRead(localTags, localIdx) == 7) { - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_LOAD_LOCAL_BOXED << 3) | 1 /* LONG */)); - } else { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) result); - UFA.unsafeSetLong($frame, $sp, (long) result); - return; - } - } - } - Object result = $frame.getValue(localIdx); - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7); - UFA.unsafeSetObject($frame, localIdx, result); - UFA.unsafeSetObject($frame, $sp, result); - } - - private static void do_storeLocalSpecialize(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int primitiveTag, int localIdx, int sourceSlot) { - CompilerAsserts.neverPartOfCompilation(); - Object value = $frame.getValue(sourceSlot); - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - int bciOffset = (unsafeFromBytecode($bc, $bci + STORE_LOCAL_POP_INDEXED_OFFSET + 0) & 0xff); - // System.err.printf("primitiveTag=%d value=%s %s curKind=%s tag=%s%n", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot)); - if (bciOffset != 0) { - if ((primitiveTag == 0 || primitiveTag == 5 /* BOOLEAN */) && (curKind == 0 || curKind == 5 /* BOOLEAN */)) { - if (value instanceof Boolean) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 5 /* BOOLEAN */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 5 /* BOOLEAN */)); - doSetResultBoxed($bc, $bci, bciOffset, 5 /* BOOLEAN */); - UFA.unsafeSetBoolean($frame, localIdx, (boolean) value); - return; - } - } - if ((primitiveTag == 0 || primitiveTag == 1 /* LONG */) && (curKind == 0 || curKind == 1 /* LONG */)) { - if (value instanceof Long) { - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 1 /* LONG */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 1 /* LONG */)); - doSetResultBoxed($bc, $bci, bciOffset, 1 /* LONG */); - UFA.unsafeSetLong($frame, localIdx, (long) value); - return; - } - } - doSetResultBoxed($bc, $bci, bciOffset, 0 /* OBJECT */); - } - UFA.unsafeByteArrayWrite(localTags, localIdx, (byte) 7 /* generic */); - unsafeWriteBytecode($bc, $bci, (short) ((INSTR_STORE_LOCAL << 3) | 7 /* generic */)); - UFA.unsafeSetObject($frame, localIdx, value); - } - - private static void do_storeLocal_OBJECT(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 0 /* OBJECT */, localIdx, sourceSlot); - } - - private static void do_storeLocal_BOOLEAN(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 5 /* BOOLEAN */) { - try { - UFA.unsafeSetBoolean($frame, localIdx, UFA.unsafeGetBoolean($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 5 /* BOOLEAN */, localIdx, sourceSlot); - } - - private static void do_storeLocal_LONG(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - if (curKind == 1 /* LONG */) { - try { - UFA.unsafeSetLong($frame, localIdx, UFA.unsafeGetLong($frame, sourceSlot)); - return; - } catch (FrameSlotTypeException ex) { - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - do_storeLocalSpecialize($this, $frame, $bc, $bci, $sp, localTags, 1 /* LONG */, localIdx, sourceSlot); - } - - private static void do_storeLocal_null(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $bci, int $sp, byte[] localTags, int localIdx) { - int sourceSlot = $sp - 1; - byte curKind = UFA.unsafeByteArrayRead(localTags, localIdx); - try { - UFA.unsafeSetObject($frame, localIdx, UFA.unsafeGetObject($frame, sourceSlot)); - } catch (FrameSlotTypeException ex) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - UFA.unsafeSetObject($frame, localIdx, $frame.getValue(sourceSlot)); - } - } - - private static void SLEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessOrEqual_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessOrEqual_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessOrEqual_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLessThan_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLessThan_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLessThan_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLessThan_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLLogicalNot_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLLogicalNot_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLLogicalNot_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLLogicalNot_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLFunctionLiteral_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLFunctionLiteral_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBigNumber_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBigNumber_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromLong_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromLong_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromLong_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLUnbox_q_FromBoolean_entryPoint_BOOLEAN(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetBoolean($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeBoolean_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLUnbox_q_FromBoolean_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLUnbox_q_FromBoolean_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLDiv_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLDiv_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLDiv_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLDiv_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLMul_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLMul_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLMul_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLMul_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLReadProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLSub_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLSub_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLSub_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLSub_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLAdd_q_Add0_entryPoint_OBJECT(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLAdd_q_Add0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } - - private static void SLAdd_q_Add0_entryPoint_LONG(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - try { - UFA.unsafeSetLong($frame, destSlot, BytecodeNode.SLAdd_q_Add0_executeLong_($frame, $this, $bc, $bci, $sp, $consts, $children)); - return; - } catch (UnexpectedResultException ex) { - UFA.unsafeSetObject($frame, destSlot, ex.getResult()); - } - } - - private static void SLReadProperty_q_ReadSLObject0_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLReadProperty_q_ReadSLObject0_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLWriteProperty_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLWriteProperty_execute_($frame, $this, $bc, $bci, $sp, $consts, $children)); - } - - private static void SLInvoke_entryPoint_(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, BytecodeNode.SLInvoke_execute_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics)); - } - - private static void SLToBoolean_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLToBoolean_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLessOrEqual_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessOrEqual_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLessThan_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLessThan_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLLogicalNot_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLLogicalNot_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLUnbox_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLUnbox_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLFunctionLiteral_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 1; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLFunctionLiteral_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLAdd_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLAdd_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLDiv_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLDiv_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLMul_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLMul_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLReadProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLReadProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLSub_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 2; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLSub_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLWriteProperty_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children) { - int destSlot = $sp - 3; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLWriteProperty_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, UFA.unsafeUncheckedGetObject($frame, $sp - 3), UFA.unsafeUncheckedGetObject($frame, $sp - 2), UFA.unsafeUncheckedGetObject($frame, $sp - 1))); - } - - private static void SLInvoke_entryPoint_uncached(VirtualFrame $frame, SLOperationRootNodeGen $this, short[] $bc, int $bci, int $sp, Object[] $consts, Node[] $children, int $numVariadics) { - int destSlot = $sp - 1 - $numVariadics; - UFA.unsafeSetObject($frame, destSlot, UncachedBytecodeNode.SLInvoke_executeUncached_($frame, $this, $bc, $bci, $sp, $consts, $children, $numVariadics, UFA.unsafeUncheckedGetObject($frame, $sp - 1 - $numVariadics), do_loadVariadicArguments($frame, $sp, $numVariadics))); - } - - private static void doSetResultBoxed(short[] bc, int startBci, int bciOffset, int targetType) { - if (bciOffset != 0) { - setResultBoxedImpl(bc, startBci - bciOffset, targetType); - } - } - - @ExplodeLoop - private static Object[] do_loadVariadicArguments(VirtualFrame $frame, int $sp, int numVariadics) { - CompilerAsserts.partialEvaluationConstant($sp); - CompilerAsserts.partialEvaluationConstant(numVariadics); - Object[] result = new Object[numVariadics]; - for (int varIndex = 0; varIndex < numVariadics; varIndex++) { - result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex); - } - return result; - } - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { - bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); - } - - private static short unsafeFromBytecode(short[] bc, int index) { - return UFA.unsafeShortArrayRead(bc, index); - } - - private static void unsafeWriteBytecode(short[] bc, int index, short value) { - UFA.unsafeShortArrayWrite(bc, index, value); - } - - private static boolean do_profileCondition(SLOperationRootNodeGen $this, boolean value, int[] profiles, int index) { - int t = UFA.unsafeIntArrayRead(profiles, index); - int f = UFA.unsafeIntArrayRead(profiles, index + 1); - boolean val = value; - if (val) { - if (t == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (f == 0) { - val = true; - } - if (CompilerDirectives.inInterpreter()) { - if (t < 1073741823) { - UFA.unsafeIntArrayWrite(profiles, index, t + 1); - } - } - } else { - if (f == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - } - if (t == 0) { - val = false; - } - if (CompilerDirectives.inInterpreter()) { - if (f < 1073741823) { - UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1); - } - } - } - if (CompilerDirectives.inInterpreter()) { - return val; - } else { - int sum = t + f; - return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); - } - } - - private static ProbeNode getProbeNodeImpl(SLOperationRootNodeGen $this, int index) { - InstrumentTreeNode node = $this.instruments[index]; - if (!(node instanceof WrapperNode)) { - return null; - } - return ((WrapperNode) node).getProbeNode(); - } - - public static OperationNodes create(OperationConfig config, OperationParser generator) { - OperationNodesImpl nodes = new OperationNodesImpl(generator); - Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(nodes, false, config); - generator.parse(builder); - builder.finish(); - return nodes; - } - - public static OperationNodes deserialize(TruffleLanguage language, OperationConfig config, ByteBuffer input, OperationDeserializer callback) throws IOException { - try { - return create(config, b -> Builder.deserializeParser(language, input, callback, b)); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - } - - public static void serialize(OperationConfig config, DataOutput buffer, OperationSerializer callback, OperationParser generator) throws IOException { - Builder builder = new com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - generator.parse(builder); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class ExceptionHandler { - - int startBci; - int startStack; - int endBci; - int exceptionIndex; - int handlerBci; - - ExceptionHandler(int startBci, int startStack, int endBci, int exceptionIndex, int handlerBci) { - this.startBci = startBci; - this.startStack = startStack; - this.endBci = endBci; - this.exceptionIndex = exceptionIndex; - this.handlerBci = handlerBci; - } - - ExceptionHandler() { - } - - ExceptionHandler offset(int offset, int stackOffset) { - return new ExceptionHandler(startBci + offset, startStack + stackOffset, endBci + offset, exceptionIndex, handlerBci + offset); - } - - @Override - public String toString() { - return String.format("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}", startBci, endBci, startStack, exceptionIndex, handlerBci); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private abstract static class BytecodeLoopBase { - - abstract int continueAt(SLOperationRootNodeGen $this, VirtualFrame $frame, short[] $bc, int $startBci, int $startSp, Object[] $consts, Node[] $children, byte[] $localTags, ExceptionHandler[] $handlers, int[] $conditionProfiles, int maxLocals); - - abstract OperationIntrospection getIntrospectionData(short[] $bc, ExceptionHandler[] $handlers, Object[] $consts, OperationNodesImpl nodes, int[] sourceInfo); - - abstract void prepareForAOT(SLOperationRootNodeGen $this, short[] $bc, Object[] $consts, Node[] $children, TruffleLanguage language, RootNode root); - - protected static String formatConstant(Object obj) { - if (obj == null) { - return "null"; - } else { - Object repr = obj; - if (obj instanceof Object[]) { - repr = Arrays.deepToString((Object[]) obj); - } - return String.format("%s %s", obj.getClass().getSimpleName(), repr); - } - } - - protected static Object expectObject(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) { - if (bciOffset == 0 || UFA.unsafeIsObject(frame, slot)) { - return UFA.unsafeUncheckedGetObject(frame, slot); - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - return frame.getValue(slot); - } - } - - protected static void setResultBoxedImpl(short[] bc, int bci, int targetType) { - bc[bci] = (short) (targetType | (bc[bci] & 0xfff8)); - } - - protected static long expectLong(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { - if (bciOffset == 0) { - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - return (long) value; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(value); - } - } else { - switch (UFA.unsafeGetTag(frame, slot)) { - case 1 /* LONG */ : - return UFA.unsafeUncheckedGetLong(frame, slot); - case 0 /* OBJECT */ : - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Long) { - setResultBoxedImpl(bc, bci - bciOffset, 1 /* LONG */); - return (long) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - throw new UnexpectedResultException(frame.getValue(slot)); - } - } - - protected static boolean expectBoolean(VirtualFrame frame, int slot, short[] bc, int bci, int bciOffset) throws UnexpectedResultException { - if (bciOffset == 0) { - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - return (boolean) value; - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new UnexpectedResultException(value); - } - } else { - switch (UFA.unsafeGetTag(frame, slot)) { - case 5 /* BOOLEAN */ : - return UFA.unsafeUncheckedGetBoolean(frame, slot); - case 0 /* OBJECT */ : - CompilerDirectives.transferToInterpreterAndInvalidate(); - Object value = UFA.unsafeUncheckedGetObject(frame, slot); - if (value instanceof Boolean) { - setResultBoxedImpl(bc, bci - bciOffset, 5 /* BOOLEAN */); - return (boolean) value; - } - break; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - setResultBoxedImpl(bc, bci - bciOffset, 0); - throw new UnexpectedResultException(frame.getValue(slot)); - } - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationNodesImpl extends OperationNodes { - - OperationNodesImpl(OperationParser parse) { - super(parse); - } - - @Override - protected void reparseImpl(OperationConfig config, OperationParser parse, OperationRootNode[] nodes) { - Builder builder = new Builder(this, true, config); - ((OperationParser) parse).parse(builder); - builder.finish(); - } - - void setSources(Source[] sources) { - this.sources = sources; - } - - Source[] getSources() { - return sources; - } - - void setNodes(SLOperationRootNode[] nodes) { - this.nodes = nodes; - } - - protected void ensureSourcesAccessor() { - ensureSources(); - } - - protected void ensureInstrumentationAccessor() { - ensureInstrumentation(); - } - - @Override - public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { - Builder builder = new Builder(null, false, config); - builder.isSerializing = true; - builder.serBuffer = buffer; - builder.serCallback = callback; - try { - ((OperationParser) parse).parse(builder); - } catch (IOError ex) { - throw (IOException) ex.getCause(); - } - buffer.writeShort((short) -5); - } - - } - @GeneratedBy(SLOperationRootNode.class) - public static final class Builder extends OperationBuilder { - - private static final String[] OPERATION_NAMES = new String[] {null, "Block", "Root", "IfThen", "IfThenElse", "Conditional", "While", "TryCatch", "FinallyTry", "FinallyTryNoExcept", "Label", "Branch", "LoadConstant", "LoadArgument", "LoadLocal", "StoreLocal", "Return", "LoadLocalMaterialized", "StoreLocalMaterialized", "Source", "SourceSection", "Tag", "SLAdd", "SLDiv", "SLEqual", "SLLessOrEqual", "SLLessThan", "SLLogicalNot", "SLMul", "SLReadProperty", "SLSub", "SLWriteProperty", "SLUnbox", "SLFunctionLiteral", "SLToBoolean", "SLInvoke", "SLAnd", "SLOr"}; - private static final int OP_BLOCK = 1; - private static final int OP_ROOT = 2; - private static final int OP_IF_THEN = 3; - private static final int OP_IF_THEN_ELSE = 4; - private static final int OP_CONDITIONAL = 5; - private static final int OP_WHILE = 6; - private static final int OP_TRY_CATCH = 7; - private static final int OP_FINALLY_TRY = 8; - private static final int OP_FINALLY_TRY_NO_EXCEPT = 9; - private static final int OP_LABEL = 10; - private static final int OP_BRANCH = 11; - private static final int OP_LOAD_CONSTANT = 12; - private static final int OP_LOAD_ARGUMENT = 13; - private static final int OP_LOAD_LOCAL = 14; - private static final int OP_STORE_LOCAL = 15; - private static final int OP_RETURN = 16; - private static final int OP_LOAD_LOCAL_MATERIALIZED = 17; - private static final int OP_STORE_LOCAL_MATERIALIZED = 18; - private static final int OP_SOURCE = 19; - private static final int OP_SOURCE_SECTION = 20; - private static final int OP_TAG = 21; - private static final int OP_SL_ADD = 22; - private static final int OP_SL_DIV = 23; - private static final int OP_SL_EQUAL = 24; - private static final int OP_SL_LESS_OR_EQUAL = 25; - private static final int OP_SL_LESS_THAN = 26; - private static final int OP_SL_LOGICAL_NOT = 27; - private static final int OP_SL_MUL = 28; - private static final int OP_SL_READ_PROPERTY = 29; - private static final int OP_SL_SUB = 30; - private static final int OP_SL_WRITE_PROPERTY = 31; - private static final int OP_SL_UNBOX = 32; - private static final int OP_SL_FUNCTION_LITERAL = 33; - private static final int OP_SL_TO_BOOLEAN = 34; - private static final int OP_SL_INVOKE = 35; - private static final int OP_SL_AND = 36; - private static final int OP_SL_OR = 37; - - private final com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes; - private final boolean isReparse; - private final boolean withSource; - private final boolean withInstrumentation; - private SourceInfoBuilder sourceBuilder; - private short[] bc = new short[65535]; - private int bci; - private int curStack; - private int maxStack; - private int numLocals; - private int[] instructionHistory = new int[8]; - private int instructionHistoryIndex = 0; - private int numLabels; - private int numInstrumentNodes; - private ArrayList constPool = new ArrayList<>(); - private BuilderOperationData operationData; - private ArrayList labels = new ArrayList<>(); - private ArrayList labelFills = new ArrayList<>(); - private int numChildNodes; - private int numConditionProfiles; - private ArrayList exceptionHandlers = new ArrayList<>(); - private BuilderFinallyTryContext currentFinallyTry; - private int buildIndex; - private boolean isSerializing; - private DataOutput serBuffer; - private OperationSerializer serCallback; - private int[] stackSourceBci = new int[1024]; - private BuilderState parentData; - private SerializerContext SER_CONTEXT = new SerializerContext() { - @Override - public void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException { - buffer.writeShort((short) ((OperationSerNodeImpl) node).buildOrder); - } - } - ; - private final ArrayList builtNodes; - private int lastChildPush; - private TruffleString metadata_MethodName; - - private Builder(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.OperationNodesImpl nodes, boolean isReparse, OperationConfig config) { - this.nodes = nodes; - this.isReparse = isReparse; - builtNodes = new ArrayList<>(); - if (isReparse) { - builtNodes.addAll((java.util.Collection) nodes.getNodes()); - } - this.withSource = config.isWithSource(); - this.withInstrumentation = config.isWithInstrumentation(); - this.sourceBuilder = withSource ? new SourceInfoBuilder(new ArrayList<>()) : null; - } - - private void finish() { - if (withSource) { - nodes.setSources(sourceBuilder.buildSource()); - } - if (!isReparse) { - nodes.setNodes(builtNodes.toArray(new SLOperationRootNode[0])); - } - } - - private void reset(TruffleLanguage language) { - bci = 0; - curStack = 0; - maxStack = 0; - numLocals = 0; - constPool.clear(); - operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language); - labelFills.clear(); - numChildNodes = 0; - numConditionProfiles = 0; - exceptionHandlers.clear(); - Arrays.fill(instructionHistory, -1); - instructionHistoryIndex = 0; - if (sourceBuilder != null) { - sourceBuilder = new SourceInfoBuilder(sourceBuilder.sourceList); - } - numInstrumentNodes = 0; - metadata_MethodName = null; - } - - private int[] doBeforeEmitInstruction(int numPops, boolean pushValue, boolean doBoxing) { - int[] result = new int[numPops]; - for (int i = numPops - 1; i >= 0; i--) { - curStack--; - int predBci = stackSourceBci[curStack]; - result[i] = predBci; - } - if (pushValue) { - if (curStack >= stackSourceBci.length) { - stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2); - } - stackSourceBci[curStack] = doBoxing ? bci : -65535; - curStack++; - if (curStack > maxStack) { - maxStack = curStack; - } - } - return result; - } - - private void doLeaveFinallyTry(BuilderOperationData opData) { - BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]; - if (context.handlerBc == null) { - return; - } - System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length); - for (int offset : context.relocationOffsets) { - short oldOffset = bc[bci + offset]; - bc[bci + offset] = (short) (oldOffset + bci); - } - for (ExceptionHandler handler : context.handlerHandlers) { - exceptionHandlers.add(handler.offset(bci, curStack)); - } - for (LabelFill fill : context.handlerLabelFills) { - labelFills.add(fill.offset(bci)); - } - if (maxStack < curStack + context.handlerMaxStack) maxStack = curStack + context.handlerMaxStack; - bci += context.handlerBc.length; - } - - private void doEmitLabel(OperationLabel label) { - OperationLabelImpl lbl = (OperationLabelImpl) label; - if (lbl.hasValue) { - throw new UnsupportedOperationException("label already emitted"); - } - if (operationData != lbl.data) { - throw new UnsupportedOperationException("label must be created and emitted inside same opeartion"); - } - lbl.hasValue = true; - lbl.targetBci = bci; - } - - private void calculateLeaves(BuilderOperationData fromData, BuilderOperationData toData) { - if (toData != null && fromData.depth < toData.depth) { - throw new UnsupportedOperationException("illegal jump to deeper operation"); - } - if (fromData == toData) { - return; - } - BuilderOperationData cur = fromData; - while (true) { - doLeaveOperation(cur); - cur = cur.parent; - if (toData == null && cur == null) { - break; - } else if (toData != null && cur.depth <= toData.depth) break; - } - if (cur != toData) throw new UnsupportedOperationException("illegal jump to non-parent operation"); - } - - private void calculateLeaves(BuilderOperationData fromData) { - calculateLeaves(fromData, (BuilderOperationData) null); - } - - private void calculateLeaves(BuilderOperationData fromData, Object toLabel) { - calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data); - } - - public OperationLocal createLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -3); - return new OperationLocalImpl(null, numLocals++); - } catch (IOException ex) { - throw new IOError(ex); - } - } - return new OperationLocalImpl(operationData, numLocals++); - } - - private OperationLocalImpl createParentLocal() { - return new OperationLocalImpl(operationData.parent, numLocals++); - } - - public OperationLabel createLabel() { - if (isSerializing) { - try { - serBuffer.writeShort((short) -2); - return new OperationSerLabelImpl(numLabels++); - } catch (IOException ex) { - throw new IOError(ex); - } - } - OperationLabelImpl label = new OperationLabelImpl(operationData, currentFinallyTry); - labels.add(label); - return label; - } - - private short getLocalIndex(Object value) { - OperationLocalImpl local = (OperationLocalImpl) value; - assert verifyNesting(local.owner, operationData) : "local access not nested properly"; - return (short) local.id; - } - - private int[] getLocalIndices(Object value) { - OperationLocal[] locals = (OperationLocal[]) value; - int[] result = new int[locals.length]; - for (int i = 0; i < locals.length; i++) { - result[i] = getLocalIndex(locals[i]); - } - return result; - } - - private boolean verifyNesting(BuilderOperationData parent, BuilderOperationData child) { - BuilderOperationData cur = child; - while (cur.depth > parent.depth) { - cur = cur.parent; - } - return cur == parent; - } - - private SLOperationRootNode publish(TruffleLanguage language) { - if (isSerializing) { - SLOperationRootNode result = new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++); - numLocals = 0; - numLabels = 0; - return result; - } - if (operationData.depth != 0) { - throw new UnsupportedOperationException("Not all operations closed"); - } - SLOperationRootNodeGen result; - if (!isReparse) { - FrameDescriptor .Builder frameDescriptor; - frameDescriptor = FrameDescriptor.newBuilder(numLocals + maxStack); - frameDescriptor.addSlots(numLocals + maxStack, FrameSlotKind.Illegal); - result = new SLOperationRootNodeGen(language, frameDescriptor); - result.nodes = nodes; - labelPass(null); - result._bc = Arrays.copyOf(bc, bci); - result._consts = constPool.toArray(); - result._children = new Node[numChildNodes]; - result._localTags = new byte[numLocals]; - result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0]); - result._conditionProfiles = new int[numConditionProfiles]; - result._maxLocals = numLocals; - result._maxStack = maxStack; - if (sourceBuilder != null) { - result.sourceInfo = sourceBuilder.build(); - } - result._metadata_MethodName = metadata_MethodName; - assert builtNodes.size() == buildIndex; - builtNodes.add(result); - } else { - result = builtNodes.get(buildIndex); - if (withSource && result.sourceInfo == null) { - result.sourceInfo = sourceBuilder.build(); - } - } - buildIndex++; - reset(language); - return result; - } - - private void labelPass(BuilderFinallyTryContext finallyTry) { - for (LabelFill fill : labelFills) { - if (finallyTry != null) { - if (fill.label.belongsTo(finallyTry)) { - assert fill.label.hasValue : "inner label should have been resolved by now"; - finallyTry.relocationOffsets.add(fill.locationBci); - } else { - finallyTry.handlerLabelFills.add(fill); - } - } - bc[fill.locationBci] = (short) fill.label.targetBci; - } - } - - private void doLeaveOperation(BuilderOperationData data) { - switch (data.operationId) { - case OP_FINALLY_TRY : - { - doLeaveFinallyTry(data); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - doLeaveFinallyTry(data); - break; - } - case OP_TAG : - { - break; - } - } - } - - @SuppressWarnings("unused") - private void doBeforeChild() { - int childIndex = operationData.numChildren; - switch (operationData.operationId) { - case OP_BLOCK : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_ROOT : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_TRY_CATCH : - { - if (childIndex == 1) { - curStack = ((ExceptionHandler) operationData.aux[0]).startStack; - ((ExceptionHandler) operationData.aux[0]).handlerBci = bci; - } - break; - } - case OP_SOURCE : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_SOURCE_SECTION : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_TAG : - { - if (childIndex != 0) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - } - break; - } - case OP_SL_AND : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_SC_SL_AND << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_SC_SL_AND; - bci = bci + SC_SL_AND_LENGTH; - } - break; - } - case OP_SL_OR : - { - if (childIndex > 0) { - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_SC_SL_OR << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - labelFills.add(new LabelFill(bci + 4 + 0, ((OperationLabelImpl) operationData.aux[0]))); - bc[bci + 5 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_SC_SL_OR; - bci = bci + SC_SL_OR_LENGTH; - } - break; - } - } - } - - @SuppressWarnings("unused") - private void doAfterChild() { - int childIndex = operationData.numChildren++; - switch (operationData.operationId) { - case OP_IF_THEN : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = endLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } - bci = bci + BRANCH_FALSE_LENGTH; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } - break; - } - case OP_IF_THEN_ELSE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } - bci = bci + BRANCH_FALSE_LENGTH; - } else if (childIndex == 1) { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_CONDITIONAL : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl elseLabel = (OperationLabelImpl) createLabel(); - operationData.aux[0] = elseLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, elseLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } - bci = bci + BRANCH_FALSE_LENGTH; - } else if (childIndex == 1) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - } else { - assert lastChildPush == 1; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_WHILE : - { - if (childIndex == 0) { - assert lastChildPush == 1; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH_FALSE << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - bc[bci + 2] = (short) numConditionProfiles; - numConditionProfiles += 2; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH_FALSE; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_TO_BOOLEAN) { - bc[bci - C_SL_TO_BOOLEAN_LENGTH] = ((INSTR_SI_C_SL_TO_BOOLEAN_BRANCH_FALSE << 3) | 0); - } - bci = bci + BRANCH_FALSE_LENGTH; - } else { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[0])); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[0]))); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - } - break; - } - case OP_TRY_CATCH : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - ((ExceptionHandler) operationData.aux[0]).endBci = bci; - calculateLeaves(operationData, ((OperationLabelImpl) operationData.aux[1])); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, ((OperationLabelImpl) operationData.aux[1]))); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - } else { - } - break; - } - case OP_FINALLY_TRY : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.aux[2]); - exceptionHandlers.add(beh); - operationData.aux[1] = beh; - } - break; - } - case OP_FINALLY_TRY_NO_EXCEPT : - { - for (int i = 0; i < lastChildPush; i++) { - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_POP << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_POP; - bci = bci + POP_LENGTH; - } - if (childIndex == 0) { - labelPass(currentFinallyTry); - currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci); - currentFinallyTry.handlerHandlers = exceptionHandlers; - currentFinallyTry.handlerMaxStack = maxStack; - System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length); - bci = currentFinallyTry.bc.length; - exceptionHandlers = currentFinallyTry.exceptionHandlers; - labelFills = currentFinallyTry.labelFills; - labels = currentFinallyTry.labels; - curStack = currentFinallyTry.curStack; - maxStack = currentFinallyTry.maxStack; - currentFinallyTry = currentFinallyTry.prev; - } - break; - } - } - } - - @SuppressWarnings("unused") - public void beginBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BLOCK << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BLOCK, curStack, 0, false); - lastChildPush = 0; - } - - @SuppressWarnings("unused") - public void endBlock() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_BLOCK << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_BLOCK) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endBlock"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Block expected at least 0 children, got " + numChildren); - } - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginRoot(TruffleLanguage arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_ROOT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - lastChildPush = 0; - this.parentData = new BuilderState(this); - this.bc = new short[65535]; - this.constPool = new ArrayList<>(); - this.labels = new ArrayList<>(); - this.labelFills = new ArrayList<>(); - this.exceptionHandlers = new ArrayList<>(); - this.stackSourceBci = new int[1024]; - reset(arg0); - } - - @SuppressWarnings("unused") - public SLOperationRootNode endRoot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_ROOT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return publish(null); - } - if (operationData.operationId != OP_ROOT) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endRoot"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Root expected at least 0 children, got " + numChildren); - } - lastChildPush = 0; - SLOperationRootNode endCodeResult; - endCodeResult = publish((TruffleLanguage) operationData.arguments[0]); - this.bc = parentData.bc; - this.bci = parentData.bci; - this.curStack = parentData.curStack; - this.maxStack = parentData.maxStack; - this.numLocals = parentData.numLocals; - this.numLabels = parentData.numLabels; - this.constPool = parentData.constPool; - this.operationData = parentData.operationData; - this.labels = parentData.labels; - this.labelFills = parentData.labelFills; - this.numChildNodes = parentData.numChildNodes; - this.numConditionProfiles = parentData.numConditionProfiles; - this.exceptionHandlers = parentData.exceptionHandlers; - this.currentFinallyTry = parentData.currentFinallyTry; - this.stackSourceBci = parentData.stackSourceBci; - this.sourceBuilder = parentData.sourceBuilder; - this.parentData = parentData.parentData; - return endCodeResult; - } - - @SuppressWarnings("unused") - public void beginIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN, curStack, 1, false); - } - - @SuppressWarnings("unused") - public void endIfThen() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endIfThen"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("IfThen expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_IF_THEN_ELSE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_IF_THEN_ELSE, curStack, 2, false); - } - - @SuppressWarnings("unused") - public void endIfThenElse() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_IF_THEN_ELSE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_IF_THEN_ELSE) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endIfThenElse"); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("IfThenElse expected 3 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_CONDITIONAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_CONDITIONAL, curStack, 2, false); - } - - @SuppressWarnings("unused") - public void endConditional() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_CONDITIONAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_CONDITIONAL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endConditional"); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("Conditional expected 3 children, got " + numChildren); - } - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_WHILE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_WHILE, curStack, 2, false); - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = startLabel; - } - - @SuppressWarnings("unused") - public void endWhile() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_WHILE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_WHILE) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endWhile"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("While expected 2 children, got " + numChildren); - } - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginTryCatch(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_TRY_CATCH << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TRY_CATCH, curStack, 2, false, (Object) arg0); - ExceptionHandler beh = new ExceptionHandler(); - beh.startBci = bci; - beh.startStack = curStack; - beh.exceptionIndex = getLocalIndex(operationData.arguments[0]); - exceptionHandlers.add(beh); - operationData.aux[0] = beh; - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - operationData.aux[1] = endLabel; - } - - @SuppressWarnings("unused") - public void endTryCatch() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TRY_CATCH << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_TRY_CATCH) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endTryCatch"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("TryCatch expected 2 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[1])); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY, curStack, 3, true); - operationData.aux[2] = createParentLocal(); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - public void endFinallyTry() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endFinallyTry"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTry expected 2 children, got " + numChildren); - } - int endBci = bci; - doLeaveFinallyTry(operationData); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - { - calculateLeaves(operationData, endLabel); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, endLabel)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - } - ExceptionHandler beh = ((ExceptionHandler) operationData.aux[1]); - beh.endBci = endBci; - beh.handlerBci = bci; - doLeaveFinallyTry(operationData); - { - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_THROW << 3) | 0)); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.aux[2]); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_THROW; - bci = bci + THROW_LENGTH; - } - doEmitLabel(endLabel); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_FINALLY_TRY_NO_EXCEPT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_FINALLY_TRY_NO_EXCEPT, curStack, 1, true); - currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack); - bci = 0; - exceptionHandlers = new ArrayList<>(); - labelFills = new ArrayList<>(); - labels = new ArrayList<>(); - curStack = 0; - maxStack = 0; - operationData.aux[0] = currentFinallyTry; - } - - @SuppressWarnings("unused") - public void endFinallyTryNoExcept() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_FINALLY_TRY_NO_EXCEPT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_FINALLY_TRY_NO_EXCEPT) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endFinallyTryNoExcept"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("FinallyTryNoExcept expected 2 children, got " + numChildren); - } - doLeaveFinallyTry(operationData); - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLabel(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LABEL << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - doEmitLabel(arg0); - lastChildPush = 0; - doAfterChild(); - } - - public void emitBranch(OperationLabel arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_BRANCH << 1)); - serBuffer.writeShort((short) ((OperationSerLabelImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_BRANCH, curStack, 0, false, arg0); - calculateLeaves(operationData, (OperationLabelImpl) operationData.arguments[0]); - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_BRANCH << 3) | 0)); - labelFills.add(new LabelFill(bci + 1 + 0, (OperationLabelImpl) operationData.arguments[0])); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_BRANCH; - bci = bci + BRANCH_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadConstant(Object arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_LOAD_CONSTANT << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_CONSTANT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_CONSTANT << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(operationData.arguments[0]); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_CONSTANT; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT << 3) | 0); - } - bci = bci + LOAD_CONSTANT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadArgument(int arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_ARGUMENT << 1)); - serBuffer.writeInt(arg0); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_ARGUMENT, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_ARGUMENT << 3) | 0)); - bc[bci + 1 + 0] = (short) (int) operationData.arguments[0]; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_ARGUMENT; - bci = bci + LOAD_ARGUMENT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void emitLoadLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL, curStack, 0, false, arg0); - doBeforeEmitInstruction(0, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_LOCAL << 3) | 0)); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_LOCAL; - bci = bci + LOAD_LOCAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginStoreLocal(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_STORE_LOCAL << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endStoreLocal() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_STORE_LOCAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_STORE_LOCAL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endStoreLocal"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("StoreLocal expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_STORE_LOCAL << 3) | 0)); - bc[bci + 1 + 0] = (short) getLocalIndex(operationData.arguments[0]); - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_STORE_LOCAL; - bci = bci + STORE_LOCAL_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_RETURN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_RETURN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endReturn() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_RETURN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_RETURN) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endReturn"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("Return expected 1 children, got " + numChildren); - } - calculateLeaves(operationData); - doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_RETURN << 3) | 0)); - instructionHistory[++instructionHistoryIndex % 8] = INSTR_RETURN; - bci = bci + RETURN_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginLoadLocalMaterialized(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_LOAD_LOCAL_MATERIALIZED << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_LOAD_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endLoadLocalMaterialized() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_LOAD_LOCAL_MATERIALIZED << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_LOAD_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endLoadLocalMaterialized"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("LoadLocalMaterialized expected 1 children, got " + numChildren); - } - doBeforeEmitInstruction(1, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_LOAD_LOCAL_MAT << 3) | 0)); - bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_LOAD_LOCAL_MAT; - bci = bci + LOAD_LOCAL_MAT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginStoreLocalMaterialized(OperationLocal arg0) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_STORE_LOCAL_MATERIALIZED << 1)); - serBuffer.writeShort((short) ((OperationLocalImpl) arg0).id); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_STORE_LOCAL_MATERIALIZED, curStack, 0, false, (Object) arg0); - } - - @SuppressWarnings("unused") - public void endStoreLocalMaterialized() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_STORE_LOCAL_MATERIALIZED << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_STORE_LOCAL_MATERIALIZED) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endStoreLocalMaterialized"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("StoreLocalMaterialized expected 2 children, got " + numChildren); - } - doBeforeEmitInstruction(2, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_STORE_LOCAL_MAT << 3) | 0)); - bc[bci + 1 + 0] = (short) (int) ((OperationLocalImpl)operationData.arguments[0]).id; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_STORE_LOCAL_MAT; - bci = bci + STORE_LOCAL_MAT_LENGTH; - lastChildPush = 0; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSource(Source arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_SOURCE << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE, curStack, 0, false, (Object) arg0); - sourceBuilder.beginSource(bci, arg0); - } - } - - @SuppressWarnings("unused") - public void endSource() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSource"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Source expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSource(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginSourceSection(int arg0, int arg1) { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SOURCE_SECTION << 1)); - serBuffer.writeInt(arg0); - serBuffer.writeInt(arg1); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SOURCE_SECTION, curStack, 0, false, (Object) arg0, (Object) arg1); - sourceBuilder.beginSourceSection(bci, arg0, arg1); - } - } - - @SuppressWarnings("unused") - public void endSourceSection() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SOURCE_SECTION << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withSource) { - if (operationData.operationId != OP_SOURCE_SECTION) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSourceSection"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SourceSection expected at least 0 children, got " + numChildren); - } - sourceBuilder.endSourceSection(bci); - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginTag(Class arg0) { - if (isSerializing) { - try { - int arg0_index = constPool.indexOf(arg0); - if (arg0_index == -1) { - arg0_index = constPool.size(); - constPool.add(arg0); - serBuffer.writeShort((short) -4); - serCallback.serialize(SER_CONTEXT, serBuffer, arg0); - } - serBuffer.writeShort((short) (OP_TAG << 1)); - serBuffer.writeShort((short) arg0_index); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withInstrumentation) { - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_TAG, curStack, 3, true, (Object) arg0); - int curInstrumentId = 0; - OperationLabelImpl startLabel = (OperationLabelImpl) createLabel(); - OperationLabelImpl endLabel = (OperationLabelImpl) createLabel(); - doEmitLabel(startLabel); - operationData.aux[0] = curInstrumentId; - operationData.aux[1] = startLabel; - operationData.aux[2] = endLabel; - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_ENTER << 3) | 0)); - bc[bci + 1] = (short) numInstrumentNodes; - numInstrumentNodes += 1; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_ENTER; - bci = bci + INSTRUMENT_ENTER_LENGTH; - lastChildPush = 0; - } - } - - @SuppressWarnings("unused") - public void endTag() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_TAG << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (withInstrumentation) { - if (operationData.operationId != OP_TAG) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endTag"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("Tag expected at least 0 children, got " + numChildren); - } - if (lastChildPush != 0) { - doBeforeEmitInstruction(0, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT_VOID << 3) | 0)); - bc[bci + 1] = (short) numInstrumentNodes; - numInstrumentNodes += 1; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT_VOID; - bci = bci + INSTRUMENT_EXIT_VOID_LENGTH; - } else { - int[] predecessorBcis = doBeforeEmitInstruction(1, false, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_INSTRUMENT_EXIT << 3) | 0)); - bc[bci + 1 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 1] = (short) numInstrumentNodes; - numInstrumentNodes += 1; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_INSTRUMENT_EXIT; - bci = bci + INSTRUMENT_EXIT_LENGTH; - } - operationData = operationData.parent; - doAfterChild(); - } - } - - @SuppressWarnings("unused") - public void beginSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_ADD << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_ADD, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLAdd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_ADD << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_ADD) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLAdd"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLAdd expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_ADD << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 2; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_ADD; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_STORE_LOCAL) { - bc[bci - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD << 3) | 0); - } - bci = bci + C_SL_ADD_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_DIV << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_DIV, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLDiv() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_DIV << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_DIV) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLDiv"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLDiv expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_DIV << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_DIV; - bci = bci + C_SL_DIV_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_EQUAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLEqual"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_EQUAL << 3) | 0)); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 4; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 2 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_EQUAL; - bci = bci + C_SL_EQUAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_OR_EQUAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_OR_EQUAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLessOrEqual() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_OR_EQUAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_OR_EQUAL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLessOrEqual"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessOrEqual expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LESS_OR_EQUAL << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LESS_OR_EQUAL; - bci = bci + C_SL_LESS_OR_EQUAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LESS_THAN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LESS_THAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLessThan() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LESS_THAN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LESS_THAN) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLessThan"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLLessThan expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LESS_THAN << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LESS_THAN; - bci = bci + C_SL_LESS_THAN_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_LOGICAL_NOT << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_LOGICAL_NOT, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLLogicalNot() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_LOGICAL_NOT << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_LOGICAL_NOT) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLLogicalNot"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLLogicalNot expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_LOGICAL_NOT << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_LOGICAL_NOT; - bci = bci + C_SL_LOGICAL_NOT_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_MUL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_MUL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLMul() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_MUL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_MUL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLMul"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLMul expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_MUL << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_MUL; - bci = bci + C_SL_MUL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_READ_PROPERTY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_READ_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLReadProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_READ_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_READ_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLReadProperty"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLReadProperty expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_READ_PROPERTY << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 12; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_READ_PROPERTY; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY << 3) | 0); - } - bci = bci + C_SL_READ_PROPERTY_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_SUB << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_SUB, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLSub() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_SUB << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_SUB) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLSub"); - } - int numChildren = operationData.numChildren; - if (numChildren != 2) { - throw new IllegalStateException("SLSub expected 2 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(2, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_SUB << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 4 + 0] = 0; - bc[bci + 4 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_SUB; - bci = bci + C_SL_SUB_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_WRITE_PROPERTY << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_WRITE_PROPERTY, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLWriteProperty() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_WRITE_PROPERTY << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_WRITE_PROPERTY) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLWriteProperty"); - } - int numChildren = operationData.numChildren; - if (numChildren != 3) { - throw new IllegalStateException("SLWriteProperty expected 3 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(3, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_WRITE_PROPERTY << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 11; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] |= (short) ((bci - predecessorBcis[1] < 256 ? bci - predecessorBcis[1] : 0) << 8); - bc[bci + 3 + 1] = (short) ((bci - predecessorBcis[2] < 256 ? bci - predecessorBcis[2] : 0)); - bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_WRITE_PROPERTY; - bci = bci + C_SL_WRITE_PROPERTY_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_UNBOX << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_UNBOX, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLUnbox() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_UNBOX << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_UNBOX) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLUnbox"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLUnbox expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_UNBOX << 3) | 0)); - bc[bci + 1] = (short) numChildNodes; - numChildNodes += 3; - bc[bci + 2 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 3 + 0] = 0; - bc[bci + 3 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_UNBOX; - if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_ARGUMENT && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { - bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_STORE_LOCAL && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_ARGUMENT) { - bc[bci - LOAD_ARGUMENT_LENGTH - STORE_LOCAL_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_ARGUMENT_STORE_LOCAL_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { - bc[bci - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX) { - bc[bci - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_C_SL_READ_PROPERTY) { - bc[bci - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT) { - bc[bci - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_LESS_OR_EQUAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_LOCAL_BOXED && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_C_SL_READ_PROPERTY && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 7 + 8) % 8] == INSTR_LOAD_LOCAL) { - bc[bci - LOAD_LOCAL_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_READ_PROPERTY_LENGTH - C_SL_UNBOX_LENGTH - LOAD_LOCAL_BOXED_LENGTH - C_SL_UNBOX_LENGTH - C_SL_LESS_OR_EQUAL_LENGTH] = ((INSTR_SI_LOAD_LOCAL_LOAD_CONSTANT_C_SL_READ_PROPERTY_C_SL_UNBOX_LOAD_LOCAL_BOXED_C_SL_UNBOX_C_SL_LESS_OR_EQUAL_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_C_SL_ADD && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_C_SL_UNBOX && instructionHistory[(instructionHistoryIndex - 5 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 6 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_LOCAL_LENGTH - C_SL_UNBOX_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_UNBOX_LENGTH - C_SL_ADD_LENGTH] = ((INSTR_SI_POP_LOAD_LOCAL_C_SL_UNBOX_LOAD_CONSTANT_C_SL_UNBOX_C_SL_ADD_C_SL_UNBOX << 3) | 0); - } else if (instructionHistory[(instructionHistoryIndex - 1 + 8) % 8] == INSTR_LOAD_LOCAL && instructionHistory[(instructionHistoryIndex - 2 + 8) % 8] == INSTR_C_SL_FUNCTION_LITERAL && instructionHistory[(instructionHistoryIndex - 3 + 8) % 8] == INSTR_LOAD_CONSTANT && instructionHistory[(instructionHistoryIndex - 4 + 8) % 8] == INSTR_POP) { - bc[bci - POP_LENGTH - LOAD_CONSTANT_LENGTH - C_SL_FUNCTION_LITERAL_LENGTH - LOAD_LOCAL_LENGTH] = ((INSTR_SI_POP_LOAD_CONSTANT_C_SL_FUNCTION_LITERAL_LOAD_LOCAL_C_SL_UNBOX << 3) | 0); - } - bci = bci + C_SL_UNBOX_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_FUNCTION_LITERAL << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_FUNCTION_LITERAL, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLFunctionLiteral() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_FUNCTION_LITERAL << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_FUNCTION_LITERAL) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLFunctionLiteral"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLFunctionLiteral expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_FUNCTION_LITERAL << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_FUNCTION_LITERAL; - bci = bci + C_SL_FUNCTION_LITERAL_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_TO_BOOLEAN << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_TO_BOOLEAN, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLToBoolean() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_TO_BOOLEAN << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_TO_BOOLEAN) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLToBoolean"); - } - int numChildren = operationData.numChildren; - if (numChildren != 1) { - throw new IllegalStateException("SLToBoolean expected 1 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(1, true, true); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_TO_BOOLEAN << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 1; - bc[bci + 3 + 0] = (short) ((bci - predecessorBcis[0] < 256 ? bci - predecessorBcis[0] : 0)); - bc[bci + 4 + 0] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_TO_BOOLEAN; - bci = bci + C_SL_TO_BOOLEAN_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_INVOKE << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_INVOKE, curStack, 0, false); - } - - @SuppressWarnings("unused") - public void endSLInvoke() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_INVOKE << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_INVOKE) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLInvoke"); - } - int numChildren = operationData.numChildren; - if (numChildren < 0) { - throw new IllegalStateException("SLInvoke expected at least 0 children, got " + numChildren); - } - int[] predecessorBcis = doBeforeEmitInstruction(numChildren - 1 + 0, true, false); - unsafeWriteBytecode(bc, bci, (short) ((INSTR_C_SL_INVOKE << 3) | 0)); - int constantsStart = constPool.size(); - bc[bci + 1] = (short) constantsStart; - constPool.add(null); - bc[bci + 2] = (short) numChildNodes; - numChildNodes += 5; - bc[bci + 4] = (short) (numChildren - 1); - bc[bci + 5 + 0] = 0; - bc[bci + 5 + 1] = 0; - instructionHistory[++instructionHistoryIndex % 8] = INSTR_C_SL_INVOKE; - bci = bci + C_SL_INVOKE_LENGTH; - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_AND << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_AND, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - public void endSLAnd() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_AND << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_AND) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLAnd"); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLAnd expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - @SuppressWarnings("unused") - public void beginSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) (OP_SL_OR << 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - doBeforeChild(); - operationData = new BuilderOperationData(operationData, OP_SL_OR, curStack, 1, false); - operationData.aux[0] = (OperationLabelImpl) createLabel(); - } - - @SuppressWarnings("unused") - public void endSLOr() { - if (isSerializing) { - try { - serBuffer.writeShort((short) ((OP_SL_OR << 1) | 1)); - } catch (IOException ex) { - throw new IOError(ex); - } - return; - } - if (operationData.operationId != OP_SL_OR) { - throw new IllegalStateException("Mismatched begin/end, expected end" + OPERATION_NAMES[operationData.operationId] + ", got endSLOr"); - } - int numChildren = operationData.numChildren; - if (numChildren < 1) { - throw new IllegalStateException("SLOr expected at least 1 children, got " + numChildren); - } - doEmitLabel(((OperationLabelImpl) operationData.aux[0])); - lastChildPush = 1; - operationData = operationData.parent; - doAfterChild(); - } - - public void setMethodName(TruffleString value) { - if (isSerializing) { - try { - serBuffer.writeShort((short) -6); - serBuffer.writeShort(0); - serCallback.serialize(SER_CONTEXT, serBuffer, value); - return; - } catch (IOException ex) { - throw new IOError(ex); - } - } - metadata_MethodName = value; - } - - private static void deserializeParser(TruffleLanguage language, ByteBuffer buffer, OperationDeserializer callback, com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder builder) { - try { - ArrayList consts = new ArrayList<>(); - ArrayList locals = new ArrayList<>(); - ArrayList labels = new ArrayList<>(); - ArrayList builtNodes = new ArrayList<>(); - buffer.rewind(); - DataInput dataInput = com.oracle.truffle.api.operation.serialization.SerializationUtils.createDataInput(buffer); - DeserializerContext context = new DeserializerContext(){ - @Override - public SLOperationRootNode deserializeOperationNode(DataInput buffer) throws IOException { - return builtNodes.get(buffer.readInt()); - } - } - ; - while (true) { - switch (buffer.getShort()) { - case -2 : - { - labels.add(builder.createLabel()); - break; - } - case -3 : - { - locals.add(builder.createLocal()); - break; - } - case -4 : - { - consts.add(callback.deserialize(context, dataInput)); - break; - } - case -5 : - { - return; - } - case -6 : - { - switch (buffer.getShort()) { - case 0 : - builder.setMethodName((TruffleString) callback.deserialize(context, dataInput)); - break; - } - break; - } - case OP_BLOCK << 1 : - { - builder.beginBlock(); - break; - } - case (OP_BLOCK << 1) | 1 : - { - builder.endBlock(); - break; - } - case OP_ROOT << 1 : - { - TruffleLanguage arg0 = language; - builder.beginRoot(arg0); - break; - } - case (OP_ROOT << 1) | 1 : - { - builtNodes.add(builder.endRoot()); - break; - } - case OP_IF_THEN << 1 : - { - builder.beginIfThen(); - break; - } - case (OP_IF_THEN << 1) | 1 : - { - builder.endIfThen(); - break; - } - case OP_IF_THEN_ELSE << 1 : - { - builder.beginIfThenElse(); - break; - } - case (OP_IF_THEN_ELSE << 1) | 1 : - { - builder.endIfThenElse(); - break; - } - case OP_CONDITIONAL << 1 : - { - builder.beginConditional(); - break; - } - case (OP_CONDITIONAL << 1) | 1 : - { - builder.endConditional(); - break; - } - case OP_WHILE << 1 : - { - builder.beginWhile(); - break; - } - case (OP_WHILE << 1) | 1 : - { - builder.endWhile(); - break; - } - case OP_TRY_CATCH << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginTryCatch(arg0); - break; - } - case (OP_TRY_CATCH << 1) | 1 : - { - builder.endTryCatch(); - break; - } - case OP_FINALLY_TRY << 1 : - { - builder.beginFinallyTry(); - break; - } - case (OP_FINALLY_TRY << 1) | 1 : - { - builder.endFinallyTry(); - break; - } - case OP_FINALLY_TRY_NO_EXCEPT << 1 : - { - builder.beginFinallyTryNoExcept(); - break; - } - case (OP_FINALLY_TRY_NO_EXCEPT << 1) | 1 : - { - builder.endFinallyTryNoExcept(); - break; - } - case OP_LABEL << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitLabel(arg0); - break; - } - case OP_BRANCH << 1 : - { - OperationLabel arg0 = labels.get(buffer.getShort()); - builder.emitBranch(arg0); - break; - } - case OP_LOAD_CONSTANT << 1 : - { - Object arg0 = (Object) consts.get(buffer.getShort()); - builder.emitLoadConstant(arg0); - break; - } - case OP_LOAD_ARGUMENT << 1 : - { - int arg0 = buffer.getInt(); - builder.emitLoadArgument(arg0); - break; - } - case OP_LOAD_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.emitLoadLocal(arg0); - break; - } - case OP_STORE_LOCAL << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginStoreLocal(arg0); - break; - } - case (OP_STORE_LOCAL << 1) | 1 : - { - builder.endStoreLocal(); - break; - } - case OP_RETURN << 1 : - { - builder.beginReturn(); - break; - } - case (OP_RETURN << 1) | 1 : - { - builder.endReturn(); - break; - } - case OP_LOAD_LOCAL_MATERIALIZED << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginLoadLocalMaterialized(arg0); - break; - } - case (OP_LOAD_LOCAL_MATERIALIZED << 1) | 1 : - { - builder.endLoadLocalMaterialized(); - break; - } - case OP_STORE_LOCAL_MATERIALIZED << 1 : - { - OperationLocal arg0 = locals.get(buffer.getShort()); - builder.beginStoreLocalMaterialized(arg0); - break; - } - case (OP_STORE_LOCAL_MATERIALIZED << 1) | 1 : - { - builder.endStoreLocalMaterialized(); - break; - } - case OP_SOURCE << 1 : - { - Source arg0 = (Source) consts.get(buffer.getShort()); - builder.beginSource(arg0); - break; - } - case (OP_SOURCE << 1) | 1 : - { - builder.endSource(); - break; - } - case OP_SOURCE_SECTION << 1 : - { - int arg0 = buffer.getInt(); - int arg1 = buffer.getInt(); - builder.beginSourceSection(arg0, arg1); - break; - } - case (OP_SOURCE_SECTION << 1) | 1 : - { - builder.endSourceSection(); - break; - } - case OP_TAG << 1 : - { - Class arg0 = (Class) consts.get(buffer.getShort()); - builder.beginTag(arg0); - break; - } - case (OP_TAG << 1) | 1 : - { - builder.endTag(); - break; - } - case OP_SL_ADD << 1 : - { - builder.beginSLAdd(); - break; - } - case (OP_SL_ADD << 1) | 1 : - { - builder.endSLAdd(); - break; - } - case OP_SL_DIV << 1 : - { - builder.beginSLDiv(); - break; - } - case (OP_SL_DIV << 1) | 1 : - { - builder.endSLDiv(); - break; - } - case OP_SL_EQUAL << 1 : - { - builder.beginSLEqual(); - break; - } - case (OP_SL_EQUAL << 1) | 1 : - { - builder.endSLEqual(); - break; - } - case OP_SL_LESS_OR_EQUAL << 1 : - { - builder.beginSLLessOrEqual(); - break; - } - case (OP_SL_LESS_OR_EQUAL << 1) | 1 : - { - builder.endSLLessOrEqual(); - break; - } - case OP_SL_LESS_THAN << 1 : - { - builder.beginSLLessThan(); - break; - } - case (OP_SL_LESS_THAN << 1) | 1 : - { - builder.endSLLessThan(); - break; - } - case OP_SL_LOGICAL_NOT << 1 : - { - builder.beginSLLogicalNot(); - break; - } - case (OP_SL_LOGICAL_NOT << 1) | 1 : - { - builder.endSLLogicalNot(); - break; - } - case OP_SL_MUL << 1 : - { - builder.beginSLMul(); - break; - } - case (OP_SL_MUL << 1) | 1 : - { - builder.endSLMul(); - break; - } - case OP_SL_READ_PROPERTY << 1 : - { - builder.beginSLReadProperty(); - break; - } - case (OP_SL_READ_PROPERTY << 1) | 1 : - { - builder.endSLReadProperty(); - break; - } - case OP_SL_SUB << 1 : - { - builder.beginSLSub(); - break; - } - case (OP_SL_SUB << 1) | 1 : - { - builder.endSLSub(); - break; - } - case OP_SL_WRITE_PROPERTY << 1 : - { - builder.beginSLWriteProperty(); - break; - } - case (OP_SL_WRITE_PROPERTY << 1) | 1 : - { - builder.endSLWriteProperty(); - break; - } - case OP_SL_UNBOX << 1 : - { - builder.beginSLUnbox(); - break; - } - case (OP_SL_UNBOX << 1) | 1 : - { - builder.endSLUnbox(); - break; - } - case OP_SL_FUNCTION_LITERAL << 1 : - { - builder.beginSLFunctionLiteral(); - break; - } - case (OP_SL_FUNCTION_LITERAL << 1) | 1 : - { - builder.endSLFunctionLiteral(); - break; - } - case OP_SL_TO_BOOLEAN << 1 : - { - builder.beginSLToBoolean(); - break; - } - case (OP_SL_TO_BOOLEAN << 1) | 1 : - { - builder.endSLToBoolean(); - break; - } - case OP_SL_INVOKE << 1 : - { - builder.beginSLInvoke(); - break; - } - case (OP_SL_INVOKE << 1) | 1 : - { - builder.endSLInvoke(); - break; - } - case OP_SL_AND << 1 : - { - builder.beginSLAnd(); - break; - } - case (OP_SL_AND << 1) | 1 : - { - builder.endSLAnd(); - break; - } - case OP_SL_OR << 1 : - { - builder.beginSLOr(); - break; - } - case (OP_SL_OR << 1) | 1 : - { - builder.endSLOr(); - break; - } - } - } - } catch (IOException ex) { - throw new IOError(ex); - } - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class BuilderOperationData { - - final BuilderOperationData parent; - final int operationId; - final int stackDepth; - final boolean needsLeave; - final int depth; - final Object[] arguments; - final Object[] aux; - int numChildren; - - private BuilderOperationData(BuilderOperationData parent, int operationId, int stackDepth, int numAux, boolean needsLeave, Object ...arguments) { - this.parent = parent; - this.operationId = operationId; - this.stackDepth = stackDepth; - this.depth = parent == null ? 0 : parent.depth + 1; - this.aux = numAux > 0 ? new Object[numAux] : null; - this.needsLeave = needsLeave || (parent != null && parent.needsLeave); - this.arguments = arguments; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationLabelImpl extends OperationLabel { - - BuilderOperationData data; - BuilderFinallyTryContext finallyTry; - int targetBci = 0; - boolean hasValue = false; - - OperationLabelImpl(BuilderOperationData data, BuilderFinallyTryContext finallyTry) { - this.data = data; - this.finallyTry = finallyTry; - } - - boolean belongsTo(BuilderFinallyTryContext context) { - BuilderFinallyTryContext cur = finallyTry; - while (cur != null) { - if (cur == context) { - return true; - } - cur = cur.prev; - } - return false; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationSerLabelImpl extends OperationLabel { - - int id; - - OperationSerLabelImpl(int id) { - this.id = id; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationLocalImpl extends OperationLocal { - - final BuilderOperationData owner; - final int id; - - OperationLocalImpl(BuilderOperationData owner, int id) { - this.owner = owner; - this.id = id; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class LabelFill { - - int locationBci; - OperationLabelImpl label; - - LabelFill(int locationBci, OperationLabelImpl label) { - this.locationBci = locationBci; - this.label = label; - } - - LabelFill offset(int offset) { - return new LabelFill(offset + locationBci, label); - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class SourceInfoBuilder { - - private final ArrayList sourceList; - private final ArrayList sourceStack = new ArrayList<>(); - private int currentSource = -1; - private final ArrayList bciList = new ArrayList<>(); - private final ArrayList sourceDataList = new ArrayList<>(); - private final ArrayList sourceDataStack = new ArrayList<>(); - - SourceInfoBuilder(ArrayList sourceList) { - this.sourceList = sourceList; - } - - void reset() { - sourceStack.clear(); - sourceDataList.clear(); - sourceDataStack.clear(); - bciList.clear(); - } - - void beginSource(int bci, Source src) { - int idx = sourceList.indexOf(src); - if (idx == -1) { - idx = sourceList.size(); - sourceList.add(src); - } - sourceStack.add(currentSource); - currentSource = idx; - beginSourceSection(bci, -1, -1); - } - - void endSource(int bci) { - endSourceSection(bci); - currentSource = sourceStack.remove(sourceStack.size() - 1); - } - - void beginSourceSection(int bci, int start, int length) { - SourceData data = new SourceData(start, length, currentSource); - bciList.add(bci); - sourceDataList.add(data); - sourceDataStack.add(data); - } - - void endSourceSection(int bci) { - SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1); - SourceData prev; - if (sourceDataStack.isEmpty()) { - prev = new SourceData(-1, -1, currentSource); - } else { - prev = sourceDataStack.get(sourceDataStack.size() - 1); - } - bciList.add(bci); - sourceDataList.add(prev); - } - - int[] build() { - if (!sourceStack.isEmpty()) { - throw new IllegalStateException("not all sources ended"); - } - if (!sourceDataStack.isEmpty()) { - throw new IllegalStateException("not all source sections ended"); - } - int size = bciList.size(); - int[] resultArray = new int[size * 3]; - int index = 0; - int lastBci = -1; - boolean isFirst = true; - for (int i = 0; i < size; i++) { - SourceData data = sourceDataList.get(i); - int curBci = bciList.get(i); - if (data.start == -1 && isFirst) { - continue; - } - isFirst = false; - if (curBci == lastBci && index > 1) { - index -= 3; - } - resultArray[index + 0] = curBci | (data.sourceIndex << 16); - resultArray[index + 1] = data.start; - resultArray[index + 2] = data.length; - index += 3; - lastBci = curBci; - } - return Arrays.copyOf(resultArray, index); - } - - Source[] buildSource() { - return sourceList.toArray(new Source[0]); - } - - @GeneratedBy(SLOperationRootNode.class) - private static final class SourceData { - - final int start; - final int length; - final int sourceIndex; - - SourceData(int start, int length, int sourceIndex) { - this.start = start; - this.length = length; - this.sourceIndex = sourceIndex; - } - - } - } - @GeneratedBy(SLOperationRootNode.class) - private static final class BuilderFinallyTryContext { - - final BuilderFinallyTryContext prev; - final short[] bc; - final ArrayList exceptionHandlers; - final ArrayList labelFills; - final ArrayList labels; - final int curStack; - final int maxStack; - short[] handlerBc; - ArrayList handlerHandlers; - ArrayList handlerLabelFills = new ArrayList<>(); - ArrayList relocationOffsets = new ArrayList<>(); - int handlerMaxStack; - - BuilderFinallyTryContext(BuilderFinallyTryContext prev, short[] bc, ArrayList exceptionHandlers, ArrayList labelFills, ArrayList labels, int curStack, int maxStack) { - this.prev = prev; - this.bc = bc; - this.exceptionHandlers = exceptionHandlers; - this.labelFills = labelFills; - this.labels = labels; - this.curStack = curStack; - this.maxStack = maxStack; - } - - } - private final class BuilderState { - - BuilderState parentData; - private short[] bc = new short[65535]; - private int bci; - private int curStack; - private int maxStack; - private int numLocals; - private int numLabels; - private ArrayList constPool; - private BuilderOperationData operationData; - private ArrayList labels = new ArrayList<>(); - private ArrayList labelFills = new ArrayList<>(); - private int numChildNodes; - private int numConditionProfiles; - private ArrayList exceptionHandlers = new ArrayList<>(); - private BuilderFinallyTryContext currentFinallyTry; - private int[] stackSourceBci = new int[1024]; - private SourceInfoBuilder sourceBuilder; - - BuilderState(com.oracle.truffle.sl.operations.SLOperationRootNodeGen.Builder p) { - this.bc = p.bc; - this.bci = p.bci; - this.curStack = p.curStack; - this.maxStack = p.maxStack; - this.numLocals = p.numLocals; - this.numLabels = p.numLabels; - this.constPool = p.constPool; - this.operationData = p.operationData; - this.labels = p.labels; - this.labelFills = p.labelFills; - this.numChildNodes = p.numChildNodes; - this.numConditionProfiles = p.numConditionProfiles; - this.exceptionHandlers = p.exceptionHandlers; - this.currentFinallyTry = p.currentFinallyTry; - this.stackSourceBci = p.stackSourceBci; - this.sourceBuilder = p.sourceBuilder; - this.parentData = p.parentData; - } - - } - @GeneratedBy(SLOperationRootNode.class) - private static final class OperationSerNodeImpl extends SLOperationRootNode { - - @CompilationFinal int buildOrder; - - private OperationSerNodeImpl(TruffleLanguage language, FrameDescriptor frameDescriptor, int buildOrder) { - super(language, frameDescriptor); - this.buildOrder = buildOrder; - } - - @Override - public Object execute(VirtualFrame frame) { - throw new UnsupportedOperationException(); - } - - @Override - public SourceSection getSourceSectionAtBci(int bci) { - throw new UnsupportedOperationException(); - } - - @Override - public InstrumentableNode materializeInstrumentTree(Set> materializedTags) { - throw new UnsupportedOperationException(); - } - - } - } - private static final class Counter { - - int count; - - } -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BaseBenchmark.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BaseBenchmark.java new file mode 100644 index 000000000000..f807f18597f0 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BaseBenchmark.java @@ -0,0 +1,15 @@ +package com.oracle.truffle.api.operation.test.bml; + +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Warmup; + +@Warmup(iterations = BaseBenchmark.WARMUP_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) +@Measurement(iterations = BaseBenchmark.MEASUREMENT_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) +@Fork(BaseBenchmark.FORKS) +class BaseBenchmark { + public static final int MEASUREMENT_ITERATIONS = 10; + public static final int WARMUP_ITERATIONS = 10; + public static final int ITERATION_TIME = 1; + public static final int FORKS = 1; +} \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java index 06c285c862bd..60a23f08bec3 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/BenmarkSimple.java @@ -54,19 +54,18 @@ import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Warmup; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.operation.OperationLocal; import com.oracle.truffle.api.operation.test.bml.BMOperationRootNodeGen.Builder; +import com.oracle.truffle.api.operation.test.bml.ManualBytecodeNodedNode.AddNode; +import com.oracle.truffle.api.operation.test.bml.ManualBytecodeNodedNode.ModNode; @State(Scope.Benchmark) public class BenmarkSimple extends BaseBenchmark { @@ -79,6 +78,7 @@ public class BenmarkSimple extends BaseBenchmark { private static final String NAME_MANUAL = "simple:manual"; private static final String NAME_MANUAL_NO_BE = "simple:manual-no-be"; private static final String NAME_MANUAL_UNSAFE = "simple:manual-unsafe"; + private static final String NAME_MANUAL_NODED = "simple:manual-noded"; private static final String NAME_AST = "simple:ast"; private static final Source SOURCE_TEST_LOOP = Source.create("bm", NAME_TEST_LOOP); @@ -87,6 +87,7 @@ public class BenmarkSimple extends BaseBenchmark { private static final Source SOURCE_MANUAL = Source.create("bm", NAME_MANUAL); private static final Source SOURCE_MANUAL_NO_BE = Source.create("bm", NAME_MANUAL_NO_BE); private static final Source SOURCE_MANUAL_UNSAFE = Source.create("bm", NAME_MANUAL_UNSAFE); + private static final Source SOURCE_MANUAL_NODED = Source.create("bm", NAME_MANUAL_NODED); private static final Source SOURCE_AST = Source.create("bm", NAME_AST); private static final int LOC_I = 4; @@ -178,6 +179,171 @@ public class BenmarkSimple extends BaseBenchmark { }; + private static final short[] BC_SHORT = { + // i = 0 + /* 00 */ OP_CONST, + /* 01 */ OP_ST_LOC, + + // sum = 0 + /* 02 */ OP_CONST, + /* 03 */ OP_ST_LOC, + + // while (i < 5000) { + /* while_0_start: */ + /* 04 */ OP_LD_LOC, + /* 05 */ OP_CONST, + /* 06 */ OP_LESS, + /* 07 */ OP_JUMP_FALSE, // while_0_end + + // j = 0 + /* 08 */ OP_CONST, + /* 09 */ OP_ST_LOC, + + // while (j < i) { + /* while_1_start: */ + /* 10 */ OP_LD_LOC, // j + /* 11 */ OP_LD_LOC, // i + /* 12 */ OP_LESS, + /* 13 */ OP_JUMP_FALSE, // while_1_end + + // if (i % 3 < 1) { + /* 14 */ OP_LD_LOC, // i + /* 15 */ OP_CONST, + /* 16 */ OP_MOD, + /* 17 */ OP_CONST, + /* 18 */ OP_LESS, + /* 19 */ OP_JUMP_FALSE, // if_else + + // temp = 0 + /* 20 */ OP_CONST, + /* 21 */ OP_ST_LOC, // temp + + // } else { + /* 22 */ OP_JUMP, // if_end + /* if_else: */ + + // temp = i % 3 + /* 23 */ OP_LD_LOC, // i + /* 24 */ OP_CONST, + /* 25 */ OP_MOD, + /* 26 */ OP_ST_LOC, // temp + + // } // if end + /* if_end: */ + + // j = j + temp + /* 27 */ OP_LD_LOC, // j + /* 28 */ OP_LD_LOC, // temp + /* 29 */ OP_ADD, + /* 30 */ OP_ST_LOC, // j + + // } // while end + /* 31 */ OP_JUMP, // while_1_start + /* while_1_end: */ + + // sum = sum + j + /* 32 */ OP_LD_LOC, // sum + /* 33 */ OP_LD_LOC, // j + /* 34 */ OP_ADD, + /* 35 */ OP_ST_LOC, // sum + + // i = i + 1 + /* 36 */ OP_LD_LOC, // i + /* 37 */ OP_CONST, + /* 38 */ OP_ADD, + /* 39 */ OP_ST_LOC, // i + + // } // while end + /* 40 */ OP_JUMP, // while_0_start + /* while_0_end: */ + + // return sum + /* 41 */ OP_LD_LOC, // sum + /* 42 */ OP_RETURN, + }; + + private static final Object[] OBJ_SHORT = {// i = 0 + /* 00 */ 0, + /* 03 */ LOC_I, + + // sum = 0 + /* 05 */ 0, + /* 08 */ LOC_SUM, + + // while (i < 5000) { + /* while_0_start: */ + /* 10 */ LOC_I, + /* 12 */ TOTAL_ITERATIONS, + /* 15 */ null, + /* 16 */ 41, // while_0_end + + // j = 0 + /* 18 */ 0, + /* 21 */ LOC_J, + + // while (j < i) { + /* while_1_start: */ + /* 23 */ LOC_J, // j + /* 25 */ LOC_I, // i + /* 27 */ null, + /* 28 */ 32, // while_1_end + + // if (i % 3 < 1) { + /* 30 */ LOC_I, // i + /* 32 */ 3, + /* 35 */ ModNode.create(), + /* 36 */ 1, + /* 39 */ null, + /* 40 */ 23, // if_else + + // temp = 0 + /* 42 */ 1, + /* 45 */ LOC_TEMP, // temp + + // } else { + /* 47 */ 27, // if_end + /* if_else: */ + + // temp = i % 3 + /* 49 */ LOC_I, // i + /* 51 */ 3, + /* 54 */ ModNode.create(), + /* 55 */ LOC_TEMP, // temp + + // } // if end + /* if_end: */ + + // j = j + temp + /* 57 */ LOC_J, // j + /* 59 */ LOC_TEMP, // temp + /* 61 */ AddNode.create(), + /* 62 */ LOC_J, // j + + // } // while end + /* 64 */ 10, // while_1_start + /* while_1_end: */ + + // sum = sum + j + /* 66 */ LOC_SUM, // sum + /* 68 */ LOC_J, // j + /* 70 */ AddNode.create(), + /* 71 */ LOC_SUM, // sum + + // i = i + 1 + /* 73 */ LOC_I, // i + /* 75 */ 1, + /* 78 */ AddNode.create(), + /* 79 */ LOC_I, // i + + // } // while end + /* 81 */ 40, // while_0_start + /* while_0_end: */ + + // return sum + /* 83 */ LOC_SUM, // sum + /* 85 */ null + }; + private Context context; private static final int MODE_NORMAL = 0; @@ -241,8 +407,17 @@ public class BenmarkSimple extends BaseBenchmark { ManualUnsafeBytecodeNode node = new ManualUnsafeBytecodeNode(lang, b.build(), BYTECODE); return node.getCallTarget(); }); + BenchmarkLanguage.registerName2(NAME_MANUAL_NODED, lang -> { + FrameDescriptor.Builder b = FrameDescriptor.newBuilder(3); + b.addSlots(8, FrameSlotKind.Illegal); + ManualBytecodeNodedNode node = new ManualBytecodeNodedNode(lang, b.build(), BC_SHORT, OBJ_SHORT); + return node.getCallTarget(); + }); BenchmarkLanguage.registerName2(NAME_AST, lang -> { - int iLoc = 0, sumLoc = 1, jLoc = 2, tempLoc = 3; + int iLoc = 0; + int sumLoc = 1; + int jLoc = 2; + int tempLoc = 3; return new BMLRootNode(lang, 4, BlockNode.create( // i = 0 StoreLocalNodeGen.create(iLoc, ConstNodeGen.create(0)), @@ -500,18 +675,13 @@ public void manualUnsafe() { doEval(SOURCE_MANUAL_UNSAFE); } + @Benchmark + public void manualNoded() { + doEval(SOURCE_MANUAL_NODED); + } + @Benchmark public void ast() { doEval(SOURCE_AST); } } - -@Warmup(iterations = BaseBenchmark.WARMUP_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) -@Measurement(iterations = BaseBenchmark.MEASUREMENT_ITERATIONS, time = BaseBenchmark.ITERATION_TIME) -@Fork(BaseBenchmark.FORKS) -class BaseBenchmark { - public static final int MEASUREMENT_ITERATIONS = 10; - public static final int WARMUP_ITERATIONS = 10; - public static final int ITERATION_TIME = 1; - public static final int FORKS = 1; -} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java index c58cfebc7576..3f2c43c811ea 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/ManualBytecodeNode.java @@ -44,16 +44,18 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch; -import com.oracle.truffle.api.dsl.GeneratedBy; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.GeneratedBy; +import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.impl.UnsafeFrameAccess; import com.oracle.truffle.api.nodes.BytecodeOSRNode; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind; +import com.oracle.truffle.api.nodes.LoopNode; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; public class ManualBytecodeNode extends BaseBytecodeNode { @@ -438,3 +440,143 @@ protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { } } } + +@GeneratedBy(ManualUnsafeBytecodeNode.class) // needed for UFA +class ManualBytecodeNodedNode extends BaseBytecodeNode { + + private final Object[] objs; + + protected ManualBytecodeNodedNode(TruffleLanguage language, FrameDescriptor frameDescriptor, short[] bc, Object[] objs) { + super(language, frameDescriptor, bc); + this.objs = objs; + } + + private static final UnsafeFrameAccess UFA = UnsafeFrameAccess.lookup(); + + public abstract static class AddNode extends Node { + public abstract int execute(int lhs, int rhs); + + @Specialization + public static int doInt(int lhs, int rhs) { + return lhs + rhs; + } + + public static AddNode create() { + return ManualBytecodeNodedNodeFactory.AddNodeGen.create(); + } + } + + public abstract static class ModNode extends Node { + public abstract int execute(int lhs, int rhs); + + @Specialization + public static int doInt(int lhs, int rhs) { + return lhs % rhs; + } + + public static ModNode create() { + return ManualBytecodeNodedNodeFactory.ModNodeGen.create(); + } + } + + @Override + @BytecodeInterpreterSwitch + @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) + protected Object executeAt(VirtualFrame frame, int startBci, int startSp) { + short[] localBc = bc; + Object[] localObjs = objs; + int bci = startBci; + int sp = startSp; + + Counter loopCounter = new Counter(); + + frame.getArguments(); + + loop: while (true) { + short opcode = UFA.unsafeShortArrayRead(localBc, bci); + Object obj = UFA.unsafeObjectArrayRead(localObjs, bci); + CompilerAsserts.partialEvaluationConstant(opcode); + switch (opcode) { + // ( -- ) + case OP_JUMP: { + int nextBci = UFA.unsafeCast(obj, Integer.class); + CompilerAsserts.partialEvaluationConstant(nextBci); + if (nextBci <= bci) { + Object result = backwardsJumpCheck(frame, sp, loopCounter, nextBci); + if (result != null) { + return result; + } + } + bci = nextBci; + continue loop; + } + // (i1 i2 -- i3) + case OP_ADD: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetInt(frame, sp - 2, UFA.unsafeCast(obj, AddNode.class).execute(lhs, rhs)); + sp -= 1; + bci += 1; + continue loop; + } + // (i1 i2 -- i3) + case OP_MOD: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetInt(frame, sp - 2, UFA.unsafeCast(obj, ModNode.class).execute(lhs, rhs)); + sp -= 1; + bci += 1; + continue loop; + } + // ( -- i) + case OP_CONST: { + UFA.unsafeSetInt(frame, sp, UFA.unsafeCast(obj, Integer.class)); + sp += 1; + bci += 1; + continue loop; + } + // (b -- ) + case OP_JUMP_FALSE: { + boolean cond = UFA.unsafeGetBoolean(frame, sp - 1); + sp -= 1; + if (!cond) { + bci = UFA.unsafeCast(obj, Integer.class); + continue loop; + } else { + bci += 1; + continue loop; + } + } + // (i1 i2 -- b) + case OP_LESS: { + int lhs = UFA.unsafeGetInt(frame, sp - 2); + int rhs = UFA.unsafeGetInt(frame, sp - 1); + UFA.unsafeSetBoolean(frame, sp - 2, lhs < rhs); + sp -= 1; + bci += 1; + continue loop; + } + // (i -- ) + case OP_RETURN: { + return UFA.unsafeGetInt(frame, sp - 1); + } + // (i -- ) + case OP_ST_LOC: { + UFA.unsafeCopyPrimitive(frame, sp - 1, UFA.unsafeCast(obj, Integer.class)); + sp -= 1; + bci += 1; + continue loop; + } + // ( -- i) + case OP_LD_LOC: { + UFA.unsafeCopyPrimitive(frame, UFA.unsafeCast(obj, Integer.class), sp); + sp += 1; + bci += 1; + continue loop; + } + default: + CompilerDirectives.shouldNotReachHere(); + } + } + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 8bcfbc07c3de..94efcdc1f0d3 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -70,7 +70,9 @@ private static RootCallTarget parse(OperationParser b private static OperationRootNode parseNode(OperationParser builder) { OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, builder); - return nodes.getNodes().get(nodes.getNodes().size() - 1); + TestOperations op = nodes.getNodes().get(nodes.getNodes().size() - 1); + System.out.println(op.dump()); + return op; } @Test @@ -877,7 +879,7 @@ public void testMetadata() { OperationRootNode node = parseNode(b -> { b.beginRoot(LANGUAGE); - b.setTestData(value); +// b.setTestData(value); b.endRoot(); }); @@ -893,8 +895,8 @@ public void testMetadataChange() { OperationRootNode node = parseNode(b -> { b.beginRoot(LANGUAGE); - b.setTestData("some old value"); - b.setTestData(value); +// b.setTestData("some old value"); +// b.setTestData(value); b.endRoot(); }); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index d31687b1206d..70ef4e9e3732 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -83,7 +83,9 @@ default String dump() { Object execute(VirtualFrame frame); - SourceSection getSourceSectionAtBci(int bci); + default SourceSection getSourceSectionAtBci(int bci) { + return null; + } @SuppressWarnings("unused") default void executeProlog(VirtualFrame frame) { @@ -93,5 +95,7 @@ default void executeProlog(VirtualFrame frame) { default void executeEpilog(VirtualFrame frame, Object returnValue, Throwable throwable) { } - InstrumentableNode materializeInstrumentTree(Set> materializedTags); + default InstrumentableNode materializeInstrumentTree(Set> materializedTags) { + throw new UnsupportedOperationException(); + } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java index 3117c6417f26..083574b413d1 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java @@ -58,6 +58,12 @@ static OperationIntrospection create(Object... data) { private final Object[] data; + // format: [int 0, Object[] instructions, Object[] exHandlers, Object[] sourceInfo or null] + // instruction: [int index, String name, short[] bytes, Object[] argumentValues] + // argumentValue: [ArgumentKind kind, Object value] + // exHandler: [int startIndex, int endIndex, int handlerIndex] + // sourceInfo: [int startIndex, int endIndex, SourceSection ss] + private OperationIntrospection(Object[] data) { if (data.length == 0 || (int) data[0] != 0) { throw new UnsupportedOperationException("Illegal operation introspection version"); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java index 6c89dbc1069b..e618a0932981 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/UnsafeFrameAccess.java @@ -66,6 +66,8 @@ public static UnsafeFrameAccess lookup() { public abstract T unsafeObjectArrayRead(T[] arr, int index); + public abstract T unsafeCast(Object arr, Class clazz); + public abstract byte unsafeGetTag(Frame frame, int slot); public abstract Object unsafeGetObject(Frame frame, int slot); @@ -157,6 +159,13 @@ public T unsafeObjectArrayRead(T[] arr, int index) { return (T) FrameWithoutBoxing.UNSAFE.getObject(arr, Unsafe.ARRAY_OBJECT_BASE_OFFSET + index * Unsafe.ARRAY_OBJECT_INDEX_SCALE); } + @Override + @SuppressWarnings("unchecked") + public T unsafeCast(Object obj, Class clazz) { + // TODO: make this unsafer + return (T) obj; + } + @Override public byte unsafeGetTag(Frame frame, int slot) { return ((FrameWithoutBoxing) frame).unsafeGetTag(slot); @@ -320,6 +329,12 @@ public T unsafeObjectArrayRead(T[] arr, int index) { return arr[index]; } + @Override + @SuppressWarnings("unchecked") + public T unsafeCast(Object obj, Class clazz) { + return (T) obj; + } + @Override public byte unsafeGetTag(Frame frame, int slot) { return frame.getTag(slot); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/.checkstyle_checks.xml b/truffle/src/com.oracle.truffle.dsl.processor/.checkstyle_checks.xml index c1693404086e..2ded0a9ab995 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/.checkstyle_checks.xml +++ b/truffle/src/com.oracle.truffle.dsl.processor/.checkstyle_checks.xml @@ -42,6 +42,7 @@ + diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java index 6d1e54af3ee7..9ffb114a78d0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java @@ -68,8 +68,8 @@ import com.oracle.truffle.dsl.processor.library.ExportsParser; import com.oracle.truffle.dsl.processor.library.LibraryGenerator; import com.oracle.truffle.dsl.processor.library.LibraryParser; -import com.oracle.truffle.dsl.processor.operations.OperationsCodeGenerator; -import com.oracle.truffle.dsl.processor.operations.OperationsParser; +import com.oracle.truffle.dsl.processor.operations.generator.OperationsCodeGenerator; +import com.oracle.truffle.dsl.processor.operations.parser.OperationsParser; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; import com.oracle.truffle.dsl.processor.parser.TypeSystemParser; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 8932dd14639b..623f95ee999f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -247,6 +247,7 @@ public class TruffleTypes { public static final String Operation_Name = "com.oracle.truffle.api.operation.Operation"; public static final String OperationBytecodeNode_Name = "com.oracle.truffle.api.operation.OperationBuilder.BytecodeNode"; public static final String OperationConfig_Name = "com.oracle.truffle.api.operation.OperationConfig"; + public static final String OperationParser_Name = "com.oracle.truffle.api.operation.OperationParser"; public static final String OperationIntrospection_Name = "com.oracle.truffle.api.operation.introspection.OperationIntrospection"; public static final String OperationIntrospection_Provider_Name = "com.oracle.truffle.api.operation.introspection.OperationIntrospection.Provider"; public static final String OperationLabel_Name = "com.oracle.truffle.api.operation.OperationLabel"; @@ -273,6 +274,7 @@ public class TruffleTypes { public final DeclaredType Operation = c.getDeclaredTypeOptional(Operation_Name); public final DeclaredType OperationBytecodeNode = c.getDeclaredTypeOptional(OperationBytecodeNode_Name); public final DeclaredType OperationConfig = c.getDeclaredTypeOptional(OperationConfig_Name); + public final DeclaredType OperationParser = c.getDeclaredTypeOptional(OperationParser_Name); public final DeclaredType OperationIntrospection = c.getDeclaredTypeOptional(OperationIntrospection_Name); public final DeclaredType OperationIntrospection_Provider = c.getDeclaredTypeOptional(OperationIntrospection_Provider_Name); public final DeclaredType OperationLabel = c.getDeclaredTypeOptional(OperationLabel_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index c119039aec25..815ec039d371 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -235,7 +235,7 @@ private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); if (parseMode == ParseMode.OPERATION && "this".equals(name)) { - return new CodeVariableElement(thisType, "$this"); + return new CodeVariableElement(thisType, "this"); } switch (name) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index d9021d5508ee..8d5471892231 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -44,13 +44,10 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; -import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; @@ -61,7 +58,7 @@ import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; -public class BitSet { +class BitSet { private static final Object[] EMPTY_OBJECTS = new Object[0]; @@ -71,28 +68,18 @@ public class BitSet { private final Object[] objects; private final long allMask; private final TypeMirror type; - private NodeGeneratorPlugs plugs; - BitSet(String name, Object[] objects, NodeGeneratorPlugs plugs) { + BitSet(String name, Object[] objects) { this.name = name; this.objects = objects; this.capacity = intializeCapacity(); - TypeMirror typeTmp; if (capacity <= 32) { - typeTmp = ProcessorContext.getInstance().getType(int.class); + type = ProcessorContext.getInstance().getType(int.class); } else if (capacity <= 64) { - typeTmp = ProcessorContext.getInstance().getType(long.class); + type = ProcessorContext.getInstance().getType(long.class); } else { throw new UnsupportedOperationException("State space too big " + capacity + ". Only <= 64 supported."); } - - if (plugs != null) { - type = plugs.getBitSetType(typeTmp); - } else { - type = typeTmp; - } - - this.plugs = plugs; this.allMask = createMask(objects); } @@ -138,14 +125,10 @@ private CodeTree createLocalReference(FrameState frameState) { } } - public CodeTree createReference(FrameState frameState, boolean write) { + public CodeTree createReference(FrameState frameState) { CodeTree ref = createLocalReference(frameState); if (ref == null) { - if (plugs != null) { - ref = plugs.createBitSetReference(this, write); - } else { - ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); - } + ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); } return ref; } @@ -184,11 +167,7 @@ public CodeTree createLoad(FrameState frameState) { String fieldName = name + "_"; LocalVariable var = new LocalVariable(type, name, null); CodeTreeBuilder init = builder.create(); - if (plugs != null) { - init.tree(plugs.createBitSetReference(this, false)); - } else { - init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); - } + init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); builder.tree(var.createDeclaration(init.build())); frameState.set(name, var); return builder.build(); @@ -222,24 +201,17 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.tree(createMaskedReference(frameState, maskedElements)); builder.string(" == ").string(formatMask(createMask(selectedElements))); - builder.string("/* ", label("is-exact"), toString(selectedElements, "&&"), " */"); - return builder.build(); - } - - public CodeTree createIsEmpty(FrameState frameState) { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.tree(createReference(frameState, false)).string(" == 0"); return builder.build(); } private CodeTree createMaskedReference(FrameState frameState, long maskedElements) { if (maskedElements == this.allMask) { // no masking needed - return createReference(frameState, false); + return createReference(frameState); } else { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); // masking needed we use the state bitset for guards as well - builder.string("(").tree(createReference(frameState, false)).string(" & ").string(formatMask(maskedElements)).string(")"); + builder.string("(").tree(createReference(frameState)).string(" & ").string(formatMask(maskedElements)).string(")"); return builder.build(); } } @@ -358,7 +330,7 @@ public CodeTree createSet(FrameState frameState, Object[] elements, boolean valu if (!hasLocal && elements.length == 0) { return valueBuilder.build(); } - valueBuilder.tree(createReference(frameState, true)); + valueBuilder.tree(createReference(frameState)); if (elements.length > 0) { if (value) { valueBuilder.string(" | "); @@ -377,11 +349,7 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); if (persist) { - if (plugs != null) { - builder.tree(plugs.createBitSetReference(this, true)).string(" = "); - } else { - builder.string("this.", name, "_ = "); - } + builder.string("this.", name, "_ = "); // if there is a local variable we need to update it as well CodeTree localReference = createLocalReference(frameState); @@ -389,15 +357,9 @@ private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valu builder.tree(localReference).string(" = "); } } else { - builder.tree(createReference(frameState, true)).string(" = "); + builder.tree(createReference(frameState)).string(" = "); } - - CodeTree value = valueTree; - if (plugs != null) { - value = plugs.transformValueBeforePersist(value); - } - - builder.tree(value); + builder.tree(valueTree); builder.end(); // statement return builder.build(); } @@ -406,12 +368,9 @@ public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree int offset = getStateOffset(element); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); - builder.tree(createReference(frameState, true)).string(" = "); - if (type.getKind() != TypeKind.INT) { - builder.cast(type); - } + builder.tree(createReference(frameState)).string(" = "); builder.startParantheses(); - builder.tree(createReference(frameState, false)); + builder.tree(createReference(frameState)); builder.string(" | ("); if (capacity > 32) { builder.string("(long) "); @@ -455,30 +414,4 @@ private int getStateOffset(Object object) { return value; } - @Override - public String toString() { - return String.format("%s %s %s", getClass().getSimpleName(), getName(), Arrays.toString(getObjects())); - } - - @Override - public int hashCode() { - return Objects.hash(getClass(), getName()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - // names and types must be the same - if (obj.getClass() != getClass()) { - return false; - } - - BitSet bs = (BitSet) obj; - - return bs.getName().equals(getName()); - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 379a6fc2f186..d12212a2e7b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -200,29 +200,25 @@ public String toString() { private final boolean needsSpecializeLocking; private final GeneratorMode generatorMode; - private final NodeGeneratorPlugs plugs; - public enum GeneratorMode { DEFAULT, - EXPORTED_MESSAGE, - OPERATIONS, + EXPORTED_MESSAGE } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants, NodeGeneratorPlugs plugs) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, plugs); + StaticConstants constants) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants); } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, - StaticConstants constants, NodeGeneratorPlugs plugs) { + StaticConstants constants) { Objects.requireNonNull(node); this.generatorMode = mode; this.context = context; this.sharingNodes = stateSharingNodes; this.node = node; - this.plugs = plugs; this.typeSystem = node.getTypeSystem(); this.genericType = context.getType(Object.class); this.boxingEliminationEnabled = !TruffleProcessorOptions.generateSlowPathOnly(context.getEnvironment()); @@ -232,11 +228,6 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData this.sharedCaches = sharedCaches; List stateObjects = new ArrayList<>(); - if (plugs != null) { - plugs.setUseSpecializationClass(this::useSpecializationClass); - plugs.addAdditionalStateBits(stateObjects); - plugs.setNodeData(node); - } List excludeObjects = new ArrayList<>(); int activeStateStartIndex = -1; int activeStateEndIndex = -1; @@ -288,15 +279,9 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData if (activeStateEndIndex == -1) { activeStateEndIndex = stateObjects.size(); } - if (plugs != null) { - plugs.setStateObjects(stateObjects); - } this.multiState = createMultiStateBitset(stateObjects, activeStateStartIndex, activeStateEndIndex, volatileState); - if (plugs != null) { - plugs.setMultiState(this.multiState); - } this.allMultiState = new MultiStateBitSet(this.multiState.all, this.multiState.all); - this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState, plugs); + this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState); this.executeAndSpecializeType = createExecuteAndSpecializeType(); this.needsSpecializeLocking = exclude.getCapacity() != 0 || reachableSpecializations.stream().anyMatch((s) -> !s.getCaches().isEmpty()); @@ -312,10 +297,6 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData private MultiStateBitSet createMultiStateBitset(List stateObjects, int activeStateStartIndex, int activeStateEndIndex, boolean volatileState) { int maxBits = TruffleProcessorOptions.stateBitWidth(context.getEnvironment()); - if (plugs != null) { - maxBits = plugs.getMaxStateBits(maxBits); - } - int usedBits = 0; List allStateBits = new ArrayList<>(); List currentElements = new ArrayList<>(); @@ -337,7 +318,7 @@ private MultiStateBitSet createMultiStateBitset(List stateObjects, int a } allStateBits.add(new StateBitSet(currentElements.toArray(), relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size(), plugs)); + volatileState, allStateBits.size())); currentElements.clear(); relevantSpecializations.clear(); usedBits = 0; @@ -364,16 +345,13 @@ private MultiStateBitSet createMultiStateBitset(List stateObjects, int a allStateBits.add(new StateBitSet(currentElements.toArray(), relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size(), plugs)); + volatileState, allStateBits.size())); List activeStateBits = allStateBits.subList(activeStartBits, activeEndBits + 1); return new MultiStateBitSet(allStateBits, activeStateBits); } private boolean needsRewrites() { - if (plugs != null) { - return plugs.needsRewrites(); - } return node.needsRewrites(context); } @@ -394,18 +372,11 @@ private boolean hasMultipleNodes() { } private String createSpecializationTypeName(SpecializationData s) { - String result; if (hasMultipleNodes()) { - result = firstLetterUpperCase(getNodePrefix(s)) + firstLetterUpperCase(s.getId()) + "Data"; + return firstLetterUpperCase(getNodePrefix(s)) + firstLetterUpperCase(s.getId()) + "Data"; } else { - result = firstLetterUpperCase(s.getId()) + "Data"; + return firstLetterUpperCase(s.getId()) + "Data"; } - - if (plugs != null) { - result = plugs.transformNodeInnerTypeName(result); - } - - return result; } private String createSpecializationFieldName(SpecializationData s) { @@ -446,7 +417,7 @@ private String createAssumptionFieldName(SpecializationData specialization, Assu } } - public static String createSpecializationLocalName(SpecializationData s) { + private static String createSpecializationLocalName(SpecializationData s) { if (s == null) { return null; } @@ -461,18 +432,15 @@ private static String nodeFieldName(NodeExecutionData execution) { } } - private CodeTree accessNodeField(FrameState frame, NodeExecutionData execution) { - if (plugs != null) { - return plugs.createNodeFieldReference(frame, execution, nodeFieldName(execution), true); - } + private static String accessNodeField(NodeExecutionData execution) { if (execution.getChild() == null || execution.getChild().needsGeneratedField()) { - return CodeTreeBuilder.singleString("this." + nodeFieldName(execution)); + return "this." + nodeFieldName(execution); } else { String access = "super." + execution.getChild().getName(); if (execution.hasChildArrayIndex()) { access += "[" + execution.getChildArrayIndex() + "]"; } - return CodeTreeBuilder.singleString(access); + return access; } } @@ -532,13 +500,7 @@ private boolean useSpecializationClass(SpecializationData specialization) { return specialization.getMaximumNumberOfInstances() > 1; } - private boolean needsFrameToExecute(List specializations) { - if (plugs != null) { - Boolean result = plugs.needsFrameToExecute(specializations); - if (result != null) { - return result; - } - } + private static boolean needsFrameToExecute(List specializations) { for (SpecializationData specialization : specializations) { if (specialization.getFrame() != null) { return true; @@ -608,7 +570,6 @@ public CodeTypeElement create(CodeTypeElement clazz) { List executableTypes = filterExecutableTypes(node.getExecutableTypes(), reachableSpecializations); - List genericExecutableTypes = new ArrayList<>(); List specializedExecutableTypes = new ArrayList<>(); List voidExecutableTypes = new ArrayList<>(); @@ -664,10 +625,7 @@ public CodeTypeElement create(CodeTypeElement clazz) { } clazz.addOptional(createExecuteAndSpecialize()); - ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); - if (plugs != null) { - reportPolymorphismAction = plugs.createReportPolymorhoismAction(reportPolymorphismAction); - } + final ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); if (reportPolymorphismAction.required()) { clazz.addOptional(createCheckForPolymorphicSpecialize(reportPolymorphismAction)); if (requiresCacheCheck(reportPolymorphismAction)) { @@ -779,9 +737,6 @@ private void generateAOT(CodeTypeElement clazz) { clazz.getImplements().add(aotProviderType); CodeExecutableElement prepare = clazz.add(CodeExecutableElement.cloneNoAnnotations(ElementUtils.findMethod(types.GenerateAOT_Provider, "prepareForAOT"))); - if (plugs != null) { - prepare.setSimpleName(CodeNames.of(plugs.transformNodeMethodName(prepare.getSimpleName().toString()))); - } prepare.renameArguments("language", "root"); GeneratorUtils.addOverride(prepare); prepare.getModifiers().remove(ABSTRACT); @@ -827,11 +782,9 @@ private void generateAOT(CodeTypeElement clazz) { } } - CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); - builder.startAssert(); builder.string("!isAdoptable() || "); - builder.string("(").cast(context.getType(ReentrantLock.class), getLockTree); + builder.string("(").cast(context.getType(ReentrantLock.class), CodeTreeBuilder.singleString("getLock()")); builder.string(").isHeldByCurrentThread()"); builder.string(" : ").doubleQuote("During prepare AST lock must be held."); builder.end(); @@ -918,11 +871,11 @@ private void generateAOT(CodeTypeElement clazz) { */ boolean cachedLibrary = cache.isCachedLibrary(); if (cachedLibrary) { - builder.startIf().tree(createCacheReference(innerFrameState, specialization, cache, true)).instanceOf(aotProviderType).end().startBlock(); + builder.startIf().tree(createCacheReference(innerFrameState, specialization, cache)).instanceOf(aotProviderType).end().startBlock(); } if (NodeCodeGenerator.isSpecializedNode(cache.getParameter().getType()) || cachedLibrary) { builder.startAssert().startStaticCall(types.NodeUtil, "assertRecursion"); - builder.tree(createCacheReference(innerFrameState, specialization, cache, true)); + builder.tree(createCacheReference(innerFrameState, specialization, cache)); /* * We allow a single recursion level only for AOT preparation. It is important * that we only assert recursion for @Cached fields as regular AST children can @@ -936,7 +889,7 @@ private void generateAOT(CodeTypeElement clazz) { builder.startStatement(); builder.string("("); builder.cast(aotProviderType); - builder.tree(createCacheReference(innerFrameState, specialization, cache, true)); + builder.tree(createCacheReference(innerFrameState, specialization, cache)); builder.string(")"); builder.string(".prepareForAOT(language, root)"); builder.end(); @@ -965,12 +918,7 @@ private void generateAOT(CodeTypeElement clazz) { return; } - String resetName = "resetAOT_"; - if (plugs != null) { - resetName = plugs.transformNodeMethodName(resetName); - } - - CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), resetName)); + CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), "resetAOT_")); frameState = FrameState.load(this, NodeExecutionMode.FAST_PATH, reset); reset.getModifiers().remove(ABSTRACT); builder = reset.createBuilder(); @@ -1004,7 +952,7 @@ private void generateAOT(CodeTypeElement clazz) { builder.startBlock(); for (CacheExpression cache : resetCaches) { builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache, true)); + builder.tree(createCacheReference(frameState, specialization, cache)); builder.string(".reset()"); builder.end(); } @@ -1036,7 +984,7 @@ private void generateAOT(CodeTypeElement clazz) { break; } builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache, false)).string(" = null"); + builder.tree(createCacheReference(frameState, specialization, cache)).string(" = null"); builder.end(); } } @@ -1071,11 +1019,11 @@ public CodeTree createInitializeCaches(SpecializationData specialization, List { + return lookupConstant(constants.languageReferences, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(languageReference.asType(), "create").typeLiteral(languageType).end(); return newVar; @@ -1588,7 +1536,7 @@ public static CodeVariableElement createContextReferenceConstant(StaticConstants String constantName = ElementUtils.createConstantName(ElementUtils.getSimpleName(languageType) + "Cref"); TypeElement contextReference = (TypeElement) types.TruffleLanguage_ContextReference.asElement(); DeclaredCodeTypeMirror constantType = new DeclaredCodeTypeMirror(contextReference, Arrays.asList(NodeParser.findContextTypeFromLanguage(languageType))); - return lookupConstant(constants, constants.languageReferences, constantName, (name) -> { + return lookupConstant(constants.languageReferences, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(contextReference.asType(), "create").typeLiteral(languageType).end(); return newVar; @@ -1610,28 +1558,22 @@ public static CodeVariableElement createLibraryConstant(StaticConstants constant String constantName = ElementUtils.createConstantName(libraryType.getSimpleName().toString()); TypeElement resolvedLibrary = (TypeElement) ProcessorContext.getInstance().getTypes().LibraryFactory.asElement(); DeclaredCodeTypeMirror constantType = new DeclaredCodeTypeMirror(resolvedLibrary, Arrays.asList(libraryType.asType())); - return lookupConstant(constants, constants.libraries, constantName, (name) -> { + return lookupConstant(constants.libraries, constantName, (name) -> { CodeVariableElement newVar = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), constantType, name); newVar.createInitBuilder().startStaticCall(resolvedLibrary.asType(), "resolve").typeLiteral(libraryType.asType()).end(); return newVar; }); } - private static CodeVariableElement lookupConstant(StaticConstants sc, Map constants, String constantName, Function factory) { + private static CodeVariableElement lookupConstant(Map constants, String constantName, Function factory) { String useConstantName = constantName + "_"; while (true) { CodeVariableElement prev = constants.get(useConstantName); CodeVariableElement var = factory.apply(useConstantName); - if (sc.ignoreEnclosingType) { - var.setEnclosingElement(null); - } if (prev == null) { constants.put(useConstantName, var); return var; } else { - if (sc.ignoreEnclosingType) { - prev.setEnclosingElement(null); - } if (ElementUtils.variableEquals(prev, var)) { return prev; } @@ -1840,10 +1782,6 @@ private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTyp implementedSpecializations = compatibleSpecializations; } - if (plugs != null) { - implementedSpecializations = plugs.filterSpecializations(implementedSpecializations); - } - if (implementedSpecializations.isEmpty()) { builder.tree(GeneratorUtils.createShouldNotReachHere("Delegation failed.")); } else { @@ -1878,10 +1816,6 @@ private CodeExecutableElement createUncachedExecute(ExecutableTypeData forType) CodeTreeBuilder builder = method.createBuilder(); - if (plugs != null) { - plugs.initializeFrameState(frameState, builder); - } - int effectiveEvaluatedCount = forType.getEvaluatedCount(); while (effectiveEvaluatedCount < node.getExecutionCount()) { NodeExecutionData childExecution = node.getChildExecutions().get(effectiveEvaluatedCount); @@ -2041,41 +1975,27 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, } private String createFallbackName() { - String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - result = firstLetterLowerCase(messageName) + "FallbackGuard_"; + return firstLetterLowerCase(messageName) + "FallbackGuard_"; } else { - result = "fallbackGuard_"; + return "fallbackGuard_"; } - - if (plugs != null) { - result = plugs.transformNodeMethodName(result); - } - - return result; } private String createExecuteAndSpecializeName() { - String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - result = firstLetterLowerCase(messageName) + "AndSpecialize"; + return firstLetterLowerCase(messageName) + "AndSpecialize"; } else { - result = "executeAndSpecialize"; - } - - if (plugs != null) { - result = plugs.createExecuteAndSpecializeName(result); + return "executeAndSpecialize"; } - - return result; } private CodeExecutableElement createExecuteAndSpecialize() { @@ -2092,28 +2012,13 @@ private CodeExecutableElement createExecuteAndSpecialize() { frameState.addParametersTo(method, Integer.MAX_VALUE, frame); final CodeTreeBuilder builder = method.createBuilder(); - - if (plugs != null) { - plugs.initializeFrameState(frameState, builder); - } - - CodeTree getLockTree; - if (plugs != null) { - getLockTree = plugs.createGetLock(); - } else { - getLockTree = CodeTreeBuilder.singleString("getLock()"); - } - if (needsSpecializeLocking) { - builder.declaration(context.getType(Lock.class), "lock", getLockTree); + builder.declaration(context.getType(Lock.class), "lock", "getLock()"); builder.declaration(context.getType(boolean.class), "hasLock", "true"); builder.statement("lock.lock()"); } ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); - if (plugs != null) { - reportPolymorphismAction = plugs.createReportPolymorhoismAction(reportPolymorphismAction); - } if (needsSpecializeLocking) { builder.startTryBlock(); @@ -2123,15 +2028,7 @@ private CodeExecutableElement createExecuteAndSpecialize() { builder.startIf(); builder.tree(allMultiState.createContains(frameState, new Object[]{AOT_PREPARED})); builder.end().startBlock(); - String resetName = "resetAOT_"; - if (plugs != null) { - resetName = plugs.transformNodeMethodName(resetName); - } - builder.startStatement().startCall(resetName); - if (plugs != null) { - plugs.addNodeCallParameters(builder, false, false); - } - builder.end(2); + builder.startStatement().startCall("this.resetAOT_").end().end(); builder.end(); } @@ -2151,7 +2048,7 @@ private CodeExecutableElement createExecuteAndSpecialize() { builder.tree(execution); - if (group.hasFallthroughInSlowPath()) { + if (group.hasFallthrough()) { builder.tree(createThrowUnsupported(builder, originalFrameState)); } @@ -2186,22 +2083,15 @@ private CodeExecutableElement createExecuteAndSpecialize() { private static final String COUNT_CACHES = "countCaches"; private String createName(String defaultName) { - String result; if (hasMultipleNodes()) { String messageName = node.getNodeId(); if (messageName.endsWith("Node")) { messageName = messageName.substring(0, messageName.length() - 4); } - result = firstLetterLowerCase(messageName) + "_" + defaultName; + return firstLetterLowerCase(messageName) + "_" + defaultName; } else { - result = defaultName; - } - - if (plugs != null) { - result = plugs.transformNodeMethodName(result); + return defaultName; } - - return result; } private boolean requiresCacheCheck(ReportPolymorphismAction reportPolymorphismAction) { @@ -2239,7 +2129,7 @@ private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction rep builder.declaration(s.getType(), s.getNewName(), s.createMaskedReference(frameState, reachableSpecializationsReportingPolymorphism())); } if (requiresExclude) { - builder.declaration(exclude.getType(), NEW_EXCLUDE, exclude.createReference(frameState, false)); + builder.declaration(exclude.getType(), NEW_EXCLUDE, exclude.createReference(frameState)); } } builder.startIf(); @@ -2362,8 +2252,6 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram ExecutableElement method = parent.findMethod(); if (method != null && method.getModifiers().contains(STATIC)) { builder.string("null"); - } else if (generatorMode == GeneratorMode.OPERATIONS) { - builder.string("$this"); } else { builder.string("this"); } @@ -2373,10 +2261,8 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram for (NodeExecutionData execution : node.getChildExecutions()) { NodeChildData child = execution.getChild(); LocalVariable var = frameState.getValue(execution); - if (plugs != null) { - builder.tree(plugs.createThrowUnsupportedChild(execution)); - } else if (child != null && !frameState.getMode().isUncached()) { - builder.tree(accessNodeField(frameState, execution)); + if (child != null && !frameState.getMode().isUncached()) { + builder.string(accessNodeField(execution)); } else { builder.string("null"); } @@ -2385,11 +2271,7 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram } } builder.end(); - if (plugs != null) { - builder.trees(plugs.createThrowUnsupportedValues(frameState, values, parent, builder)); - } else { - builder.trees(values.toArray(new CodeTree[0])); - } + builder.trees(values.toArray(new CodeTree[0])); builder.end().end(); return builder.build(); @@ -2434,25 +2316,17 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List List boxingSplits = parameterBoxingElimination(originalGroup, sharedExecutes); - if (plugs != null) { - plugs.setBoxingSplits(boxingSplits); - } - if (boxingSplits.isEmpty()) { builder.tree(executeFastPathGroup(builder, frameState, currentType, originalGroup, sharedExecutes, null)); addExplodeLoop(builder, originalGroup); } else { - if (plugs != null) { - plugs.initializeFrameState(frameState, builder); - } - FrameState originalFrameState = frameState.copy(); boolean elseIf = false; for (BoxingSplit split : boxingSplits) { elseIf = builder.startIf(elseIf); builder.startGroup(); - List specializations = split.getGroup().collectSpecializations(); + List specializations = split.group.collectSpecializations(); CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), allSpecializations.toArray()); if (!tree.isEmpty()) { builder.tree(tree); @@ -2461,8 +2335,8 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List builder.tree(multiState.createIsNotAny(frameState, allSpecializations.toArray())); builder.end(); builder.end().startBlock(); - builder.tree(wrapInAMethod(builder, split.getGroup(), originalFrameState, split.getName(), - executeFastPathGroup(builder, frameState.copy(), currentType, split.getGroup(), sharedExecutes, specializations))); + builder.tree(wrapInAMethod(builder, split.group, originalFrameState, split.getName(), + executeFastPathGroup(builder, frameState.copy(), currentType, split.group, sharedExecutes, specializations))); builder.end(); } @@ -2487,18 +2361,9 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group CodeExecutableElement parentMethod = (CodeExecutableElement) parent.findMethod(); CodeTypeElement parentClass = (CodeTypeElement) parentMethod.getEnclosingElement(); String name = parentMethod.getSimpleName().toString() + "_" + suffix + (boxingSplitIndex++); - - String[] optNames; - - if (plugs != null) { - name = plugs.transformNodeMethodName(name); - optNames = new String[0]; - } else { - optNames = new String[]{FRAME_VALUE}; - } CodeExecutableElement method = parentClass.add(new CodeExecutableElement(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name)); multiState.addParametersTo(frameState, method); - frameState.addParametersTo(method, Integer.MAX_VALUE, optNames); + frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); CodeTreeBuilder builder = method.createBuilder(); builder.tree(codeTree); method.getThrownTypes().addAll(parentMethod.getThrownTypes()); @@ -2507,11 +2372,8 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group CodeTreeBuilder parentBuilder = parent.create(); parentBuilder.startReturn(); parentBuilder.startCall(method.getSimpleName().toString()); - if (plugs != null) { - plugs.addNodeCallParameters(parentBuilder, false, false); - } multiState.addReferencesTo(frameState, parentBuilder); - frameState.addReferencesTo(parentBuilder, optNames); + frameState.addReferencesTo(parentBuilder, FRAME_VALUE); parentBuilder.end(); parentBuilder.end(); return parentBuilder.build(); @@ -2521,10 +2383,6 @@ private CodeTree executeFastPathGroup(final CodeTreeBuilder parent, FrameState f List allowedSpecializations) { CodeTreeBuilder builder = parent.create(); - if (plugs != null) { - plugs.initializeFrameState(frameState, builder); - } - if (currentType.getMethod() != null && currentType.getMethod().isVarArgs()) { int readVarargsCount = node.getSignatureSize() - (currentType.getEvaluatedCount() - 1); int offset = node.getSignatureSize() - 1; @@ -2640,7 +2498,7 @@ private List parameterBoxingElimination(SpecializationGroup group, Collections.sort(groups, new Comparator() { public int compare(BoxingSplit o1, BoxingSplit o2) { - return Integer.compare(o2.getPrimitiveSignature().length, o1.getPrimitiveSignature().length); + return Integer.compare(o2.primitiveSignature.length, o1.primitiveSignature.length); } }); @@ -2754,8 +2612,7 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt boolean found = false; for (NodeExecutionData otherExecution : node.getChildExecutions()) { if (found) { - TypeMirror genericReturnType = otherExecution.getChild().findAnyGenericExecutableType(context).getReturnType(); - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericReturnType); + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericType); builder.tree(createAssignExecuteChild(slowPathFrameState.copy(), slowPathFrameState, builder, otherExecution, delegateType, childEvaluatedValue)); slowPathFrameState.setValue(otherExecution, childEvaluatedValue); } else { @@ -2849,12 +2706,7 @@ private CodeExecutableElement createNodeConstructor(CodeTypeElement clazz, Execu CreateCastData createCast = node.findCast(execution.getChild().getName()); builder.startStatement(); - if (plugs != null) { - builder.tree(plugs.createNodeFieldReference(null, execution, nodeFieldName(execution), false)); - } else { - builder.string("this.").string(nodeFieldName(execution)); - } - builder.string(" = "); + builder.string("this.").string(nodeFieldName(execution)).string(" = "); String name = childValues.get(node.getChildren().indexOf(execution.getChild())); CodeTree accessor; @@ -3041,12 +2893,12 @@ private ExecutableElement createAccessChildMethod(NodeChildData child, boolean u if (child.getCardinality().isMany()) { builder.startReturn().startNewArray((ArrayType) child.getOriginalType(), null); for (NodeExecutionData execution : executions) { - builder.tree(accessNodeField(null, execution)); + builder.string(accessNodeField(execution)); } builder.end().end(); } else { for (NodeExecutionData execution : executions) { - builder.startReturn().tree(accessNodeField(null, execution)).end(); + builder.startReturn().string(accessNodeField(execution)).end(); break; } } @@ -3165,10 +3017,7 @@ private CodeTree[] bindExecuteMethodParameters(NodeExecutionData execution, Exec } private CodeTree callChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { - if (plugs != null) { - return plugs.createCallChildExecuteMethod(execution, method, frameState); - } - return callMethod(frameState, accessNodeField(frameState, execution), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); + return callMethod(frameState, CodeTreeBuilder.singleString(accessNodeField(execution)), method.getMethod(), bindExecuteMethodParameters(execution, method, frameState)); } private CodeTree callUncachedChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { @@ -3245,7 +3094,7 @@ private CodeTree cast(TypeMirror sourceType, TypeMirror targetType, CodeTree con private CodeTree expect(TypeMirror sourceType, TypeMirror forType, CodeTree tree) { if (sourceType == null || needsCastTo(sourceType, forType)) { expectedTypes.add(forType); - return TypeSystemCodeGenerator.expect(typeSystem, forType, tree, plugs); + return TypeSystemCodeGenerator.expect(typeSystem, forType, tree); } return tree; } @@ -3260,14 +3109,9 @@ private CodeExecutableElement createExecuteMethod(ExecutableTypeData executedTyp methodName = executedType.getUniqueName(); } - if (plugs != null) { - methodName = plugs.transformNodeMethodName(methodName); - } - CodeExecutableElement executable; if (executedType.getMethod() != null) { executable = CodeExecutableElement.clone(executedType.getMethod()); - executable.setSimpleName(CodeNames.of(methodName)); executable.getAnnotationMirrors().clear(); executable.getModifiers().remove(ABSTRACT); for (VariableElement var : executable.getParameters()) { @@ -3338,7 +3182,7 @@ private boolean needsUnexpectedResultException(ExecutableTypeData executedType) } } - private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableTypeData forType, SpecializationData specialization, FrameState frameState, boolean inBoundary) { + private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableTypeData forType, SpecializationData specialization, FrameState frameState) { CodeTreeBuilder builder = parent.create(); int ifCount = 0; if (specialization.isFallback()) { @@ -3347,35 +3191,29 @@ private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableT builder.tree(multiState.createLoad(frameState, fallbackState)); } builder.startIf().startCall(createFallbackName()); - if (plugs != null) { - plugs.addNodeCallParameters(builder, false, false); - } if (fallbackNeedsState) { multiState.addReferencesTo(frameState, builder, fallbackState); } - if (plugs == null || plugs.shouldIncludeValuesInCall()) { - if (fallbackNeedsFrame) { - if (frameState.get(FRAME_VALUE) != null) { - builder.string(FRAME_VALUE); - } else { - builder.nullLiteral(); - } + if (fallbackNeedsFrame) { + if (frameState.get(FRAME_VALUE) != null) { + builder.string(FRAME_VALUE); + } else { + builder.nullLiteral(); } - frameState.addReferencesTo(builder); } + frameState.addReferencesTo(builder); builder.end(); builder.end(); builder.startBlock(); ifCount++; } - builder.tree(createCallSpecialization(builder, frameState, forType, specialization, inBoundary)); + builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); builder.end(ifCount); - return builder.build(); } - private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState parentState, final ExecutableTypeData forType, SpecializationData specialization, boolean inBoundary) { + private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState parentState, final ExecutableTypeData forType, SpecializationData specialization) { CodeTreeBuilder builder = parent.create(); FrameState frameState = parentState.copy(); @@ -3388,9 +3226,6 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par builder.statement("hasLock = false"); } - int numCachedNullChecks = 0; - boolean useSpecializationClass = useSpecializationClass(specialization); - if (specialization.getMethod() == null) { builder.tree(createThrowUnsupported(builder, frameState)); } else { @@ -3400,24 +3235,11 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par Parameter parameter = specialization.getParameters().get(i); if (parameter.getSpecification().isCached()) { - String fieldName = createFieldName(specialization, parameter); - LocalVariable var = frameState.get(fieldName); + LocalVariable var = frameState.get(createFieldName(specialization, parameter)); if (var != null) { bindings[i] = var.createReference(); - } - if (var == null) { - CodeTree cacheReference = createCacheReference(frameState, specialization, specialization.findCache(parameter), true); - if (generatorMode == GeneratorMode.OPERATIONS && frameState.getMode() == NodeExecutionMode.FAST_PATH && !useSpecializationClass) { - String localName = createCacheLocalName(specialization, specialization.findCache(parameter)); - var = new LocalVariable(parameter.getType(), localName, null); - frameState.set(fieldName, var); - builder.tree(var.createDeclaration(cacheReference)); - bindings[i] = var.createReference(); - builder.startIf().tree(var.createReference()).string(" != null").end().startBlock(); - numCachedNullChecks++; - } else { - bindings[i] = cacheReference; - } + } else { + bindings[i] = createCacheReference(frameState, specialization, specialization.findCache(parameter)); } bindingTypes[i] = parameter.getType(); } else { @@ -3468,11 +3290,6 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par builder.tree(expectOrCast(specialization.getReturnType().getType(), forType, specializationCall)); builder.end(); } - - builder.end(numCachedNullChecks); - if (numCachedNullChecks > 0 && inBoundary) { - builder.startThrow().staticReference(types.BoundaryCallFailedException, "INSTANCE").end(); - } } return createCatchRewriteException(builder, specialization, forType, frameState, builder.build()); @@ -3699,16 +3516,11 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization boolean useSpecializationClass = specialization != null && useSpecializationClass(specialization); boolean needsRewrites = needsRewrites(); - String encapsulatingThis = generatorMode == GeneratorMode.OPERATIONS ? "$this" : "this"; - if (mode.isFastPath()) { BlockState ifCount = BlockState.NONE; - boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && + final boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && group.getAllSpecializations().size() == allowedSpecializations.size(); - if (plugs != null) { - stateGuaranteed = plugs.isStateGuaranteed(stateGuaranteed); - } if (needsRewrites && (!group.isEmpty() || specialization != null)) { CodeTree stateCheck = multiState.createContains(frameState, specializations); CodeTree stateGuard = null; @@ -3774,7 +3586,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } if (pushEncapsulatingNode && libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(builder, encapsulatingThis); + GeneratorUtils.pushEncapsulatingNode(builder, "this"); builder.startTryBlock(); } @@ -3799,11 +3611,6 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } nonBoundaryIfCount = nonBoundaryIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(nonBoundaryGuards), false)); innerBuilder = extractInBoundaryMethod(builder, frameState, specialization); - frameState.setBoolean("operations_had_cache_null_check", false); - - if (plugs != null) { - plugs.initializeFrameState(innerFrameState, innerBuilder); - } for (NodeExecutionData execution : specialization.getNode().getChildExecutions()) { int index = forType.getVarArgsIndex(forType.getParameterIndex(execution.getIndex())); @@ -3826,7 +3633,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } if (pushEncapsulatingNode && !libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(innerBuilder, encapsulatingThis); + GeneratorUtils.pushEncapsulatingNode(innerBuilder, "this"); innerBuilder.startTryBlock(); } @@ -3834,7 +3641,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization innerIfCount = innerIfCount.add(IfTriple.materialize(innerBuilder, IfTriple.optimize(cachedTriples), false)); prev = visitSpecializationGroupChildren(builder, innerFrameState, prev, group, forType, allowedSpecializations); if (specialization != null && (prev == null || prev.hasFallthrough())) { - innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState, extractInBoundary)); + innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState)); } innerBuilder.end(innerIfCount.blockCount); @@ -3861,8 +3668,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.end(ifCount.blockCount); - - hasFallthrough |= ifCount.blockCount > 0; + hasFallthrough |= ifCount.ifCount > 0; } else if (mode.isSlowPath()) { @@ -3898,7 +3704,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization boolean pushBoundary = specialization.needsPushEncapsulatingNode(); if (pushBoundary) { builder.startBlock(); - GeneratorUtils.pushEncapsulatingNode(builder, encapsulatingThis); + GeneratorUtils.pushEncapsulatingNode(builder, "this"); builder.startTryBlock(); } BlockState innerIfCount = BlockState.NONE; @@ -3959,10 +3765,6 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.tree(multiState.createSet(frameState, new SpecializationData[]{specialization}, true, true)); - if (plugs != null) { - plugs.createSpecialize(frameState, specialization, builder); - } - if (needsDuplicationCheck) { hasFallthrough = true; if (useDuplicateFlag) { @@ -3998,10 +3800,10 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } builder.end().startBlock(); - builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization, false)); + builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization)); builder.end(); } else { - builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization, false)); + builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization)); builder.end(innerIfCount.blockCount); hasFallthrough |= innerIfCount.ifCount > 0; } @@ -4067,7 +3869,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); if (specialization != null && (prev == null || prev.hasFallthrough())) { - builder.tree(createCallSpecialization(builder, frameState, forType, specialization, false)); + builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); } builder.end(innerIfCount.blockCount); builder.end(ifCount.blockCount); @@ -4116,14 +3918,9 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt if (usedBoundaryNames.contains(boundaryMethodName)) { boundaryMethodName = boundaryMethodName + (boundaryIndex++); } - usedBoundaryNames.add(boundaryMethodName); - if (plugs != null) { - boundaryMethodName = plugs.transformNodeMethodName(boundaryMethodName); - } - - String includeFrameParameter; + String includeFrameParameter = null; if (specialization != null && specialization.getFrame() != null) { if (ElementUtils.typeEquals(types.MaterializedFrame, specialization.getFrame().getType())) { includeFrameParameter = FRAME_VALUE; @@ -4133,10 +3930,7 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt LocalVariable materializedFrame = new LocalVariable(types.MaterializedFrame, FRAME_VALUE, read.build()); frameState.set(includeFrameParameter, materializedFrame); } - } else { - includeFrameParameter = null; } - CodeExecutableElement boundaryMethod = new CodeExecutableElement(modifiers(PRIVATE), parentMethod.getReturnType(), boundaryMethodName); GeneratorUtils.mergeSupressWarnings(boundaryMethod, "static-method"); multiState.addParametersTo(frameState, boundaryMethod); @@ -4147,16 +3941,10 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt boundaryMethod.getThrownTypes().addAll(parentMethod.getThrownTypes()); innerBuilder = boundaryMethod.createBuilder(); ((CodeTypeElement) parentMethod.getEnclosingElement()).add(boundaryMethod); - - builder.startTryBlock(); - builder.startReturn().startCall(boundaryMethodName); - if (plugs != null) { - plugs.addNodeCallParameters(builder, true, false); - } + builder.startReturn().startCall("this", boundaryMethod); multiState.addReferencesTo(frameState, builder); frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); builder.end().end(); - builder.end().startCatchBlock(types.BoundaryCallFailedException, "ex").end(); return innerBuilder; } @@ -4334,7 +4122,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (types.Profile != null && ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile)) { CodeTreeBuilder b = builder.create(); b.startStatement(); - b.tree(createCacheReference(frameState, specialization, cache, true)); + b.tree(createCacheReference(frameState, specialization, cache)); b.string(".disable()"); b.end(); triples.add(new IfTriple(null, null, b.build())); @@ -4360,14 +4148,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, builder.tree(exclude.createSet(frameState, excludesArray, true, true)); for (SpecializationData excludes : excludesArray) { if (useSpecializationClass(excludes)) { - if (plugs != null) { - builder.startStatement(); - builder.tree(plugs.createSpecializationFieldReference(frameState, excludes, null, createSpecializationTypeMirror(specialization), true)); - builder.string(" = null"); - builder.end(); - } else { - builder.statement("this." + createSpecializationFieldName(excludes) + " = null"); - } + builder.statement("this." + createSpecializationFieldName(excludes) + " = null"); } } builder.tree((multiState.createSet(frameState, excludesArray, false, false))); @@ -4447,11 +4228,7 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.end(); builder.end(); builder.startStatement(); - if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, createSpecializationTypeMirror(specialization), true)); - } else { - builder.string("this.", createSpecializationFieldName(specialization)); - } + builder.string("this.", createSpecializationFieldName(specialization)); builder.string(" = "); builder.tree(ref); builder.end(); @@ -4480,27 +4257,21 @@ private Collection initializeSpecializationClass(FrameState GeneratedTypeMirror type = new GeneratedTypeMirror("", typeName); CodeTreeBuilder initBuilder = new CodeTreeBuilder(null); + boolean isNode = specializationClassIsNode(specialization); + if (isNode) { + initBuilder.startCall("super", "insert"); + } initBuilder.startNew(typeName); if (specialization.getMaximumNumberOfInstances() > 1) { - if (plugs != null) { - initBuilder.tree(plugs.createSpecializationFieldReference(frameState, specialization, null, - createSpecializationTypeMirror(specialization), false)); - } else { - initBuilder.string(createSpecializationFieldName(specialization)); - } + initBuilder.string(createSpecializationFieldName(specialization)); } initBuilder.end(); // new + if (isNode) { + initBuilder.end(); + } CodeTree init = initBuilder.build(); - if (specializationClassIsNode(specialization)) { - if (plugs != null) { - init = plugs.createSuperInsert(init); - } else { - init = CodeTreeBuilder.createBuilder().startCall("super", "insert").tree(init).end().build(); - } - } - CodeTreeBuilder builder = new CodeTreeBuilder(null); builder.startStatement(); if (frameState.get(localName) == null) { @@ -4566,7 +4337,7 @@ private static CodeTree createTryExecuteChild(LocalVariable value, CodeTree exec CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); boolean hasDeclaration = false; if ((hasTry || !executeChild.isSingleLine()) && needDeclaration) { - builder.startStatement().type(value.getTypeMirror()).string(" ", value.getName()).end(); + builder.tree(value.createDeclaration(null)); hasDeclaration = true; } @@ -4632,8 +4403,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState // slow path might be already already locked if (!frameState.getMode().isSlowPath()) { - CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); - builder.declaration(context.getType(Lock.class), "lock", getLockTree); + builder.declaration(context.getType(Lock.class), "lock", "getLock()"); } if (needsSpecializeLocking) { @@ -4654,13 +4424,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState for (SpecializationData removeSpecialization : specializations) { if (useSpecializationClass(removeSpecialization)) { String fieldName = createSpecializationFieldName(removeSpecialization); - builder.startStatement(); - if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, removeSpecialization, fieldName, createSpecializationTypeMirror(specialization), true)); - } else { - builder.string("this." + fieldName); - } - builder.string(" = null").end(); + builder.statement("this." + fieldName + " = null"); } } @@ -4675,7 +4439,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState if (hasReexecutingRewrite) { if (hasUnexpectedResultRewrite) { builder.startIf().string("ex").instanceOf(types.UnexpectedResultException).end().startBlock(); - builder.tree(createReturnUnexpectedResult(frameState, forType, true)); + builder.tree(createReturnUnexpectedResult(forType, true)); builder.end().startElseBlock(); builder.tree(createCallExecuteAndSpecialize(forType, frameState)); builder.end(); @@ -4684,7 +4448,7 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState } } else { assert hasUnexpectedResultRewrite; - builder.tree(createReturnUnexpectedResult(frameState, forType, false)); + builder.tree(createReturnUnexpectedResult(forType, false)); } builder.end(); @@ -4696,69 +4460,43 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, String specializationLocalName = createSpecializationLocalName(specialization); boolean useSpecializationClass = useSpecializationClass(specialization); if (method == null) { - String methodName = "remove" + specialization.getId() + "_"; - if (plugs != null) { - methodName = plugs.transformNodeMethodName(methodName); - } - method = new CodeExecutableElement(context.getType(void.class), methodName); + method = new CodeExecutableElement(context.getType(void.class), "remove" + specialization.getId() + "_"); if (useSpecializationClass) { method.addParameter(new CodeVariableElement(context.getType(Object.class), specializationLocalName)); } CodeTreeBuilder builder = method.createBuilder(); - - FrameState innerFrameState = FrameState.createEmpty(); - - if (plugs != null) { - plugs.initializeFrameState(innerFrameState, builder); - } - if (needsSpecializeLocking) { - CodeTree getLockTree = plugs != null ? plugs.createGetLock() : CodeTreeBuilder.singleString("getLock()"); - builder.declaration(context.getType(Lock.class), "lock", getLockTree); + builder.declaration(context.getType(Lock.class), "lock", "getLock()"); builder.statement("lock.lock()"); builder.startTryBlock(); } - CodeTree fieldRef = CodeTreeBuilder.singleString("this." + createSpecializationFieldName(specialization)); - CodeTree fieldRefWrite = fieldRef; - if (plugs != null) { - String fieldName = useSpecializationClass ? null : createSpecializationFieldName(specialization); - TypeMirror typeMirror = createSpecializationTypeMirror(specialization); - fieldRef = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, typeMirror, false); - fieldRefWrite = plugs.createSpecializationFieldReference(innerFrameState, specialization, fieldName, typeMirror, true); - } + String fieldName = createSpecializationFieldName(specialization); if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { // single instance remove builder.tree((multiState.createSet(null, new Object[]{specialization}, false, true))); if (useSpecializationClass) { - builder.startStatement().tree(fieldRef).string(" = null").end(); + builder.statement("this." + fieldName + " = null"); } } else { // multi instance remove String typeName = createSpecializationTypeName(specialization); boolean specializedIsNode = specializationClassIsNode(specialization); builder.declaration(typeName, "prev", "null"); - builder.declaration(typeName, "cur", fieldRef); + builder.declaration(typeName, "cur", "this." + fieldName); builder.startWhile(); builder.string("cur != null"); builder.end().startBlock(); builder.startIf().string("cur == ").string(specializationLocalName).end().startBlock(); builder.startIf().string("prev == null").end().startBlock(); - builder.startStatement().tree(fieldRefWrite).string(" = "); + builder.statement("this." + fieldName + " = cur.next_"); if (specializedIsNode) { - if (generatorMode == GeneratorMode.OPERATIONS) { - builder.string("$this.insertAccessor"); - } else { - builder.string("this.insert"); - } + builder.statement("this.adoptChildren()"); } - builder.string("(cur.next_)").end(); builder.end().startElseBlock(); - builder.startStatement().string("prev.next_ = "); + builder.statement("prev.next_ = cur.next_"); if (specializedIsNode) { - builder.string("prev.", useInsertAccessor(specialization, false)); + builder.statement("prev.adoptChildren()"); } - builder.string("(cur.next_)").end(); - builder.end(); builder.statement("break"); builder.end(); // if block @@ -4766,7 +4504,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, builder.statement("cur = cur.next_"); builder.end(); // while block - builder.startIf().tree(fieldRefWrite).string(" == null").end().startBlock(); + builder.startIf().string("this." + fieldName).string(" == null").end().startBlock(); builder.tree((multiState.createSet(null, Arrays.asList(specialization).toArray(new SpecializationData[0]), false, true))); builder.end(); } @@ -4780,9 +4518,6 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, } CodeTreeBuilder builder = parent.create(); builder.startStatement().startCall(method.getSimpleName().toString()); - if (plugs != null) { - plugs.addNodeCallParameters(builder, false, true); - } if (useSpecializationClass) { builder.string(specializationLocalName); } @@ -4791,10 +4526,6 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, return builder.build(); } - private TypeMirror createSpecializationTypeMirror(SpecializationData specialization) { - return new GeneratedTypeMirror("", createSpecializationTypeName(specialization)); - } - private CodeTree createCallExecute(ExecutableTypeData forType, ExecutableTypeData targetType, FrameState frameState) { TypeMirror returnType = targetType.getReturnType(); @@ -4826,12 +4557,7 @@ private CodeTree createCallExecute(ExecutableTypeData forType, ExecutableTypeDat } } - CodeTree call; - if (plugs == null) { - call = callMethod(frameState, null, targetType.getMethod(), bindings.toArray(new CodeTree[0])); - } else { - call = plugs.createCallExecute(frameState, targetType.getMethod(), bindings.toArray(new CodeTree[0])); - } + CodeTree call = callMethod(frameState, null, targetType.getMethod(), bindings.toArray(new CodeTree[0])); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder = builder.create(); if (isVoid(forType.getReturnType())) { @@ -4854,30 +4580,23 @@ private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, Fram CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startCall(createExecuteAndSpecializeName()); - if (plugs != null) { - plugs.addNodeCallParameters(builder, false, false); - } - if (plugs == null || plugs.shouldIncludeValuesInCall()) { - frameState.addReferencesTo(builder, frame); - } + frameState.addReferencesTo(builder, frame); builder.end(); CodeTree call = builder.build(); builder = builder.create(); - if (plugs == null || !plugs.createCallExecuteAndSpecialize(frameState, builder, call)) { - if (isVoid(forType.getReturnType())) { - builder.statement(call); - builder.returnStatement(); - } else { - builder.startReturn(); - builder.tree(expectOrCast(returnType, forType, call)); - builder.end(); - } + if (isVoid(forType.getReturnType())) { + builder.statement(call); + builder.returnStatement(); + } else { + builder.startReturn(); + builder.tree(expectOrCast(returnType, forType, call)); + builder.end(); } return builder.build(); } - private CodeTree createReturnUnexpectedResult(FrameState frameState, ExecutableTypeData forType, boolean needsCast) { + private CodeTree createReturnUnexpectedResult(ExecutableTypeData forType, boolean needsCast) { TypeMirror returnType = context.getType(Object.class); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); @@ -5005,8 +4724,6 @@ private Collection persistCache(FrameState frameState, SpecializationD String insertTarget; if (useSpecializationClass) { insertTarget = createSpecializationLocalName(specialization); - } else if (generatorMode == GeneratorMode.OPERATIONS) { - insertTarget = "$this"; } else { insertTarget = "super"; } @@ -5022,11 +4739,7 @@ private Collection persistCache(FrameState frameState, SpecializationD builder = new CodeTreeBuilder(null); String insertName; if (cache.isAdopt()) { - insertName = useSpecializationClass - ? useInsertAccessor(specialization, isNodeInterfaceArray) - : (generatorMode == GeneratorMode.OPERATIONS - ? "insertAccessor" - : "insert"); + insertName = useSpecializationClass ? useInsertAccessor(specialization, isNodeInterfaceArray) : "insert"; } else { insertName = null; } @@ -5070,7 +4783,7 @@ private Collection persistCache(FrameState frameState, SpecializationD } } - CodeTree cacheReference = createCacheReference(frameState, specialization, cache, false); + CodeTree cacheReference = createCacheReference(frameState, specialization, cache); if (cache.isUsedInGuard() && !cache.isEagerInitialize() && sharedCaches.containsKey(cache) && !ElementUtils.isPrimitive(cache.getParameter().getType())) { builder.startIf().tree(cacheReference).string(" == null").end().startBlock(); @@ -5113,9 +4826,7 @@ private Collection storeCache(FrameState frameState, SpecializationDat CodeTree useValue; if ((ElementUtils.isAssignable(type, types.Node) || ElementUtils.isAssignable(type, new ArrayCodeTypeMirror(types.Node))) && (!cache.isAlwaysInitialized()) && cache.isAdopt()) { - useValue = plugs != null - ? plugs.createSuperInsert(value) - : CodeTreeBuilder.createBuilder().startCall("super.insert").tree(value).end().build(); + useValue = builder.create().startCall("super.insert").tree(value).end().build(); } else { useValue = value; } @@ -5276,7 +4987,7 @@ public DSLExpression visitBinary(Binary binary) { private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationData specialization, GuardExpression guard, NodeExecutionMode mode) { DSLExpression expression = optimizeExpression(guard.getExpression()); CodeTree init = null; - CodeTree expressionCode = writeExpression(frameState.copy(), specialization, expression); + CodeTree expressionCode = writeExpression(frameState, specialization, expression); if (mode.isGuardFallback()) { GuardExpression guardWithBit = getGuardThatNeedsStateBit(specialization, guard); if (guardWithBit != null) { @@ -5354,7 +5065,7 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati CodeTree ref; if (localVariable == null) { CacheExpression cache = specialization.findCache(resolvedParameter); - ref = createCacheReference(frameState, specialization, cache, true); + ref = createCacheReference(frameState, specialization, cache); } else { ref = localVariable.createReference(); } @@ -5372,19 +5083,14 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati } private CodeTree createSpecializationFieldReference(FrameState frameState, SpecializationData s, String fieldName) { - boolean useSpecializationClass = useSpecializationClass(s); CodeTreeBuilder builder = new CodeTreeBuilder(null); - if (useSpecializationClass) { + if (useSpecializationClass(s)) { String localName = createSpecializationLocalName(s); LocalVariable var = frameState.get(localName); if (var != null) { builder.string(localName); } else { - if (plugs != null) { - builder.tree(plugs.createSpecializationFieldReference(frameState, s, fieldName, createSpecializationTypeMirror(s), false)); - } else { - builder.string("this.", createSpecializationFieldName(s)); - } + builder.string("this.", createSpecializationFieldName(s)); } } else { builder.string("this"); @@ -5396,7 +5102,7 @@ private CodeTree createSpecializationFieldReference(FrameState frameState, Speci return builder.build(); } - private CodeTree createCacheReference(FrameState frameState, SpecializationData specialization, CacheExpression cache, boolean forRead) { + private CodeTree createCacheReference(FrameState frameState, SpecializationData specialization, CacheExpression cache) { if (cache == null) { return CodeTreeBuilder.singleString("null /* cache not resolved */"); } @@ -5408,9 +5114,7 @@ private CodeTree createCacheReference(FrameState frameState, SpecializationData } else { String sharedName = sharedCaches.get(cache); CodeTree ref; - if (plugs != null) { - ref = plugs.createCacheReference(frameState, specialization, cache, sharedName, forRead); - } else if (sharedName != null) { + if (sharedName != null) { ref = CodeTreeBuilder.createBuilder().string("this.").string(sharedName).build(); } else { String cacheFieldName = createFieldName(specialization, cache.getParameter()); @@ -5490,7 +5194,6 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou checkBuilder.string(implicitStateName, " = ").tree(specializeCall); checkBuilder.end(); checkBuilder.string(" != 0"); - castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, CodeTreeBuilder.singleString(implicitStateName))); } } @@ -5704,14 +5407,14 @@ private static class ExecuteDelegationResult { } - int getRequiredStateBits(TypeSystemData typeData, Object object) { + static int getRequiredStateBits(TypeSystemData types, Object object) { if (object instanceof SpecializationData) { return 1; } else if (object instanceof TypeGuard) { TypeGuard guard = (TypeGuard) object; TypeMirror type = guard.getType(); - Collection sourceTypes = typeData.lookupSourceTypes(type); + Collection sourceTypes = types.lookupSourceTypes(type); if (sourceTypes.size() > 1) { return sourceTypes.size(); } @@ -5720,14 +5423,12 @@ int getRequiredStateBits(TypeSystemData typeData, Object object) { return 1; } else if (object == AOT_PREPARED) { return 1; - } else if (plugs != null) { - return plugs.getRequiredStateBits(typeData, object); } else { throw new AssertionError(); } } - public static final class MultiStateBitSet extends MultiBitSet { + private static final class MultiStateBitSet extends MultiBitSet { /* * All bitsets in used by other nodes in the same generated class. E.g. nodes in exports are @@ -5777,7 +5478,7 @@ void removeParametersFrom(CodeExecutableElement targetMethod) { } } - public void addReferencesTo(FrameState frameState, CodeTreeBuilder builder) { + void addReferencesTo(FrameState frameState, CodeTreeBuilder builder) { for (BitSet set : getSets()) { LocalVariable local = frameState.get(set.getName()); if (local != null) { @@ -5808,7 +5509,7 @@ CodeTree createLoad(FrameState frameState) { return builder.build(); } - public CodeTree createLoad(FrameState frameState, Object... relevantObjects) { + CodeTree createLoad(FrameState frameState, Object... relevantObjects) { return createLoadImpl(getSets(), frameState, relevantObjects); } @@ -5863,8 +5564,8 @@ private abstract static class NodeBitSet extends BitSet { private final boolean needsVolatile; - NodeBitSet(String name, Object[] objects, boolean needsVolatile, NodeGeneratorPlugs plugs) { - super(name, objects, plugs); + NodeBitSet(String name, Object[] objects, boolean needsVolatile) { + super(name, objects); this.needsVolatile = needsVolatile; } @@ -5882,14 +5583,15 @@ String getOldName() { String getNewName() { return "new" + ElementUtils.firstLetterUpperCase(getName()); } + } - public class StateBitSet extends NodeBitSet { + private class StateBitSet extends NodeBitSet { private final Set relevantSpecializations; - StateBitSet(Object[] objects, SpecializationData[] relevantSpecializations, boolean needsVolatile, int index, NodeGeneratorPlugs plugs) { - super("state_" + index, objects, needsVolatile, plugs); + StateBitSet(Object[] objects, SpecializationData[] relevantSpecializations, boolean needsVolatile, int index) { + super("state_" + index, objects, needsVolatile); this.relevantSpecializations = new HashSet<>(Arrays.asList(relevantSpecializations)); } @@ -5914,12 +5616,13 @@ boolean containsSpecialization() { } return false; } + } private static class ExcludeBitSet extends NodeBitSet { - ExcludeBitSet(SpecializationData[] specializations, boolean needsVolatile, NodeGeneratorPlugs plugs) { - super("exclude", specializations, needsVolatile, plugs); + ExcludeBitSet(SpecializationData[] specializations, boolean needsVolatile) { + super("exclude", specializations, needsVolatile); } @Override @@ -5935,9 +5638,10 @@ protected int calculateRequiredBits(Object object) { } throw new IllegalArgumentException(); } + } - public static final class FrameState { + static final class FrameState { private final FlatNodeGenFactory factory; private final Map values = new HashMap<>(); @@ -6009,10 +5713,6 @@ public static FrameState load(FlatNodeGenFactory factory, ExecutableTypeData typ return context; } - public static FrameState createEmpty() { - return new FrameState(null, null, null); - } - private void loadEvaluatedValues(ExecutableTypeData executedType, int varargsThreshold) { TypeMirror frame = executedType.getFrameParameter(); if (frame == null) { @@ -6164,13 +5864,13 @@ public String toString() { } - public static final class LocalVariable { + static final class LocalVariable { private final TypeMirror typeMirror; private final CodeTree accessorTree; private final String name; - public LocalVariable(TypeMirror typeMirror, String name, CodeTree accessorTree) { + LocalVariable(TypeMirror typeMirror, String name, CodeTree accessorTree) { Objects.requireNonNull(typeMirror); this.typeMirror = typeMirror; this.accessorTree = accessorTree; @@ -6232,7 +5932,7 @@ public String toString() { } - public static class BoxingSplit { + private static class BoxingSplit { private final SpecializationGroup group; private final TypeMirror[] primitiveSignature; @@ -6245,23 +5945,16 @@ public static class BoxingSplit { public String getName() { StringBuilder b = new StringBuilder(); String sep = ""; - for (TypeMirror typeMirror : getPrimitiveSignature()) { + for (TypeMirror typeMirror : primitiveSignature) { b.append(sep).append(firstLetterLowerCase(getSimpleName(typeMirror))); sep = "_"; } return b.toString(); } - public TypeMirror[] getPrimitiveSignature() { - return primitiveSignature; - } - - public SpecializationGroup getGroup() { - return group; - } } - public enum NodeExecutionMode { + private enum NodeExecutionMode { FAST_PATH, SLOW_PATH, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 631746dff84d..757f85849e70 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -62,6 +62,7 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; @@ -76,6 +77,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedElement; import com.oracle.truffle.dsl.processor.model.Template; @@ -331,7 +333,10 @@ public static CodeExecutableElement createSuperConstructor(TypeElement type, Exe public static CodeTypeElement createClass(Template sourceModel, TemplateMethod sourceMethod, Set modifiers, String simpleName, TypeMirror superType) { TypeElement templateType = sourceModel.getTemplateType(); + return createClass(templateType, sourceMethod, modifiers, simpleName, superType); + } + public static CodeTypeElement createClass(TypeElement templateType, TemplateMethod sourceMethod, Set modifiers, String simpleName, TypeMirror superType) { ProcessorContext context = ProcessorContext.getInstance(); PackageElement pack = ElementUtils.findPackageElement(templateType); @@ -371,12 +376,8 @@ public static void addSuppressWarnings(ProcessorContext context, CodeElement findUserConstructors(TypeMirror nodeType) { @@ -433,6 +434,17 @@ public static CodeExecutableElement overrideImplement(DeclaredType type, String return overrideImplement((TypeElement) type.asElement(), methodName); } + public static CodeExecutableElement createSetter(Set modifiers, VariableElement field) { + CodeExecutableElement setter = new CodeExecutableElement(modifiers, new CodeTypeMirror(TypeKind.VOID), "set" + ElementUtils.firstLetterUpperCase(field.getSimpleName().toString())); + setter.addParameter(new CodeVariableElement(field.asType(), field.getSimpleName().toString())); + + CodeTreeBuilder b = setter.createBuilder(); + + b.startAssign("this", field).string(field.getSimpleName().toString()).end(); + + return setter; + } + public static CodeExecutableElement overrideImplement(TypeElement typeElement, String methodName) { ExecutableElement method = ElementUtils.findMethod(typeElement, methodName); if (method == null) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java index f48af70f5845..036e1f7e11ab 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java @@ -135,17 +135,6 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec return builder.build(); } - public CodeTree createIsEmpty(FrameState frameState) { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - String sep = ""; - for (BitSet set : sets) { - builder.string(sep); - builder.tree(set.createIsEmpty(frameState)); - sep = " && "; - } - return builder.build(); - } - public CodeTree createIsNotAny(FrameState frameState, Object[] elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.string("("); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index ab15f2941ecb..122419bc5645 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -75,12 +75,9 @@ public class NodeCodeGenerator extends CodeTypeElementFactory { - private NodeGeneratorPlugs plugs; - private GeneratorMode generatorMode = GeneratorMode.DEFAULT; - @Override public List create(ProcessorContext context, AnnotationProcessor processor, NodeData node) { - StaticConstants constants = plugs != null ? plugs.createConstants() : new StaticConstants(); + StaticConstants constants = new StaticConstants(); List rootTypes = createImpl(context, node, constants); if (rootTypes != null) { if (rootTypes.size() != 1) { @@ -93,7 +90,7 @@ public List create(ProcessorContext context, AnnotationProcesso return rootTypes; } - private List createImpl(ProcessorContext context, NodeData node, StaticConstants constants) { + private static List createImpl(ProcessorContext context, NodeData node, StaticConstants constants) { List enclosedTypes = new ArrayList<>(); for (NodeData childNode : node.getEnclosingNodes()) { List type = createImpl(context, childNode, constants); @@ -127,14 +124,6 @@ private List createImpl(ProcessorContext context, NodeData node } } - public void setPlugs(NodeGeneratorPlugs plugs) { - this.plugs = plugs; - } - - public void setGeneratorMode(GeneratorMode generatorMode) { - this.generatorMode = generatorMode; - } - private static CodeTypeElement makeInnerClass(CodeTypeElement type) { Set modifiers = type.getModifiers(); modifiers.add(Modifier.STATIC); @@ -277,7 +266,7 @@ static String createNodeTypeName(TypeElement nodeType) { return resolveNodeId(nodeType) + NODE_SUFFIX; } - private List generateNodes(ProcessorContext context, NodeData node, StaticConstants constants) { + private static List generateNodes(ProcessorContext context, NodeData node, StaticConstants constants) { if (!node.needsFactory()) { return Collections.emptyList(); } @@ -289,7 +278,7 @@ private List generateNodes(ProcessorContext context, NodeData n return Arrays.asList(type); } - type = new FlatNodeGenFactory(context, generatorMode, node, constants, plugs).create(type); + type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants).create(type); return Arrays.asList(type); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 89aa4a8a4936..4eb1f41f9d19 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -40,93 +40,7 @@ */ package com.oracle.truffle.dsl.processor.generator; -import java.util.List; -import java.util.function.Predicate; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.model.CacheExpression; -import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; -import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; - public interface NodeGeneratorPlugs { - void setNodeData(NodeData node); - - String transformNodeMethodName(String name); - - String transformNodeInnerTypeName(String name); - - void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis); - - boolean shouldIncludeValuesInCall(); - - int getMaxStateBits(int defaultValue); - - TypeMirror getBitSetType(TypeMirror defaultType); - - CodeTree createBitSetReference(BitSet bits, boolean write); - - CodeTree transformValueBeforePersist(CodeTree tree); - - CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write); - - CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead); - - CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead); - - CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder); - - void initializeFrameState(FrameState frameState, CodeTreeBuilder builder); - - boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call); - - CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState); - - CodeTree createThrowUnsupportedChild(NodeExecutionData execution); - - Boolean needsFrameToExecute(List specializations); - - void addAdditionalStateBits(List stateObjects); - - void setStateObjects(List stateObjects); - - void setMultiState(MultiStateBitSet multiState); - - int getRequiredStateBits(TypeSystemData types, Object object); - - void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder builder); - - boolean needsRewrites(); - - void setBoxingSplits(List boxingSplits); - - List filterSpecializations(List implementedSpecializations); - - boolean isStateGuaranteed(boolean stateGuaranteed); - - StaticConstants createConstants(); - - ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original); - - CodeTree createGetLock(); - - CodeTree createSuperInsert(CodeTree value); - - void setUseSpecializationClass(Predicate useSpecializationClass); - - String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type); - - CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees); - - String createExecuteAndSpecializeName(String result); + NodeGeneratorPlugs DEFAULT = new NodeGeneratorPlugs() { + }; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index 5785c607e1ac..d2eb9bf244ef 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -76,15 +76,15 @@ public class TypeSystemCodeGenerator extends CodeTypeElementFactory extends ElementScanner8 { @Override public final R visitExecutable(ExecutableElement e, P p) { if (!(e instanceof CodeExecutableElement)) { - throw new ClassCastException(e.toString()); + throw new ClassCastException(e.toString() + " in " + e.getEnclosingElement().toString()); } return visitExecutable(cast(e, CodeExecutableElement.class), p); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index 677c57aa1cfe..f1ab40b55615 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -665,6 +665,10 @@ public CodeTreeBuilder declaration(TypeMirror type, String name, String init) { return declaration(type, name, singleString(init)); } + public CodeTreeBuilder declaration(TypeMirror type, String name) { + return declaration(type, name, (CodeTree) null); + } + public CodeTreeBuilder declarationDefault(TypeMirror type, String name) { return declaration(type, name, createBuilder().defaultValue(type).build()); } @@ -1046,4 +1050,11 @@ public CodeTreeBuilder constantLiteral(TypeMirror type, int index) { return null; } + public CodeTreeBuilder lines(List lines) { + for (String line : lines) { + string(line).newLine(); + } + return this; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java index e590d8fe8dcb..c29cb6deb6eb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @@ -40,12 +40,12 @@ */ package com.oracle.truffle.dsl.processor.java.transform; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.elementEquals; import static com.oracle.truffle.dsl.processor.java.ElementUtils.findNearestEnclosingType; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getDeclaredTypes; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getPackageName; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSuperTypes; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.elementEquals; import java.util.ArrayList; import java.util.HashMap; @@ -78,7 +78,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeKind; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; public final class OrganizedImports { @@ -214,7 +214,7 @@ private boolean needsImport(Element enclosed, TypeMirror importType) { (anyEqualEnclosingTypes(enclosed, ElementUtils.castTypeElement(importType)) || importFromEnclosingScope(enclosedType, ElementUtils.castTypeElement(importType)))) { return false; // same enclosing element -> no import - } else if (importType instanceof GeneratedTypeMirror && importPackagName.isEmpty()) { + } else if (importType instanceof DeclaredCodeTypeMirror && importPackagName.isEmpty()) { return false; } else if (ElementUtils.isDeprecated(importType)) { return false; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 7448a438ce75..6a92d61a693a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -632,7 +632,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map caches = new ArrayList<>(); for (CacheKey key : eagerCaches.keySet()) { caches.add(key.cache); @@ -812,7 +812,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map methodNames = new HashSet<>(); - final Set innerTypeNames = new HashSet<>(); - final SingleOperationData soData = cinstr.getData(); - OperationsBytecodeNodeGeneratorPlugs plugs = new OperationsBytecodeNodeGeneratorPlugs(m, innerTypeNames, methodNames, cinstr, staticConstants, isUncached); + SimpleBytecodeNodeGeneratorPlugs plugs = new SimpleBytecodeNodeGeneratorPlugs(m, cinstr, staticConstants); cinstr.setPlugs(plugs); NodeCodeGenerator generator = new NodeCodeGenerator(); @@ -660,148 +683,88 @@ private void initializeInstructions(CodeTypeElement builderBytecodeNodeType) thr if (resultList.size() != 1) { throw new AssertionError("Node generator did not return exactly one class"); } - plugs.finishUp(); - CodeTypeElement result = resultList.get(0); - List executeNames = m.getOperationsContext().getBoxingKinds().stream().map( - x -> plugs.transformNodeMethodName(x == FrameKind.OBJECT ? "execute" : "execute" + x.getFrameName())).collect(Collectors.toList()); - CodeExecutableElement[] executeMethods = new CodeExecutableElement[isUncached ? 1 : executeNames.size()]; - List execs = new ArrayList<>(); - - TypeElement target = result; - - if (isUncached) { - target = (TypeElement) result.getEnclosedElements().stream().filter(x -> x.getSimpleName().toString().equals("Uncached")).findFirst().get(); - } + // TODO: don't generate if not needed - Set copiedMethod = new HashSet<>(); + CodeTypeElement result = resultList.get(0); + result.setEnclosingElement(builderBytecodeNodeType); + result.setSuperClass(types.Node); - for (ExecutableElement ex : ElementFilter.methodsIn(target.getEnclosedElements())) { - if (!methodNames.contains(ex.getSimpleName().toString())) { - continue; - } + Object sn = result.getSimpleName(); - if (copiedMethod.contains(ex.getSimpleName().toString())) { - continue; - } + Optional el = builderBytecodeNodeType.getEnclosedElements().stream().filter(x -> x.getSimpleName().equals(sn)).findAny(); + if (el.isPresent()) { + result = (CodeTypeElement) el.get(); + } else { + processNodeType(soData, result); - String simpleName = ex.getSimpleName().toString(); + for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { + CodeTypeElement cte = (CodeTypeElement) te; + String simpleName = cte.getSimpleName().toString(); - if (isUncached) { - if (simpleName.equals(plugs.transformNodeMethodName("executeUncached"))) { - executeMethods[0] = (CodeExecutableElement) ex; - } else if (executeNames.contains(simpleName)) { + if (simpleName.endsWith("Data")) { continue; } - } else { - if (simpleName.equals(plugs.transformNodeMethodName("executeUncached"))) { - continue; - } else if (executeNames.contains(simpleName)) { - executeMethods[executeNames.indexOf(simpleName)] = (CodeExecutableElement) ex; + + switch (simpleName) { + case "Uncached": + processNodeType(soData, cte); + break; + default: + throw new AssertionError("unknown nested type: " + simpleName); } } - execs.add((CodeExecutableElement) ex); - copiedMethod.add(ex.getSimpleName().toString()); + builderBytecodeNodeType.add(result); } - for (CodeExecutableElement el : executeMethods) { - if (el != null) { - el.getAnnotationMirrors().removeIf(x -> ElementUtils.typeEquals(x.getAnnotationType(), types.CompilerDirectives_TruffleBoundary)); - } - } - - for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { - if (!innerTypeNames.contains(te.getSimpleName().toString())) { - continue; - } + result.getModifiers().add(Modifier.STATIC); + } - builderBytecodeNodeType.add(te); - } + for (CodeVariableElement element : staticConstants.elements()) { + builderBytecodeNodeType.add(element); + } + } - CodeExecutableElement metPrepareForAOT = null; + private void processNodeType(SingleOperationData soData, CodeTypeElement result) { + result.setSuperClass(types.Node); - for (CodeExecutableElement exToCopy : execs) { - boolean isBoundary = exToCopy.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().equals(types.CompilerDirectives_TruffleBoundary)); + for (ExecutableElement ctor : ElementFilter.constructorsIn(result.getEnclosedElements())) { + result.remove(ctor); + } - String exName = exToCopy.getSimpleName().toString(); - boolean isExecute = executeNames.contains(exName) || exName.contains("_executeUncached_"); - boolean isExecuteAndSpecialize = exName.endsWith("_executeAndSpecialize_"); - boolean isFallbackGuard = exName.endsWith("_fallbackGuard__"); + for (VariableElement var : ElementFilter.fieldsIn(result.getEnclosedElements())) { + String simpleName = var.getSimpleName().toString(); + if (simpleName.startsWith("$child") || simpleName.equals("$variadicChild_")) { + result.remove(var); + } + } - if (instr instanceof QuickenedInstruction) { - if (isExecuteAndSpecialize) { - continue; - } - } + for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { + String simpleName = ex.getSimpleName().toString(); - if (isExecute || isExecuteAndSpecialize || isFallbackGuard) { - List params = exToCopy.getParameters(); + if (simpleName.equals("create") || simpleName.equals("getUncached")) { + result.remove(ex); + continue; + } - int i = 0; - for (; i < params.size(); i++) { - TypeMirror paramType = params.get(i).asType(); - if (ElementUtils.typeEquals(paramType, types.Frame) || ElementUtils.typeEquals(paramType, types.VirtualFrame)) { - params.remove(i); - i--; - } - } - } + CodeExecutableElement cex = (CodeExecutableElement) ex; - if (cinstr.isVariadic()) { - exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$numVariadics")); + if (!simpleName.equals("getCost")) { + if (soData.getMainProperties().isVariadic) { + cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$numVariadics")); } - exToCopy.getParameters().add(0, new CodeVariableElement(arrayOf(types.Node), "$children")); - exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(Object[].class), "$consts")); - exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$sp")); - exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$bci")); - exToCopy.getParameters().add(0, new CodeVariableElement(context.getType(short[].class), "$bc")); - exToCopy.getParameters().add(0, new CodeVariableElement(opNodeImpl.asType(), "$this")); - if (!isBoundary) { + cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$sp")); + cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$bci")); + if (ElementUtils.findAnnotationMirror(cex, types.CompilerDirectives_TruffleBoundary) == null) { if (m.enableYield) { - exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$localFrame")); - exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$stackFrame")); + cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$localsFrame")); + cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$stackFrame")); } else { - exToCopy.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); + cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); } } - exToCopy.getModifiers().remove(Modifier.PUBLIC); - exToCopy.getModifiers().add(Modifier.PRIVATE); - exToCopy.getModifiers().add(Modifier.STATIC); - exToCopy.getAnnotationMirrors().removeIf(x -> x.getAnnotationType().equals(context.getType(Override.class))); - builderBytecodeNodeType.add(exToCopy); - - if (exName.equals(plugs.transformNodeMethodName("prepareForAOT"))) { - metPrepareForAOT = exToCopy; - } } - - if (isUncached) { - cinstr.setUncachedExecuteMethod(executeMethods[0]); - } else { - cinstr.setExecuteMethod(executeMethods); - } - cinstr.setPrepareAOTMethod(metPrepareForAOT); - - if (m.isTracing()) { - OperationGeneratorUtils.createHelperMethod(typEnclosingElement, "doGetStateBits_" + cinstr.getUniqueName() + "_", () -> { - CodeExecutableElement metGetSpecBits = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), arrayOf(context.getType(boolean.class)), - "doGetStateBits_" + cinstr.getUniqueName() + "_"); - - metGetSpecBits.addParameter(new CodeVariableElement(arrayOf(context.getType(short.class)), "$bc")); - metGetSpecBits.addParameter(new CodeVariableElement(context.getType(int.class), "$bci")); - CodeTreeBuilder b = metGetSpecBits.createBuilder(); - b.tree(plugs.createGetSpecializationBits()); - - cinstr.setGetSpecializationBits(metGetSpecBits); - - return metGetSpecBits; - }); - } - } - - for (CodeVariableElement element : staticConstants.elements()) { - builderBytecodeNodeType.add(element); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java index e8042d32e32f..af0d6ef3e14e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java @@ -41,6 +41,7 @@ package com.oracle.truffle.dsl.processor.operations; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags.USE_SIMPLE_BYTECODE; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadOpcode; import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; @@ -168,6 +169,9 @@ public int getRequiredStateBits(TypeSystemData typesData, Object object) { @Override public String transformNodeMethodName(String name) { + if (USE_SIMPLE_BYTECODE) { + return name; + } String result = cinstr.getUniqueName() + "_" + name + "_"; methodNames.add(result); return result; @@ -175,6 +179,9 @@ public String transformNodeMethodName(String name) { @Override public String transformNodeInnerTypeName(String name) { + if (USE_SIMPLE_BYTECODE) { + return name; + } if (cinstr instanceof QuickenedInstruction) { return ((QuickenedInstruction) cinstr).getOrig().getUniqueName() + "_" + name; } @@ -243,6 +250,9 @@ public CodeTree transformValueBeforePersist(CodeTree tree) { private static final String CONST_OFFSET_NAME = "constArrayOffset_"; private CodeTree createArrayReference(FrameState frame, Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild, boolean write) { + if (USE_SIMPLE_BYTECODE) { + throw new AssertionError(); + } if (refObject == null) { throw new IllegalArgumentException("refObject is null"); } @@ -319,8 +329,11 @@ public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphis return new ReportPolymorphismAction(false, false); } - @Override + // @Override public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write) { + if (USE_SIMPLE_BYTECODE) { + return CodeTreeBuilder.singleString("this." + fieldName); + } boolean specClass = useSpecializationClass.test(s); Object refObject = specClass ? s : fieldName; boolean isChild = specClass ? specializationClassIsNode(s) : ElementUtils.isAssignable(fieldType, types.Node); @@ -352,11 +365,17 @@ public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData exe if (nodeFieldName.startsWith("$child")) { return CodeTreeBuilder.singleString("__INVALID__"); } + if (USE_SIMPLE_BYTECODE) { + return CodeTreeBuilder.singleString("this." + nodeFieldName); + } return createArrayReference(frame, execution, forRead, execution.getNodeType(), true, !forRead); } @Override public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { + if (USE_SIMPLE_BYTECODE) { + return CodeTreeBuilder.singleString("this." + sharedName); + } Object refObject = null; TypeMirror mir = null; String fieldName = null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java index 0badea91384f..02b9a4f41096 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor.operations; +import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags.USE_SIMPLE_BYTECODE; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOError; @@ -385,13 +387,17 @@ CodeTypeElement createOperationNodeImpl() { typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, typOperationNodes, "nodes"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "_bc"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_consts"))); - typOperationNodeImpl.add(children(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.Node), "_children"))); + if (USE_SIMPLE_BYTECODE) { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_objs"))); + } else { + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_consts"))); + typOperationNodeImpl.add(children(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.Node), "_children"))); + typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "_conditionProfiles"))); + } if (m.getOperationsContext().hasBoxingElimination()) { typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(byte[].class), "_localTags"))); } typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(typExceptionHandler.asType()), "_handlers"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "_conditionProfiles"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxLocals"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxStack"))); typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "sourceInfo"))); @@ -887,13 +893,19 @@ private CodeExecutableElement createNodeImplExecuteAt() { b.string("_bc"); b.string("result & 0xffff"); b.string("(result >> 16) & 0xffff"); - b.string("_consts"); - b.string("_children"); + if (USE_SIMPLE_BYTECODE) { + b.string("_objs"); + } else { + b.string("_consts"); + b.string("_children"); + } if (m.getOperationsContext().hasBoxingElimination()) { b.string("_localTags"); } b.string("_handlers"); - b.string("_conditionProfiles"); + if (!USE_SIMPLE_BYTECODE) { + b.string("_conditionProfiles"); + } b.string("_maxLocals"); b.end(2); @@ -1902,13 +1914,19 @@ private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeT loopMethod.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); - loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); - loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); + if (USE_SIMPLE_BYTECODE) { + loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$objs")); + } else { + loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); + loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); + } if (m.getOperationsContext().hasBoxingElimination()) { loopMethod.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); } loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); - loopMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + if (!USE_SIMPLE_BYTECODE) { + loopMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); + } loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "maxLocals")); baseClass.add(loopMethod); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java new file mode 100644 index 000000000000..f10977869a23 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java @@ -0,0 +1,237 @@ +package com.oracle.truffle.dsl.processor.operations; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.generator.BitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; +import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; + +public class SimpleBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { + + private final OperationsData m; + private final CustomInstruction cinstr; + private final StaticConstants staticConstants; + + public SimpleBytecodeNodeGeneratorPlugs(OperationsData m, CustomInstruction cinstr, StaticConstants staticConstants) { + this.m = m; + this.cinstr = cinstr; + this.staticConstants = staticConstants; + } + + public void setNodeData(NodeData node) { + } + + public String transformNodeMethodName(String name) { + return name; + } + + public String transformNodeInnerTypeName(String name) { + return name; + } + + public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { + if (!isBoundary) { + if (m.enableYield) { + builder.string("$stackFrame"); + builder.string("$localsFrame"); + } else { + builder.string("$frame"); + } + } + builder.string("$bci"); + builder.string("$sp"); + if (cinstr.getData().getMainProperties().isVariadic) { + builder.string("$numVariadics"); + } + } + + public boolean shouldIncludeValuesInCall() { + return true; + } + + public int getMaxStateBits(int defaultValue) { + return defaultValue; + } + + public TypeMirror getBitSetType(TypeMirror defaultType) { + return defaultType; + } + + public CodeTree createBitSetReference(BitSet bits, boolean write) { + return CodeTreeBuilder.singleString("this." + bits.getName() + "_"); + } + + public CodeTree transformValueBeforePersist(CodeTree tree) { + return tree; + } + + public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead) { + return null; + } + + public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { + return null; + } + + public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { + return values.toArray(new CodeTree[0]); + } + + public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { + } + + public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { + return false; + } + + public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { + String exName = execution.getName(); + if (exName.startsWith("$localRefArray")) { + return CodeTreeBuilder.singleString("this.op_localRefArray_"); + } + if (exName.startsWith("$localRef")) { + return CodeTreeBuilder.singleString("this.op_localRef_" + exName.substring(9) + "_"); + } + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (exName.equals("$variadicChild")) { + b.startCall("do_loadVariadicArguments"); + b.string(m.enableYield ? "$stackFrame" : "$frame"); + b.string("$sp"); + b.string("$numVariadics"); + b.end(); + return b.build(); + } + + int childIndex = execution.getIndex(); + int offset = cinstr.numPopStatic() - childIndex; + + FrameKind resultKind = getFrameType(method.getReturnType().getKind()); + + b.startCall("expect" + resultKind.getFrameName()); + b.string(m.enableYield ? "$stackFrame" : "$frame"); + if (cinstr.isVariadic()) { + b.string("$sp - " + offset + " - $numVariadics"); + } else { + b.string("$sp - " + offset); + } + if (m.getOperationsContext().hasBoxingElimination()) { + b.string("$bc"); + b.string("$bci"); + b.string("this.op_popIndexed_" + childIndex + "_"); + } + b.end(); + + return b.build(); + } + + private FrameKind getFrameType(TypeKind type) { + if (!m.getBoxingEliminatedTypes().contains(type)) { + return FrameKind.OBJECT; + } + + return OperationsData.convertToFrameType(type); + } + + public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { + return CodeTreeBuilder.singleString("null"); + } + + public Boolean needsFrameToExecute(List specializations) { + return true; + } + + public void addAdditionalStateBits(List stateObjects) { + } + + public void setStateObjects(List stateObjects) { + } + + public void setMultiState(MultiStateBitSet multiState) { + } + + public int getRequiredStateBits(TypeSystemData types, Object object) { + throw new AssertionError(); + } + + public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder builder) { + } + + public boolean needsRewrites() { + return true; + } + + public void setBoxingSplits(List boxingSplits) { + } + + public List filterSpecializations(List implementedSpecializations) { + return implementedSpecializations; + } + + public boolean isStateGuaranteed(boolean stateGuaranteed) { + return stateGuaranteed; + } + + public StaticConstants createConstants() { + return staticConstants; + } + + public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original) { + return new ReportPolymorphismAction(false, false); + } + + public CodeTree createGetLock() { + return CodeTreeBuilder.singleString("getLock()"); + } + + public CodeTree createSuperInsert(CodeTree value) { + return CodeTreeBuilder.createBuilder().startCall("super.insert").tree(value).end().build(); + } + + public void setUseSpecializationClass(Predicate useSpecializationClass) { + } + + public String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type) { + return null; + } + + public CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + if (codeTrees.length > 1) { + throw new AssertionError(Arrays.toString(codeTrees)); + } + + b.startCall(executableElement.getSimpleName().toString()); + addNodeCallParameters(b, false, false); + b.end(); + + return b.build(); + } + + public String createExecuteAndSpecializeName(String result) { + return result; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java index 15c0bf5b88f9..2bd820d6b02d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java @@ -66,6 +66,7 @@ public class SingleOperationData extends Template { private final Set throwDeclarations = new HashSet<>(); private final boolean isShortCircuit; private boolean shortCircuitContinueWhen; + private TypeMirror supertype; private List possiblePrimitiveTypes; private boolean isAlwaysBoxed; @@ -251,4 +252,12 @@ public void setAlwaysBoxed(boolean isAlwaysBoxed) { this.isAlwaysBoxed = isAlwaysBoxed; } + public TypeMirror getSupertype() { + return supertype; + } + + public void setSupertype(TypeMirror supertype) { + this.supertype = supertype; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java index a52740ee43d7..b03d4af4f50f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java @@ -148,6 +148,7 @@ protected SingleOperationData parse(Element element, List mirr } data = new SingleOperationData(context, null, proxyMirror, parentData, name, isShortCircuit); + data.setSupertype(proxyType); } else { if (proxyMirror != null) { @@ -167,6 +168,7 @@ protected SingleOperationData parse(Element element, List mirr } data = new SingleOperationData(context, te, null, parentData, name, false); + data.setSupertype(types.Node); } List operationFunctions = new ArrayList<>(); @@ -505,7 +507,7 @@ private boolean isIgnoredParameter(VariableElement param) { private CodeTypeElement createRegularNodeChild() { - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); result.setSuperClass(types.Node); result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); @@ -519,7 +521,7 @@ private CodeTypeElement createRegularNodeChild() { private CodeTypeElement createVariadicNodeChild() { - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); result.setSuperClass(types.Node); result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object[].class))); @@ -528,7 +530,7 @@ private CodeTypeElement createVariadicNodeChild() { } private CodeTypeElement createConstantNodeChild(TypeMirror returnType) { - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement("p"), "C"); + CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); result.setSuperClass(types.Node); result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, returnType)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java new file mode 100644 index 000000000000..cfd381adfa31 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.generator; + +import java.util.List; + +import com.oracle.truffle.dsl.processor.AnnotationProcessor; +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; + +public class OperationsCodeGenerator extends CodeTypeElementFactory { + + @Override + public List create(ProcessorContext context, AnnotationProcessor processor, OperationsModel m) { + return List.of(new OperationsNodeFactory(context, m).create()); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java new file mode 100644 index 000000000000..af87a1502601 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -0,0 +1,933 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.generator; + +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; +import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; +import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; + +public class OperationsNodeFactory { + private final ProcessorContext context; + private final TruffleTypes types; + private final OperationsModel model; + + private CodeTypeElement operationNodeGen; + private CodeTypeElement operationBuilder = new CodeTypeElement(Set.of(PUBLIC, STATIC, FINAL), ElementKind.CLASS, null, "Builder"); + private CodeTypeElement operationNodes = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationNodesImpl"); + + private CodeTypeElement intRef = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "IntRef"); + private CodeTypeElement operationLocalImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLocalImpl"); + private CodeTypeElement operationLabelImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLabelImpl"); + + public OperationsNodeFactory(ProcessorContext context, OperationsModel model) { + this.context = context; + this.types = context.getTypes(); + this.model = model; + } + + public CodeTypeElement create() { + operationNodeGen = GeneratorUtils.createClass(model.templateType, null, Set.of(PUBLIC, FINAL), model.templateType.getSimpleName() + "Gen", model.templateType.asType()); + GeneratorUtils.addSuppressWarnings(context, operationNodeGen, "unused"); + + // CodeTreeBuilder b = operationsNodeGen.createDocBuilder(); + // b.startDoc(); + // b.lines(model.infodump()); + // b.end(); + + operationNodeGen.add(new BuilderFactory().create()); + operationNodeGen.add(new OperationNodesImplFactory().create()); + operationNodeGen.add(new IntRefFactory().create()); + operationNodeGen.add(new OperationLocalImplFactory().create()); + operationNodeGen.add(new OperationLabelImplFactory().create()); + + operationNodeGen.add(createFrameDescriptorConstructor()); + operationNodeGen.add(createFrameDescriptorBuliderConstructor()); + + operationNodeGen.add(createCreate()); + + operationNodeGen.add(createExecute()); + + operationNodeGen.add(createGetIntrospectionData()); + + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"))); + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"))); + operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); + operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); + + operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()")); + + StaticConstants consts = new StaticConstants(); + for (InstructionModel instr : model.getInstructions()) { + if (instr.nodeData == null) { + continue; + } + + FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts); + + CodeTypeElement el = new CodeTypeElement(Set.of(), ElementKind.CLASS, null, instr.nodeType.getSimpleName() + "Gen"); + el.setSuperClass(types.Node); + + operationNodeGen.add(factory.create(el)); + } + + return operationNodeGen; + } + + private CodeExecutableElement createFrameDescriptorConstructor() { + CodeExecutableElement ctor = GeneratorUtils.createSuperConstructor(operationNodeGen, model.fdConstructor); + ctor.getModifiers().clear(); + ctor.getModifiers().add(PRIVATE); + return ctor; + } + + private CodeExecutableElement createFrameDescriptorBuliderConstructor() { + CodeExecutableElement ctor; + if (model.fdBuilderConstructor == null) { + ctor = new CodeExecutableElement(Set.of(PRIVATE), null, operationNodeGen.getSimpleName().toString()); + ctor.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); + ctor.addParameter(new CodeVariableElement(new GeneratedTypeMirror("", "FrameDescriptor.Builder"), "builder")); + ctor.createBuilder().statement("this(language, builder.build())"); + } else { + ctor = GeneratorUtils.createSuperConstructor(operationNodeGen, model.fdBuilderConstructor); + ctor.getModifiers().clear(); + ctor.getModifiers().add(PRIVATE); + } + + return ctor; + } + + private CodeExecutableElement createExecute() { + CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute"); + CodeTreeBuilder b = ex.createBuilder(); + + b.returnNull(); + + return ex; + } + + private CodeExecutableElement createCreate() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC, STATIC), generic(types.OperationNodes, model.templateType.asType()), "create"); + ex.addParameter(new CodeVariableElement(types.OperationConfig, "config")); + ex.addParameter(new CodeVariableElement(generic(types.OperationParser, operationBuilder.asType()), "generator")); + + CodeTreeBuilder b = ex.getBuilder(); + + b.declaration("OperationNodesImpl", "nodes", "new OperationNodesImpl(generator)"); + b.startAssign("Builder builder").startNew(operationBuilder.asType()); + b.string("nodes"); + b.string("false"); + b.string("config"); + b.end(2); + + b.startStatement().startCall("generator", "parse"); + b.string("builder"); + b.end(2); + + b.startStatement().startCall("builder", "finish").end(2); + + b.startReturn().string("nodes").end(); + + return ex; + } + + private CodeExecutableElement createGetIntrospectionData() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationIntrospection, "getIntrospectionData"); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Object[] instructions = new Object[bc.length]"); + + b.startFor().string("int bci = 0; bci < bc.length; bci++").end().startBlock(); + + b.startSwitch().string("bc[bci]").end().startBlock(); + + for (InstructionModel instr : model.getInstructions()) { + b.startCase().string("" + instr.id + " /* " + instr.name + " */").end().startBlock(); + b.startAssign("instructions[bci]").startNewArray(arrayOf(context.getType(Object.class)), null); + b.string("bci"); + b.doubleQuote(instr.name); + b.string("new short[] {" + instr.id + "}"); + b.string("new Object[0]"); + b.end(2); + b.statement("break"); + b.end(); + } + + b.end(); + + b.end(); + + b.startReturn().startStaticCall(types.OperationIntrospection_Provider, "create"); + b.string("new Object[]{0, instructions, new Object[0], null}"); + b.end(2); + + return ex; + } + + class BuilderFactory { + + CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState"); + + CodeVariableElement[] builderState = new CodeVariableElement[]{ + new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "bci"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "operationData"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationChildCount"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "operationSp"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "maxStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "curStack"), + + // must be last + new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"), + }; + + class SavedStateFactory { + private CodeTypeElement create() { + savedState.addAll(List.of(builderState)); + savedState.add(GeneratorUtils.createConstructorUsingFields(Set.of(), savedState, null)); + + return savedState; + } + } + + private CodeTypeElement create() { + operationBuilder.setSuperClass(types.OperationBuilder); + operationBuilder.setEnclosingElement(operationNodeGen); + + operationBuilder.add(new SavedStateFactory().create()); + + operationBuilder.add(createConstructor()); + + operationBuilder.add(createOperationNames()); + + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), operationNodes.asType(), "nodes")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), context.getType(boolean.class), "isReparse")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withSource")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withInstrumentation")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex")); + + operationBuilder.addAll(List.of(builderState)); + + operationBuilder.add(createCreateLocal()); + operationBuilder.add(createCreateLabel()); + + for (OperationModel operation : model.getOperations()) { + if (operation.isVariadic || operation.numChildren > 0) { + operationBuilder.add(createBegin(operation)); + operationBuilder.add(createEnd(operation)); + } else { + operationBuilder.add(createEmit(operation)); + } + } + + operationBuilder.add(createBeginHelper()); + operationBuilder.add(createEndHelper()); + operationBuilder.add(createEmitHelperBegin()); + operationBuilder.add(createBeforeChild()); + operationBuilder.add(createAfterChild()); + operationBuilder.add(createEmitInstruction()); + operationBuilder.add(createFinish()); + + return operationBuilder; + } + + private CodeExecutableElement createFinish() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "finish"); + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("!isReparse").end().startBlock(); + b.startStatement().string("nodes.setNodes(builtNodes.toArray(new ").type(operationNodeGen.asType()).string("[0]))").end(); + b.end(); + + return ex; + } + + private CodeExecutableElement createCreateLocal() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationLocal, "createLocal"); + CodeTreeBuilder b = ex.createBuilder(); + + b.startReturn().startNew(operationLocalImpl.asType()).startNew(intRef.asType()).string("numLocals++").end(3); + + return ex; + } + + private CodeExecutableElement createCreateLabel() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationLabel, "createLabel"); + CodeTreeBuilder b = ex.createBuilder(); + + b.startReturn().startNew(operationLabelImpl.asType()).startNew(intRef.asType()).string("-1").end(3); + + return ex; + } + + private CodeVariableElement createOperationNames() { + CodeVariableElement fld = new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(String[].class), "OPERATION_NAMES"); + + CodeTreeBuilder b = fld.createInitBuilder(); + b.startNewArray((ArrayType) context.getType(String[].class), null); + b.string("null"); + + int i = 1; + for (OperationModel op : model.getOperations()) { + if (op.id != i) { + throw new AssertionError("e"); + } + + i++; + b.doubleQuote(op.name); + } + + b.end(); + + return fld; + } + + private CodeExecutableElement createBeginHelper() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "beginOperation"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "id")); + ex.addParameter(new CodeVariableElement(context.getType(Object.class), "data")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("operationStack == null").end().startBlock(); // { + b.startThrow().startNew(context.getType(IllegalStateException.class)); + b.string("\"Unexpected operation begin - no root operation present. Did you forget a beginRoot()?\"").end(); + b.end(2); + b.end(); // } + + b.startIf().string("operationSp == operationStack.length").end().startBlock(); // { + b.startAssign("operationStack").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("operationStack"); + b.string("operationStack.length * 2"); + b.end(2); + b.startAssign("operationChildCount").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("operationChildCount"); + b.string("operationChildCount.length * 2"); + b.end(2); + b.startAssign("operationData").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("operationData"); + b.string("operationData.length * 2"); + b.end(2); + b.end(); // } + + b.statement("operationStack[operationSp] = id"); + b.statement("operationChildCount[operationSp] = 0"); + b.statement("operationData[operationSp++] = data"); + + return ex; + } + + private CodeExecutableElement createBegin(OperationModel operation) { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "begin" + operation.name); + + if (operation.operationArguments != null) { + int argIndex = 0; + for (TypeMirror argument : operation.operationArguments) { + ex.addParameter(new CodeVariableElement(argument, "arg" + argIndex)); + argIndex++; + } + } + + CodeTreeBuilder b = ex.createBuilder(); + + if (operation.kind == OperationKind.ROOT) { + b.startIf().string("bc != null").end().startBlock(); // { + b.startAssign("savedState").startNew(savedState.asType()); + b.variables(List.of(builderState)); + b.end(2); + b.end(); // } + + b.statement("bc = new short[32]"); + b.statement("bci = 0"); + b.statement("objs = new Object[32]"); + b.statement("operationStack = new int[8]"); + b.statement("operationData = new Object[8]"); + b.statement("operationChildCount = new int[8]"); + b.statement("operationSp = 0"); + b.statement("numLocals = 0"); + b.statement("curStack = 0"); + b.statement("maxStack = 0"); + } else { + b.startStatement().startCall("beforeChild").end(2); + } + + b.startStatement().startCall("beginOperation"); + b.string("" + operation.id); + buildOperationBeginData(b, operation); + b.end(2); + + return ex; + } + + private void buildOperationBeginData(CodeTreeBuilder b, OperationModel operation) { + switch (operation.kind) { + case ROOT: + b.string("new Object[]{false, arg0}"); + break; + case BLOCK: + b.string("new Object[]{false}"); + break; + case IF_THEN: + b.string("new IntRef()"); + break; + case IF_THEN_ELSE: + case CONDITIONAL: + case WHILE: + b.string("new IntRef[]{new IntRef(bci), new IntRef()}"); + break; + case STORE_LOCAL: + case STORE_LOCAL_MATERIALIZED: + case LOAD_LOCAL_MATERIALIZED: + b.string("arg0"); + break; + default: + b.string("null"); + break; + } + } + + private CodeExecutableElement createEndHelper() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "endOperation"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "id")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("operationSp <= 0 || operationStack == null").end().startBlock(); // { + b.startThrow().startNew(context.getType(IllegalStateException.class)); + b.string("\"Unexpected operation end - there are no operations on the stack. Did you forget a beginRoot()?\"").end(); + b.end(2); + b.end(); // } + + b.startIf().string("operationStack[operationSp - 1] != id").end().startBlock(); // { + b.startThrow().startNew(context.getType(IllegalStateException.class)); + b.string("\"Unexpected operation end, expected end\" + OPERATION_NAMES[operationStack[operationSp - 1]] + \", but got end \" + OPERATION_NAMES[id]").end(); + b.end(2); + b.end(); // } + + b.statement("operationSp -= 1"); + + return ex; + } + + private Element createEnd(OperationModel operation) { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "end" + operation.name); + CodeTreeBuilder b = ex.createBuilder(); + + b.startStatement().startCall("endOperation"); + b.string("" + operation.id); + b.end(2); + + if (operation.isVariadic && operation.numChildren > 0) { + b.startIf().string("operationChildCount[operationSp] < " + operation.numChildren).end().startBlock(); + buildThrowIllegalStateException(b, "\"Operation " + operation.name + " expected at least " + operation.numChildren + + " children, but \" + operationChildCount[operationSp] + \" provided. This is probably a bug in the parser.\""); + b.end(); + } else if (!operation.isVariadic) { + b.startIf().string("operationChildCount[operationSp] != " + operation.numChildren).end().startBlock(); + buildThrowIllegalStateException(b, "\"Operation " + operation.name + " expected exactly " + operation.numChildren + + " children, but \" + operationChildCount[operationSp] + \" provided. This is probably a bug in the parser.\""); + b.end(); + } + + if (operation.kind == OperationKind.ROOT) { + ex.setReturnType(model.templateType.asType()); + + b.declaration(types.TruffleLanguage, "language"); + + b.startAssign("language").cast(types.TruffleLanguage).string("((Object[]) operationData[operationSp])[1]").end(); + + b.declaration(operationNodeGen.asType(), "result", (CodeTree) null); + b.startIf().string("isReparse").end().startBlock(); // { + b.statement("result = builtNodes.get(buildIndex)"); + + b.startAssert().string("result.buildIndex == buildIndex").end(); + + b.end().startElseBlock(); // } { + + b.declaration(types.FrameDescriptor, ".Builder fdb", "FrameDescriptor.newBuilder(numLocals + maxStack)"); + + b.startStatement().startCall("fdb.addSlots"); + b.string("numLocals + maxStack"); + b.staticReference(types.FrameSlotKind, "Illegal"); + b.end(2); + + b.startAssign("result").startNew(operationNodeGen.asType()).string("language").string("fdb").end(2); + + b.startAssign("result.bc").string("Arrays.copyOf(bc, bci)").end(); + b.startAssign("result.objs").string("Arrays.copyOf(objs, bci)").end(); + b.startAssign("result.numLocals").string("numLocals").end(); + b.startAssign("result.buildIndex").string("buildIndex").end(); + + b.startAssert().string("builtNodes.size() == buildIndex").end(); + b.statement("builtNodes.add(result)"); + + b.end(); // } + + b.statement("buildIndex++"); + + b.startIf().string("savedState == null").end().startBlock(); // { + b.statement("bc = null"); + b.end().startElseBlock(); // } { + for (CodeVariableElement state : builderState) { + b.startAssign("this." + state.getName()).string("savedState." + state.getName()).end(); + } + b.end(); + + b.startReturn().string("result").end(); + return ex; + } + + if (operation.instruction != null) { + buildEmitInstruction(b, operation.instruction, () -> { + switch (operation.kind) { + case STORE_LOCAL: + case STORE_LOCAL_MATERIALIZED: + case LOAD_LOCAL_MATERIALIZED: + b.string("((OperationLocalImpl) operationData[operationSp]).index"); + break; + case CUSTOM_SIMPLE: + case CUSTOM_SHORT_CIRCUIT: + case RETURN: + case YIELD: + b.string("EPSILON"); + break; + default: + b.string("/* TODO: NOT IMPLEMENTED */"); + break; + } + }); + } + + b.startStatement().startCall("afterChild"); + if (operation.isTransparent) { + b.string("(boolean) ((Object[]) operationData[operationSp])[0]"); + } else { + b.string("" + !operation.isVoid); + } + b.end(2); + + return ex; + } + + private CodeExecutableElement createEmitHelperBegin() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "emitOperationBegin"); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("operationStack == null").end().startBlock(); // { + b.startThrow().startNew(context.getType(IllegalStateException.class)); + b.string("\"Unexpected operation emit - no root operation present. Did you forget a beginRoot()?\"").end(); + b.end(2); + b.end(); // } + + return ex; + } + + private CodeExecutableElement createEmit(OperationModel operation) { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "emit" + operation.name); + + if (operation.operationArguments != null) { + int argIndex = 0; + for (TypeMirror argument : operation.operationArguments) { + ex.addParameter(new CodeVariableElement(argument, "arg" + argIndex)); + argIndex++; + } + } + + CodeTreeBuilder b = ex.createBuilder(); + + b.startStatement().startCall("beforeChild").end(2); + b.startStatement().startCall("emitOperationBegin").end(2); + + if (operation.kind == OperationKind.LABEL) { + // todo: scope check + b.startIf().string("((OperationLabelImpl) arg0).index.value != -1").end().startBlock(); + buildThrowIllegalStateException(b, "\"OperationLabel already emitted. Each label must be emitted exactly once.\""); + b.end(); + + b.statement("((OperationLabelImpl) arg0).index.value = bci"); + } + + if (operation.instruction != null) { + buildEmitInstruction(b, operation.instruction, () -> { + switch (operation.kind) { + case LOAD_ARGUMENT: + case LOAD_CONSTANT: + b.string("arg0"); + break; + case LOAD_LOCAL: + b.string("((OperationLocalImpl) arg0).index"); + break; + case BRANCH: + b.string("((OperationLabelImpl) arg0).index"); + break; + case CUSTOM_SIMPLE: + case CUSTOM_SHORT_CIRCUIT: + b.string("EPSILON"); + break; + default: + b.string("/* TODO: NOT IMPLEMENTED */"); + break; + } + }); + } + + b.startStatement().startCall("afterChild"); + b.string("" + !operation.isVoid); + b.end(2); + + return ex; + } + + private CodeExecutableElement createBeforeChild() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "beforeChild"); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Object data = operationData[operationSp - 1]"); + b.statement("int childIndex = operationChildCount[operationSp - 1]"); + + b.startSwitch().string("operationStack[operationSp - 1]").end().startBlock(); + + for (OperationModel op : model.getOperations()) { + if (!op.isVariadic && op.numChildren == 0) { + continue; + } + + b.startCase().string(op.id + " /* " + op.name + " */").end().startBlock(); + + if (op.isTransparent && (op.isVariadic || op.numChildren > 1)) { + b.startIf().string("(boolean) ((Object[]) data)[0]").end().startBlock(); + buildEmitInstruction(b, model.popInstruction, null); + b.end(); + } + + b.statement("break"); + b.end(); + } + + b.end(); + + return ex; + } + + private CodeExecutableElement createAfterChild() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "afterChild"); + ex.addParameter(new CodeVariableElement(context.getType(boolean.class), "producedValue")); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Object data = operationData[operationSp - 1]"); + b.statement("int childIndex = operationChildCount[operationSp - 1]"); + + b.startSwitch().string("operationStack[operationSp - 1]").end().startBlock(); + + for (OperationModel op : model.getOperations()) { + if (!op.isVariadic && op.numChildren == 0) { + continue; + } + + b.startCase().string(op.id + " /* " + op.name + " */").end().startBlock(); + + if (op.childrenMustBeValues != null && !op.isTransparent) { + // this can be optimized a bit, by merging all the throw cases into one, and all + // the pop cases into the other + for (int i = 0; i < op.childrenMustBeValues.length; i++) { + b.startIf().string("childIndex ", (i == op.childrenMustBeValues.length - 1 && op.isVariadic) ? ">=" : "==", " " + i).end().startBlock(); + if (op.childrenMustBeValues[i]) { + b.startIf().string("!producedValue").end().startBlock(); + b.startThrow().startNew(context.getType(IllegalStateException.class)); + b.doubleQuote("Operation " + op.name + " expected a value-producing child at position " + i + ", but a void one was provided. This likely indicates a bug in the parser."); + b.end(2); + b.end(); + } else { + b.startIf().string("producedValue").end().startBlock(); + buildEmitInstruction(b, model.popInstruction, null); + b.end(); + } + b.end(); + } + } + + if (op.isTransparent) { + b.statement("((Object[]) data)[0] = producedValue"); + } + + switch (op.kind) { + case IF_THEN: + b.startIf().string("childIndex == 0").end().startBlock(); + buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("data")); + b.end().startElseBlock(); + b.statement("((IntRef) data).value = bci"); + b.end(); + break; + case CONDITIONAL: + case IF_THEN_ELSE: + b.startIf().string("childIndex == 0").end().startBlock(); + buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("((IntRef[]) data)[0]")); + b.end().startElseIf().string("childIndex == 1").end().startBlock(); + buildEmitInstruction(b, model.branchInstruction, () -> b.string("((IntRef[]) data)[1]")); + b.statement("((IntRef[]) data)[0].value = bci"); + b.end().startElseBlock(); + b.statement("((IntRef[]) data)[1].value = bci"); + b.end(); + break; + case WHILE: + b.startIf().string("childIndex == 0").end().startBlock(); + buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("((IntRef[]) data)[1]")); + b.end().startElseBlock(); + buildEmitInstruction(b, model.branchInstruction, () -> b.string("((IntRef[]) data)[0]")); + b.statement("((IntRef[]) data)[1].value = bci"); + b.end(); + break; + } + + b.statement("break"); + b.end(); + } + + b.end(); + + b.statement("operationChildCount[operationSp - 1] = childIndex + 1"); + + return ex; + } + + private void buildThrowIllegalStateException(CodeTreeBuilder b, String reasonCode) { + b.startThrow().startNew(context.getType(IllegalStateException.class)); + if (reasonCode != null) { + b.string(reasonCode); + } + b.end(2); + } + + private CodeExecutableElement createEmitInstruction() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitInstruction"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "instr")); + ex.addParameter(new CodeVariableElement(context.getType(Object.class), "data")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("bc.length == bci").end().startBlock(); // { + b.startAssign("bc").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("bc"); + b.string("bc.length * 2"); + b.end(2); + b.startAssign("objs").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("objs"); + b.string("objs.length * 2"); + b.end(2); + b.end(); // } + + b.statement("bc[bci] = (short) instr"); + b.statement("objs[bci++] = data"); + + return ex; + } + + private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Runnable argumentBuilder) { + b.startStatement().startCall("doEmitInstruction"); + b.string(instr.id + " /* " + instr.name + " */"); + b.startGroup(); + if (argumentBuilder != null) { + argumentBuilder.run(); + } else { + b.string("EPSILON"); + } + b.end(); + b.end(2); + } + + private CodeExecutableElement createConstructor() { + CodeExecutableElement ctor = new CodeExecutableElement(null, "Builder"); + ctor.addParameter(new CodeVariableElement(operationNodes.asType(), "nodes")); + ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "isReparse")); + ctor.addParameter(new CodeVariableElement(types.OperationConfig, "config")); + + CodeTreeBuilder b = ctor.createBuilder(); + + b.statement("this.nodes = nodes"); + b.statement("this.isReparse = isReparse"); + b.statement("this.withSource = config.isWithSource()"); + b.statement("this.withInstrumentation = config.isWithInstrumentation()"); + + b.statement("this.builtNodes = new ArrayList<>()"); + + return ctor; + } + } + + class OperationNodesImplFactory { + private CodeTypeElement create() { + operationNodes.setSuperClass(generic(types.OperationNodes, model.templateType.asType())); + operationNodes.setEnclosingElement(operationNodeGen); + + operationNodes.add(createConstructor()); + operationNodes.add(createReparseImpl()); + operationNodes.add(createSetNodes()); + + return operationNodes; + } + + private CodeExecutableElement createConstructor() { + CodeExecutableElement ctor = new CodeExecutableElement(null, "OperationNodesImpl"); + ctor.addParameter(new CodeVariableElement(generic(types.OperationParser, operationBuilder.asType()), "generator")); + + ctor.createBuilder().statement("super(generator)"); + return ctor; + } + + private CodeExecutableElement createReparseImpl() { + CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Builder builder = new Builder(this, true, config)"); + + b.startStatement().startCall("builder.builtNodes.addAll"); + b.startGroup().string("(List) "); + b.startStaticCall(context.getType(List.class), "of").string("nodes").end(); + b.end(); + b.end(2); + + return ex; + } + + private CodeExecutableElement createSetNodes() { + return GeneratorUtils.createSetter(Set.of(), new CodeVariableElement(arrayOf(operationNodeGen.asType()), "nodes")); + } + } + + class OperationLocalImplFactory { + private CodeTypeElement create() { + operationLocalImpl.setSuperClass(generic(types.OperationLocal, model.templateType.asType())); + operationLocalImpl.setEnclosingElement(operationNodeGen); + + operationLocalImpl.add(new CodeVariableElement(intRef.asType(), "index")); + + operationLocalImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(), operationLocalImpl, null)); + + return operationLocalImpl; + } + } + + class OperationLabelImplFactory { + private CodeTypeElement create() { + operationLabelImpl.setSuperClass(generic(types.OperationLabel, model.templateType.asType())); + operationLabelImpl.setEnclosingElement(operationNodeGen); + + operationLabelImpl.add(new CodeVariableElement(intRef.asType(), "index")); + + operationLabelImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(), operationLabelImpl, null)); + + return operationLabelImpl; + } + } + + class IntRefFactory { + private CodeTypeElement create() { + intRef.setEnclosingElement(operationNodeGen); + + intRef.add(GeneratorUtils.createConstructorUsingFields(Set.of(), intRef, null)); + + intRef.add(new CodeVariableElement(context.getType(int.class), "value")); + + intRef.add(GeneratorUtils.createConstructorUsingFields(Set.of(), intRef, null)); + + return intRef; + } + } + + private static TypeMirror generic(DeclaredType el, TypeMirror... args) { + return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args)); + } + + private static ArrayType arrayOf(TypeMirror component) { + return new CodeTypeMirror.ArrayCodeTypeMirror(component); + } + + private CodeVariableElement compFinal(CodeVariableElement fld) { + return compFinal(-1, fld); + } + + private CodeVariableElement compFinal(int dims, CodeVariableElement fld) { + CodeAnnotationMirror mir = new CodeAnnotationMirror(types.CompilerDirectives_CompilationFinal); + if (dims != -1) { + mir.setElementValue("dimensions", new CodeAnnotationValue(dims)); + } + fld.addAnnotationMirror(mir); + return fld; + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java index cbe510814bf1..9027c381f69d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java @@ -172,6 +172,11 @@ public boolean isExplicitFlowControl() { return true; } + @Override + protected CodeTree createObjectInitializer(BuilderVariables vars, EmitArguments args) { + return CodeTreeBuilder.createBuilder().startAssign("objs[bci]").tree(args.branchTargets[0]).end().build(); + } + @Override public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { return null; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java index ebe797dc9e47..5175999377d0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java @@ -68,7 +68,6 @@ public boolean isExplicitFlowControl() { public CodeTree createExecuteCode(ExecutionVariables vars) { CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - // TODO: we should do (un)boxing elim here (but only if booleans are boxing elim'd) b.declaration("boolean", "cond", "UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - 1) == Boolean.TRUE"); b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java index 4c931023733d..91915e6bf537 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java @@ -42,20 +42,17 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; +import javax.lang.model.type.TypeMirror; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsBytecodeNodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; @@ -63,9 +60,8 @@ public class CustomInstruction extends Instruction { private final SingleOperationData data; - protected ExecutableElement[] executeMethods; - protected ExecutableElement uncachedExecuteMethod; - private OperationsBytecodeNodeGeneratorPlugs plugs; + private TypeMirror nodeType; + private NodeGeneratorPlugs plugs; private CodeExecutableElement prepareAOTMethod; private CodeExecutableElement getSpecializationBits; private final List quickenedVariants = new ArrayList<>(); @@ -86,8 +82,8 @@ public List getSpecializationNames() { return result; } - public void setExecuteMethod(ExecutableElement[] executeMethods) { - this.executeMethods = executeMethods; + public void setNodeType(TypeMirror nodeType) { + this.nodeType = nodeType; } public CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { @@ -180,156 +176,7 @@ public List getBoxingEliminationSplits() { } private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - - String exName = getUniqueName() + "_entryPoint_" + (uncached ? "uncached" : (!alwaysBoxed() && ctx.hasBoxingElimination() ? vars.specializedKind : "")); - OperationGeneratorUtils.createHelperMethod(ctx.outerType, exName, () -> { - CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), exName); - el.getParameters().addAll(executeMethods[0].getParameters()); - - CodeTreeBuilder b = el.createBuilder(); - - if (numPushedValues > 0) { - - if (isVariadic()) { - b.declaration("int", "destSlot", "$sp - " + (data.getMainProperties().numStackValues - 1) + " - $numVariadics"); - } else { - b.declaration("int", "destSlot", "$sp - " + data.getMainProperties().numStackValues); - } - - if (!uncached && ctx.hasBoxingElimination() && !alwaysBoxed()) { - int i = ctx.getBoxingKinds().indexOf(vars.specializedKind); - - if (i == -1) { - throw new AssertionError("kind=" + vars.specializedKind + " name=" + name + "bk=" + ctx.getBoxingKinds()); - } - - boolean needsUnexpectedResult = executeMethods[i] != null && executeMethods[i].getThrownTypes().size() > 0; - - if (needsUnexpectedResult) { - b.startTryBlock(); - } - - if (executeMethods[i] != null) { - b.startStatement().startCall("UFA", "unsafeSet" + vars.specializedKind.getFrameName()); - - b.variable(vars.stackFrame); - b.string("destSlot"); - - b.startStaticCall(executeMethods[i]); - b.variables(executeMethods[i].getParameters()); - b.end(); - - b.end(2); - - b.returnStatement(); - } else { - b.tree(GeneratorUtils.createShouldNotReachHere()); - } - - b.end(); - - if (needsUnexpectedResult) { - b.end().startCatchBlock(types.UnexpectedResultException, "ex"); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.string("destSlot"); - b.string("ex.getResult()"); - - b.end(2); - - b.end(); - } - - } else { - ExecutableElement target = uncached ? uncachedExecuteMethod : executeMethods[0]; - - b.startStatement().startCall("UFA", "unsafeSetObject"); - - b.variable(vars.stackFrame); - b.string("destSlot"); - - b.startStaticCall(target); - b.variables(el.getParameters()); - - if (uncached) { - for (int i = 0; i < numPopStatic(); i++) { - int offset = numPopStatic() - i; - b.startCall("UFA", "unsafeUncheckedGetObject"); - b.variable(vars.stackFrame); - if (isVariadic()) { - b.string("$sp - " + offset + " - $numVariadics"); - } else { - b.string("$sp - " + offset); - } - b.end(); - } - - if (isVariadic()) { - b.startCall("do_loadVariadicArguments"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("$numVariadics"); - b.end(); - } - - addLocalRefs(b, vars); - } - - b.end(); - - b.end(2); - } - } else { - - b.startStatement().startStaticCall(executeMethods[0]); - b.variables(executeMethods[0].getParameters()); - b.end(2); - } - - return el; - }); - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - createTracerCode(vars, b); - - if (isVariadic()) { - b.startAssign("int numVariadics").tree(createVariadicIndex(vars, false)).end(); - } - - b.startStatement(); - b.startCall(exName); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.string("$this"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); - - if (isVariadic()) { - b.string("numVariadics"); - } - b.end(2); - - int stackDelta = numPushedValues - data.getMainProperties().numStackValues + (isVariadic() ? 1 : 0); - - if (isVariadic() || stackDelta != 0) { - b.startStatement().variable(vars.sp).string(" += "); - if (stackDelta != 0) { - b.string("" + stackDelta); - } - if (isVariadic()) { - b.string(" - numVariadics"); - } - b.end(); - } - - return b.build(); + return null; } @Override @@ -368,11 +215,11 @@ public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits this.getSpecializationBits = getSpecializationBits; } - public OperationsBytecodeNodeGeneratorPlugs getPlugs() { + public NodeGeneratorPlugs getPlugs() { return plugs; } - public void setPlugs(OperationsBytecodeNodeGeneratorPlugs plugs) { + public void setPlugs(NodeGeneratorPlugs plugs) { this.plugs = plugs; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java index ec5587431e66..d26b56d71e31 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java @@ -58,6 +58,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; import com.oracle.truffle.dsl.processor.operations.OperationsContext; @@ -257,6 +258,9 @@ private int getInstrumentsOffset() { public int length() { frozen = true; + if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { + return 1; + } return getInstrumentsOffset() + instruments.size(); } @@ -357,6 +361,9 @@ public CodeTree createInstrument(ExecutionVariables vars, int index) { } public CodeTree createLength() { + if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { + return CodeTreeBuilder.singleString("1"); + } return CodeTreeBuilder.singleString(internalName + LENGTH_SUFFIX); } @@ -468,139 +475,144 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) // emit opcode b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, this, 0))); - if (!constants.isEmpty()) { - b.startAssign("int constantsStart"); - b.startCall(vars.consts, "size").end(); - b.end(); + if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { + b.tree(createObjectInitializer(vars, args)); + } else { + if (!constants.isEmpty()) { + b.startAssign("int constantsStart"); + b.startCall(vars.consts, "size").end(); + b.end(); - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); - for (int i = 0; i < constants.size(); i++) { - CodeTree initCode = null; - if (constants.get(i) != null) { - initCode = createConstantInitCode(vars, args, constants.get(i), i); - } + for (int i = 0; i < constants.size(); i++) { + CodeTree initCode = null; + if (constants.get(i) != null) { + initCode = createConstantInitCode(vars, args, constants.get(i), i); + } - if (initCode == null && args.constants != null) { - initCode = args.constants[i]; - } + if (initCode == null && args.constants != null) { + initCode = args.constants[i]; + } - if (initCode == null) { - initCode = CodeTreeBuilder.singleString("null"); - } + if (initCode == null) { + initCode = CodeTreeBuilder.singleString("null"); + } - b.startStatement().startCall(vars.consts, "add"); - b.tree(initCode); - b.end(2); + b.startStatement().startCall(vars.consts, "add"); + b.tree(initCode); + b.end(2); + } } - } - if (!children.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); - b.string("numChildNodes"); - b.end(); + if (!children.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); + b.string("numChildNodes"); + b.end(); - b.statement("numChildNodes += " + children.size()); - } + b.statement("numChildNodes += " + children.size()); + } - for (int i = 0; i < locals.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalsOffset() + " + " + i + "] = (short) "); - b.startCall("getLocalIndex").tree(args.locals[i]).end(); - b.end(); - } + for (int i = 0; i < locals.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalsOffset() + " + " + i + "] = (short) "); + b.startCall("getLocalIndex").tree(args.locals[i]).end(); + b.end(); + } - for (int i = 0; i < localRuns.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2) + "] = (short) "); - b.startCall("getLocalRunStart").tree(args.localRuns[i]).end(); - b.end(); + for (int i = 0; i < localRuns.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2) + "] = (short) "); + b.startCall("getLocalRunStart").tree(args.localRuns[i]).end(); + b.end(); - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2 + 1) + "] = (short) "); - b.startCall("getLocalRunLength").tree(args.localRuns[i]).end(); - b.end(); - } + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2 + 1) + "] = (short) "); + b.startCall("getLocalRunLength").tree(args.localRuns[i]).end(); + b.end(); + } - if (isVariadic) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getVariadicOffset() + "] = (short) "); - b.startParantheses().tree(args.variadicCount).end(); - b.end(); - } else { - for (int i = 0; i < popIndexed.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getPopIndexedOffset() + " + " + (i / 2) + "] "); - if (i % 2 == 1) { - b.string("|"); - } - b.string("= (short) ((").variable(vars.bci).string(" - predecessorBcis[" + i + "] < 256 ? ").variable(vars.bci).string(" - predecessorBcis[" + i + "] : 0)"); - if (i % 2 == 1) { - b.string(" << 8"); + if (isVariadic) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getVariadicOffset() + "] = (short) "); + b.startParantheses().tree(args.variadicCount).end(); + b.end(); + } else { + for (int i = 0; i < popIndexed.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getPopIndexedOffset() + " + " + (i / 2) + "] "); + if (i % 2 == 1) { + b.string("|"); + } + b.string("= (short) ((").variable(vars.bci).string(" - predecessorBcis[" + i + "] < 256 ? ").variable(vars.bci).string(" - predecessorBcis[" + i + "] : 0)"); + if (i % 2 == 1) { + b.string(" << 8"); + } + b.string(")").end(); } - b.string(")").end(); } - } - for (int i = 0; i < branchTargets.size(); i++) { - b.startStatement().startCall("labelFills", "add").startNew("LabelFill"); - b.startGroup().variable(vars.bci).string(" + " + getBranchTargetsOffset() + " + " + i).end(); - b.tree(args.branchTargets[i]); - b.end(3); - } + for (int i = 0; i < branchTargets.size(); i++) { + b.startStatement().startCall("labelFills", "add").startNew("LabelFill"); + b.startGroup().variable(vars.bci).string(" + " + getBranchTargetsOffset() + " + " + i).end(); + b.tree(args.branchTargets[i]); + b.end(3); + } - if (!branchProfiles.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getBranchProfileOffset() + "] = (short) "); - b.string("numConditionProfiles"); - b.end(); + if (!branchProfiles.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getBranchProfileOffset() + "] = (short) "); + b.string("numConditionProfiles"); + b.end(); - b.statement("numConditionProfiles += " + branchProfiles.size() * 2); - } + b.statement("numConditionProfiles += " + branchProfiles.size() * 2); + } - for (int i = 0; i < stateBits.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getStateBitsOffset() + " + " + i + "] = 0").end(); - } + for (int i = 0; i < stateBits.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getStateBitsOffset() + " + " + i + "] = 0").end(); + } - for (int i = 0; i < arguments.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentsOffset() + " + " + i + "] = (short) (int) "); - b.tree(args.arguments[i]); - b.end(); - } + for (int i = 0; i < arguments.size(); i++) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentsOffset() + " + " + i + "] = (short) (int) "); + b.tree(args.arguments[i]); + b.end(); + } - if (!instruments.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); - b.string("numInstrumentNodes"); - b.end(); + if (!instruments.isEmpty()) { + b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); + b.string("numInstrumentNodes"); + b.end(); - b.statement("numInstrumentNodes += " + instruments.size()); - } + b.statement("numInstrumentNodes += " + instruments.size()); + } - // superinstructions + // superinstructions - final int maxHistory = 8; + final int maxHistory = 8; - b.startAssign("instructionHistory[++instructionHistoryIndex % " + maxHistory + "]").variable(opcodeIdField).end(); + b.startAssign("instructionHistory[++instructionHistoryIndex % " + maxHistory + "]").variable(opcodeIdField).end(); - boolean elseIf = false; - for (SuperInstruction si : ctx.getSuperInstructions()) { - Instruction[] instrs = si.getInstructions(); + boolean elseIf = false; + for (SuperInstruction si : ctx.getSuperInstructions()) { + Instruction[] instrs = si.getInstructions(); - if (instrs[instrs.length - 1].id == id) { - elseIf = b.startIf(elseIf); - for (int i = 1; i < instrs.length; i++) { - if (i != 1) { - b.string(" && "); + if (instrs[instrs.length - 1].id == id) { + elseIf = b.startIf(elseIf); + for (int i = 1; i < instrs.length; i++) { + if (i != 1) { + b.string(" && "); + } + b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + maxHistory + ") % 8] == "); + b.variable(instrs[instrs.length - 1 - i].opcodeIdField); } - b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + maxHistory + ") % 8] == "); - b.variable(instrs[instrs.length - 1 - i].opcodeIdField); - } - b.end().startBlock(); + b.end().startBlock(); - b.startStatement().variable(vars.bc).string("["); - b.variable(vars.bci); - // skips the last since BCI is still not incremented for current instruction - for (int i = 0; i < instrs.length - 1; i++) { - b.string(" - ").tree(instrs[i].createLength()); - } - b.string("] = ").tree(OperationGeneratorUtils.combineBoxingBits(ctx, si, 0)).end(); + b.startStatement().variable(vars.bc).string("["); + b.variable(vars.bci); + // skips the last since BCI is still not incremented for current instruction + for (int i = 0; i < instrs.length - 1; i++) { + b.string(" - ").tree(instrs[i].createLength()); + } + b.string("] = ").tree(OperationGeneratorUtils.combineBoxingBits(ctx, si, 0)).end(); - b.end(); + b.end(); + } } + } b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); @@ -610,6 +622,10 @@ public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) return b.build(); } + protected CodeTree createObjectInitializer(BuilderVariables vars, EmitArguments args) { + return null; + } + public abstract CodeTree createExecuteCode(ExecutionVariables vars); public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java index 631f3e6adc29..127c921e5239 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java @@ -43,6 +43,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; import com.oracle.truffle.dsl.processor.operations.OperationsContext; public class LoadConstantInstruction extends Instruction { @@ -75,10 +76,14 @@ private CodeTree createGetArgument(ExecutionVariables vars, FrameKind kind) { if (kind != FrameKind.OBJECT) { b.string("(", kind.getTypeName(), ") "); } - b.startCall("UFA", "unsafeObjectArrayRead"); - b.variable(vars.consts); - b.tree(createConstantIndex(vars, 0)); - b.end(); + if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { + b.string("$obj"); + } else { + b.startCall("UFA", "unsafeObjectArrayRead"); + b.variable(vars.consts); + b.tree(createConstantIndex(vars, 0)); + b.end(); + } return b.build(); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java index 0945b1e83313..0b3464a3d0b0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java @@ -41,7 +41,6 @@ package com.oracle.truffle.dsl.processor.operations.instructions; import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.operations.OperationsContext; import com.oracle.truffle.dsl.processor.operations.SingleOperationData; @@ -59,52 +58,7 @@ public CodeTree createExecuteCode(ExecutionVariables vars) { } public CodeTree createExecuteCode(ExecutionVariables vars, boolean uncached) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - createTracerCode(vars, b); - - b.startIf(); - if (!getData().getShortCircuitContinueWhen()) { - b.string("!"); - } - - if (uncached) { - b.startStaticCall(uncachedExecuteMethod); - } else { - b.startStaticCall(executeMethods[0]); - } - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.string("$this"); - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.variable(vars.consts); - b.variable(vars.children); - if (uncached) { - b.startCall("UFA", "unsafeUncheckedGetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.end(); - } - b.end(2).startBlock(); - // { - b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - - b.statement("continue loop"); - // } - b.end().startElseBlock(); - // { - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - - b.statement("continue loop"); - // } - b.end(); - - return b.build(); + return null; } @Override diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InfoDumpable.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InfoDumpable.java new file mode 100644 index 000000000000..1fb2b7d58fef --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InfoDumpable.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +public interface InfoDumpable { + + static List dump(Object obj) { + if (obj instanceof InfoDumpable) { + Dumper d = new Dumper(); + ((InfoDumpable) obj).dump(d); + return d.lines; + } else { + return List.of("" + obj); + } + } + + class Dumper { + + private String nextIndent = ""; + private String indent = ""; + private final List lines = new ArrayList<>(); + + public void print(String text) { + lines.add(nextIndent + text.replace("\n", "\n" + indent)); + nextIndent = indent; + } + + public void print(String format, Object... args) { + print(String.format(format, args)); + } + + public void field(String fieldName, Object fieldValue) { + if (fieldValue instanceof InfoDumpable) { + print("%s:", fieldName); + String old = indent; + indent += " "; + ((InfoDumpable) fieldValue).dump(this); + indent = old; + } else if (fieldValue instanceof Collection) { + print("%s:", fieldName); + for (Object obj : (Collection) fieldValue) { + nextIndent = nextIndent + " - "; + String old = indent; + indent += " "; + print(obj); + indent = old; + nextIndent = indent; + } + } else { + print("%s: %s", fieldName, fieldValue); + } + } + + public void print(Object obj) { + if (obj instanceof InfoDumpable) { + ((InfoDumpable) obj).dump(this); + } else if (obj instanceof Collection) { + for (Object elem : (Collection) obj) { + nextIndent = nextIndent + " - "; + String old = indent; + indent += " "; + print(elem); + indent = old; + } + } else { + print(Objects.toString(obj)); + } + } + } + + void dump(Dumper dumper); + + default List infodump() { + return dump(this); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java new file mode 100644 index 000000000000..9ff190611c87 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.model; + +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; + +public class InstructionModel implements InfoDumpable { + public enum InstructionKind { + BRANCH, + BRANCH_FALSE, + POP, + INSTRUMENTATION_ENTER, + INSTRUMENTATION_EXIT, + INSTRUMENTATION_LEAVE, + LOAD_ARGUMENT, + LOAD_CONSTANT, + LOAD_LOCAL, + LOAD_LOCAL_MATERIALIZED, + STORE_LOCAL, + STORE_LOCAL_MATERIALIZED, + + RETURN, + YIELD, + THROW, + + CUSTOM, + CUSTOM_QUICKENED, + CUSTOM_SHORT_CIRCUIT, + SUPERINSTRUCTION, + } + + public final int id; + public final InstructionKind kind; + public final String name; + public CodeTypeElement nodeType; + public CustomSignature signature; + public NodeData nodeData; + + public InstructionModel(int id, InstructionKind kind, String name) { + this.id = id; + this.kind = kind; + this.name = name; + } + + public void dump(Dumper dumper) { + dumper.print("Instruction %s", name); + dumper.field("kind", kind); + if (nodeType != null) { + dumper.field("nodeType", nodeType.getSimpleName()); + } + dumper.field("signature", signature); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java new file mode 100644 index 000000000000..7f4e273c161a --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.model; + +import java.util.Arrays; + +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.model.MessageContainer; + +public class OperationModel extends MessageContainer implements InfoDumpable { + public enum OperationKind { + ROOT, + BLOCK, + IF_THEN, + IF_THEN_ELSE, + CONDITIONAL, + WHILE, + TRY_CATCH, + FINALLY_TRY, + FINALLY_TRY_NO_EXCEPT, + SOURCE, + SOURCE_SECTION, + INSTRUMENT_TAG, + + LABEL, + BRANCH, + RETURN, + YIELD, + + LOAD_CONSTANT, + LOAD_ARGUMENT, + LOAD_LOCAL, + LOAD_LOCAL_MATERIALIZED, + STORE_LOCAL, + STORE_LOCAL_MATERIALIZED, + + CUSTOM_SIMPLE, + CUSTOM_SHORT_CIRCUIT, + } + + public static class CustomSignature { + public int valueCount; + public boolean isVariadic; + + public boolean[] valueBoxingElimination; + public boolean resultBoxingElimination; + public boolean isVoid; + + public int localSetterCount; + public int localSetterRangeCount; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + if (isVoid) { + sb.append("void "); + } else if (resultBoxingElimination) { + sb.append("box "); + } else { + sb.append("obj "); + } + + sb.append("("); + + for (int i = 0; i < valueCount; i++) { + sb.append(valueBoxingElimination[i] ? "box" : "obj"); + sb.append(", "); + } + + if (isVariadic) { + sb.append("obj..., "); + } + + for (int i = 0; i < localSetterCount; i++) { + sb.append("local, "); + } + + for (int i = 0; i < localSetterRangeCount; i++) { + sb.append("localRange, "); + } + + if (sb.charAt(sb.length() - 1) == ' ') { + sb.delete(sb.length() - 2, sb.length()); + } + + sb.append(')'); + + return sb.toString(); + } + } + + public final OperationsModel parent; + public final int id; + public final OperationKind kind; + public final String name; + public final TypeElement templateType; + + public boolean isTransparent; + public boolean isVoid; + public boolean isVariadic; + + public boolean[] childrenMustBeValues; + public int numChildren; + + public InstructionModel instruction; + public TypeMirror[] operationArguments; + + public CustomSignature signature; + + public OperationModel(OperationsModel parent, TypeElement templateType, int id, OperationKind kind, String name) { + this.parent = parent; + this.templateType = templateType; + this.id = id; + this.kind = kind; + this.name = name; + } + + public OperationModel setTransparent(boolean isTransparent) { + this.isTransparent = isTransparent; + return this; + } + + public OperationModel setVoid(boolean isVoid) { + this.isVoid = isVoid; + return this; + } + + public OperationModel setChildrenMustBeValues(boolean... childrenMustBeValues) { + this.childrenMustBeValues = childrenMustBeValues; + return this; + } + + public OperationModel setAllChildrenMustBeValues() { + childrenMustBeValues = new boolean[numChildren]; + Arrays.fill(childrenMustBeValues, true); + return this; + } + + public OperationModel setVariadic(int minChildren) { + this.isVariadic = true; + this.numChildren = minChildren; + return this; + } + + public OperationModel setNumChildren(int numChildren) { + this.numChildren = numChildren; + return this; + } + + public OperationModel setInstruction(InstructionModel instruction) { + this.instruction = instruction; + return this; + } + + public OperationModel setOperationArguments(TypeMirror... operationArguments) { + this.operationArguments = operationArguments; + return this; + } + + public OperationModel setSignature(CustomSignature signature) { + this.signature = signature; + return this; + } + + @Override + public Element getMessageElement() { + return templateType; + } + + @Override + public MessageContainer getBaseContainer() { + return parent; + } + + public void dump(Dumper dumper) { + dumper.print("Operation %s", name); + dumper.field("kind", kind); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java new file mode 100644 index 000000000000..775f102b17de --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.model.MessageContainer; +import com.oracle.truffle.dsl.processor.model.Template; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; + +public class OperationsModel extends Template implements InfoDumpable { + + private final ProcessorContext context; + public final TypeElement templateType; + + public OperationsModel(ProcessorContext context, TypeElement templateType, AnnotationMirror mirror) { + super(context, templateType, mirror); + this.context = context; + this.templateType = templateType; + } + + private int operationId = 1; + private int instructionId = 1; + + private final List operations = new ArrayList<>(); + private final List instructions = new ArrayList<>(); + + private final Map operationNames = new HashMap<>(); + + public boolean enableYield; + public DeclaredType languageClass; + public ExecutableElement fdConstructor; + public ExecutableElement fdBuilderConstructor; + public boolean generateUncached; + public TypeSystemData typeSystem; + public Set boxingEliminatedTypes; + + public InstructionModel popInstruction; + public InstructionModel branchInstruction; + public InstructionModel branchFalseInstruction; + + public void addDefault() { + + popInstruction = instruction(InstructionKind.POP, "pop"); + branchInstruction = instruction(InstructionKind.BRANCH, "branch"); + branchFalseInstruction = instruction(InstructionKind.BRANCH_FALSE, "branch.false"); + + operation(OperationKind.BLOCK, "Block") // + .setTransparent(true) // + .setVariadic(0) // + .setChildrenMustBeValues(false); + operation(OperationKind.ROOT, "Root") // + .setVariadic(0) // + .setVoid(true) // + .setChildrenMustBeValues(false) // + .setOperationArguments(types.TruffleLanguage); + operation(OperationKind.IF_THEN, "IfThen") // + .setVoid(true) // + .setNumChildren(2) // + .setChildrenMustBeValues(true, false); + operation(OperationKind.IF_THEN_ELSE, "IfThenElse") // + .setVoid(true) // + .setNumChildren(3) // + .setChildrenMustBeValues(true, false, false); + operation(OperationKind.CONDITIONAL, "Conditional") // + .setNumChildren(3) // + .setChildrenMustBeValues(true, true, true); + operation(OperationKind.WHILE, "While") // + .setVoid(true) // + .setNumChildren(2) // + .setChildrenMustBeValues(true, false); + operation(OperationKind.TRY_CATCH, "TryCatch") // + .setVoid(true) // + .setNumChildren(2) // + .setChildrenMustBeValues(false, false) // + .setOperationArguments(types.OperationLocal); + operation(OperationKind.FINALLY_TRY, "FinallyTry") // + .setVoid(true) // + .setNumChildren(2) // + .setChildrenMustBeValues(false, false); + operation(OperationKind.FINALLY_TRY_NO_EXCEPT, "FinallyTryNoExcept") // + .setVoid(true) // + .setNumChildren(2) // + .setChildrenMustBeValues(false, false); + operation(OperationKind.LABEL, "Label") // + .setVoid(true) // + .setNumChildren(0) // + .setOperationArguments(types.OperationLabel); + operation(OperationKind.BRANCH, "Branch") // + .setVoid(true) // + .setNumChildren(0) // + .setOperationArguments(types.OperationLabel) // + .setInstruction(branchInstruction); + operation(OperationKind.LOAD_CONSTANT, "LoadConstant") // + .setNumChildren(0) // + .setOperationArguments(context.getType(Object.class)) // + .setInstruction(instruction(InstructionKind.LOAD_CONSTANT, "load.constant")); + operation(OperationKind.LOAD_ARGUMENT, "LoadArgument") // + .setNumChildren(0) // + .setOperationArguments(context.getType(int.class)) // + .setInstruction(instruction(InstructionKind.LOAD_ARGUMENT, "load.argument")); + operation(OperationKind.LOAD_LOCAL, "LoadLocal") // + .setNumChildren(0) // + .setOperationArguments(types.OperationLocal) // + .setInstruction(instruction(InstructionKind.LOAD_LOCAL, "load.local")); + operation(OperationKind.LOAD_LOCAL_MATERIALIZED, "LoadLocalMaterialized") // + .setNumChildren(1) // + .setChildrenMustBeValues(true) // + .setOperationArguments(types.OperationLocal) // + .setInstruction(instruction(InstructionKind.LOAD_LOCAL_MATERIALIZED, "load.local.mat")); + operation(OperationKind.STORE_LOCAL, "StoreLocal") // + .setNumChildren(1) // + .setChildrenMustBeValues(true) // + .setOperationArguments(types.OperationLocal) // + .setInstruction(instruction(InstructionKind.STORE_LOCAL, "store.local")); + operation(OperationKind.STORE_LOCAL_MATERIALIZED, "StoreLocalMaterialized") // + .setNumChildren(2) // + .setChildrenMustBeValues(true, true) // + .setOperationArguments(types.OperationLocal) // + .setInstruction(instruction(InstructionKind.STORE_LOCAL_MATERIALIZED, "store.local.mat")); + operation(OperationKind.RETURN, "Return") // + .setNumChildren(1) // + .setChildrenMustBeValues(true) // + .setInstruction(instruction(InstructionKind.RETURN, "return")); + if (enableYield) { + operation(OperationKind.YIELD, "Yield") // + .setNumChildren(1) // + .setChildrenMustBeValues(true) // + .setInstruction(instruction(InstructionKind.YIELD, "yield")); + } + operation(OperationKind.SOURCE, "Source") // + .setNumChildren(1) // + .setTransparent(true); + operation(OperationKind.SOURCE_SECTION, "SourceSection") // + .setNumChildren(1) // + .setTransparent(true); + operation(OperationKind.INSTRUMENT_TAG, "Tag") // + .setNumChildren(1) // + .setTransparent(true); + + } + + public OperationModel operation(OperationKind kind, String name) { + return operation(null, kind, name); + } + + public OperationModel operation(TypeElement template, OperationKind kind, String name) { + OperationModel op = new OperationModel(this, template, operationId++, kind, name); + operations.add(op); + operationNames.put(name, op); + return op; + } + + public InstructionModel instruction(InstructionKind kind, String name) { + InstructionModel instr = new InstructionModel(instructionId++, kind, name); + instructions.add(instr); + return instr; + } + + @Override + public Element getMessageElement() { + return templateType; + } + + @Override + protected List findChildContainers() { + return Collections.unmodifiableList(operations); + } + + public boolean isBoxingEliminated(TypeMirror mirror) { + if (!mirror.getKind().isPrimitive()) { + return false; + } + + for (TypeMirror mir : boxingEliminatedTypes) { + if (ElementUtils.typeEquals(mir, mirror)) { + return true; + } + } + + return false; + } + + public List getOperations() { + return Collections.unmodifiableList(operations); + } + + public List getInstructions() { + return Collections.unmodifiableList(instructions); + } + + public void dump(Dumper dumper) { + dumper.field("operations", operations); + dumper.field("instructions", instructions); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java new file mode 100644 index 000000000000..7a5c6e66f296 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -0,0 +1,569 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.parser; + +import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getTypeElement; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.typeEquals; +import static javax.lang.model.element.Modifier.ABSTRACT; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; +import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; +import com.oracle.truffle.dsl.processor.parser.AbstractParser; +import com.oracle.truffle.dsl.processor.parser.NodeParser; + +public class CustomOperationParser extends AbstractParser { + + private final OperationsModel parent; + private final AnnotationMirror mirror; + private final boolean isShortCircuit; + + public CustomOperationParser(OperationsModel parent, AnnotationMirror mirror) { + this(parent, mirror, false); + } + + public CustomOperationParser(OperationsModel parent, AnnotationMirror mirror, boolean isShortCircuit) { + this.parent = parent; + this.mirror = mirror; + this.isShortCircuit = isShortCircuit; + } + + @Override + protected OperationModel parse(Element element, List ignored) { + TypeElement te = (TypeElement) element; + + OperationKind kind = isShortCircuit + ? OperationKind.CUSTOM_SHORT_CIRCUIT + : OperationKind.CUSTOM_SIMPLE; + + String name = te.getSimpleName().toString(); + if (name.endsWith("Node")) { + name = name.substring(0, name.length() - 4); + } + + if (mirror != null) { + AnnotationValue nameValue = ElementUtils.getAnnotationValue(mirror, "name", false); + if (nameValue != null) { + name = (String) nameValue.getValue(); + } + } + + OperationModel data = parent.operation(te, kind, name); + + boolean isNode = isAssignable(te.asType(), types.NodeInterface); + + if (!isNode) { + // operation specification + + if (!te.getModifiers().contains(Modifier.FINAL)) { + data.addError("Operation class must be declared final. Inheritance in operation specifications is not supported."); + } + + if (te.getEnclosingElement().getKind() != ElementKind.PACKAGE && !te.getModifiers().contains(Modifier.STATIC)) { + data.addError("Operation class must not be an inner class (non-static nested class). Declare the class as static."); + } + + if (te.getModifiers().contains(Modifier.PRIVATE)) { + data.addError("Operation class must not be declared private. Remove the private modifier to make it visible."); + } + + // TODO: Add cross-package visibility check + + if (!ElementUtils.isObject(te.getSuperclass()) || !te.getInterfaces().isEmpty()) { + data.addError("Operation class must not extend any classes or implement any interfaces. Inheritance in operation specifications is not supported."); + } + + for (Element el : te.getEnclosedElements()) { + if (el.getModifiers().contains(Modifier.PRIVATE)) { + // ignore everything private + continue; + } + + if (!el.getModifiers().contains(Modifier.STATIC)) { + if (el.getKind() == ElementKind.CONSTRUCTOR && ((ExecutableElement) el).getParameters().size() == 0) { + // we must allow the implicit 0-argument non-static constructor. + continue; + } + data.addError(el, "@Operation annotated class must not contain non-static members."); + } + } + } + + for (ExecutableElement cel : findSpecializations(te)) { + if (!cel.getModifiers().contains(Modifier.STATIC)) { + data.addError("Operation specification must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); + } + } + + if (data.hasErrors()) { + return data; + } + + CodeTypeElement nodeType; + if (isNode) { + nodeType = cloneTypeHierarchy(te, ct -> { + ct.getAnnotationMirrors().removeIf(m -> typeEquals(m.getAnnotationType(), types.NodeChild) || typeEquals(m.getAnnotationType(), types.NodeChildren)); + ct.getAnnotationMirrors().removeIf(m -> typeEquals(m.getAnnotationType(), types.GenerateUncached)); + ct.getAnnotationMirrors().removeIf(m -> typeEquals(m.getAnnotationType(), types.GenerateNodeFactory)); + + // remove all non-static or private elements. this includes all the execute methods + ct.getEnclosedElements().removeIf(e -> !e.getModifiers().contains(Modifier.STATIC) || e.getModifiers().contains(Modifier.PRIVATE)); + }); + } else { + nodeType = CodeTypeElement.cloneShallow(te); + nodeType.setSuperClass(types.Node); + } + + CustomSignature signature = determineSignature(data, nodeType); + if (data.hasErrors()) { + return data; + } + + if (signature == null) { + throw new AssertionError(); + } + + if (parent.generateUncached) { + nodeType.addAnnotationMirror(new CodeAnnotationMirror(types.GenerateUncached)); + } + + nodeType.addAll(createExecuteMethods(signature)); + + CodeAnnotationMirror nodeChildrenAnnotation = new CodeAnnotationMirror(types.NodeChildren); + nodeChildrenAnnotation.setElementValue("value", new CodeAnnotationValue(createNodeChildAnnotations(signature).stream().map(CodeAnnotationValue::new).collect(Collectors.toList()))); + nodeType.addAnnotationMirror(nodeChildrenAnnotation); + + data.signature = signature; + data.numChildren = signature.valueCount; + data.isVariadic = signature.isVariadic; + data.isVoid = signature.isVoid; + + data.operationArguments = new TypeMirror[signature.localSetterCount + signature.localSetterRangeCount]; + for (int i = 0; i < signature.localSetterCount; i++) { + data.operationArguments[i] = types.OperationLocal; + } + for (int i = 0; i < signature.localSetterRangeCount; i++) { + // we might want to migrate this to a special type that validates order + // e.g. OperationLocalRange + data.operationArguments[signature.localSetterCount + i] = new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal); + } + + data.childrenMustBeValues = new boolean[signature.valueCount + (signature.isVariadic ? 1 : 0)]; + Arrays.fill(data.childrenMustBeValues, true); + + data.instruction = createCustomInstruction(data, nodeType, signature, name); + + return data; + } + + private List createNodeChildAnnotations(CustomSignature signature) { + List result = new ArrayList<>(); + + TypeMirror[] boxingEliminated = parent.boxingEliminatedTypes.toArray(new TypeMirror[0]); + + for (int i = 0; i < signature.valueCount; i++) { + result.add(createNodeChildAnnotation("child" + i, context.getType(Object.class), boxingEliminated)); + } + if (signature.isVariadic) { + result.add(createNodeChildAnnotation("variadicChild", context.getType(Object[].class))); + } + for (int i = 0; i < signature.localSetterCount; i++) { + result.add(createNodeChildAnnotation("localSetter" + i, types.LocalSetter)); + } + for (int i = 0; i < signature.localSetterRangeCount; i++) { + result.add(createNodeChildAnnotation("localSetterRange" + i, types.LocalSetterRange)); + } + + return result; + } + + private CodeAnnotationMirror createNodeChildAnnotation(String name, TypeMirror regularReturn, TypeMirror... unexpectedReturns) { + CodeAnnotationMirror mir = new CodeAnnotationMirror(types.NodeChild); + mir.setElementValue("value", new CodeAnnotationValue(name)); + mir.setElementValue("type", new CodeAnnotationValue(createNodeChildType(regularReturn, unexpectedReturns).asType())); + return mir; + } + + private CodeTypeElement createNodeChildType(TypeMirror regularReturn, TypeMirror... unexpectedReturns) { + CodeTypeElement c = new CodeTypeElement(Set.of(), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); + c.setSuperClass(types.Node); + + c.add(new CodeExecutableElement(regularReturn, "execute")); + + for (TypeMirror ty : unexpectedReturns) { + c.add(new CodeExecutableElement(ty, "execute" + firstLetterUpperCase(getSimpleName(ty)))).addThrownType(types.UnexpectedResultException); + } + + return c; + } + + private List createExecuteMethods(CustomSignature signature) { + List result = new ArrayList<>(); + + if (signature.isVoid) { + result.add(createExecuteMethod(signature, "executeVoid", context.getType(void.class), false, false)); + } else { + result.add(createExecuteMethod(signature, "execute", context.getType(Object.class), false, false)); + + for (TypeMirror ty : parent.boxingEliminatedTypes) { + result.add(createExecuteMethod(signature, "execute" + firstLetterUpperCase(getSimpleName(ty)), ty, true, false)); + } + } + + if (parent.generateUncached) { + if (signature.isVoid) { + result.add(createExecuteMethod(signature, "executeUncached", context.getType(void.class), false, true)); + } else { + result.add(createExecuteMethod(signature, "executeUncached", context.getType(Object.class), false, true)); + } + } + + return result; + } + + private CodeExecutableElement createExecuteMethod(CustomSignature signature, String name, TypeMirror type, boolean withUnexpected, boolean uncached) { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(ABSTRACT), type, name); + if (withUnexpected) { + ex.addThrownType(types.UnexpectedResultException); + } + + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + + if (uncached) { + for (int i = 0; i < signature.valueCount; i++) { + ex.addParameter(new CodeVariableElement(context.getType(Object.class), "child" + i + "Value")); + } + if (signature.isVariadic) { + ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "variadicChildValue")); + } + for (int i = 0; i < signature.localSetterCount; i++) { + ex.addParameter(new CodeVariableElement(types.LocalSetter, "localSetter" + i + "Value")); + } + for (int i = 0; i < signature.localSetterRangeCount; i++) { + ex.addParameter(new CodeVariableElement(types.LocalSetterRange, "localSetterRange" + i + "Value")); + } + } + + return ex; + } + + private InstructionModel createCustomInstruction(OperationModel data, CodeTypeElement nodeType, CustomSignature signature, String nameSuffix) { + InstructionKind kind = !isShortCircuit ? InstructionKind.CUSTOM : InstructionKind.CUSTOM_SHORT_CIRCUIT; + String namePrefix = !isShortCircuit ? "c." : "sc."; + + InstructionModel instr = parent.instruction(kind, namePrefix + nameSuffix); + instr.nodeType = nodeType; + instr.signature = signature; + + try { + NodeParser parser = NodeParser.createDefaultParser(); + instr.nodeData = parser.parse(nodeType); + } catch (Throwable ex) { + StringWriter wr = new StringWriter(); + ex.printStackTrace(new PrintWriter(wr)); + data.addError("Error generating node: %s\n%s", signature, wr.toString()); + } + + if (instr.nodeData == null) { + data.addError("Error generating node: invalid node definition."); + return instr; + } +// +// if (instr.nodeData.getTypeSystem().isDefault()) { +// instr.nodeData.setTypeSystem(parent.typeSystem); +// } + + instr.nodeData.redirectMessages(data); + + return instr; + } + + private CustomSignature determineSignature(OperationModel data, CodeTypeElement nodeType) { + List specializations = findSpecializations(nodeType); + + if (specializations.size() == 0) { + data.addError("Operation class %s contains no specializations.", nodeType.getSimpleName()); + return null; + } + + boolean isValid = true; + CustomSignature signature = null; + + for (ExecutableElement spec : specializations) { + CustomSignature other = determineSignature(data, spec); + if (signature == null) { + // first (valid) signature + signature = other; + } else if (other == null) { + // invalid signature + isValid = false; + } else { + isValid = mergeSignatures(data, signature, other, spec) && isValid; + } + + if (other != null && isShortCircuit) { + if (spec.getReturnType().getKind() != TypeKind.BOOLEAN || other.valueCount != 1 || other.isVariadic || other.localSetterCount > 0 || other.localSetterRangeCount > 0) { + data.addError(spec, "Boolean converter operation specializations must only take one value parameter and return boolean."); + isValid = false; + } + } + } + + if (!isValid || signature == null) { + // signatures are invalid or inconsistent + return null; + } + + return signature; + } + + private boolean mergeSignatures(OperationModel data, CustomSignature a, CustomSignature b, Element el) { + boolean isValid = true; + if (a.isVariadic != b.isVariadic) { + data.addError(el, "Error calculating operation signature: either all or none of the specialization must be variadic (have a @%s annotated parameter)", + getSimpleName(types.Variadic)); + isValid = false; + } + if (a.isVoid != b.isVoid) { + data.addError(el, "Error calculating operation signature: either all or none of the specialization must be declared void."); + isValid = false; + } + if (a.valueCount != b.valueCount) { + data.addError(el, "Error calculating operation signature: all specialization must have the same number of value arguments."); + isValid = false; + } + if (a.localSetterCount != b.localSetterCount) { + data.addError(el, "Error calculating operation signature: all specialization must have the same number of %s arguments.", getSimpleName(types.LocalSetter)); + isValid = false; + } + if (a.localSetterRangeCount != b.localSetterRangeCount) { + data.addError(el, "Error calculating operation signature: all specialization must have the same number of %s arguments.", getSimpleName(types.LocalSetterRange)); + isValid = false; + } + + if (!isValid) { + return false; + } + + a.resultBoxingElimination = a.resultBoxingElimination || b.resultBoxingElimination; + for (int i = 0; i < a.valueBoxingElimination.length; i++) { + a.valueBoxingElimination[i] = a.valueBoxingElimination[i] || b.valueBoxingElimination[i]; + } + + return true; + } + + private CustomSignature determineSignature(OperationModel data, ExecutableElement spec) { + + boolean isValid = true; + + List canBeBoxingEliminated = new ArrayList<>(); + + int numValues = 0; + boolean hasVariadic = false; + + int numLocalSetters = 0; + int numLocalSetterRanges = 0; + + for (VariableElement param : spec.getParameters()) { + if (isAssignable(param.asType(), types.Frame)) { + continue; + } else if (isAssignable(param.asType(), types.LocalSetter)) { + if (isDSLParameter(param)) { + data.addError(param, "%s arguments must not be annotated with @%s or @%s.", + getSimpleName(types.LocalSetter), + getSimpleName(types.Cached), + getSimpleName(types.Bind)); + isValid = false; + } + if (numLocalSetterRanges > 0) { + data.addError(param, "%s arguments must be ordered before %s arguments.", getSimpleName(types.LocalSetter), getSimpleName(types.LocalSetterRange)); + isValid = false; + } + numLocalSetters++; + } else if (isAssignable(param.asType(), types.LocalSetterRange)) { + if (isDSLParameter(param)) { + data.addError(param, "%s arguments must not be annotated with @%s or @%s.", + getSimpleName(types.LocalSetterRange), + getSimpleName(types.Cached), + getSimpleName(types.Bind)); + isValid = false; + } + numLocalSetterRanges++; + } else if (ElementUtils.findAnnotationMirror(param, types.Variadic) != null) { + if (isDSLParameter(param)) { + data.addError(param, "@%s arguments must not be annotated with @%s or @%s.", + getSimpleName(types.Variadic), + getSimpleName(types.Cached), + getSimpleName(types.Bind)); + isValid = false; + } + if (hasVariadic) { + data.addError(param, "Multiple variadic arguments not allowed to an operation. Split up the operation if such behaviour is required."); + isValid = false; + } + if (numLocalSetterRanges > 0 || numLocalSetters > 0) { + data.addError(param, "Value parameters must precede %s and %s parameters.", + getSimpleName(types.LocalSetter), + getSimpleName(types.LocalSetterRange)); + isValid = false; + } + hasVariadic = true; + } else if (isDSLParameter(param)) { + // nothing, we ignore these + } else { + if (hasVariadic) { + data.addError(param, "Non-variadic value parameters must precede variadic ones."); + isValid = false; + } + if (numLocalSetterRanges > 0 || numLocalSetters > 0) { + data.addError(param, "Value parameters must precede LocalSetter and LocalSetterRange parameters."); + isValid = false; + } + canBeBoxingEliminated.add(parent.isBoxingEliminated(param.asType())); + numValues++; + } + } + + if (!isValid) { + return null; + } + + CustomSignature signature = new CustomSignature(); + signature.valueCount = numValues; + signature.isVariadic = hasVariadic; + signature.resultBoxingElimination = parent.isBoxingEliminated(spec.getReturnType()); + signature.localSetterCount = numLocalSetters; + signature.localSetterRangeCount = numLocalSetterRanges; + signature.valueBoxingElimination = new boolean[numValues]; + for (int i = 0; i < numValues; i++) { + signature.valueBoxingElimination[i] = canBeBoxingEliminated.get(i); + } + signature.isVoid = ElementUtils.isVoid(spec.getReturnType()); + + return signature; + } + + private boolean isDSLParameter(VariableElement param) { + for (AnnotationMirror mir : param.getAnnotationMirrors()) { + DeclaredType annotationType = mir.getAnnotationType(); + if (typeEquals(annotationType, types.Cached)) { + return true; + } + if (typeEquals(annotationType, types.CachedLibrary)) { + return true; + } + if (typeEquals(annotationType, types.Bind)) { + return true; + } + } + return false; + } + + private List findSpecializations(TypeElement te) { + if (ElementUtils.isObject(te.asType())) { + return new ArrayList<>(); + } + + List result = findSpecializations(getTypeElement((DeclaredType) te.getSuperclass())); + + for (ExecutableElement ex : ElementFilter.methodsIn(te.getEnclosedElements())) { + if (ElementUtils.findAnnotationMirror(ex, types.Specialization) != null) { + result.add(ex); + } + } + + return result; + } + + @Override + public DeclaredType getAnnotationType() { + return types.Operation; + } + + private CodeTypeElement cloneTypeHierarchy(TypeElement element, Consumer mapper) { + CodeTypeElement result = CodeTypeElement.cloneShallow(element); + if (!ElementUtils.isObject(element.getSuperclass())) { + result.setSuperClass(cloneTypeHierarchy(context.getTypeElement((DeclaredType) element.getSuperclass()), mapper).asType()); + } + + mapper.accept(result); + + return result; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java new file mode 100644 index 000000000000..428421b61e1b --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.parser; + +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; + +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; +import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; +import com.oracle.truffle.dsl.processor.parser.AbstractParser; + +public class OperationsParser extends AbstractParser { + + private static final EnumSet BOXABLE_TYPE_KINDS = EnumSet.of(TypeKind.BOOLEAN, TypeKind.BYTE, TypeKind.INT, TypeKind.FLOAT, TypeKind.LONG, TypeKind.DOUBLE); + + @SuppressWarnings("unchecked") + @Override + protected OperationsModel parse(Element element, List mirror) { + TypeElement typeElement = (TypeElement) element; + AnnotationMirror generateOperationsMirror = ElementUtils.findAnnotationMirror(mirror, types.GenerateOperations); + + OperationsModel model = new OperationsModel(context, typeElement, generateOperationsMirror); + model.languageClass = (DeclaredType) ElementUtils.getAnnotationValue(generateOperationsMirror, "languageClass").getValue(); + model.enableYield = (boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "enableYield", true).getValue(); + + model.addDefault(); + + // check basic declaration properties + if (!typeElement.getModifiers().contains(Modifier.ABSTRACT)) { + model.addError(typeElement, "Operations class must be declared abstract."); + } + + if (!ElementUtils.isAssignable(typeElement.asType(), types.RootNode)) { + model.addError(typeElement, "Operations class must directly or indirectly subclass %s.", getSimpleName(types.RootNode)); + } + + if (!ElementUtils.isAssignable(typeElement.asType(), types.OperationRootNode)) { + model.addError(typeElement, "Operations class must directly or indirectly implement %s.", getSimpleName(types.OperationRootNode)); + } + + for (ExecutableElement ctor : ElementFilter.constructorsIn(typeElement.getEnclosedElements())) { + boolean isValid = ctor.getParameters().size() == 2; + + isValid = isValid && ElementUtils.isAssignable(ctor.getParameters().get(0).asType(), types.TruffleLanguage); + + isValid = isValid && (ctor.getModifiers().contains(Modifier.PUBLIC) || ctor.getModifiers().contains(Modifier.PROTECTED)); + + if (isValid) { + TypeMirror paramType2 = ctor.getParameters().get(1).asType(); + if (ElementUtils.isAssignable(paramType2, types.FrameDescriptor)) { + model.fdConstructor = ctor; + } else if (ElementUtils.isAssignable(paramType2, types.FrameDescriptor_Builder)) { + model.fdBuilderConstructor = ctor; + } else { + isValid = false; + } + } + + if (!isValid) { + model.addError(ctor, "Invalid constructor declaration, expected (%s, %s) or (%s, %s.%s). Remove this constructor.", + getSimpleName(types.TruffleLanguage), + getSimpleName(types.FrameDescriptor), + getSimpleName(types.TruffleLanguage), + getSimpleName(types.FrameDescriptor), + getSimpleName(types.FrameDescriptor_Builder)); + } + } + + if (model.fdConstructor == null) { + model.addError(typeElement, "Operations class requires a (%s, %s) constructor.", + getSimpleName(types.TruffleLanguage), + getSimpleName(types.FrameDescriptor)); + } + + if (model.hasErrors()) { + return model; + } + + // TODO: metadata + + // find @GenerateUncached + AnnotationMirror generateUncachedMirror = ElementUtils.findAnnotationMirror(typeElement, types.GenerateUncached); + if (generateUncachedMirror != null) { + model.generateUncached = true; + } + + // find and bind type system + AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); + if (typeSystemRefMirror != null) { + TypeMirror typeSystemType = getAnnotationValue(TypeMirror.class, typeSystemRefMirror, "value"); + TypeSystemData typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true); + if (typeSystem == null) { + model.addError("The used type system '%s' is invalid. Fix errors in the type system first.", getQualifiedName(typeSystemType)); + return model; + } + + model.typeSystem = typeSystem; + } else { + model.typeSystem = new TypeSystemData(context, typeElement, null, true); + } + + // find and bind boxing elimination types + Set beTypes = new HashSet<>(); + List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); + for (AnnotationValue value : boxingEliminatedTypes) { + + TypeMirror mir = getTypeMirror(value); + + if (BOXABLE_TYPE_KINDS.contains(mir.getKind())) { + beTypes.add(mir); + } else { + model.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", + mir); + } + } + + model.boxingEliminatedTypes = beTypes; + + for (TypeElement te : ElementFilter.typesIn(typeElement.getEnclosedElements())) { + AnnotationMirror op = ElementUtils.findAnnotationMirror(te, types.Operation); + if (op == null) { + continue; + } + + new CustomOperationParser(model, op).parse(te); + } + + for (AnnotationMirror mir : ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.OperationProxy)) { + TypeMirror proxiedType = getTypeMirror(ElementUtils.getAnnotationValue(mir, "value")); + + if (proxiedType.getKind() != TypeKind.DECLARED) { + model.addError("Could not proxy operation: the proxied type must be a class, not %s", proxiedType); + continue; + } + + TypeElement te = (TypeElement) ((DeclaredType) proxiedType).asElement(); + + new CustomOperationParser(model, mir).parse(te); + } + + return model; + } + + private TypeMirror getTypeMirror(AnnotationValue value) throws AssertionError { + if (value.getValue() instanceof Class) { + return context.getType((Class) value.getValue()); + } else if (value.getValue() instanceof TypeMirror) { + return (TypeMirror) value.getValue(); + } else { + throw new AssertionError(); + } + } + + @Override + public DeclaredType getAnnotationType() { + return types.GenerateOperations; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 05e57710199c..41c2817f3308 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -292,10 +292,6 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } - if (mode == ParseMode.DEFAULT && ElementUtils.findAnnotationMirror(templateType.getAnnotationMirrors(), types.Operation) != null) { - return null; - } - List lookupTypes = collectSuperClasses(new ArrayList(), templateType); NodeData node = parseNodeData(templateType, lookupTypes); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index e96c75f8c84a..25129c17c4ce 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -89,8 +89,7 @@ @GenerateOperations(// languageClass = SLLanguage.class, // - decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) From 3ddd9b6ff497d4930f69a7445b4eb8d878ae0f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 20 Dec 2022 14:14:36 +0100 Subject: [PATCH 181/312] [wip] remove old generator --- .../test/example/TestOperations.java | 17 +- .../dsl/processor/TruffleProcessor.java | 4 +- .../expression/DSLExpressionResolver.java | 27 +- .../dsl/processor/library/ExportsParser.java | 3 +- .../dsl/processor/operations/Operation.java | 1229 ------- .../operations/OperationDecisions.java | 269 -- .../operations/OperationGeneratorFlags.java | 65 - .../operations/OperationGeneratorUtils.java | 347 -- .../operations/OperationMetadataData.java | 92 - .../operations/OperationMetadataParser.java | 117 - .../OperationsBytecodeCodeGenerator.java | 774 ----- .../OperationsBytecodeNodeGeneratorPlugs.java | 699 ---- .../operations/OperationsCodeGenerator.java | 2904 ----------------- .../operations/OperationsContext.java | 291 -- .../processor/operations/OperationsData.java | 216 -- .../operations/OperationsParser.java | 342 -- .../SimpleBytecodeNodeGeneratorPlugs.java | 237 -- .../operations/SingleOperationData.java | 263 -- .../operations/SingleOperationParser.java | 591 ---- .../generator/OperationsNodeFactory.java | 36 +- .../instructions/BranchInstruction.java | 184 -- .../ConditionalBranchInstruction.java | 101 - .../instructions/CustomInstruction.java | 265 -- .../instructions/DiscardInstruction.java | 71 - .../operations/instructions/FrameKind.java | 156 - .../operations/instructions/Instruction.java | 842 ----- .../InstrumentationEnterInstruction.java | 86 - .../InstrumentationExitInstruction.java | 109 - .../InstrumentationLeaveInstruction.java | 116 - .../instructions/LoadArgumentInstruction.java | 89 - .../instructions/LoadConstantInstruction.java | 100 - .../instructions/LoadLocalInstruction.java | 316 -- .../LoadLocalMaterializedInstruction.java | 87 - .../instructions/QuickenedInstruction.java | 150 - .../instructions/ReturnInstruction.java | 102 - .../instructions/ShortCircuitInstruction.java | 73 - .../instructions/StoreLocalInstruction.java | 378 --- .../StoreLocalMaterializedInstruction.java | 82 - .../instructions/SuperInstruction.java | 206 -- .../instructions/ThrowInstruction.java | 81 - .../instructions/YieldInstruction.java | 112 - .../operations/model/OperationModel.java | 16 +- .../parser/CustomOperationParser.java | 81 +- .../dsl/processor/parser/NodeParser.java | 42 +- 44 files changed, 153 insertions(+), 12215 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java delete mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 5074e83219e5..035957f10eb9 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -45,7 +45,6 @@ import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -120,14 +119,14 @@ public static long bla(long a1, @Variadic Object[] a2) { } } - @Operation - @GenerateAOT - static final class ThrowOperation { - @Specialization - public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { - throw new TestException("fail", node, bci); - } - } +// @Operation +// @GenerateAOT +// static final class ThrowOperation { +// @Specialization +// public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { +// throw new TestException("fail", node, bci); +// } +// } @Operation static final class AlwaysBoxOperation { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java index 9ffb114a78d0..d801c5184253 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java @@ -189,7 +189,6 @@ public void callback(TypeElement template) { @Override public Set getSupportedAnnotationTypes() { Set annotations = new HashSet<>(); - annotations.add(TruffleTypes.GenerateOperations_Name); annotations.add(TruffleTypes.Specialization_Name); annotations.add(TruffleTypes.Fallback_Name); annotations.add(TruffleTypes.TypeSystemReference_Name); @@ -201,16 +200,17 @@ public Set getSupportedAnnotationTypes() { annotations.add(TruffleTypes.ExportLibrary_Name); annotations.add(TruffleTypes.ExportMessage_Name); annotations.add(TruffleTypes.ExportLibrary_Repeat_Name); + annotations.add(TruffleTypes.GenerateOperations_Name); return annotations; } private static List> createGenerators() { List> generators = new ArrayList<>(); - generators.add(new AnnotationProcessor<>(new OperationsParser(), new OperationsCodeGenerator())); generators.add(new AnnotationProcessor<>(new TypeSystemParser(), new TypeSystemCodeGenerator())); generators.add(new AnnotationProcessor<>(NodeParser.createDefaultParser(), new NodeCodeGenerator())); generators.add(new AnnotationProcessor<>(new LibraryParser(), new LibraryGenerator())); generators.add(new AnnotationProcessor<>(new ExportsParser(), new ExportsGenerator(new StaticConstants()))); + generators.add(new AnnotationProcessor<>(new OperationsParser(), new OperationsCodeGenerator())); return generators; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index 815ec039d371..ddc1fdc0b317 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -68,7 +68,6 @@ import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.parser.NodeParser.ParseMode; public class DSLExpressionResolver implements DSLExpressionVisitor { @@ -86,20 +85,16 @@ public class DSLExpressionResolver implements DSLExpressionVisitor { private final List unprocessedElements; private boolean processed; - private final ParseMode parseMode; - TypeMirror thisType; - private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements, ParseMode parseMode, TypeMirror thisType) { + private DSLExpressionResolver(ProcessorContext context, TypeElement accessType, DSLExpressionResolver parent, List lookupElements) { this.context = context; this.parent = parent; this.accessType = accessType; this.unprocessedElements = new ArrayList<>(lookupElements); - this.parseMode = parseMode; - this.thisType = thisType; } - public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements, ParseMode parseMode, TypeMirror thisType) { - this(context, accessType, null, lookupElements, parseMode, thisType); + public DSLExpressionResolver(ProcessorContext context, TypeElement accessType, List lookupElements) { + this(context, accessType, null, lookupElements); } public TypeElement getAccessType() { @@ -137,7 +132,7 @@ private void processElements(List lookupElements) { } public DSLExpressionResolver copy(List prefixElements) { - return new DSLExpressionResolver(context, accessType, this, prefixElements, parseMode, thisType); + return new DSLExpressionResolver(context, accessType, this, prefixElements); } private static String getMethodName(ExecutableElement method) { @@ -234,13 +229,11 @@ private static boolean matchExecutable(Call call, ExecutableElement method) { private VariableElement resolveVariable(Variable variable) { final String name = variable.getName(); - if (parseMode == ParseMode.OPERATION && "this".equals(name)) { - return new CodeVariableElement(thisType, "this"); - } - switch (name) { case "null": return new CodeVariableElement(new CodeTypeMirror(TypeKind.NULL), "null"); + case "$bci": + return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "-1"); case "false": return new CodeVariableElement(new CodeTypeMirror(TypeKind.BOOLEAN), "false"); case "true": @@ -262,8 +255,8 @@ private VariableElement resolveVariable(Variable variable) { return parent.resolveVariable(variable); } - if ("$bci".equals(name)) { - return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "-1"); + if (name.equals("this")) { + return new CodeVariableElement(ProcessorContext.getInstance().getTypes().Node, "this"); } return null; @@ -288,7 +281,7 @@ public void visitCall(Call call) { } } } - resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode, thisType); + resolver = new DSLExpressionResolver(context, this.accessType, elements); } ExecutableElement resolvedMethod = resolver.resolveCall(call); @@ -332,7 +325,7 @@ public void visitVariable(Variable variable) { } else if (type.getKind() == TypeKind.ARRAY) { elements.add(new CodeVariableElement(context.getType(int.class), "length")); } - resolver = new DSLExpressionResolver(context, this.accessType, elements, parseMode, thisType); + resolver = new DSLExpressionResolver(context, this.accessType, elements); } VariableElement var = resolver.resolveVariable(variable); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java index 0329759f519e..a3c04a9bd758 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java @@ -103,7 +103,6 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.NodeParser; -import com.oracle.truffle.dsl.processor.parser.NodeParser.ParseMode; public class ExportsParser extends AbstractParser { @@ -697,7 +696,7 @@ private ExportsData parseExports(TypeElement type, List elemen String transitionLimit = ElementUtils.getAnnotationValue(String.class, annotationMirror, "transitionLimit", false); if (transitionLimit != null) { DSLExpressionResolver resolver = new DSLExpressionResolver(context, model.getTemplateType(), - NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false), ParseMode.EXPORTED_MESSAGE, types.Node); + NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false)); try { DSLExpression expression = DSLExpression.parse(transitionLimit); expression.accept(resolver); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java deleted file mode 100644 index 308e3a695458..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/Operation.java +++ /dev/null @@ -1,1229 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createCreateLabel; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitBranchInstruction; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitInstruction; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createEmitLabel; - -import java.util.List; - -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalMaterializedInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalMaterializedInstruction; - -public abstract class Operation { - public static final int VARIABLE_CHILDREN = -1; - - public final OperationsContext context; - public final String name; - public final int id; - public final int children; - - public CodeVariableElement idConstantField; - - protected Operation(OperationsContext context, String name, int id, int children) { - this.context = context; - this.name = name; - this.id = id; - this.children = children; - } - - public final boolean isVariableChildren() { - return children == VARIABLE_CHILDREN; - } - - public String conditionedOn() { - return null; - } - - public void setIdConstantField(CodeVariableElement idConstantField) { - this.idConstantField = idConstantField; - } - - public static class BuilderVariables { - public CodeVariableElement bc; - public CodeVariableElement bci; - public CodeVariableElement consts; - public CodeVariableElement operationData; - public CodeVariableElement lastChildPushCount; - public CodeVariableElement childIndex; - public CodeVariableElement numChildren; - - public ExecutionVariables asExecution() { - ExecutionVariables result = new ExecutionVariables(); - result.bc = this.bc; - result.bci = this.bci; - return result; - } - } - - public int minimumChildren() { - assert isVariableChildren() : "should only be called for variadics"; - return 0; - } - - public abstract List getBuilderArgumentTypes(); - - public boolean needsOperationData() { - return true; - } - - @SuppressWarnings("unused") - public CodeTree createBeginCode(BuilderVariables vars) { - return null; - } - - @SuppressWarnings("unused") - public CodeTree createAfterChildCode(BuilderVariables vars) { - return null; - } - - @SuppressWarnings("unused") - public CodeTree createBeforeChildCode(BuilderVariables vars) { - return null; - } - - @SuppressWarnings("unused") - public CodeTree createEndCode(BuilderVariables vars) { - return null; - } - - @SuppressWarnings("unused") - public CodeTree createLeaveCode(BuilderVariables vars) { - return null; - } - - public boolean hasLeaveCode() { - return false; - } - - public int getNumAuxValues() { - return 0; - } - - public int numLocalReferences() { - return 0; - } - - public boolean isRealOperation() { - return true; - } - - public boolean isRoot() { - return false; - } - - public CodeVariableElement getResultVariable() { - return null; - } - - public abstract CodeTree createPushCountCode(BuilderVariables vars); - - public static class Simple extends Operation { - - private final Instruction instruction; - - protected Simple(OperationsContext builder, String name, int id, int children, Instruction instruction) { - super(builder, name, id, children); - this.instruction = instruction; - } - - private static int moveArguments(BuilderVariables vars, int startIndex, CodeTree[] array, String castTarget) { - int index = startIndex; - for (int i = 0; i < array.length; i++) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - if (castTarget != null) { - b.string("(", castTarget, ") "); - } - b.variable(vars.operationData).string(".arguments[" + index + "]"); - array[i] = b.build(); - index++; - } - - return index; - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - int index = 0; - - EmitArguments args = new EmitArguments(); - - args.constants = new CodeTree[instruction.numConstants()]; - args.locals = new CodeTree[instruction.numLocals()]; - args.localRuns = new CodeTree[instruction.numLocalRuns()]; - args.arguments = new CodeTree[instruction.numArguments()]; - args.branchTargets = new CodeTree[instruction.numBranchTargets()]; - - boolean[] typedConstants = instruction.typedConstants(); - for (int i = 0; i < typedConstants.length; i++) { - if (typedConstants[i]) { - args.constants[i] = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".arguments[" + index + "]").build(); - index++; - } - } - - index = moveArguments(vars, index, args.locals, null); - index = moveArguments(vars, index, args.localRuns, null); - index = moveArguments(vars, index, args.arguments, null); - index = moveArguments(vars, index, args.branchTargets, "OperationLabelImpl"); - - if (instruction.isVariadic()) { - args.variadicCount = CodeTreeBuilder.createBuilder().string("numChildren - " + instruction.numPopStatic()).build(); - } - - return OperationGeneratorUtils.createEmitInstruction(vars, instruction, args); - - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("" + instruction.numPushedValues); - } - - @Override - public List getBuilderArgumentTypes() { - return instruction.getBuilderArgumentTypes(); - } - - @Override - public int numLocalReferences() { - return instruction.numLocalReferences(); - } - } - - public static class LoadLocalMaterialized extends Operation { - private final LoadLocalMaterializedInstruction instr; - - public LoadLocalMaterialized(OperationsContext context, int id, LoadLocalMaterializedInstruction instr) { - super(context, "LoadLocalMaterialized", id, 1); - this.instr = instr; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - - EmitArguments args = new EmitArguments(); - args.arguments = new CodeTree[1]; - args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); - - // todo: validate the local is nested properly - // (not security critical since non-local accesses use safe API) - return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("1"); - } - } - - public static class StoreLocalMaterialized extends Operation { - private final StoreLocalMaterializedInstruction instr; - - public StoreLocalMaterialized(OperationsContext context, int id, StoreLocalMaterializedInstruction instr) { - super(context, "StoreLocalMaterialized", id, 2); - this.instr = instr; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - - EmitArguments args = new EmitArguments(); - args.arguments = new CodeTree[1]; - args.arguments[0] = CodeTreeBuilder.singleString("((OperationLocalImpl)operationData.arguments[0]).id"); - - // todo: validate the local is nested properly - // (not security critical since non-local accesses use safe API) - return OperationGeneratorUtils.createEmitInstruction(vars, instr, args); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - } - - public static class LoadConstant extends Operation { - private final LoadConstantInstruction[] instructions; - - protected LoadConstant(OperationsContext builder, int id, LoadConstantInstruction... instructions) { - super(builder, "ConstObject", id, 0); - this.instructions = instructions; - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - EmitArguments args = new EmitArguments(); - args.constants = new CodeTree[]{CodeTreeBuilder.singleString("arg0")}; - - b.tree(OperationGeneratorUtils.createEmitInstruction(vars, instructions[FrameKind.OBJECT.ordinal()], args)); - - return b.build(); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getType(Object.class)); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("1"); - } - } - - public static class Block extends Operation { - protected Block(OperationsContext builder, int id) { - super(builder, "Block", id, VARIABLE_CHILDREN); - } - - // for child classes - protected Block(OperationsContext builder, String name, int id) { - super(builder, name, id, VARIABLE_CHILDREN); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign(vars.lastChildPushCount).string("0").end(); - - return b.build(); - } - - @Override - public CodeTree createBeforeChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" != 0").end(); - b.startBlock(); - // { - b.tree(createPopLastChildCode(vars)); - // } - b.end(); - - return b.build(); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return null; // does not change it at all - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - } - - public static class Root extends Block { - protected Root(OperationsContext context, int id) { - super(context, "Root", id); - } - - @Override - public boolean needsOperationData() { - return false; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().TruffleLanguage); - } - - @Override - public CodeVariableElement getResultVariable() { - return new CodeVariableElement(context.getData().getTemplateType().asType(), "endCodeResult"); - } - - @Override - public boolean isRoot() { - return true; - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(super.createBeginCode(vars)); - - // todo: there is no need to store the state at top level - b.statement("this.parentData = new BuilderState(this)"); - b.statement("this.bc = new short[65535]"); - b.statement("this.constPool = new ArrayList<>()"); - b.statement("this.labels = new ArrayList<>()"); - b.statement("this.labelFills = new ArrayList<>()"); - b.statement("this.exceptionHandlers = new ArrayList<>()"); - b.statement("this.stackSourceBci = new int[1024]"); - b.statement("reset(arg0)"); - return b.build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.tree(super.createBeginCode(vars)); - - b.declaration(context.getData().getTemplateType().asType(), "endCodeResult", (CodeTree) null); - - b.statement("endCodeResult = publish((TruffleLanguage) operationData.arguments[0])"); - - b.statement("this.bc = parentData.bc"); - b.statement("this.bci = parentData.bci"); - b.statement("this.curStack = parentData.curStack"); - b.statement("this.maxStack = parentData.maxStack"); - b.statement("this.numLocals = parentData.numLocals"); - b.statement("this.numLabels = parentData.numLabels"); - b.statement("this.constPool = parentData.constPool"); - b.statement("this.operationData = parentData.operationData"); - b.statement("this.labels = parentData.labels"); - b.statement("this.labelFills = parentData.labelFills"); - b.statement("this.numChildNodes = parentData.numChildNodes"); - b.statement("this.numConditionProfiles = parentData.numConditionProfiles"); - b.statement("this.exceptionHandlers = parentData.exceptionHandlers"); - b.statement("this.currentFinallyTry = parentData.currentFinallyTry"); - b.statement("this.stackSourceBci = parentData.stackSourceBci"); - b.statement("this.sourceBuilder = parentData.sourceBuilder"); - - b.statement("this.parentData = parentData.parentData"); - - return b.build(); - } - } - - public static class IfThen extends Operation { - protected IfThen(OperationsContext builder, int id) { - super(builder, "IfThen", id, 2); - } - - @Override - public int getNumAuxValues() { - return 1; - } - - @Override - public CodeTree createAfterChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" == 0").end(); - b.startBlock(); - // { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varEndLabel))); - - b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varEndLabel)); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - // } - b.end().startElseBlock(); - // { - b.tree(createPopLastChildCode(vars)); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); - // } - b.end(); - - return b.build(); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - } - - public static class IfThenElse extends Operation { - - private final boolean hasValue; - - public IfThenElse(OperationsContext builder, int id, boolean hasValue) { - super(builder, hasValue ? "Conditional" : "IfThenElse", id, 3); - this.hasValue = hasValue; - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString(hasValue ? "1" : "0"); - } - - @Override - public int getNumAuxValues() { - return 2; - } - - @Override - public CodeTree createAfterChildCode(BuilderVariables vars) { - - // <> - // brfalse elseLabel - - // <> - // br endLabel - // elseLabel: - - // <> - // endLabel: - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" == 0").end(); - b.startBlock(); - // { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - - CodeVariableElement varElseLabel = new CodeVariableElement(context.labelType, "elseLabel"); - b.declaration(context.labelType, varElseLabel.getName(), createCreateLabel()); - - b.tree(createSetAux(vars, 0, CodeTreeBuilder.singleVariable(varElseLabel))); - - b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, varElseLabel)); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - // } - b.end(); - b.startElseIf().variable(vars.childIndex).string(" == 1").end(); - b.startBlock(); // { - // { - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - - if (hasValue) { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - } else { - b.tree(createPopLastChildCode(vars)); - } - - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.tree(createSetAux(vars, 1, CodeTreeBuilder.singleVariable(varEndLabel))); - - b.tree(createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); - // } - b.end().startElseBlock(); - // { - - if (hasValue) { - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - } else { - b.tree(createPopLastChildCode(vars)); - } - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, 1, context.labelType))); - // } - b.end(); - - return b.build(); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - } - - public static class While extends Operation { - public While(OperationsContext builder, int id) { - super(builder, "While", id, 2); - } - - private static final int AUX_START_LABEL = 0; - private static final int AUX_END_LABEL = 1; - - @Override - public int getNumAuxValues() { - return 2; - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - CodeVariableElement varStartLabel = new CodeVariableElement(context.labelType, "startLabel"); - b.declaration(context.labelType, varStartLabel.getName(), createCreateLabel()); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, varStartLabel)); - - b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); - - return b.build(); - } - - @Override - public CodeTree createAfterChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" == 0").end(); - b.startBlock(); - // { - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - - b.startAssert().variable(vars.lastChildPushCount).string(" == 1").end(); - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - - b.tree(createEmitBranchInstruction(vars, context.commonBranchFalse, CodeTreeBuilder.singleVariable(varEndLabel))); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - // } - b.end().startElseBlock(); - // { - b.tree(createPopLastChildCode(vars)); - - b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_START_LABEL, context.labelType))); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); - // } - - b.end(); - - return b.build(); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - } - - public static class Label extends Operation { - public Label(OperationsContext builder, int id) { - super(builder, "Label", id, 0); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, CodeTreeBuilder.singleString("arg0"))); - - return b.build(); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().OperationLabel); - } - - @Override - public boolean needsOperationData() { - return false; - } - } - - public static class TryCatch extends Operation { - public TryCatch(OperationsContext builder, int id) { - super(builder, "TryCatch", id, 2); - } - - private static final int AUX_BEH = 0; - private static final int AUX_END_LABEL = 1; - - @Override - public int getNumAuxValues() { - return 2; - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("0"); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - CodeVariableElement varBeh = new CodeVariableElement(context.exceptionType, "beh"); - b.declaration(context.exceptionType, "beh", CodeTreeBuilder.createBuilder().startNew(context.exceptionType).end().build()); - b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = curStack").end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = getLocalIndex(").variable(vars.operationData).string(".arguments[0])").end(); - b.startStatement().startCall("exceptionHandlers.add").variable(varBeh).end(2); - - b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); - - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - - return b.build(); - } - - @Override - public CodeTree createAfterChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(createPopLastChildCode(vars)); - - b.startIf().variable(vars.childIndex).string(" == 0").end(); - b.startBlock(); - - b.startStatement().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".endBci = ").variable(vars.bci).end(); - - b.tree(createEmitBranchInstruction(vars, context.commonBranch, createGetAux(vars, AUX_END_LABEL, context.labelType))); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.end().startElseBlock(); - - b.end(); - - return b.build(); - } - - @Override - public CodeTree createBeforeChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" == 1").end(); - b.startBlock(); - - b.startAssign("curStack").startGroup().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".startStack").end(2); - b.startStatement().tree(createGetAux(vars, AUX_BEH, context.exceptionType)).string(".handlerBci = ").variable(vars.bci).end(); - - b.end(); - - return b.build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(createEmitLabel(vars, createGetAux(vars, AUX_END_LABEL, context.labelType))); - - return b.build(); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().OperationLocal); - } - } - - public static class Source extends Block { - - public static final String NAME = "Source"; - - public Source(OperationsContext builder, int id) { - super(builder, NAME, id); - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getTypes().Source); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().statement("sourceBuilder.beginSource(bci, arg0)").build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().statement("sourceBuilder.endSource(bci)").build(); - } - - @Override - public String conditionedOn() { - return "withSource"; - } - } - - public static class SourceSection extends Block { - - public static final String NAME = "SourceSection"; - - public SourceSection(OperationsContext builder, int id) { - super(builder, NAME, id); - } - - @Override - public List getBuilderArgumentTypes() { - ProcessorContext pc = ProcessorContext.getInstance(); - return List.of(pc.getType(int.class), pc.getType(int.class)); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().statement("sourceBuilder.beginSourceSection(bci, arg0, arg1)").build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - return CodeTreeBuilder.createBuilder().statement("sourceBuilder.endSourceSection(bci)").build(); - } - - @Override - public String conditionedOn() { - return "withSource"; - } - } - - public static class InstrumentTag extends Block { - private final Instruction startInstruction; - private final Instruction endInstruction; - private final Instruction endVoidInstruction; - @SuppressWarnings("unused") private final Instruction leaveInstruction; - - public static final String NAME = "Tag"; - - public InstrumentTag(OperationsContext builder, int id, Instruction startInstruction, Instruction endInstruction, Instruction endVoidInstruction, Instruction leaveInstruction) { - super(builder, NAME, id); - this.startInstruction = startInstruction; - this.endInstruction = endInstruction; - this.endVoidInstruction = endVoidInstruction; - this.leaveInstruction = leaveInstruction; - } - - private static final int AUX_ID = 0; - private static final int AUX_START_LABEL = 1; - private static final int AUX_END_LABEL = 2; - - @Override - public int getNumAuxValues() { - return 3; - } - - @Override - public String conditionedOn() { - return "withInstrumentation"; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(ProcessorContext.getInstance().getType(Class.class)); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - CodeVariableElement varCurInstrumentId = new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "curInstrumentId"); - CodeVariableElement varStartLabel = new CodeVariableElement(context.labelType, "startLabel"); - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - - // todo - b.declaration("int", varCurInstrumentId.getName(), "0"); - b.declaration(context.labelType, varStartLabel.getName(), createCreateLabel()); - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.tree(createEmitLabel(vars, varStartLabel)); - - b.tree(createSetAux(vars, AUX_ID, CodeTreeBuilder.singleVariable(varCurInstrumentId))); - b.tree(createSetAux(vars, AUX_START_LABEL, CodeTreeBuilder.singleVariable(varStartLabel))); - b.tree(createSetAux(vars, AUX_END_LABEL, CodeTreeBuilder.singleVariable(varEndLabel))); - - b.tree(createEmitBranchInstruction(vars, startInstruction, varCurInstrumentId)); - - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - b.tree(super.createBeginCode(vars)); - return b.build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.lastChildPushCount).string(" != 0").end(); - b.startBlock(); - b.tree(createEmitBranchInstruction(vars, endInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); - b.end().startElseBlock(); - b.tree(createEmitBranchInstruction(vars, endVoidInstruction, createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)))); - b.end(); - - b.tree(super.createEndCode(vars)); - return b.build(); - } - - @Override - public CodeTree createLeaveCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - // b.tree(createEmitInstruction(vars, leaveInstruction, - // createGetAux(vars, AUX_ID, new CodeTypeMirror(TypeKind.INT)), - // createGetAux(vars, AUX_START_LABEL, builder.labelType), - // createGetAux(vars, AUX_END_LABEL, builder.labelType))); - // todo - - return b.build(); - } - - @Override - public boolean hasLeaveCode() { - return true; - } - } - - public static class FinallyTry extends Operation { - - private static final int AUX_CONTEXT = 0; - private static final int AUX_BEH = 1; - private static final int AUX_LOCAL = 2; - - private final boolean noExcept; - - public FinallyTry(OperationsContext builder, int id, boolean noExcept) { - super(builder, noExcept ? "FinallyTryNoExcept" : "FinallyTry", id, 2); - this.noExcept = noExcept; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - // todo: this could be made to return Try value on exit - return CodeTreeBuilder.singleString("0"); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (!noExcept) { - b.startStatement().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "] = "); - b.startCall("createParentLocal"); - b.end(2); - } - - b.statement("currentFinallyTry = new BuilderFinallyTryContext(currentFinallyTry, Arrays.copyOf(bc, bci), exceptionHandlers, labelFills, labels, curStack, maxStack)"); - - b.statement("bci = 0"); - b.statement("exceptionHandlers = new ArrayList<>()"); - b.statement("labelFills = new ArrayList<>()"); - b.statement("labels = new ArrayList<>()"); - b.statement("curStack = 0"); - b.statement("maxStack = 0"); - - b.startStatement().variable(vars.operationData).string(".aux[" + AUX_CONTEXT + "] = currentFinallyTry").end(2); - - return b.build(); - } - - @Override - public CodeTree createAfterChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(createPopLastChildCode(vars)); - - b.startIf().variable(vars.childIndex).string(" == 0").end().startBlock(); - // { - - b.statement("labelPass(currentFinallyTry)"); - - b.statement("currentFinallyTry.handlerBc = Arrays.copyOf(bc, bci)"); - b.statement("currentFinallyTry.handlerHandlers = exceptionHandlers"); - b.statement("currentFinallyTry.handlerMaxStack = maxStack"); - - b.statement("System.arraycopy(currentFinallyTry.bc, 0, bc, 0, currentFinallyTry.bc.length)"); - b.statement("bci = currentFinallyTry.bc.length"); - b.statement("exceptionHandlers = currentFinallyTry.exceptionHandlers"); - b.statement("labelFills = currentFinallyTry.labelFills"); - b.statement("labels = currentFinallyTry.labels"); - b.statement("curStack = currentFinallyTry.curStack"); - b.statement("maxStack = currentFinallyTry.maxStack"); - - b.statement("currentFinallyTry = currentFinallyTry.prev"); - - if (!noExcept) { - CodeVariableElement varBeh = new CodeVariableElement(context.exceptionType, "beh"); - b.declaration(context.exceptionType, "beh", CodeTreeBuilder.createBuilder().startNew(context.exceptionType).end().build()); - - b.startStatement().variable(varBeh).string(".startBci = ").variable(vars.bci).end(); - b.startStatement().variable(varBeh).string(".startStack = curStack").end(); - b.startStatement().variable(varBeh).string(".exceptionIndex = "); - b.startCall("getLocalIndex"); - b.startGroup().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").end(); - b.end(); - b.end(); - b.startStatement().startCall("exceptionHandlers.add").variable(varBeh).end(2); - b.tree(createSetAux(vars, AUX_BEH, CodeTreeBuilder.singleVariable(varBeh))); - } - - // } - b.end(); - return b.build(); - } - - @Override - public CodeTree createLeaveCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - emitLeaveCode(vars, b); - - return b.build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (noExcept) { - emitLeaveCode(vars, b); - } else { - // ; exception end - // << handler code >> - // goto end - // ; exception handler start - // << handler code >> - // throw [exc] - // end: - - b.startAssign("int endBci").variable(vars.bci).end(); - - emitLeaveCode(vars, b); - - CodeVariableElement varEndLabel = new CodeVariableElement(context.labelType, "endLabel"); - b.declaration(context.labelType, varEndLabel.getName(), createCreateLabel()); - - b.startBlock(); - b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, context.commonBranch, varEndLabel)); - if (context.getData().isTracing()) { - b.statement("isBbStart[bci] = true"); - } - b.end(); - - b.declaration(context.exceptionType, "beh", createGetAux(vars, AUX_BEH, context.exceptionType)); - b.startAssign("beh.endBci").string("endBci").end(); - b.startAssign("beh.handlerBci").variable(vars.bci).end(); - - emitLeaveCode(vars, b); - - b.startBlock(); - CodeTree localIdx = CodeTreeBuilder.createBuilder().variable(vars.operationData).string(".aux[" + AUX_LOCAL + "]").build(); - b.tree(OperationGeneratorUtils.createEmitLocalInstruction(vars, context.commonThrow, localIdx)); - b.end(); - - b.tree(OperationGeneratorUtils.createEmitLabel(vars, varEndLabel)); - } - - return b.build(); - } - - private static void emitLeaveCode(BuilderVariables vars, CodeTreeBuilder b) { - b.startStatement().startCall("doLeaveFinallyTry").variable(vars.operationData).end(2); - } - - @Override - public int getNumAuxValues() { - return noExcept ? 1 : 3; - } - - @Override - public boolean hasLeaveCode() { - return true; - } - } - - public static class ShortCircuitOperation extends Operation { - - private final ShortCircuitInstruction instruction; - - protected ShortCircuitOperation(OperationsContext builder, String name, int id, ShortCircuitInstruction instruction) { - super(builder, name, id, VARIABLE_CHILDREN); - this.instruction = instruction; - } - - @Override - public List getBuilderArgumentTypes() { - return List.of(); - } - - @Override - public int minimumChildren() { - return 1; - } - - @Override - public int getNumAuxValues() { - return 1; // only the end label - } - - @Override - public CodeTree createPushCountCode(BuilderVariables vars) { - return CodeTreeBuilder.singleString("1"); - } - - @Override - public CodeTree createBeginCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(createSetAux(vars, 0, createCreateLabel())); - - return b.build(); - } - - @Override - public CodeTree createBeforeChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startIf().variable(vars.childIndex).string(" > 0").end().startBlock(); - // { - b.tree(OperationGeneratorUtils.createEmitBranchInstruction(vars, instruction, createGetAux(vars, 0, context.labelType))); - // } - b.end(); - - return b.build(); - } - - @Override - public CodeTree createEndCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(OperationGeneratorUtils.createEmitLabel(vars, createGetAux(vars, 0, context.labelType))); - - return b.build(); - } - - } - - private static CodeTree createSetAux(BuilderVariables vars, int index, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement().variable(vars.operationData).string(".aux[" + index + "] = ").tree(value).end().build(); - } - - private static CodeTree createGetAux(BuilderVariables vars, int index, TypeMirror cast) { - return CodeTreeBuilder.createBuilder().string("(").cast(cast).variable(vars.operationData).string(".aux[" + index + "]").string(")").build(); - } - - protected final CodeTree createPopLastChildCode(BuilderVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startFor().string("int i = 0; i < ", vars.lastChildPushCount.getName(), "; i++").end(); - b.startBlock(); // { - - b.tree(createEmitInstruction(vars, context.commonPop, new EmitArguments())); - - b.end(); // } - return b.build(); - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java deleted file mode 100644 index e9571340a03f..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationDecisions.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -import com.oracle.truffle.dsl.processor.model.MessageContainer; -import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONObject; - -public class OperationDecisions { - private final List quicken = new ArrayList<>(); - private final List superInstr = new ArrayList<>(); - private final List commonInstr = new ArrayList<>(); - - public OperationDecisions() { - } - - public List getQuicken() { - return quicken; - } - - public List getSuperInstructions() { - return superInstr; - } - - public List getCommonInstructions() { - return commonInstr; - } - - public OperationDecisions merge(OperationDecisions other, MessageContainer messager) { - for (Quicken q : other.quicken) { - if (quicken.contains(q)) { - messager.addWarning("Duplicate optimization decision: %s", q); - } else { - quicken.add(q); - } - } - - return this; - } - - public static final class Quicken { - final String operation; - final String[] specializations; - - public String getOperation() { - return operation; - } - - public String[] getSpecializations() { - return specializations; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(specializations); - result = prime * result + Objects.hash(operation); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Quicken other = (Quicken) obj; - return Objects.equals(operation, other.operation) && Arrays.equals(specializations, other.specializations); - } - - @Override - public String toString() { - return "Quicken [operation=" + operation + ", specializations=" + Arrays.toString(specializations) + "]"; - } - - private Quicken(String operation, String[] specializations) { - this.operation = operation; - - Arrays.sort(specializations); - this.specializations = specializations; - } - - public static Quicken deserialize(JSONObject o) { - String operation = o.getString("operation"); - - JSONArray specs = o.getJSONArray("specializations"); - List specializations = new ArrayList<>(); - - for (int i = 0; i < specs.length(); i++) { - specializations.add(specs.getString(i)); - } - - return new Quicken(operation, specializations.toArray(new String[specializations.size()])); - } - } - - public static final class SuperInstruction { - final String[] instructions; - - private SuperInstruction(String[] instructions) { - this.instructions = instructions; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(instructions); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SuperInstruction other = (SuperInstruction) obj; - return Arrays.equals(instructions, other.instructions); - } - - @Override - public String toString() { - return "SuperInstruction [" + Arrays.toString(instructions) + "]"; - } - - public static SuperInstruction deserialize(JSONObject o) { - - JSONArray instrs = o.getJSONArray("instructions"); - List instructions = new ArrayList<>(); - - for (int i = 0; i < instrs.length(); i++) { - instructions.add(instrs.getString(i)); - } - - return new SuperInstruction(instructions.toArray(new String[instructions.size()])); - } - } - - public static final class CommonInstruction { - final String instruction; - - @Override - public int hashCode() { - return Objects.hash(instruction); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CommonInstruction other = (CommonInstruction) obj; - return Objects.equals(instruction, other.instruction); - } - - private CommonInstruction(String instruction) { - this.instruction = instruction; - } - - @Override - public String toString() { - return "CommonInstruction [" + instruction + "]"; - } - - public static CommonInstruction deserialize(JSONObject o) { - String instruction = o.getString("instruction"); - return new CommonInstruction(instruction); - } - } - - public static OperationDecisions deserialize(JSONArray o, MessageContainer messager) { - OperationDecisions decisions = new OperationDecisions(); - - for (int i = 0; i < o.length(); i++) { - if (o.get(i) instanceof String) { - // strings are treated as comments - continue; - } - - JSONObject decision = o.getJSONObject(i); - - switch (decision.getString("type")) { - case "Quicken": - Quicken q = Quicken.deserialize(decision); - decisions.quicken.add(q); - break; - case "SuperInstruction": - SuperInstruction si = SuperInstruction.deserialize(decision); - decisions.superInstr.add(si); - break; - case "CommonInstruction": - CommonInstruction ci = CommonInstruction.deserialize(decision); - decisions.commonInstr.add(ci); - break; - default: - messager.addWarning("Invalid optimization decision: '%s'", decision.getString("type")); - break; - } - } - - return decisions; - } - - @Override - public String toString() { - return "OperationDecisions [quicken=" + quicken + ", superInstr=" + superInstr + "]"; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java deleted file mode 100644 index 791a0632d237..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorFlags.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -public class OperationGeneratorFlags { - - public static final boolean LOG_LOCAL_STORES = false; - public static final boolean LOG_LOCAL_STORES_SPEC = false; - public static final boolean LOG_LOCAL_LOADS = LOG_LOCAL_STORES; - public static final boolean LOG_LOCAL_LOADS_SPEC = LOG_LOCAL_STORES_SPEC; - - public static final boolean LOG_EXECUTE_AND_SPECIALIZE_CALLS = false; - public static final boolean LOG_STACK_READS = false; - - public static final boolean ENABLE_INSTRUMENTATION = true; - - public static final boolean FLAG_NODE_AST_PRINTING = false; - public static final boolean INTERPRETER_ONLY_BOXING_ELIMINATION = false; - - public static final boolean ENABLE_SERIALIZATION = true; - - public static final int BOXING_ELIM_BITS = 3; - - public static final boolean CREATE_COMMON_EXECUTE = false; - - public static final boolean USE_SIMPLE_BYTECODE = true; -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java deleted file mode 100644 index d51ddf12a9c2..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationGeneratorUtils.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Supplier; - -import javax.lang.model.element.Element; -import javax.lang.model.element.Modifier; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.EmitArguments; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; - -public class OperationGeneratorUtils { - - public static TruffleTypes getTypes() { - return ProcessorContext.getInstance().getTypes(); - } - - public static String toScreamCase(String s) { - return s.replaceAll("([a-z]|[A-Z]+)([A-Z])", "$1_$2").replace('.', '_').toUpperCase(); - } - - public static CodeTree createEmitInstruction(BuilderVariables vars, Instruction instr, EmitArguments arguments) { - return instr.createEmitCode(vars, arguments); - } - - public static CodeTree createEmitBranchInstruction(BuilderVariables vars, Instruction instr, CodeVariableElement arguments) { - return createEmitBranchInstruction(vars, instr, CodeTreeBuilder.singleVariable(arguments)); - } - - public static CodeTree createEmitBranchInstruction(BuilderVariables vars, Instruction instr, CodeTree arguments) { - EmitArguments args = new EmitArguments(); - args.branchTargets = new CodeTree[]{arguments}; - return createEmitInstruction(vars, instr, args); - } - - public static CodeTree createEmitLocalInstruction(BuilderVariables vars, Instruction instr, CodeTree arguments) { - EmitArguments args = new EmitArguments(); - args.locals = new CodeTree[]{arguments}; - return createEmitInstruction(vars, instr, args); - } - - public static CodeTree createCreateLabel() { - return CodeTreeBuilder.createBuilder().startCall("(OperationLabelImpl) createLabel").end().build(); - } - - @SuppressWarnings("unused") - public static CodeTree createEmitLabel(BuilderVariables vars, CodeTree label) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("doEmitLabel").tree(label).end(2).build(); - } - - public static CodeTree createEmitLabel(BuilderVariables vars, CodeVariableElement label) { - return createEmitLabel(vars, CodeTreeBuilder.singleVariable(label)); - } - - public static CodeTree createReadOpcode(CodeTree bc, CodeTree bci) { - return CodeTreeBuilder.createBuilder().startCall("unsafeFromBytecode").tree(bc).tree(bci).end().build(); - } - - public static CodeTree createReadOpcode(CodeVariableElement bc, CodeVariableElement bci) { - return createReadOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleVariable(bci)); - } - - public static CodeTree createReadOpcode(CodeVariableElement bc, String bci) { - return createReadOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleString(bci)); - } - - public static CodeTree createWriteOpcode(CodeTree bc, CodeTree bci, CodeTree value) { - return CodeTreeBuilder.createBuilder().startStatement().startCall("unsafeWriteBytecode").tree(bc).tree(bci).startGroup().string("(short) ").tree(value).end(3).build(); - } - - public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeVariableElement value) { - return createWriteOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleVariable(bci), - CodeTreeBuilder.singleVariable(value)); - } - - public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, String value) { - return createWriteOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleVariable(bci), - CodeTreeBuilder.singleString(value)); - } - - public static CodeTree createWriteOpcode(CodeVariableElement bc, CodeVariableElement bci, CodeTree value) { - return createWriteOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleVariable(bci), - value); - } - - public static CodeTree createWriteOpcode(CodeVariableElement bc, String bci, CodeVariableElement value) { - return createWriteOpcode( - CodeTreeBuilder.singleVariable(bc), - CodeTreeBuilder.singleString(bci), - CodeTreeBuilder.singleVariable(value)); - } - - public static String printCode(Element el) { - StringWriter wr = new StringWriter(); - new AbstractCodeWriter() { - { - writer = wr; - } - - @Override - protected Writer createWriter(CodeTypeElement clazz) throws IOException { - return wr; - } - }.visit(el); - - return wr.toString(); - } - - public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVariables vars, Function body) { - return createInstructionSwitch(data, vars, true, body); - } - - private static final CodeTree BREAK_TREE = CodeTreeBuilder.createBuilder().statement("break").build(); - - public static CodeTree createInstructionSwitch(OperationsData data, ExecutionVariables vars, boolean instrumentation, Function body) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - List trees = new ArrayList<>(); - List> treeInstructions = new ArrayList<>(); - - CodeTree defaultTree = body.apply(null); - boolean hasDefault; - - if (defaultTree == null) { - hasDefault = false; - } else { - hasDefault = true; - trees.add(defaultTree); - treeInstructions.add(null); - } - - outerLoop: for (Instruction instr : data.getInstructions()) { - if (instr.isInstrumentationOnly() && !instrumentation) { - continue; - } - - CodeTree result = body.apply(instr); - if (result == null) { - if (hasDefault) { - // we have to explicitly do nothing for this instruction, since we have default - result = BREAK_TREE; - } else { - continue; - } - } - - for (int i = 0; i < trees.size(); i++) { - if (result.isEqualTo(trees.get(i))) { - treeInstructions.get(i).add(instr); - continue outerLoop; - } - } - - trees.add(result); - - List newList = new ArrayList<>(1); - newList.add(instr); - treeInstructions.add(newList); - - } - - b.startSwitch().tree(OperationGeneratorUtils.extractInstruction(data.getOperationsContext(), createReadOpcode(vars.bc, vars.bci))).end().startBlock(); - for (int i = 0; i < trees.size(); i++) { - if (treeInstructions.get(i) == null) { - b.caseDefault(); - } else { - for (Instruction instr : treeInstructions.get(i)) { - b.startCase().variable(instr.opcodeIdField).end(); - } - } - b.startBlock(); - b.tree(trees.get(i)); - b.end(); - } - b.end(); - - return b.build(); - } - - public static CodeTree callSetResultBoxed(CodeTree bciOffset, FrameKind kind) { - return callSetResultBoxed(bciOffset, toFrameTypeConstant(kind)); - } - - public static CodeTree callSetResultBoxed(CodeTree bciOffset, CodeTree kind) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("doSetResultBoxed"); - b.string("$bc"); - b.string("$bci"); - b.tree(bciOffset); - b.tree(kind); - b.end(2); - - return b.build(); - } - - public static CodeTree toFrameTypeConstant(FrameKind kind) { - return CodeTreeBuilder.singleString(kind.toOrdinal()); - } - - public static void createHelperMethod(CodeTypeElement element, String name, Supplier e) { - if (!element.getEnclosedElements().stream().anyMatch(x -> x.getSimpleName().toString().equals(name))) { - CodeExecutableElement ex = e.get(); - if (!ex.getSimpleName().toString().equals(name)) { - throw new IllegalArgumentException("names do not match"); - } - element.add(ex); - } - } - - public static void checkAccessibility(Element el) { - checkAccessibility(el, ""); - } - - private static void checkAccessibility(Element el, String namePrefix) { - Set mods = el.getModifiers(); - - if (mods.contains(Modifier.PRIVATE) || el.getSimpleName().toString().equals("")) { - return; - } - - if (mods.contains(Modifier.PUBLIC) || mods.contains(Modifier.PROTECTED)) { - List els = el.getEnclosedElements(); - if (els != null) { - for (Element cel : els) { - checkAccessibility(cel, namePrefix + el.getSimpleName() + "."); - } - } - return; - } - - throw new AssertionError(namePrefix + el.getSimpleName() + " must not be package-protected"); - } - - public static CodeTree combineBoxingBits(OperationsContext ctx, CodeTree instr, CodeTree kind) { - if (ctx.hasBoxingElimination()) { - return CodeTreeBuilder.createBuilder().startParantheses().startParantheses().tree(instr).string(" << " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().string( - " | ").tree(kind).end().build(); - } else { - return instr; - } - } - - public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, CodeTree kind) { - return combineBoxingBits(ctx, CodeTreeBuilder.singleVariable(instr.opcodeIdField), kind); - } - - public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, String kind) { - return combineBoxingBits(ctx, instr, CodeTreeBuilder.singleString(kind)); - } - - public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, FrameKind kind) { - return combineBoxingBits(ctx, instr, kind.toOrdinal()); - } - - public static CodeTree combineBoxingBits(OperationsContext ctx, Instruction instr, int kind) { - return combineBoxingBits(ctx, instr, "" + kind); - } - - public static CodeTree extractInstruction(OperationsContext ctx, CodeTree instr) { - if (ctx.hasBoxingElimination()) { - return CodeTreeBuilder.createBuilder().startParantheses().tree(instr).string(" >> " + OperationGeneratorFlags.BOXING_ELIM_BITS).end().string( - " & " + ((1 << (16 - OperationGeneratorFlags.BOXING_ELIM_BITS)) - 1)).build(); - } else { - return instr; - } - } - - public static CodeTree extractInstruction(OperationsContext ctx, String instr) { - return extractInstruction(ctx, CodeTreeBuilder.singleString(instr)); - } - - public static CodeTree extractBoxingBits(OperationsContext ctx, CodeTree instr) { - if (ctx.hasBoxingElimination()) { - return CodeTreeBuilder.createBuilder().tree(instr).string(" & " + ((1 << OperationGeneratorFlags.BOXING_ELIM_BITS) - 1)).build(); - } else { - return CodeTreeBuilder.singleString("0"); - } - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java deleted file mode 100644 index 01b16a659220..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataData.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.model.MessageContainer; -import com.oracle.truffle.dsl.processor.model.Template; - -public class OperationMetadataData extends Template { - - private final OperationsData parent; - - private String name; - private TypeMirror type; - - private final Element template; - - public OperationMetadataData(OperationsData parent, ProcessorContext context, Element template, AnnotationMirror annotation) { - super(context, null, annotation); - this.parent = parent; - this.template = template; - } - - @Override - public MessageContainer getBaseContainer() { - return parent; - } - - @Override - public Element getMessageElement() { - return template; - } - - public TypeMirror getType() { - return type; - } - - public void setType(TypeMirror type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java deleted file mode 100644 index fb92ce394f36..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationMetadataParser.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.Element; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.parser.AbstractParser; - -public class OperationMetadataParser extends AbstractParser { - - private final OperationsData parentData; - - public OperationMetadataParser(OperationsData parentData) { - this.parentData = parentData; - } - - @Override - protected OperationMetadataData parse(Element element, List mirror) { - AnnotationMirror mir = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), getAnnotationType()); - OperationMetadataData data = new OperationMetadataData(parentData, context, element, mir); - - if (!(element instanceof VariableElement)) { - data.addError(element, "@Metadata must be attached to a field"); - return data; - } - - VariableElement varElement = (VariableElement) element; - - if (!varElement.getModifiers().containsAll(Set.of(Modifier.STATIC, Modifier.FINAL))) { - data.addError(element, "@Metadata must be attached to a static final field"); - } - - if (varElement.getModifiers().contains(Modifier.PRIVATE)) { - data.addError(element, "@Metadata field must not be private"); - } - - TypeMirror fieldType = varElement.asType(); - - TypeMirror metadataType = null; - - if (fieldType.getKind() == TypeKind.DECLARED) { - DeclaredType declaredType = (DeclaredType) fieldType; - if (declaredType.asElement().equals(types.MetadataKey.asElement())) { - metadataType = declaredType.getTypeArguments().get(0); - } - } - - if (metadataType == null) { - data.addError(element, "@Metadata field must be of type MetadataKey<>"); - } - - data.setType(metadataType); - - String name = element.getSimpleName().toString(); - if (ElementUtils.getAnnotationValue(mir, "value") != null) { - name = (String) ElementUtils.getAnnotationValue(mir, "value").getValue(); - } - - data.setName(name); - - return data; - } - - @Override - public DeclaredType getAnnotationType() { - return types.GenerateOperations_Metadata; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java deleted file mode 100644 index afc2eab9fde3..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeCodeGenerator.java +++ /dev/null @@ -1,774 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags.USE_SIMPLE_BYTECODE; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; -import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; - -public class OperationsBytecodeCodeGenerator { - - private static final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private static final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); - private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - - static final Object MARKER_CHILD = new Object(); - static final Object MARKER_CONST = new Object(); - - private static final int INSTRUCTIONS_PER_GROUP = 21; - - static final boolean DO_STACK_LOGGING = false; - - final ProcessorContext context = ProcessorContext.getInstance(); - final TruffleTypes types = context.getTypes(); - - private static final String ConditionProfile_Name = "com.oracle.truffle.api.profiles.ConditionProfile"; - final DeclaredType typeConditionProfile = context.getDeclaredType(ConditionProfile_Name); - - private final CodeTypeElement typEnclosingElement; - private final OperationsData m; - private final boolean withInstrumentation; - private final boolean isUncached; - private final CodeTypeElement baseClass; - private final CodeTypeElement opNodeImpl; - private final CodeTypeElement typExceptionHandler; - private final boolean isCommonOnly; - - public OperationsBytecodeCodeGenerator(CodeTypeElement typEnclosingElement, CodeTypeElement baseClass, CodeTypeElement opNodeImpl, CodeTypeElement typExceptionHandler, OperationsData m, - boolean withInstrumentation, boolean isUncached, boolean isCommonOnly) { - this.typEnclosingElement = typEnclosingElement; - this.baseClass = baseClass; - this.opNodeImpl = opNodeImpl; - this.typExceptionHandler = typExceptionHandler; - this.m = m; - this.withInstrumentation = withInstrumentation; - this.isUncached = isUncached; - this.isCommonOnly = isCommonOnly; - } - - /** - * Create the BytecodeNode type. This type contains the bytecode interpreter, and is the - * executable Truffle node. - */ - public CodeTypeElement createBuilderBytecodeNode() { - String namePrefix = withInstrumentation ? "Instrumentable" : isUncached ? "Uncached" : isCommonOnly ? "Common" : ""; - - CodeTypeElement builderBytecodeNodeType = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, namePrefix + "BytecodeNode", baseClass.asType()); - builderBytecodeNodeType.setEnclosingElement(typEnclosingElement); - - builderBytecodeNodeType.setHighPriority(true); - initializeInstructionSimple(builderBytecodeNodeType); - - builderBytecodeNodeType.add(createBytecodeLoop(builderBytecodeNodeType, baseClass)); - - if (m.isGenerateAOT()) { - builderBytecodeNodeType.add(createPrepareAot(baseClass)); - - builderBytecodeNodeType.add(new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "isAdoptable")).getBuilder().statement("return true"); - } - - builderBytecodeNodeType.add(createDumpCode(baseClass)); - - return builderBytecodeNodeType; - } - - private CodeExecutableElement createPrepareAot(CodeTypeElement baseType) { - CodeExecutableElement mPrepareForAot = GeneratorUtils.overrideImplement(baseType, "prepareForAOT"); - - CodeTreeBuilder b = mPrepareForAot.createBuilder(); - - ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars, m); - - b.declaration("int", vars.bci.getName(), "0"); - - b.startWhile().variable(vars.bci).string(" < ").variable(vars.bc).string(".length").end().startBlock(); - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, instr -> { - if (instr == null) { - return null; - } - - CodeTreeBuilder binstr = b.create(); - - binstr.tree(instr.createPrepareAOT(vars, CodeTreeBuilder.singleString("language"), CodeTreeBuilder.singleString("root"))); - binstr.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); - binstr.statement("break"); - - return binstr.build(); - })); - - b.end(); - - return mPrepareForAot; - } - - private CodeExecutableElement createDumpCode(CodeTypeElement baseType) { - CodeExecutableElement mDump = GeneratorUtils.overrideImplement(baseType, "getIntrospectionData"); - - CodeTreeBuilder b = mDump.getBuilder(); - ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars, m); - - CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); - - b.declaration("int", vars.bci.getName(), "0"); - b.declaration("ArrayList", "target", "new ArrayList<>()"); - - b.startWhile().string("$bci < $bc.length").end().startBlock(); // while { - - b.tree(OperationGeneratorUtils.createInstructionSwitch(m, vars, withInstrumentation, op -> { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - - if (op == null) { - builder.declaration("Object[]", "dec", "new Object[]{$bci, \"unknown\", Arrays.copyOfRange($bc, $bci, $bci + 1), null}"); - builder.statement("$bci++"); - } else { - builder.tree(op.createDumpCode(vars)); - builder.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(op.createLength()).end(); - } - - builder.statement("target.add(dec)"); - - builder.statement("break"); - return builder.build(); - })); - - b.end(); // } - - b.declaration("ArrayList", "ehTarget", "new ArrayList<>()"); - - b.startFor().string("int i = 0; i < ").variable(varHandlers).string(".length; i++").end(); - b.startBlock(); - - b.startStatement().startCall("ehTarget.add").startNewArray((ArrayType) context.getType(Object[].class), null); - b.startGroup().variable(varHandlers).string("[i].startBci").end(); - b.startGroup().variable(varHandlers).string("[i].endBci").end(); - b.startGroup().variable(varHandlers).string("[i].handlerBci").end(); - b.end(3); - - b.end(); - - b.declaration("Object[]", "si", "null"); - - // nodes.getSources() is null until we finish parsing everything - b.startIf().string("nodes != null && nodes.getSources() != null && sourceInfo != null").end().startBlock(); // { - - b.declaration("ArrayList", "siTarget", "new ArrayList<>()"); - - b.startFor().string("int i = 0; i < sourceInfo.length; i += 3").end().startBlock(); // { - - b.declaration("int", "startBci", "sourceInfo[i] & 0xffff"); - b.declaration("int", "endBci", "i + 3 == sourceInfo.length ? $bc.length : sourceInfo[i + 3] & 0xffff"); - - b.startIf().string("startBci == endBci").end().startBlock().statement("continue").end(); - - b.declaration("int", "sourceIndex", "sourceInfo[i] >> 16"); - b.declaration("int", "sourceStart", "sourceInfo[i + 1]"); - b.declaration("int", "sourceLength", "sourceInfo[i + 2]"); - - b.startStatement().startCall("siTarget.add").startNewArray((ArrayType) context.getType(Object[].class), null); - b.string("startBci"); - b.string("endBci"); - b.string("sourceIndex < 0 || sourceStart < 0 ? null : nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)"); - b.end(3); - - b.end(); // } - - b.statement("si = siTarget.toArray()"); - - b.end(); // } - - b.startReturn().string("OperationIntrospection.Provider.create(new Object[]{0, target.toArray(), ehTarget.toArray(), si})").end(); - - vars.bci = null; - - return mDump; - } - - static void populateVariables(ExecutionVariables vars, OperationsData m) { - ProcessorContext context = ProcessorContext.getInstance(); - TruffleTypes types = context.getTypes(); - - vars.bc = new CodeVariableElement(context.getType(short[].class), "$bc"); - vars.sp = new CodeVariableElement(context.getType(int.class), "$sp"); - vars.bci = new CodeVariableElement(context.getType(int.class), "$bci"); - vars.stackFrame = new CodeVariableElement(types.VirtualFrame, m.enableYield ? "$stackFrame" : "$frame"); - vars.localFrame = new CodeVariableElement(types.VirtualFrame, m.enableYield ? "$localFrame" : "$frame"); - vars.consts = new CodeVariableElement(context.getType(Object[].class), "$consts"); - vars.children = new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children"); - } - - private CodeExecutableElement createBytecodeLoop(CodeTypeElement bytecodeType, CodeTypeElement baseType) { - CodeExecutableElement mContinueAt = GeneratorUtils.overrideImplement(baseType, "continueAt"); - createExplodeLoop(mContinueAt); - - var ctx = m.getOperationsContext(); - - ExecutionVariables vars = new ExecutionVariables(); - populateVariables(vars, m); - - mContinueAt.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); - - CodeTreeBuilder b = mContinueAt.getBuilder(); - - CodeVariableElement varCurOpcode = new CodeVariableElement(context.getType(short.class), "curOpcode"); - CodeVariableElement varHandlers = new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers"); - - b.declaration("int", vars.sp.getName(), CodeTreeBuilder.singleString("$startSp")); - b.declaration("int", vars.bci.getName(), CodeTreeBuilder.singleString("$startBci")); - if (!isUncached) { - b.declaration("Counter", "loopCounter", "new Counter()"); - } - - // this moves the frame null check out of the loop - b.startStatement().startCall(vars.stackFrame, "getArguments").end(2); - - if (isUncached) { - b.declaration("Counter", "uncachedExecuteCount", "new Counter()"); - b.statement("uncachedExecuteCount.count = $this.uncachedExecuteCount"); - } - - CodeVariableElement varTracer; - - if (m.isTracing()) { - varTracer = new CodeVariableElement(types.ExecutionTracer, "tracer"); - b.startAssign("ExecutionTracer " + varTracer.getName()).startStaticCall(types.ExecutionTracer, "get"); - b.typeLiteral(m.getTemplateType().asType()); - b.end(2); - - b.startStatement().startCall(varTracer, "startFunction").string("$this").end(2); - - b.startTryBlock(); - - } else { - varTracer = null; - } - - b.string("loop: "); - b.startWhile().string("true").end(); - b.startBlock(); - - vars.tracer = varTracer; - - b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); - b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.sp)); - - b.declaration("int", varCurOpcode.getName(), CodeTreeBuilder.createBuilder().tree(OperationGeneratorUtils.createReadOpcode(vars.bc, vars.bci)).string(" & 0xffff").build()); - - if (USE_SIMPLE_BYTECODE) { - b.declaration("Object", "$obj", "$objs[$bci]"); - } - - b.tree(GeneratorUtils.createPartialEvaluationConstant(varCurOpcode)); - - if (varTracer != null) { - b.startIf().string("$this.isBbStart[$bci]").end().startBlock(); - b.startStatement().startCall(varTracer, "traceStartBasicBlock"); - b.variable(vars.bci); - b.end(2); - b.end(); - } - - b.startTryBlock(); - - b.startAssert().variable(vars.sp).string(" >= maxLocals : \"stack underflow @ \" + $bci").end(); - - b.startSwitch(); - b.string("curOpcode"); - b.end(); - b.startBlock(); - - List outerInstructions = new ArrayList<>(); - Map> wrappedInstructions = new HashMap<>(); - - for (Instruction op : m.getInstructions()) { - if (op.isInstrumentationOnly() && !withInstrumentation) { - continue; - } - - if (op.neverInUncached() && isUncached) { - continue; - } - - if (!op.isCommon && isCommonOnly) { - continue; - } - - if (op.isExplicitFlowControl()) { - outerInstructions.add(op); - } else { - wrappedInstructions.computeIfAbsent(op.length(), l -> new ArrayList<>()).add(op); - } - } - - for (Instruction op : outerInstructions) { - generateExecuteCase(ctx, vars, b, varTracer, op, true); - } - - for (Map.Entry> lenGroup : wrappedInstructions.entrySet().stream().sorted((x, y) -> Integer.compare(x.getKey(), y.getKey())).collect(Collectors.toList())) { - int instructionLength = lenGroup.getKey(); - - int doneInstructions = 0; - int numInstructions = lenGroup.getValue().size(); - int numSubgroups = (int) Math.max(1.0, Math.round((double) numInstructions / INSTRUCTIONS_PER_GROUP)); - - for (int subgroup = 0; subgroup < numSubgroups; subgroup++) { - - b.lineCommentf("length group %d (%d / %d)", instructionLength, subgroup + 1, numSubgroups); - - int instrsInGroup = (numInstructions - doneInstructions) / (numSubgroups - subgroup); - List instructionsInGroup = lenGroup.getValue().subList(doneInstructions, doneInstructions + instrsInGroup); - - doneInstructions += instrsInGroup; - - for (Instruction instr : instructionsInGroup) { - generateAllCasesForInstruction(ctx, b, instr); - } - - b.startCaseBlock(); - - String groupMethodName = String.format("instructionGroup_%d_%d%s", instructionLength, subgroup, (isUncached ? "_uncached" : "")); - - OperationGeneratorUtils.createHelperMethod(bytecodeType, groupMethodName, () -> { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(int.class), groupMethodName); - met.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType("com.oracle.truffle.api.HostCompilerDirectives.BytecodeInterpreterSwitch"))); - - met.addParameter(mContinueAt.getParameters().get(0)); // $this - met.addParameter(vars.stackFrame); - if (m.enableYield) { - met.addParameter(vars.localFrame); - } - met.addParameter(vars.bc); - met.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); - if (USE_SIMPLE_BYTECODE) { - met.addParameter(new CodeVariableElement(context.getType(Object[].class), "$objs")); - } else { - met.addParameter(vars.consts); - met.addParameter(vars.children); - } - if (ctx.hasBoxingElimination()) { - met.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); - } - if (!USE_SIMPLE_BYTECODE) { - met.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); - } - met.addParameter(new CodeVariableElement(context.getType(int.class), "curOpcode")); - if (USE_SIMPLE_BYTECODE) { - met.addParameter(new CodeVariableElement(context.getType(Object.class), "$obj")); - } - if (ctx.getData().isTracing()) { - met.addParameter(new CodeVariableElement(types.ExecutionTracer, "tracer")); - } - - CodeTreeBuilder b2 = met.createBuilder(); - - b2.statement("int $bci = $startBci"); - b2.statement("int $sp = $startSp"); - - b2.startSwitch().string("curOpcode").end().startBlock(); - - for (Instruction instr : instructionsInGroup) { - generateExecuteCase(ctx, vars, b2, varTracer, instr, false); - } - - b2.caseDefault().startCaseBlock(); - b2.tree(GeneratorUtils.createShouldNotReachHere()); - b2.end(); - - b2.end(); - - return met; - }); - - b.startAssign(vars.sp).startCall(groupMethodName); - - b.string("$this"); - b.variable(vars.stackFrame); - if (m.enableYield) { - b.variable(vars.localFrame); - } - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - if (USE_SIMPLE_BYTECODE) { - b.string("$objs"); - } else { - b.variable(vars.consts); - b.variable(vars.children); - } - if (ctx.hasBoxingElimination()) { - b.string("$localTags"); - } - if (!USE_SIMPLE_BYTECODE) { - b.string("$conditionProfiles"); - } - b.string("curOpcode"); - if (USE_SIMPLE_BYTECODE) { - b.string("$obj"); - } - if (ctx.getData().isTracing()) { - b.string("tracer"); - } - - b.end(2); // assign, call - - b.startAssign(vars.bci).variable(vars.bci).string(" + " + instructionLength).end(); - - b.statement("continue loop"); - - b.end(); - } - - } - - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - if (isCommonOnly) { - b.statement("$this.changeInterpreters(UNCOMMON_EXECUTE)"); - b.startReturn().string("($sp << 16) | $bci").end(); - } else { - b.tree(GeneratorUtils.createShouldNotReachHere("unknown opcode encountered: \" + curOpcode + \" @ \" + $bci + \"")); - } - b.end(); - - b.end(); // switch block - - b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); - - b.tree(GeneratorUtils.createPartialEvaluationConstant(vars.bci)); - - // if (m.isTracing()) { - // b.startStatement().startCall(fldTracer, "traceException"); - // b.string("ex"); - // b.end(2); - // } - - b.startFor().string("int handlerIndex = " + varHandlers.getName() + ".length - 1; handlerIndex >= 0; handlerIndex--").end(); - b.startBlock(); - - b.tree(GeneratorUtils.createPartialEvaluationConstant("handlerIndex")); - - b.declaration(typExceptionHandler.asType(), "handler", varHandlers.getName() + "[handlerIndex]"); - - b.startIf().string("handler.startBci > $bci || handler.endBci <= $bci").end(); - b.statement("continue"); - - b.startAssign(vars.sp).string("handler.startStack + maxLocals").end(); - // todo: check exception type (?) - - b.startStatement().startCall(vars.stackFrame, "setObject").string("handler.exceptionIndex").string("ex").end(2); - - b.statement("$bci = handler.handlerBci"); - b.statement("continue loop"); - - b.end(); // for (handlerIndex ...) - - b.startThrow().string("ex").end(); - - b.end(); // catch block - - b.end(); // while loop - - if (m.isTracing()) { - b.end().startFinallyBlock(); - - b.startStatement().startCall(varTracer, "endFunction").string("$this").end(2); - - b.end(); - } - - return mContinueAt; - } - - private void generateExecuteCase(OperationsContext ctx, ExecutionVariables vars, CodeTreeBuilder b, CodeVariableElement varTracer, Instruction op, boolean outer) { - for (String line : op.dumpInfo().split("\n")) { - b.lineComment(line); - } - - Consumer createBody = (String name) -> { - if (m.isTracing()) { - b.startStatement().startCall(varTracer, "traceInstruction"); - b.variable(vars.bci); - b.variable(op.opcodeIdField); - b.string(op.isExplicitFlowControl() ? "1" : "0"); - b.string(op.isVariadic() ? "1" : "0"); - b.end(2); - } - - if (isUncached) { - b.tree(op.createExecuteUncachedCode(vars)); - } else { - b.tree(op.createExecuteCode(vars)); - } - - if (outer != op.isExplicitFlowControl()) { - throw new AssertionError(); - } - - if (!op.isExplicitFlowControl()) { - b.statement("return $sp"); - } - - }; - - if (ctx.hasBoxingElimination() && !isUncached) { - if (op.splitOnBoxingElimination()) { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - b.startBlock(); - vars.specializedKind = kind; - createBody.accept("_" + kind); - vars.specializedKind = null; - b.end(); - } - if (op.hasGeneric()) { - b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); - b.startBlock(); - createBody.accept("_GENERIC"); - b.end(); - } - } else if (op.alwaysBoxed()) { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - b.startBlock(); - createBody.accept(""); - b.end(); - } else { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - } - - b.startBlock(); - b.declaration("short", "primitiveTag", "(short) ((curOpcode >> 13) & 0x0007)"); - createBody.accept(""); - b.end(); - } - } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - b.startBlock(); - if (ctx.hasBoxingElimination()) { - vars.specializedKind = FrameKind.OBJECT; - } - createBody.accept(""); - vars.specializedKind = null; - b.end(); - } - } - - private void generateAllCasesForInstruction(OperationsContext ctx, CodeTreeBuilder b, Instruction op) { - if (ctx.hasBoxingElimination() && !isUncached) { - if (op.splitOnBoxingElimination()) { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - } - if (op.hasGeneric()) { - b.startCase().tree(combineBoxingBits(ctx, op, 7)).end(); - } - } else if (op.alwaysBoxed()) { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - } else { - for (FrameKind kind : op.getBoxingEliminationSplits()) { - b.startCase().tree(combineBoxingBits(ctx, op, kind)).end(); - } - } - } else { - b.startCase().tree(combineBoxingBits(ctx, op, 0)).end(); - } - } - - private void createExplodeLoop(CodeExecutableElement mContinueAt) { - CodeAnnotationMirror annExplodeLoop = new CodeAnnotationMirror(types.ExplodeLoop); - mContinueAt.addAnnotationMirror(annExplodeLoop); - annExplodeLoop.setElementValue("kind", new CodeAnnotationValue(new CodeVariableElement( - context.getDeclaredType("com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind"), "MERGE_EXPLODE"))); - } - - private void initializeInstructionSimple(CodeTypeElement builderBytecodeNodeType) { - StaticConstants staticConstants = new StaticConstants(true); - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - continue; - } - - CustomInstruction cinstr = (CustomInstruction) instr; - - final SingleOperationData soData = cinstr.getData(); - - SimpleBytecodeNodeGeneratorPlugs plugs = new SimpleBytecodeNodeGeneratorPlugs(m, cinstr, staticConstants); - cinstr.setPlugs(plugs); - - NodeCodeGenerator generator = new NodeCodeGenerator(); - generator.setPlugs(plugs); - generator.setGeneratorMode(GeneratorMode.OPERATIONS); - - List resultList = generator.create(context, null, soData.getNodeData()); - if (resultList.size() != 1) { - throw new AssertionError("Node generator did not return exactly one class"); - } - - // TODO: don't generate if not needed - - CodeTypeElement result = resultList.get(0); - result.setEnclosingElement(builderBytecodeNodeType); - result.setSuperClass(types.Node); - - Object sn = result.getSimpleName(); - - Optional el = builderBytecodeNodeType.getEnclosedElements().stream().filter(x -> x.getSimpleName().equals(sn)).findAny(); - if (el.isPresent()) { - result = (CodeTypeElement) el.get(); - } else { - processNodeType(soData, result); - - for (TypeElement te : ElementFilter.typesIn(result.getEnclosedElements())) { - CodeTypeElement cte = (CodeTypeElement) te; - String simpleName = cte.getSimpleName().toString(); - - if (simpleName.endsWith("Data")) { - continue; - } - - switch (simpleName) { - case "Uncached": - processNodeType(soData, cte); - break; - default: - throw new AssertionError("unknown nested type: " + simpleName); - } - } - - builderBytecodeNodeType.add(result); - } - - result.getModifiers().add(Modifier.STATIC); - } - - for (CodeVariableElement element : staticConstants.elements()) { - builderBytecodeNodeType.add(element); - } - } - - private void processNodeType(SingleOperationData soData, CodeTypeElement result) { - result.setSuperClass(types.Node); - - for (ExecutableElement ctor : ElementFilter.constructorsIn(result.getEnclosedElements())) { - result.remove(ctor); - } - - for (VariableElement var : ElementFilter.fieldsIn(result.getEnclosedElements())) { - String simpleName = var.getSimpleName().toString(); - if (simpleName.startsWith("$child") || simpleName.equals("$variadicChild_")) { - result.remove(var); - } - } - - for (ExecutableElement ex : ElementFilter.methodsIn(result.getEnclosedElements())) { - String simpleName = ex.getSimpleName().toString(); - - if (simpleName.equals("create") || simpleName.equals("getUncached")) { - result.remove(ex); - continue; - } - - CodeExecutableElement cex = (CodeExecutableElement) ex; - - if (!simpleName.equals("getCost")) { - if (soData.getMainProperties().isVariadic) { - cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$numVariadics")); - } - cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$sp")); - cex.getParameters().add(0, new CodeVariableElement(context.getType(int.class), "$bci")); - if (ElementUtils.findAnnotationMirror(cex, types.CompilerDirectives_TruffleBoundary) == null) { - if (m.enableYield) { - cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$localsFrame")); - cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$stackFrame")); - } else { - cex.getParameters().add(0, new CodeVariableElement(types.VirtualFrame, "$frame")); - } - } - } - } - } - - private static TypeMirror arrayOf(TypeMirror el) { - return new ArrayCodeTypeMirror(el); - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java deleted file mode 100644 index af0d6ef3e14e..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsBytecodeNodeGeneratorPlugs.java +++ /dev/null @@ -1,699 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags.USE_SIMPLE_BYTECODE; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createReadOpcode; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.extractBoxingBits; - -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.generator.BitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; -import com.oracle.truffle.dsl.processor.model.CacheExpression; -import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; -import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction.ExecutionVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; - -public final class OperationsBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { - private final Set innerTypeNames; - private final Set methodNames; - private final CustomInstruction cinstr; - private final StaticConstants staticConstants; - - private final ProcessorContext context; - private final TruffleTypes types; - private List specializationStates; - - private MultiStateBitSet multiState; - private List boxingSplits; - - private OperationsData m; - private final SingleOperationData data; - - private final ExecutionVariables dummyVariables = new ExecutionVariables(); - private NodeData nodeData; - private Predicate useSpecializationClass; - private final boolean uncached; - - { - context = ProcessorContext.getInstance(); - types = context.getTypes(); - } - - OperationsBytecodeNodeGeneratorPlugs(OperationsData m, Set innerTypeNames, Set methodNames, CustomInstruction cinstr, StaticConstants staticConstants, - boolean uncached) { - this.m = m; - OperationsBytecodeCodeGenerator.populateVariables(dummyVariables, m); - this.innerTypeNames = innerTypeNames; - this.methodNames = methodNames; - this.cinstr = cinstr; - this.staticConstants = staticConstants; - - this.data = cinstr.getData(); - - this.uncached = uncached; - } - - public void setUseSpecializationClass(Predicate useSpecializationClass) { - this.useSpecializationClass = useSpecializationClass; - } - - public void setNodeData(NodeData node) { - this.nodeData = node; - for (SpecializationData spec : node.getSpecializations()) { - for (CacheExpression cache : spec.getCaches()) { - createCacheReference(null, spec, cache, cache.getSharedGroup(), false); - } - } - } - - @Override - public void addAdditionalStateBits(List stateObjects) { - } - - @Override - public void setStateObjects(List stateObjects) { - this.specializationStates = stateObjects.stream().filter(x -> x instanceof SpecializationData).collect(Collectors.toUnmodifiableList()); - } - - @Override - public void setBoxingSplits(List boxingSplits) { - this.boxingSplits = boxingSplits; - } - - @Override - public void setMultiState(MultiStateBitSet multiState) { - this.multiState = multiState; - } - - @Override - public int getRequiredStateBits(TypeSystemData typesData, Object object) { - return 1; - } - - @Override - public String transformNodeMethodName(String name) { - if (USE_SIMPLE_BYTECODE) { - return name; - } - String result = cinstr.getUniqueName() + "_" + name + "_"; - methodNames.add(result); - return result; - } - - @Override - public String transformNodeInnerTypeName(String name) { - if (USE_SIMPLE_BYTECODE) { - return name; - } - if (cinstr instanceof QuickenedInstruction) { - return ((QuickenedInstruction) cinstr).getOrig().getUniqueName() + "_" + name; - } - String result = cinstr.getUniqueName() + "_" + name; - innerTypeNames.add(result); - return result; - } - - @Override - public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { - if (!isBoundary) { - if (m.enableYield) { - builder.string("$stackFrame"); - builder.string("$localFrame"); - } else { - builder.string("$frame"); - } - } - - builder.string("$this"); - builder.string("$bc"); - builder.string("$bci"); - builder.string("$sp"); - builder.string("$consts"); - builder.string("$children"); - - if (cinstr.isVariadic()) { - builder.string("$numVariadics"); - } - - for (int i = 0; i < m.getNumTosSlots(); i++) { - builder.string("$tos_" + i); - } - } - - @Override - public Boolean needsFrameToExecute(List specializations) { - return false; - } - - public boolean shouldIncludeValuesInCall() { - return true; - } - - @Override - public int getMaxStateBits(int defaultValue) { - return 16; - } - - @Override - public TypeMirror getBitSetType(TypeMirror defaultType) { - return new CodeTypeMirror(TypeKind.SHORT); - } - - @Override - public CodeTree createBitSetReference(BitSet bits, boolean write) { - return cinstr.createStateBitsIndex(dummyVariables, cinstr.addStateBits(bits), write); - } - - @Override - public CodeTree transformValueBeforePersist(CodeTree tree) { - return CodeTreeBuilder.createBuilder().cast(getBitSetType(null)).startParantheses().tree(tree).end().build(); - } - - private static final String CHILD_OFFSET_NAME = "childArrayOffset_"; - private static final String CONST_OFFSET_NAME = "constArrayOffset_"; - - private CodeTree createArrayReference(FrameState frame, Object refObject, boolean doCast, TypeMirror castTarget, boolean isChild, boolean write) { - if (USE_SIMPLE_BYTECODE) { - throw new AssertionError(); - } - if (refObject == null) { - throw new IllegalArgumentException("refObject is null"); - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - int index; - if (isChild) { - index = cinstr.addChild(refObject); - } else { - index = cinstr.addConstant(refObject, null); - } - - String offsetName = isChild ? CHILD_OFFSET_NAME : CONST_OFFSET_NAME; - - if (doCast) { - b.startParantheses(); - b.cast(castTarget); - } - - VariableElement targetField; - if (isChild) { - targetField = dummyVariables.children; - } else { - targetField = dummyVariables.consts; - } - - if (write) { - b.variable(targetField).string("["); - } else { - b.startCall("UFA", "unsafeObjectArrayRead"); - b.variable(targetField); - } - - b.startGroup(); - - if (frame == null || !frame.getBoolean("definedOffsets", false)) { - if (isChild) { - b.tree(cinstr.createChildIndex(dummyVariables, 0)); - } else { - b.tree(cinstr.createConstantIndex(dummyVariables, 0)); - } - } else if (frame.getBoolean("has_" + offsetName, false)) { - b.string(offsetName); - } else { - frame.setBoolean("has_" + offsetName, true); - b.string("(" + offsetName + " = "); - if (isChild) { - b.tree(cinstr.createChildIndex(dummyVariables, 0)); - } else { - b.tree(cinstr.createConstantIndex(dummyVariables, 0)); - } - b.string(")"); - - } - - b.string(" + " + index).end(); // group - if (write) { - b.string("]"); - } else { - b.end(); // call - } - - if (doCast) { - b.end(); - } - - return b.build(); - } - - @Override - public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original) { - // todo: maybe this would be needed at some point? - return new ReportPolymorphismAction(false, false); - } - - // @Override - public CodeTree createSpecializationFieldReference(FrameState frame, SpecializationData s, String fieldName, TypeMirror fieldType, boolean write) { - if (USE_SIMPLE_BYTECODE) { - return CodeTreeBuilder.singleString("this." + fieldName); - } - boolean specClass = useSpecializationClass.test(s); - Object refObject = specClass ? s : fieldName; - boolean isChild = specClass ? specializationClassIsNode(s) : ElementUtils.isAssignable(fieldType, types.Node); - return createArrayReference(frame, refObject, !write, fieldType, isChild, write); - } - - /* Specialization class needs to be a Node in such a case. */ - private boolean specializationClassIsNode(SpecializationData specialization) { - for (CacheExpression cache : specialization.getCaches()) { - TypeMirror type = cache.getParameter().getType(); - if (isAssignable(type, types.NodeInterface)) { - return true; - } else if (isNodeInterfaceArray(type)) { - return true; - } - } - return false; - } - - private boolean isNodeInterfaceArray(TypeMirror type) { - if (type == null) { - return false; - } - return type.getKind() == TypeKind.ARRAY && isAssignable(((ArrayType) type).getComponentType(), types.NodeInterface); - } - - @Override - public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead) { - if (nodeFieldName.startsWith("$child")) { - return CodeTreeBuilder.singleString("__INVALID__"); - } - if (USE_SIMPLE_BYTECODE) { - return CodeTreeBuilder.singleString("this." + nodeFieldName); - } - return createArrayReference(frame, execution, forRead, execution.getNodeType(), true, !forRead); - } - - @Override - public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { - if (USE_SIMPLE_BYTECODE) { - return CodeTreeBuilder.singleString("this." + sharedName); - } - Object refObject = null; - TypeMirror mir = null; - String fieldName = null; - boolean innerForRead = forRead; - CodeTree base = null; - boolean isChild; - - if (sharedName != null) { - refObject = sharedName; - mir = cache.getParameter().getType(); - isChild = ElementUtils.isAssignable(mir, types.Node); - } else if (cache.getSharedGroup() != null) { - refObject = cache.getSharedGroup(); - mir = cache.getParameter().getType(); - isChild = ElementUtils.isAssignable(mir, types.Node); - } else if (useSpecializationClass.test(specialization)) { - LocalVariable specLocal = frame != null - ? frame.get(FlatNodeGenFactory.createSpecializationLocalName(specialization)) - : null; - fieldName = cache.getParameter().getLocalName() + "_"; - isChild = true; - if (specLocal != null) { - base = specLocal.createReference(); - } else { - refObject = specialization; - mir = new GeneratedTypeMirror("", cinstr.getUniqueName() + "_" + specialization.getId() + "Data"); - innerForRead = true; - } - } else { - refObject = cache; - mir = cache.getParameter().getType(); - isChild = ElementUtils.isAssignable(mir, types.Node); - } - - if (base == null) { - base = createArrayReference(frame, refObject, innerForRead, mir, isChild, !forRead); - } - - if (fieldName == null) { - return base; - } else { - return CodeTreeBuilder.createBuilder().tree(base).string("." + fieldName).build(); - } - } - - public int getStackOffset(LocalVariable value) { - String name = value.getName(); - while (name.endsWith("_")) { - name = name.substring(0, name.length() - 1); - } - if (name.startsWith("arg") && name.endsWith("Value")) { - return cinstr.numPopStatic() - Integer.parseInt(name.substring(3, name.length() - 5)); - } - if (name.startsWith("child") && name.endsWith("Value")) { - return cinstr.numPopStatic() - Integer.parseInt(name.substring(5, name.length() - 5)); - } - throw new UnsupportedOperationException("" + value); - } - - @Override - public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { - return CodeTreeBuilder.singleString("null"); - } - - @Override - public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { - return values.toArray(new CodeTree[values.size()]); - } - - @Override - public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { - // todo: should we have the outer (local) frame as the "frame" ? probably - frameState.set("frameValue", new LocalVariable(types.VirtualFrame, m.enableYield ? "$localFrame" : "$frame", null)); - builder.declaration("int", CHILD_OFFSET_NAME, (CodeTree) null); - builder.declaration("int", CONST_OFFSET_NAME, (CodeTree) null); - frameState.setBoolean("definedOffsets", true); - } - - private int ensCall = 0; - - @Override - public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { - String easName = transformNodeMethodName("executeAndSpecialize"); - if (cinstr instanceof QuickenedInstruction) { - QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; - - // unquicken call parent EAS - builder.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), qinstr.getOrig(), 0))); - easName = qinstr.getOrig().getUniqueName() + "_executeAndSpecialize_"; - } - - if (OperationGeneratorFlags.LOG_EXECUTE_AND_SPECIALIZE_CALLS) { - builder.statement("System.out.printf(\" [!!] calling E&S @ %04x : " + cinstr.name + " " + (ensCall++) + " \", $bci)"); - builder.startStatement().startCall("System.out.println").startCall("java.util.Arrays.asList"); - frameState.addReferencesTo(builder); - builder.end(3); - } - - return false; - } - - private FrameKind getFrameType(TypeKind type) { - if (!m.getBoxingEliminatedTypes().contains(type)) { - return FrameKind.OBJECT; - } - - return OperationsData.convertToFrameType(type); - } - - @Override - public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { - if (execution.getName().startsWith("$localRefArray")) { - return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REFS, true, types.LocalSetterRange, false, false); - } - - if (execution.getName().startsWith("$localRef")) { - return createArrayReference(frameState, CustomInstruction.MARKER_LOCAL_REF_PREFIX + execution.getName().substring(9), true, types.LocalSetter, false, false); - } - - if (execution.getName().startsWith("$immediate")) { - int index = Integer.parseInt(execution.getName().substring(10)); - return createArrayReference(frameState, CustomInstruction.MARKER_IMMEDIATEE_PREFIX + index, true, data.getMainProperties().immediateTypes.get(index), false, false); - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (execution.getName().equals("$variadicChild")) { - b.startCall("do_loadVariadicArguments"); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp"); - b.string("$numVariadics"); - b.end(); - return b.build(); - } - - int childIndex = execution.getIndex(); - int offset = cinstr.numPopStatic() - childIndex; - - FrameKind resultKind = getFrameType(method.getReturnType().getKind()); - - b.startCall("expect" + resultKind.getFrameName()); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - if (cinstr.isVariadic()) { - b.string("$sp - " + offset + " - $numVariadics"); - } else { - b.string("$sp - " + offset); - } - if (m.getOperationsContext().hasBoxingElimination()) { - b.string("$bc"); - b.string("$bci"); - b.tree(cinstr.createPopIndexedIndex(dummyVariables, childIndex, false)); - } - b.end(); - - return b.build(); - } - - @Override - public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder b) { - - if (OperationGeneratorFlags.LOG_EXECUTE_AND_SPECIALIZE_CALLS) { - b.statement("System.out.println(\" [!!] finished E&S - " + specialization.getId() + " \")"); - } - - // quickening - if (!(cinstr instanceof QuickenedInstruction)) { - List quickened = cinstr.getQuickenedVariants(); - - if (!quickened.isEmpty()) { - - b.startAssign("short primitiveTagBits").string("(short) (").tree( - extractBoxingBits(m.getOperationsContext(), createReadOpcode(dummyVariables.bc, dummyVariables.bci))).string(" & 0xe000)").end(); - - // only quicken/unquicken for instructions that have quickened versions - boolean elseIf = false; - for (QuickenedInstruction qinstr : quickened) { - if (qinstr.getActiveSpecs().contains(specialization)) { - elseIf = b.startIf(elseIf); - b.tree(multiState.createIs(frameState, qinstr.getActiveSpecs().toArray(), specializationStates.toArray())); - b.end().startBlock(); - // { - b.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), qinstr, "primitiveTagBits"))); - // } - b.end(); - } - } - - if (elseIf) { - b.startElseBlock(); - } - - // quicken to generic - b.tree(createWriteOpcode(dummyVariables.bc, dummyVariables.bci, combineBoxingBits(m.getOperationsContext(), cinstr, "primitiveTagBits"))); - - if (elseIf) { - b.end(); - } - } - } - } - - @SuppressWarnings("unchecked") - public CodeTree createGetSpecializationBits() { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - FrameState frame = FrameState.createEmpty(); - - b.tree(multiState.createLoad(frame, specializationStates.toArray())); - - b.declaration("boolean[]", "result", "new boolean[" + specializationStates.size() + "]"); - - for (int i = 0; i < specializationStates.size(); i++) { - SpecializationData specData = (SpecializationData) specializationStates.get(i); - b.startAssign("result[" + i + "]"); - b.tree(multiState.createContains(frame, new Object[]{specData})); - Set excludedBy = specData.getExcludedBy(); - - if (!excludedBy.isEmpty()) { - b.string(" && "); - b.tree(multiState.createNotContains(frame, excludedBy.toArray())); - } - - b.end(); - } - - b.startReturn().string("result").end(); - - return b.build(); - } - - public boolean needsRewrites() { - return true; - } - - @Override - public List filterSpecializations(List implementedSpecializations) { - if (!(cinstr instanceof QuickenedInstruction)) { - return implementedSpecializations; - } - - QuickenedInstruction qinstr = (QuickenedInstruction) cinstr; - return qinstr.getActiveSpecs(); - } - - @Override - public boolean isStateGuaranteed(boolean stateGuaranteed) { - if (stateGuaranteed) { - return true; - } - - if (cinstr instanceof QuickenedInstruction && ((QuickenedInstruction) cinstr).getActiveSpecs().size() == 1) { - return true; - } - - return false; - } - - public void finishUp() { - } - - public StaticConstants createConstants() { - return staticConstants; - } - - @Override - public CodeTree createGetLock() { - return CodeTreeBuilder.singleString("$this.getLockAccessor()"); - } - - @Override - public CodeTree createSuperInsert(CodeTree value) { - return CodeTreeBuilder.createBuilder().startCall("$this.insertAccessor").tree(value).end().build(); - } - - @Override - public String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type) { - String name = "result_expect" + ElementUtils.getTypeId(ElementUtils.boxType(type)); - OperationGeneratorUtils.createHelperMethod(m.getOperationsContext().outerType, name, () -> { - CodeExecutableElement el = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), type, name); - - el.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); - el.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); - el.addThrownType(types.UnexpectedResultException); - - CodeTreeBuilder b = el.createBuilder(); - - b.startIf().string("value").instanceOf(ElementUtils.boxType(type)).end().startBlock(); - b.startReturn().cast(type).string("value").end(); - b.end().startElseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startThrow().startNew(types.UnexpectedResultException).string("value").end(2); - b.end(); - - return el; - }); - - return name; - } - - public CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (codeTrees.length > 1) { - throw new AssertionError(Arrays.toString(codeTrees)); - } - - b.startCall(transformNodeMethodName(executableElement.getSimpleName().toString())); - addNodeCallParameters(b, false, false); - b.end(); - - return b.build(); - } - - public String createExecuteAndSpecializeName(String result) { - CustomInstruction instr = cinstr; - if (cinstr instanceof QuickenedInstruction) { - instr = ((QuickenedInstruction) cinstr).getOrig(); - } - - return instr.getUniqueName() + "_executeAndSpecialize_"; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java deleted file mode 100644 index 02b9a4f41096..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsCodeGenerator.java +++ /dev/null @@ -1,2904 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags.USE_SIMPLE_BYTECODE; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOError; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.concurrent.locks.Lock; - -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; - -import com.oracle.truffle.dsl.processor.AnnotationProcessor; -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.CodeTypeElementFactory; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeNames; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; - -public class OperationsCodeGenerator extends CodeTypeElementFactory { - - private ProcessorContext context; - private OperationsData m; - - private static final Set MOD_FINAL = Set.of(Modifier.FINAL); - private static final Set MOD_PUBLIC = Set.of(Modifier.PUBLIC); - private static final Set MOD_PUBLIC_ABSTRACT = Set.of(Modifier.PUBLIC, Modifier.ABSTRACT); - private static final Set MOD_PUBLIC_FINAL = Set.of(Modifier.PUBLIC, Modifier.FINAL); - private static final Set MOD_PUBLIC_STATIC = Set.of(Modifier.PUBLIC, Modifier.STATIC); - private static final Set MOD_PRIVATE = Set.of(Modifier.PRIVATE); - private static final Set MOD_ABSTRACT = Set.of(Modifier.ABSTRACT); - private static final Set MOD_PRIVATE_FINAL = Set.of(Modifier.PRIVATE, Modifier.FINAL); - private static final Set MOD_PRIVATE_STATIC = Set.of(Modifier.PRIVATE, Modifier.STATIC); - private static final Set MOD_PRIVATE_STATIC_ABSTRACT = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.ABSTRACT); - private static final Set MOD_PRIVATE_STATIC_FINAL = Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL); - private static final Set MOD_PROTECTED = Set.of(Modifier.PROTECTED); - private static final Set MOD_PROTECTED_STATIC = Set.of(Modifier.PROTECTED, Modifier.STATIC); - private static final Set MOD_STATIC = Set.of(Modifier.STATIC); - - private OperationsBytecodeCodeGenerator bytecodeGenerator; - - private static final String OPERATION_NODES_IMPL_NAME = "OperationNodesImpl"; - private static final String OPERATION_BUILDER_IMPL_NAME = "Builder"; - private static final String BYTECODE_BASE_NAME = "BytecodeLoopBase"; - - private static final int SER_CODE_CREATE_LABEL = -2; - private static final int SER_CODE_CREATE_LOCAL = -3; - private static final int SER_CODE_CREATE_OBJECT = -4; - private static final int SER_CODE_END = -5; - private static final int SER_CODE_METADATA = -6; - - private static final Class DATA_INPUT_CLASS = ByteBuffer.class; - private static final Class DATA_INPUT_WRAP_CLASS = DataInput.class; - private static final Class DATA_OUTPUT_CLASS = DataOutput.class; - - private static final String DATA_READ_METHOD_PREFIX = "get"; - private static final String DATA_WRITE_METHOD_PREFIX = "write"; - - private static final TypeMirror TYPE_UNSAFE = new GeneratedTypeMirror("sun.misc", "Unsafe"); - - CodeTypeElement createOperationNodes() { - CodeTypeElement typOperationNodes = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, OPERATION_NODES_IMPL_NAME, - generic(types.OperationNodes, m.getTemplateType().asType())); - typOperationNodes.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationNodes)); - - typOperationNodes.add(createOperationNodedsReparse()); - - CodeExecutableElement mSetSources = new CodeExecutableElement(context.getType(void.class), "setSources"); - mSetSources.addParameter(new CodeVariableElement(arrayOf(types.Source), "sources")); - mSetSources.createBuilder().statement("this.sources = sources"); - typOperationNodes.add(mSetSources); - - CodeExecutableElement mGetSources = new CodeExecutableElement(arrayOf(types.Source), "getSources"); - mGetSources.createBuilder().statement("return sources"); - typOperationNodes.add(mGetSources); - - CodeExecutableElement mSetNodes = new CodeExecutableElement(context.getType(void.class), "setNodes"); - mSetNodes.addParameter(new CodeVariableElement(arrayOf(m.getTemplateType().asType()), "nodes")); - mSetNodes.createBuilder().statement("this.nodes = nodes"); - typOperationNodes.add(mSetNodes); - - for (String name : new String[]{"ensureSources", "ensureInstrumentation"}) { - CodeExecutableElement m = CodeExecutableElement.clone(ElementUtils.findExecutableElement(types.OperationNodes, name)); - m.setSimpleName(CodeNames.of(name + "Accessor")); - m.createBuilder().startStatement().startCall(name).variables(m.getParameters()).end(2); - typOperationNodes.add(m); - } - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typOperationNodes.add(createOperationNodesSerialize()); - } - - return typOperationNodes; - } - - private CodeExecutableElement createOperationNodedsReparse() { - CodeExecutableElement metReparse = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); - - CodeTreeBuilder b = metReparse.createBuilder(); - - b.statement(OPERATION_BUILDER_IMPL_NAME + " builder = new " + OPERATION_BUILDER_IMPL_NAME + "(this, true, config)"); - b.statement("((OperationParser) parse).parse(builder)"); - b.statement("builder.finish()"); - return metReparse; - } - - private CodeExecutableElement createOperationNodesSerialize() { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationNodes, "serialize"); - - CodeTreeBuilder b = met.createBuilder(); - - b.statement(OPERATION_BUILDER_IMPL_NAME + " builder = new " + OPERATION_BUILDER_IMPL_NAME + "(null, false, config)"); - b.statement("builder.isSerializing = true"); - b.statement("builder.serBuffer = buffer"); - b.statement("builder.serCallback = callback"); - - unwrapIOError(b, () -> { - b.statement("((OperationParser) parse).parse(builder)"); - }); - - b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_END + ")"); - - return met; - } - - private CodeExecutableElement createDeserializeMethod() { - CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); - CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "input"); - CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer"), "callback"); - CodeExecutableElement met = new CodeExecutableElement(MOD_PUBLIC_STATIC, generic(types.OperationNodes, m.getTemplateType().asType()), "deserialize", parLanguage, parConfig, parBuffer, - parCallback); - - met.addThrownType(context.getType(IOException.class)); - - CodeTreeBuilder b = met.createBuilder(); - - b.startTryBlock(); - - b.startReturn().startCall("create"); - b.variable(parConfig); - b.string("b -> " + OPERATION_BUILDER_IMPL_NAME + ".deserializeParser(language, input, callback, b)"); - b.end(2); - - b.end().startCatchBlock(context.getType(IOError.class), "ex"); - - b.startThrow().string("(IOException) ex.getCause()").end(); - - b.end(); - - return met; - } - - private void unwrapIOError(CodeTreeBuilder b, Runnable inner) { - b.startTryBlock(); - inner.run(); - b.end().startCatchBlock(context.getType(IOError.class), "ex"); - b.startThrow().string("(IOException) ex.getCause()").end(); - b.end(); - } - - private CodeExecutableElement createSerializeMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { - CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parBuffer = new CodeVariableElement(context.getType(DATA_OUTPUT_CLASS), "buffer"); - CodeVariableElement parCallback = new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer"), "callback"); - CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); - CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, context.getType(void.class), "serialize"); - metCreate.addParameter(parConfig); - metCreate.addParameter(parBuffer); - metCreate.addParameter(parCallback); - metCreate.addParameter(parParser); - metCreate.addThrownType(context.getType(IOException.class)); - - CodeTreeBuilder b = metCreate.getBuilder(); - - b.startAssign(OPERATION_BUILDER_IMPL_NAME + " builder").startNew(typBuilderImpl.asType()); - // ( - b.string("null"); - b.string("false"); // isReparse - b.variable(parConfig); - // ) - b.end(2); - - b.statement("builder.isSerializing = true"); - b.statement("builder.serBuffer = buffer"); - b.statement("builder.serCallback = callback"); - - unwrapIOError(b, () -> { - b.startStatement().startCall("generator", "parse"); - b.string("builder"); - b.end(2); - }); - - b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_END + ")"); - - return metCreate; - } - - private CodeExecutableElement createCreateMethod(CodeTypeElement typBuilder, CodeTypeElement typBuilderImpl) { - CodeVariableElement parConfig = new CodeVariableElement(types.OperationConfig, "config"); - CodeVariableElement parParser = new CodeVariableElement(operationParser(typBuilder.asType()), "generator"); - CodeExecutableElement metCreate = new CodeExecutableElement(MOD_PUBLIC_STATIC, generic(types.OperationNodes, m.getTemplateType().asType()), "create"); - metCreate.addParameter(parConfig); - metCreate.addParameter(parParser); - - CodeTreeBuilder b = metCreate.getBuilder(); - - b.declaration("OperationNodesImpl", "nodes", "new OperationNodesImpl(generator)"); - b.startAssign(OPERATION_BUILDER_IMPL_NAME + " builder").startNew(typBuilderImpl.asType()); - // ( - b.string("nodes"); - b.string("false"); // isReparse - b.variable(parConfig); - // ) - b.end(2); - - b.startStatement().startCall("generator", "parse"); - b.string("builder"); - b.end(2); - - b.startStatement().startCall("builder", "finish").end(2); - - b.startReturn().string("nodes").end(); - - return metCreate; - } - - private static CodeVariableElement compFinal(CodeVariableElement el) { - if (el.getType().getKind() == TypeKind.ARRAY) { - GeneratorUtils.addCompilationFinalAnnotation(el, 1); - } else { - GeneratorUtils.addCompilationFinalAnnotation(el); - } - return el; - } - - private static CodeVariableElement children(CodeVariableElement el) { - el.addAnnotationMirror(new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().Node_Children)); - return el; - } - - private CodeTypeElement createOperationSerNodeImpl() { - CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerNodeImpl", m.getTemplateType().asType()); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(context.getType(int.class), "buildOrder"))); - typOperationNodeImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, typOperationNodeImpl, m.fdConstructor)); - - for (String methodName : new String[]{"execute", "getSourceSectionAtBci", "materializeInstrumentTree"}) { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, methodName); - met.createBuilder().startThrow().startNew(context.getType(UnsupportedOperationException.class)).end(2); - typOperationNodeImpl.add(met); - } - - return typOperationNodeImpl; - } - - private CodeVariableElement createSerializationContext() { - DeclaredType typeContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext"); - CodeVariableElement fld = new CodeVariableElement(MOD_PRIVATE, typeContext, "SER_CONTEXT"); - CodeTreeBuilder b = fld.createInitBuilder(); - - b.startNew(typeContext).end().string(" ").startBlock(); - - b.string("@Override").newLine(); - b.string("public void serializeOperationNode(" + DATA_OUTPUT_CLASS.getSimpleName() + " buffer, OperationRootNode node) throws IOException ").startBlock(); - - b.statement("buffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationSerNodeImpl) node).buildOrder)"); - - b.end(); - - b.end(); - - return fld; - } - - CodeTypeElement createOperationNodeImpl() { - GeneratedTypeMirror typOperationNodes = new GeneratedTypeMirror("", OPERATION_NODES_IMPL_NAME); - - String simpleName = m.getTemplateType().getSimpleName().toString() + "Gen"; - CodeTypeElement typOperationNodeImpl = GeneratorUtils.createClass(m, null, MOD_PUBLIC_FINAL, simpleName, m.getTemplateType().asType()); - GeneratorUtils.addSuppressWarnings(context, typOperationNodeImpl, "unused", "cast", "unchecked", "hiding", "rawtypes", "static-method"); - - m.getOperationsContext().outerType = typOperationNodeImpl; - - typOperationNodeImpl.getImplements().add(types.BytecodeOSRNode); - - CodeTypeElement typExceptionHandler = typOperationNodeImpl.add(createExceptionHandler()); - - CodeTypeElement typBytecodeBase = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_ABSTRACT, BYTECODE_BASE_NAME, null); - typOperationNodeImpl.add(createBytecodeBaseClass(typBytecodeBase, typOperationNodeImpl, typOperationNodes, typExceptionHandler)); - - CodeExecutableElement genCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), m.fdConstructor)); - genCtor.setSimpleName(CodeNames.of(simpleName)); - genCtor.getModifiers().clear(); - genCtor.getModifiers().add(Modifier.PRIVATE); - - if (m.fdBuilderConstructor == null) { - CodeExecutableElement genBuilderCtor = typOperationNodeImpl.add(new CodeExecutableElement(MOD_PRIVATE, null, simpleName)); - genBuilderCtor.addParameter(genCtor.getParameters().get(0)); - genBuilderCtor.addParameter(new CodeVariableElement(types.FrameDescriptor_Builder, "builder")); - genBuilderCtor.renameArguments("language", "builder"); - - CodeTreeBuilder b = genBuilderCtor.createBuilder(); - b.startStatement().startCall("this").string("language").string("builder.build()").end(2); - } else { - CodeExecutableElement genBuilderCtor = typOperationNodeImpl.add(GeneratorUtils.createSuperConstructor(m.getTemplateType(), m.fdBuilderConstructor)); - genBuilderCtor.setSimpleName(CodeNames.of(simpleName)); - genBuilderCtor.getModifiers().clear(); - genBuilderCtor.getModifiers().add(Modifier.PRIVATE); - } - - boolean doHookTti = ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements()).stream().anyMatch(x -> x.getSimpleName().toString().equals("__magic_LogInvalidations")); - - if (doHookTti) { - GeneratorUtils.setHookTransferToInterpreter(true); - typOperationNodeImpl.add(createHookTransferToInterpreterAndInvalidate()); - } - - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getDeclaredType("com.oracle.truffle.api.impl.UnsafeFrameAccess"), "UFA = UnsafeFrameAccess.lookup()")); - - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, typOperationNodes, "nodes"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "_bc"))); - if (USE_SIMPLE_BYTECODE) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_objs"))); - } else { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object[].class), "_consts"))); - typOperationNodeImpl.add(children(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.Node), "_children"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "_conditionProfiles"))); - } - if (m.getOperationsContext().hasBoxingElimination()) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(byte[].class), "_localTags"))); - } - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(typExceptionHandler.asType()), "_handlers"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxLocals"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "_maxStack"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "sourceInfo"))); - - if (m.enableYield) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationRoot")), "yieldEntries"))); - } - - if (m.isTracing()) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart"))); - } - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, types.InstrumentRootNode, "instrumentRoot"))); - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, arrayOf(types.InstrumentTreeNode), "instruments"))); - } - - CodeVariableElement fldSwitchImpl = new CodeVariableElement(MOD_PRIVATE, typBytecodeBase.asType(), "switchImpl"); - GeneratorUtils.addCompilationFinalAnnotation(fldSwitchImpl); - fldSwitchImpl.createInitBuilder().string("INITIAL_EXECUTE"); - typOperationNodeImpl.add(fldSwitchImpl); - - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "uncachedExecuteCount = 16"))); - - typOperationNodeImpl.add(compFinal(new CodeVariableElement(MOD_PRIVATE, context.getType(Object.class), "_osrMetadata"))); - - if (!m.getMetadatas().isEmpty()) { - CodeExecutableElement staticInit = new CodeExecutableElement(MOD_STATIC, null, ""); - typOperationNodeImpl.add(staticInit); - - CodeTreeBuilder initBuilder = staticInit.createBuilder(); - - for (OperationMetadataData metadata : m.getMetadatas()) { - String fieldName = "_metadata_" + metadata.getName(); - CodeVariableElement fldMetadata = new CodeVariableElement(MOD_PRIVATE, metadata.getType(), fieldName); - - typOperationNodeImpl.add(fldMetadata); - - initBuilder.startStatement().startCall("OperationRootNode.setMetadataAccessor"); - initBuilder.staticReference((VariableElement) metadata.getMessageElement()); - initBuilder.startGroup(); - // ( - initBuilder.string("n -> "); - initBuilder.startParantheses().cast(typOperationNodeImpl.asType()).string("n").end().string("." + fieldName); - // ) - initBuilder.end(); - initBuilder.end(2); - } - } - - String initialExecute = "UNCOMMON_EXECUTE"; - - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCOMMON_EXECUTE = new BytecodeNode()")); - - if (OperationGeneratorFlags.CREATE_COMMON_EXECUTE && m.isOptimized()) { - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = new CommonBytecodeNode()")); - initialExecute = "COMMON_EXECUTE"; - } else { - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "COMMON_EXECUTE = UNCOMMON_EXECUTE")); - } - - if (m.isGenerateUncached()) { - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "UNCACHED_EXECUTE = new UncachedBytecodeNode()")); - initialExecute = "UNCACHED_EXECUTE"; - } - - typOperationNodeImpl.add(new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, typBytecodeBase.asType(), "INITIAL_EXECUTE = " + initialExecute)); - - typOperationNodeImpl.add(createNodeImplExecuteAt()); - typOperationNodeImpl.add(createNodeImplGetSourceSection()); - typOperationNodeImpl.add(createNodeImplGetSourceSectionAtBci()); - typOperationNodeImpl.add(createSneakyThrow()); - - CodeExecutableElement mExecute = createNodeExecute(); - typOperationNodeImpl.add(mExecute); - - CodeExecutableElement mDump = GeneratorUtils.overrideImplement(types.OperationIntrospection_Provider, "getIntrospectionData"); - typOperationNodeImpl.add(mDump); - mDump.createBuilder().startReturn().startCall("switchImpl.getIntrospectionData").string("_bc, _handlers, _consts, nodes, sourceInfo").end(2); - - CodeExecutableElement mGetLockAccessor = new CodeExecutableElement(MOD_PRIVATE, context.getType(Lock.class), "getLockAccessor"); - typOperationNodeImpl.add(mGetLockAccessor); - mGetLockAccessor.createBuilder().startReturn().startCall("getLock").end(2); - - CodeExecutableElement mInsertAccessor = new CodeExecutableElement(MOD_PRIVATE, null, " T insertAccessor(T node) { // "); - typOperationNodeImpl.add(mInsertAccessor); - mInsertAccessor.createBuilder().startReturn().startCall("insert").string("node").end(2); - - CodeExecutableElement mExecuteOSR = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "executeOSR"); - typOperationNodeImpl.add(mExecuteOSR); - if (m.enableYield) { - mExecuteOSR.createBuilder().startReturn().startCall("executeAt").string("osrFrame, (VirtualFrame) interpreterState, target").end(2); - } else { - mExecuteOSR.createBuilder().startReturn().startCall("executeAt").string("osrFrame, target").end(2); - } - - CodeExecutableElement mGetOSRMetadata = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "getOSRMetadata"); - typOperationNodeImpl.add(mGetOSRMetadata); - mGetOSRMetadata.createBuilder().startReturn().string("_osrMetadata").end(); - - CodeExecutableElement mSetOSRMetadata = GeneratorUtils.overrideImplement(types.BytecodeOSRNode, "setOSRMetadata"); - typOperationNodeImpl.add(mSetOSRMetadata); - mSetOSRMetadata.createBuilder().startAssign("_osrMetadata").string("osrMetadata").end(); - - typOperationNodeImpl.add(createNodeImplDeepCopy(typOperationNodeImpl)); - typOperationNodeImpl.add(createNodeImplCopy(typOperationNodeImpl)); - CodeTypeElement typOpNodesImpl = createOperationNodes(); - typOperationNodeImpl.add(typOpNodesImpl); - - CodeTypeElement builderBytecodeNodeType; - CodeTypeElement builderCommonBytecodeNodeType; - CodeTypeElement builderUncachedBytecodeNodeType; - CodeTypeElement builderInstrBytecodeNodeType; - - bytecodeGenerator = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, false); - builderBytecodeNodeType = bytecodeGenerator.createBuilderBytecodeNode(); - typOperationNodeImpl.add(builderBytecodeNodeType); - - if (m.isGenerateUncached()) { - builderUncachedBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, - true, false).createBuilderBytecodeNode(); - typOperationNodeImpl.add(builderUncachedBytecodeNodeType); - } else { - builderUncachedBytecodeNodeType = null; - } - - if (OperationGeneratorFlags.CREATE_COMMON_EXECUTE && m.isOptimized()) { - builderCommonBytecodeNodeType = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, false, false, - true).createBuilderBytecodeNode(); - typOperationNodeImpl.add(builderCommonBytecodeNodeType); - } else { - builderCommonBytecodeNodeType = null; - } - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - OperationsBytecodeCodeGenerator bcg = new OperationsBytecodeCodeGenerator(typOperationNodeImpl, typBytecodeBase, typOperationNodeImpl, typExceptionHandler, m, true, false, false); - builderInstrBytecodeNodeType = bcg.createBuilderBytecodeNode(); - typOperationNodeImpl.add(builderInstrBytecodeNodeType); - } else { - builderInstrBytecodeNodeType = null; - } - - typOperationNodeImpl.add(createMaterializeInstrumentTree()); - - CodeTypeElement typBuilderImpl = createBuilderImpl(typOperationNodeImpl, typOpNodesImpl, typExceptionHandler); - typOperationNodeImpl.add(typBuilderImpl); - typOperationNodeImpl.add(createChangeInterpreter(typBytecodeBase)); - - // instruction IDsx - for (Instruction instr : m.getOperationsContext().instructions) { - typOperationNodeImpl.addAll(instr.createInstructionFields()); - } - - typOperationNodeImpl.add(createSetResultUnboxed()); - typOperationNodeImpl.add(createLoadVariadicArguments()); - typOperationNodeImpl.add(createSetResultBoxedImpl()); - typOperationNodeImpl.add(createCounter()); - if (m.enableYield) { - typOperationNodeImpl.add(createContinuationLocationImpl(typOperationNodeImpl)); - typOperationNodeImpl.add(createContinuationRoot(typOperationNodeImpl)); - } - typOperationNodeImpl.add(createUnsafeFromBytecode()); - typOperationNodeImpl.add(createUnsafeWriteBytecode()); - typOperationNodeImpl.add(createConditionProfile()); - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - typOperationNodeImpl.add(createGetTreeProbeNode(typOperationNodeImpl.asType())); - } - - typOperationNodeImpl.add(createCreateMethod(typBuilderImpl, typBuilderImpl)); - typOperationNodeImpl.add(createDeserializeMethod()); - typOperationNodeImpl.add(createSerializeMethod(typBuilderImpl, typBuilderImpl)); - - if (doHookTti) { - GeneratorUtils.setHookTransferToInterpreter(false); - } - - return typOperationNodeImpl; - } - - private CodeExecutableElement createGetTreeProbeNode(TypeMirror thisType) { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, types.ProbeNode, "getProbeNodeImpl"); - met.addParameter(new CodeVariableElement(thisType, "$this")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - CodeTreeBuilder b = met.createBuilder(); - - b.statement("InstrumentTreeNode node = $this.instruments[index]"); - b.startIf().string("!(node").instanceOf(types.InstrumentableNode_WrapperNode).string(")").end().startBlock(); - b.returnNull(); - b.end(); - - b.startReturn().string("(").cast(types.InstrumentableNode_WrapperNode).string(" node).getProbeNode()").end(); - - return met; - } - - private CodeExecutableElement createMaterializeInstrumentTree() { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, "materializeInstrumentTree"); - CodeTreeBuilder b = met.createBuilder(); - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - b.statement("nodes.ensureInstrumentationAccessor()"); - } - - b.startReturn().string("instrumentRoot").end(); - return met; - } - - private CodeExecutableElement createHookTransferToInterpreterAndInvalidate() { - CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "hook_transferToInterpreterAndInvalidate"); - el.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); - - CodeTreeBuilder b = el.createBuilder(); - - TypeMirror swType = context.getType(StackWalker.class); - - b.startStatement().startStaticCall(types.CompilerDirectives, "transferToInterpreterAndInvalidate").end(2); - - for (VariableElement field : ElementFilter.fieldsIn(m.getTemplateType().getEnclosedElements())) { - if (field.getSimpleName().toString().equals("__magic_CountInvalidations")) { - b.startStatement().field("$this", field).string(" += 1").end(); - } - } - - b.startIf().string("__magic_LogInvalidations").end().startBlock(); - b.startStatement().startCall("System.err", "printf"); - b.doubleQuote("[ INV ] %s%s%n"); - b.doubleQuote(""); - b.startStaticCall(swType, "getInstance().walk"); - b.string("s -> s.skip(1).findFirst().get().toStackTraceElement().toString()"); - b.end(); - b.end(2); - b.end(); - - return el; - } - - private CodeExecutableElement createLoadVariadicArguments() { - CodeExecutableElement el = new CodeExecutableElement(MOD_PRIVATE_STATIC, arrayOf(context.getType(Object.class)), "do_loadVariadicArguments"); - el.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); - el.addParameter(new CodeVariableElement(context.getType(int.class), "$sp")); - el.addParameter(new CodeVariableElement(context.getType(int.class), "numVariadics")); - el.addAnnotationMirror(new CodeAnnotationMirror(types.ExplodeLoop)); - - CodeTreeBuilder b = el.createBuilder(); - b.tree(GeneratorUtils.createPartialEvaluationConstant("$sp")); - b.tree(GeneratorUtils.createPartialEvaluationConstant("numVariadics")); - b.declaration("Object[]", "result", "new Object[numVariadics]"); - - b.startFor().string("int varIndex = 0; varIndex < numVariadics; varIndex++").end().startBlock(); - b.statement("result[varIndex] = UFA.unsafeUncheckedGetObject($frame, $sp - numVariadics + varIndex)"); - b.end(); - - b.startReturn().string("result").end(); - - return el; - } - - private CodeTypeElement createContinuationRoot(CodeTypeElement typOperationNodeImpl) { - CodeTypeElement cr = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "ContinuationRoot"); - cr.setSuperClass(types.RootNode); - - cr.add(new CodeVariableElement(MOD_FINAL, typOperationNodeImpl.asType(), "root")); - cr.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "target")); - - cr.add(GeneratorUtils.createConstructorUsingFields(Set.of(), cr, - // gets the (language, frameDescriptor) ctor - ElementFilter.constructorsIn(((TypeElement) types.RootNode.asElement()).getEnclosedElements()).stream().filter(x -> x.getParameters().size() == 2).findFirst().get())); - - CodeExecutableElement mExecute = cr.add(GeneratorUtils.overrideImplement(types.RootNode, "execute")); - - CodeTreeBuilder b = mExecute.getBuilder(); - - b.statement("Object[] args = frame.getArguments()"); - b.startIf().string("args.length != 2").end().startBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("expected 2 arguments: (parentFrame, inputValue)")); - b.end(); - - b.declaration(types.MaterializedFrame, "parentFrame", "(MaterializedFrame) args[0]"); - b.declaration(context.getType(Object.class), "inputValue", "args[1]"); - - b.startIf().string("parentFrame.getFrameDescriptor() != frame.getFrameDescriptor()").end().startBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere("invalid continuation parent frame passed")); - b.end(); - - b.declaration("int", "sp", "((target >> 16) & 0xffff) + root._maxLocals"); - b.statement("parentFrame.copyTo(root._maxLocals, frame, root._maxLocals, sp - 1 - root._maxLocals)"); - b.statement("frame.setObject(sp - 1, inputValue)"); - - b.statement("return root.executeAt(frame, parentFrame, (sp << 16) | (target & 0xffff))"); - - return cr; - } - - private CodeTypeElement createContinuationLocationImpl(CodeTypeElement typOperationNodeImpl) { - DeclaredType superType = context.getDeclaredType("com.oracle.truffle.api.operation.ContinuationLocation"); - - CodeTypeElement cli = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "ContinuationLocationImpl"); - cli.setSuperClass(superType); - - cli.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "entry")); - cli.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "target")); - - cli.add(GeneratorUtils.createConstructorUsingFields(Set.of(), cli)); - - cli.add(compFinal(new CodeVariableElement(typOperationNodeImpl.asType(), "root"))); - - CodeExecutableElement mGetRootNode = cli.add(GeneratorUtils.overrideImplement(superType, "getRootNode")); - CodeTreeBuilder b = mGetRootNode.getBuilder(); - b.statement("ContinuationRoot node = root.yieldEntries[entry]"); - b.startIf().string("node == null").end().startBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.statement("node = new ContinuationRoot(root.getLanguage(), root.getFrameDescriptor(), root, target)"); - b.statement("root.yieldEntries[entry] = node"); - b.end(); - b.statement("return node"); - - CodeExecutableElement mToString = cli.add(GeneratorUtils.override(context.getDeclaredType(Object.class), "toString")); - b = mToString.getBuilder(); - b.statement("return String.format(\"ContinuationLocation [index=%d, sp=%s, bci=%04x]\", entry, target >> 16, target & 0xffff)"); - - return cli; - } - - private CodeExecutableElement createNodeExecute() { - // todo: do not generate the prolog call if not implemented - // todo: do not generate the epilog call and the try/catch if not implemented - CodeExecutableElement mExecute = GeneratorUtils.overrideImplement(types.RootNode, "execute"); - CodeTreeBuilder b = mExecute.createBuilder(); - b.declaration("Object", "returnValue", "null"); - b.declaration("Throwable", "throwable", "null"); - b.statement("executeProlog(frame)"); - b.startTryBlock(); - - b.startAssign("returnValue").startCall("executeAt"); - b.string("frame"); - if (m.enableYield) { - b.string("frame"); - } - b.string("_maxLocals << 16"); - b.end(2); - - b.startReturn().string("returnValue").end(); - b.end().startCatchBlock(context.getType(Throwable.class), "th"); - b.statement("throw sneakyThrow(throwable = th)"); - b.end().startFinallyBlock(); - b.startStatement().startCall("executeEpilog"); - b.string("frame"); - b.string("returnValue"); - b.string("throwable"); - b.end(2); - b.end(); - return mExecute; - } - - private CodeExecutableElement createUnsafeFromBytecode() { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(short.class), "unsafeFromBytecode"); - met.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - - CodeTreeBuilder b = met.createBuilder(); - b.startReturn(); - b.string("UFA.unsafeShortArrayRead(bc, index)"); - b.end(); - - return met; - } - - private CodeExecutableElement createUnsafeWriteBytecode() { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "unsafeWriteBytecode"); - met.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - met.addParameter(new CodeVariableElement(context.getType(short.class), "value")); - - CodeTreeBuilder b = met.createBuilder(); - b.statement("UFA.unsafeShortArrayWrite(bc, index, value)"); - b.end(); - - return met; - } - - private CodeExecutableElement createChangeInterpreter(CodeTypeElement loopBase) { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "changeInterpreters"); - met.addParameter(new CodeVariableElement(loopBase.asType(), "impl")); - - CodeTreeBuilder b = met.createBuilder(); - - // todo: everything here - - b.statement("this.switchImpl = impl"); - - return met; - } - - private CodeTree createNodeCopy(CodeTypeElement typOperationNodeImpl) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startNew(typOperationNodeImpl.asType()); - b.startCall("getLanguage").end(); - b.startCall("getFrameDescriptor().copy").end(); - b.end(); - return b.build(); - } - - private CodeExecutableElement createNodeImplDeepCopy(CodeTypeElement typOperationNodeImpl) { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "deepCopy"); - CodeTreeBuilder b = met.createBuilder(); - - b.declaration(typOperationNodeImpl.asType(), "result", createNodeCopy(typOperationNodeImpl)); - - b.statement("result.nodes = nodes"); - b.statement("result._bc = Arrays.copyOf(_bc, _bc.length)"); - b.statement("result._consts = Arrays.copyOf(_consts, _consts.length)"); - b.statement("result._children = Arrays.copyOf(_children, _children.length)"); - if (m.getOperationsContext().hasBoxingElimination()) { - b.statement("result._localTags = Arrays.copyOf(_localTags, _localTags.length)"); - } - if (m.isTracing()) { - b.statement("result.isBbStart = isBbStart"); - } - b.statement("result._handlers = _handlers"); - b.statement("result._conditionProfiles = Arrays.copyOf(_conditionProfiles, _conditionProfiles.length)"); - b.statement("result._maxLocals = _maxLocals"); - b.statement("result._maxStack = _maxStack"); - b.statement("result.sourceInfo = sourceInfo"); - - for (OperationMetadataData metadata : m.getMetadatas()) { - b.statement("result._metadata_" + metadata.getName() + " = _metadata_" + metadata.getName()); - } - - b.statement("return result"); - - return met; - } - - private CodeExecutableElement createSneakyThrow() { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, null, " RuntimeException sneakyThrow(Throwable e) throws E { //"); - met.createBuilder().statement("throw (E) e"); - GeneratorUtils.addSuppressWarnings(context, met, "unchecked"); - - return met; - } - - private CodeExecutableElement createNodeImplCopy(CodeTypeElement typOperationNodeImpl) { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "copy"); - CodeTreeBuilder b = met.createBuilder(); - - b.declaration(typOperationNodeImpl.asType(), "result", createNodeCopy(typOperationNodeImpl)); - - b.statement("result.nodes = nodes"); - b.statement("result._bc = _bc"); - b.statement("result._consts = _consts"); - b.statement("result._children = _children"); - if (m.getOperationsContext().hasBoxingElimination()) { - b.statement("result._localTags = _localTags"); - } - b.statement("result._handlers = _handlers"); - b.statement("result._conditionProfiles = _conditionProfiles"); - b.statement("result._maxLocals = _maxLocals"); - b.statement("result._maxStack = _maxStack"); - b.statement("result.sourceInfo = sourceInfo"); - - for (OperationMetadataData metadata : m.getMetadatas()) { - b.statement("result._metadata_" + metadata.getName() + " = _metadata_" + metadata.getName()); - } - - b.statement("return result"); - - return met; - } - - private CodeExecutableElement createNodeImplExecuteAt() { - CodeExecutableElement mExecuteAt = new CodeExecutableElement(MOD_PRIVATE, context.getType(Object.class), "executeAt"); - if (m.enableYield) { - mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "stackFrame")); - mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "localFrame")); - } else { - mExecuteAt.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - } - mExecuteAt.addParameter(new CodeVariableElement(context.getType(int.class), "storedLocation")); - - CodeTreeBuilder b = mExecuteAt.createBuilder(); - b.declaration("int", "result", "storedLocation"); - b.startWhile().string("true").end().startBlock(); - - b.startAssign("result").startCall("switchImpl", "continueAt"); - b.string("this"); - if (m.enableYield) { - b.string("stackFrame"); - b.string("localFrame"); - } else { - b.string("frame"); - } - b.string("_bc"); - b.string("result & 0xffff"); - b.string("(result >> 16) & 0xffff"); - if (USE_SIMPLE_BYTECODE) { - b.string("_objs"); - } else { - b.string("_consts"); - b.string("_children"); - } - if (m.getOperationsContext().hasBoxingElimination()) { - b.string("_localTags"); - } - b.string("_handlers"); - if (!USE_SIMPLE_BYTECODE) { - b.string("_conditionProfiles"); - } - b.string("_maxLocals"); - b.end(2); - - b.startIf().string("(result & 0xffff) == 0xffff").end().startBlock(); - b.statement("break"); - b.end().startElseBlock(); - b.declaration(m.getOperationsContext().outerType.asType(), "$this", "this"); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.end(); - - b.end(); - - b.startReturn(); - b.string(m.enableYield ? "stackFrame" : "frame"); - b.string(".getObject((result >> 16) & 0xffff)").end(); - - return mExecuteAt; - } - - private static final int SOURCE_INFO_BCI_INDEX = 0; - private static final int SOURCE_INFO_START = 1; - private static final int SOURCE_INFO_LENGTH = 2; - private static final int SOURCE_INFO_STRIDE = 3; - - private CodeExecutableElement createNodeImplGetSourceSection() { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.Node, "getSourceSection"); - - CodeTreeBuilder b = met.createBuilder(); - - b.declaration("int[]", "sourceInfo", "this.sourceInfo"); - - b.startIf().string("sourceInfo == null").end().startBlock().returnNull().end(); - - b.declaration("int", "i", (CodeTree) null); - - b.startFor().string("i = 0; i < sourceInfo.length; i += " + SOURCE_INFO_STRIDE).end().startBlock(); - b.startIf().string("sourceInfo[i + " + SOURCE_INFO_START + "] >= 0").end().startBlock(); - b.statement("int sourceIndex = sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] >> 16"); - b.statement("int sourceStart = sourceInfo[i + " + SOURCE_INFO_START + "]"); - b.statement("int sourceLength = sourceInfo[i + " + SOURCE_INFO_LENGTH + "]"); - b.startReturn().string("nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)").end(); - b.end(); - b.end(); - - b.returnNull(); - - return met; - } - - private CodeExecutableElement createNodeImplGetSourceSectionAtBci() { - CodeExecutableElement met = GeneratorUtils.overrideImplement(types.OperationRootNode, "getSourceSectionAtBci"); - - CodeTreeBuilder b = met.createBuilder(); - - b.declaration("int[]", "sourceInfo", "this.sourceInfo"); - - b.startIf().string("sourceInfo == null").end().startBlock().returnNull().end(); - - b.declaration("int", "i", (CodeTree) null); - - b.startFor().string("i = 0; i < sourceInfo.length; i += " + SOURCE_INFO_STRIDE).end().startBlock(); - b.startIf().string("(sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] & 0xffff) > bci").end().startBlock(); - b.statement("break"); - b.end(); - b.end(); - - b.startIf().string("i == 0").end().startBlock(); - b.returnNull(); - b.end().startElseBlock(); - - b.statement("i -= " + SOURCE_INFO_STRIDE); - b.statement("int sourceIndex = sourceInfo[i + " + SOURCE_INFO_BCI_INDEX + "] >> 16"); - b.startIf().string("sourceIndex < 0").end().startBlock().returnNull().end(); - b.statement("int sourceStart = sourceInfo[i + " + SOURCE_INFO_START + "]"); - b.startIf().string("sourceStart < 0").end().startBlock().returnNull().end(); - b.statement("int sourceLength = sourceInfo[i + " + SOURCE_INFO_LENGTH + "]"); - b.startReturn().string("nodes.getSources()[sourceIndex].createSection(sourceStart, sourceLength)").end(); - - b.end(); - - return met; - } - - private CodeTypeElement createBuilderImpl(CodeTypeElement typOperationNodeImpl, CodeTypeElement opNodesImpl, CodeTypeElement typExceptionHandler) { - CodeTypeElement typBuilderImpl = GeneratorUtils.createClass(m, null, Set.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), OPERATION_BUILDER_IMPL_NAME, types.OperationBuilder); - typBuilderImpl.setEnclosingElement(typOperationNodeImpl); - - if (m.isTracing()) { - String decisionsFilePath = m.getDecisionsFilePath(); - CodeExecutableElement mStaticInit = new CodeExecutableElement(MOD_STATIC, null, ""); - typBuilderImpl.add(mStaticInit); - - CodeTreeBuilder b = mStaticInit.appendBuilder(); - - b.startStatement().startStaticCall(types.ExecutionTracer, "initialize"); - - b.typeLiteral(m.getTemplateType().asType()); - - // destination path - b.doubleQuote(decisionsFilePath); - - // instruction names - b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); - b.string("null"); - for (Instruction instr : m.getInstructions()) { - b.doubleQuote(instr.name); - } - b.end(); - - // specialization names - - b.startNewArray(new ArrayCodeTypeMirror(new ArrayCodeTypeMirror(context.getType(String.class))), null); - b.string("null"); - for (Instruction instr : m.getInstructions()) { - if (!(instr instanceof CustomInstruction)) { - b.string("null"); - continue; - } - - b.startNewArray(new ArrayCodeTypeMirror(context.getType(String.class)), null); - CustomInstruction cinstr = (CustomInstruction) instr; - for (String name : cinstr.getSpecializationNames()) { - b.doubleQuote(name); - } - b.end(); - } - b.end(); - - b.end(2); - } - - CodeTypeElement opDataImpl = createOperationDataImpl(); - typBuilderImpl.add(opDataImpl); - - CodeTypeElement typFinallyTryContext = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "BuilderFinallyTryContext", null); - - CodeTypeElement typLabelData = createOperationLabelImpl(opDataImpl, typFinallyTryContext); - typBuilderImpl.add(typLabelData); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(createOperationSerLabelImpl()); - } - - CodeTypeElement typLocalData = createOperationLocalImpl(opDataImpl); - typBuilderImpl.add(typLocalData); - - CodeTypeElement typLabelFill = typBuilderImpl.add(createLabelFill(typLabelData)); - - CodeTypeElement typSourceBuilder = createSourceBuilder(typBuilderImpl); - typBuilderImpl.add(typSourceBuilder); - - createFinallyTryContext(typFinallyTryContext, typExceptionHandler, typLabelFill, typLabelData); - typBuilderImpl.add(typFinallyTryContext); - - m.getOperationsContext().labelType = typLabelData.asType(); - m.getOperationsContext().exceptionType = typExceptionHandler.asType(); - m.getOperationsContext().outerType = typOperationNodeImpl; - - typBuilderImpl.add(createBuilderImplCtor(opNodesImpl)); - - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, opNodesImpl.asType(), "nodes")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "isReparse")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withSource")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, context.getType(boolean.class), "withInstrumentation")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typSourceBuilder.asType(), "sourceBuilder")); - - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(short[].class), "bc = new short[65535]")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "bci")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "curStack")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "maxStack")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLocals")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "instructionHistory = new int[8]")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "instructionHistoryIndex = 0")); - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numLabels")); - } - if (m.enableYield) { - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "yieldCount")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, arrayOf(new GeneratedTypeMirror("", "ContinuationLocationImpl")), "yieldLocations = null")); - } - if (m.isTracing()) { - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean[].class), "isBbStart = new boolean[65535]")); - } - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numInstrumentNodes")); - } - - CodeVariableElement fldConstPool = typBuilderImpl.add( - new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(context.getType(Object.class))), "constPool")); - fldConstPool.createInitBuilder().string("new ArrayList<>()"); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, opDataImpl.asType(), "operationData")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelData.asType())), "labels = new ArrayList<>()")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typLabelFill.asType())), "labelFills = new ArrayList<>()")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numChildNodes")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "numConditionProfiles")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typExceptionHandler.asType())), - "exceptionHandlers = new ArrayList<>()")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typFinallyTryContext.asType(), "currentFinallyTry")); - - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "buildIndex")); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(boolean.class), "isSerializing")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(DATA_OUTPUT_CLASS), "serBuffer")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationSerializer"), "serCallback")); - } - - typBuilderImpl.add(createBuilderImplFinish()); - typBuilderImpl.add(createBuilderImplReset()); - - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int[].class), "stackSourceBci = new int[1024]")); - typBuilderImpl.add(createBuilderImplDoBeforeEmitInstruction()); - - CodeTypeElement typBuilderState = typBuilderImpl.add(createBuilderState(typBuilderImpl, "bc", "bci", "curStack", "maxStack", "numLocals", "numLabels", "yieldCount", "yieldLocations", - "constPool", "operationData", "labels", "labelFills", "numChildNodes", "numConditionProfiles", "exceptionHandlers", "currentFinallyTry", "stackSourceBci", "sourceBuilder")); - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE, typBuilderState.asType(), "parentData")); - - typBuilderImpl.add(createDoLeaveFinallyTry(opDataImpl)); - typBuilderImpl.add(createBuilderImplDoEmitLabel(typLabelData)); - typBuilderImpl.addAll(createBuilderImplCalculateLeaves(opDataImpl, typLabelData)); - - typBuilderImpl.add(createBuilderImplCreateLocal(typBuilderImpl, typLocalData)); - typBuilderImpl.add(createBuilderImplCreateParentLocal(typBuilderImpl, typLocalData)); - typBuilderImpl.add(createBuilderImplCreateLabel(typBuilderImpl, typLabelData)); - typBuilderImpl.addAll(createBuilderImplGetLocalIndex(typLocalData)); - typBuilderImpl.add(createBuilderImplVerifyNesting(opDataImpl)); - typBuilderImpl.add(createBuilderImplPublish(typOperationNodeImpl)); - typBuilderImpl.add(createBuilderImplLabelPass(typFinallyTryContext)); - - typBuilderImpl.add(createBuilderImplOperationNames()); - - // operation IDs - for (Operation op : m.getOperationsContext().operations) { - CodeVariableElement fldId = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(int.class), "OP_" + OperationGeneratorUtils.toScreamCase(op.name)); - CodeTreeBuilder b = fldId.createInitBuilder(); - b.string("" + op.id); - op.setIdConstantField(fldId); - typBuilderImpl.add(fldId); - } - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(createOperationSerNodeImpl()); - typBuilderImpl.add(createSerializationContext()); - } - - typBuilderImpl.add(new CodeVariableElement(MOD_PRIVATE_FINAL, new DeclaredCodeTypeMirror(context.getTypeElement(ArrayList.class), List.of(typOperationNodeImpl.asType())), "builtNodes")); - - CodeVariableElement fldOperationData = new CodeVariableElement(MOD_PRIVATE, opDataImpl.asType(), "operationData"); - - CodeVariableElement fldBc = new CodeVariableElement(MOD_PRIVATE, arrayOf(context.getType(byte.class)), "bc"); - - CodeVariableElement fldIndent = null; - if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { - fldIndent = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "indent"); - typBuilderImpl.add(fldIndent); - } - - CodeVariableElement fldBci = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "bci"); - - CodeVariableElement fldLastPush = new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "lastChildPush"); - typBuilderImpl.add(fldLastPush); - - BuilderVariables vars = new BuilderVariables(); - vars.bc = fldBc; - vars.bci = fldBci; - vars.operationData = fldOperationData; - vars.lastChildPushCount = fldLastPush; - vars.consts = fldConstPool; - - typBuilderImpl.add(createDoLeave(vars, opDataImpl)); - typBuilderImpl.add(createBeforeChild(vars)); - typBuilderImpl.add(createAfterChild(vars)); - - for (Operation op : m.getOperations()) { - List args = op.getBuilderArgumentTypes(); - CodeVariableElement[] params = new CodeVariableElement[args.size()]; - - for (int i = 0; i < params.length; i++) { - params[i] = new CodeVariableElement(args.get(i), "arg" + i); - } - - if (op.children != 0) { - typBuilderImpl.add(createBeginOperation(typBuilderImpl, vars, op)); - typBuilderImpl.add(createEndOperation(typBuilderImpl, vars, op)); - } else { - typBuilderImpl.add(createEmitOperation(typBuilderImpl, vars, op)); - } - } - - for (OperationMetadataData metadata : m.getMetadatas()) { - CodeVariableElement fldMetadata = new CodeVariableElement(MOD_PRIVATE, metadata.getType(), "metadata_" + metadata.getName()); - typBuilderImpl.add(fldMetadata); - typBuilderImpl.add(createSetMetadata(metadata, false)); - } - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - typBuilderImpl.add(createBuilderImplDeserializeParser(typBuilderImpl)); - } - - return typBuilderImpl; - } - - private CodeVariableElement createBuilderImplOperationNames() { - CodeVariableElement el = new CodeVariableElement(MOD_PRIVATE_STATIC_FINAL, context.getType(String[].class), "OPERATION_NAMES"); - CodeTreeBuilder b = el.createInitBuilder(); - - b.startNewArray((ArrayType) context.getType(String[].class), null); - - b.string("null"); - - int idx = 1; - for (Operation data : m.getOperations()) { - if (idx != data.id) { - throw new AssertionError(); - } - b.doubleQuote(data.name); - idx++; - } - - b.end(); - - return el; - } - - private CodeTypeElement createBuilderState(CodeTypeElement typBuilder, String... fields) { - CodeTypeElement typ = new CodeTypeElement(MOD_PRIVATE_FINAL, ElementKind.CLASS, null, "BuilderState"); - typ.add(new CodeVariableElement(typ.asType(), "parentData")); - - ArrayList foundFields = new ArrayList<>(); - - for (String s : fields) { - for (VariableElement field : ElementFilter.fieldsIn(typBuilder.getEnclosedElements())) { - String fn = field.getSimpleName().toString(); - if (fn.equals(s) || fn.startsWith(s + " ")) { - typ.add(CodeVariableElement.clone(field)); - foundFields.add(s); - break; - } - } - } - - foundFields.add("parentData"); - - CodeExecutableElement ctor = typ.add(new CodeExecutableElement(null, "BuilderState")); - ctor.addParameter(new CodeVariableElement(typBuilder.asType(), "p")); - CodeTreeBuilder b = ctor.createBuilder(); - for (String s : foundFields) { - b.statement(String.format("this.%s = p.%s", s, s)); - } - - return typ; - } - - private CodeExecutableElement createBuilderImplDeserializeParser(CodeTypeElement typBuilder) { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "deserializeParser"); - met.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); - met.addParameter(new CodeVariableElement(context.getType(DATA_INPUT_CLASS), "buffer")); - met.addParameter(new CodeVariableElement(context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer"), "callback")); - met.addParameter(new CodeVariableElement(typBuilder.asType(), "builder")); - - CodeTreeBuilder b = met.createBuilder(); - serializationWrapException(b, () -> { - b.statement("ArrayList consts = new ArrayList<>()"); - b.statement("ArrayList locals = new ArrayList<>()"); - b.statement("ArrayList labels = new ArrayList<>()"); - b.statement("ArrayList<" + m.getTemplateType().getSimpleName() + "> builtNodes = new ArrayList<>()"); - - b.statement("buffer.rewind()"); - b.declaration(context.getType(DATA_INPUT_WRAP_CLASS), "dataInput", "com.oracle.truffle.api.operation.serialization.SerializationUtils.createDataInput(buffer)"); - - TypeMirror deserContext = context.getDeclaredType("com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext"); - - b.startStatement(); - b.type(deserContext); - b.string(" context = ").startNew(deserContext).end().startBlock(); - - b.string("@Override").newLine(); - b.string("public " + m.getTemplateType().getSimpleName() + " deserializeOperationNode(").type(context.getType(DATA_INPUT_WRAP_CLASS)).string(" buffer) throws IOException ").startBlock(); - b.statement("return builtNodes.get(buffer.readInt())"); - b.end(); - - b.end(2); - - b.startWhile().string("true").end().startBlock(); - b.startSwitch().string("buffer." + DATA_READ_METHOD_PREFIX + "Short()").end().startBlock(); - - b.startCase().string("" + SER_CODE_CREATE_LABEL).end().startBlock(); - b.statement("labels.add(builder.createLabel())"); - b.statement("break"); - b.end(); - - b.startCase().string("" + SER_CODE_CREATE_LOCAL).end().startBlock(); - b.statement("locals.add(builder.createLocal())"); - b.statement("break"); - b.end(); - - b.startCase().string("" + SER_CODE_CREATE_OBJECT).end().startBlock(); - b.statement("consts.add(callback.deserialize(context, dataInput))"); - b.statement("break"); - b.end(); - - b.startCase().string("" + SER_CODE_END).end().startBlock(); - b.returnStatement(); - b.end(); - - if (!m.getMetadatas().isEmpty()) { - b.startCase().string("" + SER_CODE_METADATA).end().startBlock(); - // todo: we only need a byte if < 255 metadata types - b.startSwitch().string("buffer." + DATA_READ_METHOD_PREFIX + "Short()").end().startBlock(); - int i = 0; - for (OperationMetadataData metadata : m.getMetadatas()) { - b.startCase().string("" + i).end().startCaseBlock(); - b.startStatement().startCall("builder", "set" + metadata.getName()); - b.startGroup().maybeCast(context.getType(Object.class), metadata.getType()); - b.string("callback.deserialize(context, dataInput)"); - b.end(3); - b.statement("break"); - b.end(); - i++; - } - b.end(); - - b.statement("break"); - b.end(); - } - - for (Operation op : m.getOperations()) { - - // create begin/emit code - b.startCase().variable(op.idConstantField).string(" << 1").end().startBlock(); - - int i = 0; - for (TypeMirror argType : op.getBuilderArgumentTypes()) { - // ARGUMENT DESERIALIZATION - if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) { - b.declaration(types.TruffleLanguage, "arg" + i, "language"); - } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) { - b.statement("OperationLocal arg" + i + " = locals.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())"); - } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { - b.statement("OperationLocal[] arg" + i + " = new OperationLocal[buffer." + DATA_READ_METHOD_PREFIX + "Short()]"); - b.startFor().string("int i = 0; i < arg" + i + ".length; i++").end().startBlock(); - // this can be optimized since they are consecutive - b.statement("arg" + i + "[i] = locals.get(buffer." + DATA_READ_METHOD_PREFIX + "Short());"); - b.end(); - } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { - b.statement("OperationLabel arg" + i + " = labels.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())"); - } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { - b.statement("int arg" + i + " = buffer." + DATA_READ_METHOD_PREFIX + "Int()"); - } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { - b.startStatement().type(argType).string(" arg" + i + " = ").cast(argType).string("consts.get(buffer." + DATA_READ_METHOD_PREFIX + "Short())").end(); - } else { - throw new UnsupportedOperationException("cannot deserialize: " + argType); - } - i++; - } - - b.startStatement(); - if (op.children == 0) { - b.startCall("builder.emit" + op.name); - } else { - b.startCall("builder.begin" + op.name); - } - - for (int j = 0; j < i; j++) { - b.string("arg" + j); - } - - b.end(2); // statement, call - - b.statement("break"); - - b.end(); // case block - - if (op.children != 0) { - b.startCase().string("(").variable(op.idConstantField).string(" << 1) | 1").end().startBlock(); - - b.startStatement(); - if (op.isRoot()) { - b.startCall("builtNodes.add"); - } - b.string("builder.end" + op.name + "()"); - if (op.isRoot()) { - b.end(); - } - b.end(); - - b.statement("break"); - - b.end(); - } - - } - - b.end(); - b.end(); - }); - - return met; - } - - private CodeExecutableElement createConditionProfile() { - CodeExecutableElement met = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(boolean.class), "do_profileCondition"); - met.addParameter(new CodeVariableElement(m.getOperationsContext().outerType.asType(), "$this")); - met.addParameter(new CodeVariableElement(context.getType(boolean.class), "value")); - met.addParameter(new CodeVariableElement(context.getType(int[].class), "profiles")); - met.addParameter(new CodeVariableElement(context.getType(int.class), "index")); - - CodeTreeBuilder b = met.createBuilder(); - - final int maxInt = 0x3FFFFFFF; - - b.declaration("int", "t", "UFA.unsafeIntArrayRead(profiles, index)"); - b.declaration("int", "f", "UFA.unsafeIntArrayRead(profiles, index + 1)"); - - b.declaration("boolean", "val", "value"); - b.startIf().string("val").end().startBlock(); - - b.startIf().string("t == 0").end().startBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.end(); - b.startIf().string("f == 0").end().startBlock(); - b.statement("val = true"); - b.end(); - b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); - b.startIf().string("t < " + maxInt).end().startBlock(); - b.statement("UFA.unsafeIntArrayWrite(profiles, index, t + 1)"); - b.end(); - b.end(); - - b.end().startElseBlock(); - - b.startIf().string("f == 0").end().startBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.end(); - b.startIf().string("t == 0").end().startBlock(); - b.statement("val = false"); - b.end(); - b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); - b.startIf().string("f < " + maxInt).end().startBlock(); - b.statement("UFA.unsafeIntArrayWrite(profiles, index + 1, f + 1)"); - b.end(); - b.end(); - - b.end(); - - b.startIf().tree(GeneratorUtils.createInInterpreter()).end().startBlock(); - b.statement("return val"); - b.end().startElseBlock(); - b.statement("int sum = t + f"); - b.statement("return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val)"); - b.end(); - - return met; - } - - private List createBuilderImplGetLocalIndex(CodeTypeElement typLocalData) { - CodeExecutableElement mGetLocalIndex = new CodeExecutableElement(MOD_PRIVATE, context.getType(short.class), "getLocalIndex"); - mGetLocalIndex.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); - CodeTreeBuilder b = mGetLocalIndex.createBuilder(); - b.declaration(typLocalData.asType(), "local", "(" + typLocalData.getSimpleName() + ") value"); - b.startAssert().string("verifyNesting(local.owner, operationData) : \"local access not nested properly\"").end(); - b.startReturn().string("(short) local.id").end(); - - CodeExecutableElement mGetLocalIndices = new CodeExecutableElement(MOD_PRIVATE, context.getType(int[].class), "getLocalIndices"); - mGetLocalIndices.addParameter(new CodeVariableElement(context.getType(Object.class), "value")); - b = mGetLocalIndices.createBuilder(); - b.declaration(arrayOf(types.OperationLocal), "locals", "(OperationLocal[]) value"); - b.declaration("int[]", "result", "new int[locals.length]"); - b.startFor().string("int i = 0; i < locals.length; i++").end().startBlock(); - b.statement("result[i] = getLocalIndex(locals[i])"); - b.end(); - b.statement("return result"); - - return List.of(mGetLocalIndex, mGetLocalIndices); - } - - private CodeExecutableElement createBuilderImplVerifyNesting(CodeTypeElement opDataImpl) { - CodeExecutableElement mDoEmitLabel = new CodeExecutableElement(MOD_PRIVATE, context.getType(boolean.class), "verifyNesting"); - mDoEmitLabel.addParameter(new CodeVariableElement(opDataImpl.asType(), "parent")); - mDoEmitLabel.addParameter(new CodeVariableElement(opDataImpl.asType(), "child")); - - CodeTreeBuilder b = mDoEmitLabel.createBuilder(); - - b.declaration(opDataImpl.asType(), "cur", "child"); - b.startWhile().string("cur.depth > parent.depth").end().startBlock(); - b.statement("cur = cur.parent"); - b.end(); - - b.statement("return cur == parent"); - - return mDoEmitLabel; - } - - private CodeExecutableElement createBuilderImplDoEmitLabel(CodeTypeElement typLabelData) { - CodeExecutableElement mDoEmitLabel = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doEmitLabel"); - mDoEmitLabel.addParameter(new CodeVariableElement(types.OperationLabel, "label")); - - CodeTreeBuilder b = mDoEmitLabel.createBuilder(); - - b.declaration(typLabelData.asType(), "lbl", "(" + typLabelData.getSimpleName() + ") label"); - - b.startIf().string("lbl.hasValue").end().startBlock(); - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("label already emitted").end(2); - b.end(); - - b.startIf().string("operationData != lbl.data").end().startBlock(); - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("label must be created and emitted inside same opeartion").end(2); - b.end(); - - b.statement("lbl.hasValue = true"); - b.statement("lbl.targetBci = bci"); - - if (m.isTracing()) { - b.statement("isBbStart[bci] = true"); - } - - return mDoEmitLabel; - } - - private List createBuilderImplCalculateLeaves(CodeTypeElement opDataImpl, CodeTypeElement typLabelData) { - CodeExecutableElement mCalculateLeaves = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); - mCalculateLeaves.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); - mCalculateLeaves.addParameter(new CodeVariableElement(opDataImpl.asType(), "toData")); - - CodeTreeBuilder b = mCalculateLeaves.createBuilder(); - - b.startIf().string("toData != null && fromData.depth < toData.depth").end().startBlock(); - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("illegal jump to deeper operation").end(2); - b.end(); - - b.startIf().string("fromData == toData").end().startBlock().returnStatement().end(); - - b.declaration(opDataImpl.asType(), "cur", "fromData"); - - b.startWhile().string("true").end().startBlock(); - - b.statement("doLeaveOperation(cur)"); - b.statement("cur = cur.parent"); - - b.startIf().string("toData == null && cur == null").end().startBlock(); - b.statement("break"); - b.end().startElseIf().string("toData != null && cur.depth <= toData.depth").end(); - b.statement("break"); - b.end(); - - b.end(); - - b.startIf().string("cur != toData").end(); - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("illegal jump to non-parent operation").end(2); - b.end(); - - CodeExecutableElement oneArg = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); - oneArg.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); - oneArg.createBuilder().statement("calculateLeaves(fromData, (BuilderOperationData) null)"); - - CodeExecutableElement labelArg = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "calculateLeaves"); - labelArg.addParameter(new CodeVariableElement(opDataImpl.asType(), "fromData")); - labelArg.addParameter(new CodeVariableElement(context.getType(Object.class), "toLabel")); - labelArg.createBuilder().statement("calculateLeaves(fromData, ((OperationLabelImpl) toLabel).data)"); - - return List.of(mCalculateLeaves, oneArg, labelArg); - } - - private CodeTypeElement createOperationLabelImpl(CodeTypeElement opDataImpl, CodeTypeElement typFTC) { - CodeTypeElement typOperationLabel = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationLabelImpl", types.OperationLabel); - - typOperationLabel.add(new CodeVariableElement(opDataImpl.asType(), "data")); - typOperationLabel.add(new CodeVariableElement(typFTC.asType(), "finallyTry")); - - typOperationLabel.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationLabel)); - - typOperationLabel.add(new CodeVariableElement(context.getType(int.class), "targetBci = 0")); - typOperationLabel.add(new CodeVariableElement(context.getType(boolean.class), "hasValue = false")); - - CodeExecutableElement mBelongsTo = typOperationLabel.add(new CodeExecutableElement(context.getType(boolean.class), "belongsTo")); - mBelongsTo.addParameter(new CodeVariableElement(typFTC.asType(), "context")); - CodeTreeBuilder b = mBelongsTo.createBuilder(); - b.declaration(typFTC.asType(), "cur", "finallyTry"); - b.startWhile().string("cur != null").end().startBlock(); // { - - b.startIf().string("cur == context").end().startBlock().returnTrue().end(); - b.statement("cur = cur.prev"); - - b.end(); // } - - b.returnFalse(); - - return typOperationLabel; - } - - private CodeTypeElement createOperationSerLabelImpl() { - CodeTypeElement typOperationLabel = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationSerLabelImpl", types.OperationLabel); - - typOperationLabel.add(new CodeVariableElement(context.getType(int.class), "id")); - - typOperationLabel.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typOperationLabel)); - - return typOperationLabel; - } - - private CodeTypeElement createOperationLocalImpl(CodeTypeElement opDataImpl) { - CodeTypeElement typLocalData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "OperationLocalImpl", types.OperationLocal); - - typLocalData.add(new CodeVariableElement(MOD_FINAL, opDataImpl.asType(), "owner")); - typLocalData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "id")); - - typLocalData.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typLocalData)); - - return typLocalData; - } - - private void serializationWrapException(CodeTreeBuilder b, Runnable r) { - b.startTryBlock(); - r.run(); - b.end().startCatchBlock(context.getType(IOException.class), "ex"); - b.startThrow().startNew(context.getType(IOError.class)).string("ex").end(2); - b.end(); - } - - @SuppressWarnings("static-method") - private CodeExecutableElement createBuilderImplCreateLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { - CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PUBLIC_FINAL, types.OperationLocal, "createLocal"); - CodeTreeBuilder b = mCreateLocal.createBuilder(); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - b.startIf().string("isSerializing").end().startBlock(); - serializationWrapException(b, () -> { - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_LOCAL + ")"); - b.statement("return new OperationLocalImpl(null, numLocals++)"); - }); - b.end(); - } - - b.startReturn().startNew(typLocalData.asType()).string("operationData").string("numLocals++").end(2); - return mCreateLocal; - } - - @SuppressWarnings("static-method") - private CodeExecutableElement createBuilderImplCreateParentLocal(CodeTypeElement typBuilder, CodeTypeElement typLocalData) { - CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PRIVATE, typLocalData.asType(), "createParentLocal"); - mCreateLocal.createBuilder().startReturn().startNew(typLocalData.asType()).string("operationData.parent").string("numLocals++").end(2); - return mCreateLocal; - } - - @SuppressWarnings("static-method") - private CodeExecutableElement createBuilderImplCreateLabel(CodeTypeElement typBuilder, CodeTypeElement typLabelData) { - CodeExecutableElement mCreateLocal = new CodeExecutableElement(MOD_PUBLIC_FINAL, types.OperationLabel, "createLabel"); - - CodeTreeBuilder b = mCreateLocal.createBuilder(); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - b.startIf().string("isSerializing").end().startBlock(); - serializationWrapException(b, () -> { - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_LABEL + ")"); - b.statement("return new OperationSerLabelImpl(numLabels++)"); - }); - b.end(); - } - - b.startAssign("OperationLabelImpl label").startNew(typLabelData.asType()).string("operationData").string("currentFinallyTry").end(2); - b.startStatement().startCall("labels", "add").string("label").end(2); - b.startReturn().string("label").end(); - - return mCreateLocal; - } - - private CodeTypeElement createExceptionHandler() { - CodeTypeElement typ = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "ExceptionHandler", null); - - typ.add(new CodeVariableElement(context.getType(int.class), "startBci")); - typ.add(new CodeVariableElement(context.getType(int.class), "startStack")); - typ.add(new CodeVariableElement(context.getType(int.class), "endBci")); - typ.add(new CodeVariableElement(context.getType(int.class), "exceptionIndex")); - typ.add(new CodeVariableElement(context.getType(int.class), "handlerBci")); - - typ.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typ)); - - typ.add(new CodeExecutableElement(null, typ.getSimpleName().toString())); - - CodeExecutableElement metOffset = typ.add(new CodeExecutableElement(typ.asType(), "offset")); - metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "offset")); - metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "stackOffset")); - - CodeTreeBuilder b = metOffset.createBuilder(); - b.startReturn().startNew(typ.asType()); - b.string("startBci + offset"); - b.string("startStack + stackOffset"); - b.string("endBci + offset"); - b.string("exceptionIndex"); - b.string("handlerBci + offset"); - b.end(2); - - CodeExecutableElement mToString = typ.add(GeneratorUtils.override(context.getDeclaredType(Object.class), "toString")); - - b = mToString.createBuilder(); - b.startReturn().startCall("String.format"); - b.doubleQuote("handler {start=%04x, end=%04x, stack=%d, local=%d, handler=%04x}"); - b.string("startBci").string("endBci").string("startStack").string("exceptionIndex").string("handlerBci"); - b.end(2); - - return typ; - } - - // -------------------------------- source builder ---------------------------- - - private CodeTypeElement createSourceBuilder(CodeTypeElement typBuilderImpl) { - CodeTypeElement typSourceBuilder = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceInfoBuilder", null); - typSourceBuilder.setEnclosingElement(typBuilderImpl); - - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, types.Source), "sourceList")); - - typSourceBuilder.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typSourceBuilder)); - - CodeTypeElement typSourceData = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "SourceData", null); - typSourceBuilder.add(typSourceData); - typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "start")); - typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "length")); - typSourceData.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "sourceIndex")); - typSourceData.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typSourceData)); - - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "sourceStack = new ArrayList<>()")); - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE, context.getType(int.class), "currentSource = -1")); - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, context.getType(Integer.class)), "bciList = new ArrayList<>()")); - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, typSourceData.asType()), "sourceDataList = new ArrayList<>()")); - typSourceBuilder.add(new CodeVariableElement(MOD_PRIVATE_FINAL, generic(ArrayList.class, typSourceData.asType()), "sourceDataStack = new ArrayList<>()")); - - typSourceBuilder.add(createSourceBuilderReset()); - typSourceBuilder.add(createSourceBuilderBeginSource()); - typSourceBuilder.add(createSourceBuilderEndSource()); - typSourceBuilder.add(createSourceBuilderBeginSourceSection()); - typSourceBuilder.add(createSourceBuilderEndSourceSection()); - typSourceBuilder.add(createSourceBuilderBuild()); - typSourceBuilder.add(createSourceBuilderBuildSource()); - - return typSourceBuilder; - } - - private CodeExecutableElement createSourceBuilderReset() { - CodeExecutableElement mReset = new CodeExecutableElement(context.getType(void.class), "reset"); - - CodeTreeBuilder b = mReset.createBuilder(); - b.statement("sourceStack.clear()"); - b.statement("sourceDataList.clear()"); - b.statement("sourceDataStack.clear()"); - b.statement("bciList.clear()"); - return mReset; - } - - private CodeExecutableElement createSourceBuilderBeginSource() { - CodeExecutableElement mBeginSource = new CodeExecutableElement(context.getType(void.class), "beginSource"); - mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - mBeginSource.addParameter(new CodeVariableElement(types.Source, "src")); - - CodeTreeBuilder b = mBeginSource.createBuilder(); - b.statement("int idx = sourceList.indexOf(src)"); - - b.startIf().string("idx == -1").end().startBlock(); - b.statement("idx = sourceList.size()"); - b.statement("sourceList.add(src)"); - b.end(); - - b.statement("sourceStack.add(currentSource)"); - b.statement("currentSource = idx"); - b.statement("beginSourceSection(bci, -1, -1)"); - return mBeginSource; - } - - private CodeExecutableElement createSourceBuilderEndSource() { - CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(void.class), "endSource"); - mEndSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - - CodeTreeBuilder b = mEndSource.createBuilder(); - b.statement("endSourceSection(bci)"); - b.statement("currentSource = sourceStack.remove(sourceStack.size() - 1)"); - return mEndSource; - } - - private CodeExecutableElement createSourceBuilderBeginSourceSection() { - CodeExecutableElement mBeginSource = new CodeExecutableElement(context.getType(void.class), "beginSourceSection"); - mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "start")); - mBeginSource.addParameter(new CodeVariableElement(context.getType(int.class), "length")); - - CodeTreeBuilder b = mBeginSource.createBuilder(); - b.statement("SourceData data = new SourceData(start, length, currentSource)"); - b.statement("bciList.add(bci)"); - b.statement("sourceDataList.add(data)"); - b.statement("sourceDataStack.add(data)"); - return mBeginSource; - } - - private CodeExecutableElement createSourceBuilderEndSourceSection() { - CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(void.class), "endSourceSection"); - mEndSource.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - - CodeTreeBuilder b = mEndSource.createBuilder(); - b.statement("SourceData data = sourceDataStack.remove(sourceDataStack.size() - 1)"); - b.statement("SourceData prev"); - - b.startIf().string("sourceDataStack.isEmpty()").end().startBlock(); - b.statement("prev = new SourceData(-1, -1, currentSource)"); - b.end().startElseBlock(); - b.statement("prev = sourceDataStack.get(sourceDataStack.size() - 1)"); - b.end(); - - b.statement("bciList.add(bci)"); - b.statement("sourceDataList.add(prev)"); - return mEndSource; - } - - private CodeExecutableElement createSourceBuilderBuildSource() { - CodeExecutableElement mEndSource = new CodeExecutableElement(arrayOf(types.Source), "buildSource"); - - CodeTreeBuilder b = mEndSource.createBuilder(); - b.statement("return sourceList.toArray(new Source[0])"); - - return mEndSource; - } - - private CodeExecutableElement createSourceBuilderBuild() { - CodeExecutableElement mEndSource = new CodeExecutableElement(context.getType(int[].class), "build"); - - CodeTreeBuilder b = mEndSource.createBuilder(); - - b.startIf().string("!sourceStack.isEmpty()").end().startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("not all sources ended").end(2); - b.end(); - - b.startIf().string("!sourceDataStack.isEmpty()").end().startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote("not all source sections ended").end(2); - b.end(); - - int sourceStride = 3; - - b.statement("int size = bciList.size()"); - - b.statement("int[] resultArray = new int[size * " + sourceStride + "]"); - - b.statement("int index = 0"); - b.statement("int lastBci = -1"); - b.statement("boolean isFirst = true"); - - b.startFor().string("int i = 0; i < size; i++").end().startBlock(); - b.statement("SourceData data = sourceDataList.get(i)"); - b.statement("int curBci = bciList.get(i)"); - - b.startIf().string("data.start == -1 && isFirst").end().startBlock().statement("continue").end(); - - b.statement("isFirst = false"); - - b.startIf().string("curBci == lastBci && index > 1").end().startBlock(); - b.statement("index -= " + sourceStride); - b.end(); - - b.statement("resultArray[index + 0] = curBci | (data.sourceIndex << 16)"); - b.statement("resultArray[index + 1] = data.start"); - b.statement("resultArray[index + 2] = data.length"); - - b.statement("index += " + sourceStride); - b.statement("lastBci = curBci"); - - b.end(); - - b.statement("return Arrays.copyOf(resultArray, index)"); - - return mEndSource; - } - // ------------------------------ operadion data impl ------------------------ - - private CodeTypeElement createOperationDataImpl() { - CodeTypeElement opDataImpl = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "BuilderOperationData", null); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, opDataImpl.asType(), "parent")); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "operationId")); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "stackDepth")); - - CodeExecutableElement ctor = opDataImpl.add(GeneratorUtils.createConstructorUsingFields(MOD_PRIVATE, opDataImpl)); - ctor.addParameter(new CodeVariableElement(context.getType(int.class), "numAux")); - ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "needsLeave")); - ctor.addParameter(new CodeVariableElement(context.getType(Object.class), "...arguments")); - - CodeTreeBuilder b = ctor.appendBuilder(); - b.statement("this.depth = parent == null ? 0 : parent.depth + 1"); - b.statement("this.aux = numAux > 0 ? new Object[numAux] : null"); - b.statement("this.needsLeave = needsLeave || (parent != null && parent.needsLeave)"); - b.statement("this.arguments = arguments"); - - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(boolean.class), "needsLeave")); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "depth")); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(Object[].class), "arguments")); - opDataImpl.add(new CodeVariableElement(MOD_FINAL, context.getType(Object[].class), "aux")); - opDataImpl.add(new CodeVariableElement(context.getType(int.class), "numChildren")); - - return opDataImpl; - } - - private CodeTypeElement createBytecodeBaseClass(CodeTypeElement baseClass, CodeTypeElement opNodeImpl, TypeMirror typOperationNodes, CodeTypeElement typExceptionHandler) { - - CodeExecutableElement loopMethod = new CodeExecutableElement(MOD_ABSTRACT, context.getType(int.class), "continueAt"); - loopMethod.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); - if (m.enableYield) { - loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$stackFrame")); - loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$localFrame")); - } else { - loopMethod.addParameter(new CodeVariableElement(types.VirtualFrame, "$frame")); - } - loopMethod.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); - loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startBci")); - loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "$startSp")); - if (USE_SIMPLE_BYTECODE) { - loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$objs")); - } else { - loopMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); - loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); - } - if (m.getOperationsContext().hasBoxingElimination()) { - loopMethod.addParameter(new CodeVariableElement(context.getType(byte[].class), "$localTags")); - } - loopMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); - if (!USE_SIMPLE_BYTECODE) { - loopMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "$conditionProfiles")); - } - loopMethod.addParameter(new CodeVariableElement(context.getType(int.class), "maxLocals")); - baseClass.add(loopMethod); - - CodeExecutableElement dumpMethod = new CodeExecutableElement(MOD_ABSTRACT, types.OperationIntrospection, "getIntrospectionData"); - dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(context.getType(short.class)), "$bc")); - dumpMethod.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(typExceptionHandler.asType()), "$handlers")); - dumpMethod.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); - dumpMethod.addParameter(new CodeVariableElement(typOperationNodes, "nodes")); - dumpMethod.addParameter(new CodeVariableElement(context.getType(int[].class), "sourceInfo")); - baseClass.add(dumpMethod); - - if (m.isGenerateAOT()) { - CodeExecutableElement prepareAot = new CodeExecutableElement(MOD_ABSTRACT, context.getType(void.class), "prepareForAOT"); - prepareAot.addParameter(new CodeVariableElement(opNodeImpl.asType(), "$this")); - prepareAot.addParameter(new CodeVariableElement(context.getType(short[].class), "$bc")); - prepareAot.addParameter(new CodeVariableElement(context.getType(Object[].class), "$consts")); - prepareAot.addParameter(new CodeVariableElement(new ArrayCodeTypeMirror(types.Node), "$children")); - prepareAot.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); - prepareAot.addParameter(new CodeVariableElement(types.RootNode, "root")); - baseClass.add(prepareAot); - } - - baseClass.add(createFormatConstant()); - baseClass.add(createExpectObject(m.getBoxingEliminatedTypes().size() > 0)); - baseClass.add(createSetResultBoxedImpl()); - for (TypeKind kind : m.getBoxingEliminatedTypes()) { - FrameKind frameKind = FrameKind.valueOfPrimitive(kind); - baseClass.add(createExpectPrimitive(frameKind)); - // baseClass.add(createStoreLocalCheck(frameKind)); - } - - return baseClass; - } - - private CodeTypeElement createLabelFill(CodeTypeElement typLabelImpl) { - CodeTypeElement typ = GeneratorUtils.createClass(m, null, MOD_PRIVATE_STATIC_FINAL, "LabelFill", null); - typ.add(new CodeVariableElement(context.getType(int.class), "locationBci")); - typ.add(new CodeVariableElement(typLabelImpl.asType(), "label")); - - typ.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typ)); - - CodeExecutableElement metOffset = typ.add(new CodeExecutableElement(typ.asType(), "offset")); - metOffset.addParameter(new CodeVariableElement(context.getType(int.class), "offset")); - - metOffset.createBuilder().statement("return new LabelFill(offset + locationBci, label)"); - - return typ; - } - - private CodeTypeElement createFinallyTryContext(CodeTypeElement typFtc, CodeTypeElement typExceptionHandler, CodeTypeElement typLabelFill, CodeTypeElement typLabelImpl) { - typFtc.add(new CodeVariableElement(MOD_FINAL, typFtc.asType(), "prev")); - typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(short[].class), "bc")); - typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typExceptionHandler.asType()), "exceptionHandlers")); - typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typLabelFill.asType()), "labelFills")); - typFtc.add(new CodeVariableElement(MOD_FINAL, generic(ArrayList.class, typLabelImpl.asType()), "labels")); - typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "curStack")); - typFtc.add(new CodeVariableElement(MOD_FINAL, context.getType(int.class), "maxStack")); - - typFtc.add(GeneratorUtils.createConstructorUsingFields(Set.of(), typFtc)); - - typFtc.add(new CodeVariableElement(Set.of(), context.getType(short[].class), "handlerBc")); - typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, typExceptionHandler.asType()), "handlerHandlers")); - typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, typLabelFill.asType()), "handlerLabelFills = new ArrayList<>()")); - typFtc.add(new CodeVariableElement(Set.of(), generic(ArrayList.class, context.getType(Integer.class)), "relocationOffsets = new ArrayList<>()")); - typFtc.add(new CodeVariableElement(Set.of(), context.getType(int.class), "handlerMaxStack")); - - return typFtc; - } - - private CodeExecutableElement createDoLeaveFinallyTry(CodeTypeElement typOperationData) { - CodeExecutableElement mDoLeaveFinallyTry = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doLeaveFinallyTry", - new CodeVariableElement(typOperationData.asType(), "opData")); - - CodeTreeBuilder b = mDoLeaveFinallyTry.createBuilder(); - b.statement("BuilderFinallyTryContext context = (BuilderFinallyTryContext) opData.aux[0]"); - - b.startIf().string("context.handlerBc == null").end().startBlock().returnStatement().end(); - - b.statement("System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length)"); - - b.startFor().string("int offset : context.relocationOffsets").end().startBlock(); - b.statement("short oldOffset = bc[bci + offset]"); - b.statement("bc[bci + offset] = (short) (oldOffset + bci)"); - b.end(); - - b.startFor().string("ExceptionHandler handler : context.handlerHandlers").end().startBlock(); - b.statement("exceptionHandlers.add(handler.offset(bci, curStack))"); - b.end(); - - b.startFor().string("LabelFill fill : context.handlerLabelFills").end().startBlock(); - b.statement("labelFills.add(fill.offset(bci))"); - b.end(); - - b.startIf().string("maxStack < curStack + context.handlerMaxStack").end(); - b.statement("maxStack = curStack + context.handlerMaxStack"); - b.end(); - - b.statement("bci += context.handlerBc.length"); - - return mDoLeaveFinallyTry; - } - - private CodeExecutableElement createSetMetadata(OperationMetadataData metadata, boolean isAbstract) { - CodeVariableElement parValue = new CodeVariableElement(metadata.getType(), "value"); - CodeExecutableElement method = new CodeExecutableElement( - isAbstract ? MOD_PUBLIC_ABSTRACT : MOD_PUBLIC, - context.getType(void.class), "set" + metadata.getName(), - parValue); - - if (isAbstract) { - return method; - } - - CodeTreeBuilder b = method.createBuilder(); - - b.startIf().string("isSerializing").end().startBlock(); - serializationWrapException(b, () -> { - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_METADATA + ")"); - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short(" + m.getMetadatas().indexOf(metadata) + ")"); - b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, value)"); - b.returnStatement(); - }); - b.end(); - - b.startAssign("metadata_" + metadata.getName()).variable(parValue).end(); - - return method; - } - - private CodeExecutableElement createEmitOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeVariableElement resVariable = op.getResultVariable(); - CodeExecutableElement metEmit = new CodeExecutableElement(MOD_PUBLIC_FINAL, resVariable == null ? context.getType(void.class) : resVariable.asType(), "emit" + op.name); - - createBeginArguments(op, metEmit); - - CodeTreeBuilder b = metEmit.getBuilder(); - - createBeginOperationSerialize(vars, op, b); - - if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + ")\")"); - } - - String condition = op.conditionedOn(); - if (condition != null) { - b.startIf().string(condition).end().startBlock(); - } - - if (op.isRealOperation()) { - b.statement("doBeforeChild()"); - } - - boolean needsData = op.needsOperationData(); - - if (needsData) { - b.startAssign(vars.operationData); - b.startNew("BuilderOperationData"); - - b.variable(vars.operationData); - b.variable(op.idConstantField); - b.string("curStack"); - b.string("" + op.getNumAuxValues()); - b.string("false"); - - if (metEmit.getParameters().size() == 1 && metEmit.getParameters().get(0).asType().getKind() == TypeKind.ARRAY) { - b.startGroup().cast(context.getType(Object.class)).variable(metEmit.getParameters().get(0)).end(); - } else { - for (VariableElement v : metEmit.getParameters()) { - b.variable(v); - } - } - b.end(2); - } - - b.tree(op.createBeginCode(vars)); - b.tree(op.createEndCode(vars)); - - b.startAssign(vars.lastChildPushCount).tree(op.createPushCountCode(vars)).end(); - - if (needsData) { - b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); - } - - if (op.isRealOperation()) { - b.statement("doAfterChild()"); - } - - if (condition != null) { - b.end(); - } - - if (resVariable != null) { - b.startReturn().variable(resVariable).end(); - } - - return metEmit; - } - - private void createBeginArguments(Operation op, CodeExecutableElement metEmit) { - int i = 0; - for (TypeMirror mir : op.getBuilderArgumentTypes()) { - metEmit.addParameter(new CodeVariableElement(mir, "arg" + i)); - i++; - } - } - - private CodeTypeElement createCounter() { - CodeTypeElement typ = new CodeTypeElement(MOD_PRIVATE_STATIC_FINAL, ElementKind.CLASS, null, "Counter"); - typ.add(new CodeVariableElement(context.getType(int.class), "count")); - - return typ; - } - - private CodeExecutableElement createEndOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeVariableElement resultVar = op.getResultVariable(); - CodeExecutableElement metEnd = new CodeExecutableElement(MOD_PUBLIC_FINAL, resultVar == null ? context.getType(void.class) : resultVar.getType(), "end" + op.name); - GeneratorUtils.addSuppressWarnings(context, metEnd, "unused"); - - // if (operationData.id != ID) throw; - // << end >> - - // operationData = operationData.parent; - - // doAfterChild(); - CodeTreeBuilder b = metEnd.getBuilder(); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - b.startIf().string("isSerializing").end().startBlock(); - serializationWrapException(b, () -> { - b.startStatement().string("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((").variable(op.idConstantField).string(" << 1) | 1))").end(); - }); - if (op.isRoot()) { - b.startReturn().string("publish(null)").end(); - } else { - b.returnStatement(); - } - b.end(); - } - - String condition = op.conditionedOn(); - if (condition != null) { - b.startIf().string(condition).end().startBlock(); - } - - if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\")\")"); - b.statement("indent--"); - } - - b.startIf().string("operationData.operationId != ").variable(op.idConstantField).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote("Mismatched begin/end, expected end").string( - " + OPERATION_NAMES[operationData.operationId] + ").doubleQuote(", got end" + op.name).end(3); - b.end(); - - vars.numChildren = new CodeVariableElement(context.getType(int.class), "numChildren"); - b.declaration("int", "numChildren", "operationData.numChildren"); - - if (!op.isVariableChildren()) { - b.startIf().string("numChildren != " + op.children).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote(op.name + " expected " + op.children + " children, got ").string(" + numChildren").end(3); - b.end(); - } else { - b.startIf().string("numChildren < " + op.minimumChildren()).end(); - b.startBlock(); - b.startThrow().startNew(context.getType(IllegalStateException.class)).startGroup().doubleQuote(op.name + " expected at least " + op.minimumChildren() + " children, got ").string( - " + numChildren").end(3); - b.end(); - } - - b.tree(op.createEndCode(vars)); - - CodeTree lastPush = op.createPushCountCode(vars); - if (lastPush != null) { - b.startAssign(vars.lastChildPushCount).tree(lastPush).end(); - } - - if (op.needsOperationData()) { - b.startAssign(vars.operationData).variable(vars.operationData).string(".parent").end(); - } - - if (op.isRealOperation() && !op.isRoot()) { - b.statement("doAfterChild()"); - } - - if (condition != null) { - b.end(); - } - - vars.numChildren = null; - - if (resultVar != null) { - b.startReturn().variable(resultVar).end(); - } - - return metEnd; - } - - private CodeExecutableElement createBeginOperation(CodeTypeElement typBuilder, BuilderVariables vars, Operation op) { - CodeExecutableElement metBegin = new CodeExecutableElement(MOD_PUBLIC_FINAL, context.getType(void.class), "begin" + op.name); - GeneratorUtils.addSuppressWarnings(context, metBegin, "unused"); - - createBeginArguments(op, metBegin); - - // doBeforeChild(); - - // operationData = new ...(operationData, ID, , args...); - - // << begin >> - - CodeTreeBuilder b = metBegin.getBuilder(); - - createBeginOperationSerialize(vars, op, b); - - String condition = op.conditionedOn(); - if (condition != null) { - b.startIf().string(condition).end().startBlock(); - } - - if (OperationGeneratorFlags.FLAG_NODE_AST_PRINTING) { - b.statement("System.out.print(\"\\n\" + \" \".repeat(indent) + \"(" + op.name + "\")"); - b.statement("indent++"); - } - - if (op.isRealOperation() && !op.isRoot()) { - b.statement("doBeforeChild()"); - } - - if (op.needsOperationData()) { - b.startAssign(vars.operationData).startNew("BuilderOperationData"); - - b.variable(vars.operationData); - b.variable(op.idConstantField); - b.string("curStack"); - b.string("" + op.getNumAuxValues()); - b.string("" + op.hasLeaveCode()); - - for (VariableElement el : metBegin.getParameters()) { - b.startGroup().cast(context.getType(Object.class)).variable(el).end(); - } - - b.end(2); - } - - b.tree(op.createBeginCode(vars)); - - if (condition != null) { - b.end(); - } - - return metBegin; - } - - private void createBeginOperationSerialize(BuilderVariables vars, Operation op, CodeTreeBuilder b) { - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - b.startIf().string("isSerializing").end().startBlock(); - - serializationWrapException(b, () -> { - ArrayList after = new ArrayList<>(); - - int i = 0; - for (TypeMirror argType : op.getBuilderArgumentTypes()) { - // ARGUMENT SERIALIZATION - if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) { - // nothing - } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) { - after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationLocalImpl) arg" + i + ").id)"); - } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) { - after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) arg" + i + ".length)"); - after.add("for (int i = 0; i < arg" + i + ".length; i++) { serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationLocalImpl) arg" + i + "[i]).id); }"); - } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) { - after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) ((OperationSerLabelImpl) arg" + i + ").id)"); - } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) { - after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Int(arg" + i + ")"); - } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source) || ElementUtils.typeEquals(argType, context.getType(Class.class))) { - String index = "arg" + i + "_index"; - b.startAssign("int " + index).variable(vars.consts).startCall(".indexOf").string("arg" + i).end(2); - b.startIf().string(index + " == -1").end().startBlock(); - b.startAssign(index).variable(vars.consts).startCall(".size").end(2); - b.startStatement().variable(vars.consts).startCall(".add").string("arg" + i).end(2); - b.statement("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) " + SER_CODE_CREATE_OBJECT + ")"); - b.statement("serCallback.serialize(SER_CONTEXT, serBuffer, arg" + i + ")"); - b.end(); - after.add("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) arg" + i + "_index)"); - } else { - throw new UnsupportedOperationException("cannot serialize: " + argType); - } - i++; - } - - b.startStatement().string("serBuffer." + DATA_WRITE_METHOD_PREFIX + "Short((short) (").variable(op.idConstantField).string(" << 1))").end(); - - after.forEach(b::statement); - }); - - b.returnStatement(); - b.end(); - } - } - - private CodeExecutableElement createSetResultUnboxed() { - CodeExecutableElement mDoSetResultUnboxed = new CodeExecutableElement(MOD_PRIVATE_STATIC, context.getType(void.class), "doSetResultBoxed"); - - CodeVariableElement varBc = new CodeVariableElement(arrayOf(context.getType(short.class)), "bc"); - mDoSetResultUnboxed.addParameter(varBc); - - CodeVariableElement varStartBci = new CodeVariableElement(context.getType(int.class), "startBci"); - mDoSetResultUnboxed.addParameter(varStartBci); - - CodeVariableElement varBciOffset = new CodeVariableElement(context.getType(int.class), "bciOffset"); - mDoSetResultUnboxed.addParameter(varBciOffset); - - CodeVariableElement varTargetType = new CodeVariableElement(context.getType(int.class), "targetType"); - mDoSetResultUnboxed.addParameter(varTargetType); - - CodeTreeBuilder b = mDoSetResultUnboxed.createBuilder(); - - b.startIf().variable(varBciOffset).string(" != 0").end().startBlock(); - // { - b.startStatement().startCall("setResultBoxedImpl"); - b.variable(varBc); - b.string("startBci - bciOffset"); - b.variable(varTargetType); - b.end(2); - // } - b.end(); - return mDoSetResultUnboxed; - } - - private CodeExecutableElement createBuilderImplPublish(CodeTypeElement typOperationNodeImpl) { - CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PRIVATE, m.getTemplateType().asType(), "publish"); - - CodeVariableElement parLanguage = new CodeVariableElement(types.TruffleLanguage, "language"); - mPublish.addParameter(parLanguage); - - CodeTreeBuilder b = mPublish.createBuilder(); - - if (OperationGeneratorFlags.ENABLE_SERIALIZATION) { - b.startIf().string("isSerializing").end().startBlock(); - b.declaration(m.getTemplateType().getSimpleName().toString(), "result", "new OperationSerNodeImpl(null, FrameDescriptor.newBuilder().build(), buildIndex++)"); - b.statement("numLocals = 0"); - b.statement("numLabels = 0"); - b.statement("return result"); - b.end(); - } - - b.startIf().string("operationData.depth != 0").end().startBlock(); - b.startThrow().startNew(context.getType(UnsupportedOperationException.class)).doubleQuote("Not all operations closed").end(2); - b.end(); - - b.declaration(typOperationNodeImpl.asType(), "result", (CodeTree) null); - - b.startIf().string("!isReparse").end().startBlock(); - - b.declaration(types.FrameDescriptor, ".Builder frameDescriptor", (CodeTree) null); - b.startAssign("frameDescriptor").startStaticCall(types.FrameDescriptor, "newBuilder").string("numLocals + maxStack").end(2); - b.startStatement().startCall("frameDescriptor.addSlots").string("numLocals + maxStack").staticReference(types.FrameSlotKind, "Illegal").end(2); - - b.startAssign("result").startNew(typOperationNodeImpl.asType()).variable(parLanguage).string("frameDescriptor").end(2); - b.startAssign("result.nodes").string("nodes").end(); - - b.statement("labelPass(null)"); - b.statement("result._bc = Arrays.copyOf(bc, bci)"); - b.statement("result._consts = constPool.toArray()"); - b.statement("result._children = new Node[numChildNodes]"); - if (m.getOperationsContext().hasBoxingElimination()) { - b.statement("result._localTags = new byte[numLocals]"); - } - if (m.isTracing()) { - b.statement("result.isBbStart = Arrays.copyOf(isBbStart, bci)"); - } - b.statement("result._handlers = exceptionHandlers.toArray(new ExceptionHandler[0])"); - b.statement("result._conditionProfiles = new int[numConditionProfiles]"); - b.statement("result._maxLocals = numLocals"); - b.statement("result._maxStack = maxStack"); - - if (m.enableYield) { - b.statement("result.yieldEntries = yieldCount > 0 ? new ContinuationRoot[yieldCount] : null"); - b.startFor().string("int i = 0; i < yieldCount; i++").end().startBlock(); - b.statement("yieldLocations[i].root = result"); - b.end(); - } - - b.startIf().string("sourceBuilder != null").end().startBlock(); - b.statement("result.sourceInfo = sourceBuilder.build()"); - b.end(); - - for (OperationMetadataData metadata : m.getMetadatas()) { - b.statement("result._metadata_" + metadata.getName() + " = metadata_" + metadata.getName()); - } - - b.statement("assert builtNodes.size() == buildIndex"); - b.statement("builtNodes.add(result)"); - - b.end().startElseBlock(); - - b.statement("result = builtNodes.get(buildIndex)"); - - b.startIf().string("withSource && result.sourceInfo == null").end().startBlock(); - b.statement("result.sourceInfo = sourceBuilder.build()"); - b.end(); - - // todo instrumentation - - b.end(); - - b.statement("buildIndex++"); - b.statement("reset(language)"); - - b.statement("return result"); - - return mPublish; - } - - private CodeExecutableElement createBuilderImplLabelPass(CodeTypeElement typFtc) { - CodeExecutableElement mPublish = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "labelPass"); - mPublish.addParameter(new CodeVariableElement(typFtc.asType(), "finallyTry")); - - CodeTreeBuilder b = mPublish.createBuilder(); - - b.startFor().string("LabelFill fill : labelFills").end().startBlock(); // { - b.startIf().string("finallyTry != null").end().startBlock(); // { - b.startIf().string("fill.label.belongsTo(finallyTry)").end().startBlock(); // { - - b.statement("assert fill.label.hasValue : \"inner label should have been resolved by now\""); - b.statement("finallyTry.relocationOffsets.add(fill.locationBci)"); - - b.end().startElseBlock(); // } { - - b.statement("finallyTry.handlerLabelFills.add(fill)"); - - b.end(); // } - b.end(); // } - - b.statement("bc[fill.locationBci] = (short) fill.label.targetBci"); - - b.end(); // } - - return mPublish; - - } - - private CodeExecutableElement createAfterChild(BuilderVariables vars) { - CodeExecutableElement mAfterChild = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doAfterChild"); - CodeTreeBuilder b = mAfterChild.getBuilder(); - GeneratorUtils.addSuppressWarnings(context, mAfterChild, "unused"); - - CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "operationData.numChildren++"); - - vars.childIndex = varChildIndex; - - b.startSwitch().variable(vars.operationData).string(".operationId").end(2); - b.startBlock(); - - for (Operation parentOp : m.getOperations()) { - - CodeTree afterChild = parentOp.createAfterChildCode(vars); - if (afterChild == null) { - continue; - } - - b.startCase().variable(parentOp.idConstantField).end(); - b.startBlock(); - - b.tree(afterChild); - - b.statement("break"); - b.end(); - } - - b.end(); - - vars.childIndex = null; - return mAfterChild; - } - - private CodeExecutableElement createBeforeChild(BuilderVariables vars) { - CodeExecutableElement mBeforeChild = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doBeforeChild"); - CodeTreeBuilder b = mBeforeChild.getBuilder(); - GeneratorUtils.addSuppressWarnings(context, mBeforeChild, "unused"); - - CodeVariableElement varChildIndex = new CodeVariableElement(context.getType(int.class), "childIndex"); - b.declaration("int", varChildIndex.getName(), "operationData.numChildren"); - - vars.childIndex = varChildIndex; - - b.startSwitch().variable(vars.operationData).string(".operationId").end(2); - b.startBlock(); - - for (Operation parentOp : m.getOperations()) { - - CodeTree afterChild = parentOp.createBeforeChildCode(vars); - if (afterChild == null) { - continue; - } - - b.startCase().variable(parentOp.idConstantField).end(); - b.startBlock(); - - b.tree(afterChild); - - b.statement("break"); - b.end(); - } - - b.end(); - - vars.childIndex = null; - - return mBeforeChild; - } - - private CodeExecutableElement createDoLeave(BuilderVariables vars, CodeTypeElement typOperationData) { - CodeVariableElement parData = new CodeVariableElement(typOperationData.asType(), "data"); - CodeExecutableElement mDoLeave = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "doLeaveOperation", parData); - - CodeTreeBuilder b = mDoLeave.createBuilder(); - - b.startSwitch().string("data.operationId").end(); - b.startBlock(); - - CodeVariableElement oldOperationData = vars.operationData; - - vars.operationData = parData; - - for (Operation op : m.getOperations()) { - CodeTree leaveCode = op.createLeaveCode(vars); - if (leaveCode == null) { - continue; - } - - b.startCase().variable(op.idConstantField).end(); - b.startBlock(); - - b.tree(leaveCode); - b.statement("break"); - - b.end(); - - } - - vars.operationData = oldOperationData; - - b.end(); - - return mDoLeave; - } - - private static TypeMirror arrayOf(TypeMirror el) { - return new ArrayCodeTypeMirror(el); - } - - private static TypeMirror operationParser(TypeMirror el) { - return new DeclaredCodeTypeMirror(ProcessorContext.getInstance().getTypeElement("com.oracle.truffle.api.operation.OperationParser"), List.of(el)); - } - - private static TypeMirror generic(TypeElement el, TypeMirror... args) { - return new DeclaredCodeTypeMirror(el, List.of(args)); - } - - private static TypeMirror generic(DeclaredType el, TypeMirror... args) { - return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args)); - } - - private static TypeMirror generic(Class cls, TypeMirror... args) { - return generic(ProcessorContext.getInstance().getTypeElement(cls), args); - } - - @Override - @SuppressWarnings("hiding") - public List create(ProcessorContext context, AnnotationProcessor processor, OperationsData m) { - this.context = context; - this.m = m; - - String simpleName = m.getTemplateType().getSimpleName() + "Gen"; - - try { - CodeTypeElement el = createOperationNodeImpl(); - OperationGeneratorUtils.checkAccessibility(el); - return List.of(el); - - } catch (Throwable e) { - CodeTypeElement el = GeneratorUtils.createClass(m, null, Set.of(), simpleName, null); - CodeTreeBuilder b = el.createDocBuilder(); - - StringWriter sb = new StringWriter(); - e.printStackTrace(new PrintWriter(sb)); - for (String line : sb.toString().split("\n")) { - b.string("// " + line).newLine(); - } - - return List.of(el); - } - } - - // -------------------------- helper methods moved to generated code -------------------------- - - private CodeExecutableElement createExpectObject(boolean hasAnyBoxingElimination) { - CodeExecutableElement mExpectObject = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(Object.class), "expectObject"); - mExpectObject.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); - - if (hasAnyBoxingElimination) { - mExpectObject.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - mExpectObject.addParameter(new CodeVariableElement(context.getType(int.class), "bciOffset")); - } - - CodeTreeBuilder b = mExpectObject.createBuilder(); - - if (hasAnyBoxingElimination) { - b.startIf().string("bciOffset == 0 || UFA.unsafeIsObject(frame, slot)").end().startBlock(); - } - - b.startReturn().string("UFA.unsafeUncheckedGetObject(frame, slot)").end(); - - if (hasAnyBoxingElimination) { - b.end().startElseBlock(); // } else { - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string("0").end(2); - b.startReturn().string("frame.getValue(slot)").end(); - - b.end(); // } - } - - return mExpectObject; - } - - private CodeExecutableElement createExpectPrimitive(FrameKind kind) { - CodeExecutableElement mExpectPrimitive = new CodeExecutableElement(MOD_PROTECTED_STATIC, kind.getType(), "expect" + kind.getFrameName()); - mExpectPrimitive.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); - mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - mExpectPrimitive.addParameter(new CodeVariableElement(context.getType(int.class), "bciOffset")); - - mExpectPrimitive.addThrownType(types.UnexpectedResultException); - - CodeTreeBuilder b = mExpectPrimitive.createBuilder(); - - if (OperationGeneratorFlags.LOG_STACK_READS) { - b.statement("System.err.println(\"[ SRD ] stack read @ \" + slot + \" : \" + frame.getValue(slot) + \" as \" + frame.getTag(slot))"); - } - - b.startIf().string("bciOffset == 0").end().startBlock(); - - b.startAssign("Object value").startCall("UFA", "unsafeUncheckedGetObject"); - b.string("frame"); - b.string("slot"); - b.end(2); - - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - b.startReturn().string("(", kind.getTypeName(), ") value").end(); - b.end().startElseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startThrow().startNew(types.UnexpectedResultException).string("value").end(2); - b.end(); - - b.end().startElseBlock(); - - b.startSwitch().startCall("UFA", "unsafeGetTag").string("frame").string("slot").end(2).startBlock(); - - b.startCase().string(kind.toOrdinal()).end().startCaseBlock(); - b.startReturn().startCall("UFA", "unsafeUncheckedGet" + kind.getFrameName()).string("frame").string("slot").end(2); - b.end(); - - b.startCase().string(FrameKind.OBJECT.toOrdinal()).end().startCaseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.declaration("Object", "value", "UFA.unsafeUncheckedGetObject(frame, slot)"); - - b.startIf().string("value instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string(kind.toOrdinal()).end(2); - b.startReturn().string("(", kind.getTypeName(), ") value").end(); - b.end(); // if - - b.statement("break"); - b.end(); // case - - b.end(); // switch - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - - b.startStatement().startCall("setResultBoxedImpl").string("bc").string("bci - bciOffset").string("0").end(2); - b.startThrow().startNew(types.UnexpectedResultException).string("frame.getValue(slot)").end(2); - - b.end(); // else - - return mExpectPrimitive; - } - - private CodeExecutableElement createStoreLocalCheck(FrameKind kind) { - CodeExecutableElement mStoreLocalCheck = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(boolean.class), "storeLocal" + kind.getFrameName() + "Check"); - - mStoreLocalCheck.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - mStoreLocalCheck.addParameter(new CodeVariableElement(context.getType(int.class), "localSlot")); - mStoreLocalCheck.addParameter(new CodeVariableElement(context.getType(int.class), "stackSlot")); - - CodeTreeBuilder b = mStoreLocalCheck.createBuilder(); - - b.declaration(types.FrameDescriptor, "descriptor", "frame.getFrameDescriptor()"); - - b.startIf().string("descriptor.getSlotKind(localSlot) == ").staticReference(types.FrameSlotKind, kind.getFrameName()).end().startBlock(); - b.startTryBlock(); - b.statement("frame.set" + kind.getFrameName() + "(localSlot, expect" + kind.getFrameName() + "(frame, stackSlot))"); - b.returnTrue(); - b.end().startCatchBlock(types.UnexpectedResultException, "ex").end(); - b.end(); - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.statement("descriptor.setSlotKind(localSlot, FrameSlotKind.Object)"); - b.statement("frame.setObject(localSlot, frame.getValue(stackSlot))"); - b.returnFalse(); - - return mStoreLocalCheck; - } - - private CodeExecutableElement createFormatConstant() { - CodeExecutableElement mFormatConstant = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(String.class), "formatConstant"); - - mFormatConstant.addParameter(new CodeVariableElement(context.getType(Object.class), "obj")); - - CodeTreeBuilder b = mFormatConstant.createBuilder(); - - b.startIf().string("obj == null").end().startBlock(); - b.startReturn().doubleQuote("null").end(); - b.end().startElseBlock(); - b.declaration("Object", "repr", "obj"); - - b.startIf().string("obj instanceof Object[]").end().startBlock(); - b.startAssign("repr").startStaticCall(context.getType(Arrays.class), "deepToString").string("(Object[]) obj").end(2); - b.end(); - - b.startReturn().startStaticCall(context.getType(String.class), "format"); - b.doubleQuote("%s %s"); - b.string("obj.getClass().getSimpleName()"); - b.string("repr"); - b.end(2); - - b.end(); - - return mFormatConstant; - } - - private CodeExecutableElement createSetResultBoxedImpl() { - CodeExecutableElement mSetResultBoxedImpl = new CodeExecutableElement(MOD_PROTECTED_STATIC, context.getType(void.class), "setResultBoxedImpl"); - mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); - mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "bci")); - mSetResultBoxedImpl.addParameter(new CodeVariableElement(context.getType(int.class), "targetType")); - - CodeTreeBuilder b = mSetResultBoxedImpl.createBuilder(); - - int mask = (0xffff << OperationGeneratorFlags.BOXING_ELIM_BITS) & 0xffff; - b.statement("bc[bci] = (short) (targetType | (bc[bci] & " + String.format("0x%x", mask) + "))"); - - return mSetResultBoxedImpl; - } - - // ---------------------- builder static code ----------------- - - private CodeExecutableElement createBuilderImplCtor(CodeTypeElement opNodesImpl) { - CodeExecutableElement ctor = new CodeExecutableElement(MOD_PRIVATE, null, OPERATION_BUILDER_IMPL_NAME); - ctor.addParameter(new CodeVariableElement(opNodesImpl.asType(), "nodes")); - ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "isReparse")); - ctor.addParameter(new CodeVariableElement(types.OperationConfig, "config")); - - CodeTreeBuilder b = ctor.createBuilder(); - - b.statement("this.nodes = nodes"); - b.statement("this.isReparse = isReparse"); - b.statement("builtNodes = new ArrayList<>()"); - - b.startIf().string("isReparse").end().startBlock(); - b.statement("builtNodes.addAll((java.util.Collection) nodes.getNodes())"); - b.end(); - - b.statement("this.withSource = config.isWithSource()"); - b.statement("this.withInstrumentation = config.isWithInstrumentation()"); - - b.statement("this.sourceBuilder = withSource ? new SourceInfoBuilder(new ArrayList<>()) : null"); - - return ctor; - } - - private CodeExecutableElement createBuilderImplFinish() { - CodeExecutableElement mFinish = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "finish"); - - CodeTreeBuilder b = mFinish.createBuilder(); - - b.startIf().string("withSource").end().startBlock(); - b.statement("nodes.setSources(sourceBuilder.buildSource())"); - b.end(); - - b.startIf().string("!isReparse").end().startBlock(); - b.statement("nodes.setNodes(builtNodes.toArray(new " + m.getTemplateType().getSimpleName() + "[0]))"); - b.end(); - - return mFinish; - } - - private CodeExecutableElement createBuilderImplReset() { - CodeExecutableElement mReset = new CodeExecutableElement(MOD_PRIVATE, context.getType(void.class), "reset"); - mReset.addParameter(new CodeVariableElement(types.TruffleLanguage, "language")); - - CodeTreeBuilder b = mReset.createBuilder(); - - b.statement("bci = 0"); - b.statement("curStack = 0"); - b.statement("maxStack = 0"); - b.statement("numLocals = 0"); - b.statement("constPool.clear()"); - b.statement("operationData = new BuilderOperationData(null, OP_ROOT, 0, 0, false, language)"); - b.statement("labelFills.clear()"); - b.statement("numChildNodes = 0"); - b.statement("numConditionProfiles = 0"); - b.statement("exceptionHandlers.clear()"); - b.statement("Arrays.fill(instructionHistory, -1)"); - b.statement("instructionHistoryIndex = 0"); - - b.startIf().string("sourceBuilder != null").end().startBlock(); - b.statement("sourceBuilder = new SourceInfoBuilder(sourceBuilder.sourceList)"); - b.end(); - - if (m.enableYield) { - b.statement("yieldCount = 0"); - } - - if (OperationGeneratorFlags.ENABLE_INSTRUMENTATION) { - b.statement("numInstrumentNodes = 0"); - } - - for (OperationMetadataData metadata : m.getMetadatas()) { - b.startAssign("metadata_" + metadata.getName()).string("null").end(); - } - - return mReset; - } - - private CodeExecutableElement createBuilderImplDoBeforeEmitInstruction() { - CodeExecutableElement mDoBeforeEmitInstruction = new CodeExecutableElement(MOD_PRIVATE, context.getType(int[].class), "doBeforeEmitInstruction"); - mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(int.class), "numPops")); - mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(boolean.class), "pushValue")); - mDoBeforeEmitInstruction.addParameter(new CodeVariableElement(context.getType(boolean.class), "doBoxing")); - - CodeTreeBuilder b = mDoBeforeEmitInstruction.createBuilder(); - - b.statement("int[] result = new int[numPops]"); - - b.startFor().string("int i = numPops - 1; i >= 0; i--").end().startBlock(); - b.statement("curStack--"); - b.statement("int predBci = stackSourceBci[curStack]"); - b.statement("result[i] = predBci"); - b.end(); - - b.startIf().string("pushValue").end().startBlock(); - - b.startIf().string("curStack >= stackSourceBci.length").end().startBlock(); - b.statement("stackSourceBci = Arrays.copyOf(stackSourceBci, stackSourceBci.length * 2)"); - b.end(); - - b.statement("stackSourceBci[curStack] = doBoxing ? bci : -65535"); - b.statement("curStack++"); - b.startIf().string("curStack > maxStack").end().startBlock(); - b.statement("maxStack = curStack"); - b.end(); - - b.end(); - - b.startReturn().string("result").end(); - - return mDoBeforeEmitInstruction; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java deleted file mode 100644 index c01b2378c64e..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsContext.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.operations.Operation.ShortCircuitOperation; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; -import com.oracle.truffle.dsl.processor.operations.instructions.BranchInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ConditionalBranchInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.DiscardInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; -import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationEnterInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationExitInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.InstrumentationLeaveInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadArgumentInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadConstantInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.LoadLocalMaterializedInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.QuickenedInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ReturnInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ShortCircuitInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.StoreLocalMaterializedInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.SuperInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.ThrowInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.YieldInstruction; - -public class OperationsContext { - - private int instructionId = 1; - private int operationId = 1; - - public Instruction commonPop; - public Instruction commonBranch; - public Instruction commonBranchFalse; - public Instruction commonThrow; - - public LoadLocalInstruction loadLocalUnboxed; - public LoadLocalInstruction loadLocalBoxed; - - public LoadArgumentInstruction[] loadArgumentInstructions; - public LoadConstantInstruction[] loadConstantInstructions; - - public final ArrayList instructions = new ArrayList<>(); - public final ArrayList operations = new ArrayList<>(); - private final Map instructionNameMap = new HashMap<>(); - private final Map customInstructionNameMap = new HashMap<>(); - private final Map opDataNameMap = new HashMap<>(); - private final OperationsData data; - - public CodeTypeElement outerType; - - private final Set operationNames = new HashSet<>(); - public TypeMirror labelType; - public TypeMirror exceptionType; - - public OperationsContext(OperationsData data) { - this.data = data; - } - - public OperationsData getData() { - return data; - } - - public void initializeContext() { - createCommonInstructions(); - createBuiltinOperations(); - } - - private void createCommonInstructions() { - commonPop = add(new DiscardInstruction(this, "pop", instructionId++)); - commonBranch = add(new BranchInstruction(this, instructionId++)); - commonBranchFalse = add(new ConditionalBranchInstruction(this, instructionId++)); - commonThrow = add(new ThrowInstruction(this, instructionId++)); - } - - private void createBuiltinOperations() { - add(new Operation.Block(this, operationId++)); - add(new Operation.Root(this, operationId++)); - add(new Operation.IfThen(this, operationId++)); - add(new Operation.IfThenElse(this, operationId++, false)); - add(new Operation.IfThenElse(this, operationId++, true)); - add(new Operation.While(this, operationId++)); - add(new Operation.TryCatch(this, operationId++)); - add(new Operation.FinallyTry(this, operationId++, false)); - add(new Operation.FinallyTry(this, operationId++, true)); - - add(new Operation.Label(this, operationId++)); - add(new Operation.Simple(this, "Branch", operationId++, 0, commonBranch)); - - add(new Operation.Simple(this, "LoadConstant", operationId++, 0, add(new LoadConstantInstruction(this, instructionId++)))); - add(new Operation.Simple(this, "LoadArgument", operationId++, 0, add(new LoadArgumentInstruction(this, instructionId++)))); - loadLocalUnboxed = add(new LoadLocalInstruction(this, instructionId++, false)); - add(new Operation.Simple(this, "LoadLocal", operationId++, 0, loadLocalUnboxed)); - if (hasBoxingElimination()) { - loadLocalBoxed = add(new LoadLocalInstruction(this, instructionId++, true)); - } - add(new Operation.Simple(this, "StoreLocal", operationId++, 1, add(new StoreLocalInstruction(this, instructionId++)))); - add(new Operation.Simple(this, "Return", operationId++, 1, add(new ReturnInstruction(this, instructionId++)))); - - add(new Operation.LoadLocalMaterialized(this, operationId++, add(new LoadLocalMaterializedInstruction(this, instructionId++)))); - add(new Operation.StoreLocalMaterialized(this, operationId++, add(new StoreLocalMaterializedInstruction(this, instructionId++)))); - - if (data.enableYield) { - add(new Operation.Simple(this, "Yield", operationId++, 1, add(new YieldInstruction(this, instructionId++)))); - } - - add(new Operation.Source(this, operationId++)); - add(new Operation.SourceSection(this, operationId++)); - - add(new Operation.InstrumentTag(this, operationId++, - add(new InstrumentationEnterInstruction(this, instructionId++)), - add(new InstrumentationExitInstruction(this, instructionId++)), - add(new InstrumentationExitInstruction(this, instructionId++, true)), - add(new InstrumentationLeaveInstruction(this, instructionId++)))); - } - - public T add(T elem) { - instructions.add(elem); - instructionNameMap.put(elem.name, elem); - return elem; - } - - public T add(T elem) { - operations.add(elem); - operationNames.add(elem.name); - return elem; - } - - public int getNextInstructionId() { - return instructionId++; - } - - public int getNextOperationId() { - return operationId++; - } - - public void processOperation(SingleOperationData opData) { - - if (operationNames.contains(opData.getName())) { - opData.addError("Operation %s already defined", opData.getName()); - } - - MethodProperties props = opData.getMainProperties(); - - if (props == null) { - opData.addError("Operation %s not initialized", opData.getName()); - return; - } - - if (opData.isShortCircuit()) { - ShortCircuitInstruction instr = add(new ShortCircuitInstruction(this, "sc." + opData.getName(), getNextInstructionId(), opData)); - customInstructionNameMap.put(opData.getName(), instr); - opDataNameMap.put(opData.getName(), opData); - add(new ShortCircuitOperation(this, opData.getName(), getNextOperationId(), instr)); - } else { - - CustomInstruction instr = new CustomInstruction(this, "c." + opData.getName(), getNextInstructionId(), opData); - add(instr); - customInstructionNameMap.put(opData.getName(), instr); - opDataNameMap.put(opData.getName(), opData); - - int numChildren = props.isVariadic ? -1 : props.numStackValues; - - Operation.Simple op = new Operation.Simple(this, opData.getName(), getNextOperationId(), numChildren, instr); - add(op); - } - } - - public void processDecisions(OperationDecisions decisions) { - for (OperationDecisions.Quicken quicken : decisions.getQuicken()) { - CustomInstruction cinstr = customInstructionNameMap.get(quicken.getOperation()); - if (cinstr == null) { - // todo: better error reporting - data.addWarning("Invalid Quicken decision: undefined operation %s.", quicken.getOperation()); - continue; - } - if (cinstr instanceof ShortCircuitInstruction) { - // todo: make these work - continue; - } - - SingleOperationData opData = opDataNameMap.get(quicken.getOperation()); - - add(new QuickenedInstruction(this, cinstr, instructionId++, opData, List.of(quicken.specializations))); - } - - outer: for (OperationDecisions.SuperInstruction si : decisions.getSuperInstructions()) { - Instruction[] instrs = Arrays.stream(si.instructions).map(instructionNameMap::get).toArray(Instruction[]::new); - - int i = -1; - for (Instruction instr : instrs) { - i++; - if (instr == null) { - data.addWarning("Invalid SuperInstruction decision: undefined instruction %s. Rerun the corpus with tracing to regenerate decisions.", si.instructions[i]); - continue outer; - } - - if (instr.isVariadic()) { - data.addWarning("Invalid SuperInstruction decision: unsuported variadic instruction %s. Remove this decision.", si.instructions[i]); - continue outer; - } - - } - - add(new SuperInstruction(this, instructionId++, instrs)); - } - - for (OperationDecisions.CommonInstruction ci : decisions.getCommonInstructions()) { - Instruction instr = instructionNameMap.get(ci.instruction); - - if (instr == null) { - data.addWarning("Invalid CommonInstruction decision: undefined instruction %s. Rerun the corpus with tracing to regenerate decisions.", ci.instruction); - continue; - } - - instr.isCommon = true; - } - } - - public List getSuperInstructions() { - return instructions.stream().filter(x -> x instanceof SuperInstruction).map(x -> (SuperInstruction) x).collect(Collectors.toList()); - } - - public boolean hasBoxingElimination() { - return data.getBoxingEliminatedTypes().size() > 0; - } - - public List getPrimitiveBoxingKinds() { - return data.getBoxingEliminatedTypes().stream().sorted().map(FrameKind::valueOfPrimitive).collect(Collectors.toList()); - } - - public List getBoxingKinds() { - ArrayList result = new ArrayList<>(); - result.add(FrameKind.OBJECT); - result.addAll(getPrimitiveBoxingKinds()); - - return result; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java deleted file mode 100644 index d3d08d2971f0..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsData.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.model.MessageContainer; -import com.oracle.truffle.dsl.processor.model.Template; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.operations.instructions.Instruction; - -public class OperationsData extends Template { - - private final List operations = new ArrayList<>(); - private final List metadatas = new ArrayList<>(); - private final OperationsContext context = new OperationsContext(this); - - private boolean tracing; - private OperationDecisions decisions; - private String decisionsFilePath; - - private TypeSystemData typeSystem; - private final Set boxingEliminatedTypes = new HashSet<>(); - - private boolean isGenerateAOT; - private boolean isGenerateUncached; - - public DeclaredType languageClass; - - private int numTosSlots; - - public boolean enableYield; - - public ExecutableElement fdConstructor; - public ExecutableElement fdBuilderConstructor; - - public OperationsData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation) { - super(context, templateType, annotation); - } - - public OperationsContext getOperationsContext() { - return context; - } - - public int getNumTosSlots() { - return numTosSlots; - } - - public void addOperationData(SingleOperationData data) { - operations.add(data); - } - - @Override - protected List findChildContainers() { - ArrayList result = new ArrayList<>(); - result.addAll(operations); - result.addAll(metadatas); - - return result; - } - - public void setTracing(boolean tracing) { - this.tracing = tracing; - } - - public boolean isTracing() { - return tracing; - } - - public Collection getInstructions() { - return context.instructions; - } - - public Collection getOperationData() { - return operations; - } - - public List getMetadatas() { - return metadatas; - } - - public Collection getOperations() { - return context.operations; - } - - public void setTypeSystem(TypeSystemData typeSystem) { - this.typeSystem = typeSystem; - } - - public TypeSystemData getTypeSystem() { - return typeSystem; - } - - public void initializeContext() { - context.initializeContext(); - for (SingleOperationData data : operations) { - context.processOperation(data); - } - if (decisions != null) { - assert !tracing; - context.processDecisions(decisions); - } - } - - public boolean isGenerateAOT() { - return true; - } - - public void setGenerateUncached(boolean value) { - isGenerateUncached = true; - } - - public boolean isGenerateUncached() { - return isGenerateUncached; - } - - public void setDecisions(OperationDecisions decisions) { - this.decisions = decisions; - } - - public String getDecisionsFilePath() { - return this.decisionsFilePath; - } - - public void setDecisionsFilePath(String decisionsFilePath) { - this.decisionsFilePath = decisionsFilePath; - } - - public Set getBoxingEliminatedTypes() { - return boxingEliminatedTypes; - } - - static FrameKind convertToFrameType(TypeKind kind) { - switch (kind) { - case BYTE: - return FrameKind.BYTE; - case BOOLEAN: - return FrameKind.BOOLEAN; - case INT: - return FrameKind.INT; - case FLOAT: - return FrameKind.FLOAT; - case LONG: - return FrameKind.LONG; - case DOUBLE: - return FrameKind.DOUBLE; - default: - return FrameKind.OBJECT; - } - } - - public List getFrameKinds() { - List kinds = new ArrayList<>(); - kinds.add(FrameKind.OBJECT); - for (TypeKind beType : boxingEliminatedTypes) { - kinds.add(convertToFrameType(beType)); - } - - return kinds; - } - - public boolean isOptimized() { - return !isTracing() && getDecisionsFilePath() != null; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java deleted file mode 100644 index 05015ef222aa..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/OperationsParser.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.parser.AbstractParser; -import com.oracle.truffle.tools.utils.json.JSONArray; -import com.oracle.truffle.tools.utils.json.JSONTokener; - -public class OperationsParser extends AbstractParser { - - private static final Set UNBOXABLE_TYPE_KINDS = Set.of(TypeKind.BOOLEAN, TypeKind.BYTE, TypeKind.INT, TypeKind.FLOAT, TypeKind.LONG, TypeKind.DOUBLE); - - @SuppressWarnings("unchecked") - @Override - protected OperationsData parse(Element element, List mirror) { - - TypeElement typeElement = (TypeElement) element; - AnnotationMirror generateOperationsMirror = ElementUtils.findAnnotationMirror(mirror, types.GenerateOperations); - - OperationsData data = new OperationsData(ProcessorContext.getInstance(), typeElement, generateOperationsMirror); - - data.languageClass = (DeclaredType) ElementUtils.getAnnotationValue(generateOperationsMirror, "languageClass").getValue(); - data.enableYield = (boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "enableYield", true).getValue(); - - // check basic declaration properties - if (!typeElement.getModifiers().contains(Modifier.ABSTRACT)) { - data.addError(typeElement, "Operations class must be declared abstract."); - } - - if (!ElementUtils.isAssignable(typeElement.asType(), types.RootNode)) { - data.addError(typeElement, "Operations class must directly or indirectly subclass RootNode."); - } - - if (!ElementUtils.isAssignable(typeElement.asType(), types.OperationRootNode)) { - data.addError(typeElement, "Operations class must directly or indirectly implement OperationRootNode."); - } - - for (ExecutableElement ctor : ElementFilter.constructorsIn(typeElement.getEnclosedElements())) { - boolean isValid = ctor.getParameters().size() == 2; - - isValid = isValid && ElementUtils.isAssignable(ctor.getParameters().get(0).asType(), types.TruffleLanguage); - - isValid = isValid && (ctor.getModifiers().contains(Modifier.PUBLIC) || ctor.getModifiers().contains(Modifier.PROTECTED)); - - if (isValid) { - TypeMirror paramType2 = ctor.getParameters().get(1).asType(); - if (ElementUtils.isAssignable(paramType2, types.FrameDescriptor)) { - data.fdConstructor = ctor; - } else if (ElementUtils.isAssignable(paramType2, context.getDeclaredType(TruffleTypes.FrameDescriptor_Name + ".Builder"))) { - data.fdBuilderConstructor = ctor; - } else { - isValid = false; - } - } - - if (!isValid) { - data.addError(ctor, "Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder). Remove this constructor."); - } - } - - if (data.fdConstructor == null) { - data.addError(typeElement, "Operations class requires a (TruffleLanguage, FrameDescriptor) constructor."); - } - - if (data.hasErrors()) { - return data; - } - - // find all metadata - for (VariableElement ve : ElementFilter.fieldsIn(typeElement.getEnclosedElements())) { - if (ElementUtils.findAnnotationMirror(ve, types.GenerateOperations_Metadata) != null) { - OperationMetadataData metadataData = new OperationMetadataParser(data).parse(ve, false); - if (metadataData == null) { - data.addError(ve, "Could not parse metadata"); - } else { - data.getMetadatas().add(metadataData); - } - } - } - - // find @GenerateUncached - AnnotationMirror generateUncachedMirror = ElementUtils.findAnnotationMirror(typeElement, types.GenerateUncached); - if (generateUncachedMirror != null) { - data.setGenerateUncached(true); - } - - // find and bind type system - AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); - if (typeSystemRefMirror != null) { - TypeMirror typeSystemType = getAnnotationValue(TypeMirror.class, typeSystemRefMirror, "value"); - TypeSystemData typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true); - if (typeSystem == null) { - data.addError("The used type system '%s' is invalid. Fix errors in the type system first.", getQualifiedName(typeSystemType)); - return data; - } - - data.setTypeSystem(typeSystem); - } else { - data.setTypeSystem(new TypeSystemData(context, typeElement, null, true)); - } - - // find and bind boxing elimination types - List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); - for (AnnotationValue value : boxingEliminatedTypes) { - Set beTypes = data.getBoxingEliminatedTypes(); - TypeMirror mir; - if (value.getValue() instanceof Class) { - mir = context.getType((Class) value.getValue()); - } else if (value.getValue() instanceof TypeMirror) { - mir = (TypeMirror) value.getValue(); - } else { - throw new AssertionError(); - } - - if (UNBOXABLE_TYPE_KINDS.contains(mir.getKind())) { - beTypes.add(mir.getKind()); - } else { - data.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", - mir); - } - } - - List operationTypes = new ArrayList<>(ElementFilter.typesIn(typeElement.getEnclosedElements())); - List opProxies = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.OperationProxy); - - // find and bind all operation proxies - for (AnnotationMirror mir : opProxies) { - SingleOperationData opData = new SingleOperationParser(data, mir).parse(null, null); - - if (opData == null) { - data.addError(mir, ElementUtils.getAnnotationValue(mir, "value"), "Error generating operation. Fix issues on the referenced class first."); - continue; - } - - data.addOperationData(opData); - } - - // find and bind all inner declared operations - for (TypeElement inner : operationTypes) { - if (ElementUtils.findAnnotationMirror(inner, types.Operation) == null) { - continue; - } - - SingleOperationData opData = new SingleOperationParser(data).parse(inner, false); - - if (opData != null) { - data.addOperationData(opData); - } else { - data.addError("Error generating operation %s. Fix issues with the operation class fist.", inner.getSimpleName()); - } - - opData.redirectMessagesOnGeneratedElements(data); - } - - // find and bind all sc operations - List scOperations = ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.ShortCircuitOperation); - for (AnnotationMirror mir : scOperations) { - SingleOperationData opData = new SingleOperationParser(data, mir, true).parse(null, null); - if (opData == null) { - data.addError(mir, ElementUtils.getAnnotationValue(mir, "name"), "Error generating operation. Fix issues on the referenced boolean converter class first."); - continue; - } - - data.addOperationData(opData); - opData.setShortCircuitContinueWhen((boolean) ElementUtils.getAnnotationValue(mir, "continueWhen").getValue()); - } - - if (data.hasErrors()) { - return data; - } - - if (opProxies.isEmpty() && operationTypes.isEmpty()) { - data.addWarning("No operations found."); - } - - String decisionsFilePath = getMainDecisionsFilePath(typeElement, generateOperationsMirror); - data.setDecisionsFilePath(decisionsFilePath); - - AnnotationValue forceTracingValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true); - - boolean isTracing; - if ((boolean) forceTracingValue.getValue()) { - isTracing = true; - data.addWarning("Tracing compilation is forced. This should only be used during development."); - if (decisionsFilePath == null) { - data.addError("Tracing forced, but no decisions file specified. Specify the tracing decisions file."); - } - } else if (decisionsFilePath == null) { - // decisions file not specified, can't trace no matter the options - isTracing = false; - } else { - isTracing = TruffleProcessorOptions.operationsEnableTracing(processingEnv); - } - - if (!isTracing) { - OperationDecisions decisions = parseDecisions(typeElement, generateOperationsMirror, data); - data.setDecisions(decisions); - } - - data.setTracing(isTracing); - - if (data.hasErrors()) { - return data; - } - - data.initializeContext(); - - return data; - } - - private String getMainDecisionsFilePath(TypeElement element, AnnotationMirror generateOperationsMirror) { - String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); - if (file == null || file.isEmpty()) { - return null; - } - - return getDecisionsFile(element, file).getAbsolutePath(); - } - - private File getDecisionsFile(TypeElement element, String path) { - File file = CompilerFactory.getCompiler(element).getEnclosingSourceFile(processingEnv, element); - String parent = file.getParent(); - File target = new File(parent, path); - - return target; - } - - @SuppressWarnings("unchecked") - private OperationDecisions parseDecisions(TypeElement element, AnnotationMirror generateOperationsMirror, OperationsData data) { - String file = (String) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile").getValue(); - OperationDecisions mainDecisions; - - if (file == null || file.isEmpty()) { - mainDecisions = new OperationDecisions(); - } else { - mainDecisions = parseDecisions(element, file, data, true); - } - - if (mainDecisions == null) { - return null; - } - - List overrideFiles = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionOverrideFiles").getValue(); - - for (AnnotationValue overrideFile : overrideFiles) { - OperationDecisions overrideDecision = parseDecisions(element, (String) overrideFile.getValue(), data, false); - if (overrideDecision != null) { - mainDecisions.merge(overrideDecision, data); - } - } - - return mainDecisions; - } - - private OperationDecisions parseDecisions(TypeElement element, String path, OperationsData data, boolean isMain) { - File target = getDecisionsFile(element, path); - try { - FileInputStream fi = new FileInputStream(target); - JSONArray o = new JSONArray(new JSONTokener(fi)); - return OperationDecisions.deserialize(o, data); - } catch (FileNotFoundException ex) { - if (isMain) { - data.addError("Decisions file '%s' not found. Build & run with tracing to generate it.", path); - } else { - data.addError("Decisions file '%s' not found.", path); - } - } - return null; - } - - @Override - public DeclaredType getAnnotationType() { - return types.GenerateOperations; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java deleted file mode 100644 index f10977869a23..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SimpleBytecodeNodeGeneratorPlugs.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.generator.BitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.BoxingSplit; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; -import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ReportPolymorphismAction; -import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.generator.StaticConstants; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.model.CacheExpression; -import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; -import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.model.NodeExecutionData; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.model.TypeSystemData; -import com.oracle.truffle.dsl.processor.operations.instructions.CustomInstruction; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; - -public class SimpleBytecodeNodeGeneratorPlugs implements NodeGeneratorPlugs { - - private final OperationsData m; - private final CustomInstruction cinstr; - private final StaticConstants staticConstants; - - public SimpleBytecodeNodeGeneratorPlugs(OperationsData m, CustomInstruction cinstr, StaticConstants staticConstants) { - this.m = m; - this.cinstr = cinstr; - this.staticConstants = staticConstants; - } - - public void setNodeData(NodeData node) { - } - - public String transformNodeMethodName(String name) { - return name; - } - - public String transformNodeInnerTypeName(String name) { - return name; - } - - public void addNodeCallParameters(CodeTreeBuilder builder, boolean isBoundary, boolean isRemoveThis) { - if (!isBoundary) { - if (m.enableYield) { - builder.string("$stackFrame"); - builder.string("$localsFrame"); - } else { - builder.string("$frame"); - } - } - builder.string("$bci"); - builder.string("$sp"); - if (cinstr.getData().getMainProperties().isVariadic) { - builder.string("$numVariadics"); - } - } - - public boolean shouldIncludeValuesInCall() { - return true; - } - - public int getMaxStateBits(int defaultValue) { - return defaultValue; - } - - public TypeMirror getBitSetType(TypeMirror defaultType) { - return defaultType; - } - - public CodeTree createBitSetReference(BitSet bits, boolean write) { - return CodeTreeBuilder.singleString("this." + bits.getName() + "_"); - } - - public CodeTree transformValueBeforePersist(CodeTree tree) { - return tree; - } - - public CodeTree createNodeFieldReference(FrameState frame, NodeExecutionData execution, String nodeFieldName, boolean forRead) { - return null; - } - - public CodeTree createCacheReference(FrameState frame, SpecializationData specialization, CacheExpression cache, String sharedName, boolean forRead) { - return null; - } - - public CodeTree[] createThrowUnsupportedValues(FrameState frameState, List values, CodeTreeBuilder parent, CodeTreeBuilder builder) { - return values.toArray(new CodeTree[0]); - } - - public void initializeFrameState(FrameState frameState, CodeTreeBuilder builder) { - } - - public boolean createCallExecuteAndSpecialize(FrameState frameState, CodeTreeBuilder builder, CodeTree call) { - return false; - } - - public CodeTree createCallChildExecuteMethod(NodeExecutionData execution, ExecutableTypeData method, FrameState frameState) { - String exName = execution.getName(); - if (exName.startsWith("$localRefArray")) { - return CodeTreeBuilder.singleString("this.op_localRefArray_"); - } - if (exName.startsWith("$localRef")) { - return CodeTreeBuilder.singleString("this.op_localRef_" + exName.substring(9) + "_"); - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (exName.equals("$variadicChild")) { - b.startCall("do_loadVariadicArguments"); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - b.string("$sp"); - b.string("$numVariadics"); - b.end(); - return b.build(); - } - - int childIndex = execution.getIndex(); - int offset = cinstr.numPopStatic() - childIndex; - - FrameKind resultKind = getFrameType(method.getReturnType().getKind()); - - b.startCall("expect" + resultKind.getFrameName()); - b.string(m.enableYield ? "$stackFrame" : "$frame"); - if (cinstr.isVariadic()) { - b.string("$sp - " + offset + " - $numVariadics"); - } else { - b.string("$sp - " + offset); - } - if (m.getOperationsContext().hasBoxingElimination()) { - b.string("$bc"); - b.string("$bci"); - b.string("this.op_popIndexed_" + childIndex + "_"); - } - b.end(); - - return b.build(); - } - - private FrameKind getFrameType(TypeKind type) { - if (!m.getBoxingEliminatedTypes().contains(type)) { - return FrameKind.OBJECT; - } - - return OperationsData.convertToFrameType(type); - } - - public CodeTree createThrowUnsupportedChild(NodeExecutionData execution) { - return CodeTreeBuilder.singleString("null"); - } - - public Boolean needsFrameToExecute(List specializations) { - return true; - } - - public void addAdditionalStateBits(List stateObjects) { - } - - public void setStateObjects(List stateObjects) { - } - - public void setMultiState(MultiStateBitSet multiState) { - } - - public int getRequiredStateBits(TypeSystemData types, Object object) { - throw new AssertionError(); - } - - public void createSpecialize(FrameState frameState, SpecializationData specialization, CodeTreeBuilder builder) { - } - - public boolean needsRewrites() { - return true; - } - - public void setBoxingSplits(List boxingSplits) { - } - - public List filterSpecializations(List implementedSpecializations) { - return implementedSpecializations; - } - - public boolean isStateGuaranteed(boolean stateGuaranteed) { - return stateGuaranteed; - } - - public StaticConstants createConstants() { - return staticConstants; - } - - public ReportPolymorphismAction createReportPolymorhoismAction(ReportPolymorphismAction original) { - return new ReportPolymorphismAction(false, false); - } - - public CodeTree createGetLock() { - return CodeTreeBuilder.singleString("getLock()"); - } - - public CodeTree createSuperInsert(CodeTree value) { - return CodeTreeBuilder.createBuilder().startCall("super.insert").tree(value).end().build(); - } - - public void setUseSpecializationClass(Predicate useSpecializationClass) { - } - - public String createExpectTypeMethodName(TypeSystemData typeSystem, TypeMirror type) { - return null; - } - - public CodeTree createCallExecute(FrameState frameState, ExecutableElement executableElement, CodeTree[] codeTrees) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (codeTrees.length > 1) { - throw new AssertionError(Arrays.toString(codeTrees)); - } - - b.startCall(executableElement.getSimpleName().toString()); - addNodeCallParameters(b, false, false); - b.end(); - - return b.build(); - } - - public String createExecuteAndSpecializeName(String result) { - return result; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java deleted file mode 100644 index 2bd820d6b02d..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationData.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.model.MessageContainer; -import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.model.Template; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; - -public class SingleOperationData extends Template { - private String name; - private MethodProperties mainProperties; - private NodeData nodeData; - private OperationsData parent; - private final Set throwDeclarations = new HashSet<>(); - private final boolean isShortCircuit; - private boolean shortCircuitContinueWhen; - private TypeMirror supertype; - - private List possiblePrimitiveTypes; - private boolean isAlwaysBoxed; - - public enum ParameterKind { - STACK_VALUE, - VARIADIC, - IMMEDIATE, - VIRTUAL_FRAME, - LOCAL_SETTER, - LOCAL_SETTER_ARRAY; - - public boolean isStackValue() { - switch (this) { - case STACK_VALUE: - case VARIADIC: - return true; - case VIRTUAL_FRAME: - case IMMEDIATE: - case LOCAL_SETTER: - case LOCAL_SETTER_ARRAY: - return false; - default: - throw new IllegalArgumentException(this.toString()); - } - } - } - - public static class MethodProperties { - public final ExecutableElement element; - public final List parameters; - public final boolean isVariadic; - public final boolean returnsValue; - public final int numStackValues; - public final int numLocalReferences; - public final List immediateTypes; - - public MethodProperties(ExecutableElement element, List parameters, List immediateTypes, boolean isVariadic, boolean returnsValue, int numLocalReferences) { - this.element = element; - this.parameters = parameters; - this.immediateTypes = immediateTypes; - int stackValues = 0; - for (ParameterKind param : parameters) { - if (param.isStackValue()) { - stackValues++; - } - } - this.numStackValues = stackValues; - this.isVariadic = isVariadic; - this.returnsValue = returnsValue; - this.numLocalReferences = numLocalReferences; - } - - public void checkMatches(SingleOperationData data, MethodProperties other) { - if (other.numStackValues != numStackValues) { - data.addError(element, "All methods must have same number of arguments"); - } - - if (other.isVariadic != isVariadic) { - data.addError(element, "All methods must (not) be variadic"); - } - - if (other.immediateTypes.size() != immediateTypes.size()) { - data.addError(element, "All methods must have same number of immediate arguments"); - } else { - for (int i = 0; i < immediateTypes.size(); i++) { - TypeMirror type1 = other.immediateTypes.get(i); - TypeMirror type2 = immediateTypes.get(i); - if (!ElementUtils.typeEquals(type1, type2)) { - data.addError(element, "Immediate arguments %d have differing types: %s and %s", type1, type2); - } - } - } - - if (other.returnsValue != returnsValue) { - data.addError(element, "All methods must (not) return value"); - } - - if (other.numLocalReferences != numLocalReferences) { - data.addError(element, "All methods must have same number of local references"); - } - } - - @Override - public String toString() { - return "Props[parameters=" + parameters + ", variadic=" + isVariadic + ", returns=" + returnsValue + ", numStackValues=" + numStackValues + ", numLocalReferences=" + numLocalReferences + - "]"; - } - } - - public SingleOperationData(ProcessorContext context, TypeElement templateType, AnnotationMirror annotation, OperationsData parent, String name, boolean isShortCircuit) { - super(context, templateType, annotation); - this.parent = parent; - this.name = name; - this.isShortCircuit = isShortCircuit; - } - - @Override - public MessageContainer getBaseContainer() { - return parent; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Set getThrowDeclarations() { - return throwDeclarations; - } - - public MethodProperties getMainProperties() { - return mainProperties; - } - - public boolean isShortCircuit() { - return isShortCircuit; - } - - public void setMainProperties(MethodProperties mainProperties) { - this.mainProperties = mainProperties; - } - - public NodeData getNodeData() { - return nodeData; - } - - void setNodeData(NodeData data) { - this.nodeData = data; - } - - @Override - public AnnotationMirror getMessageAnnotation() { - return getTemplateTypeAnnotation(); - } - - @Override - public AnnotationValue getMessageAnnotationValue() { - return null; - } - - @Override - public Element getMessageElement() { - if (getMessageAnnotation() != null) { - return parent.getMessageElement(); - } else { - return getTemplateType(); - } - } - - @Override - protected List findChildContainers() { - if (nodeData == null) { - return List.of(); - } - return List.of(nodeData); - } - - public boolean getShortCircuitContinueWhen() { - return shortCircuitContinueWhen; - } - - public void setShortCircuitContinueWhen(boolean shortCircuitContinueWhen) { - this.shortCircuitContinueWhen = shortCircuitContinueWhen; - } - - public List getPossiblePrimitiveTypes() { - return possiblePrimitiveTypes; - } - - public void setPossiblePrimitiveTypes(List prossiblePrimitiveTypes) { - this.possiblePrimitiveTypes = prossiblePrimitiveTypes; - } - - public boolean isAlwaysBoxed() { - return isAlwaysBoxed; - } - - public void setAlwaysBoxed(boolean isAlwaysBoxed) { - this.isAlwaysBoxed = isAlwaysBoxed; - } - - public TypeMirror getSupertype() { - return supertype; - } - - public void setSupertype(TypeMirror supertype) { - this.supertype = supertype; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java deleted file mode 100644 index b03d4af4f50f..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/SingleOperationParser.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.java.ElementUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; -import com.oracle.truffle.dsl.processor.model.MessageContainer.Message; -import com.oracle.truffle.dsl.processor.model.NodeData; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.ParameterKind; -import com.oracle.truffle.dsl.processor.operations.instructions.FrameKind; -import com.oracle.truffle.dsl.processor.parser.AbstractParser; -import com.oracle.truffle.dsl.processor.parser.NodeParser; - -public class SingleOperationParser extends AbstractParser { - - private final OperationsData parentData; - private final AnnotationMirror proxyMirror; - - private static final String NODE = "Node"; - private final boolean isShortCircuit; - - public SingleOperationParser(OperationsData parentData) { - this(parentData, null, false); - } - - public SingleOperationParser(OperationsData parentData, AnnotationMirror proxyMirror) { - this(parentData, proxyMirror, false); - } - - public SingleOperationParser(OperationsData parentData, AnnotationMirror proxyMirror, boolean isShortCircuit) { - this.parentData = parentData; - this.proxyMirror = proxyMirror; - this.isShortCircuit = isShortCircuit; - } - - @Override - protected SingleOperationData parse(Element element, List mirror) { - - TypeElement te; - String name; - SingleOperationData data; - - if (element == null) { - // proxied type or short-circuiting - if (proxyMirror == null) { - throw new AssertionError(); - } - - AnnotationValue proxyTypeValue; - if (isShortCircuit) { - proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "booleanConverter"); - } else { - proxyTypeValue = ElementUtils.getAnnotationValue(proxyMirror, "value"); - } - - TypeMirror proxyType = (TypeMirror) proxyTypeValue.getValue(); - if (proxyType.getKind() != TypeKind.DECLARED) { - parentData.addError(proxyMirror, proxyTypeValue, "Type referenced by @%s must be a class, not %s.", - isShortCircuit ? "ShortCircuitOperation" : "OperationProxy", - proxyType); - return null; - } - - te = context.getTypeElement((DeclaredType) proxyType); - - if (isShortCircuit) { - name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); - } else { - AnnotationValue nameFromAnnot = ElementUtils.getAnnotationValue(proxyMirror, "operationName", false); - - if (nameFromAnnot == null) { - String nameFromType = te.getSimpleName().toString(); - // strip the `Node' suffix - if (nameFromType.endsWith(NODE)) { - name = nameFromType.substring(0, nameFromType.length() - NODE.length()); - } else { - name = nameFromType; - } - } else { - name = (String) nameFromAnnot.getValue(); - } - } - - data = new SingleOperationData(context, null, proxyMirror, parentData, name, isShortCircuit); - data.setSupertype(proxyType); - - } else { - if (proxyMirror != null) { - throw new AssertionError(); - } - - if (!(element instanceof TypeElement)) { - parentData.addError(element, "@Operation can only be attached to a type"); - return null; - } - - te = (TypeElement) element; - if (isShortCircuit) { - name = (String) ElementUtils.getAnnotationValue(proxyMirror, "name").getValue(); - } else { - name = te.getSimpleName().toString(); - } - - data = new SingleOperationData(context, te, null, parentData, name, false); - data.setSupertype(types.Node); - } - - List operationFunctions = new ArrayList<>(); - - if (!ElementUtils.isAssignable(te.asType(), types.NodeInterface)) { - // operation specification - - if (!te.getModifiers().contains(Modifier.FINAL)) { - data.addError("Operation class must be declared final. Inheritance in operation specifications is not supported."); - } - - if (te.getEnclosingElement() != null && !te.getModifiers().contains(Modifier.STATIC)) { - data.addError("Operation class must not be an inner class (non-static nested class). Declare the class as static."); - } - - if (te.getModifiers().contains(Modifier.PRIVATE)) { - data.addError("Operation class must not be declared private. Remove the private modifier to make it visible."); - } - - // TODO: Add cross-package visibility check - - if (!ElementUtils.isObject(te.getSuperclass()) || !te.getInterfaces().isEmpty()) { - data.addError("Operation class must not extend any classes or implement any interfaces. Inheritance in operation specifications is not supported."); - } - - for (Element el : te.getEnclosedElements()) { - if (el.getModifiers().contains(Modifier.PRIVATE)) { - // ignore everything private - continue; - } - - if (!el.getModifiers().contains(Modifier.STATIC)) { - if (el.getKind() == ElementKind.CONSTRUCTOR && ((ExecutableElement) el).getParameters().size() == 0) { - // we need to explicitly allow the implicit 0-argument non-static - // constructor. - continue; - } - data.addError(el, "@Operation annotated class must not contain non-static members."); - } - } - - operationFunctions.addAll(findSpecializations(te.getEnclosedElements())); - } else { - // proxied node - - for (ExecutableElement cel : findSpecializations(te)) { - // todo: also check supertypes - if (!cel.getModifiers().contains(Modifier.STATIC)) { - data.addError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance."); - } - - operationFunctions.add(cel); - } - } - - if (data.hasErrors()) { - return data; - } - - if (operationFunctions.isEmpty()) { - data.addError("Operation contains no specializations."); - return data; - } - - MethodProperties props = processMethod(data, operationFunctions.get(0)); - - boolean[] canPossiblyReturn = new boolean[FrameKind.values().length]; - canPossiblyReturn[FrameKind.OBJECT.ordinal()] = true; - - Set possiblePrimitiveReturns = new HashSet<>(); - boolean isAlwaysBoxed = true; - - for (ExecutableElement fun : operationFunctions) { - MethodProperties props2 = processMethod(data, fun); - props2.checkMatches(data, props); - data.getThrowDeclarations().addAll(fun.getThrownTypes()); - - if (ElementUtils.isObject(fun.getReturnType())) { - // object => all primitives could potentially be returned (boxed) - for (int i = 0; i < canPossiblyReturn.length; i++) { - canPossiblyReturn[i] = true; - possiblePrimitiveReturns.addAll(parentData.getOperationsContext().getPrimitiveBoxingKinds()); - } - } else if (parentData.getBoxingEliminatedTypes().contains(fun.getReturnType().getKind())) { - isAlwaysBoxed = false; - FrameKind kind = FrameKind.valueOfWithBoxing(fun.getReturnType().getKind()); - canPossiblyReturn[kind.ordinal()] = true; - if (kind != FrameKind.OBJECT && !possiblePrimitiveReturns.contains(kind)) { - possiblePrimitiveReturns.add(kind); - } - } - } - - data.setPossiblePrimitiveTypes(possiblePrimitiveReturns.stream().collect(Collectors.toList())); - data.setAlwaysBoxed(isAlwaysBoxed); - - if (isShortCircuit && (props.numStackValues != 1 || props.isVariadic || !props.returnsValue)) { - data.addError("Boolean converter must take exactly one argument, not be variadic, and return a value"); - } - - if (data.hasErrors()) { - return data; - } - - data.setMainProperties(props); - - CodeTypeElement clonedType = cloneTypeHierarchy(te, ct -> { - // remove NodeChild annotations - ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChild) || ElementUtils.typeEquals(m.getAnnotationType(), types.NodeChildren)); - // remove GenerateUncached annotations - we do not care - ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.GenerateUncached)); - ct.getAnnotationMirrors().removeIf(m -> ElementUtils.typeEquals(m.getAnnotationType(), types.GenerateNodeFactory)); - - // remove all non-static or private elements - // this includes all the execute methods - ct.getEnclosedElements().removeIf(e -> !e.getModifiers().contains(Modifier.STATIC) || e.getModifiers().contains(Modifier.PRIVATE)); - }); - - if (proxyMirror == null || isShortCircuit) { - clonedType.setSuperClass(types.Node); - } - - addBoxingEliminationNodeChildAnnotations(data, props, clonedType); - - if (parentData.isGenerateUncached()) { - clonedType.getAnnotationMirrors().add(new CodeAnnotationMirror(types.GenerateUncached)); - clonedType.add(createExecuteUncachedMethod(props)); - } - - if (isShortCircuit) { - clonedType.add(createExecuteMethod(props, "execute", context.getType(boolean.class), false)); - } else if (!props.returnsValue) { - clonedType.add(createExecuteMethod(props, "execute", context.getType(void.class), false)); - } else if (isAlwaysBoxed) { - clonedType.add(createExecuteMethod(props, "execute", context.getType(Object.class), false)); - } else { - for (FrameKind kind : parentData.getFrameKinds()) { - if (canPossiblyReturn[kind.ordinal()]) { - clonedType.add(createExecuteMethod(props, kind == FrameKind.OBJECT ? "execute" : "execute" + kind.getFrameName(), kind.getType(), kind != FrameKind.OBJECT)); - } - } - } - - NodeData nodeData = NodeParser.createOperationParser(parentData.getTemplateType()).parse(clonedType, false); - - if (nodeData == null) { - data.addError("Could not parse invalid node: " + te.getSimpleName() + ". Fix errors in the node first."); - return data; - } - - if (proxyMirror != null && nodeData.hasErrors()) { - for (Message m : nodeData.collectMessages()) { - Message nm = new Message(proxyMirror, null, null, m.getOriginalContainer(), m.getText(), m.getKind()); - data.getMessages().add(nm); - } - } else { - nodeData.redirectMessagesOnGeneratedElements(data); - } - data.setNodeData(nodeData); - - // replace the default node type system with Operations one if we have it - if (nodeData.getTypeSystem().isDefault() && parentData.getTypeSystem() != null) { - nodeData.setTypeSystem(parentData.getTypeSystem()); - } - - return data; - } - - private void addBoxingEliminationNodeChildAnnotations(SingleOperationData data, MethodProperties props, CodeTypeElement ct) { - int i = 0; - int localI = 0; - int immediateI = 0; - CodeTypeElement childType = createRegularNodeChild(); - CodeAnnotationMirror repAnnotation = new CodeAnnotationMirror(types.NodeChildren); - List anns = new ArrayList<>(); - for (ParameterKind param : props.parameters) { - CodeAnnotationMirror ann = new CodeAnnotationMirror(types.NodeChild); - switch (param) { - case STACK_VALUE: - ann.setElementValue("value", new CodeAnnotationValue("$child" + i)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(childType))); - anns.add(new CodeAnnotationValue(ann)); - i++; - break; - case LOCAL_SETTER: - ann.setElementValue("value", new CodeAnnotationValue("$localRef" + localI)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(types.LocalSetter)))); - anns.add(new CodeAnnotationValue(ann)); - localI++; - break; - case IMMEDIATE: - ann.setElementValue("value", new CodeAnnotationValue("$immediate" + immediateI)); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(props.immediateTypes.get(immediateI))))); - anns.add(new CodeAnnotationValue(ann)); - immediateI++; - break; - case LOCAL_SETTER_ARRAY: - ann.setElementValue("value", new CodeAnnotationValue("$localRefArray")); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createConstantNodeChild(types.LocalSetterRange)))); - anns.add(new CodeAnnotationValue(ann)); - break; - case VARIADIC: - ann.setElementValue("value", new CodeAnnotationValue("$variadicChild")); - ann.setElementValue("type", new CodeAnnotationValue(new DeclaredCodeTypeMirror(createVariadicNodeChild()))); - anns.add(new CodeAnnotationValue(ann)); - break; - case VIRTUAL_FRAME: - break; - default: - throw new IllegalArgumentException("" + param); - } - } - repAnnotation.setElementValue("value", new CodeAnnotationValue(anns)); - ct.addAnnotationMirror(repAnnotation); - } - - private CodeExecutableElement createExecuteMethod(MethodProperties props, String name, TypeMirror resType, boolean hasUre) { - CodeExecutableElement metExecute = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), resType, name); - metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - - if (hasUre) { - metExecute.addThrownType(types.UnexpectedResultException); - } - - return metExecute; - } - - private CodeExecutableElement createExecuteUncachedMethod(MethodProperties props) { - - Class resType; - if (isShortCircuit) { - resType = boolean.class; - } else if (props.returnsValue) { - resType = Object.class; - } else { - resType = void.class; - } - CodeExecutableElement metExecute = new CodeExecutableElement( - Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), - context.getType(resType), "executeUncached"); - - metExecute.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); - - int i = 0; - int lr = 0; - for (ParameterKind param : props.parameters) { - switch (param) { - case STACK_VALUE: - metExecute.addParameter(new CodeVariableElement(context.getType(Object.class), "arg" + i)); - break; - case VARIADIC: - metExecute.addParameter(new CodeVariableElement(context.getType(Object[].class), "arg" + i)); - break; - case LOCAL_SETTER: - metExecute.addParameter(new CodeVariableElement(types.LocalSetter, "localRef" + (lr++))); - break; - case LOCAL_SETTER_ARRAY: - metExecute.addParameter(new CodeVariableElement(types.LocalSetterRange, "localRefs")); - break; - case VIRTUAL_FRAME: - break; - default: - throw new UnsupportedOperationException("" + param); - } - i++; - } - - return metExecute; - } - - @Override - public DeclaredType getAnnotationType() { - return types.Operation; - } - - private MethodProperties processMethod(SingleOperationData data, ExecutableElement method) { - boolean isVariadic = false; - int numLocalSetters = 0; - List parameters = new ArrayList<>(); - List immediateTypes = new ArrayList<>(); - - for (VariableElement param : method.getParameters()) { - if (isVariadicParameter(param)) { - if (isVariadic) { - data.addError(method, "Multiple @Variadic arguments are not supported."); - } - if (numLocalSetters != 0) { - data.addError(param, "Value arguments after LocalSetter are not supported."); - } - isVariadic = true; - parameters.add(ParameterKind.VARIADIC); - } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetter)) { - parameters.add(ParameterKind.LOCAL_SETTER); - numLocalSetters++; - } else if (ElementUtils.typeEquals(param.asType(), types.LocalSetterRange)) { - parameters.add(ParameterKind.LOCAL_SETTER_ARRAY); - if (numLocalSetters != 0) { - data.addError(param, "Mixing regular and range local setters is not supported."); - } - numLocalSetters = -1; - } else if (!isIgnoredParameter(param)) { - if (isVariadic) { - data.addError(method, "Value arguments after @Variadic are not supported."); - } - if (numLocalSetters > 0) { - data.addError(param, "Value arguments after LocalSetter are not supported."); - } - if (ElementUtils.typeEquals(param.asType(), types.Frame) || ElementUtils.typeEquals(param.asType(), types.VirtualFrame)) { - parameters.add(ParameterKind.VIRTUAL_FRAME); - } else { - parameters.add(ParameterKind.STACK_VALUE); - } - } - } - - boolean returnsValue = method.getReturnType().getKind() != TypeKind.VOID; - - MethodProperties props = new MethodProperties(method, parameters, immediateTypes, isVariadic, returnsValue, numLocalSetters); - - return props; - } - - private boolean isIgnoredParameter(VariableElement param) { - if (ElementUtils.findAnnotationMirror(param, types.Cached) != null) { - return true; - } else if (ElementUtils.findAnnotationMirror(param, types.CachedLibrary) != null) { - return true; - } else if (ElementUtils.findAnnotationMirror(param, types.Bind) != null) { - return true; - } - - return false; - } - - private static final String GENERIC_EXECUTE_NAME = "Generic"; - - private CodeTypeElement createRegularNodeChild() { - - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); - result.setSuperClass(types.Node); - - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object.class))); - - for (TypeKind unboxKind : parentData.getBoxingEliminatedTypes()) { - result.add(createChildExecuteMethod(unboxKind.name(), new CodeTypeMirror(unboxKind))); - } - - return result; - } - - private CodeTypeElement createVariadicNodeChild() { - - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); - result.setSuperClass(types.Node); - - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, context.getType(Object[].class))); - - return result; - } - - private CodeTypeElement createConstantNodeChild(TypeMirror returnType) { - CodeTypeElement result = new CodeTypeElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); - result.setSuperClass(types.Node); - - result.add(createChildExecuteMethod(GENERIC_EXECUTE_NAME, returnType)); - - return result; - } - - private CodeExecutableElement createChildExecuteMethod(String name, TypeMirror retType) { - CodeExecutableElement result = new CodeExecutableElement(Set.of(Modifier.PUBLIC, Modifier.ABSTRACT), retType, "execute" + name); - // result.addParameter(new CodeVariableElement(types.Frame, "frame")); - - if (!GENERIC_EXECUTE_NAME.equals(name)) { - result.addThrownType(types.UnexpectedResultException); - } - return result; - } - - private boolean isVariadicParameter(VariableElement param) { - return ElementUtils.findAnnotationMirror(param, types.Variadic) != null; - } - - private boolean isSpecializationFunction(ExecutableElement el) { - return ElementUtils.findAnnotationMirror(el, types.Specialization) != null; - } - - private CodeTypeElement cloneTypeHierarchy(TypeElement element, Consumer mapper) { - CodeTypeElement result = CodeTypeElement.cloneShallow(element); - if (!ElementUtils.isObject(element.getSuperclass())) { - result.setSuperClass(cloneTypeHierarchy(context.getTypeElement((DeclaredType) element.getSuperclass()), mapper).asType()); - } - - mapper.accept(result); - - return result; - } - - private List findSpecializations(TypeElement te) { - if (ElementUtils.isObject(te.asType())) { - return new ArrayList<>(); - } - - List els = te.getSuperclass() == null - ? new ArrayList<>() - : findSpecializations(context.getTypeElement((DeclaredType) te.getSuperclass())); - els.addAll(findSpecializations(te.getEnclosedElements())); - return els; - } - - private List findSpecializations(Collection elements) { - // @formatter:off - return elements.stream(). - filter(x -> x instanceof ExecutableElement). - map(x -> (ExecutableElement) x). - filter(this::isSpecializationFunction). - collect(Collectors.toUnmodifiableList()); - // @formatter:on - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index af87a1502601..646a7cc58af3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -52,10 +52,14 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; @@ -63,9 +67,11 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.StaticConstants; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; +import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; @@ -91,6 +97,8 @@ public class OperationsNodeFactory { private CodeTypeElement operationLocalImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLocalImpl"); private CodeTypeElement operationLabelImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLabelImpl"); + private static final Name Uncached_Name = CodeNames.of("Uncached"); + public OperationsNodeFactory(ProcessorContext context, OperationsModel model) { this.context = context; this.types = context.getTypes(); @@ -136,15 +144,37 @@ public CodeTypeElement create() { FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts); - CodeTypeElement el = new CodeTypeElement(Set.of(), ElementKind.CLASS, null, instr.nodeType.getSimpleName() + "Gen"); + CodeTypeElement el = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, instr.nodeType.getSimpleName() + "Gen"); el.setSuperClass(types.Node); - - operationNodeGen.add(factory.create(el)); + factory.create(el); + processNodeType(el); + operationNodeGen.add(el); } + operationNodeGen.addAll(consts.elements()); + return operationNodeGen; } + @SuppressWarnings("unchecked") + private void processNodeType(CodeTypeElement el) { + for (VariableElement fld : ElementFilter.fieldsIn(el.getEnclosedElements())) { + if (ElementUtils.getQualifiedName(fld.asType()).equals("C")) { + el.remove(fld); + } + } + + for (ExecutableElement ctor : ElementFilter.constructorsIn(el.getEnclosedElements())) { + el.remove(ctor); + } + + for (CodeTypeElement type : (List) (List) ElementFilter.typesIn(el.getEnclosedElements())) { + if (type.getSimpleName() == Uncached_Name) { + type.setSuperClass(types.Node); + } + } + } + private CodeExecutableElement createFrameDescriptorConstructor() { CodeExecutableElement ctor = GeneratorUtils.createSuperConstructor(operationNodeGen, model.fdConstructor); ctor.getModifiers().clear(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java deleted file mode 100644 index 9027c381f69d..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/BranchInstruction.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import javax.lang.model.type.DeclaredType; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -@SuppressWarnings("unused") -public class BranchInstruction extends Instruction { - - private final ProcessorContext context = ProcessorContext.getInstance(); - private final DeclaredType typeTruffleSafepoint = context.getDeclaredType("com.oracle.truffle.api.TruffleSafepoint"); - private final DeclaredType typeBytecodeOsrNode = context.getDeclaredType("com.oracle.truffle.api.nodes.BytecodeOSRNode"); - private final DeclaredType typeLoopNode = context.getDeclaredType("com.oracle.truffle.api.nodes.LoopNode"); - - private static final boolean SAFEPOINT_POLL = true; - private static final boolean LOOP_COUNTING = true; - private static final boolean TRY_OSR = true; - - private static final int REPORT_LOOP_STRIDE = 1 << 8; - - public BranchInstruction(OperationsContext ctx, int id) { - super(ctx, "branch", id, 0); - addBranchTarget("target"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - return createExecuteImpl(vars, false); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteImpl(vars, true); - } - - private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("int", "targetBci", createBranchTargetIndex(vars, 0, false)); - - if (SAFEPOINT_POLL || LOOP_COUNTING || TRY_OSR || uncached) { - b.startIf().string("targetBci <= ").variable(vars.bci).end().startBlock(); // { - - if (!uncached && (LOOP_COUNTING || SAFEPOINT_POLL)) { - b.startIf(); - b.tree(GeneratorUtils.createHasNextTier()); - if (LOOP_COUNTING) { - b.string(" && "); - b.string("++loopCounter.count >= " + REPORT_LOOP_STRIDE); - } - b.end().startBlock(); // { - - if (SAFEPOINT_POLL) { - b.startStatement().startStaticCall(typeTruffleSafepoint, "poll"); - b.string("$this"); - b.end(2); - } - - if (LOOP_COUNTING) { - b.startStatement().startStaticCall(typeLoopNode, "reportLoopCount"); - b.string("$this"); - b.string("" + REPORT_LOOP_STRIDE); - b.end(2); - } - - b.statement("loopCounter.count = 0"); - - if (TRY_OSR) { - b.startIf(); - b.tree(GeneratorUtils.createInInterpreter()); - b.string(" && "); - b.startStaticCall(typeBytecodeOsrNode, "pollOSRBackEdge").string("$this").end(); - b.end().startBlock(); // { - b.startAssign("Object osrResult").startStaticCall(typeBytecodeOsrNode, "tryOSR"); - b.string("$this"); - b.string("($sp << 16) | targetBci"); - b.variable(vars.localFrame); - b.string("null"); - b.variable(vars.stackFrame); - b.end(2); - - b.startIf().string("osrResult != null").end().startBlock(); // { - // todo: check if this will overwrite a local in reused frames - b.startStatement().variable(vars.stackFrame).string(".setObject(0, osrResult)").end(); - b.startReturn().string("0x0000ffff").end(); - b.end(); // } - - b.end(); // } - } - - b.end(); // } - } - - if (uncached) { - b.statement("uncachedExecuteCount.count--"); - b.startIf().string("uncachedExecuteCount.count <= 0").end().startBlock(); - - b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); - b.statement("return ($sp << 16) | targetBci"); - - b.end(); - } - - b.end(); // } - } - - b.startAssign(vars.bci).string("targetBci").end(); - b.statement("continue loop"); - - return b.build(); - } - - @Override - public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("calculateLeaves"); - b.variable(vars.operationData); - b.tree(arguments.branchTargets[0]); - b.end(2); - - return b.build(); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - protected CodeTree createObjectInitializer(BuilderVariables vars, EmitArguments args) { - return CodeTreeBuilder.createBuilder().startAssign("objs[bci]").tree(args.branchTargets[0]).end().build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java deleted file mode 100644 index 5175999377d0..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ConditionalBranchInstruction.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import javax.lang.model.type.DeclaredType; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class ConditionalBranchInstruction extends Instruction { - - private final ProcessorContext context = ProcessorContext.getInstance(); - private final DeclaredType typeConditionProfile = context.getDeclaredType("com.oracle.truffle.api.profiles.ConditionProfile"); - - public ConditionalBranchInstruction(OperationsContext ctx, int id) { - super(ctx, "branch.false", id, 0); - addPopSimple("condition"); - addBranchTarget("target"); - addBranchProfile("profile"); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration("boolean", "cond", "UFA.unsafeGetObject(" + vars.stackFrame.getName() + ", $sp - 1) == Boolean.TRUE"); - - b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - - b.startIf().startCall("do_profileCondition"); - - b.string("$this"); - b.string("cond"); - b.string("$conditionProfiles"); - b.tree(createBranchProfileIndex(vars, 0, false)); - - b.end(2).startBlock(); - - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.statement("continue loop"); - - b.end().startElseBlock(); - - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.statement("continue loop"); - - b.end(); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java deleted file mode 100644 index 91915e6bf537..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/CustomInstruction.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import java.util.ArrayList; -import java.util.List; - -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData.MethodProperties; - -public class CustomInstruction extends Instruction { - - private final SingleOperationData data; - private TypeMirror nodeType; - private NodeGeneratorPlugs plugs; - private CodeExecutableElement prepareAOTMethod; - private CodeExecutableElement getSpecializationBits; - private final List quickenedVariants = new ArrayList<>(); - - public SingleOperationData getData() { - return data; - } - - public String getUniqueName() { - return data.getName(); - } - - public List getSpecializationNames() { - List result = new ArrayList<>(); - for (SpecializationData spec : data.getNodeData().getSpecializations()) { - result.add(spec.getId()); - } - return result; - } - - public void setNodeType(TypeMirror nodeType) { - this.nodeType = nodeType; - } - - public CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { - super(ctx, name, id, data.getMainProperties().returnsValue ? 1 : 0); - this.data = data; - initializePops(); - } - - public static final String MARKER_LOCAL_REFS = "LocalSetterRange"; - public static final String MARKER_LOCAL_REF_PREFIX = "LocalSetter_"; - public static final String MARKER_IMMEDIATEE_PREFIX = "Immediate_"; - - private int[] localRefs = null; - private int[] immediates = null; - - protected void initializePops() { - MethodProperties props = data.getMainProperties(); - - if (props.isVariadic) { - setVariadic(); - for (int i = 0; i < props.numStackValues - 1; i++) { - addPopIndexed("arg" + i); - } - } else { - for (int i = 0; i < props.numStackValues; i++) { - addPopIndexed("arg" + i); - } - } - - if (props.numLocalReferences == -1) { - localRefs = new int[1]; - localRefs[0] = addConstant(MARKER_LOCAL_REFS, new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); - } else { - localRefs = new int[props.numLocalReferences]; - for (int i = 0; i < props.numLocalReferences; i++) { - localRefs[i] = addConstant(MARKER_LOCAL_REF_PREFIX + i, types.OperationLocal); - } - } - - if (props.immediateTypes.size() > 0) { - immediates = new int[props.immediateTypes.size()]; - for (int i = 0; i < props.immediateTypes.size(); i++) { - immediates[i] = addConstant(MARKER_IMMEDIATEE_PREFIX + i, props.immediateTypes.get(i)); - } - } - } - - protected CustomInstruction(OperationsContext ctx, String name, int id, SingleOperationData data, int pushCount) { - super(ctx, name, id, pushCount); - this.data = data; - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - return createExecuteImpl(vars, false); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteImpl(vars, true); - } - - private void addLocalRefs(CodeTreeBuilder b, ExecutionVariables vars) { - if (data.getMainProperties().numLocalReferences == -1) { - b.startGroup().cast(types.LocalSetterRange).variable(vars.consts).string("[").tree(createConstantIndex(vars, localRefs[0])).string("]").end(); - } else { - for (int i = 0; i < data.getMainProperties().numLocalReferences; i++) { - b.startGroup().cast(types.LocalSetter).variable(vars.consts).string("[").tree(createConstantIndex(vars, localRefs[i])).string("]").end(); - } - } - } - - @Override - public boolean splitOnBoxingElimination() { - return !data.isAlwaysBoxed() && data.getMainProperties().returnsValue; - } - - @Override - public boolean alwaysBoxed() { - return data.isAlwaysBoxed(); - } - - @Override - public List getBoxingEliminationSplits() { - List result = new ArrayList<>(); - result.add(FrameKind.OBJECT); - result.addAll(data.getPossiblePrimitiveTypes()); - - return result; - } - - private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - return null; - } - - @Override - protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { - if (marker.equals(MARKER_LOCAL_REFS)) { - return CodeTreeBuilder.createBuilder().startStaticCall(types.LocalSetterRange, "create").startCall("getLocalIndices").tree(args.constants[index]).end(2).build(); - } - - if (marker instanceof String && ((String) marker).startsWith(MARKER_LOCAL_REF_PREFIX)) { - return CodeTreeBuilder.createBuilder().startStaticCall(types.LocalSetter, "create").startCall("getLocalIndex").tree(args.constants[index]).end(2).build(); - } - - return super.createConstantInitCode(vars, args, marker, index); - } - - protected void createTracerCode(ExecutionVariables vars, CodeTreeBuilder b) { - if (vars.tracer != null) { - b.startStatement().startCall(vars.tracer, "traceActiveSpecializations"); - b.variable(vars.bci); - b.variable(opcodeIdField); - - b.startStaticCall(getSpecializationBits); - b.variable(vars.bc); - b.variable(vars.bci); - b.end(); - - b.end(2); - } - } - - public void setPrepareAOTMethod(CodeExecutableElement prepareAOTMethod) { - this.prepareAOTMethod = prepareAOTMethod; - } - - public void setGetSpecializationBits(CodeExecutableElement getSpecializationBits) { - this.getSpecializationBits = getSpecializationBits; - } - - public NodeGeneratorPlugs getPlugs() { - return plugs; - } - - public void setPlugs(NodeGeneratorPlugs plugs) { - this.plugs = plugs; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - if (prepareAOTMethod == null) { - return null; - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startStatement().startStaticCall(prepareAOTMethod); - b.string("null"); - if (ctx.getData().enableYield) { - b.string("null"); - } - b.string("$this"); - b.string("$bc"); - b.variable(vars.bci); - b.string("-1"); - b.string("$consts"); - b.string("$children"); - if (isVariadic()) { - b.tree(createVariadicIndex(vars, false)); - } - b.tree(language); - b.tree(root); - b.end(2); - - return b.build(); - } - - public void addQuickenedVariant(QuickenedInstruction quick) { - quickenedVariants.add(quick); - } - - public List getQuickenedVariants() { - return quickenedVariants; - } - - public void setUncachedExecuteMethod(ExecutableElement uncachedExecuteMethod) { - this.uncachedExecuteMethod = uncachedExecuteMethod; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java deleted file mode 100644 index c282b5c583fa..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/DiscardInstruction.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class DiscardInstruction extends Instruction { - public DiscardInstruction(OperationsContext ctx, String name, int id) { - super(ctx, name, id, 0); - addPopSimple("value"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign(vars.sp).variable(vars.sp).string(" - 1").end(); - - b.startStatement().startCall(vars.stackFrame, "clear"); - b.variable(vars.sp); - b.end(2); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java deleted file mode 100644 index b8f4c9ec3588..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/FrameKind.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; - -public enum FrameKind { - // order must be the same as FrameSlotKind - OBJECT("Object", "Object"), - LONG("long", "Long"), - INT("int", "Int", "Integer"), - DOUBLE("double", "Double"), - FLOAT("float", "Float"), - BOOLEAN("boolean", "Boolean"), - BYTE("byte", "Byte"); - - private final String typeName; - private final String frameName; - private final String typeNameBoxed; - - FrameKind(String typeName, String frameName) { - this(typeName, frameName, frameName); - } - - FrameKind(String typeName, String frameName, String typeNameBoxed) { - this.typeName = typeName; - this.frameName = frameName; - this.typeNameBoxed = typeNameBoxed; - } - - public boolean isSingleByte() { - return this == BOOLEAN || this == BYTE; - } - - public boolean isBoxed() { - return this == OBJECT; - } - - public String getFrameName() { - return frameName; - } - - public String getTypeName() { - return typeName; - } - - public String getTypeNameBoxed() { - return typeNameBoxed; - } - - public TypeMirror getType() { - ProcessorContext context = ProcessorContext.getInstance(); - switch (this) { - case BOOLEAN: - return context.getType(boolean.class); - case BYTE: - return context.getType(byte.class); - case DOUBLE: - return context.getType(double.class); - case FLOAT: - return context.getType(float.class); - case INT: - return context.getType(int.class); - case LONG: - return context.getType(long.class); - case OBJECT: - return context.getType(Object.class); - default: - throw new UnsupportedOperationException(); - - } - } - - public String toOrdinal() { - return "" + this.ordinal() + " /* " + this + " */"; - } - - public static FrameKind valueOfPrimitive(TypeKind typeKind) { - switch (typeKind) { - case BOOLEAN: - return BOOLEAN; - case BYTE: - return BYTE; - case DOUBLE: - return DOUBLE; - case FLOAT: - return FLOAT; - case INT: - return INT; - case LONG: - return LONG; - default: - throw new UnsupportedOperationException(); - } - } - - public static FrameKind valueOfWithBoxing(TypeKind typeKind) { - switch (typeKind) { - case BOOLEAN: - return BOOLEAN; - case BYTE: - return BYTE; - case DOUBLE: - return DOUBLE; - case FLOAT: - return FLOAT; - case INT: - return INT; - case LONG: - return LONG; - default: - return OBJECT; - } - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java deleted file mode 100644 index d26b56d71e31..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/Instruction.java +++ /dev/null @@ -1,842 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.Modifier; -import javax.lang.model.type.ArrayType; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.TruffleTypes; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public abstract class Instruction { - - public static class ExecutionVariables { - public CodeVariableElement bc; - public CodeVariableElement bci; - public CodeVariableElement localFrame; - public CodeVariableElement stackFrame; - public CodeVariableElement sp; - public CodeVariableElement consts; - public CodeVariableElement children; - public CodeVariableElement tracer; - - public FrameKind specializedKind; - } - - public static class EmitArguments { - public CodeTree[] constants; - public CodeTree[] children; - public CodeTree[] locals; - public CodeTree[] localRuns; - public CodeTree[] branchTargets; - public CodeTree variadicCount; - public CodeTree[] arguments; - } - - protected final ProcessorContext context = ProcessorContext.getInstance(); - protected final TruffleTypes types = context.getTypes(); - - protected final OperationsContext ctx; - public final String name; - public final int id; - public final int numPushedValues; - - public final String internalName; - - // --------------------- arguments ------------------------ - - private List constants = new ArrayList<>(); - private List constantTypes = new ArrayList<>(); - private List children = new ArrayList<>(); - private List locals = new ArrayList<>(); - private List localRuns = new ArrayList<>(); - private List arguments = new ArrayList<>(); - private List popIndexed = new ArrayList<>(); - private List popSimple = new ArrayList<>(); - private boolean isVariadic; - private List branchTargets = new ArrayList<>(); - private List branchProfiles = new ArrayList<>(); - private List stateBits = new ArrayList<>(); - private List instruments = new ArrayList<>(); - - public boolean isCommon; - private boolean frozen; - - private static final String CONSTANT_OFFSET_SUFFIX = "_CONSTANT_OFFSET"; - private static final String CHILDREN_OFFSET_SUFFIX = "_CHILDREN_OFFSET"; - private static final String LOCALS_OFFSET_SUFFIX = "_LOCALS_OFFSET"; - private static final String LOCAL_RUNS_OFFSET_SUFFIX = "_LOCAL_RUNS_OFFSET"; - private static final String ARGUMENT_OFFSET_SUFFIX = "_ARGUMENT_OFFSET"; - private static final String POP_INDEXED_OFFSET_SUFFIX = "_POP_INDEXED_OFFSET"; - private static final String VARIADIC_OFFSET_SUFFIX = "_VARIADIC_OFFSET"; - private static final String BRANCH_TARGET_OFFSET_SUFFIX = "_BRANCH_TARGET_OFFSET"; - private static final String BRANCH_PROFILE_OFFSET_SUFFIX = "_BRANCH_PROFILE_OFFSET"; - private static final String STATE_BITS_OFFSET_SUFFIX = "_STATE_BITS_OFFSET"; - private static final String INSTRUMENT_OFFSET_SUFFIX = "_INSTRUMENT_OFFSET"; - private static final String LENGTH_SUFFIX = "_LENGTH"; - - private int addInstructionArgument(List holder, Object marker) { - int index = -1; - if (marker != null) { - index = holder.indexOf(marker); - } - - if (index == -1) { - if (frozen) { - throw new AssertionError(); - } - - index = holder.size(); - holder.add(marker); - } - return index; - } - - public int addConstant(Object marker, TypeMirror type) { - int result = addInstructionArgument(constants, marker); - if (result == constantTypes.size()) { - constantTypes.add(type); - } - - return result; - } - - public int addChild(Object marker) { - return addInstructionArgument(children, marker); - } - - public int addLocal(Object marker) { - return addInstructionArgument(locals, marker); - } - - public int addLocalRun(Object marker) { - return addInstructionArgument(localRuns, marker); - } - - public int addArgument(Object marker) { - return addInstructionArgument(arguments, marker); - } - - public int addPopIndexed(Object marker) { - if (!ctx.hasBoxingElimination()) { - return addPopSimple(marker); - } - if (!popSimple.isEmpty()) { - throw new AssertionError("cannot mix simple and indexed pops"); - } - return addInstructionArgument(popIndexed, marker); - } - - public int addPopSimple(Object marker) { - if (!popIndexed.isEmpty()) { - throw new AssertionError("cannot mix simple and indexed pops"); - } - return addInstructionArgument(popSimple, marker); - } - - public void setVariadic() { - isVariadic = true; - } - - public int addBranchTarget(Object marker) { - return addInstructionArgument(branchTargets, marker); - } - - public int addBranchProfile(Object marker) { - return addInstructionArgument(branchProfiles, marker); - } - - public int addStateBits(Object marker) { - return addInstructionArgument(stateBits, marker); - } - - public int addInstrument(Object marker) { - return addInstructionArgument(instruments, marker); - } - - private int getConstantsOffset() { - return opcodeLength(); - } - - private int getChildrenOffset() { - return getConstantsOffset() + (constants.isEmpty() ? 0 : 1); - } - - private int getLocalsOffset() { - return getChildrenOffset() + (children.isEmpty() ? 0 : 1); - } - - private int getLocalRunsOffset() { - return getLocalsOffset() + locals.size(); - } - - private int getArgumentsOffset() { - return getLocalRunsOffset() + localRuns.size() * 2; - } - - private int getPopIndexedOffset() { - return getArgumentsOffset() + arguments.size(); - } - - private int getVariadicOffset() { - return getPopIndexedOffset() + (popIndexed.size() + 1) / 2; - } - - private int getBranchTargetsOffset() { - return getVariadicOffset() + (isVariadic ? 1 : 0); - } - - private int getBranchProfileOffset() { - return getBranchTargetsOffset() + branchTargets.size(); - } - - private int getStateBitsOffset() { - return getBranchProfileOffset() + (branchProfiles.isEmpty() ? 0 : 1); - } - - public CodeTree createStateBitsOffset(int index) { - return CodeTreeBuilder.singleString(internalName + STATE_BITS_OFFSET_SUFFIX + " + " + index); - } - - private int getInstrumentsOffset() { - return getStateBitsOffset() + stateBits.size(); - } - - public int length() { - frozen = true; - if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { - return 1; - } - return getInstrumentsOffset() + instruments.size(); - } - - private CodeTree createIndirectIndex(ExecutionVariables vars, String suffix, int index) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startCall("unsafeFromBytecode"); - b.variable(vars.bc); - b.startGroup().variable(vars.bci).string(" + " + internalName + suffix).end(); - b.end(); - b.string(" + " + index); - - return b.build(); - } - - private CodeTree createDirectIndex(ExecutionVariables vars, String suffix, int index, boolean write) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (write) { - b.startGroup(); - b.variable(vars.bc); - b.string("["); - } else { - b.startCall("unsafeFromBytecode"); - b.variable(vars.bc); - } - b.startGroup().variable(vars.bci).string(" + " + internalName + suffix + " + " + index).end(); - - if (write) { - b.string("]").end(); - } else { - b.end(); - } - - return b.build(); - } - - public CodeTree createConstantIndex(ExecutionVariables vars, int index) { - return createIndirectIndex(vars, CONSTANT_OFFSET_SUFFIX, index); - } - - public CodeTree createChildIndex(ExecutionVariables vars, int index) { - return createIndirectIndex(vars, CHILDREN_OFFSET_SUFFIX, index); - } - - public CodeTree createLocalIndex(ExecutionVariables vars, int index, boolean write) { - return createDirectIndex(vars, LOCALS_OFFSET_SUFFIX, index, write); - } - - public CodeTree createArgumentIndex(ExecutionVariables vars, int index, boolean write) { - return createDirectIndex(vars, ARGUMENT_OFFSET_SUFFIX, index, write); - } - - public CodeTree createPopIndexedIndex(ExecutionVariables vars, int index, boolean write) { - if (!ctx.hasBoxingElimination()) { - throw new AssertionError("there is no boxing elimination"); - // return CodeTreeBuilder.singleString("0 /* XXXXXXXXXXX */"); - } - if (write) { - throw new AssertionError("cannot write to indexed pops"); - } - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startParantheses(); - if (index % 2 == 1) { - b.startParantheses(); - } - - b.tree(createDirectIndex(vars, POP_INDEXED_OFFSET_SUFFIX, index / 2, false)); - - if (index % 2 == 1) { - b.string(" >> 8").end(); - } - - b.string(" & 0xff").end(); - - return b.build(); - } - - public CodeTree createVariadicIndex(ExecutionVariables vars, boolean write) { - return createDirectIndex(vars, VARIADIC_OFFSET_SUFFIX, 0, write); - } - - public CodeTree createBranchTargetIndex(ExecutionVariables vars, int index, boolean write) { - return createDirectIndex(vars, BRANCH_TARGET_OFFSET_SUFFIX, index, write); - } - - public CodeTree createBranchProfileIndex(ExecutionVariables vars, int index, boolean write) { - return createDirectIndex(vars, BRANCH_PROFILE_OFFSET_SUFFIX, index * 2, write); - } - - public CodeTree createStateBitsIndex(ExecutionVariables vars, int index, boolean write) { - return createDirectIndex(vars, STATE_BITS_OFFSET_SUFFIX, index, write); - } - - public CodeTree createInstrument(ExecutionVariables vars, int index) { - return createIndirectIndex(vars, INSTRUMENT_OFFSET_SUFFIX, index); - } - - public CodeTree createLength() { - if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { - return CodeTreeBuilder.singleString("1"); - } - return CodeTreeBuilder.singleString(internalName + LENGTH_SUFFIX); - } - - public boolean[] typedConstants() { - boolean[] result = new boolean[constantTypes.size()]; - for (int i = 0; i < result.length; i++) { - result[i] = constantTypes.get(i) != null; - } - - return result; - } - - public int numConstants() { - return constants.size(); - } - - public int numLocals() { - return locals.size(); - } - - public int numLocalRuns() { - return localRuns.size(); - } - - public int numArguments() { - return arguments.size(); - } - - public int numBranchTargets() { - return branchTargets.size(); - } - - public boolean splitOnBoxingElimination() { - return false; - } - - public boolean alwaysBoxed() { - if (numPushedValues == 0) { - return true; - } else { - throw new AssertionError(name); - } - } - - public List getBoxingEliminationSplits() { - return ctx.getBoxingKinds(); - } - - public boolean hasGeneric() { - return false; - } - - public CodeVariableElement opcodeIdField; - - public void setOpcodeIdField(CodeVariableElement opcodeIdField) { - this.opcodeIdField = opcodeIdField; - } - - Instruction(OperationsContext ctx, String name, int id, int numPushedValues) { - this.ctx = ctx; - this.name = name; - this.id = id; - this.internalName = OperationGeneratorUtils.toScreamCase(name); - this.numPushedValues = numPushedValues; - - this.opcodeIdField = new CodeVariableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), context.getType(short.class), "INSTR_" + internalName); - opcodeIdField.createInitBuilder().string("" + id); - } - - public int opcodeLength() { - return 1; - } - - @SuppressWarnings("unused") - protected CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments args) { - return null; - } - - @SuppressWarnings("unused") - protected CodeTree createCustomEmitCodeAfter(BuilderVariables vars, EmitArguments args) { - return null; - } - - public final CodeTree createEmitCode(BuilderVariables vars, EmitArguments args) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.tree(createCustomEmitCode(vars, args)); - - CodeTree numPop; - - if (isVariadic) { - numPop = CodeTreeBuilder.createBuilder().tree(args.variadicCount).string(" + " + popSimple.size()).build(); - } else { - numPop = CodeTreeBuilder.singleString(popSimple.size() + popIndexed.size() + ""); - } - - if (popIndexed.size() > 0) { - b.startAssign("int[] predecessorBcis"); - } else { - b.startStatement(); - } - - b.startCall("doBeforeEmitInstruction"); - b.tree(numPop); - b.string(numPushedValues == 0 ? "false" : "true"); - b.string(numPushedValues > 0 && !alwaysBoxed() ? "true" : "false"); - b.end(2); - - // emit opcode - b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, this, 0))); - - if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { - b.tree(createObjectInitializer(vars, args)); - } else { - if (!constants.isEmpty()) { - b.startAssign("int constantsStart"); - b.startCall(vars.consts, "size").end(); - b.end(); - - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getConstantsOffset() + "] = (short) constantsStart").end(); - - for (int i = 0; i < constants.size(); i++) { - CodeTree initCode = null; - if (constants.get(i) != null) { - initCode = createConstantInitCode(vars, args, constants.get(i), i); - } - - if (initCode == null && args.constants != null) { - initCode = args.constants[i]; - } - - if (initCode == null) { - initCode = CodeTreeBuilder.singleString("null"); - } - - b.startStatement().startCall(vars.consts, "add"); - b.tree(initCode); - b.end(2); - } - } - - if (!children.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); - b.string("numChildNodes"); - b.end(); - - b.statement("numChildNodes += " + children.size()); - } - - for (int i = 0; i < locals.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalsOffset() + " + " + i + "] = (short) "); - b.startCall("getLocalIndex").tree(args.locals[i]).end(); - b.end(); - } - - for (int i = 0; i < localRuns.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2) + "] = (short) "); - b.startCall("getLocalRunStart").tree(args.localRuns[i]).end(); - b.end(); - - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getLocalRunsOffset() + " + " + (i * 2 + 1) + "] = (short) "); - b.startCall("getLocalRunLength").tree(args.localRuns[i]).end(); - b.end(); - } - - if (isVariadic) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getVariadicOffset() + "] = (short) "); - b.startParantheses().tree(args.variadicCount).end(); - b.end(); - } else { - for (int i = 0; i < popIndexed.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getPopIndexedOffset() + " + " + (i / 2) + "] "); - if (i % 2 == 1) { - b.string("|"); - } - b.string("= (short) ((").variable(vars.bci).string(" - predecessorBcis[" + i + "] < 256 ? ").variable(vars.bci).string(" - predecessorBcis[" + i + "] : 0)"); - if (i % 2 == 1) { - b.string(" << 8"); - } - b.string(")").end(); - } - } - - for (int i = 0; i < branchTargets.size(); i++) { - b.startStatement().startCall("labelFills", "add").startNew("LabelFill"); - b.startGroup().variable(vars.bci).string(" + " + getBranchTargetsOffset() + " + " + i).end(); - b.tree(args.branchTargets[i]); - b.end(3); - } - - if (!branchProfiles.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getBranchProfileOffset() + "] = (short) "); - b.string("numConditionProfiles"); - b.end(); - - b.statement("numConditionProfiles += " + branchProfiles.size() * 2); - } - - for (int i = 0; i < stateBits.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getStateBitsOffset() + " + " + i + "] = 0").end(); - } - - for (int i = 0; i < arguments.size(); i++) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getArgumentsOffset() + " + " + i + "] = (short) (int) "); - b.tree(args.arguments[i]); - b.end(); - } - - if (!instruments.isEmpty()) { - b.startStatement().variable(vars.bc).string("[").variable(vars.bci).string(" + " + getChildrenOffset() + "] = (short) "); - b.string("numInstrumentNodes"); - b.end(); - - b.statement("numInstrumentNodes += " + instruments.size()); - } - - // superinstructions - - final int maxHistory = 8; - - b.startAssign("instructionHistory[++instructionHistoryIndex % " + maxHistory + "]").variable(opcodeIdField).end(); - - boolean elseIf = false; - for (SuperInstruction si : ctx.getSuperInstructions()) { - Instruction[] instrs = si.getInstructions(); - - if (instrs[instrs.length - 1].id == id) { - elseIf = b.startIf(elseIf); - for (int i = 1; i < instrs.length; i++) { - if (i != 1) { - b.string(" && "); - } - b.string("instructionHistory[(instructionHistoryIndex - " + i + " + " + maxHistory + ") % 8] == "); - b.variable(instrs[instrs.length - 1 - i].opcodeIdField); - } - b.end().startBlock(); - - b.startStatement().variable(vars.bc).string("["); - b.variable(vars.bci); - // skips the last since BCI is still not incremented for current instruction - for (int i = 0; i < instrs.length - 1; i++) { - b.string(" - ").tree(instrs[i].createLength()); - } - b.string("] = ").tree(OperationGeneratorUtils.combineBoxingBits(ctx, si, 0)).end(); - - b.end(); - } - } - - } - - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - - b.tree(createCustomEmitCodeAfter(vars, args)); - - return b.build(); - } - - protected CodeTree createObjectInitializer(BuilderVariables vars, EmitArguments args) { - return null; - } - - public abstract CodeTree createExecuteCode(ExecutionVariables vars); - - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteCode(vars); - } - - public boolean neverInUncached() { - return false; - } - - @SuppressWarnings("unused") - protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { - return null; - } - - private static void printList(StringBuilder sb, List holder, String name) { - if (!holder.isEmpty()) { - sb.append(" ").append(name).append(":\n"); - int index = 0; - for (Object marker : holder) { - sb.append(String.format(" [%2d] %s\n", index++, marker == null ? "" : marker)); - } - } - } - - public String dumpInfo() { - StringBuilder sb = new StringBuilder(); - sb.append(name).append("\n"); - - printList(sb, constants, "Constants"); - printList(sb, children, "Children"); - printList(sb, locals, "Locals"); - printList(sb, localRuns, "Local Runs"); - printList(sb, popIndexed, "Indexed Pops"); - printList(sb, popSimple, "Simple Pops"); - if (isVariadic) { - sb.append(" Variadic\n"); - } - if (numPushedValues > 0 && alwaysBoxed()) { - sb.append(" Always Boxed\n"); - } else if (splitOnBoxingElimination()) { - sb.append(" Split on Boxing Elimination\n"); - } - sb.append(" Pushed Values: ").append(numPushedValues).append("\n"); - printList(sb, branchTargets, "Branch Targets"); - printList(sb, branchProfiles, "Branch Profiles"); - printList(sb, stateBits, "State Bitsets"); - - return sb.toString(); - } - - @SuppressWarnings("unused") - public CodeVariableElement boxingEliminationReplacement(FrameKind kind) { - return null; - } - - public abstract CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root); - - public boolean isExplicitFlowControl() { - return false; - } - - public boolean isInstrumentationOnly() { - return false; - } - - public List getBuilderArgumentTypes() { - ArrayList result = new ArrayList<>(); - - for (TypeMirror mir : constantTypes) { - if (mir != null) { - result.add(mir); - } - } - - for (int i = 0; i < arguments.size(); i++) { - result.add(context.getType(int.class)); - } - - for (int i = 0; i < branchTargets.size(); i++) { - result.add(types.OperationLabel); - } - - for (int i = 0; i < locals.size(); i++) { - result.add(types.OperationLocal); - } - - for (int i = 0; i < localRuns.size(); i++) { - result.add(new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal)); - } - - return result; - } - - public int numLocalReferences() { - return 0; - } - - public int numPopStatic() { - return popIndexed.size() + popSimple.size(); - } - - private void createAddArgument(CodeTreeBuilder b, String kind, Runnable value) { - b.startIndention().newLine(); - b.startNewArray((ArrayType) context.getType(Object[].class), null); - b.staticReference(context.getDeclaredType("com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind"), kind); - b.startGroup(); - value.run(); - b.end(); // group - b.end(); // array - b.end(); - } - - public CodeTree createDumpCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("Object[] dec"); - b.startNewArray((ArrayType) context.getType(Object[].class), null); - b.string("$bci"); - b.doubleQuote(name); - b.string("Arrays.copyOfRange($bc, $bci, $bci + " + internalName + LENGTH_SUFFIX + ")"); - b.startNewArray((ArrayType) context.getType(Object[].class), null); - for (int i = 0; i < constants.size(); i++) { - int ci = i; - createAddArgument(b, "CONSTANT", () -> { - b.variable(vars.consts).string("[").tree(createConstantIndex(vars, ci)).string("]"); - }); - } - - for (int i = 0; i < locals.size(); i++) { - int ci = i; - createAddArgument(b, "LOCAL", () -> b.cast(context.getType(int.class)).tree(createLocalIndex(vars, ci, false))); - } - - for (int i = 0; i < arguments.size(); i++) { - int ci = i; - createAddArgument(b, "ARGUMENT", () -> b.cast(context.getType(int.class)).tree(createArgumentIndex(vars, ci, false))); - } - - for (int i = 0; i < popIndexed.size(); i++) { - int ci = i; - createAddArgument(b, "CHILD_OFFSET", () -> b.cast(context.getType(int.class)).tree(createPopIndexedIndex(vars, ci, false))); - } - - if (isVariadic) { - createAddArgument(b, "VARIADIC", () -> b.cast(context.getType(int.class)).tree(createVariadicIndex(vars, false))); - } - - for (int i = 0; i < branchTargets.size(); i++) { - int ci = i; - createAddArgument(b, "BRANCH_OFFSET", () -> b.cast(context.getType(int.class)).tree(createBranchTargetIndex(vars, ci, false))); - } - - b.end(3); // arg array, instr array, stmt - - return b.build(); - - } - - private CodeVariableElement createConstant(String constantName, int value) { - CodeVariableElement result = new CodeVariableElement( - Set.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), - context.getType(int.class), - constantName); - result.createInitBuilder().string("" + value); - - return result; - } - - public List createInstructionFields() { - List result = new ArrayList<>(); - result.add(opcodeIdField); - if (!constants.isEmpty()) { - result.add(createConstant(internalName + CONSTANT_OFFSET_SUFFIX, getConstantsOffset())); - } - if (!children.isEmpty()) { - result.add(createConstant(internalName + CHILDREN_OFFSET_SUFFIX, getChildrenOffset())); - } - if (!localRuns.isEmpty()) { - result.add(createConstant(internalName + LOCAL_RUNS_OFFSET_SUFFIX, getLocalRunsOffset())); - } - if (!arguments.isEmpty()) { - result.add(createConstant(internalName + ARGUMENT_OFFSET_SUFFIX, getArgumentsOffset())); - } - if (!locals.isEmpty()) { - result.add(createConstant(internalName + LOCALS_OFFSET_SUFFIX, getLocalsOffset())); - } - if (!popIndexed.isEmpty()) { - result.add(createConstant(internalName + POP_INDEXED_OFFSET_SUFFIX, getPopIndexedOffset())); - } - if (isVariadic) { - result.add(createConstant(internalName + VARIADIC_OFFSET_SUFFIX, getVariadicOffset())); - } - if (!branchTargets.isEmpty()) { - result.add(createConstant(internalName + BRANCH_TARGET_OFFSET_SUFFIX, getBranchTargetsOffset())); - } - if (!branchProfiles.isEmpty()) { - result.add(createConstant(internalName + BRANCH_PROFILE_OFFSET_SUFFIX, getBranchProfileOffset())); - } - if (!stateBits.isEmpty()) { - result.add(createConstant(internalName + STATE_BITS_OFFSET_SUFFIX, getStateBitsOffset())); - } - if (!instruments.isEmpty()) { - result.add(createConstant(internalName + INSTRUMENT_OFFSET_SUFFIX, getInstrumentsOffset())); - } - result.add(createConstant(internalName + LENGTH_SUFFIX, length())); - - return result; - } - - public boolean isVariadic() { - return isVariadic; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java deleted file mode 100644 index 8eed70469eed..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationEnterInstruction.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class InstrumentationEnterInstruction extends Instruction { - - public InstrumentationEnterInstruction(OperationsContext ctx, int id) { - super(ctx, "instrument.enter", id, 0); - addInstrument("instrument"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("ProbeNode probe"); - b.startCall("getProbeNodeImpl"); - b.string("$this"); - b.tree(createInstrument(vars, 0)); - b.end(2); - - b.startIf().string("probe != null").end(); - b.startBlock(); - - b.startStatement(); - b.startCall("probe", "onEnter"); - b.variable(vars.localFrame); - b.end(2); - - b.end(); - - return b.build(); - } - - @Override - public boolean isInstrumentationOnly() { - return true; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java deleted file mode 100644 index 76ddf74dfb1e..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationExitInstruction.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class InstrumentationExitInstruction extends Instruction { - private final boolean returnsValue; - - public InstrumentationExitInstruction(OperationsContext ctx, int id) { - super(ctx, "instrument.exit.void", id, 0); - this.returnsValue = false; - addInstrument("instrument"); - } - - public InstrumentationExitInstruction(OperationsContext ctx, int id, boolean returnsValue) { - super(ctx, "instrument.exit", id, 0); - assert returnsValue; - this.returnsValue = true; - addInstrument("instrument"); - addPopIndexed("value"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("ProbeNode probe"); - b.startCall("getProbeNodeImpl"); - b.string("$this"); - b.tree(createInstrument(vars, 0)); - b.end(2); - - b.startIf().string("probe != null").end(); - b.startBlock(); - - b.startStatement(); - b.startCall("probe", "onReturnValue"); - b.variable(vars.localFrame); - if (returnsValue) { - b.startCall("expectObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - if (ctx.hasBoxingElimination()) { - b.variable(vars.bc); - b.variable(vars.bci); - b.tree(createPopIndexedIndex(vars, 0, false)); - } - b.end(); - } else { - b.string("null"); - } - b.end(2); - - b.end(); - - return b.build(); - } - - @Override - public boolean isInstrumentationOnly() { - return true; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java deleted file mode 100644 index 9b4428916ae5..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/InstrumentationLeaveInstruction.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class InstrumentationLeaveInstruction extends Instruction { - public InstrumentationLeaveInstruction(OperationsContext ctx, int id) { - super(ctx, "instrument.leave", id, 0); - addInstrument("instrument"); - addBranchTarget("startBranch"); - addBranchTarget("endBranch"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("ProbeNode probe"); - b.startCall("getProbeNodeImpl"); - b.string("$this"); - b.tree(createInstrument(vars, 0)); - b.end(2); - - b.startIf().string("probe != null").end(); - b.startBlock(); - - b.startAssign("Object result"); - b.startCall("probe", "onReturnExceptionalOrUnwind"); - b.variable(vars.localFrame); - b.string("null"); - b.string("false"); - b.end(2); - - b.startIf().string("result == ProbeNode.UNWIND_ACTION_REENTER").end().startBlock(); - - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 0, false)).end(); - b.statement("continue loop"); - - b.end().startElseIf().string("result != null").end().startBlock(); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.string("result"); - b.end(2); - - b.startAssign(vars.bci).tree(createBranchTargetIndex(vars, 1, false)).end(); - - b.statement("continue loop"); - - b.end(); // result != null - - b.end(); // probe != null - - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(createLength()).end(); - b.statement("continue loop"); - - return b.build(); - } - - @Override - public boolean isInstrumentationOnly() { - return true; - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java deleted file mode 100644 index 32387514d275..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadArgumentInstruction.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class LoadArgumentInstruction extends Instruction { - - public LoadArgumentInstruction(OperationsContext ctx, int id) { - super(ctx, "load.argument", id, 1); - addArgument("argument"); - } - - private CodeTree createGetValue(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startCall(vars.localFrame, "getArguments").end(); - b.string("["); - b.tree(createArgumentIndex(vars, 0, false)); - b.string("]"); - - return b.build(); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetValue(vars)); - b.end(2); - - b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean alwaysBoxed() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java deleted file mode 100644 index 127c921e5239..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadConstantInstruction.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class LoadConstantInstruction extends Instruction { - - public LoadConstantInstruction(OperationsContext ctx, int id) { - super(ctx, "load.constant", id, 1); - addConstant("constant", ProcessorContext.getInstance().getType(Object.class)); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.tree(createGetArgument(vars, FrameKind.OBJECT)); - b.end(2); - - b.startAssign(vars.sp).variable(vars.sp).string(" + 1").end(); - - return b.build(); - - } - - private CodeTree createGetArgument(ExecutionVariables vars, FrameKind kind) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (kind != FrameKind.OBJECT) { - b.string("(", kind.getTypeName(), ") "); - } - if (OperationGeneratorFlags.USE_SIMPLE_BYTECODE) { - b.string("$obj"); - } else { - b.startCall("UFA", "unsafeObjectArrayRead"); - b.variable(vars.consts); - b.tree(createConstantIndex(vars, 0)); - b.end(); - } - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean alwaysBoxed() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java deleted file mode 100644 index f0f73cbd0ca6..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalInstruction.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.combineBoxingBits; -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; - -import java.util.List; -import java.util.Set; - -import javax.lang.model.element.Modifier; -import javax.lang.model.type.TypeMirror; - -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class LoadLocalInstruction extends Instruction { - - private final boolean boxed; - - public LoadLocalInstruction(OperationsContext ctx, int id, boolean boxed) { - super(ctx, "load.local" + (boxed ? ".boxed" : ""), id, 1); - this.boxed = boxed; - addLocal("local"); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); - - if (ctx.getData().enableYield) { - b.startStatement().startCall("UFA", "unsafeCopyTo"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.variable(vars.stackFrame); - b.string("$sp"); - b.string("1"); - b.end(2); - } else { - b.startStatement().startCall("UFA", "unsafeCopyObject"); - b.variable(vars.stackFrame); - b.string("localIdx"); - b.string("$sp"); - b.end(2); - } - - b.statement("$sp += 1"); - - return b.build(); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - - boolean useBoxed = vars.specializedKind != FrameKind.OBJECT && boxed; - - String helperName = "do_loadLocal" + (useBoxed ? "Boxed" : "") + "_" + (ctx.hasBoxingElimination() ? vars.specializedKind : ""); - OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { - CodeExecutableElement res = new CodeExecutableElement(Set.of(Modifier.STATIC, Modifier.PRIVATE), context.getType(void.class), helperName); - - res.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); - res.addParameter(vars.stackFrame); - if (ctx.getData().enableYield) { - res.addParameter(vars.localFrame); - } - res.addParameter(vars.bc); - res.addParameter(vars.bci); - res.addParameter(vars.sp); - if (ctx.hasBoxingElimination()) { - res.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); - } - res.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); - - CodeTreeBuilder b = res.createBuilder(); - - if (ctx.hasBoxingElimination()) { - FrameKind kind = vars.specializedKind; - if (kind == FrameKind.OBJECT) { - b.statement("Object value"); - // this switch should be made to fold - b.startSwitch().startCall("UFA", "unsafeGetTag").variable(vars.localFrame).string("localIdx").end(2).startBlock(); - for (FrameKind localKind : ctx.getBoxingKinds()) { - b.startCase().string(localKind.toOrdinal()).end().startCaseBlock(); - - b.startAssign("value").startCall("UFA", "unsafeUncheckedGet" + localKind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + localKind + " (as OBJECT)%n\", localIdx, $frame.getValue(localIdx))"); - } - - b.statement("break"); - - b.end(); - } - - b.caseDefault().startCaseBlock(); - b.tree(GeneratorUtils.createShouldNotReachHere()); - b.end(); - - b.end(); // switch - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("value"); - b.end(2); - - b.returnStatement(); - } else { - b.startTryBlock(); - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.variable(vars.sp); - - b.startGroup(); - if (boxed) { - b.string("(", kind.getTypeName() + ") "); - b.startCall("UFA", "unsafeGetObject"); - } else { - b.startCall("UFA", "unsafeGet" + kind.getFrameName()); - } - b.variable(vars.localFrame); - b.string("localIdx"); - b.end(2); - - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS) { - b.statement("System.err.printf(\" [load] local=%d value=%s kind=" + kind + " boxed=" + boxed + "%n\", localIdx, $frame.getValue(localIdx))"); - } - - b.returnStatement(); - - if (boxed) { - b.end().startCatchBlock(new TypeMirror[]{types.FrameSlotTypeException, context.getType(ClassCastException.class)}, "ex"); - } else { - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - } - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); - - b.startIf().string("result instanceof " + kind.getTypeNameBoxed()).end().startBlock(); - - b.startIf().startCall("UFA", "unsafeByteArrayRead").string("localTags").string("localIdx").end().string(" == 7").end().startBlock(); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + " (boxed)%n\", localIdx, $frame.getValue(localIdx))"); - } - - b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalBoxed, kind))); - - b.end().startElseBlock(); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=OBJECT->" + kind + "%n\", localIdx, $frame.getValue(localIdx))"); - } - - b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); - b.string("localTags"); - b.string("localIdx"); - b.string("(byte) ", kind.toOrdinal()); - b.end(2); - - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()).variable(vars.localFrame).string("localIdx").string("(", kind.getTypeName(), ") result").end(2); - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()).variable(vars.stackFrame).variable(vars.sp).string("(", kind.getTypeName(), ") result").end(2); - b.returnStatement(); - - b.end(); // if tag - b.end(); // if instanceof - b.end(); // try - } - - if (kind != FrameKind.OBJECT) { - b.startAssign("Object result").startCall(vars.localFrame, "getValue").string("localIdx").end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_LOADS_SPEC) { - b.statement("System.err.printf(\" [load-spec] local=%d value=%s kind=" + kind + "->OBJECT boxed=" + boxed + "%n\", localIdx, $frame.getValue(localIdx))"); - } - - b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); - b.string("localTags"); - b.string("localIdx"); - b.string("(byte) 7"); - b.end(2); - - b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.localFrame).string("localIdx").string("result").end(2); - b.startStatement().startCall("UFA", "unsafeSetObject").variable(vars.stackFrame).variable(vars.sp).string("result").end(2); - } - } else { - if (ctx.getData().enableYield) { - b.startStatement().startCall("UFA", "unsafeCopyTo"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.variable(vars.stackFrame); - b.variable(vars.sp); - b.string("1"); - b.end(2); - } else { - b.startStatement().startCall("UFA", "unsafeCopy"); - b.variable(vars.stackFrame); - b.string("localIdx"); - b.variable(vars.sp); - b.end(2); - } - } - - return res; - }); - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (boxed && vars.specializedKind == FrameKind.OBJECT) { - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.tree(createWriteOpcode(vars.bc, vars.bci, combineBoxingBits(ctx, ctx.loadLocalUnboxed, 0))); - } - - b.startAssign("int localIdx"); - b.tree(createLocalIndex(vars, 0, false)); - b.end(); - - b.startStatement().startCall(helperName); - b.string("$this"); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - if (ctx.hasBoxingElimination()) { - b.string("$localTags"); - } - b.string("localIdx"); - b.end(2); - - b.startStatement().variable(vars.sp).string("++").end(); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean neverInUncached() { - return false; - } - - @Override - public boolean splitOnBoxingElimination() { - return true; - } - - @Override - public List getBoxingEliminationSplits() { - return ctx.getBoxingKinds(); - } - - @Override - public boolean alwaysBoxed() { - return boxed; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java deleted file mode 100644 index 82d6ee2e8516..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/LoadLocalMaterializedInstruction.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class LoadLocalMaterializedInstruction extends Instruction { - - public LoadLocalMaterializedInstruction(OperationsContext ctx, int id) { - super(ctx, "load.local.mat", id, 1); - addPopSimple("frame"); - addArgument("index"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration(types.Frame, "outerFrame", (CodeTree) null); - - b.startAssign("outerFrame").cast(types.Frame).startCall("UFA", "unsafeGetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.end(2); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.startCall("outerFrame", "getObject"); - b.tree(createArgumentIndex(vars, 0, false)); - b.end(); - b.end(2); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean alwaysBoxed() { - return true; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java deleted file mode 100644 index 660347977760..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/QuickenedInstruction.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData; - -public class QuickenedInstruction extends CustomInstruction { - - private final CustomInstruction orig; - private final List activeSpecNames; - private final List activeSpecs; - - private static String makeName(CustomInstruction orig, List activeSpecNames) { - StringBuilder sb = new StringBuilder(orig.name); - sb.append(".q"); - for (String activeSpec : activeSpecNames) { - sb.append('.'); - sb.append(activeSpec); - } - - return sb.toString(); - } - - public List getActiveSpecNames() { - return activeSpecNames; - } - - public List getActiveSpecs() { - return activeSpecs; - } - - public CustomInstruction getOrig() { - return orig; - } - - @Override - public String getUniqueName() { - StringBuilder sb = new StringBuilder(getData().getName()); - sb.append("_q"); - for (String activeSpec : activeSpecNames) { - sb.append("_"); - sb.append(activeSpec.replaceAll("[^a-zA-Z0-9_]", "_")); - } - return sb.toString(); - } - - public QuickenedInstruction(OperationsContext ctx, CustomInstruction orig, int id, SingleOperationData data, List activeSpecNames) { - super(ctx, makeName(orig, activeSpecNames), id, data); - this.orig = orig; - this.activeSpecNames = activeSpecNames; - - if (activeSpecNames.isEmpty()) { - data.addWarning("Invalid quickened instruction %s: no specializations defined.", data.getName()); - activeSpecs = new ArrayList<>(); - return; - } - - activeSpecs = new ArrayList<>(data.getNodeData().getSpecializations()); - - // validate specialization names - - boolean hasErrors = false; - outer: for (String activeSpec : activeSpecNames) { - for (SpecializationData spec : activeSpecs) { - if (spec.getId().equals(activeSpec)) { - continue outer; - } - } - - List realSpecNames = data.getNodeData().getSpecializations().stream().map(x -> x.getId()).collect(Collectors.toUnmodifiableList()); - data.addWarning("Invalid specialization id '%s' for operation %s. Expected one of %s.", activeSpec, data.getName(), realSpecNames); - hasErrors = true; - } - - if (hasErrors) { - return; - } - - activeSpecs.removeIf(spec -> { - for (String activeSpec : activeSpecNames) { - if (spec.getId().equals(activeSpec)) { - return false; - } - } - return true; - }); - - orig.addQuickenedVariant(this); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return orig.createPrepareAOT(vars, language, root); - } - - @Override - public void addQuickenedVariant(QuickenedInstruction quick) { - throw new AssertionError("should not add quickened variants to quickened instructions"); - } - - @Override - public boolean neverInUncached() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java deleted file mode 100644 index 765fe0e80951..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ReturnInstruction.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class ReturnInstruction extends Instruction { - - public ReturnInstruction(OperationsContext ctx, int id) { - super(ctx, "return", id, 0); - addPopSimple("value"); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - return createExecuteImpl(vars, false); - } - - private CodeTree createExecuteImpl(ExecutionVariables vars, boolean uncached) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - if (uncached) { - b.statement("uncachedExecuteCount.count--"); - b.startIf().string("uncachedExecuteCount.count <= 0").end().startBlock(); - b.statement("$this.changeInterpreters(COMMON_EXECUTE)"); - b.end().startElseBlock(); - b.statement("$this.uncachedExecuteCount = uncachedExecuteCount.count"); - b.end(); - } - - b.startReturn().string("((").variable(vars.sp).string(" - 1) << 16) | 0xffff").end(); - - return b.build(); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteImpl(vars, true); - } - - @Override - public CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments arguments) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().startCall("calculateLeaves"); - b.startGroup().variable(vars.operationData).end(); - b.end(2); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java deleted file mode 100644 index 0b3464a3d0b0..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ShortCircuitInstruction.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; -import com.oracle.truffle.dsl.processor.operations.SingleOperationData; - -public class ShortCircuitInstruction extends CustomInstruction { - - public ShortCircuitInstruction(OperationsContext ctx, String name, int id, SingleOperationData data) { - super(ctx, name, id, data, 0); - addPopIndexed("value"); - addBranchTarget("end"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - return createExecuteCode(vars, false); - } - - public CodeTree createExecuteCode(ExecutionVariables vars, boolean uncached) { - return null; - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - return createExecuteCode(vars, true); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java deleted file mode 100644 index b27c8ee92d88..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalInstruction.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import static com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils.createWriteOpcode; - -import java.util.Set; - -import javax.lang.model.element.Modifier; - -import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; -import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorFlags; -import com.oracle.truffle.dsl.processor.operations.OperationGeneratorUtils; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class StoreLocalInstruction extends Instruction { - - public StoreLocalInstruction(OperationsContext ctx, int id) { - super(ctx, "store.local", id, 0); - - addPopIndexed("value"); - addLocal("target"); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); - if (ctx.getData().enableYield) { - b.startStatement().startCall("UFA", "unsafeCopyTo"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.string("1"); - b.end(2); - } else { - b.startStatement().startCall("UFA", "unsafeCopyObject"); - b.variable(vars.stackFrame); - b.string("$sp - 1"); - b.string("localIdx"); - b.end(2); - } - - b.statement("$sp -= 1"); - - return b.build(); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - if (ctx.hasBoxingElimination()) { - OperationGeneratorUtils.createHelperMethod(ctx.outerType, "do_storeLocalSpecialize", () -> { - CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), "do_storeLocalSpecialize"); - - ex.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); - ex.addParameter(vars.stackFrame); - if (ctx.getData().enableYield) { - ex.addParameter(vars.localFrame); - } - ex.addParameter(vars.bc); - ex.addParameter(vars.bci); - ex.addParameter(vars.sp); - if (ctx.hasBoxingElimination()) { - ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); - ex.addParameter(new CodeVariableElement(context.getType(int.class), "primitiveTag")); - } - ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); - ex.addParameter(new CodeVariableElement(context.getType(int.class), "sourceSlot")); - - CodeTreeBuilder b = ex.getBuilder(); - - b.tree(GeneratorUtils.createNeverPartOfCompilation()); - - b.startAssign("Object value").startCall(vars.stackFrame, "getValue"); - b.string("sourceSlot"); - b.end(2); - - b.declaration("byte", "curKind", "UFA.unsafeByteArrayRead(localTags, localIdx)"); - - b.declaration("int", "bciOffset", createPopIndexedIndex(vars, 0, false)); - - b.statement("// System.err.printf(\"primitiveTag=%d value=%s %s curKind=%s tag=%s%n\", primitiveTag, value.getClass(), value, curKind, $frame.getTag(sourceSlot))"); - - b.startIf().string("bciOffset != 0").end().startBlock(); - - for (FrameKind primKind : ctx.getPrimitiveBoxingKinds()) { - // todo: use implicit conversions here - - b.startIf(); - b.string("(primitiveTag == 0 || primitiveTag == " + primKind.toOrdinal() + ")"); - b.string(" && (curKind == 0 || curKind == " + primKind.toOrdinal() + ")"); - b.end().startBlock(); - - b.startIf().string("value instanceof ", primKind.getTypeNameBoxed()).end().startBlock(); - - if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { - b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->" + primKind + "%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); - } - - createSetFrameDescriptorKind(vars, b, primKind.toOrdinal()); - createSetPrimitiveTag(vars, b, primKind.toOrdinal()); - createBoxingEliminateChild(vars, b, primKind.toOrdinal()); - - b.startStatement().startCall("UFA", "unsafeSet" + primKind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startGroup().cast(primKind.getType()).string("value").end(); - b.end(2); - - b.returnStatement(); - - b.end(); - - b.end(); - } - - if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { - b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->OBJECT%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); - } - - createBoxingEliminateChild(vars, b, "0 /* OBJECT */"); - - b.end(); - - createSetFrameDescriptorKind(vars, b, "7 /* generic */"); - createSetPrimitiveTag(vars, b, "7 /* generic */"); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.string("value"); - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_STORES_SPEC) { - b.statement("System.err.printf(\" [store-spec] local=%d value=%s kind=%d->GENERIC%n\", localIdx, $frame.getValue(sourceSlot), curKind)"); - } - - return ex; - }); - } - - String helperName = ctx.hasBoxingElimination() ? "do_storeLocal_" + vars.specializedKind : "do_storeLocal"; - OperationGeneratorUtils.createHelperMethod(ctx.outerType, helperName, () -> { - CodeExecutableElement ex = new CodeExecutableElement(Set.of(Modifier.PRIVATE, Modifier.STATIC), context.getType(void.class), helperName); - - ex.addParameter(new CodeVariableElement(ctx.outerType.asType(), "$this")); - ex.addParameter(vars.stackFrame); - if (ctx.getData().enableYield) { - ex.addParameter(vars.localFrame); - } - ex.addParameter(vars.bc); - ex.addParameter(vars.bci); - ex.addParameter(vars.sp); - if (ctx.hasBoxingElimination()) { - ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localTags")); - } - ex.addParameter(new CodeVariableElement(context.getType(int.class), "localIdx")); - - CodeTreeBuilder b = ex.getBuilder(); - - b.startAssign("int sourceSlot").variable(vars.sp).string(" - 1").end(); - - if (!ctx.hasBoxingElimination()) { - createCopyObject(vars, b); - } else { - b.declaration("byte", "curKind", "UFA.unsafeByteArrayRead(localTags, localIdx)"); - FrameKind kind = vars.specializedKind; - if (kind == FrameKind.OBJECT) { - // this is the uninitialized case - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - createCallSpecialize(vars, b, FrameKind.OBJECT); - } else if (kind != null) { - // primitive case - - b.startIf().string("curKind == " + kind.toOrdinal()).end().startBlock(); - - b.startTryBlock(); - - b.startStatement().startCall("UFA", "unsafeSet" + kind.getFrameName()); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall("UFA", "unsafeGet" + kind.getFrameName()); - b.variable(vars.stackFrame); - b.string("sourceSlot"); - b.end(); - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=" + kind + "%n\", localIdx, $frame.getValue(sourceSlot))"); - } - - b.returnStatement(); - - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - b.end(); // try catch - - b.end(); // if - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - createCallSpecialize(vars, b, kind); - } else { - // generic case - b.startTryBlock(); - - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall("UFA", "unsafeGetObject"); - b.variable(vars.stackFrame); - b.string("sourceSlot"); - b.end(); - b.end(2); - - if (OperationGeneratorFlags.LOG_LOCAL_STORES) { - b.statement("System.err.printf(\" [store] loacl=%d value=%s kind=GENERIC%n\", localIdx, $frame.getValue(sourceSlot))"); - } - - b.end().startCatchBlock(types.FrameSlotTypeException, "ex"); - - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); - b.startStatement().startCall("UFA", "unsafeSetObject"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.startCall(vars.stackFrame, "getValue"); - b.string("sourceSlot"); - b.end(); - b.end(2); - - b.end(); - } - } - - return ex; - }); - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startAssign("int localIdx").tree(createLocalIndex(vars, 0, false)).end(); - - b.startStatement().startCall(helperName); - b.string("$this"); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - if (ctx.hasBoxingElimination()) { - b.string("$localTags"); - } - b.string("localIdx"); - b.end(2); - - b.startStatement().variable(vars.sp).string("--").end(); - - return b.build(); - } - - private static final boolean USE_SPEC_FRAME_COPY = true; - - private void createCopyObject(ExecutionVariables vars, CodeTreeBuilder b) { - b.startStatement(); - if (ctx.getData().enableYield) { - b.startCall(vars.stackFrame, "copyTo"); - b.string("sourceSlot"); - b.variable(vars.localFrame); - b.string("localIdx"); - b.string("1"); - } else { - b.startCall("UFA", USE_SPEC_FRAME_COPY ? "unsafeCopyObject" : "unsafeCopy"); - b.variable(vars.localFrame); - b.string("sourceSlot"); - b.string("localIdx"); - } - b.end(2); - } - - private void createCallSpecialize(ExecutionVariables vars, CodeTreeBuilder b, FrameKind kind) { - b.startStatement().startCall("do_storeLocalSpecialize"); - b.string("$this"); - b.variable(vars.stackFrame); - if (ctx.getData().enableYield) { - b.variable(vars.localFrame); - } - b.variable(vars.bc); - b.variable(vars.bci); - b.variable(vars.sp); - b.string("localTags"); - if (ctx.hasBoxingElimination()) { - b.string(kind.toOrdinal()); - } - b.string("localIdx"); - b.string("sourceSlot"); - b.end(2); - } - - @SuppressWarnings("unused") - private static void createSetFrameDescriptorKind(ExecutionVariables vars, CodeTreeBuilder b, String kind) { - b.startStatement().startCall("UFA", "unsafeByteArrayWrite"); - b.string("localTags"); - b.string("localIdx"); - b.string("(byte) " + kind); - b.end(2); - } - - private void createSetPrimitiveTag(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.tree(createWriteOpcode(vars.bc, vars.bci, OperationGeneratorUtils.combineBoxingBits(ctx, this, tag))); - } - - private static void createBoxingEliminateChild(ExecutionVariables vars, CodeTreeBuilder b, String tag) { - b.tree(OperationGeneratorUtils.callSetResultBoxed(CodeTreeBuilder.singleString("bciOffset"), CodeTreeBuilder.singleString(tag))); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean neverInUncached() { - return false; - } - - @Override - public boolean splitOnBoxingElimination() { - return true; - } - - @Override - public boolean hasGeneric() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java deleted file mode 100644 index c55c20b4c5e0..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/StoreLocalMaterializedInstruction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class StoreLocalMaterializedInstruction extends Instruction { - - public StoreLocalMaterializedInstruction(OperationsContext ctx, int id) { - super(ctx, "store.local.mat", id, 0); - addPopSimple("frame"); - addPopSimple("value"); - addArgument("index"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.declaration(types.Frame, "outerFrame", (CodeTree) null); - - b.startAssign("outerFrame").cast(types.Frame).startCall("UFA", "unsafeGetObject"); - b.variable(vars.stackFrame); - b.string("$sp - 2"); - b.end(2); - - b.startStatement().startCall("outerFrame", "setObject"); - b.tree(createArgumentIndex(vars, 0, false)); - b.startCall("UFA", "unsafeGetObject").variable(vars.stackFrame).string("$sp - 1").end(); - b.end(2); - - b.statement("$sp -= 2"); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java deleted file mode 100644 index bef81efe5ee6..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/SuperInstruction.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import java.util.List; -import java.util.function.Function; - -import javax.lang.model.type.ArrayType; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class SuperInstruction extends Instruction { - - private final Instruction[] instructions; - - public Instruction[] getInstructions() { - return instructions; - } - - public SuperInstruction(OperationsContext ctx, int id, Instruction... instrs) { - super(ctx, makeName(instrs), id, 0); - this.instructions = instrs; - } - - private static String makeName(Instruction[] instrs) { - StringBuilder sb = new StringBuilder("si"); - for (Instruction i : instrs) { - sb.append("."); - sb.append(i.name); - } - - return sb.toString(); - } - - private static void createExecute(CodeTreeBuilder b, ExecutionVariables vars, Instruction instr, Function exec) { - // todo: merge this with OpByCoGe code, since now we have duplication (and probably bugs) - if (instr.splitOnBoxingElimination()) { - b.startSwitch().string("unsafeFromBytecode($bc, $bci) & 7").end().startBlock(); - - for (FrameKind kind : instr.getBoxingEliminationSplits()) { - b.startCase().string(kind.toOrdinal()).end().startBlock(); - vars.specializedKind = kind; - b.tree(exec.apply(vars)); - vars.specializedKind = null; - b.statement("break"); - b.end(); - } - - if (instr.hasGeneric()) { - b.startCase().string("7 /* generic */").end().startBlock(); - b.tree(exec.apply(vars)); - b.statement("break"); - b.end(); - } - - b.end(); - } else if (instr.numPushedValues == 0 || instr.alwaysBoxed()) { - b.tree(exec.apply(vars)); - } else { - b.startBlock(); - b.declaration("int", "primitiveTag", "unsafeFromBytecode($bc, $bci) & 7"); - b.tree(exec.apply(vars)); - b.end(); - } - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - for (Instruction instr : instructions) { - createExecute(b, vars, instr, instr::createExecuteCode); - if (!instr.isExplicitFlowControl()) { - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); - } - } - - return b.build(); - } - - @Override - public CodeTree createExecuteUncachedCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - for (Instruction instr : instructions) { - b.startBlock(); - b.tree(instr.createExecuteUncachedCode(vars)); - if (!instr.isExplicitFlowControl()) { - b.startAssign(vars.bci).variable(vars.bci).string(" + ").tree(instr.createLength()).end(); - } - b.end(); - } - - return b.build(); - } - - @Override - public boolean isExplicitFlowControl() { - for (Instruction i : instructions) { - if (i.isExplicitFlowControl()) { - return true; - } - } - return false; - } - - @Override - public int length() { - int len = 0; - for (Instruction i : instructions) { - len += i.length(); - } - - return len; - } - - @Override - public CodeTree createDumpCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.statement("int oldBci = $bci"); - - b.startAssign("Object[] decSuper"); - b.startNewArray((ArrayType) context.getType(Object[].class), null); - b.string("$bci"); - b.doubleQuote(name); - b.startGroup().string("Arrays.copyOfRange($bc, $bci, $bci + ").tree(createLength()).string(")").end(); - b.startNewArray((ArrayType) context.getType(Object[].class), null).end(); - b.startNewArray((ArrayType) context.getType(Object[].class), CodeTreeBuilder.singleString("" + instructions.length)).end(); - b.end(2); // outer array, assign - - for (int i = 0; i < instructions.length; i++) { - b.startBlock(); - b.tree(instructions[i].createDumpCode(vars)); - b.startAssign("((Object[]) decSuper[4])[" + i + "]").string("dec").end(); - b.end(); - - b.startStatement().string("$bci += ").tree(instructions[i].createLength()).end(); - } - - b.startAssign("Object[] dec").string("decSuper").end(); - - b.statement("$bci = oldBci"); - - return b.build(); - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - // todo: implement - return null; - } - - @Override - public boolean alwaysBoxed() { - return instructions[0].alwaysBoxed(); - } - - @Override - public List getBoxingEliminationSplits() { - return instructions[0].getBoxingEliminationSplits(); - } - - @Override - public boolean splitOnBoxingElimination() { - return false; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java deleted file mode 100644 index 13f8971a478a..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/ThrowInstruction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; - -public class ThrowInstruction extends Instruction { - public ThrowInstruction(OperationsContext ctx, int id) { - super(ctx, "throw", id, 0); - addLocal("exception"); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - // todo: since we do not have a typecheck in a catch - // we can convert this to a jump to a statically determined handler - // or a throw out of a function - - b.startAssign("int slot").tree(createLocalIndex(vars, 0, false)).end(); - - b.startThrow(); - b.cast(ProcessorContext.getInstance().getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException")); - b.startCall("UFA", "unsafeUncheckedGetObject").variable(vars.stackFrame).string("slot").end(); - b.end(); - - return b.build(); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java deleted file mode 100644 index be3993cc3e73..000000000000 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/instructions/YieldInstruction.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.dsl.processor.operations.instructions; - -import com.oracle.truffle.dsl.processor.java.model.CodeTree; -import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.operations.OperationsContext; -import com.oracle.truffle.dsl.processor.operations.Operation.BuilderVariables; - -public class YieldInstruction extends Instruction { - - private static final String CONTINUATION_POINT = "continuation-point"; - - public YieldInstruction(OperationsContext ctx, int id) { - super(ctx, "yield", id, 1); - addPopSimple("value"); - addConstant(CONTINUATION_POINT, null); - } - - @Override - protected CodeTree createCustomEmitCode(BuilderVariables vars, EmitArguments args) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.startIf().string("yieldLocations == null").end().startBlock(); - b.statement("yieldLocations = new ContinuationLocationImpl[8]"); - b.end().startElseIf().string("yieldLocations.length <= yieldCount").end().startBlock(); - b.statement("yieldLocations = Arrays.copyOf(yieldLocations, yieldCount * 2)"); - b.end(); - return b.build(); - } - - @Override - protected CodeTree createConstantInitCode(BuilderVariables vars, EmitArguments args, Object marker, int index) { - if (!CONTINUATION_POINT.equals(marker) && index != 0) { - throw new AssertionError(); - } - - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - b.string("yieldLocations[yieldCount] = "); - - b.startNew("ContinuationLocationImpl"); - b.string("yieldCount++"); - b.startGroup().string("(curStack << 16) | (bci + ").tree(createLength()).string(")").end(); - b.end(); - return b.build(); - } - - @Override - public CodeTree createExecuteCode(ExecutionVariables vars) { - CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); - - b.startStatement().string("ContinuationLocationImpl cont = (ContinuationLocationImpl) $consts[").tree(createConstantIndex(vars, 0)).string("]").end(); - b.statement("$stackFrame.copyTo($this._maxLocals, $localFrame, $this._maxLocals, ($sp - 1 - $this._maxLocals))"); - b.statement("$stackFrame.setObject($sp - 1, cont.createResult($localFrame, $stackFrame.getObject($sp - 1)))"); - - b.startReturn().string("(($sp - 1) << 16) | 0xffff").end(); - - return b.build(); - } - - @Override - public boolean isExplicitFlowControl() { - return true; - } - - @Override - public CodeTree createPrepareAOT(ExecutionVariables vars, CodeTree language, CodeTree root) { - return null; - } - - @Override - public boolean alwaysBoxed() { - return true; - } -} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java index 7f4e273c161a..6d127bdec3fb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java @@ -41,7 +41,9 @@ package com.oracle.truffle.dsl.processor.operations.model; import java.util.Arrays; +import java.util.Set; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; @@ -85,6 +87,7 @@ public static class CustomSignature { public boolean[] valueBoxingElimination; public boolean resultBoxingElimination; + public Set possibleBoxingResults; public boolean isVoid; public int localSetterCount; @@ -97,7 +100,11 @@ public String toString() { if (isVoid) { sb.append("void "); } else if (resultBoxingElimination) { - sb.append("box "); + if (possibleBoxingResults != null) { + sb.append(possibleBoxingResults).append(" "); + } else { + sb.append("box "); + } } else { sb.append("obj "); } @@ -135,7 +142,9 @@ public String toString() { public final int id; public final OperationKind kind; public final String name; + public final TypeElement templateType; + public AnnotationMirror proxyMirror; public boolean isTransparent; public boolean isVoid; @@ -209,6 +218,11 @@ public Element getMessageElement() { return templateType; } + @Override + public AnnotationMirror getMessageAnnotation() { + return proxyMirror; + } + @Override public MessageContainer getBaseContainer() { return parent; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 7a5c6e66f296..33e7be2c5738 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -41,16 +41,19 @@ package com.oracle.truffle.dsl.processor.operations.parser; import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getTypeElement; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; import static com.oracle.truffle.dsl.processor.java.ElementUtils.typeEquals; import static javax.lang.model.element.Modifier.ABSTRACT; +import static javax.lang.model.element.Modifier.PUBLIC; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Consumer; @@ -124,6 +127,10 @@ protected OperationModel parse(Element element, List ignored) OperationModel data = parent.operation(te, kind, name); + if (mirror != null) { + data.proxyMirror = mirror; + } + boolean isNode = isAssignable(te.asType(), types.NodeInterface); if (!isNode) { @@ -188,6 +195,8 @@ protected OperationModel parse(Element element, List ignored) nodeType.setSuperClass(types.Node); } + nodeType.setEnclosingElement(null); + CustomSignature signature = determineSignature(data, nodeType); if (data.hasErrors()) { return data; @@ -259,27 +268,48 @@ private CodeAnnotationMirror createNodeChildAnnotation(String name, TypeMirror r } private CodeTypeElement createNodeChildType(TypeMirror regularReturn, TypeMirror... unexpectedReturns) { - CodeTypeElement c = new CodeTypeElement(Set.of(), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); + CodeTypeElement c = new CodeTypeElement(Set.of(PUBLIC, ABSTRACT), ElementKind.CLASS, new GeneratedPackageElement(""), "C"); c.setSuperClass(types.Node); - c.add(new CodeExecutableElement(regularReturn, "execute")); - + c.add(createNodeChildExecute("execute", regularReturn, false)); for (TypeMirror ty : unexpectedReturns) { - c.add(new CodeExecutableElement(ty, "execute" + firstLetterUpperCase(getSimpleName(ty)))).addThrownType(types.UnexpectedResultException); + c.add(createNodeChildExecute("execute" + firstLetterUpperCase(getSimpleName(ty)), ty, true)); } return c; } + private CodeExecutableElement createNodeChildExecute(String name, TypeMirror returnType, boolean withUnexpected) { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC, ABSTRACT), returnType, name); + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + + if (withUnexpected) { + ex.addThrownType(types.UnexpectedResultException); + } + + return ex; + } + private List createExecuteMethods(CustomSignature signature) { List result = new ArrayList<>(); if (signature.isVoid) { result.add(createExecuteMethod(signature, "executeVoid", context.getType(void.class), false, false)); } else { - result.add(createExecuteMethod(signature, "execute", context.getType(Object.class), false, false)); + result.add(createExecuteMethod(signature, "executeObject", context.getType(Object.class), false, false)); - for (TypeMirror ty : parent.boxingEliminatedTypes) { + List boxingEliminatedTypes; + if (parent.boxingEliminatedTypes.isEmpty() || !signature.resultBoxingElimination) { + boxingEliminatedTypes = new ArrayList<>(); + } else if (signature.possibleBoxingResults == null) { + boxingEliminatedTypes = new ArrayList<>(parent.boxingEliminatedTypes); + } else { + boxingEliminatedTypes = new ArrayList<>(signature.possibleBoxingResults); + } + + boxingEliminatedTypes.sort((o1, o2) -> getQualifiedName(o1).compareTo(getQualifiedName(o2))); + + for (TypeMirror ty : boxingEliminatedTypes) { result.add(createExecuteMethod(signature, "execute" + firstLetterUpperCase(getSimpleName(ty)), ty, true, false)); } } @@ -296,7 +326,7 @@ private List createExecuteMethods(CustomSignature signatu } private CodeExecutableElement createExecuteMethod(CustomSignature signature, String name, TypeMirror type, boolean withUnexpected, boolean uncached) { - CodeExecutableElement ex = new CodeExecutableElement(Set.of(ABSTRACT), type, name); + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC, ABSTRACT), type, name); if (withUnexpected) { ex.addThrownType(types.UnexpectedResultException); } @@ -330,7 +360,7 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl instr.signature = signature; try { - NodeParser parser = NodeParser.createDefaultParser(); + NodeParser parser = NodeParser.createOperationParser(); instr.nodeData = parser.parse(nodeType); } catch (Throwable ex) { StringWriter wr = new StringWriter(); @@ -342,12 +372,13 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl data.addError("Error generating node: invalid node definition."); return instr; } -// -// if (instr.nodeData.getTypeSystem().isDefault()) { -// instr.nodeData.setTypeSystem(parent.typeSystem); -// } - instr.nodeData.redirectMessages(data); + if (instr.nodeData.getTypeSystem().isDefault()) { + instr.nodeData.setTypeSystem(parent.typeSystem); + } + + instr.nodeData.redirectMessages(parent); + instr.nodeData.redirectMessagesOnGeneratedElements(parent); return instr; } @@ -420,6 +451,13 @@ private boolean mergeSignatures(OperationModel data, CustomSignature a, CustomSi } a.resultBoxingElimination = a.resultBoxingElimination || b.resultBoxingElimination; + + if (a.possibleBoxingResults == null || b.possibleBoxingResults == null) { + a.possibleBoxingResults = null; + } else { + a.possibleBoxingResults.addAll(b.possibleBoxingResults); + } + for (int i = 0; i < a.valueBoxingElimination.length; i++) { a.valueBoxingElimination[i] = a.valueBoxingElimination[i] || b.valueBoxingElimination[i]; } @@ -506,14 +544,27 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen CustomSignature signature = new CustomSignature(); signature.valueCount = numValues; signature.isVariadic = hasVariadic; - signature.resultBoxingElimination = parent.isBoxingEliminated(spec.getReturnType()); signature.localSetterCount = numLocalSetters; signature.localSetterRangeCount = numLocalSetterRanges; signature.valueBoxingElimination = new boolean[numValues]; for (int i = 0; i < numValues; i++) { signature.valueBoxingElimination[i] = canBeBoxingEliminated.get(i); } - signature.isVoid = ElementUtils.isVoid(spec.getReturnType()); + + TypeMirror returnType = spec.getReturnType(); + if (ElementUtils.isVoid(spec.getReturnType())) { + signature.isVoid = true; + signature.resultBoxingElimination = false; + } else if (parent.isBoxingEliminated(returnType)) { + signature.resultBoxingElimination = true; + signature.possibleBoxingResults = new HashSet<>(Set.of(returnType)); + } else if (ElementUtils.isObject(returnType)) { + signature.resultBoxingElimination = false; + signature.possibleBoxingResults = null; + } else { + signature.resultBoxingElimination = false; + signature.possibleBoxingResults = new HashSet<>(Set.of(context.getType(Object.class))); + } return signature; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 41c2817f3308..1f68660e0a97 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -159,7 +159,7 @@ public final class NodeParser extends AbstractParser { public enum ParseMode { DEFAULT, EXPORTED_MESSAGE, - OPERATION + OPERATION, } private boolean nodeOnly; @@ -169,7 +169,6 @@ public enum ParseMode { private final boolean substituteThisToParent; private final List cachedAnnotations; - private TypeElement operationType; private NodeParser(ParseMode mode, TypeMirror exportLibraryType, TypeElement exportDeclarationType, boolean substituteThisToParent) { this.mode = mode; @@ -195,10 +194,8 @@ public static NodeParser createDefaultParser() { return new NodeParser(ParseMode.DEFAULT, null, null, false); } - public static NodeParser createOperationParser(TypeElement operationType) { - NodeParser nodeParser = new NodeParser(ParseMode.OPERATION, null, null, true); - nodeParser.operationType = operationType; - return nodeParser; + public static NodeParser createOperationParser() { + return new NodeParser(ParseMode.OPERATION, null, null, false); } @Override @@ -254,7 +251,7 @@ private NodeData parseRootType(TypeElement rootType) { } catch (CompileErrorException e) { throw e; } catch (Throwable e) { - RuntimeException e2 = new RuntimeException(String.format("Parsing of Node %s failed", getQualifiedName(rootType))); + RuntimeException e2 = new RuntimeException(String.format("Parsing of Node %s failed.", getQualifiedName(rootType))); e.addSuppressed(e2); throw e; } @@ -292,6 +289,10 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } + if (mode == ParseMode.DEFAULT && findAnnotationMirror(templateType.getAnnotationMirrors(), types.Operation) != null) { + return null; + } + List lookupTypes = collectSuperClasses(new ArrayList(), templateType); NodeData node = parseNodeData(templateType, lookupTypes); @@ -1630,6 +1631,10 @@ private List parseExecutableTypeData(NodeData node, List 0 && executions.size() == node.getMinimalEvaluatedParameters()) { + if (nodeChildDeclarations > 0 && executions.size() == node.getMinimalEvaluatedParameters()) { for (NodeChildData child : node.getChildren()) { child.addError("Unnecessary @NodeChild declaration. All evaluated child values are provided as parameters in execute methods."); } @@ -1806,8 +1811,7 @@ private void initializeChildren(NodeData node) { child.addError("Node type '%s' is invalid or not a subclass of Node.", getQualifiedName(nodeType)); } else { if (child.isImplicit() || child.isAllowUncached()) { - DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList(), mode, - operationType == null ? types.Node : operationType.asType()); + DSLExpressionResolver resolver = new DSLExpressionResolver(context, node.getTemplateType(), Collections.emptyList()); resolver = importStatics(resolver, node.getNodeType()); if (NodeCodeGenerator.isSpecializedNode(nodeType)) { List executables = parseNodeFactoryMethods(nodeType); @@ -1829,8 +1833,8 @@ private void initializeChildren(NodeData node) { List foundTypes = child.findGenericExecutableTypes(); if (foundTypes.isEmpty()) { AnnotationValue executeWithValue = child.getExecuteWithValue(); - child.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s and frame types %s.", child.getExecuteWith().size(), - getSimpleName(nodeType), getUniqueIdentifiers(createAllowedChildFrameTypes(node))); + child.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s and frame types %s. Found: %s", child.getExecuteWith().size(), + getSimpleName(nodeType), getUniqueIdentifiers(createAllowedChildFrameTypes(node)), child.getNodeData().getExecutableTypes(-1)); } } } @@ -1853,7 +1857,7 @@ private NodeData parseChildNodeData(NodeData parentNode, NodeChildData child, Ty // Declaration order is not required for child nodes. List members; if (templateType instanceof CodeTypeElement) { - members = ((CodeTypeElement) templateType).getEnclosedElements(); + members = templateType.getEnclosedElements(); } else { members = processingEnv.getElementUtils().getAllMembers(templateType); } @@ -2185,11 +2189,7 @@ private void initializeExpressions(List elements, NodeData no List globalMembers = new ArrayList<>(members.size() + fields.size()); globalMembers.addAll(fields); globalMembers.addAll(members); - globalMembers.add(new CodeVariableElement(types.Node, "this")); - if (mode == ParseMode.OPERATION) { - globalMembers.add(new CodeVariableElement(context.getType(int.class), "$bci")); - } - DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers, mode, operationType == null ? types.Node : operationType.asType()); + DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); // the number of specializations might grow while expressions are initialized. List specializations = node.getSpecializations(); @@ -2326,12 +2326,6 @@ private SpecializationData initializeCaches(SpecializationData specialization, D if (cache.isCached()) { boolean weakReference = getAnnotationValue(Boolean.class, foundCached, "weak"); - if (mode == ParseMode.OPERATION) { - specialization.setHasCachedExpression(true); - if (ElementUtils.isPrimitive(cache.getParameter().getType())) { - cache.addError("Cahced parameters with primitive types not allowed in Operation DSL."); - } - } if (weakReference) { if (ElementUtils.isPrimitive(cache.getParameter().getType())) { cache.addError("Cached parameters with primitive types cannot be weak. Set weak to false to resolve this."); From 3b45243658afafbf075a389cf1d4c82694b5f7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 20 Dec 2022 17:34:05 +0100 Subject: [PATCH 182/312] [wip] more generator --- .../test/example/TestOperations.java | 22 +- .../generator/FlatNodeGenFactory.java | 66 ++- .../generator/NodeGeneratorPlugs.java | 27 ++ .../OperationNodeGeneratorPlugs.java | 99 ++++ .../generator/OperationsNodeFactory.java | 447 +++++++++++++++--- .../operations/model/InstructionModel.java | 72 +++ .../operations/model/OperationsModel.java | 10 +- .../parser/CustomOperationParser.java | 26 +- .../operations/parser/OperationsParser.java | 32 +- .../sl/operations/SLOperationRootNode.java | 18 +- .../sl/parser/SLOperationsVisitor.java | 16 +- 11 files changed, 728 insertions(+), 107 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index 035957f10eb9..3b59d1b09bff 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -119,14 +120,14 @@ public static long bla(long a1, @Variadic Object[] a2) { } } -// @Operation -// @GenerateAOT -// static final class ThrowOperation { -// @Specialization -// public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { -// throw new TestException("fail", node, bci); -// } -// } + @Operation + @GenerateAOT + static final class ThrowOperation { + @Specialization + public static Object perform(@Bind("$bci") int bci, @Bind("this") Node node) { + throw new TestException("fail", node, bci); + } + } @Operation static final class AlwaysBoxOperation { @@ -138,9 +139,10 @@ public static Object perform(Object value) { @Operation static final class AppenderOperation { + @SuppressWarnings("unchecked") @Specialization - public static void perform(List list, Object value) { - list.add(value); + public static void perform(List list, Object value) { + ((List) list).add(value); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index d12212a2e7b5..ba002ea3fff6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -199,6 +199,7 @@ public String toString() { private final boolean needsSpecializeLocking; private final GeneratorMode generatorMode; + private final NodeGeneratorPlugs plugs; public enum GeneratorMode { DEFAULT, @@ -210,11 +211,24 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants); } + public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, + StaticConstants constants, NodeGeneratorPlugs plugs) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, plugs); + } + public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, StaticConstants constants) { + this(context, mode, node, stateSharingNodes, sharedCaches, constants, NodeGeneratorPlugs.DEFAULT); + } + + public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, + Collection stateSharingNodes, + Map sharedCaches, + StaticConstants constants, NodeGeneratorPlugs plugs) { Objects.requireNonNull(node); + this.plugs = plugs; this.generatorMode = mode; this.context = context; this.sharingNodes = stateSharingNodes; @@ -921,6 +935,7 @@ private void generateAOT(CodeTypeElement clazz) { CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), "resetAOT_")); frameState = FrameState.load(this, NodeExecutionMode.FAST_PATH, reset); reset.getModifiers().remove(ABSTRACT); + builder = reset.createBuilder(); for (StateBitSet set : multiState.all) { @@ -1453,6 +1468,7 @@ private Element createFallbackGuard() { ExecutableTypeData executableType = node.findAnyGenericExecutableType(context, -1); CodeExecutableElement method = new CodeExecutableElement(modifiers(PRIVATE), getType(boolean.class), createFallbackName()); + FrameState frameState = FrameState.load(this, NodeExecutionMode.FALLBACK_GUARD, method); if (!frameUsed) { frameState.removeValue(FRAME_VALUE); @@ -2028,7 +2044,8 @@ private CodeExecutableElement createExecuteAndSpecialize() { builder.startIf(); builder.tree(allMultiState.createContains(frameState, new Object[]{AOT_PREPARED})); builder.end().startBlock(); - builder.startStatement().startCall("this.resetAOT_").end().end(); + builder.startStatement().startCall("this.resetAOT_"); + builder.end().end(); builder.end(); } @@ -2261,14 +2278,7 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram for (NodeExecutionData execution : node.getChildExecutions()) { NodeChildData child = execution.getChild(); LocalVariable var = frameState.getValue(execution); - if (child != null && !frameState.getMode().isUncached()) { - builder.string(accessNodeField(execution)); - } else { - builder.string("null"); - } - if (var != null) { - values.add(var.createReference()); - } + plugs.createNodeChildReferenceForException(this, frameState, builder, values, execution, child, var); } builder.end(); builder.trees(values.toArray(new CodeTree[0])); @@ -2277,6 +2287,17 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram } + void createNodeChildReferenceForException(final FrameState frameState, CodeTreeBuilder builder, List values, NodeExecutionData execution, NodeChildData child, LocalVariable var) { + if (child != null && !frameState.getMode().isUncached()) { + builder.string(accessNodeField(execution)); + } else { + builder.string("null"); + } + if (var != null) { + values.add(var.createReference()); + } + } + private CodeTree createFastPath(CodeTreeBuilder parent, List allSpecializations, SpecializationGroup originalGroup, final ExecutableTypeData currentType, FrameState frameState) { final CodeTreeBuilder builder = parent.create(); @@ -2364,6 +2385,7 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group CodeExecutableElement method = parentClass.add(new CodeExecutableElement(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name)); multiState.addParametersTo(frameState, method); frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); + CodeTreeBuilder builder = method.createBuilder(); builder.tree(codeTree); method.getThrownTypes().addAll(parentMethod.getThrownTypes()); @@ -2374,6 +2396,7 @@ private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group parentBuilder.startCall(method.getSimpleName().toString()); multiState.addReferencesTo(frameState, parentBuilder); frameState.addReferencesTo(parentBuilder, FRAME_VALUE); + parentBuilder.end(); parentBuilder.end(); return parentBuilder.build(); @@ -2599,7 +2622,7 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt LocalVariable targetValue) { CodeTreeBuilder builder = parent.create(); - ChildExecutionResult executeChild = createExecuteChild(builder, originalFrameState, frameState, execution, targetValue); + ChildExecutionResult executeChild = plugs.createExecuteChild(this, builder, originalFrameState, frameState, execution, targetValue); builder.tree(createTryExecuteChild(targetValue, executeChild.code, true, executeChild.throwsUnexpectedResult)); builder.end(); if (executeChild.throwsUnexpectedResult) { @@ -2639,7 +2662,7 @@ private ChildExecutionResult createCallSingleChildExecute(NodeExecutionData exec return new ChildExecutionResult(result, executableType.hasUnexpectedValue() || needsCastTo(sourceType, targetType)); } - private ChildExecutionResult createExecuteChild(CodeTreeBuilder parent, FrameState originalFrameState, FrameState frameState, NodeExecutionData execution, LocalVariable target) { + public ChildExecutionResult createExecuteChild(CodeTreeBuilder parent, FrameState originalFrameState, FrameState frameState, NodeExecutionData execution, LocalVariable target) { ChildExecutionResult result; if (!typeSystem.hasImplicitSourceTypes(target.getTypeMirror())) { @@ -3125,6 +3148,10 @@ private CodeExecutableElement createExecuteMethod(ExecutableTypeData executedTyp executable = new CodeExecutableElement(modifiers(PUBLIC), returnType, methodName); } + for (VariableElement arg : plugs.additionalArguments()) { + executable.addParameter(arg); + } + DeclaredType unexpectedResult = types.UnexpectedResultException; Iterator thrownTypes = executable.getThrownTypes().iterator(); while (thrownTypes.hasNext()) { @@ -4464,6 +4491,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, if (useSpecializationClass) { method.addParameter(new CodeVariableElement(context.getType(Object.class), specializationLocalName)); } + CodeTreeBuilder builder = method.createBuilder(); if (needsSpecializeLocking) { builder.declaration(context.getType(Lock.class), "lock", "getLock()"); @@ -4521,6 +4549,7 @@ private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, if (useSpecializationClass) { builder.string(specializationLocalName); } + builder.end().end(); builder.tree(createCallExecuteAndSpecialize(forType, frameState)); return builder.build(); @@ -5383,12 +5412,12 @@ private void wrapWithTraceOnReturn(CodeExecutableElement method) { } } - private static class ChildExecutionResult { + public static class ChildExecutionResult { CodeTree code; final boolean throwsUnexpectedResult; - ChildExecutionResult(CodeTree code, boolean throwsUnexpectedResult) { + public ChildExecutionResult(CodeTree code, boolean throwsUnexpectedResult) { this.code = code; this.throwsUnexpectedResult = throwsUnexpectedResult; } @@ -5641,7 +5670,7 @@ protected int calculateRequiredBits(Object object) { } - static final class FrameState { + public static final class FrameState { private final FlatNodeGenFactory factory; private final Map values = new HashMap<>(); @@ -5835,6 +5864,10 @@ public void addReferencesTo(CodeTreeBuilder builder, String... optionalNames) { builder.startGroup().tree(var.createReference()).end(); } } + + for (VariableElement arg : factory.plugs.additionalArguments()) { + builder.variable(arg); + } } public void addParametersTo(CodeExecutableElement targetMethod, int varArgsThreshold, String... optionalNames) { @@ -5855,6 +5888,9 @@ public void addParametersTo(CodeExecutableElement targetMethod, int varArgsThres } } } + for (VariableElement arg : factory.plugs.additionalArguments()) { + targetMethod.addParameter(arg); + } } @Override @@ -5864,7 +5900,7 @@ public String toString() { } - static final class LocalVariable { + public static final class LocalVariable { private final TypeMirror typeMirror; private final CodeTree accessorTree; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index 4eb1f41f9d19..bb4d48b010fb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -40,7 +40,34 @@ */ package com.oracle.truffle.dsl.processor.generator; +import java.util.List; + +import javax.lang.model.element.VariableElement; + +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ChildExecutionResult; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.model.NodeChildData; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; + public interface NodeGeneratorPlugs { NodeGeneratorPlugs DEFAULT = new NodeGeneratorPlugs() { }; + + default List additionalArguments() { + return List.of(); + } + + default ChildExecutionResult createExecuteChild(FlatNodeGenFactory factory, CodeTreeBuilder builder, FrameState originalFrameState, FrameState frameState, NodeExecutionData execution, + LocalVariable targetValue) { + return factory.createExecuteChild(builder, originalFrameState, frameState, execution, targetValue); + } + + default void createNodeChildReferenceForException(FlatNodeGenFactory flatNodeGenFactory, FrameState frameState, CodeTreeBuilder builder, List values, NodeExecutionData execution, + NodeChildData child, LocalVariable var) { + flatNodeGenFactory.createNodeChildReferenceForException(frameState, builder, values, execution, child, var); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java new file mode 100644 index 000000000000..63c755b1c3fe --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java @@ -0,0 +1,99 @@ +package com.oracle.truffle.dsl.processor.operations.generator; + +import java.util.List; + +import javax.lang.model.element.VariableElement; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ChildExecutionResult; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; +import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.NodeChildData; +import com.oracle.truffle.dsl.processor.model.NodeExecutionData; +import com.oracle.truffle.dsl.processor.model.TemplateMethod; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; + +public class OperationNodeGeneratorPlugs implements NodeGeneratorPlugs { + + private final ProcessorContext context; + private final TruffleTypes types; + private final InstructionModel instr; + + public OperationNodeGeneratorPlugs(ProcessorContext context, InstructionModel instr) { + this.context = context; + this.types = context.getTypes(); + this.instr = instr; + } + + public List additionalArguments() { + return List.of(new CodeVariableElement(context.getType(int.class), "$sp")); + } + + public ChildExecutionResult createExecuteChild(FlatNodeGenFactory factory, CodeTreeBuilder builder, FrameState originalFrameState, FrameState frameState, NodeExecutionData execution, + LocalVariable targetValue) { + + CodeTreeBuilder b = builder.create(); + CodeTree frame = frameState.get(TemplateMethod.FRAME_NAME).createReference(); + + b.string(targetValue.getName(), " = "); + + int index = execution.getIndex(); + + buildChildExecution(b, frame, index); + + return new ChildExecutionResult(b.build(), false); + } + + private void buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx) { + int index = idx; + + if (index < instr.signature.valueCount) { + b.startCall(frame, "getObject").startGroup(); + b.string("$sp"); + if (instr.signature.isVariadic) { + b.string(" - this.op_variadicCount_"); + } + b.string(" - " + (instr.signature.valueCount - index)); + b.end(2); + return; + } + + index -= instr.signature.valueCount; + if (instr.signature.isVariadic) { + if (index == 0) { + b.startCall("readVariadic"); + b.tree(frame); + b.string("$sp"); + b.string("this.op_variadicCount_"); + b.end(); + return; + } + index -= 1; + } + + if (index < instr.signature.localSetterCount) { + b.string("this.op_localSetter" + index + "_"); + return; + } + + index -= instr.signature.localSetterCount; + + if (index < instr.signature.localSetterRangeCount) { + b.string("this.op_localSetterRange" + index + "_"); + return; + } + + throw new AssertionError("index=" + index + ", signature=" + instr.signature); + } + + public void createNodeChildReferenceForException(FlatNodeGenFactory flatNodeGenFactory, FrameState frameState, CodeTreeBuilder builder, List values, NodeExecutionData execution, + NodeChildData child, LocalVariable var) { + builder.string("null"); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 646a7cc58af3..2f01d952c7bc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations.generator; +import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; import static javax.lang.model.element.Modifier.PUBLIC; @@ -47,6 +48,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -80,7 +82,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionField; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; import com.oracle.truffle.dsl.processor.operations.model.OperationModel; +import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; @@ -97,6 +102,11 @@ public class OperationsNodeFactory { private CodeTypeElement operationLocalImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLocalImpl"); private CodeTypeElement operationLabelImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLabelImpl"); + private CodeTypeElement baseInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC, ABSTRACT), ElementKind.CLASS, null, "BaseInterpreter"); + private CodeTypeElement uncachedInterpreter; + private CodeTypeElement cachedInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "CachedInterpreter"); + private CodeTypeElement instrumentableInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "InstrumentableInterpreter"); + private static final Name Uncached_Name = CodeNames.of("Uncached"); public OperationsNodeFactory(ProcessorContext context, OperationsModel model) { @@ -107,12 +117,28 @@ public OperationsNodeFactory(ProcessorContext context, OperationsModel model) { public CodeTypeElement create() { operationNodeGen = GeneratorUtils.createClass(model.templateType, null, Set.of(PUBLIC, FINAL), model.templateType.getSimpleName() + "Gen", model.templateType.asType()); - GeneratorUtils.addSuppressWarnings(context, operationNodeGen, "unused"); + GeneratorUtils.addSuppressWarnings(context, operationNodeGen, "all"); + + if (model.generateUncached) { + uncachedInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "UncachedInterpreter"); + } - // CodeTreeBuilder b = operationsNodeGen.createDocBuilder(); - // b.startDoc(); - // b.lines(model.infodump()); - // b.end(); + CodeTreeBuilder b = operationNodeGen.createDocBuilder(); + b.startDoc(); + b.lines(model.infodump()); + b.end(); + + operationNodeGen.add(new BaseInterpreterFactory().create()); + + if (model.generateUncached) { + operationNodeGen.add(new InterpreterFactory(uncachedInterpreter, true, false).create()); + operationNodeGen.add(createInterpreterSwitch(uncachedInterpreter, "UNCACHED")); + } + + operationNodeGen.add(new InterpreterFactory(cachedInterpreter, false, false).create()); + operationNodeGen.add(new InterpreterFactory(instrumentableInterpreter, false, true).create()); + operationNodeGen.add(createInterpreterSwitch(cachedInterpreter, "CACHED")); + operationNodeGen.add(createInterpreterSwitch(instrumentableInterpreter, "INSTRUMENTABLE")); operationNodeGen.add(new BuilderFactory().create()); operationNodeGen.add(new OperationNodesImplFactory().create()); @@ -133,21 +159,24 @@ public CodeTypeElement create() { operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); + operationNodeGen.add(createInterpreterField()); operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()")); + operationNodeGen.add(createReadVariadic()); + StaticConstants consts = new StaticConstants(); for (InstructionModel instr : model.getInstructions()) { if (instr.nodeData == null) { continue; } - FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts); + FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts, new OperationNodeGeneratorPlugs(context, instr)); - CodeTypeElement el = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, instr.nodeType.getSimpleName() + "Gen"); + CodeTypeElement el = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, instr.getInternalName() + "Gen"); el.setSuperClass(types.Node); factory.create(el); - processNodeType(el); + processNodeType(el, instr); operationNodeGen.add(el); } @@ -156,8 +185,27 @@ public CodeTypeElement create() { return operationNodeGen; } + private CodeVariableElement createInterpreterField() { + CodeVariableElement fld = new CodeVariableElement(Set.of(PRIVATE), baseInterpreter.asType(), "interpreter"); + fld = compFinal(fld); + + if (model.generateUncached) { + fld.createInitBuilder().string("UNCACHED_INTERPRETER"); + } else { + fld.createInitBuilder().string("CACHED_INTERPRETER"); + } + + return fld; + } + + private CodeVariableElement createInterpreterSwitch(CodeTypeElement interpreterType, String name) { + CodeVariableElement fld = new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), interpreterType.asType(), name + "_INTERPRETER"); + fld.createInitBuilder().startNew(interpreterType.asType()).end(); + return fld; + } + @SuppressWarnings("unchecked") - private void processNodeType(CodeTypeElement el) { + private void processNodeType(CodeTypeElement el, InstructionModel instr) { for (VariableElement fld : ElementFilter.fieldsIn(el.getEnclosedElements())) { if (ElementUtils.getQualifiedName(fld.asType()).equals("C")) { el.remove(fld); @@ -173,6 +221,24 @@ private void processNodeType(CodeTypeElement el) { type.setSuperClass(types.Node); } } + + if (instr.needsUncachedData()) { + CodeTypeElement uncachedType = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, el.getSimpleName() + "_UncachedData"); + uncachedType.setSuperClass(types.Node); + uncachedType.setEnclosingElement(operationNodeGen); + operationNodeGen.add(uncachedType); + + el.setSuperClass(uncachedType.asType()); + + for (InstructionField field : instr.getUncachedFields()) { + uncachedType.add(new CodeVariableElement(field.type, field.name)); + } + } + + int index = 0; + for (InstructionField field : instr.getCachedFields()) { + el.getEnclosedElements().add(index++, new CodeVariableElement(field.type, field.name)); + } } private CodeExecutableElement createFrameDescriptorConstructor() { @@ -202,7 +268,18 @@ private CodeExecutableElement createExecute() { CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute"); CodeTreeBuilder b = ex.createBuilder(); - b.returnNull(); + b.statement("int state = numLocals << 16"); + + b.startWhile().string("true").end().startBlock(); + b.statement("state = interpreter.continueAt(frame, bc, objs, state)"); + b.startIf().string("(state & 0xffff) == 0xffff").end().startBlock(); + b.statement("break"); + b.end().startElseBlock(); + b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.end(); + b.end(); + + b.startReturn().string("frame.getObject((state >> 16) & 0xffff)").end(); return ex; } @@ -265,6 +342,28 @@ private CodeExecutableElement createGetIntrospectionData() { return ex; } + private CodeExecutableElement createReadVariadic() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object[].class), "readVariadic"); + + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "variadicCount")); + + ex.addAnnotationMirror(new CodeAnnotationMirror(types.ExplodeLoop)); + + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Object[] result = new Object[variadicCount]"); + + b.startFor().string("int i = 0; i < variadicCount; i++").end().startBlock(); + b.statement("result[i] = frame.getObject(sp - variadicCount + i)"); + b.end(); + + b.statement("return result"); + + return ex; + } + class BuilderFactory { CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState"); @@ -451,7 +550,7 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("operationSp = 0"); b.statement("numLocals = 0"); b.statement("curStack = 0"); - b.statement("maxStack = 0"); + b.statement("maxStack = 10"); } else { b.startStatement().startCall("beforeChild").end(2); } @@ -470,6 +569,9 @@ private void buildOperationBeginData(CodeTreeBuilder b, OperationModel operation b.string("new Object[]{false, arg0}"); break; case BLOCK: + case INSTRUMENT_TAG: + case SOURCE: + case SOURCE_SECTION: b.string("new Object[]{false}"); break; case IF_THEN: @@ -582,25 +684,8 @@ private Element createEnd(OperationModel operation) { return ex; } - if (operation.instruction != null) { - buildEmitInstruction(b, operation.instruction, () -> { - switch (operation.kind) { - case STORE_LOCAL: - case STORE_LOCAL_MATERIALIZED: - case LOAD_LOCAL_MATERIALIZED: - b.string("((OperationLocalImpl) operationData[operationSp]).index"); - break; - case CUSTOM_SIMPLE: - case CUSTOM_SHORT_CIRCUIT: - case RETURN: - case YIELD: - b.string("EPSILON"); - break; - default: - b.string("/* TODO: NOT IMPLEMENTED */"); - break; - } - }); + if (operation.instruction != null && operation.kind != OperationKind.CUSTOM_SHORT_CIRCUIT) { + buildEmitOperationInstruction(b, operation); } b.startStatement().startCall("afterChild"); @@ -614,6 +699,41 @@ private Element createEnd(OperationModel operation) { return ex; } + private void buildEmitOperationInstruction(CodeTreeBuilder b, OperationModel operation) { + b.startBlock(); + switch (operation.kind) { + case STORE_LOCAL: + case STORE_LOCAL_MATERIALIZED: + case LOAD_LOCAL_MATERIALIZED: + b.statement("Object argument = ((OperationLocalImpl) operationData[operationSp]).index"); + break; + case RETURN: + case YIELD: + b.statement("Object argument = EPSILON"); + break; + case LOAD_ARGUMENT: + case LOAD_CONSTANT: + b.statement("Object argument = arg0"); + break; + case LOAD_LOCAL: + b.statement("Object argument = ((OperationLocalImpl) arg0).index"); + break; + case BRANCH: + b.statement("Object argument = ((OperationLabelImpl) arg0).index"); + break; + case CUSTOM_SIMPLE: + case CUSTOM_SHORT_CIRCUIT: + buildCustomInitializer(b, operation, operation.instruction); + break; + default: + b.statement("/* TODO: NOT IMPLEMENTED */"); + break; + } + + buildEmitInstruction(b, operation.instruction, "argument"); + b.end(); + } + private CodeExecutableElement createEmitHelperBegin() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "emitOperationBegin"); @@ -654,27 +774,7 @@ private CodeExecutableElement createEmit(OperationModel operation) { } if (operation.instruction != null) { - buildEmitInstruction(b, operation.instruction, () -> { - switch (operation.kind) { - case LOAD_ARGUMENT: - case LOAD_CONSTANT: - b.string("arg0"); - break; - case LOAD_LOCAL: - b.string("((OperationLocalImpl) arg0).index"); - break; - case BRANCH: - b.string("((OperationLabelImpl) arg0).index"); - break; - case CUSTOM_SIMPLE: - case CUSTOM_SHORT_CIRCUIT: - b.string("EPSILON"); - break; - default: - b.string("/* TODO: NOT IMPLEMENTED */"); - break; - } - }); + buildEmitOperationInstruction(b, operation); } b.startStatement().startCall("afterChild"); @@ -684,6 +784,24 @@ private CodeExecutableElement createEmit(OperationModel operation) { return ex; } + private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, InstructionModel instruction) { + if (model.generateUncached) { + if (!instruction.needsUncachedData()) { + b.statement("Object argument = EPSILON"); + return; + } + + b.statement(instruction.getInternalName() + "Gen_UncachedData argument = new " + instruction.getInternalName() + "Gen_UncachedData()"); + + } else { + b.statement(instruction.getInternalName() + "Gen argument = new " + instruction.getInternalName() + "Gen()"); + } + + if (instruction.signature.isVariadic) { + b.statement("argument.op_variadicCount_ = operationChildCount[operationSp] - " + instruction.signature.valueCount); + } + } + private CodeExecutableElement createBeforeChild() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "beforeChild"); CodeTreeBuilder b = ex.createBuilder(); @@ -759,7 +877,7 @@ private CodeExecutableElement createAfterChild() { switch (op.kind) { case IF_THEN: b.startIf().string("childIndex == 0").end().startBlock(); - buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("data")); + buildEmitInstruction(b, model.branchFalseInstruction, "data"); b.end().startElseBlock(); b.statement("((IntRef) data).value = bci"); b.end(); @@ -767,9 +885,9 @@ private CodeExecutableElement createAfterChild() { case CONDITIONAL: case IF_THEN_ELSE: b.startIf().string("childIndex == 0").end().startBlock(); - buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("((IntRef[]) data)[0]")); + buildEmitInstruction(b, model.branchFalseInstruction, "((IntRef[]) data)[0]"); b.end().startElseIf().string("childIndex == 1").end().startBlock(); - buildEmitInstruction(b, model.branchInstruction, () -> b.string("((IntRef[]) data)[1]")); + buildEmitInstruction(b, model.branchInstruction, "((IntRef[]) data)[1]"); b.statement("((IntRef[]) data)[0].value = bci"); b.end().startElseBlock(); b.statement("((IntRef[]) data)[1].value = bci"); @@ -777,9 +895,9 @@ private CodeExecutableElement createAfterChild() { break; case WHILE: b.startIf().string("childIndex == 0").end().startBlock(); - buildEmitInstruction(b, model.branchFalseInstruction, () -> b.string("((IntRef[]) data)[1]")); + buildEmitInstruction(b, model.branchFalseInstruction, "((IntRef[]) data)[1]"); b.end().startElseBlock(); - buildEmitInstruction(b, model.branchInstruction, () -> b.string("((IntRef[]) data)[0]")); + buildEmitInstruction(b, model.branchInstruction, "((IntRef[]) data)[0]"); b.statement("((IntRef[]) data)[1].value = bci"); b.end(); break; @@ -828,12 +946,12 @@ private CodeExecutableElement createEmitInstruction() { return ex; } - private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Runnable argumentBuilder) { + private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, String argument) { b.startStatement().startCall("doEmitInstruction"); b.string(instr.id + " /* " + instr.name + " */"); b.startGroup(); - if (argumentBuilder != null) { - argumentBuilder.run(); + if (argument != null) { + b.string(argument); } else { b.string("EPSILON"); } @@ -900,6 +1018,217 @@ private CodeExecutableElement createSetNodes() { } } + class BaseInterpreterFactory { + private CodeTypeElement create() { + baseInterpreter.add(createContinueAt()); + + return baseInterpreter; + } + + private CodeExecutableElement createContinueAt() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(ABSTRACT), context.getType(int.class), "continueAt"); + + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); + ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "startState")); + + return ex; + } + } + + class InterpreterFactory { + + private CodeTypeElement interpreterType; + private boolean isUncached; + private boolean isInstrumented; + + InterpreterFactory(CodeTypeElement type, boolean isUncached, boolean isInstrumented) { + this.interpreterType = type; + this.isUncached = isUncached; + this.isInstrumented = isInstrumented; + } + + private CodeTypeElement create() { + interpreterType.setSuperClass(baseInterpreter.asType()); + + interpreterType.add(createContinueAt()); + + return interpreterType; + } + + private CodeExecutableElement createContinueAt() { + CodeExecutableElement ex = GeneratorUtils.overrideImplement((DeclaredType) baseInterpreter.asType(), "continueAt"); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("int bci = startState & 0xffff"); + b.statement("int sp = (startState >> 16) & 0xffff"); + + b.string("loop: ").startWhile().string("true").end().startBlock(); + + b.statement("int curOpcode = bc[bci]"); + b.statement("Object curObj = objs[bci]"); + + b.startSwitch().string("curOpcode").end().startBlock(); + + for (InstructionModel instr : model.getInstructions()) { + + b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock(); + + switch (instr.kind) { + case BRANCH: + b.statement("bci = ((IntRef) curObj).value"); + b.statement("continue loop"); + break; + case BRANCH_FALSE: + b.startIf().string("frame.getObject(sp - 1) == Boolean.TRUE").end().startBlock(); + b.statement("bci += 1"); + b.statement("continue loop"); + b.end().startElseBlock(); + b.statement("bci = ((IntRef) curObj).value"); + b.statement("continue loop"); + b.end(); + break; + case CUSTOM: { + buildCustomInstructionExecute(b, instr); + + int stackOffset = -instr.signature.valueCount + (instr.signature.isVoid ? 0 : 1); + b.statement("sp += " + stackOffset + (instr.signature.isVariadic ? " - variadicCount" : "")); + if (!instr.signature.isVoid) { + b.statement("frame.setObject(sp - 1, result)"); + } + break; + } + case CUSTOM_SHORT_CIRCUIT: + buildCustomInstructionExecute(b, instr); + + b.startIf().string("result", instr.continueWhen ? "!=" : "==", "Boolean.TRUE").end().startBlock(); + b.startAssign("bci"); + b.string("("); + if (model.generateUncached) { + b.string("(" + instr.getInternalName() + "Gen_UncachedData)"); + } else { + b.string("(" + instr.getInternalName() + "Gen)"); + } + b.string(" curObj).op_branchTarget_.value"); + b.end(); + b.statement("continue loop"); + b.end().startElseBlock(); + b.statement("sp -= 1"); + b.statement("bci += 1"); + b.statement("continue loop"); + b.end(); + break; + case INSTRUMENTATION_ENTER: + break; + case INSTRUMENTATION_EXIT: + break; + case INSTRUMENTATION_LEAVE: + break; + case LOAD_ARGUMENT: + b.statement("frame.setObject(sp, frame.getArguments()[(int) curObj])"); + b.statement("sp += 1"); + break; + case LOAD_CONSTANT: + b.statement("frame.setObject(sp, curObj)"); + b.statement("sp += 1"); + break; + case LOAD_LOCAL: + b.statement("frame.setObject(sp, frame.getObject(((IntRef) curObj).value))"); + b.statement("sp += 1"); + break; + case LOAD_LOCAL_MATERIALIZED: + b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 1)"); + b.statement("frame.setObject(sp - 1, matFrame.getObject(((IntRef) curObj).value))"); + break; + case POP: + b.statement("frame.clear(sp - 1)"); + b.statement("sp -= 1"); + break; + case RETURN: + b.statement("return ((sp - 1) << 16) | 0xffff"); + break; + case STORE_LOCAL: + b.statement("frame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))"); + b.statement("sp -= 1"); + break; + case STORE_LOCAL_MATERIALIZED: + b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 2)"); + b.statement("matFrame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))"); + break; + case THROW: + break; + case YIELD: + break; + default: + throw new UnsupportedOperationException("not implemented"); + } + + if (!instr.isControlFlow()) { + b.statement("bci += 1"); + b.statement("continue loop"); + } + + b.end(); + + } + + b.end(); + + b.end(); + + return ex; + } + + private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel instr) { + TypeMirror genType = new GeneratedTypeMirror("", instr.getInternalName() + "Gen"); + TypeMirror uncachedType = new GeneratedTypeMirror("", instr.getInternalName() + "Gen_UncachedData"); + CustomSignature signature = instr.signature; + + if (signature.isVariadic) { + b.startAssign("int variadicCount"); + b.startParantheses().cast(uncachedType).string("curObj").end().string(".op_variadicCount_"); + b.end(); + } + + String executeName; + if (signature.isVoid) { + b.startStatement(); + executeName = "executeVoid"; + } else { + b.startAssign("Object result"); + executeName = "executeObject"; + } + + if (isUncached) { + b.staticReference(genType, "UNCACHED").startCall(".executeUncached"); + b.string("frame"); + + for (int i = 0; i < instr.signature.valueCount; i++) { + b.startCall("frame.getObject").startGroup(); + b.string("sp"); + if (signature.isVariadic) { + b.string(" - variadicCount"); + } + b.string(" - " + (instr.signature.valueCount - i)); + b.end(2); + } + + if (instr.signature.isVariadic) { + b.string("readVariadic(frame, sp, variadicCount)"); + } + + } else { + b.startParantheses().cast(genType).string("curObj").end().startCall("." + executeName); + b.string("frame"); + } + + b.string("sp"); + + b.end(2); + } + } + class OperationLocalImplFactory { private CodeTypeElement create() { operationLocalImpl.setSuperClass(generic(types.OperationLocal, model.templateType.asType())); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java index 9ff190611c87..bc53c0b3a22f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java @@ -40,6 +40,12 @@ */ package com.oracle.truffle.dsl.processor.operations.model; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import javax.lang.model.type.TypeMirror; + import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; @@ -69,6 +75,18 @@ public enum InstructionKind { SUPERINSTRUCTION, } + public static class InstructionField { + public final TypeMirror type; + public final String name; + public final boolean needInUncached; + + public InstructionField(TypeMirror type, String name, boolean needInUncached) { + this.type = type; + this.name = name; + this.needInUncached = needInUncached; + } + } + public final int id; public final InstructionKind kind; public final String name; @@ -76,6 +94,9 @@ public enum InstructionKind { public CustomSignature signature; public NodeData nodeData; + public final List fields = new ArrayList<>(); + public boolean continueWhen; + public InstructionModel(int id, InstructionKind kind, String name) { this.id = id; this.kind = kind; @@ -90,4 +111,55 @@ public void dump(Dumper dumper) { } dumper.field("signature", signature); } + + public boolean isInstrumentationOnly() { + switch (kind) { + case INSTRUMENTATION_ENTER: + case INSTRUMENTATION_EXIT: + case INSTRUMENTATION_LEAVE: + return true; + default: + return false; + } + } + + public boolean isControlFlow() { + switch (kind) { + case BRANCH: + case BRANCH_FALSE: + case RETURN: + case YIELD: + case THROW: + case CUSTOM_SHORT_CIRCUIT: + return true; + default: + return false; + } + } + + public boolean needsUncachedData() { + for (InstructionField field : fields) { + if (field.needInUncached) { + return true; + } + } + + return false; + } + + public void addField(TypeMirror type, String fieldName, boolean needInUncached) { + fields.add(new InstructionField(type, fieldName, needInUncached)); + } + + public List getUncachedFields() { + return fields.stream().filter(x -> x.needInUncached).collect(Collectors.toList()); + } + + public List getCachedFields() { + return fields.stream().filter(x -> !x.needInUncached).collect(Collectors.toList()); + } + + public String getInternalName() { + return name.replace('.', '_'); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index 775f102b17de..cc8acf5b744f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -56,6 +56,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.Template; import com.oracle.truffle.dsl.processor.model.TypeSystemData; @@ -184,13 +185,16 @@ public void addDefault() { } operation(OperationKind.SOURCE, "Source") // .setNumChildren(1) // - .setTransparent(true); + .setTransparent(true) // + .setOperationArguments(types.Source); operation(OperationKind.SOURCE_SECTION, "SourceSection") // .setNumChildren(1) // - .setTransparent(true); + .setTransparent(true) // + .setOperationArguments(context.getType(int.class), context.getType(int.class)); operation(OperationKind.INSTRUMENT_TAG, "Tag") // .setNumChildren(1) // - .setTransparent(true); + .setTransparent(true) // + .setOperationArguments(new GeneratedTypeMirror("java.lang", "Class")); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 33e7be2c5738..34bbcda134c7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -80,6 +80,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedPackageElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; import com.oracle.truffle.dsl.processor.operations.model.OperationModel; @@ -310,7 +311,9 @@ private List createExecuteMethods(CustomSignature signatu boxingEliminatedTypes.sort((o1, o2) -> getQualifiedName(o1).compareTo(getQualifiedName(o2))); for (TypeMirror ty : boxingEliminatedTypes) { - result.add(createExecuteMethod(signature, "execute" + firstLetterUpperCase(getSimpleName(ty)), ty, true, false)); + if (!ElementUtils.isObject(ty)) { + result.add(createExecuteMethod(signature, "execute" + firstLetterUpperCase(getSimpleName(ty)), ty, true, false)); + } } } @@ -380,6 +383,27 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl instr.nodeData.redirectMessages(parent); instr.nodeData.redirectMessagesOnGeneratedElements(parent); + if (signature.resultBoxingElimination) { + instr.addField(context.getType(int.class), "op_resultType_", false); + } + + if (signature.isVariadic) { + instr.addField(context.getType(int.class), "op_variadicCount_", true); + } + + for (int i = 0; i < signature.localSetterCount; i++) { + instr.addField(types.LocalSetter, "op_localSetter" + i + "_", true); + } + + for (int i = 0; i < signature.localSetterRangeCount; i++) { + instr.addField(types.LocalSetterRange, "op_localSetterRange" + i + "_", true); + } + + if (isShortCircuit) { + instr.continueWhen = (boolean) ElementUtils.getAnnotationValue(mirror, "continueWhen").getValue(); + instr.addField(new GeneratedTypeMirror("", "IntRef"), "op_branchTarget_", true); + } + return instr; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index 428421b61e1b..f51c651514ec 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -157,16 +157,19 @@ protected OperationsModel parse(Element element, List mirror) // find and bind boxing elimination types Set beTypes = new HashSet<>(); - List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); - for (AnnotationValue value : boxingEliminatedTypes) { - TypeMirror mir = getTypeMirror(value); + if (false) { + List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); + for (AnnotationValue value : boxingEliminatedTypes) { - if (BOXABLE_TYPE_KINDS.contains(mir.getKind())) { - beTypes.add(mir); - } else { - model.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", - mir); + TypeMirror mir = getTypeMirror(value); + + if (BOXABLE_TYPE_KINDS.contains(mir.getKind())) { + beTypes.add(mir); + } else { + model.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", + mir); + } } } @@ -194,6 +197,19 @@ protected OperationsModel parse(Element element, List mirror) new CustomOperationParser(model, mir).parse(te); } + for (AnnotationMirror mir : ElementUtils.getRepeatedAnnotation(typeElement.getAnnotationMirrors(), types.ShortCircuitOperation)) { + TypeMirror proxiedType = getTypeMirror(ElementUtils.getAnnotationValue(mir, "booleanConverter")); + + if (proxiedType.getKind() != TypeKind.DECLARED) { + model.addError("Could not proxy operation: the proxied type must be a class, not %s", proxiedType); + continue; + } + + TypeElement te = (TypeElement) ((DeclaredType) proxiedType).asElement(); + + new CustomOperationParser(model, mir, true).parse(te); + } + return model; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index 25129c17c4ce..cb9da535e494 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -58,7 +58,6 @@ import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.operation.GenerateOperations; -import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.OperationRootNode; @@ -84,12 +83,12 @@ import com.oracle.truffle.sl.nodes.util.SLToBooleanNode; import com.oracle.truffle.sl.nodes.util.SLUnboxNode; import com.oracle.truffle.sl.runtime.SLFunction; -import com.oracle.truffle.sl.runtime.SLStrings; import com.oracle.truffle.sl.runtime.SLUndefinedNameException; @GenerateOperations(// languageClass = SLLanguage.class, // - decisionsFile = "decisions.json", boxingEliminationTypes = {long.class, boolean.class}) + decisionsFile = "decisions.json", // + boxingEliminationTypes = {long.class, boolean.class}) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @@ -125,11 +124,18 @@ public SourceSection getSourceSection() { @Override public TruffleString getTSName() { - return getMetadata(MethodName); + return tsName; } - @GenerateOperations.Metadata // - public static final MetadataKey MethodName = new MetadataKey<>(SLStrings.EMPTY_STRING); + public void setTSName(TruffleString tsName) { + this.tsName = tsName; + } + +// @GenerateOperations.Metadata // +// public static final MetadataKey MethodName = new +// MetadataKey<>(SLStrings.EMPTY_STRING); + + private TruffleString tsName; @Operation @TypeSystemReference(SLTypes.class) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 3f4708ac66c1..272bff9ce3eb 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -58,7 +58,6 @@ import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationLabel; import com.oracle.truffle.api.operation.OperationLocal; -import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -95,7 +94,7 @@ */ public final class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = false; + private static final boolean DO_LOG_NODE_CREATION = true; private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { @@ -114,7 +113,7 @@ public static void parseSL(SLLanguage language, Source source, Map Date: Wed, 21 Dec 2022 13:56:53 +0100 Subject: [PATCH 183/312] [wip] fixes to new generator --- .../operation/introspection/Instruction.java | 2 +- .../generator/FlatNodeGenFactory.java | 6 +- .../generator/OperationsNodeFactory.java | 244 +++++++++++++++++- .../operations/model/OperationsModel.java | 2 + .../parser/CustomOperationParser.java | 2 +- .../sl/parser/SLOperationsVisitor.java | 2 +- 6 files changed, 246 insertions(+), 12 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java index 960810aff913..5feabf8f1681 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/Instruction.java @@ -87,7 +87,7 @@ public List getSubInstructions() { } } - private static final int REASONABLE_INSTRUCTION_LENGTH = 16; + private static final int REASONABLE_INSTRUCTION_LENGTH = 3; @Override public String toString() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index ba002ea3fff6..c6c7f38c9464 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -2279,6 +2279,9 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram NodeChildData child = execution.getChild(); LocalVariable var = frameState.getValue(execution); plugs.createNodeChildReferenceForException(this, frameState, builder, values, execution, child, var); + if (var != null) { + values.add(var.createReference()); + } } builder.end(); builder.trees(values.toArray(new CodeTree[0])); @@ -2293,9 +2296,6 @@ void createNodeChildReferenceForException(final FrameState frameState, CodeTreeB } else { builder.string("null"); } - if (var != null) { - values.add(var.createReference()); - } } private CodeTree createFastPath(CodeTreeBuilder parent, List allSpecializations, SpecializationGroup originalGroup, final ExecutableTypeData currentType, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 2f01d952c7bc..c31f961e06a0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.dsl.processor.operations.generator; +import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; @@ -48,7 +49,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -83,7 +83,6 @@ import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionField; -import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; import com.oracle.truffle.dsl.processor.operations.model.OperationModel; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; @@ -155,10 +154,18 @@ public CodeTypeElement create() { operationNodeGen.add(createGetIntrospectionData()); + operationNodeGen.add(createChangeInterpreters()); + + operationNodeGen.add(createCloneUninitializedSupported()); + operationNodeGen.add(createCloneUninitialized()); + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"))); operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); + if (model.generateUncached) { + operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "uncachedExecuteCount")).createInitBuilder().string("16"); + } operationNodeGen.add(createInterpreterField()); operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()")); @@ -185,6 +192,61 @@ public CodeTypeElement create() { return operationNodeGen; } + private CodeExecutableElement createCloneUninitializedSupported() { + CodeExecutableElement ex = GeneratorUtils.override(types.RootNode, "isCloneUninitializedSupported"); + ex.createBuilder().returnTrue(); + return ex; + } + + private CodeExecutableElement createCloneUninitialized() { + CodeExecutableElement ex = GeneratorUtils.override(types.RootNode, "cloneUninitialized"); + + CodeTreeBuilder b = ex.createBuilder(); + + b.declaration(operationNodeGen.asType(), "clone", "(" + operationNodeGen.getSimpleName() + ") this.copy()"); + + b.statement("clone.interpreter = UNCACHED_INTERPRETER"); + b.statement("clone.objs = new Object[objs.length]"); + + b.startFor().string("int bci = 0; bci < bc.length; bci++").end().startBlock(); + + b.startSwitch().string("bc[bci]").end().startBlock(); + + for (InstructionModel instr : model.getInstructions()) { + b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock(); + + switch (instr.kind) { + case CUSTOM: + case CUSTOM_SHORT_CIRCUIT: + String udName = instr.getInternalName() + "Gen" + (model.generateUncached && instr.needsUncachedData() ? "_UncachedData" : ""); + b.declaration(udName, "curData", "(" + udName + ") objs[bci]"); + b.declaration(udName, "newData", "new " + udName + "()"); + + for (InstructionField field : instr.getUncachedFields()) { + b.statement("newData." + field.name + " = curData." + field.name); + } + + b.statement("clone.objs[bci] = newData"); + + break; + default: + b.statement("clone.objs[bci] = this.objs[bci]"); + break; + } + + b.statement("break"); + b.end(); + } + + b.end(); + + b.end(); + + b.startReturn().string("clone").end(); + + return ex; + } + private CodeVariableElement createInterpreterField() { CodeVariableElement fld = new CodeVariableElement(Set.of(PRIVATE), baseInterpreter.asType(), "interpreter"); fld = compFinal(fld); @@ -271,11 +333,11 @@ private CodeExecutableElement createExecute() { b.statement("int state = numLocals << 16"); b.startWhile().string("true").end().startBlock(); - b.statement("state = interpreter.continueAt(frame, bc, objs, state)"); + b.statement("state = interpreter.continueAt(this, frame, bc, objs, state)"); b.startIf().string("(state & 0xffff) == 0xffff").end().startBlock(); b.statement("break"); b.end().startElseBlock(); - b.tree(GeneratorUtils.createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate()); b.end(); b.end(); @@ -321,11 +383,43 @@ private CodeExecutableElement createGetIntrospectionData() { for (InstructionModel instr : model.getInstructions()) { b.startCase().string("" + instr.id + " /* " + instr.name + " */").end().startBlock(); + b.statement("Object data = objs[bci]"); b.startAssign("instructions[bci]").startNewArray(arrayOf(context.getType(Object.class)), null); b.string("bci"); b.doubleQuote(instr.name); b.string("new short[] {" + instr.id + "}"); - b.string("new Object[0]"); + + b.startNewArray(arrayOf(context.getType(Object.class)), null); + + switch (instr.kind) { + case BRANCH: + case BRANCH_FALSE: + buildIntrospectionArgument(b, "BRANCH_OFFSET", "((IntRef) data).value"); + break; + case CUSTOM: + if (instr.signature.isVariadic) { + buildIntrospectionArgument(b, "VARIADIC", "((" + instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : "") + ") data).op_variadicCount_"); + } + break; + case LOAD_CONSTANT: + buildIntrospectionArgument(b, "CONSTANT", "data"); + break; + case LOAD_ARGUMENT: + buildIntrospectionArgument(b, "ARGUMENT", "data"); + break; + case LOAD_LOCAL: + case LOAD_LOCAL_MATERIALIZED: + case STORE_LOCAL: + case STORE_LOCAL_MATERIALIZED: + buildIntrospectionArgument(b, "LOCAL", "((IntRef) data).value"); + break; + case CUSTOM_SHORT_CIRCUIT: + buildIntrospectionArgument(b, "BRANCH_OFFSET", "((" + instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : "") + " ) data).op_branchTarget_"); + break; + } + + b.end(); + b.end(2); b.statement("break"); b.end(); @@ -342,6 +436,16 @@ private CodeExecutableElement createGetIntrospectionData() { return ex; } + private void buildIntrospectionArgument(CodeTreeBuilder b, String kind, String content) { + DeclaredType argumentKindType = context.getDeclaredType("com.oracle.truffle.api.operation.introspection.Argument.ArgumentKind"); + + b.startNewArray(arrayOf(context.getType(Object.class)), null); + b.staticReference(argumentKindType, kind); + b.string(content); + b.end(); + + } + private CodeExecutableElement createReadVariadic() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object[].class), "readVariadic"); @@ -364,6 +468,80 @@ private CodeExecutableElement createReadVariadic() { return ex; } + private CodeExecutableElement createChangeInterpreters() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "changeInterpreters"); + + ex.addParameter(new CodeVariableElement(baseInterpreter.asType(), "toInterpreter")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("toInterpreter == interpreter").end().startBlock(); + b.returnStatement(); + b.end(); + + b.startIf().string("toInterpreter == CACHED_INTERPRETER && interpreter == INSTRUMENTABLE_INTERPRETER").end().startBlock(); + b.returnStatement(); + b.end(); + + b.statement("Object[] newObjs = new Object[bc.length]"); + + b.startFor().string("int bci = 0; bci < bc.length; bci++").end().startBlock(); + + b.startSwitch().string("bc[bci]").end().startBlock(); + + for (InstructionModel instr : model.getInstructions()) { + switch (instr.kind) { + case CUSTOM: + case CUSTOM_SHORT_CIRCUIT: + break; + default: + continue; + } + + b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock(); + + switch (instr.kind) { + case CUSTOM: + case CUSTOM_SHORT_CIRCUIT: + b.statement(instr.getInternalName() + "Gen data = new " + instr.getInternalName() + "Gen()"); + if (model.generateUncached && instr.needsUncachedData()) { + b.startIf().string("interpreter == UNCACHED_INTERPRETER").end().startBlock(); + + b.statement(instr.getInternalName() + "Gen_UncachedData oldData = (" + instr.getInternalName() + "Gen_UncachedData) objs[bci]"); + for (InstructionField field : instr.getUncachedFields()) { + b.statement("data." + field.name + " = oldData." + field.name); + } + + // todo: initialize cached fields + b.end(); + } + + b.statement("newObjs[bci] = insert(data)"); + break; + + default: + throw new AssertionError(); + } + + b.statement("break"); + b.end(); + } + + b.caseDefault().startBlock(); + b.statement("newObjs[bci] = objs[bci]"); + b.statement("break"); + b.end(); + + b.end(); // } switch + + b.end(); // } for + + b.statement("objs = newObjs"); + b.statement("interpreter = toInterpreter"); + + return ex; + } + class BuilderFactory { CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState"); @@ -587,6 +765,9 @@ private void buildOperationBeginData(CodeTreeBuilder b, OperationModel operation case LOAD_LOCAL_MATERIALIZED: b.string("arg0"); break; + case CUSTOM_SHORT_CIRCUIT: + b.string("new IntRef()"); + break; default: b.string("null"); break; @@ -688,6 +869,10 @@ private Element createEnd(OperationModel operation) { buildEmitOperationInstruction(b, operation); } + if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { + b.statement("((IntRef) operationData[operationSp]).value = bci"); + } + b.startStatement().startCall("afterChild"); if (operation.isTransparent) { b.string("(boolean) ((Object[]) operationData[operationSp])[0]"); @@ -800,6 +985,11 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, if (instruction.signature.isVariadic) { b.statement("argument.op_variadicCount_ = operationChildCount[operationSp] - " + instruction.signature.valueCount); } + + if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { + b.statement("argument.op_branchTarget_ = (IntRef) data"); + } + } private CodeExecutableElement createBeforeChild() { @@ -824,6 +1014,13 @@ private CodeExecutableElement createBeforeChild() { b.end(); } + if (op.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { + b.startIf().string("childIndex != 0").end().startBlock(); + buildCustomInitializer(b, op, op.instruction); + buildEmitInstruction(b, op.instruction, "argument"); + b.end(); + } + b.statement("break"); b.end(); } @@ -1028,6 +1225,7 @@ private CodeTypeElement create() { private CodeExecutableElement createContinueAt() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(ABSTRACT), context.getType(int.class), "continueAt"); + ex.addParameter(new CodeVariableElement(operationNodeGen.asType(), "$this")); ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); ex.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); @@ -1069,22 +1267,46 @@ private CodeExecutableElement createContinueAt() { b.statement("int curOpcode = bc[bci]"); b.statement("Object curObj = objs[bci]"); + if (isUncached) { + b.statement("int uncachedExecuteCount = $this.uncachedExecuteCount"); + } + b.startSwitch().string("curOpcode").end().startBlock(); for (InstructionModel instr : model.getInstructions()) { + if (instr.isInstrumentationOnly() && !isInstrumented) { + continue; + } + b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock(); switch (instr.kind) { case BRANCH: - b.statement("bci = ((IntRef) curObj).value"); + b.statement("int nextBci = ((IntRef) curObj).value"); + + if (isUncached) { + b.startIf().string("nextBci <= bci").end().startBlock(); + + b.startIf().string("uncachedExecuteCount-- <= 0").end().startBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("$this.changeInterpreters(CACHED_INTERPRETER)"); + b.statement("return (sp << 16) | nextBci"); + b.end(); + + b.end(); + } + + b.statement("bci = nextBci"); b.statement("continue loop"); break; case BRANCH_FALSE: b.startIf().string("frame.getObject(sp - 1) == Boolean.TRUE").end().startBlock(); + b.statement("sp -= 1"); b.statement("bci += 1"); b.statement("continue loop"); b.end().startElseBlock(); + b.statement("sp -= 1"); b.statement("bci = ((IntRef) curObj).value"); b.statement("continue loop"); b.end(); @@ -1146,6 +1368,15 @@ private CodeExecutableElement createContinueAt() { b.statement("sp -= 1"); break; case RETURN: + if (isUncached) { + b.startIf().string("uncachedExecuteCount-- <= 0").end().startBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("$this.changeInterpreters(CACHED_INTERPRETER)"); + b.end().startElseBlock(); + b.statement("$this.uncachedExecuteCount = uncachedExecuteCount"); + b.end(); + } + b.statement("return ((sp - 1) << 16) | 0xffff"); break; case STORE_LOCAL: @@ -1155,6 +1386,7 @@ private CodeExecutableElement createContinueAt() { case STORE_LOCAL_MATERIALIZED: b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 2)"); b.statement("matFrame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))"); + b.statement("sp -= 2"); break; case THROW: break; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index cc8acf5b744f..71a4e1dbb6f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -166,11 +166,13 @@ public void addDefault() { operation(OperationKind.STORE_LOCAL, "StoreLocal") // .setNumChildren(1) // .setChildrenMustBeValues(true) // + .setVoid(true) // .setOperationArguments(types.OperationLocal) // .setInstruction(instruction(InstructionKind.STORE_LOCAL, "store.local")); operation(OperationKind.STORE_LOCAL_MATERIALIZED, "StoreLocalMaterialized") // .setNumChildren(2) // .setChildrenMustBeValues(true, true) // + .setVoid(true) // .setOperationArguments(types.OperationLocal) // .setInstruction(instruction(InstructionKind.STORE_LOCAL_MATERIALIZED, "store.local.mat")); operation(OperationKind.RETURN, "Return") // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 34bbcda134c7..16e9bce0c25b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -219,7 +219,7 @@ protected OperationModel parse(Element element, List ignored) data.signature = signature; data.numChildren = signature.valueCount; - data.isVariadic = signature.isVariadic; + data.isVariadic = signature.isVariadic || isShortCircuit; data.isVoid = signature.isVoid; data.operationArguments = new TypeMirror[signature.localSetterCount + signature.localSetterRangeCount]; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java index 272bff9ce3eb..f6dec9fcbb98 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java @@ -94,7 +94,7 @@ */ public final class SLOperationsVisitor extends SLBaseVisitor { - private static final boolean DO_LOG_NODE_CREATION = true; + private static final boolean DO_LOG_NODE_CREATION = false; private static final boolean FORCE_SERIALIZE = false; public static void parseSL(SLLanguage language, Source source, Map functions) { From b8a7fc343c0603ccd1095231444378f3917b4bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Fri, 23 Dec 2022 12:38:18 +0100 Subject: [PATCH 184/312] [wip] exceptions --- .../generator/OperationsNodeFactory.java | 118 ++++++++++++++++-- 1 file changed, 106 insertions(+), 12 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index c31f961e06a0..91831c5abb12 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -161,6 +161,7 @@ public CodeTypeElement create() { operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"))); operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"))); + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "handlers"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); if (model.generateUncached) { @@ -205,7 +206,7 @@ private CodeExecutableElement createCloneUninitialized() { b.declaration(operationNodeGen.asType(), "clone", "(" + operationNodeGen.getSimpleName() + ") this.copy()"); - b.statement("clone.interpreter = UNCACHED_INTERPRETER"); + b.statement("clone.interpreter = " + (model.generateUncached ? "UN" : "") + "CACHED_INTERPRETER"); b.statement("clone.objs = new Object[objs.length]"); b.startFor().string("int bci = 0; bci < bc.length; bci++").end().startBlock(); @@ -333,7 +334,7 @@ private CodeExecutableElement createExecute() { b.statement("int state = numLocals << 16"); b.startWhile().string("true").end().startBlock(); - b.statement("state = interpreter.continueAt(this, frame, bc, objs, state)"); + b.statement("state = interpreter.continueAt(this, frame, bc, objs, handlers, state)"); b.startIf().string("(state & 0xffff) == 0xffff").end().startBlock(); b.statement("break"); b.end().startElseBlock(); @@ -557,6 +558,8 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "maxStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "curStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "exHandlers"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "exHandlerCount"), // must be last new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"), @@ -729,6 +732,8 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("numLocals = 0"); b.statement("curStack = 0"); b.statement("maxStack = 10"); + b.statement("exHandlers = new int[10]"); + b.statement("exHandlerCount = 0"); } else { b.startStatement().startCall("beforeChild").end(2); } @@ -738,6 +743,17 @@ private CodeExecutableElement createBegin(OperationModel operation) { buildOperationBeginData(b, operation); b.end(2); + switch (operation.kind) { + case TRY_CATCH: + b.startBlock(); + b.statement("Object[] data = (Object[]) operationData[operationSp - 1]"); + b.statement("data[0] = bci"); + b.statement("data[3] = curStack"); + b.statement("data[4] = arg0"); + b.end(); + break; + } + return ex; } @@ -765,8 +781,21 @@ private void buildOperationBeginData(CodeTreeBuilder b, OperationModel operation case LOAD_LOCAL_MATERIALIZED: b.string("arg0"); break; + case CUSTOM_SIMPLE: case CUSTOM_SHORT_CIRCUIT: - b.string("new IntRef()"); + b.startNewArray(arrayOf(context.getType(Object.class)), null); + if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { + b.string("new IntRef()"); + } + + for (int i = 0; i < operation.operationArguments.length; i++) { + b.string("arg" + i); + } + + b.end(); + break; + case TRY_CATCH: + b.string("new Object[6]"); break; default: b.string("null"); @@ -843,6 +872,7 @@ private Element createEnd(OperationModel operation) { b.startAssign("result.bc").string("Arrays.copyOf(bc, bci)").end(); b.startAssign("result.objs").string("Arrays.copyOf(objs, bci)").end(); + b.startAssign("result.handlers").string("Arrays.copyOf(exHandlers, exHandlerCount)").end(); b.startAssign("result.numLocals").string("numLocals").end(); b.startAssign("result.buildIndex").string("buildIndex").end(); @@ -865,12 +895,33 @@ private Element createEnd(OperationModel operation) { return ex; } - if (operation.instruction != null && operation.kind != OperationKind.CUSTOM_SHORT_CIRCUIT) { - buildEmitOperationInstruction(b, operation); - } + switch (operation.kind) { + case TRY_CATCH: + b.startBlock(); + b.statement("Object[] data = (Object[])operationData[operationSp]"); + b.statement("((IntRef) data[5]).value = bci"); - if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { - b.statement("((IntRef) operationData[operationSp]).value = bci"); + b.startIf().string("exHandlers.length <= exHandlerCount + 5").end().startBlock(); + b.statement("exHandlers = Arrays.copyOf(exHandlers, exHandlers.length * 2)"); + b.end(); + + b.statement("exHandlers[exHandlerCount] = (int) data[0]"); + b.statement("exHandlers[exHandlerCount + 1] = (int) data[1]"); + b.statement("exHandlers[exHandlerCount + 2] = (int) data[2]"); + b.statement("exHandlers[exHandlerCount + 3] = (int) data[3]"); + b.statement("exHandlers[exHandlerCount + 4] = ((OperationLocalImpl) data[4]).index.value"); + b.statement("exHandlerCount += 5"); + + b.end(); + break; + case CUSTOM_SHORT_CIRCUIT: + b.statement("((IntRef) operationData[operationSp]).value = bci"); + break; + default: + if (operation.instruction != null) { + buildEmitOperationInstruction(b, operation); + } + break; } b.startStatement().startCall("afterChild"); @@ -986,10 +1037,23 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, b.statement("argument.op_variadicCount_ = operationChildCount[operationSp] - " + instruction.signature.valueCount); } + int argBase; if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) { - b.statement("argument.op_branchTarget_ = (IntRef) data"); + b.statement("argument.op_branchTarget_ = (IntRef) ((Object[]) data)[0]"); + argBase = 1; + } else { + argBase = 0; } + for (int i = 0; i < instruction.signature.localSetterCount; i++) { + b.startAssign("argument.op_localSetter" + i + "_"); + b.startStaticCall(types.LocalSetter, "create"); + b.string("((IntRef)((OperationLocalImpl)((Object[]) operationData[operationSp])[" + (argBase + i) + "]).index).value"); + b.end(2); + } + + argBase += instruction.signature.localSetterCount; + } private CodeExecutableElement createBeforeChild() { @@ -1098,6 +1162,15 @@ private CodeExecutableElement createAfterChild() { b.statement("((IntRef[]) data)[1].value = bci"); b.end(); break; + case TRY_CATCH: + b.startIf().string("childIndex == 0").end().startBlock(); + b.statement("Object[] dArray = (Object[]) data"); + b.statement("dArray[1] = bci"); + b.statement("dArray[5] = new IntRef()"); + buildEmitInstruction(b, model.branchInstruction, "dArray[5]"); + b.statement("dArray[2] = bci"); + b.end(); + break; } b.statement("break"); @@ -1157,7 +1230,7 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str } private CodeExecutableElement createConstructor() { - CodeExecutableElement ctor = new CodeExecutableElement(null, "Builder"); + CodeExecutableElement ctor = new CodeExecutableElement(Set.of(PRIVATE), null, "Builder"); ctor.addParameter(new CodeVariableElement(operationNodes.asType(), "nodes")); ctor.addParameter(new CodeVariableElement(context.getType(boolean.class), "isReparse")); ctor.addParameter(new CodeVariableElement(types.OperationConfig, "config")); @@ -1229,6 +1302,7 @@ private CodeExecutableElement createContinueAt() { ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); ex.addParameter(new CodeVariableElement(context.getType(short[].class), "bc")); ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); + ex.addParameter(new CodeVariableElement(context.getType(int[].class), "handlers")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "startState")); return ex; @@ -1271,6 +1345,8 @@ private CodeExecutableElement createContinueAt() { b.statement("int uncachedExecuteCount = $this.uncachedExecuteCount"); } + b.startTryBlock(); + b.startSwitch().string("curOpcode").end().startBlock(); for (InstructionModel instr : model.getInstructions()) { @@ -1405,9 +1481,27 @@ private CodeExecutableElement createContinueAt() { } - b.end(); + b.end(); // switch - b.end(); + b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + + b.startFor().string("int idx = 0; idx < handlers.length; idx += 5").end().startBlock(); + + b.startIf().string("handlers[idx] > bci").end().startBlock().statement("continue").end(); + b.startIf().string("handlers[idx + 1] <= bci").end().startBlock().statement("break").end(); + + b.statement("bci = handlers[idx + 2]"); + b.statement("sp = handlers[idx + 3]"); + b.statement("frame.setObject(handlers[idx + 4], ex)"); + b.statement("continue loop"); + + b.end(); // for + + b.statement("throw ex"); + + b.end(); // catch + + b.end(); // while (true) return ex; } From c0ece2c720fa9120d9764e562f4f4757de8b64f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 26 Dec 2022 12:13:11 +0100 Subject: [PATCH 185/312] [wip] Source sections --- .../example/TestOperationsParserTest.java | 44 ---- .../expression/DSLExpressionResolver.java | 8 +- .../processor/generator/GeneratorUtils.java | 10 + .../OperationNodeGeneratorPlugs.java | 10 +- .../generator/OperationsNodeFactory.java | 204 +++++++++++++++++- .../operations/model/OperationModel.java | 6 +- .../dsl/processor/parser/NodeParser.java | 4 + .../sl/nodes/expression/SLLessThanNode.java | 2 +- .../nodes/expression/SLReadPropertyNode.java | 6 +- .../sl/nodes/expression/SLSubNode.java | 2 +- .../nodes/expression/SLWritePropertyNode.java | 4 +- .../sl/nodes/util/SLToBooleanNode.java | 2 +- .../sl/operations/SLOperationRootNode.java | 2 +- 13 files changed, 237 insertions(+), 67 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java index 94efcdc1f0d3..b0158e7ebd66 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java @@ -872,50 +872,6 @@ public void testFinallyTryNoExceptException() { testOrdering(true, root, 1L); } - @Test - public void testMetadata() { - final String value = "test data"; - - OperationRootNode node = parseNode(b -> { - b.beginRoot(LANGUAGE); - -// b.setTestData(value); - - b.endRoot(); - }); - - Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); - Assert.assertEquals(value, TestOperations.TestData.getValue(node)); - } - - @Test - public void testMetadataChange() { - final String value = "test data"; - - OperationRootNode node = parseNode(b -> { - b.beginRoot(LANGUAGE); - -// b.setTestData("some old value"); -// b.setTestData(value); - - b.endRoot(); - }); - - Assert.assertEquals(value, node.getMetadata(TestOperations.TestData)); - Assert.assertEquals(value, TestOperations.TestData.getValue(node)); - } - - @Test - public void testMetadataDefaultValue() { - OperationRootNode node = parseNode(b -> { - b.beginRoot(LANGUAGE); - - b.endRoot(); - }); - - Assert.assertEquals(TestOperations.TestData.getDefaultValue(), node.getMetadata(TestOperations.TestData)); - Assert.assertEquals(TestOperations.TestData.getDefaultValue(), TestOperations.TestData.getValue(node)); - } @Test public void testTeeLocal() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index ddc1fdc0b317..381706493e61 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -232,8 +232,6 @@ private VariableElement resolveVariable(Variable variable) { switch (name) { case "null": return new CodeVariableElement(new CodeTypeMirror(TypeKind.NULL), "null"); - case "$bci": - return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "-1"); case "false": return new CodeVariableElement(new CodeTypeMirror(TypeKind.BOOLEAN), "false"); case "true": @@ -255,10 +253,14 @@ private VariableElement resolveVariable(Variable variable) { return parent.resolveVariable(variable); } - if (name.equals("this")) { + if (name.equals("this") || name.equals("$root")) { return new CodeVariableElement(ProcessorContext.getInstance().getTypes().Node, "this"); } + if (name.equals("$bci")) { + return new CodeVariableElement(new CodeTypeMirror(TypeKind.INT), "-1"); + } + return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 757f85849e70..aedb70403278 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -434,6 +434,16 @@ public static CodeExecutableElement overrideImplement(DeclaredType type, String return overrideImplement((TypeElement) type.asElement(), methodName); } + public static CodeExecutableElement createGetter(Set modifiers, VariableElement field) { + CodeExecutableElement setter = new CodeExecutableElement(modifiers, field.asType(), "get" + ElementUtils.firstLetterUpperCase(field.getSimpleName().toString())); + + CodeTreeBuilder b = setter.createBuilder(); + + b.startReturn().string(field.getSimpleName().toString()).end(); + + return setter; + } + public static CodeExecutableElement createSetter(Set modifiers, VariableElement field) { CodeExecutableElement setter = new CodeExecutableElement(modifiers, new CodeTypeMirror(TypeKind.VOID), "set" + ElementUtils.firstLetterUpperCase(field.getSimpleName().toString())); setter.addParameter(new CodeVariableElement(field.asType(), field.getSimpleName().toString())); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java index 63c755b1c3fe..837894c40089 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java @@ -3,6 +3,7 @@ import java.util.List; import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; @@ -23,16 +24,21 @@ public class OperationNodeGeneratorPlugs implements NodeGeneratorPlugs { private final ProcessorContext context; private final TruffleTypes types; + private final TypeMirror nodeType; private final InstructionModel instr; - public OperationNodeGeneratorPlugs(ProcessorContext context, InstructionModel instr) { + public OperationNodeGeneratorPlugs(ProcessorContext context, TypeMirror nodeType, InstructionModel instr) { this.context = context; this.types = context.getTypes(); + this.nodeType = nodeType; this.instr = instr; } public List additionalArguments() { - return List.of(new CodeVariableElement(context.getType(int.class), "$sp")); + return List.of( + new CodeVariableElement(nodeType, "$root"), + new CodeVariableElement(context.getType(int.class), "$bci"), + new CodeVariableElement(context.getType(int.class), "$sp")); } public ChildExecutionResult createExecuteChild(FlatNodeGenFactory factory, CodeTreeBuilder builder, FrameState originalFrameState, FrameState frameState, NodeExecutionData execution, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 91831c5abb12..40a389c76829 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -156,12 +156,16 @@ public CodeTypeElement create() { operationNodeGen.add(createChangeInterpreters()); + operationNodeGen.add(createGetSourceSection()); + operationNodeGen.add(createGetSourceSectionAtBci()); operationNodeGen.add(createCloneUninitializedSupported()); operationNodeGen.add(createCloneUninitialized()); + operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), operationNodes.asType(), "nodes"))); operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"))); operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"))); operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "handlers"))); + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceInfo"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); if (model.generateUncached) { @@ -179,7 +183,8 @@ public CodeTypeElement create() { continue; } - FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts, new OperationNodeGeneratorPlugs(context, instr)); + OperationNodeGeneratorPlugs plugs = new OperationNodeGeneratorPlugs(context, operationNodeGen.asType(), instr); + FlatNodeGenFactory factory = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, instr.nodeData, consts, plugs); CodeTypeElement el = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, instr.getInternalName() + "Gen"); el.setSuperClass(types.Node); @@ -193,6 +198,56 @@ public CodeTypeElement create() { return operationNodeGen; } + private CodeExecutableElement createGetSourceSection() { + CodeExecutableElement ex = GeneratorUtils.override(types.Node, "getSourceSection"); + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("sourceInfo == null || sourceInfo.length == 0").end().startBlock(); + b.returnNull(); + b.end(); + + b.statement("Source[] sources = nodes.getSources()"); + + b.startIf().string("sources == null").end().startBlock(); + b.returnNull(); + b.end(); + + b.startReturn().string("sources[(sourceInfo[0] >> 16) & 0xffff].createSection(sourceInfo[1], sourceInfo[2])").end(); + + return ex; + } + + private CodeExecutableElement createGetSourceSectionAtBci() { + CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationRootNode, "getSourceSectionAtBci"); + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("sourceInfo == null || sourceInfo.length == 0").end().startBlock(); + b.returnNull(); + b.end(); + + b.statement("Source[] sources = nodes.getSources()"); + + b.startIf().string("sources == null").end().startBlock(); + b.returnNull(); + b.end(); + + b.statement("int i = 0;"); + + b.startWhile().string("i < sourceInfo.length && (sourceInfo[i] & 0xffff) <= bci").end().startBlock(); + b.statement("i += 3"); + b.end(); + + b.startIf().string("i == 0").end().startBlock(); + b.returnNull(); + b.end(); + + b.statement("i -= 3"); + + b.statement("return sources[(sourceInfo[i] >> 16) & 0xffff].createSection(sourceInfo[i + 1], sourceInfo[i + 2])"); + + return ex; + } + private CodeExecutableElement createCloneUninitializedSupported() { CodeExecutableElement ex = GeneratorUtils.override(types.RootNode, "isCloneUninitializedSupported"); ex.createBuilder().returnTrue(); @@ -560,6 +615,12 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "curStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "exHandlers"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "exHandlerCount"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceIndexStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceIndexSp"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceLocationStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceLocationSp"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceInfo"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceInfoIndex"), // must be last new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"), @@ -590,6 +651,7 @@ private CodeTypeElement create() { operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withInstrumentation")); operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes")); operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex")); + operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), types.Source), "sources")); operationBuilder.addAll(List.of(builderState)); @@ -611,6 +673,7 @@ private CodeTypeElement create() { operationBuilder.add(createBeforeChild()); operationBuilder.add(createAfterChild()); operationBuilder.add(createEmitInstruction()); + operationBuilder.add(createdoEmitSourceInfo()); operationBuilder.add(createFinish()); return operationBuilder; @@ -624,6 +687,10 @@ private CodeExecutableElement createFinish() { b.startStatement().string("nodes.setNodes(builtNodes.toArray(new ").type(operationNodeGen.asType()).string("[0]))").end(); b.end(); + b.startIf().string("withSource").end().startBlock(); + b.startStatement().string("nodes.setSources(sources.toArray(new ").type(types.Source).string("[0]))").end(); + b.end(); + return ex; } @@ -715,6 +782,12 @@ private CodeExecutableElement createBegin(OperationModel operation) { CodeTreeBuilder b = ex.createBuilder(); + if (operation.isSourceOnly()) { + b.startIf().string("!withSource").end().startBlock(); + b.returnStatement(); + b.end(); + } + if (operation.kind == OperationKind.ROOT) { b.startIf().string("bc != null").end().startBlock(); // { b.startAssign("savedState").startNew(savedState.asType()); @@ -734,6 +807,14 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("maxStack = 10"); b.statement("exHandlers = new int[10]"); b.statement("exHandlerCount = 0"); + b.startIf().string("withSource").end().startBlock(); + b.statement("sourceIndexStack = new int[1]"); + b.statement("sourceIndexSp = 0"); + b.statement("sourceLocationStack = new int[12]"); + b.statement("sourceLocationSp = 0"); + b.statement("sourceInfo = new int[15]"); + b.statement("sourceInfoIndex = 0"); + b.end(); } else { b.startStatement().startCall("beforeChild").end(2); } @@ -752,6 +833,42 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("data[4] = arg0"); b.end(); break; + case SOURCE: + b.startIf().string("sourceIndexStack.length == sourceIndexSp").end().startBlock(); + b.statement("sourceIndexStack = Arrays.copyOf(sourceIndexStack, sourceIndexSp * 2)"); + b.end(); + + b.statement("int index = sources.indexOf(arg0)"); + b.startIf().string("index == -1").end().startBlock(); + b.statement("index = sources.size()"); + b.statement("sources.add(arg0)"); + b.end(); + + b.statement("sourceIndexStack[sourceIndexSp++] = index"); + + b.startIf().string("sourceLocationStack.length == sourceLocationSp").end().startBlock(); + b.statement("sourceLocationStack = Arrays.copyOf(sourceLocationStack, sourceLocationSp * 2)"); + b.end(); + + b.statement("sourceLocationStack[sourceLocationSp++] = -1"); + b.statement("sourceLocationStack[sourceLocationSp++] = -1"); + + b.statement("doEmitSourceInfo(index, -1, -1)"); + + break; + case SOURCE_SECTION: + b.startIf().string("sourceIndexSp == 0").end().startBlock(); + buildThrowIllegalStateException(b, "\"No enclosing Source operation found - each SourceSection must be enclosed in a Source operation.\""); + b.end(); + + b.startIf().string("sourceLocationStack.length == sourceLocationSp").end().startBlock(); + b.statement("sourceLocationStack = Arrays.copyOf(sourceLocationStack, sourceLocationSp * 2)"); + b.end(); + + b.statement("sourceLocationStack[sourceLocationSp++] = arg0"); + b.statement("sourceLocationStack[sourceLocationSp++] = arg1"); + + b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp - 1], arg0, arg1)"); } return ex; @@ -830,6 +947,12 @@ private Element createEnd(OperationModel operation) { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "end" + operation.name); CodeTreeBuilder b = ex.createBuilder(); + if (operation.isSourceOnly()) { + b.startIf().string("!withSource").end().startBlock(); + b.returnStatement(); + b.end(); + } + b.startStatement().startCall("endOperation"); b.string("" + operation.id); b.end(2); @@ -870,6 +993,7 @@ private Element createEnd(OperationModel operation) { b.startAssign("result").startNew(operationNodeGen.asType()).string("language").string("fdb").end(2); + b.startAssign("result.nodes").string("nodes").end(); b.startAssign("result.bc").string("Arrays.copyOf(bc, bci)").end(); b.startAssign("result.objs").string("Arrays.copyOf(objs, bci)").end(); b.startAssign("result.handlers").string("Arrays.copyOf(exHandlers, exHandlerCount)").end(); @@ -883,6 +1007,10 @@ private Element createEnd(OperationModel operation) { b.statement("buildIndex++"); + b.startIf().string("withSource").end().startBlock(); + b.statement("result.sourceInfo = Arrays.copyOf(sourceInfo, sourceInfoIndex)"); + b.end(); + b.startIf().string("savedState == null").end().startBlock(); // { b.statement("bc = null"); b.end().startElseBlock(); // } { @@ -905,17 +1033,31 @@ private Element createEnd(OperationModel operation) { b.statement("exHandlers = Arrays.copyOf(exHandlers, exHandlers.length * 2)"); b.end(); - b.statement("exHandlers[exHandlerCount] = (int) data[0]"); - b.statement("exHandlers[exHandlerCount + 1] = (int) data[1]"); - b.statement("exHandlers[exHandlerCount + 2] = (int) data[2]"); - b.statement("exHandlers[exHandlerCount + 3] = (int) data[3]"); - b.statement("exHandlers[exHandlerCount + 4] = ((OperationLocalImpl) data[4]).index.value"); - b.statement("exHandlerCount += 5"); + b.statement("exHandlers[exHandlerCount++] = (int) data[0]"); + b.statement("exHandlers[exHandlerCount++] = (int) data[1]"); + b.statement("exHandlers[exHandlerCount++] = (int) data[2]"); + b.statement("exHandlers[exHandlerCount++] = (int) data[3]"); + b.statement("exHandlers[exHandlerCount++] = ((OperationLocalImpl) data[4]).index.value"); b.end(); break; case CUSTOM_SHORT_CIRCUIT: - b.statement("((IntRef) operationData[operationSp]).value = bci"); + b.statement("((IntRef) ((Object[]) operationData[operationSp])[0]).value = bci"); + break; + case SOURCE_SECTION: + b.statement("sourceLocationSp -= 2"); + + b.startStatement().startCall("doEmitSourceInfo"); + b.string("sourceIndexStack[sourceIndexSp - 1]"); + b.string("sourceLocationStack[sourceLocationSp]"); + b.string("sourceLocationStack[sourceLocationSp + 1]"); + b.end(2); + break; + + case SOURCE: + b.statement("sourceLocationSp -= 2"); + b.statement("sourceIndexSp -= 1"); + b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp], -1, -1)"); break; default: if (operation.instruction != null) { @@ -1229,6 +1371,38 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str b.end(2); } + private CodeExecutableElement createdoEmitSourceInfo() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitSourceInfo"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "sourceIndex")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "start")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "length")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startAssert().string("withSource").end(); + + b.startIf().string("sourceInfoIndex == 0 && start == -1").end().startBlock(); + b.returnStatement(); + b.end(); + + // this is > 3 and not > 0 since we explicitly want to keep the very first entry, even + // if the second has the same BCI, since that first one is the entire function source + // section that we report + b.startIf().string("sourceInfoIndex > 3 && (sourceInfo[sourceInfoIndex - 3] & 0xffff) == bci").end().startBlock(); + b.statement("sourceInfoIndex -= 3"); + b.end(); + + b.startIf().string("sourceInfo.length == sourceInfoIndex").end().startBlock(); + b.statement("sourceInfo = Arrays.copyOf(sourceInfo, sourceInfo.length * 2)"); + b.end(); + + b.statement("sourceInfo[sourceInfoIndex++] = (sourceIndex << 16) | bci"); + b.statement("sourceInfo[sourceInfoIndex++] = start"); + b.statement("sourceInfo[sourceInfoIndex++] = length"); + + return ex; + } + private CodeExecutableElement createConstructor() { CodeExecutableElement ctor = new CodeExecutableElement(Set.of(PRIVATE), null, "Builder"); ctor.addParameter(new CodeVariableElement(operationNodes.asType(), "nodes")); @@ -1242,6 +1416,8 @@ private CodeExecutableElement createConstructor() { b.statement("this.withSource = config.isWithSource()"); b.statement("this.withInstrumentation = config.isWithInstrumentation()"); + b.statement("sources = withSource ? new ArrayList<>() : null"); + b.statement("this.builtNodes = new ArrayList<>()"); return ctor; @@ -1256,6 +1432,8 @@ private CodeTypeElement create() { operationNodes.add(createConstructor()); operationNodes.add(createReparseImpl()); operationNodes.add(createSetNodes()); + operationNodes.add(createSetSources()); + operationNodes.add(createGetSources()); return operationNodes; } @@ -1286,6 +1464,14 @@ private CodeExecutableElement createReparseImpl() { private CodeExecutableElement createSetNodes() { return GeneratorUtils.createSetter(Set.of(), new CodeVariableElement(arrayOf(operationNodeGen.asType()), "nodes")); } + + private CodeExecutableElement createSetSources() { + return GeneratorUtils.createSetter(Set.of(), new CodeVariableElement(arrayOf(types.Source), "sources")); + } + + private CodeExecutableElement createGetSources() { + return GeneratorUtils.createGetter(Set.of(), new CodeVariableElement(arrayOf(types.Source), "sources")); + } } class BaseInterpreterFactory { @@ -1549,6 +1735,8 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i b.string("frame"); } + b.string("$this"); + b.string("bci"); b.string("sp"); b.end(2); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java index 6d127bdec3fb..418ab246647b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java @@ -78,7 +78,7 @@ public enum OperationKind { STORE_LOCAL_MATERIALIZED, CUSTOM_SIMPLE, - CUSTOM_SHORT_CIRCUIT, + CUSTOM_SHORT_CIRCUIT } public static class CustomSignature { @@ -233,4 +233,8 @@ public void dump(Dumper dumper) { dumper.field("kind", kind); } + public boolean isSourceOnly() { + return kind == OperationKind.SOURCE || kind == OperationKind.SOURCE_SECTION; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 1f68660e0a97..1d3808c382d3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2190,6 +2190,10 @@ private void initializeExpressions(List elements, NodeData no globalMembers.addAll(fields); globalMembers.addAll(members); DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); + if (mode == ParseMode.OPERATION) { + originalResolver.addVariable("$root", new CodeVariableElement(types.Node, "$root")); + originalResolver.addVariable("$bci", new CodeVariableElement(context.getType(int.class), "$bci")); + } // the number of specializations might grow while expressions are initialized. List specializations = node.getSpecializations(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java index 29e92c78967e..116bf0b71b80 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLLessThanNode.java @@ -69,7 +69,7 @@ public static boolean lessThan(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("$root") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, "<", bci, left, right); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index 0f08470da3b0..f1c0451a6677 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -76,7 +76,7 @@ public abstract class SLReadPropertyNode extends SLExpressionNode { @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object readArray(Object receiver, Object index, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { @@ -90,7 +90,7 @@ public static Object readArray(Object receiver, Object index, @Specialization(limit = "LIBRARY_LIMIT") public static Object readSLObject(SLObject receiver, Object name, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { @@ -105,7 +105,7 @@ public static Object readSLObject(SLObject receiver, Object name, @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") public static Object readObject(Object receiver, Object name, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java index 4c40e1737da4..a1a4f0b61654 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLSubNode.java @@ -68,7 +68,7 @@ public static SLBigNumber sub(SLBigNumber left, SLBigNumber right) { } @Fallback - public static Object typeError(Object left, Object right, @Bind("this") Node node, @Bind("$bci") int bci) { + public static Object typeError(Object left, Object right, @Bind("$root") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, "-", bci, left, right); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 41614b2c9b40..155fbf74e52f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -79,7 +79,7 @@ public abstract class SLWritePropertyNode extends SLExpressionNode { @Specialization(guards = "arrays.hasArrayElements(receiver)", limit = "LIBRARY_LIMIT") public static Object writeArray(Object receiver, Object index, Object value, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary arrays, @CachedLibrary("index") InteropLibrary numbers) { @@ -102,7 +102,7 @@ public static Object writeSLObject(SLObject receiver, Object name, Object value, @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") public static Object writeObject(Object receiver, Object name, Object value, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java index 5355fef945fb..5021f3d68d4f 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToBooleanNode.java @@ -62,7 +62,7 @@ public static boolean doBoolean(boolean value) { } @Fallback - public static boolean doFallback(Object value, @Bind("this") Node node, @Bind("$bci") int bci) { + public static boolean doFallback(Object value, @Bind("$root") Node node, @Bind("$bci") int bci) { throw SLException.typeError(node, "toBoolean", bci, value); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index cb9da535e494..dc866f3c7888 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -174,7 +174,7 @@ protected static Object doInterop( Object function, @Variadic Object[] arguments, @CachedLibrary(limit = "3") InteropLibrary library, - @Bind("this") Node node, + @Bind("$root") Node node, @Bind("$bci") int bci) { try { return library.execute(function, arguments); From 71cd73b39cdf9c37fd9c110e66c55d31668191be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 27 Dec 2022 14:12:09 +0100 Subject: [PATCH 186/312] [wip] Boxing Elimination except locals --- .../test/example/BoxingOperationsTest.java | 4 +- .../test/example/TestOperations.java | 2 +- .../generator/FlatNodeGenFactory.java | 13 +- .../OperationNodeGeneratorPlugs.java | 39 +- .../generator/OperationsNodeFactory.java | 468 +++++++++++++++--- .../operations/model/OperationsModel.java | 4 + .../parser/CustomOperationParser.java | 39 +- .../operations/parser/OperationsParser.java | 18 +- 8 files changed, 483 insertions(+), 104 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 3bba7ab4d9a3..600dd8857baa 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -78,8 +78,8 @@ private static BoxingOperations parse(OperationParser additionalArguments() { return List.of( new CodeVariableElement(nodeType, "$root"), + new CodeVariableElement(context.getType(Object[].class), "$objs"), new CodeVariableElement(context.getType(int.class), "$bci"), new CodeVariableElement(context.getType(int.class), "$sp")); } @@ -51,23 +53,36 @@ public ChildExecutionResult createExecuteChild(FlatNodeGenFactory factory, CodeT int index = execution.getIndex(); - buildChildExecution(b, frame, index); + boolean th = buildChildExecution(b, frame, index, targetValue.getTypeMirror()); - return new ChildExecutionResult(b.build(), false); + return new ChildExecutionResult(b.build(), th); } - private void buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx) { + private boolean buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx, TypeMirror resultType) { int index = idx; if (index < instr.signature.valueCount) { - b.startCall(frame, "getObject").startGroup(); - b.string("$sp"); + + String slotString = "$sp - " + (instr.signature.valueCount - index); + if (instr.signature.isVariadic) { - b.string(" - this.op_variadicCount_"); + slotString += " - this.op_variadicCount_"; + } + + if (ElementUtils.isObject(resultType)) { + b.startCall(frame, "getObject"); + b.string(slotString); + b.end(); + return false; + } else { + b.startCall("doPopPrimitive" + ElementUtils.firstLetterUpperCase(resultType.toString())); + b.tree(frame); + b.string(slotString); + b.string("this.op_childValue" + index + "_boxing_"); + b.string("$objs"); + b.end(); + return true; } - b.string(" - " + (instr.signature.valueCount - index)); - b.end(2); - return; } index -= instr.signature.valueCount; @@ -78,21 +93,21 @@ private void buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx) { b.string("$sp"); b.string("this.op_variadicCount_"); b.end(); - return; + return false; } index -= 1; } if (index < instr.signature.localSetterCount) { b.string("this.op_localSetter" + index + "_"); - return; + return false; } index -= instr.signature.localSetterCount; if (index < instr.signature.localSetterRangeCount) { b.string("this.op_localSetterRange" + index + "_"); - return; + return false; } throw new AssertionError("index=" + index + ", signature=" + instr.signature); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 40a389c76829..5ae72e74f5d7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -40,7 +40,10 @@ */ package com.oracle.truffle.dsl.processor.operations.generator; +import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createNeverPartOfCompilation; +import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createShouldNotReachHere; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; @@ -105,6 +108,7 @@ public class OperationsNodeFactory { private CodeTypeElement uncachedInterpreter; private CodeTypeElement cachedInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "CachedInterpreter"); private CodeTypeElement instrumentableInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "InstrumentableInterpreter"); + private CodeTypeElement boxableInterface = new CodeTypeElement(Set.of(PRIVATE), ElementKind.INTERFACE, null, "BoxableInterface"); private static final Name Uncached_Name = CodeNames.of("Uncached"); @@ -144,6 +148,7 @@ public CodeTypeElement create() { operationNodeGen.add(new IntRefFactory().create()); operationNodeGen.add(new OperationLocalImplFactory().create()); operationNodeGen.add(new OperationLabelImplFactory().create()); + operationNodeGen.add(new BoxableInterfaceFactory().create()); operationNodeGen.add(createFrameDescriptorConstructor()); operationNodeGen.add(createFrameDescriptorBuliderConstructor()); @@ -177,6 +182,10 @@ public CodeTypeElement create() { operationNodeGen.add(createReadVariadic()); + for (TypeMirror type : model.boxingEliminatedTypes) { + operationNodeGen.add(createDoPopPrimitive(type)); + } + StaticConstants consts = new StaticConstants(); for (InstructionModel instr : model.getInstructions()) { if (instr.nodeData == null) { @@ -189,7 +198,7 @@ public CodeTypeElement create() { CodeTypeElement el = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, instr.getInternalName() + "Gen"); el.setSuperClass(types.Node); factory.create(el); - processNodeType(el, instr); + new CustomInstructionNodeFactory().processNodeType(el, instr); operationNodeGen.add(el); } @@ -322,43 +331,6 @@ private CodeVariableElement createInterpreterSwitch(CodeTypeElement interpreterT return fld; } - @SuppressWarnings("unchecked") - private void processNodeType(CodeTypeElement el, InstructionModel instr) { - for (VariableElement fld : ElementFilter.fieldsIn(el.getEnclosedElements())) { - if (ElementUtils.getQualifiedName(fld.asType()).equals("C")) { - el.remove(fld); - } - } - - for (ExecutableElement ctor : ElementFilter.constructorsIn(el.getEnclosedElements())) { - el.remove(ctor); - } - - for (CodeTypeElement type : (List) (List) ElementFilter.typesIn(el.getEnclosedElements())) { - if (type.getSimpleName() == Uncached_Name) { - type.setSuperClass(types.Node); - } - } - - if (instr.needsUncachedData()) { - CodeTypeElement uncachedType = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, el.getSimpleName() + "_UncachedData"); - uncachedType.setSuperClass(types.Node); - uncachedType.setEnclosingElement(operationNodeGen); - operationNodeGen.add(uncachedType); - - el.setSuperClass(uncachedType.asType()); - - for (InstructionField field : instr.getUncachedFields()) { - uncachedType.add(new CodeVariableElement(field.type, field.name)); - } - } - - int index = 0; - for (InstructionField field : instr.getCachedFields()) { - el.getEnclosedElements().add(index++, new CodeVariableElement(field.type, field.name)); - } - } - private CodeExecutableElement createFrameDescriptorConstructor() { CodeExecutableElement ctor = GeneratorUtils.createSuperConstructor(operationNodeGen, model.fdConstructor); ctor.getModifiers().clear(); @@ -524,6 +496,52 @@ private CodeExecutableElement createReadVariadic() { return ex; } + private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { + String typeName = firstLetterUpperCase(resultType.toString()); + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), resultType, "doPopPrimitive" + typeName); + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "boxing")); + ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); + + ex.addThrownType(types.UnexpectedResultException); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("boxing == 0xffff0000").end().startBlock(); // { + b.statement("Object result = frame.getObject(slot)"); + + b.startIf().string("result").instanceOf(ElementUtils.boxType(resultType)).end().startBlock(); // { + b.startReturn().cast(resultType).string("result").end(); + b.end().startElseBlock(); // } { + b.tree(createTransferToInterpreterAndInvalidate()); + b.startThrow().startNew(types.UnexpectedResultException).string("result").end(2); + b.end(); // } + + b.end().startElseBlock(); // } { + + b.startIf().string("frame.is" + typeName + "(slot)").end().startBlock(); + b.startReturn().string("frame.get" + typeName + "(slot)").end(); + b.end().startElseBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) " + (resultType.getKind().ordinal() + 1) + " /* " + resultType + " */ )"); + + b.statement("Object result = frame.getValue(slot)"); + + b.startIf().string("result").instanceOf(ElementUtils.boxType(resultType)).end().startBlock(); // { + b.startReturn().cast(resultType).string("result").end(); + b.end().startElseBlock(); // } { + b.tree(createTransferToInterpreterAndInvalidate()); + b.startThrow().startNew(types.UnexpectedResultException).string("result").end(2); + b.end(); + + b.end(); + + b.end(); + + return ex; + } + private CodeExecutableElement createChangeInterpreters() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "changeInterpreters"); @@ -615,6 +633,8 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "curStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "exHandlers"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "exHandlerCount"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "stackValueBciStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "stackValueBciSp"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceIndexStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceIndexSp"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceLocationStack"), @@ -804,9 +824,15 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("operationSp = 0"); b.statement("numLocals = 0"); b.statement("curStack = 0"); - b.statement("maxStack = 10"); + b.statement("maxStack = 0"); b.statement("exHandlers = new int[10]"); b.statement("exHandlerCount = 0"); + + if (model.hasBoxingElimination()) { + b.statement("stackValueBciStack = new int[8]"); + b.statement("stackValueBciSp = 0"); + } + b.startIf().string("withSource").end().startBlock(); b.statement("sourceIndexStack = new int[1]"); b.statement("sourceIndexSp = 0"); @@ -1358,7 +1384,144 @@ private CodeExecutableElement createEmitInstruction() { return ex; } + private void buildPushStackIndex(CodeTreeBuilder b, String index, boolean performCheck) { + if (performCheck) { + b.startIf().string("stackValueBciStack.length == stackValueBciSp").end().startBlock(); + b.statement("stackValueBciStack = Arrays.copyOf(stackValueBciStack, stackValueBciStack.length * 2)"); + b.end(); + } + + if (index != null) { + if (index.equals("0")) { + b.statement("stackValueBciStack[stackValueBciSp++] = bci"); + } else { + b.statement("stackValueBciStack[stackValueBciSp++] = ((" + index + ") << 16 | bci"); + } + } else { + b.statement("stackValueBciStack[stackValueBciSp++] = 0xffff0000"); + } + + } + private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, String argument) { + + if (model.hasBoxingElimination()) { + switch (instr.kind) { + case BRANCH: + case INSTRUMENTATION_ENTER: + case INSTRUMENTATION_EXIT: + case INSTRUMENTATION_LEAVE: + case RETURN: + break; + case BRANCH_FALSE: + case CUSTOM_SHORT_CIRCUIT: + case POP: + b.statement("stackValueBciSp--"); + break; + case CUSTOM: + case CUSTOM_QUICKENED: + if (instr.signature.isVariadic) { + b.statement("stackValueBciSp -= " + argument + ".op_variadicCount_"); + } + for (int i = instr.signature.valueCount - 1; i >= 0; i--) { + if (instr.signature.valueBoxingElimination[i]) { + b.statement(argument + ".op_childValue" + i + "_boxing_ = stackValueBciStack[--stackValueBciSp]"); + } else { + b.statement("stackValueBciSp--"); + } + } + if (!instr.signature.isVoid) { + buildPushStackIndex(b, instr.signature.resultBoxingElimination ? "0" : null, instr.signature.valueCount == 0); + } + break; + case LOAD_ARGUMENT: + case LOAD_CONSTANT: + buildPushStackIndex(b, null, true); + break; + case LOAD_LOCAL: + // todo: buildPushStackIndex(b, "0", true); + buildPushStackIndex(b, null, true); + break; + case LOAD_LOCAL_MATERIALIZED: + b.statement("stackValueBciSp--"); + // todo: buildPushStackIndex(b, "0", false); + buildPushStackIndex(b, null, true); + break; + case STORE_LOCAL: + // todo: store boxing elim + b.statement("stackValueBciSp--"); + break; + case STORE_LOCAL_MATERIALIZED: + b.statement("stackValueBciSp -= 2"); + break; + case SUPERINSTRUCTION: + // todo + break; + case THROW: + break; + case YIELD: + b.statement("stackValueBciSp--"); + buildPushStackIndex(b, "0", false); + break; + default: + throw new UnsupportedOperationException(); + + } + } + + boolean hasDelta = false; + + switch (instr.kind) { + case BRANCH: + case INSTRUMENTATION_ENTER: + case INSTRUMENTATION_EXIT: + case INSTRUMENTATION_LEAVE: + case LOAD_LOCAL_MATERIALIZED: + case THROW: + case YIELD: + break; + case BRANCH_FALSE: + case CUSTOM_SHORT_CIRCUIT: + case RETURN: + case POP: + case STORE_LOCAL: + hasDelta = true; + b.statement("curStack -= 1"); + break; + case CUSTOM: + case CUSTOM_QUICKENED: + if (instr.signature.isVariadic) { + b.statement("curStack -= " + argument + ".op_variadicCount_"); + hasDelta = true; + } + int delta = (instr.signature.isVoid ? 0 : 1) - instr.signature.valueCount; + if (delta != 0) { + b.statement("curStack += " + delta); + hasDelta = true; + } + break; + case LOAD_ARGUMENT: + case LOAD_CONSTANT: + case LOAD_LOCAL: + hasDelta = true; + b.statement("curStack += 1"); + break; + case STORE_LOCAL_MATERIALIZED: + b.statement("curStack -= 2"); + break; + case SUPERINSTRUCTION: + // todo + break; + default: + throw new UnsupportedOperationException(); + } + + if (hasDelta) { + b.startIf().string("curStack > maxStack").end().startBlock(); + b.statement("maxStack = curStack"); + b.end(); + } + b.startStatement().startCall("doEmitInstruction"); b.string(instr.id + " /* " + instr.name + " */"); b.startGroup(); @@ -1574,17 +1737,11 @@ private CodeExecutableElement createContinueAt() { b.end(); break; case CUSTOM: { - buildCustomInstructionExecute(b, instr); - - int stackOffset = -instr.signature.valueCount + (instr.signature.isVoid ? 0 : 1); - b.statement("sp += " + stackOffset + (instr.signature.isVariadic ? " - variadicCount" : "")); - if (!instr.signature.isVoid) { - b.statement("frame.setObject(sp - 1, result)"); - } + buildCustomInstructionExecute(b, instr, true); break; } case CUSTOM_SHORT_CIRCUIT: - buildCustomInstructionExecute(b, instr); + buildCustomInstructionExecute(b, instr, false); b.startIf().string("result", instr.continueWhen ? "!=" : "==", "Boolean.TRUE").end().startBlock(); b.startAssign("bci"); @@ -1692,27 +1849,31 @@ private CodeExecutableElement createContinueAt() { return ex; } - private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel instr) { + private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel instr, boolean doPush) { TypeMirror genType = new GeneratedTypeMirror("", instr.getInternalName() + "Gen"); TypeMirror uncachedType = new GeneratedTypeMirror("", instr.getInternalName() + "Gen_UncachedData"); CustomSignature signature = instr.signature; + String extraArguments = "$this, objs, bci, sp"; + if (signature.isVariadic) { b.startAssign("int variadicCount"); b.startParantheses().cast(uncachedType).string("curObj").end().string(".op_variadicCount_"); b.end(); } - String executeName; - if (signature.isVoid) { - b.startStatement(); - executeName = "executeVoid"; - } else { - b.startAssign("Object result"); - executeName = "executeObject"; + if (doPush) { + int stackOffset = -instr.signature.valueCount + (instr.signature.isVoid ? 0 : 1); + b.statement("int resultSp = sp + " + stackOffset + (instr.signature.isVariadic ? " - variadicCount" : "")); } if (isUncached) { + if (signature.isVoid) { + b.startStatement(); + } else { + b.startAssign("Object result"); + } + b.staticReference(genType, "UNCACHED").startCall(".executeUncached"); b.string("frame"); @@ -1730,16 +1891,96 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i b.string("readVariadic(frame, sp, variadicCount)"); } + b.string(extraArguments); + b.end(2); + + if (!signature.isVoid && doPush) { + b.statement("frame.setObject(resultSp - 1, result)"); + } + } else if (signature.isVoid) { + b.startStatement(); + b.startParantheses().cast(genType).string("curObj").end().startCall(".executeVoid"); + b.string("frame"); + b.string(extraArguments); + b.end(2); + } else if (signature.resultBoxingElimination) { + + if (!doPush) { + throw new AssertionError("RBE is set for " + instr.name + " but !doPush"); + } + + b.startBlock(); + b.declaration(genType, "nObj"); + b.startAssign("nObj").cast(genType).string("curObj").end(); + + b.startSwitch().string("nObj.op_resultType_").end().startBlock(); + + b.startCase().string("-1").end(); + b.startCase().string("0").end().startCaseBlock(); + // object case + b.startStatement().startCall("frame.setObject"); + b.string("resultSp - 1"); + b.startCall("nObj.executeObject"); + b.string("frame").string(extraArguments); + b.end(3); + b.statement("break"); + b.end(); + + Set mirs = signature.possibleBoxingResults; + if (mirs == null) { + mirs = model.boxingEliminatedTypes; + } + + for (TypeMirror mir : mirs) { + if (ElementUtils.isObject(mir)) { + continue; + } + + b.startCase().string("" + (mir.getKind().ordinal() + 1) + " /* " + mir + " */").end().startCaseBlock(); + + b.startTryBlock(); + b.startStatement().startCall("frame.set" + firstLetterUpperCase(mir.toString())); + b.string("resultSp - 1"); + b.startCall("nObj.execute" + firstLetterUpperCase(mir.toString())); + b.string("frame").string(extraArguments); + b.end(3); + + b.end().startCatchBlock(types.UnexpectedResultException, "ex"); + + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("nObj.op_resultType_ = -1"); + b.statement("frame.setObject(resultSp - 1, ex.getResult())"); + + b.end(); + + b.statement("break"); + + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(createShouldNotReachHere("tried to BE " + instr.name + " as type \" + nObj.op_resultType_ + \" but no bueno")); + b.end(); + + b.end(); + + b.end(); } else { - b.startParantheses().cast(genType).string("curObj").end().startCall("." + executeName); + // non-boxing-eliminated, non-void, cached + b.startAssign("Object result"); + b.startParantheses().cast(genType).string("curObj").end().startCall(".executeObject"); b.string("frame"); - } + b.string(extraArguments); + b.end(2); - b.string("$this"); - b.string("bci"); - b.string("sp"); + if (doPush) { + b.statement("frame.setObject(resultSp - 1, result)"); + } + } - b.end(2); + if (doPush) { + b.statement("sp = resultSp"); + } } } @@ -1783,6 +2024,111 @@ private CodeTypeElement create() { } } + private static final Set EXECUTE_NAMES = Set.of("executeBoolean", "executeLong", "executeInt", "executeByte", "executeDouble", "executeFloat"); + + private class CustomInstructionNodeFactory { + + @SuppressWarnings({"unchecked", "rawtypes"}) + private void processNodeType(CodeTypeElement el, InstructionModel instr) { + for (VariableElement fld : ElementFilter.fieldsIn(el.getEnclosedElements())) { + if (ElementUtils.getQualifiedName(fld.asType()).equals("C")) { + el.remove(fld); + } + } + + for (ExecutableElement ctor : ElementFilter.constructorsIn(el.getEnclosedElements())) { + el.remove(ctor); + } + + for (ExecutableElement met : ElementFilter.methodsIn(el.getEnclosedElements())) { + if (EXECUTE_NAMES.contains(met.getSimpleName().toString())) { + if (!met.getThrownTypes().contains(types.UnexpectedResultException)) { + ((List) met.getThrownTypes()).add(types.UnexpectedResultException); + } + } + } + + for (CodeTypeElement type : (List) (List) ElementFilter.typesIn(el.getEnclosedElements())) { + if (type.getSimpleName() == Uncached_Name) { + type.setSuperClass(types.Node); + } + } + + if (instr.needsUncachedData()) { + CodeTypeElement uncachedType = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, el.getSimpleName() + "_UncachedData"); + uncachedType.setSuperClass(types.Node); + uncachedType.setEnclosingElement(operationNodeGen); + operationNodeGen.add(uncachedType); + + el.setSuperClass(uncachedType.asType()); + + for (InstructionField field : instr.getUncachedFields()) { + uncachedType.add(new CodeVariableElement(field.type, field.name)); + } + } + + int index = 0; + for (InstructionField field : instr.getCachedFields()) { + el.getEnclosedElements().add(index++, new CodeVariableElement(field.type, field.name)); + } + + if (instr.signature.resultBoxingElimination) { + el.getInterfaces().add(boxableInterface.asType()); + el.add(creatSetBoxing(instr)); + } + } + + private CodeExecutableElement creatSetBoxing(InstructionModel instr) { + CodeExecutableElement setBoxing = GeneratorUtils.overrideImplement((DeclaredType) boxableInterface.asType(), "setBoxing"); + CodeTreeBuilder b = setBoxing.createBuilder(); + + b.tree(createNeverPartOfCompilation()); + + b.startAssert().string("index == 0").end(); + + b.startIf().string("this.op_resultType_ == kind").end().startBlock(); + b.returnStatement(); + b.end(); + + b.startIf().string("this.op_resultType_ == 0 && ("); + Set mirs = instr.signature.possibleBoxingResults; + if (mirs == null) { + mirs = model.boxingEliminatedTypes; + } + boolean first = true; + for (TypeMirror mir : mirs) { + if (first) { + first = false; + } else { + b.string(" || "); + } + b.string("kind == " + (mir.getKind().ordinal() + 1) + " /* " + mir + " */"); + } + b.string(")").end().startBlock(); + b.statement("this.op_resultType_ = kind"); + b.returnStatement(); + b.end(); + + b.statement("this.op_resultType_ = -1"); + return setBoxing; + } + } + + class BoxableInterfaceFactory { + private CodeTypeElement create() { + boxableInterface.add(createSetBoxing()); + + return boxableInterface; + } + + private CodeExecutableElement createSetBoxing() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC, ABSTRACT), context.getType(void.class), "setBoxing"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "index")); + ex.addParameter(new CodeVariableElement(context.getType(byte.class), "kind")); + return ex; + } + } + private static TypeMirror generic(DeclaredType el, TypeMirror... args) { return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index 71a4e1dbb6f3..17fdd1586bc6 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -254,4 +254,8 @@ public void dump(Dumper dumper) { dumper.field("instructions", instructions); } + public boolean hasBoxingElimination() { + return !boxingEliminatedTypes.isEmpty(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 16e9bce0c25b..2113f5fc440e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -384,7 +384,15 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl instr.nodeData.redirectMessagesOnGeneratedElements(parent); if (signature.resultBoxingElimination) { - instr.addField(context.getType(int.class), "op_resultType_", false); + instr.addField(context.getType(byte.class), "op_resultType_", false); + } + + for (int i = 0; i < signature.valueBoxingElimination.length; i++) { + if (signature.valueBoxingElimination[i]) { + // we could move these to cached-only fields, but then we need more processing + // once we go uncached -> cached + instr.addField(context.getType(int.class), "op_childValue" + i + "_boxing_", true); + } } if (signature.isVariadic) { @@ -575,19 +583,22 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen signature.valueBoxingElimination[i] = canBeBoxingEliminated.get(i); } - TypeMirror returnType = spec.getReturnType(); - if (ElementUtils.isVoid(spec.getReturnType())) { - signature.isVoid = true; - signature.resultBoxingElimination = false; - } else if (parent.isBoxingEliminated(returnType)) { - signature.resultBoxingElimination = true; - signature.possibleBoxingResults = new HashSet<>(Set.of(returnType)); - } else if (ElementUtils.isObject(returnType)) { - signature.resultBoxingElimination = false; - signature.possibleBoxingResults = null; - } else { - signature.resultBoxingElimination = false; - signature.possibleBoxingResults = new HashSet<>(Set.of(context.getType(Object.class))); + // short-circuit ops are never boxing-eliminated + if (data.kind != OperationKind.CUSTOM_SHORT_CIRCUIT) { + TypeMirror returnType = spec.getReturnType(); + if (ElementUtils.isVoid(spec.getReturnType())) { + signature.isVoid = true; + signature.resultBoxingElimination = false; + } else if (parent.isBoxingEliminated(returnType)) { + signature.resultBoxingElimination = true; + signature.possibleBoxingResults = new HashSet<>(Set.of(returnType)); + } else if (ElementUtils.isObject(returnType)) { + signature.resultBoxingElimination = false; + signature.possibleBoxingResults = null; + } else { + signature.resultBoxingElimination = false; + signature.possibleBoxingResults = new HashSet<>(Set.of(context.getType(Object.class))); + } } return signature; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index f51c651514ec..91f1dcc9e4eb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -158,18 +158,16 @@ protected OperationsModel parse(Element element, List mirror) // find and bind boxing elimination types Set beTypes = new HashSet<>(); - if (false) { - List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); - for (AnnotationValue value : boxingEliminatedTypes) { + List boxingEliminatedTypes = (List) ElementUtils.getAnnotationValue(generateOperationsMirror, "boxingEliminationTypes").getValue(); + for (AnnotationValue value : boxingEliminatedTypes) { - TypeMirror mir = getTypeMirror(value); + TypeMirror mir = getTypeMirror(value); - if (BOXABLE_TYPE_KINDS.contains(mir.getKind())) { - beTypes.add(mir); - } else { - model.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", - mir); - } + if (BOXABLE_TYPE_KINDS.contains(mir.getKind())) { + beTypes.add(mir); + } else { + model.addError("Cannot perform boxing elimination on %s. Remove this type from the boxing eliminated types list. Only primitive types boolean, byte, int, float, long, and double are supported.", + mir); } } From e731d73613b45f7d3dfb56069f82434df46f6941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 28 Dec 2022 12:57:01 +0100 Subject: [PATCH 187/312] [wip] Local boxing elimination --- .../generator/OperationsNodeFactory.java | 337 ++++++++++++++++-- .../operations/model/OperationsModel.java | 8 +- 2 files changed, 312 insertions(+), 33 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 5ae72e74f5d7..847527a12f7d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -40,9 +40,11 @@ */ package com.oracle.truffle.dsl.processor.operations.generator; +import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createConstructorUsingFields; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createNeverPartOfCompilation; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createShouldNotReachHere; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.boxType; import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.FINAL; @@ -101,6 +103,8 @@ public class OperationsNodeFactory { private CodeTypeElement operationNodes = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationNodesImpl"); private CodeTypeElement intRef = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "IntRef"); + private CodeTypeElement loadLocalData = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "LoadLocalData"); + private CodeTypeElement storeLocalData = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "StoreLocalData"); private CodeTypeElement operationLocalImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLocalImpl"); private CodeTypeElement operationLabelImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLabelImpl"); @@ -149,6 +153,10 @@ public CodeTypeElement create() { operationNodeGen.add(new OperationLocalImplFactory().create()); operationNodeGen.add(new OperationLabelImplFactory().create()); operationNodeGen.add(new BoxableInterfaceFactory().create()); + if (model.hasBoxingElimination()) { + operationNodeGen.add(new LoadLocalDataFactory().create()); + operationNodeGen.add(new StoreLocalDataFactory().create()); + } operationNodeGen.add(createFrameDescriptorConstructor()); operationNodeGen.add(createFrameDescriptorBuliderConstructor()); @@ -173,6 +181,9 @@ public CodeTypeElement create() { operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceInfo"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); + if (model.hasBoxingElimination()) { + operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(byte[].class), "localBoxingState"))); + } if (model.generateUncached) { operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "uncachedExecuteCount")).createInitBuilder().string("16"); } @@ -181,9 +192,11 @@ public CodeTypeElement create() { operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()")); operationNodeGen.add(createReadVariadic()); - - for (TypeMirror type : model.boxingEliminatedTypes) { - operationNodeGen.add(createDoPopPrimitive(type)); + if (model.hasBoxingElimination()) { + operationNodeGen.add(createDoPopObject()); + for (TypeMirror type : model.boxingEliminatedTypes) { + operationNodeGen.add(createDoPopPrimitive(type)); + } } StaticConstants consts = new StaticConstants(); @@ -361,7 +374,12 @@ private CodeExecutableElement createExecute() { b.statement("int state = numLocals << 16"); b.startWhile().string("true").end().startBlock(); - b.statement("state = interpreter.continueAt(this, frame, bc, objs, handlers, state)"); + b.startAssign("state").startCall("interpreter.continueAt"); + b.string("this, frame, bc, objs, handlers, state"); + if (model.hasBoxingElimination()) { + b.string("localBoxingState"); + } + b.end(2); b.startIf().string("(state & 0xffff) == 0xffff").end().startBlock(); b.statement("break"); b.end().startElseBlock(); @@ -496,6 +514,26 @@ private CodeExecutableElement createReadVariadic() { return ex; } + private CodeExecutableElement createDoPopObject() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object.class), "doPopObject"); + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "boxing")); + ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("boxing == 0xffff0000 || frame.isObject(slot)").end().startBlock(); // { + b.startReturn().string("frame.getObject(slot)").end(); + b.end(); // } + + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) -1)"); + b.startReturn().string("frame.getValue(slot)").end(); + + return ex; + } + private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { String typeName = firstLetterUpperCase(resultType.toString()); CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), resultType, "doPopPrimitive" + typeName); @@ -511,7 +549,7 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.startIf().string("boxing == 0xffff0000").end().startBlock(); // { b.statement("Object result = frame.getObject(slot)"); - b.startIf().string("result").instanceOf(ElementUtils.boxType(resultType)).end().startBlock(); // { + b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { b.startReturn().cast(resultType).string("result").end(); b.end().startElseBlock(); // } { b.tree(createTransferToInterpreterAndInvalidate()); @@ -524,11 +562,13 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.startReturn().string("frame.get" + typeName + "(slot)").end(); b.end().startElseBlock(); b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) " + (resultType.getKind().ordinal() + 1) + " /* " + resultType + " */ )"); + b.startStatement(); + b.string("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) ").tree(boxingTypeToInt(resultType)).string(")"); + b.end(); b.statement("Object result = frame.getValue(slot)"); - b.startIf().string("result").instanceOf(ElementUtils.boxType(resultType)).end().startBlock(); // { + b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { b.startReturn().cast(resultType).string("result").end(); b.end().startElseBlock(); // } { b.tree(createTransferToInterpreterAndInvalidate()); @@ -610,6 +650,12 @@ private CodeExecutableElement createChangeInterpreters() { b.end(); // } for + if (model.hasBoxingElimination() && model.generateUncached) { + b.startIf().string("interpreter == UNCACHED_INTERPRETER").end().startBlock(); + b.statement("localBoxingState = new byte[numLocals]"); + b.end(); + } + b.statement("objs = newObjs"); b.statement("interpreter = toInterpreter"); @@ -649,7 +695,7 @@ class BuilderFactory { class SavedStateFactory { private CodeTypeElement create() { savedState.addAll(List.of(builderState)); - savedState.add(GeneratorUtils.createConstructorUsingFields(Set.of(), savedState, null)); + savedState.add(createConstructorUsingFields(Set.of(), savedState, null)); return savedState; } @@ -1026,6 +1072,11 @@ private Element createEnd(OperationModel operation) { b.startAssign("result.numLocals").string("numLocals").end(); b.startAssign("result.buildIndex").string("buildIndex").end(); + if (model.hasBoxingElimination() && !model.generateUncached) { + // need to initialize it now + b.startAssign("result.localBoxingState").string("new byte[numLocals]").end(); + } + b.startAssert().string("builtNodes.size() == buildIndex").end(); b.statement("builtNodes.add(result)"); @@ -1107,9 +1158,15 @@ private void buildEmitOperationInstruction(CodeTreeBuilder b, OperationModel ope b.startBlock(); switch (operation.kind) { case STORE_LOCAL: + if (model.hasBoxingElimination()) { + b.statement("StoreLocalData argument = new StoreLocalData((short) ((OperationLocalImpl) operationData[operationSp]).index.value)"); + } else { + b.statement("IntRef argument = ((OperationLocalImpl) operationData[operationSp]).index"); + } + break; case STORE_LOCAL_MATERIALIZED: case LOAD_LOCAL_MATERIALIZED: - b.statement("Object argument = ((OperationLocalImpl) operationData[operationSp]).index"); + b.statement("IntRef argument = ((OperationLocalImpl) operationData[operationSp]).index"); break; case RETURN: case YIELD: @@ -1120,10 +1177,14 @@ private void buildEmitOperationInstruction(CodeTreeBuilder b, OperationModel ope b.statement("Object argument = arg0"); break; case LOAD_LOCAL: - b.statement("Object argument = ((OperationLocalImpl) arg0).index"); + if (model.hasBoxingElimination()) { + b.statement("LoadLocalData argument = new LoadLocalData((short) ((OperationLocalImpl) arg0).index.value)"); + } else { + b.statement("IntRef argument = ((OperationLocalImpl) arg0).index"); + } break; case BRANCH: - b.statement("Object argument = ((OperationLabelImpl) arg0).index"); + b.statement("IntRef argument = ((OperationLabelImpl) arg0).index"); break; case CUSTOM_SIMPLE: case CUSTOM_SHORT_CIRCUIT: @@ -1439,17 +1500,18 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str buildPushStackIndex(b, null, true); break; case LOAD_LOCAL: - // todo: buildPushStackIndex(b, "0", true); - buildPushStackIndex(b, null, true); + buildPushStackIndex(b, "0", true); break; case LOAD_LOCAL_MATERIALIZED: b.statement("stackValueBciSp--"); - // todo: buildPushStackIndex(b, "0", false); buildPushStackIndex(b, null, true); break; case STORE_LOCAL: - // todo: store boxing elim - b.statement("stackValueBciSp--"); + if (model.hasBoxingElimination()) { + b.statement(argument + ".s_childIndex = stackValueBciStack[--stackValueBciSp]"); + } else { + b.statement("stackValueBciSp--"); + } break; case STORE_LOCAL_MATERIALIZED: b.statement("stackValueBciSp -= 2"); @@ -1469,7 +1531,7 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str } } - boolean hasDelta = false; + boolean hasPositiveDelta = false; switch (instr.kind) { case BRANCH: @@ -1485,25 +1547,23 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str case RETURN: case POP: case STORE_LOCAL: - hasDelta = true; b.statement("curStack -= 1"); break; case CUSTOM: case CUSTOM_QUICKENED: if (instr.signature.isVariadic) { b.statement("curStack -= " + argument + ".op_variadicCount_"); - hasDelta = true; } int delta = (instr.signature.isVoid ? 0 : 1) - instr.signature.valueCount; if (delta != 0) { b.statement("curStack += " + delta); - hasDelta = true; + hasPositiveDelta = delta > 0; } break; case LOAD_ARGUMENT: case LOAD_CONSTANT: case LOAD_LOCAL: - hasDelta = true; + hasPositiveDelta = true; b.statement("curStack += 1"); break; case STORE_LOCAL_MATERIALIZED: @@ -1516,7 +1576,7 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str throw new UnsupportedOperationException(); } - if (hasDelta) { + if (hasPositiveDelta) { b.startIf().string("curStack > maxStack").end().startBlock(); b.statement("maxStack = curStack"); b.end(); @@ -1653,6 +1713,9 @@ private CodeExecutableElement createContinueAt() { ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); ex.addParameter(new CodeVariableElement(context.getType(int[].class), "handlers")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "startState")); + if (model.hasBoxingElimination()) { + ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localBoxingState")); + } return ex; } @@ -1675,6 +1738,11 @@ private CodeTypeElement create() { interpreterType.add(createContinueAt()); + if (!isUncached && model.hasBoxingElimination()) { + interpreterType.add(createDoLoadLocalInitialize()); + interpreterType.add(createDoStoreLocalInitialize()); + } + return interpreterType; } @@ -1775,7 +1843,64 @@ private CodeExecutableElement createContinueAt() { b.statement("sp += 1"); break; case LOAD_LOCAL: - b.statement("frame.setObject(sp, frame.getObject(((IntRef) curObj).value))"); + if (!model.hasBoxingElimination()) { + b.statement("frame.setObject(sp, frame.getObject(((IntRef) curObj).value))"); + } else if (isUncached) { + b.statement("frame.setObject(sp, frame.getObject(((LoadLocalData) curObj).v_index))"); + } else { + b.statement("LoadLocalData curData = (LoadLocalData) curObj"); + b.statement("int curIndex = curData.v_index"); + + b.startSwitch().string("curData.v_kind").end().startBlock(); + + b.startCase().string("0").end().startCaseBlock(); + // uninitialized + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, true)"); + b.statement("break"); + b.end(); + + b.startCase().string("-1").end().startCaseBlock(); + // generic + b.startIf().string("frame.isObject(curIndex)").end().startBlock(); + b.statement("frame.copyObject(curIndex, sp)"); + b.end().startElseBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("frame.setObject(sp, frame.getValue(curIndex))"); + b.end(); + b.statement("break"); + b.end(); + + for (TypeMirror mir : model.boxingEliminatedTypes) { + String frameName = firstLetterUpperCase(mir.toString()); + + b.startCase().tree(boxingTypeToInt(mir)).end().startCaseBlock(); + b.startIf().string("frame.is" + frameName + "(curIndex)").end().startBlock(); + b.statement("frame.copyPrimitive(curIndex, sp)"); + b.end().startElseBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, false)"); + b.end(); + b.statement("break"); + b.end(); + + b.startCase().tree(boxingTypeToInt(mir)).string("| 0x40 /* (boxed) */").end().startCaseBlock(); + b.startIf().string("frame.is" + frameName + "(curIndex)").end().startBlock(); + b.statement("frame.setObject(sp, frame.get" + frameName + "(curIndex))"); + b.end().startElseBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, false)"); + b.end(); + b.statement("break"); + b.end(); + } + + b.caseDefault().startCaseBlock(); + b.tree(createShouldNotReachHere()); + b.end(); + + b.end(); + } b.statement("sp += 1"); break; case LOAD_LOCAL_MATERIALIZED: @@ -1799,7 +1924,45 @@ private CodeExecutableElement createContinueAt() { b.statement("return ((sp - 1) << 16) | 0xffff"); break; case STORE_LOCAL: - b.statement("frame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))"); + if (!model.hasBoxingElimination()) { + b.statement("frame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))"); + } else if (isUncached) { + b.statement("frame.setObject(((StoreLocalData) curObj).s_index, frame.getObject(sp - 1))"); + } else { + b.statement("StoreLocalData curData = (StoreLocalData) curObj"); + b.statement("int curIndex = curData.s_index"); + + b.startSwitch().string("localBoxingState[curIndex]").end().startBlock(); + + b.startCase().string("0").end().startBlock(); + b.tree(createTransferToInterpreterAndInvalidate()); + b.statement("doStoreLocalInitialize(frame, sp, localBoxingState, curIndex)"); + b.statement("break"); + b.end(); + + b.startCase().string("-1").end().startBlock(); + b.statement("frame.setObject(curIndex, doPopObject(frame, sp - 1, curData.s_childIndex, objs))"); + b.statement("break"); + b.end(); + + for (TypeMirror mir : model.boxingEliminatedTypes) { + + String frameName = firstLetterUpperCase(mir.toString()); + + b.startCase().tree(boxingTypeToInt(mir)).end().startBlock(); + + b.startTryBlock(); + b.statement("frame.set" + frameName + "(curIndex, doPopPrimitive" + frameName + "(frame, sp - 1, curData.s_childIndex, objs))"); + b.end().startCatchBlock(types.UnexpectedResultException, "ex"); + b.statement("localBoxingState[curIndex] = -1"); + b.statement("frame.setObject(curIndex, ex.getResult())"); + b.end(); + b.statement("break"); + b.end(); + } + + b.end(); + } b.statement("sp -= 1"); break; case STORE_LOCAL_MATERIALIZED: @@ -1936,7 +2099,7 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i continue; } - b.startCase().string("" + (mir.getKind().ordinal() + 1) + " /* " + mir + " */").end().startCaseBlock(); + b.startCase().tree(boxingTypeToInt(mir)).end().startCaseBlock(); b.startTryBlock(); b.startStatement().startCall("frame.set" + firstLetterUpperCase(mir.toString())); @@ -1982,6 +2145,63 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i b.statement("sp = resultSp"); } } + + private CodeExecutableElement createDoLoadLocalInitialize() { + CodeExecutableElement ex = new CodeExecutableElement(context.getType(void.class), "doLoadLocalInitialize"); + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp")); + ex.addParameter(new CodeVariableElement(loadLocalData.asType(), "curData")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "curIndex")); + ex.addParameter(new CodeVariableElement(context.getType(boolean.class), "prim")); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("Object value = frame.getValue(curIndex)"); + b.statement("frame.setObject(sp, value)"); + + b.startIf().string("prim").end().startBlock(); + + for (TypeMirror mir : model.boxingEliminatedTypes) { + b.startIf().string("value").instanceOf(boxType(mir)).end().startBlock(); + b.startAssign("curData.v_kind").tree(boxingTypeToInt(mir)).string(" | 0x40 /* (boxed) */").end(); + b.returnStatement(); + b.end(); + } + + b.end(); + + b.startAssign("curData.v_kind").string("-1").end(); + + return ex; + } + + private CodeExecutableElement createDoStoreLocalInitialize() { + CodeExecutableElement ex = new CodeExecutableElement(context.getType(void.class), "doStoreLocalInitialize"); + ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp")); + ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localBoxingState")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "curIndex")); + CodeTreeBuilder b = ex.createBuilder(); + + b.tree(createNeverPartOfCompilation()); + + b.startAssert().string("frame.isObject(sp - 1)").end(); + b.statement("Object value = frame.getObject(sp - 1)"); + + for (TypeMirror mir : model.boxingEliminatedTypes) { + String frameName = firstLetterUpperCase(mir.toString()); + + b.startIf().string("value").instanceOf(boxType(mir)).end().startBlock(); + b.startAssign("localBoxingState[curIndex]").tree(boxingTypeToInt(mir)).end(); + b.statement("frame.set" + frameName + "(curIndex, (" + mir + ") value)"); + b.returnStatement(); + b.end(); + } + + b.startAssign("localBoxingState[curIndex]").string("-1").end(); + b.statement("frame.setObject(curIndex, value)"); + + return ex; + } } class OperationLocalImplFactory { @@ -1991,7 +2211,7 @@ private CodeTypeElement create() { operationLocalImpl.add(new CodeVariableElement(intRef.asType(), "index")); - operationLocalImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(), operationLocalImpl, null)); + operationLocalImpl.add(createConstructorUsingFields(Set.of(), operationLocalImpl, null)); return operationLocalImpl; } @@ -2004,7 +2224,7 @@ private CodeTypeElement create() { operationLabelImpl.add(new CodeVariableElement(intRef.asType(), "index")); - operationLabelImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(), operationLabelImpl, null)); + operationLabelImpl.add(createConstructorUsingFields(Set.of(), operationLabelImpl, null)); return operationLabelImpl; } @@ -2014,16 +2234,62 @@ class IntRefFactory { private CodeTypeElement create() { intRef.setEnclosingElement(operationNodeGen); - intRef.add(GeneratorUtils.createConstructorUsingFields(Set.of(), intRef, null)); + intRef.add(createConstructorUsingFields(Set.of(), intRef, null)); intRef.add(new CodeVariableElement(context.getType(int.class), "value")); - intRef.add(GeneratorUtils.createConstructorUsingFields(Set.of(), intRef, null)); + intRef.add(createConstructorUsingFields(Set.of(), intRef, null)); return intRef; } } + class LoadLocalDataFactory { + private CodeTypeElement create() { + loadLocalData.setEnclosingElement(operationNodeGen); + loadLocalData.add(new CodeVariableElement(Set.of(FINAL), context.getType(short.class), "v_index")); + loadLocalData.add(createConstructorUsingFields(Set.of(), loadLocalData, null)); + loadLocalData.add(compFinal(new CodeVariableElement(context.getType(byte.class), "v_kind"))); + + loadLocalData.getImplements().add(boxableInterface.asType()); + loadLocalData.add(createSetBoxing()); + + return loadLocalData; + } + + private CodeExecutableElement createSetBoxing() { + CodeExecutableElement ex = GeneratorUtils.overrideImplement((DeclaredType) boxableInterface.asType(), "setBoxing"); + CodeTreeBuilder b = ex.createBuilder(); + + b.tree(createNeverPartOfCompilation()); + + b.startAssert().string("index == 0").end(); + + b.startIf().string("v_kind == kind || v_kind == -1").end().startBlock(); + b.returnStatement(); + b.end(); + + b.startIf().string("v_kind == 0").end().startBlock(); + b.statement("v_kind = kind"); + b.end(); + + b.statement("v_kind = -1"); + return ex; + } + } + + class StoreLocalDataFactory { + private CodeTypeElement create() { + storeLocalData.setEnclosingElement(operationNodeGen); + storeLocalData.add(new CodeVariableElement(Set.of(FINAL), context.getType(short.class), "s_index")); + storeLocalData.add(createConstructorUsingFields(Set.of(), storeLocalData, null)); + + storeLocalData.add(new CodeVariableElement(context.getType(int.class), "s_childIndex")); + + return storeLocalData; + } + } + private static final Set EXECUTE_NAMES = Set.of("executeBoolean", "executeLong", "executeInt", "executeByte", "executeDouble", "executeFloat"); private class CustomInstructionNodeFactory { @@ -2097,12 +2363,15 @@ private CodeExecutableElement creatSetBoxing(InstructionModel instr) { } boolean first = true; for (TypeMirror mir : mirs) { + if (!ElementUtils.isPrimitive(mir)) { + continue; + } if (first) { first = false; } else { b.string(" || "); } - b.string("kind == " + (mir.getKind().ordinal() + 1) + " /* " + mir + " */"); + b.string("kind == ").tree(boxingTypeToInt(mir)); } b.string(")").end().startBlock(); b.statement("this.op_resultType_ = kind"); @@ -2141,6 +2410,14 @@ private CodeVariableElement compFinal(CodeVariableElement fld) { return compFinal(-1, fld); } + private static CodeTree boxingTypeToInt(TypeMirror mir) { + if (!ElementUtils.isPrimitive(mir)) { + throw new AssertionError(); + } + + return CodeTreeBuilder.singleString(mir.getKind().ordinal() + 1 + " /* " + mir + " */ "); + } + private CodeVariableElement compFinal(int dims, CodeVariableElement fld) { CodeAnnotationMirror mir = new CodeAnnotationMirror(types.CompilerDirectives_CompilationFinal); if (dims != -1) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index 17fdd1586bc6..e54d49ded504 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -40,6 +40,9 @@ */ package com.oracle.truffle.dsl.processor.operations.model; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.isPrimitive; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.typeEquals; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -55,7 +58,6 @@ import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.ProcessorContext; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.model.MessageContainer; import com.oracle.truffle.dsl.processor.model.Template; @@ -228,12 +230,12 @@ protected List findChildContainers() { } public boolean isBoxingEliminated(TypeMirror mirror) { - if (!mirror.getKind().isPrimitive()) { + if (!isPrimitive(mirror)) { return false; } for (TypeMirror mir : boxingEliminatedTypes) { - if (ElementUtils.typeEquals(mir, mirror)) { + if (typeEquals(mir, mirror)) { return true; } } From ba6e1dfc72efce29033b83b9ff5df04aef8ca4d7 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 8 Aug 2022 19:35:23 +0200 Subject: [PATCH 188/312] Make checkstyle checks less strict for Truffle. --- truffle/src/com.oracle.truffle.api/.checkstyle_checks.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api/.checkstyle_checks.xml b/truffle/src/com.oracle.truffle.api/.checkstyle_checks.xml index f85e1f1c07a3..4f36ddc16fb9 100644 --- a/truffle/src/com.oracle.truffle.api/.checkstyle_checks.xml +++ b/truffle/src/com.oracle.truffle.api/.checkstyle_checks.xml @@ -53,7 +53,9 @@ - + + + From 741c0287025e66e08e70f4b08c125418ff67193d Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sun, 4 Dec 2022 20:53:06 +0100 Subject: [PATCH 189/312] Ensure unsafe accesses are tried to be transformed to loads/stores before node plugins are invoked. --- .../compiler/replacements/PEGraphDecoder.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java index 66f92e3618db..645374ad9e6b 100644 --- a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java +++ b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java @@ -98,6 +98,7 @@ import org.graalvm.compiler.nodes.extended.BytecodeExceptionNode; import org.graalvm.compiler.nodes.extended.GuardingNode; import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; +import org.graalvm.compiler.nodes.extended.UnsafeAccessNode; import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin; import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin; @@ -1466,11 +1467,21 @@ private static void deleteInvoke(Invoke invoke) { @SuppressWarnings("try") @Override - protected Node canonicalizeFixedNode(MethodScope s, Node node) { + protected Node canonicalizeFixedNode(MethodScope s, Node originalNode) { PEMethodScope methodScope = (PEMethodScope) s; + Node node = originalNode; Node replacedNode = node; if (nodePlugins != null && nodePlugins.length > 0) { + + if (originalNode instanceof UnsafeAccessNode) { + /* + * Ensure that raw stores and loads are eventually transformed to fields to make + * node plugins trigger for them reliably during PE. + */ + node = ((UnsafeAccessNode) node).canonical(canonicalizerTool); + } + if (node instanceof LoadFieldNode) { LoadFieldNode loadFieldNode = (LoadFieldNode) node; PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadFieldNode); From 99478ae729b4e2363f20edb5253d898cae7330dc Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 18:43:03 +0100 Subject: [PATCH 190/312] Implemented node object inlining and other features for Truffle DSL. --- .../StandardGraphBuilderPlugins.java | 1 + .../HotSpotTruffleGraphBuilderPlugins.java | 4 + .../truffle/runtime/GraalTruffleRuntime.java | 12 + .../test/CachedLibraryCompilationTest.java | 1 + .../compiler/truffle/test/GR35581Test.java | 1 + .../test/GenerateInlineCompilationTest.java | 318 ++ .../test/LibrarySplittingStrategyTest.java | 2 +- .../truffle/test/PartialEvaluationTest.java | 12 +- .../test/TruffleOptionsByClassLoaderTest.java | 6 + .../TRegexTStringVirtualizationTest.java | 1 + sdk/src/org.graalvm.options/snapshot.sigtest | 6 - sdk/src/org.graalvm.polyglot/snapshot.sigtest | 6 - .../polyglot/impl/AbstractPolyglotImpl.java | 4 +- .../svm/truffle/TruffleBaseFeature.java | 34 +- .../oracle/svm/truffle/TruffleFeature.java | 2 +- .../truffle/api/SubstrateTruffleRuntime.java | 7 +- .../llvm/initialization/package-info.java | 34 + .../llvm/tests/interop/package-info.java | 34 + .../tests/interop/values/package-info.java | 34 + truffle/CHANGELOG.md | 19 +- truffle/docs/DSLNodeObjectInlining.md | 416 ++ truffle/docs/DSLWarnings.md | 30 + truffle/mx.truffle/mx_truffle.py | 3 +- truffle/mx.truffle/suite.py | 6 +- .../BytecodeInterpreterBenchmark.java | 4 +- .../benchmark/DSLInterpreterBenchmark.java | 6 +- .../api/benchmark/EngineBenchmark.java | 2 +- .../api/benchmark/NodeInliningBenchmark.java | 280 + .../snapshot.sigtest | 6 - .../debug/SetThreadSuspensionEnabledNode.java | 8 +- .../truffle/api/dsl/test/AOTSupportTest.java | 112 +- .../api/dsl/test/AmbiguousClassNameTest.java | 1 + .../truffle/api/dsl/test/AssumptionsTest.java | 2 +- .../api/dsl/test/BindExpressionTest.java | 84 +- .../api/dsl/test/CachedDataRaceTest.java | 1 + .../truffle/api/dsl/test/CachedNodeTest.java | 6 +- .../dsl/test/CachedReachableFallbackTest.java | 13 +- .../truffle/api/dsl/test/CachedTest.java | 12 +- .../api/dsl/test/CachedThreadSafetyTest.java | 1 + .../api/dsl/test/CheckedExceptionTest.java | 5 +- .../truffle/api/dsl/test/CodeFormatTest.java | 3 +- .../dsl/test/DisableWarningSuppression.java | 51 + .../api/dsl/test/EnumEncodingTest.java | 258 + .../api/dsl/test/ExecuteEvaluatedTest.java | 58 +- .../api/dsl/test/ExecuteGroupingTest.java | 2 + .../api/dsl/test/ExecuteMethodTest.java | 1 + .../dsl/test/ExecuteTracingSupportTest.java | 6 + .../api/dsl/test/ExpressionOrderTest.java | 1 + .../truffle/api/dsl/test/FallbackTest.java | 4 + .../truffle/api/dsl/test/FrameTest.java | 1 + .../truffle/api/dsl/test/GR32992Test.java | 2 +- .../api/dsl/test/GenerateCachedTest.java | 259 + .../dsl/test/GenerateInlineAdvancedTest.java | 176 + .../api/dsl/test/GenerateInlineTest.java | 2190 ++++++++ .../dsl/test/GeneratePackagePrivateTest.java | 2 +- .../api/dsl/test/GenerateUncachedTest.java | 22 +- .../api/dsl/test/GenericTypeCheckTest.java | 1 + .../api/dsl/test/GuardNodeAdoptionTest.java | 5 +- .../api/dsl/test/IdentityComparisonTest.java | 1 + .../api/dsl/test/ImplicitCastTest.java | 26 +- .../api/dsl/test/ImportGenerationTest.java | 1 + .../api/dsl/test/ImportGuardsTest.java | 4 - .../api/dsl/test/InlineSupportTest.java | 435 ++ .../api/dsl/test/InsertBeforeTest.java | 1 + .../api/dsl/test/IntrospectionTest.java | 1 + .../truffle/api/dsl/test/LimitTest.java | 2 +- .../test/MethodGuardsWithArgumentsTest.java | 1 + .../api/dsl/test/NameDuplicationTest.java | 1 + .../api/dsl/test/NegatedGuardsTest.java | 1 + .../api/dsl/test/NeverDefaultTest.java | 1109 ++++ .../api/dsl/test/NoTypeSystemTest.java | 1 + .../api/dsl/test/NodeChildCreateTest.java | 13 +- .../truffle/api/dsl/test/NodeChildTest.java | 1 - .../api/dsl/test/NodeChildUncachedTest.java | 10 +- .../api/dsl/test/NodeFactoryImportsTest.java | 1 + .../dsl/test/NodeFactoryMissingChildTest.java | 2 +- .../NodeFactoryParametrizedTypesTest.java | 2 +- .../api/dsl/test/ObjectSizeEstimate.java | 281 + .../api/dsl/test/ProfileInliningTest.java | 304 + .../api/dsl/test/ReachabilityTest.java | 1 + .../truffle/api/dsl/test/ReplacesTest.java | 177 +- .../api/dsl/test/SharedCachedTest.java | 118 +- .../api/dsl/test/SlowPathListener.java | 51 + ...dString.java => SlowPathListenerNode.java} | 18 +- .../SpecializationSlowPathOnlyModeTest.java | 23 +- .../dsl/test/SpecializationUnrollingTest.java | 587 ++ .../truffle/api/dsl/test/StateBitTest.java | 1 + .../api/dsl/test/StatePackingTest.java | 185 + .../api/dsl/test/SuppressWarningTest.java | 84 + .../truffle/api/dsl/test/TestHelper.java | 68 - .../test/UnsupportedSpecializationTest.java | 1 + .../truffle/api/dsl/test/WeakCachedTest.java | 2 +- .../api/dsl/test/examples/AOTTutorial.java | 2 +- .../api/dsl/test/examples/FunctionCall.java | 2 +- .../api/dsl/test/examples/Interop.java | 2 +- .../api/dsl/test/examples/MathPow.java | 4 +- .../test/examples/NodeInliningExample1_1.java | 117 + .../test/examples/NodeInliningExample1_2.java | 118 + .../test/examples/NodeInliningExample1_3.java | 123 + .../test/examples/NodeInliningExample2_1.java | 152 + .../test/examples/NodeInliningExample2_2.java | 155 + .../test/examples/NodeInliningExample2_3.java | 181 + .../api/dsl/test/examples/RubyCall.java | 8 +- .../api/dsl/test/examples/StableDispatch.java | 4 +- .../test/otherPackage/OtherPackageGroup.java | 5 + .../test/otherPackage/OtherPackageNode.java | 7 + .../snapshot.sigtest | 185 +- .../com/oracle/truffle/api/dsl/Cached.java | 54 + .../oracle/truffle/api/dsl/DSLAccessor.java | 4 + .../oracle/truffle/api/dsl/DSLSupport.java | 76 + .../oracle/truffle/api/dsl/GenerateAOT.java | 16 +- .../truffle/api/dsl/GenerateCached.java | 95 + .../truffle/api/dsl/GenerateInline.java | 89 + .../truffle/api/dsl/GenerateNodeFactory.java | 18 +- .../truffle/api/dsl/GenerateUncached.java | 8 + .../oracle/truffle/api/dsl/InlineSupport.java | 1582 ++++++ .../oracle/truffle/api/dsl/Introspection.java | 58 +- .../oracle/truffle/api/dsl/NeverDefault.java | 61 + .../truffle/api/dsl/Specialization.java | 63 + .../api/dsl/SuppressPackageWarnings.java | 65 + .../test/ContextPauseTest.java | 6 +- .../snapshot.sigtest | 6 +- .../snapshot.sigtest | 12 +- .../truffle/api/library/test/AcceptsTest.java | 4 +- .../library/test/AcceptsTransitionTest.java | 3 +- .../api/library/test/CachedLibraryTest.java | 5 +- .../api/library/test/DefaultExportTest.java | 2 - .../api/library/test/DynamicDispatchTest.java | 2 +- .../api/library/test/ExportMethodTest.java | 62 +- .../api/library/test/ExportNodeTest.java | 115 +- .../api/library/test/ExportSharingTest.java | 4 +- .../api/library/test/ExportSubclassTest.java | 2 +- .../truffle/api/library/test/GR18252Test.java | 18 +- .../api/library/test/GenerateLibraryTest.java | 6 +- .../api/library/test/MultiExportTest.java | 2 +- .../api/library/test/NodeAdoptionTest.java | 6 +- .../api/library/test/ReflectionTest.java | 2 +- .../api/library/test/SlowPathCallTest.java | 1 + .../test/UncachedEncapsulatedNodeTest.java | 2 +- .../otherPackage/OtherPackageBaseObject.java | 4 +- .../test/otherPackage/OtherPackageNode.java | 2 + .../snapshot.sigtest | 6 +- .../snapshot.sigtest | 12 +- .../truffle/api/object/DynamicObject.java | 2 + .../snapshot.sigtest | 179 +- .../profiles/AbstractInlinedValueProfile.java | 95 + .../truffle/api/profiles/BranchProfile.java | 41 +- .../api/profiles/ByteValueProfile.java | 21 +- .../api/profiles/ConditionProfile.java | 200 +- .../profiles/CountingConditionProfile.java | 244 + .../api/profiles/DoubleValueProfile.java | 24 +- .../api/profiles/FloatValueProfile.java | 27 +- .../api/profiles/InlinedBranchProfile.java | 199 + .../api/profiles/InlinedByteValueProfile.java | 164 + .../api/profiles/InlinedConditionProfile.java | 225 + .../InlinedCountingConditionProfile.java | 277 + .../profiles/InlinedDoubleValueProfile.java | 166 + .../profiles/InlinedExactClassProfile.java | 172 + .../profiles/InlinedFloatValueProfile.java | 167 + .../api/profiles/InlinedIntValueProfile.java | 166 + .../api/profiles/InlinedLongValueProfile.java | 162 + .../profiles/InlinedLoopConditionProfile.java | 341 ++ .../truffle/api/profiles/InlinedProfile.java | 190 + .../truffle/api/profiles/IntValueProfile.java | 16 +- .../api/profiles/LongValueProfile.java | 18 +- .../api/profiles/LoopConditionProfile.java | 25 +- .../api/profiles/PrimitiveValueProfile.java | 5 +- .../oracle/truffle/api/profiles/Profile.java | 12 +- .../truffle/api/profiles/SealedProfile.java | 54 + .../truffle/api/profiles/ValueProfile.java | 47 +- .../snapshot.sigtest | 44 +- .../truffle/api/test/ReflectionUtils.java | 34 +- .../api/test/builtin/BuiltinObject.java | 10 +- .../api/test/builtin/BuiltinTestObject.java | 1 + .../test/polyglot/AbstractPolyglotTest.java | 119 + .../api/test/polyglot/FileSystemsTest.java | 2 + .../api/test/polyglot/HostAccessTest.java | 5 +- .../test/polyglot/HostClassLoadingTest.java | 6 +- .../test/polyglot/PolyglotExceptionTest.java | 2 + .../api/test/polyglot/ValueAPITest.java | 9 +- .../test/profiles/AbstractProfileTest.java | 182 + .../profiles/BinaryConditionProfileTest.java | 206 +- .../api/test/profiles/BranchProfileTest.java | 85 +- .../test/profiles/ByteValueProfileTest.java | 227 +- .../CountingConditionProfileTest.java | 198 +- .../test/profiles/DoubleValueProfileTest.java | 237 +- .../profiles/ExactClassValueProfileTest.java | 247 +- .../test/profiles/FloatValueProfileTest.java | 233 +- .../profiles/IdentityValueProfileTest.java | 2 +- .../test/profiles/IntValueProfileTest.java | 229 +- .../test/profiles/LongValueProfileTest.java | 227 +- .../wrapper/GuestToHostLanguageService.java | 4 +- .../com.oracle.truffle.api/snapshot.sigtest | 12 +- .../oracle/truffle/api/TruffleStackTrace.java | 6 +- .../com/oracle/truffle/api/impl/Accessor.java | 6 +- .../truffle/api/impl/FrameWithoutBoxing.java | 7 +- .../com/oracle/truffle/api/nodes/Node.java | 12 +- .../truffle/api/nodes/NodeAccessor.java | 6 + .../AbstractRegistrationProcessor.java | 30 +- .../dsl/processor/AnnotationProcessor.java | 65 +- .../truffle/dsl/processor/ExpectError.java | 61 +- .../processor/InstrumentableProcessor.java | 15 +- .../com/oracle/truffle/dsl/processor/Log.java | 4 - .../dsl/processor/OptionProcessor.java | 11 +- .../dsl/processor/ProcessorContext.java | 104 +- .../oracle/truffle/dsl/processor/Timer.java | 151 + .../dsl/processor/TruffleProcessor.java | 39 +- .../processor/TruffleProcessorOptions.java | 37 +- .../processor/TruffleSuppressedWarnings.java | 130 + .../truffle/dsl/processor/TruffleTypes.java | 57 + .../processor/expression/DSLExpression.java | 171 +- .../expression/DSLExpressionResolver.java | 34 +- .../InvalidExpressionException.java | 4 +- .../dsl/processor/generator/BitSet.java | 331 +- .../dsl/processor/generator/BitStateList.java | 752 +++ .../generator/FlatNodeGenFactory.java | 4877 ++++++++++++----- .../processor/generator/GeneratorUtils.java | 48 +- .../dsl/processor/generator/MultiBitSet.java | 129 +- .../generator/NodeCodeGenerator.java | 33 +- .../processor/generator/NodeConstants.java | 61 + .../generator/NodeFactoryFactory.java | 116 +- .../dsl/processor/generator/StateQuery.java | 86 + .../processor/generator/StaticConstants.java | 39 + .../generator/TypeSystemCodeGenerator.java | 7 - .../dsl/processor/java/ElementUtils.java | 117 +- .../dsl/processor/java/model/CodeElement.java | 49 +- .../java/model/CodeElementScanner.java | 11 + .../java/model/CodeExecutableElement.java | 16 - .../processor/java/model/CodeTreeBuilder.java | 52 +- .../processor/java/model/CodeTypeElement.java | 21 - .../java/model/CodeVariableElement.java | 7 - .../java/model/GeneratedTypeMirror.java | 7 +- .../java/transform/AbstractCodeWriter.java | 128 +- .../java/transform/FixWarningsVisitor.java | 40 +- .../java/transform/OrganizedImports.java | 44 +- .../processor/library/ExportsGenerator.java | 24 +- .../dsl/processor/library/ExportsParser.java | 50 +- .../dsl/processor/library/LibraryData.java | 18 - .../processor/library/LibraryGenerator.java | 15 +- .../dsl/processor/library/LibraryMessage.java | 9 - .../dsl/processor/library/LibraryParser.java | 15 +- .../dsl/processor/model/CacheExpression.java | 68 + .../processor/model/ExecutableTypeData.java | 17 - .../dsl/processor/model/GuardExpression.java | 25 +- .../dsl/processor/model/InlineFieldData.java | 194 + .../dsl/processor/model/InlinedNodeData.java | 70 + .../dsl/processor/model/MessageContainer.java | 254 +- .../dsl/processor/model/NodeChildData.java | 2 +- .../truffle/dsl/processor/model/NodeData.java | 131 +- .../processor/model/NodeExecutionData.java | 14 +- .../dsl/processor/model/Parameter.java | 28 +- .../processor/model/SpecializationData.java | 162 +- .../dsl/processor/model/TemplateMethod.java | 56 +- .../dsl/processor/parser/AbstractParser.java | 6 +- .../processor/parser/MethodSpecParser.java | 25 +- .../processor/parser/NodeMethodParser.java | 10 +- .../dsl/processor/parser/NodeParser.java | 1656 +++++- .../processor/parser/SpecializationGroup.java | 11 +- .../parser/SpecializationMethodParser.java | 10 +- .../parser/TemplateMethodParser.java | 1 - .../VerifyCompilationFinalProcessor.java | 11 +- .../verify/VerifyTruffleProcessor.java | 9 +- .../com/oracle/truffle/host/HostContext.java | 10 +- .../oracle/truffle/host/HostExecuteNode.java | 188 +- .../com/oracle/truffle/host/HostFunction.java | 8 +- .../truffle/host/HostInteropReflect.java | 5 +- .../com/oracle/truffle/host/HostLanguage.java | 2 +- .../truffle/host/HostLanguageService.java | 10 +- .../oracle/truffle/host/HostMethodScope.java | 21 +- .../com/oracle/truffle/host/HostObject.java | 893 +-- .../truffle/host/HostTargetMappingNode.java | 27 +- .../oracle/truffle/host/HostToTypeNode.java | 69 +- .../backend/libffi/FunctionExecuteNode.java | 2 + .../nfi/backend/libffi/LibFFILibrary.java | 2 + .../nfi/backend/libffi/LibFFISignature.java | 2 + .../nfi/backend/libffi/NativeBuffer.java | 2 + .../backend/libffi/SerializeArgumentNode.java | 2 + .../oracle/truffle/nfi/test/package-info.java | 9 + .../oracle/truffle/nfi/CallSignatureNode.java | 32 +- .../oracle/truffle/nfi/ConvertTypeNode.java | 6 +- .../com/oracle/truffle/nfi/NFIClosure.java | 2 + .../com/oracle/truffle/nfi/NFILibrary.java | 21 +- .../com/oracle/truffle/nfi/NFISignature.java | 2 + .../src/com/oracle/truffle/nfi/NFISymbol.java | 2 + .../oracle/truffle/nfi/SignatureRootNode.java | 2 + .../truffle/nfi/SignatureTypeCachedState.java | 2 + .../truffle/nfi/SimpleTypeCachedState.java | 4 +- .../object/basic/test/CachedGetNode.java | 2 + .../object/basic/test/CachedPutNode.java | 2 + .../basic/test/TestNestedDispatchNode.java | 1 + .../object/DynamicObjectLibraryImpl.java | 41 +- .../polyglot/OtherContextGuestObject.java | 46 +- .../truffle/polyglot/PolyglotExecuteNode.java | 42 +- .../truffle/polyglot/PolyglotIterable.java | 23 +- .../truffle/polyglot/PolyglotIterator.java | 38 +- .../polyglot/PolyglotLanguageContext.java | 170 +- .../oracle/truffle/polyglot/PolyglotList.java | 85 +- .../oracle/truffle/polyglot/PolyglotMap.java | 104 +- .../truffle/polyglot/PolyglotMapEntry.java | 25 +- .../polyglot/PolyglotObjectProxyHandler.java | 58 +- .../truffle/polyglot/PolyglotToHostNode.java | 28 +- .../polyglot/PolyglotValueDispatch.java | 708 +-- .../builtins/SLAddToHostClassPathBuiltin.java | 2 +- .../truffle/sl/builtins/SLExitBuiltin.java | 2 +- .../sl/builtins/SLNewObjectBuiltin.java | 2 +- .../SLRegisterShutdownHookBuiltin.java | 2 +- .../sl/nodes/controlflow/SLIfNode.java | 4 +- .../sl/nodes/expression/SLAddNode.java | 7 +- .../nodes/expression/SLReadPropertyNode.java | 16 +- .../nodes/expression/SLShortCircuitNode.java | 4 +- .../nodes/expression/SLWritePropertyNode.java | 14 +- .../nodes/interop/NodeObjectDescriptor.java | 4 +- .../interop/NodeObjectDescriptorKeys.java | 8 +- .../truffle/sl/nodes/local/SLScopedNode.java | 16 +- .../truffle/sl/nodes/util/SLToMemberNode.java | 9 +- .../sl/nodes/util/SLToTruffleStringNode.java | 18 +- .../truffle/sl/runtime/FunctionsObject.java | 8 +- .../micro/nodes/MicrobenchRootNode.java | 2 +- 318 files changed, 25725 insertions(+), 5093 deletions(-) create mode 100644 compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java create mode 100644 sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/package-info.java create mode 100644 sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/package-info.java create mode 100644 sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/values/package-info.java create mode 100644 truffle/docs/DSLNodeObjectInlining.md create mode 100644 truffle/docs/DSLWarnings.md create mode 100644 truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/NodeInliningBenchmark.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateCachedTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineAdvancedTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InlineSupportTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ObjectSizeEstimate.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListener.java rename truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/{BoxedString.java => SlowPathListenerNode.java} (85%) create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationUnrollingTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateCached.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NeverDefault.java create mode 100644 truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/AbstractInlinedValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/CountingConditionProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedBranchProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedByteValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedConditionProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedExactClassProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedFloatValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedIntValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLongValueProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java create mode 100644 truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/AbstractProfileTest.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Timer.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeConstants.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StateQuery.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlineFieldData.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlinedNodeData.java create mode 100644 truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java diff --git a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java index 977e043c529c..f90a2277f45b 100644 --- a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java +++ b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java @@ -702,6 +702,7 @@ private static void registerUnsafePlugins0(Registration r, boolean sunMiscUnsafe r.register(new CacheWritebackPlugin(true, "writebackPreSync0", Receiver.class)); r.register(new CacheWritebackPlugin(false, "writebackPostSync0", Receiver.class)); } + } private static void registerIntegerLongPlugins(InvocationPlugins plugins, JavaKind kind) { diff --git a/compiler/src/org.graalvm.compiler.truffle.compiler.hotspot/src/org/graalvm/compiler/truffle/compiler/hotspot/HotSpotTruffleGraphBuilderPlugins.java b/compiler/src/org.graalvm.compiler.truffle.compiler.hotspot/src/org/graalvm/compiler/truffle/compiler/hotspot/HotSpotTruffleGraphBuilderPlugins.java index 836b22cb571a..1f4f2bb52d50 100644 --- a/compiler/src/org.graalvm.compiler.truffle.compiler.hotspot/src/org/graalvm/compiler/truffle/compiler/hotspot/HotSpotTruffleGraphBuilderPlugins.java +++ b/compiler/src/org.graalvm.compiler.truffle.compiler.hotspot/src/org/graalvm/compiler/truffle/compiler/hotspot/HotSpotTruffleGraphBuilderPlugins.java @@ -43,6 +43,9 @@ final class HotSpotTruffleGraphBuilderPlugins { + /** + * Installed for runtime compilation using partial evaluation. + */ static void registerCompilationFinalReferencePlugins(InvocationPlugins plugins, boolean canDelayIntrinsification, HotSpotKnownTruffleTypes types) { InvocationPlugins.Registration r = new InvocationPlugins.Registration(plugins, Reference.class); r.register(new RequiredInvocationPlugin("get", InvocationPlugin.Receiver.class) { @@ -85,6 +88,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec return true; } }); + } } diff --git a/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java b/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java index 19325561d4b8..ecc738b93b34 100644 --- a/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java +++ b/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java @@ -94,6 +94,7 @@ import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.InlineSupport; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameInstance; @@ -402,6 +403,17 @@ private static UnmodifiableEconomicMap> initLookupTypes(Iterabl TruffleString.class, AbstractTruffleString.class, Buffer.class, + InlineSupport.InlinableField.class, + InlineSupport.StateField.class, + InlineSupport.BooleanField.class, + InlineSupport.ByteField.class, + InlineSupport.ShortField.class, + InlineSupport.IntField.class, + InlineSupport.CharField.class, + InlineSupport.FloatField.class, + InlineSupport.LongField.class, + InlineSupport.DoubleField.class, + InlineSupport.ReferenceField.class, }) { m.put(c.getName(), c); } diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/CachedLibraryCompilationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/CachedLibraryCompilationTest.java index 1fc9164b5e2c..6ed3991fcc5f 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/CachedLibraryCompilationTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/CachedLibraryCompilationTest.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +@SuppressWarnings("truffle-inlining") public class CachedLibraryCompilationTest extends PartialEvaluationTest { private Context context; diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GR35581Test.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GR35581Test.java index d80d6f0ad5ce..e0f22dc08ac7 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GR35581Test.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GR35581Test.java @@ -102,6 +102,7 @@ protected Object runUnderASTLock() { } @Specialization + @SuppressWarnings("truffle-neverdefault") Object doIt(@Cached("runUnderASTLock()") Object cacheValue) { return cacheValue; } diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java new file mode 100644 index 000000000000..ea5e2487aa65 --- /dev/null +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.graalvm.compiler.truffle.test; + +import org.graalvm.compiler.nodes.ReturnNode; +import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget; +import org.graalvm.compiler.truffle.test.GenerateInlineCompilationTestFactory.CustomNodeGen; +import org.graalvm.compiler.truffle.test.GenerateInlineCompilationTestFactory.TestChildrenNodeGen; +import org.graalvm.compiler.truffle.test.GenerateInlineCompilationTestFactory.TestDimensionsRootNodeGen; +import org.graalvm.compiler.truffle.test.GenerateInlineCompilationTestFactory.UseProfilesNodeGen; +import org.junit.Test; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.dsl.AOTSupport; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateAOT; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.ExecutionSignature; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; + +public class GenerateInlineCompilationTest extends PartialEvaluationTest { + + @GenerateInline + @GenerateCached + @SuppressWarnings("unused") + @GenerateAOT + public abstract static class CustomNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + int s0(Node node, int v) { + return 1; + } + + @Specialization(guards = "v == 1") + int s1(Node node, int v) { + return 2; + } + + @Specialization(guards = "v == 2") + int s2(Node node, int v) { + return 3; + } + + @Specialization(guards = "v == 3") + int s3(Node node, int v) { + return 4; + } + + } + + @GenerateAOT + public abstract static class UseProfilesNode extends Node { + + final boolean inlined; + + UseProfilesNode(boolean inlined) { + this.inlined = inlined; + } + + abstract int execute(int v); + + @Specialization + int s0(int v, @Cached(inline = true) CustomNode inlinedNode, + @Cached InlinedBranchProfile inlinedBranchProfile, + @Cached InlinedConditionProfile inlinedConditionProfile, + @Cached(inline = false) CustomNode node, + @Cached(inline = false) BranchProfile branchProfile, + @Cached(inline = false) ConditionProfile conditionProfile) { + if (inlined) { + inlinedBranchProfile.enter(this); + if (inlinedConditionProfile.profile(this, true)) { + return inlinedNode.execute(this, v); + } else { + return 42; + } + } else { + branchProfile.enter(); + if (conditionProfile.profile(true)) { + return node.execute(node, v); + } else { + return 42; + } + } + } + } + + static class TestProfilesNode extends RootNode { + + @Child UseProfilesNode node; + + protected TestProfilesNode(boolean inlined) { + super(null); + node = UseProfilesNodeGen.create(inlined); + } + + @Override + public Object execute(VirtualFrame frame) { + return node.execute(0) + node.execute(1) + node.execute(2); + } + + @Override + protected ExecutionSignature prepareForAOT() { + AOTSupport.prepareForAOT(this); + return ExecutionSignature.create(Integer.class, new Class[0]); + } + + @Override + public String getName() { + return "TestProfilesName[inlined=" + node.inlined + "]"; + } + + @Override + public String toString() { + return getName(); + } + + } + + @Test + public void testInlined() { + assertPartialEvalEquals(new TestProfilesNode(false), new TestProfilesNode(true), new Object[0]); + assertTrue(lastCompiledGraph.getNodes(ReturnNode.TYPE).count() > 0); + } + + @Test + public void testAOT() { + preventProfileCalls = true; + try { + OptimizedCallTarget notInlined = (OptimizedCallTarget) new TestProfilesNode(false).getCallTarget(); + OptimizedCallTarget inlined = (OptimizedCallTarget) new TestProfilesNode(true).getCallTarget(); + + notInlined.prepareForAOT(); + inlined.prepareForAOT(); + + assertPartialEvalEquals(notInlined, inlined, new Object[0], true); + assertTrue(notInlined.isValid()); + assertTrue(inlined.isValid()); + notInlined.call(); + inlined.call(); + + // test does not deopt + assertTrue(notInlined.isValid()); + assertTrue(inlined.isValid()); + } finally { + preventProfileCalls = false; + } + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class ChildrenTest extends Node { + + abstract int execute(Node node, int v); + + @Specialization + @ExplodeLoop + int s0(Node node, int v, @Cached(value = "createChildren()", neverDefault = true) CustomNode[] children) { + int sum = 0; + for (CustomNode customNode : children) { + sum += customNode.execute(customNode, v); + } + return sum; + } + + static CustomNode[] createChildren() { + CustomNode[] node = new CustomNode[10]; + for (int i = 0; i < 10; i++) { + node[i] = CustomNodeGen.create(); + } + return node; + } + + } + + abstract static class TestChildrenNode extends RootNode { + + protected TestChildrenNode() { + super(null); + } + + @Specialization + Object doDefault(@Cached ChildrenTest test) { + int result = test.execute(this, 1); + CompilerAsserts.partialEvaluationConstant(result); + return result; + } + + @Override + public String getName() { + return "TestProfilesName[]"; + } + + @Override + public String toString() { + return getName(); + } + + } + + /** + * Tests usage of inlined children fields. Fails if annotation is not used on the inlined field. + */ + @Test + public void testChildren() { + OptimizedCallTarget notInlined = (OptimizedCallTarget) TestChildrenNodeGen.create().getCallTarget(); + assertPartialEvalEquals((OptimizedCallTarget) new RootNode(null) { + + @Override + public Object execute(VirtualFrame frame) { + return 20; + } + }.getCallTarget(), notInlined, new Object[0], true); + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class DimensionsNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization + @ExplodeLoop + int s0(Node node, int v, @Cached(value = "createChildren()", dimensions = 1, neverDefault = true) Object[] children) { + int sum = 0; + for (Object customNode : children) { + sum += ((CustomNode) customNode).execute(((CustomNode) customNode), v); + } + return sum; + } + + static Object[] createChildren() { + Object[] node = new Object[10]; + for (int i = 0; i < 10; i++) { + node[i] = CustomNodeGen.create(); + } + return node; + } + + } + + abstract static class TestDimensionsRootNode extends RootNode { + + protected TestDimensionsRootNode() { + super(null); + } + + @Specialization + Object doDefault(@Cached DimensionsNode test) { + int result = test.execute(this, 1); + CompilerAsserts.partialEvaluationConstant(result); + return result; + } + + @Override + public String getName() { + return "TestProfilesName[]"; + } + + @Override + public String toString() { + return getName(); + } + + } + + /** + * Tests propagation of compilation final dimensions to inlined fields using + * {@link RequiredField#dimensions()}. + */ + @Test + public void testDimensions() { + OptimizedCallTarget notInlined = (OptimizedCallTarget) TestDimensionsRootNodeGen.create().getCallTarget(); + assertPartialEvalEquals((OptimizedCallTarget) new RootNode(null) { + + @Override + public Object execute(VirtualFrame frame) { + return 20; + } + }.getCallTarget(), notInlined, new Object[0], true); + } + +} diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/LibrarySplittingStrategyTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/LibrarySplittingStrategyTest.java index 65a4b486ae9a..8a215f7762d9 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/LibrarySplittingStrategyTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/LibrarySplittingStrategyTest.java @@ -205,7 +205,7 @@ abstract static class ReadMember { @Specialization(guards = "name == CACHED_NAME") @ReportPolymorphism.Exclude static Object readStaticCached(DynamicallyDispatchedObject receiver, @SuppressWarnings("unused") String name, - @SuppressWarnings("unused") @Cached("name") String cachedName) { + @SuppressWarnings("unused") @Cached(value = "name", neverDefault = false) String cachedName) { return receiver; } diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/PartialEvaluationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/PartialEvaluationTest.java index a4b8f7858b11..b80417699ca5 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/PartialEvaluationTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/PartialEvaluationTest.java @@ -122,10 +122,7 @@ protected OptimizedCallTarget assertPartialEvalEquals(RootNode expected, RootNod return assertPartialEvalEquals(expected, actual, arguments, true); } - protected OptimizedCallTarget assertPartialEvalEquals(RootNode expected, RootNode actual, Object[] arguments, boolean checkConstants) { - final OptimizedCallTarget expectedTarget = (OptimizedCallTarget) expected.getCallTarget(); - final OptimizedCallTarget actualTarget = (OptimizedCallTarget) actual.getCallTarget(); - + protected OptimizedCallTarget assertPartialEvalEquals(OptimizedCallTarget expectedTarget, OptimizedCallTarget actualTarget, Object[] arguments, boolean checkConstants) { BailoutException lastBailout = null; for (int i = 0; i < 10; i++) { try { @@ -156,6 +153,12 @@ protected OptimizedCallTarget assertPartialEvalEquals(RootNode expected, RootNod return actualTarget; } + protected OptimizedCallTarget assertPartialEvalEquals(RootNode expected, RootNode actual, Object[] arguments, boolean checkConstants) { + final OptimizedCallTarget expectedTarget = (OptimizedCallTarget) expected.getCallTarget(); + final OptimizedCallTarget actualTarget = (OptimizedCallTarget) actual.getCallTarget(); + return assertPartialEvalEquals(expectedTarget, actualTarget, arguments, checkConstants); + } + private static TruffleCompilationTask newTask() { return new TruffleCompilationTask() { final TruffleInlining inlining = new TruffleInlining(); @@ -258,6 +261,7 @@ private StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arg handler); try (Graph.NodeEventScope nes = nodeEventListener == null ? null : context.graph.trackNodeEvents(nodeEventListener)) { truffleTier.apply(context.graph, context); + lastCompiledGraph = context.graph; return context.graph; } } diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/TruffleOptionsByClassLoaderTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/TruffleOptionsByClassLoaderTest.java index 9c7f1dea41ab..8d4490fa3898 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/TruffleOptionsByClassLoaderTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/TruffleOptionsByClassLoaderTest.java @@ -33,6 +33,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.junit.Assume; import org.junit.Test; import com.oracle.truffle.api.TruffleOptions; @@ -47,6 +48,11 @@ public void loadTruffleOptionsByOwnClassLoader() throws Exception { String urlString = url.toString(); String protocol = url.getProtocol(); url = null; + + // may happen with exploded jars + // avoid failing this test then. + Assume.assumeFalse("file".equals(protocol)); + if ("jar".equals(protocol)) { // Example: // jar:file:/usr/lib/jvm/graalvm-ce-19.2.0/jre/lib/truffle/truffle-api.jar!/com/oracle/truffle/api/TruffleOptions.class diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/tregex/TRegexTStringVirtualizationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/tregex/TRegexTStringVirtualizationTest.java index 604351ea70d3..ec94e9e5e282 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/tregex/TRegexTStringVirtualizationTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/tregex/TRegexTStringVirtualizationTest.java @@ -60,6 +60,7 @@ import sun.misc.Unsafe; +@SuppressWarnings("truffle-inlining") public class TRegexTStringVirtualizationTest extends PartialEvaluationTest { @Before diff --git a/sdk/src/org.graalvm.options/snapshot.sigtest b/sdk/src/org.graalvm.options/snapshot.sigtest index 3917f9c0993a..8518d320fa5e 100644 --- a/sdk/src/org.graalvm.options/snapshot.sigtest +++ b/sdk/src/org.graalvm.options/snapshot.sigtest @@ -8,10 +8,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -20,7 +18,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -46,9 +43,6 @@ meth public final void wait(long,int) throws java.lang.InterruptedException meth public int hashCode() meth public java.lang.String toString() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - CLSS public final !enum org.graalvm.options.OptionCategory fld public final static org.graalvm.options.OptionCategory EXPERT fld public final static org.graalvm.options.OptionCategory INTERNAL diff --git a/sdk/src/org.graalvm.polyglot/snapshot.sigtest b/sdk/src/org.graalvm.polyglot/snapshot.sigtest index 1302a27a85ae..7dc39e19c9a4 100644 --- a/sdk/src/org.graalvm.polyglot/snapshot.sigtest +++ b/sdk/src/org.graalvm.polyglot/snapshot.sigtest @@ -11,10 +11,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -23,7 +21,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -118,9 +115,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - CLSS public final org.graalvm.polyglot.Context innr public final Builder intf java.lang.AutoCloseable diff --git a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java index 8ca51b4b9d8c..c53b5e031d99 100644 --- a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java +++ b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java @@ -796,9 +796,9 @@ public abstract void initializeHostContext(Object internalContext, Object contex public abstract Object findStaticClass(Object context, String classValue); - public abstract Object createToHostTypeNode(); + public abstract Object inlineToHostTypeNode(Object inlineTarget); - public abstract T toHostType(Object hostNode, Object hostContext, Object value, Class targetType, Type genericType); + public abstract T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType); public abstract boolean isHostValue(Object value); diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java index b94b5a07e4a0..39b6baed9fcc 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java @@ -57,8 +57,7 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.stream.Stream; -import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; -import com.oracle.truffle.api.TruffleFile; + import org.graalvm.collections.Pair; import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; import org.graalvm.compiler.nodes.ConstantNode; @@ -114,6 +113,7 @@ import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; +import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; import com.oracle.svm.hosted.heap.PodSupport; import com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins; import com.oracle.svm.truffle.api.SubstrateTruffleRuntime; @@ -121,8 +121,10 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleRuntime; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.impl.DefaultTruffleRuntime; import com.oracle.truffle.api.instrumentation.TruffleInstrument; import com.oracle.truffle.api.library.DefaultExportProvider; @@ -1160,7 +1162,7 @@ final class Target_com_oracle_truffle_api_nodes_Node { @TargetClass(className = "com.oracle.truffle.api.nodes.NodeClassImpl", innerClass = "NodeFieldData", onlyWith = TruffleBaseFeature.IsEnabled.class) final class Target_com_oracle_truffle_api_nodes_NodeClassImpl_NodeFieldData { - @Alias @RecomputeFieldValue(kind = Kind.Custom, declClass = OffsetComputer.class) // + @Alias @RecomputeFieldValue(kind = Kind.Custom, declClass = OffsetComputer.class, isFinal = true) // private long offset; private static class OffsetComputer implements FieldValueTransformerWithAvailability { @@ -1182,3 +1184,29 @@ public Object transform(Object receiver, Object originalValue) { } } } + +@TargetClass(className = "com.oracle.truffle.api.dsl.InlineSupport$UnsafeField", onlyWith = TruffleFeature.IsEnabled.class) +final class Target_com_oracle_truffle_api_dsl_InlineSupport_UnsafeField { + + @Alias @RecomputeFieldValue(kind = Kind.Custom, declClass = OffsetComputer.class, isFinal = true) // + private long offset; + + private static class OffsetComputer implements FieldValueTransformerWithAvailability { + @Override + public ValueAvailability valueAvailability() { + return ValueAvailability.AfterAnalysis; + } + + @Override + public Object transform(Object receiver, Object originalValue) { + Class declaringClass = ReflectionUtil.readField(InlinableField.class.getSuperclass(), "declaringClass", receiver); + String name = ReflectionUtil.readField(InlinableField.class.getSuperclass(), "name", receiver); + Field field = ReflectionUtil.lookupField(declaringClass, name); + int offset = ImageSingletons.lookup(ReflectionSubstitutionSupport.class).getFieldOffset(field, false); + if (offset == -1) { + throw VMError.shouldNotReachHere("Field is not marked as accessed: " + field); + } + return Long.valueOf(offset); + } + } +} diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java index b6adf26da148..a1acf19b445d 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java @@ -332,7 +332,6 @@ private boolean handleNeverPartOfCompilation(GraphBuilderContext b, ResolvedJava neverPartOfCompilationViolations.add(Pair.create(b.getMethod(), String.join(",", callTree))); } } - return true; } @@ -980,6 +979,7 @@ private static void printStaticTruffleBoundaries() { } } } + System.out.printf("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d%n", callSiteCount, calleeCount); } diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleRuntime.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleRuntime.java index 75182140c1cb..ec29dbc873f7 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleRuntime.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleRuntime.java @@ -251,7 +251,12 @@ public void notifyTransferToInterpreter() { @Override public boolean isProfilingEnabled() { if (profilingEnabled == null) { - profilingEnabled = getEngineData(null).profilingEnabled; + /* + * Inlined profiles are initialized in static initializers when the runtime is not yet + * initialized. We need to assume that profiling is enabled, if it is not yet set in the + * runtime. + */ + return Boolean.TRUE; } return profilingEnabled; } diff --git a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/package-info.java b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/package-info.java new file mode 100644 index 000000000000..8716e2e8cbfc --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.initialization; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/package-info.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/package-info.java new file mode 100644 index 000000000000..df3c447d6831 --- /dev/null +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.tests.interop; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/values/package-info.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/values/package-info.java new file mode 100644 index 000000000000..f81d517e98e9 --- /dev/null +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/interop/values/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.tests.interop.values; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index f98c7dd5ea05..0678328c222a 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -2,6 +2,7 @@ This changelog summarizes major changes between Truffle versions relevant to languages implementors building upon the Truffle framework. The main focus is on APIs exported by Truffle. + ## Version 23.0.0 * GR-38526 Added `TruffleLanguage.Env#isSocketIOAllowed()`. The method returns true if access to network sockets is allowed. @@ -16,6 +17,23 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-39189 Added attach methods on the `Instrumenter` class, that take `NearestSectionFilter` as a parameter. The new `NearestSectionFilter` class can be used to instrument or detect nearest locations to a given source line and column. For example, this can be used to implement breakpoints, where the exact line or column is not always precise and the location needs to be updated when new code is loaded. * GR-39189 Added `InstrumentableNode.findNearestNodeAt(int line, int column, ...)` to find the nearest node to the given source line and column. This is an alternative to the existing method that takes character offset. * GR-42674 It has been documented that methods `TruffleLanguage.Env#getPublicTruffleFile`, `TruffleLanguage.Env#getInternalTruffleFile`, `TruffleLanguage.Env#getTruffleFileInternal` and `TruffleInstrument.Env#getPublicTruffleFile` can throw `IllegalArgumentException` when the path string cannot be converted to a `Path` or uri preconditions required by the `FileSystem` do not hold. +* GR-31342 Implemented several new features for Truffle DSL and improved its performance: + * Added an `@GenerateInline` annotation that allows Truffle nodes to be object-inlined automatically. Object-inlined Truffle nodes become singletons and therefore reduce memory footprint. Please see the [tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/DSLNodeObjectInlining.md) for further details. + * Added an `@GenerateCached` annotation that allows to disable the generation of cached nodes. This is useful if all usages of nodes are object inlined to save code footprint. + * Updated Truffle DSL nodes no longer require the node lock during specialization, resulting in improved first execution performance. CAS-style inline cache updates are now used to avoid deadlocks when calling CallTarget.call(...) in guards. Inline caches continue to guarantee no duplicate values and are not affected by race conditions. Language implementations should be aware that the reduced contention may reveal other thread-safety issues in the language. + * Improved Truffle DSL node memory footprint by merging generated fields for state and exclude bit sets and improving specialization data class generation to consider activation probability. Specializations should be ordered by activation probability for optimal results. + * Improved memory footprint by automatically inlining cached parameter values of enum types into the state bitset + * Added `@Cached(neverDefault=true|false)` option to indicate whether the cache initializer will ever return a `null` or primitive default value. Truffle DSL now emits a warning if it is beneficial to set this property. Alternatively, the new `@NeverDefault` annotation may be used on the bound method or variable. The generated code layout can benefit from this information and reduce memory overhead. If never default is set to `true`, then the DSL will now use the default value instead internally as a marker for uninitialized values. + * `@Shared` cached values may now use primitive values. Also, `@Shared` can now be used for caches contained in specializations with multiple instances. This means that the shared cache will be used across all instances of a specialization. + * Truffle DSL now generates many more Javadoc comments in the generated code that try to explain the decisions of the code generator. + * Added inlined variants for all Truffle profiles in `com.oracle.truffle.api.profiles`. The DSL now emits recommendation warnings when inlined profiles should be used instead of the allocated ones. + * Truffle DSL now emits many more warnings for recommendations. For example, it emits warnings for inlining opportunities, cached sharing or when a cache initializer should be designated as `@NeverDefault`. To ease migration work, we added several new ways to suppress the warnings temporarily for the Java package. For a list of possible warnings and further usage instructions, see the new [warnings page](https://github.com/oracle/graal/blob/master/truffle/docs/DSLWarnings.md) in the docs. + * The DSL now produces warnings for specializations with multiple instances but an unspecified limit. The new warning can be resolved by specifying the desired limit (previously, default `"3"` was assumed) + * Added the capability to unroll specializations with multiple instances. Unrolling in combination with node object inlining may further reduce the memory footprint of a Truffle node. In particular, if all cached states can be encoded into the state bit set of the generated node. See `@Specialization(...unroll=2)` for further details + +* GR-31342 Deprecated `ConditionProfile.createBinaryProfile()` and `ConditionProfile.createCountingProfile()`. Use `ConditionProfile.create()` and `CountingConditionProfile.create()` instead. +* GR-31342 Added `ValueProfile.create()` that automatically creates an exact class value profile. This allows its usage in `@Cached` without specifying a cached initializer. +* GR-31342 The node `insert` method is now public instead of protected. This avoids the need to create cumbersome accessor methods when needed in corner-cases. ## Version 22.3.0 @@ -140,7 +158,6 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-35093 Deprecated `UnionAssumption`, use arrays of assumptions instead. Deprecated `NeverValidAssumption` and `AlwaysValidAssumption`, use `Assumption.NEVER_VALID` and `Assumption.ALWAYS_VALID` instead. Language implementations should avoid custom `Assumption` subclasses, they lead to performance degradation in the interpreter. * GR-35093 Added `create()` constructor methods to profiles in `com.oracle.truffle.api.profiles` where appropriate to simplify use with Truffle DSL. - ## Version 22.0.0 * Truffle DSL generated code now inherits all annotations on constructor parameters to the static create factory method. * Added a [Message#getId()](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/library/Message.html#getId--) method returning a unique message id within a library. diff --git a/truffle/docs/DSLNodeObjectInlining.md b/truffle/docs/DSLNodeObjectInlining.md new file mode 100644 index 000000000000..7ef60aee8157 --- /dev/null +++ b/truffle/docs/DSLNodeObjectInlining.md @@ -0,0 +1,416 @@ +In 23.0, we have introduced a new annotation called `@GenerateInline`. This annotation instructs the Truffle DSL annotation processor to generate an inlinable version of a node. This works analogously to `@GenerateCached` and `@GenerateUncached`, which generate a cached or uncached node version. +By default, the DSL does not generate an inlined version of a node. +Node inlining provides a simple way to reduce the memory footprint of nodes but often also improves interpreter execution speed. + +### Basic Usage + +Let us assume we have a node with specializations that computes the sum of the absolute value of two values. +For simplicity, we will only look at the `long` typed specializations in this example. + +A runnable but slightly more advanced version of this example can be found in the Truffle unit tests. +* [NodeInliningExample1_1.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java) shows an example without any inlining. +* [NodeInliningExample1_2.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java) shows an example without partial inlining. +* [NodeInliningExample1_3.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java) shows an example with full inlining. + + +Consider the following examples that specify two regular nodes it specializations. One node computes the sum of two values, and one computes the absolute number of a number. The `AbsNode` is then reused in the `AddAbsNode` to share the implementation. + +```java +public abstract class AddAbsNode extends Node { + + abstract long execute(Object left, Object right); + + @Specialization + long add(long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(left) + rightAbs.execute(right); + } + // ... +} + +public abstract class AbsNode extends Node { + + abstract long execute(long value); + + @Specialization(guards = "v >= 0") + long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + long doLong(long v) { + return -v; + } +} +``` + +The compressed memory footprint for `AbsNode` and `AddAbsNode` after one execution are computed as follows: + +``` +AbsNodeGen = object header + + Node field for Node.parent + + int field for state + +AddAbsNodeGen = object header + + Node field for Node.parent + + int field for state + + Node field for @Cached AbsNode leftAbs + + Node field for @Cached AbsNode rightAbs + +Footprint = headerCount * 12 + pointerCount * 4 + primitiveByteSize +Footprint = 3 * 12 + 5 * 4 + 12 = 68 bytes +``` + +Therefore, we use `68` bytes to represent a single operation with nodes. + +The Truffle DSL annotation processor will now produce the following warning for the `AbsNode` class: + +``` +This node is a candidate for node object inlining. The memory footprint is estimated to be reduced from 20 to 1 byte(s). Add @GenerateInline(true) to enable object inlining for this node or @GenerateInline(false) to disable this warning. Also, consider disabling cached node generation with @GenerateCached(false) if all usages will be inlined. This warning may be suppressed using @SuppressWarnings("truffle-inlining"). +``` + +Following the recommendation of this warning, we modify our example as follows by adding the `@GenerateInline` annotation: + +``` +@GenerateInline +public abstract class AbsNode extends Node { + + abstract long execute(long value); + + @Specialization(guards = "v >= 0") + long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + long doLong(long v) { + return -v; + } + +} +``` + +Now the DSL reports a compile error for `AbsNode`: + +``` +Error generating code for @GenerateInline: Found non-final execute method without a node parameter execute(long). Inlinable nodes + must use the Node type as the first parameter after the optional frame for all non-final execute methods. A valid signature for an + inlinable node is execute([VirtualFrame frame, ] Node node, ...). +``` + +For inlinable nodes, we must pass a node parameter to the execute method as the first parameter. +This is necessary as inlined nodes become singletons and no longer have their own state, but instead, it is passed as a parameter to the execute method. + +Again, we follow the error and modify our example as follows: + +``` +@GenerateInline +public abstract class AbsNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + +} +``` + +Note that the node parameter is optional for specialization methods, but they are typically needed if transitively inlined nodes are used. + + +Next, we also need to modify `AddAbsNode` to pass `this` as a node parameter to the new execute signature: + +```java +public abstract static class AddAbsNode extends Node { + + abstract long execute(long left, long right); + + @Specialization + long add(long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(this, left) + rightAbs.execute(this, right); + } + // ... +} +``` + +The DSL now produces a warning for each of the `@Cached AbsNode` parameters: + +``` +The cached type 'AbsNode' supports object-inlining. The footprint is estimated to be reduced from 36 to 1 byte(s). Set @Cached(..., inline=true|false) to determine whether object-inlining should be performed. Alternatively, @GenerateCached(alwaysInlineCached=true) can be used to enable inlining for an entire class or in combination with the inherit option for a hierarchy of node classes. This warning may be suppressed using @SuppressWarnings("truffle-inlining"). +``` + +We follow the recommendation in this message and enable object inlining: + +``` +public abstract static class AddAbsNode extends Node { + + abstract long execute(long left, long right); + + @Specialization + long add(long left, long right, + @Cached(inline = true) AbsNode leftAbs, + @Cached(inline = true) AbsNode rightAbs) { + return leftAbs.execute(this, left) + rightAbs.execute(this, right); + } + // ... +} +``` + +Now we have achieved object-inlining of `AbsNode` into `AddAbsNode`. +The new memory footprint computes as follows: + +``` +AddAbsNodeGen = object header + + Node field for Node.parent + + int field for state + +Footprint = headerCount * 12 + pointerCount * 4 + primitiveByteSize +Footprint = 1 * 12 + 1 * 4 + 4 = 20 bytes +``` + +The footprint has gone down from `68` bytes to only `20` bytes for each instance of `AddAbsNodeGen`. + +But we are still going. Since all cached nodes are inlined we can also make the `AddAbsNode` inlinable for its usages. +The DSL helps us again by detecting such cases and prints a warning for `AddAbsNode` now: + +``` +This node is a candidate for node object inlining. The memory footprint is estimated to be reduced from 20 to 1 byte(s). Add @GenerateInline(true) to enable object inlining for this node or @GenerateInline(false) to disable this warning. Also consider disabling cached node generation with @GenerateCached(false) if all usages will be inlined. This warning may be suppressed using @SuppressWarnings("truffle-inlining"). +``` + +Again, we follow the guide and add a `@GenerateInline` annotation to `AddAbsNode`. Just like before, we also add a `Node` parameter to the execute method: + +``` +@GenerateInline +public abstract static class AddAbsNode extends Node { + + abstract long execute(Node node, long left, long right); + + @Specialization + static long add(Node node, long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(node, left) + rightAbs.execute(node, right); + } + // ... +} +``` + +We also need to use the `Node` parameter in the specialization method and pass it on to the child nodes. +Again, we want all specializations to be `static` to avoid accidentally passing `this`. +In addition, the DSL complained about the `inline=true` attribute, which is now always implied as the parent node uses the `@GenerateInline` annotation. + + +To measure the overhead of our new inlinable `AddAbsNode` node, we declare a new operation called `Add4AbsNode` that adds four numbers using our `AddAbsNode` operation: + + +``` +@GenerateCached(alwaysInlineCached = true) +public abstract static class Add4AbsNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(this, v0, v1); + v = add1.execute(this, v, v2); + v = add2.execute(this, v, v3); + return v; + } + +} +``` + +This time, instead of specifying `@Cached(inline=true)`, we auto-enable inlining wherever possible using `@GenerateCached(alwaysInlineCached = true)`. +Depending on the use case, it can hinder readability to repeat individual inlining commands for every cached node. + +Computing the overhead now becomes more tricky. We need to understand how many state bits each node requires to keep track of active specializations. +That computation is generally implementation specific and subject to change. However, a good rule of thumb is that the DSL requires one bit per declared specialization. +Implicit casts and `@Fallback` annotations may further increase that requirement. + +For this example, each `AddAbsNode` requires 5 bits. 2 bits for each of the `AbsNode` usages and one bit for the `AddAbsNode` specializations. +The `Add4AbsNode` uses three instances of `AddAbsNode`, has one specialization, and therefore needs `3 * 5 + 1` state bits in total. +Since the number of bits is below 32, we can assume that we need a single `int` field in the generated code. +The memory footprint of an executed `Add4AbsNode` is therefore computed as follows: + +``` +Footprint = 1 * 12 + 1 * 4 + 4 = 20 bytes +``` + +As you can see, this is the same memory footprint a single `AddAbsNode` had. +If we use the same formula to compute the memory footprint of an `Add4AbsNode` without any object inlining + +``` +Footprint = 1 * 12 + 4 * 4 + 4 + 3 * 68 = 236 bytes +``` + +We have reduced the overhead from `236` bytes to `20` bytes. + +In addition to the memory footprint advantages, interpreter-only execution may be faster, as we save the reads for the node fields and benefit from better CPU cache locality due to smaller memory consumption. +After compilation using partial evaluation, both cached and uncached versions are expected to perform the same. + +There is a last thing we should do. Since our `AddAbsNode` and `AbsNode` are no longer used in their cached version, we can turn off cached generation using `@GenerateCached(false)` to save Java code footprint. + +This is the final example: + +``` +@GenerateInline +@GenerateCached(false) +public abstract static class AbsNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + +} + +@GenerateInline +@GenerateCached(false) +public abstract static class AddAbsNode extends Node { + + abstract long execute(Node node, long left, long right); + + @Specialization + static long add(Node node, long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(node, left) + rightAbs.execute(node, right); + } + // ... +} + +@GenerateCached(alwaysInlineCached = true) +@GenerateInline(false) +public abstract static class Add4AbsNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(this, v0, v1); + v = add1.execute(this, v, v2); + v = add2.execute(this, v, v3); + return v; + } +} +``` + +Note that the DSL again informed us that `Add4AbsNode` could use `@GenerateInline` by emitting the following warning: + +``` +This node is a candidate for node object inlining. The memory footprint is estimated to be reduced from 20 to 2 byte(s). Add @GenerateInline(true) to enable object inlining for this node or @GenerateInline(false) to disable this warning. Also consider disabling cached node generation with @GenerateCached(false) if all usages will be inlined. This warning may be suppressed using @SuppressWarnings("truffle-inlining"). +``` + +This time we suppressed the warning by explicitly specifying `@GenerateInline(false)`. + + +### Advanced Inline Cache Usage + +The following example explains how specialization unrolling and new inlinable cache classes can be helpful in reducing the memory footprint of nodes with specializations that have multiple instances. + +Examples: +* [NodeInliningExample2_1.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java) shows an example without any inlining. +* [NodeInliningExample2_2.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java) shows an example without partial inlining. +* [NodeInliningExample2_3.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java) shows an example with full inlining. + + +### Limitations + +Node object inlining supports arbitrary deep nestings. However, there are some limitations to using `@GenerateInline`. + +* There must not be any instance fields on the node class or a parent class. +* The node must not use `@NodeField` or `@NodeChild`. +* The usage of inlined nodes must not be recursive. + +### Manually implementing Inlinable Nodes and Profiles + +Nodes or profiles that can be inlined in the DSL can also be implemented manually. +The class must implement a static method called `inline`. +For example, most inlinable Truffle profiles use custom inlining. +Extra care must be taken when implementing such inlinable classes and if possible, a DSL generated node should be used instead. +See [InlinedBranchProfile](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedBranchProfile.java) or [InlinedIntValueProfile](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedIntValueProfile.java) class as an example on how to implement the inline method. + +### API Compatibility for Inlinable Nodes + +The `TruffleString` API extensively uses DSL nodes like in the above example. +However, allowing nodes to be inlined makes every change to the specializations of that node an incompatible API change. +This is because the signature of the static `inline` method changes depending on the required state bits of the specializations. + +In order to support inlining across stable API boundaries, it is recommended to manually specify an inline method that forwards to the generated inline method. + +As an example, consider the following node: + +``` +@GenerateInline +@GenerateUncached +@GeneratePackagePrivate +public abstract static class APINode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + public static APINode inline(@RequiredField(value = StateField.class, bits = 32) InlineContext context) { + return APINodeGen.inline(context); + } + + public static APINode create() { + return APINodeGen.create(); + } + + public static APINode getUncached() { + return APINodeGen.getUncached(); + } +} +``` + +We use `@GeneratePackagePrivate` in order not to expose any generated code as public. +We specify a manual `inline` method that specifies the required bits for this node. +If the specializations of a node require more bits or more additional fields other than specified, then the annotation processor fails with an error. +If the node requires fewer bits, then this does not cause any compiler error. +This allows API to use node inlining across stable API boundaries as long as the reserved field capacity is not exceeded. + +A change is compatible if: +* There was previously no `inline` method for this node before. +* If the required bit space is reduced and all other fields are changed. + +A change is incompatible if: +* A new `@RequiredField` annotation to an existing `inline` method was added or removed. +* The required bits were increased. + +The DSL validates whether the required fields are matching to the state specification of the parent node and emits a warning if it is not compatible to the node specification. + + diff --git a/truffle/docs/DSLWarnings.md b/truffle/docs/DSLWarnings.md new file mode 100644 index 000000000000..3fcad6739802 --- /dev/null +++ b/truffle/docs/DSLWarnings.md @@ -0,0 +1,30 @@ +--- +layout: docs +toc_group: truffle +link_title: Truffle DSL Node Object Inlining +permalink: /graalvm-as-a-platform/language-implementation-framework/NodeObjectInlining/ +--- +# Truffle DSL Warnings + +Since version 23.0, Truffle DSL now produces significantly more warnings. +These warnings are intended to guide the user to better DSL usage. +The following sections describe how to handle and eventually suppress warnings. + +All warnings of Truffle DSL can be suppressed using the `-Atruffle.dsl.SuppressAllWarnings=true` option. +If a language uses strict checks where warnings are treated as errors in their CI, it is recommended to add this option to the Java compilation command line. This can be useful to avoid CI failures when Truffle DSL adds new warning messages. Adding new warning messages in Truffle DSL is considered a compatible change. + +Truffle DSL warnigns can be suppressed just like Java warnings using the `@SuppressWarnings` annotation or with`@SuppressPackageWarnings` for entire packages. +The following warning keys are supported: + +* `all` all warnings emitted by the Java compiler or Truffle DSL +* `truffle` all warnings emitted by Truffle DSL +* `truffle-sharing` warnings when the DSL recommends sharing between cached values +* `truffle-inlining` warnings when the DSL recommends using node object inlining. +* `truffle-neverdefault` warnings for when cached initializers should be marked as never having a default value. +* `truffle-limit` warnings when a specialization limit is recommended, but not specified. +* `truffle-static-method` warnings when the DSL recommends to use the `static` modifier. +* `truffle-unused` warnings if a DSL attribute or annotation has no effect and is recommended to be removed. + + +Suppressing a specific warning should be preferred over suppressing all warnings. +Find the latest list of warnings in the [source code](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java) diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index ed57233523aa..64948deebf32 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -102,7 +102,8 @@ def extraVmArgs(self): def javadoc(args, vm=None): """build the Javadoc for all API packages""" extraArgs = mx_sdk.build_oracle_compliant_javadoc_args(_suite, 'GraalVM', 'Truffle') - mx.javadoc(['--unified', '--exclude-packages', 'com.oracle.truffle.tck,com.oracle.truffle.tck.impl'] + extraArgs + args) + mx.javadoc(['--unified', '--exclude-packages', + 'com.oracle.truffle.tck,com.oracle.truffle.tck.impl'] + extraArgs + args) javadoc_dir = os.sep.join([_suite.dir, 'javadoc']) checkLinks(javadoc_dir) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 46b7a112eda5..562fc163c504 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -351,6 +351,7 @@ "dependencies" : ["com.oracle.truffle.api"], "requires" : [ "java.logging", + "jdk.unsupported", # sun.misc.Unsafe ], "checkstyle" : "com.oracle.truffle.api", "javaCompliance" : "11+", @@ -363,6 +364,7 @@ "dependencies" : [ "com.oracle.truffle.polyglot", "com.oracle.truffle.api.test", + "com.oracle.truffle.api.dsl", "com.oracle.truffle.api.library", "mx:JUNIT", ], @@ -414,6 +416,7 @@ ], "requires" : [ "java.compiler", + "jdk.management" ], "checkstyle" : "com.oracle.truffle.dsl.processor", "javaCompliance" : "11+", @@ -643,7 +646,8 @@ "com.oracle.truffle.api.profiles" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api"], + "dependencies" : ["com.oracle.truffle.api", + "com.oracle.truffle.api.dsl"], "checkstyle" : "com.oracle.truffle.api", "javaCompliance" : "11+", "workingSets" : "API,Truffle", diff --git a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/BytecodeInterpreterBenchmark.java b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/BytecodeInterpreterBenchmark.java index 17f267af7aed..040adc476977 100644 --- a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/BytecodeInterpreterBenchmark.java +++ b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/BytecodeInterpreterBenchmark.java @@ -248,14 +248,14 @@ static final class BytecodeNode extends Node { @TruffleBoundary @CompilerControl(Mode.DONT_INLINE) - static void boundary(MaterializedFrame f) { + static void boundary(@SuppressWarnings("unused") MaterializedFrame f) { // just have some complicated code here map.put("s", "s"); } @BytecodeInterpreterSwitch @ExplodeLoop(kind = LoopExplosionKind.MERGE_EXPLODE) - public int executeUnsafe(VirtualFrame f) { + public int executeUnsafe(@SuppressWarnings("unused") VirtualFrame f) { // VirtualFrame frame = Truffle.getRuntime().createVirtualFrame(new Object[0], // descriptor); final int maxLocals = locals + 2; diff --git a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/DSLInterpreterBenchmark.java b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/DSLInterpreterBenchmark.java index 2dd86ac7b482..1bec23046618 100644 --- a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/DSLInterpreterBenchmark.java +++ b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/DSLInterpreterBenchmark.java @@ -54,6 +54,8 @@ import com.oracle.truffle.api.benchmark.DSLInterpreterBenchmarkFactory.CachedDSLNodeGen; import com.oracle.truffle.api.benchmark.DSLInterpreterBenchmarkFactory.SimpleDSLNodeGen; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; import com.oracle.truffle.api.frame.VirtualFrame; @@ -195,6 +197,7 @@ abstract static class AbstractNode extends Node { abstract int execute(Object v); } + @GenerateInline(false) abstract static class SimpleDSLNode extends AbstractNode { @Specialization @@ -209,6 +212,7 @@ int doLong(long v) { } + @SuppressWarnings("truffle-inlining") abstract static class CachedDSLNode extends AbstractNode { @Specialization @@ -221,7 +225,7 @@ int doLong(long v) { return (int) v; } - static final int CACHED = 42; + @NeverDefault static final int CACHED = 42; } diff --git a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/EngineBenchmark.java b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/EngineBenchmark.java index 6140406afa0b..82578164c2cb 100644 --- a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/EngineBenchmark.java +++ b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/EngineBenchmark.java @@ -526,7 +526,7 @@ public static class BenchmarkObjectLookup extends BenchmarkObjectConstant { @ExplodeLoop final Object execute(Object[] arguments, @CachedLibrary("this") InteropLibrary lib, - @Cached("this.iterations") int cachedIterations) { + @Cached(value = "this.iterations", neverDefault = false) int cachedIterations) { int sum = 0; for (int i = 0; i < cachedIterations; i++) { sum += BenchmarkContext.get(lib).index; diff --git a/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/NodeInliningBenchmark.java b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/NodeInliningBenchmark.java new file mode 100644 index 000000000000..9bd408d9a88c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.benchmark/src/com/oracle/truffle/api/benchmark/NodeInliningBenchmark.java @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.benchmark; + +import org.graalvm.polyglot.Context; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.OperationsPerInvocation; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; + +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.benchmark.NodeInliningBenchmarkFactory.CachedNodeGen; +import com.oracle.truffle.api.benchmark.NodeInliningBenchmarkFactory.InlinedNodeGen; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.impl.DefaultTruffleRuntime; +import com.oracle.truffle.api.nodes.Node; + +public class NodeInliningBenchmark extends TruffleBenchmark { + + static final int INNER_LOOP = 100000; + + @State(Scope.Thread) + public static class BenchmarkState { + final Context context; + { + if (Truffle.getRuntime() instanceof DefaultTruffleRuntime) { + context = Context.newBuilder().build(); + } else { + context = Context.newBuilder().allowExperimentalOptions(true).option("engine.Compilation", "false").build(); + } + context.enter(); + } + + final InlinedNode[] inlinedNodes = new InlinedNode[INNER_LOOP]; + final CachedNode[] cachedNodes = new CachedNode[INNER_LOOP]; + { + for (int i = 0; i < INNER_LOOP; i++) { + inlinedNodes[i] = InlinedNodeGen.create(); + cachedNodes[i] = CachedNodeGen.create(); + } + } + + @TearDown + public void tearDown() { + context.leave(); + context.close(); + } + } + + @State(Scope.Thread) + public static class FirstCallState extends BenchmarkState { + + final InlinedNode[] inlinedNodes = new InlinedNode[INNER_LOOP]; + final CachedNode[] cachedNodes = new CachedNode[INNER_LOOP]; + + @Setup(Level.Invocation) + public void setup() { + for (int i = 0; i < INNER_LOOP; i++) { + inlinedNodes[i] = InlinedNodeGen.create(); + cachedNodes[i] = CachedNodeGen.create(); + } + } + + @TearDown(Level.Invocation) + public void tearDownIteration() { + System.gc(); + } + + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public void createInlined(BenchmarkState state) { + InlinedNode[] nodes = state.inlinedNodes; + for (int i = 0; i < nodes.length; i++) { + nodes[i] = InlinedNodeGen.create(); + } + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public void createCached(BenchmarkState state) { + CachedNode[] nodes = state.cachedNodes; + for (int i = 0; i < nodes.length; i++) { + nodes[i] = CachedNodeGen.create(); + } + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public long executeSpecializeInlined(FirstCallState state) { + InlinedNode[] nodes = state.inlinedNodes; + long sum = 0; + for (int i = 0; i < nodes.length; i++) { + sum += nodes[i].execute(i, -i, i, -i); + } + return sum; + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public long executeSpecializeCached(FirstCallState state) { + CachedNode[] nodes = state.cachedNodes; + long sum = 0; + for (int i = 0; i < nodes.length; i++) { + sum += nodes[i].execute(i, -i, i, -i); + } + return sum; + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public long executeFastInlined(BenchmarkState state) { + InlinedNode[] nodes = state.inlinedNodes; + long sum = 0; + for (int i = 0; i < nodes.length; i++) { + sum += nodes[i].execute(i, -i, i, -i); + } + return sum; + } + + @Benchmark + @OperationsPerInvocation(INNER_LOOP) + public long executeFastCached(BenchmarkState state) { + CachedNode[] nodes = state.cachedNodes; + long sum = 0; + for (int i = 0; i < nodes.length; i++) { + sum += nodes[i].execute(i, -i, i, -i); + } + return sum; + } + + @GenerateInline + @GenerateCached(false) + public abstract static class InlinedAbsNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + } + + @GenerateInline + @GenerateCached(false) + public abstract static class InlinedAddAbsNode extends Node { + + abstract long execute(Node node, long left, long right); + + @Specialization + static long add(Node node, long left, long right, + @Cached InlinedAbsNode leftAbs, + @Cached InlinedAbsNode rightAbs) { + return leftAbs.execute(node, left) + rightAbs.execute(node, right); + } + // ... + } + + @GenerateCached(alwaysInlineCached = true) + @GenerateInline(false) + public abstract static class InlinedNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached InlinedAddAbsNode add0, + @Cached InlinedAddAbsNode add1, + @Cached InlinedAddAbsNode add2) { + long v; + v = add0.execute(this, v0, v1); + v = add1.execute(this, v, v2); + v = add2.execute(this, v, v3); + return v; + } + + } + + @SuppressWarnings("truffle-inlining") + public abstract static class AbsNode extends Node { + + abstract long execute(long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + } + + @SuppressWarnings("truffle-inlining") + public abstract static class AddAbsNode extends Node { + + abstract long execute(long left, long right); + + @Specialization + static long add(long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(left) + rightAbs.execute(right); + } + // ... + } + + @SuppressWarnings("truffle-inlining") + public abstract static class CachedNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(v0, v1); + v = add1.execute(v, v2); + v = add2.execute(v, v3); + return v; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest index 0f155c58c9a9..39e2b3d55d64 100644 --- a/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest @@ -400,10 +400,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -412,7 +410,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -475,6 +472,3 @@ supr java.lang.Object hfds CAUSE_CAPTION,EMPTY_THROWABLE_ARRAY,NULL_CAUSE_MESSAGE,SELF_SUPPRESSION_MESSAGE,SUPPRESSED_CAPTION,SUPPRESSED_SENTINEL,UNASSIGNED_STACK,backtrace,cause,depth,detailMessage,serialVersionUID,stackTrace,suppressedExceptions hcls PrintStreamOrWriter,SentinelHolder,WrappedPrintStream,WrappedPrintWriter -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - diff --git a/truffle/src/com.oracle.truffle.api.debug/src/com/oracle/truffle/api/debug/SetThreadSuspensionEnabledNode.java b/truffle/src/com.oracle.truffle.api.debug/src/com/oracle/truffle/api/debug/SetThreadSuspensionEnabledNode.java index 2b03e4b41756..e3cf855bd956 100644 --- a/truffle/src/com.oracle.truffle.api.debug/src/com/oracle/truffle/api/debug/SetThreadSuspensionEnabledNode.java +++ b/truffle/src/com.oracle.truffle.api.debug/src/com/oracle/truffle/api/debug/SetThreadSuspensionEnabledNode.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.debug.Breakpoint.SessionList; import com.oracle.truffle.api.debug.DebuggerSession.ThreadSuspension; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; @@ -52,6 +53,7 @@ * This node sets thread-local enabled suspension flag. It uses {@link DebuggerSession}'s * {@link ThreadLocal} field, which is cached in 10 threads for fast access. */ +@GenerateInline(false) abstract class SetThreadSuspensionEnabledNode extends Node { static final int CACHE_LIMIT = 10; @@ -63,7 +65,7 @@ public final void execute(boolean suspensionEnabled, SessionList sessions) { protected abstract void execute(boolean suspensionEnabled, SessionList sessions, long threadId); @Specialization(guards = {"sessions.next == null", "threadId == currentThreadId"}, limit = "CACHE_LIMIT") - protected void executeCached(boolean suspensionEnabled, + protected void doCached(boolean suspensionEnabled, @SuppressWarnings("unused") SessionList sessions, @SuppressWarnings("unused") long threadId, @SuppressWarnings("unused") @Cached("currentThreadId()") long currentThreadId, @@ -72,8 +74,8 @@ protected void executeCached(boolean suspensionEnabled, } @ExplodeLoop - @Specialization(replaces = "executeCached") - protected void executeGeneric(boolean suspensionEnabled, + @Specialization(replaces = "doCached") + protected void doGeneric(boolean suspensionEnabled, SessionList sessions, @SuppressWarnings("unused") long threadId) { SessionList current = sessions; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AOTSupportTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AOTSupportTest.java index 1c0d026e1858..ac62ff549a85 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AOTSupportTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AOTSupportTest.java @@ -54,6 +54,7 @@ import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLanguage.Registration; import com.oracle.truffle.api.dsl.AOTSupport; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.GenerateAOT; @@ -89,8 +90,17 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ByteValueProfile; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.api.profiles.DoubleValueProfile; import com.oracle.truffle.api.profiles.FloatValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedByteValueProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile; +import com.oracle.truffle.api.profiles.InlinedDoubleValueProfile; +import com.oracle.truffle.api.profiles.InlinedFloatValueProfile; +import com.oracle.truffle.api.profiles.InlinedIntValueProfile; +import com.oracle.truffle.api.profiles.InlinedLongValueProfile; import com.oracle.truffle.api.profiles.IntValueProfile; import com.oracle.truffle.api.profiles.LongValueProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; @@ -101,7 +111,7 @@ /** * Note that this test is also used in AOTSupportCompilationTest. */ -@SuppressWarnings("deprecation") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "deprecation"}) public class AOTSupportTest extends AbstractPolyglotTest { public static final String LANGUAGE_ID = "AOTSupportTest_TestLanguage"; @@ -339,7 +349,7 @@ int implicitCast(long arg, @Cached("6") int cachedArg) { return (int) arg; } - @Specialization(guards = {"arg == 8", "arg == cachedArg"}) + @Specialization(guards = {"arg == 8", "arg == cachedArg"}, limit = "3") int ignoredCache(int arg, @Cached("arg") int cachedArg) { return arg; } @@ -360,18 +370,28 @@ int noRecursiveCache(int arg) { } @Specialization(guards = {"arg == 10"}) - int profiles(int arg, @Cached BranchProfile branch, - @Cached("createBinaryProfile()") ConditionProfile binaryCondition, - @Cached("createCountingProfile()") ConditionProfile countingCondition, - @Cached("createCountingProfile()") LoopConditionProfile loopCondition, - @Cached("createIdentityProfile()") ByteValueProfile byteValue, - @Cached("createIdentityProfile()") IntValueProfile intValue, - @Cached("createIdentityProfile()") LongValueProfile longValue, - @Cached("createRawIdentityProfile()") FloatValueProfile floatValue, - @Cached("createRawIdentityProfile()") DoubleValueProfile doubleValue, + static int profiles(int arg, + @Bind("$node") Node node, + @Cached(inline = false) BranchProfile branch, + @Cached(inline = false) ConditionProfile binaryCondition, + @Cached(inline = false) CountingConditionProfile countingCondition, + @Cached LoopConditionProfile loopCondition, + @Cached(inline = false) ByteValueProfile byteValue, + @Cached(inline = false) IntValueProfile intValue, + @Cached(inline = false) LongValueProfile longValue, + @Cached(inline = false) FloatValueProfile floatValue, + @Cached(inline = false) DoubleValueProfile doubleValue, @Cached("createEqualityProfile()") PrimitiveValueProfile primitiveValue, @Cached("createClassProfile()") ValueProfile classValue, - @Cached("createIdentityProfile()") ValueProfile identityValue) { + @Cached("createIdentityProfile()") ValueProfile identityValue, + @Cached InlinedBranchProfile inlinedbranch, + @Cached InlinedConditionProfile inlinedConditionProfile, + @Cached InlinedCountingConditionProfile inlinedCountingCondition, + @Cached InlinedByteValueProfile inlinedByteValue, + @Cached InlinedIntValueProfile inlinedIntValue, + @Cached InlinedLongValueProfile inlinedLongValue, + @Cached InlinedFloatValueProfile inlinedFloatValue, + @Cached InlinedDoubleValueProfile inlinedDoubleValue) { branch.enter(); binaryCondition.profile(true); @@ -412,7 +432,23 @@ int profiles(int arg, @Cached BranchProfile branch, primitiveValue.profile(Integer.valueOf(2)); classValue.profile(Integer.class); - identityValue.profile(this); + identityValue.profile(node); + + inlinedbranch.enter(node); + inlinedConditionProfile.profile(node, true); + inlinedConditionProfile.profile(node, false); + inlinedCountingCondition.profile(node, true); + inlinedCountingCondition.profile(node, false); +// + inlinedByteValue.profile(node, (byte) 1); + inlinedByteValue.profile(node, (byte) 2); + inlinedIntValue.profile(node, 1); + inlinedIntValue.profile(node, 2); + inlinedLongValue.profile(node, 1); + inlinedLongValue.profile(node, 2); + inlinedFloatValue.profile(node, 1); + inlinedFloatValue.profile(node, 2); + inlinedDoubleValue.profile(node, 1); return arg; } @@ -531,7 +567,7 @@ static Assumption createAssumption() { return Truffle.getRuntime().createAssumption(); } - @Specialization(guards = {"arg == 7", "arg == cachedArg"}) + @Specialization(guards = {"arg == 7", "arg == cachedArg"}, limit = "3") static int ignoredCache(AOTInitializable receiver, int arg, @Cached("arg") int cachedArg) { return arg; } @@ -542,18 +578,28 @@ static int genericCache(AOTInitializable receiver, int arg) { } @Specialization(guards = {"arg == 8"}) - static int profiles(AOTInitializable receiver, int arg, @Cached BranchProfile branch, - @Cached("createBinaryProfile()") ConditionProfile binaryCondition, - @Cached("createCountingProfile()") ConditionProfile countingCondition, - @Cached("createCountingProfile()") LoopConditionProfile loopCondition, - @Cached("createIdentityProfile()") ByteValueProfile byteValue, - @Cached("createIdentityProfile()") IntValueProfile intValue, - @Cached("createIdentityProfile()") LongValueProfile longValue, - @Cached("createRawIdentityProfile()") FloatValueProfile floatValue, - @Cached("createRawIdentityProfile()") DoubleValueProfile doubleValue, + static int profiles(AOTInitializable receiver, int arg, + @Bind("this") Node node, + @Cached(inline = false) BranchProfile branch, + @Cached(inline = false) ConditionProfile binaryCondition, + @Cached(inline = false) CountingConditionProfile countingCondition, + @Cached LoopConditionProfile loopCondition, + @Cached(inline = false) ByteValueProfile byteValue, + @Cached(inline = false) IntValueProfile intValue, + @Cached(inline = false) LongValueProfile longValue, + @Cached(inline = false) FloatValueProfile floatValue, + @Cached(inline = false) DoubleValueProfile doubleValue, @Cached("createEqualityProfile()") PrimitiveValueProfile primitiveValue, @Cached("createClassProfile()") ValueProfile classValue, - @Cached("createIdentityProfile()") ValueProfile identityValue) { + @Cached("createIdentityProfile()") ValueProfile identityValue, + @Cached InlinedBranchProfile inlinedbranch, + @Cached InlinedConditionProfile inlinedConditionProfile, + @Cached InlinedCountingConditionProfile inlinedCountingCondition, + @Cached InlinedByteValueProfile inlinedByteValue, + @Cached InlinedIntValueProfile inlinedIntValue, + @Cached InlinedLongValueProfile inlinedLongValue, + @Cached InlinedFloatValueProfile inlinedFloatValue, + @Cached InlinedDoubleValueProfile inlinedDoubleValue) { branch.enter(); binaryCondition.profile(true); @@ -596,6 +642,23 @@ static int profiles(AOTInitializable receiver, int arg, @Cached BranchProfile br classValue.profile(Integer.class); identityValue.profile(receiver); + inlinedbranch.enter(node); + inlinedConditionProfile.profile(node, true); + inlinedCountingCondition.profile(node, false); + inlinedCountingCondition.profile(node, true); + inlinedCountingCondition.profile(node, false); + + inlinedByteValue.profile(node, (byte) 1); + inlinedByteValue.profile(node, (byte) 2); + inlinedIntValue.profile(node, 1); + inlinedIntValue.profile(node, 2); + inlinedLongValue.profile(node, 1); + inlinedLongValue.profile(node, 2); + inlinedFloatValue.profile(node, 1); + inlinedFloatValue.profile(node, 2); + inlinedDoubleValue.profile(node, 1); + inlinedDoubleValue.profile(node, 2); + return arg; } @@ -846,6 +909,7 @@ abstract static class WithoutAOTSupportDSLNode extends Node { int s0(int arg) { return arg; } + } @GenerateAOT diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AmbiguousClassNameTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AmbiguousClassNameTest.java index bfe9a9bc0d78..2f7c4112a3e3 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AmbiguousClassNameTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AmbiguousClassNameTest.java @@ -50,6 +50,7 @@ import com.oracle.truffle.api.dsl.test.examples.ExampleTypes; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class AmbiguousClassNameTest { /* diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java index 29b082339a8d..2c3863768eb1 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/AssumptionsTest.java @@ -86,6 +86,7 @@ import com.oracle.truffle.api.dsl.test.examples.ExampleTypes; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class AssumptionsTest { @Test @@ -663,7 +664,6 @@ public void testCachedAssumptionNode() { assertEquals(i, node.execute(i)); } - // check fallback first node = CachedAssumptionNodeGen.create(); assertEquals(Integer.MAX_VALUE, node.execute(Integer.MAX_VALUE - 1)); for (int i = 0; i < CachedAssumptionNode.SPECIALIZATIONS; i++) { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BindExpressionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BindExpressionTest.java index 4d336b525d35..6a6a1b528aa3 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BindExpressionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BindExpressionTest.java @@ -41,6 +41,7 @@ package com.oracle.truffle.api.dsl.test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -66,6 +67,8 @@ import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindMethodNodeGen; import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindMethodTwiceNodeGen; import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindNodeFieldNodeGen; +import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindThisMultipleInstancesTestNodeGen; +import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindThisTestNodeGen; import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindTransitiveCachedInAssumptionNodeGen; import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindTransitiveCachedInLimitNodeGen; import com.oracle.truffle.api.dsl.test.BindExpressionTestFactory.BindTransitiveCachedWithLibraryNodeGen; @@ -77,9 +80,10 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class BindExpressionTest extends AbstractPolyglotTest { static class TestObject { @@ -419,7 +423,7 @@ abstract static class BindTransitiveCachedInAssumptionNode extends Node { @Specialization(assumptions = "extractAssumption2") Object s0(TestObject a0, - @Cached("a0.assumption") Assumption assumption, + @Cached(value = "a0.assumption", neverDefault = true) Assumption assumption, @Bind("assumption") Assumption extractAssumption1, @Bind("extractAssumption1") Assumption extractAssumption2) { return a0; @@ -446,6 +450,72 @@ int s0(TestObject a0, } } + @Test + public void testBindThis() { + BindThisTest node = BindThisTestNodeGen.create(); + node.execute(); + } + + abstract static class BindThisTest extends Node { + + abstract void execute(); + + @Specialization + void s0(@Bind("this") Node thisNode) { + assertSame(this, thisNode); + } + } + + abstract static class BindThisParentTest extends Node { + + abstract void execute(); + + @Specialization + void s0(@Bind("this.getParent()") Node thisNode) { + assertSame(this.getParent(), thisNode); + } + } + + @Test + public void testBindThisMultipleInstances() { + BindThisMultipleInstancesTest node = BindThisMultipleInstancesTestNodeGen.create(); + node.execute(42); + node.execute(43); + node.execute(44); + node.execute(45); + } + + abstract static class BindThisMultipleInstancesTest extends Node { + + abstract void execute(int arg); + + @Specialization(guards = "arg == cachedArg", limit = "2") + void s0(int arg, + @Cached("arg") int cachedArg, + @Bind("this") Node thisNode) { + /* + * The specialization does not bind nodes therefore it returns the current node instead + * of the specialization class. + */ + assertSame(this, this); + } + + @SuppressWarnings("truffle-static-method") + @Specialization(guards = "arg == cachedArg", limit = "2") + void s1(int arg, + @Cached("arg") int cachedArg, + @Cached InlinedBranchProfile branchProfile, + @Bind("this") Node thisNode) { + /* + * The specialization does not bind nodes therefore it returns the current node instead + * of the specialization class. + */ + branchProfile.enter(thisNode); + assertNotSame(this, thisNode); + assertSame(thisNode.getParent(), this); + } + } + @Test public void testBindCachedNodeTest() { BindCachedNodeTest node = adoptNode(BindCachedNodeTestNodeGen.create()).get(); @@ -566,4 +636,14 @@ Object s0(TestObject a0, } + abstract static class ErrorBindThisWithCachedTest extends Node { + + abstract void execute(); + + @Specialization + void s0(@ExpectError("Cannot use 'this' with @Cached use @Bind instead.") // + @Cached("this") Node thisNode) { + } + } + } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedDataRaceTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedDataRaceTest.java index cd7c4319fe05..720156b64f7d 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedDataRaceTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedDataRaceTest.java @@ -60,6 +60,7 @@ * the CachedLibrary in the generated "execute" method and write of that field in the generated * "executeAndSpecialize" method. Note that the race was reproducible only on JDK8. */ +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class CachedDataRaceTest { private static final int TEST_REPETITIONS = 1000; // Don't go too crazy, if JVM reports lots of available threads diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedNodeTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedNodeTest.java index 7f7fc35add67..40e2c7741b79 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedNodeTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedNodeTest.java @@ -55,7 +55,7 @@ import com.oracle.truffle.api.dsl.test.CachedNodeTestFactory.ValidDSLCachedNodeGen; import com.oracle.truffle.api.nodes.Node; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class CachedNodeTest { public static class ValidNode1 extends Node { @@ -195,6 +195,7 @@ static Object s0(Object arg0, Object arg1, } @GenerateUncached + public abstract static class ValidDSLNode extends Node { abstract String execute(Object arg); @@ -234,6 +235,7 @@ public void testValidDSLNode2() { } @GenerateUncached + public abstract static class CustomCreateTakesPrecedence extends Node { abstract String execute(Object arg); @@ -304,7 +306,7 @@ static Object s0(Object arg0, public abstract static class SupportTrivialUncached2 extends Node { abstract Object execute(Object arg0); - @Specialization(guards = "cachedArg0 == arg0.getClass()") + @Specialization(guards = "cachedArg0 == arg0.getClass()", limit = "3") static Object s0(Object arg0, @Cached("arg0.getClass()") Class cachedArg0) { return "cached"; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedReachableFallbackTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedReachableFallbackTest.java index 2ec217a8baec..ab48527e3698 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedReachableFallbackTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedReachableFallbackTest.java @@ -60,6 +60,7 @@ import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.nodes.NodeVisitor; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class CachedReachableFallbackTest { static final String CACHED_GUARD_FALLBACK_ERROR = "Some guards for the following specializations could not be negated for the @Fallback specialization: [s1].%"; @@ -69,7 +70,7 @@ abstract static class ValidWithGenericNode extends Node { abstract Object execute(Object other); - @Specialization(guards = {"guardNode.execute(obj)"}) + @Specialization(guards = {"guardNode.execute(obj)"}, limit = "3") protected Object s1(int obj, @Cached("createGuard()") GuardNode guardNode) { return "s1"; @@ -174,7 +175,7 @@ public void testValidWithoutGeneric() { Assert.assertEquals("s1", node.execute(42)); Assert.assertEquals("fallback", node.execute("42")); Assert.assertEquals("s1", node.execute(42)); // s2 does not replace s1 - Assert.assertEquals(2, node.createGuardCalls); + Assert.assertEquals(1, node.createGuardCalls); Assert.assertEquals(1, countGuardNodes(node)); // test fallback first @@ -183,12 +184,12 @@ public void testValidWithoutGeneric() { Assert.assertEquals("fallback", node.execute("42")); Assert.assertEquals(0, countGuardNodes(node)); Assert.assertEquals("s1", node.execute(42)); - Assert.assertEquals(2, node.createGuardCalls); + Assert.assertEquals(1, node.createGuardCalls); Assert.assertEquals(1, countGuardNodes(node)); } @SuppressWarnings("unused") - abstract static class CacheDuplicatesNode extends Node { + abstract static class CacheDuplicatesNode extends SlowPathListenerNode { abstract Object execute(Object other); @@ -216,6 +217,7 @@ public void testCacheDuplicates() { Assert.assertEquals("fallback", node.execute(41)); Assert.assertEquals(42, node.execute(42)); Assert.assertEquals("fallback", node.execute(41)); + Assert.assertEquals(2, node.specializeCount); // test fallback with string node = CacheDuplicatesNodeGen.create(); @@ -223,6 +225,7 @@ public void testCacheDuplicates() { Assert.assertEquals(41, node.execute(41)); Assert.assertEquals("fallback", node.execute(42)); Assert.assertEquals(41, node.execute(41)); + Assert.assertEquals(2, node.specializeCount); } private static void assertAdopted(Node node) { @@ -303,7 +306,7 @@ abstract static class GuardKindsNode extends Node { @Specialization(guards = {"guardNode1.execute(obj)", "notTwo(obj)"}, rewriteOn = RuntimeException.class, assumptions = "createAssumption()", limit = "1") protected Object s1(int obj, - @Cached("create(1)") NotGuardNode guardNode1) { + @Cached(value = "create(1)", neverDefault = true) NotGuardNode guardNode1) { assertAdopted(guardNode1); if (obj == 3) { throw new RuntimeException(); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java index 4f68c36aba3c..91966303ae19 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java @@ -106,7 +106,7 @@ import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class CachedTest { @Test @@ -387,7 +387,7 @@ static boolean dynamicMethod(int value) { @NodeChildren({@NodeChild, @NodeChild}) static class RegressionTestWarningInIsIdentical extends ValueNode { - @Specialization(guards = {"cachedName == name"}) + @Specialization(guards = {"cachedName == name"}, limit = "3") protected Object directAccess(String receiver, String name, // @Cached("name") String cachedName, // @Cached("create(receiver, name)") Object callHandle) { @@ -424,7 +424,7 @@ public void testMultipleCaches() { static class TestCachedWithProfile extends ValueNode { @Specialization - static int do1(int value, @Cached("create()") MySubClass mySubclass) { + static int do1(int value, @Cached MySubClass mySubclass) { return 42; } } @@ -582,7 +582,7 @@ abstract static class NullChildAdoption extends Node { @Specialization static int do1(int value, // - @Cached("createNode()") Node cachedValue) { + @Cached(value = "createNode()", neverDefault = false) Node cachedValue) { return value; } @@ -920,7 +920,7 @@ abstract static class ProfileNode extends Node { @Specialization static ConditionProfile do1(String value, // - @Cached ConditionProfile conditionProfile) { + @Cached(inline = false) ConditionProfile conditionProfile) { return conditionProfile; } @@ -953,7 +953,7 @@ private static boolean hasParent(Node parent, Node node) { @NodeChild static class CacheDimensionsError1 extends ValueNode { - @Specialization(guards = "value == cachedValue") + @Specialization(guards = "value == cachedValue", limit = "3") static int[] do1(int[] value, // @ExpectError("The cached dimensions attribute must be specified for array types.") @Cached("value") int[] cachedValue) { return cachedValue; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedThreadSafetyTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedThreadSafetyTest.java index a5bad5f49ddc..8e7c74921372 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedThreadSafetyTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedThreadSafetyTest.java @@ -62,6 +62,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class CachedThreadSafetyTest { private static final int TASKS = 128; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CheckedExceptionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CheckedExceptionTest.java index 9cda0bf38dde..29f544f3a9de 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CheckedExceptionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CheckedExceptionTest.java @@ -45,18 +45,20 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.CheckedExceptionTestFactory.Default1NodeGen; import com.oracle.truffle.api.dsl.test.CheckedExceptionTestFactory.Default2NodeGen; import com.oracle.truffle.api.nodes.Node; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class CheckedExceptionTest { @SuppressWarnings("serial") static class CheckedException extends Exception { } + @GenerateInline(false) abstract static class Default1Node extends Node { abstract void execute(Object arg) throws CheckedException; @@ -81,6 +83,7 @@ public void testDefault1() { } } + @GenerateInline(false) abstract static class Default2Node extends Node { abstract void execute(Object arg) throws CheckedException; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java index c216ca28f0b9..8c094baa5850 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CodeFormatTest.java @@ -50,6 +50,7 @@ /** * Tests the generated code compiles without warnings for unusual large guard names. */ +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class CodeFormatTest { @Test @@ -75,7 +76,7 @@ protected static boolean guardWithaReeeeeeeeaaaaaaaaaaalllllllllyyyyyyyyLLLLLLLL "guardWithaReeeeeeeeaaaaaaaaaaalllllllllyyyyyyyyLLLLLLLLLLLLLoooooooonnnnnnngggggggName1()", "guardWithaReeeeeeeeaaaaaaaaaaalllllllllyyyyyyyyLLLLLLLLLLLLLoooooooonnnnnnngggggggName2()", "guardWithaReeeeeeeeaaaaaaaaaaalllllllllyyyyyyyyLLLLLLLLLLLLLoooooooonnnnnnngggggggName1()"}) - public int execute() { + public int doDefault() { return 42; } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java new file mode 100644 index 000000000000..9693c013fd50 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface DisableWarningSuppression { + + String[] value() default {}; + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java new file mode 100644 index 000000000000..418d8ffa9e17 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.Introspectable; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.GuaranteedNeverDefaultNodeGen; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.NeverDefaultNodeGen; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.SpecializationClassNodeGen; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.WithDefaultNodeGen; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.WithSharedClassNodeGen; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +public class EnumEncodingTest extends AbstractPolyglotTest { + + enum Enum1 { + E0, + } + + enum Enum2 { + E0, + E1, + } + + enum Enum3 { + E0, + E1, + E2, + } + + enum Enum8 { + E0, + E1, + E2, + E3, + E4, + E5, + E6, + E7, + } + + @Introspectable + @GenerateInline(value = true, inherit = true) + @GenerateCached(value = true, inherit = true) + @GenerateUncached(value = true, inherit = true) + static class BaseNode extends Node implements SlowPathListener { + + static int specializeCounter = 0; + + public void afterSpecialize() { + specializeCounter++; + } + + } + + @SuppressWarnings("unused") + abstract static class GuaranteedNeverDefaultNode extends BaseNode { + + abstract Enum1 execute(Node node, Object value); + + @Specialization + Enum1 s0(Enum1 value, + @Cached("value") Enum1 enumValue) { + return enumValue; + } + + } + + @Test + public void testGuaranteedNeverDefaultNode() { + BaseNode.specializeCounter = 0; + GuaranteedNeverDefaultNode node = GuaranteedNeverDefaultNodeGen.create(); + assertEquals(Enum1.E0, node.execute(null, Enum1.E0)); + assertEquals(Enum1.E0, node.execute(null, Enum1.E0)); + assertEquals(1, BaseNode.specializeCounter); + } + + @SuppressWarnings("unused") + abstract static class NeverDefaultNode extends BaseNode { + + abstract Enum8 execute(Node node, Enum8 value); + + @Specialization + Enum8 s0(Enum8 value, @Cached("value") Enum8 enumValue) { + return enumValue; + } + + } + + @Test + public void testNeverDefaultNode() { + BaseNode.specializeCounter = 0; + NeverDefaultNode node = NeverDefaultNodeGen.create(); + assertEquals(Enum8.E0, node.execute(null, Enum8.E0)); + assertEquals(Enum8.E0, node.execute(null, Enum8.E1)); + assertEquals(1, BaseNode.specializeCounter); + } + + @SuppressWarnings("unused") + abstract static class WithDefaultNode extends BaseNode { + + abstract Enum3 execute(Node node, Enum3 value); + + @Specialization + Enum3 s0(Enum3 value, @Cached(value = "value", neverDefault = false) Enum3 enumValue) { + return enumValue; + } + + } + + @Test + public void testWithDefaultNode() { + BaseNode.specializeCounter = 0; + WithDefaultNode node = WithDefaultNodeGen.create(); + assertEquals(Enum3.E0, node.execute(null, Enum3.E0)); + assertEquals(Enum3.E0, node.execute(null, Enum3.E1)); + assertEquals(1, BaseNode.specializeCounter); + + BaseNode.specializeCounter = 0; + node = WithDefaultNodeGen.create(); + assertEquals(null, node.execute(null, null)); + assertEquals(null, node.execute(null, Enum3.E1)); + assertEquals(1, BaseNode.specializeCounter); + } + + @SuppressWarnings("unused") + @ImportStatic(Enum2.class) + abstract static class WithSharedClassNode extends BaseNode { + + abstract Enum2 execute(Node node, Enum2 value); + + @Specialization(guards = "value == E0") + Enum2 s0(Enum2 value, @Shared("cache") @Cached(value = "value", neverDefault = false) Enum2 enumValue) { + return enumValue; + } + + @Specialization(guards = "value == E1") + Enum2 s1(Enum2 value, @Shared("cache") @Cached(value = "value", neverDefault = false) Enum2 enumValue) { + return enumValue; + } + + } + + @Test + public void testWithSharedClassNode() { + BaseNode.specializeCounter = 0; + WithSharedClassNode node = WithSharedClassNodeGen.create(); + assertEquals(Enum2.E0, node.execute(null, Enum2.E0)); + assertEquals(Enum2.E0, node.execute(null, Enum2.E1)); + assertEquals(Enum2.E0, node.execute(null, Enum2.E0)); + assertEquals(Enum2.E0, node.execute(null, Enum2.E1)); + assertEquals(2, BaseNode.specializeCounter); + + BaseNode.specializeCounter = 0; + node = WithSharedClassNodeGen.create(); + assertEquals(Enum2.E1, node.execute(null, Enum2.E1)); + assertEquals(Enum2.E1, node.execute(null, Enum2.E0)); + assertEquals(Enum2.E1, node.execute(null, Enum2.E1)); + assertEquals(Enum2.E1, node.execute(null, Enum2.E0)); + assertEquals(2, BaseNode.specializeCounter); + } + + @SuppressWarnings("unused") + @ImportStatic(Enum2.class) + abstract static class SpecializationClassNode extends BaseNode { + + abstract Enum8 execute(Node node, Enum8 value); + + @Specialization(guards = "value == cachedValue", limit = "2") + Enum8 s0(Enum8 value, @Cached("value") Enum8 cachedValue) { + return cachedValue; + } + + } + + @Test + public void testSpecializationClassNode() { + BaseNode.specializeCounter = 0; + SpecializationClassNode node = SpecializationClassNodeGen.create(); + assertEquals(Enum8.E0, node.execute(null, Enum8.E0)); + assertEquals(Enum8.E0, node.execute(null, Enum8.E0)); + assertEquals(Enum8.E1, node.execute(null, Enum8.E1)); + assertEquals(Enum8.E1, node.execute(null, Enum8.E1)); + assertEquals(2, BaseNode.specializeCounter); + } + + /* + * This class name triggers a naming confict with a class in the parent node. No need to execute + * this node. The test is that the generate code compiles correctly. + */ + @SuppressWarnings("unused") + abstract static class NamingConflictNode extends BaseNode { + + abstract Object execute(Node node, Object value); + + enum Enum1 { + E0, + } + + @Specialization + int s0(Enum1 value, + @Cached("value") Enum1 enumValue) { + assertEquals(value, enumValue); + return 42; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java index 20d082afa149..994f9f5252f9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java @@ -40,14 +40,13 @@ */ package com.oracle.truffle.api.dsl.test; -import static com.oracle.truffle.api.dsl.test.TestHelper.getSlowPathCount; -import static com.oracle.truffle.api.dsl.test.TestHelper.instrumentSlowPath; import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Test; import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; @@ -77,6 +76,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class ExecuteEvaluatedTest { @Test @@ -323,6 +323,7 @@ int call() { * Failed test where execute parameter Object[] was cased using (Object) which led to a compile * error. */ + abstract static class TestExecuteWithObjectArg extends Node { public abstract Object execute(VirtualFrame frame, Object[] args); @@ -336,17 +337,16 @@ public Object test(@SuppressWarnings("unused") final Object[] args) { @Test public void testEvaluatedImplicitCast0() { TestEvaluatedImplicitCast0Node node = TestEvaluatedImplicitCast0NodeGen.create(); - instrumentSlowPath(node); - assertEquals(0, getSlowPathCount(node)); + assertEquals(0, node.specializeCount); node.execute("a", 0); - assertEquals(1, getSlowPathCount(node)); + assertEquals(1, node.specializeCount); node.execute("b", 0); - assertEquals(1, getSlowPathCount(node)); + assertEquals(1, node.specializeCount); node.execute(42, 0); - assertEquals(2, getSlowPathCount(node)); + assertEquals(2, node.specializeCount); node.execute(43, 0); - assertEquals(2, getSlowPathCount(node)); + assertEquals(2, node.specializeCount); } @TypeSystem @@ -361,7 +361,8 @@ public static int toInt(short s) { @TypeSystemReference(TestEvaluatedImplicitCast0TypeSystem.class) @SuppressWarnings("unused") - abstract static class TestEvaluatedImplicitCast0Node extends Node { + + abstract static class TestEvaluatedImplicitCast0Node extends SlowPathListenerNode { public abstract Object execute(Object receiver, int intValue); @@ -379,7 +380,9 @@ public double doInt(Number receiver, int intValue) { * Avoid locking optimization to trigger. */ @Specialization(replaces = "doInt") - public double doInt2(Void receiver, int intValue) { + public double doInt2(Void receiver, int intValue, + // forces locking behavior + @Cached("intValue") int cachedValue) { return 42; } @@ -388,21 +391,20 @@ public double doInt2(Void receiver, int intValue) { @Test public void testEvaluatedImplicitCast1() { TestEvaluatedImplicitCast1Node node = TestEvaluatedImplicitCast1NodeGen.create(); - instrumentSlowPath(node); - assertEquals(0, getSlowPathCount(node)); + assertEquals(0, node.specializeCount); node.execute("a", (short) 0); node.execute("a", (short) 0); - assertEquals(1, getSlowPathCount(node)); + assertEquals(1, node.specializeCount); node.execute("b", 0); node.execute("b", 0); - assertEquals(2, getSlowPathCount(node)); + assertEquals(2, node.specializeCount); node.execute(42, (short) 0); node.execute(42, (short) 0); - assertEquals(3, getSlowPathCount(node)); + assertEquals(3, node.specializeCount); node.execute(43, 0); node.execute(43, 0); - assertEquals(3, getSlowPathCount(node)); + assertEquals(3, node.specializeCount); } @TypeSystem @@ -417,7 +419,8 @@ public static int toInt(short s) { @TypeSystemReference(TestEvaluatedImplicitCast1TypeSystem.class) @SuppressWarnings("unused") - abstract static class TestEvaluatedImplicitCast1Node extends Node { + + abstract static class TestEvaluatedImplicitCast1Node extends SlowPathListenerNode { public abstract Object execute(Object receiver, Object intValue); @@ -435,7 +438,9 @@ public double doInt(Number receiver, int intValue) { * Avoid locking optimization to trigger. */ @Specialization(replaces = "doInt") - public double doInt2(Void receiver, int intValue) { + public double doInt2(Void receiver, int intValue, + // forces locking behavior + @Cached("intValue") int cachedValue) { return 42; } @@ -444,21 +449,20 @@ public double doInt2(Void receiver, int intValue) { @Test public void testEvaluatedImplicitCast2() { TestEvaluatedImplicitCast2Node node = TestEvaluatedImplicitCast2NodeGen.create(); - instrumentSlowPath(node); - assertEquals(0, getSlowPathCount(node)); + assertEquals(0, node.specializeCount); node.execute("a", (short) 0); node.execute("a", (short) 0); - assertEquals(1, getSlowPathCount(node)); + assertEquals(1, node.specializeCount); node.execute("b", 0); node.execute("b", 0); - assertEquals(2, getSlowPathCount(node)); + assertEquals(2, node.specializeCount); node.execute(42, (short) 0); node.execute(42, (short) 0); - assertEquals(3, getSlowPathCount(node)); + assertEquals(3, node.specializeCount); node.execute("c", 0); node.execute("c", 0); - assertEquals(3, getSlowPathCount(node)); + assertEquals(3, node.specializeCount); } @TypeSystem @@ -473,7 +477,7 @@ public static int toInt(short s) { @TypeSystemReference(TestEvaluatedImplicitCast2TypeSystem.class) @SuppressWarnings("unused") - abstract static class TestEvaluatedImplicitCast2Node extends Node { + abstract static class TestEvaluatedImplicitCast2Node extends SlowPathListenerNode { public abstract Object execute(Object receiver, short intValue); @@ -493,7 +497,9 @@ public String doShort(Number receiver, short intValue) { * Avoid locking optimization to trigger. */ @Specialization(replaces = "doInt") - public double doInt2(Void receiver, int intValue) { + public double doInt2(Void receiver, int intValue, + // forces locking behavior + @Cached("intValue") int cachedValue) { return 42; } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteGroupingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteGroupingTest.java index a8d32fef9829..a3e54800ceff 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteGroupingTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteGroupingTest.java @@ -47,6 +47,7 @@ import org.junit.experimental.theories.Theory; import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.ExecuteGroupingTestFactory.ExecuteGrouping1NodeGen; @@ -155,6 +156,7 @@ int s2(Object a, Object b, Object c) { } + @GenerateInline(false) abstract static class StrangeReturnCase extends Node { // we don't know how to implement executeDouble diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteMethodTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteMethodTest.java index 0d50ba990b4f..0199294768a2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteMethodTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteMethodTest.java @@ -56,6 +56,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class ExecuteMethodTest { private static final String ERROR_NO_EXECUTE = "No accessible and overridable generic execute method found. Generic execute methods usually have the signature 'public abstract {Type} " + diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteTracingSupportTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteTracingSupportTest.java index af291ae741ed..e22ed4e4380f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteTracingSupportTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteTracingSupportTest.java @@ -54,6 +54,7 @@ import org.junit.Test; import com.oracle.truffle.api.dsl.ExecuteTracingSupport; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -137,6 +138,7 @@ int doIt(@SuppressWarnings("unused") VirtualFrame frame) { } @GenerateUncached + @GenerateInline(false) abstract static class OverloadedExecuteNode extends TracingBaseNode { abstract Object execute(int x, Object y); @@ -159,6 +161,7 @@ String doIt(int b0, String b1) { } } + @GenerateInline(false) abstract static class TraceDisabledNode extends TracingBaseNode { abstract Object execute(int x); @@ -173,6 +176,7 @@ Object doIt(int x) { } } + @GenerateInline(false) abstract static class VoidNoArgsNode extends TracingBaseNode { abstract void execute(); @@ -181,6 +185,7 @@ void doIt() { } } + @GenerateInline(false) abstract static class VoidExecuteWithNonVoidSpecializationNode extends TracingBaseNode { abstract void execute(int a); @@ -197,6 +202,7 @@ long doLong(long a) { } } + @GenerateInline(false) abstract static class ObjectArrayArgNode extends TracingBaseNode { abstract Object execute(Object[] arg); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExpressionOrderTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExpressionOrderTest.java index 7c6c88c74dbd..8eef38fe3c73 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExpressionOrderTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExpressionOrderTest.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.dsl.test.examples.ExampleTypes; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class ExpressionOrderTest { @SuppressWarnings("unused") diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java index 1ce2d9a683ef..34b2c7e0e0aa 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java @@ -55,6 +55,7 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Introspectable; import com.oracle.truffle.api.dsl.NodeChild; @@ -85,6 +86,7 @@ import com.oracle.truffle.api.nodes.NodeUtil; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class FallbackTest extends AbstractPolyglotTest { private static final Object UNKNOWN_OBJECT = new Object() { @@ -625,6 +627,7 @@ static class ImplicitValue { @TypeSystemReference(ImplicitCastInFallbackTypeSystem.class) @SuppressWarnings("unused") + @GenerateInline(false) public abstract static class ImplicitCastInFallbackNode extends Node { public abstract String execute(Object n); @@ -647,6 +650,7 @@ protected String f0(Object n) { * problems. */ @SuppressWarnings("unused") + @GenerateInline(false) public abstract static class FrameInFallbackTestNode extends Node { public abstract String execute(VirtualFrame frame, Object left); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FrameTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FrameTest.java index 3b87e7ad6c1b..25f67229ff0f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FrameTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FrameTest.java @@ -55,6 +55,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings("truffle") public class FrameTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GR32992Test.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GR32992Test.java index 08271665f815..d2c17215ec2c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GR32992Test.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GR32992Test.java @@ -56,7 +56,7 @@ * * This example remains here to ensure that it compiles clean with the DSL. */ -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class GR32992Test { static class T0 { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateCachedTest.java new file mode 100644 index 000000000000..5cb55c55840a --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateCachedTest.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest.assertFails; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.AlwaysInlineNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.DefaultEnabledNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.EnabledInheritInheritNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.EnabledInheritNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.EnabledSubNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.OnlyInliningNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateCachedTestFactory.OnlyUncachedNodeGen; +import com.oracle.truffle.api.nodes.Node; + +@SuppressWarnings("truffle") +public class GenerateCachedTest { + + @Test + public void testEnabled() { + // just tests that all nodes are generated as expected by calling the create method + DefaultEnabledNodeGen.create(); + EnabledSubNodeGen.create(); + EnabledInheritNodeGen.create(); + EnabledInheritInheritNodeGen.create(); + } + + @Test + public void testDisabled() { + assertFails(() -> loadGeneratedClass("DisabledNodeGen"), ClassNotFoundException.class); + assertFails(() -> loadGeneratedClass("DisabledInheritSubNodeGen"), ClassNotFoundException.class); + } + + abstract static class DefaultEnabledNode extends Node { + + abstract void execute(); + + @Specialization + void s0() { + } + } + + static Class loadGeneratedClass(String name) throws ClassNotFoundException { + try { + return Class.forName(DefaultEnabledNodeGen.class.getEnclosingClass().getName() + "." + name); + } catch (SecurityException e) { + throw new AssertionError("unexpected error", e); + } + } + + @GenerateCached(value = false, inherit = false) + abstract static class DisabledNode extends Node { + + abstract void execute(); + + @Specialization + void s0() { + } + + } + + abstract static class EnabledSubNode extends DisabledNode { + + @Override + @Specialization + void s0() { + } + + } + + @GenerateCached(value = false, inherit = true) + abstract static class DisabledInheritNode extends Node { + + abstract void execute(); + + @Specialization + void s0() { + } + + } + + abstract static class DisabledInheritSubNode extends DisabledNode { + + @Override + @Specialization + void s0() { + } + + } + + @GenerateCached(value = true, inherit = true) + abstract static class EnabledInheritNode extends DisabledInheritNode { + @Override + @Specialization + void s0() { + } + } + + abstract static class EnabledInheritInheritNode extends EnabledInheritNode { + + @Override + @Specialization + void s0() { + } + + } + + @Test + public void testInliningOnly() throws NoSuchMethodException { + assertNotNull(findInlineMethod(OnlyInliningNodeGen.class)); + assertFails(() -> findCreateMethod(OnlyInliningNodeGen.class), NoSuchMethodException.class); + assertFails(() -> findUncachedMethod(OnlyInliningNodeGen.class), NoSuchMethodException.class); + } + + @GenerateCached(false) + @GenerateInline(true) + abstract static class OnlyInliningNode extends Node { + + abstract void execute(Node node); + + @Specialization + void s0() { + } + } + + private static Method findInlineMethod(Class c) throws NoSuchMethodException { + try { + return c.getDeclaredMethod("inline", InlineTarget.class); + } catch (SecurityException e) { + throw new AssertionError("unexpected error", e); + } + } + + private static Method findCreateMethod(Class c) throws NoSuchMethodException { + try { + return c.getDeclaredMethod("create"); + } catch (SecurityException e) { + throw new AssertionError("unexpected error", e); + } + } + + private static Method findUncachedMethod(Class c) throws NoSuchMethodException { + try { + return c.getDeclaredMethod("getUncached"); + } catch (SecurityException e) { + throw new AssertionError("unexpected error", e); + } + } + + @Test + public void testUncachedOnly() throws NoSuchMethodException { + assertFails(() -> findInlineMethod(OnlyUncachedNodeGen.class), NoSuchMethodException.class); + assertFails(() -> findCreateMethod(OnlyUncachedNodeGen.class), NoSuchMethodException.class); + assertNotNull(findUncachedMethod(OnlyUncachedNodeGen.class)); + } + + @GenerateCached(false) + @GenerateUncached(true) + abstract static class OnlyUncachedNode extends Node { + + abstract void execute(Node node); + + @Specialization + void s0() { + } + } + + @GenerateCached(false) + @GenerateInline(true) + abstract static class OnlyInlineNode extends Node { + + abstract void execute(Node node); + + @Specialization + void s0() { + } + } + + @GenerateCached(alwaysInlineCached = true) + @SuppressWarnings("unused") + abstract static class AlwaysInline extends Node { + + abstract void execute(Node node); + + /* + * No warning should appear here. + */ + @Specialization + void s0( + @ExpectError("Redundant specification of @Cached(... inline=true). %") // + @Cached(inline = true) OnlyInlineNode node) { + } + } + + @Test + public void testAlwaysInline() { + AlwaysInline node = AlwaysInlineNodeGen.create(); + for (Field f : node.getClass().getDeclaredFields()) { + if (Modifier.isStatic(f.getModifiers())) { + continue; + } + // assert no instance fields with type InlineableNode + assertNotEquals(OnlyInlineNode.class, f.getType()); + } + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineAdvancedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineAdvancedTest.java new file mode 100644 index 000000000000..08b6980cb4ce --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineAdvancedTest.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.GenerateInlineAdvancedTestFactory.UseInlinableNodeGen; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +@SuppressWarnings({"truffle-sharing"}) +public class GenerateInlineAdvancedTest extends AbstractPolyglotTest { + + @Test + public void test01() { + UseInlinableNode node = UseInlinableNodeGen.create(); + int sum = 0; + for (int i = 0; i < UseInlinableNode.SPECIALIZATIONS; i++) { + sum += node.execute(i); + } + assertEquals(301, sum); + } + + @GenerateInline(false) + abstract static class UseInlinableNode extends Node { + + static final int SPECIALIZATIONS = 2; + + abstract int execute(Object parameter); + + @Specialization(guards = "value == 0") + int s0(int value, @Cached(inline = true) InlinableNode inlining) { + int result = value; + for (int i = 0; i < InlinableNode.SPECIALIZATIONS; i++) { + result += inlining.execute(this, i); + } + return result; + } + + @Specialization(guards = "value == 1") + int s1(int value, @Cached(inline = false) InlinableNode inlining) { + int result = value; + for (int i = 0; i < InlinableNode.SPECIALIZATIONS; i++) { + result += inlining.execute(this, i); + } + return result; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + abstract static class InlinableNode extends Node { + + static final int SPECIALIZATIONS = 10; + + abstract int execute(Node node, int value); + + @Specialization(guards = "value == 0") + int s0(int value) { + return value; + } + + @Specialization(guards = "value == 1") + int s1(@NeverDefault int value, @Cached("value") int cachedValue) { + return cachedValue; + } + + @Specialization(guards = "value == 2") + int s2(int value, @Cached("value") Object cachedValue) { + return value; + } + + @Specialization(guards = "value == 3") + static int s3(Node node, int value, @Cached TransitiveInlinableNode inlining) { + int result = value; + for (int i = 0; i < TransitiveInlinableNode.SPECIALIZATIONS; i++) { + result += inlining.execute(node, i); + } + return result; + } + + @Specialization(guards = {"value <= 6", "value == cachedValue"}, limit = "3") + static int s4(Node node, int value, @Cached("value") int cachedValue, @Cached TransitiveInlinableNode inlining) { + int result = value; + for (int i = 0; i < TransitiveInlinableNode.SPECIALIZATIONS; i++) { + result += inlining.execute(node, i); + } + return result; + } + + @Specialization(guards = {"value <= 9", "value == cachedValue"}, limit = "3", unroll = 3) + static int s5(Node node, int value, @Cached("value") int cachedValue, @Cached TransitiveInlinableNode inlining) { + int result = value; + for (int i = 0; i < TransitiveInlinableNode.SPECIALIZATIONS; i++) { + result += inlining.execute(node, i); + } + return result; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + abstract static class TransitiveInlinableNode extends Node { + + static final int SPECIALIZATIONS = 6; + + abstract int execute(Node node, int value); + + @Specialization(guards = "value == 0") + int s0(int value) { + return value; + } + + @Specialization(guards = "value == 1") + int s1(@NeverDefault int value, @Cached("value") int cachedValue) { + return cachedValue; + } + + @Specialization(guards = "value == 2") + int s2(int value, @Cached("value") Object cachedValue) { + return value; + } + + @Specialization(guards = {"value <= 5", "value == cachedValue"}, limit = "3") + static int s3(Node node, int value, @Cached("value") int cachedValue) { + return value; + } + + } +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java new file mode 100644 index 000000000000..0f0d29fdbd12 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -0,0 +1,2190 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.ExecuteTracingSupport; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GeneratePackagePrivate; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.dsl.Introspectable; +import com.oracle.truffle.api.dsl.Introspection; +import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; +import com.oracle.truffle.api.dsl.NodeChild; +import com.oracle.truffle.api.dsl.NodeField; +import com.oracle.truffle.api.dsl.ReportPolymorphism; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.CustomInline1NodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.CustomInline2NodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.ErrorRuntimeUsageNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.InlineReplaceNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.InlineRewriteOnNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.InlinedUsageNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.MultiInstanceInlineWithGenericNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.MultiInstanceInliningNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.MultiInstanceMixedInliningNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.PassNodeAndFrameNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.ReplaceNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.RewriteOnNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.SharedProfileInSpecializationClassNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.SpecializationClassAndInlinedNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.Use128BitsNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.Use2048BitsNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.Use32BitsNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.Use512BitsNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseAssumptionCacheNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseBindInInlinedNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseCustomInlineNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseDoNotInlineInlinableNodeNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseFailEarlyNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseInlineInlineCacheNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseInlineSharedWithSpecializationClassNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseInlinedAdoptNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseInlinedNodeInGuardNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseIntrospectionNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseMixedAndInlinedNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseNoStateNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseTracingNodeGen; +import com.oracle.truffle.api.dsl.test.GenerateInlineTestFactory.UseUncachedEnculapsingNodeGen; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExecutableNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.strings.TruffleString.CompactionLevel; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +@SuppressWarnings({"truffle-neverdefault", "truffle-sharing"}) +public class GenerateInlineTest extends AbstractPolyglotTest { + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class SingleBitNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 1") + static int s0(Node node, int v) { + return v; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class TwoBitNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + static int s0(Node node, int v) { + return v; + } + + @Specialization(guards = "v == 1") + static int s1(Node node, int v) { + return v; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + @GenerateUncached + public abstract static class FourBitNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + static int s0(Node node, int v) { + return 1; + } + + @Specialization(guards = "v == 1") + static int s1(Node node, int v) { + return 2; + } + + @Specialization(guards = "v == 2") + static int s2(Node node, int v) { + return 3; + } + + @Specialization(guards = "v == 3") + static int s3(Node node, int v) { + return 4; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + @GenerateUncached + public abstract static class NotInlineFourBitNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization + static int s0(Node node, int v, @Cached(inline = false) FourBitNode bitNode) { + return bitNode.execute(bitNode, v); + } + + } + + @GenerateInline + @SuppressWarnings("unused") + @GenerateUncached + public abstract static class InlinableInlineCacheNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == cachedV", limit = "3") + static int s0(Node node, int v, + @Cached("v") int cachedV, + @Cached FourBitNode bitNode) { + return bitNode.execute(node, v); + } + + } + + public abstract static class UseStateNode extends Node { + + abstract int execute(Node node); + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class Use32BitsNode extends UseStateNode { + + @Specialization + static int doInt(Node node, + @Cached FourBitNode p0, + @Cached FourBitNode p1, + @Cached FourBitNode p2, + @Cached FourBitNode p3, + @Cached FourBitNode p4, + @Cached FourBitNode p5, + @Cached FourBitNode p6, + @Cached FourBitNode p7) { + int sum = 0; + for (int i = 0; i < 4; i++) { + sum += p0.execute(node, i); + sum += p1.execute(node, i); + sum += p2.execute(node, i); + sum += p3.execute(node, i); + sum += p4.execute(node, i); + sum += p5.execute(node, i); + sum += p6.execute(node, i); + sum += p7.execute(node, i); + } + + return sum; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class Use128BitsNode extends UseStateNode { + + @Specialization + static int doInt(Node node, + @Cached Use32BitsNode p0, + @Cached Use32BitsNode p1, + @Cached Use32BitsNode p2, + @Cached Use32BitsNode p3) { + int sum = 0; + sum += p0.execute(node); + sum += p1.execute(node); + sum += p2.execute(node); + sum += p3.execute(node); + return sum; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class Use512BitsNode extends UseStateNode { + + @Specialization + static int doInt(Node node, + @Cached Use128BitsNode p0, + @Cached Use128BitsNode p1, + @Cached Use128BitsNode p2, + @Cached Use128BitsNode p3) { + int sum = 0; + sum += p0.execute(node); + sum += p1.execute(node); + sum += p2.execute(node); + sum += p3.execute(node); + return sum; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class Use2048BitsNode extends UseStateNode { + + @Specialization + static int doInt(Node node, + @Cached Use512BitsNode p0, + @Cached Use512BitsNode p1, + @Cached Use512BitsNode p2, + @Cached Use512BitsNode p3) { + int sum = 0; + sum += p0.execute(node); + sum += p1.execute(node); + sum += p2.execute(node); + sum += p3.execute(node); + return sum; + } + } + + @Test + public void testUseBitsState() throws IllegalArgumentException, IllegalAccessException { + assertUseStateFields(Use32BitsNodeGen.create(), 1); + assertUseStateFields(Use128BitsNodeGen.create(), 4); + assertUseStateFields(Use512BitsNodeGen.create(), 16); + assertUseStateFields(Use2048BitsNodeGen.create(), 64); + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class InlineCacheTest extends Node { + + abstract int execute(int arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + static int doInt(int arg, + @Bind("this") Node node, + @Cached("arg") int cachedArg, + @Cached InlinedBranchProfile p0) { + p0.enter(node); + return cachedArg; + } + + } + + private static void assertUseStateFields(UseStateNode node, final int expectedFields) throws IllegalAccessException { + List fields = collectStateFields(node.getClass(), true); + assertEquals(expectedFields, fields.size()); + + for (Field field : fields) { + field.setAccessible(true); + } + + // assert no bits set + for (Field field : fields) { + assertEquals(0, (int) field.get(node)); + } + + assertEquals(expectedFields * 80, node.execute(node)); + + // assert all bits set + for (Field field : fields) { + assertEquals(0xFFFFFFFF, (int) field.get(node)); + } + } + + static List collectStateFields(Class c, boolean assertNoOtherFields) { + List fields = new ArrayList<>(); + for (Field f : c.getDeclaredFields()) { + if (Modifier.isStatic(f.getModifiers())) { + continue; + } + if (f.getName().startsWith("state")) { + fields.add(f); + } else if (assertNoOtherFields) { + throw new AssertionError("Unexpected field found " + f); + } + } + return fields; + } + + /* + * Tests the combination of inlined branch profiles and non-inlined branch profiles. The three + * branch profile instances also trigger a specialization data class. + */ + @GenerateInline(false) + public abstract static class SpecializationClassAndInlinedNode extends Node { + + abstract int execute(); + + @Specialization + int doInt(@Cached(inline = true) SingleBitNode p0, + @Cached(inline = true) SingleBitNode p1, + @Cached(inline = false) SingleBitNode p2, + @Cached(inline = false) SingleBitNode p3, + @Cached(inline = false) SingleBitNode p4) { + int sum = 0; + sum += p0.execute(this, 1); + sum += p1.execute(this, 1); + sum += p2.execute(p2, 1); + sum += p3.execute(p3, 1); + sum += p4.execute(p4, 1); + return sum; + } + } + + @Test + public void testSpecializationClassAndInlined() { + assertEquals(5, SpecializationClassAndInlinedNodeGen.create().execute()); + } + + @GenerateInline + public abstract static class ErrorRuntimeNode extends Node { + + abstract void execute(Node node); + + @Specialization + @SuppressWarnings("unused") + static void doInt(Node node, @Cached InnerNode simpleNode) { + /* + * This is wrong on purpose to test its behavior (not crashing). + */ + simpleNode.execute(node, 42); + } + + } + + @GenerateInline(false) + public abstract static class ErrorRuntimeUsageNode extends Node { + + abstract void execute(); + + @Specialization + void doInt(@Cached(inline = true) ErrorRuntimeNode simpleNode) { + simpleNode.execute(simpleNode); + } + + } + + @Test + public void testErrorRuntimeUsage() { + assertFails(() -> ErrorRuntimeUsageNodeGen.create().execute(), ClassCastException.class, (e) -> { + assertEquals("Invalid parameter type passed to updater. Instance of type 'GenerateInlineTestFactory.ErrorRuntimeUsageNodeGen' expected but was 'GenerateInlineTestFactory.ErrorRuntimeNodeGen.Inlined'. " + + "Did you pass the wrong node to an execute method of an inlined cached node?", + e.getMessage()); + }); + } + + @Test + public void test() { + InlinedUsageNode node = adoptNode(InlinedUsageNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(42L, node.execute(42L)); + assertFails(() -> node.execute(""), UnsupportedSpecializationException.class); + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class InlinedUsageNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + Object doInt(int arg, @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + @Specialization + Object doLong(long arg, @Shared("simpleNode") @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + @Specialization + Object doLong(Object arg, @Shared("simpleNode") @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + } + + @GenerateInline + @GenerateUncached + @SuppressWarnings("unused") + public abstract static class SimpleNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization + static Object doInt(Node node, int arg, @Cached InnerNode innerNode) { + return innerNode.execute(node, arg); + } + + @Specialization + static Object doLong(Node node, long arg, @Cached InnerNode innerNode) { + return innerNode.execute(node, arg); + } + + @Specialization + static Object doObject(Node node, Object arg, @Cached InnerNode innerNode) { + return innerNode.execute(node, arg); + } + + } + + @GenerateInline + @GenerateUncached + @SuppressWarnings("unused") + public abstract static class InnerNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization + static int doInt(Node node, int arg) { + return arg; + } + + @Specialization + static long doLong(Node node, long arg) { + return arg; + } + + } + + @Test + public void testInvalidUsage() { + InlinedUsageNode node = adoptNode(InlinedUsageNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(42L, node.execute(42L)); + assertFails(() -> node.execute(""), UnsupportedSpecializationException.class); + } + + @Test + public void testReplace() { + ReplaceNode node = adoptNode(ReplaceNodeGen.create()).get(); + assertEquals("s0", node.execute(node, 42)); + assertEquals("s1", node.execute(node, 43)); + assertEquals("s1", node.execute(node, 42)); + + InlineReplaceNode useReplace = adoptNode(InlineReplaceNodeGen.create()).get(); + assertEquals("s0", useReplace.execute(42)); + assertEquals("s1", useReplace.execute(43)); + assertEquals("s1", useReplace.execute(42)); + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class InlineReplaceNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + Object s0(int arg, + @Cached(inline = true) ReplaceNode innerNode) { + return innerNode.execute(this, arg); + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ReplaceNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 42") + static String s0(Node node, int arg, + @Cached InnerNode innerNode) { + innerNode.execute(node, arg); + return "s0"; + } + + @Specialization(replaces = "s0") + static String s1(Node node, int arg, @Cached InnerNode innerNode) { + innerNode.execute(node, arg); + return "s1"; + } + + } + + @Test + public void testReplaceOn() { + RewriteOnNode node = adoptNode(RewriteOnNodeGen.create()).get(); + assertEquals("s0", node.execute(node, 42)); + assertEquals("s1", node.execute(node, 43)); + assertEquals("s1", node.execute(node, 42)); + + InlineRewriteOnNode useReplace = adoptNode(InlineRewriteOnNodeGen.create()).get(); + assertEquals("s0", useReplace.execute(42)); + assertEquals("s1", useReplace.execute(43)); + assertEquals("s1", useReplace.execute(42)); + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class InlineRewriteOnNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + Object s0(int arg, + @Cached(inline = true) RewriteOnNode innerNode) { + return innerNode.execute(this, arg); + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class RewriteOnNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(rewriteOn = ArithmeticException.class) + static String s0(Node node, int arg, + @Cached InnerNode innerNode) { + if (arg != 42) { + throw new ArithmeticException(); + } + innerNode.execute(node, arg); + return "s0"; + } + + @Specialization(replaces = "s0") + static String s1(Node node, int arg, @Cached InnerNode innerNode) { + innerNode.execute(node, arg); + return "s1"; + } + + } + + @GenerateInline + @GeneratePackagePrivate + public abstract static class CustomInline1Node extends Node { + + abstract int execute(Node node, int value); + + @Specialization(guards = "v >= 0") + static int doInt(int v) { + return v; + } + + @Specialization(guards = "v < 0") + static int doLong(int v) { + return -v; + } + + public static CustomInline1Node inline(@RequiredField(value = StateField.class, bits = 2) InlineTarget updater) { + return CustomInline1NodeGen.inline(updater); + } + + } + + @GenerateInline + @GeneratePackagePrivate + public abstract static class CustomInline2Node extends Node { + + abstract int execute(Node node, int value); + + @Specialization(guards = "v >= 0") + static int doInt(int v) { + return v; + } + + @Specialization(guards = "v < 0") + static int doLong(int v) { + return -v; + } + + public static CustomInline2Node inline(@RequiredField(value = StateField.class, bits = 16) InlineTarget updater) { + return CustomInline2NodeGen.inline(updater); + } + + } + + @SuppressWarnings({"truffle", "unused"}) + public abstract static class UseCustomInlineNode extends Node { + + abstract Object execute(int value); + + @Specialization + int s1(int value, + @Cached(inline = true) CustomInline1Node node1, + @Cached(inline = true) CustomInline2Node node2) { + int v; + v = node1.execute(this, value); + v = node2.execute(this, v); + return v; + } + } + + @Test + public void testCustomInlineNode() { + UseCustomInlineNode node = adoptNode(UseCustomInlineNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(42, node.execute(-42)); + + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class InvalidUsageNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + Object doInt(int arg, @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + @Specialization + Object doLong(long arg, @Shared("shared") @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + @Specialization + Object doLong(Object arg, @Shared("shared") @Cached(inline = true) SimpleNode simpleNode) { + return simpleNode.execute(this, arg); + } + + } + + @Test + public void testMultiInstanceInline() { + MultiInstanceInliningNode node = adoptNode(MultiInstanceInliningNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(41, node.execute(41)); + assertEquals(40, node.execute(40)); + assertEquals(42, node.execute(42)); + assertEquals(41, node.execute(41)); + assertEquals(40, node.execute(40)); + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class MultiInstanceInliningNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + static Object doInt(int arg, + @Bind("this") Node node, + @Cached(inline = true) SimpleNode simpleNode, + @Cached(inline = true) SimpleNode simpleNode2, + @Cached("arg") int cachedArg) { + return simpleNode.execute(node, cachedArg); + } + + } + + @Test + public void testMultiInstanceInlineWithGeneric() { + MultiInstanceInlineWithGenericNode node = adoptNode(MultiInstanceInlineWithGenericNodeGen.create()).get(); + + assertEquals("doCached", node.execute(42)); + assertEquals("doCached", node.execute(41)); + assertEquals("doCached", node.execute(40)); + assertEquals("doGeneric", node.execute(43)); + assertEquals("doCached", node.execute(42)); + assertEquals("doCached", node.execute(41)); + assertEquals("doCached", node.execute(40)); + assertEquals("doGeneric", node.execute(43)); + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class MultiInstanceInlineWithGenericNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + static Object doCached(int arg, + @Bind("this") Node node, + @Cached(inline = true) SimpleNode simpleNode, + @Cached(inline = true) SimpleNode simpleNode2, + @Cached("arg") int cachedArg) { + simpleNode.execute(node, cachedArg); + simpleNode2.execute(node, cachedArg); + return "doCached"; + } + + @Specialization + static Object doOther(int arg, + @Bind("this") Node node, + @Cached(inline = true) SimpleNode simpleNode, + @Cached(inline = true) SimpleNode simpleNode2, + @Cached(value = "arg", neverDefault = true) int cachedArg) { + simpleNode.execute(node, cachedArg); + simpleNode2.execute(node, cachedArg); + return "doGeneric"; + } + } + + @Test + public void testMultiInstanceMixedInliningNode() { + MultiInstanceMixedInliningNode node = adoptNode(MultiInstanceMixedInliningNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(41, node.execute(41)); + assertEquals(40, node.execute(40)); + assertEquals(42, node.execute(42)); + assertEquals(41, node.execute(41)); + assertEquals(40, node.execute(40)); + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class MultiInstanceMixedInliningNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + static Object doInt(int arg, + @Bind("this") Node node, + @Cached(inline = true) SimpleNode simpleNode, + @Cached(inline = false) SimpleNode simpleNode2, + @Cached("arg") int cachedArg) { + return simpleNode.execute(node, cachedArg); + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class BindInInlinedNode extends Node { + + abstract int execute(Node node); + + @Specialization + static int doDefault(Node node, + @Cached SingleBitNode cachedNode, + @Bind("cachedNode.execute(node, 1)") int result) { + return result; + } + + } + + @SuppressWarnings({"unused", "truffle"}) + public abstract static class UseBindInInlinedNode extends Node { + + abstract Object execute(); + + @Specialization + int doDefault(@Cached(inline = true) BindInInlinedNode cachedNode) { + return cachedNode.execute(this); + } + + } + + @Test + public void testBindInInlined() { + UseBindInInlinedNode node = adoptNode(UseBindInInlinedNodeGen.create()).get(); + assertEquals(1, node.execute()); + } + + @GenerateInline(false) + public abstract static class UseMixedAndInlinedNode extends Node { + + abstract Object execute(); + + @Specialization + int doDefault(@Cached(inline = true) TwoBitNode inlinedNode, + @Cached(inline = false) TwoBitNode dispatchedNode) { + inlinedNode.execute(this, 0); + return dispatchedNode.execute(dispatchedNode, 1); + } + + } + + @Test + public void testUseMixedAndInlinedNode() { + UseMixedAndInlinedNode node = adoptNode(UseMixedAndInlinedNodeGen.create()).get(); + assertEquals(1, node.execute()); + } + + @GenerateInline + public abstract static class AssumptionCacheNode extends Node { + + abstract int execute(Node node, Assumption[] assumption, int value); + + @Specialization(guards = "value == cachedValue", limit = "2", assumptions = "get(cachedAssumptions, cachedValue)") + @SuppressWarnings("unused") + int doDefault(Assumption[] assumptions, int value, + @Cached("value") int cachedValue, + @Cached(value = "assumptions", dimensions = 1) Assumption[] cachedAssumptions) { + return cachedValue; + } + + static Assumption get(Assumption[] assumptions, int index) { + return assumptions[index]; + } + + } + + @GenerateInline(false) + public abstract static class UseAssumptionCacheNode extends Node { + + abstract int execute(Assumption[] assumption, int value); + + @Specialization + int doDefault(Assumption[] assumptions, int value, + @Cached(inline = true) AssumptionCacheNode node) { + return node.execute(this, assumptions, value); + } + } + + @Test + public void testAssumptionCacheNode() { + UseAssumptionCacheNode node = adoptNode(UseAssumptionCacheNodeGen.create()).get(); + + Assumption[] assumptions = new Assumption[5]; + for (int i = 0; i < assumptions.length; i++) { + assumptions[i] = Truffle.getRuntime().createAssumption(); + } + assertEquals(0, node.execute(assumptions, 0)); + assertEquals(1, node.execute(assumptions, 1)); + assumptions[0].invalidate(); + assertEquals(2, node.execute(assumptions, 2)); + assumptions[1].invalidate(); + assumptions[2].invalidate(); + + // assumption invalidated + assertFails(() -> { + node.execute(assumptions, 2); + }, UnsupportedSpecializationException.class); + + // recreate assumptions + assumptions[2] = Truffle.getRuntime().createAssumption(); + + assertEquals(2, node.execute(assumptions, 2)); + assertEquals(3, node.execute(assumptions, 3)); + + // out of limit + assertFails(() -> { + node.execute(assumptions, 4); + }, UnsupportedSpecializationException.class); + + } + + @GenerateInline(true) + @GenerateCached(false) + public abstract static class DoNotInlineInlinableNodeNode extends Node { + + abstract int execute(Node node, int value); + + @Specialization + static int doDefault(Node node, int value, + @Cached(inline = false) SingleBitNode cached) { + return cached.execute(node, value); + } + } + + @GenerateInline(false) + public abstract static class UseDoNotInlineInlinableNodeNode extends Node { + + abstract int execute(int value); + + @Specialization + int doDefault(int value, + @Cached DoNotInlineInlinableNodeNode cached) { + return cached.execute(this, value); + } + } + + @Test + public void testDoNotInlineInlinableNodeNode() { + UseDoNotInlineInlinableNodeNode node = adoptNode(UseDoNotInlineInlinableNodeNodeGen.create()).get(); + assertEquals(1, node.execute(1)); + + } + + static int enterCount = 0; + static int exceptionCount = 0; + static int returnCount = 0; + + @GenerateInline(true) + @GenerateCached(false) + public abstract static class TracingNode extends Node implements ExecuteTracingSupport { + + abstract int execute(Node node, int value); + + @Specialization + int doDefault(int value) { + return value; + } + + public void traceOnEnter(Object[] arguments) { + enterCount++; + } + + public void traceOnException(Throwable t) { + exceptionCount++; + } + + public void traceOnReturn(Object returnValue) { + returnCount++; + } + + public boolean isTracingEnabled() { + return true; + } + } + + @GenerateInline(false) + public abstract static class UseTracingNode extends Node { + + abstract int execute(int value); + + @Specialization + int doDefault(int value, + @Cached TracingNode cached) { + return cached.execute(this, value); + } + } + + @Test + public void testTracingNode() { + enterCount = 0; + exceptionCount = 0; + returnCount = 0; + UseTracingNode node = adoptNode(UseTracingNodeGen.create()).get(); + + assertEquals(42, node.execute(42)); + assertEquals(1, enterCount); + assertEquals(0, exceptionCount); + assertEquals(1, returnCount); + + assertEquals(42, node.execute(42)); + assertEquals(2, enterCount); + assertEquals(0, exceptionCount); + assertEquals(2, returnCount); + } + + /* + * Compile correctly with report polymorphism. + */ + @GenerateInline(true) + @GenerateCached(false) + @ReportPolymorphism + @SuppressWarnings("unused") + public abstract static class ReportPolymorphismTest extends Node { + + abstract Object execute(Node node, Object value); + + @Specialization(guards = "value == cachedValue", limit = "3") + int doDefault(int value, @Cached("value") int cachedValue) { + return value; + } + + @Specialization + long doDefault(long value) { + return value; + } + } + + /* + * Compile correctly with report polymorphism. + */ + @GenerateInline(true) + @GenerateCached(false) + @Introspectable + @SuppressWarnings("unused") + public abstract static class IntrospectionNode extends Node { + + abstract Object execute(Node node, Object value); + + @Specialization(guards = "value == cachedValue", limit = "3") + int doDefault(int value, @Cached("value") int cachedValue) { + return value; + } + + @Specialization + long doDefault(long value) { + return value; + } + } + + @GenerateInline(false) + @Introspectable + public abstract static class UseIntrospectionNode extends Node { + + abstract Object execute(Object value); + + @Specialization + Object doDefault(Object value, + @Cached IntrospectionNode cached) { + return cached.execute(this, value); + } + } + + @Test + public void testIntrospection() { + UseIntrospectionNode node = adoptNode(UseIntrospectionNodeGen.create()).get(); + + node.execute(42); + node.execute(43); + node.execute(42L); + + SpecializationInfo info = Introspection.getSpecialization(node, node, "doDefault"); + IntrospectionNode introspectionNode = (IntrospectionNode) info.getCachedData(0).get(0); + + List inlinedInfos = Introspection.getSpecializations(node, introspectionNode); + assertEquals(2, inlinedInfos.size()); + + assertTrue(inlinedInfos.get(0).isActive()); + assertFalse(inlinedInfos.get(0).isExcluded()); + assertEquals(2, inlinedInfos.get(0).getInstances()); + assertEquals(43, inlinedInfos.get(0).getCachedData(0).get(0)); + assertEquals(42, inlinedInfos.get(0).getCachedData(1).get(0)); + + assertTrue(inlinedInfos.get(1).isActive()); + assertFalse(inlinedInfos.get(1).isExcluded()); + assertEquals(1, inlinedInfos.get(1).getInstances()); + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline + public abstract static class InlineInlineCache extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + static Object doInt(Node node, int arg, @Cached("arg") int cachedArg, + @Cached FourBitNode fourBit, + @Cached NotInlineFourBitNode notInlined, + @Cached InlinableInlineCacheNode inlineCacheInlined) { + inlineCacheInlined.execute(node, arg); + return fourBit.execute(node, cachedArg); + } + + @Specialization + static Object doGeneric(Node node, int arg, @Cached FourBitNode fourBit, // + @Cached InlinableInlineCacheNode inlineCacheInlined) { + return inlineCacheInlined.execute(node, arg); + } + + } + + @GenerateInline(false) + public abstract static class UseInlineInlineCache extends Node { + + abstract Object execute(Object arg); + + @Specialization + @SuppressWarnings("truffle-inlining") + Object doInt(int arg, @Cached InlineInlineCache inlined) { + return inlined.execute(this, arg); + } + + } + + @Test + public void testUseInlineInlineCache() { + UseInlineInlineCache node = adoptNode(UseInlineInlineCacheNodeGen.create()).get(); + + node.execute(0); + node.execute(1); + node.execute(2); + node.execute(3); + } + + @GenerateInline(true) + @GenerateCached(false) + public abstract static class FailEarlyNode extends Node { + + abstract Object execute(Node node); + + @Specialization + @SuppressWarnings("unused") + static Object doInt(Node node, @Cached InlinedBranchProfile branchProfile) { + // we do not call the branchProfile, but we still want to validate the node passed. + // this is useful to validate branch profiles that are rarely executed, so wouldn't fail + throw new AssertionError("should not reach here"); + } + + } + + @GenerateInline(false) + public abstract static class UseFailEarlyNode extends Node { + + abstract Object execute(); + + @Specialization + static Object doInt(@Cached FailEarlyNode node) { + assertFails(() -> node.execute(node), ClassCastException.class, (e) -> { + assertTrue(e.getMessage(), e.getMessage().contains("Invalid parameter type passed to updater.")); + }); + return "doInt"; + } + + } + + @Test + public void testFailEarly() { + UseFailEarlyNode node = adoptNode(UseFailEarlyNodeGen.create()).get(); + assertEquals("doInt", node.execute()); + } + + @SuppressWarnings("unused") + @GenerateCached(false) + @GenerateInline + public abstract static class InlineSharedNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 0") + static Object s0(Node node, int arg, + @Shared("bits") @Cached Use128BitsNode bits) { + return bits.execute(node); + } + + @Specialization(guards = "arg == 2") + static Object s1(Node node, int arg, + @Shared("bits") @Cached Use128BitsNode bits) { + return bits.execute(node); + } + + @Specialization(guards = "arg == 3") + static Object s2(Node node, int arg, + @Shared("bits") @Cached Use128BitsNode bits) { + return bits.execute(node); + } + + @Specialization(guards = "arg == 4") + static Object s3(Node node, int arg, + @Shared("bits") @Cached Use128BitsNode bits) { + return bits.execute(node); + } + + } + + @SuppressWarnings("unused") + @GenerateCached(false) + @GenerateInline + public abstract static class InlineSharedWithSpecializationClassNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 0") + static Object s0(Node node, int arg, + @Shared("innerShared") @Cached InlineInlineCache innerShared) { + return innerShared.execute(node, arg); + } + + @Specialization(guards = "arg == 1") + static Object s1(Node node, int arg, + @Shared("innerShared") @Cached InlineInlineCache innerShared, + @Cached(inline = false) InlineInlineCache innerNotInlined0, + @Cached(inline = false) InlineInlineCache innerNotInlined1, + @Cached(inline = false) InlineInlineCache innerNotInlined2, + @Cached(inline = false) InlineInlineCache innerNotInlined3, + @Cached InlineInlineCache innerRegular) { + innerRegular.execute(node, arg); + innerNotInlined0.execute(node, arg); + innerNotInlined1.execute(node, arg); + innerNotInlined2.execute(node, arg); + innerNotInlined3.execute(node, arg); + return innerShared.execute(node, arg); + } + } + + @SuppressWarnings("unused") + @GenerateInline + public abstract static class SharedNoneInlinedWithSpecializationClassNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 1") + static Object s0(Node node, int arg, + @Cached(inline = false) InlineInlineCache innerNotInlined0, + @Cached(inline = false) InlineInlineCache innerNotInlined1, + @Cached(inline = false) InlineInlineCache innerNotInlined2, + @Cached(inline = false) InlineInlineCache innerNotInlined3, + @Cached(inline = false) InlineInlineCache innerNotInlined4, + @Cached(inline = false) InlineInlineCache innerNotInlined5, + @Cached(inline = false) InlineInlineCache innerNotInlined6, + @Cached(inline = false) InlineInlineCache innerNotInlined7, + @Cached(inline = false) InlineInlineCache innerNotInlined8, + @Cached(inline = false) InlineInlineCache innerNotInlined9, + @Cached(inline = false) InlineInlineCache innerNotInlined10, + @Shared("innerShared") @Cached InlineInlineCache innerShared) { + innerShared.execute(node, 0); + return innerShared.execute(node, 1); + } + + @Specialization(guards = "arg == 2") + static Object s1(Node node, int arg, + @Cached(inline = false) InlineInlineCache innerNotInlined0, + @Cached(inline = false) InlineInlineCache innerNotInlined1, + @Cached(inline = false) InlineInlineCache innerNotInlined2, + @Cached(inline = false) InlineInlineCache innerNotInlined3, + @Shared("innerShared") @Cached InlineInlineCache innerShared) { + innerShared.execute(node, 2); + return innerShared.execute(node, 3); + } + + } + + @SuppressWarnings("unused") + @GenerateInline + public abstract static class SharedAllInlinedWithSpecializationClassNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 1") + static Object s0(Node node, int arg, + @Cached Use512BitsNode node0, + @Shared("innerShared") @Cached InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined) { + innerShared.execute(node, 0); + return innerShared.execute(node, 1); + } + + @Specialization(guards = "arg == 2") + static Object s1(Node node, int arg, + @Cached Use512BitsNode node0, + @Shared("innerShared") @Cached InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined) { + innerShared.execute(node, 2); + return innerShared.execute(node, 3); + } + + } + + @SuppressWarnings("unused") + @GenerateInline + public abstract static class SharedMixedInlinedWithSpecializationClassNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 1") + static Object s0(Node node, int arg, + @Cached Use512BitsNode node0, + @Shared("innerShared") @Cached InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined) { + innerShared.execute(node, 0); + return innerShared.execute(node, 1); + } + + @SuppressWarnings("truffle-neverdefault") + @Specialization(guards = "arg == 2") + static Object s1(Node node, int arg, + @Shared("innerShared") @Cached InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined) { + innerShared.execute(node, 2); + return innerShared.execute(node, 3); + } + + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class UseInlineSharedWithSpecializationClassNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == 1") + Object s0(int arg, + @Cached InlineSharedWithSpecializationClassNode bits, + @Shared("innerShared") @Cached(inline = true) InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined) { + bits.execute(this, 0); + return bits.execute(this, 1); + } + + @Specialization(guards = "arg == 2") + static Object s1(int arg, + @Bind("this") Node node, + @Shared("innerShared") @Cached(inline = true) InlineInlineCache innerShared, + @Shared("innerSharedPrimitive") @Cached("arg") int innerSharedPrimitive, + @Shared("innerSharedNotInlined") @Cached(inline = false) InlineInlineCache innerSharedNotInlined, + @Cached(inline = false) InlineInlineCache innerNotInlined0, + @Cached(inline = false) InlineInlineCache innerNotInlined1, + @Cached(inline = false) InlineInlineCache innerNotInlined2, + @Cached(inline = false) InlineInlineCache innerNotInlined3, + @Cached(inline = true) InlineInlineCache innerRegular) { + + innerRegular.execute(node, arg); + innerNotInlined0.execute(node, arg); + innerNotInlined1.execute(node, arg); + innerNotInlined2.execute(node, arg); + innerNotInlined3.execute(node, arg); + return innerShared.execute(node, arg); + } + + @Specialization(guards = "arg == 3") + static Object s2(int arg, + @Bind("this") Node node, + @Cached(inline = true) SharedAllInlinedWithSpecializationClassNode bits) { + + bits.execute(node, 1); + return bits.execute(node, 2); + } + + @Specialization(guards = "arg == 4") + static Object s3(int arg, + @Bind("this") Node node, + @Cached(inline = true) SharedNoneInlinedWithSpecializationClassNode bits) { + + bits.execute(node, 1); + return bits.execute(node, 2); + } + + @Specialization(guards = "arg == 5") + static Object s4(int arg, + @Bind("this") Node node, + @Cached(inline = true) SharedMixedInlinedWithSpecializationClassNode bits) { + + bits.execute(node, 1); + return bits.execute(node, 2); + } + + } + + @Test + public void testInlineSharedWithSpecializationClass() { + UseInlineSharedWithSpecializationClassNode node = adoptNode(UseInlineSharedWithSpecializationClassNodeGen.create()).get(); + node.execute(1); + node.execute(2); + node.execute(3); + node.execute(4); + node.execute(5); + } + + @SuppressWarnings("unused") + @GenerateInline + @GenerateCached(false) + public abstract static class InlinedAdoptNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == 1") + static int s0(Node node, int arg, + @Cached Use512BitsNode node0, + @Cached(inline = false, adopt = false) InlineInlineCache innerShared) { + assertNull(innerShared.getParent()); + return arg; + } + + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class UseInlinedAdoptNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == 1") + Object s0(int arg, + @Cached InlinedAdoptNode bits) { + return bits.execute(this, 1); + } + + } + + @Test + public void testAdopt() { + UseInlinedAdoptNode node = adoptNode(UseInlinedAdoptNodeGen.create()).get(); + node.execute(1); + node.execute(1); + node.execute(1); + } + + public static class InlinedInGuard extends Node { + + final StateField field; + + InlinedInGuard(InlineTarget target) { + this.field = target.getState(0, 1); + } + + boolean execute(Node node, int arg) { + field.set(node, arg); + return true; + } + + public static InlinedInGuard inline( + @RequiredField(value = StateField.class, bits = 1) InlineTarget target) { + return new InlinedInGuard(target); + } + + } + + @SuppressWarnings("unused") + @GenerateInline(false) + @Introspectable + public abstract static class UseInlinedNodeInGuard extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "guard.execute(this, arg)", limit = "1") + Object s0(int arg, @Cached InlinedInGuard guard) { + /* + * Inlined caches that are bound in guards must not be in the same state bitset as the + * dependent specialization bits. At the end of slow-path specialization we set the + * state bits of the specialization. If an inlined node in the guard changes the state + * bits we would override when we set the specialization bits. + */ + assertEquals(1, guard.field.get(this)); + return arg; + } + } + + @Test + public void testInlinedNodeInGuard() { + UseInlinedNodeInGuard node = adoptNode(UseInlinedNodeInGuardNodeGen.create()).get(); + node.execute(1); + } + + @SuppressWarnings("unused") + @GenerateInline(true) + @GenerateCached(false) + @Introspectable + public abstract static class UncachedEnculapsingNode extends Node { + + abstract boolean execute(Node node, Object arg); + + @Specialization(limit = "1") + boolean s0(Node node, Object arg, @CachedLibrary("arg") InteropLibrary interop) { + if (arg instanceof String) { + // ensure target node is pushed instead of inline singleton + assertSame(node, EncapsulatingNodeReference.getCurrent().get()); + } + return interop.isString(arg); + } + } + + @SuppressWarnings("unused") + @GenerateInline(false) + @Introspectable + public abstract static class UseUncachedEnculapsingNode extends Node { + + abstract boolean execute(Object arg); + + @Specialization + boolean s0(Object arg, @Cached UncachedEnculapsingNode node) { + return node.execute(this, arg); + } + } + + @Test + public void testUncachedEnculapsingNode() { + UseUncachedEnculapsingNode node = adoptNode(UseUncachedEnculapsingNodeGen.create()).get(); + assertFalse(node.execute(1)); + + // pushes an encapsulating node in uncached + assertTrue(node.execute("")); + } + + @SuppressWarnings("unused") + @GenerateInline(true) + @GenerateCached(false) + @Introspectable + public abstract static class NoStateNode extends Node { + + abstract String execute(Node node, Object arg); + + @Specialization + String s0(Node node, Object arg) { + return "s0"; + } + } + + @SuppressWarnings("unused") + @GenerateInline(false) + @Introspectable + public abstract static class UseNoStateNode extends Node { + + abstract String execute(Object arg); + + @Specialization + String s0(Object arg, @Cached NoStateNode node) { + return node.execute(node, arg); + } + } + + @Test + public void testNoState() { + UseNoStateNode node = adoptNode(UseNoStateNodeGen.create()).get(); + assertEquals("s0", node.execute(1)); + } + + enum EnumValue { + + S0, + S1, + S2; + + static EnumValue fromInt(int value) { + return EnumValue.values()[value]; + } + + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class WarningMultiInstanceInliningNeedsStaticNode extends Node { + + abstract Object execute(Object arg); + + @ExpectError("For this specialization with inlined cache parameters it is recommended to use the static modifier.%") + @Specialization(guards = "arg == cachedArg", limit = "3") + Object doInt(int arg, + @Bind("this") Node node, + @Cached(inline = true) SimpleNode simpleNode, + @Cached("arg") int cachedArg) { + return simpleNode.execute(node, cachedArg); + } + } + + @GenerateUncached + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class ErrorMultiInstanceInliningNeedsNode extends Node { + + abstract Object execute(Object arg); + + @ExpectError("For this specialization with inlined cache parameters a '@Bind(\"this\") Node node' parameter must be declared. %") + @Specialization(guards = "arg == cachedArg", limit = "3") + static Object doInt(int arg, + @Cached(inline = true) SimpleNode simpleNode, + @Cached("arg") int cachedArg) { + return 42; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorGenerateInlineNeedsStaticNode extends Node { + + abstract Object execute(Node node, Object arg); + + @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. %") + @Specialization + Object doInt(Node node, int arg, + @Cached SimpleNode simpleNode) { + return simpleNode.execute(node, arg); + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorGenerateInlineNeedsNeedsParameterNode extends Node { + + abstract Object execute(Node node, Object arg); + + @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. %") + @Specialization + static Object doInt(int arg, + @Cached SimpleNode simpleNode) { + return simpleNode.execute(null, arg); + } + } + + static class NoInliningNode extends Node { + static NoInliningNode create() { + return null; + } + } + + @GenerateUncached + @SuppressWarnings("unused") + public abstract static class ErrorNotInlinableNode extends Node { + + abstract Object execute(Object arg); + + @Specialization() + Object doInt(int arg, + @ExpectError("The cached node type does not support object inlining. Add @GenerateInline on the node type or disable inline using @Cached(inline=false) to resolve this.") @Cached(inline = true) NoInliningNode simpleNode) { + return ""; + } + + } + + public abstract static class BaseNode extends Node { + + abstract Object execute(); + + } + + @GenerateInline + @NodeChild + @ExpectError("Error generating code for @GenerateInline: Inlinable nodes cannot use @NodeChild. Disable inlining generation or remove @NodeChild to resolve this.") + public abstract static class ErrorUsedNodeChildNode extends BaseNode { + + @Specialization + int doDefault(int arg) { + return arg; + } + + } + + @GenerateInline + @ExpectError("Error generating code for @GenerateInline: Found non-final execute method without a node parameter execute(). " + + "Inlinable nodes must use the Node type as the first parameter after the optional frame for all non-final execute methods. " + + "A valid signature for an inlinable node is execute([VirtualFrame frame, ] Node node, ...).") + public abstract static class ErrorNoNodeNode extends Node { + + abstract Object execute(); + + abstract Object execute(Node node); + + @Specialization + int doDefault() { + return 42; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorDirectRecursionNode extends Node { + + abstract Object execute(Node node); + + @Specialization + int doDefault(Node node, + @ExpectError("Detected recursive inlined cache with type 'ErrorDirectRecursionNode'. " + + "Recursive inlining cannot be supported. Remove the recursive declaration or disable inlining with @Cached(..., inline=false) to resolve this.") // + @Cached ErrorDirectRecursionNode cachedNode) { + return 42; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorDirectRecursionDisableNode extends Node { + + abstract Object execute(Node node); + + @Specialization + static int doDefault(Node node, + // test no recursion error here if inlining is disabled. + @ExpectError("Message redirected from element GenerateInlineTest.ErrorDirectRecursionNode.doDefault(..., ErrorDirectRecursionNode cachedNode):%") // + @Cached(inline = true) ErrorDirectRecursionNode cachedNode) { + return 42; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorIndirectRecursionNode1 extends Node { + + abstract Object execute(Node node); + + @Specialization + static int doDefault(Node node, + @ExpectError("Message redirected from element GenerateInlineTest.ErrorIndirectRecursionNode2.doDefault(..., ErrorIndirectRecursionNode1 cachedNode):%")// + @Cached ErrorIndirectRecursionNode2 cachedNode) { + return 42; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorIndirectRecursionNode2 extends Node { + + abstract Object execute(Node node); + + @Specialization + static int doDefault(Node node, + @ExpectError("Message redirected from element GenerateInlineTest.ErrorIndirectRecursionNode1.doDefault(..., ErrorIndirectRecursionNode2 cachedNode):\n" + + "Detected recursive inlined cache with type 'ErrorIndirectRecursionNode2'. Recursive inlining cannot be supported. " + + "Remove the recursive declaration or disable inlining with @Cached(..., inline=false) to resolve this.") // + @Cached ErrorIndirectRecursionNode1 cachedNode) { + return 42; + } + + } + + @ExpectError("Failed to generate code for @GenerateInline: The node must not declare any instance variables. Found instance variable ErrorInstanceFieldsNode.foobar. Remove instance variable to resolve this.") + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorInstanceFieldsNode extends Node { + + private String foobar; + + abstract Object execute(Node node); + + @Specialization + static int doDefault(Node node) { + return 42; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class ErrorRedundantInliningNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization + static Object doInt(Node node, int arg, + @ExpectError("Redundant specification of @GenerateInline(... inline=true). Cached values of nodes with @Cached are implicitely inlined.") // + @Cached(inline = true) InnerNode innerNode) { + return innerNode.execute(node, arg); + } + + } + + @SuppressWarnings("unused") + @ExpectError("This node is a candidate for node object inlining.%") + public abstract static class WarningPossibleInliningNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + Object doInt(int arg, + @Cached(inline = true) InnerNode innerNode) { + return innerNode.execute(this, arg); + } + + } + + @SuppressWarnings("unused") + public abstract static class InvalidInlineMethodParameterType extends Node { + + public static Object inline() { + return null; + } + + public static InvalidInlineMethodParameterType create() { + return null; + } + + } + + @SuppressWarnings("unused") + public abstract static class InvalidInlineMethodParameterTypeNode extends Node { + + abstract void execute(); + + @Specialization + void doInt(@ExpectError("Inline method inline() is invalid. The method must have exactly one parameter of type 'InlineTarget'.") // + @Cached(inline = true) InvalidInlineMethodParameterType innerNode) { + } + + } + + @SuppressWarnings("unused") + public abstract static class InvalidInlineMethodReturnType extends Node { + + public static InvalidInlineMethodReturnType inline(Object o) { + return null; + } + + public static InvalidInlineMethodReturnType create() { + return null; + } + + } + + @SuppressWarnings("unused") + public abstract static class InvalidInlineMethodReturnTypeNode extends Node { + + abstract void execute(); + + @Specialization + void doInt( + @ExpectError("Inline method inline(Object) is invalid. The method must have exactly one parameter of type 'InlineTarget'.") // + @Cached(inline = true) InvalidInlineMethodReturnType innerNode) { + } + + } + + @ExpectError("Failed to generate code for @GenerateInline: The node must not declare any instance variables. Found instance variable ErrorNodeFieldsNode.foo. Remove instance variable to resolve this.") + @GenerateInline + public abstract static class ErrorNodeFieldsNode extends Node { + + String foo; + + abstract void execute(Node node); + + @Specialization + static void doInt() { + } + + } + + public abstract static class SuperNodeWithFields extends Node { + + String foo; + + } + + @ExpectError("Failed to generate code for @GenerateInline: The node must not declare any instance variables. Found instance variable SuperNodeWithFields.foo. Remove instance variable to resolve this.") + @GenerateInline + public abstract static class ErrorNodeFieldsInSuperNode extends SuperNodeWithFields { + + abstract void execute(Node node); + + @Specialization + static void doInt() { + } + + } + + @Test + public void testNodeAndFrame() { + VirtualFrame f = Truffle.getRuntime().createVirtualFrame(new Object[]{"42"}, new FrameDescriptor()); + PassNodeAndFrameNode inlinedNode = PassNodeAndFrameNodeGen.inline(InlineTarget.create(PassNodeAndFrameNode.class)); + inlinedNode.execute(inlinedNode, f); + } + + @GenerateInline + public abstract static class PassNodeAndFrameNode extends Node { + + abstract void execute(Node node, VirtualFrame frame); + + @Specialization + static void doInt(@SuppressWarnings("unused") Node node, @SuppressWarnings("unused") VirtualFrame frame) { + assertSame(node, node); + assertEquals("42", frame.getArguments()[0]); + + } + + } + + @GenerateInline + @GenerateCached(false) + abstract static class OnlyInlineNode extends UseStateNode { + + @Specialization + static int s0() { + return 0; + } + } + + @SuppressWarnings("unused") + @GenerateInline(false) + abstract static class SharedProfileInSpecializationClassNode extends Node { + + public abstract void execute(CompactionLevel s); + + @Specialization(guards = {"cachedCompaction ==compaction"}, limit = "2") + static void doCached(CompactionLevel compaction, + @Bind("this") Node node, + @Cached("compaction") CompactionLevel cachedCompaction, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + errorProfile.enter(node); + } + + @Specialization(replaces = "doCached") + void doUncached(CompactionLevel s, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + errorProfile.enter(this); + } + + } + + @Test + public void testSharedProfileInSpecializationClass() { + SharedProfileInSpecializationClassNode node = SharedProfileInSpecializationClassNodeGen.create(); + + node.execute(CompactionLevel.S1); + node.execute(CompactionLevel.S2); + node.execute(CompactionLevel.S4); + + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class ErrorOnlyInlineMessage1 extends UseStateNode { + + @Specialization + // automatically inlines + static int s0(@Cached OnlyInlineNode p0) { + return 0; + } + } + + @SuppressWarnings("unused") + public abstract static class ErrorOnlyInlineMessage2 extends UseStateNode { + + @Specialization + int s0(@ExpectError("Error parsing expression 'create()': The method create is undefined for the enclosing scope.") // + @Cached(inline = false) OnlyInlineNode p0) { + return 0; + } + } + + @SuppressWarnings("unused") + @GenerateInline(false) + public abstract static class ErrorOnlyInlineMessage3 extends UseStateNode { + + @Specialization + int s0(@ExpectError("Redundant specification of @Cached(... inline=true)%") // + @Cached(inline = true) OnlyInlineNode p0) { + return 0; + } + } + + /* + * Test that it does not produce the recommendation for inlining when a NodeChild is used. + */ + @SuppressWarnings("unused") + @NodeChild(type = ExecutableNode.class) + public abstract static class ErrorChildUsage extends Node { + + abstract Object execute(VirtualFrame frame); + + @Specialization + int s0(Object arg) { + return 0; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class TestFrameAndNodeCombinationsNode extends Node { + + abstract Object execute(VirtualFrame frame, Node node, int value); + + @Specialization(guards = "value == 1") + static Object s0(VirtualFrame frame, Node node, int value) { + return "s0"; + } + + @Specialization(guards = "value == 2") + static Object s1(Node node, int value) { + return "s1"; + } + + @Specialization(guards = "value == 3") + static Object s2(VirtualFrame frame, int value) { + return "s2"; + } + + @Specialization(guards = "value == 4") + static Object s3(int value) { + return "s3"; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class TestOmitNodeInOneSpecialization extends Node { + + abstract Object execute(Node node, int value); + + @Specialization(guards = "value == 1") + static Object s0(int value) { + return "s0"; + } + + @Specialization + static Object s1(Node node, int value) { + return "s0"; + } + } + + @GenerateInline + @SuppressWarnings("unused") + public abstract static class TestOmitNodeInAllSpecializations extends Node { + + abstract Object execute(Node node, int value); + + @Specialization(guards = "value == 1") + static Object s0(int value) { + return "s0"; + } + + @Specialization + static Object s1(int value) { + return "s1"; + } + } + + @GenerateInline + @GeneratePackagePrivate + public abstract static class ErrorNodeWithCustomInlineNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + // too little bit space + @SuppressWarnings("unused") + @ExpectError("The custom inline method does not specify enough bit space%") + public static ErrorNodeWithCustomInlineNode inline(@RequiredField(value = StateField.class, bits = 1) InlineTarget target) { + return null; + } + + } + + @GenerateInline + @GeneratePackagePrivate + public abstract static class ErrorNodeWithCustomInline2Node extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + // too many parameters + @SuppressWarnings("unused") + @ExpectError("The custom inline method does not specify enough bit space%") + public static ErrorNodeWithCustomInlineNode inline(@RequiredField(value = StateField.class, bits = 2) @RequiredField(value = StateField.class, bits = 1) InlineTarget target) { + return null; + } + + } + + @GenerateInline + @NodeField(name = "field", type = int.class) + @ExpectError("Error generating code for @GenerateInline: Inlinable nodes cannot use @NodeField. Disable inlining generation or remove @NodeField to resolve this.") + public abstract static class ErrorNodeNodeFieldNode extends Node { + + abstract long execute(Node node, long value); + + @SuppressWarnings("unused") + @Specialization(guards = "v >= 0") + static long doInt(long v, @Bind("field") int nodeField) { + return v; + } + + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class ErrorInvalidInlineMethod1Node extends Node { + + abstract String execute(Node node, int value); + + @Specialization + static String s0(Node node, int value, + @ExpectError("Inline method customInline() is invalid. The method must have exactly one parameter of type 'InlineTarget'.") // + @Cached(inlineMethod = "customInline") Node inlinedNnode) { + return "s0"; + } + + static Node customInline() { + return null; + } + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class ErrorInvalidInlineMethod2Node extends Node { + + abstract String execute(Node node, int value); + + @Specialization + static String s0(Node node, int value, + @ExpectError("Invalid return type java.lang.Object found but expected com.oracle.truffle.api.nodes.Node. %") // + @Cached(inlineMethod = "customInline") Node inlinedNnode) { + return "s0"; + } + + static Object customInline(InlineTarget target) { + return null; + } + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class ErrorInvalidInlineMethod3Node extends Node { + + abstract String execute(Node node, int value); + + @Specialization + static String s0(Node node, int value, + @ExpectError("Static inline method with name 'doesNotExist' and parameter type 'InlineTarget' could not be resolved. %") // + @Cached(inlineMethod = "doesNotExist") Node inlinedNnode) { + return "s0"; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GeneratePackagePrivateTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GeneratePackagePrivateTest.java index b8c114b9851a..7e2e2718a08a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GeneratePackagePrivateTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GeneratePackagePrivateTest.java @@ -49,7 +49,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class GeneratePackagePrivateTest { @GeneratePackagePrivate diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateUncachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateUncachedTest.java index 13aba325dd1a..659b16158d33 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateUncachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateUncachedTest.java @@ -44,7 +44,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; -import com.oracle.truffle.api.frame.VirtualFrame; import org.junit.Test; import com.oracle.truffle.api.Assumption; @@ -75,9 +74,10 @@ import com.oracle.truffle.api.dsl.test.GenerateUncachedTestFactory.UncachedTrivial5NodeGen; import com.oracle.truffle.api.dsl.test.GenerateUncachedTestFactory.UncachedTrivial6NodeGen; import com.oracle.truffle.api.dsl.test.GenerateUncachedTestFactory.UncachedTrivial7NodeGen; +import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class GenerateUncachedTest { @GenerateUncached @@ -85,7 +85,7 @@ abstract static class Uncached1Node extends Node { abstract Object execute(Object arg); - @Specialization(guards = "v == cachedV") + @Specialization(guards = "v == cachedV", limit = "3") static String s1(int v, @Cached("v") int cachedV) { return "s1"; } @@ -114,9 +114,10 @@ abstract static class Uncached2Node extends Node { abstract Object execute(Object arg); - @Specialization(guards = "v == cachedV") + @Specialization(guards = "v == cachedV", limit = "3") static String s1(int v, @Cached("v") int cachedV) { + return "s1"; } @@ -493,19 +494,6 @@ int nonTrivialCache(int v) { } - @GenerateUncached - abstract static class ErrorNode3 extends Node { - - abstract Object execute(Object arg); - - @ExpectError("Failed to generate code for @GenerateUncached: The specialization must declare the modifier static. Add a static modifier to the method to resolve this.") - @Specialization - int f0(int v) { - return v; - } - - } - @ExpectError("Failed to generate code for @GenerateUncached: The node must not declare any instance variables. Found instance variable ErrorNode5.guard. Remove instance variable to resolve this.") @GenerateUncached abstract static class ErrorNode5 extends Node { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenericTypeCheckTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenericTypeCheckTest.java index c060829580b3..f2a42de37778 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenericTypeCheckTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenericTypeCheckTest.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class GenericTypeCheckTest { public interface YYY { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardNodeAdoptionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardNodeAdoptionTest.java index 4e42d6ba20b3..dd87b181eeea 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardNodeAdoptionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardNodeAdoptionTest.java @@ -46,6 +46,7 @@ import org.junit.Test; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.GuardNodeAdoptionTestFactory.UseCachedNodeGen; import com.oracle.truffle.api.dsl.test.GuardNodeAdoptionTestFactory.UseNoCacheNodeGen; @@ -53,8 +54,10 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class GuardNodeAdoptionTest { + @GenerateInline(false) abstract static class GuardNode extends Node { abstract boolean execute(String argument); @@ -71,7 +74,7 @@ abstract static class UseCachedNode extends Node { abstract String execute(String argument); - @Specialization(guards = "guardNode.execute(argument)") + @Specialization(guards = "guardNode.execute(argument)", limit = "3") String s0(String argument, @Cached GuardNode guardNode) { assertNotNull(this.getRootNode()); return "cached"; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IdentityComparisonTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IdentityComparisonTest.java index 7cf1211d47f3..4812a37ed630 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IdentityComparisonTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IdentityComparisonTest.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.dsl.test.examples.ExampleTypes; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class IdentityComparisonTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java index baf3d58ffbea..f02ed93b32f9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java @@ -43,8 +43,6 @@ import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; import static org.junit.Assert.assertEquals; -import java.util.concurrent.locks.ReentrantLock; - import org.junit.Assert; import org.junit.Assume; import org.junit.Test; @@ -82,6 +80,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; +@SuppressWarnings("truffle") public class ImplicitCastTest { @TypeSystem({int.class, String.class, boolean.class}) @@ -595,19 +594,19 @@ public void testImplicitCastExecute2() { public void testImplicitCastWithCache() { TestImplicitCastWithCacheNode node = TestImplicitCastWithCacheNodeGen.create(); - Assert.assertEquals(0, node.specializeCalls); + Assert.assertEquals(0, node.specializeCount); ConcreteString concrete = new ConcreteString(); node.execute("a", true); - Assert.assertEquals(1, node.specializeCalls); + Assert.assertEquals(1, node.specializeCount); node.execute(concrete, true); - Assert.assertEquals(2, node.specializeCalls); + Assert.assertEquals(1, node.specializeCount); node.execute(concrete, true); node.execute(concrete, true); node.execute(concrete, true); // ensure we stabilize - Assert.assertEquals(2, node.specializeCalls); + Assert.assertEquals(1, node.specializeCount); } interface AbstractString { @@ -625,28 +624,17 @@ public static AbstractString toAbstractStringVector(@SuppressWarnings("unused") } @TypeSystemReference(TestTypeSystem.class) - abstract static class TestImplicitCastWithCacheNode extends Node { - - int specializeCalls; + abstract static class TestImplicitCastWithCacheNode extends SlowPathListenerNode { public abstract int execute(Object arg, boolean flag); - @Specialization(guards = {"specializeCall(flag)", "cachedFlag == flag"}) + @Specialization(guards = {"cachedFlag == flag"}) @SuppressWarnings("unused") protected static int test(AbstractString arg, boolean flag, @Cached("flag") boolean cachedFlag) { return flag ? 100 : -100; } - boolean specializeCall(@SuppressWarnings("unused") boolean flag) { - ReentrantLock lock = (ReentrantLock) getLock(); - if (lock.isHeldByCurrentThread()) { - // the lock is held for guards executed in executeAndSpecialize - specializeCalls++; - } - return true; - } - } @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGenerationTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGenerationTest.java index 82608a3c920c..99f24e4cb5a5 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGenerationTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGenerationTest.java @@ -56,6 +56,7 @@ /* * Tests that import generation generates valid code for all combinations of referring to nodes. */ +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class ImportGenerationTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java index bd0e0b3e7981..895acd3b469f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImportGuardsTest.java @@ -115,7 +115,6 @@ private static boolean privateGuard(int a) { } - @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports1' must be public.") @NodeChild("a") @ImportStatic(Imports1.class) static class ImportGuards2 extends ValueNode { @@ -129,7 +128,6 @@ static class Imports1 { } - @ExpectError("The specified import guard class 'com.oracle.truffle.api.dsl.test.ImportGuardsTest.Imports2' must be public.") @NodeChild("a") @ImportStatic(Imports2.class) static class ImportGuards3 extends ValueNode { @@ -139,7 +137,6 @@ int do1(int a) { } } - @ExpectError("The specified import guard class 'boolean' is not a declared type.") @NodeChild("a") @ImportStatic(boolean.class) static class ImportGuards4 extends ValueNode { @@ -153,7 +150,6 @@ private static class Imports2 { } - @ExpectError("At least import guard classes must be specified.") @NodeChild("a") @ImportStatic({}) static class ImportGuards5 extends ValueNode { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InlineSupportTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InlineSupportTest.java new file mode 100644 index 000000000000..025c42925d5c --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InlineSupportTest.java @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest.assertFails; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.BooleanField; +import com.oracle.truffle.api.dsl.InlineSupport.ByteField; +import com.oracle.truffle.api.dsl.InlineSupport.CharField; +import com.oracle.truffle.api.dsl.InlineSupport.DoubleField; +import com.oracle.truffle.api.dsl.InlineSupport.FloatField; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.LongField; +import com.oracle.truffle.api.dsl.InlineSupport.ShortField; +import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +public class InlineSupportTest { + + static final StateField STATE0 = StateField.create(TestNode.lookup(), "state0"); + static final StateField STATE1 = StateField.create(TestNode.lookup(), "state1"); + + private static final StateField stateField = StateField.create(TestNode.lookup(), "state"); + + private static final BooleanField booleanField = BooleanField.create(TestNode.lookup(), "bool"); + private static final ByteField byteField = ByteField.create(TestNode.lookup(), "b"); + private static final CharField charField = CharField.create(TestNode.lookup(), "c"); + private static final ShortField shortField = ShortField.create(TestNode.lookup(), "s"); + private static final IntField intField = IntField.create(TestNode.lookup(), "i"); + private static final FloatField floatField = FloatField.create(TestNode.lookup(), "f"); + private static final LongField longField = LongField.create(TestNode.lookup(), "l"); + private static final DoubleField doubleField = DoubleField.create(TestNode.lookup(), "d"); + + private static final ReferenceField referenceObjectField = ReferenceField.create(TestNode.lookup(), "refObject", Object.class); + private static final ReferenceField referenceStringField = ReferenceField.create(TestNode.lookup(), "refString", String.class); + + static final class TestNode extends Node { + static final int FIELD_COUNT = 11; + + static final Object OBJECT_VALUE_1 = new Object(); + static final String STRING_VALUE_1 = "42"; + + static final Object OBJECT_VALUE_2 = new Object(); + static final String STRING_VALUE_2 = "42"; + + int state0; + int state1; + + final int finalState = 0; + + double invalidType; + + int state = 42; + boolean bool = true; + byte b = 42; + char c = 42; + short s = 42; + int i = 42; + float f = 42.0F; + long l = 42L; + double d = 42.0D; + + Object refObject = OBJECT_VALUE_1; + String refString = STRING_VALUE_1; + + static Lookup lookup() { + return MethodHandles.lookup(); + } + + } + + @Test + public void testStateErrors() { + assertFails(() -> STATE0.set(null, 0xFFFF_FFFF), NullPointerException.class); + assertFails(() -> STATE0.set(new Node() { + }, 0xFFFF_FFFF), ClassCastException.class); + + assertFails(() -> STATE0.get(null), NullPointerException.class); + assertFails(() -> STATE0.get(new Node() { + }), ClassCastException.class); + + assertFails(() -> StateField.create(TestNode.lookup(), null), NullPointerException.class); + assertFails(() -> StateField.create(null, ""), NullPointerException.class); + assertFails(() -> StateField.create(TestNode.lookup(), "doesNotExist"), IllegalArgumentException.class); + assertFails(() -> StateField.create(TestNode.lookup(), "invalidType"), IllegalArgumentException.class); + } + + @Test + public void testStateSet() { + TestNode node = new TestNode(); + STATE0.set(node, 0xFFFF_FFFF); + assertEquals(0xFFFF_FFFF, node.state0); + + node = new TestNode(); + StateField subUpdater = STATE0.subUpdater(2, 30); + subUpdater.set(node, 0x3FFF_FFFF); + assertEquals(0xFFFF_FFFF & ~0b11, node.state0); + + node = new TestNode(); + StateField subSubUpdater = subUpdater.subUpdater(1, 29); + subSubUpdater.set(node, 0x1FFF_FFFF); + assertEquals(0xFFFF_FFFF & ~0b111, node.state0); + } + + @Test + public void testStateGet() { + TestNode node = new TestNode(); + node.state0 = 0xFFFF_FFFF; + assertEquals(0xFFFF_FFFF, STATE0.get(node)); + + node = new TestNode(); + node.state0 = 0xFFFF_FFFF; + StateField subUpdater = STATE0.subUpdater(2, 30); + assertEquals(0xFFFF_FFFF >>> 2, subUpdater.get(node)); + + node = new TestNode(); + node.state0 = 0xFFFF_FFFF; + StateField subSubUpdater = subUpdater.subUpdater(1, 29); + assertEquals(0xFFFF_FFFF >>> 3, subSubUpdater.get(node)); + } + + @SuppressWarnings("unchecked") + @Test + public void testFieldsAccess() { + TestNode node = new TestNode(); + assertTrue(stateField.get(node) == 42); + assertTrue(booleanField.get(node) == true); + assertTrue(byteField.get(node) == 42); + assertTrue(charField.get(node) == 42); + assertTrue(shortField.get(node) == 42); + assertTrue(intField.get(node) == 42); + assertTrue(floatField.get(node) == 42.f); + assertTrue(longField.get(node) == 42L); + assertTrue(doubleField.get(node) == 42.d); + assertTrue(referenceObjectField.get(node) == TestNode.OBJECT_VALUE_1); + assertTrue(referenceStringField.get(node) == TestNode.STRING_VALUE_1); + assertTrue(referenceStringField.getVolatile(node) == TestNode.STRING_VALUE_1); + + stateField.set(node, 43); + booleanField.set(node, false); + byteField.set(node, (byte) 43); + charField.set(node, (char) 43); + shortField.set(node, (short) 43); + intField.set(node, 43); + floatField.set(node, 43); + longField.set(node, 43); + doubleField.set(node, 43); + referenceObjectField.set(node, TestNode.OBJECT_VALUE_2); + referenceStringField.compareAndSet(node, TestNode.STRING_VALUE_1, TestNode.STRING_VALUE_2); + + assertTrue(stateField.get(node) == 43); + assertTrue(booleanField.get(node) == false); + assertTrue(byteField.get(node) == 43); + assertTrue(charField.get(node) == 43); + assertTrue(shortField.get(node) == 43); + assertTrue(intField.get(node) == 43); + assertTrue(floatField.get(node) == 43.f); + assertTrue(longField.get(node) == 43L); + assertTrue(doubleField.get(node) == 43.d); + assertTrue(referenceObjectField.get(node) == TestNode.OBJECT_VALUE_2); + assertTrue(referenceStringField.get(node) == TestNode.STRING_VALUE_2); + assertTrue(referenceStringField.getVolatile(node) == TestNode.STRING_VALUE_2); + } + + @SuppressWarnings("unchecked") + @Test + public void testFieldsCrashing() { + assertFails(() -> stateField.get(null), NullPointerException.class); + assertFails(() -> booleanField.get(null), NullPointerException.class); + assertFails(() -> byteField.get(null), NullPointerException.class); + assertFails(() -> charField.get(null), NullPointerException.class); + assertFails(() -> shortField.get(null), NullPointerException.class); + assertFails(() -> intField.get(null), NullPointerException.class); + assertFails(() -> floatField.get(null), NullPointerException.class); + assertFails(() -> longField.get(null), NullPointerException.class); + assertFails(() -> doubleField.get(null), NullPointerException.class); + assertFails(() -> referenceObjectField.get(null), NullPointerException.class); + assertFails(() -> referenceStringField.get(null), NullPointerException.class); + assertFails(() -> referenceStringField.getVolatile(null), NullPointerException.class); + + assertFails(() -> stateField.set(null, 42), NullPointerException.class); + assertFails(() -> booleanField.set(null, true), NullPointerException.class); + assertFails(() -> byteField.set(null, (byte) 42), NullPointerException.class); + assertFails(() -> charField.set(null, (char) 42), NullPointerException.class); + assertFails(() -> shortField.set(null, (short) 42), NullPointerException.class); + assertFails(() -> intField.set(null, 42), NullPointerException.class); + assertFails(() -> floatField.set(null, 42), NullPointerException.class); + assertFails(() -> longField.set(null, 42), NullPointerException.class); + assertFails(() -> doubleField.set(null, 42), NullPointerException.class); + assertFails(() -> referenceObjectField.set(null, TestNode.OBJECT_VALUE_2), NullPointerException.class); + assertFails(() -> referenceStringField.set(null, TestNode.STRING_VALUE_2), NullPointerException.class); + assertFails(() -> referenceStringField.compareAndSet(null, TestNode.STRING_VALUE_2, TestNode.STRING_VALUE_2), NullPointerException.class); + + Node node = new Node() { + }; + assertFails(() -> stateField.get(node), ClassCastException.class); + assertFails(() -> booleanField.get(node), ClassCastException.class); + assertFails(() -> byteField.get(node), ClassCastException.class); + assertFails(() -> charField.get(node), ClassCastException.class); + assertFails(() -> shortField.get(node), ClassCastException.class); + assertFails(() -> intField.get(node), ClassCastException.class); + assertFails(() -> floatField.get(node), ClassCastException.class); + assertFails(() -> longField.get(node), ClassCastException.class); + assertFails(() -> doubleField.get(node), ClassCastException.class); + assertFails(() -> referenceObjectField.get(node), ClassCastException.class); + assertFails(() -> referenceStringField.get(node), ClassCastException.class); + assertFails(() -> referenceStringField.getVolatile(node), ClassCastException.class); + + assertFails(() -> stateField.set(node, 42), ClassCastException.class); + assertFails(() -> booleanField.set(node, true), ClassCastException.class); + assertFails(() -> byteField.set(node, (byte) 42), ClassCastException.class); + assertFails(() -> charField.set(node, (char) 42), ClassCastException.class); + assertFails(() -> shortField.set(node, (short) 42), ClassCastException.class); + assertFails(() -> intField.set(node, 42), ClassCastException.class); + assertFails(() -> floatField.set(node, 42), ClassCastException.class); + assertFails(() -> longField.set(node, 42), ClassCastException.class); + assertFails(() -> doubleField.set(node, 42), ClassCastException.class); + assertFails(() -> referenceObjectField.set(node, TestNode.OBJECT_VALUE_2), ClassCastException.class); + assertFails(() -> referenceStringField.set(node, TestNode.STRING_VALUE_2), ClassCastException.class); + assertFails(() -> referenceStringField.compareAndSet(node, TestNode.STRING_VALUE_2, TestNode.STRING_VALUE_2), ClassCastException.class); + + TestNode test = new TestNode(); + assertFails(() -> ((ReferenceField) (ReferenceField) referenceStringField).set(test, 42), IllegalArgumentException.class); + } + + @Test + public void testInlineTarget() { + assertFails(() -> InlineTarget.create(TestNode.class, null, null), NullPointerException.class); + assertFails(() -> InlineTarget.create(TestNode.class, (InlinableField[]) null), NullPointerException.class); + StateField subUpdater = stateField.subUpdater(1, 3); + InlineTarget target = InlineTarget.create(TestNode.class, stateField, charField, referenceStringField, subUpdater); + final int outOfBoundsIndex = 4; + + assertSame(stateField, target.getState(0, 32)); + assertSame(subUpdater, target.getState(3, 3)); + assertSame(stateField, target.getState(0, 1)); + assertSame(subUpdater, target.getState(3, 1)); + assertFails(() -> target.getState(outOfBoundsIndex, 1), IncompatibleClassChangeError.class); + assertFails(() -> target.getState(3, 4), IncompatibleClassChangeError.class); + assertFails(() -> target.getState(3, 32), IncompatibleClassChangeError.class); + + assertFails(() -> target.getState(-1, 1), ArrayIndexOutOfBoundsException.class); + assertFails(() -> target.getState(0, 33), IllegalArgumentException.class); + assertFails(() -> target.getState(0, 0), IllegalArgumentException.class); + + assertSame(charField, target.getPrimitive(1, CharField.class)); + assertFails(() -> target.getPrimitive(outOfBoundsIndex, CharField.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getPrimitive(1, IntField.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getPrimitive(0, IntField.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getPrimitive(1, ReferenceField.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getPrimitive(1, ReferenceField.class), IncompatibleClassChangeError.class); + + assertFails(() -> target.getPrimitive(-1, IntField.class), ArrayIndexOutOfBoundsException.class); + assertFails(() -> target.getPrimitive(1, null), NullPointerException.class); + + assertSame(referenceStringField, target.getReference(2, String.class)); + assertFails(() -> target.getReference(outOfBoundsIndex, String.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getReference(1, String.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getReference(0, String.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getReference(2, Object.class), IncompatibleClassChangeError.class); + assertFails(() -> target.getReference(2, Integer.class), IncompatibleClassChangeError.class); + + assertFails(() -> target.getReference(-1, String.class), ArrayIndexOutOfBoundsException.class); + assertFails(() -> target.getReference(1, null), NullPointerException.class); + + } + + @Test + public void testSubUpdater() { + StateField all = stateField.subUpdater(0, 2); + StateField first = all.subUpdater(0, 1); + StateField second = all.subUpdater(1, 1); + + TestNode node = new TestNode(); + all.set(node, 0b11); + + assertEquals(0b1, first.get(node)); + assertEquals(0b1, second.get(node)); + + all.set(node, 0b00); + first.set(node, 0b1); + second.set(node, 0b1); + + assertEquals(0b11, all.get(node)); + + // only if assertions are enabled + assertFails(() -> all.set(node, 0b111), IllegalArgumentException.class, (e) -> { + assertEquals("Bits lost in masked state updater set. Provided bits: 0x7 Written bits: 0x3. This could indicate a bug in subUpdater indices in the node object inlining logic.", + e.getMessage()); + }); + + assertSame(all, all.subUpdater(0, 2)); + assertSame(first, first.subUpdater(0, 1)); + + assertFails(() -> all.subUpdater(-1, 2), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(0, 3), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(1, 2), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(2, 1), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(3, 0), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(2, 0), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(1, 0), IllegalArgumentException.class); + assertFails(() -> all.subUpdater(0, 0), IllegalArgumentException.class); + + } + + @Test + public void testValidate() { + stateField.validate(new TestNode()); + charField.validate(new TestNode()); + referenceStringField.validate(new TestNode()); + + assertFails(() -> stateField.validate(null), NullPointerException.class); + assertFails(() -> charField.validate(null), NullPointerException.class); + assertFails(() -> referenceStringField.validate(null), NullPointerException.class); + + Node node = new Node() { + }; + assertFails(() -> stateField.validate(node), ClassCastException.class); + assertFails(() -> charField.validate(node), ClassCastException.class); + assertFails(() -> referenceStringField.validate(node), ClassCastException.class); + } + + static class ParentUpdaterNode extends Node { + } + + @Test + public void testParentUpdater() { + TestNode node = new TestNode(); + ParentUpdaterNode updater = node.insert(new ParentUpdaterNode()); + Node otherNode = new Node() { + }; + + StateField parentState = stateField.createParentAccessor(ParentUpdaterNode.class); + assertEquals(42, parentState.get(updater)); + parentState.set(updater, 43); + assertEquals(43, parentState.get(updater)); + + assertFails(() -> parentState.get(null), NullPointerException.class); + assertFails(() -> parentState.get(node), ClassCastException.class, (e) -> { + assertEquals("Invalid parameter type passed to updater. Instance of type 'InlineSupportTest.ParentUpdaterNode' expected but was 'InlineSupportTest.TestNode'. " + + "Did you pass the wrong node to an execute method of an inlined cached node?", e.getMessage()); + }); + assertFails(() -> parentState.get(otherNode), ClassCastException.class); + + assertFails(() -> parentState.set(null, 42), NullPointerException.class); + assertFails(() -> parentState.set(node, 42), ClassCastException.class); + assertFails(() -> parentState.set(otherNode, 42), ClassCastException.class); + assertEquals(43, parentState.get(updater)); + + IntField parentInt = intField.createParentAccessor(ParentUpdaterNode.class); + assertEquals(42, parentInt.get(updater)); + parentInt.set(updater, 43); + assertEquals(43, parentInt.get(updater)); + + assertFails(() -> parentInt.get(null), NullPointerException.class); + assertFails(() -> parentInt.get(node), ClassCastException.class, (e) -> { + assertEquals("Invalid parameter type passed to updater. Instance of type 'InlineSupportTest.ParentUpdaterNode' expected but was 'InlineSupportTest.TestNode'. " + + "Did you pass the wrong node to an execute method of an inlined cached node?", e.getMessage()); + }); + assertFails(() -> parentInt.get(otherNode), ClassCastException.class); + + assertFails(() -> parentInt.set(null, 42), NullPointerException.class); + assertFails(() -> parentInt.set(node, 42), ClassCastException.class); + assertFails(() -> parentInt.set(otherNode, 42), ClassCastException.class); + assertEquals(43, parentInt.get(updater)); + + ReferenceField parentString = referenceStringField.createParentAccessor(ParentUpdaterNode.class); + assertEquals("42", parentString.get(updater)); + parentString.set(updater, "43"); + assertEquals("43", parentString.get(updater)); + + assertFails(() -> parentString.get(null), NullPointerException.class); + assertFails(() -> parentString.get(node), ClassCastException.class, (e) -> { + assertEquals("Invalid parameter type passed to updater. Instance of type 'InlineSupportTest.ParentUpdaterNode' expected but was 'InlineSupportTest.TestNode'. " + + "Did you pass the wrong node to an execute method of an inlined cached node?", e.getMessage()); + }); + assertFails(() -> parentString.get(otherNode), ClassCastException.class); + + assertFails(() -> parentString.set(null, "42"), NullPointerException.class); + assertFails(() -> parentString.set(node, "42"), ClassCastException.class); + assertFails(() -> parentString.set(otherNode, "42"), ClassCastException.class); + assertEquals("43", parentString.get(updater)); + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java index 36f5c0d3ba24..9c8f65c49309 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.dsl.test.otherPackage.OtherPackageNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class InsertBeforeTest { @NodeChild("a") diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntrospectionTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntrospectionTest.java index 3077440f690c..8922c8cb77da 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntrospectionTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntrospectionTest.java @@ -63,6 +63,7 @@ import com.oracle.truffle.api.dsl.test.IntrospectionTestFactory.TrivialNodeGen; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings("truffle") public class IntrospectionTest { @TypeSystem diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java index a12e4a238feb..d5149581859c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LimitTest.java @@ -75,7 +75,7 @@ public void testDefaultLimit3() { @NodeChild static class DefaultLimit3Test extends ValueNode { - @Specialization(guards = "value == cachedValue") + @Specialization(guards = "value == cachedValue", limit = "3") static int do1(int value, @Cached("value") int cachedValue) { return cachedValue; } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java index a564552b876e..3067fde9d823 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsWithArgumentsTest.java @@ -59,6 +59,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class MethodGuardsWithArgumentsTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NameDuplicationTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NameDuplicationTest.java index 00c541eb4657..95d532e22a2b 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NameDuplicationTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NameDuplicationTest.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class NameDuplicationTest { @NodeChild diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java index 25c41d3bc714..7f0879d12a39 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java @@ -51,6 +51,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class NegatedGuardsTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java new file mode 100644 index 000000000000..b309a13d2a07 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -0,0 +1,1109 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.function.Supplier; + +import org.junit.Test; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Introspectable; +import com.oracle.truffle.api.dsl.Introspection; +import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.CachedReachableFallbackTest.GuardNode; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.CachedGuardAndFallbackNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.FallbackManyCachesNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.GuardCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.MultiInstanceCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.MultiInstanceNodeCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt1NodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt2NodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt3NodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.ReplaceThisNoCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.ReplaceThisNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedDefaultInlinedNodeNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedDefaultIntNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedDefaultNodeNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedDefaultObjectNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedNeverDefaultInlinedNodeNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedNeverDefaultIntNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedNeverDefaultNodeNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedNeverDefaultObjectNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SingleInstanceAssumptionNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SingleInstanceNodeCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SingleInstancePrimitiveCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseMultiInstanceNodeCacheNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseSharedDefaultInlinedNodeNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseSharedNeverDefaultInlinedNodeNodeGen; +import com.oracle.truffle.api.nodes.ControlFlowException; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +/** + * Tests the never default behavior of shared caches and caches without generated specialization + * class. In order to use lock free caching, we need to make sure we do not trigger the + * specialization with a default value. Hence we assert for not zero or null in that case. + */ +@SuppressWarnings({"truffle-inlining", "truffle-sharing"}) +public class NeverDefaultTest extends AbstractPolyglotTest { + + abstract static class TestNode extends Node { + + abstract int execute(int argument); + + } + + abstract static class SharedDefaultIntNode extends TestNode { + + @Specialization(guards = "value == cachedValue", limit = "1") + int s0(int value, + @Shared("a") @Cached(value = "value", neverDefault = false) int cachedValue, + @Cached(value = "value", neverDefault = false) int notShared) { + assertNotEquals(0, cachedValue); + assertNotEquals(0, notShared); + return value; + } + + @Specialization + int s1(int value, + @Shared("a") @Cached(value = "value", neverDefault = false) int cachedValue, + @Cached(value = "value", neverDefault = false) int notShared) { + assertNotEquals(0, cachedValue); + assertNotEquals(0, notShared); + return value; + } + } + + abstract static class SharedNeverDefaultIntNode extends TestNode { + + @Specialization(guards = "value == cachedValue", limit = "1") + int s0(int value, + @Shared("a") @Cached(value = "value", neverDefault = true) int cachedValue, + @Cached(value = "value", neverDefault = true) int notShared) { + assertNotEquals(0, cachedValue); + assertNotEquals(0, notShared); + return value; + } + + @Specialization + int s1(int value, + @Shared("a") @Cached(value = "value", neverDefault = true) int cachedValue, + @Cached(value = "value", neverDefault = true) int notShared) { + assertNotEquals(0, cachedValue); + assertNotEquals(0, notShared); + return value; + } + + } + + @Test + public void testSharedDefaultIntNode() throws InterruptedException { + assertInParallel(SharedDefaultIntNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 3 + 1); + }); + + assertInParallel(SharedNeverDefaultIntNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 3 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class SharedDefaultObjectNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false) Object cachedValue) { + assertEquals("42", cachedValue); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false) Object cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertEquals("42", cachedValue); + return value; + } + + @SuppressWarnings("unused") + static Object fromInt(int intValue) { + return "42"; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class SharedNeverDefaultObjectNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached("fromInt(value)") Object cachedValue) { + assertEquals("42", cachedValue); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached("fromInt(value)") Object cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertEquals("42", cachedValue); + return value; + } + + @SuppressWarnings("unused") + @NeverDefault + static Object fromInt(int intValue) { + return "42"; + } + + } + + @Test + public void testSharedDefaultObjectNode() throws InterruptedException { + assertInParallel(SharedDefaultObjectNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + + assertInParallel(SharedNeverDefaultObjectNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class SharedDefaultNodeNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false) Node cachedValue) { + assertNotNull(cachedValue.getParent()); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false) Node cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertNotNull(cachedValue.getParent()); + return value; + } + + @SuppressWarnings("unused") + static Node fromInt(int intValue) { + return SharedDefaultNodeNodeGen.create(); + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class SharedNeverDefaultNodeNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached("fromInt(value)") Node cachedValue) { + assertNotNull(cachedValue.getParent()); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached("fromInt(value)") Node cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertNotNull(cachedValue.getParent()); + return value; + } + + @SuppressWarnings("unused") + @NeverDefault + static Node fromInt(int intValue) { + return SharedNeverDefaultNodeNodeGen.create(); + } + + } + + @Test + public void testSharedDefaultNodeNode() throws InterruptedException { + assertInParallel(SharedNeverDefaultNodeNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + + assertInParallel(SharedDefaultNodeNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @GenerateInline + abstract static class SharedDefaultInlinedNodeNode extends Node { + + abstract Object execute(Node node, Object value); + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false, inline = false) SharedDefaultInlinedNodeNode cachedValue) { + assertNotNull(cachedValue.getParent()); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = false, inline = false) SharedDefaultInlinedNodeNode cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertNotNull(cachedValue.getParent()); + return value; + } + + @SuppressWarnings("unused") + static SharedDefaultInlinedNodeNode fromInt(int intValue) { + return SharedDefaultInlinedNodeNodeGen.create(); + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class UseSharedDefaultInlinedNodeNode extends TestNode { + + @Specialization + int s0(int value, @Cached SharedDefaultInlinedNodeNode cachedValue) { + cachedValue.execute(this, value); + return value; + } + + } + + @GenerateInline + abstract static class SharedNeverDefaultInlinedNodeNode extends Node { + + abstract Object execute(Node node, Object value); + + @Specialization(guards = "value == 1") + int s0(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = true, inline = false) SharedNeverDefaultInlinedNodeNode cachedValue) { + assertNotNull(cachedValue.getParent()); + return value; + } + + @Specialization + int s1(int value, @Shared("a") @Cached(value = "fromInt(value)", neverDefault = true, inline = false) SharedNeverDefaultInlinedNodeNode cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertNotNull(cachedValue.getParent()); + return value; + } + + @SuppressWarnings("unused") + static SharedNeverDefaultInlinedNodeNode fromInt(int intValue) { + return SharedNeverDefaultInlinedNodeNodeGen.create(); + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class UseSharedNeverDefaultInlinedNodeNode extends TestNode { + + @Specialization + int s0(int value, @Cached SharedNeverDefaultInlinedNodeNode cachedValue) { + cachedValue.execute(this, value); + return value; + } + + } + + @Test + public void testInlinedSharedDefaultNodeNode() throws InterruptedException { + assertInParallel(UseSharedDefaultInlinedNodeNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + + assertInParallel(UseSharedNeverDefaultInlinedNodeNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultInt1Node extends Node { + + abstract int execute(Object argument); + + @Specialization + int s0(int value, @Cached(value = "value", neverDefault = true) int cachedValue) { + assertNotEquals(0, cachedValue); + return value; + } + + } + + @Test + public void testNeverDefaultInt1Node() throws InterruptedException { + assertInParallel(NeverDefaultInt1NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultInt2Node extends Node { + + abstract int execute(Object argument); + + @Specialization + int s0(int value, @Cached(value = "value", neverDefault = true) int cachedValue1, + @Cached(value = "value", neverDefault = true) int cachedValue2) { + assertNotEquals(0, cachedValue1); + assertNotEquals(0, cachedValue2); + return value; + } + + } + + @Test + public void testNeverDefaultInt2Node() throws InterruptedException { + assertInParallel(NeverDefaultInt2NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultInt3Node extends Node { + + abstract int execute(Object argument); + + /* + * Triggers a specialization class, so there is an implicit null check. + */ + @Specialization + @SuppressWarnings("truffle") // never default warning + int s0(int value, @Cached("value") int cachedValue1, + @Cached("value") int cachedValue2, + @Cached("value") int cachedValue3) { + assertNotEquals(0, cachedValue1); + assertNotEquals(0, cachedValue2); + assertNotEquals(0, cachedValue3); + return value; + } + + } + + @Test + public void testNeverDefaultInt3Node() throws InterruptedException { + assertInParallel(NeverDefaultInt3NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2 + 1); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultObject1Node extends Node { + + abstract int execute(int argument); + + @Specialization + int s0(int value, @Cached(value = "fromInt(value)", neverDefault = true) Object cachedValue) { + assertEquals("42", cachedValue); + return value; + } + + @SuppressWarnings("unused") + static Object fromInt(int intValue) { + return "42"; + } + + } + + @Test + public void testNeverDefaultObject1Node() throws InterruptedException { + assertInParallel(NeverDefaultInt1NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultObject2Node extends Node { + + abstract int execute(int argument); + + @Specialization + int s0(int value, @Cached(value = "fromInt(value)", neverDefault = true) Object cachedValue1, + @Cached(value = "fromInt(value)", neverDefault = true) Object cachedValue2) { + assertEquals("42", cachedValue1); + assertEquals("42", cachedValue2); + return value; + } + + @SuppressWarnings("unused") + static Object fromInt(int intValue) { + return "42"; + } + + } + + @Test + public void testNeverDefaultObject2Node() throws InterruptedException { + assertInParallel(NeverDefaultInt2NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultObject3Node extends Node { + + abstract int execute(int argument); + + @Specialization + @SuppressWarnings("truffle") // never default warning + int s0(int value, @Cached("fromInt(value)") Object cachedValue1, + @Cached("fromInt(value)") Object cachedValue2, + @Cached("fromInt(value)") Object cachedValue3) { + assertEquals("42", cachedValue1); + assertEquals("42", cachedValue2); + assertEquals("42", cachedValue3); + return value; + } + + @SuppressWarnings("unused") + static Object fromInt(int intValue) { + return "42"; + } + + } + + @Test + public void testNeverDefaultObject3Node() throws InterruptedException { + assertInParallel(NeverDefaultInt3NodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex); + }); + } + + @GenerateInline(inherit = true) + @Introspectable + abstract static class InlinableTestNode extends Node { + + abstract int execute(Node node, int argument); + + } + + abstract static class MultipleInstanceAssumptionCacheNode extends InlinableTestNode { + + @SuppressWarnings("unused") + @Specialization(guards = "value == cachedValue", limit = "3", assumptions = "a") + int s0(int value, @Cached("value") int cachedValue, + @Cached Assumption a, + @Cached(inline = false) CachedNode cachedNode) { + assertNotEquals(0, cachedValue); + assertEquals(this, cachedNode.getParent()); + return value; + } + + } + + @Test + public void testMultipleInstanceAssumptionCacheNode() throws InterruptedException { + assertInParallel(SingleInstanceAssumptionNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex % 3 + 1); + if (objectIndex == THREADS / 2) { + // invalidate once in between + SpecializationInfo info = Introspection.getSpecialization(node, "s0"); + if (info.getInstances() > 0) { + List cacheData = info.getCachedData(threadIndex % info.getInstances()); + if (!cacheData.isEmpty()) { + ((Assumption) cacheData.get(0)).invalidate(); + } + } + } + }); + } + + @GenerateInline + @Introspectable + abstract static class SingleInstanceAssumptionNode extends InlinableTestNode { + + @Specialization(assumptions = "cachedAssumption") + int s0(int value, @Cached(neverDefault = false) Assumption cachedAssumption) { + assertNotNull(cachedAssumption); + return value; + } + + } + + @Test + public void testSingleInstanceAssumptionNode() throws InterruptedException { + assertInParallel(SingleInstanceAssumptionNodeGen::create, (node, threadIndex, objectIndex) -> { + if (objectIndex == THREADS / 2) { + // invalidate once in between + SpecializationInfo info = Introspection.getSpecialization(node, "s0"); + if (info.getInstances() > 0) { + List cacheData = info.getCachedData(threadIndex % info.getInstances()); + if (!cacheData.isEmpty()) { + ((Assumption) cacheData.get(0)).invalidate(); + } + } + } + node.execute(node, threadIndex % 3 + 1); + }); + } + + @GenerateInline + abstract static class MultiInstanceCacheNode extends InlinableTestNode { + + @Specialization(guards = "value == cachedValue", limit = "3") + int s0(int value, @Cached("value") int cachedValue) { + assertNotEquals(0, cachedValue); + return value; + } + } + + @Test + public void testMultiInstanceCacheNode() throws InterruptedException { + assertInParallel(MultiInstanceCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex % 3 + 1); + }); + } + + abstract static class CachedNode extends InlinableTestNode { + + @Specialization + int s0(int value) { + return value; + } + } + + @SuppressWarnings("unused") + abstract static class MultiInstanceNodeCacheNode extends InlinableTestNode { + + @Specialization(guards = "value == cachedValue", limit = "3") + static int s0(Node node, int value, @Cached("value") int cachedValue, + @Cached(inline = false) CachedNode cachedNode) { + assertNotEquals(0, cachedValue); + assertNotNull(node); + assertEquals(node, cachedNode.getParent()); + cachedNode.execute(node, 42); + return value; + } + } + + @Test + public void testMultiInstanceNodeCacheNode() throws InterruptedException { + assertInParallel(MultiInstanceNodeCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex % 3 + 1); + }); + } + + @SuppressWarnings("unused") + abstract static class UseMultiInstanceNodeCacheNode extends InlinableTestNode { + + @Specialization + static int s0(Node node, int value, @Cached MultiInstanceNodeCacheNode cachedNode) { + assertNotNull(node); + return cachedNode.execute(node, 42); + } + } + + @Test + public void testUseMultiInstanceNodeCacheNode() throws InterruptedException { + assertInParallel(UseMultiInstanceNodeCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex % 3 + 1); + }); + } + + @GenerateInline + abstract static class SingleInstancePrimitiveCacheNode extends InlinableTestNode { + + @Specialization(guards = "value == cachedValue", limit = "1") + int s0(int value, @Cached(value = "value", neverDefault = true) int cachedValue) { + assertNotEquals(0, cachedValue); + return value; + } + + } + + @Test + public void testSingleInstancePrimitiveCacheNode() throws InterruptedException { + assertInParallel(SingleInstancePrimitiveCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, 1); + }); + + SingleInstancePrimitiveCacheNode node = adoptNode(SingleInstancePrimitiveCacheNodeGen.create()).get(); + assertFails(() -> node.execute(null, 0), IllegalStateException.class, (e) -> { + assertEquals("Specialization 's0(int, int)' cache 'cachedValue' returned a '0' default value. The cache initializer must never return a default value for this cache. " + + "Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns '0'.", + e.getMessage()); + }); + } + + @SuppressWarnings("truffle-inlining") + abstract static class GuardCacheNode extends Node { + + abstract boolean execute(int argument); + + @Specialization + boolean s0(int value) { + return value == 1; + } + + static volatile boolean returnNull = false; + + static GuardCacheNode create() { + if (returnNull) { + return null; + } + return GuardCacheNodeGen.create(); + } + + } + + @GenerateInline + abstract static class SingleInstanceNodeCacheNode extends InlinableTestNode { + + @Specialization(guards = {"value == 1"}) + int s0(int value, @Cached(inline = false) GuardCacheNode cachedNode) { + assertNotNull(cachedNode); + assertTrue(cachedNode.execute(value)); + return value; + } + + } + + @Test + public void testSingleInstanceNodeCacheNode() throws InterruptedException { + GuardCacheNode.returnNull = false; + assertInParallel(SingleInstanceNodeCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, 1); + }); + + SingleInstanceNodeCacheNode node = adoptNode(SingleInstanceNodeCacheNodeGen.create()).get(); + node.execute(node, 1); + + SingleInstanceNodeCacheNode returnNull = adoptNode(SingleInstanceNodeCacheNodeGen.create()).get(); + GuardCacheNode.returnNull = true; + assertFails(() -> returnNull.execute(null, 1), IllegalStateException.class, (e) -> { + assertEquals("Specialization 's0(int, GuardCacheNode)' cache 'cachedNode' returned a 'null' default value. " + + "The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns 'null'.", + e.getMessage()); + }); + GuardCacheNode.returnNull = false; + } + + @GenerateInline + @Introspectable + abstract static class ReplaceThisNode extends InlinableTestNode { + + @Specialization(guards = "value == cachedValue", limit = "3", rewriteOn = ControlFlowException.class) + int s0(int value, @Cached("value") int cachedValue) throws ControlFlowException { + assertNotEquals(0, cachedValue); + if (cachedValue == 2) { + throw new ControlFlowException(); + } + return value; + } + + @Specialization + int s1(int value) { + return value; + } + + } + + @Test + public void testReplaceThisNode() throws InterruptedException { + assertInParallel(ReplaceThisNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex); + }); + } + + @GenerateInline + abstract static class ReplaceThisNoCacheNode extends InlinableTestNode { + + @Specialization(rewriteOn = ControlFlowException.class) + int s0(int value) throws ControlFlowException { + if (value == 2) { + throw new ControlFlowException(); + } + return value; + } + + @Specialization + int s1(int value) { + return value; + } + + } + + @Test + public void testReplaceThisNoCacheNode() throws InterruptedException { + assertInParallel(ReplaceThisNoCacheNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(node, threadIndex); + }); + } + + /* + * This test triggers multiple guards bits with the fallback + */ + @SuppressWarnings("truffle-inlining") + abstract static class FallbackManyCachesNode extends Node { + + abstract int execute(int argument); + + @Specialization(guards = {"guardNode1.execute(obj)", "guardNode2.execute(obj)", "guardNode3.execute(obj)"}, limit = "1") + protected int s1(@SuppressWarnings("unused") int obj, + @Exclusive @Cached GuardCacheNode guardNode1, + @Exclusive @Cached GuardCacheNode guardNode2, + @Exclusive @Cached GuardCacheNode guardNode3, + @Exclusive @Cached GuardCacheNode unboundGuard) { + assertNotNull(guardNode1); + assertNotNull(guardNode2); + assertNotNull(guardNode3); + assertNotNull(unboundGuard); + return 0; + } + + @Fallback + protected int fallback(@SuppressWarnings("unused") int x) { + return 1; + } + + static GuardNode createGuard() { + return new GuardNode(); + } + } + + @Test + public void testFallbackManyCachesNode() throws InterruptedException { + assertInParallel(FallbackManyCachesNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex); + }); + } + + @SuppressWarnings("unused") + public abstract static class InnerGuardNode extends Node { + + abstract boolean execute(int value); + + @Specialization(guards = "value == 0") + protected boolean s0(int value) { + return true; + } + + @Specialization(guards = "value == 1") + protected boolean s1(int value) { + return false; + } + } + + public abstract static class RegularNode extends Node { + + abstract int execute(int value); + + @Specialization + protected int s1(int value) { + return value + 1; + } + + } + + /* + * Tests special race discovered in JSRegExpExecIntlNode. + */ + @SuppressWarnings("unused") + public abstract static class CachedGuardAndFallbackNode extends Node { + + abstract String execute(Object thisObject); + + @SuppressWarnings("truffle-unused") + @Specialization(guards = {"guardNode1.execute(arg)", "guardNode2.execute(arg)"}, limit = "1") + protected String s0(int arg, + @Cached InnerGuardNode guardNode1, + @Cached InnerGuardNode guardNode2, + @Cached(neverDefault = false) RegularNode regularNode) { + // this may be null if the cache guard is partially initialized + assertNotNull(guardNode1); + assertNotNull(guardNode2); + assertNotNull(regularNode); + return "s0"; + } + + @Fallback + protected String fallback(Object thisNonObj) { + return "fallback"; + } + + } + + @Test + public void testCachedGuardAndFallbackNode() throws InterruptedException { + assertInParallel(CachedGuardAndFallbackNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2); + }); + } + + static final int NODES = 10; + static final int THREADS = 10; + + private void assertInParallel(Supplier nodeFactory, ParallelObjectConsumer assertions) throws InterruptedException { + final int threads = THREADS; + final int threadPools = 2; + final int iterations = 1000; + /* + * We create multiple nodes and run the assertions in a loop to avoid implicit + * synchronization through the synchronization primitives when running the assertions just + * for a single node. + */ + final int nodesCount = NODES; + assertNodeInParallel(nodeFactory, assertions, threadPools, threads, iterations, nodesCount); + } + + @SuppressWarnings("truffle-inlining") + abstract static class WarningNeverDefaultForSharedCachesNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, + @ExpectError("It is recommended to set the @Cached(neverDefault=true|false) property for this cache expression%") // + @Shared("a") @Cached(value = "value") int cachedValue) { + assertNotEquals(0, cachedValue); + return value; + } + + @Specialization + int s1(int value, + @ExpectError("It is recommended to set the @Cached(neverDefault=true|false) property for this cache expression%") // + @Shared("a") @Cached("value") int cachedValue) { + /* + * The invariant is that the cached values are never 0. + */ + assertNotEquals(0, cachedValue); + return value; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class WarningNeverSharedBeneficial1Node extends Node { + + abstract long execute(Object argument); + + @Specialization(guards = "value == 1") + @SuppressWarnings("unused") + long s1(long value, + @ExpectError("It is recommended to set the @Cached(neverDefault=true|false) property for this cache expression to allow the DSL to further optimize the generated layout of this node%") // + @Cached("value") long cachedValue0) { + return value; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class WarningNeverSharedBeneficial2Node extends Node { + + abstract int execute(Object argument); + + @Specialization + int s0(int value, + @ExpectError("It is recommended to set the @Cached(neverDefault=true|false) property for this cache expression to allow the DSL to further optimize the generated layout of this node%") // + @Cached("value") int cachedValue1, + @ExpectError("It is recommended to set the @Cached(neverDefault=true|false) property for this cache expression to allow the DSL to further optimize the generated layout of this node%") // + @Cached("value") int cachedValue2) { + assertNotEquals(0, cachedValue1); + assertNotEquals(0, cachedValue2); + return value; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class WarningNeverSharedBeneficial3Node extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization(guards = "value == 1") + int s0(int value, + // three fields generates a specialization class, so no warning needed. + @Cached SharedDefaultIntNode cachedValue1, + @Cached SharedDefaultIntNode cachedValue2, + @Cached(value = "value") int cachedValue3, + @Cached(value = "value") int cachedValue4, + @Cached(value = "value") int cachedValue5, + @ExpectError("The @Cached(neverDefault=true|false) property is not needed to be set. %") // + @Cached(value = "value", neverDefault = true) int cachedValue0) { + return value; + } + + @Specialization(guards = "value == 2") + int s2(int value) { + return value; + } + + @Specialization(guards = "value == 3") + int s3(int value) { + return value; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultGuaranteedAnnotationMethod extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + @ExpectError("The @Cached(neverDefault=true|false) property is guaranteed or implied by the initializer expression.%") // + @Cached(value = "neverDefault(value)", neverDefault = true) int cachedValue0) { + assertNotEquals(0, cachedValue0); + return cachedValue0; + } + + @NeverDefault + int neverDefault(int v) { + return v; + } + + } + + abstract static class NeverDefaultGuaranteedAnnotationField extends Node { + + @NeverDefault int neverDefault = 42; + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + @ExpectError("The @Cached(neverDefault=true|false) property is guaranteed or implied by the initializer expression.%") // + @Cached(value = "neverDefault", neverDefault = true) int cachedValue0) { + assertNotEquals(0, cachedValue0); + return cachedValue0; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultGuaranteedConstant1 extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + @ExpectError("The @Cached(neverDefault=true|false) property is guaranteed or implied by the initializer expression.%") // + @Cached(value = "42", neverDefault = true) int cachedValue) { + return cachedValue; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultGuaranteedConstant2 extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + // constant 0 needs a default value + @Cached(value = "0", neverDefault = true) int cachedValue) { + return cachedValue; + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultGuaranteedConstructor extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + @ExpectError("The @Cached(neverDefault=true|false) property is guaranteed or implied by the initializer expression.%") // + @Cached(value = "new()", neverDefault = true) MyObject cached) { + return value; + } + + static class MyObject { + + } + + } + + @SuppressWarnings("truffle-inlining") + abstract static class NeverDefaultGuaranteedPrimitiveBoxed extends Node { + + abstract int execute(Object argument); + + @SuppressWarnings("unused") + @Specialization + int s0(int value, + @ExpectError("The @Cached(neverDefault=true|false) property is guaranteed or implied by the initializer expression.%") // + @Cached(value = "value", neverDefault = true) Integer cached) { + return value; + } + + } + + @SuppressWarnings({"truffle-inlining", "unused"}) + abstract static class ErrorSharedNeverDefaultInconsistentNode extends TestNode { + + @Specialization(guards = "value == 1") + int s0(int value, + @ExpectError("Could not share some of the cached parameters in group 'a': %") // + @Shared("a") @Cached(value = "value", neverDefault = true) int cachedValue) { + return value; + } + + @Specialization + int s1(int value, + @ExpectError("Could not share some of the cached parameters in group 'a': %") // + @Shared("a") @Cached(value = "value", neverDefault = false) int cachedValue) { + return value; + } + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NoTypeSystemTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NoTypeSystemTest.java index e3b165201a35..fd4d72f7b1dc 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NoTypeSystemTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NoTypeSystemTest.java @@ -56,6 +56,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class NoTypeSystemTest { abstract static class DummyChild extends Node { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildCreateTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildCreateTest.java index a24841b2a051..4034049d3ddf 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildCreateTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildCreateTest.java @@ -40,18 +40,21 @@ */ package com.oracle.truffle.api.dsl.test; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; + +import org.junit.Assert; +import org.junit.Test; + import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.NodeChildCreateTestFactory.CreateTestChildNodeGen; import com.oracle.truffle.api.dsl.test.NodeChildCreateTestFactory.CreateTestNodeGen; import com.oracle.truffle.api.dsl.test.NodeChildCreateTestFactory.CustomCreateTestNodeGen; import com.oracle.truffle.api.nodes.Node; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import org.junit.Assert; -import org.junit.Test; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class NodeChildCreateTest { abstract static class CreateTestBaseNode extends Node { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java index b478ccff6410..977de477dc68 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildTest.java @@ -96,7 +96,6 @@ abstract static class Base2Node extends ValueNode { @NodeChildren({@NodeChild(value = "child2", type = ValueNode.class)}) abstract static class Child2Node extends Base1Node { - @ExpectError("Method signature (int, int, int) does not match to the expected signature:%") @Specialization int intField(int child0, int child1, int child2) { return child0 + child1 + child2; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildUncachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildUncachedTest.java index 2b5ee35ac8bd..733941c01cec 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildUncachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeChildUncachedTest.java @@ -40,6 +40,11 @@ */ package com.oracle.truffle.api.dsl.test; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -48,11 +53,8 @@ import com.oracle.truffle.api.dsl.test.NodeChildUncachedTestFactory.UncachedTestNodeGen; import com.oracle.truffle.api.dsl.test.NodeChildUncachedTestFactory.UncachedTestWithNodeGen; import com.oracle.truffle.api.nodes.Node; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class NodeChildUncachedTest { abstract static class TestBaseNode extends Node { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryImportsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryImportsTest.java index 113a5a905a7c..c26df3250d54 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryImportsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryImportsTest.java @@ -46,6 +46,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class NodeFactoryImportsTest { @GenerateUncached diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryMissingChildTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryMissingChildTest.java index 495e4510289f..48d3efb333b0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryMissingChildTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryMissingChildTest.java @@ -45,7 +45,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class NodeFactoryMissingChildTest { abstract static class TestBase extends Node { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryParametrizedTypesTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryParametrizedTypesTest.java index fb3ba7d31ca6..c7fb9c8c69cc 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryParametrizedTypesTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NodeFactoryParametrizedTypesTest.java @@ -70,7 +70,7 @@ abstract static class BinaryNode extends BaseNode { abstract Object executeBinary(Object left, Object right); @Specialization - Object executeForeign(@SuppressWarnings("unused") TruffleObject left, @SuppressWarnings("unused") TruffleObject right) { + Object doForeign(@SuppressWarnings("unused") TruffleObject left, @SuppressWarnings("unused") TruffleObject right) { throw new UnsupportedOperationException("Unsupported"); } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ObjectSizeEstimate.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ObjectSizeEstimate.java new file mode 100644 index 000000000000..cfc5285a2efc --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ObjectSizeEstimate.java @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; + +import org.graalvm.collections.EconomicMap; +import org.graalvm.collections.Equivalence; + +/** + * Calculates approximate estimates of the size of an object graph. + * + * The result contains number of object headers {@link #getHeaderCount()}, number of pointers + * {@link #getPointerCount()} and size of the primitive data {@link #getPrimitiveByteSize()}. + * + * The methods {@link #getTotalBytes()} and {@link #getCompressedTotalBytes()} estimate the total + * number of bytes occupied. The real number of bytes occupied may vary due to different alignment + * or different header sizes on different virtual machines. + * + * This utility uses reflection and relies on {@link Modules} to open up classes. As such, the + * caller must ensure this class has access to {@link Modules} (e.g., + * {@code --add-exports=java.base/jdk.internal.module=jdk.internal.vm.compiler}). + */ +public final class ObjectSizeEstimate { + + private static final int UNCOMPRESSED_POINTER_SIZE = 8; + private static final int UNCOMPRESSED_HEADER_SIZE = 16; + private static final int COMPRESSED_POINTER_SIZE = 4; + private static final int COMPRESSED_HEADER_SIZE = 12; + + /** + * Collect the size occupied by the object graph reachable from the given root object. + * + * @param root the starting point of the object graph traversal + */ + public static ObjectSizeEstimate forObject(Object root) { + return forObject(root, Integer.MAX_VALUE); + } + + /** + * Collect the size occupied by the object graph reachable from the given root object. + * + * @param root the starting point of the object graph traversal + * @param maxDepth the maximum depth of the traversal + */ + public static ObjectSizeEstimate forObject(Object root, int maxDepth) { + return forObjectHelper(root, maxDepth); + } + + private int headerCount; + private int pointerCount; + private int primitiveByteSize; + + private ObjectSizeEstimate() { + } + + public ObjectSizeEstimate add(ObjectSizeEstimate other) { + ObjectSizeEstimate result = new ObjectSizeEstimate(); + result.headerCount = headerCount + other.headerCount; + result.primitiveByteSize = primitiveByteSize + other.primitiveByteSize; + result.pointerCount = pointerCount + other.pointerCount; + return result; + } + + public ObjectSizeEstimate subtract(ObjectSizeEstimate other) { + ObjectSizeEstimate result = new ObjectSizeEstimate(); + result.headerCount = headerCount - other.headerCount; + result.primitiveByteSize = primitiveByteSize - other.primitiveByteSize; + result.pointerCount = pointerCount - other.pointerCount; + return result; + } + + public int getHeaderCount() { + return headerCount; + } + + public int getPointerCount() { + return pointerCount; + } + + public int getPrimitiveByteSize() { + return primitiveByteSize; + } + + @Override + public String toString() { + return String.format("(#headers=%s, #pointers=%s, #primitiveBytes=%s, totalCompressed=%s, totalNonCompressed=%s)", headerCount, pointerCount, primitiveByteSize, + getCompressedTotalBytes(), getTotalBytes()); + } + + public int getCompressedTotalBytes() { + return headerCount * COMPRESSED_HEADER_SIZE + pointerCount * COMPRESSED_POINTER_SIZE + primitiveByteSize; + } + + public int getTotalBytes() { + return headerCount * UNCOMPRESSED_HEADER_SIZE + pointerCount * UNCOMPRESSED_POINTER_SIZE + primitiveByteSize; + } + + private void recordHeader() { + headerCount++; + } + + private void recordPointer() { + pointerCount++; + } + + private void recordPrimitiveBytes(int size) { + primitiveByteSize += size; + } + + private static ObjectSizeEstimate forObjectHelper(Object object, int maxDepth) { + EconomicMap identityHashMap = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE); + EconomicMap, Field[]> fieldsMap = EconomicMap.create(); + ObjectSizeEstimate size = new ObjectSizeEstimate(); + + ArrayList stack = new ArrayList<>(); + ArrayList depthStack = new ArrayList<>(); + stack.add(object); + depthStack.add(0); + identityHashMap.put(object, object); + + while (!stack.isEmpty()) { + Object o = stack.remove(stack.size() - 1); + int depth = depthStack.remove(depthStack.size() - 1); + size.recordHeader(); + Class c = o.getClass(); + if (c.isArray()) { + size.recordPrimitiveBytes(Integer.BYTES); + if (o instanceof byte[]) { + size.recordPrimitiveBytes(Byte.BYTES * ((byte[]) o).length); + } else if (o instanceof boolean[]) { + size.recordPrimitiveBytes(Byte.BYTES * ((boolean[]) o).length); + } else if (o instanceof char[]) { + size.recordPrimitiveBytes(Character.BYTES * ((char[]) o).length); + } else if (o instanceof short[]) { + size.recordPrimitiveBytes(Short.BYTES * ((short[]) o).length); + } else if (o instanceof int[]) { + size.recordPrimitiveBytes(Integer.BYTES * ((int[]) o).length); + } else if (o instanceof long[]) { + size.recordPrimitiveBytes(Long.BYTES * ((long[]) o).length); + } else if (o instanceof float[]) { + size.recordPrimitiveBytes(Float.BYTES * ((float[]) o).length); + } else if (o instanceof double[]) { + size.recordPrimitiveBytes(Byte.BYTES * ((double[]) o).length); + } else { + for (Object element : (Object[]) o) { + size.recordPointer(); + if (element != null) { + if (depth < maxDepth && !identityHashMap.containsKey(element)) { + identityHashMap.put(element, null); + stack.add(element); + depthStack.add(depth + 1); + } + } + } + } + } else { + while (c != null) { + + Field[] fields = fieldsMap.get(c); + if (fields == null) { + fields = c.getDeclaredFields(); + fieldsMap.put(c, fields); + } + for (Field f : fields) { + if (!Modifier.isStatic(f.getModifiers())) { + Class type = f.getType(); + if (type == Byte.TYPE) { + size.recordPrimitiveBytes(Byte.BYTES); + } else if (type == Boolean.TYPE) { + size.recordPrimitiveBytes(Byte.BYTES); + } else if (type == Character.TYPE) { + size.recordPrimitiveBytes(Character.BYTES); + } else if (type == Short.TYPE) { + size.recordPrimitiveBytes(Short.BYTES); + } else if (type == Integer.TYPE) { + size.recordPrimitiveBytes(Integer.BYTES); + } else if (type == Long.TYPE) { + size.recordPrimitiveBytes(Long.BYTES); + } else if (type == Float.TYPE) { + size.recordPrimitiveBytes(Float.BYTES); + } else if (type == Double.TYPE) { + size.recordPrimitiveBytes(Double.BYTES); + } else { + size.recordPointer(); + if (maxDepth > 1 && type != Class.class) { + try { + if (!f.canAccess(o)) { + f.setAccessible(true); + } + Object inner = f.get(o); + if (inner != null) { + if (depth < maxDepth && !identityHashMap.containsKey(inner)) { + identityHashMap.put(inner, null); + stack.add(inner); + depthStack.add(depth + 1); + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new UnsupportedOperationException("Must have access privileges to traverse object graph"); + } catch (RuntimeException e) { + if ("java.lang.reflect.InaccessibleObjectException".equals(e.getClass().getName())) { + // This is a newly introduced exception in JDK9 and thus + // cannot be declared in the catch clause. + throw new UnsupportedOperationException("Target class is not exported to the current module.", e); + } else { + throw e; + } + } + } + } + } + } + c = c.getSuperclass(); + } + } + } + return size; + } + + public static ObjectSizeEstimate zero() { + return new ObjectSizeEstimate(); + } + + @Override + public int hashCode() { + final int prime = 31; + return headerCount + prime * (pointerCount + prime * primitiveByteSize); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj instanceof ObjectSizeEstimate) { + ObjectSizeEstimate other = (ObjectSizeEstimate) obj; + return headerCount == other.headerCount && pointerCount == other.pointerCount && primitiveByteSize == other.primitiveByteSize; + } + return false; + } +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java new file mode 100644 index 000000000000..2270a8a327a5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static com.oracle.truffle.api.test.ReflectionUtils.invoke; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import org.junit.Test; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ProfileInliningTestFactory.UsageNodeGen; +import com.oracle.truffle.api.interop.ArityException; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.ByteValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedByteValueProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile; +import com.oracle.truffle.api.profiles.InlinedIntValueProfile; +import com.oracle.truffle.api.profiles.InlinedLongValueProfile; +import com.oracle.truffle.api.profiles.InlinedProfile; +import com.oracle.truffle.api.profiles.IntValueProfile; +import com.oracle.truffle.api.profiles.LongValueProfile; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) +public class ProfileInliningTest extends AbstractPolyglotTest { + + @Test + public void test() { + UsageNode node = adoptNode(UsageNodeGen.create()).get(); + + assertEquals(true, node.execute(true)); + assertEquals(false, node.execute(false)); + assertEquals(true, node.execute(true)); + assertEquals(false, node.execute(false)); + assertEquals(true, node.execute(true)); + assertEquals(false, node.execute(false)); + + assertEquals(42, node.execute(42)); + assertEquals(43, node.execute(43)); + assertEquals(44, node.execute(44)); + + assertEquals((byte) 42, node.execute((byte) 42)); + assertEquals((byte) 43, node.execute((byte) 43)); + assertEquals((byte) 44, node.execute((byte) 44)); + + assertEquals(Long.MAX_VALUE - 1, node.execute(Long.MAX_VALUE - 1)); + assertEquals(Long.MAX_VALUE - 2, node.execute(Long.MAX_VALUE - 2)); + } + + @GenerateCached(alwaysInlineCached = true) + @SuppressWarnings({"unused"}) + public abstract static class UsageNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "triggerGuards(arg, g0, g1, g2)", limit = "1") + @TruffleBoundary + final Object doBoolean(boolean arg, + @Cached InlinedBranchProfile g0, + @Cached InlinedConditionProfile g1, + @Cached InlinedCountingConditionProfile g2, + @Cached InlinedBranchProfile p0, + @Cached InlinedConditionProfile p1, + @Cached InlinedCountingConditionProfile p2) { + assertFalse(isUninitialized(this, g0)); + assertFalse(isUninitialized(this, g1)); + assertFalse(isUninitialized(this, g2)); + int trueCount = (int) invokeProfileMethod(this, g2, "getTrueCount"); + + triggerGuards(arg, p0, p1, p2); + + assertFalse(isUninitialized(this, p0)); + assertFalse(isUninitialized(this, p1)); + assertFalse(isUninitialized(this, p2)); + + return arg; + } + + @TruffleBoundary + boolean triggerGuards(boolean arg, InlinedBranchProfile p0, + InlinedConditionProfile p1, + InlinedCountingConditionProfile p2) { + p0.enter(this); + p1.profile(this, arg); + p2.profile(this, arg); + return true; + } + + @Specialization + final Object doInt(int arg, + @Cached InlinedIntValueProfile p) { + return p.profile(this, arg); + } + + @Specialization + Object doByte(byte arg, + @Cached InlinedByteValueProfile p) { + return p.profile(this, arg); + } + + @Specialization + static Object doLong(long arg, + @Bind("this") Node node, + @Cached InlinedLongValueProfile p) { + return p.profile(node, arg); + } + + } + + @ExportLibrary(InteropLibrary.class) + static class UsageExport implements TruffleObject { + + @ExportMessage + boolean isExecutable() { + return true; + } + + @ExportMessage + @SuppressWarnings("unused") + static Object execute(UsageExport receiver, Object[] arguments, + @Bind("$node") Node node, + @Cached InlinedBranchProfile p0, + @Cached InlinedConditionProfile p1, + @Cached InlinedCountingConditionProfile p2, + // add regular profiles such that useSpecializationClass becomes true + @Cached(inline = false) ByteValueProfile byteValue, + @Cached(inline = false) IntValueProfile intValue, + @Cached(inline = false) LongValueProfile longValue) { + p0.enter(node); + return p1.profile(node, true) & p2.profile(node, true); + } + + } + + @Test + public void testExport() throws UnsupportedTypeException, ArityException, UnsupportedMessageException { + UsageExport export = new UsageExport(); + InteropLibrary node = adoptNode(InteropLibrary.getFactory().create(export)).get(); + node.execute(export); + } + + public abstract static class BaseNode extends Node { + + abstract int execute(Node node); + + } + + @SuppressWarnings({"unused", "truffle"}) + public abstract static class TestInlineMessage1 extends BaseNode { + + // even though BranchProfile needs a different type we report as inlinable + @Specialization + int s0(@ExpectError("The cached type 'BranchProfile' supports object-inlining. %") // + @Cached BranchProfile p0) { + return 0; + } + } + + @SuppressWarnings({"unused", "truffle"}) + public abstract static class TestInlineMessage2 extends BaseNode { + + // test warning goes away + @Specialization + int s0(@Cached(inline = false) BranchProfile p0) { + return 0; + } + } + + @SuppressWarnings({"unused", "truffle"}) + @GenerateCached(alwaysInlineCached = false) + public abstract static class TestInlineMessage3 extends BaseNode { + + // test warning goes away + @Specialization + int s0(@Cached(inline = false) BranchProfile p0) { + return 0; + } + } + + @SuppressWarnings("unused") + public abstract static class TestInlineMessage4 extends BaseNode { + + // give a reasonable error that the branch profile type needs to be updated + @Specialization + int s0(@ExpectError("Invalid return type com.oracle.truffle.api.profiles.InlinedBranchProfile found but expected com.oracle.truffle.api.profiles.BranchProfile. " + + "This is a common error if a different type is required for inlining. %") // + @Cached(inline = true) BranchProfile p0) { + return 0; + } + } + + @SuppressWarnings("unused") + public abstract static class TestInlineMessage5 extends BaseNode { + + // test warning goes away + @Specialization + int s0(@ExpectError("Error parsing expression 'create()': The method create is undefined for the enclosing scope.") // + @Cached(inline = false) InlinedBranchProfile p0) { + return 0; + } + } + + @SuppressWarnings({"unused", "truffle"}) + public abstract static class TestInlineMessage6 extends BaseNode { + + // test no warning for inlinable + @Specialization + int s0(@ExpectError("Redundant specification of @Cached(... inline=true)%") // + @Cached(inline = true) InlinedBranchProfile p0) { + return 0; + } + } + + @SuppressWarnings("unused") + @GenerateInline + @GenerateCached(false) + public abstract static class TestInlineMessage7 extends BaseNode { + + // test no warning for inlinable + @Specialization + static int s0(Node node, @Cached InlinedBranchProfile p0) { + return 0; + } + } + + @GenerateUncached + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + public abstract static class TestInlineMessage8 extends BaseNode { + + @Specialization + static int s0( + @ExpectError("Invalid return type com.oracle.truffle.api.profiles.InlinedBranchProfile found but expected com.oracle.truffle.api.profiles.BranchProfile. " + + "This is a common error if a different type is required for inlining. Signature inline(InlineTarget).") // + @Cached BranchProfile p0) { + return 0; + } + } + + private static boolean isUninitialized(Node node, InlinedProfile profile) { + return (boolean) invokeProfileMethod(node, profile, "isUninitialized"); + } + + @SuppressWarnings("rawtypes") + private static Object invokeProfileMethod(Node node, InlinedProfile profile, String name) { + return invoke(profile, name, new Class[]{Node.class}, node); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java index 5d220b39fbe6..e1166c8613d9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.nodes.Node; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class ReachabilityTest { static class Reachability1 extends ValueNode { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java index be1962611322..6602c59a1269 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesTest.java @@ -50,6 +50,7 @@ import org.junit.Assert; import org.junit.Test; +import com.oracle.truffle.api.dsl.Introspectable; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; @@ -62,7 +63,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.nodes.NodeCost; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class ReplacesTest { /* @@ -193,6 +194,180 @@ int f2(int a) { } + @NodeChild("a") + @Introspectable + abstract static class ReplaceMaxLimitNode extends ValueNode { + + static boolean isOne(int a) { + return a == 1; + } + + @Specialization(guards = "a == 0") + int s0(int a) { + return a; + } + + @Specialization(guards = "a == 1") + int s1(int a) { + return a; + } + + @Specialization(guards = "a == 2") + int s2(int a) { + return a; + } + + @Specialization(guards = "a == 3") + int s3(int a) { + return a; + } + + @Specialization(guards = "a == 4") + int s4(int a) { + return a; + } + + @Specialization(guards = "a == 5") + int s5(int a) { + return a; + } + + @Specialization(guards = "a == 6") + int s6(int a) { + return a; + } + + @Specialization(guards = "a ==7") + int s7(int a) { + return a; + } + + @Specialization(guards = "a == 8") + int s8(int a) { + return a; + } + + @Specialization(guards = "a == 9") + int s9(int a) { + return a; + } + + @Specialization(guards = "a == 10") + int s10(int a) { + return a; + } + + @Specialization(guards = "a == 11") + int s11(int a) { + return a; + } + + @Specialization(guards = "a == 12") + int s12(int a) { + return a; + } + + @Specialization(guards = "a == 13") + int s13(int a) { + return a; + } + + @Specialization(guards = "a == 14") + int s14(int a) { + return a; + } + + @Specialization(guards = "a == 15") + int s15(int a) { + return a; + } + + @Specialization(guards = "a == 16") + int s16(int a) { + return a; + } + + @Specialization(guards = "a == 17") + int s17(int a) { + return a; + } + + @Specialization(guards = "a == 18") + int s18(int a) { + return a; + } + + @Specialization(guards = "a == 19") + int s19(int a) { + return a; + } + + @Specialization(guards = "a == 20") + int s20(int a) { + return a; + } + + @Specialization(guards = "a == 21") + int s21(int a) { + return a; + } + + @Specialization(guards = "a == 22") + int s22(int a) { + return a; + } + + @Specialization(guards = "a == 23") + int s23(int a) { + return a; + } + + @Specialization(guards = "a == 24") + int s24(int a) { + return a; + } + + @Specialization(guards = "a == 25") + int s25(int a) { + return a; + } + + @Specialization(guards = "a == 26") + int s26(int a) { + return a; + } + + @Specialization(guards = "a == 27") + int s27(int a) { + return a; + } + + @Specialization(guards = "a == 28") + int s28(int a) { + return a; + } + + @Specialization(guards = "a == 29") + int s29(int a) { + return a; + } + + @Specialization(guards = "a == 30") + int s30(int a) { + return a; + } + + @Specialization(replaces = {"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", // + "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", // + "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", // + "s30", + }) + int generic(int a) { + return a; + } + + } + @NodeChild("a") abstract static class ReplacesError1 extends ValueNode { @ExpectError("The replaced specialization 'f1' must be declared before the replacing specialization.") diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index bc883bc9e458..6e19f066a70f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -48,18 +48,22 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.dsl.test.GenerateInlineTest.SimpleNode; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.SharedStringInGuardNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundExclusiveObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundSharedObjectNodeGen; +import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UseGenerateInlineSharedNodeGen; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "unused"}) public class SharedCachedTest { - // TODO GR-38632 how to share primitive caches? maybe through a specialization class? abstract static class UnboundCachedPrimitiveNode extends Node { abstract Object execute(Object arg); @@ -106,7 +110,7 @@ public void testUnboundSharedObject() { assertSame(UnboundSharedObjectNode.ARG1, node.execute(UnboundSharedObjectNode.ARG0)); } - @SuppressWarnings("unused") + @SuppressWarnings("truffle-inlining") abstract static class UnboundExclusiveObjectNode extends Node { static final Object ARG0 = new Object(); @@ -115,12 +119,12 @@ abstract static class UnboundExclusiveObjectNode extends Node { abstract Object execute(Object arg); @Specialization(guards = "arg == ARG0") - Object s0(Object arg, @Exclusive @Cached("arg") Object cachedArg) { + Object s0(Object arg, @Exclusive @Cached(value = "arg", neverDefault = true) Object cachedArg) { return cachedArg; } @Specialization(guards = "arg == ARG1") - Object s1(Object arg, @Exclusive @Cached("arg") Object cachedArg) { + Object s1(Object arg, @Exclusive @Cached(value = "arg", neverDefault = true) Object cachedArg) { return cachedArg; } } @@ -153,6 +157,69 @@ boolean execute(Object arg) { } + @GenerateInline + @GenerateUncached + @GenerateCached(false) + public abstract static class GenerateInlineSharedNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization + static Object doInt(Node node, int arg, @Shared("inner") @Cached SimpleNode innerNode) { + return innerNode.execute(node, arg); + } + + @Specialization + static Object doLong(Node node, long arg, @Shared("inner") @Cached SimpleNode innerNode) { + return innerNode.execute(node, arg); + } + + @Specialization + static Object doObject(Node node, Object arg, @Shared("inner") @Cached SimpleNode innerNode) { + return innerNode.execute(node, arg); + } + + } + + @GenerateUncached + public abstract static class UseGenerateInlineSharedNode extends Node { + + abstract Object execute(Object arg); + + @Specialization + final Object doInt(Object arg, @Cached GenerateInlineSharedNode innerNode) { + return innerNode.execute(this, arg); + } + } + + @Test + public void testUseGenerateInlineSharedNode() { + UseGenerateInlineSharedNode node = UseGenerateInlineSharedNodeGen.create(); + + assertEquals(42, node.execute(42)); + assertEquals(42L, node.execute(42L)); + AbstractPolyglotTest.assertFails(() -> node.execute(""), UnsupportedSpecializationException.class); + } + +// abstract static class InlineCacheSharingNode extends Node { +// +// abstract Object execute(Object arg); +// +// @Specialization(guards = "cachedArg == arg") +// Object s0(int arg, +// @Cached("arg") int cachedArg, +// @Shared("group") @Cached InlinedBranchProfile node) { +// return arg; +// } +// +// @Specialization(guards = "cachedArg == arg") +// Object s1(int arg, +// @Cached("arg") int cachedArg, +// @Shared("group") @Cached InlinedBranchProfile node) { +// return arg; +// } +// } + abstract static class UnboundCachedNodeNode extends Node { abstract Object execute(Object arg); @@ -168,6 +235,7 @@ Object s1(int arg, @Shared("group") @Cached TestNode node) { } } + @SuppressWarnings("truffle-sharing") abstract static class BoundCachedNodeNode extends Node { abstract Object execute(Object arg); @@ -189,13 +257,13 @@ abstract static class ErrorUnboundCachedNode2 extends Node { @Specialization(guards = "arg == 42") Object s0(int arg, - @Cached TestNode node) { + @Exclusive @Cached TestNode node) { return arg; } @Specialization(guards = "arg == 43") Object s1(int arg, - @Cached TestNode node) { + @Exclusive @Cached TestNode node) { return arg; } } @@ -206,7 +274,7 @@ abstract static class ErrorUnboundCachedNode3 extends Node { @Specialization(guards = "arg == 42") Object s0(int arg, - @Cached TestNode node) { + @Exclusive @Cached TestNode node) { return arg; } @@ -291,7 +359,7 @@ abstract static class ErrorInvalidGroup4 extends Node { abstract Object execute(Object arg); - @Specialization(guards = "node == arg") + @Specialization(guards = "node == arg", limit = "3") Object s0(int arg, @Cached("arg") int node, @ExpectError("Could not share some of the cached parameters in group 'shared': %n" + @@ -301,7 +369,7 @@ Object s0(int arg, return arg; } - @Specialization(guards = "arg == node") + @Specialization(guards = "arg == node", limit = "3") Object s1(int arg, @Cached("arg") int node, @ExpectError("Could not share some of the cached parameters in group 'shared': %n" + @@ -339,13 +407,13 @@ public abstract static class SharedStringInGuardNode extends Node { @Specialization(guards = "name == cachedName", limit = "1") public Object s0(String name, - @Cached("name") @Shared("name") String cachedName) { + @Cached(value = "name", neverDefault = true) @Shared("name") String cachedName) { return cachedName; } @Specialization(guards = "name == cachedName", limit = "1") public Object s1(String name, - @Cached("name") @Shared("name") String cachedName) { + @Cached(value = "name", neverDefault = true) @Shared("name") String cachedName) { return cachedName; } } @@ -358,31 +426,11 @@ public void testObjectReference() { assertEquals("a", node.execute("a")); SharedStringInGuardNode errorNode = SharedStringInGuardNodeGen.create(); - AbstractPolyglotTest.assertFails(() -> errorNode.execute(null), AssertionError.class, (e) -> { - assertEquals("Specialization 's0(String, String)' contains a shared cache with name 'cachedName' that returned a null value for the cached initializer. " + - "Null values are not supported for shared cached initializers because null is reserved for the uninitialized state.", + AbstractPolyglotTest.assertFails(() -> errorNode.execute(null), IllegalStateException.class, (e) -> { + assertEquals("Specialization 's0(String, String)' contains a shared cache with name 'cachedName' that returned a default value for the cached initializer. " + + "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", e.getMessage()); }); } - @SuppressWarnings("unused") - public abstract static class SharedPrimitiveInGuardNode extends Node { - - public abstract Object execute(Object arg0); - - @ExpectError("This guard references a @Shared cache with a primitive type. This is not supported.%") - @Specialization(guards = "value == cachedValue", limit = "1") - public Object s0(int value, - @Cached("value") @Shared("value") int cachedValue) { - return cachedValue; - } - - @ExpectError("This guard references a @Shared cache with a primitive type. This is not supported.%") - @Specialization(guards = "value == cachedValue", limit = "1") - public Object s1(int value, - @Cached("value") @Shared("value") int cachedValue) { - return cachedValue; - } - } - } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListener.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListener.java new file mode 100644 index 000000000000..e7c5ffc05dd5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListener.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +/** + * Truffle DSL knows about this test interface and calls it automatically. + */ +public interface SlowPathListener { + + default void afterSpecialize() { + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BoxedString.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListenerNode.java similarity index 85% rename from truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BoxedString.java rename to truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListenerNode.java index 617d6dbaa616..835fd34e137f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BoxedString.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathListenerNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * The Universal Permissive License (UPL), Version 1.0 @@ -40,20 +40,14 @@ */ package com.oracle.truffle.api.dsl.test; -public class BoxedString { +import com.oracle.truffle.api.nodes.Node; - private final String delegate; +public abstract class SlowPathListenerNode extends Node implements SlowPathListener { - public BoxedString(String delegate) { - this.delegate = delegate; - } + public int specializeCount; - public String getDelegate() { - return delegate; + public void afterSpecialize() { + specializeCount++; } - @Override - public String toString() { - return getDelegate(); - } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationSlowPathOnlyModeTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationSlowPathOnlyModeTest.java index 5ccd14356c80..d2e455c58d6a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationSlowPathOnlyModeTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationSlowPathOnlyModeTest.java @@ -43,24 +43,25 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import org.junit.Test; + import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.SpecializationSlowPathOnlyModeTestFactory.SpecializationTestingTestNodeGen; import com.oracle.truffle.api.dsl.test.SpecializationSlowPathOnlyModeTestFactory.SpecializationTestingWithCachedTestNodeGen; -import com.oracle.truffle.api.interop.InvalidArrayIndexException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; -import org.junit.Test; - -import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.InvalidArrayIndexException; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; +import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class SpecializationSlowPathOnlyModeTest { @AlwaysGenerateOnlySlowPath @@ -96,7 +97,7 @@ public boolean s0(int arg, @SuppressWarnings("unused") public boolean s1(int arg, @Shared("argLib") @CachedLibrary(limit = "2") InteropLibrary argLib, - @Shared("branch") @Cached BranchProfile profile) { + @Shared("branch") @Cached(inline = false) BranchProfile profile) { profile.enter(); return argLib.fitsInByte(arg); } @@ -142,7 +143,7 @@ public boolean isArrayElementInsertable(long index) { @ExportMessage @SuppressWarnings("unused") public boolean isArrayElementRemovable(long index, - @Shared("branch1") @Cached BranchProfile branch1) { + @Shared("branch1") @Cached(inline = false) BranchProfile branch1) { branch1.enter(); return true; } @@ -162,7 +163,7 @@ static Object doCached(SpecializationTestingTruffleObj receiver, long index, @Specialization(replaces = "doCached") @SuppressWarnings("unused") static Object doGeneric(SpecializationTestingTruffleObj receiver, long index, - @Shared("branch2") @Cached BranchProfile branch2) { + @Shared("branch2") @Cached(inline = false) BranchProfile branch2) { branch2.enter(); return "generic"; } @@ -174,7 +175,7 @@ static class WriteArrayElement { @Specialization @SuppressWarnings("unused") static void doIt(SpecializationTestingTruffleObj receiver, long index, Object value, - @Shared("branch3") @Cached BranchProfile branch3) { + @Shared("branch3") @Cached(inline = false) BranchProfile branch3) { branch3.enter(); } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationUnrollingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationUnrollingTest.java new file mode 100644 index 000000000000..d7a0cc068309 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationUnrollingTest.java @@ -0,0 +1,587 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + +import org.junit.Test; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.dsl.test.GenerateInlineTest.SimpleNode; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.IdentityCacheNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.InlineIdentityCacheNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.InlineIdentityCacheSharedNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.NoUnrollLibraryNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.RemoveSpecializationNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.ReplaceSpecializationNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollAllNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollHigherThanLimitNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollLibraryNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollNoneNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollTwoNodeGen; +import com.oracle.truffle.api.dsl.test.SpecializationUnrollingTestFactory.UnrollWithCachedLibraryNodeGen; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) +public class SpecializationUnrollingTest extends AbstractPolyglotTest { + + @GenerateInline + public abstract static class InnerNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v == 0") + static long s0(long v) { + return 0; + } + + @Specialization(guards = "v == 1") + static long s1(long v) { + return 1; + } + + @Specialization(guards = "v == 2") + static long s2(long v) { + return 2; + } + + @Specialization(guards = "v == 3") + static long s3(long v) { + return 3; + } + + } + + public abstract static class UnrollNoneNode extends Node { + + abstract long execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "2", unroll = 0) + static long doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode test, + @Cached("v0") long cachedV0) { + return test.execute(node, cachedV0); + } + + } + + @Test + public void testUnrollNone() { + UnrollNoneNode node = adoptNode(UnrollNoneNodeGen.create()).get(); + assertEquals(0, node.execute(0)); + assertEquals(1, node.execute(1)); + assertFails(() -> node.execute(3), UnsupportedSpecializationException.class); + } + + public abstract static class UnrollTwoNode extends Node { + + static int limit = 2; + + abstract long execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "limit", unroll = 2) + static long doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode test, + @Cached("v0") long cachedV0) { + return test.execute(node, cachedV0); + } + + } + + @Test + public void testUnrollTwo() { + UnrollTwoNode node = adoptNode(UnrollTwoNodeGen.create()).get(); + assertEquals(0, node.execute(0)); + assertEquals(1, node.execute(1)); + assertFails(() -> node.execute(2), UnsupportedSpecializationException.class); + } + + public abstract static class UnrollAllNode extends Node { + + static int limit = 2; + + abstract long execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "2", unroll = 2) + static long doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode abs, + @Cached("v0") long cachedV0) { + return abs.execute(node, cachedV0); + } + } + + @Test + public void testUnrollAll() { + UnrollAllNode node = adoptNode(UnrollAllNodeGen.create()).get(); + assertEquals(0, node.execute(0)); + assertEquals(1, node.execute(1)); + assertFails(() -> node.execute(3), UnsupportedSpecializationException.class); + } + + public abstract static class UnrollHigherThanLimitNode extends Node { + + static int limit = 2; + + abstract long execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "limit", unroll = 3) + static long doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode test, + @Cached("v0") long cachedV0) { + return test.execute(node, cachedV0); + } + + } + + @Test + public void testUnrollHigherThanLimit() { + UnrollHigherThanLimitNode node = adoptNode(UnrollHigherThanLimitNodeGen.create()).get(); + assertEquals(0, node.execute(0)); + assertEquals(1, node.execute(1)); + assertFails(() -> node.execute(3), UnsupportedSpecializationException.class); + } + + public abstract static class UnrollWithCachedLibraryNode extends Node { + + static int limit = 1; + + abstract long execute(Object v0); + + @Specialization(guards = "guard(cachedV0,v0)", limit = "limit", unroll = 1) + static long doInt(Object v0, + @CachedLibrary("v0") InteropLibrary lib, + @Cached("v0") Object cachedV0) { + return 42; + } + + static boolean guard(Object o, Object o2) { + return o == o2; + } + + } + + @Test + public void testUnrollWithCachedLibrary() { + UnrollWithCachedLibraryNode node = adoptNode(UnrollWithCachedLibraryNodeGen.create()).get(); + node.execute(0); + node.execute(1); + assertFails(() -> node.execute(2), UnsupportedSpecializationException.class); + } + + public abstract static class RemoveSpecializationNode extends Node { + + static int limit = 3; + + abstract long execute(Assumption v0); + + @Specialization(guards = "v0 == assumption", limit = "limit", unroll = 2, assumptions = "assumption") + static long doInt(Assumption v0, + @Cached("v0") Assumption assumption) { + return 42; + } + + static boolean guard(Object o, Object o2) { + return o == o2; + } + } + + @Test + public void testRemoveSpecialization() { + RemoveSpecializationNode node = adoptNode(RemoveSpecializationNodeGen.create()).get(); + Assumption a0 = Truffle.getRuntime().createAssumption(); + Assumption a1 = Truffle.getRuntime().createAssumption(); + Assumption a2 = Truffle.getRuntime().createAssumption(); + + node.execute(a0); + node.execute(a1); + node.execute(a2); + + // remove first unrolled + a0.invalidate(); + a0 = Truffle.getRuntime().createAssumption(); + node.execute(a0); + + // remove second unrolled + a1.invalidate(); + a1 = Truffle.getRuntime().createAssumption(); + node.execute(a1); + + // remove regular specialization + a2.invalidate(); + a2 = Truffle.getRuntime().createAssumption(); + node.execute(a2); + + // test limit == 3 + assertFails(() -> node.execute(Truffle.getRuntime().createAssumption()), UnsupportedSpecializationException.class); + } + + public abstract static class ReplaceSpecializationNode extends Node { + + static int limit = 2; + + abstract String execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "limit", unroll = 1) + static String doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode test, + @Cached("v0") long cachedV0) { + return "cached"; + } + + @Specialization(replaces = "doInt") + static String doGeneric(long v0) { + return "generic"; + } + + } + + @Test + public void testReplaceSpecialization() { + ReplaceSpecializationNode node = adoptNode(ReplaceSpecializationNodeGen.create()).get(); + assertEquals("cached", node.execute(0)); + assertEquals("cached", node.execute(1)); + assertEquals("generic", node.execute(2)); + assertEquals("generic", node.execute(0)); + assertEquals("generic", node.execute(1)); + } + + public abstract static class ReplaceAllUnrolledNode extends Node { + + abstract String execute(long v0); + + @Specialization(guards = "cachedV0 == v0", limit = "2", unroll = 2) + static String doInt(long v0, + @Bind("this") Node node, + @Cached(inline = true) InnerNode test, + @Cached("v0") long cachedV0) { + return "cached"; + } + + @Specialization(replaces = "doInt") + static String doGeneric(long v0) { + return "generic"; + } + + } + + @Test + public void testReplaceAllUnrolled() { + ReplaceSpecializationNode node = adoptNode(ReplaceSpecializationNodeGen.create()).get(); + assertEquals("cached", node.execute(0)); + assertEquals("cached", node.execute(1)); + assertEquals("generic", node.execute(2)); + assertEquals("generic", node.execute(0)); + assertEquals("generic", node.execute(1)); + } + + @SuppressWarnings("unused") + @GenerateInline + @GenerateCached(false) + public abstract static class InlineWithUnrollNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3", unroll = 3) + static Object doInt(Node node, int arg, + @Cached SimpleNode simpleNode, + @Cached SimpleNode simpleNode2, + @Cached("arg") int cachedArg) { + return simpleNode.execute(node, cachedArg); + } + } + + @GenerateInline + public abstract static class UnrollInlineWithUnrollNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3", unroll = 3) + static Object doInt(Node node, int arg, + @Cached("arg") int cachedArg, + @Cached InlineWithUnrollNode simpleNode) { + return simpleNode.execute(node, cachedArg); + } + } + + public abstract static class UseInlineWithUnrollNode extends Node { + + abstract Object execute(Object arg); + + @Specialization() + Object doInt(int arg, @Cached InlineWithUnrollNode simpleNode) { + return simpleNode.execute(this, arg); + } + } + + @Test + public void testIdentityCacheNode() { + IdentityCacheNode node = adoptNode(IdentityCacheNodeGen.create()).get(); + Object o = new Object(); + String s = "a"; + + assertEquals("cached", node.execute(node, o, s, (byte) 42, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + assertEquals("cached", node.execute(node, o, s, (byte) 41, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + + assertFails(() -> { + node.execute(node, o, s, (byte) 40, 42, 42L, 42f, 42d, true, (short) 42, (char) 42); + }, UnsupportedSpecializationException.class); + } + + @GenerateInline + public abstract static class IdentityCacheNode extends Node { + public abstract String execute(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9); + + @Specialization(guards = { + "arg0 == cachedArg0", + "arg1 == cachedArg1", + "arg2 == cachedArg2", + "arg3 == cachedArg3", + "arg4 == cachedArg4", + "arg5 == cachedArg5", + "arg6 == cachedArg6", + "arg7 == cachedArg7", + "arg8 == cachedArg8", + "arg9 == cachedArg9", + + }, limit = "2", unroll = 2) + public String doCached(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9, + @Cached("arg0") Object cachedArg0, + @Cached("arg1") String cachedArg1, + @Cached("arg2") byte cachedArg2, + @Cached("arg3") int cachedArg3, + @Cached("arg4") long cachedArg4, + @Cached("arg5") float cachedArg5, + @Cached("arg6") double cachedArg6, + @Cached("arg7") boolean cachedArg7, + @Cached("arg8") short cachedArg8, + @Cached("arg9") char cachedArg9) { + return "cached"; + } + } + + @Test + public void testInlinedIdentityCacheNode() { + InlineIdentityCacheNode node = adoptNode(InlineIdentityCacheNodeGen.create()).get(); + Object o = new Object(); + String s = "a"; + + assertEquals("cached", node.execute(node, o, s, (byte) 42, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + assertEquals("cached", node.execute(node, o, s, (byte) 41, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + + assertFails(() -> { + node.execute(node, o, s, (byte) 40, 42, 42L, 42f, 42d, true, (short) 42, (char) 42); + }, UnsupportedSpecializationException.class); + } + + public abstract static class InlineIdentityCacheNode extends Node { + + public abstract String execute(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9); + + @Specialization + public String doCached(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9, + @Cached(inline = true) IdentityCacheNode unrolledIdentity) { + return unrolledIdentity.execute(node, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + } + + @Test + public void testInlinedIdentityCacheSharedNode() { + InlineIdentityCacheSharedNode node = adoptNode(InlineIdentityCacheSharedNodeGen.create()).get(); + Object o = "b"; + String s = "a"; + + assertEquals("cached", node.execute(node, o, s, (byte) 42, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + assertEquals("cached", node.execute(node, o, s, (byte) 41, 42, 42L, 42f, 42d, true, (short) 42, (char) 42)); + + assertFails(() -> { + node.execute(node, o, s, (byte) 40, 42, 42L, 42f, 42d, true, (short) 42, (char) 42); + }, UnsupportedSpecializationException.class); + } + + public abstract static class InlineIdentityCacheSharedNode extends Node { + + public abstract String execute(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9); + + @Specialization + public String doCached1(Node node, String arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9, + @Shared("unrolledIdentity") @Cached(inline = true) IdentityCacheNode unrolledIdentity) { + return unrolledIdentity.execute(node, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + @Specialization + public String doCached2(Node node, Object arg0, String arg1, + byte arg2, int arg3, long arg4, float arg5, double arg6, + boolean arg7, short arg8, char arg9, + @Shared("unrolledIdentity") @Cached(inline = true) IdentityCacheNode unrolledIdentity) { + return unrolledIdentity.execute(node, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + } + + @Test + public void testUnrollLibrary() { + UnrollLibraryNode node = adoptNode(UnrollLibraryNodeGen.create()).get(); + String s = "b"; + int i = 42; + TruffleObject o = new TruffleObject() { + }; + + assertSame(node, node.execute(s).getParent()); + assertSame(node, node.execute(i).getParent()); + // switch to uncached -> replaces doDefault. + assertNull(node.execute(o).getParent()); + assertNull(node.execute(i).getParent()); + assertNull(node.execute(s).getParent()); + } + + public abstract static class UnrollLibraryNode extends Node { + + abstract InteropLibrary execute(Object arg); + + @Specialization(limit = "2", unroll = 2) + InteropLibrary doDefault(Object arg, + @CachedLibrary("arg") InteropLibrary lib) { + return lib; + } + + } + + @Test + public void testNoUnrollLibrary() { + NoUnrollLibraryNode node = adoptNode(NoUnrollLibraryNodeGen.create()).get(); + String s = "b"; + int i = 42; + TruffleObject o = new TruffleObject() { + }; + + assertSame(node, node.execute(s).getParent().getParent()); + assertSame(node, node.execute(i).getParent().getParent()); + // switch to uncached -> replaces doDefault. + assertNull(node.execute(o).getParent()); + assertNull(node.execute(s).getParent()); + assertNull(node.execute(i).getParent()); + } + + public abstract static class NoUnrollLibraryNode extends Node { + + abstract InteropLibrary execute(Object arg); + + @Specialization(limit = "2") + InteropLibrary doDefault(Object arg, + @CachedLibrary("arg") InteropLibrary lib) { + return lib; + } + + } + + public abstract static class UnrollLibraryWithCustomCacheNode extends Node { + + abstract Object execute(Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3", unroll = 3) + int doDefault(Object arg, + @CachedLibrary("arg") InteropLibrary lib, + @Cached("arg") Object cachedArg) { + return 42; + } + + } + + @GenerateInline + public abstract static class UnrollLibraryInlineNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(limit = "3", unroll = 3) + int doDefault(Object arg, + @CachedLibrary("arg") InteropLibrary lib) { + return 42; + } + + } + +// + @GenerateInline + public abstract static class UnrollLibraryInlineCustomCacheNode extends Node { + + abstract Object execute(Node node, Object arg); + + @Specialization(guards = "arg == cachedArg", limit = "3") + int doDefault(Object arg, + @Cached("arg") Object cachedArg) { + return 42; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java index ef1422758250..52328dcee4c2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java @@ -57,6 +57,7 @@ import com.oracle.truffle.api.test.ReflectionUtils; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class StateBitTest { /* diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java new file mode 100644 index 000000000000..4ed74eebff3f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Field; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.StatePackingTestFactory.Test64NodeGen; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) +public class StatePackingTest extends AbstractPolyglotTest { + + @GenerateInline + @SuppressWarnings("unused") + @GenerateCached(false) + abstract static class OneNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 1") + static int s0(Node node, int v) { + return v; + } + + } + + @GenerateInline + @SuppressWarnings("unused") + @GenerateCached(false) + abstract static class TwoNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + static int s0(Node node, int v) { + return v; + } + + @Specialization(guards = "v == 1") + static int s1(Node node, int v) { + return v; + } + + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + abstract static class ThreeNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + static int s0(Node node, int v) { + return 1; + } + + @Specialization(guards = "v == 1") + static int s1(Node node, int v) { + return 2; + } + + @Specialization(guards = "v == 2") + static int s2(Node node, int v) { + return 3; + } + + } + + @GenerateInline + @GenerateCached(false) + @SuppressWarnings("unused") + abstract static class TwelveNode extends Node { + + abstract int execute(Node node, int v); + + @Specialization(guards = "v == 0") + static int s0(Node node, int v, @Cached ThreeNode three) { + three.execute(node, v); + return 1; + } + + @Specialization(guards = "v == 1") + static int s1(Node node, int v, @Cached ThreeNode three) { + three.execute(node, v); + return 2; + } + + @Specialization(guards = "v == 2") + static int s2(Node node, int v, @Cached ThreeNode three) { + three.execute(node, v); + return 3; + } + + } + + @SuppressWarnings("unused") + abstract static class Test64Node extends Node { + + abstract int execute(int v); + + @Specialization + int s0(int v, + @Cached TwelveNode c0, + @Cached OneNode c4, + @Cached OneNode c5, + @Cached TwelveNode c2, + @Cached OneNode c6, + @Cached TwelveNode c1, + @Cached OneNode c7, + @Cached OneNode c8, + @Cached ThreeNode c9, + @Cached OneNode c10, + @Cached OneNode c11, + @Cached TwelveNode c3, + @Cached OneNode c12, + @Cached TwoNode c13, + @Cached ThreeNode c14) { + return 1; + } + + } + + /* + * Tests that a node can pack all these cached values in exactly two ints of 32 bits. + */ + @Test + public void testPacking() { + int fieldCount = 0; + for (Field field : Test64NodeGen.class.getDeclaredFields()) { + if (field.getName().startsWith("state")) { + fieldCount++; + } + } + assertEquals(2, fieldCount); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java new file mode 100644 index 000000000000..a184af27b0a9 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; + +@DisableWarningSuppression +public class SuppressWarningTest { + + @SuppressWarnings({"unused", "truffle-inlining"}) + public abstract static class DeprecationTestNode extends Node { + + abstract int execute(int v); + + /* + * Suppress deprecated warning with deprecated. + */ + @SuppressWarnings("deprecated") + @Specialization(guards = "deprecatedGuard(v)") + int s0(int v) { + return v; + } + + /* + * Suppress deprecated warning with all. + */ + @SuppressWarnings("all") + @Specialization(guards = "deprecatedGuard(v)") + int s1(int v) { + return v; + } + + @Specialization + int s2(int v) { + return v; + } + + @Deprecated + static boolean deprecatedGuard(int v) { + return true; + } + + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java index 25c1a92eaba1..d709c76e37e3 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java @@ -43,12 +43,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReentrantLock; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; @@ -235,21 +232,6 @@ static void assertValue(TestRootNode root, int index, Objec } } - static int getSlowPathCount(Node node) { - if (!(node.getRootNode() instanceof SlowPathCounterRoot)) { - throw new IllegalArgumentException("Not instrumented. Instrument with instrumentSlowPath"); - } - return ((SlowPathCounterRoot) node.getRootNode()).getSlowPathCount(); - } - - static void instrumentSlowPath(Node node) { - if (node.getParent() != null) { - throw new IllegalArgumentException("Node already adopted."); - } - SlowPathCounterRoot rootNode = new SlowPathCounterRoot(node); - rootNode.adoptChildren(); - } - public static final class LogListener implements TestExecutionListener { public void afterExecution(TestRootNode node, int index, Object value, Object expectedResult, Object actualResult, boolean last) { @@ -264,54 +246,4 @@ interface TestExecutionListener { } - static class SlowPathCounterRoot extends RootNode { - - @Child Node node; - - private final AtomicInteger lockedCount = new AtomicInteger(0); - private final AtomicInteger slowPathCount = new AtomicInteger(0); - - @SuppressWarnings("serial") - SlowPathCounterRoot(Node node) { - super(null); - this.node = node; - try { - Field lock = RootNode.class.getDeclaredField("lock"); - lock.setAccessible(true); - lock.set(this, new ReentrantLock() { - - @Override - public void lock() { - slowPathCount.incrementAndGet(); - lockedCount.incrementAndGet(); - super.lock(); - } - - @Override - public void unlock() { - lockedCount.decrementAndGet(); - super.unlock(); - } - - }); - } catch (Exception e) { - throw new AssertionError(e); - } - } - - @Override - public Object execute(VirtualFrame frame) { - return null; - } - - boolean isInSlowPath() { - return lockedCount.get() > 0; - } - - int getSlowPathCount() { - return slowPathCount.get(); - } - - } - } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java index 49948a5f0df9..82f7722d9c37 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java @@ -60,6 +60,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class UnsupportedSpecializationTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/WeakCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/WeakCachedTest.java index 78fd2f614cb7..8ca91fdf72c8 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/WeakCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/WeakCachedTest.java @@ -69,7 +69,7 @@ import com.oracle.truffle.api.test.GCUtils; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class WeakCachedTest extends AbstractPolyglotTest { @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/AOTTutorial.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/AOTTutorial.java index dcca349a9fac..fd3716526c8c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/AOTTutorial.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/AOTTutorial.java @@ -218,7 +218,7 @@ protected static boolean isString(Object a, Object b) { @TruffleBoundary @SuppressWarnings("unused") protected static double doDouble(double left, double right, - @Cached("getASTLanguage()") AOTTestLanguage language) { + @Cached(value = "getASTLanguage()", neverDefault = true) AOTTestLanguage language) { return left + right; } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java index 27505ec3d429..2b2cba5f0b56 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/FunctionCall.java @@ -151,7 +151,7 @@ protected Object directCall(Function function, Object argument, @Specialization(replaces = "directCall") protected Object indirectCall(Function function, Object argument, - @Cached("create()") IndirectCallNode callNode) { + @Cached IndirectCallNode callNode) { indirectCall++; return callNode.call(function.getTarget(), new Object[]{argument}); } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java index ac9d66157060..fab1cbd9c0c5 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java @@ -86,7 +86,7 @@ public static class UseInterop extends ExampleNode { int cachedCount = 0; int genericCount = 0; - @Specialization(guards = "operation.accept(target)") + @Specialization(guards = "operation.accept(target)", limit = "3") protected Object interopCached(VirtualFrame frame, TruffleObject target, Object value, // @Cached("target.createOperation()") TruffleObjectOperation operation) { cachedCount++; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java index f430eaa5bc4a..8a7750ac1dad 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/MathPow.java @@ -107,7 +107,7 @@ public static class MathPowNode extends ExampleNode { int doPowDoubleInt; int doPow; - @Specialization(guards = {"base == cachedBase", "exponent == cachedExponent"}) + @Specialization(guards = {"base == cachedBase", "exponent == cachedExponent"}, limit = "3") double doPowCached(double base, int exponent, // @Cached("base") double cachedBase, // @Cached("exponent") int cachedExponent, // @@ -124,7 +124,7 @@ protected static double cachePow(double base, int exponent) { return Math.pow(base, exponent); } - @Specialization(replaces = "doPowCached", guards = {"exponent == cachedExponent", "cachedExponent <= 10"}) + @Specialization(replaces = "doPowCached", guards = {"exponent == cachedExponent", "cachedExponent <= 10"}, limit = "3") double doPowCachedExponent(double base, int exponent, @Cached("exponent") int cachedExponent) { doPowCachedExponent++; double result = 1.0; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java new file mode 100644 index 000000000000..20155efd305e --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_1Factory.Add4AbsNodeGen; +import com.oracle.truffle.api.nodes.Node; + +/** + * See the tutorial description here. + */ +public class NodeInliningExample1_1 { + + @GenerateInline(false) + public abstract static class AbsNode extends Node { + + abstract long execute(long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + } + + @GenerateInline(false) + public abstract static class AddAbsNode extends Node { + + abstract long execute(long left, long right); + + @Specialization + static long add(long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(left) + rightAbs.execute(right); + } + // ... + } + + @GenerateInline(false) + public abstract static class Add4AbsNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(v0, v1); + v = add1.execute(v, v2); + v = add2.execute(v, v3); + return v; + } + + } + + @Test + public void test() { + Add4AbsNode abs = Add4AbsNodeGen.create(); + abs.execute(1, -2, -4, 5); + assertEquals(236, ObjectSizeEstimate.forObject(abs).getCompressedTotalBytes()); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java new file mode 100644 index 000000000000..4fe4d37f45f2 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_2Factory.Add4AbsNodeGen; +import com.oracle.truffle.api.nodes.Node; + +/** + * See the tutorial description here. + */ +public class NodeInliningExample1_2 { + + @GenerateInline + public abstract static class AbsNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + } + + @GenerateInline(false) + public abstract static class AddAbsNode extends Node { + + abstract long execute(long left, long right); + + @Specialization + long add(long left, long right, + @Cached(inline = true) AbsNode leftAbs, + @Cached(inline = true) AbsNode rightAbs) { + return leftAbs.execute(this, left) + rightAbs.execute(this, right); + } + // ... + } + + @GenerateInline(false) + public abstract static class Add4AbsNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(v0, v1); + v = add1.execute(v, v2); + v = add2.execute(v, v3); + return v; + } + + } + + @Test + public void test() { + Add4AbsNode abs = Add4AbsNodeGen.create(); + abs.execute(1, -2, -4, 5); + // 92 bytes down from 236 bytes with partial object inlining + assertEquals(92, ObjectSizeEstimate.forObject(abs).getCompressedTotalBytes()); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java new file mode 100644 index 000000000000..8cc289d6f974 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_3Factory.Add4AbsNodeGen; +import com.oracle.truffle.api.nodes.Node; + +/** + * See the tutorial description here. + */ +public class NodeInliningExample1_3 { + + @GenerateInline + @GenerateCached(false) + public abstract static class AbsNode extends Node { + + abstract long execute(Node node, long value); + + @Specialization(guards = "v >= 0") + static long doInt(long v) { + return v; + } + + @Specialization(guards = "v < 0") + static long doLong(long v) { + return -v; + } + + } + + @GenerateInline + @GenerateCached(false) + public abstract static class AddAbsNode extends Node { + + abstract long execute(Node node, long left, long right); + + @Specialization + static long add(Node node, long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(node, left) + rightAbs.execute(node, right); + } + // ... + } + + @GenerateCached(alwaysInlineCached = true) + @SuppressWarnings("truffle") // ignore inlining candidate warning + public abstract static class Add4AbsNode extends Node { + + abstract long execute(long v0, long v1, long v2, long v3); + + @Specialization + long doInt(long v0, long v1, long v2, long v3, + @Cached AddAbsNode add0, + @Cached AddAbsNode add1, + @Cached AddAbsNode add2) { + long v; + v = add0.execute(this, v0, v1); + v = add1.execute(this, v, v2); + v = add2.execute(this, v, v3); + return v; + } + + } + + @Test + public void test() { + Add4AbsNode abs = Add4AbsNodeGen.create(); + abs.execute(1, -2, -4, 5); + + // 20 bytes down from 256 bytes when everything is inlined. success! + assertEquals(20, ObjectSizeEstimate.forObject(abs).getCompressedTotalBytes()); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java new file mode 100644 index 000000000000..64b9aaa06c31 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.Test; + +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_1Factory.SumArrayNodeGen; +import com.oracle.truffle.api.nodes.Node; + +public class NodeInliningExample2_1 { + + abstract static class AbstractArray { + } + + static class RangeArray extends AbstractArray { + + final int start; + final int end; + + RangeArray(int start, int end) { + this.start = start; + this.end = end; + } + + int[] getStore() { + int[] array = new int[end - start]; + for (int i = 0; i < array.length; i++) { + array[i] = start + i; + } + return array; + } + + } + + static class MaterializedArray extends AbstractArray { + private final int[] array; + + MaterializedArray(int size) { + this.array = new int[size]; + } + + int[] getStore() { + return array; + } + } + + @SuppressWarnings("truffle") + public abstract static class GetStoreNode extends Node { + + abstract int[] execute(Object v0); + + @Specialization + int[] doRange(RangeArray array) { + return array.getStore(); + } + + @Specialization + int[] doMaterialized(MaterializedArray array) { + return array.getStore(); + } + + } + + @SuppressWarnings("truffle-inlining") + public abstract static class SumArrayNode extends Node { + + abstract int execute(Object v0); + + @Specialization(guards = {"cachedClass != null", "cachedClass == array.getClass()"}, limit = "2") + int doCached( + Object array, + @Cached("getCachedClass(array)") Class cachedClass, + @Cached GetStoreNode getStore) { + Object castStore = cachedClass.cast(array); + int[] store = getStore.execute(castStore); + int sum = 0; + for (int element : store) { + sum += element; + TruffleSafepoint.poll(this); + } + return sum; + } + + static Class getCachedClass(Object array) { + if (array instanceof AbstractArray) { + return array.getClass(); + } + return null; + } + } + + @Test + public void test() { + RangeArray array1 = new RangeArray(0, 42); + MaterializedArray array2 = new MaterializedArray(42); + Arrays.fill(array2.array, 1); + + SumArrayNode sum = SumArrayNodeGen.create(); + assertEquals(861, sum.execute(array1)); + assertEquals(42, sum.execute(array2)); + + // 120 bytes without object inlining + assertEquals(120, ObjectSizeEstimate.forObject(sum).getCompressedTotalBytes()); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java new file mode 100644 index 000000000000..e074d4d10921 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.Test; + +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_2Factory.SumArrayNodeGen; +import com.oracle.truffle.api.nodes.Node; + +public class NodeInliningExample2_2 { + + abstract static class AbstractArray { + } + + static final class RangeArray extends AbstractArray { + + final int start; + final int end; + + RangeArray(int start, int end) { + this.start = start; + this.end = end; + } + + int[] getStore() { + int[] array = new int[end - start]; + for (int i = 0; i < array.length; i++) { + array[i] = start + i; + } + return array; + } + + } + + static final class MaterializedArray extends AbstractArray { + private final int[] array; + + MaterializedArray(int size) { + this.array = new int[size]; + } + + int[] getStore() { + return array; + } + } + + @GenerateInline + @GenerateCached(false) + public abstract static class GetStoreNode extends Node { + + abstract int[] execute(Node node, Object v0); + + @Specialization + int[] doRange(RangeArray array) { + return array.getStore(); + } + + @Specialization + int[] doMaterialized(MaterializedArray array) { + return array.getStore(); + } + + } + + @SuppressWarnings("truffle-inlining") + public abstract static class SumArrayNode extends Node { + + abstract int execute(Object v0); + + @Specialization(guards = {"cachedClass != null", "cachedClass == array.getClass()"}, limit = "2") + static int doCached(Object array, + @Bind("this") Node node, + @Cached("getCachedClass(array)") Class cachedClass, + @Cached GetStoreNode getStore) { + Object castStore = cachedClass.cast(array); + int[] store = getStore.execute(node, castStore); + int sum = 0; + for (int element : store) { + sum += element; + TruffleSafepoint.poll(node); + } + return sum; + } + + static Class getCachedClass(Object array) { + if (array instanceof AbstractArray) { + return array.getClass(); + } + return null; + } + } + + @Test + public void test() { + RangeArray array1 = new RangeArray(0, 42); + MaterializedArray array2 = new MaterializedArray(42); + Arrays.fill(array2.array, 1); + + SumArrayNode sum = SumArrayNodeGen.create(); + assertEquals(861, sum.execute(array1)); + assertEquals(42, sum.execute(array2)); + + // 80 bytes down from 120 bytes with partial object inlining + assertEquals(80, ObjectSizeEstimate.forObject(sum).getCompressedTotalBytes()); + } +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java new file mode 100644 index 000000000000..574db66b1cf0 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test.examples; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.Test; + +import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; +import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_3Factory.SumArrayNodeGen; +import com.oracle.truffle.api.nodes.Node; + +public class NodeInliningExample2_3 { + + abstract static class AbstractArray { + + } + + static final class RangeArray extends AbstractArray { + + final int start; + final int end; + + RangeArray(int start, int end) { + this.start = start; + this.end = end; + } + + int[] getStore() { + int[] array = new int[end - start]; + for (int i = 0; i < array.length; i++) { + array[i] = start + i; + } + return array; + } + + } + + static final class MaterializedArray extends AbstractArray { + private final int[] array; + + MaterializedArray(int size) { + this.array = new int[size]; + } + + int[] getStore() { + return array; + } + } + + @GenerateInline + @GenerateCached(false) + public abstract static class GetStoreNode extends Node { + + abstract int[] execute(Node node, Object v0); + + @Specialization + int[] doRange(RangeArray array) { + return array.getStore(); + } + + @Specialization + int[] doMaterialized(MaterializedArray array) { + return array.getStore(); + } + + } + + enum ArrayKind { + + RANGE(RangeArray.class), + MATERIALIZED(MaterializedArray.class); + + final Class type; + + ArrayKind(Class type) { + this.type = type; + } + + static ArrayKind resolve(Object value) { + for (ArrayKind kind : values()) { + if (kind.type.isInstance(value)) { + return kind; + } + } + return null; + } + + } + + @SuppressWarnings({"unused", "truffle-inlining"}) + @ImportStatic(AbstractArray.class) + public abstract static class SumArrayNode extends Node { + + abstract int execute(Object v0); + + @Specialization(guards = {"kind != null", "kind.type == array.getClass()"}, limit = "2", unroll = 2) + static int doDefault(Object array, + @Bind("this") Node node, + @Cached("resolve(array)") ArrayKind kind, + @Cached GetStoreNode getStore) { + Object castStore = kind.type.cast(array); + int[] store = getStore.execute(node, castStore); + int sum = 0; + for (int element : store) { + sum += element; + TruffleSafepoint.poll(node); + } + return sum; + } + + static Class getCachedClass(Object array) { + if (array instanceof AbstractArray) { + return array.getClass(); + } + return null; + } + } + + @Test + public void test() { + + RangeArray array1 = new RangeArray(0, 42); + MaterializedArray array2 = new MaterializedArray(42); + Arrays.fill(array2.array, 1); + + SumArrayNode sum = SumArrayNodeGen.create(); + assertEquals(861, sum.execute(array1)); + assertEquals(42, sum.execute(array2)); + + // 20 bytes down from 120 bytes when everything is inlined and unrolled. success! + assertEquals(20, ObjectSizeEstimate.forObject(sum, 1).getCompressedTotalBytes()); + } +} diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java index 15886d2c46a3..e24637e4075f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/RubyCall.java @@ -137,11 +137,12 @@ public Object doCall(VirtualFrame frame, RubyObject receiverObject, Object metho } } + @SuppressWarnings("truffle-inlining") public abstract static class RubyLookupNode extends Node { public abstract InternalMethod executeLookup(RubyObject receiver, Object method); - @Specialization(guards = "receiver.getRubyClass() == cachedClass", assumptions = "cachedClass.getDependentAssumptions()") + @Specialization(guards = "receiver.getRubyClass() == cachedClass", assumptions = "cachedClass.getDependentAssumptions()", limit = "3") protected static InternalMethod cachedLookup(RubyObject receiver, Object name, // @Cached("receiver.getRubyClass()") RubyClass cachedClass, // @Cached("genericLookup(receiver, name)") InternalMethod cachedLookup) { @@ -156,6 +157,7 @@ protected static InternalMethod genericLookup(RubyObject receiver, Object name) } @ImportStatic(InternalMethod.class) + @SuppressWarnings("truffle-inlining") public abstract static class RubyDispatchNode extends Node { public abstract Object executeDispatch(VirtualFrame frame, InternalMethod function, Object[] packedArguments); @@ -164,7 +166,7 @@ public abstract static class RubyDispatchNode extends Node { * Please note that cachedMethod != METHOD_MISSING is invoked once at specialization * instantiation. It is never executed on the fast path. */ - @Specialization(guards = {"method == cachedMethod", "cachedMethod != METHOD_MISSING"}) + @Specialization(guards = {"method == cachedMethod", "cachedMethod != METHOD_MISSING"}, limit = "3") protected static Object directCall(InternalMethod method, Object[] arguments, // @Cached("method") InternalMethod cachedMethod, // @Cached("create(cachedMethod.getTarget())") DirectCallNode callNode) { @@ -183,7 +185,7 @@ protected static Object methodMissing(InternalMethod method, Object[] arguments) @Specialization(replaces = "directCall", guards = "method != METHOD_MISSING") protected static Object indirectCall(InternalMethod method, Object[] arguments, // - @Cached("create()") IndirectCallNode callNode) { + @Cached IndirectCallNode callNode) { return callNode.call(method.getTarget(), arguments); } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/StableDispatch.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/StableDispatch.java index 45de455945ca..d5a5c61bd14f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/StableDispatch.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/StableDispatch.java @@ -62,7 +62,7 @@ public class StableDispatch { public static class StableDispatchNode extends ExampleNode { - @Specialization(guards = "function == cachedFunction", assumptions = "cachedFunction.getCallTargetStable()") + @Specialization(guards = "function == cachedFunction", assumptions = "cachedFunction.getCallTargetStable()", limit = "3") protected static Object directDispatch(SLFunction function, Object[] arguments, // @Cached("function") SLFunction cachedFunction, // @Cached("create(cachedFunction.getCallTarget())") DirectCallNode callNode) { @@ -71,7 +71,7 @@ protected static Object directDispatch(SLFunction function, Object[] arguments, @Specialization(replaces = "directDispatch") protected static Object indirectDispatch(SLFunction function, Object[] arguments, // - @Cached("create()") IndirectCallNode callNode) { + @Cached IndirectCallNode callNode) { return callNode.call(function.getCallTarget(), arguments); } } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageGroup.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageGroup.java index 405946d3825a..32a23cf8d479 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageGroup.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageGroup.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.api.dsl.test.otherPackage; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -49,6 +50,7 @@ public class OtherPackageGroup { public static class InnerGroup { @GenerateUncached + @GenerateInline(false) public abstract static class InnerNode extends Node { public abstract Object execute(Object arg); @@ -66,6 +68,7 @@ public static InnerGroup create() { } @GenerateUncached + @GenerateInline(false) public abstract static class InnerNode extends Node { public abstract Object execute(Object arg); @@ -76,6 +79,7 @@ int doDefault(int arg) { } @GenerateUncached + @GenerateInline(false) public abstract static class InnerInnerNode extends Node { public abstract Object execute(Object arg); @@ -91,6 +95,7 @@ int doDefault(int arg) { public static class InnerGroup { @GenerateUncached + @GenerateInline(false) public abstract static class InnerInnerNode extends Node { public abstract Object execute(Object arg); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageNode.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageNode.java index 3a323a4c7637..d2b0d472e3a5 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageNode.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/otherPackage/OtherPackageNode.java @@ -40,11 +40,13 @@ */ package com.oracle.truffle.api.dsl.test.otherPackage; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @GenerateUncached +@GenerateInline(false) public abstract class OtherPackageNode extends Node { public abstract Object execute(Object arg); @@ -55,6 +57,7 @@ protected int doDefault(int arg) { } @GenerateUncached + @GenerateInline(false) public abstract static class InnerNode extends Node { public abstract Object execute(Object arg); @@ -74,6 +77,7 @@ public static OtherPackageGroup create() { public static class InnerGroup { @GenerateUncached + @GenerateInline(false) public abstract static class InnerNode extends Node { public abstract Object execute(Object arg); @@ -92,6 +96,7 @@ public static InnerGroup create() { } @GenerateUncached + @GenerateInline(false) public abstract static class InnerNode extends Node { public abstract Object execute(Object arg); @@ -102,6 +107,7 @@ int doDefault(int arg) { } @GenerateUncached + @GenerateInline(false) public abstract static class InnerInnerNode extends Node { public abstract Object execute(Object arg); @@ -115,6 +121,7 @@ int doDefault(int arg) { public static class InnerGroup { @GenerateUncached + @GenerateInline(false) public abstract static class InnerInnerNode extends Node { public abstract Object execute(Object arg); diff --git a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest index c3e545181ad0..d1c5fcb75373 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest @@ -19,8 +19,11 @@ innr public abstract interface static !annotation Shared intf java.lang.annotation.Annotation meth public abstract !hasdefault boolean adopt() meth public abstract !hasdefault boolean allowUncached() +meth public abstract !hasdefault boolean inline() +meth public abstract !hasdefault boolean neverDefault() meth public abstract !hasdefault boolean weak() meth public abstract !hasdefault int dimensions() +meth public abstract !hasdefault java.lang.String inlineMethod() meth public abstract !hasdefault java.lang.String uncached() meth public abstract !hasdefault java.lang.String value() meth public abstract !hasdefault java.lang.String[] parameters() @@ -44,6 +47,11 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.CreateCast intf java.lang.annotation.Annotation meth public abstract java.lang.String[] value() +CLSS public abstract com.oracle.truffle.api.dsl.DSLSupport +meth public static <%0 extends java.lang.Enum> {%%0}[] lookupEnumConstants(java.lang.Class<{%%0}>) +supr java.lang.Object +hfds ENUM_CONSTANTS + CLSS public abstract interface com.oracle.truffle.api.dsl.ExecuteTracingSupport meth public abstract boolean isTracingEnabled() meth public void traceOnEnter(java.lang.Object[]) @@ -76,12 +84,30 @@ intf java.lang.annotation.Annotation CLSS public abstract interface static com.oracle.truffle.api.dsl.GenerateAOT$Provider outer com.oracle.truffle.api.dsl.GenerateAOT -meth public abstract void prepareForAOT(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.nodes.RootNode) +meth public void prepareForAOT(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.nodes.RootNode) +meth public void prepareForAOT(com.oracle.truffle.api.TruffleLanguage,com.oracle.truffle.api.nodes.RootNode,com.oracle.truffle.api.nodes.Node) + +CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateCached + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean alwaysInlineCached() +meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() + +CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateInline + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateNodeFactory anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratePackagePrivate anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) @@ -93,6 +119,7 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateUn anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratedBy anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) @@ -112,6 +139,145 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.ImportStat intf java.lang.annotation.Annotation meth public abstract java.lang.Class[] value() +CLSS public final com.oracle.truffle.api.dsl.InlineSupport +innr public abstract interface static !annotation RequiredField +innr public abstract interface static !annotation RequiredFields +innr public abstract static InlinableField +innr public final static BooleanField +innr public final static ByteField +innr public final static CharField +innr public final static DoubleField +innr public final static FloatField +innr public final static InlineTarget +innr public final static IntField +innr public final static LongField +innr public final static ReferenceField +innr public final static ShortField +innr public final static StateField +meth public !varargs static boolean validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport$InlinableField,com.oracle.truffle.api.dsl.InlineSupport$InlinableField,com.oracle.truffle.api.dsl.InlineSupport$InlinableField[]) +meth public static boolean validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport$InlinableField) +meth public static boolean validate(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.dsl.InlineSupport$InlinableField,com.oracle.truffle.api.dsl.InlineSupport$InlinableField) +supr java.lang.Object +hcls UnsafeField,VarHandleField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$BooleanField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public boolean get(com.oracle.truffle.api.nodes.Node) +meth public com.oracle.truffle.api.dsl.InlineSupport$BooleanField createParentAccessor(java.lang.Class) +meth public static com.oracle.truffle.api.dsl.InlineSupport$BooleanField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,boolean) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$ByteField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public byte get(com.oracle.truffle.api.nodes.Node) +meth public com.oracle.truffle.api.dsl.InlineSupport$ByteField createParentAccessor(java.lang.Class) +meth public static com.oracle.truffle.api.dsl.InlineSupport$ByteField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,byte) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$CharField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public char get(com.oracle.truffle.api.nodes.Node) +meth public com.oracle.truffle.api.dsl.InlineSupport$CharField createParentAccessor(java.lang.Class) +meth public static com.oracle.truffle.api.dsl.InlineSupport$CharField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,char) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$DoubleField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$DoubleField createParentAccessor(java.lang.Class) +meth public double get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$DoubleField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,double) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$FloatField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$FloatField createParentAccessor(java.lang.Class) +meth public float get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$FloatField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,float) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public abstract static com.oracle.truffle.api.dsl.InlineSupport$InlinableField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public final boolean validate(com.oracle.truffle.api.nodes.Node) +supr java.lang.Object +hfds parentField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$InlineTarget + outer com.oracle.truffle.api.dsl.InlineSupport +meth public !varargs static com.oracle.truffle.api.dsl.InlineSupport$InlineTarget create(java.lang.Class,com.oracle.truffle.api.dsl.InlineSupport$InlinableField[]) +meth public <%0 extends com.oracle.truffle.api.dsl.InlineSupport$InlinableField> {%%0} getPrimitive(int,java.lang.Class<{%%0}>) +meth public <%0 extends java.lang.Object> com.oracle.truffle.api.dsl.InlineSupport$ReferenceField<{%%0}> getReference(int,java.lang.Class) +meth public com.oracle.truffle.api.dsl.InlineSupport$StateField getState(int,int) +meth public java.lang.Class getTargetClass() +supr java.lang.Object +hfds targetClass,updaters + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$IntField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$IntField createParentAccessor(java.lang.Class) +meth public int get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$IntField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,int) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$LongField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$LongField createParentAccessor(java.lang.Class) +meth public long get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$LongField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,long) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$ReferenceField<%0 extends java.lang.Object> + outer com.oracle.truffle.api.dsl.InlineSupport +meth public boolean compareAndSet(com.oracle.truffle.api.nodes.Node,{com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0},{com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0}) +meth public com.oracle.truffle.api.dsl.InlineSupport$ReferenceField<{com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0}> createParentAccessor(java.lang.Class) +meth public static <%0 extends java.lang.Object> com.oracle.truffle.api.dsl.InlineSupport$ReferenceField<{%%0}> create(java.lang.invoke.MethodHandles$Lookup,java.lang.String,java.lang.Class<{%%0}>) +meth public void set(com.oracle.truffle.api.nodes.Node,{com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0}) +meth public {com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0} get(com.oracle.truffle.api.nodes.Node) +meth public {com.oracle.truffle.api.dsl.InlineSupport$ReferenceField%0} getVolatile(com.oracle.truffle.api.nodes.Node) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public abstract interface static !annotation com.oracle.truffle.api.dsl.InlineSupport$RequiredField + outer com.oracle.truffle.api.dsl.InlineSupport + anno 0 java.lang.annotation.Repeatable(java.lang.Class value=class com.oracle.truffle.api.dsl.InlineSupport$RequiredFields) + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault int bits() +meth public abstract !hasdefault int dimensions() +meth public abstract !hasdefault java.lang.Class type() +meth public abstract java.lang.Class value() + +CLSS public abstract interface static !annotation com.oracle.truffle.api.dsl.InlineSupport$RequiredFields + outer com.oracle.truffle.api.dsl.InlineSupport + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract com.oracle.truffle.api.dsl.InlineSupport$RequiredField[] value() + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$ShortField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$ShortField createParentAccessor(java.lang.Class) +meth public short get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$ShortField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,short) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField + +CLSS public final static com.oracle.truffle.api.dsl.InlineSupport$StateField + outer com.oracle.truffle.api.dsl.InlineSupport +meth public com.oracle.truffle.api.dsl.InlineSupport$StateField createParentAccessor(java.lang.Class) +meth public com.oracle.truffle.api.dsl.InlineSupport$StateField subUpdater(int,int) +meth public int get(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.InlineSupport$StateField create(java.lang.invoke.MethodHandles$Lookup,java.lang.String) +meth public void set(com.oracle.truffle.api.nodes.Node,int) +supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField +hfds bitLength,bitMask,bitOffset + CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.Introspectable anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) @@ -121,15 +287,18 @@ CLSS public final com.oracle.truffle.api.dsl.Introspection innr public abstract interface static Provider innr public final static SpecializationInfo meth public static boolean isIntrospectable(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.dsl.Introspection$SpecializationInfo getSpecialization(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node,java.lang.String) meth public static com.oracle.truffle.api.dsl.Introspection$SpecializationInfo getSpecialization(com.oracle.truffle.api.nodes.Node,java.lang.String) meth public static java.util.List getSpecializations(com.oracle.truffle.api.nodes.Node) +meth public static java.util.List getSpecializations(com.oracle.truffle.api.nodes.Node,com.oracle.truffle.api.nodes.Node) supr java.lang.Object hfds EMPTY_CACHED,NO_CACHED,data CLSS public abstract interface static com.oracle.truffle.api.dsl.Introspection$Provider outer com.oracle.truffle.api.dsl.Introspection meth public !varargs static com.oracle.truffle.api.dsl.Introspection create(java.lang.Object[]) -meth public abstract com.oracle.truffle.api.dsl.Introspection getIntrospectionData() +meth public com.oracle.truffle.api.dsl.Introspection getIntrospectionData() +meth public com.oracle.truffle.api.dsl.Introspection getIntrospectionData(com.oracle.truffle.api.nodes.Node) CLSS public final static com.oracle.truffle.api.dsl.Introspection$SpecializationInfo outer com.oracle.truffle.api.dsl.Introspection @@ -142,6 +311,11 @@ meth public java.util.List getCachedData(int) supr java.lang.Object hfds cachedData,methodName,state +CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.NeverDefault + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, PARAMETER]) +intf java.lang.annotation.Annotation + CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.NodeChild anno 0 java.lang.annotation.Repeatable(java.lang.Class value=class com.oracle.truffle.api.dsl.NodeChildren) anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) @@ -207,6 +381,7 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.Specializa anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD]) intf java.lang.annotation.Annotation +meth public abstract !hasdefault int unroll() meth public abstract !hasdefault java.lang.Class[] rewriteOn() meth public abstract !hasdefault java.lang.String insertBefore() meth public abstract !hasdefault java.lang.String limit() @@ -242,6 +417,12 @@ meth public abstract void acceptExecute(int,java.lang.Class,java.lang.Classinline with a single + * parameter of type {@link InlineTarget}. For specializing DSL nodes the {@link GenerateInline} + * is sufficient to be enabled for the cached target type, the static inline method will be + * resolved automatically from the generated code of the target type. + *

+ * Inlining is enabled by default if: + *

    + *
  • {@link GenerateInline} is set to true for the declaring specializing node + * type. + *
  • The {@link GenerateCached#alwaysInlineCached()} property is set to true for + * the declaring specializing node type. + *
  • If a target parameter type is a specializing node and has {@link GenerateInline} enabled + * but {@link GenerateCached} disabled. + *
+ * Else, inlining is disabled by default. If a node is inlinable but is not inlined by default, + * the DSL will emit a warning to indicate this possibility. + * + * @see InlineSupport + * @since 23.0 + */ + boolean inline() default false; + + /** + * Instead of looking up the the inline method from the receiver type use an accessible + * enclosing method of a name instead. The method must have a single parameter + * {@link InlineTarget} and return a type compatible to the cached type. This can be useful if + * you want to route calls to the inline method through an abstraction that does not allow + * direct type access to the node classes. + * + * @since 23.0 + */ + String inlineMethod() default ""; + /** * Specifies the bindings used for the $parameters variable in cached or uncached initializers. * @@ -352,6 +388,24 @@ */ boolean adopt() default true; + /** + * Returns true if the cache initializer never returns the default value of its + * parameter type at runtime. For reference types the default value is null, for + * primitive values 0. By default, default values in cache initializers are allowed. The DSL may + * use the default state of a cache for optimizations in the generated code layout. The DSL + * informs with a warning when the use of this property has an effect and is recommended to be + * set. Alternatively to specifying {@link #neverDefault()}, the {@link NeverDefault} annotation + * may be used on the method or field bound by the cache initializer. + *

+ * If a cache initializer returns the illegal default value when this property is set to + * true then the node will throw an {@link IllegalStateException} at runtime. + *

+ * + * @see NeverDefault + * @since 23.0 + */ + boolean neverDefault() default false; + /** * Allows sharing between multiple Cached parameters between multiple specializations or * exported library messages. If no sharing is desired then the {@link Cached cached} parameter diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLAccessor.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLAccessor.java index 4e2c642cb2a4..85926f9ee0ab 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLAccessor.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLAccessor.java @@ -52,4 +52,8 @@ private DSLAccessor() { static NodeSupport nodeAccessor() { return ACCESSOR.nodeSupport(); } + + static RuntimeSupport runtimeAccessor() { + return ACCESSOR.runtimeSupport(); + } } diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java new file mode 100644 index 000000000000..7016d0bbe14f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +/** + * APIs to support share code in generated code. APIs in this class are aggressively deprecated and + * removed in this class. + * + * @since 23.0 + */ +public abstract class DSLSupport { + + private DSLSupport() { + /* + * No instances. + */ + } + + private static final ClassValue[]> ENUM_CONSTANTS = new ClassValue<>() { + @Override + protected Enum[] computeValue(Class type) { + return (Enum[]) type.getEnumConstants(); + } + }; + + /** + * Looks up shared enum constants for DSL generated code. This avoids unnecessary enum arrays in + * the heap when the DSL creates constants with enum values to avoid the memory overhead of + * calling the values() method of enum classes. + * + * @since 23.0 + */ + @SuppressWarnings("unchecked") + public static > T[] lookupEnumConstants(Class c) { + return (T[]) ENUM_CONSTANTS.get(c); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateAOT.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateAOT.java index 3699501df90d..2cebf6cf08f7 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateAOT.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateAOT.java @@ -46,6 +46,7 @@ import java.lang.annotation.Target; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; /** @@ -116,7 +117,20 @@ public interface Provider { * * @since 21.1 */ - void prepareForAOT(TruffleLanguage language, RootNode root); + @SuppressWarnings("unused") + default void prepareForAOT(TruffleLanguage language, RootNode root) { + throw new UnsupportedOperationException(); + } + + /** + * Called and implemented by framework code. Do not use directly. + * + * @since 23.0 + */ + @SuppressWarnings("unused") + default void prepareForAOT(TruffleLanguage language, RootNode root, Node inlinedNode) { + throw new UnsupportedOperationException(); + } } diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateCached.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateCached.java new file mode 100644 index 000000000000..3638dcdc9081 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateCached.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.oracle.truffle.api.nodes.Node; + +/** + * Allows to enable or disable the generation of the cached version of a Truffle DSL node. By + * default any node generates a cached version of a node if it contains {@link Specialization + * specialization methods}. The cached version of a node is accessed through a generated class that + * is named with the suffix Gen of the source node. For example if the node containing + * specializations is named TestNode the generated node will be called + * TestNodeGen. Any node where generated cached is enabled will contain a + * create method. + *

+ * This annotation is useful if only an {@link GenerateUncached uncached} or {@link GenerateInline + * inlinable} version of the node should be generated. It also allows to disable code generation for + * abstract {@link Node nodes} with specializations that should not generate code. + * + * @since 23.0 + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE}) +public @interface GenerateCached { + + /** + * If true enables the generation of a cached version of this {@link Specialization + * specializing} node. It is enabled by default. + * + * @since 23.0 + */ + boolean value() default true; + + /** + * If true enables inheritance of {@link #value()} and + * {@link #alwaysInlineCached()} to subclasses. It is false by default. + * + * @since 23.0 + */ + boolean inherit() default false; + + /** + * Configures whether a {@link Cached cached} {@link GenerateInline inlinable} node is inlined + * by default. By default a warning is emitted if the inline flag is not enabled explicitly. + * This is not necessary for nodes annotated with {@link GenerateInline} they must always inline + * their cached values, as they are otherwise themselves not inlinable. + * + * @since 23.0 + */ + boolean alwaysInlineCached() default false; + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java new file mode 100644 index 000000000000..1f60b921d888 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.oracle.truffle.api.nodes.Node; + +/** + * Generates code for a node that makes this node inlinable when used in {@link Cached cached} + * parameters of {@link Specialization specializations}. Inlining nodes significantly reduces the + * footprint of cached nodes as node allocations are avoided. + * + * A node subclass must fullfill the following requirements in order to be inlinable: + *

    + *
  • All execute methods of a the node must have a {@link Node node} as first parameter type. + *
  • The node has no instance fields. + *
  • The cached node types must not be recursive. + *
+ * + * + * + * @see GenerateCached + * @see GenerateUncached + * @see GenerateAOT + * @since 23.0 + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE}) +public @interface GenerateInline { + + /** + * If true enables the generation of a inlined version of this + * {@link Specialization specializing} node. It is enabled by default. + * + * @since 23.0 + */ + boolean value() default true; + + /** + * If true enables inheritance of {@link #value()} to subclasses. It is + * false by default. + * + * @since 23.0 + */ + boolean inherit() default false; + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java index 33ab498552c5..fc4df2ceb4df 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java @@ -49,11 +49,25 @@ * Annotate nodes or base classes of nodes to generate factory handlers implementing the * {@link NodeFactory} interface. The generated factory handlers class name starts with the source * original class and ends with 'Factory'. - * - * @since 0.8 or earlier + * + * @since 23.0 */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.TYPE}) public @interface GenerateNodeFactory { + /** + * If true enables the generation of node factories of this {@link Specialization + * specializing} node. It is disabled by default. + * + * @since 23.0 + */ + boolean value() default true; + + /** + * Inherits the semantics of the annotation to subclasses. + * + * @since 23.0 + */ + boolean inherit() default true; } diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateUncached.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateUncached.java index 0cf08e84cc2e..1eff98338c4f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateUncached.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateUncached.java @@ -114,6 +114,14 @@ @Target({ElementType.TYPE}) public @interface GenerateUncached { + /** + * If true enables the generation of an uncached version of this + * {@link Specialization specializing} node. It is disabled by default. + * + * @since 19.0 + */ + boolean value() default true; + /** * Inherits the semantics of the annotation to subclasses. * diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java new file mode 100644 index 000000000000..90aa2115c390 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -0,0 +1,1582 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.invoke.VarHandle; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.Objects; + +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.Node; + +import sun.misc.Unsafe; + +/** + * Contains classes to support node object inlining in Truffle. These classes are only needed if + * manual node inlining is implemented. Typically Truffle DSL's {@link GenerateInline} takes care of + * applying these APIs correctly. For manual usage see + * {@link com.oracle.truffle.api.profiles.InlinedBranchProfile} as an example. + * + * @see GenerateInline + * @since 23.0 + */ +public final class InlineSupport { + + private InlineSupport() { + // no instances + } + + /** + * Shortcut to {@link InlinableField#validate(Node) validate} multiple inlinable fields. + * + * @since 23.0 + **/ + public static boolean validate(Node node, InlinableField field0, InlinableField field1, InlinableField... fields) { + field0.validate(node); + field1.validate(node); + for (InlinableField field : fields) { + field.validate(node); + } + return true; + } + + /** + * Shortcut to {@link InlinableField#validate(Node) validate} multiple inlinable fields. + * + * @since 23.0 + **/ + public static boolean validate(Node node, InlinableField field0, InlinableField field1) { + field0.validate(node); + field1.validate(node); + return true; + } + + /** + * Shortcut to {@link InlinableField#validate(Node) validate} multiple inlinable fields. + * + * @since 23.0 + **/ + public static boolean validate(Node node, InlinableField field0) { + field0.validate(node); + return true; + } + + /** + * Used to specify fields for node object inlining in inline methods for the {@link InlineTarget + * inline target}. + *

+ * See {@link InlineTarget} for a full usage example. + * + * @since 23.0 + */ + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.PARAMETER}) + @Repeatable(RequiredFields.class) + public @interface RequiredField { + + /** + * Species which field type is expected. See subclasses of {@link InlinableField}. + * + * @since 23.0 + */ + Class value(); + + /** + * Specifies the number of bits needed for {@link StateField state fields}. This property + * only has an effect for {@link StateField}. The number of bits must be between + * 1 and32. + * + * @since 23.0 + */ + int bits() default 0; + + /** + * 90 Specifies the the value type for {@link ReferenceField reference} required fields. + * This property only has an effect for {@link ReferenceField}. + * + * @since 23.0 + */ + Class type() default InlinableField.class; + + /** + * Specifies the compilation final {@link CompilationFinal#dimensions() dimensions} of the + * required inlined field. This property has only an effect with array types and + * {@link ReferenceField reference fields}. + * + * @since 23.0 + */ + int dimensions() default 0; + } + + /** + * Used to specify multiple {@link RequiredField}. + * + * @see RequiredField + * @since 23.0 + **/ + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.PARAMETER}) + public @interface RequiredFields { + + /** + * Used to specify multiple {@link RequiredField}. + * + * @since 23.0 + **/ + RequiredField[] value(); + + } + + /** + * An inline targert for an inlinable node. This is used as first parameter of an inline method. + * The inline method is used by generated Truffle DSL code as well as manually written inlinable + * nodes. + * + * Usage example: + * + *

+     * public static InlinedCountingConditionProfile inline(
+     *                 @RequiredField(value = StateField.class, bits = 7) //
+     *                 @RequiredField(value = PrimitiveIntField.class) //
+     *                 @RequiredField(value = ReferenceField.class, type = String.class) InlineTarget target) {
+     *     StateField state = target.getState(0, 7);
+     *     PrimitiveIntField primitive = target.getPrimitive(1, PrimitiveIntField.class);
+     *     ReferenceField reference = target.getReference(2, String.class);
+     *
+     *     // pass fields on to inline node
+     * }
+     * 
+ * + * @since 23.0 + */ + public static final class InlineTarget { + + private final Class targetClass; + private final InlinableField[] updaters; + + InlineTarget(Class targetClass, InlinableField[] updaters) { + this.targetClass = targetClass; + this.updaters = updaters; + } + + /** + * Returns static target class this inlining specification was applied. + * + * @since 23.0 + */ + public Class getTargetClass() { + return targetClass; + } + + /** + * Requests a primitive field for a given field index. Fields that are requested from a + * target must match the required fields specified using {@link RequiredField} on the target + * parameter of an inline method otherwise an {@link IncompatibleClassChangeError} is + * thrown. + * + * @since 23.0 + */ + public T getPrimitive(int index, Class fieldClass) { + Objects.requireNonNull(fieldClass); + if (!isPrimitiveField(fieldClass)) { + throw incompatibleAccessError(String.format("Invalid or modified field type. Expected primitive field but got %s.", fieldClass.getName())); + } + return get(index, fieldClass); + } + + /** + * Requests a state field for a given field index. Fields that are requested from a target + * must match the required fields specified using {@link RequiredField} on the target + * parameter of an inline method otherwise an {@link IncompatibleClassChangeError} is + * thrown. + * + * @since 23.0 + */ + public StateField getState(int index, int minimumBits) { + if (minimumBits <= 0 || minimumBits > 32) { + throw new IllegalArgumentException("Invalid minimum bits. Expected >= 0 and <= 32 but was " + minimumBits + "."); + } + StateField field = get(index, StateField.class); + if (!(minimumBits <= field.bitLength)) { + throw incompatibleAccessError( + String.format("Expected minimum state bits %s, but got %s.", + minimumBits, field.bitLength)); + } + return field; + } + + /** + * Requests a reference field for a given field index. Fields that are requested from a + * target must match the required fields specified using {@link RequiredField} on the target + * parameter of an inline method otherwise an {@link IncompatibleClassChangeError} is + * thrown. + * + * @since 23.0 + */ + @SuppressWarnings("unchecked") + public ReferenceField getReference(int index, Class valueClass) { + Objects.requireNonNull(valueClass); + ReferenceField reference = get(index, ReferenceField.class); + Class varType = reference.getFieldClass(); + if (!varType.isAssignableFrom(valueClass)) { + throw incompatibleAccessError(String.format("Expected reference type %s, but got %s. ", + valueClass.getName(), varType.getName())); + } + return (ReferenceField) reference; + } + + private T get(int index, Class fieldClass) throws IncompatibleClassChangeError { + if (index >= updaters.length) { + throw incompatibleAccessError( + String.format("Expected number of updaters %s, but got %s. ", + index + 1, updaters.length)); + } else if (updaters[index].getClass() != fieldClass) { + throw incompatibleAccessError( + String.format("Expected field type %s, but got %s. ", + fieldClass, updaters[index].getClass())); + } + return fieldClass.cast(updaters[index]); + } + + private static IncompatibleClassChangeError incompatibleAccessError(String detailMessage) { + return new IncompatibleClassChangeError( + String.format("Node inlining specification has changed in an incompatible way. %sRecompilation from source may solve this problem.", + detailMessage)); + } + + private static boolean isReferenceField(Class fieldClass) { + return fieldClass == ReferenceField.class; + } + + private static boolean isStateField(Class fieldClass) { + return fieldClass == StateField.class; + } + + private static boolean isPrimitiveField(Class fieldClass) { + return !isReferenceField(fieldClass) && !isStateField(fieldClass); + } + + /** + * Creates an inline target for an inlined node. Intended for use by generated code only. + * + * @since 23.0 + */ + public static InlineTarget create(Class targetClass, InlinableField... updaters) { + Objects.requireNonNull(targetClass); + Objects.requireNonNull(updaters); + for (InlinableField updater : updaters) { + Objects.requireNonNull(updater); + } + return new InlineTarget(targetClass, updaters); + } + + } + + /** + * Base class for inlined field references. + * + * @since 23.0 + */ + /* + * Swap the super class to switch between VarHandleField and UnsafeField. + * + * SVM is not yet ready for the VarHandle implementation. + */ + @SuppressWarnings({"static-method"}) + public abstract static class InlinableField extends UnsafeField { + + final ReferenceField parentField; + + InlinableField(Lookup tclass, String fieldName, Class valueClass) { + this(tclass.lookupClass(), tclass.lookupClass(), tclass, fieldName, valueClass); + } + + InlinableField(Class receiverClass, Class lookupClass, Lookup fieldClass, String fieldName, Class valueClass) { + super(receiverClass, lookupClass, fieldClass, fieldName, valueClass); + this.parentField = null; + } + + InlinableField(InlinableField prev, Class parentClass) { + super(prev); + this.parentField = new ReferenceField<>(parentClass, Node.class, DSLAccessor.nodeAccessor().nodeLookup(), "parent", Node.class); + } + + InlinableField(InlinableField prev) { + super(prev); + this.parentField = prev.parentField; + } + + final Object resolveReceiver(Node node) { + CompilerAsserts.partialEvaluationConstant(this); + CompilerAsserts.partialEvaluationConstant(node); + + // produces better error messages when assertions are enabled. + Object receiver; + if (parentField != null) { + receiver = parentField.get(node); + } else { + receiver = node; + } + return receiver; + } + + private static String getEnclosingSimpleName(Class c) { + if (c.getEnclosingClass() != null) { + return getEnclosingSimpleName(c.getEnclosingClass()) + "." + c.getSimpleName(); + } + return c.getSimpleName(); + } + + /** + * Validates a receiver of an inlined field. This is used for generated DSL code to fail + * early for usage mistakes. + * + * @since 23.0 + */ + public final boolean validate(Node node) { + // this receiver class is more precise than the + // var handle type, so this produces better errors. + validateImpl(resolveReceiver(node)); + // return boolean for convenient use in assertions + return true; + } + + static RuntimeException invalidAccessError(Class expectedClass, Object node) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + String message = String.format("Invalid parameter type passed to updater. Instance of type '%s' expected but was '%s'. " + // + "Did you pass the wrong node to an execute method of an inlined cached node?", + getEnclosingSimpleName(expectedClass), node != null ? getEnclosingSimpleName(node.getClass()) : "null"); + if (node == null) { + throw new NullPointerException(message); + } else { + throw new ClassCastException(message); + } + } + + static RuntimeException invalidValue(Class expectedClass, Object value) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + String message = String.format("Invalid parameter type passed to set. Instance of type '%s' expected but was '%s'. ", + getEnclosingSimpleName(expectedClass), value != null ? getEnclosingSimpleName(value.getClass()) : "null"); + throw new IllegalArgumentException(message); + } + + } + + /** + * Represents a field for updating state fields in inlined nodes. + * + * @since 23.0 + */ + public static final class StateField extends InlinableField { + + final int bitOffset; + final int bitLength; + final int bitMask; + + StateField(Lookup tclass, String fieldName, int offset, int length) { + super(tclass, fieldName, int.class); + this.bitOffset = offset; + this.bitLength = length; + this.bitMask = computeMask(offset, length); + } + + StateField(StateField prev, int offset, int length) { + super(prev); + this.bitOffset = prev.bitOffset + offset; + this.bitLength = length; + this.bitMask = computeMask(bitOffset, length); + } + + StateField(StateField prev, Class parentClass) { + super(prev, parentClass); + this.bitOffset = prev.bitOffset; + this.bitLength = prev.bitLength; + this.bitMask = prev.bitMask; + } + + private static int computeMask(int offset, int length) { + int mask = 0; + for (int i = offset; i < offset + length; i++) { + mask |= 1 << i; + } + return mask; + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public StateField createParentAccessor(Class parentClass) { + return new StateField(this, parentClass); + } + + /** + * Creates a sub updater for a subset of bits in a state field. This method is intended to + * be used by DSL-generated code only. + * + * @since 23.0 + */ + public StateField subUpdater(int newOffset, int newLength) { + if (newOffset < 0) { + throw new IllegalArgumentException("New offset parameter must not be negative."); + } else if (newOffset + newLength > this.bitLength) { + throw new IllegalArgumentException("Illegal new length parameter must not exceed the available bit length."); + } else if (newLength <= 0) { + throw new IllegalArgumentException("Invalid new length."); + } else if (newOffset == 0 && newLength == this.bitLength) { + return this; + } else { + return new StateField(this, newOffset, newLength); + } + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public int get(Node node) { + return (getInt(resolveReceiver(node)) & bitMask) >>> bitOffset; + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, int value) { + assert noBitsLost(value); + Object receiver = resolveReceiver(node); + int newState = getInt(receiver) & ~bitMask | ((value << bitOffset) & bitMask); + setInt(receiver, newState); + } + + private boolean noBitsLost(int providedBits) { + int writtenBits = ((providedBits << bitOffset) & bitMask) >>> bitOffset; + if (writtenBits != providedBits) { + throw new IllegalArgumentException( + String.format("Bits lost in masked state updater set. Provided bits: 0x%s Written bits: 0x%s. " + + "This could indicate a bug in subUpdater indices in the node object inlining logic.", + Integer.toHexString(providedBits), + Integer.toHexString(writtenBits))); + } + return true; + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static StateField create(Lookup lookup, String field) { + return new StateField(lookup, field, 0, 32); + } + + } + + /** + * Represents a field for references in inlined nodes. + * + * @since 23.0 + */ + public static final class ReferenceField extends InlinableField { + + ReferenceField(Class receiverClass, Class lookupFieldClass, Lookup lookup, String fieldName, Class valueClass) { + super(receiverClass, lookupFieldClass, lookup, fieldName, valueClass); + } + + ReferenceField(ReferenceField prev, Class pclass) { + super(prev, pclass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public ReferenceField createParentAccessor(Class parentClass) { + return new ReferenceField<>(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + @SuppressWarnings("unchecked") + public T get(Node node) { + return (T) getObject(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, T value) { + setObject(resolveReceiver(node), value); + } + + /** + * This method returns the value of the target field given a target node using volatile + * semantics. The node parameter must match the class the field was created with. If the + * type is not compatible, an {@link ClassCastException} is thrown. If null is + * provided, then a {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + @SuppressWarnings("unchecked") + public T getVolatile(Node node) { + return (T) getObjectVolatile(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node and expected + * value using compare and set semantics. The node parameter must match the class the field + * was created with. If the type is not compatible, an {@link ClassCastException} is thrown. + * If null is provided, then a {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public boolean compareAndSet(Node node, T expect, T update) { + return compareAndSetObject(resolveReceiver(node), expect, update); + } + + /** + * This method creates a new field given a lookup class, field name and value class. The + * lookup class requires access to the field and must be directly accessible. If the field + * is not found or the field type is not compatible, then an + * {@link IllegalArgumentException} is thrown. The given field must not be final. This + * method is intended to be used by DSL-generated code only. + * + * @since 23.0 + */ + public static ReferenceField create(Lookup nodeClass, String field, Class valueClass) { + Class lookupClass = nodeClass.lookupClass(); + return new ReferenceField<>(lookupClass, lookupClass, nodeClass, field, valueClass); + } + } + + /** + * Represents a field for boolean primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class BooleanField extends InlinableField { + + BooleanField(Lookup tclass, String fieldName) { + super(tclass, fieldName, boolean.class); + } + + BooleanField(BooleanField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public BooleanField createParentAccessor(Class parentClass) { + return new BooleanField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public boolean get(Node node) { + return getBoolean(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, boolean value) { + setBoolean(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static BooleanField create(Lookup nodeClass, String field) { + return new BooleanField(nodeClass, field); + } + } + + /** + * Represents a field for byte primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class ByteField extends InlinableField { + + ByteField(Lookup tclass, String fieldName) { + super(tclass, fieldName, byte.class); + } + + ByteField(ByteField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public ByteField createParentAccessor(Class parentClass) { + return new ByteField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public byte get(Node node) { + return getByte(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, byte value) { + setByte(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static ByteField create(Lookup nodeClass, String field) { + return new ByteField(nodeClass, field); + } + } + + /** + * Represents a field for short primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class ShortField extends InlinableField { + + ShortField(Lookup tclass, String fieldName) { + super(tclass, fieldName, short.class); + } + + ShortField(ShortField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public ShortField createParentAccessor(Class parentClass) { + return new ShortField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public short get(Node node) { + return getShort(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, short value) { + setShort(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static ShortField create(Lookup nodeClass, String field) { + return new ShortField(nodeClass, field); + } + } + + /** + * Represents a field for char primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class CharField extends InlinableField { + + CharField(Lookup tclass, String fieldName) { + super(tclass, fieldName, char.class); + } + + CharField(CharField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public CharField createParentAccessor(Class parentClass) { + return new CharField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public char get(Node node) { + return getChar(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, char value) { + setChar(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static CharField create(Lookup nodeClass, String field) { + return new CharField(nodeClass, field); + } + } + + /** + * Represents a field for float primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class FloatField extends InlinableField { + + FloatField(Lookup tclass, String fieldName) { + super(tclass, fieldName, float.class); + } + + FloatField(FloatField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public FloatField createParentAccessor(Class parentClass) { + return new FloatField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public float get(Node node) { + return getFloat(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, float value) { + setFloat(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static FloatField create(Lookup nodeClass, String field) { + return new FloatField(nodeClass, field); + } + } + + /** + * Represents a field for int primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class IntField extends InlinableField { + + IntField(Lookup tclass, String fieldName) { + super(tclass, fieldName, int.class); + } + + IntField(IntField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public IntField createParentAccessor(Class parentClass) { + return new IntField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public int get(Node node) { + return getInt(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, int value) { + setInt(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static IntField create(Lookup nodeClass, String field) { + return new IntField(nodeClass, field); + } + } + + /** + * Represents a field for long primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class LongField extends InlinableField { + + LongField(Lookup tclass, String fieldName) { + super(tclass, fieldName, long.class); + } + + LongField(LongField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public LongField createParentAccessor(Class parentClass) { + return new LongField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public long get(Node node) { + return getLong(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, long value) { + setLong(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static LongField create(Lookup nodeClass, String field) { + return new LongField(nodeClass, field); + } + } + + /** + * Represents a field for double primitives in inlined nodes. + * + * @since 23.0 + */ + public static final class DoubleField extends InlinableField { + + DoubleField(Lookup tclass, String fieldName) { + super(tclass, fieldName, double.class); + } + + DoubleField(DoubleField prev, Class parentClass) { + super(prev, parentClass); + } + + /** + * This method creates a parent accessor field. A parent accessor allows access to a field + * through a parent pointer. The given class must exactly match the given receiver. This + * method is intended to be used by the DSL-generated code. + * + * @since 23.0 + */ + public DoubleField createParentAccessor(Class parentClass) { + return new DoubleField(this, parentClass); + } + + /** + * This method returns the value of the target field given a target node. The node parameter + * must match the class the field was created with. If the type is not compatible, an + * {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public double get(Node node) { + return getDouble(resolveReceiver(node)); + } + + /** + * This method sets the value of the target field giving the a target node. The node + * parameter must match the class the field was created with. If the type is not compatible, + * an {@link ClassCastException} is thrown. If null is provided, then a + * {@link NullPointerException} is thrown. + * + * @since 23.0 + */ + public void set(Node node, double value) { + setDouble(resolveReceiver(node), value); + } + + /** + * This method creates a new field given a lookup class and a field name. The lookup class + * requires access to the field and must be directly accessible. If the field is not found + * or the field type is not compatible, then an {@link IllegalArgumentException} is thrown. + * The given field must not be final. This method is intended to be used by DSL-generated + * code only. + * + * @since 23.0 + */ + public static DoubleField create(Lookup nodeClass, String field) { + return new DoubleField(nodeClass, field); + } + } + + /** + * Unsafe base class for fields. + */ + @SuppressWarnings("unused") + abstract static class UnsafeField { + + // used for TruffleBaseFeature substitution + final Class declaringClass; + // used for TruffleBaseFeature substitution + final String name; + + // used for precise checking -> exact type + final Class receiverClass; + final long offset; + + final Class fieldClass; + + UnsafeField(UnsafeField prev) { + this.offset = prev.offset; + this.receiverClass = prev.receiverClass; + this.declaringClass = prev.declaringClass; + this.name = prev.name; + this.fieldClass = prev.fieldClass; + } + + UnsafeField(Class receiverClass, Class declaringClass, Lookup declaringLookup, String fieldName, Class valueClass) { + Field field; + try { + this.declaringClass = declaringClass; + this.name = fieldName; + field = java.security.AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Field run() throws NoSuchFieldException { + if (declaringLookup == null) { + return null; + } + return declaringClass.getDeclaredField(fieldName); + } + }); + this.fieldClass = field.getType(); + } catch (PrivilegedActionException pae) { + if (pae.getException() instanceof NoSuchFieldException) { + throw new IllegalArgumentException(String.format("No such field %s.%s.", declaringClass.getName(), fieldName), pae); + } + throw new AssertionError(pae.getException()); + } + if (!fieldClass.isAssignableFrom(valueClass)) { + throw new IllegalArgumentException(String.format("Expected field type %s, but got %s. ", + valueClass.getName(), fieldClass.getName())); + } + final int modifiers = field.getModifiers(); + if (Modifier.isFinal(modifiers)) { + throw new IllegalArgumentException("Must not be final field"); + } + this.receiverClass = receiverClass; + this.offset = U.objectFieldOffset(field); + } + + final boolean validateImpl(Object node) { + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } + return true; + } + + final Class getFieldClass() { + return fieldClass; + } + + final boolean getBoolean(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getBoolean(useNode, offset); + } + + final byte getByte(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getByte(useNode, offset); + } + + final short getShort(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getShort(useNode, offset); + } + + final char getChar(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getChar(useNode, offset); + } + + final int getInt(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getInt(useNode, offset); + } + + final float getFloat(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getFloat(useNode, offset); + } + + final long getLong(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getLong(useNode, offset); + } + + final double getDouble(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getDouble(useNode, offset); + } + + final Object getObject(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getObject(useNode, offset); + } + + final void setBoolean(Object node, boolean v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putBoolean(useNode, offset, v); + } + + final void setByte(Object node, byte v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putByte(useNode, offset, v); + } + + final void setShort(Object node, short v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putShort(useNode, offset, v); + } + + final void setChar(Object node, char v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putChar(useNode, offset, v); + } + + final void setInt(Object node, int v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putInt(useNode, offset, v); + } + + final void setFloat(Object node, float v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putFloat(useNode, offset, v); + } + + final void setLong(Object node, long v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putLong(useNode, offset, v); + } + + final void setDouble(Object node, double v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + U.putDouble(useNode, offset, v); + } + + final void setObject(Object node, Object v) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + if (!fieldClass.isInstance(v) && v != null) { + throw InlinableField.invalidValue(fieldClass, v); + } + U.putObject(useNode, offset, v); + } + + final Object getObjectVolatile(Object node) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + return U.getObjectVolatile(useNode, offset); + } + + final boolean compareAndSetObject(Object node, Object expect, Object update) { + Object useNode; + if (node == null || !receiverClass.isInstance(node)) { + throw InlinableField.invalidAccessError(receiverClass, node); + } else { + useNode = receiverClass.cast(node); + } + if (!fieldClass.isInstance(update) && update != null) { + throw InlinableField.invalidValue(fieldClass, update); + } + return U.compareAndSwapObject(useNode, offset, expect, update); + } + + private static Unsafe getUnsafe() { + try { + return Unsafe.getUnsafe(); + } catch (SecurityException e) { + } + try { + Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafeInstance.setAccessible(true); + return (Unsafe) theUnsafeInstance.get(Unsafe.class); + } catch (Exception e) { + throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e); + } + } + + static final Unsafe U = getUnsafe(); + } + + /* + * Dead code expected to be revitalized as soon as SVM supports better optimizations of var + * handles. + */ + abstract static class VarHandleField { + + private final Class receiverClass; + private final VarHandle handle; + + @SuppressWarnings("unused") + VarHandleField(Class receiverClass, Class lookupClass, Lookup fieldClass, String fieldName, Class valueClass) { + try { + this.receiverClass = receiverClass; + this.handle = fieldClass.findVarHandle(lookupClass, fieldName, valueClass); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new IllegalArgumentException(e); + } + } + + VarHandleField(VarHandleField prev) { + this.handle = prev.handle; + this.receiverClass = prev.receiverClass; + } + + Class getFieldClass() { + return handle.varType(); + } + + /* + * For method handles only an assertion is needed on the fast-path for it to be safe. + */ + final boolean validateImpl(Object node) { + if (!receiverClass.isInstance(node)) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + throw InlinableField.invalidAccessError(receiverClass, node); + } + return true; + } + + final boolean getBoolean(Object node) { + assert validateImpl(node); + return (boolean) handle.get(node); + } + + final byte getByte(Object node) { + assert validateImpl(node); + return (byte) handle.get(node); + } + + final short getShort(Object node) { + assert validateImpl(node); + return (short) handle.get(node); + } + + final char getChar(Object node) { + assert validateImpl(node); + return (char) handle.get(node); + } + + final int getInt(Object node) { + assert validateImpl(node); + return (int) handle.get(node); + } + + final float getFloat(Object node) { + return (float) handle.get(node); + } + + final long getLong(Object node) { + assert validateImpl(node); + return (long) handle.get(node); + } + + final double getDouble(Object node) { + assert validateImpl(node); + return (double) handle.get(node); + } + + final void setBoolean(Object node, boolean v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setByte(Object node, byte v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setShort(Object node, short v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setChar(Object node, char v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setInt(Object node, int v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setFloat(Object node, float v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setLong(Object node, long v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setDouble(Object node, double v) { + assert validateImpl(node); + handle.set(node, v); + } + + final void setObject(Object node, Object v) { + assert validateImpl(node); + handle.set(node, v); + } + + final Object getObject(Object node) { + assert validateImpl(node); + return handle.get(node); + } + + final Object getObjectVolatile(Object node) { + assert validateImpl(node); + return handle.getVolatile(node); + } + + final boolean compareAndSetObject(Object node, Object expect, Object update) { + assert validateImpl(node); + return handle.compareAndSet(node, expect, update); + } + + @Override + public final String toString() { + StringBuilder b = new StringBuilder(getClass().getSimpleName()); + b.append("["); + b.append(handle); + b.append("]"); + return b.toString(); + } + } + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java index 4496ce6ffa79..c8dc0705a4e3 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java @@ -95,6 +95,9 @@ public static boolean isIntrospectable(Node node) { * name. The returned introspection information is not updated when the state of the given * operation node is updated. The implementation of this method might be slow, do not use it in * performance critical code. + *

+ * For a node was {@link GenerateInline inlined} use + * {@link #getSpecialization(Node, Node, String)}. * * @param node a introspectable DSL operation with at least one specialization * @param methodName the Java method name of the specialization to introspect @@ -106,6 +109,21 @@ public static SpecializationInfo getSpecialization(Node node, String methodName) return getIntrospectionData(node).getSpecialization(methodName); } + /** + * Like {@link #getSpecialization(Node, String)} but must be used for nodes that were + * {@link GenerateInline inlined}. + * + * @param inlineParent the inlined parent node. + * @param node a introspectable DSL operation with at least one specialization + * @param methodName the Java method name of the specialization to introspect + * @return introspection info for the method + * @see Introspection example usage + * @since 23.0 + */ + public static SpecializationInfo getSpecialization(Node inlineParent, Node node, String methodName) { + return getIntrospectionData(inlineParent, node).getSpecialization(methodName); + } + /** * Returns introspection information for all declared specializations as unmodifiable list. A * given node must declare at least one specialization and must be annotated with @@ -113,6 +131,9 @@ public static SpecializationInfo getSpecialization(Node node, String methodName) * introspection information is not updated when the state of the given operation node is * updated. The implementation of this method might be slow, do not use it in performance * critical code. + *

+ * For a node was {@link GenerateInline inlined} use + * {@link #getSpecialization(Node, Node, String)}. * * @param node a introspectable DSL operation with at least one specialization * @see Introspection example usage @@ -122,6 +143,19 @@ public static List getSpecializations(Node node) { return getIntrospectionData(node).getSpecializations(); } + /** + * Like {@link #getSpecializations(Node)} but must be used for nodes that were + * {@link GenerateInline inlined}. + * + * @param inlineParent the inlined parent node. + * @param node a introspectable DSL operation with at least one specialization + * @see Introspection example usage + * @since 23.0 + */ + public static List getSpecializations(Node inlineParent, Node node) { + return getIntrospectionData(inlineParent, node).getSpecializations(); + } + private static Introspection getIntrospectionData(Node node) { if (!(node instanceof Provider)) { throw new IllegalArgumentException(String.format("Provided node is not introspectable. Annotate with @%s to make a node introspectable.", Introspectable.class.getSimpleName())); @@ -129,6 +163,13 @@ private static Introspection getIntrospectionData(Node node) { return ((Provider) node).getIntrospectionData(); } + private static Introspection getIntrospectionData(Node inlineParent, Node node) { + if (!(node instanceof Provider)) { + throw new IllegalArgumentException(String.format("Provided node is not introspectable. Annotate with @%s to make a node introspectable.", Introspectable.class.getSimpleName())); + } + return ((Provider) node).getIntrospectionData(inlineParent); + } + /** * Represents dynamic introspection information of a specialization of a DSL operation. * @@ -202,7 +243,7 @@ public List getCachedData(int instanceIndex) { /** * {@inheritDoc} - * + * * @since 21.1 */ @Override @@ -226,7 +267,20 @@ public interface Provider { * * @since 0.22 */ - Introspection getIntrospectionData(); + default Introspection getIntrospectionData() { + throw new UnsupportedOperationException( + "Introspection provider for regular nodes is not implemented. Use Introspection.getSpecializations(Node, Node) with inlinedParent parameter instead."); + } + + /** + * Returns internal reflection data in undefined format. A DSL user must not call this + * method. + * + * @since 23.0 + */ + default Introspection getIntrospectionData(@SuppressWarnings("unused") Node inlinedParent) { + return getIntrospectionData(); + } /** * Factory method to create {@link Node} introspection data. The factory is used to create diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NeverDefault.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NeverDefault.java new file mode 100644 index 000000000000..156ae70a4db0 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NeverDefault.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Useful to annotate methods, fields or parameters bound by any DSL expression to indicate that it + * never returns a null or default primitive value. This may in some case be + * preferential to specifying {@link Cached#neverDefault()} for each cache expression. The DSL emits + * a warnings when the usage of this method is recommended. + * + * @see Cached#neverDefault() + * @since 23.0 + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) +public @interface NeverDefault { + +} diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java index 0e9629343dec..f759b8c05c55 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java @@ -372,4 +372,67 @@ */ String limit() default ""; + /** + * Instructs the specialization to unroll a specialization with multiple instances. Unrolling + * causes fields of the inline cache to be directly stored in the node instead of a chained + * inline cache. At most 8 instances of a specialization can be unrolled to avoid code explosion + * in the interpreter. + *

+ * A common use-case for this feature is to unroll the first instance of an inline cache. It is + * often the case that specializations with multiple instances are instantiated only once. By + * unrolling the first instance we can optimize for this common situation which may lead to + * footprint and interpreter performance improvements. + *

+ * This feature is prone to cause inefficiencies if used too aggressively. Extra care should be + * taken, e.g. the generated code should be inspected and profiled to verify that the new code + * is better than the previous version. + *

+ * Consider the following example: + * + *

+     * class MyNode extends Node {
+     *
+     *     static int limit = 2;
+     *
+     *     abstract int execute(int value);
+     *
+     *     @Specialization(guards = "value == cachedValue", limit = "limit", unroll = 1)
+     *     int doDefault(int value,
+     *                     @Cached("value") int cachedValue) {
+     *         return value;
+     *     }
+     *
+     * }
+     * 
+ * + * In this example we unroll the first instance of an inline cache on int values. + * This is equivalent to manually specifying the following specializations: + * + *
+     * class MyUnrollNode extends Node {
+     *
+     *     static int limit = 2;
+     *
+     *     abstract int execute(int value);
+     *
+     *     @Specialization(guards = "value == cachedValue", limit = "1")
+     *     int doUnrolled0(int value,
+     *                     @Cached("value") int cachedValue) {
+     *         return value;
+     *     }
+     *
+     *     @Specialization(guards = "value == cachedValue", limit = "limit - 1")
+     *     int doDefault(int value,
+     *                     @Cached("value") int cachedValue) {
+     *         return value;
+     *     }
+     * }
+     *
+     * 
+ * + * + * @since 23.0 + */ + int unroll() default 0; + } diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java new file mode 100644 index 000000000000..978573b95d4d --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/SuppressPackageWarnings.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Use to suppress Truffle DSL warnings in whole packages using a package-info.java class. For + * regular Java elements use {@link SuppressWarnings}. + * + * https://github.com/oracle/graal/blob/master/truffle/docs/DSLWarnings.md + * + * @since 23.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.PACKAGE}) +public @interface SuppressPackageWarnings { + + /** + * @since 23.0 + */ + String[] value(); + +} diff --git a/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java b/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java index 2bfabd85dcec..3b5f112b19ac 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java +++ b/truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java @@ -191,7 +191,7 @@ public void testPause() throws ExecutionException, InterruptedException { stop.set(true); for (Future pauseFuture : pauseFutures) { for (Future future : guestActionFutures) { - AbstractPolyglotTest.assertFails(() -> future.get(100, TimeUnit.MILLISECONDS), TimeoutException.class); + AbstractPolyglotTest.assertFails(() -> future.get(10, TimeUnit.MILLISECONDS), TimeoutException.class); } truffleContext.resume(pauseFuture); } @@ -199,7 +199,7 @@ public void testPause() throws ExecutionException, InterruptedException { } @Test - public void testPauseFiniteCountOfInifiniteLoops() throws ExecutionException, InterruptedException { + public void testPauseFiniteCountOfInfiniteLoops() throws ExecutionException, InterruptedException { testCommon( (c, pauseLatch, stop) -> { if (stop.get()) { @@ -224,7 +224,7 @@ public void testPauseFiniteCountOfInifiniteLoops() throws ExecutionException, In stop.set(true); for (Future pauseFuture : pauseFutures) { for (Future future : guestActionFutures) { - AbstractPolyglotTest.assertFails(() -> future.get(100, TimeUnit.MILLISECONDS), TimeoutException.class); + AbstractPolyglotTest.assertFails(() -> future.get(10, TimeUnit.MILLISECONDS), TimeoutException.class); } truffleContext.resume(pauseFuture); } diff --git a/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest index f141b16f6bcc..fd81ee307dd6 100644 --- a/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.instrumentation/snapshot.sigtest @@ -464,11 +464,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -476,8 +473,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -486,6 +485,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() diff --git a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest index 52c85b9159f1..20ef78c8cec3 100644 --- a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest @@ -287,11 +287,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -299,8 +296,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -309,6 +308,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() @@ -326,10 +326,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -338,7 +336,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -425,6 +422,3 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTest.java index ca0708bf05dc..03bd1e162a1a 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTest.java @@ -154,8 +154,8 @@ static class ErrorAccepts1 { @ExportMessage // invalid receiver type - @ExpectError("Invalid parameter type. Expected 'ErrorAccepts1' but was 'Object'. %") - static boolean accepts(Object receiver) { + static boolean accepts(@ExpectError("Invalid parameter type. Expected 'ErrorAccepts1' but was 'Object'. %") // + Object receiver) { return true; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTransitionTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTransitionTest.java index 26c461433497..e1ea3b01395a 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTransitionTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/AcceptsTransitionTest.java @@ -49,6 +49,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -85,7 +86,7 @@ enum Strategy { @ExportLibrary(value = TransitionTestLibrary.class, transitionLimit = "LIMIT") static class StrategyObject implements TruffleObject { static final int LIMIT = 1; - protected Strategy strategy = Strategy.STRATEGY1; + @NeverDefault protected Strategy strategy = Strategy.STRATEGY1; protected final Object mergeKey = "testMerged"; StrategyObject(Strategy s) { diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/CachedLibraryTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/CachedLibraryTest.java index 135a6cf1e703..8fe7bf4164ac 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/CachedLibraryTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/CachedLibraryTest.java @@ -50,6 +50,7 @@ import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Introspectable; import com.oracle.truffle.api.dsl.NodeChild; @@ -81,6 +82,7 @@ import com.oracle.truffle.api.test.AbstractLibraryTest; import com.oracle.truffle.api.test.ExpectError; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class CachedLibraryTest extends AbstractLibraryTest { @GenerateLibrary @@ -264,6 +266,7 @@ public void testAssumption() { @GenerateUncached @SuppressWarnings("unused") + @GenerateInline(false) public abstract static class ConstantNode extends Node { abstract String execute(Object receiver); @@ -293,7 +296,7 @@ public abstract static class FromCached1Node extends Node { abstract String execute(Object receiver); - @Specialization(guards = "receiver == cachedReceiver") + @Specialization(guards = "receiver == cachedReceiver", limit = "3") public static String s1(Object receiver, @Cached("receiver") Object cachedReceiver, @CachedLibrary("cachedReceiver") SomethingLibrary lib) { diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DefaultExportTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DefaultExportTest.java index 7a53b1ad82c0..51fdbc719471 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DefaultExportTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DefaultExportTest.java @@ -254,7 +254,6 @@ static final class DefaultExportError1 { @ExportLibrary(value = DefaultLibrary.class, receiverType = Integer.class) static class DefaultExportError2 { - @ExpectError("Exported methods with explicit receiver must be static.") @ExportMessage int abstractMethod(Integer receiverObject) { return 42; @@ -266,7 +265,6 @@ int abstractMethod(Integer receiverObject) { static class DefaultExportError3 { @ExportMessage - @ExpectError("Invalid exported type. Expected 'Integer' but was 'Object'. %") static int abstractMethod(Object receiverObject) { return 42; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DynamicDispatchTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DynamicDispatchTest.java index 9652692da709..8845d22139cb 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DynamicDispatchTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/DynamicDispatchTest.java @@ -387,7 +387,6 @@ String m0() { // test that cast cannot be override @ExportLibrary(DynamicDispatchLibrary.class) @SuppressWarnings("static-method") - @ExpectError("No message 'cast' found for library DynamicDispatchLibrary.") static final class ErrorOverrideCast1 { @ExportMessage @@ -396,6 +395,7 @@ Class dispatch() { } @ExportMessage + @ExpectError("No message 'cast' found for library DynamicDispatchLibrary.") Object cast() { return null; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportMethodTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportMethodTest.java index 8dade33444a2..3b85fd2aefc7 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportMethodTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportMethodTest.java @@ -48,7 +48,9 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.library.ExportLibrary; @@ -62,7 +64,7 @@ import com.oracle.truffle.api.test.AbstractLibraryTest; import com.oracle.truffle.api.test.ExpectError; -@SuppressWarnings({"unused", "static-method"}) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused", "static-method"}) public class ExportMethodTest extends AbstractLibraryTest { @GenerateLibrary @@ -184,6 +186,7 @@ TestSubClass classArg(TestClass arg) { } @GenerateUncached + @GenerateInline(false) abstract static class CachedTestNode extends Node { abstract String execute(); @@ -363,16 +366,17 @@ public String foo(int arg, return "foo"; } + @NeverDefault String boundMethod() { return "boundMethod"; } } @ExportLibrary(ExportsTestLibrary1.class) - @ExpectError("Class 'com.oracle.truffle.api.library.test.ExportMethodTest.NoLibrary' is not a library annotated with @GenerateLibrary.") static final class ExportsTestObjectError2 { @ExportMessage(library = NoLibrary.class) + @ExpectError("Class 'com.oracle.truffle.api.library.test.ExportMethodTest.NoLibrary' is not a library annotated with @GenerateLibrary.") String foo() { return "foo"; } @@ -380,10 +384,10 @@ String foo() { } @ExportLibrary(ExportsTestLibrary1.class) - @ExpectError("No message 'invalidName' found for library ExportsTestLibrary1.") static class ExportsTestObjectError3 { @ExportMessage + @ExpectError("No message 'invalidName' found for library ExportsTestLibrary1.") String invalidName() { return "foo"; } @@ -391,10 +395,10 @@ String invalidName() { } @ExportLibrary(ExportsTestLibrary1.class) - @ExpectError("No message 'invalidName' found for library ExportsTestLibrary1.") static class ExportsTestObjectError4 { @ExportMessage(name = "invalidName") + @ExpectError("No message 'invalidName' found for library ExportsTestLibrary1.") String foo() { return "foo"; } @@ -410,11 +414,11 @@ static class ExportsTestObjectError5 { @ExportLibrary(ExportsTestLibrary1.class) @ExportLibrary(ExportsTestLibrary2.class) - @ExpectError({"The message name 'foo' is ambiguous for libraries ExportsTestLibrary1 and ExportsTestLibrary2. Disambiguate the library by specifying the library explicitely using " + - "@ExportMessage(library=Library.class)."}) static class ExportsTestObjectError6 { @ExportMessage + @ExpectError({"The message name 'foo' is ambiguous for libraries ExportsTestLibrary1 and ExportsTestLibrary2. Disambiguate the library by specifying the library explicitely using " + + "@ExportMessage(library=Library.class)."}) String foo() { return "foo"; } @@ -430,20 +434,20 @@ String foo() { } @ExportLibrary(ExportsTestLibrary3.class) - @ExpectError("No message 'foo' found for library ExportsTestLibrary3. Did you mean 'foo1', 'foo2', 'foo3'?") static class ExportsTestObjectError8 { @ExportMessage + @ExpectError("No message 'foo' found for library ExportsTestLibrary3. Did you mean 'foo1', 'foo2', 'foo3'?") String foo() { return "foo"; } } + @SuppressWarnings("truffle") @ExportLibrary(ExportsTestLibrary3.class) - @ExpectError({"The method has the same name 'foo1' as a message in the exported library ExportsTestLibrary3. Did you forget to export it? Use @ExportMessage to export the message, @Ignore to " + - "ignore this warning, rename the method or reduce the visibility of the method to private to resolve this warning.", - "Exported library ExportsTestLibrary3 does not export any messages and therefore has no effect. Remove the export declaration to resolve this."}) static class ExportsTestObjectError9 { + @ExpectError({"The method has the same name 'foo1' as a message in the exported library ExportsTestLibrary3. Did you forget to export it? Use @ExportMessage to export the message, @Ignore to " + + "ignore this warning, rename the method or reduce the visibility of the method to private to resolve this warning."}) String foo1() { return "foo1"; } @@ -464,15 +468,13 @@ static class ExportsTestObjectError11 { // wrong primitive type @ExportMessage - @ExpectError("Invalid parameter type. Expected 'int' but was 'double'.%") - public int intArg(double arg) { + public int intArg(@ExpectError("Invalid parameter type. Expected 'int' but was 'double'.%") double arg) { return 42; } // wront class type @ExportMessage - @ExpectError("Invalid parameter type. Expected 'TestClass' but was 'Object'.%") - public TestClass classArg(Object arg) { + public TestClass classArg(@ExpectError("Invalid parameter type. Expected 'TestClass' but was 'Object'.%") Object arg) { return (TestClass) arg; } @@ -485,8 +487,7 @@ public Object interfaceArg(TestInterface arg) { // wrong multiple types @ExportMessage - @ExpectError({"Invalid parameter type. Expected 'int' but was 'byte'.%"}) - public int multiArg(byte intArg, String arg) { + public int multiArg(@ExpectError({"Invalid parameter type. Expected 'int' but was 'byte'.%"}) byte intArg, String arg) { return intArg; } @@ -510,16 +511,6 @@ public int intArg(int arg) { @ExportLibrary(ExportsTestLibrary1.class) static class ExportTestObjectError13 { - @ExportMessage - public String foo(int arg, - @ExpectError("Error parsing expression 'create()': The method create is undefined for the enclosing scope.")// - @Cached Node node) { - return "42"; - } - } - - @ExportLibrary(ExportsTestLibrary1.class) - static class ExportTestObjectError14 { @ExportMessage public String foo(int arg, @ExpectError("Invalid library type Node. Library is not a subclass of Library.")// @@ -610,4 +601,23 @@ public int intArg(int arg) { } + @ExportLibrary(ExportsTestLibrary3.class) + static class WarningSharedTest { + + private final Object storage = new Object(); + + @ExportMessage + String foo1(@ExpectError("The cached parameter may be shared with%") // + @CachedLibrary(limit = "1") ExportsTestLibrary3 shared) { + return "foo1"; + } + + @ExportMessage + String foo2(@ExpectError("The cached parameter may be shared with%") // + @CachedLibrary(limit = "1") ExportsTestLibrary3 shared) { + return "foo1"; + } + + } + } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportNodeTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportNodeTest.java index 1301cc5b1a55..625c03b077e6 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportNodeTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportNodeTest.java @@ -49,20 +49,25 @@ import org.junit.Test; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.library.GenerateLibrary; import com.oracle.truffle.api.library.Library; import com.oracle.truffle.api.library.test.ExportMethodTest.ExportsTestLibrary4; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.AbstractLibraryTest; import com.oracle.truffle.api.test.ExpectError; -@SuppressWarnings({"unused", "hiding"}) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused", "hiding"}) public class ExportNodeTest extends AbstractLibraryTest { @GenerateLibrary @@ -342,7 +347,7 @@ static class MultiExportMethod5 { @ExportMessage(name = "m1") @ExportMessage(name = "m2") static class M { - @Specialization(guards = "receiver == cachedReceiver") + @Specialization(guards = "receiver == cachedReceiver", limit = "3") static String m(MultiExportMethod5 receiver, String arg, @Exclusive @Cached("arg") String cachedArg, @Exclusive @Cached("receiver") MultiExportMethod5 cachedReceiver) { return cachedArg; @@ -423,15 +428,103 @@ static String s0(@SuppressWarnings("unused") WeakReferenceNodeTest object, } + @GenerateInline + @GenerateCached(false) + @GenerateUncached + abstract static class InlinableNode extends Node { + + abstract String execute(Node node, String value); + + @Specialization(guards = "equalsOne(value)") + String one(String value) { + return "one"; + } + + @Specialization(guards = "equalsTwo(value)") + String two(String value) { + return "two"; + } + + static boolean equalsOne(String s) { + return s.equals("1"); + } + + static boolean equalsTwo(String s) { + return s.equals("2"); + } + + } + + @ExportLibrary(MultiNodeExportLibrary.class) + static class ExportInlinedObject1 { + + @ExportMessage + public String m0(String argument, @Exclusive @Cached InlinableNode inlinableNode, + @Bind("$node") Node node) { + return inlinableNode.execute(node, argument); + } + + @ExportMessage + public String m1(String argument, @Exclusive @Cached InlinableNode inlinableNode, + @Bind("$node") Node node) { + return inlinableNode.execute(node, argument); + } + + @ExportMessage + static class M2 { + + @Specialization(guards = "argument == cachedArgument", limit = "3") + static String doCached(ExportInlinedObject1 receiver, String argument, + @Bind("this") Node node, + @Cached("argument") String cachedArgument, + @Cached InlinableNode inlinableNode) { + return inlinableNode.execute(node, argument); + } + + @Specialization(replaces = "doCached") + static String doGeneric(ExportInlinedObject1 receiver, String argument, + @Exclusive @Cached InlinableNode node, + @Bind("this") Node library) { + return node.execute(library, argument); + } + } + } + + @ExportLibrary(MultiNodeExportLibrary.class) + static class ErrorBindThisInExport { + + @ExportMessage + public String m0(String argument, + @ExpectError("Variable 'this' is reserved for library receiver values in methods annotated with @ExportMessage. " + + "If the intention was to access the encapsulting Node for inlined nodes or profiles, you may use '$node' as expression instead.") @Bind("this") Node node) { + throw new AssertionError(); + } + + } + + @Test + public void testExportInlinedObject() { + ExportInlinedObject1 o = new ExportInlinedObject1(); + MultiNodeExportLibrary cached = createCached(MultiNodeExportLibrary.class, o); + assertEquals("one", cached.m0(o, "1")); + assertEquals("two", cached.m0(o, "2")); + assertEquals("one", cached.m1(o, "1")); + assertEquals("two", cached.m1(o, "2")); + assertEquals("one", cached.m2(o, "1")); + assertEquals("two", cached.m2(o, "2")); + + } + // forgot ExportMessage + @SuppressWarnings("truffle") @ExportLibrary(ExportNodeLibrary1.class) - @ExpectError({"The method has the same name 'Foo' as a message in the exported library ExportNodeLibrary1. " + - "Did you forget to export it? " + - "Use @ExportMessage to export the message, @Ignore to ignore this warning, rename the method or reduce the visibility of the method to private to resolve this warning.", - "Exported library ExportNodeLibrary1 does not export any messages and therefore has no effect. Remove the export declaration to resolve this." - }) static class TestObjectError1 { + @ExpectError({"The method has the same name 'Foo' as a message in the exported library ExportNodeLibrary1. " + + "Did you forget to export it? " + + "Use @ExportMessage to export the message, @Ignore to ignore this warning, rename the method or reduce the visibility of the method to private to resolve this warning.", + "Exported library ExportNodeLibrary1 does not export any messages and therefore has no effect. Remove the export declaration to resolve this." + }) static class Foo { } @@ -439,10 +532,10 @@ static class Foo { // no message found @ExportLibrary(ExportNodeLibrary1.class) - @ExpectError("No message 'foo2' found for library ExportNodeLibrary1. Did you mean 'foo'?") static class TestObjectError2 { @ExportMessage + @ExpectError("No message 'foo2' found for library ExportNodeLibrary1. Did you mean 'foo'?") static class Foo2 { } @@ -511,10 +604,10 @@ private void execute(TestObjectError7 receiver) { @ExportLibrary(ExportNodeLibrary1.class) static class TestObjectError8 { - @ExpectError("An @ExportMessage annotated class must not declare any visible methods starting with 'execute'.%") @ExportMessage abstract static class Foo { + @ExpectError("An @ExportMessage annotated class must not declare any visible methods starting with 'execute'.%") abstract void execute(TestObjectError8 receiver); } @@ -525,9 +618,9 @@ abstract static class Foo { static class TestObjectError9 { @ExportMessage - @ExpectError("An @ExportMessage annotated class must not declare any visible methods starting with 'execute'.%") static class Foo { + @ExpectError("An @ExportMessage annotated class must not declare any visible methods starting with 'execute'.%") void execute(TestObjectError9 receiver, int param) { } } @@ -611,7 +704,6 @@ static TestObjectError13 nonTrivalInitializer(TestObjectError13 v) { static class TestObjectError14 { @ExportMessage - @ExpectError("Failed to generate code for @GenerateUncached: The node must not declare any instance variables. Found instance variable Foo.instanceVar. Remove instance variable to resolve this.") abstract static class Foo { Object instanceVar; @@ -650,7 +742,6 @@ static void doFoo(TestObjectError15 receiver, static class TestObjectError16 { @ExportMessage - @ExpectError("Failed to generate code for @GenerateUncached: The node must not declare any instance variables. Found instance variable Foo.guard. Remove instance variable to resolve this.") abstract static class Foo { boolean guard; diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSharingTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSharingTest.java index bd0b193b280c..3822504f6175 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSharingTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSharingTest.java @@ -51,9 +51,10 @@ import org.junit.Test; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.library.GenerateLibrary; @@ -117,6 +118,7 @@ public void testTrivialSingletons() { } @GenerateUncached + @GenerateInline(false) abstract static class TestCached1Node extends Node { abstract String execute(); diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSubclassTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSubclassTest.java index fcffeefb4993..82f6a5fc8601 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSubclassTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ExportSubclassTest.java @@ -367,10 +367,10 @@ String m2() { } } - @ExpectError("No message 'invalidMessageName' found for library ExportSubclassLibrary1.") static class MissingExportWithBaseTypeInvalidMessageError extends ExportRedirectionBase { @ExportMessage + @ExpectError("No message 'invalidMessageName' found for library ExportSubclassLibrary1.") String invalidMessageName() { return ""; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GR18252Test.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GR18252Test.java index 55670050d2ca..baae6b4c40fc 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GR18252Test.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GR18252Test.java @@ -103,13 +103,13 @@ static class AMessages { @ExportMessage public static boolean is(Data receiver, - @Shared("profile") @Cached BranchProfile profile) { + @Shared("profile") @Cached(inline = false) BranchProfile profile) { return false; } @ExportMessage public static Object get(Data receiver, - @Shared("profile") @Cached BranchProfile profile) { + @Shared("profile") @Cached(inline = false) BranchProfile profile) { return null; } } @@ -121,8 +121,8 @@ static class BMessages extends AMessages { public static class Is { @Specialization public static boolean is(Data receiver, - @Cached BranchProfile p0, - @Cached BranchProfile p1) { + @Cached(inline = false) BranchProfile p0, + @Cached(inline = false) BranchProfile p1) { return true; } } @@ -141,8 +141,8 @@ static class CMessagesNoWarn1 extends AMessages { @ExportMessage public static boolean is(Data receiver, - @Cached BranchProfile p0, - @Cached BranchProfile p1) { + @Cached(inline = false) BranchProfile p0, + @Cached(inline = false) BranchProfile p1) { return true; } @@ -158,8 +158,8 @@ static class CMessagesNoWarn2 extends AMessages { public static class Is { @Specialization public static boolean is(Data receiver, - @Cached BranchProfile profile, - @Cached BranchProfile profile1) { + @Cached(inline = false) BranchProfile profile, + @Cached(inline = false) BranchProfile profile1) { return true; } } @@ -173,7 +173,7 @@ static class CMessagesNoWarn3 extends BMessages { @ExportMessage public static Object get(Data receiver, - @Cached BranchProfile profile1) { + @Cached(inline = false) BranchProfile profile1) { return receiver.value; } } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java index 706b782eb072..9bd9893787b3 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/GenerateLibraryTest.java @@ -105,7 +105,7 @@ boolean accepts(@Cached(value = "this") Sample cachedS) { } @ExportMessage - static final String call(Sample s, @Cached(value = "0", uncached = "1") int cached) { + static final String call(Sample s, @Cached(value = "0", uncached = "1", neverDefault = false) int cached) { if (cached == 0) { if (s.name != null) { return s.name + "_cached"; @@ -593,8 +593,8 @@ protected String call(Object receiver) { public abstract static class AbstractErrorLibrary11 extends Library { @SuppressWarnings("static-method") - @ExpectError("Library messages must be public.") - protected String call(Object receiver) { + @ExpectError("Library messages must be public or protected.%") + String call(Object receiver) { return "default"; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/MultiExportTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/MultiExportTest.java index 1ab79fb265fa..01d0e4fcd453 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/MultiExportTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/MultiExportTest.java @@ -58,7 +58,7 @@ import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest; import com.oracle.truffle.api.test.ExpectError; -@SuppressWarnings({"static-method", "unused"}) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "static-method", "unused"}) public class MultiExportTest extends AbstractParametrizedLibraryTest { @Parameters(name = "{0}") diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/NodeAdoptionTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/NodeAdoptionTest.java index d3e18c0d3f7f..856e3ce8f4bb 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/NodeAdoptionTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/NodeAdoptionTest.java @@ -47,6 +47,7 @@ import org.junit.Test; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; @@ -56,7 +57,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.AbstractLibraryTest; -@SuppressWarnings({"unused", "static-method"}) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused", "static-method"}) public class NodeAdoptionTest extends AbstractLibraryTest { @GenerateLibrary @@ -71,7 +72,7 @@ static final class NodeAdoptionObject { @ExportMessage static class M0 { - @Specialization(guards = "innerNode.execute(receiver)") + @Specialization(guards = "innerNode.execute(receiver)", limit = "1") @CompilerDirectives.TruffleBoundary static String doM0(NodeAdoptionObject receiver, @Cached(allowUncached = true) InnerNode innerNode, @@ -86,6 +87,7 @@ static String doM0(NodeAdoptionObject receiver, } } + @GenerateInline(false) abstract static class InnerNode extends Node { abstract boolean execute(Object argument); diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ReflectionTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ReflectionTest.java index f39bf62b9be1..b9411312d643 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ReflectionTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/ReflectionTest.java @@ -56,7 +56,7 @@ import com.oracle.truffle.api.library.ReflectionLibrary; import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest; -@SuppressWarnings("unused") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "unused"}) public class ReflectionTest extends AbstractParametrizedLibraryTest { @Parameters(name = "{0}") diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/SlowPathCallTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/SlowPathCallTest.java index de557d6992a4..d1901a026c7a 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/SlowPathCallTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/SlowPathCallTest.java @@ -50,6 +50,7 @@ import com.oracle.truffle.api.library.Library; import com.oracle.truffle.api.test.AbstractLibraryTest; +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class SlowPathCallTest extends AbstractLibraryTest { @GenerateLibrary diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/UncachedEncapsulatedNodeTest.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/UncachedEncapsulatedNodeTest.java index c46303c0b3df..1f93a52a1a95 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/UncachedEncapsulatedNodeTest.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/UncachedEncapsulatedNodeTest.java @@ -58,7 +58,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.AbstractLibraryTest; -@SuppressWarnings("static-method") +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing", "static-method"}) public class UncachedEncapsulatedNodeTest extends AbstractLibraryTest { @GenerateLibrary diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageBaseObject.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageBaseObject.java index 39543ff72ccc..4ae299f89a96 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageBaseObject.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageBaseObject.java @@ -62,7 +62,7 @@ public String m0() { } @ExportMessage - public String m1(@Cached("this.value") int cachedValue) { + public String m1(@Cached(value = "this.value", neverDefault = false) int cachedValue) { return "m1_base"; } @@ -76,7 +76,7 @@ public static String doDefault(OtherPackageBaseObject receiver) { @ExportMessage public static class M3 { - @Specialization(guards = "receiver.value == value") + @Specialization(guards = "receiver.value == value", limit = "3") public static String doDefault(OtherPackageBaseObject receiver, @Cached("receiver.value") int value) { return "m3_base"; } diff --git a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageNode.java b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageNode.java index fae756763540..05339934eef1 100644 --- a/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageNode.java +++ b/truffle/src/com.oracle.truffle.api.library.test/src/com/oracle/truffle/api/library/test/otherPackage/OtherPackageNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.api.library.test.otherPackage; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -47,6 +48,7 @@ public class OtherPackageNode { @GenerateUncached + @GenerateInline(false) public abstract static class InnerDSLNode extends Node { public abstract Object execute(); diff --git a/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest index e61d20c56c0a..cb888cbe8444 100644 --- a/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.library/snapshot.sigtest @@ -194,11 +194,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -206,8 +203,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -216,6 +215,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() diff --git a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest index 56a5a4c837a9..5b8f90f3cc2b 100644 --- a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest @@ -40,11 +40,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -52,8 +49,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -62,6 +61,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() @@ -520,10 +520,8 @@ meth public abstract !hasdefault java.lang.String since() CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -532,7 +530,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -619,6 +616,3 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - diff --git a/truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java b/truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java index fd8000196c46..8e812f721e72 100644 --- a/truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java +++ b/truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/DynamicObject.java @@ -49,6 +49,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.interop.TruffleObject; import sun.misc.Unsafe; @@ -169,6 +170,7 @@ private static IllegalArgumentException illegalShapeProperties() { * @since 0.8 or earlier * @see Shape */ + @NeverDefault public final Shape getShape() { return getShapeHelper(shape); } diff --git a/truffle/src/com.oracle.truffle.api.profiles/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.profiles/snapshot.sigtest index d8c16ee5c870..61de6091f6b9 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.profiles/snapshot.sigtest @@ -11,6 +11,7 @@ CLSS public final com.oracle.truffle.api.profiles.BranchProfile meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.BranchProfile create() meth public static com.oracle.truffle.api.profiles.BranchProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedBranchProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public void disable() meth public void enter() meth public void reset() @@ -23,19 +24,38 @@ meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.ByteValueProfile create() meth public static com.oracle.truffle.api.profiles.ByteValueProfile createIdentityProfile() meth public static com.oracle.truffle.api.profiles.ByteValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedByteValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public void disable() meth public void reset() supr com.oracle.truffle.api.profiles.Profile hfds DISABLED,GENERIC,SPECIALIZED,UNINITIALIZED,cachedValue,state -CLSS public abstract com.oracle.truffle.api.profiles.ConditionProfile -meth public abstract boolean profile(boolean) +CLSS public com.oracle.truffle.api.profiles.ConditionProfile +meth public boolean profile(boolean) +meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.ConditionProfile create() meth public static com.oracle.truffle.api.profiles.ConditionProfile createBinaryProfile() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public static com.oracle.truffle.api.profiles.ConditionProfile createCountingProfile() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public static com.oracle.truffle.api.profiles.ConditionProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedConditionProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable() +meth public void reset() supr com.oracle.truffle.api.profiles.Profile -hcls Binary,Counting,Disabled +hfds DISABLED,wasFalse,wasTrue +hcls Counting,Disabled + +CLSS public final com.oracle.truffle.api.profiles.CountingConditionProfile +meth public boolean profile(boolean) +meth public java.lang.String toString() +meth public static com.oracle.truffle.api.profiles.CountingConditionProfile create() +meth public static com.oracle.truffle.api.profiles.CountingConditionProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedCountingConditionProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable() +meth public void reset() +supr com.oracle.truffle.api.profiles.Profile +hfds DISABLED,MAX_VALUE,falseCount,trueCount CLSS public final com.oracle.truffle.api.profiles.DoubleValueProfile meth public double profile(double) @@ -43,6 +63,7 @@ meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.DoubleValueProfile create() meth public static com.oracle.truffle.api.profiles.DoubleValueProfile createRawIdentityProfile() meth public static com.oracle.truffle.api.profiles.DoubleValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedDoubleValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public void disable() meth public void reset() supr com.oracle.truffle.api.profiles.Profile @@ -54,14 +75,162 @@ meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.FloatValueProfile create() meth public static com.oracle.truffle.api.profiles.FloatValueProfile createRawIdentityProfile() meth public static com.oracle.truffle.api.profiles.FloatValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedFloatValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public void disable() meth public void reset() supr com.oracle.truffle.api.profiles.Profile hfds DISABLED,GENERIC,SPECIALIZED,UNINITIALIZED,cachedRawValue,cachedValue,state +CLSS public final com.oracle.truffle.api.profiles.InlinedBranchProfile +meth public boolean wasEntered(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedBranchProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedBranchProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable(com.oracle.truffle.api.nodes.Node) +meth public void enter(com.oracle.truffle.api.nodes.Node) +meth public void reset(com.oracle.truffle.api.nodes.Node) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,REQUIRED_STATE_BITS,state + +CLSS public final com.oracle.truffle.api.profiles.InlinedByteValueProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public byte profile(com.oracle.truffle.api.nodes.Node,byte) +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedByteValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedByteValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue + +CLSS public final com.oracle.truffle.api.profiles.InlinedConditionProfile +meth public boolean profile(com.oracle.truffle.api.nodes.Node,boolean) +meth public boolean wasFalse(com.oracle.truffle.api.nodes.Node) +meth public boolean wasTrue(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedConditionProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedConditionProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable(com.oracle.truffle.api.nodes.Node) +meth public void reset(com.oracle.truffle.api.nodes.Node) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,REQUIRED_STATE_BITS,state + +CLSS public final com.oracle.truffle.api.profiles.InlinedCountingConditionProfile +meth public boolean profile(com.oracle.truffle.api.nodes.Node,boolean) +meth public boolean wasFalse(com.oracle.truffle.api.nodes.Node) +meth public boolean wasTrue(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedCountingConditionProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedCountingConditionProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable(com.oracle.truffle.api.nodes.Node) +meth public void reset(com.oracle.truffle.api.nodes.Node) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,MAX_VALUE,falseCount,trueCount + +CLSS public final com.oracle.truffle.api.profiles.InlinedDoubleValueProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public double profile(com.oracle.truffle.api.nodes.Node,double) +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedDoubleValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedDoubleValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue0 + +CLSS public final com.oracle.truffle.api.profiles.InlinedExactClassProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public <%0 extends java.lang.Object> {%%0} profile(com.oracle.truffle.api.nodes.Node,{%%0}) +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedExactClassProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedExactClassProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue + +CLSS public final com.oracle.truffle.api.profiles.InlinedFloatValueProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public float profile(com.oracle.truffle.api.nodes.Node,float) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedFloatValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedFloatValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue + +CLSS public final com.oracle.truffle.api.profiles.InlinedIntValueProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public int profile(com.oracle.truffle.api.nodes.Node,int) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedIntValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedIntValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue + +CLSS public final com.oracle.truffle.api.profiles.InlinedLongValueProfile +fld protected final com.oracle.truffle.api.dsl.InlineSupport$StateField state +fld protected final static int GENERIC = 2 +fld protected final static int REQUIRED_STATE_BITS = 2 +fld protected final static int SPECIALIZED = 1 +fld protected final static int UNINITIALIZED = 0 +meth public final void disable(com.oracle.truffle.api.nodes.Node) +meth public final void reset(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public long profile(com.oracle.truffle.api.nodes.Node,long) +meth public static com.oracle.truffle.api.profiles.InlinedLongValueProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedLongValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,cachedValue + +CLSS public final com.oracle.truffle.api.profiles.InlinedLoopConditionProfile +meth public boolean inject(com.oracle.truffle.api.nodes.Node,boolean) +meth public boolean profile(com.oracle.truffle.api.nodes.Node,boolean) +meth public boolean wasFalse(com.oracle.truffle.api.nodes.Node) +meth public boolean wasTrue(com.oracle.truffle.api.nodes.Node) +meth public java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public static com.oracle.truffle.api.profiles.InlinedLoopConditionProfile getUncached() +meth public static com.oracle.truffle.api.profiles.InlinedLoopConditionProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public void disable(com.oracle.truffle.api.nodes.Node) +meth public void profileCounted(com.oracle.truffle.api.nodes.Node,long) +meth public void reset(com.oracle.truffle.api.nodes.Node) +supr com.oracle.truffle.api.profiles.InlinedProfile +hfds DISABLED,MAX_VALUE,falseCount,trueCount + +CLSS public abstract com.oracle.truffle.api.profiles.InlinedProfile +meth public abstract java.lang.String toString(com.oracle.truffle.api.nodes.Node) +meth public abstract void disable(com.oracle.truffle.api.nodes.Node) +meth public abstract void reset(com.oracle.truffle.api.nodes.Node) +meth public final java.lang.String toString() +supr java.lang.Object + CLSS public final com.oracle.truffle.api.profiles.IntValueProfile meth public int profile(int) meth public java.lang.String toString() +meth public static com.oracle.truffle.api.profiles.InlinedIntValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public static com.oracle.truffle.api.profiles.IntValueProfile create() meth public static com.oracle.truffle.api.profiles.IntValueProfile createIdentityProfile() meth public static com.oracle.truffle.api.profiles.IntValueProfile getUncached() @@ -73,6 +242,7 @@ hfds DISABLED,GENERIC,SPECIALIZED,UNINITIALIZED,cachedValue,state CLSS public final com.oracle.truffle.api.profiles.LongValueProfile meth public java.lang.String toString() meth public long profile(long) +meth public static com.oracle.truffle.api.profiles.InlinedLongValueProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) meth public static com.oracle.truffle.api.profiles.LongValueProfile create() meth public static com.oracle.truffle.api.profiles.LongValueProfile createIdentityProfile() meth public static com.oracle.truffle.api.profiles.LongValueProfile getUncached() @@ -87,6 +257,7 @@ meth public boolean profile(boolean) meth public java.lang.String toString() meth public static com.oracle.truffle.api.profiles.LoopConditionProfile create() meth public static com.oracle.truffle.api.profiles.LoopConditionProfile createCountingProfile() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="") meth public static com.oracle.truffle.api.profiles.LoopConditionProfile getUncached() meth public void disable() meth public void profileCounted(long) @@ -120,6 +291,8 @@ supr com.oracle.truffle.api.nodes.NodeCloneable CLSS public abstract com.oracle.truffle.api.profiles.ValueProfile meth public abstract <%0 extends java.lang.Object> {%%0} profile({%%0}) +meth public static com.oracle.truffle.api.profiles.InlinedExactClassProfile inline(com.oracle.truffle.api.dsl.InlineSupport$InlineTarget) +meth public static com.oracle.truffle.api.profiles.ValueProfile create() meth public static com.oracle.truffle.api.profiles.ValueProfile createClassProfile() meth public static com.oracle.truffle.api.profiles.ValueProfile createIdentityProfile() meth public static com.oracle.truffle.api.profiles.ValueProfile getUncached() diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/AbstractInlinedValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/AbstractInlinedValueProfile.java new file mode 100644 index 000000000000..9dde974eeb88 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/AbstractInlinedValueProfile.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +abstract class AbstractInlinedValueProfile extends InlinedProfile { + + protected static final int UNINITIALIZED = 0; + protected static final int SPECIALIZED = 1; + protected static final int GENERIC = 2; + + protected static final int REQUIRED_STATE_BITS = 2; + + protected final StateField state; + + AbstractInlinedValueProfile() { + this.state = null; + } + + AbstractInlinedValueProfile(InlineTarget target) { + this.state = target.getState(0, REQUIRED_STATE_BITS); + } + + @Override + public final void disable(Node node) { + if (state == null) { + return; + } + this.state.set(node, GENERIC); + } + + @Override + public final void reset(Node node) { + if (state == null) { + return; + } + this.state.set(node, UNINITIALIZED); + } + + final boolean isGeneric(Node node) { + if (state == null) { + return true; + } + return this.state.get(node) == GENERIC; + } + + final boolean isUninitialized(Node node) { + if (state == null) { + return false; + } + return this.state.get(node) == UNINITIALIZED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/BranchProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/BranchProfile.java index b387210aa103..e34b3a215f56 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/BranchProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/BranchProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.nodes.Node; /** @@ -87,19 +89,6 @@ public void enter() { } } - /** - * Call to create a new instance of a branch profile. - * - * @since 0.10 - */ - public static BranchProfile create() { - if (Profile.isProfilingEnabled()) { - return new BranchProfile(); - } else { - return getUncached(); - } - } - /** * {@inheritDoc} * @@ -133,12 +122,36 @@ public void reset() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(BranchProfile.class); + return toStringDisabled(); } else { return toString(BranchProfile.class, !visited, false, "VISITED"); } } + /** + * Call to create a new instance of a branch profile. + * + * @since 0.10 + */ + @NeverDefault + public static BranchProfile create() { + if (isProfilingEnabled()) { + return new BranchProfile(); + } else { + return getUncached(); + } + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedBranchProfile inline(InlineTarget target) { + return InlinedBranchProfile.inline(target); + } + /** * Returns the uncached version of the profile. The uncached version of a profile does nothing. * diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java index 626eb992cbc3..3a611e662a52 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ByteValueProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -144,7 +146,7 @@ public void reset() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(ByteValueProfile.class); + return toStringDisabled(); } else { return toString(ByteValueProfile.class, state == UNINITIALIZED, state == GENERIC, // String.format("value == (byte)%s", cachedValue)); @@ -157,6 +159,7 @@ public String toString() { * @see ByteValueProfile * @since 0.10 */ + @NeverDefault public static ByteValueProfile createIdentityProfile() { return create(); } @@ -167,8 +170,9 @@ public static ByteValueProfile createIdentityProfile() { * @see ByteValueProfile * @since 22.1 */ + @NeverDefault public static ByteValueProfile create() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new ByteValueProfile(); } else { return DISABLED; @@ -183,6 +187,17 @@ public static ByteValueProfile create() { public static ByteValueProfile getUncached() { return DISABLED; } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedByteValueProfile inline(InlineTarget target) { + return InlinedByteValueProfile.inline(target); + } + } class ByteProfileSnippets { @@ -192,7 +207,7 @@ class Node { // BEGIN: com.oracle.truffle.api.profiles.ByteProfileSnippets.ByteProfileNode#profile class ByteProfileNode extends Node { - final ByteValueProfile profile = ByteValueProfile.createIdentityProfile(); + final ByteValueProfile profile = ByteValueProfile.create(); byte execute(byte input) { byte profiledValue = profile.profile(input); diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ConditionProfile.java index bb3107806812..b12b63ce7b2d 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ConditionProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ConditionProfile.java @@ -42,10 +42,15 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

- * ConditionProfiles are useful to profile the outcome of conditions. + * ConditionProfiles are useful to profile the outcome of conditions. A regular condition profile + * keeps track of a binary state, for each branch whether a branch was hit or not and communicates + * this to the compiler. If frequency information for each branch should be collected use + * {@link CountingConditionProfile} instead. *

* *

@@ -54,7 +59,7 @@ *

  * class AbsoluteNode extends Node {
  *
- *     final ConditionProfile greaterZeroProfile = ConditionProfile.create{Binary,Counting}Profile();
+ *     final ConditionProfile greaterZeroProfile = ConditionProfile.create();
  *
  *     void execute(int value) {
  *         if (greaterZeroProfile.profile(value >= 0)) {
@@ -68,33 +73,97 @@
  *
  * {@inheritDoc}
  *
- * @see #createBinaryProfile()
- * @see #createCountingProfile()
+ * @see #create()
  * @see LoopConditionProfile
+ * @see CountingConditionProfile
  * @since 0.10
  */
-public abstract class ConditionProfile extends Profile {
+public class ConditionProfile extends Profile {
+
+    private static final ConditionProfile DISABLED;
+    static {
+        ConditionProfile profile = new ConditionProfile();
+        profile.disable();
+        DISABLED = profile;
+    }
 
     ConditionProfile() {
     }
 
+    @CompilationFinal private boolean wasTrue;
+    @CompilationFinal private boolean wasFalse;
+
     /** @since 0.10 */
-    public abstract boolean profile(boolean value);
+    public boolean profile(boolean value) {
+        if (value) {
+            if (!wasTrue) {
+                CompilerDirectives.transferToInterpreterAndInvalidate();
+                wasTrue = true;
+            }
+            return true;
+        } else {
+            if (!wasFalse) {
+                CompilerDirectives.transferToInterpreterAndInvalidate();
+                wasFalse = true;
+            }
+            return false;
+        }
+    }
 
     /**
-     * Returns a {@link ConditionProfile} that speculates on conditions to be never
-     * true or to be never false. Additionally to a binary profile this
-     * method returns a condition profile that also counts the number of times the condition was
-     * true and false. This information is reported to the underlying optimization system using
-     * {@link CompilerDirectives#injectBranchProbability(double, boolean)}. Condition profiles are
-     * intended to be used as part of if conditions.
+     * {@inheritDoc}
+     *
+     * @since 23.0
+     */
+    @Override
+    public void disable() {
+        this.wasFalse = true;
+        this.wasTrue = true;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @since 23.0
+     */
+    @Override
+    public void reset() {
+        if (this == DISABLED) {
+            return;
+        }
+        this.wasFalse = false;
+        this.wasTrue = false;
+    }
+
+    boolean wasTrue() {
+        return wasTrue;
+    }
+
+    boolean wasFalse() {
+        return wasFalse;
+    }
+
+    /**
+     * {@inheritDoc}
      *
-     * @see ConditionProfile
-     * @see #createBinaryProfile()
+     * @since 23.0
+     */
+    @Override
+    public String toString() {
+        if (this == DISABLED) {
+            return toStringDisabled();
+        } else {
+            return String.format("%s(wasTrue=%s, wasFalse=%s)@%x", getClass().getSimpleName(), wasTrue, wasFalse, hashCode());
+        }
+    }
+
+    /**
      * @since 0.10
+     * @deprecated use {@link CountingConditionProfile} instead
      */
+    @Deprecated
     public static ConditionProfile createCountingProfile() {
-        if (Profile.isProfilingEnabled()) {
+        if (isProfilingEnabled()) {
             return Counting.createLazyLoadClass();
         } else {
             return Disabled.INSTANCE;
@@ -102,29 +171,27 @@ public static ConditionProfile createCountingProfile() {
     }
 
     /**
-     * Returns a {@link ConditionProfile} that speculates on conditions to be never
-     * true or to be never false. Condition profiles are intended to be
-     * used as part of if conditions.
-     *
-     * @see ConditionProfile
-     * @see ConditionProfile#createCountingProfile()
      * @since 0.10
+     * @deprecated use {@link ConditionProfile#create()} instead.
      */
+    @Deprecated
+    @NeverDefault
     public static ConditionProfile createBinaryProfile() {
-        if (Profile.isProfilingEnabled()) {
-            return Binary.createLazyLoadClass();
+        if (isProfilingEnabled()) {
+            return new ConditionProfile();
         } else {
-            return Disabled.INSTANCE;
+            return DISABLED;
         }
     }
 
     /**
-     * Creates a binary ConditionProfile using {@link #createBinaryProfile()}. This is a convenience
-     * method so it can be used as {@code @Cached ConditionProfile myProfile} instead of the much
-     * longer {@code @Cached("createBinaryProfile()") ConditionProfile myProfile}.
+     * Returns a {@link ConditionProfile} that speculates on conditions to be never
+     * true or to be never false. Condition profiles are intended to be
+     * used as part of if conditions.
      *
      * @since 20.2
      */
+    @NeverDefault
     public static ConditionProfile create() {
         return createBinaryProfile();
     }
@@ -135,7 +202,17 @@ public static ConditionProfile create() {
      * @since 19.0
      */
     public static ConditionProfile getUncached() {
-        return Disabled.INSTANCE;
+        return DISABLED;
+    }
+
+    /**
+     * Returns an inlined version of the profile. This version is automatically used by Truffle DSL
+     * node inlining.
+     *
+     * @since 23.0
+     */
+    public static InlinedConditionProfile inline(InlineTarget target) {
+        return InlinedConditionProfile.inline(target);
     }
 
     static final class Disabled extends ConditionProfile {
@@ -154,11 +231,14 @@ public boolean profile(boolean value) {
 
         @Override
         public String toString() {
-            return toStringDisabled(ConditionProfile.class);
+            return toStringDisabled();
         }
 
     }
 
+    /*
+     * Code to be removed with deprecated API. New code lives in CountingConditionProfile.
+     */
     static final class Counting extends ConditionProfile {
 
         @CompilationFinal private int trueCount;
@@ -255,66 +335,4 @@ static ConditionProfile createLazyLoadClass() {
         }
     }
 
-    /**
-     * Utility class to speculate on conditions to be never true or to be never false. Condition
-     * profiles are intended to be used as part of if conditions.
-     *
-     * @see ConditionProfile#createBinaryProfile()
-     */
-    static final class Binary extends ConditionProfile {
-
-        @CompilationFinal private boolean wasTrue;
-        @CompilationFinal private boolean wasFalse;
-
-        Binary() {
-        }
-
-        @Override
-        public boolean profile(boolean value) {
-            if (value) {
-                if (!wasTrue) {
-                    CompilerDirectives.transferToInterpreterAndInvalidate();
-                    wasTrue = true;
-                }
-                return true;
-            } else {
-                if (!wasFalse) {
-                    CompilerDirectives.transferToInterpreterAndInvalidate();
-                    wasFalse = true;
-                }
-                return false;
-            }
-        }
-
-        @Override
-        public void disable() {
-            this.wasFalse = true;
-            this.wasTrue = true;
-        }
-
-        @Override
-        public void reset() {
-            this.wasFalse = false;
-            this.wasTrue = false;
-        }
-
-        boolean wasTrue() {
-            return wasTrue;
-        }
-
-        boolean wasFalse() {
-            return wasFalse;
-        }
-
-        @Override
-        public String toString() {
-            return String.format("%s(wasTrue=%s, wasFalse=%s)@%x", getClass().getSimpleName(), wasTrue, wasFalse, hashCode());
-        }
-
-        /* Needed for lazy class loading. */
-        static ConditionProfile createLazyLoadClass() {
-            return new Binary();
-        }
-    }
-
 }
diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/CountingConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/CountingConditionProfile.java
new file mode 100644
index 000000000000..c66608a2860f
--- /dev/null
+++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/CountingConditionProfile.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * The Universal Permissive License (UPL), Version 1.0
+ *
+ * Subject to the condition set forth below, permission is hereby granted to any
+ * person obtaining a copy of this software, associated documentation and/or
+ * data (collectively the "Software"), free of charge and under any and all
+ * copyright rights in the Software, and any and all patent rights owned or
+ * freely licensable by each licensor hereunder covering either (i) the
+ * unmodified Software as contributed to or provided by such licensor, or (ii)
+ * the Larger Works (as defined below), to deal in both
+ *
+ * (a) the Software, and
+ *
+ * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
+ * one is included with the Software each a "Larger Work" to which the Software
+ * is contributed by such licensors),
+ *
+ * without restriction, including without limitation the rights to copy, create
+ * derivative works of, display, perform, and distribute the Software and make,
+ * use, sell, offer for sale, import, export, have made, and have sold the
+ * Software and the Larger Work(s), and to sublicense the foregoing rights on
+ * either these or other terms.
+ *
+ * This license is subject to the following condition:
+ *
+ * The above copyright notice and either this complete permission notice or at a
+ * minimum a reference to the UPL must be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.oracle.truffle.api.profiles;
+
+import com.oracle.truffle.api.CompilerDirectives;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget;
+import com.oracle.truffle.api.dsl.NeverDefault;
+
+/**
+ * 

+ * CountingConditionProfiles are useful to profile the outcome of conditions. A counting condition + * profile holds a count for each branch whether a branch was hit or not and communicates this to + * the compiler as frequency information. If binary information only is desired for each branch + * should use {@link ConditionProfile} instead. + * + *

+ * + *

+ * Usage example: + * + *

+ * class AbsoluteNode extends Node {
+ *
+ *     final CountingConditionProfile greaterZeroProfile = CountingConditionProfile.create();
+ *
+ *     void execute(int value) {
+ *         if (greaterZeroProfile.profile(value >= 0)) {
+ *             return value;
+ *         } else {
+ *             return -value;
+ *         }
+ *     }
+ * }
+ * 
+ * + * {@inheritDoc} + * + * @see #create() + * @see LoopConditionProfile + * @see CountingConditionProfile + * @since 23.0 + */ +public final class CountingConditionProfile extends Profile { + + private static final CountingConditionProfile DISABLED; + static { + CountingConditionProfile profile = new CountingConditionProfile(); + profile.trueCount = Integer.MAX_VALUE; + profile.falseCount = Integer.MAX_VALUE; + DISABLED = profile; + } + + @CompilationFinal private int trueCount; + @CompilationFinal private int falseCount; + + /** + * A constant holding the maximum value an {@code int} can have, 230-1. The sum of + * the true and false count must not overflow. This constant is used to check whether one of the + * counts does not exceed the required maximum value. + */ + static final int MAX_VALUE = 0x3fffffff; + + private CountingConditionProfile() { + } + + /** @since 22.1 */ + public boolean profile(boolean value) { + // locals required to guarantee no overflow in multi-threaded environments + int t = trueCount; + int f = falseCount; + boolean val = value; + if (val) { + if (t == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (f == 0) { + // Make this branch fold during PE + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < MAX_VALUE) { + trueCount = t + 1; + } + } + } else { + if (f == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (t == 0) { + // Make this branch fold during PE + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < MAX_VALUE) { + falseCount = f + 1; + } + } + } + if (CompilerDirectives.inInterpreter()) { + // no branch probability calculation in the interpreter + return val; + } else { + if (this == DISABLED) { + return val; + } + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void disable() { + if (this.trueCount == 0) { + this.trueCount = 1; + } + if (this.falseCount == 0) { + this.falseCount = 1; + } + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void reset() { + if (this == DISABLED) { + return; + } + this.trueCount = 0; + this.falseCount = 0; + } + + int getTrueCount() { + return trueCount; + } + + int getFalseCount() { + return falseCount; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString() { + if (this == DISABLED) { + return toStringDisabled(); + } else { + int t = trueCount; + int f = falseCount; + int sum = t + f; + String details = String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", (double) t / (double) sum, t, f); + return toString(CountingConditionProfile.class, sum == 0, false, details); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does nothing. + * + * @since 23.0 + */ + public static CountingConditionProfile getUncached() { + return DISABLED; + } + + /** + * Returns a {@link ConditionProfile} that speculates on conditions to be never + * true or to be never false. Additionally to a binary profile this + * method returns a condition profile that also counts the number of times the condition was + * true and false. This information is reported to the underlying optimization system using + * {@link CompilerDirectives#injectBranchProbability(double, boolean)}. Condition profiles are + * intended to be used as part of if conditions. + * + * @see ConditionProfile + * @since 23.0 + */ + @NeverDefault + public static CountingConditionProfile create() { + if (isProfilingEnabled()) { + return new CountingConditionProfile(); + } else { + return DISABLED; + } + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedCountingConditionProfile inline(InlineTarget target) { + return InlinedCountingConditionProfile.inline(target); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/DoubleValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/DoubleValueProfile.java index c3ded81f60f3..88176c46a94d 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/DoubleValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/DoubleValueProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -84,9 +86,9 @@ public final class DoubleValueProfile extends Profile { profile.disable(); DISABLED = profile; } - private static final byte UNINITIALIZED = 0; - private static final byte SPECIALIZED = 1; - private static final byte GENERIC = 2; + private static final int UNINITIALIZED = 0; + private static final int SPECIALIZED = 1; + private static final int GENERIC = 2; @CompilationFinal private double cachedValue; @CompilationFinal private long cachedRawValue; @@ -158,7 +160,7 @@ boolean isUninitialized() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(DoubleValueProfile.class); + return toStringDisabled(); } else { return toString(DoubleValueProfile.class, state == UNINITIALIZED, state == GENERIC, // String.format("value == (double)%s (raw %h)", cachedValue, cachedRawValue)); @@ -172,6 +174,7 @@ public String toString() { * @see IntValueProfile * @since 0.10 */ + @NeverDefault public static DoubleValueProfile createRawIdentityProfile() { return create(); } @@ -183,8 +186,9 @@ public static DoubleValueProfile createRawIdentityProfile() { * @see IntValueProfile * @since 22.1 */ + @NeverDefault public static DoubleValueProfile create() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new DoubleValueProfile(); } else { return DISABLED; @@ -200,4 +204,14 @@ public static DoubleValueProfile getUncached() { return DISABLED; } + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedDoubleValueProfile inline(InlineTarget target) { + return InlinedDoubleValueProfile.inline(target); + } + } diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/FloatValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/FloatValueProfile.java index 6ab63dde619b..58d8458d5a94 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/FloatValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/FloatValueProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -77,7 +79,6 @@ * @since 0.10 */ public final class FloatValueProfile extends Profile { - private static final FloatValueProfile DISABLED; static { FloatValueProfile profile = new FloatValueProfile(); @@ -85,15 +86,15 @@ public final class FloatValueProfile extends Profile { DISABLED = profile; } - private static final byte UNINITIALIZED = 0; - private static final byte SPECIALIZED = 1; - private static final byte GENERIC = 2; + private static final int UNINITIALIZED = 0; + private static final int SPECIALIZED = 1; + private static final int GENERIC = 2; @CompilationFinal private float cachedValue; @CompilationFinal private int cachedRawValue; @CompilationFinal private byte state = UNINITIALIZED; - FloatValueProfile() { + private FloatValueProfile() { } /** @since 0.10 */ @@ -157,7 +158,7 @@ float getCachedValue() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(FloatValueProfile.class); + return toStringDisabled(); } else { return toString(FloatValueProfile.class, state == UNINITIALIZED, state == GENERIC, // String.format("value == (float)%s (raw %h)", cachedValue, cachedRawValue)); @@ -171,6 +172,7 @@ public String toString() { * @see IntValueProfile * @since 0.10 */ + @NeverDefault public static FloatValueProfile createRawIdentityProfile() { return create(); } @@ -182,8 +184,9 @@ public static FloatValueProfile createRawIdentityProfile() { * @see IntValueProfile * @since 22.1 */ + @NeverDefault public static FloatValueProfile create() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new FloatValueProfile(); } else { return DISABLED; @@ -199,4 +202,14 @@ public static FloatValueProfile getUncached() { return DISABLED; } + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedFloatValueProfile inline(InlineTarget target) { + return InlinedFloatValueProfile.inline(target); + } + } diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedBranchProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedBranchProfile.java new file mode 100644 index 000000000000..cc584575862b --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedBranchProfile.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * BranchProfiles are profiles to speculate on branches that are unlikely to be visited. If the + * {@link #enter(Node)} method is invoked first the optimized code is invalidated and the branch + * where {@link #enter(Node)} is invoked is enabled for compilation. Otherwise if the + * {@link #enter(Node)} method was never invoked the branch will not get compiled. + *

+ * Usage example: + * + *

+ * class ExampleNode extends Node {
+ *
+ *     abstract int execute(int value);
+ *
+ *     @Specialization
+ *     int doDefault(int value, @Cached InlinedBranchProfile errorProfile) {
+ *         if (value == Integer.MAX_VALUE) {
+ *             errorProfile.enter(this);
+ *             throw new Error("Invalid input value");
+ *         }
+ *         return value;
+ *     }
+ * }
+ * 
+ * + * @see InlinedProfile + * @since 23.0 + */ +public final class InlinedBranchProfile extends InlinedProfile { + + private static final InlinedBranchProfile DISABLED; + static { + InlinedBranchProfile profile = new InlinedBranchProfile(); + DISABLED = profile; + } + private static final int REQUIRED_STATE_BITS = 1; + + private final StateField state; + + private InlinedBranchProfile() { + this.state = null; + } + + private InlinedBranchProfile(InlineTarget target) { + this.state = target.getState(0, REQUIRED_STATE_BITS); + } + + /** @since 23.0 */ + public void enter(Node node) { + if (state == null) { + return; + } + int s = state.get(node); + if (s == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + state.set(node, 1); + } + } + + /** + * Returns true if the {@link #enter(Node)} method was ever called, otherwise + * false. For profiles with profiling disabled or {@link #getUncached() uncached} + * profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasEntered(Node node) { + if (state == null) { + return true; + } + return state.get(node) != 0; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void reset(Node node) { + if (state == null) { + return; + } + state.set(node, 0); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void disable(Node node) { + if (state == null) { + return; + } + state.set(node, 1); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(InlinedBranchProfile.class, state.get(node) == 0, false, "VISITED"); + } + + boolean isGeneric(Node node) { + if (state == null) { + return true; + } + return this.state.get(node) == 1; + } + + boolean isUninitialized(Node node) { + if (state == null) { + return false; + } + return this.state.get(node) == 0; + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedBranchProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedBranchProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedBranchProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedByteValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedByteValueProfile.java new file mode 100644 index 000000000000..06543238fc08 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedByteValueProfile.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.ByteField; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture certain properties of byte runtime values. + * Value profiles require a runtime check in their initialized state to verify their profiled + * assumption. Value profiles are limited to capture monomorphic profiles only. This means that if + * two or more values are profiled within a single profile then the profile has no effect. If the + * value assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class ByteProfileNode extends Node {
+ *
+ *     abstract byte execute(byte input);
+ *
+ *     @Specialization
+ *     byte doDefault(byte input, @Cached InlinedByteValueProfile profile) {
+ *         byte profiledValue = profile.profile(this, input);
+ *         // compiler may now see profiledValue as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedByteValueProfile extends AbstractInlinedValueProfile { + + private static final InlinedByteValueProfile DISABLED; + static { + InlinedByteValueProfile profile = new InlinedByteValueProfile(); + DISABLED = profile; + } + + private final ByteField cachedValue; + + private InlinedByteValueProfile() { + super(); + this.cachedValue = null; + } + + private InlinedByteValueProfile(InlineTarget target) { + super(target); + this.cachedValue = target.getPrimitive(1, ByteField.class); + } + + /** @since 23.0 */ + public byte profile(Node node, byte value) { + if (this.state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED) { + byte v = this.cachedValue.get(node); + if (v == value) { + return v; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED) { + this.state.set(node, SPECIALIZED); + this.cachedValue.set(node, value); + } else { + this.state.set(node, GENERIC); + this.cachedValue.set(node, (byte) 0); + } + } + } + return value; + } + + byte getCachedValue(Node node) { + return this.cachedValue.get(node); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(ByteValueProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == (byte)%s", getCachedValue(node))); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedByteValueProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(value = ByteField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedByteValueProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedByteValueProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedConditionProfile.java new file mode 100644 index 000000000000..5f65d6cb68de --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedConditionProfile.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * ConditionProfiles are useful to profile the outcome of conditions. A regular condition profile + * keeps track of a binary state, for each branch whether a branch was hit or not and communicates + * this to the compiler. If frequency information for each branch should be collected use + * {@link InlinedCountingConditionProfile} instead. + * + *

+ * Usage example: + * + *

+ * abstract class AbsoluteNode extends Node {
+ *
+ *     abstract void execute(int value);
+ *
+ *     @Specialization
+ *     int doDefault(int value,
+ *                     @Cached InlinedConditionProfile p) {
+ *         if (p.profile(this, value >= 0)) {
+ *             return value;
+ *         } else {
+ *             return -value;
+ *         }
+ *     }
+ * }
+ * 
+ * + * + * @since 23.0 + */ +public final class InlinedConditionProfile extends InlinedProfile { + + private static final InlinedConditionProfile DISABLED; + static { + InlinedConditionProfile profile = new InlinedConditionProfile(); + DISABLED = profile; + } + + private static final int REQUIRED_STATE_BITS = 2; + + private final StateField state; + + private InlinedConditionProfile() { + this.state = null; + } + + private InlinedConditionProfile(InlineTarget target) { + this.state = target.getState(0, REQUIRED_STATE_BITS); + } + + /** @since 23.0 */ + public boolean profile(Node node, boolean value) { + if (state != null) { + int s = this.state.get(node); + if (value) { + if ((s & 0b01) == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + state.set(node, s | 0b01); + } + return true; + } else { + if ((s & 0b10) == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + state.set(node, s | 0b10); + } + return false; + } + } + return value; + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * true value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasTrue(Node node) { + if (state == null) { + return true; + } + return (state.get(node) & 0b01) == 0b01; + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * false value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasFalse(Node node) { + if (state == null) { + return true; + } + return (state.get(node) & 0b10) == 0b10; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void disable(Node node) { + if (state == null) { + return; + } + state.set(node, 0b11); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void reset(Node node) { + if (state == null) { + return; + } + state.set(node, 0b00); + } + + boolean isGeneric(Node node) { + if (state == null) { + return true; + } + return wasTrue(node) && wasFalse(node); + } + + boolean isUninitialized(Node node) { + if (state == null) { + return false; + } + return !wasTrue(node) && !wasFalse(node); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return String.format("%s(wasTrue=%s, wasFalse=%s)@%x", getClass().getSimpleName(), wasTrue(node), wasFalse(node), hashCode()); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedConditionProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedConditionProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedConditionProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.java new file mode 100644 index 000000000000..0b4e5c34a463 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedCountingConditionProfile.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.nodes.Node; + +/** + * CountingConditionProfiles are useful to profile the outcome of conditions. A counting condition + * profile holds a count for each branch whether a branch was hit or not and communicates this to + * the compiler as frequency information. If binary information only is desired for each branch + * should use {@link InlinedConditionProfile} instead. + * + * + *

+ * Usage example: + * + *

+ * abstract class AbsoluteNode extends Node {
+ *
+ *     abstract void execute(int value);
+ *
+ *     @Specialization
+ *     int doDefault(int value,
+ *                     @Cached InlinedCountingConditionProfile p) {
+ *         if (p.profile(this, value >= 0)) {
+ *             return value;
+ *         } else {
+ *             return -value;
+ *         }
+ *     }
+ * }
+ * 
+ * + * + * @since 23.0 + */ +public final class InlinedCountingConditionProfile extends InlinedProfile { + + private static final InlinedCountingConditionProfile DISABLED; + static { + InlinedCountingConditionProfile profile = new InlinedCountingConditionProfile(); + DISABLED = profile; + } + + private final IntField trueCount; + private final IntField falseCount; + + /** + * A constant holding the maximum value an {@code int} can have, 230-1. The sum of + * the true and false count must not overflow. This constant is used to check whether one of the + * counts does not exceed the required maximum value. + */ + static final int MAX_VALUE = 0x3fffffff; + + private InlinedCountingConditionProfile() { + this.trueCount = null; + this.falseCount = null; + } + + private InlinedCountingConditionProfile(InlineTarget target) { + this.trueCount = target.getPrimitive(0, IntField.class); + this.falseCount = target.getPrimitive(1, IntField.class); + } + + /** @since 23.0 */ + public boolean profile(Node node, boolean value) { + if (trueCount == null) { + return value; + } + // locals required to guarantee no overflow in multi-threaded environments + int t = trueCount.get(node); + int f = falseCount.get(node); + boolean val = value; + if (val) { + if (t == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (f == 0) { + // Make this branch fold during PE + val = true; + } + if (CompilerDirectives.inInterpreter()) { + if (t < MAX_VALUE) { + trueCount.set(node, t + 1); + } + } + } else { + if (f == 0) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + if (t == 0) { + // Make this branch fold during PE + val = false; + } + if (CompilerDirectives.inInterpreter()) { + if (f < MAX_VALUE) { + falseCount.set(node, f + 1); + } + } + } + if (CompilerDirectives.inInterpreter()) { + // no branch probability calculation in the interpreter + return val; + } else { + int sum = t + f; + return CompilerDirectives.injectBranchProbability((double) t / (double) sum, val); + } + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * true value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasTrue(Node node) { + return getTrueCount(node) != 0; + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * false value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasFalse(Node node) { + return getFalseCount(node) != 0; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void disable(Node node) { + if (trueCount == null) { + return; + } + if (this.trueCount.get(node) == 0) { + this.trueCount.set(node, 1); + } + if (this.falseCount.get(node) == 0) { + this.falseCount.set(node, 1); + } + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void reset(Node node) { + if (trueCount == null) { + return; + } + this.trueCount.set(node, 0); + this.falseCount.set(node, 0); + } + + int getTrueCount(Node node) { + if (trueCount == null) { + return Integer.MAX_VALUE; + } + return trueCount.get(node); + } + + int getFalseCount(Node node) { + if (trueCount == null) { + return Integer.MAX_VALUE; + } + return falseCount.get(node); + } + + boolean isGeneric(Node node) { + if (trueCount == null) { + return true; + } + return getTrueCount(node) != 0 && getFalseCount(node) != 0; + } + + boolean isUninitialized(Node node) { + if (trueCount == null) { + return false; + } + return getTrueCount(node) == 0 && getFalseCount(node) == 0; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (trueCount == null) { + return toStringDisabled(); + } + int t = trueCount.get(node); + int f = falseCount.get(node); + int sum = t + f; + String details = String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", (double) t / (double) sum, t, f); + return toString(ConditionProfile.class, sum == 0, false, details); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedCountingConditionProfile inline( + @RequiredField(value = IntField.class)// + @RequiredField(value = IntField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedCountingConditionProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedCountingConditionProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.java new file mode 100644 index 000000000000..0c795f8ac306 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedDoubleValueProfile.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.LongField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture certain properties of byte runtime values. + * Value profiles require a runtime check in their initialized state to verify their profiled + * assumption. Value profiles are limited to capture monomorphic profiles only. This means that if + * two or more values are profiled within a single profile then the profile has no effect. If the + * value assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class DoubleProfileNode extends Node {
+ *
+ *     abstract double execute(double input);
+ *
+ *     @Specialization
+ *     double doDefault(double input, @Cached InlinedDoubleValueProfile profile) {
+ *         double profiledValue = profile.profile(this, input);
+ *         // compiler may now see profiledValue as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedDoubleValueProfile extends AbstractInlinedValueProfile { + + private static final InlinedDoubleValueProfile DISABLED; + static { + InlinedDoubleValueProfile profile = new InlinedDoubleValueProfile(); + DISABLED = profile; + } + private final LongField cachedValue0; + + private InlinedDoubleValueProfile() { + super(); + this.cachedValue0 = null; + } + + private InlinedDoubleValueProfile(InlineTarget target) { + super(target); + this.cachedValue0 = target.getPrimitive(1, LongField.class); + } + + /** @since 23.0 */ + public double profile(Node node, double value) { + if (this.state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED) { + long v = cachedValue0.get(node); + if (v == Double.doubleToRawLongBits(value)) { + if (CompilerDirectives.inCompiledCode()) { + return Double.longBitsToDouble(v); + } else { + return value; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED) { + cachedValue0.set(node, Double.doubleToRawLongBits(value)); + this.state.set(node, SPECIALIZED); + } else { + this.state.set(node, GENERIC); + } + } + } + return value; + } + + double getCachedValue(Node node) { + return Double.longBitsToDouble(cachedValue0.get(node)); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(DoubleValueProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == (double)%s (raw %h)", getCachedValue(node), Double.doubleToRawLongBits(getCachedValue(node)))); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedDoubleValueProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(value = LongField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedDoubleValueProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedDoubleValueProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedExactClassProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedExactClassProfile.java new file mode 100644 index 000000000000..d25b85d543bc --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedExactClassProfile.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture the exact class of reference runtime values. + * Value profiles require a runtime check in their initialized state to verify their profiled + * assumption. Value profiles are limited to capture monomorphic profiles only. This means that if + * two or more values are profiled within a single profile then the profile has no effect. If the + * value assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class ReferenceProfileNode extends Node {
+ *
+ *     abstract Object execute(Object input);
+ *
+ *     @Specialization
+ *     Object doDefault(Object input, @Cached InlinedExactClassProfile profile) {
+ *         Object profiledValue = profile.profile(this, input);
+ *         // compiler may now see the exact class as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedExactClassProfile extends AbstractInlinedValueProfile { + + private static final InlinedExactClassProfile DISABLED; + static { + InlinedExactClassProfile profile = new InlinedExactClassProfile(); + DISABLED = profile; + } + + private final ReferenceField> cachedValue; + + private InlinedExactClassProfile() { + this.cachedValue = null; + } + + private InlinedExactClassProfile(InlineTarget target) { + super(target); + this.cachedValue = target.getReference(1, Class.class); + } + + /** @since 23.0 */ + @SuppressWarnings("unchecked") + public T profile(Node node, T value) { + if (state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED && value != null) { + Class c = cachedValue.get(node); + if (c != null) { + if (CompilerDirectives.inCompiledCode()) { + if (CompilerDirectives.isExact(value, c)) { + return (T) CompilerDirectives.castExact(value, c); + } + } else { + if (value.getClass() == c) { + return value; + } + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED && value != null) { + this.cachedValue.set(node, value.getClass()); + this.state.set(node, SPECIALIZED); + } else { + this.cachedValue.set(node, Object.class); + this.state.set(node, GENERIC); + } + } + } + return value; + } + + Class getCachedValue(Node node) { + return this.cachedValue.get(node); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(InlinedExactClassProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == %s", getCachedValue(node))); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedExactClassProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(value = ReferenceField.class, type = Class.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedExactClassProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedExactClassProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedFloatValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedFloatValueProfile.java new file mode 100644 index 000000000000..66827a6cf045 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedFloatValueProfile.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture certain properties of float runtime values. + * Value profiles require a runtime check in their initialized state to verify their profiled + * assumption. Value profiles are limited to capture monomorphic profiles only. This means that if + * two or more values are profiled within a single profile then the profile has no effect. If the + * value assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class FloatProfileNode extends Node {
+ *
+ *     abstract float execute(float input);
+ *
+ *     @Specialization
+ *     float doDefault(float input, @Cached InlinedFloatValueProfile profile) {
+ *         float profiledValue = profile.profile(this, input);
+ *         // compiler may now see profiledValue as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedFloatValueProfile extends AbstractInlinedValueProfile { + + private static final InlinedFloatValueProfile DISABLED; + static { + InlinedFloatValueProfile profile = new InlinedFloatValueProfile(); + DISABLED = profile; + } + + private final IntField cachedValue; + + private InlinedFloatValueProfile() { + super(); + this.cachedValue = null; + } + + private InlinedFloatValueProfile(InlineTarget target) { + super(target); + this.cachedValue = target.getPrimitive(1, IntField.class); + } + + /** @since 23.0 */ + public float profile(Node node, float value) { + if (this.state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED) { + int v = cachedValue.get(node); + if (v == Float.floatToRawIntBits(value)) { + if (CompilerDirectives.inCompiledCode()) { + return Float.intBitsToFloat(v); + } else { + return value; + } + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED) { + this.cachedValue.set(node, Float.floatToRawIntBits(value)); + this.state.set(node, SPECIALIZED); + } else { + this.state.set(node, GENERIC); + } + } + } + return value; + } + + float getCachedValue(Node node) { + return Float.intBitsToFloat(this.cachedValue.get(node)); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(IntValueProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == (float)%s", cachedValue)); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedFloatValueProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(value = IntField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedFloatValueProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedFloatValueProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedIntValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedIntValueProfile.java new file mode 100644 index 000000000000..062a29b27796 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedIntValueProfile.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture certain properties of int runtime values. Value + * profiles require a runtime check in their initialized state to verify their profiled assumption. + * Value profiles are limited to capture monomorphic profiles only. This means that if two or more + * values are profiled within a single profile then the profile has no effect. If the value + * assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class IntProfileNode extends Node {
+ *
+ *     abstract int execute(int input);
+ *
+ *     @Specialization
+ *     int doDefault(int input, @Cached InlinedIntValueProfile profile) {
+ *         int profiledValue = profile.profile(this, input);
+ *         // compiler may now see profiledValue as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedIntValueProfile extends AbstractInlinedValueProfile { + + private static final InlinedIntValueProfile DISABLED; + static { + InlinedIntValueProfile profile = new InlinedIntValueProfile(); + DISABLED = profile; + } + + private final IntField cachedValue; + + private InlinedIntValueProfile() { + super(); + this.cachedValue = null; + } + + private InlinedIntValueProfile(InlineTarget target) { + super(target); + this.cachedValue = target.getPrimitive(1, IntField.class); + } + + /** @since 23.0 */ + public int profile(Node node, int value) { + if (state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED) { + int v = cachedValue.get(node); + if (v == value) { + return v; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED) { + this.cachedValue.set(node, value); + this.state.set(node, SPECIALIZED); + } else { + this.state.set(node, GENERIC); + } + } + } + return value; + } + + int getCachedValue(Node node) { + if (this.state == null) { + return 0; + } + return this.cachedValue.get(node); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(IntValueProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == (int)%s", cachedValue)); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedIntValueProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(value = IntField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedIntValueProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedIntValueProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLongValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLongValueProfile.java new file mode 100644 index 000000000000..8fb160270c54 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLongValueProfile.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.LongField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * Specialized value profile to capture certain properties of long runtime values. + * Value profiles require a runtime check in their initialized state to verify their profiled + * assumption. Value profiles are limited to capture monomorphic profiles only. This means that if + * two or more values are profiled within a single profile then the profile has no effect. If the + * value assumption is invalidated in compiled code then it is invalidated. + * + *

+ * Usage example: + * + *

+ * abstract class LongProfileNode extends Node {
+ *
+ *     abstract long execute(long input);
+ *
+ *     @Specialization
+ *     long doDefault(byte input, @Cached InlinedLongValueProfile profile) {
+ *         long profiledValue = profile.profile(this, input);
+ *         // compiler may now see profiledValue as a partial evaluation constant
+ *         return profiledValue;
+ *     }
+ * }
+ * 
+ * + * @since 23.0 + */ +public final class InlinedLongValueProfile extends AbstractInlinedValueProfile { + + private static final InlinedLongValueProfile DISABLED; + static { + InlinedLongValueProfile profile = new InlinedLongValueProfile(); + DISABLED = profile; + } + + private final LongField cachedValue; + + private InlinedLongValueProfile() { + this.cachedValue = null; + } + + private InlinedLongValueProfile(InlineTarget target) { + super(target); + this.cachedValue = target.getPrimitive(1, LongField.class); + } + + /** @since 23.0 */ + public long profile(Node node, long value) { + if (state != null) { + int localState = this.state.get(node); + if (localState != GENERIC) { + if (localState == SPECIALIZED) { + long v = cachedValue.get(node); + if (v == value) { + return v; + } + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + if (localState == UNINITIALIZED) { + this.cachedValue.set(node, value); + this.state.set(node, SPECIALIZED); + } else { + this.state.set(node, GENERIC); + } + } + } + return value; + } + + long getCachedValue(Node node) { + return this.cachedValue.get(node); + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (state == null) { + return toStringDisabled(); + } + return toString(LongValueProfile.class, isUninitialized(node), isGeneric(node), // + String.format("value == (long)%s", getCachedValue(node))); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedLongValueProfile inline( + @RequiredField(value = StateField.class, bits = REQUIRED_STATE_BITS) // + @RequiredField(LongField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedLongValueProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedLongValueProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.java new file mode 100644 index 000000000000..2ab658d5eca2 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedLoopConditionProfile.java @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.LongField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.nodes.Node; + +/** + *

+ * InlinedLoopConditionProfiles are designed to profile the outcome of loop conditions. Loop + * profiles can be used to profile unpredictable loops as well as predictable loops. This profile is + * intended to be used in combination with Truffle DSL. + *

+ * + *

+ * Uncounted loop usage example: + * + *

+ * class LoopNode extends Node {
+ *
+ *     abstract void execute();
+ *
+ *     @Specialization
+ *     void doDefault(@Cached InlinedLoopConditionProfile loopProfile) {
+ *         // loop count cannot be predicted
+ *         while (loopProfile.profile(this, Math.random() >= 0.9)) {
+ *             // work
+ *         }
+ *     }
+ * }
+ * 
+ * + *

+ * + *

+ * Counted loop usage example: + * + *

+ * class CountedLoopNode extends Node {
+ *
+ *     abstract void execute(int length);
+ *
+ *     @Specialization
+ *     void doDefault(int length, @Cached InlinedLoopConditionProfile loopProfile) {
+ *         // loop count can be predicted
+ *         loopProfile.profileCounted(this, length);
+ *         for (int i = 0; loopProfile.inject(this, i < length); i++) {
+ *             // work
+ *         }
+ *     }
+ * }
+ * 
+ *

+ * The advantage of using {@link #profileCounted(Node, long)} to using + * {@link #profile(Node, boolean)} is that it incurs less overhead in the interpreter. Using + * {@link InlinedLoopConditionProfile#inject(Node, boolean)} is a no-op in the interpreter while + * {@link #profile(Node, boolean)} needs to use a counter for each iteration. + *

+ * {@inheritDoc} + * + * @see InlinedConditionProfile + * @see InlinedCountingConditionProfile + * @see LoopConditionProfile + * @since 23.0 + */ +public final class InlinedLoopConditionProfile extends InlinedProfile { + + private static final InlinedLoopConditionProfile DISABLED; + static { + InlinedLoopConditionProfile profile = new InlinedLoopConditionProfile(); + DISABLED = profile; + } + + private final LongField trueCount; + private final IntField falseCount; + + /** + * A constant holding the maximum value an {@code int} can have, 230-1. The sum of + * the true and false count must not overflow. This constant is used to check whether one of the + * counts does not exceed the required maximum value. + */ + static final int MAX_VALUE = 0x3fffffff; + + private InlinedLoopConditionProfile() { + this.trueCount = null; + this.falseCount = null; + } + + private InlinedLoopConditionProfile(InlineTarget target) { + this.trueCount = target.getPrimitive(0, LongField.class); + this.falseCount = target.getPrimitive(1, IntField.class); + } + + /** @since 23.0 */ + public boolean profile(Node node, boolean condition) { + if (trueCount == null) { + return condition; + } + // locals required to guarantee no overflow in multi-threaded environments + long trueCountLocal = trueCount.get(node); + int falseCountLocal = falseCount.get(node); + + if (trueCountLocal == 0) { + // Deopt for never entering the loop. + if (condition) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + } + } + + if (CompilerDirectives.inInterpreter()) { + if (condition) { + if (trueCountLocal < Long.MAX_VALUE) { + trueCount.set(node, trueCountLocal + 1); + } + } else { + if (falseCountLocal < Integer.MAX_VALUE) { + falseCount.set(node, falseCountLocal + 1); + } + } + // no branch probability calculation in the interpreter + return condition; + } else { + if (this != DISABLED) { + return CompilerDirectives.injectBranchProbability(calculateProbability(trueCountLocal, falseCountLocal), condition); + } else { + return condition; + } + } + } + + /** + * Provides an alternative way to profile counted loops with less interpreter footprint. Please + * see {@link InlinedLoopConditionProfile} for an usage example. + * + * @see #inject(Node, boolean) + * @since 23.0 + */ + public void profileCounted(Node node, long length) { + if (CompilerDirectives.inInterpreter()) { + long trueCountLocal = trueCount.get(node) + length; + if (trueCountLocal >= 0) { // don't write overflow values + trueCount.set(node, trueCountLocal); + int falseCountLocal = falseCount.get(node); + if (falseCountLocal < Integer.MAX_VALUE) { + falseCount.set(node, falseCountLocal + 1); + } + } + } + } + + /** + * Provides an alternative way to profile counted loops with less interpreter footprint. Please + * see {@link InlinedLoopConditionProfile} for an usage example. + * + * @since 23.0 + */ + public boolean inject(Node node, boolean condition) { + if (CompilerDirectives.inCompiledCode() && this != DISABLED) { + return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount.get(node), falseCount.get(node)), condition); + } else { + return condition; + } + } + + private static double calculateProbability(long trueCountLocal, int falseCountLocal) { + if (falseCountLocal == 0 && trueCountLocal == 0) { + /* Avoid division by zero if profile was never used. */ + return 0.0; + } else { + return (double) trueCountLocal / (double) (trueCountLocal + falseCountLocal); + } + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * true value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasTrue(Node node) { + return getTrueCount(node) != 0; + } + + /** + * Returns true if the {@link #profile(Node, boolean)} method ever received a + * false value, otherwise false. For profiles with profiling disabled + * or {@link #getUncached() uncached} profiles this method always returns true. + * + * @since 23.0 + */ + public boolean wasFalse(Node node) { + return getFalseCount(node) != 0; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void disable(Node node) { + if (trueCount == null) { + return; + } + if (this.trueCount.get(node) == 0) { + this.trueCount.set(node, 1); + } + if (this.falseCount.get(node) == 0) { + this.falseCount.set(node, 1); + } + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public void reset(Node node) { + if (trueCount == null) { + return; + } + this.trueCount.set(node, 0); + this.falseCount.set(node, 0); + } + + long getTrueCount(Node node) { + if (trueCount == null) { + return Integer.MAX_VALUE; + } + return trueCount.get(node); + } + + int getFalseCount(Node node) { + if (trueCount == null) { + return Integer.MAX_VALUE; + } + return falseCount.get(node); + } + + boolean isGeneric(Node node) { + if (trueCount == null) { + return true; + } + return getTrueCount(node) != 0 && getFalseCount(node) != 0; + } + + boolean isUninitialized(Node node) { + if (trueCount == null) { + return false; + } + return getTrueCount(node) == 0 && getFalseCount(node) == 0; + } + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public String toString(Node node) { + if (trueCount == null) { + return toStringDisabled(); + } + long t = trueCount.get(node); + int f = falseCount.get(node); + long sum = t + f; + String details = String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", (double) t / (double) sum, t, f); + return toString(ConditionProfile.class, sum == 0, false, details); + } + + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedLoopConditionProfile inline( + @RequiredField(value = IntField.class)// + @RequiredField(value = IntField.class) InlineTarget target) { + if (Profile.isProfilingEnabled()) { + return new InlinedLoopConditionProfile(target); + } else { + return getUncached(); + } + } + + /** + * Returns the uncached version of the profile. The uncached version of a profile does not + * perform any profiling. + * + * @since 23.0 + */ + public static InlinedLoopConditionProfile getUncached() { + return DISABLED; + } + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedProfile.java new file mode 100644 index 000000000000..7633cf71bfb2 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/InlinedProfile.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.TruffleRuntime; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; + +/** + * A profile is a Truffle utility class that uses the {@link CompilerDirectives Truffle compiler + * directives} to guard for and/or forward runtime information to the compiler. Whenever Truffle DSL + * can be used {@link InlinedProfile inlined profiles} subclasses should be used instead of regular + * {@link Profile profile} subclasses. + *

+ * Usage: Inlined profiles are used using the {@link Cached} annotation in specialization + * methods. See the individual profile subclasses for further usage examples. Profiles are intended + * for local speculation only. For global speculations use {@link Assumption assumptions} instead. + *

+ * Compilation: Some profiles like {@link InlinedBranchProfile branch} profiles do not induce + * additional overhead in compiled code. Others like {@link InlinedByteValueProfile value} profiles + * might require a runtime check to verify their local speculation. Even if profiles do not induce + * direct overhead in compiled code it still might get invalidated as a result of using profiles. + * Invalidating profiles will result in the invalidation of compiled code. It is therefore essential + * to place these profiles in way that is neither too aggressive nor too conservative, ideally based + * on measurements in real world applications. + *

+ * Footprint: Inlined versions of profiles have a significantly reduced memory footprint + * compared to their {@link Profile allocated} counterparts, however they do rely on their usage + * being inlined to have the same performance characteristics. Whether profiling information can be + * forwarded to the compiler depends on the capabilities of the {@link TruffleRuntime runtime + * system}. If the runtime returns true in {@link TruffleRuntime#isProfilingEnabled()} + * then runtime information will get collected. This comes at at the cost of additional overhead and + * footprint in interpreted mode. Thats why the factory methods of profiles can return + * implementations where profiling is disabled. Using disabled profiles makes sense for runtimes + * that are unable to use the collected profiling information. Even runtime implementations that are + * able to use this information might decide to turn off profiling for benchmarking purposes. + *

+ * Inlined profile subclasses: + *

    + *
  • {@link InlinedBranchProfile} to profile on unlikely branches like errors.
  • + *
  • {@link InlinedConditionProfile} to profile on conditionals or boolean values.
  • + *
  • {@link InlinedCountingConditionProfile} to profile on conditionals or boolean values using + * counters.
  • + *
  • {@link InlinedLoopConditionProfile} to profile on conditionals of loops with special support + * for counted loops.
  • + *
  • {@link InlinedByteValueProfile} to profile on byte values.
  • + *
  • {@link InlinedIntValueProfile} to profile on int values.
  • + *
  • {@link InlinedLongValueProfile} to profile on long values.
  • + *
  • {@link InlinedFloatValueProfile} to profile on float values.
  • + *
  • {@link InlinedDoubleValueProfile} to profile on double values.
  • + *
+ * + * @see InlinedProfile + * @see Assumption + * @since 23.0 + */ +public abstract class InlinedProfile { + + InlinedProfile() { + } + + /** + * Disables this profile by setting it to its generic state. After disabling it is guaranteed to + * never {@link CompilerDirectives#transferToInterpreterAndInvalidate() deoptimize} on any + * invocation of a profile method. + *

+ * This method must not be called on compiled code paths. Note that disabling the profile will + * not invalidate existing compiled code that uses this profile. + * + * @since 23.0 + */ + public abstract void disable(Node node); + + /** + * Resets this profile to its uninitialized state. Has no effect if this profile is already in + * its uninitialized state or a disabled version of this profile is used. + *

+ * This method must not be called on compiled code paths. Note that disabling the profile will + * not invalidate existing compiled code that uses this profile. + * + * @since 23.0 + */ + public abstract void reset(Node node); + + /** + * Prints a string representation of this inlined profile given a target node. + * + * @since 23.0 + */ + public abstract String toString(Node node); + + /** + * {@inheritDoc} + * + * @since 23.0 + */ + @Override + public final String toString() { + return String.format("%s(INLINED)", getClass().getSimpleName()); + } + + static int getStateInt(StateField field, Node node) { + return field.get(node); + } + + static byte getStateByte(StateField field, Node node) { + return (byte) (field.get(node) & 0xFF); + } + + static void setStateByte(StateField field, Node node, byte b) { + field.set(node, (b & 0xFF)); + } + + static float getStateFloat(StateField field, Node node) { + return Float.intBitsToFloat(field.get(node)); + } + + static void setStateFloat(StateField field, Node node, float f) { + field.set(node, Float.floatToRawIntBits(f)); + } + + static boolean getStateBoolean(StateField field, Node node) { + return field.get(node) == 1; + } + + static void setStateInt(StateField field, Node node, int value) { + field.set(node, value); + } + + static void setStateBoolean(StateField field, Node node, boolean value) { + field.set(node, value ? 1 : 0); + } + + final String toStringDisabled() { + return String.format("%s(DISABLED)", getClass().getSimpleName()); + } + + final String toString(Class profileClass, boolean uninitialized, boolean generic, String specialization) { + String s; + if (uninitialized) { + s = "UNINITIALIZED"; + } else if (generic) { + s = "GENERIC"; + } else { + s = specialization == null ? "" : specialization; + } + return String.format("%s(%s)@%s", profileClass.getSimpleName(), s, Integer.toHexString(this.hashCode())); + } +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/IntValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/IntValueProfile.java index f275e91cfa18..49cfb852ec9a 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/IntValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/IntValueProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -77,7 +79,6 @@ * @since 0.10 */ public final class IntValueProfile extends Profile { - private static final IntValueProfile DISABLED; static { IntValueProfile profile = new IntValueProfile(); @@ -175,8 +176,9 @@ public static IntValueProfile createIdentityProfile() { * @see IntValueProfile * @since 22.1 */ + @NeverDefault public static IntValueProfile create() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new IntValueProfile(); } else { return DISABLED; @@ -192,4 +194,14 @@ public static IntValueProfile getUncached() { return DISABLED; } + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedIntValueProfile inline(InlineTarget target) { + return InlinedIntValueProfile.inline(target); + } + } diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LongValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LongValueProfile.java index 02d5169df87b..a08806c0496f 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LongValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LongValueProfile.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -157,7 +159,7 @@ long getCachedValue() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(LongValueProfile.class); + return toStringDisabled(); } else { return toString(LongValueProfile.class, state == UNINITIALIZED, state == GENERIC, // String.format("value == (long)%s", cachedValue)); @@ -171,6 +173,7 @@ public String toString() { * @see LongValueProfile * @since 0.10 */ + @NeverDefault public static LongValueProfile createIdentityProfile() { return create(); } @@ -181,8 +184,9 @@ public static LongValueProfile createIdentityProfile() { * @see LongValueProfile * @since 22.1 */ + @NeverDefault public static LongValueProfile create() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new LongValueProfile(); } else { return DISABLED; @@ -198,4 +202,14 @@ public static LongValueProfile getUncached() { return DISABLED; } + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedLongValueProfile inline(InlineTarget target) { + return InlinedLongValueProfile.inline(target); + } + } diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LoopConditionProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LoopConditionProfile.java index 950b74063808..00a998daf7e9 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LoopConditionProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/LoopConditionProfile.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -97,8 +98,7 @@ * * {@inheritDoc} * - * @see #createBinaryProfile() - * @see #createCountingProfile() + * @see #create() * @see LoopConditionProfile * @since 0.10 */ @@ -243,7 +243,7 @@ int getFalseCount() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(LoopConditionProfile.class); + return toStringDisabled(); } else { return toString(LoopConditionProfile.class, falseCount == 0, false, // String.format("trueProbability=%s (trueCount=%s, falseCount=%s)", calculateProbability(trueCount, falseCount), trueCount, falseCount)); @@ -251,15 +251,14 @@ public String toString() { } /** - * Returns a {@link LoopConditionProfile} that speculates on loop conditions to be never - * true. It also captures loop probabilities for the compiler. Loop condition - * profiles are intended to be used for loop conditions. - * - * @see LoopConditionProfile * @since 0.10 + * @deprecated use {@link #create()} instead. */ + @SuppressWarnings("deprecation") + @Deprecated + @NeverDefault public static LoopConditionProfile createCountingProfile() { - if (Profile.isProfilingEnabled()) { + if (isProfilingEnabled()) { return new LoopConditionProfile(); } else { return DISABLED; @@ -267,13 +266,13 @@ public static LoopConditionProfile createCountingProfile() { } /** - * Creates a {@link LoopConditionProfile} using {@link #createCountingProfile()}. This is a - * convenience method so it can be used as {@code @Cached LoopConditionProfile loopProfile} - * instead of the much longer - * {@code @Cached("createCountingProfile()") LoopConditionProfile loopProfile}. + * Returns a {@link LoopConditionProfile} that speculates on loop conditions to be never + * true. It also captures loop probabilities for the compiler. Loop condition + * profiles are intended to be used for loop conditions. * * @since 21.2 */ + @NeverDefault public static LoopConditionProfile create() { return createCountingProfile(); } diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/PrimitiveValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/PrimitiveValueProfile.java index 0e6002b86194..9f483226d7f9 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/PrimitiveValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/PrimitiveValueProfile.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -302,7 +303,7 @@ Object getCachedValue() { @Override public String toString() { if (this == DISABLED) { - return toStringDisabled(PrimitiveValueProfile.class); + return toStringDisabled(); } else { return toString(PrimitiveValueProfile.class, isUninitialized(), isGeneric(), formatSpecialization()); } @@ -333,6 +334,7 @@ private String formatSpecialization() { * @since 0.10 */ @SuppressWarnings("deprecation") + @NeverDefault public static PrimitiveValueProfile createEqualityProfile() { return create(); } @@ -344,6 +346,7 @@ public static PrimitiveValueProfile createEqualityProfile() { * @since 22.1 */ @SuppressWarnings("deprecation") + @NeverDefault public static PrimitiveValueProfile create() { if (Profile.isProfilingEnabled()) { return new PrimitiveValueProfile(); diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java index 219454a34f4c..516f2e28dd59 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/Profile.java @@ -52,7 +52,9 @@ /** *

* A profile is a Truffle utility class that uses the {@link CompilerDirectives Truffle compiler - * directives} to guard for and/or forward runtime information to the compiler. + * directives} to guard for and/or forward runtime information to the compiler. Whenever Truffle DSL + * can be used {@link InlinedProfile inlined profiles} subclasses should be used instead of regular + * {@link Profile profile} subclasses. *

* *

@@ -105,10 +107,12 @@ * *

* + * @see InlinedProfile * @see Assumption * @since 0.10 */ public abstract class Profile extends NodeCloneable { + static boolean isProfilingEnabled() { boolean enabled; try { @@ -124,8 +128,8 @@ static boolean isProfilingEnabled() { /* We don't to allow custom profiles. We want to evolve this API further first. Sorry. */ } - String toStringDisabled(Class profileClass) { - return String.format("%s(DISABLED)", profileClass.getSimpleName()); + final String toStringDisabled() { + return String.format("%s(DISABLED)", getClass().getSimpleName()); } /** @@ -153,7 +157,7 @@ public void disable() { public void reset() { } - String toString(Class profileClass, boolean uninitialized, boolean generic, String specialization) { + final String toString(Class profileClass, boolean uninitialized, boolean generic, String specialization) { String s; if (uninitialized) { s = "UNINITIALIZED"; diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java new file mode 100644 index 000000000000..6d7ae6ad29b5 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.profiles; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface SealedProfile { + + Class[] value(); + +} diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ValueProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ValueProfile.java index abc948014145..75e5dded252a 100644 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ValueProfile.java +++ b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/ValueProfile.java @@ -44,6 +44,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.NeverDefault; /** *

@@ -109,6 +111,7 @@ public abstract class ValueProfile extends Profile { * @see ValueProfile usage example * @since 0.10 */ + @NeverDefault public static ValueProfile createClassProfile() { if (Profile.isProfilingEnabled()) { return ExactClass.create(); @@ -117,6 +120,31 @@ public static ValueProfile createClassProfile() { } } + /** + *

+ * Returns a value profile that profiles the exact class of a value. It will check the class of + * the profiled value and provide additional information to the compiler if only non-null values + * of exactly one concrete Java class are passed as a parameter to the + * {@link ValueProfile#profile} method. This can be beneficial if subsequent code can take + * advantage of knowing the concrete class of the value. The profile will degrade to the generic + * case if a null value or if at least two instances of two different Java classes are + * registered. + *

+ * + *

+ * Compilation notes: Value profiles require a runtime check in their initialized state + * to verify their profiled class. If two classes have been seen on a single profile instance + * then this profile will transition to a generic state with no overhead. + *

+ * + * @see ValueProfile usage example + * @since 23.0 + */ + @NeverDefault + public static ValueProfile create() { + return createClassProfile(); + } + /** *

* Returns a value profile that profiles the object identity of a value. A single instance can @@ -131,9 +159,10 @@ public static ValueProfile createClassProfile() { * * @since 0.10 */ + @NeverDefault public static ValueProfile createIdentityProfile() { if (Profile.isProfilingEnabled()) { - return Identity.create(); + return Identity.create0(); } else { return Disabled.INSTANCE; } @@ -148,6 +177,16 @@ public static ValueProfile getUncached() { return Disabled.INSTANCE; } + /** + * Returns an inlined version of the profile. This version is automatically used by Truffle DSL + * node inlining. + * + * @since 23.0 + */ + public static InlinedExactClassProfile inline(InlineTarget target) { + return InlinedExactClassProfile.inline(target); + } + static final class Disabled extends ValueProfile { static final ValueProfile INSTANCE = new Disabled(); @@ -164,7 +203,7 @@ public T profile(T value) { @Override public String toString() { - return toStringDisabled(ValueProfile.class); + return toStringDisabled(); } } @@ -228,7 +267,7 @@ public String toString() { } /* Needed for lazy class loading. */ - static ValueProfile create() { + static ValueProfile create0() { return new Identity(); } @@ -287,7 +326,7 @@ public void reset() { cachedClass = null; } - Class getCachedClass() { + Class getCachedValue() { return cachedClass; } diff --git a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest index 4449b1f729d9..f9ac389dd0d2 100644 --- a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest @@ -1,6 +1,21 @@ #Signature file v4.1 #Version +CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateCached + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean alwaysInlineCached() +meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() + +CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateInline + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() + CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratePackagePrivate anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) @@ -11,6 +26,7 @@ CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GenerateUn anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) intf java.lang.annotation.Annotation meth public abstract !hasdefault boolean inherit() +meth public abstract !hasdefault boolean value() CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.GeneratedBy anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) @@ -31,11 +47,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -43,8 +56,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -53,6 +68,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() @@ -171,7 +187,7 @@ meth public void notifyExternalMutation() meth public void writeByteUncached(int,byte,com.oracle.truffle.api.strings.TruffleString$Encoding) supr com.oracle.truffle.api.strings.AbstractTruffleString hfds codePointLength,codeRange -hcls CalcLazyAttributesNode +hcls CalcLazyAttributesNode,DataClassProfile CLSS public abstract static com.oracle.truffle.api.strings.MutableTruffleString$AsManagedNode outer com.oracle.truffle.api.strings.MutableTruffleString @@ -246,7 +262,7 @@ supr com.oracle.truffle.api.nodes.Node CLSS public final com.oracle.truffle.api.strings.MutableTruffleStringFactory cons public init() supr java.lang.Object -hcls AsManagedNodeGen,AsMutableTruffleStringNodeGen,CalcLazyAttributesNodeGen,ConcatNodeGen,ForceEncodingNodeGen,FromByteArrayNodeGen,FromNativePointerNodeGen,SubstringByteIndexNodeGen,SubstringNodeGen,SwitchEncodingNodeGen,WriteByteNodeGen +hcls AsManagedNodeGen,AsMutableTruffleStringNodeGen,CalcLazyAttributesNodeGen,ConcatNodeGen,DataClassProfileNodeGen,ForceEncodingNodeGen,FromByteArrayNodeGen,FromNativePointerNodeGen,SubstringByteIndexNodeGen,SubstringNodeGen,SwitchEncodingNodeGen,WriteByteNodeGen CLSS public abstract interface com.oracle.truffle.api.strings.NativeAllocator anno 0 java.lang.FunctionalInterface() @@ -334,7 +350,7 @@ meth public static com.oracle.truffle.api.strings.TruffleString fromLongUncached meth public static com.oracle.truffle.api.strings.TruffleString fromNativePointerUncached(java.lang.Object,int,int,com.oracle.truffle.api.strings.TruffleString$Encoding,boolean) supr com.oracle.truffle.api.strings.AbstractTruffleString hfds FLAG_CACHE_HEAD,NEXT_UPDATER,codePointLength,codeRange,next -hcls ToIndexableNode +hcls InternalAsTruffleStringNode,InternalCopyToByteArrayNode,InternalSwitchEncodingNode,ToIndexableNode CLSS public abstract static com.oracle.truffle.api.strings.TruffleString$AsManagedNode outer com.oracle.truffle.api.strings.TruffleString @@ -1049,13 +1065,14 @@ supr com.oracle.truffle.api.nodes.Node CLSS public final com.oracle.truffle.api.strings.TruffleStringBuilderFactory cons public init() supr java.lang.Object +hfds COMPACTION_LEVEL_VALUES hcls AppendArrayIntlNodeGen,AppendByteNodeGen,AppendCharUTF16NodeGen,AppendCodePointIntlNodeGen,AppendCodePointNodeGen,AppendIntNumberNodeGen,AppendJavaStringUTF16NodeGen,AppendLongNumberNodeGen,AppendStringNodeGen,AppendSubstringByteIndexNodeGen,ToStringNodeGen CLSS public final com.oracle.truffle.api.strings.TruffleStringFactory cons public init() innr public final static WithMaskFactory supr java.lang.Object -hcls AsManagedNodeGen,AsNativeNodeGen,AsTruffleStringNodeGen,ByteIndexOfAnyByteNodeGen,ByteIndexOfCodePointNodeGen,ByteIndexOfStringNodeGen,ByteIndexToCodePointIndexNodeGen,ByteLengthOfCodePointNodeGen,CharIndexOfAnyCharUTF16NodeGen,CodePointAtByteIndexNodeGen,CodePointAtIndexNodeGen,CodePointIndexToByteIndexNodeGen,CodePointLengthNodeGen,CodeRangeEqualsNodeGen,CompareBytesNodeGen,CompareCharsUTF16NodeGen,CompareIntsUTF32NodeGen,ConcatNodeGen,CopyToByteArrayNodeGen,CopyToNativeMemoryNodeGen,CreateBackwardCodePointIteratorNodeGen,CreateCodePointIteratorNodeGen,EqualNodeGen,ForceEncodingNodeGen,FromByteArrayNodeGen,FromCharArrayUTF16NodeGen,FromCodePointNodeGen,FromIntArrayUTF32NodeGen,FromJavaStringNodeGen,FromLongNodeGen,FromNativePointerNodeGen,GetByteCodeRangeNodeGen,GetCodeRangeNodeGen,GetInternalByteArrayNodeGen,GetInternalNativePointerNodeGen,GetStringCompactionLevelNodeGen,HashCodeNodeGen,IndexOfCodePointNodeGen,IndexOfStringNodeGen,IntIndexOfAnyIntUTF32NodeGen,IsValidNodeGen,LastByteIndexOfCodePointNodeGen,LastByteIndexOfStringNodeGen,LastIndexOfCodePointNodeGen,LastIndexOfStringNodeGen,MaterializeNodeGen,ParseDoubleNodeGen,ParseIntNodeGen,ParseLongNodeGen,ReadByteNodeGen,ReadCharUTF16NodeGen,RegionEqualByteIndexNodeGen,RegionEqualNodeGen,RepeatNodeGen,SubstringByteIndexNodeGen,SubstringNodeGen,SwitchEncodingNodeGen,ToIndexableNodeFactory,ToJavaStringNodeGen +hcls AsManagedNodeGen,AsNativeNodeGen,AsTruffleStringNodeGen,ByteIndexOfAnyByteNodeGen,ByteIndexOfCodePointNodeGen,ByteIndexOfStringNodeGen,ByteIndexToCodePointIndexNodeGen,ByteLengthOfCodePointNodeGen,CharIndexOfAnyCharUTF16NodeGen,CodePointAtByteIndexNodeGen,CodePointAtIndexNodeGen,CodePointIndexToByteIndexNodeGen,CodePointLengthNodeGen,CodeRangeEqualsNodeGen,CompareBytesNodeGen,CompareCharsUTF16NodeGen,CompareIntsUTF32NodeGen,ConcatNodeGen,CopyToByteArrayNodeGen,CopyToNativeMemoryNodeGen,CreateBackwardCodePointIteratorNodeGen,CreateCodePointIteratorNodeGen,EqualNodeGen,ForceEncodingNodeGen,FromByteArrayNodeGen,FromCharArrayUTF16NodeGen,FromCodePointNodeGen,FromIntArrayUTF32NodeGen,FromJavaStringNodeGen,FromLongNodeGen,FromNativePointerNodeGen,GetByteCodeRangeNodeGen,GetCodeRangeNodeGen,GetInternalByteArrayNodeGen,GetInternalNativePointerNodeGen,GetStringCompactionLevelNodeGen,HashCodeNodeGen,IndexOfCodePointNodeGen,IndexOfStringNodeGen,IntIndexOfAnyIntUTF32NodeGen,InternalAsTruffleStringNodeGen,InternalCopyToByteArrayNodeGen,InternalSwitchEncodingNodeGen,IsValidNodeGen,LastByteIndexOfCodePointNodeGen,LastByteIndexOfStringNodeGen,LastIndexOfCodePointNodeGen,LastIndexOfStringNodeGen,MaterializeNodeGen,ParseDoubleNodeGen,ParseIntNodeGen,ParseLongNodeGen,ReadByteNodeGen,ReadCharUTF16NodeGen,RegionEqualByteIndexNodeGen,RegionEqualNodeGen,RepeatNodeGen,SubstringByteIndexNodeGen,SubstringNodeGen,SwitchEncodingNodeGen,ToIndexableNodeGen,ToJavaStringNodeGen CLSS public final static com.oracle.truffle.api.strings.TruffleStringFactory$WithMaskFactory outer com.oracle.truffle.api.strings.TruffleStringFactory @@ -1073,17 +1090,18 @@ meth public int nextUncached() meth public int previousUncached() supr java.lang.Object hfds a,arrayA,codeRangeA,encoding,errorHandling,rawIndex +hcls InternalNextNode,InternalPreviousNode CLSS public abstract static com.oracle.truffle.api.strings.TruffleStringIterator$NextNode outer com.oracle.truffle.api.strings.TruffleStringIterator -meth public final int execute(com.oracle.truffle.api.strings.TruffleStringIterator) +meth public abstract int execute(com.oracle.truffle.api.strings.TruffleStringIterator) meth public static com.oracle.truffle.api.strings.TruffleStringIterator$NextNode create() meth public static com.oracle.truffle.api.strings.TruffleStringIterator$NextNode getUncached() supr com.oracle.truffle.api.nodes.Node CLSS public abstract static com.oracle.truffle.api.strings.TruffleStringIterator$PreviousNode outer com.oracle.truffle.api.strings.TruffleStringIterator -meth public final int execute(com.oracle.truffle.api.strings.TruffleStringIterator) +meth public abstract int execute(com.oracle.truffle.api.strings.TruffleStringIterator) meth public static com.oracle.truffle.api.strings.TruffleStringIterator$PreviousNode create() meth public static com.oracle.truffle.api.strings.TruffleStringIterator$PreviousNode getUncached() supr com.oracle.truffle.api.nodes.Node @@ -1091,7 +1109,7 @@ supr com.oracle.truffle.api.nodes.Node CLSS public final com.oracle.truffle.api.strings.TruffleStringIteratorFactory cons public init() supr java.lang.Object -hcls NextNodeGen,PreviousNodeGen +hcls InternalNextNodeGen,InternalPreviousNodeGen,NextNodeGen,PreviousNodeGen CLSS public abstract interface java.io.Serializable @@ -1102,10 +1120,8 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -1114,7 +1130,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -1217,6 +1232,3 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReflectionUtils.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReflectionUtils.java index 200744d9a6cf..42f785b1c11b 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReflectionUtils.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReflectionUtils.java @@ -166,23 +166,33 @@ public static Object invoke(Object object, String name, Class[] argTypes, Obj public static Method requireDeclaredMethod(Class clazz, String name, Class[] argTypes) { try { + Class lookupClass = clazz; Method found = null; - if (argTypes == null) { - // search just by name - for (Method search : clazz.getDeclaredMethods()) { - if (search.getName().equals(name)) { - if (found != null) { - throw new AssertionError("Ambiguous method name " + search + " " + found + ". Use argTypes to disamgbiguate."); + + while (found == null && lookupClass != null) { + if (argTypes == null) { + // search just by name + for (Method search : lookupClass.getDeclaredMethods()) { + if (search.getName().equals(name)) { + if (found != null) { + throw new AssertionError("Ambiguous method name " + search + " " + found + ". Use argTypes to disamgbiguate."); + } + found = search; } - found = search; + } + } else { + try { + found = lookupClass.getDeclaredMethod(name, argTypes); + } catch (NoSuchMethodException e) { } } - if (found == null) { - throw new NoSuchMethodException(name); - } - } else { - found = clazz.getDeclaredMethod(name, argTypes); + lookupClass = lookupClass.getSuperclass(); } + + if (found == null) { + throw new NoSuchMethodException(name); + } + setAccessible(found, true); return found; } catch (Exception e) { diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinObject.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinObject.java index e76a249f353f..44823daa944f 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinObject.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinObject.java @@ -50,11 +50,13 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; @@ -68,7 +70,7 @@ import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) @SuppressWarnings("static-method") @@ -150,6 +152,7 @@ final boolean isMemberExisting(String member, return false; } + @NeverDefault static BuiltinDescriptor getDescriptorImpl(BuiltinObject object) { return object.getBuiltinDescriptor(); } @@ -314,9 +317,10 @@ boolean isArrayElementReadable(long idx) { @ExportMessage String readArrayElement(long idx, - @Cached BranchProfile exception) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(idx); } return members[(int) idx].name; diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinTestObject.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinTestObject.java index c06356c5993d..def75a60524e 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinTestObject.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/builtin/BuiltinTestObject.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.CachedLibrary; +@SuppressWarnings("truffle-inlining") public final class BuiltinTestObject extends BuiltinObject { private static final BuiltinDescriptor DESCRIPTOR = describe(BuiltinTestObjectFactory.getFactories()); diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java index efc5f08aaa35..7b579ac454e4 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java @@ -43,7 +43,16 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; @@ -228,6 +237,116 @@ protected final Supplier adoptNode(TruffleLanguage lang, return () -> (T) root.node; } + protected interface ParallelObjectConsumer { + + /** + * @param object current object previously created by the objectFactory that is shared + * across threads. + * @param threadIndex current thread index of the current iteration + * @param objectIndex object index of the current iteration and thread + */ + void accept(T object, int threadIndex, int objectIndex); + + } + + protected final List assertNodeInParallel(Supplier objectFactory, ParallelObjectConsumer assertions, + int threadPools, + int threads, + int iterations, + int objectCount) throws InterruptedException { + return assertInParallel(() -> adoptNode(objectFactory.get()).get(), assertions, threadPools, threads, iterations, objectCount); + } + + /** + * Runs assertions for a node in parallel. This method aims to maximize races for each + * assertions consumer running in parallel. + * + * @param threadPools number of thread pools + * @param threads number of threads in parallel for each iteration + * @param number of iterations per thread pool + * @param number of objects created through the factory per iteration. + */ + @SuppressWarnings({"unchecked", "static-method"}) + protected final List assertInParallel(Supplier objectFactory, ParallelObjectConsumer assertions, + int threadPools, + int threads, + int iterations, + int objectCount) throws InterruptedException { + List createdObjects = new ArrayList<>(); + for (int poolIndex = 0; poolIndex < threadPools; poolIndex++) { + ExecutorService executorService = Executors.newFixedThreadPool(threads); + try { + Semaphore semaphore = new Semaphore(0); + AtomicReference node = new AtomicReference<>(); + AtomicReference latchRef = new AtomicReference<>(); + List> futures = new ArrayList<>(); + AtomicReference error = new AtomicReference<>(); + for (int i = 0; i < threads; i++) { + int threadIndex = i + 1; + futures.add(executorService.submit(() -> { + while (true) { + try { + semaphore.acquire(); + } catch (InterruptedException e1) { + throw new AssertionError(e1); + } + CountDownLatch latch = latchRef.get(); + try { + T[] nodes = node.get(); + for (int objectIndex = 0; objectIndex < objectCount; objectIndex++) { + assertions.accept(nodes[objectIndex], threadIndex, objectIndex); + } + if (latch == null) { + break; + } + } catch (Throwable t) { + error.set(t); + } finally { + if (latch != null) { + latch.countDown(); + try { + latch.await(); + } catch (InterruptedException e) { + throw new AssertionError(e); + } + } + } + } + })); + } + try { + for (int i = 0; i < iterations; i++) { + T[] nodes = (T[]) new Node[objectCount]; + for (int j = 0; j < objectCount; j++) { + nodes[j] = objectFactory.get(); + createdObjects.add(nodes[j]); + } + node.set(nodes); + CountDownLatch latch = new CountDownLatch(threads); + latchRef.set(latch); + semaphore.release(threads); + latch.await(); + if (error.get() != null) { + break; + } + } + + } finally { + latchRef.set(null); + semaphore.release(threads); + } + + if (error.get() != null) { + throw new AssertionError(error.get()); + } + } finally { + executorService.shutdownNow(); + executorService.awaitTermination(100, TimeUnit.SECONDS); + } + } + return createdObjects; + } + @After public final void cleanup() { if (context != null) { diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/FileSystemsTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/FileSystemsTest.java index 9da583bf7bea..314e67594c8f 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/FileSystemsTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/FileSystemsTest.java @@ -1543,6 +1543,8 @@ public void testGetAttribute() { @Test public void testSetAttribute() { + Assume.assumeTrue(false); + Context ctx = cfg.getContext(); Path path = cfg.getPath(); boolean canRead = cfg.canRead(); diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java index 232672237698..665ea48aa03b 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java @@ -968,9 +968,8 @@ public void testOverloadedFunctionalMethod() throws Exception { function.execute("ok"); // when calling a functional interface implementation, only dispatch to implementations of // the single abstract method and not other methods with the same name in the subclass. - assertFails(() -> function.execute(42), PolyglotException.class, e -> { - assertTrue(e.toString(), e.isHostException()); - assertTrue(e.asHostException().toString(), e.asHostException() instanceof ClassCastException); + assertFails(() -> function.execute(42), IllegalArgumentException.class, e -> { + assertTrue(e.getMessage(), e.getMessage().contains("Cannot convert '42'(language: Java, type: java.lang.Integer)")); }); assertFails(() -> function.execute("ok", "not ok"), IllegalArgumentException.class); diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java index c87fb4343719..9b111057d8ee 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java @@ -334,7 +334,11 @@ public void testMultipleJarStreams() throws IOException, InteropException { try (InputStream stream = hostClass.getResourceAsStream("/" + HostClassLoadingTestClass3.class.getName().replace('.', '/') + ".class")) { assertNotNull(stream); - assertEquals(HostClassLoadingTestClass3.countBytes(stream), result); + long bytes = HostClassLoadingTestClass3.countBytes(stream); + // weird behavior on osx that sometimes countBytes returns Integer.MAX_VALUE + if (bytes != Integer.MAX_VALUE) { + assertEquals(HostClassLoadingTestClass3.countBytes(stream), result); + } } } finally { Files.deleteIfExists(jar); diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotExceptionTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotExceptionTest.java index c6f141b7d072..f5b08fa2ed20 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotExceptionTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotExceptionTest.java @@ -81,6 +81,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.exception.AbstractTruffleException; @@ -740,6 +741,7 @@ abstract static class BaseNode extends Node { abstract Object execute(VirtualFrame frame); } + @GenerateInline(false) abstract static class ReadBindingsNode extends BaseNode { @Specialization diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ValueAPITest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ValueAPITest.java index d45c9dea8f21..0c8f6eb031c2 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ValueAPITest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/ValueAPITest.java @@ -125,6 +125,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -134,7 +135,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.tck.tests.ValueAssert.Trait; public class ValueAPITest { @@ -2449,9 +2451,10 @@ boolean isArrayElementReadable(long idx) { @ExportMessage String readArrayElement(long idx, - @Cached BranchProfile exception) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(idx); } return members[(int) idx]; diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/AbstractProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/AbstractProfileTest.java new file mode 100644 index 000000000000..be3b20e082bd --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/AbstractProfileTest.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.test.profiles; + +import static com.oracle.truffle.api.test.ReflectionUtils.invoke; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; + +import com.oracle.truffle.api.dsl.InlineSupport.ByteField; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.IntField; +import com.oracle.truffle.api.dsl.InlineSupport.LongField; +import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedProfile; +import com.oracle.truffle.api.profiles.Profile; +import com.oracle.truffle.api.test.ReflectionUtils; + +public abstract class AbstractProfileTest { + + protected T createEnabled(Class p) { + if (InlinedProfile.class.isAssignableFrom(p)) { + return inline(p); + } else { + return ReflectionUtils.newInstance(p); + } + } + + static final class InlinedStateNode extends Node { + + int state0; + int state1; + int state2; + int state3; + + int int0; + int int1; + int int2; + int int3; + + byte byte0; + byte byte1; + byte byte2; + byte byte3; + + long long0; + long long1; + long long2; + long long3; + + Object ref0; + Object ref1; + Object ref2; + Object ref3; + + static Lookup lookup() { + return MethodHandles.lookup(); + } + + } + + protected abstract InlinableField[] getInlinedFields(); + + protected static final InlinableField[] createInlinedFields(int stateFields, int byteFields, int intFields, int longFields, int refFields) { + List fields = new ArrayList<>(); + + for (int i = 0; i < stateFields; i++) { + fields.add(StateField.create(InlinedStateNode.lookup(), "state" + i)); + } + + for (int i = 0; i < byteFields; i++) { + fields.add(ByteField.create(InlinedStateNode.lookup(), "byte" + i)); + } + + for (int i = 0; i < intFields; i++) { + fields.add(IntField.create(InlinedStateNode.lookup(), "int" + i)); + } + + for (int i = 0; i < longFields; i++) { + fields.add(LongField.create(InlinedStateNode.lookup(), "long" + i)); + } + + for (int i = 0; i < refFields; i++) { + fields.add(ReferenceField.create(InlinedStateNode.lookup(), "ref" + i, Object.class)); + } + + return fields.toArray(new InlinableField[fields.size()]); + } + + protected InlinedStateNode state; + + @Before + public final void setup() { + } + + @SuppressWarnings("unchecked") + private T inline(Class inlined) { + state = new InlinedStateNode(); + return ReflectionUtils.newInstance(inlined, InlineTarget.create(Profile.class, getInlinedFields())); + + } + + protected static boolean isInlined(Object p) { + return p instanceof InlinedProfile; + } + + protected String toString(Object profile) { + if (isInlined(profile)) { + return ((InlinedProfile) profile).toString(state); + } else { + return profile.toString(); + } + } + + protected boolean isGeneric(Object profile) { + return (boolean) invokeProfileMethod(profile, "isGeneric"); + } + + @SuppressWarnings("rawtypes") + protected final Object invokeProfileMethod(Object profile, String name) { + if (isInlined(profile)) { + return invoke(profile, name, new Class[]{Node.class}, state); + } else { + return invoke(profile, name); + } + } + + protected boolean isUninitialized(Object profile) { + return (boolean) invokeProfileMethod(profile, "isUninitialized"); + } + + @SuppressWarnings("unchecked") + protected V getCachedValue(Object profile) { + return (V) invokeProfileMethod(profile, "getCachedValue"); + } + +} diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BinaryConditionProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BinaryConditionProfileTest.java index 603d664ae2da..0e4485d99e7f 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BinaryConditionProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BinaryConditionProfileTest.java @@ -40,89 +40,201 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; -import static com.oracle.truffle.api.test.ReflectionUtils.invokeStatic; -import static com.oracle.truffle.api.test.ReflectionUtils.loadRelative; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class BinaryConditionProfileTest { +public class BinaryConditionProfileTest extends AbstractProfileTest { - @DataPoints public static boolean[] data = new boolean[]{true, false}; + private static boolean[] VALUES = new boolean[]{true, false}; @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private ConditionProfile profile; + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 0, 0, 0); + } - @Before - public void create() { - profile = (ConditionProfile) invokeStatic(loadRelative(BinaryConditionProfileTest.class, "ConditionProfile$Binary"), "createLazyLoadClass"); + private boolean wasTrue(Object profile) { + return (boolean) invokeProfileMethod(profile, "wasTrue"); } - private static boolean wasTrue(ConditionProfile profile) { - return (boolean) invoke(profile, "wasTrue"); + private boolean wasFalse(Object profile) { + return (boolean) invokeProfileMethod(profile, "wasFalse"); } - private static boolean wasFalse(ConditionProfile profile) { - return (boolean) invoke(profile, "wasFalse"); + @Test + public void testNotCrashing() { + ConditionProfile profile = createEnabled(ConditionProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } @Test public void testInitial() { + ConditionProfile profile = createEnabled(ConditionProfile.class); assertThat(wasTrue(profile), is(false)); assertThat(wasFalse(profile), is(false)); - profile.toString(); + profile.toString(); // test that it is not crashing } - @Theory - public void testProfileOne(boolean value) { - boolean result = profile.profile(value); + @Test + public void testProfileOne() { + for (boolean value : VALUES) { + ConditionProfile profile = createEnabled(ConditionProfile.class); + boolean result = profile.profile(value); + + assertThat(result, is(value)); + assertThat(wasTrue(profile), is(value)); + assertThat(wasFalse(profile), is(!value)); + profile.toString(); + } + } - assertThat(result, is(value)); - assertThat(wasTrue(profile), is(value)); - assertThat(wasFalse(profile), is(!value)); - profile.toString(); + @Test + public void testProfileTwo() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + ConditionProfile profile = createEnabled(ConditionProfile.class); + + boolean result0 = profile.profile(value0); + boolean result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(wasTrue(profile), is(value0 || value1)); + assertThat(wasFalse(profile), is(!value0 || !value1)); + profile.toString(); + } + } } - @Theory - public void testProfileTwo(boolean value0, boolean value1) { - boolean result0 = profile.profile(value0); - boolean result1 = profile.profile(value1); + @Test + public void testProfileThree() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + for (boolean value2 : VALUES) { + ConditionProfile profile = createEnabled(ConditionProfile.class); + + boolean result0 = profile.profile(value0); + boolean result1 = profile.profile(value1); + boolean result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + assertThat(wasTrue(profile), is(value0 || value1 || value2)); + assertThat(wasFalse(profile), is(!value0 || !value1 || !value2)); + profile.toString(); + } + } + } + + } - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(wasTrue(profile), is(value0 || value1)); - assertThat(wasFalse(profile), is(!value0 || !value1)); - profile.toString(); + @Test + public void testNotCrashingInlined() { + InlinedConditionProfile profile = createEnabled(InlinedConditionProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - @Theory - public void testProfileThree(boolean value0, boolean value1, boolean value2) { - boolean result0 = profile.profile(value0); - boolean result1 = profile.profile(value1); - boolean result2 = profile.profile(value2); + @Test + public void testInitialInlined() { + InlinedConditionProfile profile = createEnabled(InlinedConditionProfile.class); + assertThat(wasTrue(profile), is(false)); + assertThat(wasFalse(profile), is(false)); + profile.toString(); // test that it is not crashing + } - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); - assertThat(wasTrue(profile), is(value0 || value1 || value2)); - assertThat(wasFalse(profile), is(!value0 || !value1 || !value2)); - profile.toString(); + @Test + public void testProfileOneInlined() { + for (boolean value : VALUES) { + InlinedConditionProfile profile = createEnabled(InlinedConditionProfile.class); + boolean result = profile.profile(state, value); + + assertThat(result, is(value)); + assertThat(wasTrue(profile), is(value)); + assertThat(wasFalse(profile), is(!value)); + profile.toString(); + } + } + + @Test + public void testProfileTwoInlined() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + InlinedConditionProfile profile = createEnabled(InlinedConditionProfile.class); + + boolean result0 = profile.profile(state, value0); + boolean result1 = profile.profile(state, value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(wasTrue(profile), is(value0 || value1)); + assertThat(wasFalse(profile), is(!value0 || !value1)); + profile.toString(); + } + } + } + + @Test + public void testProfileThreeInlined() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + for (boolean value2 : VALUES) { + InlinedConditionProfile profile = createEnabled(InlinedConditionProfile.class); + + boolean result0 = profile.profile(state, value0); + boolean result1 = profile.profile(state, value1); + boolean result2 = profile.profile(state, value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + assertThat(wasTrue(profile), is(value0 || value1 || value2)); + assertThat(wasFalse(profile), is(!value0 || !value1 || !value2)); + profile.toString(); + } + } + } + + } + + @Test + public void testDisabled() { + ConditionProfile p = ConditionProfile.getUncached(); + for (boolean value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedConditionProfile p = InlinedConditionProfile.getUncached(); + for (boolean value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } + p.toString(); // test that it is not crashing } } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BranchProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BranchProfileTest.java index 5163e992eb73..bbd3f1849719 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BranchProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/BranchProfileTest.java @@ -40,38 +40,97 @@ */ package com.oracle.truffle.api.test.profiles; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.test.ReflectionUtils; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -public class BranchProfileTest { +public class BranchProfileTest extends AbstractProfileTest { @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 0, 0, 0); + } + @Test public void testEnter() { - BranchProfile profile = ReflectionUtils.newInstance(BranchProfile.class); - profile.enter(); + BranchProfile profile = createEnabled(BranchProfile.class); + + assertTrue(toString(profile).contains(BranchProfile.class.getSimpleName())); + assertTrue(toString(profile).contains("UNINITIALIZED")); + assertTrue(toString(profile).contains(Integer.toHexString(profile.hashCode()))); + profile.enter(); + + assertTrue(toString(profile).contains(BranchProfile.class.getSimpleName())); + assertTrue(toString(profile).contains("VISITED")); + assertTrue(toString(profile).contains(Integer.toHexString(profile.hashCode()))); } @Test - public void testToString() { - BranchProfile profile = ReflectionUtils.newInstance(BranchProfile.class); - assertTrue(profile.toString().contains(BranchProfile.class.getSimpleName())); - assertTrue(profile.toString().contains("UNINITIALIZED")); - assertTrue(profile.toString().contains(Integer.toHexString(profile.hashCode()))); - profile.enter(); - assertTrue(profile.toString().contains(BranchProfile.class.getSimpleName())); - assertTrue(profile.toString().contains("VISITED")); - assertTrue(profile.toString().contains(Integer.toHexString(profile.hashCode()))); + public void testEnterInlined() { + InlinedBranchProfile profile = createEnabled(InlinedBranchProfile.class); + + assertTrue(toString(profile).contains(BranchProfile.class.getSimpleName())); + assertTrue(toString(profile).contains("UNINITIALIZED")); + assertTrue(toString(profile).contains(Integer.toHexString(profile.hashCode()))); + + if (isInlined(profile)) { + assertEquals(0, state.state0); + } + + profile.enter(state); + + assertTrue(toString(profile).contains(BranchProfile.class.getSimpleName())); + assertTrue(toString(profile).contains("VISITED")); + assertTrue(toString(profile).contains(Integer.toHexString(profile.hashCode()))); + + assertEquals(1, state.state0); + } + + @Test + public void testNotCrashing() { + BranchProfile profile = createEnabled(BranchProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } + + @Test + public void testNotCrashingInlined() { + InlinedBranchProfile profile = createEnabled(InlinedBranchProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } + + @Test + public void testDisabled() { + BranchProfile p = BranchProfile.getUncached(); + p.enter(); + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedBranchProfile p = InlinedBranchProfile.getUncached(); + p.enter(state); + p.toString(); // test that it is not crashing } } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ByteValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ByteValueProfileTest.java index 477d60af75dc..6b88b50840b7 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ByteValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ByteValueProfileTest.java @@ -40,117 +40,208 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.ByteValueProfile; -import com.oracle.truffle.api.test.ReflectionUtils; +import com.oracle.truffle.api.profiles.InlinedByteValueProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class ByteValueProfileTest { +public class ByteValueProfileTest extends AbstractProfileTest { - @DataPoint public static final byte VALUE0 = Byte.MIN_VALUE; - @DataPoint public static final byte VALUE1 = 0; - @DataPoint public static final byte VALUE2 = 14; - @DataPoint public static final byte VALUE3 = Byte.MAX_VALUE; + private static byte[] VALUES = new byte[]{Byte.MIN_VALUE, 0, 14, Byte.MAX_VALUE}; @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private ByteValueProfile profile; + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 1, 0, 0, 0); + } - @Before - public void create() { - profile = ReflectionUtils.newInstance(ByteValueProfile.class); + @Test + public void testNotCrashing() { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - private static boolean isGeneric(ByteValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); + @Test + public void testInitial() { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing } - private static boolean isUninitialized(ByteValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); + @Test + public void testProfileOneObject() { + for (byte value : VALUES) { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + byte result = profile.profile(value); + assertThat(result, is(value)); + assertEquals((byte) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + } } - private static byte getCachedValue(ByteValueProfile profile) { - return (byte) invoke(profile, "getCachedValue"); + @Test + public void testProfileTwoObject() { + for (byte value0 : VALUES) { + for (byte value1 : VALUES) { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + byte result0 = profile.profile(value0); + byte result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + toString(profile); // test that it is not crashing + } + } } @Test - public void testInitial() { - assertThat(isGeneric(profile), is(false)); - assertThat(isUninitialized(profile), is(true)); - profile.toString(); // test that it is not crashing + public void testProfileThreeObject() { + for (byte value0 : VALUES) { + for (byte value1 : VALUES) { + for (byte value2 : VALUES) { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + byte result0 = profile.profile(value0); + byte result1 = profile.profile(value1); + byte result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + + } + } + } } - @Theory - public void testProfileOneObject(byte value) { - byte result = profile.profile(value); + @Test + public void testNotCrashingInlined() { + InlinedByteValueProfile profile = createEnabled(InlinedByteValueProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } - assertThat(result, is(value)); - assertEquals(getCachedValue(profile), value); - assertThat(isUninitialized(profile), is(false)); + @Test + public void testInitialInlined() { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } - @Theory - public void testProfileTwoObject(byte value0, byte value1) { - byte result0 = profile.profile(value0); - byte result1 = profile.profile(value1); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); + @Test + public void testProfileOneObjectInlined() { + for (byte value : VALUES) { + InlinedByteValueProfile profile = createEnabled(InlinedByteValueProfile.class); + byte result = profile.profile(state, value); + assertThat(result, is(value)); + assertEquals((byte) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + } + } - if (value0 == value1) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileTwoObjectInlined() { + for (byte value0 : VALUES) { + for (byte value1 : VALUES) { + InlinedByteValueProfile profile = createEnabled(InlinedByteValueProfile.class); + byte result0 = profile.profile(state, value0); + byte result1 = profile.profile(state, value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + toString(profile); // test that it is not crashing + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } - @Theory - public void testProfileThreeObject(byte value0, byte value1, byte value2) { - byte result0 = profile.profile(value0); - byte result1 = profile.profile(value1); - byte result2 = profile.profile(value2); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); - - if (value0 == value1 && value1 == value2) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileThreeObjectInlined() { + for (byte value0 : VALUES) { + for (byte value1 : VALUES) { + for (byte value2 : VALUES) { + InlinedByteValueProfile profile = createEnabled(InlinedByteValueProfile.class); + byte result0 = profile.profile(state, value0); + byte result1 = profile.profile(state, value1); + byte result2 = profile.profile(state, value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + + } + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } @Test public void testDisabled() { ByteValueProfile p = ByteValueProfile.getUncached(); - assertThat(p.profile(VALUE0), is(VALUE0)); - assertThat(p.profile(VALUE1), is(VALUE1)); - assertThat(p.profile(VALUE2), is(VALUE2)); - assertThat(p.profile(VALUE3), is(VALUE3)); + for (byte value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedByteValueProfile p = InlinedByteValueProfile.getUncached(); + for (byte value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } p.toString(); // test that it is not crashing } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/CountingConditionProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/CountingConditionProfileTest.java index 09db63bdce5d..6fb27edf6d26 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/CountingConditionProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/CountingConditionProfileTest.java @@ -40,89 +40,197 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; -import static com.oracle.truffle.api.test.ReflectionUtils.invokeStatic; -import static com.oracle.truffle.api.test.ReflectionUtils.loadRelative; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class CountingConditionProfileTest { +public class CountingConditionProfileTest extends AbstractProfileTest { - @DataPoints public static boolean[] data = new boolean[]{true, false}; + private static boolean[] VALUES = new boolean[]{true, false}; @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private ConditionProfile profile; + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(0, 0, 2, 0, 0); + } - @Before - public void create() { - profile = (ConditionProfile) invokeStatic(loadRelative(CountingConditionProfileTest.class, "ConditionProfile$Counting"), "createLazyLoadClass"); + private int getTrueCount(Object profile) { + return (int) invokeProfileMethod(profile, "getTrueCount"); } - private static int getTrueCount(ConditionProfile profile) { - return (int) invoke(profile, "getTrueCount"); + private int getFalseCount(Object profile) { + return (int) invokeProfileMethod(profile, "getFalseCount"); } - private static int getFalseCount(ConditionProfile profile) { - return (int) invoke(profile, "getFalseCount"); + @Test + public void testNotCrashing() { + CountingConditionProfile profile = createEnabled(CountingConditionProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } @Test public void testInitial() { + CountingConditionProfile profile = createEnabled(CountingConditionProfile.class); assertThat(getTrueCount(profile), is(0)); assertThat(getFalseCount(profile), is(0)); profile.toString(); } - @Theory - public void testProfileOne(boolean value) { - boolean result = profile.profile(value); + @Test + public void testProfileOne() { + for (boolean value : VALUES) { + CountingConditionProfile profile = createEnabled(CountingConditionProfile.class); + boolean result = profile.profile(value); + + assertThat(result, is(value)); + assertThat(getTrueCount(profile), is(value ? 1 : 0)); + assertThat(getFalseCount(profile), is(!value ? 1 : 0)); + profile.toString(); + } + } - assertThat(result, is(value)); - assertThat(getTrueCount(profile), is(value ? 1 : 0)); - assertThat(getFalseCount(profile), is(!value ? 1 : 0)); - profile.toString(); + @Test + public void testProfileTwo() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + CountingConditionProfile profile = createEnabled(CountingConditionProfile.class); + boolean result0 = profile.profile(value0); + boolean result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0))); + assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0))); + profile.toString(); + } + } + } + + @Test + public void testProfileThree() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + for (boolean value2 : VALUES) { + CountingConditionProfile profile = createEnabled(CountingConditionProfile.class); + boolean result0 = profile.profile(value0); + boolean result1 = profile.profile(value1); + boolean result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0) + (value2 ? 1 : 0))); + assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0) + (!value2 ? 1 : 0))); + profile.toString(); + } + } + } } - @Theory - public void testProfileTwo(boolean value0, boolean value1) { - boolean result0 = profile.profile(value0); - boolean result1 = profile.profile(value1); + @Test + public void testNotCrashingInlined() { + InlinedCountingConditionProfile profile = createEnabled(InlinedCountingConditionProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0))); - assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0))); + @Test + public void testInitialInlined() { + InlinedCountingConditionProfile profile = createEnabled(InlinedCountingConditionProfile.class); + assertThat(getTrueCount(profile), is(0)); + assertThat(getFalseCount(profile), is(0)); profile.toString(); } - @Theory - public void testProfileThree(boolean value0, boolean value1, boolean value2) { - boolean result0 = profile.profile(value0); - boolean result1 = profile.profile(value1); - boolean result2 = profile.profile(value2); + @Test + public void testProfileOneInlined() { + for (boolean value : VALUES) { + InlinedCountingConditionProfile profile = createEnabled(InlinedCountingConditionProfile.class); + boolean result = profile.profile(state, value); + + assertThat(result, is(value)); + assertThat(getTrueCount(profile), is(value ? 1 : 0)); + assertThat(getFalseCount(profile), is(!value ? 1 : 0)); + profile.toString(); + } + } - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); - assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0) + (value2 ? 1 : 0))); - assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0) + (!value2 ? 1 : 0))); - profile.toString(); + @Test + public void testProfileTwoInlined() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + InlinedCountingConditionProfile profile = createEnabled(InlinedCountingConditionProfile.class); + boolean result0 = profile.profile(state, value0); + boolean result1 = profile.profile(state, value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0))); + assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0))); + profile.toString(); + } + } + } + + @Test + public void testProfileThreeInlined() { + for (boolean value0 : VALUES) { + for (boolean value1 : VALUES) { + for (boolean value2 : VALUES) { + InlinedCountingConditionProfile profile = createEnabled(InlinedCountingConditionProfile.class); + boolean result0 = profile.profile(state, value0); + boolean result1 = profile.profile(state, value1); + boolean result2 = profile.profile(state, value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + assertThat(getTrueCount(profile), is((value0 ? 1 : 0) + (value1 ? 1 : 0) + (value2 ? 1 : 0))); + assertThat(getFalseCount(profile), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0) + (!value2 ? 1 : 0))); + profile.toString(); + } + } + } + } + + @Test + public void testDisabled() { + ConditionProfile p = ConditionProfile.getUncached(); + for (boolean value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedConditionProfile p = InlinedConditionProfile.getUncached(); + for (boolean value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } + p.toString(); // test that it is not crashing } } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/DoubleValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/DoubleValueProfileTest.java index afa5342718ee..2a184ae55f06 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/DoubleValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/DoubleValueProfileTest.java @@ -40,31 +40,22 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.DoubleValueProfile; -import com.oracle.truffle.api.test.ReflectionUtils; +import com.oracle.truffle.api.profiles.InlinedDoubleValueProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class DoubleValueProfileTest { +public class DoubleValueProfileTest extends AbstractProfileTest { - @DataPoint public static final double VALUE0 = Double.MIN_VALUE; - @DataPoint public static final double VALUE1 = -0.0f; - @DataPoint public static final double VALUE2 = +0.0f; - @DataPoint public static final double VALUE3 = 14.5f; - @DataPoint public static final double VALUE4 = Double.MAX_VALUE; + private static double[] VALUES = new double[]{Double.MIN_VALUE, -0.0d, +0.0d, 14.5f, Double.MAX_VALUE}; private static final double FLOAT_DELTA = 0.00001f; @@ -73,23 +64,9 @@ public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private DoubleValueProfile profile; - - @Before - public void create() { - profile = ReflectionUtils.newInstance(DoubleValueProfile.class); - } - - private static boolean isGeneric(DoubleValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); - } - - private static boolean isUninitialized(DoubleValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); - } - - private static double getCachedValue(DoubleValueProfile profile) { - return (double) invoke(profile, "getCachedValue"); + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 0, 2, 0); } public static boolean exactCompare(double a, double b) { @@ -100,71 +77,183 @@ public static boolean exactCompare(double a, double b) { return Double.doubleToRawLongBits(a) == Double.doubleToRawLongBits(b); } + @Test + public void testNotCrashing() { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } + @Test public void testInitial() { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); assertThat(isGeneric(profile), is(false)); assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } - @Theory - public void testProfileOneFloat(double value) { - double result = profile.profile(value); + @Test + public void testProfileOneFloat() { + for (double value : VALUES) { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); + double result = profile.profile(value); - assertThat(result, is(value)); - assertEquals(getCachedValue(profile), value, FLOAT_DELTA); - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing + assertThat(result, is(value)); + assertEquals((double) getCachedValue(profile), value, FLOAT_DELTA); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - @SuppressWarnings("deprecation") - @Theory - public void testProfileTwoFloat(double value0, double value1) { - double result0 = profile.profile(value0); - double result1 = profile.profile(value1); + @Test + public void testProfileTwoFloat() { + for (double value0 : VALUES) { + for (double value1 : VALUES) { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); + double result0 = profile.profile(value0); + double result1 = profile.profile(value1); - assertEquals(result0, value0, FLOAT_DELTA); - assertEquals(result1, value1, FLOAT_DELTA); + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); - if (exactCompare(value0, value1)) { - assertEquals(getCachedValue(profile), value0, FLOAT_DELTA); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + if (exactCompare(value0, value1)) { + assertEquals((double) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } - @SuppressWarnings("deprecation") - @Theory - public void testProfileThreeFloat(double value0, double value1, double value2) { - double result0 = profile.profile(value0); - double result1 = profile.profile(value1); - double result2 = profile.profile(value2); - - assertEquals(result0, value0, FLOAT_DELTA); - assertEquals(result1, value1, FLOAT_DELTA); - assertEquals(result2, value2, FLOAT_DELTA); - - if (exactCompare(value0, value1) && exactCompare(value1, value2)) { - assertEquals(getCachedValue(profile), value0, FLOAT_DELTA); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileThreeFloat() { + for (double value0 : VALUES) { + for (double value1 : VALUES) { + for (double value2 : VALUES) { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); + double result0 = profile.profile(value0); + double result1 = profile.profile(value1); + double result2 = profile.profile(value2); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + assertEquals(result2, value2, FLOAT_DELTA); + + if (exactCompare(value0, value1) && exactCompare(value1, value2)) { + assertEquals((double) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } - assertThat(isUninitialized(profile), is(false)); + } + + @Test + public void testNotCrashingInlined() { + InlinedDoubleValueProfile profile = createEnabled(InlinedDoubleValueProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } + + @Test + public void testInitialInlined() { + DoubleValueProfile profile = createEnabled(DoubleValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } + @Test + public void testProfileOneFloatInlined() { + for (double value : VALUES) { + InlinedDoubleValueProfile profile = createEnabled(InlinedDoubleValueProfile.class); + double result = profile.profile(state, value); + + assertThat(result, is(value)); + assertEquals((double) getCachedValue(profile), value, FLOAT_DELTA); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + + @Test + public void testProfileTwoFloatInlined() { + for (double value0 : VALUES) { + for (double value1 : VALUES) { + InlinedDoubleValueProfile profile = createEnabled(InlinedDoubleValueProfile.class); + double result0 = profile.profile(state, value0); + double result1 = profile.profile(state, value1); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + + if (exactCompare(value0, value1)) { + assertEquals((double) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + } + + @Test + public void testProfileThreeFloatInlined() { + for (double value0 : VALUES) { + for (double value1 : VALUES) { + for (double value2 : VALUES) { + InlinedDoubleValueProfile profile = createEnabled(InlinedDoubleValueProfile.class); + double result0 = profile.profile(state, value0); + double result1 = profile.profile(state, value1); + double result2 = profile.profile(state, value2); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + assertEquals(result2, value2, FLOAT_DELTA); + + if (exactCompare(value0, value1) && exactCompare(value1, value2)) { + assertEquals((double) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + } + } + @Test public void testDisabled() { DoubleValueProfile p = DoubleValueProfile.getUncached(); - assertThat(p.profile(VALUE0), is(VALUE0)); - assertThat(p.profile(VALUE1), is(VALUE1)); - assertThat(p.profile(VALUE2), is(VALUE2)); - assertThat(p.profile(VALUE3), is(VALUE3)); - assertThat(p.profile(VALUE4), is(VALUE4)); + for (double value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedDoubleValueProfile p = InlinedDoubleValueProfile.getUncached(); + for (double value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } p.toString(); // test that it is not crashing } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ExactClassValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ExactClassValueProfileTest.java index ec5430c42caa..0c4fd923909a 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ExactClassValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/ExactClassValueProfileTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * The Universal Permissive License (UPL), Version 1.0 @@ -40,126 +40,229 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; -import static com.oracle.truffle.api.test.ReflectionUtils.invokeStatic; -import static com.oracle.truffle.api.test.ReflectionUtils.loadRelative; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; +import com.oracle.truffle.api.profiles.ByteValueProfile; +import com.oracle.truffle.api.profiles.InlinedExactClassProfile; import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class ExactClassValueProfileTest { +public class ExactClassValueProfileTest extends AbstractProfileTest { - @SuppressWarnings("deprecation") - private static Integer newInteger(int value) { - return new Integer(value); + private static Object[] VALUES = new Object[]{"", 42, 42d, new TestBaseClass(), new TestSubClass()}; + + private static class TestBaseClass { } - @DataPoint public static final String O1 = new String(); - @DataPoint public static final String O2 = new String(); - @DataPoint public static final Object O3 = new Object(); - @DataPoint public static final Integer O4 = newInteger(1); - @DataPoint public static final Integer O5 = null; - @DataPoint public static final TestBaseClass O6 = new TestBaseClass(); - @DataPoint public static final TestSubClass O7 = new TestSubClass(); + private static class TestSubClass extends TestBaseClass { + } @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private ValueProfile profile; + @SuppressWarnings("unchecked") + @Override + protected T createEnabled(Class p) { + if (p == ValueProfile.class) { + for (Class c : ValueProfile.class.getDeclaredClasses()) { + if (c.getSimpleName().equals("ExactClass")) { + return (T) super.createEnabled(c); + } + } + } + return super.createEnabled(p); + } - private static class TestBaseClass { + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 0, 0, 1); } - private static class TestSubClass extends TestBaseClass { + @Test + public void testNotCrashing() { + ValueProfile profile = createEnabled(ValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - @Before - public void create() { - profile = (ValueProfile) invokeStatic(loadRelative(ExactClassValueProfileTest.class, "ValueProfile$ExactClass"), "create"); + @Test + public void testInitial() { + ValueProfile profile = createEnabled(ValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing } - private static boolean isGeneric(ValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); + @Test + public void testProfileOneObject() { + for (Object value : VALUES) { + ValueProfile profile = createEnabled(ValueProfile.class); + Object result = profile.profile(value); + assertThat(result, is(value)); + assertEquals(getCachedValue(profile), value.getClass()); + assertThat(isUninitialized(profile), is(false)); + } } - private static boolean isUninitialized(ValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); + @Test + public void testProfileTwoObject() { + for (Object value0 : VALUES) { + for (Object value1 : VALUES) { + ValueProfile profile = createEnabled(ValueProfile.class); + Object result0 = profile.profile(value0); + Object result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is((Object) value0.getClass())); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + toString(profile); // test that it is not crashing + } + } } - private static Object getCachedClass(ValueProfile profile) { - return invoke(profile, "getCachedClass"); + @Test + public void testProfileThreeObject() { + for (Object value0 : VALUES) { + for (Object value1 : VALUES) { + for (Object value2 : VALUES) { + ValueProfile profile = createEnabled(ValueProfile.class); + Object result0 = profile.profile(value0); + Object result1 = profile.profile(value1); + Object result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is((Object) value0.getClass())); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + + } + } + } } @Test - public void testInitial() throws Exception { - assertThat(isGeneric(profile), is(false)); - assertThat(isUninitialized(profile), is(true)); - assertNull(getCachedClass(profile)); + public void testNotCrashingInlined() { + InlinedExactClassProfile profile = createEnabled(InlinedExactClassProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); assertNotNull(profile.toString()); } - @Theory - public void testProfileOne(Object value) throws Exception { - Object result = profile.profile(value); - - assertThat(result, is(value)); - assertEquals(expectedClass(value), getCachedClass(profile)); - assertThat(isUninitialized(profile), is(false)); - assertNotNull(profile.toString()); + @Test + public void testInitialInlined() { + ByteValueProfile profile = createEnabled(ByteValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing } - @Theory - public void testProfileTwo(Object value0, Object value1) throws Exception { - Object result0 = profile.profile(value0); - Object result1 = profile.profile(value1); + @Test + public void testProfileOneObjectInlined() { + for (Object value : VALUES) { + InlinedExactClassProfile profile = createEnabled(InlinedExactClassProfile.class); + Object result = profile.profile(state, value); + assertThat(result, is(value)); + assertEquals(getCachedValue(profile), value.getClass()); + assertThat(isUninitialized(profile), is(false)); + } + } - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); + @Test + public void testProfileTwoObjectInlined() { + for (Object value0 : VALUES) { + for (Object value1 : VALUES) { + InlinedExactClassProfile profile = createEnabled(InlinedExactClassProfile.class); + Object result0 = profile.profile(state, value0); + Object result1 = profile.profile(state, value1); - Object expectedClass = expectedClass(value0) == expectedClass(value1) ? expectedClass(value0) : Object.class; + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); - assertEquals(expectedClass, getCachedClass(profile)); - assertThat(isUninitialized(profile), is(false)); - assertThat(isGeneric(profile), is(expectedClass == Object.class)); - assertNotNull(profile.toString()); + if (value0 == value1) { + assertThat(getCachedValue(profile), is((Object) value0.getClass())); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + toString(profile); // test that it is not crashing + } + } } - @Theory - public void testProfileThree(Object value0, Object value1, Object value2) throws Exception { - Object result0 = profile.profile(value0); - Object result1 = profile.profile(value1); - Object result2 = profile.profile(value2); + @Test + public void testProfileThreeObjectInlined() { + for (Object value0 : VALUES) { + for (Object value1 : VALUES) { + for (Object value2 : VALUES) { + InlinedExactClassProfile profile = createEnabled(InlinedExactClassProfile.class); + Object result0 = profile.profile(state, value0); + Object result1 = profile.profile(state, value1); + Object result2 = profile.profile(state, value2); - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); - Object expectedClass = expectedClass(value0) == expectedClass(value1) && expectedClass(value1) == expectedClass(value2) ? expectedClass(value0) : Object.class; + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is((Object) value0.getClass())); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing - assertEquals(expectedClass, getCachedClass(profile)); - assertThat(isUninitialized(profile), is(false)); - assertThat(isGeneric(profile), is(expectedClass == Object.class)); - assertNotNull(profile.toString()); + } + } + } } - private static Class expectedClass(Object value) { - return value == null ? Object.class : value.getClass(); + @Test + public void testDisabled() { + ValueProfile p = ValueProfile.getUncached(); + for (Object value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedExactClassProfile p = InlinedExactClassProfile.getUncached(); + for (Object value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } + p.toString(); // test that it is not crashing } } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/FloatValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/FloatValueProfileTest.java index 32d7afab5b0a..3d263b43a8fa 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/FloatValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/FloatValueProfileTest.java @@ -40,32 +40,23 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; import static com.oracle.truffle.api.test.profiles.PrimitiveValueProfileTest.exactCompare; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.profiles.FloatValueProfile; -import com.oracle.truffle.api.test.ReflectionUtils; +import com.oracle.truffle.api.profiles.InlinedFloatValueProfile; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class FloatValueProfileTest { +public class FloatValueProfileTest extends AbstractProfileTest { - @DataPoint public static final float VALUE0 = Float.MIN_VALUE; - @DataPoint public static final float VALUE1 = -0.0f; - @DataPoint public static final float VALUE2 = +0.0f; - @DataPoint public static final float VALUE3 = 14.5f; - @DataPoint public static final float VALUE4 = Float.MAX_VALUE; + private static float[] VALUES = new float[]{Float.MIN_VALUE, -0.0f, +0.0f, 14.5f, Float.MAX_VALUE}; private static final float FLOAT_DELTA = 0.00001f; @@ -74,90 +65,188 @@ public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private FloatValueProfile profile; + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 1, 0, 0); + } - @Before - public void create() { - profile = ReflectionUtils.newInstance(FloatValueProfile.class); + @Test + public void testNotCrashing() { + FloatValueProfile profile = createEnabled(FloatValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - private static boolean isGeneric(FloatValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); + @Test + public void testInitial() { + FloatValueProfile profile = createEnabled(FloatValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing } - private static boolean isUninitialized(FloatValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); + @Test + public void testProfileOneFloat() { + for (float value : VALUES) { + FloatValueProfile profile = createEnabled(FloatValueProfile.class); + float result = profile.profile(value); + + assertThat(result, is(value)); + assertEquals((float) getCachedValue(profile), value, FLOAT_DELTA); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - private static float getCachedValue(FloatValueProfile profile) { - return (float) invoke(profile, "getCachedValue"); + @Test + public void testProfileTwoFloat() { + for (float value0 : VALUES) { + for (float value1 : VALUES) { + FloatValueProfile profile = createEnabled(FloatValueProfile.class); + float result0 = profile.profile(value0); + float result1 = profile.profile(value1); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + + if (exactCompare(value0, value1)) { + assertEquals((float) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } @Test - public void testInitial() { - assertThat(isGeneric(profile), is(false)); - assertThat(isUninitialized(profile), is(true)); - profile.toString(); // test that it is not crashing + public void testProfileThreeFloat() { + for (float value0 : VALUES) { + for (float value1 : VALUES) { + for (float value2 : VALUES) { + FloatValueProfile profile = createEnabled(FloatValueProfile.class); + float result0 = profile.profile(value0); + float result1 = profile.profile(value1); + float result2 = profile.profile(value2); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + assertEquals(result2, value2, FLOAT_DELTA); + + if (exactCompare(value0, value1) && exactCompare(value1, value2)) { + assertEquals((float) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + } } - @Theory - public void testProfileOneFloat(float value) { - float result = profile.profile(value); + @Test + public void testNotCrashingInlined() { + InlinedFloatValueProfile profile = createEnabled(InlinedFloatValueProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } - assertThat(result, is(value)); - assertEquals(getCachedValue(profile), value, FLOAT_DELTA); - assertThat(isUninitialized(profile), is(false)); + @Test + public void testInitialInlined() { + InlinedFloatValueProfile profile = createEnabled(InlinedFloatValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } - @SuppressWarnings("deprecation") - @Theory - public void testProfileTwoFloat(float value0, float value1) { - float result0 = profile.profile(value0); - float result1 = profile.profile(value1); - - assertEquals(result0, value0, FLOAT_DELTA); - assertEquals(result1, value1, FLOAT_DELTA); + @Test + public void testProfileOneFloatInlined() { + for (float value : VALUES) { + InlinedFloatValueProfile profile = createEnabled(InlinedFloatValueProfile.class); + float result = profile.profile(state, value); + + assertThat(result, is(value)); + assertEquals((float) getCachedValue(profile), value, FLOAT_DELTA); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } - if (exactCompare(value0, value1)) { - assertEquals(getCachedValue(profile), value0, FLOAT_DELTA); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileTwoFloatInlined() { + for (float value0 : VALUES) { + for (float value1 : VALUES) { + InlinedFloatValueProfile profile = createEnabled(InlinedFloatValueProfile.class); + float result0 = profile.profile(state, value0); + float result1 = profile.profile(state, value1); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + + if (exactCompare(value0, value1)) { + assertEquals((float) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } - @SuppressWarnings("deprecation") - @Theory - public void testProfileThreeFloat(float value0, float value1, float value2) { - float result0 = profile.profile(value0); - float result1 = profile.profile(value1); - float result2 = profile.profile(value2); - - assertEquals(result0, value0, FLOAT_DELTA); - assertEquals(result1, value1, FLOAT_DELTA); - assertEquals(result2, value2, FLOAT_DELTA); - - if (exactCompare(value0, value1) && exactCompare(value1, value2)) { - assertEquals(getCachedValue(profile), value0, FLOAT_DELTA); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileThreeFloatInlined() { + for (float value0 : VALUES) { + for (float value1 : VALUES) { + for (float value2 : VALUES) { + InlinedFloatValueProfile profile = createEnabled(InlinedFloatValueProfile.class); + float result0 = profile.profile(state, value0); + float result1 = profile.profile(state, value1); + float result2 = profile.profile(state, value2); + + assertEquals(result0, value0, FLOAT_DELTA); + assertEquals(result1, value1, FLOAT_DELTA); + assertEquals(result2, value2, FLOAT_DELTA); + + if (exactCompare(value0, value1) && exactCompare(value1, value2)) { + assertEquals((float) getCachedValue(profile), value0, FLOAT_DELTA); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } @Test public void testDisabled() { FloatValueProfile p = FloatValueProfile.getUncached(); - assertThat(p.profile(VALUE0), is(VALUE0)); - assertThat(p.profile(VALUE1), is(VALUE1)); - assertThat(p.profile(VALUE2), is(VALUE2)); - assertThat(p.profile(VALUE3), is(VALUE3)); - assertThat(p.profile(VALUE4), is(VALUE4)); + for (float value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedFloatValueProfile p = InlinedFloatValueProfile.getUncached(); + for (float value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } p.toString(); // test that it is not crashing } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IdentityValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IdentityValueProfileTest.java index 3bf3bebb07f2..d5525d44e6ca 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IdentityValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IdentityValueProfileTest.java @@ -82,7 +82,7 @@ public static void runWithWeakEncapsulationOnly() { @Before public void create() { - profile = (ValueProfile) invokeStatic(loadRelative(IdentityValueProfileTest.class, "ValueProfile$Identity"), "create"); + profile = (ValueProfile) invokeStatic(loadRelative(IdentityValueProfileTest.class, "ValueProfile$Identity"), "create0"); } private static boolean isGeneric(ValueProfile profile) { diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IntValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IntValueProfileTest.java index e6d2dcebe683..25e2c7cd02ff 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IntValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/IntValueProfileTest.java @@ -40,117 +40,210 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; +import com.oracle.truffle.api.profiles.InlinedIntValueProfile; import com.oracle.truffle.api.profiles.IntValueProfile; -import com.oracle.truffle.api.test.ReflectionUtils; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class IntValueProfileTest { +public class IntValueProfileTest extends AbstractProfileTest { - @DataPoint public static final int VALUE0 = Integer.MIN_VALUE; - @DataPoint public static final int VALUE1 = 0; - @DataPoint public static final int VALUE2 = 14; - @DataPoint public static final int VALUE3 = Integer.MAX_VALUE; + private static int[] VALUES = new int[]{Integer.MIN_VALUE, 0, 14, Integer.MAX_VALUE}; @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private IntValueProfile profile; + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 1, 0, 0); + } - @Before - public void create() { - profile = ReflectionUtils.newInstance(IntValueProfile.class); + @Test + public void testNotCrashing() { + IntValueProfile profile = createEnabled(IntValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - private static boolean isGeneric(IntValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); + @Test + public void testInitial() { + IntValueProfile profile = createEnabled(IntValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing } - private static boolean isUninitialized(IntValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); + @Test + public void testProfileOneObject() { + for (int value : VALUES) { + IntValueProfile profile = createEnabled(IntValueProfile.class); + int result = profile.profile(value); + + assertThat(result, is(value)); + assertEquals((int) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - private static int getCachedValue(IntValueProfile profile) { - return (int) invoke(profile, "getCachedValue"); + @Test + public void testProfileTwoObject() { + for (int value0 : VALUES) { + for (int value1 : VALUES) { + IntValueProfile profile = createEnabled(IntValueProfile.class); + int result0 = profile.profile(value0); + int result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } @Test - public void testInitial() { - assertThat(isGeneric(profile), is(false)); - assertThat(isUninitialized(profile), is(true)); - profile.toString(); // test that it is not crashing + public void testProfileThreeObject() { + for (int value0 : VALUES) { + for (int value1 : VALUES) { + for (int value2 : VALUES) { + IntValueProfile profile = createEnabled(IntValueProfile.class); + int result0 = profile.profile(value0); + int result1 = profile.profile(value1); + int result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + } } - @Theory - public void testProfileOneObject(int value) { - int result = profile.profile(value); + @Test + public void testNotCrashingInlined() { + InlinedIntValueProfile profile = createEnabled(InlinedIntValueProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); + } - assertThat(result, is(value)); - assertEquals(getCachedValue(profile), value); - assertThat(isUninitialized(profile), is(false)); + @Test + public void testInitialInlined() { + InlinedIntValueProfile profile = createEnabled(InlinedIntValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } - @Theory - public void testProfileTwoObject(int value0, int value1) { - int result0 = profile.profile(value0); - int result1 = profile.profile(value1); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); + @Test + public void testProfileOneObjectInlined() { + for (int value : VALUES) { + InlinedIntValueProfile profile = createEnabled(InlinedIntValueProfile.class); + int result = profile.profile(state, value); + + assertThat(result, is(value)); + assertEquals((int) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } - if (value0 == value1) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileTwoObjectInlined() { + for (int value0 : VALUES) { + for (int value1 : VALUES) { + InlinedIntValueProfile profile = createEnabled(InlinedIntValueProfile.class); + int result0 = profile.profile(state, value0); + int result1 = profile.profile(state, value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } - @Theory - public void testProfileThreeObject(int value0, int value1, int value2) { - int result0 = profile.profile(value0); - int result1 = profile.profile(value1); - int result2 = profile.profile(value2); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); - - if (value0 == value1 && value1 == value2) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileThreeObjectInlined() { + for (int value0 : VALUES) { + for (int value1 : VALUES) { + for (int value2 : VALUES) { + InlinedIntValueProfile profile = createEnabled(InlinedIntValueProfile.class); + int result0 = profile.profile(state, value0); + int result1 = profile.profile(state, value1); + int result2 = profile.profile(state, value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } @Test public void testDisabled() { IntValueProfile p = IntValueProfile.getUncached(); - assertThat(p.profile(VALUE0), is(VALUE0)); - assertThat(p.profile(VALUE1), is(VALUE1)); - assertThat(p.profile(VALUE2), is(VALUE2)); - assertThat(p.profile(VALUE3), is(VALUE3)); + for (int value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedIntValueProfile p = InlinedIntValueProfile.getUncached(); + for (int value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } p.toString(); // test that it is not crashing } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/LongValueProfileTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/LongValueProfileTest.java index 176bcd93c522..42a2e717f397 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/LongValueProfileTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/profiles/LongValueProfileTest.java @@ -40,117 +40,210 @@ */ package com.oracle.truffle.api.test.profiles; -import static com.oracle.truffle.api.test.ReflectionUtils.invoke; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; +import com.oracle.truffle.api.profiles.InlinedLongValueProfile; import com.oracle.truffle.api.profiles.LongValueProfile; -import com.oracle.truffle.api.test.ReflectionUtils; import com.oracle.truffle.tck.tests.TruffleTestAssumptions; -@RunWith(Theories.class) -public class LongValueProfileTest { +public class LongValueProfileTest extends AbstractProfileTest { - @DataPoint public static final long VALUE0 = Long.MIN_VALUE; - @DataPoint public static final long VALUE1 = 0L; - @DataPoint public static final long VALUE2 = 14L; - @DataPoint public static final long VALUE3 = Long.MAX_VALUE; + private static long[] VALUES = new long[]{Long.MIN_VALUE, 0, 14, Long.MAX_VALUE}; + + @Override + protected InlinableField[] getInlinedFields() { + return createInlinedFields(1, 0, 0, 2, 0); + } @BeforeClass public static void runWithWeakEncapsulationOnly() { TruffleTestAssumptions.assumeWeakEncapsulation(); } - private LongValueProfile profile; + @Test + public void testInitial() { + LongValueProfile profile = createEnabled(LongValueProfile.class); + assertThat(isGeneric(profile), is(false)); + assertThat(isUninitialized(profile), is(true)); + profile.toString(); // test that it is not crashing + } - @Before - public void create() { - profile = ReflectionUtils.newInstance(LongValueProfile.class); + @Test + public void testNotCrashing() { + LongValueProfile profile = createEnabled(LongValueProfile.class); + profile.disable(); + profile.reset(); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - private static boolean isGeneric(LongValueProfile profile) { - return (boolean) invoke(profile, "isGeneric"); + @Test + public void testProfileOneObject() { + for (long value : VALUES) { + LongValueProfile profile = createEnabled(LongValueProfile.class); + long result = profile.profile(value); + + assertThat(result, is(value)); + assertEquals((long) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - private static boolean isUninitialized(LongValueProfile profile) { - return (boolean) invoke(profile, "isUninitialized"); + @Test + public void testProfileTwoObject() { + for (long value0 : VALUES) { + for (long value1 : VALUES) { + LongValueProfile profile = createEnabled(LongValueProfile.class); + long result0 = profile.profile(value0); + long result1 = profile.profile(value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } - private static long getCachedValue(LongValueProfile profile) { - return (long) invoke(profile, "getCachedValue"); + @Test + public void testProfileThreeObject() { + for (long value0 : VALUES) { + for (long value1 : VALUES) { + for (long value2 : VALUES) { + LongValueProfile profile = createEnabled(LongValueProfile.class); + long result0 = profile.profile(value0); + long result1 = profile.profile(value1); + long result2 = profile.profile(value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } + } } @Test - public void testInitial() { + public void testInitialInlined() { + InlinedLongValueProfile profile = createEnabled(InlinedLongValueProfile.class); assertThat(isGeneric(profile), is(false)); assertThat(isUninitialized(profile), is(true)); profile.toString(); // test that it is not crashing } - @Theory - public void testProfileOneObject(long value) { - long result = profile.profile(value); - - assertThat(result, is(value)); - assertEquals(getCachedValue(profile), value); - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing + @Test + public void testNotCrashingInlined() { + InlinedLongValueProfile profile = createEnabled(InlinedLongValueProfile.class); + profile.disable(state); + profile.reset(state); + assertEquals(profile, profile); + assertEquals(profile.hashCode(), profile.hashCode()); + assertNotNull(profile.toString()); } - @Theory - public void testProfileTwoObject(long value0, long value1) { - long result0 = profile.profile(value0); - long result1 = profile.profile(value1); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); + @Test + public void testProfileOneObjectInlined() { + for (long value : VALUES) { + InlinedLongValueProfile profile = createEnabled(InlinedLongValueProfile.class); + long result = profile.profile(state, value); + + assertThat(result, is(value)); + assertEquals((long) getCachedValue(profile), value); + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } - if (value0 == value1) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileTwoObjectInlined() { + for (long value0 : VALUES) { + for (long value1 : VALUES) { + InlinedLongValueProfile profile = createEnabled(InlinedLongValueProfile.class); + long result0 = profile.profile(state, value0); + long result1 = profile.profile(state, value1); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + + if (value0 == value1) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } - @Theory - public void testProfileThreeObject(long value0, long value1, long value2) { - long result0 = profile.profile(value0); - long result1 = profile.profile(value1); - long result2 = profile.profile(value2); - - assertThat(result0, is(value0)); - assertThat(result1, is(value1)); - assertThat(result2, is(value2)); - - if (value0 == value1 && value1 == value2) { - assertThat(getCachedValue(profile), is(value0)); - assertThat(isGeneric(profile), is(false)); - } else { - assertThat(isGeneric(profile), is(true)); + @Test + public void testProfileThreeObjectInlined() { + for (long value0 : VALUES) { + for (long value1 : VALUES) { + for (long value2 : VALUES) { + InlinedLongValueProfile profile = createEnabled(InlinedLongValueProfile.class); + long result0 = profile.profile(state, value0); + long result1 = profile.profile(state, value1); + long result2 = profile.profile(state, value2); + + assertThat(result0, is(value0)); + assertThat(result1, is(value1)); + assertThat(result2, is(value2)); + + if (value0 == value1 && value1 == value2) { + assertThat(getCachedValue(profile), is(value0)); + assertThat(isGeneric(profile), is(false)); + } else { + assertThat(isGeneric(profile), is(true)); + } + assertThat(isUninitialized(profile), is(false)); + profile.toString(); // test that it is not crashing + } + } } - assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing } @Test public void testDisabled() { LongValueProfile p = LongValueProfile.getUncached(); - assertThat(p.profile(VALUE0), is(VALUE0)); - assertThat(p.profile(VALUE1), is(VALUE1)); - assertThat(p.profile(VALUE2), is(VALUE2)); - assertThat(p.profile(VALUE3), is(VALUE3)); + for (long value : VALUES) { + assertThat(p.profile(value), is(value)); + } + p.toString(); // test that it is not crashing + } + + @Test + public void testDisabledInlined() { + InlinedLongValueProfile p = InlinedLongValueProfile.getUncached(); + for (long value : VALUES) { + assertThat(p.profile(state, value), is(value)); + } p.toString(); // test that it is not crashing } diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java index 6c47953b5d93..63f879b57a52 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java @@ -101,12 +101,12 @@ public Object findStaticClass(Object context, String classValue) { } @Override - public Object createToHostTypeNode() { + public Object inlineToHostTypeNode(Object inlineTarget) { throw new UnsupportedOperationException(); } @Override - public T toHostType(Object hostNode, Object hostContext, Object value, Class targetType, Type genericType) { + public T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType) { throw new UnsupportedOperationException(); } diff --git a/truffle/src/com.oracle.truffle.api/snapshot.sigtest b/truffle/src/com.oracle.truffle.api/snapshot.sigtest index 9b5801669d60..1e7263b5a5d5 100644 --- a/truffle/src/com.oracle.truffle.api/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api/snapshot.sigtest @@ -1058,11 +1058,8 @@ innr public abstract interface static !annotation Child innr public abstract interface static !annotation Children intf com.oracle.truffle.api.nodes.NodeInterface intf java.lang.Cloneable -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) -meth protected final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth protected final java.util.concurrent.locks.Lock getLock() meth protected final void notifyInserted(com.oracle.truffle.api.nodes.Node) -meth protected final void reportPolymorphicSpecialize() meth protected void onReplace(com.oracle.truffle.api.nodes.Node,java.lang.CharSequence) meth public boolean isAdoptable() meth public com.oracle.truffle.api.nodes.Node copy() @@ -1070,8 +1067,10 @@ meth public com.oracle.truffle.api.nodes.Node deepCopy() meth public com.oracle.truffle.api.nodes.NodeCost getCost() meth public com.oracle.truffle.api.source.SourceSection getEncapsulatingSourceSection() meth public com.oracle.truffle.api.source.SourceSection getSourceSection() +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} insert({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0}) meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0} replace({%%0},java.lang.CharSequence) +meth public final <%0 extends com.oracle.truffle.api.nodes.Node> {%%0}[] insert({%%0}[]) meth public final <%0 extends java.lang.Object> {%%0} atomic(java.util.concurrent.Callable<{%%0}>) meth public final boolean isSafelyReplaceableBy(com.oracle.truffle.api.nodes.Node) meth public final com.oracle.truffle.api.nodes.Node getParent() @@ -1080,6 +1079,7 @@ meth public final java.lang.Iterable getChild meth public final void accept(com.oracle.truffle.api.nodes.NodeVisitor) meth public final void adoptChildren() meth public final void atomic(java.lang.Runnable) +meth public final void reportPolymorphicSpecialize() meth public java.lang.String getDescription() meth public java.lang.String toString() meth public java.util.Map getDebugProperties() @@ -1362,10 +1362,8 @@ meth public abstract !hasdefault java.lang.String since() CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) -innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> -intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -1374,7 +1372,6 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() -meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -1483,6 +1480,3 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() -CLSS public abstract interface java.lang.constant.Constable -meth public abstract java.util.Optional describeConstable() - diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleStackTrace.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleStackTrace.java index 09276b853a58..2a4c7202ee74 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleStackTrace.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleStackTrace.java @@ -399,11 +399,11 @@ static void addStackFrameInfo(Node callNode, RootCallTarget root, Throwable t, F } boolean isTProfiled = CompilerDirectives.isPartialEvaluationConstant(t.getClass()); + MaterializedFrame frame = null; if (currentFrame != null && root.getRootNode().isCaptureFramesForTrace()) { - callInnerAddStackFrameInfo(isTProfiled, callNode, root, t, currentFrame.materialize()); - } else { - callInnerAddStackFrameInfo(isTProfiled, callNode, root, t, null); + frame = currentFrame.materialize(); } + callInnerAddStackFrameInfo(isTProfiled, callNode, root, t, frame); } private static void callInnerAddStackFrameInfo(boolean isTProfiled, Node callNode, RootCallTarget root, Throwable t, MaterializedFrame currentFrame) { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java index d7fcd5ddf83d..463153ad29d3 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java @@ -40,13 +40,12 @@ */ package com.oracle.truffle.api.impl; -import static org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostLanguageService; - import java.io.Closeable; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Constructor; import java.net.URI; import java.net.URL; @@ -82,6 +81,7 @@ import org.graalvm.polyglot.impl.AbstractPolyglotImpl; import org.graalvm.polyglot.impl.AbstractPolyglotImpl.LogHandler; import org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostAccess; +import org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostLanguageService; import org.graalvm.polyglot.io.FileSystem; import org.graalvm.polyglot.io.MessageTransport; import org.graalvm.polyglot.io.ProcessHandler; @@ -158,6 +158,8 @@ protected NodeSupport() { super(IMPL_CLASS_NAME); } + public abstract Lookup nodeLookup(); + public abstract boolean isInstrumentable(RootNode rootNode); public abstract boolean isCloneUninitializedSupported(RootNode rootNode); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index c9f64c8ccd07..f3f468fe0d01 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -124,9 +124,14 @@ public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame assert STATIC_TAG == FrameSlotKind.Static.tag; // Check if assertions are enabled + ASSERTIONS_ENABLED = areAsseritonsEnabled(); + } + + @SuppressWarnings("all") + private static boolean areAsseritonsEnabled() { boolean enabled = false; assert enabled = true; - ASSERTIONS_ENABLED = enabled; + return enabled; } private static Unsafe initUnsafe() { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java index dcd0b9a605eb..1c538d8b75c5 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @@ -46,6 +46,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -198,7 +200,7 @@ public boolean isAdoptable() { * @return the array of new children * @since 0.8 or earlier */ - protected final T[] insert(final T[] newChildren) { + public final T[] insert(final T[] newChildren) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChildren != null) { for (Node newChild : newChildren) { @@ -217,7 +219,7 @@ protected final T[] insert(final T[] newChildren) { * @return the new child * @since 0.8 or earlier */ - protected final T insert(final T newChild) { + public final T insert(final T newChild) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChild != null) { adoptHelper(newChild); @@ -552,7 +554,7 @@ private RootNode getRootNodeImpl() { * * @since 0.33 */ - protected final void reportPolymorphicSpecialize() { + public final void reportPolymorphicSpecialize() { CompilerAsserts.neverPartOfCompilation(); NodeAccessor.RUNTIME.reportPolymorphicSpecialize(this); } @@ -673,6 +675,10 @@ private boolean inAtomicBlock() { return ((ReentrantLock) getLock()).isHeldByCurrentThread(); } + static Lookup lookup() { + return MethodHandles.lookup(); + } + } @SuppressWarnings("unused") diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeAccessor.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeAccessor.java index 1fa63447b8b4..1e0fe4471b10 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeAccessor.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeAccessor.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.api.nodes; +import java.lang.invoke.MethodHandles.Lookup; import java.util.List; import java.util.Set; import java.util.concurrent.locks.Lock; @@ -70,6 +71,11 @@ private NodeAccessor() { static final class AccessNodes extends NodeSupport { + @Override + public Lookup nodeLookup() { + return Node.lookup(); + } + @Override public boolean isInstrumentable(RootNode rootNode) { return rootNode.isInstrumentable(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AbstractRegistrationProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AbstractRegistrationProcessor.java index 1b0082713a17..4a29294d11ae 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AbstractRegistrationProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AbstractRegistrationProcessor.java @@ -46,14 +46,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; -import java.util.Properties; import java.util.Set; -import java.util.TreeSet; import java.util.function.Predicate; import javax.annotation.processing.AbstractProcessor; @@ -99,9 +96,7 @@ public final SourceVersion getSupportedSourceVersion() { @SuppressWarnings({"deprecation", "unchecked"}) @Override public final boolean process(Set annotations, RoundEnvironment roundEnv) { - ProcessorContext.enter(processingEnv); - try { - ProcessorContext context = ProcessorContext.getInstance(); + try (ProcessorContext context = ProcessorContext.enter(processingEnv)) { String providerServiceBinName = processingEnv.getElementUtils().getBinaryName(context.getTypeElement(getProviderClass())).toString(); if (roundEnv.processingOver()) { generateServicesRegistration(providerServiceBinName, registrations); @@ -130,8 +125,6 @@ public final boolean process(Set annotations, RoundEnviro } } return true; - } finally { - ProcessorContext.leave(); } } @@ -143,33 +136,33 @@ public final boolean process(Set annotations, RoundEnviro abstract void implementMethod(TypeElement annotatedElement, CodeExecutableElement methodToImplement); - final void assertNoErrorExpected(Element e) { - ExpectError.assertNoErrorExpected(processingEnv, e); + static void assertNoErrorExpected(Element e) { + ExpectError.assertNoErrorExpected(e); } final void emitError(String msg, Element e) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, msg, e); } final void emitError(String msg, Element e, AnnotationMirror mirror, AnnotationValue value) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, msg, e, mirror, value); } final void emitWarning(String msg, Element e) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.WARNING, msg, e); } final void emitWarning(String msg, Element e, AnnotationMirror mirror, AnnotationValue value) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.WARNING, msg, e, mirror, value); @@ -208,7 +201,7 @@ private String generateProvider(TypeElement annotatedElement) { } DeclaredType overrideType = (DeclaredType) context.getType(Override.class); providerClass.accept(new GenerateOverrideVisitor(overrideType), null); - providerClass.accept(new FixWarningsVisitor(annotatedElement, overrideType), null); + providerClass.accept(new FixWarningsVisitor(overrideType), null); providerClass.accept(new CodeWriter(context.getEnvironment(), annotatedElement), null); return providerClass.getQualifiedName().toString(); } @@ -298,11 +291,4 @@ static boolean shouldGenerateProviderFiles(Element currentElement) { return CompilerFactory.getCompiler(currentElement) instanceof JDTCompiler; } - @SuppressWarnings("serial") - static class SortedProperties extends Properties { - @Override - public synchronized Enumeration keys() { - return Collections.enumeration(new TreeSet<>(super.keySet())); - } - } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AnnotationProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AnnotationProcessor.java index 871f086dc7f2..eb82ebc0b0b2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AnnotationProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/AnnotationProcessor.java @@ -95,56 +95,55 @@ public void registerService(String serviceBinaryName, String implBinaryName, Ele services.put(implBinaryName, sourceElement); } - public void process(Element element, boolean callback) { + public void process(Element element) { // since it is not guaranteed to be called only once by the compiler // we check for already processed elements to avoid errors when writing files. - if (!callback) { - String qualifiedName = ElementUtils.getQualifiedName((TypeElement) element); - if (processedElements.contains(qualifiedName)) { - return; - } - processedElements.add(qualifiedName); + String qualifiedName = ElementUtils.getQualifiedName((TypeElement) element); + if (processedElements.contains(qualifiedName)) { + return; } + processedElements.add(qualifiedName); - processImpl(element, callback); + processImpl(element); } - @SuppressWarnings({"unchecked"}) - private void processImpl(Element element, boolean callback) { + @SuppressWarnings({"unchecked", "try"}) + private void processImpl(Element element) { ProcessorContext context = ProcessorContext.getInstance(); TypeElement type = (TypeElement) element; + M model = context.parseIfAbsent(type, parser.getClass(), (e) -> { + try (Timer timer = Timer.create("Parse", e)) { + return parser.parse(e); + } + }); - M model = (M) context.getTemplate(type.asType(), false); - boolean firstRun = !context.containsTemplate(type); - - if (firstRun || !callback) { - context.registerTemplate(type, null); - model = parser.parse(element); - context.registerTemplate(type, model); - - if (model != null) { - List units; - try { + if (model != null) { + List units; + try { + try (Timer timer = Timer.create("Generate", element)) { units = factory.create(ProcessorContext.getInstance(), this, model); - } catch (Throwable e) { - RuntimeException ex = new RuntimeException(String.format("Failed to write code for %s.", ElementUtils.getQualifiedName(type))); - e.addSuppressed(ex); - throw e; - } - if (units == null || units.isEmpty()) { - return; } + } catch (Throwable e) { + RuntimeException ex = new RuntimeException(String.format("Failed to write code for %s.", ElementUtils.getQualifiedName(type))); + e.addSuppressed(ex); + throw e; + } + if (units == null || units.isEmpty()) { + return; + } + try (Timer timer = Timer.create("Fixup", element)) { for (CodeTypeElement unit : units) { unit.setGeneratorAnnotationMirror(model.getTemplateTypeAnnotation()); unit.setGeneratorElement(model.getTemplateType()); DeclaredType overrideType = (DeclaredType) context.getType(Override.class); unit.accept(new GenerateOverrideVisitor(overrideType), null); - unit.accept(new FixWarningsVisitor(model.getTemplateType(), overrideType), null); - - if (!callback) { - unit.accept(new CodeWriter(context.getEnvironment(), element), null); - } + unit.accept(new FixWarningsVisitor(overrideType), null); + } + } + try (Timer timer = Timer.create("CodeWriter", element)) { + for (CodeTypeElement unit : units) { + unit.accept(new CodeWriter(context.getEnvironment(), element), null); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java index 7df98a68d682..ef4a0b24e332 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ExpectError.java @@ -40,42 +40,36 @@ */ package com.oracle.truffle.dsl.processor; -import com.oracle.truffle.dsl.processor.java.ElementUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; -import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.AnnotationMirror; -import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; import javax.tools.Diagnostic.Kind; -public class ExpectError { +import com.oracle.truffle.dsl.processor.java.ElementUtils; - private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2}; +public final class ExpectError { - public static void assertNoErrorExpected(ProcessingEnvironment processingEnv, Element element) { - for (String errorType : EXPECT_ERROR_TYPES) { - assertNoErrorExpectedImpl(processingEnv, element, ElementUtils.getTypeElement(errorType)); + public static void assertNoErrorExpected(Element element) { + for (DeclaredType errorType : ProcessorContext.types().ExpectErrorTypes) { + assertNoErrorExpectedImpl(element, errorType); } } - private static void assertNoErrorExpectedImpl(ProcessingEnvironment processingEnv, Element element, TypeElement eee) { + private static void assertNoErrorExpectedImpl(Element element, DeclaredType eee) { if (eee != null) { - for (AnnotationMirror am : element.getAnnotationMirrors()) { - if (am.getAnnotationType().asElement().equals(eee)) { - processingEnv.getMessager().printMessage(Kind.ERROR, "Expected an error, but none found!", element); - } + AnnotationMirror am = ElementUtils.findAnnotationMirror(element, eee); + if (am != null) { + ProcessorContext.getInstance().getEnvironment().getMessager().printMessage(Kind.ERROR, "Expected an error, but none found!", element); } } } - public static boolean isExpectedError(ProcessingEnvironment processingEnv, Element element, String actualText) { - List expectedErrors = getExpectedErrors(processingEnv, element); + public static boolean isExpectedError(Element element, String actualText) { + List expectedErrors = getExpectedErrors(element); for (String expectedText : expectedErrors) { String newExpectedText = expectedText.replaceAll("%n", System.lineSeparator()); if (newExpectedText.endsWith("%") && actualText.startsWith(newExpectedText.substring(0, newExpectedText.length() - 1))) { @@ -87,35 +81,22 @@ public static boolean isExpectedError(ProcessingEnvironment processingEnv, Eleme return false; } - public static List getExpectedErrors(ProcessingEnvironment processingEnv, Element element) { - if (element == null) { + public static List getExpectedErrors(Element element) { + if (element == null || ProcessorContext.types().ExpectErrorTypes.isEmpty()) { return Collections.emptyList(); } List expectedErrors = new ArrayList<>(); - for (String errorType : EXPECT_ERROR_TYPES) { - collectExpectedErrors(expectedErrors, element, processingEnv.getElementUtils().getTypeElement(errorType)); + for (DeclaredType errorType : ProcessorContext.types().ExpectErrorTypes) { + collectExpectedErrors(expectedErrors, element, errorType); } return expectedErrors; } - private static void collectExpectedErrors(List expectedErrors, Element element, TypeElement eee) { - if (eee != null) { - for (AnnotationMirror am : element.getAnnotationMirrors()) { - if (am.getAnnotationType().asElement().equals(eee)) { - Map vals = am.getElementValues(); - if (vals.size() == 1) { - AnnotationValue av = vals.values().iterator().next(); - if (av.getValue() instanceof List) { - List arr = (List) av.getValue(); - for (Object o : arr) { - if (o instanceof AnnotationValue) { - AnnotationValue ov = (AnnotationValue) o; - expectedErrors.add((String) ov.getValue()); - } - } - } - } - } + private static void collectExpectedErrors(List expectedErrors, Element element, DeclaredType type) { + if (type != null) { + AnnotationMirror mirror = ElementUtils.findAnnotationMirror(element, type); + if (mirror != null) { + expectedErrors.addAll(ElementUtils.getAnnotationValueList(String.class, mirror, "value")); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java index 7834b9d85ba8..fafcebb8d6b7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/InstrumentableProcessor.java @@ -108,8 +108,7 @@ public boolean process(Set annotations, RoundEnvironment if (roundEnv.processingOver()) { return false; } - ProcessorContext context = ProcessorContext.enter(processingEnv); - try { + try (ProcessorContext context = ProcessorContext.enter(processingEnv)) { TruffleTypes types = context.getTypes(); DeclaredType instrumentableNode = types.InstrumentableNode; ExecutableElement createWrapper = ElementUtils.findExecutableElement(instrumentableNode, CREATE_WRAPPER_NAME); @@ -184,7 +183,7 @@ public boolean process(Set annotations, RoundEnvironment } DeclaredType overrideType = (DeclaredType) context.getType(Override.class); unit.accept(new GenerateOverrideVisitor(overrideType), null); - unit.accept(new FixWarningsVisitor(element, overrideType), null); + unit.accept(new FixWarningsVisitor(overrideType), null); unit.accept(new CodeWriter(context.getEnvironment(), element), null); } catch (Throwable e) { // never throw annotation processor exceptions to the compiler @@ -194,8 +193,6 @@ public boolean process(Set annotations, RoundEnvironment } return true; - } finally { - ProcessorContext.leave(); } } @@ -699,19 +696,19 @@ private static CodeVariableElement createNodeChild(ProcessorContext context, Typ return var; } - void assertNoErrorExpected(Element e) { - ExpectError.assertNoErrorExpected(processingEnv, e); + static void assertNoErrorExpected(Element e) { + ExpectError.assertNoErrorExpected(e); } void emitError(Element e, String msg) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, msg, e); } void emitError(Element e, AnnotationMirror annotation, String msg) { - if (ExpectError.isExpectedError(processingEnv, e, msg)) { + if (ExpectError.isExpectedError(e, msg)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, msg, e, annotation); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Log.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Log.java index f87504b135d0..c37baca5941c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Log.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Log.java @@ -65,10 +65,6 @@ public Log(ProcessingEnvironment env, boolean emitWarnings) { this.emitWarnings = emitWarnings; } - public void debug(String message, Object... args) { - message(Kind.ERROR, null, null, null, message, args); - } - public void message(Kind kind, Element element, AnnotationMirror mirror, AnnotationValue value, String format, Object... args) { AnnotationMirror usedMirror = mirror; Element usedElement = element; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java index d41d3eb17ddd..d3b4c03630a1 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/OptionProcessor.java @@ -104,8 +104,7 @@ public boolean process(Set annotations, RoundEnvironment if (roundEnv.processingOver()) { return true; } - ProcessorContext context = ProcessorContext.enter(processingEnv); - try { + try (ProcessorContext context = ProcessorContext.enter(processingEnv)) { TruffleTypes types = context.getTypes(); Map map = new HashMap<>(); for (Element element : roundEnv.getElementsAnnotatedWith(ElementUtils.castTypeElement(types.Option))) { @@ -148,7 +147,7 @@ public boolean process(Set annotations, RoundEnvironment while (listIterator.hasNext()) { OptionInfo info = listIterator.next(); if (info.valid) { - ExpectError.assertNoErrorExpected(processingEnv, info.field); + ExpectError.assertNoErrorExpected(info.field); } else { listIterator.remove(); } @@ -167,8 +166,6 @@ public int compare(OptionInfo o1, OptionInfo o2) { handleThrowable(t, info.type); } } - } finally { - ProcessorContext.leave(); } return true; @@ -331,7 +328,7 @@ private boolean processElement(Element element, AnnotationMirror elementAnnotati private static void error(Element element, AnnotationMirror annotation, String message, Object... args) { ProcessingEnvironment processingEnv = ProcessorContext.getInstance().getEnvironment(); String formattedMessage = String.format(message, args); - if (ExpectError.isExpectedError(processingEnv, element, formattedMessage)) { + if (ExpectError.isExpectedError(element, formattedMessage)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, formattedMessage, element, annotation); @@ -344,7 +341,7 @@ private static void generateOptionDescriptor(OptionsInfo info) { CodeTypeElement unit = generateDescriptors(context, element, info); DeclaredType overrideType = (DeclaredType) context.getType(Override.class); unit.accept(new GenerateOverrideVisitor(overrideType), null); - unit.accept(new FixWarningsVisitor(element, overrideType), null); + unit.accept(new FixWarningsVisitor(overrideType), null); try { unit.accept(new CodeWriter(context.getEnvironment(), element), null); } catch (RuntimeException e) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java index 08da04ad00e9..32fab0ead908 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java @@ -44,6 +44,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.TypeElement; @@ -56,57 +57,55 @@ import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; -import com.oracle.truffle.dsl.processor.model.Template; /** * THIS IS NOT PUBLIC API. */ -public class ProcessorContext { +public class ProcessorContext implements AutoCloseable { private final ProcessingEnvironment environment; - - private final Map models = new HashMap<>(); - - private final ProcessCallback callback; private final Log log; private TruffleTypes types; private final Map typeLookupCache = new HashMap<>(); + private final Map, Map> modelCache = new HashMap<>(); + + private Timer currentTimer; - public ProcessorContext(ProcessingEnvironment env, ProcessCallback callback) { + private final boolean timingsEnabled; + + public ProcessorContext(ProcessingEnvironment env) { this.environment = env; - this.callback = callback; - boolean emitWarnings = !Boolean.parseBoolean(System.getProperty("truffle.dsl.ignoreCompilerWarnings", "false")); + boolean emitWarnings = !Boolean.parseBoolean(System.getProperty("truffle.dsl.ignoreCompilerWarnings", "false")) || TruffleProcessorOptions.suppressAllWarnings(env); this.log = new Log(environment, emitWarnings); + this.timingsEnabled = TruffleProcessorOptions.printTimings(env); } - public TruffleTypes getTypes() { - return types; + Timer getCurrentTimer() { + return currentTimer; } - public Log getLog() { - return log; + void setCurrentTimer(Timer currentTimer) { + this.currentTimer = currentTimer; } - public ProcessingEnvironment getEnvironment() { - return environment; + public boolean timingsEnabled() { + return timingsEnabled; } - public boolean containsTemplate(TypeElement element) { - return models.containsKey(ElementUtils.getQualifiedName(element)); + public static TruffleTypes types() { + return getInstance().getTypes(); } - public void registerTemplate(TypeElement element, Template model) { - models.put(ElementUtils.getQualifiedName(element), model); + public TruffleTypes getTypes() { + return types; } - public Template getTemplate(TypeMirror templateTypeMirror, boolean invokeCallback) { - String qualifiedName = ElementUtils.getQualifiedName(templateTypeMirror); - Template model = models.get(qualifiedName); - if (model == null && invokeCallback) { - callback.callback(ElementUtils.fromTypeMirror(templateTypeMirror)); - model = models.get(qualifiedName); - } - return model; + public Log getLog() { + return log; + } + + public ProcessingEnvironment getEnvironment() { + return environment; } public DeclaredType getDeclaredType(Class element) { @@ -223,21 +222,11 @@ public TypeMirror reloadType(TypeMirror type) { private static final ThreadLocal instance = new ThreadLocal<>(); - public static ProcessorContext enter(ProcessingEnvironment environment, ProcessCallback callback) { - ProcessorContext context = new ProcessorContext(environment, callback); - setThreadLocalInstance(context); - return context; - } - public static ProcessorContext enter(ProcessingEnvironment environment) { - return enter(environment, null); - } - - public static void leave() { - instance.set(null); - } - - private static void setThreadLocalInstance(ProcessorContext context) { + ProcessorContext context = new ProcessorContext(environment); + if (instance.get() != null) { + throw new IllegalStateException("context already entered"); + } instance.set(context); if (context != null && context.types == null) { try { @@ -247,6 +236,23 @@ private static void setThreadLocalInstance(ProcessorContext context) { throw e; } } + return context; + } + + @Override + public void close() { + ProcessorContext context = instance.get(); + if (context != this) { + throw new IllegalStateException("context cannot be left if not entered"); + } + context.notifyLeave(); + instance.set(null); + } + + private void notifyLeave() { + if (currentTimer != null && timingsEnabled()) { + currentTimer.printSummary(System.out, " "); + } } public static ProcessorContext getInstance() { @@ -268,4 +274,20 @@ public Map getCacheMap(Class key) { } return (Map) cacheMap; } + + @SuppressWarnings("unchecked") + public T parseIfAbsent(TypeElement element, Class cacheKey, + Function parser) { + Map cache = modelCache.computeIfAbsent(cacheKey, (e) -> new HashMap<>()); + String typeId = ElementUtils.getUniqueIdentifier(element.asType()); + T result; + if (cache.containsKey(typeId)) { + result = (T) cache.get(typeId); + } else { + result = parser.apply(element); + cache.put(typeId, result); + } + return result; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Timer.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Timer.java new file mode 100644 index 000000000000..33fa3e9ab860 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/Timer.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor; + +import java.io.PrintStream; +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public final class Timer implements AutoCloseable { + + private static final Timer DISABLED = new Timer(null, null, null); + + private final String category; + private final Object key; + private final long startTime; + private long endTime; + private final Timer parent; + private List children; + + private Timer(Timer parent, String category, Object key) { + this.key = key; + this.category = category; + this.parent = parent; + this.startTime = key != null ? getTimeNS() : 0L; + } + + long elapsedNS() { + return endTime - startTime; + } + + @Override + public void close() { + if (key == null) { + return; + } + endTime = getTimeNS(); + if (parent != null) { + if (parent.children == null) { + parent.children = new ArrayList<>(); + } + parent.children.add(this); + ProcessorContext.getInstance().setCurrentTimer(parent); + } + } + + public void printSummary(PrintStream out, String indent) { + if (key == null) { + // disabled + return; + } + printTime(out, indent, category, 1, elapsedNS()); + printCategories(out, Arrays.asList(this), indent + " "); + } + + private static void printCategories(PrintStream out, List all, String indent) { + Map> categories = new HashMap<>(); + for (Timer current : all) { + if (current.children != null) { + for (Timer timer : current.children) { + categories.computeIfAbsent(timer.category, (e) -> new ArrayList<>()).add(timer); + } + } + } + for (var entry : categories.entrySet()) { + String key = entry.getKey(); + List group = entry.getValue(); + Set element = new HashSet<>(); + long elapsedNS = 0; + for (Timer timer : group) { + elapsedNS += timer.elapsedNS(); + element.add(timer.key); + } + printTime(out, indent, key, element.size(), elapsedNS); + printCategories(out, group, indent + " "); + } + + } + + private static void printTime(PrintStream out, String indent, String key, int count, long elapsedNS) { + out.printf(String.format("%s %-15s %10.2fms (count %s)%n", indent, key, elapsedNS / 1_000_000d, count)); + } + + public static Timer create(String category, Object key) { + ProcessorContext context = ProcessorContext.getInstance(); + if (!context.timingsEnabled()) { + return DISABLED; + } + Timer timer = new Timer(context.getCurrentTimer(), category, key); + context.setCurrentTimer(timer); + return timer; + } + + private static final java.lang.management.ThreadMXBean threadMXBean; + static { + java.lang.management.ThreadMXBean bean = null; + try { + bean = ManagementFactory.getThreadMXBean(); + } catch (NoClassDefFoundError e) { + } + threadMXBean = bean; + } + + private static long getTimeNS() { + return threadMXBean != null && threadMXBean.isThreadCpuTimeSupported() ? threadMXBean.getCurrentThreadCpuTime() : System.nanoTime(); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java index 4cd53fbd9241..8033e8339b5d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java @@ -53,13 +53,11 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; -import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.tools.Diagnostic.Kind; -import com.oracle.truffle.dsl.processor.ProcessorContext.ProcessCallback; import com.oracle.truffle.dsl.processor.generator.NodeCodeGenerator; import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.generator.TypeSystemCodeGenerator; @@ -75,7 +73,7 @@ /** * THIS IS NOT PUBLIC API. */ -public class TruffleProcessor extends AbstractProcessor implements ProcessCallback { +public final class TruffleProcessor extends AbstractProcessor { private final Map> serviceRegistrations = new LinkedHashMap<>(); @@ -84,10 +82,12 @@ public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } + @SuppressWarnings({"unchecked", "try"}) @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - try { - ProcessorContext.enter(processingEnv, this); + try (var context = ProcessorContext.enter(processingEnv); + Timer timer = Timer.create("TruffleProcessor Round", this)) { + if (roundEnv.processingOver()) { for (Entry> element : serviceRegistrations.entrySet()) { AbstractRegistrationProcessor.generateServicesRegistration(element.getKey(), element.getValue()); @@ -96,17 +96,16 @@ public boolean process(Set annotations, RoundEnvironment return true; } List> processors = createGenerators(); - currentProcessors.set(processors); for (AnnotationProcessor generator : processors) { AbstractParser parser = generator.getParser(); if (parser.getAnnotationType() != null) { for (Element e : roundEnv.getElementsAnnotatedWith(ElementUtils.castTypeElement(parser.getAnnotationType()))) { - processElement(generator, e, false); + processElement(generator, e); } DeclaredType repeat = parser.getRepeatAnnotationType(); if (repeat != null) { for (Element e : roundEnv.getElementsAnnotatedWith(ElementUtils.castTypeElement(repeat))) { - processElement(generator, e, false); + processElement(generator, e); } } } @@ -119,7 +118,7 @@ public boolean process(Set annotations, RoundEnvironment } else { processedType = ElementUtils.findParentEnclosingType(e); } - processElement(generator, processedType.orElseThrow(AssertionError::new), false); + processElement(generator, processedType.orElseThrow(AssertionError::new)); } } @@ -144,18 +143,13 @@ public boolean process(Set annotations, RoundEnvironment } } } - } finally { - ProcessorContext.leave(); - currentProcessors.set(null); } return false; } - private final ThreadLocal>> currentProcessors = new ThreadLocal<>(); - - private static void processElement(AnnotationProcessor generator, Element e, boolean callback) { + private static void processElement(AnnotationProcessor generator, Element e) { try { - generator.process(e, callback); + generator.process(e); } catch (Throwable e1) { handleThrowable(generator, e1, e); } @@ -171,19 +165,6 @@ public Set getSupportedOptions() { return TruffleProcessorOptions.getSupportedOptions(); } - @Override - public void callback(TypeElement template) { - for (AnnotationProcessor generator : currentProcessors.get()) { - DeclaredType annotationType = generator.getParser().getAnnotationType(); - if (annotationType != null) { - AnnotationMirror annotation = ElementUtils.findAnnotationMirror(template, annotationType); - if (annotation != null) { - processElement(generator, template, true); - } - } - } - } - @Override public Set getSupportedAnnotationTypes() { Set annotations = new HashSet<>(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java index 357ba4ce778c..a1ad60e003a9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java @@ -40,23 +40,37 @@ */ package com.oracle.truffle.dsl.processor; +import java.util.HashSet; +import java.util.Set; + import javax.annotation.processing.ProcessingEnvironment; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; -import java.util.HashSet; -import java.util.Set; - /** * Aggregates all options recognized by {@link TruffleProcessor}. + * + * Pass using javac: + * + *
+ * -Atruffle.dsl.SuppressAllWarnings=true
+ * 
+ * + * Pass to mx build: + * + *
+ * mx build -A-Atruffle.dsl.SuppressAllWarnings=true
+ * 
*/ public class TruffleProcessorOptions { private static final String OptionsPrefix = "truffle.dsl."; private static final String GenerateSpecializationStatisticsOptionName = "GenerateSpecializationStatistics"; private static final String GenerateSlowPathOnlyOptionName = "GenerateSlowPathOnly"; private static final String GenerateSlowPathOnlyFilterOptionName = "GenerateSlowPathOnlyFilter"; + private static final String SuppressAllWarnings = "SuppressAllWarnings"; private static final String CacheSharingWarningsEnabledOptionName = "cacheSharingWarningsEnabled"; private static final String StateBitWidth = "StateBitWidth"; + private static final String PrintTimings = "PrintTimings"; public static Boolean generateSpecializationStatistics(ProcessingEnvironment env) { String value = env.getOptions().get(OptionsPrefix + GenerateSpecializationStatisticsOptionName); @@ -67,12 +81,25 @@ public static boolean generateSlowPathOnly(ProcessingEnvironment env) { return Boolean.parseBoolean(env.getOptions().get(OptionsPrefix + GenerateSlowPathOnlyOptionName)); } + public static boolean printTimings(ProcessingEnvironment env) { + return Boolean.parseBoolean(env.getOptions().get(OptionsPrefix + PrintTimings)); + } + public static String generateSlowPathOnlyFilter(ProcessingEnvironment env) { return env.getOptions().get(OptionsPrefix + GenerateSlowPathOnlyFilterOptionName); } + public static boolean suppressAllWarnings(ProcessingEnvironment env) { + String v = env.getOptions().get(OptionsPrefix + SuppressAllWarnings); + return Boolean.parseBoolean(v); + } + public static boolean cacheSharingWarningsEnabled(ProcessingEnvironment env) { - return Boolean.parseBoolean(env.getOptions().get(OptionsPrefix + CacheSharingWarningsEnabledOptionName)); + String s = env.getOptions().get(OptionsPrefix + CacheSharingWarningsEnabledOptionName); + if (s == null) { + return !TruffleProcessorOptions.generateSlowPathOnly(env); + } + return Boolean.parseBoolean(s); } public static int stateBitWidth(ProcessingEnvironment env) { @@ -91,6 +118,8 @@ public static Set getSupportedOptions() { result.add(OptionsPrefix + GenerateSlowPathOnlyFilterOptionName); result.add(OptionsPrefix + CacheSharingWarningsEnabledOptionName); result.add(OptionsPrefix + StateBitWidth); + result.add(OptionsPrefix + SuppressAllWarnings); + result.add(OptionsPrefix + PrintTimings); return result; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java new file mode 100644 index 000000000000..692f9e8936e6 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; + +public final class TruffleSuppressedWarnings { + + private TruffleSuppressedWarnings() { + } + + public static final String ALL = "all"; + public static final String TRUFFLE = "truffle"; + public static final String STATIC_METHOD = "truffle-static-method"; + public static final String LIMIT = "truffle-limit"; + public static final String UNUSED = "truffle-unused"; + public static final String NEVERDEFAULT = "truffle-neverdefault"; + public static final String INLINING_RECOMMENDATION = "truffle-inlining"; + public static final String SHARING_RECOMMENDATION = "truffle-sharing"; + + public static Set getWarnings(Element element) { + AnnotationMirror currentWarnings = ElementUtils.findAnnotationMirror(element, SuppressWarnings.class); + Set warnings = null; + if (currentWarnings != null) { + List currentValues = ElementUtils.getAnnotationValueList(String.class, currentWarnings, "value"); + if (currentValues != null && !currentValues.isEmpty()) { + if (warnings == null) { + warnings = new LinkedHashSet<>(); + } + warnings.addAll(currentValues); + } + } + if (element.getKind() == ElementKind.PACKAGE) { + TruffleTypes types = ProcessorContext.getInstance().getTypes(); + AnnotationMirror packageWarnings = ElementUtils.findAnnotationMirror(element, + types.SuppressPackageWarnings); + if (packageWarnings != null) { + List currentValues = ElementUtils.getAnnotationValueList(String.class, packageWarnings, + "value"); + if (currentValues != null && !currentValues.isEmpty()) { + if (warnings == null) { + warnings = new LinkedHashSet<>(); + } + warnings.addAll(currentValues); + } + } + } + + return warnings == null ? Collections.emptySet() : warnings; + } + + public static boolean isSuppressed(Element element, String... warningKind) { + final TruffleTypes types = ProcessorContext.getInstance().getTypes(); + Element e = element; + do { + if (types.DisableWarningSuppression != null) { + AnnotationMirror disabled = ElementUtils.findAnnotationMirror(e, types.DisableWarningSuppression); + if (disabled != null) { + List elements = ElementUtils.getAnnotationValueList(String.class, disabled, "value"); + if (elements.isEmpty()) { + return false; + } else { + for (String warning : warningKind) { + if (elements.contains(warning)) { + return false; + } + } + } + } + } + + Set warnings = getWarnings(e); + if (warnings.contains(ALL) || warnings.contains(TRUFFLE) || // + warnings.stream().anyMatch((s) -> (Arrays.asList(warningKind).contains(s)))) { + return true; + } + e = e.getEnclosingElement(); + } while (e != null); + return false; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index ebb614cc2dab..498efb93417c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.dsl.processor; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.lang.model.type.DeclaredType; @@ -51,12 +53,25 @@ public class TruffleTypes { // Checkstyle: stop // Testing API + private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2}; public static final String ALWAYS_SLOW_PATH_MODE_NAME = "com.oracle.truffle.api.dsl.test.AlwaysGenerateOnlySlowPath"; + public static final String DISABLE_WARNING_SUPRESSION = "com.oracle.truffle.api.dsl.test.DisableWarningSuppression"; public static final String EXPECT_ERROR_CLASS_NAME1 = "com.oracle.truffle.api.dsl.test.ExpectError"; public static final String EXPECT_ERROR_CLASS_NAME2 = "com.oracle.truffle.api.test.ExpectError"; public static final List TEST_PACKAGES = List.of("com.oracle.truffle.api.test", "com.oracle.truffle.api.instrumentation.test"); + public static final String SlowPathListener_Name = "com.oracle.truffle.api.dsl.test.SlowPathListener"; + public final DeclaredType SlowPathListener = c.getDeclaredTypeOptional(SlowPathListener_Name); public final DeclaredType AlwaysSlowPath = c.getDeclaredTypeOptional(ALWAYS_SLOW_PATH_MODE_NAME); + public final DeclaredType DisableWarningSuppression = c.getDeclaredTypeOptional(DISABLE_WARNING_SUPRESSION); + public final List ExpectErrorTypes; + { + List types = new ArrayList<>(EXPECT_ERROR_TYPES.length); + for (String errorType : EXPECT_ERROR_TYPES) { + types.add(c.getDeclaredTypeOptional(errorType)); + } + ExpectErrorTypes = Collections.unmodifiableList(types); + } // Graal SDK public static final String OptionCategory_Name = "org.graalvm.options.OptionCategory"; @@ -82,6 +97,7 @@ public class TruffleTypes { public static final String CompilerDirectives_Name = "com.oracle.truffle.api.CompilerDirectives"; public static final String CompilerDirectives_TruffleBoundary_Name = "com.oracle.truffle.api.CompilerDirectives.TruffleBoundary"; public static final String DenyReplace_Name = "com.oracle.truffle.api.nodes.DenyReplace"; + public static final String DirectCallNode_Name = "com.oracle.truffle.api.nodes.DirectCallNode"; public static final String EncapsulatingNodeReference_Name = "com.oracle.truffle.api.nodes.EncapsulatingNodeReference"; public static final String ExplodeLoop_Name = "com.oracle.truffle.api.nodes.ExplodeLoop"; public static final String Frame_Name = "com.oracle.truffle.api.frame.Frame"; @@ -98,6 +114,7 @@ public class TruffleTypes { public static final String Option_Group_Name = "com.oracle.truffle.api.Option.Group"; public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; + public static final String InlinedProfile_Name = "com.oracle.truffle.api.profiles.InlinedProfile"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; public static final String SourceSection_Name = "com.oracle.truffle.api.source.SourceSection"; public static final String TruffleLanguage_ContextReference_Name = "com.oracle.truffle.api.TruffleLanguage.ContextReference"; @@ -116,6 +133,7 @@ public class TruffleTypes { public final DeclaredType CompilerDirectives_CompilationFinal = c.getDeclaredType(CompilerDirectives_CompilationFinal_Name); public final DeclaredType CompilerDirectives_TruffleBoundary = c.getDeclaredType(CompilerDirectives_TruffleBoundary_Name); public final DeclaredType DenyReplace = c.getDeclaredType(DenyReplace_Name); + public final DeclaredType DirectCallNode = c.getDeclaredType(DirectCallNode_Name); public final DeclaredType EncapsulatingNodeReference = c.getDeclaredType(EncapsulatingNodeReference_Name); public final DeclaredType ExplodeLoop = c.getDeclaredType(ExplodeLoop_Name); public final DeclaredType Frame = c.getDeclaredType(Frame_Name); @@ -130,6 +148,7 @@ public class TruffleTypes { public final DeclaredType NodeInterface = c.getDeclaredType(NodeInterface_Name); public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); + public final DeclaredType InlinedProfile = c.getDeclaredTypeOptional(InlinedProfile_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); public final DeclaredType SourceSection = c.getDeclaredType(SourceSection_Name); public final DeclaredType TruffleLanguage = c.getDeclaredType(TruffleLanguage_Name); @@ -148,12 +167,15 @@ public class TruffleTypes { public static final String Cached_Name = "com.oracle.truffle.api.dsl.Cached"; public static final String Cached_Shared_Name = "com.oracle.truffle.api.dsl.Cached.Shared"; public static final String CreateCast_Name = "com.oracle.truffle.api.dsl.CreateCast"; + public static final String DSLSupport_Name = "com.oracle.truffle.api.dsl.DSLSupport"; public static final String Executed_Name = "com.oracle.truffle.api.dsl.Executed"; public static final String ExecuteTracingSupport_Name = "com.oracle.truffle.api.dsl.ExecuteTracingSupport"; public static final String Fallback_Name = "com.oracle.truffle.api.dsl.Fallback"; public static final String GenerateAOT_Name = "com.oracle.truffle.api.dsl.GenerateAOT"; public static final String GenerateAOT_Exclude_Name = "com.oracle.truffle.api.dsl.GenerateAOT.Exclude"; public static final String GenerateAOT_Provider_Name = "com.oracle.truffle.api.dsl.GenerateAOT.Provider"; + public static final String GenerateCached_Name = "com.oracle.truffle.api.dsl.GenerateCached"; + public static final String GenerateInline_Name = "com.oracle.truffle.api.dsl.GenerateInline"; public static final String GeneratedBy_Name = "com.oracle.truffle.api.dsl.GeneratedBy"; public static final String GeneratePackagePrivate_Name = "com.oracle.truffle.api.dsl.GeneratePackagePrivate"; public static final String GenerateNodeFactory_Name = "com.oracle.truffle.api.dsl.GenerateNodeFactory"; @@ -163,8 +185,23 @@ public class TruffleTypes { public static final String Introspectable_Name = "com.oracle.truffle.api.dsl.Introspectable"; public static final String Introspection_Name = "com.oracle.truffle.api.dsl.Introspection"; public static final String Introspection_Provider_Name = "com.oracle.truffle.api.dsl.Introspection.Provider"; + public static final String InlineSupport_Name = "com.oracle.truffle.api.dsl.InlineSupport"; + public static final String InlineSupport_RequiredField_Name = "com.oracle.truffle.api.dsl.InlineSupport.RequiredField"; + public static final String InlineSupport_RequiredFields_Name = "com.oracle.truffle.api.dsl.InlineSupport.RequiredFields"; + public static final String InlineSupport_InlineTarget_Name = "com.oracle.truffle.api.dsl.InlineSupport.InlineTarget"; + public static final String InlineSupport_StateField_Name = "com.oracle.truffle.api.dsl.InlineSupport.StateField"; + public static final String InlineSupport_BooleanField_Name = "com.oracle.truffle.api.dsl.InlineSupport.BooleanField"; + public static final String InlineSupport_ByteField_Name = "com.oracle.truffle.api.dsl.InlineSupport.ByteField"; + public static final String InlineSupport_ShortField_Name = "com.oracle.truffle.api.dsl.InlineSupport.ShortField"; + public static final String InlineSupport_CharField_Name = "com.oracle.truffle.api.dsl.InlineSupport.CharField"; + public static final String InlineSupport_FloatField_Name = "com.oracle.truffle.api.dsl.InlineSupport.FloatField"; + public static final String InlineSupport_IntField_Name = "com.oracle.truffle.api.dsl.InlineSupport.IntField"; + public static final String InlineSupport_LongField_Name = "com.oracle.truffle.api.dsl.InlineSupport.LongField"; + public static final String InlineSupport_DoubleField_Name = "com.oracle.truffle.api.dsl.InlineSupport.DoubleField"; + public static final String InlineSupport_ReferenceField_Name = "com.oracle.truffle.api.dsl.InlineSupport.ReferenceField"; public static final String NodeChild_Name = "com.oracle.truffle.api.dsl.NodeChild"; public static final String NodeChildren_Name = "com.oracle.truffle.api.dsl.NodeChildren"; + public static final String NeverDefault_Name = "com.oracle.truffle.api.dsl.NeverDefault"; public static final String NodeFactory_Name = "com.oracle.truffle.api.dsl.NodeFactory"; public static final String NodeField_Name = "com.oracle.truffle.api.dsl.NodeField"; public static final String NodeFields_Name = "com.oracle.truffle.api.dsl.NodeFields"; @@ -175,6 +212,7 @@ public class TruffleTypes { public static final String SpecializationStatistics_Name = "com.oracle.truffle.api.dsl.SpecializationStatistics"; public static final String SpecializationStatistics_AlwaysEnabled_Name = "com.oracle.truffle.api.dsl.SpecializationStatistics.AlwaysEnabled"; public static final String SpecializationStatistics_NodeStatistics_Name = "com.oracle.truffle.api.dsl.SpecializationStatistics.NodeStatistics"; + public static final String SuppressPackageWarnings_Name = "com.oracle.truffle.api.dsl.SuppressPackageWarnings"; public static final String TypeCast_Name = "com.oracle.truffle.api.dsl.TypeCast"; public static final String TypeCheck_Name = "com.oracle.truffle.api.dsl.TypeCheck"; public static final String TypeSystem_Name = "com.oracle.truffle.api.dsl.TypeSystem"; @@ -186,12 +224,15 @@ public class TruffleTypes { public final DeclaredType Cached_Exclusive = c.getDeclaredType(Cached_Exclusive_Name); public final DeclaredType Cached_Shared = c.getDeclaredType(Cached_Shared_Name); public final DeclaredType CreateCast = c.getDeclaredType(CreateCast_Name); + public final DeclaredType DSLSupport = c.getDeclaredType(DSLSupport_Name); public final DeclaredType Executed = c.getDeclaredType(Executed_Name); public final DeclaredType ExecuteTracingSupport = c.getDeclaredType(ExecuteTracingSupport_Name); public final DeclaredType Fallback = c.getDeclaredType(Fallback_Name); public final DeclaredType GenerateAOT = c.getDeclaredType(GenerateAOT_Name); public final DeclaredType GenerateAOT_Exclude = c.getDeclaredType(GenerateAOT_Exclude_Name); public final DeclaredType GenerateAOT_Provider = c.getDeclaredType(GenerateAOT_Provider_Name); + public final DeclaredType GenerateCached = c.getDeclaredType(GenerateCached_Name); + public final DeclaredType GenerateInline = c.getDeclaredType(GenerateInline_Name); public final DeclaredType GeneratedBy = c.getDeclaredType(GeneratedBy_Name); public final DeclaredType GeneratePackagePrivate = c.getDeclaredType(GeneratePackagePrivate_Name); public final DeclaredType GenerateNodeFactory = c.getDeclaredType(GenerateNodeFactory_Name); @@ -201,8 +242,23 @@ public class TruffleTypes { public final DeclaredType Introspectable = c.getDeclaredType(Introspectable_Name); public final DeclaredType Introspection = c.getDeclaredType(Introspection_Name); public final DeclaredType Introspection_Provider = c.getDeclaredType(Introspection_Provider_Name); + public final DeclaredType InlineSupport = c.getDeclaredType(InlineSupport_Name); + public final DeclaredType InlineSupport_RequiredField = c.getDeclaredType(InlineSupport_RequiredField_Name); + public final DeclaredType InlineSupport_RequiredFields = c.getDeclaredType(InlineSupport_RequiredFields_Name); + public final DeclaredType InlineSupport_InlineTarget = c.getDeclaredType(InlineSupport_InlineTarget_Name); + public final DeclaredType InlineSupport_StateField = c.getDeclaredType(InlineSupport_StateField_Name); + public final DeclaredType InlineSupport_ReferenceField = c.getDeclaredType(InlineSupport_ReferenceField_Name); + public final DeclaredType InlineSupport_BooleanField = c.getDeclaredType(InlineSupport_BooleanField_Name); + public final DeclaredType InlineSupport_ByteField = c.getDeclaredType(InlineSupport_ByteField_Name); + public final DeclaredType InlineSupport_ShortField = c.getDeclaredType(InlineSupport_ShortField_Name); + public final DeclaredType InlineSupport_CharField = c.getDeclaredType(InlineSupport_CharField_Name); + public final DeclaredType InlineSupport_FloatField = c.getDeclaredType(InlineSupport_FloatField_Name); + public final DeclaredType InlineSupport_IntField = c.getDeclaredType(InlineSupport_IntField_Name); + public final DeclaredType InlineSupport_LongField = c.getDeclaredType(InlineSupport_LongField_Name); + public final DeclaredType InlineSupport_DoubleField = c.getDeclaredType(InlineSupport_DoubleField_Name); public final DeclaredType NodeChild = c.getDeclaredType(NodeChild_Name); public final DeclaredType NodeChildren = c.getDeclaredType(NodeChildren_Name); + public final DeclaredType NeverDefault = c.getDeclaredType(NeverDefault_Name); public final DeclaredType NodeFactory = c.getDeclaredType(NodeFactory_Name); public final DeclaredType NodeField = c.getDeclaredType(NodeField_Name); public final DeclaredType NodeFields = c.getDeclaredType(NodeFields_Name); @@ -213,6 +269,7 @@ public class TruffleTypes { public final DeclaredType SpecializationStatistics = c.getDeclaredType(SpecializationStatistics_Name); public final DeclaredType SpecializationStatistics_NodeStatistics = c.getDeclaredType(SpecializationStatistics_NodeStatistics_Name); public final DeclaredType SpecializationStatistics_AlwaysEnabled = c.getDeclaredType(SpecializationStatistics_AlwaysEnabled_Name); + public final DeclaredType SuppressPackageWarnings = c.getDeclaredType(SuppressPackageWarnings_Name); public final DeclaredType TypeCast = c.getDeclaredType(TypeCast_Name); public final DeclaredType TypeCheck = c.getDeclaredType(TypeCheck_Name); public final DeclaredType TypeSystem = c.getDeclaredType(TypeSystem_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java index c7782a883b67..fc364f87f88f 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java @@ -48,6 +48,8 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; @@ -68,9 +70,12 @@ import org.antlr.v4.runtime.TokenStream; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleSuppressedWarnings; import com.oracle.truffle.dsl.processor.generator.DSLExpressionGenerator; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeTree; +import com.oracle.truffle.dsl.processor.model.MessageContainer; +import com.oracle.truffle.dsl.processor.parser.NodeParser; public abstract class DSLExpression { @@ -156,7 +161,7 @@ public void visitVariable(Variable var) { if (resolvedVar != null && !resolvedVar.getModifiers().contains(Modifier.STATIC) && (resolvedVar.getEnclosingElement() == null || resolvedVar.getEnclosingElement().getKind() != ElementKind.METHOD)) { String name = resolvedVar.getSimpleName().toString(); - if (!name.equals("null") && !name.equals("this")) { + if (!name.equals("null") && !name.equals("this") && !name.equals(NodeParser.NODE_KEYWORD)) { bindsReceiver.set(true); } } @@ -177,7 +182,47 @@ public void visitCall(Call binary) { return bindsReceiver.get(); } - public static DSLExpression parse(String input) { + public static DSLExpression resolve(DSLExpressionResolver resolver, MessageContainer container, String annotationValueName, DSLExpression expression, String originalString) { + try { + expression.accept(resolver); + List deprecatedElements = expression.findBoundDeprecatedElements(); + if (!deprecatedElements.isEmpty() && !TruffleSuppressedWarnings.isSuppressed(container.getMessageElement(), "deprecated")) { + AnnotationMirror mirror = container.getMessageAnnotation(); + AnnotationValue value = null; + if (mirror != null && annotationValueName != null) { + value = ElementUtils.getAnnotationValue(mirror, annotationValueName); + } + StringBuilder b = new StringBuilder(); + b.append(String.format("The expression '%s' binds the following deprecated elements and should be updated:", originalString)); + for (Element deprecatedElement : deprecatedElements) { + String relativeName = ElementUtils.getReadableReference(container.getMessageElement(), deprecatedElement); + b.append(String.format("%n - ")); + b.append(relativeName); + } + b.append(String.format("%nUpdate the usage of the elements or suppress the warning with @SuppressWarnings(\"deprecated\").")); + container.addWarning(value, b.toString()); + } + return expression; + } catch (InvalidExpressionException e) { + AnnotationMirror mirror = container.getMessageAnnotation(); + AnnotationValue value = null; + if (mirror != null && annotationValueName != null) { + value = ElementUtils.getAnnotationValue(mirror, annotationValueName); + } + container.addError(value, "Error parsing expression '%s': %s", originalString, e.getMessage()); + } + return null; + } + + public static DSLExpression parseAndResolve(DSLExpressionResolver resolver, MessageContainer container, String annotationValueName, String string) { + DSLExpression expression = DSLExpression.parse(container, annotationValueName, string); + if (expression == null) { + return null; + } + return resolve(resolver, container, annotationValueName, expression, string); + } + + public static DSLExpression parse(MessageContainer container, String annotationValueName, String input) { ExpressionLexer lexer = new ExpressionLexer(CharStreams.fromString(input)); TokenStream tokens = new CommonTokenStream(lexer); ExpressionParser parser = new ExpressionParser(tokens); @@ -188,8 +233,14 @@ public static DSLExpression parse(String input) { parser.addErrorListener(DSLErrorListener.INSTANCE); try { return parser.expression().result; - } catch (RecognitionException e) { - throw new InvalidExpressionException(e.getMessage()); + } catch (InvalidExpressionException | RecognitionException e) { + AnnotationMirror mirror = container.getMessageAnnotation(); + AnnotationValue value = null; + if (mirror != null && annotationValueName != null) { + value = ElementUtils.getAnnotationValue(mirror, annotationValueName); + } + container.addError(value, "Error parsing expression '%s': %s", input, e.getMessage()); + return null; } } @@ -238,10 +289,50 @@ public void visitVariable(Variable variable) { return variables; } + private List findBoundDeprecatedElements() { + final List deprecatedElements = new ArrayList<>(); + accept(new AbstractDSLExpressionVisitor() { + @Override + public void visitCall(Call n) { + visitElement(n.getResolvedMethod()); + } + + @Override + public void visitVariable(Variable n) { + visitElement(n.getResolvedVariable()); + } + + @Override + public void visitClassLiteral(ClassLiteral n) { + visitElement(ElementUtils.castTypeElement(n.getLiteral())); + } + + @Override + public void visitCast(Cast n) { + visitElement(ElementUtils.castTypeElement(n.getCastType())); + } + + private void visitElement(Element element) { + if (element != null && ElementUtils.isDeprecated(element)) { + deprecatedElements.add(element); + } + } + }); + return deprecatedElements; + } + public Object resolveConstant() { return null; } + public ExecutableElement resolveExecutable() { + return null; + } + + public VariableElement resolveVariable() { + return null; + } + public void setResolvedTargetType(TypeMirror resolvedTargetType) { this.resolvedTargetType = resolvedTargetType; } @@ -298,6 +389,16 @@ public DSLExpression getReceiver() { return receiver; } + @Override + public ExecutableElement resolveExecutable() { + return receiver.resolveExecutable(); + } + + @Override + public VariableElement resolveVariable() { + return receiver.resolveVariable(); + } + @Override public Object resolveConstant() { Object constant = receiver.resolveConstant(); @@ -332,6 +433,7 @@ public static final class Cast extends DSLExpression { private final TypeMirror castType; public Cast(DSLExpression receiver, TypeMirror castType) { + Objects.requireNonNull(receiver); this.receiver = receiver; this.castType = castType; } @@ -353,6 +455,16 @@ public DSLExpression reduce(DSLExpressionReducer visitor) { return negate; } + @Override + public ExecutableElement resolveExecutable() { + return receiver.resolveExecutable(); + } + + @Override + public VariableElement resolveVariable() { + return receiver.resolveVariable(); + } + public TypeMirror getCastType() { return castType; } @@ -531,6 +643,14 @@ public boolean equals(Object obj) { return false; } + public List getResolvedParameterTypes() { + List types = new ArrayList<>(parameters.size()); + for (DSLExpression parameter : parameters) { + types.add(parameter.getResolvedType()); + } + return types; + } + @Override public int hashCode() { return Objects.hash(receiver, name, parameters); @@ -587,6 +707,14 @@ public DSLExpression reduce(DSLExpressionReducer reducer) { return reducer.visitCall(c); } + @Override + public ExecutableElement resolveExecutable() { + if (resolvedMethod != null) { + return resolvedMethod; + } + return null; + } + @Override public TypeMirror getResolvedType() { if (resolvedMethod == null) { @@ -692,6 +820,23 @@ public DSLExpression reduce(DSLExpressionReducer reducer) { return reducer.visitVariable(c); } + @Override + public Object resolveConstant() { + /* + * Unfortunately calling resolvedVariable.getConstantValue() here leads to bad + * compilation problems later, at least in the ECJ compiler. + */ + return super.resolveConstant(); + } + + @Override + public VariableElement resolveVariable() { + if (resolvedVariable != null) { + return resolvedVariable; + } + return null; + } + @Override public TypeMirror getResolvedType() { return resolvedVariable != null ? resolvedVariable.asType() : null; @@ -860,33 +1005,35 @@ public String toString() { } public abstract static class AbstractDSLExpressionVisitor implements DSLExpressionVisitor { + @Override - public void visitBinary(Binary binary) { + public void visitBinary(Binary n) { } @Override - public void visitCall(Call binary) { + public void visitCall(Call n) { } @Override - public void visitIntLiteral(IntLiteral binary) { + public void visitIntLiteral(IntLiteral n) { } - public void visitClassLiteral(ClassLiteral classLiteral) { + public void visitClassLiteral(ClassLiteral n) { } @Override - public void visitNegate(Negate negate) { + public void visitNegate(Negate n) { } @Override - public void visitVariable(Variable binary) { + public void visitVariable(Variable n) { } - public void visitBooleanLiteral(BooleanLiteral binary) { + public void visitBooleanLiteral(BooleanLiteral n) { } - public void visitCast(Cast binary) { + public void visitCast(Cast n) { + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index e304e1214246..4f67473c2c19 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -184,20 +184,20 @@ public void visitNegate(Negate negate) { } } - private ExecutableElement resolveCall(Call call) { + public ExecutableElement lookupMethod(String searchName, List searchParameters) { lazyProcess(); - List methodsWithName = this.methods.get(call.getName()); + List methodsWithName = this.methods.get(searchName); ExecutableElement foundWithName = null; if (methodsWithName != null) { for (ExecutableElement method : methodsWithName) { - if (matchExecutable(call, method) && ElementUtils.isVisible(accessType, method)) { + if (matchExecutable(searchName, searchParameters, method) && ElementUtils.isVisible(accessType, method)) { return method; } foundWithName = method; } } if (parent != null) { - ExecutableElement parentResult = parent.resolveCall(call); + ExecutableElement parentResult = parent.lookupMethod(searchName, searchParameters); if (parentResult != null) { return parentResult; } @@ -205,22 +205,34 @@ private ExecutableElement resolveCall(Call call) { return foundWithName; } - private static boolean matchExecutable(Call call, ExecutableElement method) { - if (!getMethodName(method).equals(call.getName())) { + private ExecutableElement resolveCall(Call call) { + lazyProcess(); + + ExecutableElement foundMethod = lookupMethod(call.getName(), call.getResolvedParameterTypes()); + if (foundMethod != null) { + List expressions = call.getParameters(); + // refine resolved parameter types + for (int i = 0; i < expressions.size() && i < foundMethod.getParameters().size(); i++) { + expressions.get(i).setResolvedTargetType(foundMethod.getParameters().get(i).asType()); + } + } + return foundMethod; + } + + public static boolean matchExecutable(String name, List searchParameters, ExecutableElement method) { + if (!getMethodName(method).equals(name)) { return false; } List parameters = method.getParameters(); - if (parameters.size() != call.getParameters().size()) { + if (parameters.size() != searchParameters.size()) { return false; } int parameterIndex = 0; - for (DSLExpression expression : call.getParameters()) { - TypeMirror sourceType = expression.getResolvedType(); + for (TypeMirror sourceType : searchParameters) { TypeMirror targetType = parameters.get(parameterIndex).asType(); if (!ElementUtils.isAssignable(sourceType, targetType)) { return false; } - expression.setResolvedTargetType(targetType); parameterIndex++; } return true; @@ -284,7 +296,7 @@ public void visitCall(Call call) { throw new InvalidExpressionException(message); } else if (!ElementUtils.isVisible(accessType, resolvedMethod)) { throw new InvalidExpressionException(String.format("The method %s is not visible.", ElementUtils.getReadableSignature(resolvedMethod))); - } else if (!matchExecutable(call, resolvedMethod)) { + } else if (!matchExecutable(call.getName(), call.getResolvedParameterTypes(), resolvedMethod)) { StringBuilder arguments = new StringBuilder(); String sep = ""; for (DSLExpression expression : call.getParameters()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/InvalidExpressionException.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/InvalidExpressionException.java index a61b3ce69650..d6a0d767aef0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/InvalidExpressionException.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/InvalidExpressionException.java @@ -40,11 +40,11 @@ */ package com.oracle.truffle.dsl.processor.expression; -public class InvalidExpressionException extends RuntimeException { +public final class InvalidExpressionException extends RuntimeException { private static final long serialVersionUID = 1L; - public InvalidExpressionException(String message) { + InvalidExpressionException(String message) { super(message); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index 8d5471892231..af8d6ea7ff3b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -40,13 +40,7 @@ */ package com.oracle.truffle.dsl.processor.generator; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.createReferenceName; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; - -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.lang.model.type.TypeMirror; @@ -55,65 +49,51 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.LocalVariable; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -import com.oracle.truffle.dsl.processor.model.SpecializationData; -import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; - -class BitSet { - private static final Object[] EMPTY_OBJECTS = new Object[0]; +final class BitSet { - private final int capacity; + private final BitStateList states; private final String name; - private final Map offsets = new HashMap<>(); - private final Object[] objects; private final long allMask; private final TypeMirror type; - BitSet(String name, Object[] objects) { + BitSet(String name, BitStateList states) { this.name = name; - this.objects = objects; - this.capacity = intializeCapacity(); - if (capacity <= 32) { + this.states = states; + int bitCount = states.getBitCount(); + if (bitCount <= 32) { type = ProcessorContext.getInstance().getType(int.class); - } else if (capacity <= 64) { + } else if (bitCount <= 64) { type = ProcessorContext.getInstance().getType(long.class); } else { - throw new UnsupportedOperationException("State space too big " + capacity + ". Only <= 64 supported."); - } - this.allMask = createMask(objects); - } - - private int intializeCapacity() { - if (objects.length == 0) { - return 0; - } - int bitIndex = 0; - for (Object o : objects) { - int size = calculateRequiredBits(o); - offsets.put(o, bitIndex); - bitIndex += size; + throw new UnsupportedOperationException("State space too big " + bitCount + ". Only <= 64 supported."); } - return bitIndex; + this.allMask = createMask(StateQuery.create(null, getStates().queryKeys(null))); } - public Object[] getObjects() { - return objects; + public BitStateList getStates() { + return states; } - protected int calculateRequiredBits(@SuppressWarnings("unused") Object object) { - return 1; - } - - public int getCapacity() { - return capacity; + public int getBitCount() { + return states.getBitCount(); } public TypeMirror getType() { return type; } - public final boolean contains(Object element) { - return offsets.containsKey(element); + public boolean contains(StateQuery element) { + return getStates().contains(element); + } + + public boolean contains(StateQuery... element) { + for (StateQuery stateQuery : element) { + if (getStates().contains(stateQuery)) { + return true; + } + } + return false; } private CodeTree createLocalReference(FrameState frameState) { @@ -125,10 +105,16 @@ private CodeTree createLocalReference(FrameState frameState) { } } + public boolean hasLocal(FrameState frameState) { + return frameState.get(getName()) != null; + } + public CodeTree createReference(FrameState frameState) { CodeTree ref = createLocalReference(frameState); if (ref == null) { - ref = CodeTreeBuilder.createBuilder().string("this.", getName(), "_").build(); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.string(getName(), "_"); + ref = FlatNodeGenFactory.createInlinedAccess(frameState, null, builder.build(), null); } return ref; } @@ -136,95 +122,93 @@ public CodeTree createReference(FrameState frameState) { /** * Filters passed elements to return only elements contained in this set. */ - public final Object[] filter(Object[] elements) { - if (elements == null || elements.length == 0) { - return elements; - } - List includedElements = null; - for (int i = 0; i < elements.length; i++) { - if (contains(elements[i])) { - if (includedElements == null) { - includedElements = new ArrayList<>(); - } - includedElements.add(elements[i]); - } - } - if (includedElements == null || includedElements.isEmpty()) { - return EMPTY_OBJECTS; - } else if (includedElements.size() == elements.length) { - return elements; - } else { - return includedElements.toArray(); - } + public StateQuery filter(StateQuery elements) { + return getStates().filter(elements); } public CodeTree createLoad(FrameState frameState) { - if (frameState.get(name) != null) { + return createLoad(frameState, false); + } + + public CodeTree createLoad(FrameState frameState, boolean forceLoad) { + LocalVariable var = frameState.get(name); + if (!forceLoad && var != null) { // already loaded return CodeTreeBuilder.singleString(""); } - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + String fieldName = name + "_"; - LocalVariable var = new LocalVariable(type, name, null); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); CodeTreeBuilder init = builder.create(); init.string("this.").tree(CodeTreeBuilder.singleString(fieldName)); - builder.tree(var.createDeclaration(init.build())); - frameState.set(name, var); - return builder.build(); - } - public CodeTree createContainsOnly(FrameState frameState, int offset, int length, Object[] selectedElements, Object[] allElements) { - long mask = ~createMask(offset, length, selectedElements) & createMask(allElements); - if (mask == 0) { - return null; + CodeTree inlinedAccess = FlatNodeGenFactory.createInlinedAccess(frameState, null, init.build(), null); + + if (var == null) { + var = new LocalVariable(type, name, null); + frameState.set(name, var); + builder.tree(var.createDeclaration(inlinedAccess)); + } else { + builder.startStatement(); + builder.string(name).string(" = ").tree(inlinedAccess); + builder.end(); } - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.tree(createMaskedReference(frameState, mask)); - builder.string(" == 0"); - builder.string(" /* only-active ", toString(selectedElements, " && "), " */"); + return builder.build(); } - public CodeTree createContainsAny(FrameState frameState, Object[] selectedElements, Object[] allElements) { - long mask = createMask(allElements); + public void clearLoaded(FrameState frameState) { + frameState.clear(name); + } + + public CodeTree createContainsOnly(FrameState frameState, int offset, int length, StateQuery selectedElements, StateQuery allElements) { + long mask = ~createMask(offset, length, selectedElements) & createMask(allElements); if (mask == 0) { return null; } CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.tree(createMaskedReference(frameState, mask)); - builder.string(" != 0"); - builder.string(" /* contains-any ", toString(selectedElements, " && "), " */"); + builder.string(" == 0"); + builder.string(" /* only-active ", getStates().toString(selectedElements, " && "), " */"); return builder.build(); } - public CodeTree createIs(FrameState frameState, Object[] selectedElements, Object[] maskedElements) { + public CodeTree createIs(FrameState frameState, StateQuery selectedElements, StateQuery maskedElements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.tree(createMaskedReference(frameState, maskedElements)); builder.string(" == ").string(formatMask(createMask(selectedElements))); return builder.build(); } - private CodeTree createMaskedReference(FrameState frameState, long maskedElements) { + private CodeTree createMaskedReference(CodeTree receiver, long maskedElements) { if (maskedElements == this.allMask) { // no masking needed - return createReference(frameState); + return receiver; } else { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); // masking needed we use the state bitset for guards as well - builder.string("(").tree(createReference(frameState)).string(" & ").string(formatMask(maskedElements)).string(")"); + builder.string("(").tree(receiver).string(" & ").string(formatMask(maskedElements)).string(")"); return builder.build(); } } - public CodeTree createMaskedReference(FrameState frameState, Object[] maskedElements) { + private CodeTree createMaskedReference(FrameState frameState, long maskedElements) { + return createMaskedReference(createReference(frameState), maskedElements); + } + + public CodeTree createMaskedReference(CodeTree receiver, StateQuery... maskedElements) { + return createMaskedReference(receiver, createMask(maskedElements)); + } + + public CodeTree createMaskedReference(FrameState frameState, StateQuery... maskedElements) { return createMaskedReference(frameState, createMask(maskedElements)); } - public CodeTree createIsNotAny(FrameState frameState, Object[] elements) { + public CodeTree createIsNotAny(FrameState frameState, StateQuery elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.tree(createMaskedReference(frameState, elements)); builder.string(" != 0 "); - builder.string(" /* is-not ", toString(elements, " && "), " */"); + builder.string(" /* is-not ", getStates().toString(elements, " && "), " */"); return builder.build(); } @@ -236,7 +220,7 @@ public String formatMask(long mask) { if (bitsUsed <= 16) { return "0b" + Integer.toBinaryString((int) mask); } else { - if (capacity <= 32) { + if (getBitCount() <= 32) { return "0x" + Integer.toHexString((int) mask); } else { return "0x" + Long.toHexString(mask) + "L"; @@ -244,7 +228,7 @@ public String formatMask(long mask) { } } - public CodeTree createIsOneBitOf(FrameState frameState, Object[] elements) { + public CodeTree createIsOneBitOf(FrameState frameState, StateQuery elements) { CodeTree masked = createMaskedReference(frameState, elements); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); @@ -252,166 +236,177 @@ public CodeTree createIsOneBitOf(FrameState frameState, Object[] elements) { // (state & (state - 1L)) == 0L builder.startParantheses().tree(masked).string(" & ").startParantheses().tree(masked).string(" - 1").end().end().string(" == 0"); - builder.string(" /* ", label("is-single"), " */"); + builder.string(" /* ", "is-single ", " */"); return builder.build(); } - public CodeTree createContains(FrameState frameState, Object... elements) { + public CodeTree createContains(FrameState frameState, StateQuery query) { + return createContains(createReference(frameState), query); + } + + public CodeTree createContains(CodeTree receiver, StateQuery query) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.tree(createMaskedReference(frameState, elements)); + builder.tree(createMaskedReference(receiver, query)); builder.string(" != 0"); - builder.string(" /* ", label("is"), toString(elements, " || "), " */"); + builder.string(" /* ", "is ", getStates().toString(query, " || "), " */"); return builder.build(); } - private static String toString(Object[] elements, String elementSep) { - StringBuilder b = new StringBuilder(); - String sep = ""; - for (int i = 0; i < elements.length; i++) { - b.append(sep).append(toString(elements[i])); - sep = elementSep; - } - return b.toString(); - } - - private static String toString(Object element) { - if (element instanceof SpecializationData) { - SpecializationData specialization = (SpecializationData) element; - return createReferenceName(specialization.getMethod()); - } else if (element instanceof TypeGuard) { - int index = ((TypeGuard) element).getSignatureIndex(); - String simpleName = getSimpleName(((TypeGuard) element).getType()); - return index + ":" + simpleName; - } - return element.toString(); - } - - public CodeTree createNotContains(FrameState frameState, Object... elements) { + public CodeTree createNotContains(CodeTree receiver, StateQuery elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startParantheses(); - builder.tree(createMaskedReference(frameState, elements)); + builder.tree(createMaskedReference(receiver, elements)); builder.end(); builder.string(" == 0"); - builder.string(" /* ", label("is-not"), toString(elements, " && "), " */"); + builder.string(" /* ", "is-not ", getStates().toString(elements, " && "), " */"); return builder.build(); } - private String label(String message) { - return message + "-" + getName() + " "; + public CodeTree createNotContains(FrameState frameState, StateQuery elements) { + return createNotContains(createReference(frameState), elements); } public String getName() { return name; } - public CodeTree createExtractInteger(FrameState frameState, Object element) { + public CodeTree createExtractInteger(CodeTree receiver, StateQuery query) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - if (capacity > 32) { + if (getBitCount() > 32) { builder.string("(int)("); } - - builder.tree(createMaskedReference(frameState, createMask(element))); - builder.string(" >>> ", Integer.toString(getStateOffset(element))); - if (capacity > 32) { + builder.tree(createMaskedReference(receiver, createMask(query))); + builder.string(" >>> ", Integer.toString(getStateOffset(query))); + if (getBitCount() > 32) { builder.string(")"); } - builder.string(" /* ", label("extract-implicit"), toString(element), " */"); + builder.string(" /* ", "get-int" + " ", getStates().toString(query, ""), " */"); return builder.build(); } + public CodeTree createExtractInteger(FrameState frameState, StateQuery query) { + return createExtractInteger(createReference(frameState), query); + } + public CodeTree createSetZero(FrameState frameState, boolean persist) { return createSet(frameState, persist, CodeTreeBuilder.singleString("0"), false); } - public CodeTree createSet(FrameState frameState, Object[] elements, boolean value, boolean persist) { + public CodeTree createSetExpression(CodeTree receiver, StateQuery elements, Boolean value) { CodeTreeBuilder valueBuilder = CodeTreeBuilder.createBuilder(); - boolean hasLocal = createLocalReference(frameState) != null; - - if (!hasLocal && elements.length == 0) { - return valueBuilder.build(); - } - valueBuilder.tree(createReference(frameState)); - if (elements.length > 0) { + valueBuilder.tree(receiver); + if (elements != null) { if (value) { valueBuilder.string(" | "); valueBuilder.string(formatMask(createMask(elements))); - valueBuilder.string(" /* ", label("add"), toString(elements, ", "), " */"); + valueBuilder.string(" /* ", "add" + " ", getStates().toString(elements, ", "), " */"); } else { valueBuilder.string(" & "); valueBuilder.string(formatMask(~createMask(elements))); - valueBuilder.string(" /* ", label("remove"), toString(elements, ", "), " */"); + valueBuilder.string(" /* ", "remove" + " ", getStates().toString(elements, ", "), " */"); } } - return createSet(frameState, persist, valueBuilder.build(), elements.length > 0); + return valueBuilder.build(); + } + + public CodeTree createSet(FrameState frameState, StateQuery elements, Boolean value, boolean persist) { + CodeTreeBuilder valueBuilder = CodeTreeBuilder.createBuilder(); + boolean isEmpty = elements == null || elements.isEmpty(); + if (!hasLocal(frameState) && isEmpty) { + return valueBuilder.build(); + } + valueBuilder.tree(createSetExpression(createReference(frameState), elements, value)); + return createSet(frameState, persist, valueBuilder.build(), !isEmpty); } private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valueTree, boolean update) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); if (persist) { - builder.string("this.", name, "_ = "); + builder.string("this.", name, "_"); + if (frameState != null && frameState.isInlinedNode()) { + builder.startCall(".set"); + builder.tree(frameState.getValue(0).createReference()); + } else { + builder.string(" = "); + } + builder.startGroup(); // if there is a local variable we need to update it as well CodeTree localReference = createLocalReference(frameState); if (localReference != null && update) { builder.tree(localReference).string(" = "); } } else { + builder.startGroup(); builder.tree(createReference(frameState)).string(" = "); } builder.tree(valueTree); + builder.end(); + + if (persist && frameState != null && frameState.isInlinedNode()) { + builder.end(); + } + builder.end(); // statement return builder.build(); } - public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree value) { + public CodeTree createSetInteger(CodeTree receiver, StateQuery element, CodeTree value) { int offset = getStateOffset(element); CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.startStatement(); - builder.tree(createReference(frameState)).string(" = "); + builder.tree(receiver).string(" = "); builder.startParantheses(); - builder.tree(createReference(frameState)); + builder.tree(receiver); builder.string(" | ("); - if (capacity > 32) { + if (getBitCount() > 32) { builder.string("(long) "); } builder.tree(value).string(" << ", Integer.toString(offset), ")"); - builder.string(" /* ", label("set-implicit"), toString(element), " */"); - builder.end(); + builder.string(" /* ", "set-int" + " ", getStates().toString(element, ""), " */"); builder.end(); return builder.build(); } - private long createMask(Object e) { - return createMask(new Object[]{e}); + public CodeTree createSetInteger(FrameState frameState, StateQuery element, CodeTree value) { + return createSetInteger(createReference(frameState), element, value); } - public long createMask(Object[] e) { + public long createMask(StateQuery... e) { return createMask(0, -1, e); } - private long createMask(int offset, int length, Object[] e) { + private long createMask(int offset, int length, StateQuery... queries) { long mask = 0; - for (Object element : e) { - if (!offsets.containsKey(element)) { - continue; - } - int stateOffset = getStateOffset(element); - int stateLength = calculateRequiredBits(element); - int realLength = length < 0 ? stateLength : Math.min(stateLength, offset + length); - for (int i = offset; i < realLength; i++) { - mask |= 1L << (stateOffset + i); + for (StateQuery e : queries) { + for (BitRange range : getStates().queryRanges(e)) { + int realLength = length < 0 ? range.length : Math.min(range.length, offset + length); + for (int i = offset; i < realLength; i++) { + mask |= 1L << (range.offset + i); + } } } return mask; } - private int getStateOffset(Object object) { - Integer value = offsets.get(object); - if (value == null) { - return 0; + private int getStateOffset(StateQuery query) { + List ranges = getStates().queryRanges(query); + for (BitRange range : ranges) { + return range.offset; + } + return 0; + } + + static final class BitRange { + + final int offset; + final int length; + + BitRange(int offset, int length) { + this.offset = offset; + this.length = length; } - return value; + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java new file mode 100644 index 000000000000..c1cd523c7732 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java @@ -0,0 +1,752 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.generator; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import javax.lang.model.element.Element; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.generator.BitSet.BitRange; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.MultiStateBitSet; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; +import com.oracle.truffle.dsl.processor.model.CacheExpression; +import com.oracle.truffle.dsl.processor.model.GuardExpression; +import com.oracle.truffle.dsl.processor.model.InlineFieldData; +import com.oracle.truffle.dsl.processor.model.NodeData; +import com.oracle.truffle.dsl.processor.model.SpecializationData; +import com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard; + +final class BitStateList { + + private final List entries; + private final LinkedHashMap> byKey = new LinkedHashMap<>(); + private final int bitCount; + + BitStateList(List> stateObjects) { + int bitOffset = 0; + List newStates = new ArrayList<>(); + for (State state : stateObjects) { + List values = byKey.computeIfAbsent(state.key, (v) -> new ArrayList<>()); + for (BitRangedState nodeState : values) { + if (nodeState.state.getClass() == state.getClass()) { + throw new IllegalArgumentException(String.format("Duplicate state for value with key %s and class %s.", + state.key, nodeState.state.getClass())); + } + } + int bits = state.getBits(); + BitRangedState rangedState = new BitRangedState(state, new BitRange(bitOffset, bits)); + newStates.add(rangedState); + values.add(rangedState); + bitOffset += bits; + } + this.entries = Collections.unmodifiableList(newStates); + this.bitCount = bitOffset; + } + + int getBitCount() { + return bitCount; + } + + List getEntries() { + return entries; + } + + @SuppressWarnings("unchecked") + boolean contains(Class clazz, Object key) { + return lookup((Class>) clazz, key) != null; + } + + > List queryStates(Class statesClass) { + List newStates = new ArrayList<>(); + for (BitRangedState ranged : entries) { + if (statesClass.isInstance(ranged.state)) { + newStates.add(statesClass.cast(ranged.state)); + } + } + return newStates; + } + + @SuppressWarnings({"unchecked", "cast"}) + , E> Collection queryKeys(Class statesClass) { + if (statesClass == null) { + return (Collection) byKey.keySet(); + } + Set newKeys = new LinkedHashSet<>(); + for (BitRangedState ranged : entries) { + if (statesClass.isInstance(ranged.state)) { + newKeys.add((E) statesClass.cast(ranged.state).key); + } + } + return newKeys; + } + + List queryRanges(StateQuery query) { + List range = new ArrayList<>(); + for (Object key : getQueryKeys(query)) { + List values = byKey.get(key); + if (values != null) { + for (BitRangedState v : values) { + if (query.match(v.state)) { + range.add(v.bitRange); + } + } + } + } + return range; + } + + BitRange queryRange(StateQuery query) { + if (!query.filtersClass()) { + throw new IllegalArgumentException("A query for a single range must query the state class."); + } + for (Object key : getQueryKeys(query)) { + BitRangedState state = matchQueryAny(query, byKey.get(key)); + if (state != null) { + return state.bitRange; + } + } + return null; + } + + boolean contains(StateQuery query) { + for (Object key : getQueryKeys(query)) { + if (matchQueryAny(query, byKey.get(key)) != null) { + return true; + } + } + return false; + } + + private Collection getQueryKeys(StateQuery query) { + if (query.keys == null) { + return byKey.keySet(); + } + return query.keys; + } + + private static BitRangedState matchQueryAny(StateQuery query, List values) { + if (values != null) { + for (BitRangedState v : values) { + if (query.match(v.state)) { + return v; + } + } + } + return null; + } + + @SuppressWarnings("unchecked") + StateQuery filter(StateQuery query) { + List newKeys = new ArrayList<>(); + for (Object key : query.keys) { + BitRangedState state = matchQueryAny(query, byKey.get(key)); + if (state != null) { + newKeys.add(state.state.key); + } + } + return StateQuery.create((Class>) query.filterClass, (List) newKeys); + } + + String toString(StateQuery query, String elementSep) { + StringBuilder b = new StringBuilder(); + String sep = ""; + for (Object key : query.keys) { + BitRangedState state = matchQueryAny(query, byKey.get(key)); + if (state != null) { + b.append(sep).append(state.state.toString()); + sep = elementSep; + } + } + return b.toString(); + } + + MultiStateBitSet splitBitSets(String namePrefix, NodeData activeNode, int maxBitWidth) { + List groups = groupByDependentSpecializations(this.entries); + List stateLists = splitByWidth(groups, maxBitWidth); + + for (BitRangedState state : entries) { + boolean found = false; + Class stateClass = state.state.getClass(); + for (BitStateList list : stateLists) { + if (list.contains(stateClass, state.state.key)) { + if (found) { + throw new AssertionError("found twice"); + } + found = true; + } + } + + if (!found) { + throw new AssertionError("element not contained in split lists " + state); + } + } + + List allBitSets = new ArrayList<>(); + List activeBitSets = new ArrayList<>(); + int index = 0; + for (BitStateList list : stateLists) { + BitSet bitSet = new BitSet(namePrefix + "state_" + index, list); + if (list.isRelevantFor(activeNode)) { + if (list.getBitCount() == 0) { + continue; + } + activeBitSets.add(bitSet); + } + allBitSets.add(bitSet); + index++; + } + return new MultiStateBitSet(allBitSets, activeBitSets); + } + + private static int countGroupBits(List groupedStates) { + int bits = 0; + for (StateGroup state : groupedStates) { + bits += state.countBits(); + } + return bits; + } + + private static List splitByWidth(List groups, int maxBitWidth) { + List> split = new ArrayList<>(); + List currentStates = new ArrayList<>(); + int currentWidth = 0; + + // naively pack them in order (we want to preserve order as much as possible) + for (StateGroup grouped : groups) { + int bits = grouped.countBits(); + if (!currentStates.isEmpty()) { + boolean forceNewGroup = !canBeInSameBitSet(currentStates, grouped); + if (forceNewGroup || currentWidth + bits > maxBitWidth) { + split.add(currentStates); + currentStates = new ArrayList<>(); + currentWidth = 0; + } + } + + currentStates.add(grouped); + currentWidth += bits; + } + if (!currentStates.isEmpty()) { + split.add(currentStates); + } + + if (split.size() > 1) { + /* + * Try to compress. + */ + for (int i = split.size() - 1; i >= 0; i--) { + List pack = split.get(i); + int bits = countGroupBits(pack); + + for (int y = i - 1; y >= 0; y--) { + List otherPack = split.get(y); + int otherBits = countGroupBits(otherPack); + int otherBitsLeft = maxBitWidth - otherBits; + + if (otherBitsLeft <= 0) { + // other pack is full + continue; + } + + if (bits <= otherBitsLeft) { + boolean canFullyMerge = true; + for (StateGroup group : pack) { + if (!canBeInSameBitSet(otherPack, group)) { + canFullyMerge = false; + break; + } + } + + // we can merge packs fully + if (canFullyMerge) { + otherPack.addAll(pack); + split.remove(i); + break; + } + } + + if (pack.size() > 1) { + ListIterator packsIterator = pack.listIterator(); + while (packsIterator.hasNext()) { + StateGroup group = packsIterator.next(); + int groupBits = group.countBits(); + if (groupBits <= otherBitsLeft && canBeInSameBitSet(otherPack, group)) { + packsIterator.remove(); + otherPack.add(group); + otherBitsLeft -= groupBits; + + if (otherBitsLeft <= 0) { + // no more potential with this pack + break; + } + } + } + } + } + } + } + + // create flattened lists + List packedLists = new ArrayList<>(); + for (List pack : split) { + List> flattendGroup = new ArrayList<>(); + for (StateGroup group : pack) { + flattendGroup.addAll(group.states); + } + BitStateList list = new BitStateList(flattendGroup); + if (maxBitWidth == 32 && list.getBitCount() > maxBitWidth) { + /* + * Note we only check this here for 32 bits, because its possible the processor runs + * with fewer or more bits were it may happen that we overpack due to atomic group + * size. + */ + throw new AssertionError("Max bitwidth exceeded. Probably packing error."); + } + packedLists.add(list); + } + + return packedLists; + } + + private static boolean canBeInSameBitSet(List states, StateGroup group) { + for (StateGroup state : states) { + if (!state.canBeInSameBitSet(group)) { + return false; + } + } + return true; + } + + private static List groupByDependentSpecializations(List states) { + List groups = new ArrayList<>(); + Map specializationGroups = new HashMap<>(); + + for (BitRangedState state : states) { + SpecializationData dependentSpecialization = state.state.getDependentSpecialization(); + + if (dependentSpecialization != null) { + StateGroup group = specializationGroups.get(dependentSpecialization); + if (group == null) { + /* + * A specialization must share the same group as all specializations it replaces + * to ensure that specializations are updated atomically from the same state + * bitset. This allows us to avoid locks for any updates. + */ + for (SpecializationData replaces : dependentSpecialization.getReplaces()) { + group = specializationGroups.get(replaces); + if (group != null) { + break; + } + } + } + if (group == null) { + group = new StateGroup(new ArrayList<>(), null, dependentSpecialization); + specializationGroups.put(dependentSpecialization, group); + groups.add(group); + } + + if (group.excludedSpecialization != state.state.getExcludedSpecialization()) { + throw new AssertionError("States with dependent specializations must not use excluded specializations."); + } + group.states.add(state.state); + } else { + // without a dependent specialization it does not matter where the bit is set + groups.add(new StateGroup(Arrays.asList(state.state), state.state.getExcludedSpecialization(), null)); + } + } + + return groups; + } + + private boolean isRelevantFor(NodeData activeNode) { + for (BitRangedState ranged : entries) { + if (ranged.state.node == activeNode) { + return true; + } + } + return false; + } + + private BitRangedState lookup(Class> clazz, Object key) { + List values = byKey.get(key); + if (values != null) { + for (BitRangedState v : values) { + if (v.state.getClass() == clazz) { + return v; + } + } + } + return null; + } + + static final class StateGroup { + + final List> states; + final SpecializationData excludedSpecialization; + final SpecializationData dependentSpecialization; + + StateGroup(List> states, SpecializationData excludedSpecialization, SpecializationData dependentSpecialization) { + this.states = states; + this.excludedSpecialization = excludedSpecialization; + this.dependentSpecialization = dependentSpecialization; + } + + boolean canBeInSameBitSet(StateGroup group) { + if (this.excludedSpecialization != null && this.excludedSpecialization.equals(group.dependentSpecialization)) { + return false; + } else if (group.excludedSpecialization != null && group.excludedSpecialization.equals(this.dependentSpecialization)) { + return false; + } else { + return true; + } + } + + int countBits() { + int bits = 0; + for (State state : states) { + bits += state.getBits(); + } + return bits; + } + + } + + static final class BitRangedState { + + final State state; + final BitRange bitRange; + + BitRangedState(State state, BitRange bitRange) { + this.state = state; + this.bitRange = bitRange; + } + + } + + static final class SpecializationActive extends State { + + SpecializationActive(SpecializationData key) { + super(key.getNode(), key); + } + + @Override + SpecializationData getDependentSpecialization() { + return key; + } + + @Override + int getBits() { + return 1; + } + + @Override + public String toString() { + return String.format("SpecializationActive[%s]", + ElementUtils.getReadableReference(node.getMessageElement(), key.getMethod())); + } + + @Override + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string("SpecializationActive "); + docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); + } + + } + + static final class SpecializationExcluded extends State { + + SpecializationExcluded(SpecializationData key) { + super(key.getNode(), key); + } + + @Override + SpecializationData getDependentSpecialization() { + return key; + } + + @Override + int getBits() { + return 1; + } + + @Override + public String toString() { + return String.format("SpecializationExcluded ", + ElementUtils.getReadableReference(node.getMessageElement(), key.getMethod())); + } + + @Override + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string("SpecializationExcluded "); + docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); + } + + } + + static final class SpecializationCachesInitialized extends State { + + private final SpecializationData specialization; + + SpecializationCachesInitialized(SpecializationData specialization) { + super(specialization.getNode(), specialization); + this.specialization = specialization; + } + + @Override + int getBits() { + return 1; + } + + @Override + public String toString() { + return String.format("SpecializationCachesInitialized ", + ElementUtils.getReadableReference(node.getMessageElement(), key.getMethod())); + } + + @Override + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string("SpecializationCachesInitialized "); + docBuilder.javadocLink(specialization.getMethod(), null); + } + } + + static final class GuardActive extends State { + + private final SpecializationData specialization; + + GuardActive(SpecializationData specialization, GuardExpression key) { + super(specialization.getNode(), key); + this.specialization = specialization; + } + + @Override + SpecializationData getDependentSpecialization() { + return specialization; + } + + @Override + int getBits() { + return 1; + } + + @Override + public String toString() { + return String.format("GuardActive[specialization=%s, guardIndex=%s]", + ElementUtils.getReadableReference(node.getMessageElement(), specialization.getMethod()), + getDependentSpecialization().getGuards().indexOf(key)); + } + + @Override + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string(String.format("GuardActive[guardIndex=%s] ", + getDependentSpecialization().getGuards().indexOf(key))); + docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); + } + + } + + static final class ImplicitCastState extends State { + + ImplicitCastState(NodeData node, TypeGuard key) { + super(node, key); + } + + @Override + int getBits() { + TypeMirror type = key.getType(); + Collection sourceTypes = key.getTypeSystem().lookupSourceTypes(type); + if (sourceTypes.size() > 1) { + return sourceTypes.size(); + } + throw new AssertionError(); + } + + @Override + public String toString() { + return String.format("ImplicitCast[type=%s, index=%s]", + ElementUtils.getSimpleName(key.getType()), + key.getSignatureIndex()); + } + + } + + static final class EncodedEnumState extends State { + + private final CacheExpression cache; + + EncodedEnumState(NodeData node, CacheExpression cache) { + super(node, cache); + this.cache = cache; + } + + @Override + int getBits() { + List values = ElementUtils.getEnumValues(ElementUtils.castTypeElement(cache.getParameter().getType())); + int reservedValues = 0; + if (cache.isNeverDefault()) { + reservedValues = 2; + } else { + reservedValues = 1; + } + int maxValue = values.size() + reservedValues; + return Integer.SIZE - Integer.numberOfLeadingZeros(maxValue); + } + + @Override + public String toString() { + return String.format("EncodedEnum[cache=%s]", + ElementUtils.getReadableReference(node.getMessageElement(), cache.getParameter().getVariableElement())); + + } + } + + static final class InlinedNodeState extends State { + + private final CacheExpression cache; + private final SpecializationData excludedSpecialization; + + InlinedNodeState(NodeData node, CacheExpression cache, InlineFieldData key, SpecializationData excludedSpecialization) { + super(node, key); + this.excludedSpecialization = excludedSpecialization; + this.cache = cache; + } + + @Override + int getBits() { + return this.key.getBits(); + } + + @Override + SpecializationData getExcludedSpecialization() { + return excludedSpecialization; + } + + @Override + public String toString() { + return String.format("InlinedCache[cache=%s]", + ElementUtils.getReadableReference(node.getMessageElement(), cache.getParameter().getVariableElement())); + } + + @Override + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string("InlinedCache").newLine(); + FlatNodeGenFactory.addCacheInfo(docBuilder, " ", getDependentSpecialization(), cache, key); + } + + } + + static final class AOTPreparedState extends State { + + AOTPreparedState(NodeData node) { + super(node, "aot-prepared"); + } + + @Override + int getBits() { + return 1; + } + + @Override + public String toString() { + return "AOTPrepared"; + } + + } + + abstract static class State { + + final NodeData node; + final T key; + + State(NodeData node, T key) { + this.node = node; + this.key = key; + } + + SpecializationData getDependentSpecialization() { + return null; + } + + SpecializationData getExcludedSpecialization() { + return null; + } + + abstract int getBits(); + + @Override + public abstract String toString(); + + @Override + public int hashCode() { + return Objects.hash(getClass(), key); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + State other = (State) obj; + return Objects.equals(key, other.key); + } + + void addStateDoc(CodeTreeBuilder docBuilder) { + docBuilder.string(toString()); + } + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index d12212a2e7b5..e6aa404961a9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -40,10 +40,10 @@ */ package com.oracle.truffle.dsl.processor.generator; +import static com.oracle.truffle.dsl.processor.ProcessorContext.types; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; import static com.oracle.truffle.dsl.processor.java.ElementUtils.boxType; import static com.oracle.truffle.dsl.processor.java.ElementUtils.executableEquals; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.findAnnotationMirror; import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterLowerCase; import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; @@ -53,7 +53,6 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.isAssignable; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isObject; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isPrimitive; -import static com.oracle.truffle.dsl.processor.java.ElementUtils.isSubtype; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isSubtypeBoxed; import static com.oracle.truffle.dsl.processor.java.ElementUtils.isVoid; import static com.oracle.truffle.dsl.processor.java.ElementUtils.modifiers; @@ -61,12 +60,15 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.setVisibility; import static com.oracle.truffle.dsl.processor.java.ElementUtils.typeEquals; import static com.oracle.truffle.dsl.processor.java.ElementUtils.uniqueSortedTypes; +import static com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder.singleString; import static javax.lang.model.element.Modifier.ABSTRACT; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; import static javax.lang.model.element.Modifier.PUBLIC; import static javax.lang.model.element.Modifier.STATIC; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.VarHandle; import java.util.ArrayList; import java.util.Arrays; @@ -85,7 +87,6 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Function; @@ -103,6 +104,7 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; +import com.oracle.truffle.dsl.processor.TruffleSuppressedWarnings; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.expression.DSLExpression; import com.oracle.truffle.dsl.processor.expression.DSLExpression.AbstractDSLExpressionVisitor; @@ -112,6 +114,18 @@ import com.oracle.truffle.dsl.processor.expression.DSLExpression.DSLExpressionReducer; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Negate; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable; +import com.oracle.truffle.dsl.processor.generator.BitSet.BitRange; +import com.oracle.truffle.dsl.processor.generator.BitStateList.AOTPreparedState; +import com.oracle.truffle.dsl.processor.generator.BitStateList.BitRangedState; +import com.oracle.truffle.dsl.processor.generator.BitStateList.EncodedEnumState; +import com.oracle.truffle.dsl.processor.generator.BitStateList.GuardActive; +import com.oracle.truffle.dsl.processor.generator.BitStateList.ImplicitCastState; +import com.oracle.truffle.dsl.processor.generator.BitStateList.InlinedNodeState; +import com.oracle.truffle.dsl.processor.generator.BitStateList.SpecializationActive; +import com.oracle.truffle.dsl.processor.generator.BitStateList.SpecializationCachesInitialized; +import com.oracle.truffle.dsl.processor.generator.BitStateList.SpecializationExcluded; +import com.oracle.truffle.dsl.processor.generator.BitStateList.State; +import com.oracle.truffle.dsl.processor.generator.MultiBitSet.StateTransaction; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; @@ -122,7 +136,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; -import com.oracle.truffle.dsl.processor.java.model.CodeTypeParameterElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.library.ExportsGenerator; @@ -132,6 +145,8 @@ import com.oracle.truffle.dsl.processor.model.ExecutableTypeData; import com.oracle.truffle.dsl.processor.model.GuardExpression; import com.oracle.truffle.dsl.processor.model.ImplicitCastData; +import com.oracle.truffle.dsl.processor.model.InlineFieldData; +import com.oracle.truffle.dsl.processor.model.InlinedNodeData; import com.oracle.truffle.dsl.processor.model.NodeChildData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; @@ -159,14 +174,10 @@ public class FlatNodeGenFactory { private static final String FRAME_VALUE = TemplateMethod.FRAME_NAME; private static final String NAME_SUFFIX = "_"; + public static final int INLINED_NODE_INDEX = 0; private static final String VARARGS_NAME = "args"; - private static final Object AOT_PREPARED = new Object() { - @Override - public String toString() { - return "AOT-prepared"; - } - }; + static final StateQuery AOT_PREPARED = StateQuery.create(AOTPreparedState.class, "aot-prepared"); private final ProcessorContext context; private final TruffleTypes types = ProcessorContext.getInstance().getTypes(); @@ -174,8 +185,6 @@ public String toString() { private final TypeSystemData typeSystem; private final TypeMirror genericType; private final Set expectedTypes = new HashSet<>(); - private List reachableSpecializations; - private SpecializationData[] reachableSpecializationsArray; private final Collection sharingNodes; private final boolean boxingEliminationEnabled; @@ -183,22 +192,22 @@ public String toString() { private final MultiStateBitSet multiState; // only active node private final MultiStateBitSet allMultiState; // all nodes - private final ExcludeBitSet exclude; private final ExecutableTypeData executeAndSpecializeType; private boolean fallbackNeedsState = false; private boolean fallbackNeedsFrame = false; private final Map specializationClasses = new LinkedHashMap<>(); - private final Set usedInsertAccessorsArray = new LinkedHashSet<>(); - private final Set usedInsertAccessorsSimple = new LinkedHashSet<>(); private final boolean primaryNode; private final Map sharedCaches; + private final Map sharedCacheKey; + private final ParentInlineData parentInlineAccess; private final Map> substitutions = new LinkedHashMap<>(); private final StaticConstants constants; + private NodeConstants nodeConstants; - private final boolean needsSpecializeLocking; private final GeneratorMode generatorMode; + private final NodeStateResult state; public enum GeneratorMode { DEFAULT, @@ -206,14 +215,15 @@ public enum GeneratorMode { } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants); + StaticConstants constants, NodeConstants nodeConstants) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, nodeConstants); } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, - StaticConstants constants) { + StaticConstants constants, + NodeConstants nodeConstants) { Objects.requireNonNull(node); this.generatorMode = mode; this.context = context; @@ -222,145 +232,284 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData this.typeSystem = node.getTypeSystem(); this.genericType = context.getType(Object.class); this.boxingEliminationEnabled = !TruffleProcessorOptions.generateSlowPathOnly(context.getEnvironment()); - this.reachableSpecializations = calculateReachableSpecializations(node); - this.reachableSpecializationsArray = reachableSpecializations.toArray(new SpecializationData[0]); this.primaryNode = stateSharingNodes.iterator().next() == node; this.sharedCaches = sharedCaches; + this.sharedCacheKey = computeSharedCacheKeys(stateSharingNodes, sharedCaches); + this.parentInlineAccess = computeParentInlineAccess(); + this.state = createNodeState(); + this.multiState = state.activeState; + this.allMultiState = state.allState; + this.executeAndSpecializeType = createExecuteAndSpecializeType(); - List stateObjects = new ArrayList<>(); - List excludeObjects = new ArrayList<>(); - int activeStateStartIndex = -1; - int activeStateEndIndex = -1; - boolean volatileState = false; - boolean aotStateAdded = false; - for (NodeData stateNode : stateSharingNodes) { - boolean primary = stateNode == node; - if (primary && activeStateStartIndex == -1) { - activeStateStartIndex = stateObjects.size(); - } - if (!primary && activeStateStartIndex != -1 && activeStateEndIndex == -1) { - activeStateEndIndex = stateObjects.size(); + this.constants = constants; + this.nodeConstants = nodeConstants; + this.substitutions.put(ElementUtils.findExecutableElement(types.LibraryFactory, "resolve"), + (binary) -> substituteLibraryCall(binary)); + this.substitutions.put(ElementUtils.findExecutableElement(types.TruffleLanguage_ContextReference, "create"), + (binary) -> substituteContextReference(binary)); + this.substitutions.put(ElementUtils.findExecutableElement(types.TruffleLanguage_LanguageReference, "create"), + (binary) -> substituteLanguageReference(binary)); + + } + + private static final class NodeStateResult { + + final MultiStateBitSet activeState; + final MultiStateBitSet allState; + + NodeStateResult(MultiStateBitSet state, MultiStateBitSet allState) { + this.activeState = state; + this.allState = allState; + } + } + + public static List createInlinedFields(NodeData node) { + FlatNodeGenFactory factory = new FlatNodeGenFactory(ProcessorContext.getInstance(), GeneratorMode.DEFAULT, node, new StaticConstants(), new NodeConstants()); + return factory.createInlineFields(true); + } + + private List createInlineFields(boolean pruneInternalClasses) { + List fields = new ArrayList<>(); + + for (BitSet bitSet : state.activeState.getSets()) { + String name = bitSet.getName() + "_"; + TypeMirror referenceType = types().InlineSupport_StateField; + CodeVariableElement var = MultiStateBitSet.createCachedField(bitSet); + fields.add(new InlineFieldData(var, name, referenceType, bitSet.getBitCount(), null, 0)); + } + + /* + * createInlineFieldSignature should not generate nodeConstants so we discard everything + * generated there. + */ + NodeConstants savedConstants = this.nodeConstants; + this.nodeConstants = new NodeConstants(); + + List elements = createCachedFields(null); + for (Element element : elements) { + if (!(element instanceof CodeVariableElement)) { + continue; } - if (!aotStateAdded && needsAOTReset()) { - stateObjects.add(AOT_PREPARED); - aotStateAdded = true; + CodeVariableElement var = (CodeVariableElement) element; + if (var.getModifiers().contains(STATIC)) { + // for inlining we only care about instance fields + continue; } + TypeMirror type = var.asType(); + String name = var.getName(); + if (ElementUtils.isPrimitive(type)) { + fields.add(new InlineFieldData(element, name, InlineFieldData.resolvePrimitiveFieldType(type), null, type, 0)); + } else { + int dimensions = 0; + if (pruneInternalClasses) { + if (ElementUtils.isAssignable(type, types.Node)) { + type = types.Node; + } else if (ElementUtils.isAssignable(type, types.NodeInterface)) { + type = types.NodeInterface; + } else if (isNodeArray(type)) { + type = new ArrayCodeTypeMirror(types.Node); + } else if (type.getKind() == TypeKind.ARRAY) { + type = context.getType(Object[].class); + AnnotationMirror annotationMirror = ElementUtils.findAnnotationMirror(var, types.CompilerDirectives_CompilationFinal); + if (annotationMirror != null) { + dimensions = ElementUtils.getAnnotationValue(Integer.class, annotationMirror, "dimensions"); + } + } else { + type = context.getType(Object.class); + } + } - boolean needsRewrites = stateNode.needsRewrites(context); - if (!needsRewrites) { - continue; + fields.add(new InlineFieldData(element, name, types().InlineSupport_ReferenceField, null, type, dimensions)); } + } - List specializations = calculateReachableSpecializations(stateNode); + this.nodeConstants = savedConstants; + return fields; + + } + + BitStateList computeNodeState() { + List> stateObjects = new ArrayList<>(); + boolean aotStateAdded = false; + + Set handledCaches = new HashSet<>(); + for (NodeData stateNode : sharingNodes) { Set implicitCasts = new LinkedHashSet<>(); + boolean needsRewrites = stateNode.needsRewrites(context); + List specializations = stateNode.getReachableSpecializations(); for (SpecializationData specialization : specializations) { - stateObjects.add(specialization); + if (!aotStateAdded && needsAOTReset(node, sharingNodes)) { + stateObjects.add(new AOTPreparedState(node)); + aotStateAdded = true; + } + + if (needsRewrites) { + stateObjects.add(new SpecializationActive(specialization)); + } + + if (hasExcludeBit(specialization)) { + stateObjects.add(new SpecializationExcluded(specialization)); + } + + for (GuardExpression guard : specialization.getGuards()) { + if (guardNeedsNodeStateBit(specialization, guard)) { + stateObjects.add(new GuardActive(specialization, guard)); + } + } + + boolean useSpecializationClass = useSpecializationClass(specialization); + for (CacheExpression cache : specialization.getCaches()) { + if (useSpecializationClass && canCacheBeStoredInSpecialializationClass(cache)) { + continue; + } + if (!cache.isEncodedEnum()) { + continue; + } + String sharedGroup = cache.getSharedGroup(); + if (sharedGroup == null || !handledCaches.contains(sharedGroup)) { + stateObjects.add(new BitStateList.EncodedEnumState(node, cache)); + if (sharedGroup != null) { + handledCaches.add(sharedGroup); + } + } + } + int index = 0; for (Parameter p : specialization.getSignatureParameters()) { TypeMirror targetType = p.getType(); Collection sourceTypes = stateNode.getTypeSystem().lookupSourceTypes(targetType); if (sourceTypes.size() > 1) { - implicitCasts.add(new TypeGuard(targetType, index)); + implicitCasts.add(new TypeGuard(stateNode.getTypeSystem(), targetType, index)); } index++; } - if (!specialization.getCaches().isEmpty()) { - volatileState = true; - } - for (GuardExpression guard : specialization.getGuards()) { - if (guardNeedsStateBit(specialization, guard)) { - stateObjects.add(guard); - } - } - excludeObjects.add(specialization); } - stateObjects.addAll(implicitCasts); - } - if (activeStateEndIndex == -1) { - activeStateEndIndex = stateObjects.size(); + for (TypeGuard cast : implicitCasts) { + stateObjects.add(new ImplicitCastState(stateNode, cast)); + } } - this.multiState = createMultiStateBitset(stateObjects, activeStateStartIndex, activeStateEndIndex, volatileState); - this.allMultiState = new MultiStateBitSet(this.multiState.all, this.multiState.all); - this.exclude = new ExcludeBitSet(excludeObjects.toArray(new SpecializationData[0]), volatileState); - this.executeAndSpecializeType = createExecuteAndSpecializeType(); - this.needsSpecializeLocking = exclude.getCapacity() != 0 || reachableSpecializations.stream().anyMatch((s) -> !s.getCaches().isEmpty()); - this.constants = constants; - this.substitutions.put(ElementUtils.findExecutableElement(types.LibraryFactory, "resolve"), - (binary) -> substituteLibraryCall(binary)); - this.substitutions.put(ElementUtils.findExecutableElement(types.TruffleLanguage_ContextReference, "create"), - (binary) -> substituteContextReference(binary)); - this.substitutions.put(ElementUtils.findExecutableElement(types.TruffleLanguage_LanguageReference, "create"), - (binary) -> substituteLanguageReference(binary)); - } + for (NodeData stateNode : sharingNodes) { + for (SpecializationData specialization : stateNode.getReachableSpecializations()) { + boolean useSpecializationClass = useSpecializationClass(specialization); + BitStateList specializationState = computeSpecializationState(specialization); + for (CacheExpression cache : specialization.getCaches()) { + InlinedNodeData inline = cache.getInlinedNode(); + if (inline == null) { + continue; + } - private MultiStateBitSet createMultiStateBitset(List stateObjects, int activeStateStartIndex, int activeStateEndIndex, boolean volatileState) { - int maxBits = TruffleProcessorOptions.stateBitWidth(context.getEnvironment()); + String cacheGroup = cache.getSharedGroup(); + if (cacheGroup != null) { + if (handledCaches.contains(cacheGroup)) { + continue; + } + handledCaches.add(cacheGroup); + } - int usedBits = 0; - List allStateBits = new ArrayList<>(); - List currentElements = new ArrayList<>(); - SpecializationData currentSpecialization = null; - Set relevantSpecializations = new LinkedHashSet<>(); - int activeStartBits = 0; - int activeEndBits = -1; - for (int i = 0; i < stateObjects.size(); i++) { - Object o = stateObjects.get(i); + if (cacheGroup == null && useSpecializationClass) { + // state is handled in computeSpecializationState + for (InlineFieldData fieldData : cache.getInlinedNode().getFields()) { + if (fieldData.isState()) { + if (!specializationState.contains(InlinedNodeState.class, fieldData)) { + throw new AssertionError("Detected unhandled state"); + } + } + } + continue; + } - if (activeEndBits == -1 && activeStateEndIndex == i) { - activeEndBits = allStateBits.size(); - } + SpecializationData excludeSpecialization = null; + if (cache.isUsedInGuard()) { + /* + * Inlined caches that are bound in guards must not be in the same state + * bitset as the dependent specialization bits. At the end of slow-path + * specialization we set the state bits of the specialization. If an inlined + * node in the guard changes the state bits we would override when we set + * the specialization bits. Alternatively we could re-read the state bit-set + * before we specialize in such case after the bound guards were executed, + * but that is very hard to get right in a thread-safe manner. + */ + excludeSpecialization = specialization; + } - int currentBits = getRequiredStateBits(typeSystem, o); - if (usedBits + currentBits > maxBits) { - if (usedBits == 0 || currentElements.isEmpty()) { - throw new AssertionError("single object bit size too high for range"); + for (InlineFieldData fieldData : cache.getInlinedNode().getFields()) { + if (fieldData.isState()) { + stateObjects.add(new InlinedNodeState(stateNode, cache, fieldData, excludeSpecialization)); + } + } } - allStateBits.add(new StateBitSet(currentElements.toArray(), - relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size())); - currentElements.clear(); - relevantSpecializations.clear(); - usedBits = 0; } + } + + return new BitStateList(stateObjects); + } - if (activeStartBits == 0 && activeStateStartIndex == i) { - activeStartBits = allStateBits.size(); + private static BitStateList computeSpecializationState(SpecializationData specialization) { + List> stateObjects = new ArrayList<>(); + if (useSpecializationClass(specialization)) { + + for (GuardExpression guard : specialization.getGuards()) { + if (guardNeedsSpecializationStateBit(specialization, guard)) { + stateObjects.add(new GuardActive(specialization, guard)); + } } - if (o instanceof SpecializationData) { - currentSpecialization = (SpecializationData) o; + if (specializationNeedsInitializedBit(specialization)) { + stateObjects.add(new SpecializationCachesInitialized(specialization)); } - // type guards do not belong to any specialization - if (!(o instanceof TypeGuard) && !(o instanceof GuardExpression)) { - relevantSpecializations.add(currentSpecialization); + for (CacheExpression cache : specialization.getCaches()) { + if (!canCacheBeStoredInSpecialializationClass(cache)) { + continue; + } + + if (cache.getInlinedNode() != null) { + for (InlineFieldData field : cache.getInlinedNode().getFields()) { + if (field.isState()) { + stateObjects.add(new InlinedNodeState(specialization.getNode(), cache, field, null)); + } + } + } else if (cache.isEncodedEnum()) { + stateObjects.add(new EncodedEnumState(specialization.getNode(), cache)); + } } - currentElements.add(o); - usedBits += currentBits; - } - if (activeEndBits == -1) { - activeEndBits = allStateBits.size(); } + return new BitStateList(stateObjects); + } - allStateBits.add(new StateBitSet(currentElements.toArray(), - relevantSpecializations.toArray(new SpecializationData[0]), - volatileState, allStateBits.size())); + @SuppressWarnings("hiding") + NodeStateResult createNodeState() { + BitStateList list = computeNodeState(); + MultiStateBitSet state = createMultiStateBitset("", node, list); + MultiStateBitSet allState = new MultiStateBitSet(state.all, state.all); + return new NodeStateResult(state, allState); + } - List activeStateBits = allStateBits.subList(activeStartBits, activeEndBits + 1); - return new MultiStateBitSet(allStateBits, activeStateBits); + private static MultiStateBitSet createMultiStateBitset(String namePrefix, NodeData activeNode, BitStateList objects) { + ProcessorContext context = ProcessorContext.getInstance(); + int maxBits = TruffleProcessorOptions.stateBitWidth(context.getEnvironment()); + return objects.splitBitSets(namePrefix, activeNode, maxBits); } private boolean needsRewrites() { - return node.needsRewrites(context); + if (node.needsRewrites(context)) { + return true; + } + for (SpecializationData specialization : node.getReachableSpecializations()) { + if (useSpecializationClass(specialization)) { + return true; + } + } + return false; } - private boolean needsAOTReset() { + private static boolean needsAOTReset(NodeData node, Collection stateSharingNodes) { if (!node.isGenerateAOT()) { return false; } - for (NodeData currentNode : sharingNodes) { - if (currentNode.needsRewrites(context)) { + for (NodeData currentNode : stateSharingNodes) { + if (currentNode.needsRewrites(node.getContext())) { return true; } } @@ -372,44 +521,73 @@ private boolean hasMultipleNodes() { } private String createSpecializationTypeName(SpecializationData s) { - if (hasMultipleNodes()) { - return firstLetterUpperCase(getNodePrefix(s)) + firstLetterUpperCase(s.getId()) + "Data"; + if (sharingNodes.size() > 1) { + return firstLetterUpperCase(getNodePrefix(s.getNode())) + firstLetterUpperCase(s.getId()) + "Data"; } else { return firstLetterUpperCase(s.getId()) + "Data"; } } + private static TypeMirror createCacheClassType(CacheExpression cache) { + return new GeneratedTypeMirror("", createCacheClassName(cache)); + } + + private static String createCacheClassName(CacheExpression cache) { + return firstLetterUpperCase(cache.getSharedGroup()) + "SharedWrapper"; + } + private String createSpecializationFieldName(SpecializationData s) { - if (hasMultipleNodes()) { - return firstLetterLowerCase(getNodePrefix(s)) + "_" + firstLetterLowerCase(s.getId()) + "_cache"; + if (sharingNodes.size() > 1) { + return firstLetterLowerCase(getNodePrefix(s.getNode())) + "_" + firstLetterLowerCase(s.getId()) + "_cache"; } else { return firstLetterLowerCase(s.getId()) + "_cache"; } } - private String createFieldName(SpecializationData specialization, Parameter cacheParameter) { - if (useSpecializationClass(specialization)) { - return cacheParameter.getLocalName() + "_"; + private String createStaticInlinedCacheName(SpecializationData specialization, CacheExpression cache) { + String baseName; + String sharedName = sharedCaches.get(cache); + if (sharedName != null && specialization != null && hasCacheParentAccess(cache)) { + baseName = specialization.getId() + "_" + sharedName; + } else { + baseName = createFieldName(specialization, cache); + } + return "INLINED_" + ElementUtils.createConstantName(baseName); + } + + private String createFieldName(SpecializationData specialization, CacheExpression cache) { + String sharedName = sharedCaches.get(cache); + if (sharedName != null) { + return sharedName; + } + + if (specialization == null) { + throw new AssertionError("if specialization is null it must be shared cache"); + } + + Parameter parameter = cache.getParameter(); + if (useSpecializationClass(specialization) && cache.getInlinedNode() == null) { + return parameter.getLocalName() + "_"; } else { String prefix = ""; - if (hasMultipleNodes()) { - prefix = firstLetterLowerCase(getNodePrefix(specialization)) + "_" + firstLetterLowerCase(specialization.getId()) + "_"; - } else if (reachableSpecializations.size() > 1) { - prefix = prefix + firstLetterLowerCase(specialization.getId()) + "_"; + if (sharingNodes.size() > 1) { + prefix = firstLetterLowerCase(getNodePrefix(specialization.getNode())) + "_" + firstLetterLowerCase(specialization.getId()) + "_"; + } else if (specialization.getNode().getReachableSpecializations().size() > 1) { + prefix = firstLetterLowerCase(specialization.getId()) + "_"; } - return prefix + cacheParameter.getLocalName() + "_"; + return prefix + parameter.getLocalName() + "_"; } } - private static String getNodePrefix(SpecializationData specialization) { - String name = specialization.getNode().getNodeId(); + private static String getNodePrefix(NodeData node) { + String name = node.getNodeId(); if (name.endsWith("Node")) { name = name.substring(0, name.length() - 4); } return name; } - private String createAssumptionFieldName(SpecializationData specialization, AssumptionExpression assumption) { + private static String createAssumptionFieldName(SpecializationData specialization, AssumptionExpression assumption) { if (useSpecializationClass(specialization)) { return assumption.getId() + "_"; } else { @@ -424,6 +602,13 @@ private static String createSpecializationLocalName(SpecializationData s) { return "s" + s.getIndex() + "_"; } + private static String createSpecializationLocalOriginalName(SpecializationData s) { + if (s == null) { + return null; + } + return "s" + s.getIndex() + "_original"; + } + private static String nodeFieldName(NodeExecutionData execution) { if (execution.getChild() == null || execution.getChild().needsGeneratedField()) { return execution.getName() + NAME_SUFFIX; @@ -444,60 +629,202 @@ private static String accessNodeField(NodeExecutionData execution) { } } - /* Whether a new class should be generated for specialization instance fields. */ - private boolean useSpecializationClass(SpecializationData specialization) { - /* - * Children with node array require a final field. Therefore we need to always use a - * specialization class in this case. - */ - for (CacheExpression expression : specialization.getCaches()) { - if (expression.getDefaultExpression() == null) { - continue; + private CacheExpression lookupSharedCacheKey(CacheExpression cache) { + if (!sharedCaches.containsKey(cache)) { + return cache; + } + CacheExpression key = sharedCacheKey.get(cache); + if (key == null) { + return cache; + } + return key; + } + + private static Map computeSharedCacheKeys(Collection stateSharingNodes, Map sharedCaches) { + Map foundCaches = new LinkedHashMap<>(); + Map firstCache = new LinkedHashMap<>(); + for (NodeData n : stateSharingNodes) { + for (SpecializationData specialization : n.getReachableSpecializations()) { + // shared caches not supported with multiple instances at the moment + for (CacheExpression cache : specialization.getCaches()) { + String cacheName = sharedCaches.get(cache); + if (cacheName == null) { + continue; + } + CacheExpression key = firstCache.get(cacheName); + if (key != null) { + foundCaches.put(cache, key); + } else { + firstCache.put(cacheName, cache); + foundCaches.put(cache, cache); + } + } + } + } + return foundCaches; + } + + private boolean hasCacheParentAccess(CacheExpression cache) { + return parentInlineAccess.foundSharedParentAccess.contains(cache); + } + + private boolean hasSharedCacheDirectAccess(CacheExpression cache) { + return parentInlineAccess.foundSharedDirectAccess.contains(cache); + } + + private static final class ParentInlineData { + + final Set foundSharedParentAccess = new LinkedHashSet<>(); + final Set foundSharedDirectAccess = new LinkedHashSet<>(); + + } + + private ParentInlineData computeParentInlineAccess() { + ParentInlineData data = new ParentInlineData(); + for (NodeData n : this.sharingNodes) { + for (SpecializationData specialization : n.getReachableSpecializations()) { + // shared caches are not supported with multiple instances at the moment + boolean parentInlinedAccess = useParentInlinedAccess(specialization); + for (CacheExpression cache : specialization.getCaches()) { + if (sharedCaches.containsKey(cache) && cache.getInlinedNode() != null) { + if (parentInlinedAccess) { + data.foundSharedParentAccess.add(cache); + } else { + data.foundSharedDirectAccess.add(lookupSharedCacheKey(cache)); + } + } + } + } + } + return data; + } + + /** + * This is needed if a specialization contains both shared and non-shared inlined elements and + * at the same time requires a specialization class. So in order to pass in a single node into + * the specialization to access inlined nodes, the shared inlined nodes must use a special field + * with a configured parent class. + */ + private static boolean useParentInlinedAccess(SpecializationData specialization) { + if (!useSpecializationClass(specialization)) { + return false; + } + boolean hasSharedInlined = false; + boolean hasSpecializationClassInlined = false; + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getInlinedNode() != null) { + if (canCacheBeStoredInSpecialializationClass(cache)) { + hasSpecializationClassInlined = true; + } else if (cache.getSharedGroup() != null) { + hasSharedInlined = true; + } } - if (sharedCaches.containsKey(expression)) { - return false; + if (hasSharedInlined && hasSpecializationClassInlined) { + return true; } - if (isNodeInterfaceArray(expression.getDefaultExpression().getResolvedType())) { + } + return false; + } + + /* Whether a new class should be generated for specialization instance fields. */ + public static boolean useSpecializationClass(SpecializationData specialization) { + if (shouldUseSpecializationClassBySize(specialization)) { + return true; + } else { + if (specialization.hasMultipleInstances()) { + // we need a data class if we need to support multiple specialization instances + // we need a place to store the next pointer. return true; } + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isEncodedEnum()) { + continue; + } + if (!canCacheBeStoredInSpecialializationClass(cache)) { + continue; + } + if (!cache.isNeverDefault()) { + /* + * If we do not know whether a cache initializer is non-default we must use a + * specialization class because otherwise we cannot guarantee a thread-safe + * initialization. + */ + return true; + } + } + return false; } + } + + public static boolean shouldUseSpecializationClassBySize(SpecializationData specialization) { + SpecializationClassSizeEstimate result = computeSpecializationClassSizeEstimate(specialization); + return result.sizeWithClass < result.sizeWithoutClass; + } - int size = 0; - for (CacheExpression expression : specialization.getCaches()) { - if (expression.isAlwaysInitialized()) { - // no space needed + private static SpecializationClassSizeEstimate computeSpecializationClassSizeEstimate(SpecializationData specialization) { + boolean needsNode = specializationClassIsNode(specialization); + int fieldsSize = 0; + int stateBits = 0; + for (CacheExpression cache : specialization.getCaches()) { + if (!canCacheBeStoredInSpecialializationClass(cache)) { continue; } - TypeMirror type = expression.getParameter().getType(); - if (isPrimitive(type)) { - switch (type.getKind()) { - case BOOLEAN: - case BYTE: - size++; - break; - case CHAR: - case SHORT: - size += 2; - break; - case INT: - case FLOAT: - size += 4; - break; - case LONG: - case DOUBLE: - size += 8; - break; + if (cache.getInlinedNode() != null) { + for (InlineFieldData field : cache.getInlinedNode().getFields()) { + if (field.isState()) { + stateBits += field.getBits(); + } else { + fieldsSize += ElementUtils.getCompressedReferenceSize(field.getType()); + } } } else { - size += 4; + TypeMirror type = cache.getParameter().getType(); + fieldsSize += ElementUtils.getCompressedReferenceSize(type); } } - // if we exceed the size of two references we generate a class - if (size > 8 && !hasMultipleNodes()) { + // for a specialization class we always need to create all the state ints, even if they are + // unused + int stateBytesByInt = (int) Math.ceil((double) stateBits / 32) * 4; + // without a specialization class we can compress somewhat so we use byte granularity. + int stateBytesByByte = (int) Math.ceil((double) stateBits / 8); + + int instanceOverhead = ElementUtils.COMPRESSED_HEADER_SIZE; + if (needsNode) { + instanceOverhead += ElementUtils.COMPRESSED_POINTER_SIZE; // parent pointer + } + if (specialization.hasMultipleInstances()) { + instanceOverhead += ElementUtils.COMPRESSED_POINTER_SIZE; // next pointer; + } + int sizeWithClass = ElementUtils.COMPRESSED_POINTER_SIZE + (int) ((instanceOverhead + fieldsSize + stateBytesByInt) * specialization.getActivationProbability()); + int sizeWithoutClass = fieldsSize + stateBytesByByte; + + return new SpecializationClassSizeEstimate(sizeWithClass, sizeWithoutClass); + } + + static class SpecializationClassSizeEstimate { + + final int sizeWithClass; + final int sizeWithoutClass; + + SpecializationClassSizeEstimate(int sizeWithClass, int sizeWithoutClass) { + this.sizeWithClass = sizeWithClass; + this.sizeWithoutClass = sizeWithoutClass; + } + + } + + static boolean canCacheBeStoredInSpecialializationClass(CacheExpression cache) { + if (cache.isBind()) { + return false; + } else if (cache.isAlwaysInitialized()) { + return false; + } else if (cache.getSharedGroup() != null) { + return false; + } else if (cache.isEagerInitialize()) { + return false; + } else { return true; } - // we need a data class if we need to support multiple specialization instances - return specialization.getMaximumNumberOfInstances() > 1; } private static boolean needsFrameToExecute(List specializations) { @@ -514,65 +841,29 @@ private static String createImplicitTypeStateLocalName(Parameter execution) { return name + "Cast" + execution.getSpecification().getExecution().getIndex(); } - private static boolean mayBeExcluded(SpecializationData specialization) { - return !specialization.getExceptions().isEmpty() || !specialization.getExcludedBy().isEmpty(); + private static boolean hasExcludeBit(SpecializationData specialization) { + return !specialization.getExceptions().isEmpty(); } - public CodeTypeElement create(CodeTypeElement clazz) { - if (primaryNode) { - for (NodeChildData child : node.getChildren()) { - clazz.addOptional(createAccessChildMethod(child, false)); - } - - for (NodeFieldData field : node.getFields()) { - if (!field.isGenerated()) { - continue; - } - - Set fieldModifiers; - if (field.isSettable()) { - fieldModifiers = modifiers(PRIVATE); - } else { - fieldModifiers = modifiers(PRIVATE, FINAL); - } - clazz.add(new CodeVariableElement(fieldModifiers, field.getType(), field.getName())); - - if (field.getGetter() != null && field.getGetter().getModifiers().contains(Modifier.ABSTRACT)) { - CodeExecutableElement method = CodeExecutableElement.clone(field.getGetter()); - method.getModifiers().remove(Modifier.ABSTRACT); - method.createBuilder().startReturn().string("this.").string(field.getName()).end(); - clazz.add(method); - } - - if (field.isSettable()) { - CodeExecutableElement method = CodeExecutableElement.clone(field.getSetter()); - method.renameArguments(field.getName()); - method.getModifiers().remove(Modifier.ABSTRACT); - method.createBuilder().startStatement().string("this.").string(field.getName()).string(" = ", field.getName()).end(); - clazz.add(method); - } - } - for (ExecutableElement superConstructor : GeneratorUtils.findUserConstructors(node.getTemplateType().asType())) { - clazz.add(createNodeConstructor(clazz, superConstructor)); - } - - for (NodeExecutionData execution : node.getChildExecutions()) { - if (execution.getChild() != null && execution.getChild().needsGeneratedField()) { - clazz.add(createNodeField(PRIVATE, execution.getNodeType(), nodeFieldName(execution), - types.Node_Child)); - } - } - } - - createFields(clazz); + private static boolean hasExcludes(SpecializationData specialization) { + return !specialization.getExceptions().isEmpty() || !specialization.getReplacedBy().isEmpty(); + } + public CodeTypeElement create(CodeTypeElement clazz) { TypeMirror genericReturnType = node.getPolymorphicExecutable().getReturnType(); - List executableTypes = filterExecutableTypes(node.getExecutableTypes(), - reachableSpecializations); + List executableTypes = filterExecutableTypes(node.getExecutableTypes(), node.getReachableSpecializations()); List genericExecutableTypes = new ArrayList<>(); List specializedExecutableTypes = new ArrayList<>(); List voidExecutableTypes = new ArrayList<>(); + AnnotationMirror nodeInfo = null; + try { + nodeInfo = ElementUtils.findAnnotationMirror(node.getTemplateType(), types.NodeInfo); + } catch (UnsupportedOperationException e) { + } + final String cost = nodeInfo != null ? ElementUtils.getAnnotationValue(VariableElement.class, nodeInfo, "cost").getSimpleName().toString() : null; + + GeneratorUtils.mergeSuppressWarnings(clazz, "javadoc"); for (ExecutableTypeData type : executableTypes) { if (isVoid(type.getReturnType())) { @@ -604,72 +895,244 @@ public CodeTypeElement create(CodeTypeElement clazz) { } } - SpecializationData fallback = node.getFallbackSpecialization(); - if (fallback.getMethod() != null && fallback.isReachable()) { - clazz.add(createFallbackGuard()); - } + if (node.isGenerateCached()) { + if (primaryNode) { - for (ExecutableTypeData type : genericExecutableTypes) { - wrapWithTraceOnReturn(createExecute(clazz, type, Collections. emptyList())); - } + for (NodeChildData child : node.getChildren()) { + clazz.addOptional(createAccessChildMethod(child, false)); + } - for (ExecutableTypeData type : specializedExecutableTypes) { - wrapWithTraceOnReturn(createExecute(clazz, type, genericExecutableTypes)); - } + for (NodeFieldData field : node.getFields()) { + if (!field.isGenerated()) { + continue; + } - for (ExecutableTypeData type : voidExecutableTypes) { - List genericAndSpecialized = new ArrayList<>(); - genericAndSpecialized.addAll(genericExecutableTypes); - genericAndSpecialized.addAll(specializedExecutableTypes); - wrapWithTraceOnReturn(createExecute(clazz, type, genericAndSpecialized)); - } + Set fieldModifiers; + if (field.isSettable()) { + fieldModifiers = modifiers(PRIVATE); + } else { + fieldModifiers = modifiers(PRIVATE, FINAL); + } + clazz.add(new CodeVariableElement(fieldModifiers, field.getType(), field.getName())); - clazz.addOptional(createExecuteAndSpecialize()); - final ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); - if (reportPolymorphismAction.required()) { - clazz.addOptional(createCheckForPolymorphicSpecialize(reportPolymorphismAction)); - if (requiresCacheCheck(reportPolymorphismAction)) { - clazz.addOptional(createCountCaches()); + if (field.getGetter() != null && field.getGetter().getModifiers().contains(Modifier.ABSTRACT)) { + CodeExecutableElement method = CodeExecutableElement.clone(field.getGetter()); + method.getModifiers().remove(Modifier.ABSTRACT); + method.createBuilder().startReturn().string("this.").string(field.getName()).end(); + clazz.add(method); + } + + if (field.isSettable()) { + CodeExecutableElement method = CodeExecutableElement.clone(field.getSetter()); + method.renameArguments(field.getName()); + method.getModifiers().remove(Modifier.ABSTRACT); + method.createBuilder().startStatement().string("this.").string(field.getName()).string(" = ", field.getName()).end(); + clazz.add(method); + } + } + for (ExecutableElement superConstructor : GeneratorUtils.findUserConstructors(node.getTemplateType().asType())) { + clazz.add(createNodeConstructor(clazz, superConstructor)); + } + + for (NodeExecutionData execution : node.getChildExecutions()) { + if (execution.getChild() != null && execution.getChild().needsGeneratedField()) { + clazz.add(createNodeField(PRIVATE, execution.getNodeType(), nodeFieldName(execution), + types.Node_Child)); + } + } } - } - AnnotationMirror nodeInfo = null; - try { - nodeInfo = ElementUtils.findAnnotationMirror(node.getTemplateType(), types.NodeInfo); - } catch (UnsupportedOperationException e) { - } - String cost = nodeInfo != null ? ElementUtils.getAnnotationValue(VariableElement.class, nodeInfo, "cost").getSimpleName().toString() : null; - if ((cost == null || cost.equals("MONOMORPHIC") /* the default */) && isUndeclaredOrOverrideable(clazz, "getCost")) { if (primaryNode) { - clazz.add(createGetCostMethod(false)); + if (state.activeState.getAllCapacity() > 0) { + clazz.getEnclosedElements().addAll(state.activeState.createCachedFields()); + } } - } - for (TypeMirror type : uniqueSortedTypes(expectedTypes, false)) { - if (!typeSystem.hasType(type)) { - clazz.addOptional(TypeSystemCodeGenerator.createExpectMethod(PRIVATE, typeSystem, - context.getType(Object.class), type)); + clazz.getEnclosedElements().addAll(createCachedFields(clazz)); + generateStatisticsFields(clazz); + + SpecializationData fallback = node.getFallbackSpecialization(); + if (fallback.getMethod() != null && fallback.isReachable()) { + clazz.add(createFallbackGuard()); + } + + for (ExecutableTypeData type : genericExecutableTypes) { + wrapWithTraceOnReturn(createExecute(clazz, type, Collections. emptyList(), false)); } - } - clazz.getEnclosedElements().addAll(removeThisMethods.values()); + for (ExecutableTypeData type : specializedExecutableTypes) { + wrapWithTraceOnReturn(createExecute(clazz, type, genericExecutableTypes, false)); + } + + for (ExecutableTypeData type : voidExecutableTypes) { + List genericAndSpecialized = new ArrayList<>(); + genericAndSpecialized.addAll(genericExecutableTypes); + genericAndSpecialized.addAll(specializedExecutableTypes); + wrapWithTraceOnReturn(createExecute(clazz, type, genericAndSpecialized, false)); + } + + clazz.addOptional(createExecuteAndSpecialize(false)); + final ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, node.getReachableSpecializations()); + if (reportPolymorphismAction.required()) { + clazz.addOptional(createCheckForPolymorphicSpecialize(reportPolymorphismAction, false)); + if (requiresCacheCheck(reportPolymorphismAction)) { + clazz.addOptional(createCountCaches(false)); + } + } + + if ((cost == null || cost.equals("MONOMORPHIC") /* the default */) && isUndeclaredOrOverrideable(clazz, "getCost")) { + if (primaryNode) { + clazz.add(createGetCostMethod(false)); + } + } - for (SpecializationData specialization : specializationClasses.keySet()) { - CodeTypeElement type = specializationClasses.get(specialization); - if (getInsertAccessorSet(true).contains(specialization)) { - type.add(createInsertAccessor(true)); + for (TypeMirror type : uniqueSortedTypes(expectedTypes, false)) { + if (!typeSystem.hasType(type)) { + clazz.addOptional(TypeSystemCodeGenerator.createExpectMethod(PRIVATE, typeSystem, + context.getType(Object.class), type)); + } } - if (getInsertAccessorSet(false).contains(specialization)) { - type.add(createInsertAccessor(false)); + + clazz.getEnclosedElements().addAll(removeThisMethods.values()); + + if (isGenerateIntrospection()) { + generateIntrospectionInfo(clazz, false); + } + + if (isGenerateAOT()) { + generateAOT(clazz, false); } } - if (isGenerateIntrospection()) { - generateIntrospectionInfo(clazz); + removeThisMethods.clear(); + + if (node.isGenerateInline()) { + CodeTypeElement inlined = GeneratorUtils.createClass(node, null, modifiers(PRIVATE, STATIC, FINAL), "Inlined", node.getTemplateType().asType()); + + inlined.addAnnotationMirror(new CodeAnnotationMirror(types.DenyReplace)); + + List inlinedFields = createInlineFields(false); + CodeExecutableElement constructor = inlined.add(GeneratorUtils.createConstructorUsingFields(modifiers(PRIVATE), inlined)); + CodeTreeBuilder builder = constructor.appendBuilder(); + + CodeVariableElement inlineTarget = new CodeVariableElement(types.InlineSupport_InlineTarget, "target"); + constructor.addParameter(inlineTarget); + builder.startAssert().string("target.getTargetClass().isAssignableFrom(").typeLiteral(node.getTemplateType().asType()).string(")").end(); + + if (primaryNode) { + int index = 0; + for (InlineFieldData inlinedField : inlinedFields) { + CodeVariableElement field = inlined.add(new CodeVariableElement(modifiers(PRIVATE, FINAL), inlinedField.getFieldType(), inlinedField.getName())); + + if (index < state.activeState.getSets().size()) { + CodeTreeBuilder docBuilder = field.createDocBuilder(); + docBuilder.startJavadoc(); + FlatNodeGenFactory.addStateDoc(docBuilder, state.activeState.getSets().get(index)); + docBuilder.end(); + } + + builder.startStatement(); + builder.string("this.", field.getName(), " = "); + if (inlinedField.isReference()) { + GeneratorUtils.mergeSuppressWarnings(constructor, "unchecked"); + builder.startCall(inlineTarget.getName(), "getReference").string(String.valueOf(index)).typeLiteral(inlinedField.getType()).end(); + } else if (inlinedField.isState()) { + builder.startCall(inlineTarget.getName(), "getState").string(String.valueOf(index)).string(String.valueOf(inlinedField.getBits())).end(); + } else { + builder.startCall(inlineTarget.getName(), "getPrimitive").string(String.valueOf(index)).typeLiteral(inlinedField.getFieldType()).end(); + } + builder.end(); + index++; + } + + Set expressions = new HashSet<>(); + for (Entry entry : sharedCaches.entrySet()) { + CacheExpression cache = entry.getKey(); + String fieldName = entry.getValue(); + if (expressions.contains(fieldName)) { + continue; + } + expressions.add(fieldName); + + if (cache.getInlinedNode() == null) { + continue; + } + + if (!hasSharedCacheDirectAccess(cache)) { + continue; + } + + inlined.add(createCacheInlinedField(builder, null, null, cache)); + } + } + + SpecializationData fallback = node.getFallbackSpecialization(); + if (fallback.getMethod() != null && fallback.isReachable()) { + inlined.add(createFallbackGuard()); + } + + for (SpecializationData specialization : node.getReachableSpecializations()) { + MultiStateBitSet specializationState = lookupSpecializationState(specialization); + + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getInlinedNode() == null) { + continue; + } + + if (sharedCaches.containsKey(cache) && !hasCacheParentAccess(cache)) { + // already generated + continue; + } + + inlined.add(createCacheInlinedField(builder, specialization, specializationState, cache)); + + } + } + + for (ExecutableTypeData type : genericExecutableTypes) { + wrapWithTraceOnReturn(createExecute(inlined, type, Collections. emptyList(), true)); + } + + for (ExecutableTypeData type : specializedExecutableTypes) { + wrapWithTraceOnReturn(createExecute(inlined, type, genericExecutableTypes, true)); + } + + for (ExecutableTypeData type : voidExecutableTypes) { + List genericAndSpecialized = new ArrayList<>(); + genericAndSpecialized.addAll(genericExecutableTypes); + genericAndSpecialized.addAll(specializedExecutableTypes); + wrapWithTraceOnReturn(createExecute(inlined, type, genericAndSpecialized, true)); + } + + inlined.addOptional(createExecuteAndSpecialize(true)); + + final ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, node.getReachableSpecializations()); + if (reportPolymorphismAction.required()) { + inlined.addOptional(createCheckForPolymorphicSpecialize(reportPolymorphismAction, true)); + if (requiresCacheCheck(reportPolymorphismAction)) { + inlined.addOptional(createCountCaches(true)); + } + } + + inlined.getEnclosedElements().addAll(removeThisMethods.values()); + + CodeExecutableElement isAdoptable = CodeExecutableElement.cloneNoAnnotations(ElementUtils.findExecutableElement(types.Node, "isAdoptable")); + isAdoptable.createBuilder().returnFalse(); + inlined.add(isAdoptable); + + if (isGenerateIntrospection()) { + generateIntrospectionInfo(inlined, true); + } + + if (isGenerateAOT()) { + generateAOT(inlined, true); + } + + clazz.add(inlined); } - if (isGenerateAOT()) { - generateAOT(clazz); + for (CodeTypeElement specializationClass : specializationClasses.values()) { + clazz.add(specializationClass); } if (node.isUncachable() && node.isGenerateUncached()) { @@ -727,24 +1190,218 @@ public CodeTypeElement create(CodeTypeElement clazz) { uncachedField.createInitBuilder().startNew(uncachedType).end(); } + // generate debug info + + CodeTreeBuilder debug = clazz.createDocBuilder(); + debug.startJavadoc(); + debug.string("Debug Info:
").newLine();
+
+        for (SpecializationData specialization : node.getReachableSpecializations()) {
+            debug.string("  Specialization ").javadocLink(specialization.getMethod(), null).newLine();
+            SpecializationClassSizeEstimate estimate = computeSpecializationClassSizeEstimate(specialization);
+            debug.string("    Activation probability: ").string(String.format("%.5f", specialization.getActivationProbability())).newLine();
+            debug.string("    With/without class size: ").string(String.valueOf(estimate.sizeWithClass)).string("/", String.valueOf(estimate.sizeWithoutClass), " bytes").newLine();
+        }
+        debug.string("
"); + debug.end(); + return clazz; } + private CodeVariableElement createCacheInlinedField(CodeTreeBuilder init, SpecializationData specialization, + MultiStateBitSet specializationState, CacheExpression cache) { + final Parameter parameter = cache.getParameter(); + final String fieldName = createLocalCachedInlinedName(specialization, cache); + + // for state access we need use the shared cache + CacheExpression sharedCache = lookupSharedCacheKey(cache); + + init.startStatement(); + init.string("this.", fieldName, " = "); + + init.startStaticCall(cache.getInlinedNode().getMethod()); + init.startStaticCall(types().InlineSupport_InlineTarget, "create"); + init.typeLiteral(cache.getParameter().getType()); + + boolean parentAccess = hasCacheParentAccess(cache); + + for (InlineFieldData field : sharedCache.getInlinedNode().getFields()) { + if (field.isState()) { + BitSet bitSet = allMultiState.findSet(InlinedNodeState.class, field); + + if (bitSet == null) { + bitSet = findInlinedState(specializationState, field); + + CodeVariableElement var = createStateUpdaterField(specialization, specializationState, field, specializationClasses.get(specialization).getEnclosedElements()); + init.startCall(var.getName(), "subUpdater"); + BitRange range = bitSet.getStates().queryRange(StateQuery.create(InlinedNodeState.class, field)); + init.string(String.valueOf(range.offset)); + init.string(String.valueOf(range.length)); + init.end(); + + } else { + if (specializationState != null && specializationState.findSet(InlinedNodeState.class, field) != null) { + throw new AssertionError("Inlined field in specializationState and regular state at the same time."); + } + init.startGroup(); + init.startCall(bitSet.getName() + "_", "subUpdater"); + BitRange range = bitSet.getStates().queryRange(StateQuery.create(InlinedNodeState.class, field)); + init.string(String.valueOf(range.offset)); + init.string(String.valueOf(range.length)); + init.end(); + + if (specialization != null && parentAccess) { + init.startGroup(); + init.startCall(".createParentAccessor"); + init.typeLiteral(createSpecializationClassReferenceType(specialization)); + init.end(); + init.end(); + } + init.end(); + } + } else { + + String inlinedFieldName = createCachedInlinedFieldName(specialization, cache, field); + if (specialization != null && useSpecializationClass(specialization)) { + if (parentAccess) { + init.startGroup(); + init.string("this.", inlinedFieldName); + init.startCall(".createParentAccessor"); + init.typeLiteral(createSpecializationClassReferenceType(specialization)); + init.end(); + init.end(); + } else { + init.startStaticCall(field.getFieldType(), "create"); + init.startGroup(); + init.tree(createLookupNodeType(createSpecializationClassReferenceType(specialization), specializationClasses.get(specialization).getEnclosedElements())); + init.end(); + init.doubleQuote(inlinedFieldName); + if (field.isReference()) { + init.typeLiteral(field.getType()); + } + init.end(); + } + + } else { + init.string(inlinedFieldName); + } + } + + } + init.end(); + init.end(); + init.end(); + CodeVariableElement var = new CodeVariableElement(modifiers(PRIVATE, FINAL), parameter.getType(), fieldName); + CodeTreeBuilder builder = var.createDocBuilder(); + builder.startJavadoc(); + addSourceDoc(builder, specialization, cache, null); + builder.end(); + + return var; + } + + private String createLocalCachedInlinedName(SpecializationData specialization, CacheExpression cache) { + String sharedName = sharedCaches.get(cache); + if (sharedName != null && specialization != null && hasCacheParentAccess(cache)) { + return specialization.getId().toLowerCase() + "_" + sharedName + "_"; + } else { + return createFieldName(specialization, cache); + } + } + + private String createCachedInlinedFieldName(SpecializationData specialization, CacheExpression cache, InlineFieldData field) { + return createFieldName(specialization, cache) + "_" + field.getName() + "_"; + } + + static void addStateDoc(CodeTreeBuilder docBuilder, BitSet set) { + docBuilder.string("State Info:
").newLine();
+
+        for (BitRangedState value : set.getStates().getEntries()) {
+            BitRange range = value.bitRange;
+            docBuilder.string("  ");
+            docBuilder.string(String.valueOf(range.offset));
+
+            if (range.length != 1) {
+                docBuilder.string("-").string(String.valueOf(range.offset + range.length));
+            }
+            docBuilder.string(": ");
+            value.state.addStateDoc(docBuilder);
+            docBuilder.newLine();
+        }
+
+        docBuilder.string("
"); + } + + private static void addSourceDoc(CodeTreeBuilder builder, SpecializationData specialization, CacheExpression cache, InlineFieldData inlinedField) { + builder.string("Source Info:
").newLine();
+        addCacheInfo(builder, "  ", specialization, cache, inlinedField);
+        builder.string("
"); + } + + static void addCacheInfo(CodeTreeBuilder builder, String linePrefix, + SpecializationData specialization, CacheExpression cache, InlineFieldData inlinedField) { + + Element specializationSource = resolveSpecializationSource(specialization, cache); + if (specializationSource != null) { + builder.string(linePrefix).string("Specialization: ").javadocLink(specializationSource, null); + } + if (cache != null) { + builder.newLine(); + builder.string(linePrefix).string("Parameter: "); + linkParameter(builder, cache.getParameter().getType(), cache.getParameter().getVariableElement().getSimpleName().toString()); + + if (cache.getInlinedNode() != null) { + builder.newLine(); + builder.string(linePrefix).string("Inline method: "); + builder.javadocLink(cache.getInlinedNode().getMethod(), null); + } + } + + if (inlinedField != null && !inlinedField.isState()) { + builder.newLine(); + builder.string(linePrefix).string("Inline field: "); + linkParameter(builder, inlinedField.getType(), inlinedField.getName()); + } + } + + static Element resolveSpecializationSource(SpecializationData specialization, CacheExpression cache) { + Element specializationSource; + if (specialization != null && specialization.getMethod() != null) { + specializationSource = specialization.getMethod(); + } else if (cache != null) { + specializationSource = cache.getParameter().getVariableElement().getEnclosingElement(); + } else { + specializationSource = null; + } + return specializationSource; + } + + private static void linkParameter(CodeTreeBuilder builder, TypeMirror type, String name) { + TypeElement typeElement = ElementUtils.fromTypeMirror(type); + if (typeElement != null) { + builder.javadocLink(typeElement, null); + } else { + builder.string(getSimpleName(type)); + } + builder.string(" ").string(name); + } + private static final String AOT_STATE = "$aot"; - private void generateAOT(CodeTypeElement clazz) { + private void generateAOT(CodeTypeElement clazz, boolean inlined) { TypeMirror aotProviderType = new GeneratedTypeMirror(ElementUtils.getPackageName(types.GenerateAOT_Provider), "GenerateAOT.Provider"); clazz.getImplements().add(aotProviderType); - CodeExecutableElement prepare = clazz.add(CodeExecutableElement.cloneNoAnnotations(ElementUtils.findMethod(types.GenerateAOT_Provider, "prepareForAOT"))); - prepare.renameArguments("language", "root"); + CodeExecutableElement prepare = clazz.add(CodeExecutableElement.cloneNoAnnotations( + ElementUtils.findMethod(types.GenerateAOT_Provider, "prepareForAOT", inlined ? 3 : 2))); + prepare.getModifiers().remove(Modifier.DEFAULT); GeneratorUtils.addOverride(prepare); prepare.getModifiers().remove(ABSTRACT); CodeTreeBuilder builder = prepare.createBuilder(); List filteredSpecializations = new ArrayList<>(); for (NodeData currentNode : sharingNodes) { - for (SpecializationData s : calculateReachableSpecializations(currentNode)) { + for (SpecializationData s : currentNode.getReachableSpecializations()) { if (s.getMethod() == null || !s.isPrepareForAOT()) { continue; } @@ -754,18 +1411,25 @@ private void generateAOT(CodeTypeElement clazz) { FrameState frameState = FrameState.load(this, NodeExecutionMode.SLOW_PATH, prepare); frameState.setBoolean(AOT_STATE, true); + frameState.setInlinedNode(inlined); - Map> stateGroup = new LinkedHashMap<>(); + if (inlined) { + prepare.renameArguments("language", "root", frameState.getValue(node.getChildExecutions().get(0)).getName()); + } else { + prepare.renameArguments("language", "root"); + } + + Map> stateGroup = new LinkedHashMap<>(); Set implicitCasts = new LinkedHashSet<>(); for (SpecializationData specialization : filteredSpecializations) { - for (StateBitSet set : allMultiState.getSets()) { + for (BitSet set : allMultiState.getSets()) { if (set.contains(AOT_PREPARED)) { // make sure we have an entry for a state bitset // without any specialization but only with the AOT bit set stateGroup.computeIfAbsent(set, (s) -> new ArrayList<>()); } - if (set.contains(specialization)) { + if (set.contains(StateQuery.create(SpecializationActive.class, specialization))) { stateGroup.computeIfAbsent(set, (s) -> new ArrayList<>()).add(specialization); break; } @@ -776,7 +1440,7 @@ private void generateAOT(CodeTypeElement clazz) { TypeMirror targetType = p.getType(); Collection sourceTypes = node.getTypeSystem().lookupSourceTypes(targetType); if (sourceTypes.size() > 1) { - implicitCasts.add(new TypeGuard(targetType, index)); + implicitCasts.add(new TypeGuard(node.getTypeSystem(), targetType, index)); } index++; } @@ -789,10 +1453,7 @@ private void generateAOT(CodeTypeElement clazz) { builder.string(" : ").doubleQuote("During prepare AST lock must be held."); builder.end(); - builder.tree(multiState.createLoad(frameState, AOT_PREPARED)); - builder.tree(multiState.createLoad(frameState, filteredSpecializations.toArray())); - - for (StateBitSet set : multiState.getSets()) { + for (BitSet set : multiState.getSets()) { if (set.contains(AOT_PREPARED)) { builder.startIf(); builder.tree(set.createContains(frameState, AOT_PREPARED)); @@ -803,10 +1464,14 @@ private void generateAOT(CodeTypeElement clazz) { } } - List bulkStateSet = new ArrayList<>(); + List bulkStateSetGuards = new ArrayList<>(); for (SpecializationData specialization : filteredSpecializations) { + if (hasMultipleNodes()) { + builder.startBlock(); // local can overlap between nodes + } + // we need to copy otherwise local variables of caches may conflict. FrameState innerFrameState = frameState.copy(); @@ -835,7 +1500,7 @@ private void generateAOT(CodeTypeElement clazz) { List usedGuards = new ArrayList<>(); for (GuardExpression guard : specialization.getGuards()) { if (guardNeedsStateBit(specialization, guard)) { - bulkStateSet.add(guard); + bulkStateSetGuards.add(guard); } if (specialization.isDynamicParameterBound(guard.getExpression(), true)) { /* @@ -846,15 +1511,11 @@ private void generateAOT(CodeTypeElement clazz) { usedGuards.add(guard); } - for (GuardExpression guard : usedGuards) { - Set caches = specialization.getBoundCaches(guard.getExpression(), true); - tripples.addAll(initializeCaches(innerFrameState, NodeExecutionMode.SLOW_PATH, specializationGroup, caches, true, false)); - tripples.add(createMethodGuardCheck(innerFrameState, specialization, guard, NodeExecutionMode.SLOW_PATH)); - } + tripples.addAll(createMethodGuardChecks(innerFrameState, specializationGroup, usedGuards, NodeExecutionMode.SLOW_PATH)); - BlockState state = IfTriple.materialize(builder, tripples, false); + BlockState blockState = IfTriple.materialize(builder, tripples, false); - builder.tree(createSpecialize(builder, innerFrameState, specializationGroup, specialization, true)); + builder.tree(createSpecialize(builder, innerFrameState, null, specializationGroup, specialization, true)); for (CacheExpression cache : specialization.getCaches()) { if (cache.isAlwaysInitialized()) { @@ -871,11 +1532,11 @@ private void generateAOT(CodeTypeElement clazz) { */ boolean cachedLibrary = cache.isCachedLibrary(); if (cachedLibrary) { - builder.startIf().tree(createCacheReference(innerFrameState, specialization, cache)).instanceOf(aotProviderType).end().startBlock(); + builder.startIf().tree(createCacheAccess(innerFrameState, specialization, cache, null)).instanceOf(aotProviderType).end().startBlock(); } if (NodeCodeGenerator.isSpecializedNode(cache.getParameter().getType()) || cachedLibrary) { builder.startAssert().startStaticCall(types.NodeUtil, "assertRecursion"); - builder.tree(createCacheReference(innerFrameState, specialization, cache)); + builder.tree(createCacheAccess(innerFrameState, specialization, cache, null)); /* * We allow a single recursion level only for AOT preparation. It is important * that we only assert recursion for @Cached fields as regular AST children can @@ -889,9 +1550,19 @@ private void generateAOT(CodeTypeElement clazz) { builder.startStatement(); builder.string("("); builder.cast(aotProviderType); - builder.tree(createCacheReference(innerFrameState, specialization, cache)); + builder.tree(createCacheAccess(innerFrameState, specialization, cache, null)); builder.string(")"); - builder.string(".prepareForAOT(language, root)"); + builder.startCall(".prepareForAOT"); + builder.string("language").string("root"); + + if (cache.getInlinedNode() != null) { + if (frameState.isInlinedNode()) { + builder.tree(innerFrameState.getValue(INLINED_NODE_INDEX).createReference()); + } else { + builder.string("this"); + } + } + builder.end(); builder.end(); } if (cachedLibrary) { @@ -899,103 +1570,85 @@ private void generateAOT(CodeTypeElement clazz) { } } - if (usedGuards.isEmpty()) { - bulkStateSet.add(specialization); - } else { - builder.tree(multiState.createSet(innerFrameState, new SpecializationData[]{specialization}, true, false)); - } - builder.end(state.blockCount); + builder.tree(multiState.createSet(innerFrameState, null, StateQuery.create(SpecializationActive.class, specialization), true, true)); + builder.end(blockState.blockCount); + if (hasMultipleNodes()) { + builder.end(); + } } - List allElements = new ArrayList<>(); - allElements.add(AOT_PREPARED); - allElements.addAll(bulkStateSet); - allElements.addAll(implicitCasts); - - builder.tree(multiState.createSet(frameState, allElements.toArray(), true, true)); + StateTransaction transaction = new StateTransaction(); + builder.tree(multiState.createForceLoad(frameState, + AOT_PREPARED, StateQuery.create(SpecializationActive.class, filteredSpecializations), + StateQuery.create(GuardActive.class, bulkStateSetGuards), StateQuery.create(ImplicitCastState.class, implicitCasts))); + builder.tree(multiState.createSet(frameState, transaction, AOT_PREPARED, true, false)); + builder.tree(multiState.createSet(frameState, transaction, StateQuery.create(GuardActive.class, bulkStateSetGuards), true, false)); + builder.tree(multiState.createSet(frameState, transaction, StateQuery.create(ImplicitCastState.class, implicitCasts), true, false)); + builder.tree(multiState.persistTransaction(frameState, transaction)); - if (!needsAOTReset()) { + if (!needsAOTReset(node, sharingNodes)) { return; } CodeExecutableElement reset = clazz.add(new CodeExecutableElement(modifiers(PRIVATE), context.getType(void.class), "resetAOT_")); frameState = FrameState.load(this, NodeExecutionMode.FAST_PATH, reset); - reset.getModifiers().remove(ABSTRACT); - builder = reset.createBuilder(); - - for (StateBitSet set : multiState.all) { - if (set.contains(AOT_PREPARED)) { - builder.tree(set.createLoad(frameState)); - builder.startIf(); - builder.tree(set.createNotContains(frameState, AOT_PREPARED)); - builder.end().startBlock(); - builder.returnDefault(); - builder.end(); - } - break; + frameState.setInlinedNode(inlined); + if (inlined) { + reset.addParameter(new CodeVariableElement(types.Node, frameState.getValue(node.getChildExecutions().get(0)).getName())); } - for (SpecializationData specialization : filteredSpecializations) { - List resetCaches = new ArrayList<>(); - for (CacheExpression cache : specialization.getCaches()) { - if (cache.isAlwaysInitialized()) { - continue; - } - if (types.Profile != null && ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile)) { - resetCaches.add(cache); - } - } + reset.getModifiers().remove(ABSTRACT); + builder = reset.createBuilder(); - if (resetCaches.size() > 0) { - builder.tree(multiState.createLoadAll(frameState, specialization)); - builder.startIf().tree(multiState.createContainsAll(frameState, new Object[]{specialization})).end(); - builder.startBlock(); - for (CacheExpression cache : resetCaches) { - builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache)); - builder.string(".reset()"); - builder.end(); - } + for (BitSet set : multiState.all) { + if (set.contains(AOT_PREPARED)) { + builder.tree(set.createLoad(frameState)); + builder.startIf(); + builder.tree(set.createNotContains(frameState, AOT_PREPARED)); + builder.end().startBlock(); + builder.returnDefault(); builder.end(); } + break; } - for (StateBitSet set : multiState.getSets()) { + for (BitSet set : multiState.getSets()) { builder.tree(set.createSetZero(frameState, true)); } - if (requiresExclude()) { - builder.tree(exclude.createSetZero(frameState, true)); - } - /* - * It is important that we reset the state first before we clear the caches for initialized - * libraries. Otherwise we might observe an enabled specialization without initialized cache - * on the fast-path. - */ for (SpecializationData specialization : filteredSpecializations) { - boolean resetSpecializationClass = false; - for (CacheExpression cache : specialization.getCaches()) { - if (cache.isAlwaysInitialized()) { - continue; - } - if (cache.isCachedLibraryManuallyDispatched()) { - if (useSpecializationClass(specialization)) { - resetSpecializationClass = true; - break; - } - builder.startStatement(); - builder.tree(createCacheReference(frameState, specialization, cache)).string(" = null"); - builder.end(); - } - } - - if (resetSpecializationClass || specialization.hasMultipleInstances()) { + if (useSpecializationClass(specialization)) { builder.startStatement(); - builder.string("this.", createSpecializationFieldName(specialization)); - builder.string(" = null"); + builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, null, singleString("null"))); builder.end(); + } else { + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isAlwaysInitialized()) { + continue; + } else if (cache.isEagerInitialize()) { + continue; + } else if (cache.isBind()) { + continue; + } + if (types.Profile != null && + (ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile) || ElementUtils.isAssignable(cache.getParameter().getType(), types.InlinedProfile))) { + builder.startStatement(); + builder.tree(createCacheAccess(frameState, specialization, cache, null)); + builder.startCall(".reset"); + if (cache.getInlinedNode() != null) { + builder.tree(createNodeAccess(frameState, specialization)); + } + builder.end(); + builder.end(); + } else if (cache.getInlinedNode() == null) { + builder.startStatement(); + builder.tree(createCacheAccess(frameState, specialization, cache, singleString(ElementUtils.defaultValue(cache.getParameter().getType())))); + builder.end(); + } + } } } + } public List createUncachedFields() { @@ -1013,7 +1666,8 @@ public CodeTree createInitializeCaches(SpecializationData specialization, List triples = persistAndInitializeCache(frameState, specialization, cache, false, true); + List triples = new ArrayList<>(); + triples.addAll(persistAndInitializeCache(frameState, NodeExecutionMode.SLOW_PATH, specialization, cache, false, true)); IfTriple.materialize(b, triples, true); } return b.build(); @@ -1044,7 +1698,7 @@ private static ReportPolymorphismAction reportPolymorphismAction(NodeData node, return new ReportPolymorphismAction(node.isReportPolymorphism(), reportMegamorphism); } - private void generateIntrospectionInfo(CodeTypeElement clazz) { + private void generateIntrospectionInfo(CodeTypeElement clazz, boolean inlined) { clazz.getImplements().add(new GeneratedTypeMirror(ElementUtils.getPackageName(types.Introspection_Provider), "Introspection.Provider")); CodeExecutableElement reflection = new CodeExecutableElement(modifiers(PUBLIC), types.Introspection, "getIntrospectionData"); GeneratorUtils.addOverride(reflection); @@ -1067,21 +1721,32 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { boolean needsRewrites = needsRewrites(); FrameState frameState = FrameState.load(this, NodeExecutionMode.SLOW_PATH, reflection); + frameState.setInlinedNode(inlined); + + if (inlined) { + reflection.addParameter(frameState.getValue(INLINED_NODE_INDEX).createParameter()); + } + + StateQuery specializationsActive = StateQuery.create(SpecializationActive.class, filteredSpecializations); + StateQuery specializationsExcluded = StateQuery.create(SpecializationExcluded.class, filteredSpecializations); if (needsRewrites) { - builder.tree(multiState.createLoad(frameState)); - if (requiresExclude()) { - builder.tree(exclude.createLoad(frameState)); - } + builder.tree(multiState.createLoad(frameState, specializationsActive, specializationsExcluded)); } int index = 1; for (SpecializationData specialization : filteredSpecializations) { + + FrameState innerFrameState = frameState.copy(); + builder.startStatement().string("s = ").startNewArray(objectArray, CodeTreeBuilder.singleString("3")).end().end(); builder.startStatement().string("s[0] = ").doubleQuote(specialization.getMethodName()).end(); + BlockState blocks = BlockState.NONE; if (needsRewrites) { - builder.startIf().tree(multiState.createContains(frameState, new Object[]{specialization})).end().startBlock(); + builder.startIf().tree(multiState.createContains(innerFrameState, StateQuery.create(SpecializationActive.class, specialization))).end().startBlock(); + List tripples = createFastPathNeverDefaultGuards(innerFrameState, specialization); + blocks = IfTriple.materialize(builder, tripples, false); } builder.startStatement().string("s[1] = (byte)0b01 /* active */").end(); TypeMirror listType = new DeclaredCodeTypeMirror((TypeElement) context.getDeclaredType(ArrayList.class).asElement(), Arrays.asList(context.getType(Object.class))); @@ -1093,7 +1758,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { String name = createSpecializationLocalName(specialization); if (useSpecializationClass) { - builder.tree(loadSpecializationClass(frameState, specialization)); + builder.tree(loadSpecializationClass(innerFrameState, specialization, false)); if (specialization.hasMultipleInstances()) { builder.startWhile(); @@ -1106,7 +1771,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { } builder.startStatement().startCall("cached", "add"); - builder.startStaticCall(context.getType(Arrays.class), "asList"); + builder.startStaticCall(context.getType(Arrays.class), "asList"); for (CacheExpression cache : specialization.getCaches()) { if (cache.isAlwaysInitialized()) { continue; @@ -1116,7 +1781,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { builder.staticReference(createLibraryConstant(constants, cache.getParameter().getType())); builder.startCall(".getUncached").end(); } else { - builder.tree(createCacheReference(frameState, specialization, cache)); + builder.tree(createCacheAccess(innerFrameState, specialization, cache, null)); } builder.end(); } @@ -1132,15 +1797,34 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { builder.statement("s[2] = cached"); } + if (needsRewrites) { + builder.end(blocks.blockCount); builder.end(); - if (mayBeExcluded(specialization)) { - builder.startElseIf().tree(exclude.createContains(frameState, new Object[]{specialization})).end().startBlock(); + + builder.startIf().string("s[1] == null").end().startBlock(); + + List excludeTripples = new ArrayList<>(); + if (hasExcludeBit(specialization)) { + CodeTree excludeCheck = multiState.createNotContains(frameState, StateQuery.create(SpecializationExcluded.class, specialization)); + excludeTripples.add(0, new IfTriple(null, excludeCheck, null)); + } + if (hasExcludes(specialization)) { + CodeTree excludeCheck = multiState.createContains(frameState, StateQuery.create(SpecializationActive.class, specialization.getReplacedBy())); + excludeTripples.add(0, new IfTriple(null, excludeCheck, null)); + } + BlockState excludeBlocks = BlockState.NONE; + if (!excludeTripples.isEmpty()) { + excludeBlocks = IfTriple.materialize(builder, excludeTripples, false); builder.startStatement().string("s[1] = (byte)0b10 /* excluded */").end(); - builder.end(); + builder.end(excludeBlocks.blockCount); + builder.startElseBlock(); } - builder.startElseBlock(); builder.startStatement().string("s[1] = (byte)0b00 /* inactive */").end(); + + if (!excludeTripples.isEmpty()) { + builder.end(); + } builder.end(); } builder.startStatement().string("data[", String.valueOf(index), "] = s").end(); @@ -1152,18 +1836,13 @@ private void generateIntrospectionInfo(CodeTypeElement clazz) { clazz.add(reflection); } - private void createFields(CodeTypeElement clazz) { - if (primaryNode) { - if (multiState.getAllCapacity() > 0) { - multiState.declareFields(clazz); - } - - if (exclude.getCapacity() > 0) { - exclude.declareFields(clazz); - } - } + private List createCachedFields(CodeTypeElement baseType) { + List nodeElements = new ArrayList<>(); - if (primaryNode && !sharedCaches.isEmpty()) { + if (primaryNode) { + /* + * We only generated shared cached fields once for the primary node. + */ Set expressions = new HashSet<>(); for (Entry entry : sharedCaches.entrySet()) { CacheExpression cache = entry.getKey(); @@ -1171,62 +1850,22 @@ private void createFields(CodeTypeElement clazz) { if (expressions.contains(fieldName)) { continue; } - if (cache.isAlwaysInitialized()) { - continue; - } expressions.add(fieldName); - Parameter parameter = cache.getParameter(); - TypeMirror type = parameter.getType(); - Modifier visibility = Modifier.PRIVATE; - - CodeVariableElement cachedField; - if (isAssignable(type, types.NodeInterface) && cache.isAdopt()) { - cachedField = createNodeField(visibility, type, fieldName, types.Node_Child); - } else if (isNodeInterfaceArray(type) && cache.isAdopt()) { - cachedField = createNodeField(visibility, type, fieldName, types.Node_Children); - } else { - cachedField = createNodeField(visibility, type, fieldName, null); - AnnotationMirror mirror = findAnnotationMirror(parameter.getVariableElement().getAnnotationMirrors(), types.Cached); - int dimensions = mirror == null ? 0 : getAnnotationValue(Integer.class, mirror, "dimensions"); - setFieldCompilationFinal(cachedField, dimensions); - } - clazz.getEnclosedElements().add(cachedField); + + createCachedFieldsImpl(nodeElements, nodeElements, null, null, cache); } } - for (SpecializationData specialization : reachableSpecializations) { - List fields = new ArrayList<>(); + for (SpecializationData specialization : node.getReachableSpecializations()) { boolean useSpecializationClass = useSpecializationClass(specialization); + MultiStateBitSet specializationState = lookupSpecializationState(specialization); + List specializationClassElements = useSpecializationClass ? new ArrayList<>() : nodeElements; for (CacheExpression cache : specialization.getCaches()) { - if (cache.isAlwaysInitialized()) { - // no field required for fast path caches. - continue; - } - - String sharedName = sharedCaches.get(cache); - if (sharedName != null) { + if (sharedCaches.containsKey(cache) && !hasCacheParentAccess(cache)) { continue; } - - Parameter parameter = cache.getParameter(); - String fieldName = createFieldName(specialization, parameter); - TypeMirror type = parameter.getType(); - Modifier visibility = useSpecializationClass ? null : Modifier.PRIVATE; - CodeVariableElement cachedField; - if (isAssignable(type, types.NodeInterface) && cache.isAdopt()) { - cachedField = createNodeField(visibility, type, fieldName, types.Node_Child); - } else if (isNodeInterfaceArray(type) && cache.isAdopt()) { - cachedField = createNodeField(visibility, type, fieldName, types.Node_Children); - } else { - cachedField = createNodeField(visibility, type, fieldName, null); - if (cache.isCached()) { - AnnotationMirror mirror = cache.getMessageAnnotation(); - int dimensions = getAnnotationValue(Integer.class, mirror, "dimensions"); - setFieldCompilationFinal(cachedField, dimensions); - } - } - fields.add(cachedField); + createCachedFieldsImpl(nodeElements, specializationClassElements, specialization, specializationState, cache); } for (AssumptionExpression assumption : specialization.getAssumptionExpressions()) { @@ -1250,63 +1889,407 @@ private void createFields(CodeTypeElement clazz) { } else { assumptionField = createNodeField(PRIVATE, type, fieldName, null); } + addCompilationFinalAnnotation(assumptionField, compilationFinalDimensions); - setFieldCompilationFinal(assumptionField, compilationFinalDimensions); - - fields.add(assumptionField); + if (useSpecializationClass) { + specializationClassElements.add(assumptionField); + } else { + nodeElements.add(assumptionField); + } } if (useSpecializationClass) { - TypeMirror baseType; - boolean useNode = specializationClassIsNode(specialization); - if (useNode) { - baseType = types.Node; + createSpecializationClass(baseType, specialization, specializationState, specializationClassElements); + + // force creating the specialization class. + CodeVariableElement specializationClassVar = createNodeField(PRIVATE, createSpecializationClassReferenceType(specialization), + createSpecializationFieldName(specialization), null); + + if (specializationClassIsNode(specialization)) { + specializationClassVar.getAnnotationMirrors().add(new CodeAnnotationMirror(types().Node_Child)); } else { - baseType = context.getType(Object.class); + specializationClassVar.getAnnotationMirrors().add(new CodeAnnotationMirror(types().CompilerDirectives_CompilationFinal)); } - String typeName = createSpecializationTypeName(specialization); - CodeTypeElement cacheType = GeneratorUtils.createClass(node, null, modifiers(PRIVATE, FINAL, - STATIC), createSpecializationTypeName(specialization), baseType); + nodeElements.add(specializationClassVar); + } - TypeMirror referenceType = new GeneratedTypeMirror("", typeName); + } + return nodeElements; + } - DeclaredType annotationType; - if (useNode) { - annotationType = types.Node_Child; - if (specialization.getMaximumNumberOfInstances() > 1) { - cacheType.add(createNodeField(null, referenceType, "next_", types.Node_Child)); - } + private static boolean needsUpdater(SpecializationData specialization) { + if (!specialization.getNode().isGenerateCached()) { + return false; + } + return needsDuplicationCheck(specialization); + } + + private static boolean needsDuplicationCheck(SpecializationData specialization) { + if (specialization.hasMultipleInstances()) { + return true; + } else if (specialization.isGuardBindsCache()) { + return true; + } + return false; + } + + private CodeTypeElement createCacheClass(CacheExpression cache, CodeVariableElement wrappedField, boolean needsAdoption) { + TypeMirror baseType; + if (needsAdoption) { + baseType = types.Node; + } else { + baseType = context.getType(Object.class); + } + CodeTypeElement specializationClass = GeneratorUtils.createClass(node, null, modifiers(PRIVATE, FINAL, STATIC), + createCacheClassName(cache), baseType); + specializationClass.getAnnotationMirrors().add(new CodeAnnotationMirror(types.DenyReplace)); + specializationClass.add(wrappedField); + wrappedField.setName("delegate"); + + return specializationClass; + } + + @SuppressWarnings("unchecked") + private CodeTree createLookupNodeType(TypeMirror lookupType, List elements) { + List enclosingElements = (List) elements; + ExecutableElement found = null; + for (ExecutableElement method : ElementFilter.methodsIn(enclosingElements)) { + if (method.getSimpleName().toString().equals("lookup_")) { + found = method; + break; + } + } + + if (found == null) { + found = createLookupMethod(); + enclosingElements.add(found); + } + return createLookupCall(lookupType); + } + + private static CodeTree createLookupCall(TypeMirror type) { + return CodeTreeBuilder.createBuilder().startStaticCall(type, "lookup_").end().build(); + } + + private ExecutableElement createLookupMethod() { + CodeExecutableElement method = new CodeExecutableElement(modifiers(PRIVATE, STATIC), context.getType(Lookup.class), "lookup_"); + CodeTreeBuilder builder = method.createBuilder(); + builder.startReturn().startStaticCall(context.getType(MethodHandles.class), "lookup").end().end(); + return method; + } + + private String createSpecializationClassUpdaterName(SpecializationData specialization) { + return ElementUtils.createConstantName(createSpecializationFieldName(specialization)) + "_UPDATER"; + } + + private void createSpecializationClass(CodeTypeElement enclosingType, SpecializationData specialization, + MultiStateBitSet specializationState, + List specializationClassElements) { + CodeTypeElement specializationClass = specializationClasses.get(specialization); + if (specializationClass != null) { + return; + } + + if (specializationClassElements.isEmpty() && specializationState != null && specializationState.getCapacity() == 0) { + throw new AssertionError("Should not create an empty specialization class."); + } + + boolean useNode = specializationClassIsNode(specialization); + TypeMirror baseType; + if (useNode) { + baseType = types.Node; + } else { + baseType = context.getType(Object.class); + } + + specializationClass = GeneratorUtils.createClass(node, null, modifiers(PRIVATE, FINAL, STATIC), + createSpecializationTypeName(specialization), baseType); + specializationClass.getAnnotationMirrors().add(new CodeAnnotationMirror(types.DenyReplace)); + specializationClasses.put(specialization, specializationClass); + + TypeMirror referenceType = createSpecializationClassReferenceType(specialization); + if (needsUpdater(specialization) && enclosingType != null) { + TypeMirror fieldType = new DeclaredCodeTypeMirror(context.getTypeElement(types.InlineSupport_ReferenceField), Arrays.asList(referenceType)); + CodeVariableElement updater = new CodeVariableElement(modifiers(STATIC, FINAL), fieldType, createSpecializationClassUpdaterName(specialization)); + CodeTreeBuilder init = updater.createInitBuilder(); + init.startStaticCall(types.InlineSupport_ReferenceField, "create"); + init.startStaticCall(context.getType(MethodHandles.class), "lookup").end(); + init.doubleQuote(createSpecializationFieldName(specialization)); + init.typeLiteral(referenceType); + init.end(); + enclosingType.getEnclosedElements().add(updater); + } + + DeclaredType annotationType; + if (useNode) { + annotationType = types.Node_Child; + CodeExecutableElement getNodeCost = new CodeExecutableElement(modifiers(PUBLIC), types.NodeCost, "getCost"); + getNodeCost.createBuilder().startReturn().staticReference(types.NodeCost, "NONE").end(); + specializationClass.add(getNodeCost); + } else { + annotationType = types.CompilerDirectives_CompilationFinal; + } + + if (specialization.getMaximumNumberOfInstances() > 1) { + CodeVariableElement var = createNodeField(null, referenceType, "next_", annotationType); + if (annotationType != types.Node_Child) { + var.getModifiers().add(Modifier.FINAL); + } + specializationClass.add(var); + } + + specializationClass.add(GeneratorUtils.createConstructorUsingFields(modifiers(), specializationClass)); + + if (specializationState != null) { + specializationClass.addAll(specializationState.createCachedFields()); + } + + specializationClass.getEnclosedElements().addAll(specializationClassElements); + + if (specialization.hasMultipleInstances() && !specialization.getAssumptionExpressions().isEmpty()) { + CodeExecutableElement remove = specializationClass.add(new CodeExecutableElement(referenceType, "remove")); + remove.addParameter(new CodeVariableElement(referenceType, "search")); + CodeTreeBuilder builder = remove.createBuilder(); + builder.declaration(referenceType, "newNext", "this.next_"); + builder.startIf().string("newNext != null").end().startBlock(); + builder.startIf().string("search == newNext").end().startBlock(); + builder.statement("newNext = newNext.next_"); + builder.end().startElseBlock(); + builder.statement("newNext = newNext.remove(search)"); + builder.end(); + builder.end(); + + builder.declaration(referenceType, "copy", builder.create().startNew(referenceType).string("newNext").end()); + for (Element element : specializationClassElements) { + String name = element.getSimpleName().toString(); + builder.startStatement().string("copy.", name, " = this.", name).end(); + } + builder.startReturn().string("copy").end(); + } + } + + private TypeMirror createSpecializationClassReferenceType(SpecializationData specialization) { + CodeTypeElement type = specializationClasses.get(specialization); + if (type == null) { + TypeMirror baseType = specializationClassIsNode(specialization) ? types.Node : context.getType(Object.class); + return new GeneratedTypeMirror("", createSpecializationTypeName(specialization), baseType); + } + return new GeneratedTypeMirror("", type.getSimpleName().toString(), type.getSuperclass()); + } + + private final Map specializationStates = new HashMap<>(); + + private MultiStateBitSet lookupSpecializationState(SpecializationData specialization) { + MultiStateBitSet specializationState = specializationStates.get(specialization); + if (!specializationStates.containsKey(specialization)) { + BitStateList list = computeSpecializationState(specialization); + if (list.getBitCount() > 0) { + specializationState = createMultiStateBitset(ElementUtils.firstLetterLowerCase(specialization.getId()) + "_", specialization.getNode(), list); + } + specializationStates.put(specialization, specializationState); + } + return specializationState; + } + + private void createCachedFieldsImpl( + List nodeElements, + List specializationClassElements, + SpecializationData specialization, + MultiStateBitSet specializationState, + CacheExpression cache) { + if (cache.isAlwaysInitialized()) { + return; + } else if (cache.isEncodedEnum()) { + return; + } + CacheExpression sharedCache = lookupSharedCacheKey(cache); + InlinedNodeData inline = sharedCache.getInlinedNode(); + + if (inline != null) { + boolean parentAccess = hasCacheParentAccess(cache); + + Parameter parameter = cache.getParameter(); + String fieldName = createStaticInlinedCacheName(specialization, cache); + ExecutableElement cacheMethod = cache.getInlinedNode().getMethod(); + CodeVariableElement cachedField = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), parameter.getType(), fieldName); + CodeTreeBuilder builder = cachedField.createInitBuilder(); + builder.startStaticCall(cacheMethod); + builder.startStaticCall(types().InlineSupport_InlineTarget, "create"); + builder.typeLiteral(cache.getParameter().getType()); + + for (InlineFieldData field : inline.getFields()) { + + if (field.isState()) { + BitSet specializationBitSet = findInlinedState(specializationState, field); + CodeVariableElement updaterField = createStateUpdaterField(specialization, specializationState, field, specializationClassElements); + String updaterFieldName = updaterField.getName(); + builder.startGroup(); + builder.startCall(updaterFieldName, "subUpdater"); + BitRange range = specializationBitSet.getStates().queryRange(StateQuery.create(InlinedNodeState.class, field)); + builder.string(String.valueOf(range.offset)); + builder.string(String.valueOf(range.length)); + builder.end(); - CodeExecutableElement getNodeCost = new CodeExecutableElement(modifiers(PUBLIC), - types.NodeCost, "getCost"); - getNodeCost.createBuilder().startReturn().staticReference(types.NodeCost, - "NONE").end(); - cacheType.add(getNodeCost); + if (specialization != null && parentAccess) { + builder.startCall(".createParentAccessor"); + builder.typeLiteral(createSpecializationClassReferenceType(specialization)); + builder.end(); + } + builder.end(); } else { - annotationType = types.CompilerDirectives_CompilationFinal; - if (specialization.getMaximumNumberOfInstances() > 1) { - cacheType.add(createNodeField(null, referenceType, "next_", annotationType)); + /* + * All other fields need fields to get inlined. We do not support specialization + * classes in this branch. + */ + String inlinedFieldName = createCachedInlinedFieldName(specialization, cache, field); + + TypeMirror type = field.getType(); + CodeVariableElement inlinedCacheField; + if (isAssignable(type, types().Node)) { + inlinedCacheField = createNodeField(Modifier.PRIVATE, types.Node, inlinedFieldName, types().Node_Child); + } else if (isAssignable(type, types().NodeInterface)) { + inlinedCacheField = createNodeField(Modifier.PRIVATE, types.NodeInterface, inlinedFieldName, types().Node_Child); + } else if (isNodeArray(type)) { + inlinedCacheField = createNodeField(Modifier.PRIVATE, new ArrayCodeTypeMirror(types.Node), inlinedFieldName, types().Node_Children); + } else { + inlinedCacheField = createNodeField(Modifier.PRIVATE, type, inlinedFieldName, null); + addCompilationFinalAnnotation(inlinedCacheField, field.getDimensions()); } - } + if (specialization != null && useSpecializationClass(specialization)) { + specializationClassElements.add(inlinedCacheField); + } else { + nodeElements.add(inlinedCacheField); + } + + CodeTreeBuilder javadoc = inlinedCacheField.createDocBuilder(); + javadoc.startJavadoc(); + addSourceDoc(javadoc, specialization, cache, field); + javadoc.end(); + + // never directly used, so will produce a warning. + GeneratorUtils.mergeSuppressWarnings(inlinedCacheField, "unused"); - cacheType.add(GeneratorUtils.createConstructorUsingFields(modifiers(), cacheType)); - cacheType.getEnclosedElements().addAll(fields); + builder.startStaticCall(field.getFieldType(), "create"); + if (specialization != null && useSpecializationClass(specialization)) { + builder.tree(createLookupNodeType(createSpecializationClassReferenceType(specialization), specializationClassElements)); + } else { + builder.startStaticCall(context.getType(MethodHandles.class), "lookup").end(); + } + builder.doubleQuote(inlinedFieldName); - clazz.add(createNodeField(PRIVATE, referenceType, - createSpecializationFieldName(specialization), annotationType)); + if (field.isReference()) { + builder.typeLiteral(field.getType()); + } - clazz.add(cacheType); + builder.end(); + } + } + builder.end(); + builder.end(); - specializationClasses.put(specialization, cacheType); + CodeTreeBuilder javadoc = cachedField.createDocBuilder(); + javadoc.startJavadoc(); + addSourceDoc(javadoc, specialization, cache, null); + javadoc.end(); + nodeElements.add(cachedField); + } else { + Parameter parameter = cache.getParameter(); + String fieldName = createFieldName(specialization, cache); + TypeMirror type = parameter.getType(); + + boolean useSpecializationClass = specialization != null ? useSpecializationClass(specialization) : false; + Modifier visibility = useSpecializationClass ? null : Modifier.PRIVATE; + CodeVariableElement cachedField; + boolean needsAdoption; + if (isAssignable(type, types().NodeInterface) && cache.isAdopt()) { + cachedField = createNodeField(visibility, type, fieldName, types().Node_Child); + needsAdoption = true; + } else if (isNodeArray(type) && cache.isAdopt()) { + cachedField = createNodeField(visibility, type, fieldName, types().Node_Children); + needsAdoption = true; } else { - clazz.getEnclosedElements().addAll(fields); + needsAdoption = false; + cachedField = createNodeField(visibility, type, fieldName, null); + if (cache.isCached()) { + AnnotationMirror mirror = cache.getMessageAnnotation(); + int dimensions = getAnnotationValue(Integer.class, mirror, "dimensions"); + addCompilationFinalAnnotation(cachedField, dimensions); + } + } + + CodeTreeBuilder javadoc = cachedField.createDocBuilder(); + javadoc.startJavadoc(); + addSourceDoc(javadoc, specialization, cache, null); + javadoc.end(); + + if (useCacheClass(specialization, sharedCache)) { + String name = cachedField.getSimpleName().toString(); + CodeTypeElement cacheClass = createCacheClass(sharedCache, cachedField, needsAdoption); + specializationClassElements.add(cacheClass); + GeneratedTypeMirror generatedType = new GeneratedTypeMirror("", cacheClass.getSimpleName().toString(), cacheClass.asType()); + CodeVariableElement var = new CodeVariableElement(modifiers(PRIVATE), generatedType, name); + addCompilationFinalAnnotation(var, 0, needsAdoption); + + javadoc = var.createDocBuilder(); + javadoc.startJavadoc(); + addSourceDoc(javadoc, specialization, cache, null); + javadoc.newLine().string("Note: Shared cache value requires a wrapper class for thread-safety."); + javadoc.newLine().string("Set Cached(neverDefault = true) to avoid the wrapper class."); + javadoc.end(); + specializationClassElements.add(var); + } else { + specializationClassElements.add(cachedField); + } + } + } + + private BitSet findInlinedState(MultiStateBitSet specializationState, InlineFieldData field) throws AssertionError { + BitSet bitSet = state.allState.findSet(InlinedNodeState.class, field); + if (bitSet == null) { + bitSet = specializationState.findSet(InlinedNodeState.class, field); + } + if (bitSet == null) { + throw new AssertionError("Bits not contained."); + } + return bitSet; + } + + private CodeVariableElement createStateUpdaterField(SpecializationData specialization, MultiStateBitSet specializationState, InlineFieldData field, + List specializationClassElements) { + BitSet bitSet = state.allState.findSet(InlinedNodeState.class, field); + TypeMirror nodeType; + String updaterFieldName; + + if (bitSet == null) { + bitSet = findInlinedState(specializationState, field); + if (bitSet == null) { + throw new AssertionError("Inlined bits not contained."); } + nodeType = createSpecializationClassReferenceType(specialization); + updaterFieldName = ElementUtils.createConstantName(specialization.getId() + "_" + bitSet.getName()) + "_UPDATER"; + } else { + nodeType = null; + updaterFieldName = ElementUtils.createConstantName(bitSet.getName()) + "_UPDATER"; } - generateStatisticsFields(clazz); + CodeVariableElement var = nodeConstants.updaterReferences.get(updaterFieldName); + if (var == null) { + var = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), field.getFieldType(), updaterFieldName); + CodeTreeBuilder b = var.createInitBuilder(); + b.startStaticCall(types().InlineSupport_StateField, "create"); + if (nodeType == null) { + b.startStaticCall(context.getType(MethodHandles.class), "lookup").end(); + } else { + b.tree(createLookupNodeType(nodeType, specializationClassElements)); + } + b.doubleQuote(bitSet.getName() + "_"); + b.end(); + nodeConstants.updaterReferences.put(updaterFieldName, var); + } + return var; } private void generateStatisticsFields(CodeTypeElement clazz) { @@ -1315,7 +2298,7 @@ private void generateStatisticsFields(CodeTypeElement clazz) { ArrayType stringArray = new ArrayCodeTypeMirror(context.getType(String.class)); b = clazz.add(new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), stringArray, "SPECIALIZATION_NAMES")).createInitBuilder(); b.startNewArray(stringArray, null); - for (SpecializationData specialization : reachableSpecializations) { + for (SpecializationData specialization : node.getReachableSpecializations()) { if (specialization.getMethod() == null) { continue; } @@ -1340,72 +2323,60 @@ private boolean isGenerateIntrospection() { return generatorMode == GeneratorMode.DEFAULT && primaryNode && node.isGenerateIntrospection(); } - private static final String INSERT_ACCESSOR_NAME = "insertAccessor"; - - private CodeExecutableElement createInsertAccessor(boolean array) { - CodeTypeParameterElement tVar = new CodeTypeParameterElement(CodeNames.of("T"), types.Node); - TypeMirror type = tVar.createMirror(null, null); - if (array) { - type = new ArrayCodeTypeMirror(type); + private static boolean isNodeArray(TypeMirror type) { + if (type == null) { + return false; } - CodeExecutableElement insertAccessor = new CodeExecutableElement(modifiers(FINAL), type, INSERT_ACCESSOR_NAME); - insertAccessor.getParameters().add(new CodeVariableElement(type, "node")); - insertAccessor.getTypeParameters().add(tVar); - insertAccessor.createBuilder().startReturn().string("super.insert(node)").end(); - return insertAccessor; - } - - private String useInsertAccessor(SpecializationData specialization, boolean array) { - getInsertAccessorSet(array).add(specialization); - return INSERT_ACCESSOR_NAME; + return type.getKind() == TypeKind.ARRAY && isAssignable(((ArrayType) type).getComponentType(), ProcessorContext.getInstance().getTypes().NodeInterface); } - private Set getInsertAccessorSet(boolean array) { - if (array) { - return usedInsertAccessorsArray; + private static void addCompilationFinalAnnotation(CodeVariableElement field, int dimensions, boolean adopt) { + TypeMirror type = field.getType(); + if (adopt && isAssignable(type, types().NodeInterface)) { + field.getAnnotationMirrors().add(new CodeAnnotationMirror(types().Node_Child)); + } else if (adopt && isNodeArray(type)) { + field.getAnnotationMirrors().add(new CodeAnnotationMirror(types().Node_Children)); } else { - return usedInsertAccessorsSimple; + if (field.getModifiers().contains(Modifier.FINAL) && dimensions <= 0) { + // no need for the compilation final annotation. + return; + } + CodeAnnotationMirror annotation = new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal); + if (dimensions > 0 || field.getType().getKind() == TypeKind.ARRAY) { + annotation.setElementValue(annotation.findExecutableElement("dimensions"), new CodeAnnotationValue(dimensions < 0 ? 0 : dimensions)); + } + field.getAnnotationMirrors().add(annotation); } } - private boolean isNodeInterfaceArray(TypeMirror type) { - if (type == null) { - return false; - } - return type.getKind() == TypeKind.ARRAY && isAssignable(((ArrayType) type).getComponentType(), types.NodeInterface); + private static void addCompilationFinalAnnotation(CodeVariableElement field, int dimensions) { + addCompilationFinalAnnotation(field, dimensions, false); } - private static void setFieldCompilationFinal(CodeVariableElement field, int dimensions) { - if (field.getModifiers().contains(Modifier.FINAL) && dimensions <= 0) { - // no need for the compilation final annotation. - return; - } - CodeAnnotationMirror annotation = new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal); - if (dimensions > 0 || field.getType().getKind() == TypeKind.ARRAY) { - annotation.setElementValue(annotation.findExecutableElement("dimensions"), new CodeAnnotationValue(dimensions < 0 ? 0 : dimensions)); - } - field.getAnnotationMirrors().add(annotation); + /* + * Shared caches that may be never default need a wrapper to be safely initialized on mmultiple + * threads. + */ + private static boolean useCacheClass(SpecializationData specialization, CacheExpression cache) { + return specialization == null && cache.getSharedGroup() != null && !cache.isNeverDefault() && !cache.isEncodedEnum(); } /* Specialization class needs to be a Node in such a case. */ - private boolean specializationClassIsNode(SpecializationData specialization) { - boolean useSpecializationClass = useSpecializationClass(specialization); - if (useSpecializationClass) { - for (CacheExpression cache : specialization.getCaches()) { - TypeMirror type = cache.getParameter().getType(); - if (isAssignable(type, types.NodeInterface)) { - return true; - } else if (isNodeInterfaceArray(type)) { - return true; - } + private static boolean specializationClassIsNode(SpecializationData specialization) { + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getInlinedNode() != null) { + /* + * Unfortunately inline fields only work with nodes. + */ + return true; } - } - return false; - } - - private boolean requiresExclude() { - for (SpecializationData specialization : reachableSpecializations) { - if (mayBeExcluded(specialization)) { + if (!canCacheBeStoredInSpecialializationClass(cache)) { + continue; + } + TypeMirror type = cache.getParameter().getType(); + if (isAssignable(type, types().NodeInterface)) { + return true; + } else if (isNodeArray(type)) { return true; } } @@ -1413,7 +2384,7 @@ private boolean requiresExclude() { } private List getFallbackSpecializations() { - List specializations = new ArrayList<>(reachableSpecializations); + List specializations = new ArrayList<>(node.getReachableSpecializations()); for (ListIterator iterator = specializations.listIterator(); iterator.hasNext();) { SpecializationData specialization = iterator.next(); if (specialization.isFallback()) { @@ -1425,14 +2396,13 @@ private List getFallbackSpecializations() { return specializations; } - private List getFallbackState() { - List fallbackState = new ArrayList<>(); + private List getFallbackGuards() { + List fallbackState = new ArrayList<>(); List specializations = getFallbackSpecializations(); for (SpecializationData specialization : specializations) { - fallbackState.add(specialization); for (GuardExpression guard : specialization.getGuards()) { if (guardNeedsStateBit(specialization, guard)) { - fallbackState.add(specialization.getGuards()); + fallbackState.add(guard); } } } @@ -1461,8 +2431,10 @@ private Element createFallbackGuard() { fallbackNeedsState = false; fallbackNeedsFrame = frameUsed; - Object[] fallbackSpecializations = getFallbackState().toArray(); - multiState.createLoad(frameState, fallbackSpecializations); // already loaded + multiState.createLoad(frameState, + StateQuery.create(SpecializationActive.class, getFallbackSpecializations()), + StateQuery.create(GuardActive.class, getFallbackGuards())); // already + // loaded multiState.addParametersTo(frameState, method); frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); @@ -1691,8 +2663,13 @@ private List filterCompatibleSpecializations(Collection signatureParameters = forType.getSignatureParameters(); for (int i = 0; i < signatureParameters.size(); i++) { TypeMirror evaluatedType = signatureParameters.get(i); - TypeMirror specializedType = specialization.findParameterOrDie(node.getChildExecutions().get(i)).getType(); - + Parameter specializedParameter = specialization.findParameter(node.getChildExecutions().get(i)); + TypeMirror specializedType; + if (specializedParameter == null) { + specializedType = evaluatedType; + } else { + specializedType = specializedParameter.getType(); + } if (typeSystem.lookupCast(evaluatedType, specializedType) == null && !isSubtypeBoxed(context, specializedType, evaluatedType) && !isSubtypeBoxed(context, evaluatedType, specializedType)) { // unreachable type parameter for the execute signature. For example evaluated @@ -1749,8 +2726,8 @@ private List filterCompatibleExecutableTypes(ExecutableTypeD return compatible; } - private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTypeData type, List delegateableTypes) { - final List allSpecializations = reachableSpecializations; + private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTypeData type, List delegateableTypes, boolean inlined) { + final List allSpecializations = node.getReachableSpecializations(); final List compatibleSpecializations = filterCompatibleSpecializations(allSpecializations, type); List implementedSpecializations; if (delegateableTypes.isEmpty()) { @@ -1761,6 +2738,7 @@ private CodeExecutableElement createExecute(CodeTypeElement clazz, ExecutableTyp CodeExecutableElement method = createExecuteMethod(type); FrameState frameState = FrameState.load(this, type, Integer.MAX_VALUE, NodeExecutionMode.FAST_PATH, method); + frameState.setInlinedNode(inlined); if (type.getMethod() == null) { frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); } else { @@ -1803,7 +2781,7 @@ public CodeExecutableElement createUncached() { } private CodeExecutableElement createUncachedExecute(ExecutableTypeData forType) { - final Collection allSpecializations = node.computeUncachedSpecializations(reachableSpecializations); + final Collection allSpecializations = node.computeUncachedSpecializations(node.getReachableSpecializations()); final List compatibleSpecializations = filterCompatibleSpecializations(allSpecializations, forType); CodeExecutableElement method = createExecuteMethod(forType); @@ -1881,7 +2859,7 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, boolean coversAllSpecializations = false; if (boxingEliminationEnabled) { Set optimizeTypes = new HashSet<>(); - for (SpecializationData specialization : reachableSpecializations) { + for (SpecializationData specialization : node.getReachableSpecializations()) { TypeMirror returnType = specialization.getReturnType().getType(); if (isPrimitive(returnType)) { optimizeTypes.add(returnType); @@ -1899,20 +2877,22 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, if (delegateType != null) { List delegateSpecializations = filterImplementedSpecializations( - filterCompatibleSpecializations(reachableSpecializations, delegateType), delegateType.getReturnType()); - coversAllSpecializations = delegateSpecializations.size() == reachableSpecializations.size(); + filterCompatibleSpecializations(node.getReachableSpecializations(), delegateType), delegateType.getReturnType()); + coversAllSpecializations = delegateSpecializations.size() == node.getReachableSpecializations().size(); if (!coversAllSpecializations) { - builder.tree(multiState.createLoad(frameState, delegateSpecializations)); + builder.tree(multiState.createLoadFastPath(frameState, delegateSpecializations)); elseIf = delegateBuilder.startIf(elseIf); delegateBuilder.startGroup(); - CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, delegateSpecializations.toArray(), reachableSpecializationsArray); + CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, + StateQuery.create(SpecializationActive.class, delegateSpecializations), + StateQuery.create(SpecializationActive.class, node.getReachableSpecializations())); if (!tree.isEmpty()) { delegateBuilder.tree(tree); delegateBuilder.string(" && "); } - delegateBuilder.tree(multiState.createIsNotAny(frameState, reachableSpecializationsArray)); + delegateBuilder.tree(multiState.createIsNotAny(frameState, StateQuery.create(SpecializationActive.class, node.getReachableSpecializations()))); delegateBuilder.end(); delegateBuilder.end(); @@ -1932,11 +2912,11 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, if (!compatibleDelegateTypes.isEmpty() && !coversAllSpecializations) { ExecutableTypeData delegateType = compatibleDelegateTypes.get(0); - coversAllSpecializations = notImplemented.size() == reachableSpecializations.size(); + coversAllSpecializations = notImplemented.size() == node.getReachableSpecializations().size(); if (!coversAllSpecializations) { - builder.tree(multiState.createLoad(frameState, notImplemented)); + builder.tree(multiState.createLoadFastPath(frameState, notImplemented)); elseIf = delegateBuilder.startIf(elseIf); - delegateBuilder.tree(multiState.createContains(frameState, notImplemented.toArray())).end(); + delegateBuilder.tree(multiState.createContains(frameState, StateQuery.create(SpecializationActive.class, notImplemented))).end(); delegateBuilder.startBlock(); } delegatedDelegateTypes.add(delegateType); @@ -1998,45 +2978,38 @@ private String createExecuteAndSpecializeName() { } } - private CodeExecutableElement createExecuteAndSpecialize() { + private CodeExecutableElement createExecuteAndSpecialize(boolean inlined) { if (!needsRewrites()) { return null; } String frame = null; - if (needsFrameToExecute(reachableSpecializations)) { + if (needsFrameToExecute(node.getReachableSpecializations())) { frame = FRAME_VALUE; } TypeMirror returnType = executeAndSpecializeType.getReturnType(); CodeExecutableElement method = new CodeExecutableElement(modifiers(PRIVATE), returnType, createExecuteAndSpecializeName()); final FrameState frameState = FrameState.load(this, NodeExecutionMode.SLOW_PATH, method); + frameState.setInlinedNode(inlined); frameState.addParametersTo(method, Integer.MAX_VALUE, frame); final CodeTreeBuilder builder = method.createBuilder(); - if (needsSpecializeLocking) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); - builder.declaration(context.getType(boolean.class), "hasLock", "true"); - builder.statement("lock.lock()"); - } + ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, node.getReachableSpecializations()); - ReportPolymorphismAction reportPolymorphismAction = reportPolymorphismAction(node, reachableSpecializations); + builder.tree(multiState.createLoadSlowPath(frameState, node.getReachableSpecializations(), false)); - if (needsSpecializeLocking) { - builder.startTryBlock(); - } - - if (needsAOTReset()) { + if (needsAOTReset(node, sharingNodes)) { builder.startIf(); - builder.tree(allMultiState.createContains(frameState, new Object[]{AOT_PREPARED})); + builder.tree(allMultiState.createContains(frameState, AOT_PREPARED)); builder.end().startBlock(); - builder.startStatement().startCall("this.resetAOT_").end().end(); + builder.startStatement().startCall("this.resetAOT_"); + if (inlined) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } + builder.end().end(); + builder.tree(multiState.createLoadSlowPath(frameState, node.getReachableSpecializations(), true)); builder.end(); } - builder.tree(multiState.createLoad(frameState)); - if (requiresExclude()) { - builder.tree(exclude.createLoad(frameState)); - } - if (reportPolymorphismAction.required()) { generateSaveOldPolymorphismState(builder, frameState, reportPolymorphismAction); builder.startTryBlock(); @@ -2055,29 +3028,18 @@ private CodeExecutableElement createExecuteAndSpecialize() { if (reportPolymorphismAction.required()) { builder.end().startFinallyBlock(); if (reportPolymorphismAction.required()) { - generateCheckNewPolymorphismState(builder, reportPolymorphismAction); + generateCheckNewPolymorphismState(builder, frameState, reportPolymorphismAction); } builder.end(); } - if (needsSpecializeLocking) { - builder.end().startFinallyBlock(); - builder.startIf().string("hasLock").end().startBlock(); - builder.statement("lock.unlock()"); - builder.end(); - builder.end(); - } - return method; } // Polymorphism reporting constants private static final String OLD_PREFIX = "old"; - private static final String NEW_PREFIX = "new"; private static final String COUNT_SUFIX = "Count"; - private static final String OLD_EXCLUDE = OLD_PREFIX + "Exclude"; private static final String OLD_CACHE_COUNT = OLD_PREFIX + "Cache" + COUNT_SUFIX; - private static final String NEW_EXCLUDE = NEW_PREFIX + "Exclude"; private static final String REPORT_POLYMORPHIC_SPECIALIZE = "reportPolymorphicSpecialize"; private static final String CHECK_FOR_POLYMORPHIC_SPECIALIZE = "checkForPolymorphicSpecialize"; private static final String COUNT_CACHES = "countCaches"; @@ -2098,7 +3060,7 @@ private boolean requiresCacheCheck(ReportPolymorphismAction reportPolymorphismAc if (!reportPolymorphismAction.polymorphism) { return false; } - for (SpecializationData specialization : reachableSpecializations) { + for (SpecializationData specialization : node.getReachableSpecializations()) { if (useSpecializationClass(specialization) && specialization.getMaximumNumberOfInstances() > 1) { return true; } @@ -2106,47 +3068,61 @@ private boolean requiresCacheCheck(ReportPolymorphismAction reportPolymorphismAc return false; } - private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction reportPolymorphismAction) { - final boolean requiresExclude = reportPolymorphismAction.polymorphism && requiresExclude(); - final boolean requiresCacheCheck = requiresCacheCheck(reportPolymorphismAction); + private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction reportPolymorphismAction, boolean inlined) { TypeMirror returnType = getType(void.class); CodeExecutableElement executable = new CodeExecutableElement(modifiers(PRIVATE), returnType, createName(CHECK_FOR_POLYMORPHIC_SPECIALIZE)); FrameState frameState = FrameState.load(this, NodeExecutionMode.SLOW_PATH, executable); - final SpecializationData[] maskedElements = reachableSpecializationsReportingMegamorpism(); - for (StateBitSet s : multiState.getSets()) { - executable.addParameter(new CodeVariableElement(s.getType(), s.getOldName())); + frameState.setInlinedNode(inlined); + final boolean requiresCacheCheck = requiresCacheCheck(reportPolymorphismAction); + + SpecializationData[] relevantSpecializations = getSpecalizationsForReportAction(reportPolymorphismAction); + + StateQuery specializationActive = StateQuery.create(SpecializationActive.class, relevantSpecializations); + StateQuery specializationExcluded = StateQuery.create(SpecializationExcluded.class, relevantSpecializations); + + if (inlined) { + executable.addParameter(frameState.getValue(INLINED_NODE_INDEX).createParameter()); } - if (requiresExclude) { - executable.addParameter(new CodeVariableElement(exclude.getType(), OLD_EXCLUDE)); + + List relevantSets = new ArrayList<>(); + for (BitSet s : multiState.getSets()) { + if (s.contains(specializationActive, specializationExcluded)) { + relevantSets.add(s); + } + } + + for (BitSet s : relevantSets) { + executable.addParameter(new CodeVariableElement(s.getType(), getSetOldName(s))); } + if (requiresCacheCheck) { executable.addParameter(new CodeVariableElement(getType(int.class), OLD_CACHE_COUNT)); } + CodeTreeBuilder builder = executable.createBuilder(); if (reportPolymorphismAction.polymorphism) { - for (StateBitSet s : multiState.getSets()) { - builder.declaration(s.getType(), s.getNewName(), s.createMaskedReference(frameState, reachableSpecializationsReportingPolymorphism())); - } - if (requiresExclude) { - builder.declaration(exclude.getType(), NEW_EXCLUDE, exclude.createReference(frameState)); + builder.tree(multiState.createLoad(frameState, specializationActive, specializationExcluded)); + for (BitSet s : relevantSets) { + builder.declaration(s.getType(), getSetNewName(s), s.createMaskedReference(frameState, specializationActive, specializationExcluded)); } } builder.startIf(); if (reportPolymorphismAction.polymorphism) { String sep = ""; - for (StateBitSet s : multiState.getSets()) { + for (BitSet s : multiState.getSets()) { builder.string(sep); - builder.string("((", s.getOldName(), " ^ ", s.getNewName(), ") != 0)"); + builder.string("((", getSetOldName(s), " ^ ", getSetNewName(s), ") != 0)"); sep = " || "; } - if (requiresExclude) { - builder.string(" || "); - builder.string("(" + OLD_EXCLUDE + " ^ " + NEW_EXCLUDE + ") != 0"); - } if (requiresCacheCheck) { - builder.string(" || " + OLD_CACHE_COUNT + " < " + createName(COUNT_CACHES) + "()"); + builder.string(" || ", OLD_CACHE_COUNT, " < "); + builder.startCall(createName(COUNT_CACHES)); + if (inlined) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } + builder.end(); } if (reportPolymorphismAction.megamorphism) { builder.string(" || "); @@ -2154,50 +3130,65 @@ private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction rep } if (reportPolymorphismAction.megamorphism) { String sep = ""; - for (StateBitSet s : multiState.getSets()) { - Object[] elements = s.filter(maskedElements); - if (elements.length > 0) { - builder.string(sep); - builder.string("("); - builder.string("(", s.getOldName(), " & ", s.formatMask(s.createMask(elements))); - builder.string(") == 0"); - builder.string(" && "); - builder.tree(s.createMaskedReference(frameState, elements)); - builder.string(" != 0"); - builder.string(")"); - sep = " || "; - } + for (BitSet s : relevantSets) { + builder.string(sep); + builder.string("("); + builder.string("(", getSetOldName(s), " & ", s.formatMask(s.createMask(specializationActive, specializationExcluded))); + builder.string(") == 0"); + builder.string(" && "); + builder.tree(s.createMaskedReference(frameState, specializationActive, specializationExcluded)); + builder.string(" != 0"); + builder.string(")"); + sep = " || "; } } builder.end(); // if - builder.startBlock().startStatement().startCall("this", REPORT_POLYMORPHIC_SPECIALIZE).end(2); - builder.end(); // true block - return executable; - } + builder.startBlock().startStatement(); + if (inlined) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } else { + builder.string("this"); + } + builder.string("."); + builder.startCall(REPORT_POLYMORPHIC_SPECIALIZE).end(); - private SpecializationData[] reachableSpecializationsReportingPolymorphism() { - return reachableSpecializations.stream().filter(SpecializationData::isReportPolymorphism).toArray(SpecializationData[]::new); + builder.end(2); // statement, block + return executable; } - private SpecializationData[] reachableSpecializationsReportingMegamorpism() { - return reachableSpecializations.stream().filter(SpecializationData::isReportMegamorphism).toArray(SpecializationData[]::new); + private SpecializationData[] getSpecalizationsForReportAction(ReportPolymorphismAction reportPolymorphismAction) { + if (reportPolymorphismAction.polymorphism) { + return node.getReachableSpecializations().stream().filter(SpecializationData::isReportPolymorphism).toArray(SpecializationData[]::new); + } else if (reportPolymorphismAction.megamorphism) { + return node.getReachableSpecializations().stream().filter(SpecializationData::isReportMegamorphism).toArray(SpecializationData[]::new); + } + return new SpecializationData[0]; } - private Element createCountCaches() { + private Element createCountCaches(boolean inlined) { TypeMirror returnType = getType(int.class); CodeExecutableElement executable = new CodeExecutableElement(modifiers(PRIVATE), returnType, createName(COUNT_CACHES)); + + FrameState frameState = FrameState.load(this, NodeExecutionMode.SLOW_PATH, executable); + frameState.setInlinedNode(inlined); + + if (inlined) { + executable.addParameter(frameState.getValue(INLINED_NODE_INDEX).createParameter()); + } + CodeTreeBuilder builder = executable.createBuilder(); - final String cacheCount = "cache" + COUNT_SUFIX; + final String cacheCount = "cacheCount"; builder.declaration(context.getType(int.class), cacheCount, "0"); - for (SpecializationData specialization : reachableSpecializationsReportingPolymorphism()) { + for (SpecializationData specialization : node.getReachableSpecializations().stream().filter(SpecializationData::isReportPolymorphism).toArray(SpecializationData[]::new)) { if (useSpecializationClass(specialization) && specialization.getMaximumNumberOfInstances() > 1) { - String typeName = createSpecializationTypeName(specialization); - String fieldName = createSpecializationFieldName(specialization); - String localName = createSpecializationLocalName(specialization); - builder.declaration(typeName, localName, "this." + fieldName); - builder.startWhile().string(localName, " != null"); + builder.tree(loadSpecializationClass(frameState, specialization, false)); + CodeTree specializationClass = createGetSpecializationClass(frameState, specialization, true); + builder.startWhile().tree(specializationClass).string(" != null"); + builder.end(); + builder.startBlock(); + builder.statement("cacheCount++"); + builder.startStatement().tree(specializationClass).string(" = ").tree(specializationClass).string(".next_").end(); builder.end(); - builder.startBlock().statement(cacheCount + "++").statement(localName + "= " + localName + ".next_"); builder.end(); } } @@ -2205,28 +3196,29 @@ private Element createCountCaches() { return executable; } - private void generateCheckNewPolymorphismState(CodeTreeBuilder builder, ReportPolymorphismAction reportPolymorphismAction) { + private void generateCheckNewPolymorphismState(CodeTreeBuilder builder, FrameState frameState, ReportPolymorphismAction reportPolymorphismAction) { builder.startIf(); String sep = ""; - for (StateBitSet s : multiState.getSets()) { + for (BitSet s : multiState.getSets()) { builder.string(sep); - builder.string(s.getOldName(), " != 0"); + builder.string(getSetOldName(s), " != 0"); sep = " || "; } - final boolean requiresExclude = reportPolymorphismAction.polymorphism && requiresExclude(); - if (requiresExclude) { - builder.string(" || " + OLD_EXCLUDE + " != 0"); - } builder.end(); builder.startBlock(); builder.startStatement(); builder.startCall(createName(CHECK_FOR_POLYMORPHIC_SPECIALIZE)); - for (StateBitSet s : multiState.getSets()) { - builder.string(s.getOldName()); + + if (frameState.isInlinedNode()) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); } - if (requiresExclude) { - builder.string(OLD_EXCLUDE); + SpecializationData[] relevantSpecializations = getSpecalizationsForReportAction(reportPolymorphismAction); + StateQuery query = StateQuery.create(SpecializationActive.class, relevantSpecializations); + for (BitSet s : multiState.getSets()) { + if (s.contains(query)) { + builder.string(getSetOldName(s)); + } } if (requiresCacheCheck(reportPolymorphismAction)) { builder.string(OLD_CACHE_COUNT); @@ -2235,17 +3227,38 @@ private void generateCheckNewPolymorphismState(CodeTreeBuilder builder, ReportPo } private void generateSaveOldPolymorphismState(CodeTreeBuilder builder, FrameState frameState, ReportPolymorphismAction reportPolymorphismAction) { - for (StateBitSet s : multiState.getSets()) { - builder.declaration(s.getType(), s.getOldName(), s.createMaskedReference(frameState, reachableSpecializationsReportingPolymorphism())); - } - if (reportPolymorphismAction.polymorphism && requiresExclude()) { - builder.declaration(exclude.getType(), OLD_EXCLUDE, "exclude"); + SpecializationData[] specializations = node.getReachableSpecializations().stream().filter(SpecializationData::isReportPolymorphism).toArray(SpecializationData[]::new); + StateQuery specializationActive = StateQuery.create(SpecializationActive.class, specializations); + StateQuery specializationExcluded = StateQuery.create(SpecializationExcluded.class, specializations); + + for (BitSet s : multiState.getSets()) { + StateQuery localSpecializationActive = s.filter(specializationActive); + StateQuery localExclude = s.filter(specializationExcluded); + if (!localSpecializationActive.isEmpty() || !localExclude.isEmpty()) { + builder.declaration(s.getType(), getSetOldName(s), s.createMaskedReference(frameState, localSpecializationActive, localExclude)); + } } + if (requiresCacheCheck(reportPolymorphismAction)) { - builder.declaration(context.getType(int.class), OLD_CACHE_COUNT, createName(COUNT_CACHES) + "()"); + builder.startStatement(); + builder.type(context.getType(int.class)).string(" ", OLD_CACHE_COUNT, " = "); + builder.startCall(createName(COUNT_CACHES)); + if (frameState.isInlinedNode()) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } + builder.end(); + builder.end(); } } + private static String getSetOldName(BitSet bitSet) { + return "old" + ElementUtils.firstLetterUpperCase(bitSet.getName()); + } + + private static String getSetNewName(BitSet bitSet) { + return "new" + ElementUtils.firstLetterUpperCase(bitSet.getName()); + } + private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final FrameState frameState) { CodeTreeBuilder builder = parent.create(); builder.startThrow().startNew(types.UnsupportedSpecializationException); @@ -2283,7 +3296,7 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List boolean needsRewrites = needsRewrites(); if (needsRewrites) { - builder.tree(multiState.createLoad(frameState, allSpecializations)); + builder.tree(multiState.createLoadFastPath(frameState, allSpecializations)); } int sharedExecutes = 0; @@ -2321,27 +3334,31 @@ private CodeTree createFastPath(CodeTreeBuilder parent, List addExplodeLoop(builder, originalGroup); } else { FrameState originalFrameState = frameState.copy(); + StateQuery allSpecializationQuery = StateQuery.create(SpecializationActive.class, allSpecializations); boolean elseIf = false; for (BoxingSplit split : boxingSplits) { elseIf = builder.startIf(elseIf); builder.startGroup(); List specializations = split.group.collectSpecializations(); - CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializations.toArray(), allSpecializations.toArray()); + StateQuery specializationQuery = StateQuery.create(SpecializationActive.class, specializations); + + CodeTree tree = multiState.createContainsOnly(frameState, 0, -1, specializationQuery, allSpecializationQuery); if (!tree.isEmpty()) { builder.tree(tree); builder.string(" && "); } - builder.tree(multiState.createIsNotAny(frameState, allSpecializations.toArray())); + builder.tree(multiState.createIsNotAny(frameState, allSpecializationQuery)); builder.end(); builder.end().startBlock(); - builder.tree(wrapInAMethod(builder, split.group, originalFrameState, split.getName(), + builder.tree(wrapInAMethod(builder, specializations, split.group, originalFrameState, split.getName(), executeFastPathGroup(builder, frameState.copy(), currentType, split.group, sharedExecutes, specializations))); builder.end(); } builder.startElseBlock(); - builder.tree(wrapInAMethod(builder, originalGroup, originalFrameState, "generic", executeFastPathGroup(builder, frameState, currentType, originalGroup, sharedExecutes, null))); + builder.tree(wrapInAMethod(builder, allSpecializations, originalGroup, originalFrameState, "generic", + executeFastPathGroup(builder, frameState, currentType, originalGroup, sharedExecutes, null))); builder.end(); } @@ -2357,14 +3374,33 @@ private void addExplodeLoop(final CodeTreeBuilder builder, SpecializationGroup o } } - private CodeTree wrapInAMethod(CodeTreeBuilder parent, SpecializationGroup group, FrameState frameState, String suffix, CodeTree codeTree) { + private CodeTree wrapInAMethod(CodeTreeBuilder parent, List specializations, SpecializationGroup group, FrameState frameState, + String suffix, CodeTree codeTree) { CodeExecutableElement parentMethod = (CodeExecutableElement) parent.findMethod(); CodeTypeElement parentClass = (CodeTypeElement) parentMethod.getEnclosingElement(); String name = parentMethod.getSimpleName().toString() + "_" + suffix + (boxingSplitIndex++); CodeExecutableElement method = parentClass.add(new CodeExecutableElement(modifiers(Modifier.PRIVATE), parentMethod.getReturnType(), name)); + multiState.addParametersTo(frameState, method); frameState.addParametersTo(method, Integer.MAX_VALUE, FRAME_VALUE); CodeTreeBuilder builder = method.createBuilder(); + + /* + * We might modify state bits in the code, so we reassign it to a variable. + */ + int parameterIndex = 0; + for (BitSet set : multiState.getSets()) { + LocalVariable local = frameState.get(set.getName()); + if (local != null && MultiStateBitSet.isRelevantForFastPath(set, specializations)) { + CodeVariableElement var = (CodeVariableElement) method.getParameters().get(parameterIndex); + String oldName = var.getName(); + String newName = var.getName() + "__"; + var.setName(newName); + builder.declaration(var.getType(), oldName, newName); + parameterIndex++; + } + } + builder.tree(codeTree); method.getThrownTypes().addAll(parentMethod.getThrownTypes()); addExplodeLoop(builder, group); @@ -2407,11 +3443,11 @@ private CodeTree executeFastPathGroup(final CodeTreeBuilder parent, FrameState f generateTraceOnEnterCall(builder, frameState); generateTraceOnExceptionStart(builder); - if (needsAOTReset() && node.needsRewrites(context)) { + if (needsAOTReset(node, sharingNodes) && node.needsRewrites(context)) { builder.startIf(); builder.startStaticCall(ElementUtils.findMethod(types.CompilerDirectives, "inInterpreter")).end(); builder.string(" && "); - builder.tree(allMultiState.createContains(frameState, new Object[]{AOT_PREPARED})); + builder.tree(allMultiState.createContains(frameState, AOT_PREPARED)); builder.end().startBlock(); builder.tree(createCallExecuteAndSpecialize(currentType, originalFrameState)); builder.end(); @@ -2456,7 +3492,7 @@ private List parameterBoxingElimination(SpecializationGroup group, continue; } } - guards.add(new TypeGuard(p.getType(), index)); + guards.add(new TypeGuard(typeSystem, p.getType(), index)); } if (!guards.isEmpty()) { boolean directFound = false; @@ -2543,7 +3579,7 @@ private CodeTree createFastPathExecuteChild(final CodeTreeBuilder parent, FrameS List originalSourceTypes = new ArrayList<>(typeSystem.lookupSourceTypes(targetType)); List sourceTypes = resolveOptimizedImplicitSourceTypes(execution, targetType); if (sourceTypes.size() > 1) { - TypeGuard typeGuard = new TypeGuard(targetType, execution.getIndex()); + TypeGuard typeGuard = new TypeGuard(typeSystem, targetType, execution.getIndex()); TypeMirror generic = node.getPolymorphicExecutable().getParameterTypeOrDie(execution); fallbackVar = originalFrameState.createValue(execution, generic); @@ -2561,13 +3597,14 @@ private CodeTree createFastPathExecuteChild(final CodeTreeBuilder parent, FrameS CodeTreeBuilder accessBuilder = builder.create(); accessBuilder.startParantheses(); - CodeTree containsOnly = multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sType), 1, new Object[]{typeGuard}, - new Object[]{typeGuard}); + CodeTree containsOnly = multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sType), 1, + StateQuery.create(ImplicitCastState.class, typeGuard), + StateQuery.create(ImplicitCastState.class, typeGuard)); if (!containsOnly.isEmpty()) { accessBuilder.tree(containsOnly); accessBuilder.string(" && "); } - accessBuilder.tree(multiState.createIsNotAny(frameState, reachableSpecializationsArray)); + accessBuilder.tree(multiState.createIsNotAny(frameState, StateQuery.create(SpecializationActive.class, node.getReachableSpecializations()))); accessBuilder.string(" ? "); if (isPrimitive(sType)) { @@ -2792,14 +3829,17 @@ private Element createGetCostMethod(boolean uncached) { if (uncached) { builder.startReturn().staticReference(types.NodeCost, "MEGAMORPHIC").end(); } else { - if (needsRewrites()) { + if (node.needsRewrites(context)) { FrameState frameState = FrameState.load(this, NodeExecutionMode.UNCACHED, executable); - builder.tree(multiState.createLoadContainsSpecialization(frameState)); - builder.startIf().tree(multiState.createIs(frameState, new Object[0], reachableSpecializationsArray)).end(); + StateQuery allSpecializationQuery = StateQuery.create(SpecializationActive.class, node.getReachableSpecializations()); + StateQuery noSpecializationQuery = StateQuery.create(SpecializationActive.class); + builder.tree(multiState.createLoad(frameState, allSpecializationQuery)); + + builder.startIf().tree(multiState.createIs(frameState, noSpecializationQuery, allSpecializationQuery)).end(); builder.startBlock(); builder.startReturn().staticReference(types.NodeCost, "UNINITIALIZED").end(); builder.end(); - if (reachableSpecializations.size() == 1 && !reachableSpecializations.iterator().next().hasMultipleInstances()) { + if (node.getReachableSpecializations().size() == 1 && !node.getReachableSpecializations().iterator().next().hasMultipleInstances()) { builder.startElseBlock(); builder.startReturn().staticReference(types.NodeCost, "MONOMORPHIC").end(); builder.end(); @@ -2808,13 +3848,13 @@ private Element createGetCostMethod(boolean uncached) { if (multiState.getSets().size() == 1) { builder.startIf(); - builder.tree(multiState.getSets().get(0).createIsOneBitOf(frameState, reachableSpecializationsArray)); + builder.tree(multiState.getSets().get(0).createIsOneBitOf(frameState, allSpecializationQuery)); builder.end().startBlock(); } else { builder.declaration("int", "counter", "0"); for (BitSet set : multiState.getSets()) { - Object[] filtered = set.filter(reachableSpecializationsArray); - if (filtered.length == 0) { + StateQuery filtered = set.filter(allSpecializationQuery); + if (filtered.isEmpty()) { continue; } builder.startStatement(); @@ -2830,7 +3870,7 @@ private Element createGetCostMethod(boolean uncached) { } List additionalChecks = new ArrayList<>(); - for (SpecializationData specialization : reachableSpecializations) { + for (SpecializationData specialization : node.getReachableSpecializations()) { if (useSpecializationClass(specialization) && specialization.getMaximumNumberOfInstances() > 1) { String typeName = createSpecializationTypeName(specialization); String fieldName = createSpecializationFieldName(specialization); @@ -2908,18 +3948,6 @@ private ExecutableElement createAccessChildMethod(NodeChildData child, boolean u return null; } - private static List calculateReachableSpecializations(NodeData node) { - List specializations = new ArrayList<>(); - for (SpecializationData specialization : node.getSpecializations()) { - if (specialization.isReachable() && // - (specialization.isSpecialized() // - || (specialization.isFallback() && specialization.getMethod() != null))) { - specializations.add(specialization); - } - } - return specializations; - } - private TypeMirror getType(Class clazz) { return context.getType(clazz); } @@ -2928,7 +3956,7 @@ static CodeVariableElement createNodeField(Modifier visibility, TypeMirror type, CodeVariableElement childField = new CodeVariableElement(modifiers(modifiers), type, name); if (annotationClass != null) { if (annotationClass == ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal) { - setFieldCompilationFinal(childField, 0); + addCompilationFinalAnnotation(childField, 0); } else { childField.getAnnotationMirrors().add(new CodeAnnotationMirror(annotationClass)); } @@ -3072,7 +4100,7 @@ private CodeTree createParameterReference(LocalVariable sourceVariable, Executab } private SpecializationGroup createSpecializationGroups() { - return SpecializationGroup.create(reachableSpecializations); + return SpecializationGroup.create(node.getReachableSpecializations()); } private CodeTree expectOrCast(TypeMirror sourceType, ExecutableTypeData targetType, CodeTree content) { @@ -3186,13 +4214,15 @@ private CodeTree createFastPathExecute(CodeTreeBuilder parent, final ExecutableT CodeTreeBuilder builder = parent.create(); int ifCount = 0; if (specialization.isFallback()) { - Object[] fallbackState = getFallbackState().toArray(); + StateQuery fallbackActive = StateQuery.create(SpecializationActive.class, getFallbackSpecializations()); + StateQuery fallbackGuardsActive = StateQuery.create(GuardActive.class, getFallbackGuards()); + if (fallbackNeedsState) { - builder.tree(multiState.createLoad(frameState, fallbackState)); + builder.tree(multiState.createLoad(frameState, fallbackActive, fallbackGuardsActive)); } builder.startIf().startCall(createFallbackName()); if (fallbackNeedsState) { - multiState.addReferencesTo(frameState, builder, fallbackState); + multiState.addReferencesTo(frameState, builder, fallbackActive, fallbackGuardsActive); } if (fallbackNeedsFrame) { if (frameState.get(FRAME_VALUE) != null) { @@ -3221,25 +4251,30 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par frameState.addCaughtException(throwsData.getJavaClass()); } - if (needsSpecializeLocking && frameState.getMode().isSlowPath()) { - builder.statement("lock.unlock()"); - builder.statement("hasLock = false"); + Set suppressed = TruffleSuppressedWarnings.getWarnings(specialization.getMethod()); + if (!suppressed.isEmpty()) { + suppressed.retainAll(Arrays.asList("deprecated", "all")); + GeneratorUtils.mergeSuppressWarnings(frameState.method, suppressed.toArray(new String[suppressed.size()])); } - - if (specialization.getMethod() == null) { + ExecutableElement targetMethod = specialization.getMethod(); + if (targetMethod == null) { builder.tree(createThrowUnsupported(builder, frameState)); } else { - CodeTree[] bindings = new CodeTree[specialization.getParameters().size()]; - TypeMirror[] bindingTypes = new TypeMirror[specialization.getParameters().size()]; + CodeTree[] bindings = new CodeTree[targetMethod.getParameters().size()]; + TypeMirror[] bindingTypes = new TypeMirror[targetMethod.getParameters().size()]; for (int i = 0; i < bindings.length; i++) { - Parameter parameter = specialization.getParameters().get(i); - + Parameter parameter = specialization.findByVariable(targetMethod.getParameters().get(i)); + if (parameter == null) { + // synthetic parameter, may happen for optional signature parameters + continue; + } if (parameter.getSpecification().isCached()) { - LocalVariable var = frameState.get(createFieldName(specialization, parameter)); + CacheExpression cache = specialization.findCache(parameter); + LocalVariable var = frameState.get(createFieldName(specialization, cache)); if (var != null) { bindings[i] = var.createReference(); } else { - bindings[i] = createCacheReference(frameState, specialization, specialization.findCache(parameter)); + bindings[i] = createCacheAccess(frameState, specialization, cache, null); } bindingTypes[i] = parameter.getType(); } else { @@ -3277,6 +4312,47 @@ private CodeTree createCallSpecialization(CodeTreeBuilder parent, FrameState par builder.tree(statistics.build()); } + if (frameState.isInlinedNode() && !substituteNodeWithSpecializationClass(specialization)) { + + List usedFields = new ArrayList<>(); + for (CacheExpression cache : specialization.getCaches()) { + + if (cache.getSharedGroup() != null) { + // shared caches are validated at the beginning of the execute + continue; + } + + if (cache.getInlinedNode() != null) { + + for (InlineFieldData field : cache.getInlinedNode().getFields()) { + CodeTreeBuilder inner = builder.create(); + if (field.isState()) { + BitSet bitSet = state.activeState.findSet(InlinedNodeState.class, field); + if (bitSet != null) { + inner.string("this.", bitSet.getName(), "_"); + usedFields.add(inner.build()); + } + } else { + inner.string("this.", createCachedInlinedFieldName(specialization, cache, field)); + usedFields.add(inner.build()); + } + } + } + } + + if (!usedFields.isEmpty()) { + builder.startAssert(); + builder.startStaticCall(types.InlineSupport, "validate"); + builder.tree(createNodeAccess(frameState, specialization)); + for (CodeTree field : usedFields) { + builder.tree(field); + } + builder.end(); + builder.end(); + } + + } + CodeTree specializationCall = callMethod(frameState, null, specialization.getMethod(), bindings); if (isVoid(specialization.getMethod().getReturnType())) { builder.statement(specializationCall); @@ -3445,8 +4521,19 @@ public static BlockState materialize(CodeTreeBuilder builder, Collection allowedSpecializations) { + private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, SpecializationGroup originalPrev, SpecializationGroup group, + ExecutableTypeData forType, FrameState frameState, Collection allowedSpecializations) { + final CodeTreeBuilder builder = parent.create(); SpecializationGroup prev = originalPrev; @@ -3494,14 +4582,13 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } SpecializationData specialization = group.getSpecialization(); - SpecializationData[] specializations = group.collectSpecializations().toArray(new SpecializationData[0]); - List guardExpressions = new ArrayList<>(group.getGuards()); + List remainingGuards = new ArrayList<>(group.getGuards()); // for specializations with multiple instances we can move certain guards // out of the loop. if (specialization != null && specialization.hasMultipleInstances()) { List unboundGuards = new ArrayList<>(); - for (GuardExpression guard : guardExpressions) { + for (GuardExpression guard : remainingGuards) { if (!specialization.isGuardBoundWithCache(guard)) { unboundGuards.add(guard); } else { @@ -3510,377 +4597,556 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } } cachedTriples.addAll(createMethodGuardChecks(frameState, group, unboundGuards, mode)); - guardExpressions.removeAll(unboundGuards); + remainingGuards.removeAll(unboundGuards); } boolean useSpecializationClass = specialization != null && useSpecializationClass(specialization); - boolean needsRewrites = needsRewrites(); if (mode.isFastPath()) { + BlockState ifCount = BlockState.NONE; + cachedTriples.addAll(0, createSpecializationActive(frameState, group, allowedSpecializations)); + ifCount = ifCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); + + if (specialization == null) { + prev = visitSpecializationGroupChildren(builder, frameState.copy(), prev, group, forType, allowedSpecializations); + } else { + hasFallthrough |= buildSpecializationFastPath(builder, frameState, prev, group, forType, remainingGuards); + } + builder.end(ifCount.blockCount); + hasFallthrough |= ifCount.ifCount > 0; + } else if (mode.isSlowPath()) { + if (specialization == null) { + BlockState outerIfCount = BlockState.NONE; + cachedTriples.addAll(createMethodGuardChecks(frameState, group, remainingGuards, mode)); + outerIfCount = outerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); + prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); + + builder.end(outerIfCount.blockCount); + hasFallthrough |= outerIfCount.ifCount > 0; + } else { + hasFallthrough |= buildSpecializationSlowPath(builder, frameState, group, mode, cachedTriples, remainingGuards); + } + } else if (mode.isGuardFallback()) { BlockState ifCount = BlockState.NONE; - final boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && - group.getAllSpecializations().size() == allowedSpecializations.size(); - if (needsRewrites && (!group.isEmpty() || specialization != null)) { - CodeTree stateCheck = multiState.createContains(frameState, specializations); - CodeTree stateGuard = null; - CodeTree assertCheck = null; - if (stateGuaranteed) { - assertCheck = CodeTreeBuilder.createBuilder().startAssert().tree(stateCheck).end().build(); - } else { - stateGuard = stateCheck; - } - cachedTriples.add(0, new IfTriple(null, stateGuard, assertCheck)); + + if (specialization != null && specialization.hasMultipleInstances()) { + throw new AssertionError("unsupported path. should be caught by the parser."); } - ifCount = ifCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); - cachedTriples = new ArrayList<>(); // reset current triples - String specializationLocalName = null; + BlockState innerIfCount = BlockState.NONE; + if (useSpecializationClass) { - specializationLocalName = createSpecializationLocalName(specialization); - builder.tree(loadSpecializationClass(frameState, specialization)); - if (specialization.getMaximumNumberOfInstances() > 1) { - builder.startWhile(); - } else { - builder.startIf(); + if (specialization.isGuardBindsCache()) { + cachedTriples.add(new IfTriple(loadSpecializationClass(frameState, specialization, false), null, null)); } - builder.string(specializationLocalName, " != null"); - builder.end(); - builder.startBlock(); - ifCount = ifCount.incrementIf(); - } - - if (specialization != null && !specialization.getAssumptionExpressions().isEmpty()) { - BlockState state = IfTriple.materialize(builder, createAssumptionCheck(frameState, specialization, NodeExecutionMode.FAST_PATH, false), false); - builder.tree(createTransferToInterpreterAndInvalidate()); - builder.tree(createRemoveThis(builder, frameState, forType, specialization)); - builder.end(state.blockCount); - } - - boolean extractInBoundary = false; - boolean pushEncapsulatingNode = false; - // if library is used in guard we need to push encapsulating node early - // otherwise we can push it behind the guard - boolean libraryInGuard = false; - if (specialization != null) { - libraryInGuard = specialization.isAnyLibraryBoundInGuard(); - pushEncapsulatingNode = specialization.needsPushEncapsulatingNode(); - extractInBoundary = specialization.needsTruffleBoundary(); - if (extractInBoundary && specialization.needsVirtualFrame()) { - // Cannot extract to boundary with a virtual frame. - extractInBoundary = false; - } - } - List nonBoundaryGuards = new ArrayList<>(); - guards: for (Iterator iterator = guardExpressions.iterator(); iterator.hasNext();) { - GuardExpression guard = iterator.next(); - Set caches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); - for (CacheExpression cache : caches) { - if (cache.isAlwaysInitialized() && cache.isRequiresBoundary()) { - break guards; - } + } + cachedTriples.addAll(createMethodGuardChecks(frameState, group, remainingGuards, mode)); + cachedTriples.addAll(createAssumptionCheck(frameState, specialization, NodeExecutionMode.FALLBACK_GUARD, true)); + + cachedTriples = IfTriple.optimize(cachedTriples); + + if (specialization != null && !hasImplicitCast) { + IfTriple singleCondition = null; + if (cachedTriples.size() == 1) { + singleCondition = cachedTriples.get(0); + } + if (singleCondition != null) { + int index = cachedTriples.indexOf(singleCondition); + CodeTree stateCheck = multiState.createNotContains(frameState, StateQuery.create(SpecializationActive.class, specialization)); + cachedTriples.set(index, new IfTriple(singleCondition.prepare, combineTrees(" && ", stateCheck, singleCondition.condition), singleCondition.statements)); + fallbackNeedsState = true; } - nonBoundaryGuards.addAll(initializeCaches(frameState, mode, group, caches, true, false)); - nonBoundaryGuards.add(createMethodGuardCheck(frameState, group.getSpecialization(), guard, mode)); - iterator.remove(); } - if (pushEncapsulatingNode && libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(builder, "this"); - builder.startTryBlock(); + innerIfCount = innerIfCount.add(IfTriple.materialize(builder, cachedTriples, false)); + prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); + if (specialization != null && (prev == null || prev.hasFallthrough())) { + builder.returnFalse(); } - for (Iterator iterator = guardExpressions.iterator(); iterator.hasNext();) { - GuardExpression guard = iterator.next(); - Set caches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); - nonBoundaryGuards.addAll(initializeCaches(frameState, mode, group, caches, true, false)); - nonBoundaryGuards.add(createMethodGuardCheck(frameState, group.getSpecialization(), guard, mode)); + builder.end(innerIfCount.blockCount); + + builder.end(ifCount.blockCount); + hasFallthrough |= ifCount.ifCount > 0 || innerIfCount.ifCount > 0; + + } else if (mode.isUncached()) { + BlockState ifCount = BlockState.NONE; + + cachedTriples.addAll(createAssumptionCheck(frameState, specialization, NodeExecutionMode.UNCACHED, true)); + + ifCount = ifCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); + cachedTriples = createMethodGuardChecks(frameState, group, remainingGuards, mode); + + BlockState innerIfCount = IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false); + + prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); + if (specialization != null && (prev == null || prev.hasFallthrough())) { + builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); } + builder.end(innerIfCount.blockCount); + builder.end(ifCount.blockCount); + hasFallthrough |= ifCount.ifCount > 0 || innerIfCount.ifCount > 0; + } else { + throw new AssertionError("unexpected path"); + } - FrameState innerFrameState = frameState; + group.setFallthrough(hasFallthrough); - BlockState nonBoundaryIfCount = BlockState.NONE; + return builder.build(); + } - CodeTreeBuilder innerBuilder; - if (extractInBoundary) { - innerFrameState = frameState.copy(); - for (CacheExpression cache : specialization.getCaches()) { - if (cache.isAlwaysInitialized()) { - setCacheInitialized(innerFrameState, specialization, cache, false); - } - } - nonBoundaryIfCount = nonBoundaryIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(nonBoundaryGuards), false)); - innerBuilder = extractInBoundaryMethod(builder, frameState, specialization); + private boolean buildSpecializationFastPath(final CodeTreeBuilder builder, FrameState frameState, SpecializationGroup prev, SpecializationGroup group, + ExecutableTypeData forType, List guardExpressions) { - for (NodeExecutionData execution : specialization.getNode().getChildExecutions()) { - int index = forType.getVarArgsIndex(forType.getParameterIndex(execution.getIndex())); - if (index != -1) { - LocalVariable var = innerFrameState.getValue(execution); - innerFrameState.set(execution, var.accessWith(CodeTreeBuilder.singleString(var.getName()))); - } - } + boolean hasFallthrough = false; + SpecializationData specialization = group.getSpecialization(); + BlockState ifCount = BlockState.NONE; - } else if (pushEncapsulatingNode) { - innerBuilder = builder; - nonBoundaryIfCount = IfTriple.materialize(innerBuilder, IfTriple.optimize(nonBoundaryGuards), false); + if (useSpecializationClass(specialization)) { + builder.tree(loadSpecializationClass(frameState, specialization, false)); + if (specialization.hasMultipleInstances()) { + builder.startWhile(); } else { - innerBuilder = builder; - cachedTriples.addAll(0, nonBoundaryGuards); + builder.startIf(); } - if (specialization != null) { - cachedTriples.addAll(initializeCaches(innerFrameState, frameState.getMode(), group, specialization.getCaches(), true, false)); - } + builder.tree(createGetSpecializationClass(frameState, specialization, true)).string(" != null"); + builder.end(); + builder.startBlock(); + ifCount = ifCount.incrementIf(); + } - if (pushEncapsulatingNode && !libraryInGuard) { - GeneratorUtils.pushEncapsulatingNode(innerBuilder, "this"); - innerBuilder.startTryBlock(); - } + if (!specialization.getAssumptionExpressions().isEmpty()) { + BlockState blockState = IfTriple.materialize(builder, createAssumptionCheck(frameState, specialization, NodeExecutionMode.FAST_PATH, false), false); + builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(createRemoveThis(builder, frameState, forType, specialization)); + builder.end(blockState.blockCount); + } - BlockState innerIfCount = BlockState.NONE; - innerIfCount = innerIfCount.add(IfTriple.materialize(innerBuilder, IfTriple.optimize(cachedTriples), false)); - prev = visitSpecializationGroupChildren(builder, innerFrameState, prev, group, forType, allowedSpecializations); - if (specialization != null && (prev == null || prev.hasFallthrough())) { - innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState)); - } + // if library is used in guard we need to push encapsulating node early + // otherwise we can push it behind the guard + boolean libraryInGuard = specialization.isAnyLibraryBoundInGuard(); + boolean pushEncapsulatingNode = specialization.needsPushEncapsulatingNode(); + boolean extractInBoundary = specialization.needsTruffleBoundary(); - innerBuilder.end(innerIfCount.blockCount); + if (extractInBoundary && specialization.needsVirtualFrame()) { + // Cannot extract to boundary with a virtual frame. + extractInBoundary = false; + } - if (pushEncapsulatingNode && !libraryInGuard) { - innerBuilder.end().startFinallyBlock(); - GeneratorUtils.popEncapsulatingNode(innerBuilder); - innerBuilder.end(); + List nonBoundaryGuards = new ArrayList<>(); + List nonBoundaryGuardExpressions = new ArrayList<>(); + guards: for (Iterator iterator = guardExpressions.iterator(); iterator.hasNext();) { + GuardExpression guard = iterator.next(); + Set caches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); + for (CacheExpression cache : caches) { + if (cache.isAlwaysInitialized() && cache.isRequiresBoundary()) { + break guards; + } } - hasFallthrough |= innerIfCount.ifCount > 0; + nonBoundaryGuardExpressions.add(guard); + iterator.remove(); + } - builder.end(nonBoundaryIfCount.blockCount); + nonBoundaryGuards.addAll(createFastPathNeverDefaultGuards(frameState, group.getSpecialization())); + nonBoundaryGuards.addAll(createMethodGuardChecks(frameState, group, nonBoundaryGuardExpressions, NodeExecutionMode.FAST_PATH)); - if (pushEncapsulatingNode && libraryInGuard) { - builder.end().startFinallyBlock(); - GeneratorUtils.popEncapsulatingNode(builder); - builder.end(); + if (pushEncapsulatingNode && libraryInGuard) { + GeneratorUtils.pushEncapsulatingNode(builder, createNodeAccess(frameState)); + builder.startTryBlock(); + } + + nonBoundaryGuards.addAll(createMethodGuardChecks(frameState, group, guardExpressions, NodeExecutionMode.FAST_PATH)); + + FrameState innerFrameState = frameState; + BlockState nonBoundaryIfCount = BlockState.NONE; + + List cachedTriples = new ArrayList<>(); + CodeTreeBuilder innerBuilder; + if (extractInBoundary) { + innerFrameState = frameState.copy(); + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isAlwaysInitialized()) { + setCacheInitialized(innerFrameState, specialization, cache, false); + } } - if (useSpecializationClass && specialization.getMaximumNumberOfInstances() > 1) { - String name = createSpecializationLocalName(specialization); - builder.startStatement().string(name, " = ", name, ".next_").end(); + nonBoundaryIfCount = nonBoundaryIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(nonBoundaryGuards), false)); + innerBuilder = extractInBoundaryMethod(builder, frameState, specialization); + + for (NodeExecutionData execution : specialization.getNode().getChildExecutions()) { + int index = forType.getVarArgsIndex(forType.getParameterIndex(execution.getIndex())); + if (index != -1) { + LocalVariable var = innerFrameState.getValue(execution); + innerFrameState.set(execution, var.accessWith(CodeTreeBuilder.singleString(var.getName()))); + } } - builder.end(ifCount.blockCount); - hasFallthrough |= ifCount.ifCount > 0; + } else if (pushEncapsulatingNode) { + innerBuilder = builder; + nonBoundaryIfCount = IfTriple.materialize(innerBuilder, IfTriple.optimize(nonBoundaryGuards), false); + } else { + innerBuilder = builder; + cachedTriples.addAll(0, nonBoundaryGuards); + } - } else if (mode.isSlowPath()) { + cachedTriples.addAll(initializeCaches(innerFrameState, frameState.getMode(), group, specialization.getCaches(), true, false)); - if (specialization != null && mayBeExcluded(specialization)) { - CodeTree excludeCheck = exclude.createNotContains(frameState, (Object[]) specializations); - cachedTriples.add(0, new IfTriple(null, excludeCheck, null)); - } + if (pushEncapsulatingNode && !libraryInGuard) { + GeneratorUtils.pushEncapsulatingNode(innerBuilder, createNodeAccess(frameState)); + innerBuilder.startTryBlock(); + } - BlockState outerIfCount = BlockState.NONE; - if (specialization == null) { - cachedTriples.addAll(createMethodGuardChecks(frameState, group, guardExpressions, mode)); + BlockState innerIfCount = BlockState.NONE; + innerIfCount = innerIfCount.add(IfTriple.materialize(innerBuilder, IfTriple.optimize(cachedTriples), false)); + if (prev == null || prev.hasFallthrough()) { + innerBuilder.tree(createFastPathExecute(builder, forType, specialization, innerFrameState)); + } + innerBuilder.end(innerIfCount.blockCount); - outerIfCount = outerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); + if (pushEncapsulatingNode && !libraryInGuard) { + innerBuilder.end().startFinallyBlock(); + GeneratorUtils.popEncapsulatingNode(innerBuilder); + innerBuilder.end(); + } - prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); + hasFallthrough |= innerIfCount.ifCount > 0; + builder.end(nonBoundaryIfCount.blockCount); + + if (pushEncapsulatingNode && libraryInGuard) { + builder.end().startFinallyBlock(); + GeneratorUtils.popEncapsulatingNode(builder); + builder.end(); + } + + if (useSpecializationClass(specialization) && specialization.hasMultipleInstances()) { + String name = createSpecializationLocalName(specialization); + builder.startStatement().string(name, " = ", name, ".next_").end(); + } + + builder.end(ifCount.blockCount); + + hasFallthrough |= ifCount.ifCount > 0; + return hasFallthrough; + } + + private List createSpecializationActive(FrameState frameState, SpecializationGroup group, + Collection allowedSpecializations) { + List specializations = group.collectSpecializations(); + final boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && + group.getAllSpecializations().size() == allowedSpecializations.size(); + if (needsRewrites()) { + CodeTree stateCheck = multiState.createContains(frameState, StateQuery.create(SpecializationActive.class, specializations)); + CodeTree stateGuard = null; + CodeTree assertCheck = null; + if (stateGuaranteed) { + assertCheck = CodeTreeBuilder.createBuilder().startAssert().tree(stateCheck).end().build(); } else { + stateGuard = stateCheck; + } + return Arrays.asList(new IfTriple(null, stateGuard, assertCheck)); + } + return Collections.emptyList(); + } - for (CacheExpression cache : specialization.getCaches()) { - if (!cache.isAlwaysInitialized()) { - continue; - } - CodeTree prepare = CodeTreeBuilder.createBuilder().declarationDefault(cache.getParameter().getType(), - createCacheLocalName(specialization, cache)).build(); - cachedTriples.add(0, new IfTriple(prepare, null, null)); - } + private boolean buildSpecializationSlowPath(final CodeTreeBuilder builder, FrameState frameState, SpecializationGroup group, NodeExecutionMode mode, + List outerTriples, List guardExpressions) throws AssertionError { + SpecializationData specialization = group.getSpecialization(); + Objects.requireNonNull(specialization); + + if (hasExcludeBit(specialization)) { + CodeTree excludeCheck = multiState.createNotContains(frameState, StateQuery.create(SpecializationExcluded.class, specialization)); + outerTriples.add(0, new IfTriple(null, excludeCheck, null)); + } + + if (hasExcludes(specialization)) { + CodeTree excludeCheck = multiState.createNotContains(frameState, StateQuery.create(SpecializationActive.class, specialization.getReplacedBy())); + outerTriples.add(0, new IfTriple(null, excludeCheck, null)); + } + + boolean hasFallthrough = false; + BlockState outerIfCount = BlockState.NONE; + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isAlwaysInitialized()) { + continue; + } + CodeTree prepare = CodeTreeBuilder.createBuilder().declarationDefault(cache.getParameter().getType(), + createCacheLocalName(cache)).build(); + outerTriples.add(0, new IfTriple(prepare, null, null)); + } - outerIfCount = outerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); - String countName = specialization != null ? "count" + specialization.getIndex() + "_" : null; - boolean needsDuplicationCheck = specialization.isGuardBindsCache() || specialization.hasMultipleInstances(); - boolean useDuplicateFlag = specialization.isGuardBindsCache() && !specialization.hasMultipleInstances(); - String duplicateFoundName = specialization.getId() + "_duplicateFound_"; + outerIfCount = outerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(outerTriples), false)); + String countName = specialization != null ? "count" + specialization.getIndex() + "_" : null; + final boolean useSpecializationClass = useSpecializationClass(specialization); + final boolean multipleInstances = specialization.hasMultipleInstances(); + final boolean needsDuplicationCheck = specialization.isGuardBindsCache() || multipleInstances; + final boolean useDuplicateFlag = specialization.isGuardBindsCache() && !useSpecializationClass; + final String duplicateFoundName = specialization.getId() + "_duplicateFound_"; - boolean pushBoundary = specialization.needsPushEncapsulatingNode(); - if (pushBoundary) { - builder.startBlock(); - GeneratorUtils.pushEncapsulatingNode(builder, "this"); - builder.startTryBlock(); - } - BlockState innerIfCount = BlockState.NONE; + boolean pushBoundary = specialization.needsPushEncapsulatingNode(); + if (pushBoundary) { + builder.startBlock(); + GeneratorUtils.pushEncapsulatingNode(builder, createNodeAccess(frameState)); + builder.startTryBlock(); + } + BlockState innerIfCount = BlockState.NONE; + String specializationLocalName = createSpecializationLocalName(specialization); - String specializationLocalName = createSpecializationLocalName(specialization); + if (needsDuplicationCheck) { + builder.startWhile().string("true").end(); + builder.startBlock(); + builder.tree(createDuplicationCheck(builder, frameState, group, guardExpressions, useDuplicateFlag, countName, duplicateFoundName, + specializationLocalName)); - if (needsDuplicationCheck) { - builder.tree(createDuplicationCheck(builder, frameState, group, guardExpressions, useDuplicateFlag, countName, duplicateFoundName, - specializationLocalName)); + builder.startIf(); + if (useDuplicateFlag) { + // we reuse the specialization class local name instead of a duplicate found + // name + builder.string("!", duplicateFoundName); + } else { + builder.string(createSpecializationLocalName(specialization), " == null"); - builder.startIf(); - if (useDuplicateFlag) { - // we reuse the specialization class local name instead of a duplicate found - // name - builder.string("!", duplicateFoundName); - } else { - builder.string(createSpecializationLocalName(specialization), " == null"); - } - builder.end().startBlock(); - innerIfCount = innerIfCount.incrementIf(); + if (!multipleInstances) { + builder.string(" && ", countName, " < 1"); } + } + builder.end().startBlock(); + innerIfCount = innerIfCount.incrementIf(); + } + + FrameState innerFrameState = frameState.copy(); - FrameState innerFrameState = frameState.copy(); + List innerTripples = new ArrayList<>(); + innerTripples.addAll(createMethodGuardChecks(innerFrameState, group, guardExpressions, mode)); - List innerTripples = new ArrayList<>(); - innerTripples.addAll(createMethodGuardChecks(innerFrameState, group, guardExpressions, mode)); + List assumptions = specialization.getAssumptionExpressions(); + if (!assumptions.isEmpty()) { + for (AssumptionExpression assumption : assumptions) { + innerTripples.addAll(createAssumptionSlowPathTriples(innerFrameState, group, assumption)); + } + } - List assumptions = specialization.getAssumptionExpressions(); - if (!assumptions.isEmpty()) { - for (AssumptionExpression assumption : assumptions) { - innerTripples.addAll(createAssumptionSlowPathTriples(innerFrameState, group, assumption)); - } - } + CodeTree specializeElseBranch = null; + if (needsDuplicationCheck && useSpecializationClass) { + DSLExpression limit = optimizeExpression(specialization.getLimitExpression()); + Set caches = specialization.getBoundCaches(limit, true); + innerTripples.addAll(initializeCaches(innerFrameState, innerFrameState.getMode(), group, caches, true, false)); + CodeTree limitExpression = writeExpression(innerFrameState, specialization, limit); + CodeTreeBuilder limitBuilder = CodeTreeBuilder.createBuilder(); + limitBuilder.string(countName).string(" < ").tree(limitExpression); + if (specialization.hasUnroll() && !specialization.isUnrolled()) { + // subtract unrolled count from limit + limitBuilder.string(" - ").string(String.valueOf(specialization.getUnroll())); + } + innerTripples.add(new IfTriple(null, limitBuilder.build(), null)); + } else if (needsDuplicationCheck) { + innerTripples.add(new IfTriple(null, multiState.createNotContains(innerFrameState, StateQuery.create(SpecializationActive.class, specialization)), null)); + } - if (specialization.hasMultipleInstances()) { - DSLExpression limit = optimizeExpression(specialization.getLimitExpression()); + if (innerFrameState.isSpecializationClassInitialized(specialization)) { + // we need to null an already initialized specialization class if initialized in the + // else branch of any guard + specializeElseBranch = builder.create().startStatement().string(createSpecializationLocalName(specialization)).string(" = null").end().build(); + } + int innerIfCountDiff = innerIfCount.ifCount; + innerIfCount = innerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(innerTripples), false)); + innerIfCountDiff = innerIfCount.ifCount - innerIfCountDiff; - Set caches = specialization.getBoundCaches(limit, true); - innerTripples.addAll(initializeCaches(innerFrameState, innerFrameState.getMode(), group, caches, true, false)); + StateTransaction stateTransaction = new StateTransaction(); + builder.tree(createSpecialize(builder, innerFrameState, stateTransaction, group, specialization, false)); + CodeTree updateImplicitCast = createUpdateImplicitCastState(builder, innerFrameState, stateTransaction, specialization); + if (updateImplicitCast != null) { + builder.tree(updateImplicitCast); + } + builder.tree(multiState.createSet(innerFrameState, stateTransaction, StateQuery.create(SpecializationActive.class, specialization), true, false)); + builder.tree(multiState.persistTransaction(innerFrameState, stateTransaction)); - CodeTree limitExpression = writeExpression(innerFrameState, specialization, limit); - CodeTree limitCondition = CodeTreeBuilder.createBuilder().string(countName).string(" < ").tree(limitExpression).build(); + if (types.SlowPathListener != null && ElementUtils.isAssignable(specialization.getNode().getTemplateType().asType(), types.SlowPathListener)) { + builder.startStatement().startCall("afterSpecialize").end().end(); + } - innerTripples.add(new IfTriple(null, limitCondition, null)); + if (needsDuplicationCheck) { + hasFallthrough = true; + if (useDuplicateFlag) { + builder.startStatement().string(duplicateFoundName, " = true").end(); + } - // assert that specialization is not initialized - // otherwise we have been inserting invalid instances - assertSpecializationClassNotInitialized(innerFrameState, specialization); - } else if (needsDuplicationCheck) { - innerTripples.add(new IfTriple(null, multiState.createNotContains(innerFrameState, new Object[]{specialization}), null)); - } + endAndElse(builder, innerIfCountDiff, specializeElseBranch); + builder.end(innerIfCount.blockCount - innerIfCountDiff); - innerIfCount = innerIfCount.add(IfTriple.materialize(builder, IfTriple.optimize(innerTripples), false)); - builder.tree(createSpecialize(builder, innerFrameState, group, specialization, false)); - CodeTree updateImplicitCast = createUpdateImplicitCastState(builder, frameState, specialization); - if (updateImplicitCast != null) { - builder.tree(updateImplicitCast); + /* + * We keep around always initialized caches in locals explicitly to avoid that weak + * references get collected between null check and specialization invocation. + */ + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isAlwaysInitialized()) { + continue; } - builder.tree(multiState.createSet(frameState, new SpecializationData[]{specialization}, true, true)); + setCacheInitialized(frameState, specialization, cache, true); + } - if (needsDuplicationCheck) { - hasFallthrough = true; - if (useDuplicateFlag) { - builder.startStatement().string(duplicateFoundName, " = true").end(); - } - builder.end(innerIfCount.blockCount); + // need to ensure that we update the implicit cast specializations on duplicates + if (updateImplicitCast != null) { + builder.startElseBlock(); + stateTransaction = new StateTransaction(); + builder.tree(createUpdateImplicitCastState(builder, frameState, stateTransaction, specialization)); + builder.tree(multiState.createSet(frameState, stateTransaction, StateQuery.create(SpecializationActive.class, specialization), true, false)); + builder.tree(multiState.persistTransaction(innerFrameState, stateTransaction)); + builder.end(); + } - /* - * We keep around always initialized caches in locals explicitly to avoid that - * weak references get collected between null check and specialization - * invocation. - */ - for (CacheExpression cache : specialization.getCaches()) { - if (!cache.isAlwaysInitialized()) { - continue; - } - setCacheInitialized(frameState, specialization, cache, true); - } + builder.startIf(); + if (useDuplicateFlag) { + builder.string(duplicateFoundName); + } else { + builder.string(createSpecializationLocalName(specialization), " != null"); + } + builder.end().startBlock(); - // need to ensure that we update the implicit cast specializations on duplicates - if (updateImplicitCast != null) { - builder.startElseBlock(); - builder.tree(createUpdateImplicitCastState(builder, frameState, specialization)); - builder.tree(multiState.createSet(frameState, new Object[]{specialization}, true, true)); - builder.end(); - } + builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization)); + builder.end(); + builder.statement("break"); + builder.end(); + } else { + builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization)); + builder.end(innerIfCount.blockCount); + hasFallthrough |= innerIfCount.ifCount > 0; + } - builder.startIf(); - if (useDuplicateFlag) { - builder.string(duplicateFoundName); - } else { - builder.string(createSpecializationLocalName(specialization), " != null"); - } - builder.end().startBlock(); + if (pushBoundary) { + builder.end().startFinallyBlock(); + GeneratorUtils.popEncapsulatingNode(builder); + builder.end(); + builder.end(); + } - builder.tree(createCallSpecialization(builder, frameState, executeAndSpecializeType, specialization)); - builder.end(); - } else { - builder.tree(createCallSpecialization(builder, innerFrameState, executeAndSpecializeType, specialization)); - builder.end(innerIfCount.blockCount); - hasFallthrough |= innerIfCount.ifCount > 0; - } + builder.end(outerIfCount.blockCount); + hasFallthrough |= outerIfCount.ifCount > 0; - if (pushBoundary) { - builder.end().startFinallyBlock(); - GeneratorUtils.popEncapsulatingNode(builder); - builder.end(); - builder.end(); - } + return hasFallthrough; + } + static void endAndElse(CodeTreeBuilder b, int endCount, CodeTree elseBranch) { + for (int i = 0; i < endCount; i++) { + b.end(); + if (elseBranch != null) { + b.startElseBlock(); + b.tree(elseBranch); + b.end(); } + } + } - builder.end(outerIfCount.blockCount); - hasFallthrough |= outerIfCount.ifCount > 0; - - } else if (mode.isGuardFallback()) { - BlockState ifCount = BlockState.NONE; - - if (specialization != null && specialization.getMaximumNumberOfInstances() > 1) { - throw new AssertionError("unsupported path. should be caught by parser.."); + private static boolean specializationNeedsInitializedBit(SpecializationData specialization) { + if (useSpecializationClass(specialization) && specialization.isReachesFallback() && !specialization.getCaches().isEmpty()) { + for (GuardExpression guard : specialization.getGuards()) { + if (guardNeedsStateBit(specialization, guard)) { + return true; + } } + } + return false; + } - BlockState innerIfCount = BlockState.NONE; - cachedTriples.addAll(createMethodGuardChecks(frameState, group, guardExpressions, mode)); - cachedTriples.addAll(createAssumptionCheck(frameState, specialization, NodeExecutionMode.FALLBACK_GUARD, true)); + private List createFastPathNeverDefaultGuards(FrameState frameState, + SpecializationData specialization) { + List caches = specialization.getCaches(); + if (specialization == null || caches.isEmpty()) { + return Collections.emptyList(); + } - cachedTriples = IfTriple.optimize(cachedTriples); + List triples = new ArrayList<>(); - if (specialization != null && !hasImplicitCast) { - IfTriple singleCondition = null; - if (cachedTriples.size() == 1) { - singleCondition = cachedTriples.get(0); - } - if (singleCondition != null) { - int index = cachedTriples.indexOf(singleCondition); - CodeTree stateCheck = multiState.createNotContains(frameState, specializations); - cachedTriples.set(index, new IfTriple(singleCondition.prepare, combineTrees(" && ", stateCheck, singleCondition.condition), singleCondition.statements)); - fallbackNeedsState = true; - } + if (specializationNeedsInitializedBit(specialization)) { + StateQuery query = StateQuery.create(SpecializationCachesInitialized.class, specialization); + SpecializationStateReference ref = createStateReference(frameState, specialization, query); + triples.add(new IfTriple(null, ref.bitSet.createContains(ref.reference, query), null)); + } + + for (CacheExpression cache : caches) { + if (cache.isBind()) { + continue; + } else if (cache.isAlwaysInitialized()) { + continue; + } else if (cache.getInlinedNode() != null) { + continue; + } else if (cache.isEagerInitialize()) { + continue; } - innerIfCount = innerIfCount.add(IfTriple.materialize(builder, cachedTriples, false)); - prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); - if (specialization != null && (prev == null || prev.hasFallthrough())) { - builder.returnFalse(); + boolean needsNeverDefaultCheck = cache.getSharedGroup() != null || (!useSpecializationClass(specialization)); + + /* + * If a cache is never default or is shared it must not have a default value. We add a + * guard such that we go to executeAndSpecialize in such a case. + */ + if (needsNeverDefaultCheck || isCacheNullDueToFallback(specialization, cache)) { + triples.add(createNeverDefaultGuard(frameState, specialization, cache, " != ")); } + } + return triples; + } - builder.end(innerIfCount.blockCount); + private static boolean isCacheNullDueToFallback(SpecializationData specialization, CacheExpression cache) { + if (!specialization.isReachesFallback()) { + return false; + } + /* + * Guards that bind caches that reach fallback must never be null, as they can be + * initialized. + */ + for (GuardExpression guard : specialization.getGuards()) { + if (getNullCachesDueToFallback(specialization, guard).contains(cache)) { + return true; + } + } + return false; + } - builder.end(ifCount.blockCount); - hasFallthrough |= ifCount.ifCount > 0 || innerIfCount.ifCount > 0; + private static Collection getNullCachesDueToFallback(SpecializationData specialization, GuardExpression guard) { + if (!specialization.isReachesFallback()) { + return Collections.emptyList(); + } + Set boundCaches = specialization.getBoundCaches(guard.getExpression(), false); + if (useSpecializationClass(specialization)) { + return Collections.emptyList(); + } else { + return boundCaches; + } + } - } else if (mode.isUncached()) { - BlockState ifCount = BlockState.NONE; + private IfTriple createNeverDefaultGuard(FrameState frameState, SpecializationData specialization, + CacheExpression cache, String operator) { - cachedTriples.addAll(createAssumptionCheck(frameState, specialization, NodeExecutionMode.UNCACHED, true)); + CodeTreeBuilder prepare = CodeTreeBuilder.createBuilder(); + CodeTreeBuilder condition = CodeTreeBuilder.createBuilder(); - ifCount = ifCount.add(IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false)); - cachedTriples = createMethodGuardChecks(frameState, group, guardExpressions, mode); + if (cache.isEncodedEnum()) { + CacheExpression sharedCache = lookupSharedCacheKey(cache); + condition.startGroup(); - BlockState innerIfCount = IfTriple.materialize(builder, IfTriple.optimize(cachedTriples), false); + StateQuery query = StateQuery.create(EncodedEnumState.class, sharedCache); + SpecializationStateReference ref = createStateReference(frameState, specialization, query); + condition.tree(ref.bitSet.createExtractInteger(ref.reference, query)); + condition.string(" ", operator, " 0"); + condition.end(); - prev = visitSpecializationGroupChildren(builder, frameState, prev, group, forType, allowedSpecializations); - if (specialization != null && (prev == null || prev.hasFallthrough())) { - builder.tree(createCallSpecialization(builder, frameState, forType, specialization)); - } - builder.end(innerIfCount.blockCount); - builder.end(ifCount.blockCount); - hasFallthrough |= ifCount.ifCount > 0 || innerIfCount.ifCount > 0; } else { - throw new AssertionError("unexpected path"); + LocalVariable wrapper = createCacheClassAccess(frameState, prepare, cache); + String localName = createCacheLocalName(cache); + CodeTree tree = createCacheAccess(frameState, specialization, cache, null); + if (wrapper == null) { + prepare.declaration(cache.getParameter().getType(), localName, tree); + condition.string(localName).string(operator).defaultValue(cache.getParameter().getType()); + setCacheInitialized(frameState, specialization, cache, true); + } else { + condition.tree(wrapper.createReference()).string(operator, "null"); + } } - group.setFallthrough(hasFallthrough); - - return builder.build(); + return new IfTriple(prepare.build(), condition.build(), null); } private SpecializationGroup visitSpecializationGroupChildren(final CodeTreeBuilder builder, FrameState frameState, SpecializationGroup prev, SpecializationGroup group, ExecutableTypeData forType, @@ -3932,7 +5198,7 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt } } CodeExecutableElement boundaryMethod = new CodeExecutableElement(modifiers(PRIVATE), parentMethod.getReturnType(), boundaryMethodName); - GeneratorUtils.mergeSupressWarnings(boundaryMethod, "static-method"); + GeneratorUtils.mergeSuppressWarnings(boundaryMethod, "static-method"); multiState.addParametersTo(frameState, boundaryMethod); frameState.addParametersTo(boundaryMethod, Integer.MAX_VALUE, includeFrameParameter, createSpecializationLocalName(specialization)); @@ -3944,6 +5210,19 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt builder.startReturn().startCall("this", boundaryMethod); multiState.addReferencesTo(frameState, builder); frameState.addReferencesTo(builder, includeFrameParameter, createSpecializationLocalName(specialization)); + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isAlwaysInitialized()) { + continue; + } + LocalVariable var = frameState.getCacheInitialized(specialization, cache); + if (var != null) { + CodeVariableElement v = var.createParameter(); + v.setName(createCacheLocalName(cache)); + boundaryMethod.addParameter(v); + builder.tree(var.createReference()); + } + } + builder.end().end(); return innerBuilder; @@ -3954,6 +5233,8 @@ private List createAssumptionCheck(FrameState frameState, Specializati return Collections.emptyList(); } + boolean useSpecializationClass = useSpecializationClass(specialization); + CodeTreeBuilder builder = new CodeTreeBuilder(null); List triples = new ArrayList<>(); @@ -3967,7 +5248,6 @@ private List createAssumptionCheck(FrameState frameState, Specializati /* * For the receiver null check we need to get to the root field expression. - * */ DSLExpression e = assumption.getExpression(); while (e instanceof Variable) { @@ -3978,6 +5258,10 @@ private List createAssumptionCheck(FrameState frameState, Specializati e = v.getReceiver(); } nullCheckReference = writeExpression(frameState, specialization, e); + if (!useSpecializationClass(specialization)) { + assumptionReference = createInlinedAccess(frameState, specialization, assumptionReference, null); + nullCheckReference = createInlinedAccess(frameState, specialization, nullCheckReference, null); + } } else { assumptionReference = createAssumptionReference(frameState, specialization, assumption); nullCheckReference = assumptionReference; @@ -3989,8 +5273,14 @@ private List createAssumptionCheck(FrameState frameState, Specializati } if (mode.isGuardFallback()) { builder.string("("); + if (useSpecializationClass) { + builder.tree(createGetSpecializationClass(frameState, specialization, true)); + builder.string(" == null || "); + } + builder.tree(nullCheckReference); builder.string(" == null || "); + builder.tree(createAssumptionGuard(assumptionReference)); builder.string(")"); } else { @@ -4014,8 +5304,13 @@ private CodeTree writeExpression(FrameState frameState, SpecializationData speci @Override public void visitCall(Call binary) { frameState.addThrownExceptions(binary.getResolvedMethod()); + if (ElementUtils.isDeprecated(binary.getResolvedMethod())) { + GeneratorUtils.mergeSuppressWarnings(frameState.method, "deprecation"); + } } + }); + return DSLExpressionGenerator.write(optimizeExpression(expression), null, castBoundTypes(bindExpressionValues(frameState, expression, specialization))); } @@ -4041,27 +5336,42 @@ private CodeTree createDuplicationCheck(CodeTreeBuilder parent, FrameState frame SpecializationData specialization = group.getSpecialization(); CodeTreeBuilder builder = parent.create(); - if (!useDuplicate) { + boolean multipleInstances = specialization.hasMultipleInstances(); + boolean useSpecializationClass = useSpecializationClass(specialization); + + if (useSpecializationClass) { builder.declaration("int", countName, CodeTreeBuilder.singleString("0")); } - if (useSpecializationClass(specialization)) { - builder.tree(loadSpecializationClass(frameState, specialization)); + + if (useSpecializationClass) { + builder.tree(loadSpecializationClass(frameState, specialization, true)); + builder.declaration(createSpecializationClassReferenceType(specialization), + createSpecializationLocalOriginalName(specialization), + createGetSpecializationClass(frameState, specialization, true)); } - if (!specialization.hasMultipleInstances()) { + + if (useDuplicate) { builder.declaration("boolean", duplicateFoundName, CodeTreeBuilder.singleString("false")); } + for (CacheExpression cache : specialization.getCaches()) { + createCacheClassAccess(frameState, builder, cache); + } + FrameState innerFrameState = frameState.copy(); - builder.startIf().tree(multiState.createContains(innerFrameState, new Object[]{specialization})).end().startBlock(); - if (specialization.hasMultipleInstances()) { + List duplicationTriples = new ArrayList<>(); + if (useSpecializationClass) { builder.startWhile().string(specializationLocalName, " != null").end().startBlock(); + } else { + duplicationTriples.add(new IfTriple(null, state.activeState.createContains(innerFrameState, StateQuery.create(SpecializationActive.class, specialization)), null)); } - List duplicationtriples = new ArrayList<>(); - duplicationtriples.addAll(createMethodGuardChecks(innerFrameState, group, guardExpressions, NodeExecutionMode.FAST_PATH)); - duplicationtriples.addAll(createAssumptionCheck(innerFrameState, specialization, NodeExecutionMode.SLOW_PATH, true)); - BlockState duplicationIfCount = IfTriple.materialize(builder, IfTriple.optimize(duplicationtriples), false); + duplicationTriples.addAll(createFastPathNeverDefaultGuards(innerFrameState, group.getSpecialization())); + duplicationTriples.addAll(createMethodGuardChecks(innerFrameState, group, guardExpressions, NodeExecutionMode.FAST_PATH)); + duplicationTriples.addAll(createAssumptionCheck(innerFrameState, specialization, NodeExecutionMode.SLOW_PATH, true)); + BlockState duplicationIfCount = IfTriple.materialize(builder, IfTriple.optimize(duplicationTriples), false); + if (useDuplicate) { builder.startStatement().string(duplicateFoundName, " = true").end(); } @@ -4078,25 +5388,36 @@ private CodeTree createDuplicationCheck(CodeTreeBuilder parent, FrameState frame cachesToInitialize.add(cache); } if (!cachesToInitialize.isEmpty()) { - List triples = initializeCaches(innerFrameState, NodeExecutionMode.FAST_PATH, group, cachesToInitialize, true, false); + List triples = initializeCaches(innerFrameState, NodeExecutionMode.FAST_PATH, group, + cachesToInitialize, true, false); IfTriple.materialize(builder, IfTriple.optimize(triples), true); } - if (specialization.hasMultipleInstances()) { + if (useSpecializationClass) { builder.statement("break"); } + builder.end(duplicationIfCount.blockCount); - if (useDuplicate) { - // no counting and next traversal necessary for duplication only check - } else { - if (specialization.getMaximumNumberOfInstances() > 1) { + if (useSpecializationClass) { + if (multipleInstances) { + builder.statement(countName + "++"); builder.startStatement().string(specializationLocalName, " = ", specializationLocalName, ".next_").end(); } else { - builder.statement(specializationLocalName + " = null"); + + if (specializationNeedsInitializedBit(specialization)) { + StateQuery initializedQuery = StateQuery.create(SpecializationCachesInitialized.class, specialization); + SpecializationStateReference ref = createStateReference(frameState, specialization, initializedQuery); + builder.startIf().tree(ref.bitSet.createContains(ref.reference, initializedQuery)).end().startBlock(); + builder.statement(countName + "++"); + builder.end(); + } else { + builder.statement(countName + "++"); + } + builder.statement(specializationLocalName, " = null"); + builder.statement("break"); } - builder.statement(countName + "++"); builder.end(); } @@ -4104,12 +5425,13 @@ private CodeTree createDuplicationCheck(CodeTreeBuilder parent, FrameState frame return builder.build(); } - private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, SpecializationGroup group, SpecializationData specialization, boolean aotSpecialize) { + private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, StateTransaction transaction, SpecializationGroup group, SpecializationData specialization, + boolean aotSpecialize) { CodeTreeBuilder builder = parent.create(); List triples = new ArrayList<>(); - triples.addAll(initializeSpecializationClass(frameState, specialization)); + triples.add(new IfTriple(initializeSpecializationClass(frameState, specialization, aotSpecialize), null, null)); triples.addAll(initializeCaches(frameState, frameState.getMode(), group, specialization.getCaches(), false, true)); triples.addAll(persistAssumptions(frameState, specialization)); @@ -4119,39 +5441,55 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, if (cache.isAlwaysInitialized()) { continue; } - if (types.Profile != null && ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile)) { + if (types.Profile != null && + (ElementUtils.isAssignable(cache.getParameter().getType(), types.Profile) || ElementUtils.isAssignable(cache.getParameter().getType(), types.InlinedProfile))) { CodeTreeBuilder b = builder.create(); b.startStatement(); - b.tree(createCacheReference(frameState, specialization, cache)); - b.string(".disable()"); + b.tree(createCacheAccess(frameState, specialization, cache, null)); + b.startCall(".disable"); + if (cache.getInlinedNode() != null) { + b.tree(createNodeAccess(frameState, specialization)); + } + b.end(); b.end(); triples.add(new IfTriple(null, null, b.build())); } } } - triples.addAll(persistSpecializationClass(frameState, specialization)); + if (specializationNeedsInitializedBit(specialization)) { + StateQuery query = StateQuery.create(SpecializationCachesInitialized.class, specialization); + SpecializationStateReference stateRef = createStateReference(frameState, specialization, query); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.startStatement(); + b.tree(stateRef.reference).string(" = "); + b.tree(stateRef.bitSet.createSetExpression(stateRef.reference, query, true)); + b.end(); + triples.add(new IfTriple(null, null, b.build())); + } + + triples.addAll(persistSpecializationClass(frameState, specialization, aotSpecialize)); builder.end(IfTriple.materialize(builder, triples, true).blockCount); List excludesSpecializations = new ArrayList<>(); - for (SpecializationData otherSpeciailzation : reachableSpecializations) { + for (SpecializationData otherSpeciailzation : node.getReachableSpecializations()) { if (otherSpeciailzation == specialization) { continue; } - if (otherSpeciailzation.getExcludedBy().contains(specialization)) { + if (otherSpeciailzation.getReplacedBy().contains(specialization)) { excludesSpecializations.add(otherSpeciailzation); } } if (!excludesSpecializations.isEmpty()) { - SpecializationData[] excludesArray = excludesSpecializations.toArray(new SpecializationData[0]); - builder.tree(exclude.createSet(frameState, excludesArray, true, true)); - for (SpecializationData excludes : excludesArray) { + for (SpecializationData excludes : excludesSpecializations) { if (useSpecializationClass(excludes)) { - builder.statement("this." + createSpecializationFieldName(excludes) + " = null"); + builder.startStatement(); + builder.tree(createSpecializationFieldAccess(frameState, excludes, true, true, null, CodeTreeBuilder.singleString("null"))); + builder.end(); } } - builder.tree((multiState.createSet(frameState, excludesArray, false, false))); + builder.tree((multiState.createSet(frameState, transaction, StateQuery.create(SpecializationActive.class, excludesSpecializations), false, false))); } return builder.build(); @@ -4167,16 +5505,16 @@ private List persistAssumptions(FrameState frameState, SpecializationD String name = createAssumptionFieldName(specialization, assumption); CodeTreeBuilder builder = new CodeTreeBuilder(null); builder.startStatement(); - builder.tree(createSpecializationFieldReference(frameState, specialization, name)).string(" = ").tree(var.createReference()); + builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, name, var.createReference())); builder.end(); triples.add(new IfTriple(builder.build(), null, null)); } return triples; } - private CodeTree loadSpecializationClass(FrameState frameState, SpecializationData specialization) { + private CodeTree loadSpecializationClass(FrameState frameState, SpecializationData specialization, boolean useUpdater) { if (!useSpecializationClass(specialization)) { - return null; + throw new AssertionError("Not using specialization class."); } String localName = createSpecializationLocalName(specialization); @@ -4190,15 +5528,25 @@ private CodeTree loadSpecializationClass(FrameState frameState, SpecializationDa } builder.string(localName); builder.string(" = "); - builder.tree(createSpecializationFieldReference(frameState, specialization, null)); + if (useUpdater) { + if (frameState.isInlinedNode()) { + builder.string("this.", createSpecializationFieldName(specialization)).startCall(".getVolatile"); + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + builder.end(); + } else { + builder.string(createSpecializationClassUpdaterName(specialization)).string(".getVolatile(this)"); + } + } else { + builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, null, null)); + } builder.end(); if (var == null) { - frameState.set(localName, new LocalVariable(new GeneratedTypeMirror("", typeName), localName, null)); + frameState.set(localName, new LocalVariable(createSpecializationClassReferenceType(specialization), localName, null)); } return builder.build(); } - private Collection persistSpecializationClass(FrameState frameState, SpecializationData specialization) { + private Collection persistSpecializationClass(FrameState frameState, SpecializationData specialization, boolean aotSpecialize) { if (!useSpecializationClass(specialization)) { return Collections.emptyList(); } @@ -4224,14 +5572,35 @@ private Collection persistSpecializationClass(FrameState frameState, S // here: we must ensure that the item that is being appended to the list is fully // initialized. builder.startStatement(); - builder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence"); - builder.end(); - builder.end(); - builder.startStatement(); - builder.string("this.", createSpecializationFieldName(specialization)); - builder.string(" = "); - builder.tree(ref); + builder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence").end(); builder.end(); + + if (!aotSpecialize && needsDuplicationCheck(specialization)) { + builder.startIf(); + if (frameState.isInlinedNode()) { + String fieldName = createSpecializationFieldName(specialization); + builder.string("!this.", fieldName); + builder.startCall(".compareAndSet"); + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + builder.string(createSpecializationLocalOriginalName(specialization)); + builder.tree(ref); + builder.end(); + } else { + builder.string("!").string(createSpecializationClassUpdaterName(specialization)).startCall(".compareAndSet"); + builder.string("this"); + builder.string(createSpecializationLocalOriginalName(specialization)); + builder.tree(ref); + builder.end(); + } + builder.end().startBlock(); + builder.statement("continue"); + builder.end(); + } else { + builder.startStatement(); + builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, null, ref)); + builder.end(); + } + return Arrays.asList(new IfTriple(builder.build(), null, null)); } @@ -4239,31 +5608,36 @@ private static String createSpecializationClassPersisted(SpecializationData spec return createSpecializationLocalName(specialization) + "$persisted"; } - private static void assertSpecializationClassNotInitialized(FrameState frameState, SpecializationData specialization) { - String framestateVarName = createSpecializationClassInitialized(specialization); - if (frameState.get(framestateVarName) != null) { - throw new AssertionError("Specialization class already initialized. " + specialization); - } - } - - private Collection initializeSpecializationClass(FrameState frameState, SpecializationData specialization) { + private CodeTree initializeSpecializationClass(FrameState frameState, SpecializationData specialization, boolean aotInitialize) { boolean useSpecializationClass = useSpecializationClass(specialization); if (useSpecializationClass) { String localName = createSpecializationLocalName(specialization); String typeName = createSpecializationTypeName(specialization); // we cannot use local name, because its used track reads not init writes - String classInitialized = createSpecializationClassInitialized(specialization); - if (!frameState.getBoolean(classInitialized, false)) { - GeneratedTypeMirror type = new GeneratedTypeMirror("", typeName); + if (!frameState.isSpecializationClassInitialized(specialization)) { + + if (frameState.getMode().isFastPath()) { + throw new AssertionError("Must never initilization the specialization cache on the fast-path."); + } + + TypeMirror type = createSpecializationClassReferenceType(specialization); CodeTreeBuilder initBuilder = new CodeTreeBuilder(null); boolean isNode = specializationClassIsNode(specialization); if (isNode) { - initBuilder.startCall("super", "insert"); + if (frameState.isInlinedNode()) { + initBuilder.startCall(frameState.getValue(INLINED_NODE_INDEX).createReference(), "insert"); + } else { + initBuilder.startCall("this.insert"); + } } initBuilder.startNew(typeName); - if (specialization.getMaximumNumberOfInstances() > 1) { - initBuilder.string(createSpecializationFieldName(specialization)); + if (specialization.hasMultipleInstances()) { + if (aotInitialize) { + initBuilder.tree(createSpecializationFieldAccess(frameState, specialization, true, false, null, null)); + } else { + initBuilder.string(createSpecializationLocalOriginalName(specialization)); + } } initBuilder.end(); // new if (isNode) { @@ -4283,20 +5657,16 @@ private Collection initializeSpecializationClass(FrameState builder.string(" = "); builder.tree(init); builder.end(); - frameState.setBoolean(classInitialized, true); + frameState.setSpecializationClassInitialized(specialization, true); frameState.set(localName, new LocalVariable(type, localName, CodeTreeBuilder.singleString(localName))); - return Arrays.asList(new IfTriple(builder.build(), null, null)); + return builder.build(); } } - return Collections.emptyList(); - } - - private static String createSpecializationClassInitialized(SpecializationData specialization) { - return createSpecializationLocalName(specialization) + "$initialized"; + return null; } - private CodeTree createUpdateImplicitCastState(CodeTreeBuilder parent, FrameState frameState, SpecializationData specialization) { + private CodeTree createUpdateImplicitCastState(CodeTreeBuilder parent, FrameState frameState, StateTransaction transaction, SpecializationData specialization) { CodeTreeBuilder builder = null; int signatureIndex = 0; for (Parameter p : specialization.getSignatureParameters()) { @@ -4307,7 +5677,10 @@ private CodeTree createUpdateImplicitCastState(CodeTreeBuilder parent, FrameStat if (builder == null) { builder = parent.create(); } - builder.tree(multiState.createSetInteger(frameState, new TypeGuard(p.getType(), signatureIndex), CodeTreeBuilder.singleString(implicitFieldName))); + StateQuery implicitCastState = StateQuery.create(ImplicitCastState.class, new TypeGuard(typeSystem, p.getType(), signatureIndex)); + builder.startStatement(); + builder.tree(multiState.createSetInteger(frameState, transaction, implicitCastState, CodeTreeBuilder.singleString(implicitFieldName))); + builder.end(); } signatureIndex++; } @@ -4398,41 +5771,35 @@ private CodeTree createCatchRewriteException(CodeTreeBuilder parent, Specializat private final Map removeThisMethods = new LinkedHashMap<>(); - private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState, ExecutableTypeData forType, SpecializationData specialization) { - CodeTreeBuilder builder = parent.create(); - - // slow path might be already already locked - if (!frameState.getMode().isSlowPath()) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); - } - - if (needsSpecializeLocking) { - builder.statement("lock.lock()"); - builder.startTryBlock(); - } + @SuppressWarnings("unchecked") + private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState, ExecutableTypeData forType, SpecializationData specialization) { + CodeTreeBuilder builder = parent.create(); - SpecializationData[] specializations; + List specializations = new ArrayList<>(); + specializations.add(specialization); if (specialization.getUncachedSpecialization() != null) { - specializations = new SpecializationData[]{specialization, specialization.getUncachedSpecialization()}; - } else { - specializations = new SpecializationData[]{specialization}; + specializations.add(specialization.getUncachedSpecialization()); } - // pass null frame state to ensure values are reloaded. - builder.tree(this.exclude.createSet(null, specializations, true, true)); - builder.tree(this.multiState.createSet(null, specializations, false, true)); + FrameState innerFrameState = frameState.copy(); + + StateQuery excludedQuery = StateQuery.create(SpecializationExcluded.class, specializations); + StateQuery activeQuery = StateQuery.create(SpecializationActive.class, specializations); + + builder.tree(this.multiState.createForceLoad(innerFrameState, activeQuery, excludedQuery)); + StateTransaction transaction = new StateTransaction(); + builder.tree(this.multiState.createSet(innerFrameState, transaction, activeQuery, false, false)); + builder.tree(this.multiState.createSet(innerFrameState, transaction, excludedQuery, true, false)); + builder.tree(this.multiState.persistTransaction(innerFrameState, transaction)); + for (SpecializationData removeSpecialization : specializations) { if (useSpecializationClass(removeSpecialization)) { - String fieldName = createSpecializationFieldName(removeSpecialization); - builder.statement("this." + fieldName + " = null"); + builder.startStatement(); + builder.tree(createSpecializationFieldAccess(innerFrameState, specialization, true, false, null, CodeTreeBuilder.singleString("null"))); + builder.end(); } } - if (needsSpecializeLocking) { - builder.end().startFinallyBlock(); - builder.statement("lock.unlock()"); - builder.end(); - } boolean hasUnexpectedResultRewrite = specialization.hasUnexpectedResultRewrite(); boolean hasReexecutingRewrite = !hasUnexpectedResultRewrite || specialization.getExceptions().size() > 1; @@ -4455,69 +5822,90 @@ private CodeTree createExcludeThis(CodeTreeBuilder parent, FrameState frameState return builder.build(); } - private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState frameState, ExecutableTypeData forType, SpecializationData specialization) { + private CodeTree createRemoveThis(CodeTreeBuilder parent, FrameState outerFrameState, ExecutableTypeData forType, SpecializationData specialization) { CodeExecutableElement method = removeThisMethods.get(specialization); String specializationLocalName = createSpecializationLocalName(specialization); + FrameState frameState = outerFrameState.copy(); + multiState.clearLoaded(frameState); + + TypeMirror specializationType = createSpecializationClassReferenceType(specialization); boolean useSpecializationClass = useSpecializationClass(specialization); + boolean inline = frameState.isInlinedNode(); if (method == null) { method = new CodeExecutableElement(context.getType(void.class), "remove" + specialization.getId() + "_"); + if (inline) { + method.addParameter(frameState.getValue(INLINED_NODE_INDEX).createParameter()); + } if (useSpecializationClass) { - method.addParameter(new CodeVariableElement(context.getType(Object.class), specializationLocalName)); + method.addParameter(new CodeVariableElement(specializationType, specializationLocalName)); } CodeTreeBuilder builder = method.createBuilder(); - if (needsSpecializeLocking) { - builder.declaration(context.getType(Lock.class), "lock", "getLock()"); - builder.statement("lock.lock()"); - builder.startTryBlock(); - } - String fieldName = createSpecializationFieldName(specialization); - if (!useSpecializationClass || specialization.getMaximumNumberOfInstances() == 1) { + if (!useSpecializationClass || !specialization.hasMultipleInstances()) { // single instance remove - builder.tree((multiState.createSet(null, new Object[]{specialization}, false, true))); + builder.tree((multiState.createSet(frameState, null, StateQuery.create(SpecializationActive.class, specialization), false, true))); if (useSpecializationClass) { - builder.statement("this." + fieldName + " = null"); + builder.startStatement(); + builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, null, CodeTreeBuilder.singleString("null"))); + builder.end(); } } else { // multi instance remove + builder.startWhile().string("true").end().startBlock(); String typeName = createSpecializationTypeName(specialization); boolean specializedIsNode = specializationClassIsNode(specialization); - builder.declaration(typeName, "prev", "null"); - builder.declaration(typeName, "cur", "this." + fieldName); - builder.startWhile(); - builder.string("cur != null"); - builder.end().startBlock(); + builder.declaration(typeName, "cur", createSpecializationFieldAccess(frameState, specialization, true, false, null, null)); + builder.declaration(typeName, "original", "cur"); + builder.declaration(typeName, "update", "null"); + + builder.startWhile().string("cur != null").end().startBlock(); + builder.startIf().string("cur == ").string(specializationLocalName).end().startBlock(); - builder.startIf().string("prev == null").end().startBlock(); - builder.statement("this." + fieldName + " = cur.next_"); - if (specializedIsNode) { - builder.statement("this.adoptChildren()"); - } + + builder.startIf().string("cur == original").end().startBlock(); + builder.statement("update = cur.next_"); builder.end().startElseBlock(); - builder.statement("prev.next_ = cur.next_"); - if (specializedIsNode) { - builder.statement("prev.adoptChildren()"); - } + builder.statement("update = original.remove(", specializationLocalName, ")"); builder.end(); builder.statement("break"); - builder.end(); // if block - builder.statement("prev = cur"); + builder.end(); // if cur == s0_ builder.statement("cur = cur.next_"); builder.end(); // while block - builder.startIf().string("this." + fieldName).string(" == null").end().startBlock(); - builder.tree((multiState.createSet(null, Arrays.asList(specialization).toArray(new SpecializationData[0]), false, true))); - builder.end(); - } + builder.startIf(); + builder.string("cur != null && "); + + if (frameState.isInlinedNode()) { + String fieldName = createSpecializationFieldName(specialization); + builder.string("!this.", fieldName); + builder.startCall(".compareAndSet"); + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } else { + builder.string("!").string(createSpecializationClassUpdaterName(specialization)).startCall(".compareAndSet"); + builder.string("this"); + } - if (needsSpecializeLocking) { - builder.end().startFinallyBlock(); - builder.statement("lock.unlock()"); + builder.string("original"); + builder.string("update"); + builder.end(); + builder.end().startBlock(); + builder.statement("continue"); builder.end(); + builder.statement("break"); + builder.end(); + builder.end(); + + if (specializedIsNode) { + builder.statement("this.adoptChildren()"); + } + } removeThisMethods.put(specialization, method); } CodeTreeBuilder builder = parent.create(); builder.startStatement().startCall(method.getSimpleName().toString()); + if (inline) { + builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); + } if (useSpecializationClass) { builder.string(specializationLocalName); } @@ -4574,7 +5962,7 @@ private CodeTree createCallExecute(ExecutableTypeData forType, ExecutableTypeDat private CodeTree createCallExecuteAndSpecialize(ExecutableTypeData forType, FrameState frameState) { TypeMirror returnType = node.getPolymorphicExecutable().getReturnType(); String frame = null; - if (needsFrameToExecute(reachableSpecializations)) { + if (needsFrameToExecute(node.getReachableSpecializations())) { frame = FRAME_VALUE; } @@ -4615,44 +6003,91 @@ private CodeTree createReturnUnexpectedResult(ExecutableTypeData forType, boolea return builder.build(); } - private List createMethodGuardChecks(FrameState frameState, SpecializationGroup group, List guardExpressions, NodeExecutionMode mode) { + private List createMethodGuardChecks(FrameState frameState, SpecializationGroup group, Collection guardExpressions, NodeExecutionMode mode) { List triples = new ArrayList<>(); + SpecializationData specialization = group.getSpecialization(); for (GuardExpression guard : guardExpressions) { - if (mode.isSlowPath() && !guard.isConstantTrueInSlowPath(context, mode.isUncached())) { - CodeTreeBuilder builder = new CodeTreeBuilder(null); - List innerTriples = new ArrayList<>(); - boolean guardStateBit = guardNeedsStateBit(group.getSpecialization(), guard); - FrameState innerFrameState = frameState; - if (guardStateBit) { - if (group.getSpecialization() == null) { - throw new AssertionError(); - } - innerFrameState = frameState.copy(); - builder.startIf().tree(multiState.createNotContains(innerFrameState, new Object[]{guard})).end().startBlock(); - innerTriples.addAll(initializeSpecializationClass(innerFrameState, group.getSpecialization())); - innerTriples.addAll(persistSpecializationClass(innerFrameState, group.getSpecialization())); - } - boolean store = !guardStateBit; + switch (mode) { + case SLOW_PATH: + triples.addAll(initializeCachesForSlowPathGuard(frameState, mode, group, guard)); + break; + case FAST_PATH: + triples.addAll(initializeCaches(frameState, mode, group, specialization.getBoundCaches(guard.getExpression(), true), true, false)); + break; + case FALLBACK_GUARD: + triples.addAll(initializeCasts(frameState, group, guard.getExpression(), mode)); + break; + case UNCACHED: + // nothing to do + break; + default: + throw new AssertionError("unhandled mode"); + } - Set boundCaches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); - innerTriples.addAll(initializeCaches(innerFrameState, mode, group, boundCaches, store, guardStateBit)); - innerTriples.addAll(initializeCasts(innerFrameState, group, guard.getExpression(), mode)); + triples.add(createMethodGuardCheck(frameState, specialization, guard, mode)); + } + return triples; + } - IfTriple.materialize(builder, innerTriples, true); + private List initializeCachesForSlowPathGuard(FrameState frameState, + NodeExecutionMode mode, SpecializationGroup group, GuardExpression guard) { + SpecializationData specialization = group.getSpecialization(); + boolean guardStateBit = guardNeedsStateBit(specialization, guard); + if (!guardStateBit && guard.isConstantTrueInSlowPath(context, mode.isUncached())) { + return Collections.emptyList(); + } - if (guardStateBit) { - builder.tree(multiState.createSet(innerFrameState, new Object[]{guard}, true, true)); - builder.end(); - } - triples.add(new IfTriple(builder.build(), null, null)); - } else if (mode.isGuardFallback()) { - triples.addAll(initializeCasts(frameState, group, guard.getExpression(), mode)); - } else if (mode.isFastPath()) { - triples.addAll(initializeCaches(frameState, mode, group, group.getSpecialization().getBoundCaches(guard.getExpression(), true), true, false)); + CodeTreeBuilder builder = new CodeTreeBuilder(null); + List triples = new ArrayList<>(); + StateQuery query = StateQuery.create(GuardActive.class, guard); + SpecializationStateReference stateRef = null; + if (guardStateBit) { + if (specialization == null) { + throw new AssertionError(); } - triples.add(createMethodGuardCheck(frameState, group.getSpecialization(), guard, mode)); + builder.tree(initializeSpecializationClass(frameState, group.getSpecialization(), false)); + stateRef = createStateReference(frameState, specialization, query); } - return triples; + + boolean store = !guardStateBit; + + Set boundCaches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); + + triples.addAll(initializeCaches(frameState, mode, group, boundCaches, store, guardStateBit)); + triples.addAll(initializeCasts(frameState, group, guard.getExpression(), mode)); + IfTriple.materialize(builder, triples, true); + + FrameState innerFrameState = frameState; + + if (guardStateBit) { + List innerTriples = new ArrayList<>(); + innerFrameState = frameState.copy(); + + builder.startIf().tree(stateRef.bitSet.createNotContains(stateRef.reference, StateQuery.create(GuardActive.class, guard))).end().startBlock(); + + builder.startStatement(); + builder.tree(stateRef.reference).string(" = "); + builder.tree(stateRef.bitSet.createSetExpression(stateRef.reference, query, true)); + builder.end(); + + innerTriples.addAll(persistSpecializationClass(innerFrameState, group.getSpecialization(), false)); + + if (useSpecializationClass(specialization) && needsDuplicationCheck(specialization)) { + CodeTreeBuilder b = builder.create(); + b.startStatement(); + b.string(createSpecializationLocalOriginalName(specialization)); + b.string(" = "); + b.tree(createGetSpecializationClass(frameState, specialization, true)); + b.end(); + innerTriples.add(new IfTriple(null, null, b.build())); + } + + IfTriple.materialize(builder, innerTriples, true); + + builder.end(); + } + + return Arrays.asList(new IfTriple(builder.build(), null, null)); } private List initializeCaches(FrameState frameState, NodeExecutionMode mode, SpecializationGroup group, Collection caches, boolean store, boolean forcePersist) { @@ -4662,28 +6097,40 @@ private List initializeCaches(FrameState frameState, NodeExecutionMode List triples = new ArrayList<>(); for (CacheExpression cache : caches) { if (cache.isEagerInitialize()) { + triples.addAll(createLoadCacheClass(frameState, cache)); continue; } else if (mode.isFastPath() && !cache.isAlwaysInitialized()) { + triples.addAll(createLoadCacheClass(frameState, cache)); continue; } else if (mode.isUncached() && cache.isWeakReference()) { continue; } boolean useStore = store; - if (cache.isAlwaysInitialized()) { + if (cache.isAlwaysInitialized() || sharedCaches.containsKey(cache)) { useStore = true; } triples.addAll(initializeCasts(frameState, group, cache.getDefaultExpression(), mode)); - triples.addAll(persistAndInitializeCache(frameState, group.getSpecialization(), cache, useStore, forcePersist)); + triples.addAll(persistAndInitializeCache(frameState, mode, group.getSpecialization(), cache, useStore, forcePersist)); } return triples; } - private Collection persistAndInitializeCache(FrameState frameState, SpecializationData specialization, CacheExpression cache, boolean store, boolean persist) { + private List createLoadCacheClass(FrameState frameState, CacheExpression cache) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + createCacheClassAccess(frameState, b, cache); + if (!b.isEmpty()) { + return Arrays.asList(new IfTriple(b.build(), null, null)); + } + return Collections.emptyList(); + } + + private Collection persistAndInitializeCache(FrameState frameState, NodeExecutionMode mode, SpecializationData specialization, CacheExpression cache, boolean store, boolean persist) { List triples = new ArrayList<>(); CodeTree init = initializeCache(frameState, specialization, cache); + if (store) { // store as local variable - triples.addAll(storeCache(frameState, specialization, cache, init)); + triples.addAll(storeCache(frameState, mode, specialization, cache, init)); } if (persist) { // persist to node instance @@ -4695,122 +6142,210 @@ private Collection persistAndInitializeCache(FrameState frameState, Sp private Collection persistCache(FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree cacheValue) { if (cache.isAlwaysInitialized()) { return Collections.emptyList(); + } + + List triples = new ArrayList<>(); + String name = createFieldName(specialization, cache); + LocalVariable local = frameState.get(name); + CodeTree value; + if (local != null) { + // already initialized and stored don't use init. + value = local.createReference(); + } else if (cacheValue == null) { + return Collections.emptyList(); } else { - List triples = new ArrayList<>(); - String name = createFieldName(specialization, cache.getParameter()); - LocalVariable local = frameState.get(name); - CodeTree value; - if (local != null) { - // already initialized and stored don't use init. - value = local.createReference(); - } else if (cacheValue == null) { - return Collections.emptyList(); - } else { - value = cacheValue; - } + value = cacheValue; + } - TypeMirror type = cache.getParameter().getType(); - String frameStateInitialized = name + "$initialized"; - if (frameState.getBoolean(frameStateInitialized, false)) { - return Collections.emptyList(); - } else { - frameState.setBoolean(frameStateInitialized, true); - } + String frameStateInitialized = name + "$initialized"; + if (frameState.getBoolean(frameStateInitialized, false)) { + return Collections.emptyList(); + } else { + frameState.setBoolean(frameStateInitialized, true); + } - CodeTreeBuilder builder = new CodeTreeBuilder(null); - Parameter parameter = cache.getParameter(); - boolean useSpecializationClass = useSpecializationClass(specialization); + CodeTreeBuilder builder = new CodeTreeBuilder(null); + value = createInsertNode(builder, frameState, specialization, cache, value); - String insertTarget; - if (useSpecializationClass) { - insertTarget = createSpecializationLocalName(specialization); - } else { - insertTarget = "super"; - } - TypeMirror nodeType = types.Node; - TypeMirror nodeArrayType = new ArrayCodeTypeMirror(types.Node); + boolean sharedCheck = sharedCaches.containsKey(cache); + boolean defaultCheck = !cache.isWeakReference() && cache.isNeverDefault() && !cache.isNeverDefaultGuaranteed(); - boolean isNode = isAssignable(parameter.getType(), nodeType); - boolean isNodeInterface = isNode || isAssignable(type, types.NodeInterface); - boolean isNodeArray = isAssignable(type, nodeArrayType); - boolean isNodeInterfaceArray = isNodeArray || isNodeInterfaceArray(type); + if (sharedCheck || defaultCheck) { - if (isNodeInterface || isNodeInterfaceArray) { - builder = new CodeTreeBuilder(null); - String insertName; - if (cache.isAdopt()) { - insertName = useSpecializationClass ? useInsertAccessor(specialization, isNodeInterfaceArray) : "insert"; - } else { - insertName = null; + String localName = createCacheLocalName(cache); + String defaultValue = ElementUtils.defaultValue(cache.getParameter().getType()); + boolean cacheInitialized = isCacheInitialized(frameState, specialization, cache); + + if (sharedCheck) { + if (!cacheInitialized) { + builder.declaration(cache.getParameter().getType(), localName, value); } - final TypeMirror castType; - if (isNodeInterface) { - if (isNode) { - castType = null; - } else { - castType = nodeType; - } + LocalVariable cacheClass = createCacheClassAccess(frameState, builder, cache); + if (cacheClass != null) { + builder.startIf().tree(cacheClass.createReference()).string(" == null").end().startBlock(); + + builder.startStatement(); + builder.string(cacheClass.getName(), " = "); + builder.tree(createInsertNode(builder, frameState, specialization, cache, builder.create().startNew(createCacheClassType(cache)).end().build())); + builder.end(); + + builder.startStatement(); + builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); + builder.end(); + + builder.startStatement(); + builder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence").end(); + builder.end(); + + builder.startStatement(); + builder.tree(createInlinedAccess(frameState, null, CodeTreeBuilder.singleString("this." + name), cacheClass.createReference())); + builder.end(); + + builder.end(); + } else { - assert isNodeInterfaceArray; - if (isNodeArray) { - castType = null; + if (cache.isEncodedEnum()) { + IfTriple triple = createNeverDefaultGuard(frameState, specialization, cache, " == "); + builder.startIf().tree(triple.condition).end().startBlock(); } else { - castType = nodeArrayType; - } - } - if (castType == null) { - CodeTreeBuilder noCast = new CodeTreeBuilder(null); - if (cache.isAdopt()) { - noCast.startCall(insertTarget, insertName); + builder.startIf().tree(createCacheAccess(frameState, specialization, cache, null)).string(" == ").string(defaultValue).end().startBlock(); } - noCast.tree(value); - if (cache.isAdopt()) { - noCast.end(); - } - value = noCast.build(); - } else { - String fieldName = createFieldName(specialization, cache.getParameter()) + "__"; - builder.declaration(cache.getDefaultExpression().getResolvedType(), fieldName, value); - if (cache.isAdopt()) { - builder.startIf().string(fieldName).instanceOf(castType).end().startBlock(); - builder.startStatement(); - builder.startCall(insertTarget, insertName); - builder.startGroup().cast(castType).string(fieldName).end(); - builder.end().end(); + + if (!cacheInitialized) { + checkSharedCacheNull(builder, localName, specialization, cache); } + + builder.startStatement(); + builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); + builder.end(); + builder.end(); - value = CodeTreeBuilder.singleString(fieldName); - } - } - - CodeTree cacheReference = createCacheReference(frameState, specialization, cache); - if (cache.isUsedInGuard() && !cache.isEagerInitialize() && sharedCaches.containsKey(cache) && - !ElementUtils.isPrimitive(cache.getParameter().getType())) { - builder.startIf().tree(cacheReference).string(" == null").end().startBlock(); - String localName = createCacheLocalName(specialization, cache) + "_check"; - builder.declaration(cache.getParameter().getType(), localName, value); - builder.startIf().string(localName).string(" == null").end().startBlock(); - builder.startThrow().startNew(context.getType(AssertionError.class)).doubleQuote( - String.format("Specialization '%s' contains a shared cache with name '%s' that returned a null value for the cached initializer. " + - "Null values are not supported for shared cached initializers because null is reserved for the uninitialized state.", - ElementUtils.getReadableSignature(specialization.getMethod()), - cache.getParameter().getLocalName())).end().end(); + } + builder.end(); + builder.end(); + + } else if (defaultCheck) { + if (cacheInitialized) { + GeneratorUtils.mergeSuppressWarnings(frameState.method, "unused"); + } else { + builder.declaration(cache.getParameter().getType(), localName, value); + value = CodeTreeBuilder.singleString(localName); + } + builder.startIf().tree(value).string(" == ").string(defaultValue).end().startBlock(); + + String message = String.format( + "Specialization '%s' cache '%s' returned a '%s' default value. The cache initializer must never return a default value for this cache. " + + "Use @%s(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns '%s'.", + ElementUtils.getReadableSignature(specialization.getMethod()), + cache.getParameter().getLocalName(), + defaultValue, + getSimpleName(types.Cached), + defaultValue); + + builder.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote(message).end().end(); builder.end(); - builder.startStatement().tree(cacheReference).string(" = ").string(localName).end(); + builder.end(); + builder.startStatement().tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))).end(); } else { - builder.startStatement().tree(cacheReference).string(" = ").tree(value).end(); + throw new AssertionError(); } + setCacheInitialized(frameState, specialization, cache, true); - triples.add(new IfTriple(builder.build(), null, null)); - return triples; + } else { + builder.startStatement().tree(createCacheAccess(frameState, specialization, cache, value)).end(); + } + + triples.add(new IfTriple(builder.build(), null, null)); + return triples; + + } + + private CodeTree createInsertNode(CodeTreeBuilder builder, FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { + if (cache.isAlwaysInitialized()) { + return value; + } else if (cache.isBind()) { + return value; + } + + Parameter parameter = cache.getParameter(); + TypeMirror nodeType = types.Node; + TypeMirror nodeArrayType = new ArrayCodeTypeMirror(types.Node); + TypeMirror type = parameter.getType(); + boolean isNode = isAssignable(parameter.getType(), nodeType); + boolean isNodeInterface = isNode || isAssignable(type, types.NodeInterface); + boolean isNodeArray = isAssignable(type, nodeArrayType); + boolean isNodeInterfaceArray = isNodeArray || isNodeArray(type); + + if (isNodeInterface || isNodeInterfaceArray) { + CodeTree insertTarget; + + if (frameState.isSpecializationClassInitialized(specialization) && specializationClassIsNode(specialization)) { + insertTarget = singleString(createSpecializationLocalName(specialization)); + } else { + insertTarget = createNodeAccess(frameState); + } + final TypeMirror castType; + if (isNodeInterface) { + if (isNode) { + castType = null; + } else { + castType = nodeType; + } + } else { + assert isNodeInterfaceArray; + if (isNodeArray) { + castType = null; + } else { + castType = nodeArrayType; + } + } + if (castType == null) { + CodeTreeBuilder noCast = new CodeTreeBuilder(null); + if (cache.isAdopt()) { + noCast.startCall(insertTarget, "insert"); + } + noCast.tree(value); + if (cache.isAdopt()) { + noCast.end(); + } + return noCast.build(); + } else { + String fieldName = createFieldName(specialization, cache) + "__"; + builder.declaration(cache.getDefaultExpression().getResolvedType(), fieldName, value); + if (cache.isAdopt()) { + builder.startIf().string(fieldName).instanceOf(castType).end().startBlock(); + builder.startStatement(); + builder.startCall(insertTarget, "insert"); + builder.startGroup().cast(castType).string(fieldName).end(); + builder.end().end(); + } + builder.end(); + return CodeTreeBuilder.singleString(fieldName); + } + } + return value; + } + + private static CodeTree createNodeAccess(FrameState frameState, SpecializationData specialization) { + if (specialization != null && substituteNodeWithSpecializationClass(specialization) && !frameState.getMode().isUncached()) { + return singleString(createSpecializationLocalName(specialization)); + } else { + return createNodeAccess(frameState); } + } + private static CodeTree createNodeAccess(FrameState frameState) { + if (frameState.isInlinedNode()) { + return frameState.getValue(INLINED_NODE_INDEX).createReference(); + } else { + return singleString("this"); + } } private Map> uniqueCachedParameterLocalNames = new HashMap<>(); - private Collection storeCache(FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { + private Collection storeCache(FrameState frameState, NodeExecutionMode mode, SpecializationData specialization, CacheExpression cache, CodeTree value) { if (value == null) { return Collections.emptyList(); } @@ -4821,44 +6356,105 @@ private Collection storeCache(FrameState frameState, SpecializationDat TypeMirror type = cache.getParameter().getType(); CodeTreeBuilder builder = new CodeTreeBuilder(null); - String refName = createCacheLocalName(specialization, cache); + String refName = createCacheLocalName(cache); - CodeTree useValue; - if ((ElementUtils.isAssignable(type, types.Node) || ElementUtils.isAssignable(type, new ArrayCodeTypeMirror(types.Node))) && - (!cache.isAlwaysInitialized()) && cache.isAdopt()) { - useValue = builder.create().startCall("super.insert").tree(value).end().build(); - } else { - useValue = value; + if (mode.isSlowPath() && cacheNeedsSpecializationClass(frameState, specialization, cache)) { + builder.tree(initializeSpecializationClass(frameState, specialization, false)); } - if (cache.isAlwaysInitialized() && frameState.getMode().isSlowPath()) { + + CodeTree useValue = createInsertNode(builder, frameState, specialization, cache, value); + + if (sharedCaches.containsKey(cache)) { + builder.declaration(type, refName, (CodeTree) null); + + LocalVariable cacheClass = createCacheClassAccess(frameState, builder, cache); + if (cacheClass != null) { + builder.startIf().tree(cacheClass.createReference()).string(" != null").end().startBlock(); + builder.startStatement(); + builder.string(refName).string(" = ").tree(createCacheAccess(frameState, specialization, cache, null)); + builder.end(); + builder.end().startElseBlock(); + builder.startStatement(); + builder.string(refName).string(" = ").tree(useValue); + builder.end(); + } else { + String sharedName = refName + "_shared"; + builder.declaration(type, sharedName, createCacheAccess(frameState, specialization, cache, null)); + builder.startIf().string(sharedName).string(" != ").string(ElementUtils.defaultValue(cache.getParameter().getType())).end().startBlock(); + builder.startStatement(); + builder.string(refName).string(" = ").string(sharedName); + builder.end(); + builder.end().startElseBlock(); + builder.startStatement(); + builder.string(refName).string(" = ").tree(useValue); + builder.end(); + checkSharedCacheNull(builder, refName, specialization, cache); + } + + builder.end(); + builder.end(); + + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + + b.tree(createCacheAccess(frameState, specialization, cache, null)); + b.string(" == "); + b.string(ElementUtils.defaultValue(cache.getParameter().getType())); + b.string(" ? "); + b.tree(useValue); + b.string(" : "); + b.tree(createCacheAccess(frameState, specialization, cache, null)); + + useValue = b.build(); + } else if (cache.isAlwaysInitialized() && frameState.getMode().isSlowPath()) { builder.startStatement().string(refName, " = ").tree(useValue).end(); } else { builder.declaration(type, refName, useValue); } setCacheInitialized(frameState, specialization, cache, true); + List triples = new ArrayList<>(); triples.add(new IfTriple(builder.build(), null, null)); return triples; } - private boolean isCacheInitialized(FrameState frameState, SpecializationData specialization, CacheExpression cache) { - String name = createFieldName(specialization, cache.getParameter()); - return frameState.get(name) != null; + private static boolean cacheNeedsSpecializationClass(FrameState frameState, SpecializationData specialization, CacheExpression cache) { + return frameState.getMode().isSlowPath() && substituteNodeWithSpecializationClass(specialization) && specialization.isNodeReceiverBound(cache.getDefaultExpression()); + } + + private void checkSharedCacheNull(CodeTreeBuilder builder, String refName, SpecializationData specialization, CacheExpression cache) { + if (useCacheClass(specialization, cache)) { + // no shared check needed. + return; + } + builder.startIf().string(refName).string(" == ").string(ElementUtils.defaultValue(cache.getParameter().getType())).end().startBlock(); + String message = String.format("Specialization '%s' contains a shared cache with name '%s' that returned a default value for the cached initializer. " + + "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", + ElementUtils.getReadableSignature(specialization.getMethod()), + cache.getParameter().getLocalName()); + builder.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote(message).end().end(); + builder.end(); + } + + private static boolean isCacheInitialized(FrameState frameState, SpecializationData specialization, CacheExpression cache) { + return frameState.getCacheInitialized(specialization, cache) != null; } private void setCacheInitialized(FrameState frameState, SpecializationData specialization, CacheExpression cache, boolean initialized) { - String name = createFieldName(specialization, cache.getParameter()); + String name = createFieldName(specialization, cache); if (initialized) { frameState.set(name, new LocalVariable(cache.getParameter().getType(), name, - CodeTreeBuilder.singleString(createCacheLocalName(specialization, cache)))); + CodeTreeBuilder.singleString(createCacheLocalName(cache)))); } else { frameState.set(name, null); } } - private String createCacheLocalName(SpecializationData specialization, CacheExpression cache) { - String name = createFieldName(specialization, cache.getParameter()); + private String createCacheLocalName(CacheExpression cache) { + String name = sharedCaches.get(cache); + if (name == null) { + name = firstLetterLowerCase(cache.getParameter().getLocalName()) + "_"; + } String refName = name + "_"; List variables = uniqueCachedParameterLocalNames.computeIfAbsent(refName, (v) -> new ArrayList<>()); int index = variables.indexOf(cache.getParameter()); @@ -4873,7 +6469,7 @@ private String createCacheLocalName(SpecializationData specialization, CacheExpr } private CodeTree initializeCache(FrameState frameState, SpecializationData specialization, CacheExpression cache) { - String name = createFieldName(specialization, cache.getParameter()); + String name = createFieldName(specialization, cache); if (frameState.get(name) != null) { // already initialized return null; @@ -4898,31 +6494,25 @@ private CodeTree initializeCache(FrameState frameState, SpecializationData speci expression = cache.getUncachedExpression(); } else { expression = cache.getDefaultExpression(); - if (aot) { + if (aot && expression != null) { expression = substituteManualToAutoDispatch(expression); } - if (specialization.needsTruffleBoundary() && - (specialization.isAnyLibraryBoundInGuard() || specialization.needsVirtualFrame())) { - /* - * Library.getUncached() should be used instead of Library.getUncached(receiver) - * in order to avoid non TruffleBoundary virtual dispatches on the compiled code - * path. - */ - expression = substituteToDispatchedUncached(expression); + if (cache.getInlinedNode() != null) { + // no initialization necessary + return null; + } else { + if (specialization.needsTruffleBoundary() && + (specialization.isAnyLibraryBoundInGuard() || specialization.needsVirtualFrame())) { + /* + * Library.getUncached() should be used instead of + * Library.getUncached(receiver) in order to avoid non TruffleBoundary + * virtual dispatches on the compiled code path. + */ + expression = substituteToDispatchedUncached(expression); + } } } - String sharedName; - if (frameState.getMode().isSlowPath() && !frameState.getBoolean(AOT_STATE, false) && !cache.isEagerInitialize() && (sharedName = sharedCaches.get(cache)) != null && - !ElementUtils.isPrimitive(cache.getParameter().getType())) { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.string("this.").string(sharedName).string(" == null ? ("); - builder.tree(writeExpression(frameState, specialization, expression)); - builder.string(") : "); - builder.string("this.").string(sharedName); - tree = builder.build(); - } else { - tree = writeExpression(frameState, specialization, expression); - } + tree = writeExpression(frameState, specialization, expression); } return tree; @@ -4985,37 +6575,76 @@ public DSLExpression visitBinary(Binary binary) { } private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationData specialization, GuardExpression guard, NodeExecutionMode mode) { + CodeTreeBuilder init = CodeTreeBuilder.createBuilder(); + CodeTreeBuilder condition = CodeTreeBuilder.createBuilder(); DSLExpression expression = optimizeExpression(guard.getExpression()); - CodeTree init = null; - CodeTree expressionCode = writeExpression(frameState, specialization, expression); + if (mode.isGuardFallback()) { GuardExpression guardWithBit = getGuardThatNeedsStateBit(specialization, guard); if (guardWithBit != null) { - CodeTreeBuilder builder = new CodeTreeBuilder(null); - builder.string("("); - builder.tree(multiState.createNotContains(frameState, new Object[]{guardWithBit})); - builder.string(" || "); - builder.tree(expressionCode); - builder.string(")"); - expressionCode = builder.build(); + condition.string("("); + StateQuery query = StateQuery.create(GuardActive.class, guardWithBit); + SpecializationStateReference ref = createStateReference(frameState, specialization, StateQuery.create(GuardActive.class, guardWithBit)); + + if (useSpecializationClass(specialization)) { + condition.tree(createGetSpecializationClass(frameState, specialization, true)); + condition.string(" == null || "); + } + + condition.tree(ref.bitSet.createNotContains(ref.reference, query)); + condition.string(" || "); + + for (CacheExpression cache : getNullCachesDueToFallback(specialization, guard)) { + String localName = createCacheLocalName(cache); + if (!isCacheInitialized(frameState, specialization, cache)) { + init.startStatement(); + init.type(cache.getParameter().getType()); + init.string(" ", localName, " = "); + + if (useSpecializationClass(specialization) && cache.getSharedGroup() == null) { + init.tree(createGetSpecializationClass(frameState, specialization, true)); + init.string(" == null ? null : "); + } + + init.tree(createCacheAccess(frameState, specialization, cache, null)); + init.end(); + setCacheInitialized(frameState, specialization, cache, true); + } + + condition.string(localName).string(" == ").defaultValue(cache.getParameter().getType()); + condition.string(" || "); + } + + condition.tree(writeExpression(frameState, specialization, expression)); + condition.string(")"); fallbackNeedsState = true; + } else { + condition.tree(writeExpression(frameState, specialization, expression)); } } + if (mode.isSlowPath() && specialization.isNodeReceiverBound(expression) && substituteNodeWithSpecializationClass(specialization)) { + init.tree(initializeSpecializationClass(frameState, specialization, false)); + } + CodeTree assertion = null; // overrule with assertion if (mode.isFastPath()) { + CodeTree guardExpression = writeExpression(frameState, specialization, expression); if (!specialization.isDynamicParameterBound(expression, true) && !guard.isWeakReferenceGuard()) { - assertion = CodeTreeBuilder.createBuilder().startAssert().tree(expressionCode).end().build(); - expressionCode = null; + assertion = CodeTreeBuilder.createBuilder().startAssert().tree(guardExpression).end().build(); + } else { + condition.tree(guardExpression); } } else if (mode.isSlowPath() || mode.isUncached()) { + CodeTree guardExpression = writeExpression(frameState, specialization, expression); if (guard.isConstantTrueInSlowPath(context, mode.isUncached())) { - assertion = CodeTreeBuilder.createBuilder().startStatement().string("// assert ").tree(expressionCode).end().build(); - expressionCode = null; + assertion = CodeTreeBuilder.createBuilder().startStatement().string("// assert ").tree(guardExpression).end().build(); + } else { + condition.tree(guardExpression); } } - return new IfTriple(init, expressionCode, assertion); + return new IfTriple(init.build(), condition.build(), assertion); } private static Map castBoundTypes(Map bindings) { @@ -5051,6 +6680,14 @@ private Map bindExpressionValues(FrameState frameState, if (localVariable != null) { bindings.put(variable, localVariable); } + } else if (specialization.isNodeReceiverVariable(variable.getResolvedVariable())) { + CodeTree accessor = createNodeAccess(frameState, specialization); + if (substituteNodeWithSpecializationClass(specialization) && !frameState.mode.isUncached()) { + String localName = createSpecializationLocalName(specialization); + bindings.put(variable, new LocalVariable(types.Node, localName, accessor)); + } else { + bindings.put(variable, new LocalVariable(variable.getResolvedType(), "this", accessor)); + } } } return bindings; @@ -5060,12 +6697,12 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati LocalVariable localVariable; if (resolvedParameter.getSpecification().isCached()) { // bind cached variable - String cachedMemberName = createFieldName(specialization, resolvedParameter); + CacheExpression cache = specialization.findCache(resolvedParameter); + String cachedMemberName = createFieldName(specialization, cache); localVariable = frameState.get(cachedMemberName); CodeTree ref; if (localVariable == null) { - CacheExpression cache = specialization.findCache(resolvedParameter); - ref = createCacheReference(frameState, specialization, cache); + ref = createCacheAccess(frameState, specialization, cache, null); } else { ref = localVariable.createReference(); } @@ -5074,7 +6711,20 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati // bind local variable if (resolvedParameter.getSpecification().isSignature()) { NodeExecutionData execution = resolvedParameter.getSpecification().getExecution(); - localVariable = frameState.getValue(execution); + if (!frameState.getMode().isUncached() && specialization.isNodeReceiverVariable(resolvedParameter.getVariableElement())) { + if (substituteNodeWithSpecializationClass(specialization)) { + String localName = createSpecializationLocalName(specialization); + localVariable = new LocalVariable(types.Node, localName, createGetSpecializationClass(frameState, specialization, true)); + } else { + if (frameState.isInlinedNode()) { + localVariable = frameState.getValue(execution); + } else { + localVariable = new LocalVariable(types.Node, "this", CodeTreeBuilder.singleString("this")); + } + } + } else { + localVariable = frameState.getValue(execution); + } } else { localVariable = frameState.get(resolvedParameter.getLocalName()); } @@ -5082,52 +6732,334 @@ private LocalVariable bindExpressionVariable(FrameState frameState, Specializati return localVariable; } - private CodeTree createSpecializationFieldReference(FrameState frameState, SpecializationData s, String fieldName) { + private static boolean substituteNodeWithSpecializationClass(SpecializationData specialization) { + if (!useSpecializationClass(specialization)) { + return false; + } + if (!specializationClassIsNode(specialization)) { + return false; + } + if (useParentInlinedAccess(specialization)) { + // we always need to pass the target node if that happens. + return true; + } else if (hasSharedInlinedCache(specialization)) { + return false; + } + if (specialization.hasMultipleInstances()) { + return true; + } + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getSharedGroup() == null && cache.getInlinedNode() != null) { + return true; + } + } + return false; + } + + private static boolean hasSharedInlinedCache(SpecializationData specialization) { + boolean hasSharedInlined = false; + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getInlinedNode() != null && !canCacheBeStoredInSpecialializationClass(cache) && cache.getSharedGroup() != null) { + hasSharedInlined = true; + break; + } + } + return hasSharedInlined; + } + + private CodeTree createSpecializationFieldAccess(FrameState frameState, SpecializationData specialization, boolean useSpecializationClass, boolean useSpecializationClassLocal, String fieldName, + CodeTree value) { CodeTreeBuilder builder = new CodeTreeBuilder(null); - if (useSpecializationClass(s)) { - String localName = createSpecializationLocalName(s); - LocalVariable var = frameState.get(localName); + + if (value != null && fieldName == null) { + if (useSpecializationClass(specialization)) { + builder.string("this.", createSpecializationFieldName(specialization)); + return createInlinedAccess(frameState, null, builder.build(), value); + } else { + throw new AssertionError("Cannot set this"); + } + } else { + CodeTree specializationClass = useSpecializationClass ? createGetSpecializationClass(frameState, specialization, useSpecializationClassLocal) : null; + if (specializationClass != null) { + builder.tree(specializationClass); + + if (fieldName != null) { + builder.string("."); + builder.string(fieldName); + } + + if (value != null) { + builder.string(" = ").tree(value); + } + } else { + if (fieldName == null) { + throw new AssertionError("Invalid specialization field access."); + } + builder.string("this."); + builder.string(fieldName); + return createInlinedAccess(frameState, specialization, builder.build(), value); + } + } + + return builder.build(); + } + + private CodeTree createGetSpecializationClass(FrameState frameState, SpecializationData specialization, boolean useLocal) { + if (useSpecializationClass(specialization)) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + String localName = createSpecializationLocalName(specialization); + LocalVariable var = useLocal ? frameState.get(localName) : null; if (var != null) { builder.string(localName); + return builder.build(); } else { - builder.string("this.", createSpecializationFieldName(s)); + builder.string("this.", createSpecializationFieldName(specialization)); + return createInlinedAccess(frameState, null, builder.build(), null); } } else { - builder.string("this"); + return null; + } + } + + private LocalVariable createCacheClassAccess(FrameState frameState, + CodeTreeBuilder builder, CacheExpression cache) { + if (cache.getSharedGroup() == null) { + return null; } - if (fieldName != null) { - builder.string("."); - builder.string(fieldName); + if (!useCacheClass(null, cache)) { + return null; } - return builder.build(); + + String name = createFieldName(null, cache); + String key = name + "$wrapper"; + LocalVariable var = frameState.get(key); + if (var != null) { + // already initialized + return var; + } + if (builder != null) { + TypeMirror type = createCacheClassType(cache); + String localName = name + "_wrapper"; + builder.declaration(type, localName, createInlinedAccess(frameState, null, CodeTreeBuilder.singleString("this." + name), null)); + var = new LocalVariable(type, localName, CodeTreeBuilder.singleString(localName)); + frameState.set(key, var); + } + + return var; } - private CodeTree createCacheReference(FrameState frameState, SpecializationData specialization, CacheExpression cache) { + private CodeTree createCacheAccess(FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { if (cache == null) { return CodeTreeBuilder.singleString("null /* cache not resolved */"); } - if (frameState.getMode().isUncached()) { + if (frameState.getMode().isUncached() || cache.isAlwaysInitialized()) { return initializeCache(frameState, specialization, cache); - } else { - if (cache.isAlwaysInitialized()) { - return initializeCache(frameState, specialization, cache); + } + if (cache.getInlinedNode() != null) { + if (frameState.isInlinedNode()) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + String cacheFieldName = createLocalCachedInlinedName(specialization, cache); + builder.string("this.", cacheFieldName); + if (value != null) { + throw new AssertionError("Cannot set inlined field."); + } + return builder.build(); } else { - String sharedName = sharedCaches.get(cache); - CodeTree ref; - if (sharedName != null) { - ref = CodeTreeBuilder.createBuilder().string("this.").string(sharedName).build(); - } else { - String cacheFieldName = createFieldName(specialization, cache.getParameter()); - ref = createSpecializationFieldReference(frameState, specialization, cacheFieldName); + return CodeTreeBuilder.singleString(createStaticInlinedCacheName(specialization, cache)); + } + } else if (cache.isEncodedEnum()) { + if (value == null) { + return createDecodeEnum(frameState, specialization, cache); + } else { + return createEncodeEnum(frameState, specialization, cache, value); + } + } else if (cache.getSharedGroup() != null) { + String cacheFieldName = createFieldName(specialization, cache); + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + LocalVariable cacheClass = createCacheClassAccess(frameState, null, cache); + if (cacheClass != null) { + builder.tree(cacheClass.createReference()).string(".delegate"); + if (value != null) { + builder.string(" = ").tree(value); } - return ref; + return builder.build(); + } else { + builder.string("this.").string(cacheFieldName); + if (useCacheClass(specialization, cache)) { + builder.string(".delegate"); + } + CodeTree nodeAccess = createNodeAccess(frameState); + return createInlinedAccess(frameState, specialization, builder.build(), value, nodeAccess); + } + } else { + String cacheFieldName = createLocalCachedInlinedName(specialization, cache); + return createSpecializationFieldAccess(frameState, specialization, true, true, cacheFieldName, value); + } + } + + private CodeTree createEncodeEnum(FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { + CodeTreeBuilder innerValue = CodeTreeBuilder.createBuilder(); + + innerValue.startGroup().string("("); + if (cache.isNeverDefaultGuaranteed()) { + innerValue.tree(value); + innerValue.string(".ordinal()"); + } else { + CodeExecutableElement method = lookupEncodeEnum(cache.getParameter().getType()); + innerValue.startCall(method.getSimpleName().toString()); + innerValue.tree(value); + innerValue.end(); + } + innerValue.string(" + ").string(getEncodedEnumOffset(cache)); + innerValue.string(")").end(); + + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + StateQuery query = StateQuery.create(EncodedEnumState.class, lookupSharedCacheKey(cache)); + SpecializationStateReference ref = createStateReference(frameState, specialization, query); + builder.tree(ref.bitSet.createSetInteger(ref.reference, query, innerValue.build())); + + return builder.build(); + } + + private static int getEncodedEnumOffset(CacheExpression cache) { + if (cache.isNeverDefault()) { + return 1; + } else { + return 2; + } + } + + private CodeTree createDecodeEnum(FrameState frameState, SpecializationData specialization, CacheExpression cache) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + CodeExecutableElement decodeMethod = lookupDecodeEnum(cache.getParameter().getType()); + StateQuery query = StateQuery.create(EncodedEnumState.class, lookupSharedCacheKey(cache)); + + builder.startCall(decodeMethod.getSimpleName().toString()); + builder.startGroup().string("("); + + SpecializationStateReference reference = createStateReference(frameState, specialization, query); + builder.tree(reference.bitSet.createExtractInteger(reference.reference, query)); + builder.string(")"); + builder.string(" - ").string(getEncodedEnumOffset(cache)); + builder.end(); // group + builder.end(); // call + return builder.build(); + } + + static class SpecializationStateReference { + + final BitSet bitSet; + final CodeTree reference; + + SpecializationStateReference(BitSet set, CodeTree reference) { + Objects.requireNonNull(set); + Objects.requireNonNull(reference); + this.bitSet = set; + this.reference = reference; + } + + } + + private SpecializationStateReference createStateReference(FrameState frameState, SpecializationData specialization, StateQuery query) { + MultiStateBitSet multiSet = specialization != null ? lookupSpecializationState(specialization) : null; + BitSet foundSet = null; + if (multiSet != null) { + foundSet = multiSet.findSet(query); + } + CodeTree reference; + if (foundSet == null) { // state is in node + multiSet = multiState; + foundSet = multiSet.findSet(query); + if (foundSet == null) { + throw new AssertionError("Could not find state."); + } + reference = foundSet.createReference(frameState); + } else { // state is in specialization class + CodeTreeBuilder inner = CodeTreeBuilder.createBuilder(); + inner.tree(createGetSpecializationClass(frameState, specialization, true)); + inner.string(".", foundSet.getName(), "_"); + reference = inner.build(); + } + return new SpecializationStateReference(foundSet, reference); + } + + private CodeExecutableElement lookupEncodeEnum(TypeMirror mirror) { + String typeId = ElementUtils.getUniqueIdentifier(mirror); + CodeExecutableElement method = constants.encodeConstants.get(typeId); + if (method == null) { + String methodName = constants.reserveSymbol(mirror, "encode" + ElementUtils.firstLetterUpperCase(ElementUtils.getTypeId(mirror))); + method = new CodeExecutableElement(modifiers(PRIVATE, STATIC), context.getType(int.class), methodName); + method.addParameter(new CodeVariableElement(mirror, "e")); + CodeTreeBuilder builder = method.createBuilder(); + builder.startIf().string("e != null").end().startBlock(); + builder.statement("return e.ordinal()"); + builder.end().startElseBlock(); + builder.statement("return -1"); + builder.end(); + constants.encodeConstants.put(typeId, method); + } + return method; + } + + private CodeExecutableElement lookupDecodeEnum(TypeMirror mirror) { + String typeId = ElementUtils.getUniqueIdentifier(mirror); + CodeExecutableElement method = constants.decodeConstants.get(typeId); + if (method == null) { + String methodName = constants.reserveSymbol(mirror, "decode" + ElementUtils.firstLetterUpperCase(ElementUtils.getTypeId(mirror))); + method = new CodeExecutableElement(modifiers(PRIVATE, STATIC), mirror, methodName); + method.addParameter(new CodeVariableElement(context.getType(int.class), "state")); + CodeTreeBuilder builder = method.createBuilder(); + builder.startIf().string("state >= 0").end().startBlock(); + builder.startReturn().string(lookupEnumConstants(mirror).getName()).string("[state]").end(); + builder.end().startElseBlock(); + builder.statement("return null"); + builder.end(); + constants.decodeConstants.put(typeId, method); + } + return method; + } + + private CodeVariableElement lookupEnumConstants(TypeMirror mirror) { + String typeId = ElementUtils.getUniqueIdentifier(mirror); + CodeVariableElement var = constants.enumValues.get(typeId); + if (var == null) { + String constantName = constants.reserveSymbol(mirror, ElementUtils.createConstantName(ElementUtils.getTypeId(mirror)) + "_VALUES"); + var = new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), new ArrayCodeTypeMirror(mirror), constantName); + addCompilationFinalAnnotation(var, 1); + CodeTreeBuilder init = var.createInitBuilder(); + init.startStaticCall(types.DSLSupport, "lookupEnumConstants").typeLiteral(mirror).end(); + constants.enumValues.put(typeId, var); + } + return var; + } + + @SuppressWarnings("unused") + static CodeTree createInlinedAccess(FrameState frameState, SpecializationData specialization, CodeTree reference, CodeTree value, CodeTree nodeReference) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + builder.tree(reference); + if (frameState != null && frameState.isInlinedNode()) { + if (value == null) { + builder.startCall(".get").tree(nodeReference).end().build(); + } else { + builder.startCall(".set").tree(nodeReference).tree(value).end().build(); + } + } else { + if (value == null) { + return builder.build(); + } else { + builder.string(" = ").tree(value); } } + return builder.build(); + } + + static CodeTree createInlinedAccess(FrameState frameState, SpecializationData specialization, CodeTree reference, CodeTree value) { + return createInlinedAccess(frameState, specialization, reference, value, createNodeAccess(frameState, specialization)); } private CodeTree createAssumptionReference(FrameState frameState, SpecializationData s, AssumptionExpression a) { String assumptionFieldName = createAssumptionFieldName(s, a); - return createSpecializationFieldReference(frameState, s, assumptionFieldName); + return createSpecializationFieldAccess(frameState, s, true, true, assumptionFieldName, null); } private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGroup group, TypeGuard typeGuard, @@ -5138,9 +7070,13 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou LocalVariable value = frameState.getValue(signatureIndex); TypeMirror targetType = typeGuard.getType(); + if (value == null) { + return null; + } + if (!needsCastTo(value.getTypeMirror(), targetType)) { - TypeMirror genericTargetType = node.getFallbackSpecialization().findParameterOrDie(node.getChildExecutions().get(signatureIndex)).getType(); - if (typeEquals(value.getTypeMirror(), genericTargetType)) { + Parameter parameter = node.getFallbackSpecialization().findParameter(node.getChildExecutions().get(signatureIndex)); + if (parameter == null || typeEquals(value.getTypeMirror(), parameter.getType())) { // no implicit casts needed if it matches the generic type return null; } @@ -5149,7 +7085,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou if (forceImplicitCast) { List casts = typeSystem.lookupByTargetType(targetType); for (ImplicitCastData cast : casts) { - if (isSubtype(cast.getSourceType(), targetType)) { + if (ElementUtils.isSubtype(cast.getSourceType(), targetType)) { foundImplicitSubType = true; break; } @@ -5180,7 +7116,7 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou if (specializationExecution.isGuardFallback() || specializationExecution.isUncached()) { implicitState = null; } else { - implicitState = multiState.createExtractInteger(frameState, typeGuard); + implicitState = multiState.createExtractInteger(frameState, StateQuery.create(ImplicitCastState.class, typeGuard)); } checkBuilder.tree(TypeSystemCodeGenerator.implicitCheckFlat(typeSystem, targetType, valueReference, implicitState)); castBuilder.tree(TypeSystemCodeGenerator.implicitCastFlat(typeSystem, targetType, valueReference, implicitState)); @@ -5211,6 +7147,9 @@ private IfTriple createTypeCheckOrCast(FrameState frameState, SpecializationGrou } private List initializeCasts(FrameState frameState, SpecializationGroup group, DSLExpression expression, NodeExecutionMode specializationExecution) { + if (expression == null) { + return Collections.emptyList(); + } Set boundElements = expression.findBoundVariableElements(); if (boundElements.isEmpty()) { return Collections.emptyList(); @@ -5223,10 +7162,11 @@ private List initializeCasts(FrameState frameState, SpecializationGrou if (execution != null) { LocalVariable var = frameState.getValue(execution); if (var == null) { - throw new AssertionError(); + continue; } - IfTriple triple = createTypeCheckOrCast(frameState, group, new TypeGuard(p.getType(), execution.getIndex()), specializationExecution, true, false); + IfTriple triple = createTypeCheckOrCast(frameState, group, new TypeGuard(typeSystem, p.getType(), execution.getIndex()), specializationExecution, true, + false); if (triple != null) { triples.add(triple); } @@ -5237,6 +7177,9 @@ private List initializeCasts(FrameState frameState, SpecializationGrou } private ExecutableTypeData createExecuteAndSpecializeType() { + if (node.getPolymorphicExecutable() == null) { + return null; + } TypeMirror polymorphicType = node.getPolymorphicExecutable().getReturnType(); List parameters = new ArrayList<>(); for (TypeMirror param : node.getPolymorphicExecutable().getSignatureParameters()) { @@ -5274,7 +7217,7 @@ private ChildExecutionResult createExecuteChildImplicitCast(CodeTreeBuilder pare CodeTreeBuilder builder = parent.create(); List originalSourceTypes = new ArrayList<>(typeSystem.lookupSourceTypes(target.getTypeMirror())); List sourceTypes = resolveOptimizedImplicitSourceTypes(execution, target.getTypeMirror()); - TypeGuard typeGuard = new TypeGuard(target.getTypeMirror(), execution.getIndex()); + StateQuery implicitTypeGuardQuery = StateQuery.create(ImplicitCastState.class, new TypeGuard(typeSystem, target.getTypeMirror(), execution.getIndex())); boolean throwsUnexpected = false; boolean elseIf = false; for (TypeMirror sourceType : sourceTypes) { @@ -5282,12 +7225,12 @@ private ChildExecutionResult createExecuteChildImplicitCast(CodeTreeBuilder pare elseIf = builder.startIf(elseIf); throwsUnexpected |= executableType.hasUnexpectedValue(); builder.startGroup(); - CodeTree tree = multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sourceType), 1, new Object[]{typeGuard}, new Object[]{typeGuard}); + CodeTree tree = multiState.createContainsOnly(frameState, originalSourceTypes.indexOf(sourceType), 1, implicitTypeGuardQuery, implicitTypeGuardQuery); if (!tree.isEmpty()) { builder.tree(tree); builder.string(" && "); } - builder.tree(multiState.createIsNotAny(frameState, reachableSpecializationsArray)); + builder.tree(multiState.createIsNotAny(frameState, StateQuery.create(SpecializationActive.class, node.getReachableSpecializations()))); builder.end(); builder.end(); builder.startBlock(); @@ -5315,7 +7258,7 @@ private ChildExecutionResult createExecuteChildImplicitCast(CodeTreeBuilder pare LocalVariable genericValue = target.makeGeneric(context).nextName(); builder.tree(createAssignExecuteChild(originalFrameState, frameState, builder, execution, node.getGenericExecutableType(null), genericValue)); builder.startStatement().string(target.getName()).string(" = "); - CodeTree implicitState = multiState.createExtractInteger(frameState, typeGuard); + CodeTree implicitState = multiState.createExtractInteger(frameState, implicitTypeGuardQuery); builder.tree(TypeSystemCodeGenerator.implicitExpectFlat(typeSystem, target.getTypeMirror(), genericValue.createReference(), implicitState)); builder.end(); @@ -5407,56 +7350,66 @@ private static class ExecuteDelegationResult { } - static int getRequiredStateBits(TypeSystemData types, Object object) { - if (object instanceof SpecializationData) { - return 1; - } else if (object instanceof TypeGuard) { - TypeGuard guard = (TypeGuard) object; - - TypeMirror type = guard.getType(); - Collection sourceTypes = types.lookupSourceTypes(type); - if (sourceTypes.size() > 1) { - return sourceTypes.size(); - } - throw new AssertionError(); - } else if (object instanceof GuardExpression) { - return 1; - } else if (object == AOT_PREPARED) { - return 1; - } else { - throw new AssertionError(); - } - } - - private static final class MultiStateBitSet extends MultiBitSet { + static final class MultiStateBitSet extends MultiBitSet { /* * All bitsets in used by other nodes in the same generated class. E.g. nodes in exports are * all generated into the same class. */ - private final List all; + private final List all; - MultiStateBitSet(List all, List active) { + MultiStateBitSet(List all, List active) { super(active); this.all = all; } + public void clearLoaded(FrameState frameState) { + for (BitSet state : all) { + state.clearLoaded(frameState); + } + } + + BitSet findSet(StateQuery query) { + for (BitSet state : all) { + if (state.contains(query)) { + return state; + } + } + return null; + } + + BitSet findSet(Class> clazz, T param) { + return findSet(StateQuery.create(clazz, param)); + } + int getAllCapacity() { int length = 0; for (BitSet a : all) { - length += a.getCapacity(); + length += a.getBitCount(); } return length; } - public CodeTree createContainsAll(FrameState frameState, Object[] elements) { + CodeTree createContainsAll(FrameState frameState, StateQuery elements) { return createContainsImpl(all, frameState, elements); } - void declareFields(CodeTypeElement clazz) { - for (StateBitSet bitSet : all) { - bitSet.declareFields(clazz); + List createCachedFields() { + List variables = new ArrayList<>(); + for (BitSet bitSet : all) { + variables.add(createCachedField(bitSet)); } + return variables; + } + + static CodeVariableElement createCachedField(BitSet bitSet) { + CodeVariableElement var = FlatNodeGenFactory.createNodeField(PRIVATE, bitSet.getType(), bitSet.getName() + "_", + ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal); + CodeTreeBuilder docBuilder = var.createDocBuilder(); + docBuilder.startJavadoc(); + FlatNodeGenFactory.addStateDoc(docBuilder, bitSet); + docBuilder.end(); + return var; } void addParametersTo(FrameState frameState, CodeExecutableElement targetMethod) { @@ -5487,156 +7440,97 @@ void addReferencesTo(FrameState frameState, CodeTreeBuilder builder) { } } - void addReferencesTo(FrameState frameState, CodeTreeBuilder builder, Object... relevantObjects) { + void addReferencesTo(FrameState frameState, CodeTreeBuilder builder, StateQuery... relevantQuery) { for (BitSet set : getSets()) { LocalVariable local = frameState.get(set.getName()); if (local != null) { - for (Object object : relevantObjects) { - if (set.contains(object)) { - builder.tree(local.createReference()); - break; - } + if (set.contains(relevantQuery)) { + builder.tree(local.createReference()); } } } } - CodeTree createLoad(FrameState frameState) { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - for (BitSet bitSet : getSets()) { - builder.tree(bitSet.createLoad(frameState)); - } - return builder.build(); + CodeTree createLoad(FrameState frameState, StateQuery... relevantQuery) { + return createLoadImpl(getSets(), frameState, false, relevantQuery); } - CodeTree createLoad(FrameState frameState, Object... relevantObjects) { - return createLoadImpl(getSets(), frameState, relevantObjects); + CodeTree createForceLoad(FrameState frameState, StateQuery... relevantQuery) { + return createLoadImpl(getSets(), frameState, true, relevantQuery); } - private static CodeTree createLoadImpl(List sets, FrameState frameState, Object... relevantObjects) { + private static CodeTree createLoadImpl(List sets, FrameState frameState, boolean force, StateQuery... relevantQuery) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); for (BitSet bitSet : sets) { - for (Object object : relevantObjects) { - if (bitSet.contains(object)) { - builder.tree(bitSet.createLoad(frameState)); - break; - } + if (bitSet.contains(relevantQuery)) { + builder.tree(bitSet.createLoad(frameState, force)); } } return builder.build(); } - CodeTree createLoadAll(FrameState frameState, Object... relevantObjects) { - return createLoadImpl(all, frameState, relevantObjects); + CodeTree createLoadAll(FrameState frameState, StateQuery relevantQuery) { + return createLoadImpl(all, frameState, false, relevantQuery); } - CodeTree createLoad(FrameState frameState, List specializations) { + CodeTree createLoadFastPath(FrameState frameState, List specializations) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - - for (StateBitSet bitSet : getSets()) { - boolean relevant = false; - for (SpecializationData specialization : specializations) { - if (bitSet.isRelevantForSpecialization(specialization)) { - relevant = true; - break; - } - } - if (relevant) { + for (BitSet bitSet : getSets()) { + if (isRelevantForFastPath(bitSet, specializations)) { builder.tree(bitSet.createLoad(frameState)); } } return builder.build(); } - CodeTree createLoadContainsSpecialization(FrameState frameState) { + CodeTree createLoadSlowPath(FrameState frameState, List specializations, boolean force) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - for (StateBitSet bitSet : getSets()) { - if (!bitSet.containsSpecialization()) { - continue; + + for (BitSet bitSet : getSets()) { + if (isRelevantForSlowPath(bitSet, specializations)) { + builder.tree(bitSet.createLoad(frameState, force)); } - builder.tree(bitSet.createLoad(frameState)); } return builder.build(); } - } - - private abstract static class NodeBitSet extends BitSet { - - private final boolean needsVolatile; - - NodeBitSet(String name, Object[] objects, boolean needsVolatile) { - super(name, objects); - this.needsVolatile = needsVolatile; - } - void declareFields(CodeTypeElement clazz) { - CodeVariableElement var = clazz.add(FlatNodeGenFactory.createNodeField(PRIVATE, getType(), getName() + "_", ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal)); - if (needsVolatile) { - var.getModifiers().add(Modifier.VOLATILE); + static boolean isRelevantForFastPath(BitSet bitSet, Collection usedSpecializations) { + if (bitSet.getStates().contains(StateQuery.create(SpecializationActive.class, usedSpecializations))) { + return true; } - } - - String getOldName() { - return "old" + ElementUtils.firstLetterUpperCase(getName()); - } - - String getNewName() { - return "new" + ElementUtils.firstLetterUpperCase(getName()); - } - - } - - private class StateBitSet extends NodeBitSet { - - private final Set relevantSpecializations; - - StateBitSet(Object[] objects, SpecializationData[] relevantSpecializations, boolean needsVolatile, int index) { - super("state_" + index, objects, needsVolatile); - this.relevantSpecializations = new HashSet<>(Arrays.asList(relevantSpecializations)); - } - - @Override - protected int calculateRequiredBits(Object object) { - return getRequiredStateBits(typeSystem, object); - } - - /* - * Returns true if this state bitset contains any state relevant for this specialization. - * Note that the specialization itself might not be contained here. - */ - boolean isRelevantForSpecialization(SpecializationData specialization) { - return relevantSpecializations.contains(specialization); - } - - boolean containsSpecialization() { - for (Object o : getObjects()) { - if (o instanceof SpecializationData) { + if (bitSet.getStates().contains(AOT_PREPARED)) { + return true; + } + for (SpecializationData specialization : usedSpecializations) { + if (bitSet.getStates().contains(StateQuery.create(EncodedEnumState.class, specialization.getCaches()))) { return true; } } return false; } - } - - private static class ExcludeBitSet extends NodeBitSet { - - ExcludeBitSet(SpecializationData[] specializations, boolean needsVolatile) { - super("exclude", specializations, needsVolatile); - } - - @Override - protected int calculateRequiredBits(Object object) { - if (object instanceof SpecializationData) { - - mayBeExcluded((SpecializationData) object); - SpecializationData specialization = (SpecializationData) object; - if (!specialization.getExceptions().isEmpty() || !specialization.getExcludedBy().isEmpty()) { - return 1; + @SuppressWarnings("unused") + static boolean isRelevantForSlowPath(BitSet bitSet, Collection usedSpecializations) { + if (bitSet.getStates().contains(StateQuery.create(SpecializationActive.class, usedSpecializations))) { + return true; + } + if (bitSet.getStates().contains(StateQuery.create(SpecializationExcluded.class, usedSpecializations))) { + return true; + } + for (GuardActive state : bitSet.getStates().queryStates(GuardActive.class)) { + if (usedSpecializations.contains(state.getDependentSpecialization())) { + return true; } - return 0; } - throw new IllegalArgumentException(); + for (SpecializationData specialization : usedSpecializations) { + if (bitSet.getStates().contains(StateQuery.create(EncodedEnumState.class, specialization.getCaches()))) { + return true; + } + } + for (ImplicitCastState state : bitSet.getStates().queryStates(ImplicitCastState.class)) { + return true; + } + return false; } } @@ -5650,14 +7544,14 @@ static final class FrameState { private final NodeExecutionMode mode; private final CodeExecutableElement method; + private final List caughtTypes = new ArrayList<>(); + private FrameState(FlatNodeGenFactory factory, NodeExecutionMode mode, CodeExecutableElement method) { this.factory = factory; this.mode = mode; this.method = method; } - private final List caughtTypes = new ArrayList<>(); - public void addCaughtException(TypeMirror exceptionType) { this.caughtTypes.add(exceptionType); } @@ -5690,6 +7584,14 @@ public void addThrownExceptions(ExecutableElement calledMethod) { } } + public boolean isInlinedNode() { + return getBoolean("$inlinedNode", false); + } + + public void setInlinedNode(boolean b) { + setBoolean("$inlinedNode", b); + } + public NodeExecutionMode getMode() { return mode; } @@ -5707,6 +7609,18 @@ public boolean getBoolean(String name, boolean defaultValue) { } } + public boolean isSpecializationClassInitialized(SpecializationData specialization) { + return getBoolean(createSpecializationClassInitialized(specialization), false); + } + + public void setSpecializationClassInitialized(SpecializationData specialization, boolean b) { + setBoolean(createSpecializationClassInitialized(specialization), b); + } + + private static String createSpecializationClassInitialized(SpecializationData specialization) { + return createSpecializationLocalName(specialization) + "$initialized"; + } + public static FrameState load(FlatNodeGenFactory factory, ExecutableTypeData type, int varargsThreshold, NodeExecutionMode mode, CodeExecutableElement method) { FrameState context = new FrameState(factory, mode, method); context.loadEvaluatedValues(type, varargsThreshold); @@ -5768,7 +7682,7 @@ public LocalVariable createValue(NodeExecutionData execution, TypeMirror type) { return new LocalVariable(type, valueName(execution), null); } - private static String valueName(NodeExecutionData execution) { + public static String valueName(NodeExecutionData execution) { return execution.getName() + "Value"; } @@ -5776,10 +7690,19 @@ public void set(String id, LocalVariable var) { values.put(id, var); } + public void clear(String id) { + values.remove(id); + } + public void set(NodeExecutionData execution, LocalVariable var) { set(valueName(execution), var); } + public LocalVariable getCacheInitialized(SpecializationData specialization, CacheExpression cache) { + String name = factory.createFieldName(specialization, cache); + return get(name); + } + public LocalVariable get(String id) { return values.get(id); } @@ -5954,7 +7877,7 @@ public String getName() { } - private enum NodeExecutionMode { + enum NodeExecutionMode { FAST_PATH, SLOW_PATH, diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 006b697ff372..7f854df48030 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -72,7 +72,6 @@ import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeElement; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; -import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; @@ -83,11 +82,14 @@ public class GeneratorUtils { - public static void pushEncapsulatingNode(CodeTreeBuilder builder, String nodeRef) { + public static void pushEncapsulatingNode(CodeTreeBuilder builder, CodeTree nodeRef) { TruffleTypes types = ProcessorContext.getInstance().getTypes(); builder.startStatement().type(types.EncapsulatingNodeReference).string(" encapsulating_ = ").// startStaticCall(types.EncapsulatingNodeReference, "getCurrent").end().end(); - builder.startStatement().type(types.Node).string(" prev_ = encapsulating_.set(" + nodeRef + ")").end(); + + builder.startStatement().type(types.Node).string(" prev_ = encapsulating_."); + builder.startCall("set").tree(nodeRef).end(); + builder.end(); } public static void popEncapsulatingNode(CodeTreeBuilder builder) { @@ -122,13 +124,6 @@ public static CodeTree createShouldNotReachHere(CodeTree causeExpression) { return builder.build(); } - public static CodeTree createTransferToInterpreter() { - ProcessorContext context = ProcessorContext.getInstance(); - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.startStatement().startStaticCall(context.getTypes().CompilerDirectives, "transferToInterpreter").end().end(); - return builder.build(); - } - public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) { TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); ExecutableElement constructor = findConstructor(superClass); @@ -168,7 +163,7 @@ public static void addOverride(CodeExecutableElement method) { method.addAnnotationMirror(new CodeAnnotationMirror(override)); } - public static void mergeSupressWarnings(CodeElement element, String... addWarnings) { + public static void mergeSuppressWarnings(CodeElement element, String... addWarnings) { List mergedWarnings = Arrays.asList(addWarnings); AnnotationMirror currentWarnings = ElementUtils.findAnnotationMirror(element, SuppressWarnings.class); if (currentWarnings != null) { @@ -181,15 +176,11 @@ public static void mergeSupressWarnings(CodeElement element, String... addWar } DeclaredType suppressWarnings = ProcessorContext.getInstance().getDeclaredType(SuppressWarnings.class); CodeAnnotationMirror mirror = new CodeAnnotationMirror(suppressWarnings); - if (mergedWarnings.size() == 1) { - mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue(mergedWarnings.iterator().next())); - } else { - List values = new ArrayList<>(); - for (String warning : mergedWarnings) { - values.add(new CodeAnnotationValue(warning)); - } - mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue(values)); + List values = new ArrayList<>(); + for (String warning : mergedWarnings) { + values.add(new CodeAnnotationValue(warning)); } + mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue(values)); if (currentWarnings != null) { ((CodeElement) element).getAnnotationMirrors().remove(currentWarnings); @@ -247,25 +238,6 @@ private static ExecutableElement findConstructor(TypeElement clazz) { } } - public static CodeExecutableElement createSuperConstructor(TypeElement type, ExecutableElement element) { - if (element.getModifiers().contains(Modifier.PRIVATE)) { - return null; - } - CodeExecutableElement executable = CodeExecutableElement.clone(element); - executable.setReturnType(null); - executable.setSimpleName(CodeNames.of(type.getSimpleName().toString())); - CodeTreeBuilder b = executable.createBuilder(); - b.startStatement(); - b.startSuperCall(); - for (VariableElement v : element.getParameters()) { - b.string(v.getSimpleName().toString()); - } - b.end(); - b.end(); - - return executable; - } - public static CodeTypeElement createClass(Template sourceModel, TemplateMethod sourceMethod, Set modifiers, String simpleName, TypeMirror superType) { TypeElement templateType = sourceModel.getTemplateType(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java index 036e1f7e11ab..0d625698a0d9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/MultiBitSet.java @@ -40,75 +40,121 @@ */ package com.oracle.truffle.dsl.processor.generator; +import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; -class MultiBitSet { +class MultiBitSet { - private final List sets; + private final List sets; - MultiBitSet(List sets) { + MultiBitSet(List sets) { this.sets = sets; } - public List getSets() { + public List getSets() { return sets; } public int getCapacity() { int length = 0; for (BitSet a : sets) { - length += a.getCapacity(); + length += a.getBitCount(); } return length; } - public CodeTree createContains(FrameState frameState, Object[] elements) { + public CodeTree createContains(FrameState frameState, StateQuery elements) { return createContainsImpl(sets, frameState, elements); } - protected static CodeTree createContainsImpl(List sets, FrameState frameState, Object[] elements) { + protected static CodeTree createContainsImpl(List sets, FrameState frameState, StateQuery elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - String sep = ""; - if (sets.size() > 1) { - builder.string("("); - } + List conditions = new ArrayList<>(); for (BitSet set : sets) { - Object[] included = set.filter(elements); - if (included.length > 0) { - builder.string(sep); - builder.tree(set.createContains(frameState, included)); - sep = " || "; + StateQuery included = set.filter(elements); + if (!included.isEmpty()) { + conditions.add(set.createContains(frameState, included)); } } - if (sets.size() > 1) { + + if (conditions.size() > 1) { + builder.string("("); + } + String sep = ""; + for (CodeTree tree : conditions) { + builder.string(sep); + builder.tree(tree); + sep = " || "; + } + if (conditions.size() > 1) { builder.string(")"); } return builder.build(); } - public CodeTree createSet(FrameState frameState, Object[] elements, boolean value, boolean persist) { + static final class StateTransaction { + + private final LinkedHashSet modified = new LinkedHashSet<>(); + + } + + public CodeTree persistTransaction(FrameState frameState, StateTransaction transaction) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - for (BitSet set : sets) { - Object[] included = set.filter(elements); + for (BitSet set : transaction.modified) { + if (set.hasLocal(frameState)) { + builder.tree(set.createSet(frameState, null, null, true)); + } else { + throw new AssertionError("Cannot persist transaction state local without a local variable in the frame state."); + } + } + return builder.build(); - if (included.length > 0 || persist) { + } + + public CodeTree createSet(FrameState frameState, StateTransaction transaction, StateQuery query, boolean value, boolean persist) { + CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); + for (BitSet set : sets) { + StateQuery included = set.getStates().filter(query); + if (!included.isEmpty()) { + if (transaction != null) { + if (!set.hasLocal(frameState) || persist) { + throw new AssertionError("Must be loaded for transactional write."); + } + transaction.modified.add(set); + } builder.tree(set.createSet(frameState, included, value, persist)); } } return builder.build(); } - public CodeTree createContainsOnly(FrameState frameState, int offset, int length, Object[] selectedElements, Object[] allElements) { + public CodeTree createSetInteger(FrameState frameState, StateTransaction transaction, StateQuery element, CodeTree value) { + for (BitSet set : sets) { + if (set.contains(element)) { + if (transaction != null) { + if (!set.hasLocal(frameState)) { + throw new AssertionError("Cannot use transactions without the state being loaded."); + } + transaction.modified.add(set); + } + return set.createSetInteger(frameState, element, value); + } + } + throw new AssertionError("element not contained"); + } + + public CodeTree createContainsOnly(FrameState frameState, int offset, int length, StateQuery selectedElements, StateQuery allElements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); String sep = ""; for (BitSet set : sets) { - Object[] selected = set.filter(selectedElements); - Object[] filteredAll = set.filter(allElements); - if (filteredAll.length > 0) { + StateQuery selected = set.filter(selectedElements); + StateQuery filteredAll = set.filter(allElements); + if (!filteredAll.isEmpty()) { CodeTree containsOnly = set.createContainsOnly(frameState, offset, length, selected, filteredAll); if (containsOnly != null) { builder.string(sep); @@ -120,13 +166,13 @@ public CodeTree createContainsOnly(FrameState frameState, int offset, int length return builder.build(); } - public CodeTree createIs(FrameState frameState, Object[] selectedElements, Object[] maskedElements) { + public CodeTree createIs(FrameState frameState, StateQuery selectedElements, StateQuery maskedElements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); String sep = ""; for (BitSet set : sets) { - Object[] selected = set.filter(selectedElements); - Object[] masked = set.filter(maskedElements); - if (masked.length > 0) { + StateQuery masked = set.filter(maskedElements); + if (!masked.isEmpty()) { + StateQuery selected = set.filter(selectedElements); builder.string(sep); builder.tree(set.createIs(frameState, selected, masked)); sep = " && "; @@ -135,15 +181,15 @@ public CodeTree createIs(FrameState frameState, Object[] selectedElements, Objec return builder.build(); } - public CodeTree createIsNotAny(FrameState frameState, Object[] elements) { + public CodeTree createIsNotAny(FrameState frameState, StateQuery elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.string("("); String sep = ""; for (BitSet set : sets) { - Object[] setElements = set.filter(elements); - if (setElements.length > 0) { + StateQuery filteredElements = set.filter(elements); + if (!filteredElements.isEmpty()) { builder.string(sep); - builder.tree(set.createIsNotAny(frameState, setElements)); + builder.tree(set.createIsNotAny(frameState, filteredElements)); sep = " || "; // exclusive or needed for one bit check } } @@ -151,7 +197,7 @@ public CodeTree createIsNotAny(FrameState frameState, Object[] elements) { return builder.build(); } - public CodeTree createExtractInteger(FrameState frameState, Object element) { + public CodeTree createExtractInteger(FrameState frameState, StateQuery element) { for (BitSet set : sets) { if (set.contains(element)) { return set.createExtractInteger(frameState, element); @@ -160,12 +206,12 @@ public CodeTree createExtractInteger(FrameState frameState, Object element) { throw new AssertionError("element not contained"); } - public CodeTree createNotContains(FrameState frameState, Object[] elements) { + public CodeTree createNotContains(FrameState frameState, StateQuery elements) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); String sep = ""; for (BitSet set : sets) { - Object[] setElements = set.filter(elements); - if (setElements.length > 0) { + StateQuery setElements = set.filter(elements); + if (!setElements.isEmpty()) { builder.string(sep); builder.tree(set.createNotContains(frameState, setElements)); sep = " && "; // exclusive or needed for one bit check @@ -174,13 +220,4 @@ public CodeTree createNotContains(FrameState frameState, Object[] elements) { return builder.build(); } - public CodeTree createSetInteger(FrameState frameState, Object element, CodeTree value) { - for (BitSet set : sets) { - if (set.contains(element)) { - return set.createSetInteger(frameState, element, value); - } - } - throw new AssertionError("element not contained"); - } - } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index 122419bc5645..1e0c29476fbd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -83,9 +83,7 @@ public List create(ProcessorContext context, AnnotationProcesso if (rootTypes.size() != 1) { throw new AssertionError(); } - rootTypes.get(0).addAll(constants.libraries.values()); - rootTypes.get(0).addAll(constants.contextReferences.values()); - rootTypes.get(0).addAll(constants.languageReferences.values()); + constants.addElementsTo(rootTypes.get(0)); } return rootTypes; } @@ -237,9 +235,12 @@ static boolean isSpecializedNode(Element element) { } public static TypeMirror nodeType(NodeData node) { + return nodeElement(node).asType(); + } + + public static CodeTypeElement nodeElement(NodeData node) { TypeElement element = node.getTemplateType(); - CodeTypeElement type = (CodeTypeElement) buildClassName(element, true, node.isGenerateFactory()); - return type.asType(); + return (CodeTypeElement) buildClassName(element, true, node.isGenerateFactory()); } public static TypeMirror factoryOrNodeType(NodeData node) { @@ -271,19 +272,37 @@ private static List generateNodes(ProcessorContext context, Nod return Collections.emptyList(); } - CodeTypeElement type = GeneratorUtils.createClass(node, null, modifiers(FINAL), createNodeTypeName(node.getTemplateType()), node.getTemplateType().asType()); + TypeMirror superType; + if (node.isGenerateCached()) { + superType = node.getTemplateType().asType(); + } else { + superType = context.getType(Object.class); + } + CodeTypeElement type = GeneratorUtils.createClass(node, null, modifiers(FINAL), createNodeTypeName(node.getTemplateType()), superType); + ElementUtils.setVisibility(type.getModifiers(), node.getVisibility()); if (node.hasErrors()) { generateErrorNode(context, node, type); return Arrays.asList(type); } - type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants).create(type); + NodeConstants nodeConstants = new NodeConstants(); + try { + type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, nodeConstants).create(type); + } catch (Throwable t) { + Exception e = new Exception("Generating node " + node.getNodeId()); + e.setStackTrace(new StackTraceElement[0]); + t.addSuppressed(e); + throw t; + } + nodeConstants.prependToClass(type); return Arrays.asList(type); } private static void generateErrorNode(ProcessorContext context, NodeData node, CodeTypeElement type) { + type.setSuperClass(node.getTemplateType().asType()); + for (ExecutableElement superConstructor : GeneratorUtils.findUserConstructors(node.getTemplateType().asType())) { CodeExecutableElement constructor = GeneratorUtils.createConstructorUsingFields(modifiers(), type, superConstructor); ElementUtils.setVisibility(constructor.getModifiers(), ElementUtils.getVisibility(superConstructor.getModifiers())); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeConstants.java new file mode 100644 index 000000000000..1d16b0dc9b5f --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeConstants.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.generator; + +import java.util.LinkedHashMap; +import java.util.Map; + +import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; + +/** + * Constants per generated specialized node. + */ +public final class NodeConstants { + + public final Map updaterReferences = new LinkedHashMap<>(); + + public void prependToClass(CodeTypeElement clazz) { + clazz.getEnclosedElements().addAll(0, updaterReferences.values()); + updaterReferences.clear(); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeFactoryFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeFactoryFactory.java index ce2dc03dc726..e76f7fa8ee96 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeFactoryFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeFactoryFactory.java @@ -60,11 +60,14 @@ import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; +import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeNames; import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +import com.oracle.truffle.dsl.processor.model.InlineFieldData; import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.NodeExecutionData; @@ -103,8 +106,12 @@ public CodeTypeElement create() { clazz.add(createCreateGetNodeClass()); clazz.add(createCreateGetExecutionSignature()); clazz.add(createCreateGetNodeSignatures()); - clazz.add(createCreateNodeMethod()); - clazz.addOptional(createGetUncached()); + if (node.isGenerateCached()) { + clazz.add(createCreateNodeMethod()); + } + if (node.isGenerateUncached()) { + clazz.addOptional(createGetUncached()); + } clazz.add(createGetInstanceMethod(visibility)); clazz.add(createInstanceConstant(clazz.asType())); List constructors = GeneratorUtils.findUserConstructors(createdFactoryElement.asType()); @@ -233,7 +240,7 @@ private CodeExecutableElement createCreateNodeMethod() { if (!ElementUtils.isObject(param.asType())) { builder.string("(").type(param.asType()).string(") "); if (ElementUtils.hasGenericTypes(param.asType())) { - GeneratorUtils.mergeSupressWarnings(method, "unchecked"); + GeneratorUtils.mergeSuppressWarnings(method, "unchecked"); } } builder.string("arguments[").string(String.valueOf(index)).string("]"); @@ -284,18 +291,117 @@ private CodeVariableElement createInstanceConstant(TypeMirror factoryType) { public static List createFactoryMethods(NodeData node, List constructors) { List methods = new ArrayList<>(); for (ExecutableElement constructor : constructors) { - methods.add(createCreateMethod(node, constructor)); + if (node.isGenerateCached()) { + methods.add(createCreateMethod(node, constructor)); + } if (constructor instanceof CodeExecutableElement) { ElementUtils.setVisibility(constructor.getModifiers(), Modifier.PRIVATE); } if (node.isGenerateUncached()) { methods.add(createGetUncached(node, constructor)); } + if (node.isGenerateInline()) { + // avoid compile errors in the error node. + if (!node.hasErrors() || ElementUtils.findStaticMethod(node.getTemplateType(), "inline") == null) { + methods.add(createInlineMethod(node, constructor)); + } + } } return methods; } + public static CodeExecutableElement createInlineMethod(NodeData node, ExecutableElement constructorPrototype) { + CodeExecutableElement method; + if (constructorPrototype == null) { + method = new CodeExecutableElement(node.getNodeType(), "inline"); + } else { + method = CodeExecutableElement.clone(constructorPrototype); + method.setSimpleName(CodeNames.of("inline")); + method.getModifiers().clear(); + method.setReturnType(node.getNodeType()); + } + method.getModifiers().add(Modifier.PUBLIC); + method.getModifiers().add(Modifier.STATIC); + method.getAnnotationMirrors().add(new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().NeverDefault)); + CodeTreeBuilder body = method.createBuilder(); + TypeMirror nodeType = NodeCodeGenerator.nodeType(node); + body.startReturn(); + if (node.hasErrors()) { + body.startNew(nodeType); + for (VariableElement var : method.getParameters()) { + body.defaultValue(var.asType()); + } + body.end(); + } else { + body.startNew(ElementUtils.getSimpleName(nodeType) + ".Inlined"); + TruffleTypes types = ProcessorContext.getInstance().getTypes(); + + CodeVariableElement inlineTarget = new CodeVariableElement(types.InlineSupport_InlineTarget, "target"); + body.string(inlineTarget.getName()); + method.addParameter(inlineTarget); + + List requiredFields = new ArrayList<>(); + + ExecutableElement value = ElementUtils.findMethod(types.InlineSupport_RequiredField, "value"); + ExecutableElement bits = ElementUtils.findMethod(types.InlineSupport_RequiredField, "bits"); + ExecutableElement type = ElementUtils.findMethod(types.InlineSupport_RequiredField, "type"); + ExecutableElement dimensions = ElementUtils.findMethod(types.InlineSupport_RequiredField, "dimensions"); + + CodeTreeBuilder docBuilder = method.createDocBuilder(); + docBuilder.startJavadoc(); + docBuilder.string("Required Fields: "); + docBuilder.string("
    "); + docBuilder.newLine(); + + for (InlineFieldData field : FlatNodeGenFactory.createInlinedFields(node)) { + CodeAnnotationMirror requiredField = new CodeAnnotationMirror(types.InlineSupport_RequiredField); + requiredField.setElementValue(value, new CodeAnnotationValue(field.getFieldType())); + + if (field.hasBits()) { + requiredField.setElementValue(bits, new CodeAnnotationValue(field.getBits())); + } + if (!field.isPrimitive() && field.getType() != null) { + requiredField.setElementValue(type, new CodeAnnotationValue(field.getType())); + } + + if (field.getDimensions() != 0) { + requiredField.setElementValue(dimensions, new CodeAnnotationValue(field.getDimensions())); + } + + Element sourceElement = field.getSourceElement(); + docBuilder.string("
  • "); + if (sourceElement != null) { + if (sourceElement.getEnclosingElement() == null) { + docBuilder.string("{@link "); + docBuilder.string("Inlined#"); + docBuilder.string(sourceElement.getSimpleName().toString()); + docBuilder.string("}"); + } else { + docBuilder.javadocLink(sourceElement, null); + } + } else { + docBuilder.string("Unknown source"); + } + docBuilder.newLine(); + + requiredFields.add(new CodeAnnotationValue(requiredField)); + } + docBuilder.string("
"); + docBuilder.end(); + + ExecutableElement fieldsValue = ElementUtils.findMethod(types.InlineSupport_RequiredFields, "value"); + CodeAnnotationMirror requiredFieldsMirror = new CodeAnnotationMirror(types.InlineSupport_RequiredFields); + requiredFieldsMirror.setElementValue(fieldsValue, new CodeAnnotationValue(requiredFields)); + inlineTarget.getAnnotationMirrors().add(requiredFieldsMirror); + body.end(); + + } + + body.end(); + return method; + } + private static CodeExecutableElement createGetUncached(NodeData node, ExecutableElement constructor) { CodeExecutableElement method = CodeExecutableElement.clone(constructor); method.setSimpleName(CodeNames.of("getUncached")); @@ -303,6 +409,7 @@ private static CodeExecutableElement createGetUncached(NodeData node, Executable method.getModifiers().add(Modifier.PUBLIC); method.getModifiers().add(Modifier.STATIC); method.setReturnType(node.getNodeType()); + method.getAnnotationMirrors().add(new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().NeverDefault)); CodeTreeBuilder body = method.createBuilder(); body.startReturn(); TypeMirror type = NodeCodeGenerator.nodeType(node); @@ -328,6 +435,7 @@ private static CodeExecutableElement createCreateMethod(NodeData node, Executabl method.getModifiers().add(Modifier.PUBLIC); method.getModifiers().add(Modifier.STATIC); method.setReturnType(node.getNodeType()); + method.getAnnotationMirrors().add(new CodeAnnotationMirror(ProcessorContext.getInstance().getTypes().NeverDefault)); CodeTreeBuilder body = method.createBuilder(); body.startReturn(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StateQuery.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StateQuery.java new file mode 100644 index 000000000000..83c876c44e23 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StateQuery.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.generator; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Objects; + +import com.oracle.truffle.dsl.processor.generator.BitStateList.State; + +final class StateQuery { + + final Collection keys; + final Class> filterClass; + + private StateQuery(Class> filterClass, Collection keys) { + this.keys = keys; + this.filterClass = filterClass; + } + + boolean isEmpty() { + return keys != null && keys.isEmpty(); + } + + boolean match(State state) { + if (filterClass == null) { + return true; + } + return filterClass.isInstance(state); + } + + boolean filtersClass() { + return filterClass != null; + } + + @SafeVarargs + @SuppressWarnings("varargs") + static StateQuery create(Class> clazz, T... keys) { + return create(clazz, Arrays.asList(keys)); + } + + @SuppressWarnings("unchecked") + static StateQuery create(Class> clazz, Collection keys) { + Objects.requireNonNull(keys); + return new StateQuery(clazz, keys); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java index c26e36cdc342..cd7b210bb6cf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java @@ -43,18 +43,57 @@ import java.util.LinkedHashMap; import java.util.Map; +import javax.lang.model.element.Element; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; +/** + * Constants per top-level class. If multiple nodes are generated per top-level class, this allows + * to put them into the top-level class. They must not be specific to the individual generated node. + */ public final class StaticConstants { public final Map libraries = new LinkedHashMap<>(); public final Map contextReferences = new LinkedHashMap<>(); public final Map languageReferences = new LinkedHashMap<>(); + public final Map enumValues = new LinkedHashMap<>(); + public final Map decodeConstants = new LinkedHashMap<>(); + public final Map encodeConstants = new LinkedHashMap<>(); + public final Map reservedSymbols = new LinkedHashMap<>(); public void clear() { libraries.clear(); contextReferences.clear(); languageReferences.clear(); + enumValues.clear(); + reservedSymbols.clear(); + decodeConstants.clear(); + encodeConstants.clear(); + } + + public void addElementsTo(CodeElement element) { + element.addAll(libraries.values()); + element.addAll(contextReferences.values()); + element.addAll(languageReferences.values()); + element.addAll(enumValues.values()); + element.addAll(decodeConstants.values()); + element.addAll(encodeConstants.values()); + } + + public String reserveSymbol(TypeMirror type, String name) { + TypeMirror foundType = reservedSymbols.get(name); + if (foundType == null) { + reservedSymbols.put(name, type); + return name; + } else if (ElementUtils.typeEquals(foundType, type)) { + return name; + } else { + return reserveSymbol(type, name + "_"); + } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index d2eb9bf244ef..7aa52da2eb7d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -110,13 +110,6 @@ static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, String content) return cast(typeSystem, type, CodeTreeBuilder.singleString(content)); } - static CodeTree invokeImplicitCast(TypeSystemData typeSystem, ImplicitCastData cast, CodeTree expression) { - CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); - builder.startStaticCall(createTypeSystemGen(typeSystem), cast.getMethodName()).tree(expression); - builder.end(); - return builder.build(); - } - static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, CodeTree content) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 3b6218303c7c..017ad5292a98 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -107,6 +107,36 @@ public static ExecutableElement findMethod(DeclaredType type, String methodName) return null; } + public static List getEnumValues(TypeElement type) { + List values = new ArrayList<>(); + for (Element element : type.getEnclosedElements()) { + if (element.getKind() == ElementKind.ENUM_CONSTANT) { + values.add(element); + } + } + return values; + } + + public static ExecutableElement findMethod(DeclaredType type, String methodName, int parameterCount) { + ProcessorContext context = ProcessorContext.getInstance(); + TypeElement typeElement = context.getTypeElement(type); + for (ExecutableElement method : ElementFilter.methodsIn(typeElement.getEnclosedElements())) { + if (method.getParameters().size() == parameterCount && method.getSimpleName().toString().equals(methodName)) { + return method; + } + } + return null; + } + + public static ExecutableElement findStaticMethod(TypeElement type, String methodName) { + for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) { + if (method.getModifiers().contains(Modifier.STATIC) && method.getSimpleName().toString().equals(methodName)) { + return method; + } + } + return null; + } + public static String defaultValue(TypeMirror mirror) { switch (mirror.getKind()) { case VOID: @@ -137,10 +167,6 @@ public static String defaultValue(TypeMirror mirror) { } } - public static TypeMirror getType(Class element) { - return ProcessorContext.getInstance().getType(element); - } - public static TypeElement getTypeElement(final CharSequence typeName) { return ProcessorContext.getInstance().getTypeElement(typeName); } @@ -166,7 +192,11 @@ public static ExecutableElement findExecutableElement(DeclaredType type, String } public static VariableElement findVariableElement(DeclaredType type, String name) { - List elements = ElementFilter.fieldsIn(type.asElement().getEnclosedElements()); + return findVariableElement(type.asElement(), name); + } + + public static VariableElement findVariableElement(Element element, String name) { + List elements = ElementFilter.fieldsIn(element.getEnclosedElements()); for (VariableElement variableElement : elements) { if (variableElement.getSimpleName().toString().equals(name)) { return variableElement; @@ -304,6 +334,39 @@ public static String getReadableSignature(ExecutableElement method) { return builder.toString(); } + public static boolean hasOverloads(TypeElement enclosingType, ExecutableElement e) { + String name = e.getSimpleName().toString(); + for (ExecutableElement otherExecutable : ElementFilter.methodsIn(enclosingType.getEnclosedElements())) { + if (otherExecutable.getSimpleName().toString().equals(name)) { + if (!ElementUtils.elementEquals(e, otherExecutable)) { + return true; + } + } + } + return false; + } + + public static String getReadableSignature(ExecutableElement method, int highlightParameter) { + StringBuilder builder = new StringBuilder(); + builder.append(method.getSimpleName().toString()); + builder.append("("); + VariableElement var = method.getParameters().get(highlightParameter); + if (highlightParameter > 0) { + // not first parameter + builder.append("..., "); + } + + builder.append(getSimpleName(var.asType())).append(" "); + builder.append(var.getSimpleName().toString()); + + if (highlightParameter < method.getParameters().size() - 1) { + // not last + builder.append(", ..."); + } + builder.append(")"); + return builder.toString(); + } + public static boolean hasError(TypeMirror mirror) { switch (mirror.getKind()) { case BOOLEAN: @@ -1678,8 +1741,17 @@ public static String getReadableReference(Element relativeTo, Element element) { parent = getReadableReference(relativeTo, element.getEnclosingElement()); return parent + "." + getReadableSignature((ExecutableElement) element); case PARAMETER: - parent = getReadableReference(relativeTo, element.getEnclosingElement()); - return parent + " parameter " + element.getSimpleName().toString(); + Element enclosing = element.getEnclosingElement(); + if (enclosing instanceof ExecutableElement) { + ExecutableElement method = (ExecutableElement) enclosing; + int highlightIndex = method.getParameters().indexOf(element); + if (highlightIndex != -1) { + parent = getReadableReference(relativeTo, method.getEnclosingElement()); + return parent + "." + getReadableSignature(method, highlightIndex); + } + } + parent = getReadableReference(relativeTo, enclosing); + return " parameter " + element.getSimpleName().toString() + " in " + parent; case FIELD: parent = getReadableReference(relativeTo, element.getEnclosingElement()); return parent + "." + element.getSimpleName().toString(); @@ -1722,4 +1794,35 @@ public static String getBinaryName(TypeElement provider) { } } + public static final int COMPRESSED_POINTER_SIZE = 4; + public static final int COMPRESSED_HEADER_SIZE = 12; + + public static int getCompressedReferenceSize(TypeMirror mirror) { + switch (mirror.getKind()) { + case BOOLEAN: + case BYTE: + return 1; + case SHORT: + return 2; + case INT: + case FLOAT: + case CHAR: + return 4; + case DOUBLE: + case LONG: + return 8; + case DECLARED: + case ARRAY: + case TYPEVAR: + return COMPRESSED_POINTER_SIZE; + case VOID: + case NULL: + case EXECUTABLE: + // unknown + return 0; + default: + throw new RuntimeException("Unknown type specified " + mirror.getKind()); + } + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java index 7793ce233207..8fb8efae79c8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java @@ -58,6 +58,7 @@ import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.transform.AbstractCodeWriter; public abstract class CodeElement implements Element, GeneratedElement { @@ -69,6 +70,7 @@ public abstract class CodeElement implements Element, Generat private Element generatorElement; private AnnotationMirror generatorAnnotationMirror; + private CodeTree docTree; public CodeElement(Set modifiers) { this.modifiers = new LinkedHashSet<>(modifiers); @@ -89,6 +91,21 @@ public AnnotationMirror getGeneratorAnnotationMirror() { return generatorAnnotationMirror; } + public final CodeTree getDocTree() { + return docTree; + } + + public final void setDocTree(CodeTree docTree) { + this.docTree = docTree; + } + + public final CodeTreeBuilder createDocBuilder() { + CodeTreeBuilder builder = new CodeTreeBuilder(null); + builder.setEnclosingElement(this); + this.docTree = builder.getTree(); + return builder; + } + @Override public boolean equals(Object obj) { if (obj != null && this.getClass() == obj.getClass()) { @@ -131,10 +148,6 @@ public T addOptional(T element) { return element; } - public void remove(E element) { - getEnclosedElements().remove(element); - } - @Override public Set getModifiers() { return modifiers; @@ -165,15 +178,6 @@ public A[] getAnnotationsByType(Class annotationType) throw new UnsupportedOperationException(); } - /** - * Support for some JDK8 builds. (remove after jdk8 is released) - * - * @param annotationType - */ - public A[] getAnnotations(Class annotationType) { - throw new UnsupportedOperationException(); - } - /** * Support for some JDK8 builds. (remove after jdk8 is released) * @@ -210,23 +214,32 @@ List parentableList(Element parent, List list) { @Override public String toString() { StringBuilderCodeWriter codeWriter = new StringBuilderCodeWriter(); - accept(codeWriter, null); - return codeWriter.getString(); + String s; + try { + accept(codeWriter, null); + s = codeWriter.getString(); + } catch (Exception t) { + s = ElementUtils.printException(t); + } + return s; } private static class StringBuilderCodeWriter extends AbstractCodeWriter { + private final CharArrayWriter charWriter; + StringBuilderCodeWriter() { - this.writer = new CharArrayWriter(); + this.charWriter = new CharArrayWriter(); + this.writer = charWriter; } @Override protected Writer createWriter(CodeTypeElement clazz) throws IOException { - return writer; + return this.charWriter; } public String getString() { - return new String(((CharArrayWriter) writer).toCharArray()).trim(); + return new String(this.charWriter.toCharArray()).trim(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElementScanner.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElementScanner.java index 89fbb795bbf1..3b9f273ca7ac 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElementScanner.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElementScanner.java @@ -65,6 +65,9 @@ public R visitExecutable(CodeExecutableElement e, P p) { if (e.getBodyTree() != null) { visitTree(e.getBodyTree(), p, e); } + if (e.getDocTree() != null) { + visitTree(e.getDocTree(), p, e); + } return ret; } @@ -75,6 +78,10 @@ public R visitVariable(VariableElement e, P p) { if (init != null) { visitTree(init, p, e); } + CodeTree doc = ((CodeVariableElement) e).getDocTree(); + if (doc != null) { + visitTree(doc, p, e); + } } return super.visitVariable(e, p); } @@ -90,6 +97,10 @@ public final R visitType(TypeElement e, P p) { } public R visitType(CodeTypeElement e, P p) { + CodeTree doc = e.getDocTree(); + if (doc != null) { + visitTree(doc, p, e); + } return super.visitType(e, p); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeExecutableElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeExecutableElement.java index 80ab1510804a..a8c1fea0c9fb 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeExecutableElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeExecutableElement.java @@ -71,7 +71,6 @@ public class CodeExecutableElement extends CodeElement implements Execu private String body; private AnnotationValue defaultValue; private boolean varArgs; - private CodeTree docTree; public CodeExecutableElement(TypeMirror returnType, String name) { super(ElementUtils.modifiers()); @@ -154,13 +153,6 @@ public CodeTreeBuilder getBuilder() { return createBuilder().tree(tree); } - public CodeTreeBuilder createDocBuilder() { - CodeTreeBuilder builder = new CodeTreeBuilder(null); - builder.setEnclosingElement(this); - this.docTree = builder.getTree(); - return builder; - } - public CodeTreeBuilder createBuilder() { CodeTreeBuilder builder = new CodeTreeBuilder(null); builder.setEnclosingElement(this); @@ -180,14 +172,6 @@ public CodeTreeBuilder appendBuilder() { return builder; } - public CodeTree getDocTree() { - return docTree; - } - - public void setDocTree(CodeTree docTree) { - this.docTree = docTree; - } - public void setBodyTree(CodeTree body) { this.bodyTree = body; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java index 4ecab659ecaa..bf48cc32794e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java @@ -99,22 +99,37 @@ public CodeTreeBuilder startJavadoc() { public CodeTreeBuilder javadocLink(Element element, String title) { string("{@link "); if (element.getKind().isClass() || element.getKind().isInterface()) { - type(element.asType()); + push(element.asType(), true); } else if (element.getKind() == ElementKind.METHOD) { ExecutableElement e = (ExecutableElement) element; - type(e.getEnclosingElement().asType()); + TypeElement enclosingType = (TypeElement) e.getEnclosingElement(); + if (enclosingType != null) { + push(enclosingType.asType(), true); + } string("#"); - string(e.getSimpleName().toString()); - string("("); - String sep = ""; - for (VariableElement var : e.getParameters()) { - string(sep); - type(var.asType()); - sep = ", "; + String name = element.getSimpleName().toString(); + string(name); + + if (enclosingType == null || ElementUtils.hasOverloads(enclosingType, e)) { + string("("); + String sep = ""; + for (VariableElement var : e.getParameters()) { + string(sep); + push(var.asType(), true); + sep = ", "; + } + string(")"); } - string(")"); + } else if (element.getKind() == ElementKind.FIELD || element.getKind() == ElementKind.PARAMETER) { + VariableElement e = (VariableElement) element; + Element enclosing = e.getEnclosingElement(); + if (enclosing != null) { + push(enclosing.asType(), true); + } + string("#"); + string(e.getSimpleName().toString()); } else { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(element.getKind().toString()); } if (title != null && !title.isEmpty()) { string(" ", title); @@ -132,6 +147,15 @@ public CodeTreeBuilder statement(String statement) { return startStatement().string(statement).end(); } + public CodeTreeBuilder statement(String statement, String... strings) { + startStatement(); + string(statement); + for (String string : strings) { + string(string); + } + return end(); + } + public CodeTreeBuilder statement(CodeTree statement) { return startStatement().tree(statement).end(); } @@ -373,6 +397,10 @@ public CodeTreeBuilder doubleQuote(String s) { return startGroup().string("\"" + s + "\"").end(); } + public CodeTreeBuilder string(int chunk1) { + return push(String.valueOf(chunk1)); + } + public CodeTreeBuilder string(String chunk1) { return push(chunk1); } @@ -692,7 +720,7 @@ public CodeTreeBuilder type(TypeMirror type) { } public CodeTreeBuilder typeLiteral(TypeMirror type) { - return startGroup().push(type, true).end(); + return startGroup().push(type, true).string(".class").end(); } private void assertRoot() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTypeElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTypeElement.java index d28cdc88b799..bb6accf8ec10 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTypeElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTypeElement.java @@ -77,7 +77,6 @@ public class CodeTypeElement extends CodeElement implements TypeElement private final List typeParameters = parentableList(this, new ArrayList<>()); private ElementKind kind; private TypeMirror superClass; - private CodeTree docTree; private final DeclaredCodeTypeMirror mirror = new DeclaredCodeTypeMirror(this); @@ -94,21 +93,6 @@ public CodeTypeElement(Set modifiers, ElementKind kind, PackageElement this.qualifiedName = createQualifiedName(); } - public CodeTreeBuilder createDocBuilder() { - CodeTreeBuilder builder = new CodeTreeBuilder(null); - builder.setEnclosingElement(this); - this.docTree = builder.getTree(); - return builder; - } - - public CodeTree getDocTree() { - return docTree; - } - - public void setDocTree(CodeTree docTree) { - this.docTree = docTree; - } - public void setSimpleName(Name simpleName) { this.simpleName = simpleName; this.qualifiedName = createQualifiedName(); @@ -247,11 +231,6 @@ public List getInnerClasses() { return ElementFilter.typesIn(getEnclosedElements()); } - @Override - public String toString() { - return getQualifiedName().toString(); - } - @Override public R accept(ElementVisitor v, P p) { return v.visitType(this, p); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeVariableElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeVariableElement.java index 1f2453d46b69..c6bc911bbbc5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeVariableElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeVariableElement.java @@ -80,13 +80,6 @@ public CodeVariableElement(Set modifiers, TypeMirror type, String name this.name = CodeNames.of(name); } - public CodeVariableElement(Set modifiers, TypeMirror type, String name, String init) { - this(modifiers, type, name); - if (init != null) { - this.init = new CodeTree(null, CodeTreeKind.STRING, null, init); - } - } - public CodeTreeBuilder createInitBuilder() { CodeTreeBuilder builder = new CodeTreeBuilder(null); builder.setEnclosingElement(this); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/GeneratedTypeMirror.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/GeneratedTypeMirror.java index db8591d3193a..93b9089e9df7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/GeneratedTypeMirror.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/GeneratedTypeMirror.java @@ -51,10 +51,13 @@ public final class GeneratedTypeMirror extends DeclaredCodeTypeMirror { public GeneratedTypeMirror(String packageName, String name) { - super(new GeneratedTypeElement(Collections. emptySet(), ElementKind.CLASS, new GeneratedPackageElement(packageName), name, null)); + super(new GeneratedTypeElement(Collections. emptySet(), ElementKind.CLASS, + new GeneratedPackageElement(packageName), name, null)); } public GeneratedTypeMirror(String packageName, String name, TypeMirror superType) { - super(new GeneratedTypeElement(Collections. emptySet(), ElementKind.CLASS, new GeneratedPackageElement(packageName), name, superType)); + super(new GeneratedTypeElement(Collections. emptySet(), ElementKind.CLASS, + new GeneratedPackageElement(packageName), name, superType)); } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java index caecce10ca7a..f80db66264e9 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/AbstractCodeWriter.java @@ -44,6 +44,7 @@ import java.io.IOException; import java.io.Writer; +import java.lang.annotation.Repeatable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -51,7 +52,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Function; import javax.annotation.processing.FilerException; import javax.lang.model.element.AnnotationMirror; @@ -71,6 +71,7 @@ import javax.lang.model.util.AbstractAnnotationValueVisitor8; import javax.lang.model.util.ElementFilter; +import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeElementScanner; import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; @@ -84,7 +85,7 @@ public abstract class AbstractCodeWriter extends CodeElementScanner private static final int MAX_LINE_LENGTH = Integer.MAX_VALUE; // line wrapping disabled private static final int LINE_WRAP_INDENTS = 3; - private static final int MAX_JAVADOC_LINE_LENGTH = 100; + private static final int MAX_JAVADOC_LINE_LENGTH = 500; private static final String IDENT_STRING = " "; private static final String LN = System.lineSeparator(); /* unix style */ @@ -145,7 +146,7 @@ private void writeRootClass(CodeTypeElement e) { writeEmptyLn(); } - Set generateImports = imports.generateImports(); + Set generateImports = getImports().generateImports(); List typeImports = new ArrayList<>(); List staticImports = new ArrayList<>(); @@ -186,10 +187,6 @@ private String useImport(Element enclosedType, TypeMirror type, boolean rawType) } } - static class Foobar, BiFunction> { - - } - private void writeClassImpl(CodeTypeElement e) { if (e.getDocTree() != null) { visitTree(e.getDocTree(), null, e); @@ -356,16 +353,21 @@ private static List getInstanceMethods(CodeTypeElement clazz) public Void visitVariable(VariableElement f, Void p) { Element parent = f.getEnclosingElement(); + CodeTree init = null; + if (f instanceof CodeVariableElement) { + CodeVariableElement codeVar = ((CodeVariableElement) f); + init = codeVar.getInit(); + + if (codeVar.getDocTree() != null) { + visitTree(codeVar.getDocTree(), null, f); + } + } + for (AnnotationMirror annotation : f.getAnnotationMirrors()) { visitAnnotation(f, annotation); write(" "); } - CodeTree init = null; - if (f instanceof CodeVariableElement) { - init = ((CodeVariableElement) f).getInit(); - } - if (parent != null && parent.getKind() == ElementKind.ENUM && f.getModifiers().contains(Modifier.STATIC)) { write(f.getSimpleName()); if (init != null) { @@ -406,13 +408,23 @@ public Void visitVariable(VariableElement f, Void p) { } private void visitAnnotation(Element enclosedElement, AnnotationMirror e) { - write("@").write(useImport(enclosedElement, e.getAnnotationType(), true)); + List repeatableAnnotations = unpackRepeatable(e); + if (repeatableAnnotations != null) { + for (AnnotationMirror annotationMirror : repeatableAnnotations) { + visitAnnotationImpl(enclosedElement, annotationMirror); + } + } else { + visitAnnotationImpl(enclosedElement, e); + } + } + + private void visitAnnotationImpl(Element enclosedElement, AnnotationMirror e) { + final ExecutableElement defaultElement = findExecutableElement(e.getAnnotationType(), "value"); + Map values = e.getElementValues(); + write("@").write(useImport(enclosedElement, e.getAnnotationType(), true)); if (!e.getElementValues().isEmpty()) { write("("); - final ExecutableElement defaultElement = findExecutableElement(e.getAnnotationType(), "value"); - - Map values = e.getElementValues(); if (defaultElement != null && values.size() == 1 && values.get(defaultElement) != null) { visitAnnotationValue(enclosedElement, values.get(defaultElement)); } else { @@ -424,7 +436,6 @@ private void visitAnnotation(Element enclosedElement, AnnotationMirror e) { } methodsList.add(method); } - Collections.sort(methodsList, new Comparator() { @Override @@ -450,6 +461,64 @@ public int compare(ExecutableElement o1, ExecutableElement o2) { } } + /** + * This method checks whether an annotation can be written as a set of repeatable annotations + * instead. Returns a list of elements if it can or null if it can't. + */ + static List unpackRepeatable(AnnotationMirror e) { + final ExecutableElement defaultElement = findExecutableElement(e.getAnnotationType(), "value"); + if (defaultElement == null) { + return null; + } + TypeMirror returnType = defaultElement.getReturnType(); + if (returnType.getKind() != TypeKind.ARRAY) { + /* + * Not an array. Not a repeatable annotation. + */ + return null; + } + + ArrayType arrayReturnType = (ArrayType) returnType; + + TypeElement typeElement = ElementUtils.fromTypeMirror(arrayReturnType.getComponentType()); + if (typeElement == null) { + // just to be robust against not referenced classes. + return null; + } + + AnnotationMirror repeatable = ElementUtils.findAnnotationMirror(typeElement.getAnnotationMirrors(), ProcessorContext.getInstance().getType(Repeatable.class)); + if (repeatable == null) { + /* + * Annotation type does not declare repeatable. + */ + return null; + } + + TypeMirror repeatableType = ElementUtils.getAnnotationValue(TypeMirror.class, repeatable, "value"); + if (!ElementUtils.typeEquals(repeatableType, e.getAnnotationType())) { + /* + * Not the right repeatable type. + */ + return null; + } + + if (e.getElementValues().size() != 1) { + /* + * Repeating annotation has more than one attribute. We should not unpack repeatable + * annotations to not loose some attributes there. + */ + return null; + } + if (!e.getElementValues().containsKey(defaultElement)) { + /* + * Does not contain the default element. + */ + return null; + } + + return ElementUtils.getAnnotationValueList(AnnotationMirror.class, e, "value"); + } + private void visitAnnotationValue(Element enclosedElement, AnnotationValue e) { e.accept(new AnnotationValueWriterVisitor(enclosedElement), null); } @@ -541,15 +610,20 @@ public Void visitAnnotation(AnnotationMirror a, Void p) { @Override public Void visitArray(List vals, Void p) { - write("{"); - for (int i = 0; i < vals.size(); i++) { + int size = vals.size(); + if (size > 1) { + write("{"); + } + for (int i = 0; i < size; i++) { AnnotationValue value = vals.get(i); AbstractCodeWriter.this.visitAnnotationValue(enclosedElement, value); - if (i < vals.size() - 1) { + if (i < size - 1) { write(", "); } } - write("}"); + if (size > 1) { + write("}"); + } return null; } } @@ -668,6 +742,13 @@ public Void visitExecutable(CodeExecutableElement e, Void p) { return null; } + private OrganizedImports getImports() { + if (imports == null) { + return OrganizedImports.organize(null); + } + return imports; + } + @Override public void visitTree(CodeTree e, Void p, Element enclosingElement) { CodeTreeKind kind = e.getCodeKind(); @@ -717,14 +798,14 @@ public void visitTree(CodeTree e, Void p, Element enclosingElement) { break; case STATIC_FIELD_REFERENCE: if (e.getString() != null) { - write(imports.createStaticFieldReference(enclosingElement, e.getType(), e.getString())); + write(getImports().createStaticFieldReference(enclosingElement, e.getType(), e.getString())); } else { write("null"); } break; case STATIC_METHOD_REFERENCE: if (e.getString() != null) { - write(imports.createStaticMethodReference(enclosingElement, e.getType(), e.getString())); + write(getImports().createStaticMethodReference(enclosingElement, e.getType(), e.getString())); } else { write("null"); } @@ -734,7 +815,6 @@ public void visitTree(CodeTree e, Void p, Element enclosingElement) { break; case TYPE_LITERAL: write(useImport(enclosingElement, e.getType(), true)); - write(".class"); break; case JAVA_DOC: case DOC: diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/FixWarningsVisitor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/FixWarningsVisitor.java index 026d89e4325c..9044a93028bd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/FixWarningsVisitor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/FixWarningsVisitor.java @@ -60,6 +60,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement; import com.oracle.truffle.dsl.processor.java.model.CodeTree; import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; public class FixWarningsVisitor extends CodeElementScanner { @@ -67,14 +68,12 @@ public class FixWarningsVisitor extends CodeElementScanner { private final DeclaredType overrideType; - private final Element generatedBy; private Set suppressedWarnings = new HashSet<>(); private boolean computeSymbols = false; - private boolean seenDeprecatedType = false; + private boolean seenDeprecatedElement = false; - public FixWarningsVisitor(Element generatedBy, DeclaredType overrideType) { + public FixWarningsVisitor(DeclaredType overrideType) { this.overrideType = overrideType; - this.generatedBy = generatedBy; } @Override @@ -95,27 +94,36 @@ public Void visitType(CodeTypeElement e, Void p) { } } + if (e.getDocTree() != null) { + suppressedWarnings.add("javadoc"); + } + if (ElementUtils.isPackageDeprecated(e)) { suppressedWarnings.add("deprecation"); } super.visitType(e, p); - if (seenDeprecatedType && rootType) { - AnnotationMirror suppressWarnings = ElementUtils.findAnnotationMirror(generatedBy, SuppressWarnings.class); - if (suppressWarnings != null) { - List currentValues = ElementUtils.getAnnotationValueList(String.class, suppressWarnings, "value"); - if (currentValues.contains("deprecation")) { - suppressedWarnings.add("deprecation"); - } - } + if (seenDeprecatedElement && rootType) { + suppressedWarnings.add("deprecation"); } if (rootType && !suppressedWarnings.isEmpty()) { - GeneratorUtils.mergeSupressWarnings(e, suppressedWarnings.toArray(new String[0])); + GeneratorUtils.mergeSuppressWarnings(e, suppressedWarnings.toArray(new String[0])); } return null; } + @Override + public Void visitVariable(VariableElement e, Void p) { + if (e instanceof CodeVariableElement) { + CodeVariableElement var = (CodeVariableElement) e; + if (var.getDocTree() != null) { + suppressedWarnings.add("javadoc"); + } + } + return super.visitVariable(e, p); + } + @Override public Void visitExecutable(CodeExecutableElement e, Void p) { boolean checkIgnored = !suppressedWarnings.contains("unused"); @@ -127,6 +135,10 @@ public Void visitExecutable(CodeExecutableElement e, Void p) { checkIgnored = false; } + if (e.getDocTree() != null) { + suppressedWarnings.add("javadoc"); + } + symbolsUsed.clear(); computeSymbols = checkIgnored; @@ -150,7 +162,7 @@ public Void visitExecutable(CodeExecutableElement e, Void p) { private void checkDeprecated(TypeMirror mirror) { if (ElementUtils.isDeprecated(mirror)) { - seenDeprecatedType = true; + seenDeprecatedElement = true; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java index d9029edfe847..a3e523b894ce 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @@ -100,7 +100,9 @@ public static OrganizedImports organize(CodeTypeElement topLevelClass) { private void organizeImpl() { ImportTypeReferenceVisitor reference = new ImportTypeReferenceVisitor(); - topLevelClass.accept(reference, null); + if (topLevelClass != null) { + topLevelClass.accept(reference, null); + } } public String createTypeReference(Element enclosedElement, TypeMirror type, boolean raw) { @@ -166,6 +168,9 @@ private String createDeclaredTypeName(Element enclosedElement, DeclaredType type } } if (raw) { + if (name.equals("com.oracle.truffle.api.dsl.test.Cached")) { + System.out.println(); + } return name; } @@ -329,9 +334,6 @@ public void visitTree(CodeTree e, Void p, Element enclosing) { @Override public Void visitExecutable(CodeExecutableElement e, Void p) { - if (e.getDocTree() != null) { - visitTree(e.getDocTree(), null, e); - } visitAnnotations(e, e.getAnnotationMirrors()); if (e.getReturnType() != null) { visitTypeReference(e, e.getReturnType()); @@ -369,21 +371,29 @@ private void visitAnnotations(Element enclosingElement, List values = e.getElementValues(); - Set methodsSet = values.keySet(); - List methodsList = new ArrayList<>(); - for (ExecutableElement method : methodsSet) { - if (values.get(method) == null) { - continue; - } - methodsList.add(method); + List repeatables = AbstractCodeWriter.unpackRepeatable(e); + if (repeatables != null) { + for (AnnotationMirror repeatable : repeatables) { + visitAnnotation(enclosingElement, repeatable); } + } else { + visitTypeReference(enclosingElement, e.getAnnotationType()); + + if (!e.getElementValues().isEmpty()) { + Map values = e.getElementValues(); + Set methodsSet = values.keySet(); + List methodsList = new ArrayList<>(); + for (ExecutableElement method : methodsSet) { + if (values.get(method) == null) { + continue; + } + methodsList.add(method); + } - for (int i = 0; i < methodsList.size(); i++) { - AnnotationValue value = values.get(methodsList.get(i)); - visitAnnotationValue(enclosingElement, value); + for (int i = 0; i < methodsList.size(); i++) { + AnnotationValue value = values.get(methodsList.get(i)); + visitAnnotationValue(enclosingElement, value); + } } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 6a92d61a693a..8ee8926c9e47 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -86,6 +86,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; +import com.oracle.truffle.dsl.processor.generator.NodeConstants; import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; @@ -234,9 +235,7 @@ public List create(ProcessorContext context1, AnnotationProcess statics.end(); statics.end(); - genClass.addAll(constants.libraries.values()); - genClass.addAll(constants.contextReferences.values()); - genClass.addAll(constants.languageReferences.values()); + constants.addElementsTo(genClass); return Arrays.asList(genClass); } @@ -583,6 +582,8 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map caches = new ArrayList<>(); for (CacheKey key : eagerCaches.keySet()) { caches.add(key.cache); @@ -812,8 +813,8 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map { public static final String EXECUTE_PREFIX = "execute"; public static final String EXECUTE_SUFFIX = "_"; - public final List annotations = Arrays.asList(types.ExportMessage, types.ExportLibrary); - @Override public boolean isDelegateToRootDeclaredType() { return false; @@ -346,6 +344,7 @@ protected ExportsData parse(Element element, List elementMirro for (ExportsLibrary exportsLibrary : declaredExports) { // recreate cache for every exports library to not confuse exports configuration Map parsedNodeCache = new HashMap<>(); + int specializedNodeCount = 0; for (ExportMessageData exportedElement : exportsLibrary.getExportedMessages().values()) { if (exportedElement.isOverriden()) { // must not initialize overridden elements because otherwise the parsedNodeCache @@ -360,6 +359,20 @@ protected ExportsData parse(Element element, List elementMirro } else { throw new AssertionError("should not be reachable"); } + if (exportedElement.getSpecializedNode() != null) { + specializedNodeCount++; + } + } + for (ExportMessageData exportedElement : exportsLibrary.getExportedMessages().values()) { + if (exportedElement.isOverriden()) { + // must not initialize overridden elements because otherwise the parsedNodeCache + // gets confused. + continue; + } + + if (exportedElement.getSpecializedNode() != null) { + exportedElement.getSpecializedNode().setActivationProbability(1.0d / specializedNodeCount); + } } } @@ -433,9 +446,11 @@ protected ExportsData parse(Element element, List elementMirro for (ExportsLibrary libraryExports : model.getExportedLibraries().values()) { List cachedSharedNodes = new ArrayList<>(); List exportedMessages = new ArrayList<>(); + for (ExportMessageData export : libraryExports.getExportedMessages().values()) { - if (export.getSpecializedNode() != null) { - cachedSharedNodes.add(export.getSpecializedNode()); + NodeData node = export.getSpecializedNode(); + if (node != null) { + cachedSharedNodes.add(node); exportedMessages.add(export); } } @@ -557,8 +572,7 @@ private ExportsData parseExports(TypeElement type, List elemen explicitReceiver = true; } - Map libraryCache = ProcessorContext.getInstance().getCacheMap(LibraryParser.class); - LibraryData libraryData = libraryCache.computeIfAbsent(fromTypeMirror(libraryMirror), (t) -> new LibraryParser().parse(t)); + LibraryData libraryData = context.parseIfAbsent(fromTypeMirror(libraryMirror), LibraryParser.class, (t) -> new LibraryParser().parse(t)); ExportsLibrary lib = new ExportsLibrary(context, type, annotationMirror, model, libraryData, receiverClass, explicitReceiver); ExportsLibrary otherLib = model.getExportedLibraries().get(libraryId); @@ -697,14 +711,7 @@ private ExportsData parseExports(TypeElement type, List elemen if (transitionLimit != null) { DSLExpressionResolver resolver = new DSLExpressionResolver(context, model.getTemplateType(), NodeParser.importVisibleStaticMembers(model.getTemplateType(), model.getTemplateType(), false)); - try { - DSLExpression expression = DSLExpression.parse(transitionLimit); - expression.accept(resolver); - lib.setTransitionLimit(expression); - } catch (InvalidExpressionException e) { - AnnotationValue allowTransition = ElementUtils.getAnnotationValue(annotationMirror, "transitionLimit"); - model.addError(annotationMirror, allowTransition, "Error parsing expression '%s': %s", transitionLimit, e.getMessage()); - } + lib.setTransitionLimit(DSLExpression.parseAndResolve(resolver, lib, "transitionLimit", transitionLimit)); } String delegateTo = ElementUtils.getAnnotationValue(String.class, annotationMirror, "delegateTo", false); @@ -1155,6 +1162,17 @@ private void initializeExportedMethod(Map parsedNodeCache, Exp element.getParameters().add(0, new CodeVariableElement(exportedElement.getReceiverType(), "this")); element.getModifiers().add(Modifier.STATIC); } + + if (message.getName().equals("accepts")) { + /* + * We suppress never default messages in accepts because they will be eager + * initialized. So it does not matter whether they are never default. Eager + * initialization is computed later in the exports generated, so is not yet + * available here. + */ + GeneratorUtils.mergeSuppressWarnings(element, TruffleSuppressedWarnings.NEVERDEFAULT); + } + type.add(element); NodeData parsedNodeData = parseNode(parsedNodeCache, type, exportedElement, Collections.emptyList()); if (parsedNodeData == null) { @@ -1228,9 +1246,11 @@ private NodeData parseNode(Map parsedNodeCache, TypeElement no clonedType.getAnnotationMirrors().clear(); clonedType.getAnnotationMirrors().add(newImports); + if (exportedMessage.getExportsLibrary().isUseForAOT()) { clonedType.getAnnotationMirrors().add(new CodeAnnotationMirror(types.GenerateAOT)); } + if (generateUncached != null) { clonedType.getAnnotationMirrors().add(generateUncached); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryData.java index a3c57377f00a..c95791d511b4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryData.java @@ -56,8 +56,6 @@ public final class LibraryData extends Template { private final List methods = new ArrayList<>(); private final List superTypes = new ArrayList<>(); - private List cachedSignature; - private List cachedSignatureNames; private final List defaultExports = new ArrayList<>(); private TypeMirror signatureReceiverType; @@ -136,22 +134,6 @@ protected List findChildContainers() { return (List) (List) methods; } - void setCachedSignatureNames(List cachedSignatureNames) { - this.cachedSignatureNames = cachedSignatureNames; - } - - public List getCachedSignatureNames() { - return cachedSignatureNames; - } - - void setCachedSignature(List cachedSignature) { - this.cachedSignature = cachedSignature; - } - - public List getCachedSignature() { - return cachedSignature; - } - public List getDefaultExports() { return defaultExports; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryGenerator.java index 58f7e2486439..fce66a2c254a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryGenerator.java @@ -97,7 +97,6 @@ public class LibraryGenerator extends CodeTypeElementFactory { class MessageObjects { final LibraryMessage model; final int messageIndex; - int cacheIndex; CodeVariableElement messageField; MessageObjects(LibraryMessage message, int messageIndex) { @@ -127,7 +126,7 @@ public List create(ProcessorContext context1, AnnotationProcess TypeMirror classLiteral = new CodeTypeMirror.DeclaredCodeTypeMirror(context.getTypeElement(Class.class), Arrays.asList(libraryTypeMirror)); CodeExecutableElement loadLibraryClass = genClass.add(new CodeExecutableElement(modifiers(PRIVATE, STATIC), classLiteral, "lazyLibraryClass")); - GeneratorUtils.mergeSupressWarnings(loadLibraryClass, "unchecked"); + GeneratorUtils.mergeSuppressWarnings(loadLibraryClass, "unchecked"); builder = loadLibraryClass.createBuilder(); builder.startTryBlock(); builder.startStatement().string("return "); @@ -335,7 +334,7 @@ public List create(ProcessorContext context1, AnnotationProcess } } if (uncheckedCast) { - GeneratorUtils.mergeSupressWarnings(executeImpl, "unchecked"); + GeneratorUtils.mergeSuppressWarnings(executeImpl, "unchecked"); } } @@ -439,7 +438,7 @@ public List create(ProcessorContext context1, AnnotationProcess builder.end(); // else block } if (uncheckedCast) { - GeneratorUtils.mergeSupressWarnings(executeImpl, "unchecked"); + GeneratorUtils.mergeSuppressWarnings(executeImpl, "unchecked"); } } @@ -470,7 +469,7 @@ public List create(ProcessorContext context1, AnnotationProcess boolean pushEncapsulating = model.isPushEncapsulatingNode(); if (pushEncapsulating) { - GeneratorUtils.pushEncapsulatingNode(builder, "getParent()"); + GeneratorUtils.pushEncapsulatingNode(builder, CodeTreeBuilder.singleString("getParent()")); builder.startTryBlock(); } builder.startReturn().startCall("INSTANCE.getUncached(receiver_)", execute.getSimpleName().toString()); @@ -761,9 +760,7 @@ public List create(ProcessorContext context1, AnnotationProcess builder.end(); // superCall builder.end(); // statement - genClass.addAll(constants.libraries.values()); - genClass.addAll(constants.contextReferences.values()); - genClass.addAll(constants.languageReferences.values()); + constants.addElementsTo(genClass); return Arrays.asList(genClass); } @@ -937,7 +934,7 @@ private CodeExecutableElement createGenericDispatch(List methods builder.startThrow().startNew(context.getType(AbstractMethodError.class)).string("message.toString()").end().end(); if (uncheckedCast) { - GeneratorUtils.mergeSupressWarnings(reflectionGenericDispatch, "unchecked"); + GeneratorUtils.mergeSuppressWarnings(reflectionGenericDispatch, "unchecked"); } return reflectionGenericDispatch; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryMessage.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryMessage.java index a2c7b2510888..1eeaa963d61a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryMessage.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryMessage.java @@ -54,7 +54,6 @@ public final class LibraryMessage extends MessageContainer { private final LibraryData library; private final String name; private final ExecutableElement executable; - private String cacheName; private boolean isAbstract; private final Set abstractIfExported = new LinkedHashSet<>(); @@ -76,14 +75,6 @@ public String getSimpleName() { return library.getMessageElement().getSimpleName().toString() + "." + name; } - public String getCacheName() { - return cacheName; - } - - void setCacheName(String cacheName) { - this.cacheName = cacheName; - } - public ExecutableElement getExecutable() { return executable; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryParser.java index a976475b6006..aa54412257a2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/LibraryParser.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.dsl.processor.library; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -63,8 +62,6 @@ public class LibraryParser extends AbstractParser { - public final List annotations = Arrays.asList(types.GenerateLibrary, types.GenerateLibrary_DefaultExport, types.GenerateLibrary_Abstract); - @Override public boolean isDelegateToRootDeclaredType() { return true; @@ -99,6 +96,18 @@ protected LibraryData parse(Element element, List mirrors) { model.setGenerateAOT(true); } + AnnotationMirror invalidAnnotation = ElementUtils.findAnnotationMirror(element, types.GenerateCached); + if (invalidAnnotation == null) { + invalidAnnotation = ElementUtils.findAnnotationMirror(element, types.GenerateUncached); + } + if (invalidAnnotation == null) { + invalidAnnotation = ElementUtils.findAnnotationMirror(element, types.GenerateInline); + } + if (invalidAnnotation != null) { + model.addError(invalidAnnotation, null, "The annotation @%s cannot be used on a library.", ElementUtils.getSimpleName(invalidAnnotation.getAnnotationType())); + return model; + } + model.setDefaultExportLookupEnabled(ElementUtils.getAnnotationValue(Boolean.class, mirror, "defaultExportLookupEnabled")); model.setDynamicDispatchEnabled(ElementUtils.getAnnotationValue(Boolean.class, mirror, "dynamicDispatchEnabled")); model.setPushEncapsulatingNode(ElementUtils.getAnnotationValue(Boolean.class, mirror, "pushEncapsulatingNode")); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java index cce25b538427..ea7b110465f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java @@ -42,11 +42,14 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue; +import java.util.Objects; + import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.type.DeclaredType; +import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.expression.DSLExpression; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Binary; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Call; @@ -72,6 +75,9 @@ public final class CacheExpression extends MessageContainer { private boolean isWeakReferenceGet; private boolean isWeakReference; private boolean adopt = true; + private boolean neverDefault; + private boolean neverDefaultGuaranteed; + private InlinedNodeData inlinedNode; private LibraryData cachedlibrary; private boolean usedInGuard; @@ -87,6 +93,17 @@ public CacheExpression copy() { copy.defaultExpression = this.defaultExpression; copy.uncachedExpression = this.uncachedExpression; copy.alwaysInitialized = this.alwaysInitialized; + copy.eagerInitialize = this.eagerInitialize; + copy.uncachedExpressionError = this.uncachedExpressionError; + copy.requiresBoundary = this.requiresBoundary; + copy.mergedLibrary = this.mergedLibrary; + copy.isWeakReference = this.isWeakReference; + copy.isWeakReferenceGet = this.isWeakReferenceGet; + copy.adopt = this.adopt; + copy.inlinedNode = this.inlinedNode != null ? this.inlinedNode.copy() : null; + copy.cachedlibrary = cachedlibrary; + copy.usedInGuard = usedInGuard; + copy.neverDefault = neverDefault; return copy; } @@ -98,6 +115,30 @@ public boolean isUsedInGuard() { return usedInGuard; } + public boolean isNeverDefault() { + return neverDefault; + } + + public void setNeverDefault(boolean neverDefault) { + this.neverDefault = neverDefault; + } + + public boolean isNeverDefaultGuaranteed() { + return neverDefaultGuaranteed; + } + + public void setNeverDefaultGuaranteed(boolean neverDefault) { + this.neverDefaultGuaranteed = neverDefault; + } + + public void setInlinedNode(InlinedNodeData inlinedNode) { + this.inlinedNode = inlinedNode; + } + + public InlinedNodeData getInlinedNode() { + return inlinedNode; + } + public boolean isEagerInitialize() { return eagerInitialize; } @@ -110,6 +151,13 @@ public AnnotationMirror getSharedGroupMirror() { return ElementUtils.findAnnotationMirror(sourceParameter.getVariableElement(), types.Cached_Shared); } + public boolean isEncodedEnum() { + if (!isCached()) { + return false; + } + return ElementUtils.isAssignable(getParameter().getType(), ProcessorContext.getInstance().getType(Enum.class)); + } + public AnnotationValue getSharedGroupValue() { AnnotationMirror sharedAnnotation = getSharedGroupMirror(); if (sharedAnnotation != null) { @@ -230,6 +278,21 @@ public boolean isMergedLibrary() { return mergedLibrary; } + public boolean isThisExpression() { + DSLExpression e = getDefaultExpression(); + if (!(e instanceof Variable)) { + return false; + } + Variable v = (Variable) e; + if (v.getResolvedVariable() instanceof CodeVariableElement) { + if (v.getResolvedVariable().getSimpleName().toString().equals("this")) { + return true; + } + } + + return false; + } + public String getMergedLibraryIdentifier() { DSLExpression identifierExpression = getDefaultExpression().reduce(new DSLExpressionReducer() { @@ -316,4 +379,9 @@ public boolean usesDefaultCachedInitializer() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "value", false) == null; } + @Override + public String toString() { + return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) + "[" + Objects.toString(sourceParameter) + "]"; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ExecutableTypeData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ExecutableTypeData.java index acc9d552dbc5..439df0a09f2d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ExecutableTypeData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ExecutableTypeData.java @@ -368,23 +368,6 @@ public String toString() { return String.format("%s %s(%s,%s)", formatType(getReturnType()), getName(), formatType(getFrameParameter()), getEvaluatedParameters()); } - public boolean sameParameters(ExecutableTypeData other) { - if (!typeEquals(other.getFrameParameter(), getFrameParameter())) { - return false; - } - - if (getEvaluatedCount() != other.getEvaluatedCount()) { - return false; - } - - for (int i = 0; i < getEvaluatedCount(); i++) { - if (!typeEquals(getEvaluatedParameters().get(i), other.getEvaluatedParameters().get(i))) { - return false; - } - } - return true; - } - public boolean sameSignature(ExecutableTypeData other) { if (!typeEquals(other.getReturnType(), getReturnType())) { return false; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java index 6d53af610c9d..b883637ddbce 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java @@ -57,7 +57,6 @@ import com.oracle.truffle.dsl.processor.expression.DSLExpression.Binary; import com.oracle.truffle.dsl.processor.expression.DSLExpression.BooleanLiteral; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Call; -import com.oracle.truffle.dsl.processor.expression.DSLExpression.Negate; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -76,6 +75,13 @@ public GuardExpression(SpecializationData source, DSLExpression expression) { this.expression = expression; } + public GuardExpression copy(SpecializationData newSpecialization) { + GuardExpression guard = new GuardExpression(newSpecialization, expression); + guard.libraryAcceptsGuard = libraryAcceptsGuard; + guard.weakReferenceGuard = weakReferenceGuard; + return guard; + } + @Override public Element getMessageElement() { return source.getMessageElement(); @@ -193,23 +199,6 @@ public DSLExpression visitBinary(Binary binary) { return false; } - public boolean equalsNegated(GuardExpression other) { - boolean negated = false; - DSLExpression thisExpression = expression; - if (thisExpression instanceof Negate) { - negated = true; - thisExpression = ((Negate) thisExpression).getReceiver(); - } - - boolean otherNegated = false; - DSLExpression otherExpression = other.expression; - if (otherExpression instanceof Negate) { - otherNegated = true; - otherExpression = ((Negate) otherExpression).getReceiver(); - } - return Objects.equals(thisExpression, otherExpression) && negated != otherNegated; - } - public boolean implies(GuardExpression other) { if (Objects.equals(expression, other.expression)) { return true; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlineFieldData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlineFieldData.java new file mode 100644 index 000000000000..bbdf1e1a6357 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlineFieldData.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.model; + +import static com.oracle.truffle.dsl.processor.ProcessorContext.types; +import static com.oracle.truffle.dsl.processor.java.ElementUtils.typeEquals; + +import java.util.Arrays; + +import javax.lang.model.element.Element; +import javax.lang.model.type.TypeMirror; + +import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleTypes; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror; + +public final class InlineFieldData { + + final Element sourceElement; + final String name; + final Integer bits; + final TypeMirror type; + final TypeMirror fieldType; + final int dimensions; + + public InlineFieldData(Element sourceElement, String name, TypeMirror fieldType, Integer bits, TypeMirror type, int dimensions) { + this.sourceElement = sourceElement; + this.name = name; + this.fieldType = fieldType; + this.bits = bits; + this.dimensions = dimensions; + if (isPrimitive()) { + this.type = resolvePrimitiveValueType(fieldType); + } else { + this.type = type; + } + } + + public static TypeMirror resolvePrimitiveFieldType(TypeMirror valueType) { + ProcessorContext context = ProcessorContext.getInstance(); + if (typeEquals(valueType, context.getType(boolean.class))) { + return types().InlineSupport_BooleanField; + } else if (typeEquals(valueType, context.getType(byte.class))) { + return types().InlineSupport_ByteField; + } else if (typeEquals(valueType, context.getType(short.class))) { + return types().InlineSupport_ShortField; + } else if (typeEquals(valueType, context.getType(char.class))) { + return types().InlineSupport_CharField; + } else if (typeEquals(valueType, context.getType(int.class))) { + return types().InlineSupport_IntField; + } else if (typeEquals(valueType, context.getType(float.class))) { + return types().InlineSupport_FloatField; + } else if (typeEquals(valueType, context.getType(long.class))) { + return types().InlineSupport_LongField; + } else if (typeEquals(valueType, context.getType(double.class))) { + return types().InlineSupport_DoubleField; + } else { + throw new AssertionError("Invalid primitive field type."); + } + } + + private static TypeMirror resolvePrimitiveValueType(TypeMirror fieldType) { + ProcessorContext context = ProcessorContext.getInstance(); + if (typeEquals(fieldType, types().InlineSupport_BooleanField)) { + return context.getType(boolean.class); + } else if (typeEquals(fieldType, types().InlineSupport_ByteField)) { + return context.getType(byte.class); + } else if (typeEquals(fieldType, types().InlineSupport_ShortField)) { + return context.getType(short.class); + } else if (typeEquals(fieldType, types().InlineSupport_CharField)) { + return context.getType(char.class); + } else if (typeEquals(fieldType, types().InlineSupport_IntField)) { + return context.getType(int.class); + } else if (typeEquals(fieldType, types().InlineSupport_FloatField)) { + return context.getType(float.class); + } else if (typeEquals(fieldType, types().InlineSupport_LongField)) { + return context.getType(long.class); + } else if (typeEquals(fieldType, types().InlineSupport_DoubleField)) { + return context.getType(double.class); + } else { + throw new AssertionError("Invalid primitive field type."); + } + } + + public int getDimensions() { + return dimensions; + } + + public String getName() { + return name; + } + + public Element getSourceElement() { + return sourceElement; + } + + public TypeMirror getFieldType() { + if (isReference()) { + return new CodeTypeMirror.DeclaredCodeTypeMirror(ElementUtils.castTypeElement(fieldType), Arrays.asList(getType())); + } + return fieldType; + } + + public boolean isState() { + TruffleTypes types = ProcessorContext.getInstance().getTypes(); + return typeEquals(fieldType, types.InlineSupport_StateField); + } + + public boolean isPrimitive() { + return !isState() && !isReference(); + } + + public boolean isReference() { + TruffleTypes types = ProcessorContext.getInstance().getTypes(); + return typeEquals(fieldType, types.InlineSupport_ReferenceField); + } + + public boolean hasBits() { + return bits != null; + } + + public int getBits() { + return bits; + } + + public TypeMirror getType() { + return type; + } + + public InlineFieldData copy() { + return new InlineFieldData(sourceElement, name, fieldType, bits, type, dimensions); + } + + public boolean isCompatibleWith(InlineFieldData declared) { + if (!ElementUtils.typeEquals(fieldType, declared.fieldType)) { + return false; + } + if (!ElementUtils.typeEquals(type, declared.type)) { + return false; + } + if (this.dimensions != declared.dimensions) { + return false; + } + if (declared.bits == null ^ bits == null) { + return false; + } + if (declared.bits != null) { + if (declared.bits < bits) { + return false; + } + } + return true; + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlinedNodeData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlinedNodeData.java new file mode 100644 index 000000000000..e973be599375 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/InlinedNodeData.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.model; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.lang.model.element.ExecutableElement; + +public final class InlinedNodeData { + + private final ExecutableElement method; + private List fields; + + public InlinedNodeData(ExecutableElement method, List fields) { + this.method = method; + this.fields = fields; + } + + public List getFields() { + return fields; + } + + public ExecutableElement getMethod() { + return method; + } + + public InlinedNodeData copy() { + return new InlinedNodeData(method, fields.stream().map((f) -> f.copy()).collect(Collectors.toList())); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java index 39d29876cf86..5d5a2193c869 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/MessageContainer.java @@ -43,35 +43,50 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; -import java.util.ListIterator; +import java.util.Map; import java.util.Set; +import java.util.function.Predicate; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; import com.oracle.truffle.dsl.processor.ExpectError; import com.oracle.truffle.dsl.processor.Log; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; +import com.oracle.truffle.dsl.processor.TruffleSuppressedWarnings; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.GeneratedElement; public abstract class MessageContainer implements Iterable { - private final List messages = new ArrayList<>(); + private List messages; + protected final TruffleTypes types = ProcessorContext.getInstance().getTypes(); public final void addWarning(String text, Object... params) { - getMessages().add(new Message(null, null, null, this, String.format(text, params), Kind.WARNING)); + getMessagesForModification().add(new Message(null, null, null, this, String.format(text, params), Kind.WARNING, null)); + } + + public final void addSuppressableWarning(String suppressionKey, String text, Object... params) { + getMessagesForModification().add(new Message(null, null, null, this, String.format(text, params), Kind.WARNING, suppressionKey)); } public final void addWarning(AnnotationValue value, String text, Object... params) { - getMessages().add(new Message(null, value, null, this, String.format(text, params), Kind.WARNING)); + getMessagesForModification().add(new Message(null, value, null, this, String.format(text, params), Kind.WARNING, null)); + } + + public final void addSuppressableWarning(String suppressionKey, AnnotationValue value, String text, Object... params) { + getMessagesForModification().add(new Message(null, value, null, this, String.format(text, params), Kind.WARNING, suppressionKey)); } public final void addError(String text, Object... params) { @@ -79,15 +94,15 @@ public final void addError(String text, Object... params) { } public final void addError(Element enclosedElement, String text, Object... params) { - getMessages().add(new Message(null, null, enclosedElement, this, String.format(text, params), Kind.ERROR)); + getMessagesForModification().add(new Message(null, null, enclosedElement, this, String.format(text, params), Kind.ERROR, null)); } public final void addError(AnnotationValue value, String text, Object... params) { - getMessages().add(new Message(null, value, null, this, String.format(text, params), Kind.ERROR)); + getMessagesForModification().add(new Message(null, value, null, this, String.format(text, params), Kind.ERROR, null)); } public final void addError(AnnotationMirror mirror, AnnotationValue value, String text, Object... params) { - getMessages().add(new Message(mirror, value, null, this, String.format(text, params), Kind.ERROR)); + getMessagesForModification().add(new Message(mirror, value, null, this, String.format(text, params), Kind.ERROR, null)); } protected List findChildContainers() { @@ -105,47 +120,36 @@ public Iterator iterator() { } public final void redirectMessages(MessageContainer to) { - if (!getMessages().isEmpty()) { - for (Message message : getMessages()) { + if (messages != null) { + List list = getMessagesForModification(); + for (Message message : list) { + if (message.getKind() == Kind.WARNING) { + continue; + } Element element = message.getEnclosedElement(); if (element == null) { element = message.getOriginalContainer().getMessageElement(); } String reference = ElementUtils.getReadableReference(to.getMessageElement(), element); String prefix = "Message redirected from element " + reference + ":" + System.lineSeparator(); - to.getMessages().add(message.redirect(prefix, to.getMessageElement())); + to.getMessagesForModification().add(message.redirect(prefix, to.getMessageElement())); } - getMessages().clear(); + list.clear(); } for (MessageContainer container : findChildContainers()) { container.redirectMessages(to); } } - public final void redirectMessagesNotEnclosedIn(MessageContainer to) { - if (!getMessages().isEmpty()) { - Element baseElement = to.getMessageElement(); - ListIterator messageIterator = getMessages().listIterator(); - while (messageIterator.hasNext()) { - Message message = messageIterator.next(); - if (!ElementUtils.isEnclosedIn(baseElement, message.getEnclosedElement())) { - messageIterator.set(message.redirect("", baseElement)); - } - } - } - for (MessageContainer container : findChildContainers()) { - container.redirectMessagesNotEnclosedIn(to); - } - } - public final void redirectMessagesOnGeneratedElements(MessageContainer to) { - if (!getMessages().isEmpty()) { + if (messages != null) { Element messageElement = getMessageElement(); if (messageElement == null || messageElement instanceof GeneratedElement || messageElement.getEnclosingElement() instanceof GeneratedElement) { - for (Message message : getMessages()) { - to.getMessages().add(message.redirect("", to.getMessageElement())); + List list = getMessagesForModification(); + for (Message message : list) { + to.getMessagesForModification().add(message.redirect("", to.getMessageElement())); } - getMessages().clear(); + list.clear(); } } for (MessageContainer container : findChildContainers()) { @@ -154,67 +158,53 @@ public final void redirectMessagesOnGeneratedElements(MessageContainer to) { } public final void emitMessages(ProcessorContext context, Log log) { - emitMessagesImpl(context, log, new HashSet(), null); - } - - private void emitMessagesImpl(ProcessorContext context, Log log, Set visitedSinks, List verifiedMessages) { - List childMessages; - if (verifiedMessages == null) { - childMessages = collectMessagesWithElementChildren(new HashSet(), getMessageElement()); - } else { - childMessages = verifiedMessages; - } - - if (verifiedMessages != null) { - verifyExpectedMessages(context, log, childMessages); - } - - for (int i = getMessages().size() - 1; i >= 0; i--) { - emitDefault(context, log, getMessages().get(i)); - } - - for (MessageContainer sink : findChildContainers()) { - if (visitedSinks.contains(sink)) { - continue; + Map> emittedMessages = new HashMap<>(); + Set relevantTypes = new LinkedHashSet<>(); + visit((container) -> { + List m = container.getMessages(); + for (int i = m.size() - 1; i >= 0; i--) { + Message message = m.get(i); + Element targetElement = container.emitDefault(context, log, message); + emittedMessages.computeIfAbsent(targetElement, (e) -> new ArrayList<>()).add(message); } + if (container.getMessageElement() instanceof TypeElement) { + relevantTypes.add(container.getMessageElement()); + } + return true; // continue + }); - visitedSinks.add(sink); - if (sink.getMessageElement() == this.getMessageElement()) { - sink.emitMessagesImpl(context, log, visitedSinks, childMessages); - } else { - sink.emitMessagesImpl(context, log, visitedSinks, null); + if (!ProcessorContext.types().ExpectErrorTypes.isEmpty()) { + for (Element element : relevantTypes) { + verifyExpectedErrors(element, emittedMessages); } } } - private List collectMessagesWithElementChildren(Set visitedSinks, Element e) { - if (visitedSinks.contains(this)) { - return Collections.emptyList(); - } - visitedSinks.add(this); - - List foundMessages = new ArrayList<>(); - if (getMessageElement() != null && ElementUtils.typeEquals(getMessageElement().asType(), e.asType())) { - foundMessages.addAll(getMessages()); - } - for (MessageContainer sink : findChildContainers()) { - foundMessages.addAll(sink.collectMessagesWithElementChildren(visitedSinks, e)); + private static void verifyExpectedErrors(Element element, Map> emitted) { + List expectedErrors = ExpectError.getExpectedErrors(element); + if (!expectedErrors.isEmpty()) { + List foundMessages = emitted.get(element); + foundMessages = foundMessages == null ? Collections.emptyList() : foundMessages; + if (expectedErrors.size() != foundMessages.size()) { + ProcessorContext.getInstance().getLog().message(Kind.ERROR, element, null, null, "Error count expected %s but was %s. Expected errors %s but got %s.", + expectedErrors.size(), + foundMessages.size(), + expectedErrors.toString(), + foundMessages.toString()); + } } - return foundMessages; - } - private void verifyExpectedMessages(ProcessorContext context, Log log, List msgs) { - Element element = getMessageElement(); - List expectedErrors = ExpectError.getExpectedErrors(context.getEnvironment(), element); - if (expectedErrors.size() > 0) { - if (expectedErrors.size() != msgs.size()) { - log.message(Kind.ERROR, element, null, null, "Error count expected %s but was %s. Expected errors %s but got %s.", expectedErrors.size(), msgs.size(), expectedErrors.toString(), - msgs.toString()); + for (Element enclosed : element.getEnclosedElements()) { + if (enclosed instanceof TypeElement) { + // we just validate types. + continue; } + verifyExpectedErrors(enclosed, emitted); } + } - private void emitDefault(ProcessorContext context, Log log, Message message) { + private Element emitDefault(ProcessorContext context, Log log, Message message) { Kind kind = message.getKind(); Element messageElement = getMessageElement(); AnnotationMirror messageAnnotation = getMessageAnnotation(); @@ -227,24 +217,33 @@ private void emitDefault(ProcessorContext context, Log log, Message message) { } Element enclosedElement = message.getEnclosedElement(); - if (messageElement instanceof GeneratedElement) { + Element targetElement = enclosedElement == null ? messageElement : enclosedElement; + if (targetElement instanceof GeneratedElement) { throw new AssertionError("Tried to emit message to generated element: " + messageElement + ". Make sure messages are redirected correctly. Message: " + message.getText()); } String text = trimLongMessage(message.getText()); - List expectedErrors = ExpectError.getExpectedErrors(context.getEnvironment(), messageElement); + List expectedErrors = ExpectError.getExpectedErrors(targetElement); if (!expectedErrors.isEmpty()) { - if (ExpectError.isExpectedError(context.getEnvironment(), messageElement, text)) { - return; + if (ExpectError.isExpectedError(targetElement, text)) { + return targetElement; } - log.message(kind, messageElement, null, null, "Message expected one of '%s' but was '%s'.", expectedErrors, text); + log.message(Kind.ERROR, targetElement, null, null, "Message expected one of '%s' but was '%s'.", expectedErrors, text); } else { + if (kind == Kind.WARNING && + (TruffleProcessorOptions.suppressAllWarnings(context.getEnvironment()) || TruffleSuppressedWarnings.isSuppressed(messageElement, message.suppressionKey))) { + return targetElement; + } + if (message.suppressionKey != null) { + text = text + " This warning may be suppressed using @SuppressWarnings(\"" + message.suppressionKey + "\")."; + } if (enclosedElement == null) { - log.message(kind, messageElement, messageAnnotation, messageValue, text); + log.message(kind, targetElement, messageAnnotation, messageValue, text); } else { - log.message(kind, enclosedElement, null, null, text); + log.message(kind, targetElement, null, null, text); } } + return targetElement; } private static final int MAX_MARKER_BYTE_LENGTH = 60000; @@ -283,52 +282,67 @@ public AnnotationValue getMessageAnnotationValue() { } public final boolean hasErrors() { - return hasErrorsImpl(new HashSet(), false); + return !visit((container) -> { + for (Message msg : container.getMessages()) { + if (msg.getKind() == Kind.ERROR) { + return false; + } + } + return true; + }); } public final boolean hasErrorsOrWarnings() { - return hasErrorsImpl(new HashSet(), true); + return !visit((container) -> { + for (Message msg : container.getMessages()) { + if (msg.getKind() == Kind.ERROR || msg.getKind() == Kind.WARNING) { + return false; + } + } + return true; + }); } - public final List collectMessages() { - List collectedMessages = new ArrayList<>(); - collectMessagesImpl(collectedMessages, new HashSet()); - return collectedMessages; + private boolean visit(Predicate vistor) { + return visitImpl(new HashSet(), vistor); } - private void collectMessagesImpl(List collectedMessages, Set visitedSinks) { - collectedMessages.addAll(getMessages()); - for (MessageContainer sink : findChildContainers()) { - if (visitedSinks.contains(sink)) { - return; - } - - visitedSinks.add(sink); - sink.collectMessagesImpl(collectedMessages, visitedSinks); + private boolean visitImpl(Set visited, Predicate visitor) { + if (visited.contains(this)) { + return true; } - } - - private boolean hasErrorsImpl(Set visitedSinks, boolean orWarnings) { - for (Message msg : getMessages()) { - if (msg.getKind() == Kind.ERROR || (orWarnings && msg.getKind() == Kind.WARNING)) { - return true; - } + visited.add(this); + if (!visitor.test(this)) { + return false; } for (MessageContainer sink : findChildContainers()) { - if (visitedSinks.contains(sink)) { - continue; + if (!sink.visitImpl(visited, visitor)) { + return false; } + } + return true; + } - visitedSinks.add(sink); + public final List collectMessages() { + List foundMessages = new ArrayList<>(); + visit((s) -> { + foundMessages.addAll(s.getMessages()); + return true; + }); + return foundMessages; + } - if (sink.hasErrorsImpl(visitedSinks, orWarnings)) { - return true; - } + protected final List getMessagesForModification() { + if (messages == null) { + messages = new ArrayList<>(); } - return false; + return messages; } - public List getMessages() { + public final List getMessages() { + if (messages == null) { + return Collections.emptyList(); + } return messages; } @@ -341,18 +355,20 @@ public static final class Message { private final AnnotationValue annotationValue; private final String text; private final Kind kind; + private final String suppressionKey; - public Message(AnnotationMirror annotationMirror, AnnotationValue annotationValue, Element enclosedElement, MessageContainer originalContainer, String text, Kind kind) { + public Message(AnnotationMirror annotationMirror, AnnotationValue annotationValue, Element enclosedElement, MessageContainer originalContainer, String text, Kind kind, String suppressionKey) { this.annotationMirror = annotationMirror; this.annotationValue = annotationValue; this.enclosedElement = enclosedElement; this.originalContainer = originalContainer; this.text = text; this.kind = kind; + this.suppressionKey = suppressionKey; } public Message redirect(String textPrefix, Element element) { - return new Message(null, null, element, originalContainer, textPrefix + text, kind); + return new Message(null, null, element, originalContainer, textPrefix + text, kind, null); } public Element getEnclosedElement() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java index 400db1ff5116..82beebcb88bc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java @@ -181,7 +181,7 @@ public AnnotationMirror getMessageAnnotation() { public void setNode(NodeData nodeData) { this.childNode = nodeData; if (nodeData != null) { - getMessages().addAll(nodeData.collectMessages()); + getMessagesForModification().addAll(nodeData.collectMessages()); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java index a4c8a22e27ad..3258381e8238 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java @@ -44,7 +44,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -83,6 +82,10 @@ public class NodeData extends Template implements Comparable { private boolean generateIntrospection; private boolean generateStatistics; private boolean generateAOT; + private boolean generateInline; + private boolean generateUncached; + private boolean generateCached = true; + private boolean defaultInlineCached; private boolean generateTraceOnEnter; private boolean generateTraceOnReturn; @@ -91,14 +94,20 @@ public class NodeData extends Template implements Comparable { private boolean reportPolymorphism; private boolean isUncachable; private boolean isNodeBound; - private boolean generateUncached; private boolean generatePackagePrivate; + + private double activationProbability = 1.0d; + private Set allowedCheckedExceptions; private Map sharedCaches = Collections.emptyMap(); private ExecutableTypeData polymorphicExecutable; - public NodeData(ProcessorContext context, TypeElement type, TypeSystemData typeSystem, boolean generateFactory, boolean generateUncached, boolean generatePackagePrivate) { + private final NodeData parsingParent; + private List reachableSpecializations; + + public NodeData(ProcessorContext context, NodeData inliningParent, TypeElement type, TypeSystemData typeSystem, boolean generateFactory, boolean generateUncached, boolean generatePackagePrivate) { super(context, type, null); + this.parsingParent = inliningParent; this.nodeId = ElementUtils.getSimpleName(type); this.typeSystem = typeSystem; this.fields = new ArrayList<>(); @@ -111,6 +120,57 @@ public NodeData(ProcessorContext context, TypeElement type, TypeSystemData typeS this.generatePackagePrivate = generatePackagePrivate; } + public double getActivationProbability() { + return activationProbability; + } + + public void setActivationProbability(double activationProbability) { + this.activationProbability = activationProbability; + } + + public List getReachableSpecializations() { + if (reachableSpecializations == null) { + List reachable = new ArrayList<>(); + for (SpecializationData specialization : getSpecializations()) { + if (specialization.isReachable() && // + (specialization.isSpecialized() // + || (specialization.isFallback() && specialization.getMethod() != null))) { + reachable.add(specialization); + } + } + return reachable; + } + return reachableSpecializations; + } + + public void setReachableSpecializations(List reachableSpecializations) { + this.reachableSpecializations = reachableSpecializations; + } + + public NodeData getParsingParent() { + return parsingParent; + } + + public boolean shouldInlineByDefault() { + return isGenerateInline() || isDefaultInlineCached(); + } + + public boolean isDefaultInlineCached() { + return defaultInlineCached; + } + + public void setDefaultInlineCached(boolean defaultInlineCached) { + this.defaultInlineCached = defaultInlineCached; + } + + public void setGenerateCached(boolean generateCached) { + this.generateCached = generateCached; + } + + public boolean isGenerateCached() { + return generateCached; + } + public void setGenerateStatistics(boolean generateStatistics) { this.generateStatistics = generateStatistics; } @@ -127,8 +187,8 @@ public void setSharedCaches(Map sharedCaches) { this.sharedCaches = sharedCaches; } - public NodeData(ProcessorContext context, TypeElement type) { - this(context, type, null, false, false, false); + public NodeData(ProcessorContext context, NodeData inliningParent, TypeElement type) { + this(context, inliningParent, type, null, false, false, false); } public void setNodeBound(boolean isNodeBound) { @@ -218,6 +278,14 @@ public void setGenerateExecuteTracing(boolean generateTraceOnEnter, boolean gene this.generateTraceOnException = generateTraceOnException; } + public boolean isGenerateInline() { + return generateInline; + } + + public void setGenerateInline(boolean generateInline) { + this.generateInline = generateInline; + } + public boolean isFallbackReachable() { SpecializationData generic = getFallbackSpecialization(); if (generic != null) { @@ -243,35 +311,6 @@ public List getChildExecutions() { return childExecutions; } - public Set findSpecializedTypes(NodeExecutionData execution) { - Set foundTypes = new HashSet<>(); - for (SpecializationData specialization : getSpecializations()) { - if (!specialization.isSpecialized()) { - continue; - } - List parameters = specialization.findByExecutionData(execution); - for (Parameter parameter : parameters) { - TypeMirror type = parameter.getType(); - if (type == null) { - throw new AssertionError(); - } - foundTypes.add(type); - } - } - return foundTypes; - } - - public Collection findSpecializedReturnTypes() { - Set foundTypes = new HashSet<>(); - for (SpecializationData specialization : getSpecializations()) { - if (!specialization.isSpecialized()) { - continue; - } - foundTypes.add(specialization.getReturnType().getType()); - } - return foundTypes; - } - public int getExecutionCount() { return getChildExecutions().size(); } @@ -378,30 +417,6 @@ public boolean supportsFrame() { return true; } - public NodeExecutionData findExecutionByExpression(String childNameExpression) { - String childName = childNameExpression; - int index = -1; - - int start = childName.indexOf('['); - int end = childName.lastIndexOf(']'); - if (start != -1 && end != -1 && start < end) { - try { - index = Integer.parseInt(childName.substring(start + 1, end)); - childName = childName.substring(0, start); - childName = NodeExecutionData.createName(childName, index); - } catch (NumberFormatException e) { - // ignore - } - } - - for (NodeExecutionData execution : childExecutions) { - if (execution.getName().equals(childName) && (execution.getChildArrayIndex() == -1 || execution.getChildArrayIndex() == index)) { - return execution; - } - } - return null; - } - public List getNodesWithFactories() { List nodeChildren = new ArrayList<>(); for (NodeData child : getEnclosingNodes()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java index 0f465eba6aff..19d40dca1956 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java @@ -40,9 +40,6 @@ */ package com.oracle.truffle.dsl.processor.model; -import java.util.ArrayList; -import java.util.List; - import javax.lang.model.type.ArrayType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; @@ -52,10 +49,9 @@ public class NodeExecutionData { private final NodeChildData child; - private final String name; + private String name; private final int index; private final int childArrayIndex; - private final List typeRestrictions = new ArrayList<>(); public NodeExecutionData(NodeChildData child, int index, int childArrayIndex) { this.child = child; @@ -68,12 +64,12 @@ private String createName() { return child != null ? createName(child.getName(), childArrayIndex) : ("arg" + index); } - public int getIndex() { - return index; + public void setName(String name) { + this.name = name; } - public List getTypeRestrictions() { - return typeRestrictions; + public int getIndex() { + return index; } public TypeMirror getNodeType() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/Parameter.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/Parameter.java index 4862455dc194..11f3190a4e1d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/Parameter.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/Parameter.java @@ -51,11 +51,13 @@ public final class Parameter { private final int typeVarArgsIndex; private final VariableElement variableElement; private final TypeMirror type; + private final boolean declared; - public Parameter(ParameterSpec specification, VariableElement variableElement, int specificationVarArgsIndex, int typeVarArgsIndex) { + public Parameter(ParameterSpec specification, VariableElement variableElement, + int specificationVarArgsIndex, int typeVarArgsIndex, boolean declared) { this.specification = specification; this.variableElement = variableElement; - this.type = variableElement.asType(); + this.type = variableElement != null ? variableElement.asType() : null; this.specificationVarArgsIndex = specificationVarArgsIndex; String valueName = specification.getName() + "Value"; @@ -64,24 +66,17 @@ public Parameter(ParameterSpec specification, VariableElement variableElement, i } this.typeVarArgsIndex = typeVarArgsIndex; this.localName = valueName; + this.declared = declared; } - public Parameter(Parameter parameter) { - this.specification = parameter.specification; - this.specificationVarArgsIndex = parameter.specificationVarArgsIndex; - this.localName = parameter.localName; - this.typeVarArgsIndex = parameter.typeVarArgsIndex; - this.variableElement = parameter.variableElement; - this.type = parameter.type; - } - - public Parameter(Parameter parameter, TypeMirror newType) { + Parameter(Parameter parameter, TypeMirror newType) { this.specification = parameter.specification; this.specificationVarArgsIndex = parameter.specificationVarArgsIndex; this.localName = parameter.localName; this.typeVarArgsIndex = parameter.typeVarArgsIndex; this.variableElement = parameter.variableElement; this.type = newType; + this.declared = parameter.declared; } public Parameter(Parameter parameter, VariableElement newVariable) { @@ -91,6 +86,15 @@ public Parameter(Parameter parameter, VariableElement newVariable) { this.typeVarArgsIndex = parameter.typeVarArgsIndex; this.variableElement = newVariable; this.type = newVariable.asType(); + this.declared = parameter.declared; + } + + /** + * Returns true if this parameter was actually declared in the method. Not all + * parameters must be declared, e.g. optional parameters. + */ + public boolean isDeclared() { + return declared; } public void setLocalName(String localName) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java index 467c4bce94ae..d8bf86d64e78 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java @@ -60,7 +60,9 @@ import com.oracle.truffle.dsl.processor.expression.DSLExpression.AbstractDSLExpressionVisitor; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Call; import com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable; +import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.parser.NodeParser; public final class SpecializationData extends TemplateMethod { @@ -76,20 +78,24 @@ public enum SpecializationKind { private final List guards = new ArrayList<>(); private List caches = Collections.emptyList(); private List assumptionExpressions = Collections.emptyList(); - private final Set replaces = new LinkedHashSet<>(); - private final Set replacesNames = new LinkedHashSet<>(); - private final Set excludedBy = new LinkedHashSet<>(); + private Set replaces; + private Set replacesNames; + private Set replacedBy; private String insertBeforeName; private SpecializationData insertBefore; private boolean replaced; private boolean reachable; private boolean reachesFallback; + private int unroll; + private int unrollIndex = -1; private int index; private DSLExpression limitExpression; private SpecializationData uncachedSpecialization; private final boolean reportPolymorphism; private final boolean reportMegamorphism; + private Double localActivationProbability; + private boolean aotReachable; public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind, List exceptions, boolean hasUnexpectedResultRewrite, @@ -104,24 +110,110 @@ public SpecializationData(NodeData node, TemplateMethod template, Specialization this.reportMegamorphism = reportMegamorphism; } + public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind) { + this(node, template, kind, new ArrayList(), false, true, false); + } + public SpecializationData copy() { SpecializationData copy = new SpecializationData(node, this, kind, new ArrayList<>(exceptions), hasUnexpectedResultRewrite, reportPolymorphism, reportMegamorphism); - copy.guards.addAll(guards); - copy.caches = new ArrayList<>(caches); + + copy.guards.clear(); + for (GuardExpression guard : guards) { + copy.guards.add(guard.copy(copy)); + } + + copy.caches = new ArrayList<>(caches.size()); + for (CacheExpression cache : caches) { + copy.caches.add(cache.copy()); + } + copy.assumptionExpressions = new ArrayList<>(assumptionExpressions); + if (replacesNames != null) { + copy.replacesNames = new LinkedHashSet<>(); + copy.replacesNames.addAll(replacesNames); + } + copy.replaced = replaced; - copy.replaces.addAll(replaces); - copy.replacesNames.addAll(replacesNames); - copy.excludedBy.addAll(excludedBy); + + if (replaces != null) { + copy.replaces = new LinkedHashSet<>(); + copy.replaces.addAll(replaces); + } + if (replacedBy != null) { + copy.replacedBy = new LinkedHashSet<>(); + copy.replacedBy.addAll(replacedBy); + } copy.insertBeforeName = insertBeforeName; copy.reachable = reachable; copy.reachesFallback = reachesFallback; copy.index = index; copy.limitExpression = limitExpression; copy.aotReachable = aotReachable; + copy.unroll = unroll; + copy.uncachedSpecialization = uncachedSpecialization; return copy; } + public boolean isNodeReceiverVariable(VariableElement var) { + if (getNode().isGenerateInline()) { + Parameter p = findByVariable(var); + if (p != null && p.getSpecification().isSignature()) { + NodeExecutionData execution = p.getSpecification().getExecution(); + if (execution.getIndex() == FlatNodeGenFactory.INLINED_NODE_INDEX) { + return true; + } + } + } + + String simpleString = var.getSimpleName().toString(); + return (simpleString.equals("this") || simpleString.equals(NodeParser.NODE_KEYWORD)) && ElementUtils.typeEquals(var.asType(), types.Node); + } + + public boolean isNodeReceiverBound(DSLExpression expression) { + for (Variable variable : expression.findBoundVariables()) { + if (isNodeReceiverVariable(variable.getResolvedVariable())) { + return true; + } + } + return false; + } + + public boolean isUncachedSpecialization() { + // do not initialize unroll for uncached specializations + if (getReplaces() != null) { + for (SpecializationData replace : getReplaces()) { + if (replace.getUncachedSpecialization() == this) { + return true; + } + } + } + return false; + } + + public void setUnrollIndex(int unrollIndex) { + this.unrollIndex = unrollIndex; + } + + public int getUnrollIndex() { + return unrollIndex; + } + + public void setUnroll(int unroll) { + this.unroll = unroll; + } + + public boolean hasUnroll() { + return unroll > 0; + } + + public boolean isUnrolled() { + return hasUnroll() && unrollIndex != -1; + } + + public int getUnroll() { + return unroll; + } + /** * Returns true if an expression can always be folded to a constant during PE. Method calls are * natural boundaries as we cannot look into them at annotation processing time. The passed @@ -358,6 +450,9 @@ public void visitCall(Call binary) { } public boolean isDynamicParameterBound(DSLExpression expression, boolean transitive) { + if (expression == null) { + return false; + } Set boundVariables = expression.findBoundVariableElements(); for (Parameter parameter : getDynamicParameters()) { if (boundVariables.contains(parameter.getVariableElement())) { @@ -425,16 +520,24 @@ public Set getReplacesNames() { return replacesNames; } - public SpecializationData(NodeData node, TemplateMethod template, SpecializationKind kind) { - this(node, template, kind, new ArrayList(), false, true, false); + public void setReplacesNames(Set replacesNames) { + this.replacesNames = replacesNames; } public Set getReplaces() { return replaces; } - public Set getExcludedBy() { - return excludedBy; + public void setReplaces(Set replaces) { + this.replaces = replaces; + } + + public Set getReplacedBy() { + return replacedBy; + } + + public void setReplacedBy(Set replacedBy) { + this.replacedBy = replacedBy; } public void setReachable(boolean reachable) { @@ -487,6 +590,9 @@ public boolean needsRewrite(ProcessorContext context) { if (cache.isEagerInitialize()) { continue; } + if (cache.getInlinedNode() != null) { + continue; + } if (!cache.isAlwaysInitialized()) { return true; } @@ -589,19 +695,22 @@ public List getGuards() { return guards; } - public SpecializationData findNextSpecialization() { - List specializations = node.getSpecializations(); - for (int i = 0; i < specializations.size() - 1; i++) { - if (specializations.get(i) == this) { - return specializations.get(i + 1); - } - } - return null; + public void setLocalActivationProbability(double activationProbability) { + this.localActivationProbability = activationProbability; + } + + public double getLocalActivationProbability() { + return localActivationProbability; + } + + public double getActivationProbability() { + return getNode().getActivationProbability() * localActivationProbability; } @Override public String toString() { - return String.format("%s [id = %s, method = %s, guards = %s, signature = %s]", getClass().getSimpleName(), getId(), getMethod(), getGuards(), getDynamicTypes()); + return String.format("%s [nodeId =%s, id = %s, method = %s, guards = %s, signature = %s]", getClass().getSimpleName(), getNode().getNodeId(), getId(), getMethod(), getGuards(), + getDynamicTypes()); } public boolean isFrameUsedByGuard() { @@ -613,7 +722,7 @@ public boolean isFrameUsedByGuard() { } } for (CacheExpression cache : getCaches()) { - if (cache.getDefaultExpression().findBoundVariableElements().contains(frame.getVariableElement())) { + if (cache.getDefaultExpression() != null && cache.getDefaultExpression().findBoundVariableElements().contains(frame.getVariableElement())) { return true; } } @@ -641,15 +750,6 @@ public boolean hasMultipleInstances() { return getMaximumNumberOfInstances() > 1; } - public boolean isExpressionBindsCache(DSLExpression expression, CacheExpression cache) { - for (CacheExpression otherCache : getBoundCaches(expression, true)) { - if (otherCache == cache) { - return true; - } - } - return false; - } - public boolean isGuardBindsCache() { if (!getCaches().isEmpty() && !getGuards().isEmpty()) { for (GuardExpression guard : getGuards()) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TemplateMethod.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TemplateMethod.java index 7229f08f13c9..751eec8ea907 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TemplateMethod.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TemplateMethod.java @@ -97,11 +97,6 @@ public final Parameter getFrame() { return findParameter(FRAME_NAME); } - public void removeParameter(Parameter p) { - this.parameters.remove(p); - this.parameterCache.remove(p.getLocalName()); - } - public void addParameter(int index, Parameter p) { this.parameters.add(index, p); this.parameterCache.put(p.getLocalName(), p); @@ -120,12 +115,16 @@ public int getNaturalOrder() { public TemplateMethod(TemplateMethod method) { this(method.id, method.naturalOrder, method.template, method.specification, method.method, method.markerAnnotation, method.returnType, method.parameters); - getMessages().addAll(method.getMessages()); + if (!method.getMessages().isEmpty()) { + getMessagesForModification().addAll(method.getMessages()); + } } public TemplateMethod(TemplateMethod method, ExecutableElement executable) { this(method.id, method.naturalOrder, method.template, method.specification, executable, method.markerAnnotation, method.returnType, method.parameters); - getMessages().addAll(method.getMessages()); + if (!method.getMessages().isEmpty()) { + getMessagesForModification().addAll(method.getMessages()); + } } @Override @@ -203,6 +202,15 @@ public Parameter findParameterOrDie(NodeExecutionData execution) { throw new AssertionError("Could not find parameter for execution"); } + public Parameter findParameter(NodeExecutionData execution) { + for (Parameter parameter : parameters) { + if (parameter.getSpecification().isSignature() && parameter.getSpecification().getExecution() == execution) { + return parameter; + } + } + return null; + } + public List findByExecutionData(NodeExecutionData execution) { List foundParameters = new ArrayList<>(); for (Parameter parameter : getParameters()) { @@ -248,17 +256,6 @@ public String toString() { return String.format("%s [id = %s, method = %s]", getClass().getSimpleName(), getId(), getMethod()); } - public Parameter getPreviousParam(Parameter searchParam) { - Parameter prev = null; - for (Parameter param : getParameters()) { - if (param == searchParam) { - return prev; - } - prev = param; - } - return prev; - } - @SuppressWarnings("unused") public int getSignatureSize() { int signatureSize = 0; @@ -280,25 +277,6 @@ public TypeSignature getTypeSignature() { return signature; } - public void updateSignature(TypeSignature signature) { - // TODO(CH): fails in normal usage - output ok though - // assert signature.size() >= 1; - - int signatureIndex = 0; - for (Parameter parameter : getReturnTypeAndParameters()) { - if (!parameter.getSpecification().isSignature()) { - continue; - } - if (signatureIndex >= signature.size()) { - break; - } - TypeMirror newType = signature.get(signatureIndex++); - if (!ElementUtils.typeEquals(newType, parameter.getType())) { - replaceParameter(parameter.getLocalName(), new Parameter(parameter, newType)); - } - } - } - @Override public int compareTo(TemplateMethod o) { if (this == o) { @@ -352,10 +330,6 @@ public TypeSignature() { this.types = new ArrayList<>(); } - public TypeSignature(List signature) { - this.types = signature; - } - @Override public int hashCode() { return types.hashCode(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/AbstractParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/AbstractParser.java index d33c50fd1a0c..67c9d013444a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/AbstractParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/AbstractParser.java @@ -54,6 +54,7 @@ import com.oracle.truffle.dsl.processor.CompileErrorException; import com.oracle.truffle.dsl.processor.Log; import com.oracle.truffle.dsl.processor.ProcessorContext; +import com.oracle.truffle.dsl.processor.Timer; import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; import com.oracle.truffle.dsl.processor.TruffleTypes; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -104,9 +105,10 @@ protected boolean isGenerateSlowPathOnly(TypeElement element) { return true; } + @SuppressWarnings({"unchecked", "try"}) public final M parse(Element element, boolean emitErrors) { M model = null; - try { + try (Timer timer = Timer.create(getClass().getSimpleName(), element)) { List mirrors = null; if (getAnnotationType() != null) { mirrors = ElementUtils.getRepeatedAnnotation(element.getAnnotationMirrors(), getAnnotationType()); @@ -126,7 +128,7 @@ public final M parse(Element element, boolean emitErrors) { return emitErrors ? filterErrorElements(model) : model; } } catch (CompileErrorException e) { - log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s", e.getMessage()); + log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s%nError: ", e.getMessage(), ElementUtils.printException(e)); return null; } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/MethodSpecParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/MethodSpecParser.java index 7b940198ab2e..ed9e84bd1985 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/MethodSpecParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/MethodSpecParser.java @@ -53,6 +53,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import com.oracle.truffle.dsl.processor.ProcessorContext; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.model.MethodSpec; @@ -208,6 +209,28 @@ private static List parseParametersOptional(MethodSpec spec, List { - public final List annotations = Arrays.asList(types.Fallback, types.TypeSystemReference, + private final List annotations = Arrays.asList(types.Fallback, types.TypeSystemReference, types.Specialization, types.NodeChild, types.Executed, types.NodeChildren, types.ReportPolymorphism); - public enum ParseMode { + public static final String NODE_KEYWORD = "$node"; + + private enum ParseMode { DEFAULT, EXPORTED_MESSAGE } @@ -167,6 +173,10 @@ public enum ParseMode { private final TypeElement exportDeclarationType; private final boolean substituteThisToParent; + /* + * Parsing parent to detect recursions. + */ + private NodeData parsingParent; private final List cachedAnnotations; private NodeParser(ParseMode mode, TypeMirror exportLibraryType, TypeElement exportDeclarationType, boolean substituteThisToParent) { @@ -195,12 +205,16 @@ public static NodeParser createDefaultParser() { @Override protected NodeData parse(Element element, List mirror) { - NodeData node = parseRootType((TypeElement) element); - if (Log.isDebug() && node != null) { - String dump = node.dump(); - log.message(Kind.ERROR, null, null, null, dump); + try { + NodeData node = parseRootType((TypeElement) element); + if (Log.isDebug() && node != null) { + String dump = node.dump(); + log.message(Kind.ERROR, null, null, null, dump); + } + return node; + } finally { + nodeDataCache.clear(); } - return node; } @Override @@ -251,9 +265,8 @@ private NodeData parseRootType(TypeElement rootType) { throw e; } if (node == null && !enclosedNodes.isEmpty()) { - node = new NodeData(context, rootType); + node = new NodeData(context, parsingParent, rootType); } - if (node != null) { for (NodeData enclosedNode : enclosedNodes) { node.addEnclosedNode(enclosedNode); @@ -262,7 +275,7 @@ private NodeData parseRootType(TypeElement rootType) { return node; } - private NodeData parseNode(TypeElement originalTemplateType) { + public NodeData parseNode(TypeElement originalTemplateType) { // reloading the type elements is needed for ecj TypeElement templateType; if (originalTemplateType instanceof CodeTypeElement) { @@ -294,6 +307,26 @@ private NodeData parseNode(TypeElement originalTemplateType) { return null; } + AnnotationMirror generateAOT = findFirstAnnotation(lookupTypes, types.GenerateAOT); + if (generateAOT != null) { + node.setGenerateAOT(true); + } + AnnotationMirror generateCached = findGenerateAnnotation(templateType.asType(), types.GenerateCached); + if (generateCached != null) { + node.setGenerateCached(ElementUtils.getAnnotationValue(Boolean.class, generateCached, "value")); + node.setDefaultInlineCached(ElementUtils.getAnnotationValue(Boolean.class, generateCached, "alwaysInlineCached")); + } else { + node.setGenerateCached(true); + node.setDefaultInlineCached(false); + } + node.setGenerateUncached(isGenerateUncached(templateType)); + node.setGenerateInline(isGenerateInline(templateType)); + + if (!node.isGenerateCached() && !node.isGenerateInline() && !node.isGenerateUncached()) { + // no generated code needed. + return null; + } + if (nodeOnly) { return node; } @@ -330,9 +363,11 @@ private NodeData parseNode(TypeElement originalTemplateType) { node.setGenerateExecuteTracing(traceOnEnter, traceOnReturn, traceOnException); } - AnnotationMirror generateAOT = findFirstAnnotation(lookupTypes, types.GenerateAOT); - if (generateAOT != null) { - node.setGenerateAOT(true); + if (node.isGenerateAOT() && !node.isGenerateCached() && !node.isGenerateInline()) { + node.addError("%@s cannot be enabled if @%s and @%s is disabled for this node.", + getSimpleName(types.GenerateAOT), + getSimpleName(types.GenerateCached), + getSimpleName(types.GenerateInline)); } AnnotationMirror reportPolymorphism = findFirstAnnotation(lookupTypes, types.ReportPolymorphism); @@ -360,7 +395,9 @@ private NodeData parseNode(TypeElement originalTemplateType) { if (node.hasErrors()) { return node; // error sync point } - initializeSpecializations(members, node); + DSLExpressionResolver resolver = createBaseResolver(node, members); + + initializeSpecializations(resolver, node); if (node.hasErrors()) { return node; // error sync point @@ -376,6 +413,7 @@ private NodeData parseNode(TypeElement originalTemplateType) { initializeUncachable(node); initializeAOT(node); + boolean recommendInline = initializeInlinable(resolver, node); if (mode == ParseMode.DEFAULT) { boolean emitWarnings = TruffleProcessorOptions.cacheSharingWarningsEnabled(processingEnv) && // @@ -394,9 +432,533 @@ private NodeData parseNode(TypeElement originalTemplateType) { if (isGenerateSlowPathOnly(node)) { removeFastPathSpecializations(node); } + + verifyRecommendationWarnings(node, recommendInline); + return node; } + private DSLExpressionResolver createBaseResolver(NodeData node, List members) { + List fields = new ArrayList<>(); + for (NodeFieldData field : node.getFields()) { + fields.add(field.getVariable()); + } + + List globalMembers = new ArrayList<>(members.size() + fields.size()); + globalMembers.addAll(fields); + globalMembers.addAll(members); + globalMembers.add(new CodeVariableElement(types.Node, "this")); + globalMembers.add(new CodeVariableElement(types.Node, NODE_KEYWORD)); + return new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); + } + + private static final class NodeSizeEstimate { + + final int inlinedSize; + final int notInlinedSize; + + NodeSizeEstimate(int inlinedSize, int notInlinedSize) { + this.inlinedSize = inlinedSize; + this.notInlinedSize = notInlinedSize; + } + + } + + private int computeInstanceSize(TypeMirror mirror) { + TypeElement type = fromTypeMirror(mirror); + if (type != null) { + List members = loadAllMembers(type); + int size = ElementUtils.COMPRESSED_HEADER_SIZE; + for (VariableElement var : ElementFilter.fieldsIn(members)) { + size += ElementUtils.getCompressedReferenceSize(var.asType()); + } + return size; + } else { + return ElementUtils.getCompressedReferenceSize(mirror); + } + } + + private NodeSizeEstimate computeCachedInlinedSizeEstimate(ExecutableElement inlineMethod) { + if (inlineMethod == null) { + return new NodeSizeEstimate(0, 0); + } + TypeMirror type = inlineMethod.getReturnType(); + List fields = parseInlineMethod(null, null, inlineMethod); + NodeSizeEstimate estimate = computeInlinedSizeEstimate(fields); + int inlineFootprint = estimate.inlinedSize; + int notInlineFootprint; + if (NodeCodeGenerator.isSpecializedNode(type)) { + notInlineFootprint = ElementUtils.COMPRESSED_HEADER_SIZE + ElementUtils.COMPRESSED_POINTER_SIZE + + estimate.notInlinedSize; + } else { + notInlineFootprint = computeInstanceSize(type) + ElementUtils.COMPRESSED_POINTER_SIZE; + } + return new NodeSizeEstimate(inlineFootprint, notInlineFootprint); + } + + private static NodeSizeEstimate computeInlinedSizeEstimate(List fields) { + int stateBits = 0; + int referenceSizes = 0; + for (InlineFieldData field : fields) { + if (field.isState()) { + stateBits += field.getBits(); + } else { + referenceSizes += ElementUtils.getCompressedReferenceSize(field.getType()); + } + } + + int inlinedSize = (int) Math.ceil(stateBits / 8d) + referenceSizes; + int notInlinedSize = (int) Math.ceil(stateBits / 32d) * 4 + referenceSizes; + + // node header and parent pointer. + notInlinedSize += ElementUtils.COMPRESSED_HEADER_SIZE + ElementUtils.COMPRESSED_POINTER_SIZE; + + return new NodeSizeEstimate(inlinedSize, notInlinedSize); + } + + private void verifyRecommendationWarnings(NodeData node, boolean recommendInline) { + if (node.hasErrors()) { + // no recommendations if there are errors. + return; + } + + if (recommendInline && !node.isGenerateInline() && mode == ParseMode.DEFAULT && node.isGenerateCached()) { + + AnnotationMirror annotation = getGenerateInlineAnnotation(node.getTemplateType()); + if (annotation == null) { + + NodeSizeEstimate estimate = computeInlinedSizeEstimate(FlatNodeGenFactory.createInlinedFields(node)); + if (estimate.inlinedSize <= estimate.notInlinedSize) { + node.addSuppressableWarning(TruffleSuppressedWarnings.INLINING_RECOMMENDATION, "This node is a candidate for node object inlining. " + // + "The memory footprint is estimated to be reduced from %s to %s byte(s). " + + "Add @%s(true) to enable object inlining for this node or @%s(false) to disable this warning. " + // + "Also consider disabling cached node generation with @%s(false) if all usages will be inlined.", + estimate.notInlinedSize, + estimate.inlinedSize, + getSimpleName(types.GenerateInline), + getSimpleName(types.GenerateInline), + getSimpleName(types.GenerateCached), + getSimpleName(types.GenerateInline), + getSimpleName(types.GenerateInline)); + } + } + } + + for (SpecializationData specialization : node.getSpecializations()) { + ExecutableElement element = (ExecutableElement) specialization.getMessageElement(); + if (element == null) { + continue; + } + + if (mode == ParseMode.DEFAULT && element.getSimpleName().toString().startsWith("execute")) { + specialization.addWarning("It is discouraged that @%s annotated methods start with the prefix 'execute'. " + // + "This prefix is reserved for execute methods, which identifies methods to execute nodes and should alwas be separate from execute methods. " + // + "Rename this method to resolve this. Examples for specialization names are 'doInt', 'doInBounds' or 'doCached'.", + getSimpleName(types.Specialization)); + } + + boolean usesInlinedNodes = false; + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getInlinedNode() != null) { + usesInlinedNodes = true; + break; + } + } + if (usesInlinedNodes) { + boolean firstParameterNode = false; + for (Parameter p : specialization.getSignatureParameters()) { + firstParameterNode = p.isDeclared(); + break; + } + + boolean isStatic = element.getModifiers().contains(Modifier.STATIC); + if (node.isGenerateInline()) { + if (!isStatic || !firstParameterNode) { + specialization.addError("For @%s annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. " + + "When using inlinable nodes it is a common mistake to pass the wrong inline target node to inlined cached values. " + + "Making the method static avoids this mistake as the invalid receiver node can no longer be accessed. " + // + "To resolve this add the static keyword and the 'Node node' parameter as first parameter to the specialization method. " + // + "Use the first node parameter and pass it along to inlined caches. ", + getSimpleName(types.GenerateInline)); + } + } else if (FlatNodeGenFactory.useSpecializationClass(specialization)) { + + boolean hasNodeParameter = false; + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isBind() && specialization.isNodeReceiverBound(cache.getDefaultExpression())) { + hasNodeParameter = true; + break; + } + } + + if (!isStatic || !hasNodeParameter) { + if (!hasNodeParameter) { + String message = String.format( + "For this specialization with inlined cache parameters a '@%s(\"this\") Node node' parameter must be declared. " + // + "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + + "To resolve this add a '@%s(\"this\") Node node' parameter to the specialization method. " + + "Use the new node parameter and pass it along to cached inlined nodes or profiles. ", + getSimpleName(types.Bind), + getSimpleName(types.Bind), + getSimpleName(types.Bind)); + + specialization.addError(message); + } else { + String message = String.format( + "For this specialization with inlined cache parameters it is recommended to use the static modifier. " + // + "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + + "To resolve this add the static keyword to the method and fix potential misuses of the 'this' reference. " + + "If a node needs to access instance fields it is recommended to suppress this warning.", + getSimpleName(types.Bind), + getSimpleName(types.Bind), + getSimpleName(types.Bind)); + + specialization.addSuppressableWarning(TruffleSuppressedWarnings.STATIC_METHOD, message); + } + } + } + } + + if (specialization.hasMultipleInstances() && ElementUtils.getAnnotationValue(specialization.getMessageAnnotation(), "limit", false) == null) { + specialization.addSuppressableWarning(TruffleSuppressedWarnings.LIMIT, + "For this specialization no limit attribute was specified, but multiple instances of this specialization are possible. " + // + "To resolve this add the limit attribute to the @%s annotation.", + getSimpleName(types.Specialization), + getSimpleName(types.Specialization)); + } + + boolean isLayoutBenefittingFromNeverDefault = isLayoutBenefittingFromNeverDefault(specialization); + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isAlwaysInitialized()) { + // no space needed + continue; + } + if (cache.getInlinedNode() != null) { + // no space needed for inlined + continue; + } + if (!cache.isCached()) { + continue; + } + + Boolean neverDefault = getAnnotationValue(Boolean.class, cache.getMessageAnnotation(), "neverDefault", false); + if (neverDefault != null) { + if (!isLayoutBenefittingFromNeverDefault && cache.getSharedGroup() == null) { + cache.addSuppressableWarning(TruffleSuppressedWarnings.UNUSED, + ElementUtils.getAnnotationValue(cache.getMessageAnnotation(), "neverDefault"), + "The @%s(neverDefault=true|false) property is not needed to be set. Remove the property to resolve this warning.", + getSimpleName(types.Cached)); + + } else if (isNeverDefaultGuaranteed(specialization, cache) || isNeverDefaultImpliedByAnnotation(cache) || (neverDefault && isNeverDefaultImplied(cache))) { + cache.addSuppressableWarning(TruffleSuppressedWarnings.UNUSED, + ElementUtils.getAnnotationValue(cache.getMessageAnnotation(), "neverDefault"), + "The @%s(neverDefault=true|false) property is guaranteed or implied by the initializer expression. Remove the property to resolve this warning.", + getSimpleName(types.Cached), + getSimpleName(types.NeverDefault)); + } + } else { + if (!cache.isEagerInitialize() && (cache.getSharedGroup() != null || isLayoutBenefittingFromNeverDefault) && !isNeverDefaultImplied(cache)) { + /* + * The exports parser adds a suppress warning when calling into the node + * parser for accepts messages. Normally suppression is calculated later, + * but here we do it eagerly because of that. + */ + if (!TruffleSuppressedWarnings.isSuppressed(specialization.getMessageElement(), TruffleSuppressedWarnings.NEVERDEFAULT)) { + cache.addSuppressableWarning( + TruffleSuppressedWarnings.NEVERDEFAULT, + "It is recommended to set the @%s(neverDefault=true|false) property for this cache expression to allow the DSL to further optimize the generated layout of this node. " + + "Please set the neverDefault property to true if the value may never return the default value, else false. " + + "You may also use the @%s annotation on any method or field bound in the initializer expression to indicate never default. " + + "To allow optimizations in the generated code layout, it is recommended to guarantee non-default values for initializer expressions whenever possible.", + getSimpleName(types.Cached), + getSimpleName(types.NeverDefault)); + } + } + } + } + + } + } + + private static boolean isLayoutBenefittingFromNeverDefault(SpecializationData specialization) { + return !specialization.hasMultipleInstances() && !FlatNodeGenFactory.shouldUseSpecializationClassBySize(specialization); + } + + private static TypeMirror findRedirectedInliningType(SpecializationData specialization, CacheExpression cache) { + if (specialization.hasMultipleInstances()) { + return null; + } + TypeElement typeElement = ElementUtils.castTypeElement(cache.getParameter().getType()); + if (typeElement == null) { + return null; + } + + ExecutableElement inlineMethod = ElementUtils.findStaticMethod(typeElement, "inline"); + if (inlineMethod != null && !typeEquals(inlineMethod.getReturnType(), cache.getParameter().getType())) { + return inlineMethod.getReturnType(); + } + return null; + } + + private static boolean isInliningSupported(CacheExpression cache) { + TypeMirror type = cache.getParameter().getType(); + if (ElementUtils.isPrimitive(type) && !ElementUtils.isVoid(type)) { + return true; + } + TypeElement typeElement = ElementUtils.castTypeElement(type); + ExecutableElement inlineMethod = typeElement != null ? ElementUtils.findStaticMethod(typeElement, "inline") : null; + if (inlineMethod == null) { + if (ElementUtils.isAssignable(cache.getParameter().getType(), ProcessorContext.types().Node)) { + if (typeElement != null && isGenerateInline(typeElement) && NodeCodeGenerator.isSpecializedNode(type)) { + return true; + } + return false; + } else { + // references can be inlined + return true; + } + } else { + // inline method available -> inlinable + return true; + } + + } + + private boolean initializeInlinable(DSLExpressionResolver resolver, NodeData node) { + for (SpecializationData specialization : node.getSpecializations()) { + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isCached()) { + continue; + } + Boolean inline = getAnnotationValue(Boolean.class, cache.getMessageAnnotation(), "inline", false); + if (inline != null && inline && !isInliningSupported(cache)) { + AnnotationValue inlineValue = getAnnotationValue(cache.getMessageAnnotation(), "inline", false); + cache.addError(inlineValue, "Cached type '%s' does not support inlining. " + // + "Only inlinable types are supported for nodes annotated with @%s. " + // + "Inlinable types declare a static inline method or use the @%s annotation. " + // + "Non node references and primtives types are also considered inlinable.", + getSimpleName(cache.getParameter().getType()), + getSimpleName(types.GenerateInline), + getSimpleName(types.GenerateInline)); + } + } + } + + if (!node.shouldInlineByDefault()) { + for (SpecializationData specialization : node.getSpecializations()) { + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isCached()) { + continue; + } + if (cache.hasErrors()) { + continue; + } + if (hasInlineMethod(cache)) { + Boolean inline = getAnnotationValue(Boolean.class, cache.getMessageAnnotation(), "inline", false); + if (inline == null && !forceInlineByDefault(cache)) { + TypeMirror type = findRedirectedInliningType(specialization, cache); + String solutionHint = String.format("Set @%s(..., inline=true|false) to determine whether object-inlining should be performed. ", + getSimpleName(types.Cached)); + if (type != null) { + solutionHint = String.format("To use object-inlining use the cached type '%s' instead or set @%s(..., inline=true|false). ", + getSimpleName(type), + getSimpleName(types.Cached)); + } + + TypeMirror cacheType = type == null ? cache.getParameter().getType() : type; + ExecutableElement inlineMethod = lookupInlineMethod(resolver, node, cache, cacheType, null); + NodeSizeEstimate estimate = computeCachedInlinedSizeEstimate(inlineMethod); + + AnnotationValue inlineValue = getAnnotationValue(cache.getMessageAnnotation(), "inline", false); + cache.addSuppressableWarning(TruffleSuppressedWarnings.INLINING_RECOMMENDATION, + inlineValue, "The cached type '%s' supports object-inlining. The footprint is estimated to be reduced from %s to %s byte(s). %s" + // + "Alternatively @%s(alwaysInlineCached=true) can be used to enable inlining for an entire class or in combination with the inherit option for a hierarchy of node classes.", + getSimpleName(cache.getParameter().getType()), + estimate.notInlinedSize, estimate.inlinedSize, + solutionHint, + getSimpleName(types.GenerateCached)); + } + } + } + } + } + + for (SpecializationData specialization : node.getSpecializations()) { + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isCached()) { + continue; + } + if (cache.hasErrors()) { + continue; + } + Boolean inline = getAnnotationValue(Boolean.class, cache.getMessageAnnotation(), "inline", false); + + if (node.isGenerateInline() && inline != null && inline && cache.getInlinedNode() != null) { + // failing later see code below + continue; + } + + if (inline != null) { + boolean defaultInline = node.shouldInlineByDefault() || forceInlineByDefault(cache); + if (inline && defaultInline || // + (!inline && !defaultInline && !isInliningSupported(cache))) { + AnnotationValue inlineValue = getAnnotationValue(cache.getMessageAnnotation(), "inline", false); + cache.addSuppressableWarning(TruffleSuppressedWarnings.UNUSED, inlineValue, "Redundant specification of @Cached(... inline=%s). The attribute has no effect. " + // + "Inlining is forced to '%s' for this cached parameter. " + // + "To resolve this remove the redundant inlining attribute.", + inline, defaultInline, + getSimpleName(context.getType(SuppressWarnings.class))); + } + } + } + } + + boolean emitErrors = node.isGenerateInline(); + boolean recommendInline = true; + + if (!node.getChildren().isEmpty()) { + if (emitErrors) { + node.addError("Error generating code for @%s: Inlinable nodes cannot use @%s. " + // + "Disable inlining generation or remove @%s to resolve this.", getSimpleName(types.GenerateInline), + getSimpleName(types.NodeChild), getSimpleName(types.NodeChild)); + } + recommendInline = false; + } + + if (!node.getFields().isEmpty()) { + if (emitErrors) { + node.addError("Error generating code for @%s: Inlinable nodes cannot use @%s. " + // + "Disable inlining generation or remove @%s to resolve this.", getSimpleName(types.GenerateInline), + getSimpleName(types.NodeField), getSimpleName(types.NodeField)); + } + recommendInline = false; + } + + VariableElement instanceField = getNodeFirstInstanceField(node.getTemplateType()); + if (instanceField != null) { + if (emitErrors) { + node.addError(getGenerateInlineAnnotation(node.getTemplateType()), null, "Failed to generate code for @%s: The node must not declare any instance variables. " + + "Found instance variable %s.%s. Remove instance variable to resolve this.", + getSimpleName(types.GenerateInline), + getSimpleName(instanceField.getEnclosingElement().asType()), instanceField.getSimpleName().toString()); + } + recommendInline = false; + } + + for (SpecializationData specialization : node.getSpecializations()) { + for (CacheExpression cache : specialization.getCaches()) { + if (!cache.isCached()) { + continue; + } + AnnotationValue inlineValue = getAnnotationValue(cache.getMessageAnnotation(), "inline", false); + Boolean inline = getAnnotationValue(Boolean.class, cache.getMessageAnnotation(), "inline", false); + if (cache.getInlinedNode() == null) { + if (inline == null) { + inline = node.shouldInlineByDefault(); + } + if (inline && !isInliningSupported(cache)) { + if (emitErrors) { + cache.addError("Failed to generate code for @%s: Cached type '%s' does not support inlining. " + // + "Only inlinable types are supported for nodes annotated with @%s. " + // + "Inlinable types declare a static inline method or use the @%s annotation. " + // + "The primitive types boolean, byte, short, int are also considered inlinable.", + getSimpleName(types.GenerateInline), + getSimpleName(cache.getParameter().getType()), + getSimpleName(types.GenerateInline), + getSimpleName(types.GenerateInline)); + } + } + } else if (inline != null && inline) { + if (emitErrors) { + cache.addSuppressableWarning(TruffleSuppressedWarnings.UNUSED, inlineValue, "Redundant specification of @%s(... inline=true). " + // + "Cached values of nodes with @%s are implicitely inlined.", + getSimpleName(types.GenerateInline), + getSimpleName(types.Cached), + getSimpleName(types.GenerateInline)); + } + } + } + } + + ExecutableElement method = ElementUtils.findStaticMethod(node.getTemplateType(), "inline"); + if (method != null) { + + List declaredFields = parseInlineMethod(node, method, method); + if (node.hasErrors()) { + return false; + } + List requiredFields = FlatNodeGenFactory.createInlinedFields(node); + + boolean valid = declaredFields.size() == requiredFields.size(); + if (valid) { + for (int i = 0; i < declaredFields.size(); i++) { + InlineFieldData declared = declaredFields.get(i); + InlineFieldData required = requiredFields.get(i); + + if (!required.isCompatibleWith(declared)) { + valid = false; + break; + } + } + } + + if (!valid) { + CodeExecutableElement expectedInline = NodeFactoryFactory.createInlineMethod(node, null); + node.addError(method, "The custom inline method does not specify enough bit space or too few or too many fields for this node. The expected inline method for this node is:%n%s", + expectedInline.toString()); + } + } + + return recommendInline; + + } + + static boolean isGenerateUncached(TypeElement templateType) { + AnnotationMirror annotation = findGenerateAnnotation(templateType.asType(), ProcessorContext.getInstance().getTypes().GenerateUncached); + Boolean value = Boolean.FALSE; + if (annotation != null) { + value = ElementUtils.getAnnotationValue(Boolean.class, annotation, "value"); + } + return value; + } + + static boolean isGenerateInline(TypeElement templateType) { + AnnotationMirror annotation = getGenerateInlineAnnotation(templateType); + Boolean value = Boolean.FALSE; + if (annotation != null) { + value = ElementUtils.getAnnotationValue(Boolean.class, annotation, "value"); + } + return value; + } + + static AnnotationMirror getGenerateInlineAnnotation(TypeElement templateType) { + return findGenerateAnnotation(templateType.asType(), ProcessorContext.getInstance().getTypes().GenerateInline); + } + + private static AnnotationMirror findGenerateAnnotation(TypeMirror nodeType, DeclaredType annotationType) { + TypeElement originalType = ElementUtils.castTypeElement(nodeType); + TypeElement currentType = originalType; + while (currentType != null) { + AnnotationMirror annotation = ElementUtils.findAnnotationMirror(currentType, annotationType); + if (annotation != null) { + Boolean inherit = ElementUtils.getAnnotationValue(Boolean.class, annotation, "inherit"); + if (inherit == null) { + inherit = Boolean.TRUE; + } + + if (currentType != originalType && !inherit) { + // not inherited from to the sub type + currentType = ElementUtils.castTypeElement(currentType.getSuperclass()); + continue; + } + + return annotation; + } + currentType = ElementUtils.castTypeElement(currentType.getSuperclass()); + } + return null; + } + private void initializeAOT(NodeData node) { if (!node.isGenerateAOT()) { return; @@ -536,7 +1098,6 @@ private void initializeAOT(NodeData node) { getSimpleName(types.GenerateAOT)); continue outer; } - } } } @@ -647,21 +1208,21 @@ public static Map computeSharing(Element templateType, } } else if (expressions != null && expressions.size() > 1) { if (emitSharingWarnings) { - /* - * We only emit sharing warnings for the same declaring type, because - * otherwise sharing warnings might not be resolvable if the base type - * is not modifiable. - */ - List declaredInExpression = new ArrayList<>(); + List filteredExpressions = new ArrayList<>(); for (CacheExpression expression : expressions) { + /* + * We only emit sharing warnings for the same declaring type, + * because otherwise sharing warnings might not be resolvable if the + * base type is not modifiable. + */ if (ElementUtils.isDeclaredIn(expression.getParameter().getVariableElement(), declaringElement)) { - declaredInExpression.add(expression); + filteredExpressions.add(expression); } } - if (declaredInExpression.size() > 1 && findAnnotationMirror(cache.getParameter().getVariableElement(), types.Cached_Exclusive) == null) { + if (filteredExpressions.size() > 1 && findAnnotationMirror(cache.getParameter().getVariableElement(), types.Cached_Exclusive) == null) { StringBuilder sharedCaches = new StringBuilder(); Set recommendedGroups = new LinkedHashSet<>(); - for (CacheExpression cacheExpression : declaredInExpression) { + for (CacheExpression cacheExpression : filteredExpressions) { if (cacheExpression != cache) { String signature = formatCacheExpression(cacheExpression); sharedCaches.append(String.format(" - %s%n", signature)); @@ -673,7 +1234,8 @@ public static Map computeSharing(Element templateType, } String recommendedGroup = recommendedGroups.size() == 1 ? recommendedGroups.iterator().next() : "group"; - cache.addWarning("The cached parameter may be shared with: %n%s Annotate the parameter with @%s(\"%s\") or @%s to allow or deny sharing of the parameter.", + cache.addSuppressableWarning(TruffleSuppressedWarnings.SHARING_RECOMMENDATION, + "The cached parameter may be shared with: %n%s Annotate the parameter with @%s(\"%s\") or @%s to allow or deny sharing of the parameter.", sharedCaches, types.Cached_Shared.asElement().getSimpleName().toString(), recommendedGroup, types.Cached_Exclusive.asElement().getSimpleName().toString()); @@ -764,36 +1326,40 @@ private void initializeReceiverBound(NodeData node) { node.setNodeBound(nodeBound); } - private void initializeUncachable(NodeData node) { - AnnotationMirror generateUncached = findAnnotationMirror(node.getTemplateType().getAnnotationMirrors(), types.GenerateUncached); - - boolean requireUncachable = node.isGenerateUncached(); - boolean uncachable = true; - TypeElement type = node.getTemplateType(); - while (type != null) { - if (ElementUtils.typeEquals(type.asType(), types.Node)) { + private VariableElement getNodeFirstInstanceField(TypeElement nodeType) { + TypeElement currentType = nodeType; + while (currentType != null) { + if (ElementUtils.typeEquals(currentType.asType(), types.Node)) { // don't care about fields in node. break; } - for (VariableElement field : ElementFilter.fieldsIn(type.getEnclosedElements())) { + for (VariableElement field : ElementFilter.fieldsIn(currentType.getEnclosedElements())) { if (field.getModifiers().contains(Modifier.STATIC)) { continue; - } else if (typeEquals(field.getEnclosingElement().asType(), types.Node)) { - // ignore fields in Node. They are safe. - continue; } - // uncachable because local non-static fields are not allowed - uncachable = false; + return field; + } + currentType = ElementUtils.getSuperType(currentType); + } + return null; + } - if (requireUncachable) { - node.addError(generateUncached, null, "Failed to generate code for @%s: The node must not declare any instance variables. " + - "Found instance variable %s.%s. Remove instance variable to resolve this.", - types.GenerateUncached.asElement().getSimpleName().toString(), - getSimpleName(field.getEnclosingElement().asType()), field.getSimpleName().toString()); - } - break; + private void initializeUncachable(NodeData node) { + AnnotationMirror generateUncached = findAnnotationMirror(node.getTemplateType().getAnnotationMirrors(), types.GenerateUncached); + + boolean requireUncachable = node.isGenerateUncached(); + boolean uncachable = true; + + VariableElement instanceField = getNodeFirstInstanceField(node.getTemplateType()); + if (instanceField != null) { + uncachable = false; + + if (requireUncachable) { + node.addError(generateUncached, null, "Failed to generate code for @%s: The node must not declare any instance variables. " + + "Found instance variable %s.%s. Remove instance variable to resolve this.", + types.GenerateUncached.asElement().getSimpleName().toString(), + getSimpleName(instanceField.getEnclosingElement().asType()), instanceField.getSimpleName().toString()); } - type = ElementUtils.getSuperType(type); } for (SpecializationData specialization : node.computeUncachedSpecializations(node.getSpecializations())) { @@ -1078,7 +1644,7 @@ private static void buildExecutableHierarchy(NodeData node, ExecutableTypeData p } private List loadMembers(TypeElement templateType) { - List elements = newElementList(CompilerFactory.getCompiler(templateType).getAllMembersInDeclarationOrder(context.getEnvironment(), templateType)); + List elements = loadAllMembers(templateType); Iterator elementIterator = elements.iterator(); while (elementIterator.hasNext()) { Element element = elementIterator.next(); @@ -1094,6 +1660,10 @@ private List loadMembers(TypeElement templateType) { return elements; } + private List loadAllMembers(TypeElement templateType) { + return newElementList(CompilerFactory.getCompiler(templateType).getAllMembersInDeclarationOrder(context.getEnvironment(), templateType)); + } + private boolean containsSpecializations(List elements) { boolean foundSpecialization = false; for (ExecutableElement method : ElementFilter.methodsIn(elements)) { @@ -1252,9 +1822,13 @@ private NodeData parseNodeData(TypeElement templateType, List typeH TypeSystemData typeSystem = null; if (typeSystemMirror != null) { TypeMirror typeSystemType = getAnnotationValue(TypeMirror.class, typeSystemMirror, "value"); - typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true); + TypeElement type = ElementUtils.castTypeElement(typeSystemType); + typeSystem = context.parseIfAbsent(type, TypeSystemParser.class, (e) -> { + TypeSystemParser parser = new TypeSystemParser(); + return parser.parse(e, false); + }); if (typeSystem == null) { - NodeData nodeData = new NodeData(context, templateType); + NodeData nodeData = new NodeData(context, parsingParent, templateType); nodeData.addError("The used type system '%s' is invalid. Fix errors in the type system first.", getQualifiedName(typeSystemType)); return nodeData; } @@ -1263,7 +1837,6 @@ private NodeData parseNodeData(TypeElement templateType, List typeH typeSystem = new TypeSystemData(context, templateType, null, true); } boolean useNodeFactory = findFirstAnnotation(typeHierarchy, types.GenerateNodeFactory) != null; - AnnotationMirror generateUncachedMirror = null; boolean needsInherit = false; for (Element element : typeHierarchy) { @@ -1285,7 +1858,7 @@ private NodeData parseNodeData(TypeElement templateType, List typeH generateUncached = false; } boolean generatePackagePrivate = findFirstAnnotation(typeHierarchy, types.GeneratePackagePrivate) != null; - return new NodeData(context, templateType, typeSystem, useNodeFactory, generateUncached, generatePackagePrivate); + return new NodeData(context, parsingParent, templateType, typeSystem, useNodeFactory, generateUncached, generatePackagePrivate); } @@ -1525,6 +2098,7 @@ private List parseExecutions(@SuppressWarnings("unused") Node List frameTypes = context.getFrameTypes(); // pre-parse specializations to find signature size + boolean seenNodeParameter = false; for (ExecutableElement method : methods) { AnnotationMirror mirror = findAnnotationMirror(method, types.Specialization); if (mirror == null) { @@ -1534,6 +2108,10 @@ private List parseExecutions(@SuppressWarnings("unused") Node parameter: for (VariableElement var : method.getParameters()) { TypeMirror type = var.asType(); if (currentArgumentIndex == 0) { + if (node.isGenerateInline() && typeEquals(type, types.Node)) { + seenNodeParameter = true; + } + // skip optionals for (TypeMirror frameType : frameTypes) { if (typeEquals(type, frameType)) { @@ -1561,6 +2139,14 @@ private List parseExecutions(@SuppressWarnings("unused") Node maxSignatureSize = Math.max(maxSignatureSize, currentArgumentIndex); } + /* + * No specialization uses the Node parameter so we need to artificially increment the max + * signature count. + */ + if (node.isGenerateInline() && !seenNodeParameter) { + maxSignatureSize++; + } + List executions = new ArrayList<>(); for (int i = 0; i < maxSignatureSize; i++) { boolean varArgParameter = false; @@ -1703,14 +2289,43 @@ private void initializeExecutableTypes(NodeData node) { } } - if (!requireNodeChildDeclarations.isEmpty()) { - node.addError("Not enough child node declarations found. Please annotate the node class with additional @NodeChild annotations or remove all execute methods that do not provide all evaluated values. " + - "The following execute methods do not provide all evaluated values for the expected signature size %s: %s.", executions.size(), requireNodeChildDeclarations); - } + if (node.isGenerateInline()) { + if (nodeChildDeclarations <= 0) { + for (ExecutableTypeData type : allExecutes) { + int index; + if (type.getFrameParameter() != null) { + index = 1; + } else { + index = 0; + } + TypeMirror firstParameter; + if (index < type.getMethod().getParameters().size()) { + firstParameter = type.getMethod().getParameters().get(index).asType(); + } else { + firstParameter = null; + } - if (nodeChildDeclarations > 0 && executions.size() == node.getMinimalEvaluatedParameters()) { - for (NodeChildData child : node.getChildren()) { - child.addError("Unnecessary @NodeChild declaration. All evaluated child values are provided as parameters in execute methods."); + if (firstParameter == null || !typeEquals(types.Node, firstParameter)) { + node.addError("Error generating code for @%s: Found non-final execute method without a node parameter %s. " + + "Inlinable nodes must use the %s type as the first parameter after the optional frame for all non-final execute methods. " + + "A valid signature for an inlinable node is execute([VirtualFrame frame, ] Node node, ...).", + getSimpleName(types.GenerateInline), + ElementUtils.getReadableSignature(type.getMethod()), + getSimpleName(types.Node)); + break; + } + } + } + } else { + if (!requireNodeChildDeclarations.isEmpty()) { + node.addError("Not enough child node declarations found. Please annotate the node class with additional @NodeChild annotations or remove all execute methods that do not provide all evaluated values. " + + "The following execute methods do not provide all evaluated values for the expected signature size %s: %s.", executions.size(), requireNodeChildDeclarations); + } + + if (nodeChildDeclarations > 0 && executions.size() == node.getMinimalEvaluatedParameters()) { + for (NodeChildData child : node.getChildren()) { + child.addError("Unnecessary @NodeChild declaration. All evaluated child values are provided as parameters in execute methods."); + } } } @@ -1866,28 +2481,138 @@ private List createAllowedChildFrameTypes(NodeData parentNode) { return allowedFrameTypes; } - private void initializeSpecializations(List elements, final NodeData node) { + private void initializeSpecializations(DSLExpressionResolver resolver, final NodeData node) { if (node.getSpecializations().isEmpty()) { return; } - initializeReplaces(node); + initializeFallback(node); + resolveReplaces(node); - initializeExpressions(elements, node); + + initializeExpressions(resolver, node); if (node.hasErrors()) { return; } + initializeUnroll(node); - initializeFallback(node); initializeOrder(node); initializeReachability(node); + initializeProbability(node); initializeFallbackReachability(node); + initializeCheckedExceptions(node); - initializeExcludeBy(node); initializeSpecializationIdsWithMethodNames(node.getSpecializations()); } + private static void initializeProbability(NodeData node) { + /* + * TODO GR-42193 probabilities should be provided by the user. + */ + List specializations = node.getReachableSpecializations(); + int count = specializations.size(); + double sum = 0; + for (int i = 0; i < count; i++) { + SpecializationData s = specializations.get(i); + + // bonus factor degrades linearly with each specialization + // sum of all bonus factors is 1.0d + double bonus = (count - i) / ((count / 2d) * (1d + count)); + + // we do not know much about specialization activation without profiling + // this is a rough heuristic to favor specializations that are declared first. + // every specialization minimally gets a 10% share in the total probability + // The rest of the 90% is distributed with the bonus factor that already accounts for + // count. + double probability = (0.10d / count) + (bonus * 0.90d); + s.setLocalActivationProbability(probability); + sum += probability; + } + + if (Math.abs(1.0 - sum) > 0.000001d) { // sum != 1.0 + throw new AssertionError("Activation probability must sum up to 1.0 but was " + sum); + } + } + + private void initializeUnroll(NodeData node) { + List newSpecializations = null; + List specializations = node.getSpecializations(); + for (int index = 0; index < specializations.size(); index++) { + SpecializationData specialization = specializations.get(index); + if (specialization.getMethod() == null) { + if (newSpecializations != null) { + newSpecializations.add(specialization); + } + continue; + } + + Integer unrollCount = ElementUtils.getAnnotationValue(Integer.class, specialization.getMarkerAnnotation(), "unroll"); + if (unrollCount == null) { + unrollCount = 0; + } + + if (specialization.isUncachedSpecialization()) { + unrollCount = 0; + } + + if (unrollCount > 0) { + specialization.setUnroll(unrollCount); + } + + // to future me or maintainer: let us be reasonable and not increase this limit. + AnnotationValue unrollAnnotationValue = ElementUtils.getAnnotationValue(specialization.getMarkerAnnotation(), "unroll"); + if (unrollCount > 8 || unrollCount < 0) { + node.addError(unrollAnnotationValue, + "The maximum specialization instance unroll count is 8. The number is limited to avoid code explosion. Reduce the unroll limit to resolve this."); + } + + if (unrollCount <= 0) { + if (newSpecializations != null) { + newSpecializations.add(specialization); + } + } else { + int maxInstances = specialization.getMaximumNumberOfInstances(); + if (maxInstances <= 1) { + specialization.addError(unrollAnnotationValue, "A specialization that cannot have multiple instances cannot be unrolled. Remove the unroll specification to resolve this."); + } + + if (maxInstances < unrollCount) { + specialization.addError(unrollAnnotationValue, + "The maximum number of instances for this specialization is %s. But there were %s instances unrolled. Set the unrolled index to %s to resolve this.", + maxInstances, unrollCount, maxInstances); + } + + if (newSpecializations == null) { + newSpecializations = new ArrayList<>(); + newSpecializations.addAll(specializations.subList(0, index)); + } + + for (int unrollIndex = 0; unrollIndex < unrollCount; unrollIndex++) { + SpecializationData unrolled = specialization.copy(); + unrolled.setUnrollIndex(unrollIndex); + if (maxInstances > unrollCount) { + DSLExpression guard = new Binary("<", new IntLiteral(String.valueOf(unrollIndex)), unrolled.getLimitExpression()); + unrolled.getGuards().add(new GuardExpression(specialization, guard)); + } + unrolled.setLimitExpression(new IntLiteral("1")); + + newSpecializations.add(unrolled); + } + + if (maxInstances > unrollCount) { + // we need to keep the generic specialization + newSpecializations.add(specialization); + } + } + } + if (newSpecializations != null) { + node.getSpecializations().clear(); + node.getSpecializations().addAll(newSpecializations); + resolveReplaces(node); + } + } + private void initializeCheckedExceptions(NodeData node) { for (SpecializationData specialization : node.getSpecializations()) { @@ -1984,31 +2709,37 @@ private static void initializeOrder(NodeData node) { } } - private static void initializeReplaces(NodeData node) { + private void resolveReplaces(NodeData node) { + for (SpecializationData specialization : node.getSpecializations()) { + specialization.setReplaces(new LinkedHashSet<>()); + } + for (SpecializationData specialization : node.getSpecializations()) { - Set resolvedSpecializations = specialization.getReplaces(); + Set resolvedReplaces = specialization.getReplaces(); Set includeNames = specialization.getReplacesNames(); - for (String includeName : includeNames) { - // TODO GR-38632 reduce complexity of this lookup. - List foundSpecializations = lookupSpecialization(node, includeName); - - AnnotationValue value = getAnnotationValue(specialization.getMarkerAnnotation(), "replaces"); - if (foundSpecializations.isEmpty()) { - specialization.addError(value, "The referenced specialization '%s' could not be found.", includeName); - } else { - resolvedSpecializations.addAll(foundSpecializations); - for (SpecializationData foundSpecialization : foundSpecializations) { - if (foundSpecialization.compareTo(specialization) > 0) { - specialization.addError(value, "The replaced specialization '%s' must be declared before the replacing specialization.", includeName); + if (includeNames != null) { + for (String includeName : includeNames) { + // TODO GR-38632 reduce complexity of this lookup. + List foundSpecializations = lookupSpecialization(node, includeName); + + AnnotationValue value = getAnnotationValue(specialization.getMarkerAnnotation(), "replaces"); + if (foundSpecializations.isEmpty()) { + specialization.addError(value, "The referenced specialization '%s' could not be found.", includeName); + } else { + resolvedReplaces.addAll(foundSpecializations); + for (SpecializationData foundSpecialization : foundSpecializations) { + if (foundSpecialization.compareTo(specialization) > 0) { + specialization.addError(value, "The replaced specialization '%s' must be declared before the replacing specialization.", includeName); + } } } } } + if (specialization.getUncachedSpecialization() != null) { + specialization.getUncachedSpecialization().getReplaces().add(specialization); + } } - } - private void resolveReplaces(NodeData node) { - // flatten transitive includes for (SpecializationData specialization : node.getSpecializations()) { if (specialization.getReplaces().isEmpty()) { continue; @@ -2018,10 +2749,25 @@ private void resolveReplaces(NodeData node) { replaced.setReplaced(true); } + // transitively resolve includes Set foundSpecializations = new HashSet<>(); collectIncludes(specialization, foundSpecializations, new HashSet()); specialization.getReplaces().addAll(foundSpecializations); } + + // compute replaced by + List specializations = node.getSpecializations(); + for (SpecializationData cur : specializations) { + cur.setReplacedBy(new LinkedHashSet<>()); + } + + for (SpecializationData cur : specializations) { + for (SpecializationData contained : cur.getReplaces()) { + if (contained != cur) { + contained.getReplacedBy().add(cur); + } + } + } } private static List lookupSpecialization(NodeData node, String includeName) { @@ -2075,17 +2821,9 @@ private static void initializeReachability(final NodeData node) { } current.setReachable(shadowedBy == null); } - } - private static void initializeExcludeBy(NodeData node) { - List specializations = node.getSpecializations(); - for (SpecializationData cur : specializations) { - for (SpecializationData contained : cur.getReplaces()) { - if (contained != cur) { - contained.getExcludedBy().add(cur); - } - } - } + // reachability is no longer changing. + node.setReachableSpecializations(node.getReachableSpecializations()); } public static void removeFastPathSpecializations(NodeData node) { @@ -2099,6 +2837,7 @@ public static void removeFastPathSpecializations(NodeData node) { } } specializations.removeAll(toRemove); + node.getReachableSpecializations().removeAll(toRemove); } private static void initializeSpecializationIdsWithMethodNames(List specializations) { @@ -2160,21 +2899,10 @@ private static boolean renameDuplicateIds(List signatures) { return changed; } - private void initializeExpressions(List elements, NodeData node) { - List members = elements; - - List fields = new ArrayList<>(); - for (NodeFieldData field : node.getFields()) { - fields.add(field.getVariable()); - } - - List globalMembers = new ArrayList<>(members.size() + fields.size()); - globalMembers.addAll(fields); - globalMembers.addAll(members); - DSLExpressionResolver originalResolver = new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); - + private void initializeExpressions(DSLExpressionResolver originalResolver, NodeData node) { // the number of specializations might grow while expressions are initialized. List specializations = node.getSpecializations(); + int originalSize = specializations.size(); int i = 0; while (i < specializations.size()) { SpecializationData specialization = specializations.get(i); @@ -2202,6 +2930,10 @@ private void initializeExpressions(List elements, NodeData no i++; } + if (originalSize != specializations.size()) { + resolveReplaces(node); + } + } private void initializeAssumptions(SpecializationData specialization, DSLExpressionResolver resolver) { @@ -2211,22 +2943,18 @@ private void initializeAssumptions(SpecializationData specialization, DSLExpress List assumptionExpressions = new ArrayList<>(); int assumptionId = 0; for (String assumption : assumptionDefinitions) { - AssumptionExpression assumptionExpression; - DSLExpression expression = null; - try { - expression = DSLExpression.parse(assumption); - expression.accept(resolver); - assumptionExpression = new AssumptionExpression(specialization, expression, "assumption" + assumptionId); - if (!isAssignable(expression.getResolvedType(), assumptionType) && !isAssignable(expression.getResolvedType(), assumptionArrayType)) { - assumptionExpression.addError("Incompatible return type %s. Assumptions must be assignable to %s or %s.", getSimpleName(expression.getResolvedType()), - getSimpleName(assumptionType), getSimpleName(assumptionArrayType)); - } - if (specialization.isDynamicParameterBound(expression, true)) { - specialization.addError("Assumption expressions must not bind dynamic parameter values."); - } - } catch (InvalidExpressionException e) { - assumptionExpression = new AssumptionExpression(specialization, null, "assumption" + assumptionId); - assumptionExpression.addError("Error parsing expression '%s': %s", assumption, e.getMessage()); + DSLExpression expression = DSLExpression.parseAndResolve(resolver, specialization, "assumptions", assumption); + if (expression == null) { + // failed to parse + continue; + } + AssumptionExpression assumptionExpression = new AssumptionExpression(specialization, expression, "assumption" + assumptionId); + if (!isAssignable(expression.getResolvedType(), assumptionType) && !isAssignable(expression.getResolvedType(), assumptionArrayType)) { + assumptionExpression.addError("Incompatible return type %s. Assumptions must be assignable to %s or %s.", getSimpleName(expression.getResolvedType()), + getSimpleName(assumptionType), getSimpleName(assumptionArrayType)); + } + if (specialization.isDynamicParameterBound(expression, true)) { + specialization.addError("Assumption expressions must not bind dynamic parameter values."); } assumptionExpressions.add(assumptionExpression); assumptionId++; @@ -2246,15 +2974,15 @@ private void initializeLimit(SpecializationData specialization, DSLExpressionRes if (!uncached && annotationValue != null && !specialization.hasMultipleInstances()) { if (!specialization.hasErrors()) { - specialization.addWarning(annotationValue, "The limit expression has no effect. Multiple specialization instantiations are impossible for this specialization."); + specialization.addSuppressableWarning(TruffleSuppressedWarnings.UNUSED, annotationValue, + "The limit expression has no effect. Multiple specialization instantiations are impossible for this specialization."); } return; } TypeMirror expectedType = context.getType(int.class); - try { - DSLExpression expression = DSLExpression.parse(limitValue); - expression.accept(resolver); + DSLExpression expression = DSLExpression.parseAndResolve(resolver, specialization, "limit", limitValue); + if (expression != null) { if (!typeEquals(expression.getResolvedType(), expectedType)) { specialization.addError(annotationValue, "Incompatible return type %s. Limit expressions must return %s.", getSimpleName(expression.getResolvedType()), getSimpleName(expectedType)); @@ -2262,11 +2990,8 @@ private void initializeLimit(SpecializationData specialization, DSLExpressionRes if (specialization.isDynamicParameterBound(expression, true)) { specialization.addError(annotationValue, "Limit expressions must not bind dynamic parameter values."); } - - specialization.setLimitExpression(expression); - } catch (InvalidExpressionException e) { - specialization.addError(annotationValue, "Error parsing expression '%s': %s", limitValue, e.getMessage()); } + specialization.setLimitExpression(expression); } private SpecializationData initializeCaches(SpecializationData specialization, DSLExpressionResolver resolver) { @@ -2328,12 +3053,13 @@ private SpecializationData initializeCaches(SpecializationData specialization, D DSLExpression newWeakReference = new DSLExpression.Call(null, "new", Arrays.asList(sourceExpression)); newWeakReference.setResolvedTargetType(weakType); - resolveCachedExpression(resolver, cache, weakType, newWeakReference, null); + resolveCachedExpression(resolver, cache, weakType, cache.getParameter().getType(), newWeakReference, null); CacheExpression weakCache = new CacheExpression(weakParameter, foundCached); weakCache.setDefaultExpression(newWeakReference); weakCache.setUncachedExpression(newWeakReference); weakCache.setWeakReference(true); + weakCache.setNeverDefault(true); caches.add(0, weakCache); @@ -2346,10 +3072,17 @@ private SpecializationData initializeCaches(SpecializationData specialization, D cache.setUncachedExpression(sourceExpression); cache.setAlwaysInitialized(true); cache.setWeakReferenceGet(true); + } else { parseCached(cache, specialization, resolver, parameter); } + if (this.mode == ParseMode.DEFAULT && cache.isThisExpression()) { + cache.addError("Cannot use 'this' with @%s use @%s instead.", + getSimpleName(types.Cached), + getSimpleName(types.Bind)); + } + } else if (cache.isCachedLibrary()) { String expression = cache.getCachedLibraryExpression(); String limit = cache.getCachedLibraryLimit(); @@ -2360,10 +3093,10 @@ private SpecializationData initializeCaches(SpecializationData specialization, D "Use @%s(\"value\") for a specialized or " + "@%s(limit=\"\") for a dispatched library. " + "See the javadoc of @%s for further details.", - types.CachedLibrary.asElement().getSimpleName().toString(), - types.CachedLibrary.asElement().getSimpleName().toString(), - types.CachedLibrary.asElement().getSimpleName().toString(), - types.CachedLibrary.asElement().getSimpleName().toString()); + getSimpleName(types.CachedLibrary), + getSimpleName(types.CachedLibrary), + getSimpleName(types.CachedLibrary), + getSimpleName(types.CachedLibrary)); continue; } DSLExpression limitExpression = parseCachedExpression(resolver, cache, context.getType(int.class), limit); @@ -2375,13 +3108,11 @@ private SpecializationData initializeCaches(SpecializationData specialization, D TypeMirror usedLibraryType = parameter.getType(); DSLExpression resolveCall = new DSLExpression.Call(null, "resolve", Arrays.asList(new DSLExpression.ClassLiteral(usedLibraryType))); - DSLExpression defaultExpression = new DSLExpression.Call(resolveCall, "createDispatched", - Arrays.asList(limitExpression)); - DSLExpression uncachedExpression = new DSLExpression.Call(resolveCall, "getUncached", - Arrays.asList()); + DSLExpression defaultExpression = new DSLExpression.Call(resolveCall, "createDispatched", Arrays.asList(limitExpression)); + DSLExpression uncachedExpression = new DSLExpression.Call(resolveCall, "getUncached", Arrays.asList()); - cache.setDefaultExpression(resolveCachedExpression(cachedResolver, cache, libraryType, defaultExpression, null)); - cache.setUncachedExpression(resolveCachedExpression(cachedResolver, cache, libraryType, uncachedExpression, null)); + cache.setDefaultExpression(resolveCachedExpression(cachedResolver, cache, libraryType, null, defaultExpression, null)); + cache.setUncachedExpression(resolveCachedExpression(cachedResolver, cache, libraryType, null, uncachedExpression, null)); } else { if (limit != null) { cache.addError("The limit and specialized value expression cannot be specified at the same time. They are mutually exclusive."); @@ -2389,14 +3120,26 @@ private SpecializationData initializeCaches(SpecializationData specialization, D } cachedLibraries.add(cache); } + cache.setNeverDefault(true); } else if (cache.isBind()) { AnnotationMirror dynamic = cache.getMessageAnnotation(); String expression = ElementUtils.getAnnotationValue(String.class, dynamic, "value", false); + if (mode == ParseMode.EXPORTED_MESSAGE && cache.isBind() && expression.trim().equals("this") && typeEquals(cache.getParameter().getType(), types.Node)) { + Iterator firstParameter = specialization.getSignatureParameters().iterator(); + if (firstParameter.hasNext() && firstParameter.next().getVariableElement().getSimpleName().toString().equals("this")) { + cache.addError("Variable 'this' is reserved for library receiver values in methods annotated with @%s. " + + "If the intention was to access the encapsulting Node for inlined nodes or profiles, you may use '%s' as expression instead.", + getSimpleName(types.ExportMessage), + NodeParser.NODE_KEYWORD); + } + } - DSLExpression parsedExpression = parseCachedExpression(resolver, cache, parameter.getType(), expression); - cache.setDefaultExpression(parsedExpression); - cache.setUncachedExpression(parsedExpression); - cache.setAlwaysInitialized(true); + if (!cache.hasErrors()) { + DSLExpression parsedExpression = parseCachedExpression(resolver, cache, parameter.getType(), expression); + cache.setDefaultExpression(parsedExpression); + cache.setUncachedExpression(parsedExpression); + cache.setAlwaysInitialized(true); + } } } specialization.setCaches(caches); @@ -2463,7 +3206,6 @@ private SpecializationData parseCachedLibraries(SpecializationData specializatio if (!specialization.isReplaced()) { uncachedSpecialization = specialization.copy(); uncachedLibraries = new ArrayList<>(); - uncachedSpecialization.getReplaces().add(specialization); List caches = uncachedSpecialization.getCaches(); for (int i = 0; i < caches.size(); i++) { @@ -2503,9 +3245,7 @@ private SpecializationData parseCachedLibraries(SpecializationData specializatio continue; } - Map libraryCache = ProcessorContext.getInstance().getCacheMap(LibraryParser.class); - LibraryData parsedLibrary = libraryCache.computeIfAbsent(type, (t) -> new LibraryParser().parse(t)); - + LibraryData parsedLibrary = context.parseIfAbsent(type, LibraryParser.class, (t) -> new LibraryParser().parse(t)); if (parsedLibrary == null || parsedLibrary.hasErrors()) { cachedLibrary.addError("Library '%s' has errors. Please resolve them first.", getSimpleName(parameterType)); continue; @@ -2579,7 +3319,7 @@ private SpecializationData parseCachedLibraries(SpecializationData specializatio String receiverName = cachedLibrary.getParameter().getVariableElement().getSimpleName().toString(); DSLExpression acceptGuard = new DSLExpression.Call(new DSLExpression.Variable(null, receiverName), "accepts", Arrays.asList(receiverExpression)); - acceptGuard = resolveCachedExpression(resolver, cachedLibrary, context.getType(boolean.class), acceptGuard, expression); + acceptGuard = resolveCachedExpression(resolver, cachedLibrary, context.getType(boolean.class), null, acceptGuard, expression); if (acceptGuard != null) { GuardExpression guard = new GuardExpression(specialization, acceptGuard); guard.setLibraryAcceptsGuard(true); @@ -2593,14 +3333,14 @@ private SpecializationData parseCachedLibraries(SpecializationData specializatio DSLExpression defaultExpression = new DSLExpression.Call(resolveCall, "create", Arrays.asList(receiverExpression)); - defaultExpression = resolveCachedExpression(cachedResolver, cachedLibrary, libraryType, defaultExpression, expression); + defaultExpression = resolveCachedExpression(cachedResolver, cachedLibrary, libraryType, null, defaultExpression, expression); cachedLibrary.setDefaultExpression(defaultExpression); DSLExpression uncachedExpression = new DSLExpression.Call(resolveCall, "getUncached", Arrays.asList(receiverExpression)); cachedLibrary.setUncachedExpression(uncachedExpression); - uncachedExpression = resolveCachedExpression(cachedResolver, cachedLibrary, libraryType, uncachedExpression, expression); + uncachedExpression = resolveCachedExpression(cachedResolver, cachedLibrary, libraryType, null, uncachedExpression, expression); if (uncachedLibrary != null) { uncachedLibrary.setDefaultExpression(uncachedExpression); @@ -2666,24 +3406,20 @@ public void visitVariable(Variable binary) { private void parseCached(CacheExpression cache, SpecializationData specialization, DSLExpressionResolver originalResolver, Parameter parameter) { DSLExpressionResolver resolver = originalResolver; AnnotationMirror cachedAnnotation = cache.getMessageAnnotation(); - AnnotationValue adopt = null; - if (!cache.hasErrors()) { - adopt = getAnnotationValue(cachedAnnotation, "adopt", false); - AnnotationMirror cached = findAnnotationMirror(cache.getParameter().getVariableElement(), types.Cached); - cache.setDimensions(getAnnotationValue(Integer.class, cached, "dimensions")); - boolean disabledAdopt = adopt != null && Boolean.FALSE.equals(adopt.getValue()); - if (parameter.getType().getKind() == TypeKind.ARRAY && - (disabledAdopt || !isSubtype(((ArrayType) parameter.getType()).getComponentType(), types.NodeInterface))) { - if (cache.getDimensions() == -1) { - cache.addWarning("The cached dimensions attribute must be specified for array types."); - } + final NodeData node = specialization.getNode(); + Boolean inline = getAnnotationValue(Boolean.class, cachedAnnotation, "inline", false); + boolean hasInline = hasInlineMethod(cache); + boolean requireCached = node.isGenerateCached() || !hasInline || (inline != null && !inline); + if (inline == null) { + if (forceInlineByDefault(cache)) { + inline = true; } else { - if (!disabledAdopt && cache.getDimensions() != -1) { - cache.addError("The dimensions attribute has no affect for the type %s.", getSimpleName(parameter.getType())); - } + inline = node.shouldInlineByDefault(); } } + boolean requireUncached = node.isGenerateUncached() || mode == ParseMode.EXPORTED_MESSAGE; + List expressionParameters = getAnnotationValueList(String.class, cachedAnnotation, "parameters"); String initializer = getAnnotationValue(String.class, cachedAnnotation, "value"); @@ -2705,12 +3441,50 @@ private void parseCached(CacheExpression cache, SpecializationData specializatio } } - if (!cache.hasErrors()) { + if (cache.hasErrors()) { + return; + } + + AnnotationValue adopt = getAnnotationValue(cachedAnnotation, "adopt", false); + if (inline && hasInline) { + ExecutableElement inlineMethod = lookupInlineMethod(originalResolver, node, cache, cache.getParameter().getType(), cache); + List fields; + if (inlineMethod != null) { + fields = parseInlineMethod(cache, null, inlineMethod); + if (!cache.hasErrors() && !typeEquals(inlineMethod.getReturnType(), cache.getParameter().getType())) { + cache.addError("Invalid return type %s found but expected %s. This is a common error if a different type is required for inlining. Signature %s.", + getQualifiedName(inlineMethod.getReturnType()), + getQualifiedName(cache.getParameter().getType()), + ElementUtils.getReadableSignature(inlineMethod)); + } + } else { + /* + * May happen for recursive inlines. + */ + fields = Collections.emptyList(); + } + + cache.setInlinedNode(new InlinedNodeData(inlineMethod, fields)); + } else if (requireCached) { + AnnotationMirror cached = findAnnotationMirror(cache.getParameter().getVariableElement(), types.Cached); cache.setDefaultExpression(parseCachedExpression(resolver, cache, parameter.getType(), initializer)); + + cache.setDimensions(getAnnotationValue(Integer.class, cached, "dimensions")); + boolean disabledAdopt = adopt != null && Boolean.FALSE.equals(adopt.getValue()); + if (parameter.getType().getKind() == TypeKind.ARRAY && + (disabledAdopt || !isSubtype(((ArrayType) parameter.getType()).getComponentType(), types.NodeInterface))) { + if (cache.getDimensions() == -1) { + cache.addWarning("The cached dimensions attribute must be specified for array types."); + } + } else { + if (!disabledAdopt && cache.getDimensions() != -1) { + cache.addError("The dimensions attribute has no affect for the type %s.", getSimpleName(parameter.getType())); + } + } } - boolean requireUncached = specialization.getNode().isGenerateUncached() || mode == ParseMode.EXPORTED_MESSAGE; + if (cache.hasErrors()) { - return; // error sync point + return; } boolean uncachedSpecified = getAnnotationValue(cachedAnnotation, "uncached", false) != null; @@ -2732,13 +3506,15 @@ private void parseCached(CacheExpression cache, SpecializationData specializatio } } } - } - - if (requireUncached && cache.getUncachedExpression() == null && cache.getDefaultExpression() != null) { - if (specialization.isTrivialExpression(cache.getDefaultExpression())) { - cache.setUncachedExpression(cache.getDefaultExpression()); + if (cache.getUncachedExpression() == null && cache.getDefaultExpression() != null) { + if (specialization.isTrivialExpression(cache.getDefaultExpression())) { + cache.setUncachedExpression(cache.getDefaultExpression()); + } } } + if (cache.hasErrors()) { + return; + } if (adopt != null) { TypeMirror type = parameter.getType(); @@ -2749,8 +3525,421 @@ private void parseCached(CacheExpression cache, SpecializationData specializatio } } cache.setAdopt(getAnnotationValue(Boolean.class, cachedAnnotation, "adopt", true)); + + if (inline != null && inline && !hasInline && ElementUtils.isAssignable(cache.getParameter().getType(), types.Node)) { + cache.addError(cachedAnnotation, getAnnotationValue(cachedAnnotation, "inline"), + "The cached node type does not support object inlining." + // + " Add @%s on the node type or disable inline using @%s(inline=false) to resolve this.", + getSimpleName(types.GenerateInline), + getSimpleName(types.Cached)); + } + + Boolean neverDefault = getAnnotationValue(Boolean.class, cachedAnnotation, "neverDefault", false); + cache.setNeverDefaultGuaranteed(isNeverDefaultGuaranteed(specialization, cache)); + if (neverDefault != null) { + cache.setNeverDefault(neverDefault); + } else { + cache.setNeverDefault(isNeverDefaultImplied(cache)); + } + + } + + private boolean isNeverDefaultImplied(CacheExpression cache) { + /* + * Never default is implied if there is no custom initializer expression set. Default + * initializer create expressions very rarely may return null, therefore it is enough to + * fail at runtime for these cases. + */ + if (cache.isWeakReference()) { + return true; + } + + if (cache.isCachedLibrary()) { + return true; + } + + if (cache.getInlinedNode() != null) { + return true; + } + + if (cache.isNeverDefaultGuaranteed()) { + return true; + } + + String initializer = getAnnotationValue(String.class, cache.getMessageAnnotation(), "value", false); + if (initializer == null || initializer.equals("create()")) { + return true; + } + + if (cache.isEncodedEnum()) { + return true; + } + + if (isNeverDefaultImpliedByAnnotation(cache)) { + return true; + } + + return false; + } + + private boolean isNeverDefaultImpliedByAnnotation(CacheExpression cache) { + if (cache.getDefaultExpression() != null) { + ExecutableElement executable = cache.getDefaultExpression().resolveExecutable(); + if (executable != null) { + if (ElementUtils.findAnnotationMirror(executable, types.NeverDefault) != null) { + return true; + } + + Element enclosing = executable.getEnclosingElement(); + if (enclosing != null && typeEquals(enclosing.asType(), types.DirectCallNode)) { + // cannot use NeverDefault annotation in certain TruffleTypes + return true; + } + + } + VariableElement var = cache.getDefaultExpression().resolveVariable(); + if (var != null) { + if (ElementUtils.findAnnotationMirror(var, types.NeverDefault) != null) { + return true; + } + } + + } + return false; + } + + private static boolean isNeverDefaultGuaranteed(SpecializationData specialization, CacheExpression cache) { + if (cache.getDefaultExpression() == null) { + return false; + } + + TypeMirror type = cache.getDefaultExpression().getResolvedType(); + if (type != null && ElementUtils.isPrimitive(type) && !ElementUtils.isPrimitive(cache.getParameter().getType())) { + // An assignment of a primitive to its boxed type is never null. + return true; + } + + Object constant = cache.getDefaultExpression().resolveConstant(); + if (constant != null) { + if (constant instanceof Number) { + long value = ((Number) constant).longValue(); + if (value != 0) { + return true; + } + } else if (constant instanceof Boolean) { + if ((boolean) constant != false) { + return true; + } + } else if (constant instanceof String) { + return true; + } else { + throw new AssertionError("Unhandled constant type."); + } + } + + ExecutableElement method = cache.getDefaultExpression().resolveExecutable(); + if (method != null && method.getKind() == ElementKind.CONSTRUCTOR) { + // Constructors never return null. + return true; + } + + /* + * Object.getClass() and Object.toString() always returns a non-null value. + */ + if (method != null && ElementUtils.typeEquals(ProcessorContext.getInstance().getType(Object.class), method.getEnclosingElement().asType()) && + (method.getSimpleName().toString().equals("getClass") || method.getSimpleName().toString().equals("toString"))) { + return true; + } + + VariableElement var = cache.getDefaultExpression().resolveVariable(); + if (var != null && var.getSimpleName().toString().equals("this")) { + // this pointer for libraries never null + return true; + } + + /* + * If cached value binds a type guard checked reference type we know the value is never + * null. + */ + if (var != null && !var.asType().getKind().isPrimitive()) { + int index = 0; + for (Parameter p : specialization.getSignatureParameters()) { + if (Objects.equals(var, p.getVariableElement())) { + SpecializationData generic = specialization.getNode().getFallbackSpecialization(); + NodeExecutionData execution = specialization.getNode().getChildExecutions().get(index); + TypeMirror genericType = generic.findParameter(execution).getType(); + if (ElementUtils.needsCastTo(genericType, p.getType())) { + return true; + } + } + index++; + } + } + + return false; + } + + private List parseInlineMethod(MessageContainer errorContainer, Element errorElement, ExecutableElement inlineMethod) { + List fields = new ArrayList<>(); + if (inlineMethod.getParameters().size() != 1 || !typeEquals(types.InlineSupport_InlineTarget, inlineMethod.getParameters().get(0).asType())) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. The method must have exactly one parameter of type '%s'.", + ElementUtils.getReadableSignature(inlineMethod), + getSimpleName(types.InlineSupport_InlineTarget)); + } + return fields; + } + + VariableElement var = inlineMethod.getParameters().get(0); + List requiredFields = ElementUtils.getRepeatedAnnotation(var.getAnnotationMirrors(), types.InlineSupport_RequiredField); + + int fieldIndex = 0; + for (AnnotationMirror requiredField : requiredFields) { + TypeMirror value = ElementUtils.getAnnotationValue(TypeMirror.class, requiredField, "value"); + Integer bits = ElementUtils.getAnnotationValue(Integer.class, requiredField, "bits", false); + TypeMirror type = ElementUtils.getAnnotationValue(TypeMirror.class, requiredField, "type", false); + int dimensions = ElementUtils.getAnnotationValue(Integer.class, requiredField, "dimensions"); + + if (value == null) { + // compile error; + continue; + } + if (bits != null) { + if (bits < 0 || bits > 32) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Bits specification is out of range (must be >= 0 && <= 32).", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + } + if (type != null) { + if (ElementUtils.isPrimitive(type)) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Field type must not be a primitive type. Use primitive field classes instead.", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + } + + InlineFieldData fieldData = new InlineFieldData(null, "field" + fieldIndex, value, bits, type, dimensions); + if (fieldData.isState()) { + if (bits == null) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. State fields must specify a bits attribute", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + if (type != null) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. State fields must not specify a type. ", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + type = context.getType(int.class); + } else if (fieldData.isPrimitive()) { + if (type != null) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Primitive fields must not specify a type. ", + ElementUtils.getReadableSignature(inlineMethod)); + } + + continue; + } + if (bits != null) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Primitive fields must not specify bits. ", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + + } else if (fieldData.isReference()) { + if (type == null) { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Reference fields must specify a type. ", + ElementUtils.getReadableSignature(inlineMethod)); + } + continue; + } + } else { + if (errorContainer != null) { + errorContainer.addError(errorElement, "Inline method %s is invalid. Invalid field type %s.", + ElementUtils.getReadableSignature(inlineMethod), + ElementUtils.getSimpleName(type)); + } + continue; + } + + fields.add(fieldData); + fieldIndex++; + } + return fields; } + /* + * Is force inline by default enabled. Special case when cached is not set explicitly and the + * target type only has an inline method and no create method, then we turn on inline by default + * on. This enables that @Cached InlinedBranchProfile inlines by default even if a cached + * version is generated and no warning is printed. + */ + private static boolean forceInlineByDefault(CacheExpression cache) { + AnnotationMirror cacheAnnotation = cache.getMessageAnnotation(); + TypeElement parameterType = ElementUtils.castTypeElement(cache.getParameter().getType()); + if (parameterType == null) { + return false; + } + boolean defaultCached = getAnnotationValue(cacheAnnotation, "value", false) == null; + if (defaultCached && !hasDefaultCreateCacheMethod(parameterType.asType())) { + return hasInlineMethod(cache); + } + return false; + } + + private static boolean hasInlineMethod(CacheExpression cache) { + TypeMirror type = cache.getParameter().getType(); + TypeElement parameterType = ElementUtils.castTypeElement(type); + if (parameterType == null) { + return false; + } + + ExecutableElement inlineMethod = ElementUtils.findStaticMethod(parameterType, "inline"); + if (inlineMethod != null) { + return true; + } + if (isGenerateInline(parameterType) && NodeCodeGenerator.isSpecializedNode(parameterType.asType())) { + return true; + } + + String inlineMethodName = ElementUtils.getAnnotationValue(String.class, cache.getMessageAnnotation(), "inlineMethod", false); + if (inlineMethodName != null) { + return true; + } + + return false; + } + + private ExecutableElement lookupInlineMethod(DSLExpressionResolver resolver, NodeData node, CacheExpression cache, TypeMirror type, MessageContainer errorTarget) { + + String inlineMethodName = ElementUtils.getAnnotationValue(String.class, cache.getMessageAnnotation(), "inlineMethod", false); + ExecutableElement inlineMethod = null; + if (inlineMethodName != null) { + inlineMethod = resolver.lookupMethod(inlineMethodName, Arrays.asList(types.InlineSupport_InlineTarget)); + + String errorMessage = null; + if (inlineMethod == null) { + errorMessage = String.format("Static inline method with name '%s' and parameter type '%s' could not be resolved. ", + inlineMethodName, + ElementUtils.getSimpleName(types.InlineSupport_InlineTarget)); + } else if (!ElementUtils.isVisible(node.getTemplateType(), inlineMethod)) { + errorMessage = String.format("The method %s is not visible. ", ElementUtils.getReadableSignature(inlineMethod)); + } + + if (errorMessage != null && errorTarget != null) { + errorTarget.addError( + "%sExpected method with signature 'static %s inline(%s target)' in an enclosing class like '%s'. ", + errorMessage, + cache.getParameter().getType(), + getSimpleName(types.InlineSupport_InlineTarget), + getSimpleName(node.getTemplateType())); + } + } + + if (inlineMethod == null) { + if (!hasInlineMethod(cache)) { + return null; + } + TypeElement parameterType = ElementUtils.castTypeElement(type); + inlineMethod = ElementUtils.findStaticMethod(parameterType, "inline"); + + if (node.isGenerateInline() && isRecursiveType(node, parameterType)) { + if (errorTarget != null) { + errorTarget.addError("Detected recursive inlined cache with type '%s'. Recursive inlining cannot be supported. " + // + "Remove the recursive declaration or disable inlining with @%s(..., inline=false) to resolve this.", + getSimpleName(parameterType), + getSimpleName(types.Cached)); + } + return null; + } + + NodeData inlinedNode = lookupNodeData(node, type, errorTarget); + if (inlinedNode != null && inlinedNode.isGenerateInline()) { + CodeExecutableElement method = NodeFactoryFactory.createInlineMethod(inlinedNode, null); + method.setEnclosingElement(NodeCodeGenerator.nodeElement(inlinedNode)); + inlineMethod = method; + } + } + return inlineMethod; + + } + + private static boolean hasDefaultCreateCacheMethod(TypeMirror type) { + TypeElement parameterType = ElementUtils.castTypeElement(type); + if (parameterType == null) { + return false; + } + ExecutableElement createMethod = ElementUtils.findStaticMethod(parameterType, "create"); + if (createMethod != null) { + return true; + } + AnnotationMirror annotation = findGenerateAnnotation(parameterType.asType(), ProcessorContext.getInstance().getTypes().GenerateCached); + Boolean value = Boolean.TRUE; + if (annotation != null) { + value = ElementUtils.getAnnotationValue(Boolean.class, annotation, "value"); + } + return value && NodeCodeGenerator.isSpecializedNode(type); + } + + @SuppressWarnings({"unchecked", "try"}) + private NodeData lookupNodeData(NodeData node, TypeMirror type, MessageContainer errorTarget) { + TypeElement parameterType = ElementUtils.castTypeElement(type); + String typeId = ElementUtils.getTypeId(type); + NodeData nodeData = nodeDataCache.get(typeId); + if (nodeDataCache.containsKey(typeId)) { + return nodeData; + } + if (NodeCodeGenerator.isSpecializedNode(type) && !isRecursiveType(node, parameterType)) { + try (Timer timer = Timer.create(getClass().getSimpleName(), parameterType)) { + /* + * The annotation processor cannot see the code that it is producing, so we actually + * parse the entire specialized node to fully be able to compute the state space and + * therefore get a valid inline state space parameters. + */ + NodeParser parser = NodeParser.createDefaultParser(); + // assign parent inlining parser for recursion detection + parser.parsingParent = node; + + nodeData = parser.parseNode(parameterType); + + if (nodeData == null || nodeData.hasErrors()) { + if (errorTarget != null && nodeData != null && nodeData.hasErrors()) { + nodeData.redirectMessages(errorTarget); + } + // do not cache if there are errors + return nodeData; + } + } + } + nodeDataCache.put(typeId, nodeData); + return nodeData; + } + + private static boolean isRecursiveType(NodeData node, TypeElement parameterType) { + NodeData parent = node; + while (parent != null) { + if (ElementUtils.elementEquals(parent.getTemplateType(), parameterType)) { + return true; + } + parent = parent.getParsingParent(); + } + return false; + } + + private final Map nodeDataCache = new HashMap<>(); + private static class FactoryMethodCacheKey { } @@ -2779,25 +3968,28 @@ private List parseNodeFactoryMethods(TypeMirror nodeType) return executables; } - private DSLExpression resolveCachedExpression(DSLExpressionResolver resolver, MessageContainer msg, TypeMirror targetType, DSLExpression expression, String originalString) { - DSLExpressionResolver localResolver = targetType == null ? resolver : importStatics(resolver, targetType); - try { - expression.accept(localResolver); - } catch (InvalidExpressionException e) { - msg.addError("Error parsing expression '%s': %s", originalString, e.getMessage()); - return null; - } + private DSLExpression resolveCachedExpression(DSLExpressionResolver resolver, MessageContainer msg, + TypeMirror targetType, TypeMirror importType, DSLExpression expression, String originalString) { + DSLExpressionResolver localResolver = importStatics(resolver, importType); + localResolver = importStatics(localResolver, targetType); - if (targetType == null || isAssignable(expression.getResolvedType(), targetType)) { - return expression; - } else { - msg.addError("Incompatible return type %s. The expression type must be equal to the parameter type %s.", getSimpleName(expression.getResolvedType()), - getSimpleName(targetType)); - return null; + DSLExpression resolvedExpression = DSLExpression.resolve(localResolver, msg, null, expression, originalString); + if (resolvedExpression != null) { + if (targetType == null || isAssignable(resolvedExpression.getResolvedType(), targetType)) { + return resolvedExpression; + } else { + msg.addError("Incompatible return type %s. The expression type must be equal to the parameter type %s.", getSimpleName(resolvedExpression.getResolvedType()), + getSimpleName(targetType)); + return null; + } } + return resolvedExpression; } private DSLExpressionResolver importStatics(DSLExpressionResolver resolver, TypeMirror targetType) { + if (targetType == null) { + return resolver; + } DSLExpressionResolver localResolver = resolver; if (targetType.getKind() == TypeKind.DECLARED) { List prefixedImports = importVisibleStaticMembersImpl(resolver.getAccessType(), fromTypeMirror(targetType), true); @@ -2807,12 +3999,11 @@ private DSLExpressionResolver importStatics(DSLExpressionResolver resolver, Type } private DSLExpression parseCachedExpression(DSLExpressionResolver resolver, MessageContainer msg, TypeMirror targetType, String string) { - try { - return resolveCachedExpression(resolver, msg, targetType, DSLExpression.parse(string), string); - } catch (InvalidExpressionException e) { - msg.addError("Error parsing expression '%s': %s", string, e.getMessage()); + DSLExpression expression = DSLExpression.parse(msg, null, string); + if (expression == null) { return null; } + return resolveCachedExpression(resolver, msg, targetType, null, expression, string); } private void initializeGuards(SpecializationData specialization, DSLExpressionResolver resolver) { @@ -2839,20 +4030,6 @@ private void initializeGuards(SpecializationData specialization, DSLExpressionRe if (cache.isWeakReferenceGet()) { newGuards.add(createWeakReferenceGuard(resolver, specialization, cache)); } - if (cache.getSharedGroup() != null) { - if (ElementUtils.isPrimitive(cache.getParameter().getType())) { - guard.addError("This guard references a @%s cache with a primitive type. This is not supported. " + - "Resolve this by either:%n" + - " - Removing the @%s annotation from the referenced cache.%n" + - " - Removing the guard.%n" + - " - Removing the reference from the cache to the guard.", - getSimpleName(types.Cached_Shared), - getSimpleName(types.Cached_Shared)); - } else { - // generated code will verify that the returned shared value is - // non-null. - } - } } } @@ -2878,18 +4055,13 @@ private GuardExpression createWeakReferenceGuard(DSLExpressionResolver resolver, private GuardExpression parseGuard(DSLExpressionResolver resolver, SpecializationData specialization, String guard) { final TypeMirror booleanType = context.getType(boolean.class); - GuardExpression guardExpression; - DSLExpression expression; - try { - expression = DSLExpression.parse(guard); - expression.accept(resolver); - guardExpression = new GuardExpression(specialization, expression); - if (!typeEquals(expression.getResolvedType(), booleanType)) { - guardExpression.addError("Incompatible return type %s. Guards must return %s.", getSimpleName(expression.getResolvedType()), getSimpleName(booleanType)); - } - } catch (InvalidExpressionException e) { - guardExpression = new GuardExpression(specialization, null); - guardExpression.addError("Error parsing expression '%s': %s", guard, e.getMessage()); + DSLExpression expression = DSLExpression.parseAndResolve(resolver, specialization, "guards", guard); + GuardExpression guardExpression = new GuardExpression(specialization, expression); + if (expression == null) { + return guardExpression; + } + if (!typeEquals(expression.getResolvedType(), booleanType)) { + guardExpression.addError("Incompatible return type %s. Guards must return %s.", getSimpleName(expression.getResolvedType()), getSimpleName(booleanType)); } return guardExpression; } @@ -2935,10 +4107,15 @@ private SpecializationData createFallbackSpecialization(final NodeData node) { TypeMirror returnType = createGenericType(node, specification.getReturnType()); SpecializationData generic = parser.create("Generic", TemplateMethod.NO_NATURAL_ORDER, null, null, returnType, parameterTypes); + if (generic == null) { throw new RuntimeException("Unable to create generic signature for node " + node.getNodeId() + " with " + parameterTypes + ". Specification " + specification + "."); } + generic.setReplaced(false); + generic.setReplaces(new LinkedHashSet<>()); + generic.setReplacedBy(new LinkedHashSet<>()); + return generic; } @@ -2958,6 +4135,11 @@ private TypeMirror createGenericType(NodeData node, ParameterSpec spec) { } private static boolean verifySpecializationSameLength(NodeData nodeData) { + if (nodeData.isGenerateInline()) { + // no children allowed. the execute method determines the number of children + // necessary because the node signature parameter is optional. + return true; + } int lastArgs = -1; for (SpecializationData specializationData : nodeData.getSpecializations()) { int signatureArgs = specializationData.getSignatureSize(); @@ -3209,15 +4391,31 @@ private static Map> computeSharableCa if (specialization == null) { continue; } + if (specialization.isUncachedSpecialization()) { + continue; + } + if (specialization.isUnrolled()) { + continue; + } + for (CacheExpression cache : specialization.getCaches()) { - if (cache.isAlwaysInitialized() || cache.isCachedLibrary()) { + if (cache.isAlwaysInitialized()) { + continue; + } + if (cache.isCachedLibrary() && cache.getCachedLibraryLimit() == null) { + // can never be shared without a limit continue; } + if (specialization.isDynamicParameterBound(cache.getDefaultExpression(), true)) { + continue; + } + SharableCache sharable = new SharableCache(specialization, cache); sharableCaches.computeIfAbsent(sharable, (c) -> new ArrayList<>()).add(cache); } } } + return sharableCaches; } @@ -3244,7 +4442,6 @@ public boolean equals(Object obj) { if (this == obj) { return true; } else if (ElementUtils.executableEquals(specialization.getMethod(), other.specialization.getMethod()) && - !specialization.hasMultipleInstances() && !other.specialization.hasMultipleInstances() && ElementUtils.variableEquals(expression.getParameter().getVariableElement(), other.expression.getParameter().getVariableElement())) { return true; } @@ -3280,26 +4477,35 @@ private String equalsWithReasonImpl(SharableCache other, boolean generateMessage if (!generateMessage) { return ""; } - return String.format("The cache initializer does not match."); + return "The cache initializer does not match."; } if (!equalsExpression(expression.getUncachedExpression(), other.specialization, other.expression.getUncachedExpression())) { if (!generateMessage) { return ""; } - return String.format("The uncached initializer does not match."); + return "The uncached initializer does not match."; } - if (specialization.hasMultipleInstances()) { + + if (this.expression.isNeverDefault() != other.expression.isNeverDefault()) { if (!generateMessage) { return ""; } - return String.format("The specialization '%s' has multiple instances.", ElementUtils.getReadableSignature(specialization.getMethod())); + return String.format("The value for @%s(neverDefault=...) must be equal for all shared caches.", + getSimpleName(ProcessorContext.types().Cached)); + } - if (other.specialization.hasMultipleInstances()) { + + boolean isInlined = this.expression.getInlinedNode() != null; + boolean otherIsInlined = other.expression.getInlinedNode() != null; + if (isInlined != otherIsInlined) { if (!generateMessage) { return ""; } - return String.format("The specialization '%s' has multiple instances.", ElementUtils.getReadableSignature(other.specialization.getMethod())); + return String.format("The value for @%s(inline=...) must be equal for all shared caches.", + getSimpleName(ProcessorContext.types().Cached)); + } + return null; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java index bd22240505e6..82fb8de581c0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java @@ -52,6 +52,7 @@ import com.oracle.truffle.dsl.processor.model.NodeData; import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.model.TemplateMethod.TypeSignature; +import com.oracle.truffle.dsl.processor.model.TypeSystemData; /** * Class creates groups of specializations to optimize the layout of generated executeAndSpecialize @@ -76,7 +77,7 @@ private SpecializationGroup(SpecializationData data) { TypeSignature sig = data.getTypeSignature(); for (int i = 1; i < sig.size(); i++) { - typeGuards.add(new TypeGuard(sig.get(i), i - 1)); + typeGuards.add(new TypeGuard(node.getTypeSystem(), sig.get(i), i - 1)); } this.guards.addAll(data.getGuards()); } @@ -300,14 +301,20 @@ public int getMaxSpecializationIndex() { public static final class TypeGuard { + private final TypeSystemData typeSystem; private final int signatureIndex; private final TypeMirror type; - public TypeGuard(TypeMirror type, int signatureIndex) { + public TypeGuard(TypeSystemData typeSystem, TypeMirror type, int signatureIndex) { + this.typeSystem = typeSystem; this.type = type; this.signatureIndex = signatureIndex; } + public TypeSystemData getTypeSystem() { + return typeSystem; + } + @Override public int hashCode() { final int prime = 31; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationMethodParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationMethodParser.java index f03f8ecb985e..527f847c0352 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationMethodParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationMethodParser.java @@ -43,6 +43,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -137,19 +138,18 @@ public int compare(SpecializationThrowsData o1, SpecializationThrowsData o2) { List replacesDefs = new ArrayList<>(); replacesDefs.addAll(ElementUtils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "replaces")); - Set containsNames = specialization.getReplacesNames(); - containsNames.clear(); + Set replaceNames = new LinkedHashSet<>(); if (replacesDefs != null) { for (String include : replacesDefs) { - if (!containsNames.contains(include)) { - specialization.getReplacesNames().add(include); + if (!replaceNames.contains(include)) { + replaceNames.add(include); } else { AnnotationValue value = ElementUtils.getAnnotationValue(specialization.getMarkerAnnotation(), "replaces"); specialization.addError(value, "Duplicate replace declaration '%s'.", include); } } - } + specialization.setReplacesNames(replaceNames); } return specialization; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/TemplateMethodParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/TemplateMethodParser.java index 2b4737f35bc1..c366b5a63ef2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/TemplateMethodParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/TemplateMethodParser.java @@ -127,7 +127,6 @@ private E parse(int naturalOrder, ExecutableElement method, AnnotationMirror ann if (methodSpecification == null) { return null; } - TemplateMethod templateMethod = parser.parse(methodSpecification, method, annotation, naturalOrder); if (templateMethod != null) { return create(templateMethod, templateMethod.hasErrors()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyCompilationFinalProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyCompilationFinalProcessor.java index 957b4653c92f..a22feeacb3a4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyCompilationFinalProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyCompilationFinalProcessor.java @@ -73,8 +73,7 @@ public boolean process(Set annotations, RoundEnvironment if (roundEnv.processingOver()) { return false; } - ProcessorContext context = ProcessorContext.enter(processingEnv); - try { + try (ProcessorContext context = ProcessorContext.enter(processingEnv)) { TruffleTypes types = context.getTypes(); for (Element element : roundEnv.getElementsAnnotatedWith(ElementUtils.castTypeElement(types.CompilerDirectives_CompilationFinal))) { if (!element.getKind().isField()) { @@ -87,8 +86,6 @@ public boolean process(Set annotations, RoundEnvironment assertNoErrorExpected(element); } return false; - } finally { - ProcessorContext.leave(); } } @@ -127,18 +124,18 @@ private boolean checkDimensions(final VariableElement field) { } void assertNoErrorExpected(final Element originatingElm) { - ExpectError.assertNoErrorExpected(processingEnv, originatingElm); + ExpectError.assertNoErrorExpected(originatingElm); } private void emitError(final Element originatingElm, final String message) { - if (ExpectError.isExpectedError(processingEnv, originatingElm, message)) { + if (ExpectError.isExpectedError(originatingElm, message)) { return; } processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message, originatingElm); } private void emitWarning(final Element originatingElm, final String message) { - if (ExpectError.isExpectedError(processingEnv, originatingElm, message)) { + if (ExpectError.isExpectedError(originatingElm, message)) { return; } processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, message, originatingElm); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java index 8e2509a7a9e9..b2b99949d7d2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java @@ -128,8 +128,7 @@ public boolean process(Set annotations, RoundEnvironment return false; } - ProcessorContext context = ProcessorContext.enter(processingEnv); - try { + try (ProcessorContext context = ProcessorContext.enter(processingEnv)) { TruffleTypes types = context.getTypes(); TypeElement virtualFrameType = ElementUtils.castTypeElement(types.VirtualFrame); TypeElement frameType = ElementUtils.castTypeElement(types.Frame); @@ -222,17 +221,15 @@ public boolean process(Set annotations, RoundEnvironment } return false; - } finally { - ProcessorContext.leave(); } } void assertNoErrorExpected(Element element) { - ExpectError.assertNoErrorExpected(processingEnv, element); + ExpectError.assertNoErrorExpected(element); } void emitError(String message, Element element) { - if (ExpectError.isExpectedError(processingEnv, element, message)) { + if (ExpectError.isExpectedError(element, message)) { return; } processingEnv.getMessager().printMessage(Kind.ERROR, message, element); diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostContext.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostContext.java index fedc02ab70f6..8ccdbe0a194e 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostContext.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostContext.java @@ -65,7 +65,9 @@ import com.oracle.truffle.api.TruffleLanguage.ContextReference; import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -143,6 +145,7 @@ public HostClassCache getHostClassCache() { return language.hostClassCache; } + @NeverDefault GuestToHostCodeCache getGuestToHostCache() { GuestToHostCodeCache cache = (GuestToHostCodeCache) HostAccessor.ENGINE.getGuestToHostCodeCache(internalContext); if (cache == null) { @@ -350,9 +353,10 @@ static HostContext get(Node node) { } @GenerateUncached + @GenerateInline abstract static class ToGuestValueNode extends Node { - abstract Object execute(HostContext context, Object receiver); + abstract Object execute(Node node, HostContext context, Object receiver); @Specialization(guards = "receiver == null") Object doNull(HostContext context, @SuppressWarnings("unused") Object receiver) { @@ -423,7 +427,7 @@ private Object[] fastToGuestValuesUnroll(ToGuestValueNode[] nodes, HostContext c Object[] newArgs = needsCopy ? new Object[nodes.length] : args; for (int i = 0; i < nodes.length; i++) { Object arg = args[i]; - Object newArg = nodes[i].execute(context, arg); + Object newArg = nodes[i].execute(this, context, arg); if (needsCopy) { newArgs[i] = newArg; } else if (arg != newArg) { @@ -446,7 +450,7 @@ private Object[] fastToGuestValues(ToGuestValueNode node, HostContext context, O Object[] newArgs = needsCopy ? new Object[args.length] : args; for (int i = 0; i < args.length; i++) { Object arg = args[i]; - Object newArg = node.execute(context, arg); + Object newArg = node.execute(this, context, arg); if (needsCopy) { newArgs[i] = newArg; } else if (arg != newArg) { diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostExecuteNode.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostExecuteNode.java index f0ae16b60c35..c2677b13193b 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostExecuteNode.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostExecuteNode.java @@ -57,7 +57,10 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; @@ -68,9 +71,9 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.profiles.InlinedExactClassProfile; import com.oracle.truffle.host.HostContext.ToGuestValueNode; import com.oracle.truffle.host.HostMethodDesc.OverloadedMethod; import com.oracle.truffle.host.HostMethodDesc.SingleMethod; @@ -79,6 +82,8 @@ @ReportPolymorphism @GenerateUncached +@GenerateInline +@GenerateCached(false) abstract class HostExecuteNode extends Node { static final int LIMIT = 3; private static final Class[] EMPTY_CLASS_ARRAY = new Class[0]; @@ -86,11 +91,7 @@ abstract class HostExecuteNode extends Node { HostExecuteNode() { } - static HostExecuteNode create() { - return HostExecuteNodeGen.create(); - } - - public abstract Object execute(HostMethodDesc method, Object obj, Object[] args, HostContext hostContext) throws UnsupportedTypeException, ArityException; + public abstract Object execute(Node node, HostMethodDesc method, Object obj, Object[] args, HostContext hostContext) throws UnsupportedTypeException, ArityException; static HostToTypeNode[] createToHost(int argsLength) { HostToTypeNode[] toJava = new HostToTypeNode[argsLength]; @@ -103,17 +104,17 @@ static HostToTypeNode[] createToHost(int argsLength) { @SuppressWarnings("unused") @ExplodeLoop @Specialization(guards = {"!method.isVarArgs()", "method == cachedMethod"}, limit = "LIMIT") - Object doFixed(SingleMethod method, Object obj, Object[] args, HostContext hostContext, + static Object doFixed(Node node, SingleMethod method, Object obj, Object[] args, HostContext hostContext, @Cached("method") SingleMethod cachedMethod, @Cached("createToHost(method.getParameterCount())") HostToTypeNode[] toJavaNodes, - @Cached ToGuestValueNode toGuest, - @Cached("createClassProfile()") ValueProfile receiverProfile, - @Cached BranchProfile errorBranch, - @Cached BranchProfile seenDynamicScope, + @Exclusive @Cached ToGuestValueNode toGuest, + @Exclusive @Cached InlinedExactClassProfile receiverProfile, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch, + @Shared("seenScope") @Cached InlinedBranchProfile seenDynamicScope, @Cached(value = "hostContext.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws ArityException, UnsupportedTypeException { int arity = cachedMethod.getParameterCount(); if (args.length != arity) { - errorBranch.enter(); + errorBranch.enter(node); throw ArityException.create(arity, arity, args.length); } Class[] types = cachedMethod.getParameterTypes(); @@ -125,36 +126,36 @@ Object doFixed(SingleMethod method, Object obj, Object[] args, HostContext hostC try { for (int i = 0; i < toJavaNodes.length; i++) { Object operand = HostMethodScope.addToScopeStatic(scope, cachedMethod, i, args[i]); - convertedArguments[i] = toJavaNodes[i].execute(hostContext, operand, types[i], genericTypes[i], true); + convertedArguments[i] = toJavaNodes[i].execute(toJavaNodes[i], hostContext, operand, types[i], genericTypes[i], true); } } catch (RuntimeException e) { - errorBranch.enter(); + errorBranch.enter(node); if (cache.language.access.isEngineException(e)) { throw HostInteropErrors.unsupportedTypeException(args, cache.language.access.unboxEngineException(e)); } throw e; } - return doInvoke(cachedMethod, receiverProfile.profile(obj), convertedArguments, cache, hostContext, toGuest); + return doInvoke(node, cachedMethod, receiverProfile.profile(node, obj), convertedArguments, cache, hostContext, toGuest); } finally { - HostMethodScope.closeStatic(scope, cachedMethod, seenDynamicScope); + HostMethodScope.closeStatic(node, scope, cachedMethod, seenDynamicScope); } } @SuppressWarnings("unused") @Specialization(guards = {"method.isVarArgs()", "method == cachedMethod"}, limit = "LIMIT") - Object doVarArgs(SingleMethod method, Object obj, Object[] args, HostContext hostContext, + static Object doVarArgs(Node node, SingleMethod method, Object obj, Object[] args, HostContext hostContext, @Cached("method") SingleMethod cachedMethod, - @Cached HostToTypeNode toJavaNode, - @Cached ToGuestValueNode toGuest, - @Cached("createClassProfile()") ValueProfile receiverProfile, - @Cached BranchProfile errorBranch, - @Cached BranchProfile seenDynamicScope, + @Exclusive @Cached HostToTypeNode toJavaNode, + @Exclusive @Cached ToGuestValueNode toGuest, + @Exclusive @Cached InlinedExactClassProfile receiverProfile, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch, + @Shared("seenScope") @Cached InlinedBranchProfile seenDynamicScope, @Cached("asVarArgs(args, cachedMethod, hostContext)") boolean asVarArgs, @Cached(value = "hostContext.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws ArityException, UnsupportedTypeException { int parameterCount = cachedMethod.getParameterCount(); int minArity = parameterCount - 1; if (args.length < minArity) { - errorBranch.enter(); + errorBranch.enter(node); throw ArityException.create(minArity, -1, args.length); } Class[] types = cachedMethod.getParameterTypes(); @@ -166,7 +167,7 @@ Object doVarArgs(SingleMethod method, Object obj, Object[] args, HostContext hos try { for (int i = 0; i < minArity; i++) { Object operand = HostMethodScope.addToScopeStatic(scope, cachedMethod, i, args[i]); - convertedArguments[i] = toJavaNode.execute(hostContext, operand, types[i], genericTypes[i], true); + convertedArguments[i] = toJavaNode.execute(node, hostContext, operand, types[i], genericTypes[i], true); } if (asVarArgs) { for (int i = minArity; i < args.length; i++) { @@ -174,40 +175,40 @@ Object doVarArgs(SingleMethod method, Object obj, Object[] args, HostContext hos Type expectedGenericType = getGenericComponentType(genericTypes[minArity]); Object operand = HostMethodScope.addToScopeStatic(scope, cachedMethod, i, args[i]); - convertedArguments[i] = toJavaNode.execute(hostContext, operand, expectedType, expectedGenericType, true); + convertedArguments[i] = toJavaNode.execute(node, hostContext, operand, expectedType, expectedGenericType, true); } convertedArguments = createVarArgsArray(cachedMethod, convertedArguments, parameterCount); } else { Object operand = HostMethodScope.addToScopeStatic(scope, cachedMethod, minArity, args[minArity]); - convertedArguments[minArity] = toJavaNode.execute(hostContext, operand, types[minArity], genericTypes[minArity], true); + convertedArguments[minArity] = toJavaNode.execute(node, hostContext, operand, types[minArity], genericTypes[minArity], true); } } catch (RuntimeException e) { - errorBranch.enter(); + errorBranch.enter(node); if (cache.language.access.isEngineException(e)) { throw HostInteropErrors.unsupportedTypeException(args, cache.language.access.unboxEngineException(e)); } throw e; } - return doInvoke(cachedMethod, receiverProfile.profile(obj), convertedArguments, cache, hostContext, toGuest); + return doInvoke(node, cachedMethod, receiverProfile.profile(node, obj), convertedArguments, cache, hostContext, toGuest); } finally { - HostMethodScope.closeStatic(scope, cachedMethod, seenDynamicScope); + HostMethodScope.closeStatic(node, scope, cachedMethod, seenDynamicScope); } } @Specialization(replaces = {"doFixed", "doVarArgs"}) - static Object doSingleUncached(SingleMethod method, Object obj, Object[] args, HostContext hostContext, + static Object doSingleUncached(Node node, SingleMethod method, Object obj, Object[] args, HostContext hostContext, @Shared("toHost") @Cached HostToTypeNode toJavaNode, @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("varArgsProfile") @Cached ConditionProfile isVarArgsProfile, + @Shared("varArgsProfile") @Cached InlinedConditionProfile isVarArgsProfile, @Shared("hostMethodProfile") @Cached HostMethodProfileNode methodProfile, - @Shared("errorBranch") @Cached BranchProfile errorBranch, - @Shared("seenScope") @Cached BranchProfile seenScope, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch, + @Shared("seenScope") @Cached InlinedBranchProfile seenScope, @Shared("cache") @Cached(value = "hostContext.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws ArityException, UnsupportedTypeException { int parameterCount = method.getParameterCount(); int minArity; int maxArity; boolean arityError; - if (isVarArgsProfile.profile(method.isVarArgs())) { + if (isVarArgsProfile.profile(node, method.isVarArgs())) { minArity = parameterCount - 1; maxArity = -1; arityError = args.length < minArity; @@ -217,44 +218,44 @@ static Object doSingleUncached(SingleMethod method, Object obj, Object[] args, H arityError = args.length != minArity; } if (arityError) { - errorBranch.enter(); + errorBranch.enter(node); throw ArityException.create(minArity, maxArity, args.length); } Object[] convertedArguments; - HostMethodScope scope = HostMethodScope.openDynamic(method, args.length, seenScope); + HostMethodScope scope = HostMethodScope.openDynamic(node, method, args.length, seenScope); try { try { - convertedArguments = prepareArgumentsUncached(method, args, hostContext, toJavaNode, scope, isVarArgsProfile); + convertedArguments = prepareArgumentsUncached(node, method, args, hostContext, toJavaNode, scope, isVarArgsProfile); } catch (RuntimeException e) { - errorBranch.enter(); + errorBranch.enter(node); if (cache.language.access.isEngineException(e)) { throw HostInteropErrors.unsupportedTypeException(args, cache.language.access.unboxEngineException(e)); } throw e; } - return doInvoke(methodProfile.execute(method), obj, convertedArguments, cache, hostContext, toGuest); + return doInvoke(node, methodProfile.execute(node, method), obj, convertedArguments, cache, hostContext, toGuest); } finally { HostMethodScope.closeDynamic(scope, method); } } // Note: checkArgTypes must be evaluated after selectOverload. - @SuppressWarnings({"unused", "static-method"}) + @SuppressWarnings({"unused", "static-method", "truffle-static-method"}) @ExplodeLoop @Specialization(guards = {"method == cachedMethod", "checkArgTypes(args, cachedArgTypes, interop, hostContext, asVarArgs)"}, limit = "LIMIT") - final Object doOverloadedCached(OverloadedMethod method, Object obj, Object[] args, HostContext hostContext, + static final Object doOverloadedCached(Node node, OverloadedMethod method, Object obj, Object[] args, HostContext hostContext, @Cached("method") OverloadedMethod cachedMethod, - @Cached HostToTypeNode toJavaNode, - @Cached ToGuestValueNode toGuest, + @Exclusive @Cached HostToTypeNode toJavaNode, + @Exclusive @Cached ToGuestValueNode toGuest, @CachedLibrary(limit = "LIMIT") InteropLibrary interop, @Cached("createArgTypesArray(args)") TypeCheckNode[] cachedArgTypes, - @Cached("selectOverload(method, args, hostContext, cachedArgTypes)") SingleMethod overload, + @Cached("selectOverload(node, method, args, hostContext, cachedArgTypes)") SingleMethod overload, @Cached("asVarArgs(args, overload, hostContext)") boolean asVarArgs, - @Cached("createClassProfile()") ValueProfile receiverProfile, - @Cached BranchProfile errorBranch, - @Cached BranchProfile seenVariableScope, + @Exclusive @Cached InlinedExactClassProfile receiverProfile, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch, + @Shared("seenScope") @Cached InlinedBranchProfile seenVariableScope, @Cached(value = "hostContext.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws ArityException, UnsupportedTypeException { - assert overload == selectOverload(method, args, hostContext); + assert overload == selectOverload(node, method, args, hostContext); Class[] types = overload.getParameterTypes(); Type[] genericTypes = overload.getGenericParameterTypes(); Object[] convertedArguments = new Object[cachedArgTypes.length]; @@ -269,76 +270,76 @@ final Object doOverloadedCached(OverloadedMethod method, Object obj, Object[] ar Class expectedType = i < parameterCount - 1 ? types[i] : types[parameterCount - 1].getComponentType(); Type expectedGenericType = i < parameterCount - 1 ? genericTypes[i] : getGenericComponentType(genericTypes[parameterCount - 1]); Object operand = HostMethodScope.addToScopeStatic(scope, overload, i, args[i]); - convertedArguments[i] = toJavaNode.execute(hostContext, operand, expectedType, expectedGenericType, true); + convertedArguments[i] = toJavaNode.execute(node, hostContext, operand, expectedType, expectedGenericType, true); } convertedArguments = createVarArgsArray(overload, convertedArguments, parameterCount); } else { for (int i = 0; i < cachedArgTypes.length; i++) { Object operand = HostMethodScope.addToScopeStatic(scope, overload, i, args[i]); - convertedArguments[i] = toJavaNode.execute(hostContext, operand, types[i], genericTypes[i], true); + convertedArguments[i] = toJavaNode.execute(node, hostContext, operand, types[i], genericTypes[i], true); } } } catch (RuntimeException e) { - errorBranch.enter(); + errorBranch.enter(node); if (cache.language.access.isEngineException(e)) { throw HostInteropErrors.unsupportedTypeException(args, cache.language.access.unboxEngineException(e)); } throw e; } - return doInvoke(overload, receiverProfile.profile(obj), convertedArguments, cache, hostContext, toGuest); + return doInvoke(node, overload, receiverProfile.profile(node, obj), convertedArguments, cache, hostContext, toGuest); } finally { - HostMethodScope.closeStatic(scope, overload, seenVariableScope); + HostMethodScope.closeStatic(node, scope, overload, seenVariableScope); } } @SuppressWarnings("static-method") @Specialization(replaces = "doOverloadedCached") - final Object doOverloadedUncached(OverloadedMethod method, Object obj, Object[] args, HostContext hostContext, + static final Object doOverloadedUncached(Node node, OverloadedMethod method, Object obj, Object[] args, HostContext hostContext, @Shared("toHost") @Cached HostToTypeNode toJavaNode, @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("varArgsProfile") @Cached ConditionProfile isVarArgsProfile, + @Shared("varArgsProfile") @Cached InlinedConditionProfile isVarArgsProfile, @Shared("hostMethodProfile") @Cached HostMethodProfileNode methodProfile, - @Shared("errorBranch") @Cached BranchProfile errorBranch, - @Shared("seenScope") @Cached BranchProfile seenScope, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch, + @Shared("seenScope") @Cached InlinedBranchProfile seenScope, @Shared("cache") @Cached(value = "hostContext.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws ArityException, UnsupportedTypeException { - SingleMethod overload = selectOverload(method, args, hostContext); + SingleMethod overload = selectOverload(node, method, args, hostContext); Object[] convertedArguments; - HostMethodScope scope = HostMethodScope.openDynamic(overload, args.length, seenScope); + HostMethodScope scope = HostMethodScope.openDynamic(node, overload, args.length, seenScope); try { try { - convertedArguments = prepareArgumentsUncached(overload, args, hostContext, toJavaNode, scope, isVarArgsProfile); + convertedArguments = prepareArgumentsUncached(node, overload, args, hostContext, toJavaNode, scope, isVarArgsProfile); } catch (RuntimeException e) { - errorBranch.enter(); + errorBranch.enter(node); if (cache.language.access.isEngineException(e)) { throw HostInteropErrors.unsupportedTypeException(args, cache.language.access.unboxEngineException(e)); } throw e; } - return doInvoke(methodProfile.execute(overload), obj, convertedArguments, cache, hostContext, toGuest); + return doInvoke(node, methodProfile.execute(node, overload), obj, convertedArguments, cache, hostContext, toGuest); } finally { HostMethodScope.closeDynamic(scope, overload); } } - private static Object[] prepareArgumentsUncached(SingleMethod method, Object[] args, HostContext context, HostToTypeNode toJavaNode, HostMethodScope scope, - ConditionProfile isVarArgsProfile) { + private static Object[] prepareArgumentsUncached(Node node, SingleMethod method, Object[] args, HostContext context, HostToTypeNode toJavaNode, HostMethodScope scope, + InlinedConditionProfile isVarArgsProfile) { Class[] types = method.getParameterTypes(); Type[] genericTypes = method.getGenericParameterTypes(); Object[] convertedArguments = new Object[args.length]; - if (isVarArgsProfile.profile(method.isVarArgs()) && asVarArgs(args, method, context)) { + if (isVarArgsProfile.profile(node, method.isVarArgs()) && asVarArgs(args, method, context)) { int parameterCount = method.getParameterCount(); for (int i = 0; i < args.length; i++) { Class expectedType = i < parameterCount - 1 ? types[i] : types[parameterCount - 1].getComponentType(); Type expectedGenericType = i < parameterCount - 1 ? genericTypes[i] : getGenericComponentType(genericTypes[parameterCount - 1]); Object operand = HostMethodScope.addToScopeDynamic(scope, args[i]); - convertedArguments[i] = toJavaNode.execute(context, operand, expectedType, expectedGenericType, true); + convertedArguments[i] = toJavaNode.execute(node, context, operand, expectedType, expectedGenericType, true); } convertedArguments = createVarArgsArray(method, convertedArguments, parameterCount); } else { for (int i = 0; i < args.length; i++) { Object operand = HostMethodScope.addToScopeDynamic(scope, args[i]); - convertedArguments[i] = toJavaNode.execute(context, operand, types[i], genericTypes[i], true); + convertedArguments[i] = toJavaNode.execute(node, context, operand, types[i], genericTypes[i], true); } } return convertedArguments; @@ -352,7 +353,7 @@ static TypeCheckNode[] createArgTypesArray(Object[] args) { } @SuppressWarnings("unchecked") - private void fillArgTypesArray(Object[] args, TypeCheckNode[] cachedArgTypes, SingleMethod selected, boolean varArgs, List applicable, int priority, + private static void fillArgTypesArray(Node node, Object[] args, TypeCheckNode[] cachedArgTypes, SingleMethod selected, boolean varArgs, List applicable, int priority, HostContext context) { if (cachedArgTypes == null) { return; @@ -380,7 +381,7 @@ private void fillArgTypesArray(Object[] args, TypeCheckNode[] cachedArgTypes, Si * checked for not applicable in order to ensure that mappings with priority * continue to not apply. */ - if (!HostToTypeNode.canConvert(arg, paramType, paramType, null, context, priority, + if (!HostToTypeNode.canConvert(null, arg, paramType, paramType, null, context, priority, InteropLibrary.getFactory().getUncached(), HostTargetMappingNode.getUncached())) { HostTargetMapping[] otherMappings = cache.getMappings(paramType); if (otherPossibleMappings == null) { @@ -411,7 +412,7 @@ private void fillArgTypesArray(Object[] args, TypeCheckNode[] cachedArgTypes, Si * We need to eagerly insert as the cachedArgTypes might be used before they are adopted * by the DSL. */ - cachedArgTypes[i] = insert(argType); + cachedArgTypes[i] = node.insert(argType); } assert checkArgTypes(args, cachedArgTypes, InteropLibrary.getFactory().getUncached(), context, false) : Arrays.toString(cachedArgTypes); @@ -469,7 +470,7 @@ static boolean asVarArgs(Object[] args, SingleMethod overload, HostContext hostC int parameterCount = overload.getParameterCount(); if (args.length == parameterCount) { Class varArgParamType = overload.getParameterTypes()[parameterCount - 1]; - return !HostToTypeNode.canConvert(args[parameterCount - 1], varArgParamType, overload.getGenericParameterTypes()[parameterCount - 1], + return !HostToTypeNode.canConvert(null, args[parameterCount - 1], varArgParamType, overload.getGenericParameterTypes()[parameterCount - 1], null, hostContext, HostToTypeNode.COERCE, InteropLibrary.getFactory().getUncached(), HostTargetMappingNode.getUncached()); } else { @@ -527,12 +528,12 @@ static Class boxedTypeToPrimitiveType(Class primitiveType) { } @TruffleBoundary - SingleMethod selectOverload(OverloadedMethod method, Object[] args, HostContext hostContext) throws ArityException, UnsupportedTypeException { - return selectOverload(method, args, hostContext, null); + static SingleMethod selectOverload(Node node, OverloadedMethod method, Object[] args, HostContext hostContext) throws ArityException, UnsupportedTypeException { + return selectOverload(node, method, args, hostContext, null); } @TruffleBoundary - SingleMethod selectOverload(OverloadedMethod method, Object[] args, HostContext hostContext, TypeCheckNode[] cachedArgTypes) + static SingleMethod selectOverload(Node node, OverloadedMethod method, Object[] args, HostContext hostContext, TypeCheckNode[] cachedArgTypes) throws ArityException, UnsupportedTypeException { SingleMethod[] overloads = method.getOverloads(); List applicableByArity = new ArrayList<>(); @@ -565,13 +566,13 @@ SingleMethod selectOverload(OverloadedMethod method, Object[] args, HostContext SingleMethod best; for (int priority : HostToTypeNode.PRIORITIES) { - best = findBestCandidate(applicableByArity, args, hostContext, false, priority, cachedArgTypes); + best = findBestCandidate(node, applicableByArity, args, hostContext, false, priority, cachedArgTypes); if (best != null) { return best; } if (anyVarArgs) { - best = findBestCandidate(applicableByArity, args, hostContext, true, priority, cachedArgTypes); + best = findBestCandidate(node, applicableByArity, args, hostContext, true, priority, cachedArgTypes); if (best != null) { return best; } @@ -580,8 +581,7 @@ SingleMethod selectOverload(OverloadedMethod method, Object[] args, HostContext throw noApplicableOverloadsException(overloads, args); } - @SuppressWarnings("static-method") - private SingleMethod findBestCandidate(List applicableByArity, Object[] args, HostContext hostContext, boolean varArgs, int priority, + private static SingleMethod findBestCandidate(Node node, List applicableByArity, Object[] args, HostContext hostContext, boolean varArgs, int priority, TypeCheckNode[] cachedArgTypes) throws UnsupportedTypeException { List candidates = new ArrayList<>(); @@ -594,7 +594,7 @@ private SingleMethod findBestCandidate(List applicableByArity, Obj Type[] genericParameterTypes = candidate.getGenericParameterTypes(); boolean applicable = true; for (int i = 0; i < paramCount; i++) { - if (!HostToTypeNode.canConvert(args[i], parameterTypes[i], genericParameterTypes[i], null, + if (!HostToTypeNode.canConvert(null, args[i], parameterTypes[i], genericParameterTypes[i], null, hostContext, priority, InteropLibrary.getFactory().getUncached(args[i]), HostTargetMappingNode.getUncached())) { applicable = false; @@ -614,7 +614,7 @@ private SingleMethod findBestCandidate(List applicableByArity, Obj Type[] genericParameterTypes = candidate.getGenericParameterTypes(); boolean applicable = true; for (int i = 0; i < parameterCount - 1; i++) { - if (!HostToTypeNode.canConvert(args[i], parameterTypes[i], genericParameterTypes[i], null, + if (!HostToTypeNode.canConvert(null, args[i], parameterTypes[i], genericParameterTypes[i], null, hostContext, priority, InteropLibrary.getFactory().getUncached(args[i]), HostTargetMappingNode.getUncached())) { applicable = false; @@ -631,7 +631,7 @@ private SingleMethod findBestCandidate(List applicableByArity, Obj varArgsGenericComponentType = varArgsComponentType; } for (int i = parameterCount - 1; i < args.length; i++) { - if (!HostToTypeNode.canConvert(args[i], varArgsComponentType, varArgsGenericComponentType, null, + if (!HostToTypeNode.canConvert(null, args[i], varArgsComponentType, varArgsGenericComponentType, null, hostContext, priority, InteropLibrary.getFactory().getUncached(args[i]), HostTargetMappingNode.getUncached())) { applicable = false; @@ -651,7 +651,7 @@ private SingleMethod findBestCandidate(List applicableByArity, Obj SingleMethod best = candidates.get(0); if (cachedArgTypes != null) { - fillArgTypesArray(args, cachedArgTypes, best, varArgs, applicableByArity, priority, hostContext); + fillArgTypesArray(node, args, cachedArgTypes, best, varArgs, applicableByArity, priority, hostContext); } return best; @@ -659,7 +659,7 @@ private SingleMethod findBestCandidate(List applicableByArity, Obj SingleMethod best = findMostSpecificOverload(hostContext, candidates, args, varArgs, priority); if (best != null) { if (cachedArgTypes != null) { - fillArgTypesArray(args, cachedArgTypes, best, varArgs, applicableByArity, priority, hostContext); + fillArgTypesArray(node, args, cachedArgTypes, best, varArgs, applicableByArity, priority, hostContext); } return best; @@ -749,8 +749,8 @@ private static int compareByPriority(HostContext context, Class t1, Class if (p > priority) { break; } - boolean p1 = HostToTypeNode.canConvert(arg, t1, t1, null, context, p, argInterop, mapping); - boolean p2 = HostToTypeNode.canConvert(arg, t2, t2, null, context, p, argInterop, mapping); + boolean p1 = HostToTypeNode.canConvert(null, arg, t1, t1, null, context, p, argInterop, mapping); + boolean p2 = HostToTypeNode.canConvert(null, arg, t2, t2, null, context, p, argInterop, mapping); if (p1 != p2) { return p1 ? -1 : 1; } @@ -865,11 +865,11 @@ private static Object[] createVarArgsArray(SingleMethod method, Object[] args, i return arguments; } - private static Object doInvoke(SingleMethod method, Object obj, Object[] arguments, GuestToHostCodeCache cache, HostContext hostContext, ToGuestValueNode toGuest) { + private static Object doInvoke(Node node, SingleMethod method, Object obj, Object[] arguments, GuestToHostCodeCache cache, HostContext hostContext, ToGuestValueNode toGuest) { assert cache == hostContext.getGuestToHostCache(); assert arguments.length == method.getParameterCount(); - Object ret = method.invokeGuestToHost(obj, arguments, cache, hostContext, toGuest); - return toGuest.execute(hostContext, ret); + Object ret = method.invokeGuestToHost(obj, arguments, cache, hostContext, node); + return toGuest.execute(node, hostContext, ret); } private static String arrayToStringWithTypes(Object[] args) { @@ -1081,17 +1081,19 @@ public String toString() { @Override public boolean execute(Object value, InteropLibrary interop, HostContext context) { for (Class otherType : otherTypes) { - if (HostToTypeNode.canConvert(value, otherType, otherType, null, context, priority, interop, null)) { + if (HostToTypeNode.canConvert(null, value, otherType, otherType, null, context, priority, interop, null)) { return false; } } - return HostToTypeNode.canConvert(value, targetType, targetType, null, context, priority, interop, null); + return HostToTypeNode.canConvert(null, value, targetType, targetType, null, context, priority, interop, null); } } @GenerateUncached + @GenerateCached(false) + @GenerateInline abstract static class HostMethodProfileNode extends Node { - public abstract SingleMethod execute(SingleMethod method); + public abstract SingleMethod execute(Node node, SingleMethod method); @Specialization static SingleMethod mono(SingleMethod.MHBase method) { diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostFunction.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostFunction.java index 628df030daaf..e1f7a3870c7b 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostFunction.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostFunction.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -51,6 +52,7 @@ import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.utilities.TriState; @ExportLibrary(InteropLibrary.class) @@ -81,8 +83,10 @@ boolean isExecutable() { } @ExportMessage - Object execute(Object[] args, @Cached HostExecuteNode execute) throws UnsupportedTypeException, ArityException { - return execute.execute(method, obj, args, context); + Object execute(Object[] args, + @Bind("$node") Node node, + @Cached HostExecuteNode execute) throws UnsupportedTypeException, ArityException { + return execute.execute(node, method, obj, args, context); } @SuppressWarnings("static-method") diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostInteropReflect.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostInteropReflect.java index 171f79c1dbee..645071c4d6d7 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostInteropReflect.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostInteropReflect.java @@ -51,6 +51,7 @@ import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnsupportedTypeException; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.host.HostAdapterFactory.AdapterResult; final class HostInteropReflect { @@ -223,7 +224,7 @@ static boolean isInternal(HostObject object, Class clazz, String name, boolea } @TruffleBoundary - static Object newAdapterInstance(HostContext hostContext, Class clazz, Object obj) throws IllegalArgumentException { + static Object newAdapterInstance(Node node, HostContext hostContext, Class clazz, Object obj) throws IllegalArgumentException { if (TruffleOptions.AOT) { throw HostEngineException.unsupported(hostContext.access, "Unsupported target type."); } @@ -235,7 +236,7 @@ static Object newAdapterInstance(HostContext hostContext, Class clazz, Object HostMethodDesc.SingleMethod adapterConstructor = adapter.getValueConstructor(); Object[] arguments = new Object[]{obj}; try { - return ((HostObject) HostExecuteNodeGen.getUncached().execute(adapterConstructor, null, arguments, hostContext)).obj; + return ((HostObject) HostExecuteNodeGen.getUncached().execute(node, adapterConstructor, null, arguments, hostContext)).obj; } catch (UnsupportedTypeException e) { throw HostInteropErrors.invalidExecuteArgumentType(hostContext, null, e.getSuppliedValues()); } catch (ArityException e) { diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguage.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguage.java index 27dfb45c349b..2795b6929af5 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguage.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguage.java @@ -154,7 +154,7 @@ protected Object getLanguageView(HostContext hostContext, Object value) { } catch (UnsupportedMessageException e) { throw shouldNotReachHere(e); } - wrapped = HostToTypeNode.convertToObject(hostContext, value, lib); + wrapped = HostToTypeNode.convertToObject(lib, hostContext, value, lib); } else { wrapped = value; } diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java index 1e2d29de0aa2..614d0622b039 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java @@ -53,8 +53,10 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleOptions; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.host.HostAdapterFactory.AdapterResult; import com.oracle.truffle.host.HostLanguage.HostLanguageException; import com.oracle.truffle.host.HostMethodDesc.SingleMethod; @@ -119,19 +121,19 @@ public Object findStaticClass(Object receiver, String classValue) { } @Override - public Object createToHostTypeNode() { - return HostToTypeNodeGen.create(); + public Object inlineToHostTypeNode(Object inlineTarget) { + return HostToTypeNodeGen.inline((InlineTarget) inlineTarget); } @SuppressWarnings("unchecked") @Override - public T toHostType(Object hostNode, Object hostContext, Object value, Class targetType, Type genericType) { + public T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType) { HostContext context = (HostContext) hostContext; HostToTypeNode node = (HostToTypeNode) hostNode; if (node == null) { node = HostToTypeNodeGen.getUncached(); } - return (T) node.execute(context, value, targetType, genericType, true); + return (T) node.execute((Node) targetNode, context, value, targetType, genericType, true); } @Override diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostMethodScope.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostMethodScope.java index 0294aa0e59c3..28de3dceba03 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostMethodScope.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostMethodScope.java @@ -46,6 +46,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; @@ -54,7 +55,8 @@ import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.library.Message; import com.oracle.truffle.api.library.ReflectionLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.host.HostMethodDesc.SingleMethod; import sun.misc.Unsafe; @@ -77,9 +79,9 @@ final class HostMethodScope { this.nextDynamicIndex = 0; } - static HostMethodScope openDynamic(SingleMethod method, int argumentCount, BranchProfile seenScope) { + static HostMethodScope openDynamic(Node node, SingleMethod method, int argumentCount, InlinedBranchProfile seenScope) { if (method.hasScopedParameters()) { - seenScope.enter(); + seenScope.enter(node); return new HostMethodScope(argumentCount); } return null; @@ -127,7 +129,7 @@ static void pin(Object value) { } } - static void closeStatic(HostMethodScope scope, SingleMethod method, BranchProfile seenDynamicScope) { + static void closeStatic(Node node, HostMethodScope scope, SingleMethod method, InlinedBranchProfile seenDynamicScope) { if (method.hasScopedParameters()) { int[] scopePos = method.getScopedParameters(); ScopedObject[] array = scope.scope; @@ -139,7 +141,7 @@ static void closeStatic(HostMethodScope scope, SingleMethod method, BranchProfil } } for (int i = scopePos.length; i < array.length; i++) { - seenDynamicScope.enter(); + seenDynamicScope.enter(node); ScopedObject o = array[i]; // static scoped objects may be null on error of the host invocation if (o != null) { @@ -228,16 +230,17 @@ static final class ScopedObject implements TruffleObject { @ExportMessage Object send(Message message, Object[] args, + @Bind("$node") Node node, @CachedLibrary(limit = "5") ReflectionLibrary library, - @Cached BranchProfile seenError, - @Cached BranchProfile seenOther) throws Exception { + @Cached InlinedBranchProfile seenError, + @Cached InlinedBranchProfile seenOther) throws Exception { if (message.getLibraryClass() != InteropLibrary.class) { - seenOther.enter(); + seenOther.enter(node); return fallbackSend(message, args); } Object d = this.delegate; if (d == null) { - seenError.enter(); + seenError.enter(node); throw createReleaseException("Released objects cannot be accessed. " + "Avoid accessing scoped objects after their corresponding method has finished execution. " + "Alternatively, use Value.pin() to prevent a scoped object from being released after the host call completed."); diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostObject.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostObject.java index 8124dbb72374..57aabcce4897 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostObject.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostObject.java @@ -68,10 +68,13 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleStackTrace; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.exception.AbstractTruffleException; @@ -91,10 +94,11 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedExactClassProfile; import com.oracle.truffle.api.utilities.TriState; import com.oracle.truffle.host.HostContext.ToGuestValueNode; +import com.oracle.truffle.host.HostContextFactory.ToGuestValueNodeGen; @ExportLibrary(InteropLibrary.class) @SuppressWarnings("unused") @@ -272,9 +276,10 @@ boolean isArrayElementReadable(long idx) { @ExportMessage String readArrayElement(long idx, - @Cached BranchProfile error) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(idx); } return keys[(int) idx]; @@ -292,22 +297,23 @@ Object getMembers(boolean includeInternal) throws UnsupportedMessageException { @ExportMessage Object readMember(String name, + @Bind("$node") Node node, @Shared("lookupField") @Cached LookupFieldNode lookupField, @Shared("readField") @Cached ReadFieldNode readField, @Shared("lookupMethod") @Cached LookupMethodNode lookupMethod, @Cached LookupInnerClassNode lookupInnerClass, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException, UnknownIdentifierException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException, UnknownIdentifierException { if (isNull()) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } boolean isStatic = isStaticClass(); Class lookupClass = getLookupClass(); - HostFieldDesc foundField = lookupField.execute(this, lookupClass, name, isStatic); + HostFieldDesc foundField = lookupField.execute(node, this, lookupClass, name, isStatic); if (foundField != null) { - return readField.execute(foundField, this); + return readField.execute(node, foundField, this); } - HostMethodDesc foundMethod = lookupMethod.execute(this, lookupClass, name, isStatic); + HostMethodDesc foundMethod = lookupMethod.execute(node, this, lookupClass, name, isStatic); if (foundMethod != null) { return new HostFunction(foundMethod, this.obj, this.context); } @@ -317,7 +323,7 @@ Object readMember(String name, if (HostInteropReflect.STATIC_TO_CLASS.equals(name)) { return HostObject.forClass(lookupClass, context); } - Class innerclass = lookupInnerClassNode.execute(lookupClass, name); + Class innerclass = lookupInnerClassNode.execute(node, lookupClass, name); if (innerclass != null) { return HostObject.forStaticClass(innerclass, context); } @@ -326,7 +332,7 @@ Object readMember(String name, } else if (HostInteropReflect.ADAPTER_SUPER_MEMBER.equals(name) && HostAdapterFactory.isAdapterInstance(this.obj)) { return HostAdapterFactory.getSuperAdapter(this); } - error.enter(); + error.enter(node); throw UnknownIdentifierException.create(name); } @@ -383,24 +389,25 @@ boolean isMemberInsertable(String member) { @ExportMessage void writeMember(String member, Object value, + @Bind("$node") Node node, @Shared("lookupField") @Cached LookupFieldNode lookupField, @Cached WriteFieldNode writeField, - @Shared("error") @Cached BranchProfile error) + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException, UnknownIdentifierException, UnsupportedTypeException { if (isNull()) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } - HostFieldDesc f = lookupField.execute(this, getLookupClass(), member, isStaticClass()); + HostFieldDesc f = lookupField.execute(node, this, getLookupClass(), member, isStaticClass()); if (f == null) { - error.enter(); + error.enter(node); throw UnknownIdentifierException.create(member); } try { - writeField.execute(f, this, value); + writeField.execute(node, f, this, value); } catch (ClassCastException | NullPointerException e) { // conversion failed by ToJavaNode - error.enter(); + error.enter(node); throw UnsupportedTypeException.create(new Object[]{value}, getMessage(e)); } } @@ -434,14 +441,15 @@ static boolean doUncached(HostObject receiver, String name) { @ExportMessage Object invokeMember(String name, Object[] args, + @Bind("$node") Node node, @Shared("lookupMethod") @Cached LookupMethodNode lookupMethod, @Shared("hostExecute") @Cached HostExecuteNode executeMethod, @Shared("lookupField") @Cached LookupFieldNode lookupField, @Shared("readField") @Cached ReadFieldNode readField, @CachedLibrary(limit = "5") InteropLibrary fieldValues, - @Shared("error") @Cached BranchProfile error) throws UnsupportedTypeException, ArityException, UnsupportedMessageException, UnknownIdentifierException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedTypeException, ArityException, UnsupportedMessageException, UnknownIdentifierException { if (isNull()) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -449,54 +457,58 @@ Object invokeMember(String name, Object[] args, Class lookupClass = getLookupClass(); // (1) look for a method; if found, invoke it on obj. - HostMethodDesc foundMethod = lookupMethod.execute(this, lookupClass, name, isStatic); + HostMethodDesc foundMethod = lookupMethod.execute(node, this, lookupClass, name, isStatic); if (foundMethod != null) { - return executeMethod.execute(foundMethod, obj, args, context); + return executeMethod.execute(node, foundMethod, obj, args, context); } // (2) look for a field; if found, read its value and if that IsExecutable, Execute it. - HostFieldDesc foundField = lookupField.execute(this, lookupClass, name, isStatic); + HostFieldDesc foundField = lookupField.execute(node, this, lookupClass, name, isStatic); if (foundField != null) { - Object fieldValue = readField.execute(foundField, this); + Object fieldValue = readField.execute(node, foundField, this); if (fieldValues.isExecutable(fieldValue)) { return fieldValues.execute(fieldValue, args); } } - error.enter(); + error.enter(node); throw UnknownIdentifierException.create(name); } @ExportMessage static class IsArrayElementReadable { - @Specialization(guards = "isArray.execute(receiver)", limit = "1") + @Specialization(guards = "isArray.execute(node, receiver)", limit = "1") static boolean doArray(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray) { long size = Array.getLength(receiver.obj); return index >= 0 && index < size; } - @Specialization(guards = "isList.execute(receiver)", limit = "1") + @Specialization(guards = "isList.execute(node, receiver)", limit = "1") static boolean doList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { long size = GuestToHostCalls.getListSize(receiver); return index >= 0 && index < size; } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = "isMapEntry.execute(receiver)", limit = "1") + @Specialization(guards = "isMapEntry.execute(node, receiver)", limit = "1") static boolean doMapEntry(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { return index >= 0 && index < 2; } - @Specialization(guards = {"!isList.execute(receiver)", "!isArray.execute(receiver)", "!isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isList.execute(node, receiver)", "!isArray.execute(node, receiver)", "!isMapEntry.execute(node, receiver)"}, limit = "1") static boolean doNotArrayOrList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { @@ -507,34 +519,38 @@ static boolean doNotArrayOrList(HostObject receiver, long index, @ExportMessage static class IsArrayElementModifiable { - @Specialization(guards = "isArray.execute(receiver)", limit = "1") + @Specialization(guards = "isArray.execute(node, receiver)", limit = "1") static boolean doArray(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray) { long size = Array.getLength(receiver.obj); return index >= 0 && index < size; } - @Specialization(guards = "isList.execute(receiver)", limit = "1") + @Specialization(guards = "isList.execute(node, receiver)", limit = "1") static boolean doList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { long size = GuestToHostCalls.getListSize(receiver); return index >= 0 && index < size; } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = "isMapEntry.execute(receiver)", limit = "1") + @Specialization(guards = "isMapEntry.execute(node, receiver)", limit = "1") static boolean doMapEntry(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { return index == 1; } - @Specialization(guards = {"!isList.execute(receiver)", "!isArray.execute(receiver)", "!isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isList.execute(node, receiver)", "!isArray.execute(node, receiver)", "!isMapEntry.execute(node, receiver)"}, limit = "1") static boolean doNotArrayOrList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { @@ -543,12 +559,14 @@ static boolean doNotArrayOrList(HostObject receiver, long index, } @ExportMessage - boolean isArrayElementInsertable(long index, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) { + boolean isArrayElementInsertable(long index, + @Bind("$node") Node node, + @Shared("isList") @Cached IsListNode isList, + @Shared("error") @Cached InlinedBranchProfile error) { try { - return isList.execute(this) && GuestToHostCalls.getListSize(this) == index; + return isList.execute(node, this) && GuestToHostCalls.getListSize(this) == index; } catch (Throwable t) { - error.enter(); + error.enter(node); throw context.hostToGuestException(t); } } @@ -556,23 +574,24 @@ boolean isArrayElementInsertable(long index, @Shared("isList") @Cached IsListNod @ExportMessage static class WriteArrayElement { - @Specialization(guards = {"isArray.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isArray.execute(node, receiver)"}, limit = "1") @SuppressWarnings("unchecked") static void doArray(HostObject receiver, long index, Object value, - @Shared("toHost") @Cached HostToTypeNode toHostNode, + @Bind("$node") Node node, + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHostNode, @Shared("isArray") @Cached IsArrayNode isArray, @Cached ArraySet arraySet, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } Object obj = receiver.obj; Object javaValue; try { - javaValue = toHostNode.execute(receiver.context, value, obj.getClass().getComponentType(), null, true); + javaValue = toHostNode.execute(node, receiver.context, value, obj.getClass().getComponentType(), null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnsupportedTypeException.create(new Object[]{value}, getMessage(ee)); @@ -580,28 +599,29 @@ static void doArray(HostObject receiver, long index, Object value, throw e; } try { - arraySet.execute(obj, (int) index, javaValue); + arraySet.execute(node, obj, (int) index, javaValue); } catch (ArrayIndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } } - @Specialization(guards = {"isList.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isList.execute(node, receiver)"}, limit = "1") @SuppressWarnings("unchecked") static void doList(HostObject receiver, long index, Object value, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("toHost") @Cached HostToTypeNode toHostNode, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHostNode, + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } Object javaValue; try { - javaValue = toHostNode.execute(receiver.context, value, Object.class, null, true); + javaValue = toHostNode.execute(node, receiver.context, value, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnsupportedTypeException.create(new Object[]{value}, getMessage(ee)); @@ -611,26 +631,27 @@ static void doList(HostObject receiver, long index, Object value, try { GuestToHostCalls.setListElement(receiver, index, javaValue); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = {"isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isMapEntry.execute(node, receiver)"}, limit = "1") @SuppressWarnings("unchecked") static void doMapEntry(HostObject receiver, long index, Object value, + @Bind("$node") Node node, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry, - @Shared("toHost") @Cached HostToTypeNode toHostNode, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHostNode, + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException, UnsupportedTypeException { if (index == 1) { Object hostValue; try { - hostValue = toHostNode.execute(receiver.context, value, Object.class, null, true); + hostValue = toHostNode.execute(node, receiver.context, value, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnsupportedTypeException.create(new Object[]{value}, getMessage(ee)); @@ -640,7 +661,7 @@ static void doMapEntry(HostObject receiver, long index, Object value, try { GuestToHostCalls.setMapEntryValue(receiver, hostValue); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } else { @@ -649,8 +670,9 @@ static void doMapEntry(HostObject receiver, long index, Object value, } @SuppressWarnings("unused") - @Specialization(guards = {"!isList.execute(receiver)", "!isArray.execute(receiver)", "!isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isList.execute(node, receiver)", "!isArray.execute(node, receiver)", "!isMapEntry.execute(node, receiver)"}, limit = "1") static void doNotArrayOrList(HostObject receiver, long index, Object value, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) throws UnsupportedMessageException { @@ -662,20 +684,22 @@ static void doNotArrayOrList(HostObject receiver, long index, Object value, @ExportMessage static class IsArrayElementRemovable { - @Specialization(guards = "isList.execute(receiver)", limit = "1") + @Specialization(guards = "isList.execute(node, receiver)", limit = "1") static boolean doList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { return index >= 0 && index < GuestToHostCalls.getListSize(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = "!isList.execute(receiver)", limit = "1") + @Specialization(guards = "!isList.execute(node, receiver)", limit = "1") static boolean doOther(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList) { return false; } @@ -684,116 +708,124 @@ static boolean doOther(HostObject receiver, long index, @ExportMessage static class RemoveArrayElement { - @Specialization(guards = "isList.execute(receiver)", limit = "1") + @Specialization(guards = "isList.execute(node, receiver)", limit = "1") static void doList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException { + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } try { GuestToHostCalls.removeListElement(receiver, index); } catch (IndexOutOfBoundsException outOfBounds) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = "!isList.execute(receiver)", limit = "1") + @Specialization(guards = "!isList.execute(node, receiver)", limit = "1") static void doOther(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @ExportMessage - boolean hasArrayElements(@Shared("isList") @Cached IsListNode isList, + boolean hasArrayElements( + @Bind("$node") Node node, + @Shared("isList") @Cached IsListNode isList, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { - return isList.execute(this) || isArray.execute(this) || isMapEntry.execute(this); + return isList.execute(node, this) || isArray.execute(node, this) || isMapEntry.execute(node, this); } @ExportMessage abstract static class ReadArrayElement { - @Specialization(guards = {"isArray.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isArray.execute(node, receiver)"}, limit = "1") protected static Object doArray(HostObject receiver, long index, + @Bind("$node") Node node, @Cached ArrayGet arrayGet, @Shared("isArray") @Cached IsArrayNode isArray, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } Object obj = receiver.obj; Object val = null; try { - val = arrayGet.execute(obj, (int) index); + val = arrayGet.execute(node, obj, (int) index); } catch (ArrayIndexOutOfBoundsException outOfBounds) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } - return toGuest.execute(receiver.context, val); + return toGuest.execute(node, receiver.context, val); } @TruffleBoundary - @Specialization(guards = {"isList.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isList.execute(node, receiver)"}, limit = "1") protected static Object doList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } Object hostValue; try { hostValue = GuestToHostCalls.readListElement(receiver, index); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } - return toGuest.execute(receiver.context, hostValue); + return toGuest.execute(node, receiver.context, hostValue); } - @Specialization(guards = "isMapEntry.execute(receiver)", limit = "1") + @Specialization(guards = "isMapEntry.execute(node, receiver)", limit = "1") protected static Object doMapEntry(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) throws InvalidArrayIndexException { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { Object hostResult; if (index == 0L) { try { hostResult = GuestToHostCalls.getMapEntryKey(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } else if (index == 1L) { try { hostResult = GuestToHostCalls.getMapEntryValue(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } else { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } - return toGuest.execute(receiver.context, hostResult); + return toGuest.execute(node, receiver.context, hostResult); } @SuppressWarnings("unused") - @Specialization(guards = {"!isArray.execute(receiver)", "!isList.execute(receiver)", "!isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isArray.execute(node, receiver)", "!isList.execute(node, receiver)", "!isMapEntry.execute(node, receiver)"}, limit = "1") protected static Object doNotArrayOrList(HostObject receiver, long index, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isList") @Cached IsListNode isList, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) throws UnsupportedMessageException { @@ -805,32 +837,36 @@ protected static Object doNotArrayOrList(HostObject receiver, long index, @ExportMessage abstract static class GetArraySize { - @Specialization(guards = {"isArray.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isArray.execute(node, receiver)"}, limit = "1") protected static long doArray(HostObject receiver, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray) { return Array.getLength(receiver.obj); } - @Specialization(guards = {"isList.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isList.execute(node, receiver)"}, limit = "1") protected static long doList(HostObject receiver, + @Bind("$node") Node node, @Shared("isList") @Cached IsListNode isList, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { return GuestToHostCalls.getListSize(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } - @Specialization(guards = "isMapEntry.execute(receiver)", limit = "1") + @Specialization(guards = "isMapEntry.execute(node, receiver)", limit = "1") protected static long doMapEntry(HostObject receiver, + @Bind("$node") Node node, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) { return 2; } - @Specialization(guards = {"!isArray.execute(receiver)", "!isList.execute(receiver)", "!isMapEntry.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isArray.execute(node, receiver)", "!isList.execute(node, receiver)", "!isMapEntry.execute(node, receiver)"}, limit = "1") protected static long doNotArrayOrList(HostObject receiver, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isList") @Cached IsListNode isList, @Shared("isMapEntry") @Cached IsMapEntryNode isMapEntry) throws UnsupportedMessageException { @@ -842,17 +878,22 @@ protected static long doNotArrayOrList(HostObject receiver, // region Buffer Messages @ExportMessage - boolean hasBufferElements(@Shared("isBuffer") @Cached IsBufferNode isBuffer) { - return isBuffer.execute(this); + boolean hasBufferElements( + @Bind("$node") Node node, + @Shared("isBuffer") @Cached IsBufferNode isBuffer) { + return isBuffer.execute(node, this); } @ExportMessage - boolean isBufferWritable(@Shared("isBuffer") @Cached IsBufferNode isBuffer, @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { - if (isBuffer.execute(this)) { + boolean isBufferWritable( + @Bind("$node") Node node, + @Shared("isBuffer") @Cached IsBufferNode isBuffer, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { + if (isBuffer.execute(node, this)) { final ByteBuffer buffer = (ByteBuffer) obj; return isPEFriendlyBuffer(buffer) ? !buffer.isReadOnly() : isBufferWritableBoundary(buffer); } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -862,12 +903,15 @@ private static boolean isBufferWritableBoundary(ByteBuffer buffer) { } @ExportMessage - long getBufferSize(@Shared("isBuffer") @Cached IsBufferNode isBuffer, @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { - if (isBuffer.execute(this)) { + long getBufferSize( + @Bind("$node") Node node, + @Shared("isBuffer") @Cached IsBufferNode isBuffer, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { + if (isBuffer.execute(node, this)) { final ByteBuffer buffer = (ByteBuffer) obj; return isPEFriendlyBuffer(buffer) ? buffer.limit() : getBufferSizeBoundary(buffer); } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -886,22 +930,23 @@ private static boolean isPEFriendlyBuffer(ByteBuffer buffer) { @ExportMessage public byte readBufferByte(long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Byte.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); return isPEFriendlyBuffer(buffer) ? buffer.get((int) index) : getBufferByteBoundary(buffer, (int) index); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Byte.BYTES); } } @@ -913,29 +958,30 @@ private static byte getBufferByteBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferByte(long index, byte value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Byte.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); if (isPEFriendlyBuffer(buffer)) { buffer.put((int) index, value); } else { putBufferByteBoundary(buffer, (int) index, value); } } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Byte.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -947,26 +993,27 @@ private static void putBufferByteBoundary(ByteBuffer buffer, int index, byte val @ExportMessage public short readBufferShort(ByteOrder order, long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Short.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); final short result = isPEFriendlyBuffer(buffer) ? buffer.getShort((int) index) : getBufferShortBoundary(buffer, (int) index); buffer.order(originalOrder); return result; } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Short.BYTES); } } @@ -978,19 +1025,20 @@ private static short getBufferShortBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferShort(ByteOrder order, long index, short value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Short.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); if (isPEFriendlyBuffer(buffer)) { @@ -1000,10 +1048,10 @@ public void writeBufferShort(ByteOrder order, long index, short value, } buffer.order(originalOrder); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Short.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1015,26 +1063,27 @@ private static void putBufferShortBoundary(ByteBuffer buffer, int index, short v @ExportMessage public int readBufferInt(ByteOrder order, long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Integer.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); final int result = isPEFriendlyBuffer(buffer) ? buffer.getInt((int) index) : getBufferIntBoundary(buffer, (int) index); buffer.order(originalOrder); return result; } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Integer.BYTES); } } @@ -1046,19 +1095,20 @@ private static int getBufferIntBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferInt(ByteOrder order, long index, int value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Integer.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); if (isPEFriendlyBuffer(buffer)) { @@ -1068,10 +1118,10 @@ public void writeBufferInt(ByteOrder order, long index, int value, } buffer.order(originalOrder); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Integer.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1083,26 +1133,27 @@ private static void putBufferIntBoundary(ByteBuffer buffer, int index, int value @ExportMessage public long readBufferLong(ByteOrder order, long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Long.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); final long result = isPEFriendlyBuffer(buffer) ? buffer.getLong((int) index) : getBufferLongBoundary(buffer, (int) index); buffer.order(originalOrder); return result; } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Long.BYTES); } } @@ -1114,19 +1165,20 @@ private static long getBufferLongBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferLong(ByteOrder order, long index, long value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Long.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); if (isPEFriendlyBuffer(buffer)) { @@ -1136,10 +1188,10 @@ public void writeBufferLong(ByteOrder order, long index, long value, } buffer.order(originalOrder); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Long.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1151,26 +1203,27 @@ private static void putBufferLongBoundary(ByteBuffer buffer, int index, long val @ExportMessage public float readBufferFloat(ByteOrder order, long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Float.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); final float result = isPEFriendlyBuffer(buffer) ? buffer.getFloat((int) index) : getBufferFloatBoundary(buffer, (int) index); buffer.order(originalOrder); return result; } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Float.BYTES); } } @@ -1182,19 +1235,20 @@ private static float getBufferFloatBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferFloat(ByteOrder order, long index, float value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Float.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); if (isPEFriendlyBuffer(buffer)) { @@ -1204,10 +1258,10 @@ public void writeBufferFloat(ByteOrder order, long index, float value, } buffer.order(originalOrder); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Float.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1219,26 +1273,27 @@ private static void putBufferFloatBoundary(ByteBuffer buffer, int index, float v @ExportMessage public double readBufferDouble(ByteOrder order, long index, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws UnsupportedMessageException, InvalidBufferOffsetException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Double.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); final double result = isPEFriendlyBuffer(buffer) ? buffer.getDouble((int) index) : getBufferDoubleBoundary(buffer, (int) index); buffer.order(originalOrder); return result; } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Double.BYTES); } } @@ -1250,19 +1305,20 @@ private static double getBufferDoubleBoundary(ByteBuffer buffer, int index) { @ExportMessage public void writeBufferDouble(ByteOrder order, long index, double value, + @Bind("$node") Node node, @Shared("isBuffer") @Cached IsBufferNode isBuffer, - @Shared("error") @Cached BranchProfile error, - @Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { - if (!isBuffer.execute(this)) { - error.enter(); + @Shared("error") @Cached InlinedBranchProfile error, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) throws InvalidBufferOffsetException, UnsupportedMessageException { + if (!isBuffer.execute(node, this)) { + error.enter(node); throw UnsupportedMessageException.create(); } if (index < 0 || Integer.MAX_VALUE < index) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Double.BYTES); } try { - final ByteBuffer buffer = (ByteBuffer) classProfile.profile(obj); + final ByteBuffer buffer = (ByteBuffer) classProfile.profile(node, obj); final ByteOrder originalOrder = buffer.order(); buffer.order(order); if (isPEFriendlyBuffer(buffer)) { @@ -1272,10 +1328,10 @@ public void writeBufferDouble(ByteOrder order, long index, double value, } buffer.order(originalOrder); } catch (IndexOutOfBoundsException e) { - error.enter(); + error.enter(node); throw InvalidBufferOffsetException.create(index, Double.BYTES); } catch (ReadOnlyBufferException e) { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1308,28 +1364,32 @@ static boolean doArrayCached(@SuppressWarnings("unused") HostObject receiver) { @Specialization(guards = "receiver.isDefaultClass()") static boolean doObjectCached(HostObject receiver, + @Bind("$node") Node node, @Shared("lookupConstructor") @Cached LookupConstructorNode lookupConstructor) { - return lookupConstructor.execute(receiver, receiver.asClass()) != null; + return lookupConstructor.execute(node, receiver, receiver.asClass()) != null; } } @ExportMessage - boolean isExecutable(@Shared("lookupFunctionalMethod") @Cached LookupFunctionalMethodNode lookupMethod) { - return !isNull() && !isClass() && lookupMethod.execute(this, getLookupClass()) != null; + boolean isExecutable( + @Bind("$node") Node node, + @Shared("lookupFunctionalMethod") @Cached LookupFunctionalMethodNode lookupMethod) { + return !isNull() && !isClass() && lookupMethod.execute(node, this, getLookupClass()) != null; } @ExportMessage Object execute(Object[] args, + @Bind("$node") Node node, @Shared("hostExecute") @Cached HostExecuteNode doExecute, @Shared("lookupFunctionalMethod") @Cached LookupFunctionalMethodNode lookupMethod, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { if (!isNull() && !isClass()) { - HostMethodDesc method = lookupMethod.execute(this, getLookupClass()); + HostMethodDesc method = lookupMethod.execute(node, this, getLookupClass()); if (method != null) { - return doExecute.execute(method, obj, args, context); + return doExecute.execute(node, method, obj, args, context); } } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -1344,10 +1404,11 @@ static Object doUnsupported(HostObject receiver, Object[] args) throws Unsupport @Specialization(guards = "receiver.isArrayClass()") static Object doArrayCached(HostObject receiver, Object[] args, + @Bind("$node") Node node, @CachedLibrary(limit = "1") InteropLibrary indexes, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { if (args.length != 1) { - error.enter(); + error.enter(node); throw ArityException.create(1, 1, args.length); } Object arg0 = args[0]; @@ -1355,7 +1416,7 @@ static Object doArrayCached(HostObject receiver, Object[] args, if (indexes.fitsInInt(arg0)) { length = indexes.asInt(arg0); } else { - error.enter(); + error.enter(node); throw UnsupportedTypeException.create(args); } Object array = Array.newInstance(receiver.asClass().getComponentType(), length); @@ -1364,26 +1425,28 @@ static Object doArrayCached(HostObject receiver, Object[] args, @Specialization(guards = "receiver.isDefaultClass()") static Object doObjectCached(HostObject receiver, Object[] arguments, + @Bind("$node") Node node, @Shared("lookupConstructor") @Cached LookupConstructorNode lookupConstructor, @Shared("hostExecute") @Cached HostExecuteNode executeMethod, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { assert !receiver.isArrayClass(); - HostMethodDesc constructor = lookupConstructor.execute(receiver, receiver.asClass()); + HostMethodDesc constructor = lookupConstructor.execute(node, receiver, receiver.asClass()); if (constructor != null) { - return executeMethod.execute(constructor, null, arguments, receiver.context); + return executeMethod.execute(node, constructor, null, arguments, receiver.context); } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - boolean isNumber(@Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) { + boolean isNumber(@Shared("classProfile") @Bind("$node") Node node, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) { if (isNull()) { return false; } - Class c = classProfile.profile(obj).getClass(); + Class c = classProfile.profile(node, obj).getClass(); return c == Byte.class || c == Short.class || c == Integer.class || c == Long.class || c == Float.class || c == Double.class; } @@ -1452,94 +1515,103 @@ boolean fitsInDouble(@CachedLibrary("this") InteropLibrary thisLibrary, } @ExportMessage - byte asByte(@CachedLibrary("this") InteropLibrary thisLibrary, + byte asByte(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asByte(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage short asShort(@CachedLibrary("this") InteropLibrary thisLibrary, + @Bind("$node") Node node, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asShort(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - int asInt(@CachedLibrary("this") InteropLibrary thisLibrary, + int asInt(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asInt(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - long asLong(@CachedLibrary("this") InteropLibrary thisLibrary, + long asLong(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asLong(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - float asFloat(@CachedLibrary("this") InteropLibrary thisLibrary, + float asFloat(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asFloat(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - double asDouble(@CachedLibrary("this") InteropLibrary thisLibrary, + double asDouble(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary numbers, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isNumber(this)) { return numbers.asDouble(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @ExportMessage - boolean isString(@Shared("classProfile") @Cached("createClassProfile()") ValueProfile classProfile) { + boolean isString( + @Bind("$node") Node node, + @Shared("classProfile") @Cached InlinedExactClassProfile classProfile) { if (isNull()) { return false; } - Class c = classProfile.profile(obj).getClass(); + Class c = classProfile.profile(node, obj).getClass(); return c == String.class || c == Character.class; } @ExportMessage - String asString(@CachedLibrary("this") InteropLibrary thisLibrary, + String asString(@Bind("$node") Node node, + @CachedLibrary("this") InteropLibrary thisLibrary, @Shared("numbers") @CachedLibrary(limit = "LIMIT") InteropLibrary strings, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (thisLibrary.isString(this)) { return strings.asString(obj); } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1553,11 +1625,13 @@ boolean isBoolean() { } @ExportMessage - boolean asBoolean(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + boolean asBoolean( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (isBoolean()) { return (boolean) obj; } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -1670,27 +1744,33 @@ boolean isException() { } @ExportMessage - ExceptionType getExceptionType(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + ExceptionType getExceptionType( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (isException()) { return obj instanceof InterruptedException ? ExceptionType.INTERRUPT : ExceptionType.RUNTIME_ERROR; } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @ExportMessage - boolean isExceptionIncompleteSource(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + boolean isExceptionIncompleteSource( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (isException()) { return false; } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @ExportMessage @SuppressWarnings("static-method") - int getExceptionExitStatus(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { - error.enter(); + int getExceptionExitStatus( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { + error.enter(node); throw UnsupportedMessageException.create(); } @@ -1702,12 +1782,14 @@ boolean hasExceptionMessage() { @ExportMessage @TruffleBoundary - Object getExceptionMessage(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + Object getExceptionMessage( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { String message = isException() ? ((Throwable) obj).getMessage() : null; if (message != null) { return message; } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -1745,7 +1827,9 @@ Object getExceptionStackTrace() throws UnsupportedMessageException { } @ExportMessage - RuntimeException throwException(@Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + RuntimeException throwException( + @Bind("$node") Node node, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (isException()) { HostException ex = (HostException) extraInfo; if (ex == null) { @@ -1753,7 +1837,7 @@ RuntimeException throwException(@Shared("error") @Cached BranchProfile error) th } throw ex; } - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } @@ -1851,19 +1935,22 @@ private static String arrayToString(HostContext context, Object array, int level } @ExportMessage - boolean hasIterator(@Shared("isIterable") @Cached IsIterableNode isIterable, + boolean hasIterator( + @Bind("$node") Node node, + @Shared("isIterable") @Cached IsIterableNode isIterable, @Shared("isArray") @Cached IsArrayNode isArray) { - return isIterable.execute(this) || isArray.execute(this); + return isIterable.execute(node, this) || isArray.execute(node, this); } @ExportMessage abstract static class GetIterator { - @Specialization(guards = {"isArray.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isArray.execute(node, receiver)"}, limit = "1") protected static Object doArray(HostObject receiver, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray, - @Shared("toGuest") @Cached ToGuestValueNode toGuest) { - return toGuest.execute(receiver.context, arrayIteratorImpl(receiver)); + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest) { + return toGuest.execute(node, receiver.context, arrayIteratorImpl(receiver)); } @TruffleBoundary @@ -1871,24 +1958,26 @@ private static Object arrayIteratorImpl(Object receiver) { return HostAccessor.INTEROP.createDefaultIterator(receiver); } - @Specialization(guards = {"isIterable.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isIterable.execute(node, receiver)"}, limit = "1") protected static Object doIterable(HostObject receiver, + @Bind("$node") Node node, @Shared("isIterable") @Cached IsIterableNode isIterable, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) { Object hostValue; try { hostValue = GuestToHostCalls.getIterator(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } - return toGuest.execute(receiver.context, hostValue); + return toGuest.execute(node, receiver.context, hostValue); } @SuppressWarnings("unused") - @Specialization(guards = {"!isArray.execute(receiver)", "!isIterable.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isArray.execute(node, receiver)", "!isIterable.execute(node, receiver)"}, limit = "1") protected static Object doNotArrayOrIterable(HostObject receiver, + @Bind("$node") Node node, @Shared("isArray") @Cached IsArrayNode isArray, @Shared("isIterable") @Cached IsIterableNode isIterable) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); @@ -1896,28 +1985,32 @@ protected static Object doNotArrayOrIterable(HostObject receiver, } @ExportMessage - boolean isIterator(@Shared("isIterator") @Cached IsIteratorNode isIterator) { - return isIterator.execute(this); + boolean isIterator( + @Bind("$node") Node node, + @Shared("isIterator") @Cached IsIteratorNode isIterator) { + return isIterator.execute(node, this); } @ExportMessage abstract static class HasIteratorNextElement { - @Specialization(guards = {"isIterator.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isIterator.execute(node, receiver)"}, limit = "1") protected static boolean doIterator(HostObject receiver, + @Bind("$node") Node node, @Shared("isIterator") @Cached IsIteratorNode isIterator, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { return GuestToHostCalls.hasIteratorNext(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } @SuppressWarnings("unused") - @Specialization(guards = {"!isIterator.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isIterator.execute(node, receiver)"}, limit = "1") protected static boolean doNotIterator(HostObject receiver, + @Bind("$node") Node node, @Shared("isIterator") @Cached IsIteratorNode isIterator) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } @@ -1926,56 +2019,63 @@ protected static boolean doNotIterator(HostObject receiver, @ExportMessage abstract static class GetIteratorNextElement { - @Specialization(guards = {"isIterator.execute(receiver)"}, limit = "1") + @Specialization(guards = {"isIterator.execute(node, receiver)"}, limit = "1") protected static Object doIterator(HostObject receiver, + @Bind("$node") Node node, @Shared("isIterator") @Cached IsIteratorNode isIterator, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error, - @Exclusive @Cached BranchProfile stopIteration) throws StopIterationException { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error, + @Exclusive @Cached InlinedBranchProfile stopIteration) throws StopIterationException { Object next; try { next = GuestToHostCalls.getIteratorNext(receiver); } catch (NoSuchElementException e) { - stopIteration.enter(); + stopIteration.enter(node); throw StopIterationException.create(); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } - return toGuest.execute(receiver.context, next); + return toGuest.execute(node, receiver.context, next); } @SuppressWarnings("unused") - @Specialization(guards = {"!isIterator.execute(receiver)"}, limit = "1") + @Specialization(guards = {"!isIterator.execute(node, receiver)"}, limit = "1") protected static Object doNotIterator(HostObject receiver, + @Bind("$node") Node node, @Shared("isIterator") @Cached IsIteratorNode isIterator) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @ExportMessage - boolean hasHashEntries(@Shared("isMap") @Cached IsMapNode isMap) { - return isMap.execute(this); + boolean hasHashEntries( + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) { + return isMap.execute(node, this); } @ExportMessage abstract static class GetHashSize { - @Specialization(guards = "isMap.execute(receiver)", limit = "1") + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") protected static long doMap(HostObject receiver, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, - @Shared("error") @Cached BranchProfile error) { + @Shared("error") @Cached InlinedBranchProfile error) { try { return GuestToHostCalls.getMapSize(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static long doNotMap(HostObject receiver, @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static long doNotMap(HostObject receiver, + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @@ -1984,9 +2084,10 @@ protected static long doNotMap(HostObject receiver, @Shared("isMap") @Cached IsM @ExportMessage(name = "isHashEntryModifiable") @ExportMessage(name = "isHashEntryRemovable") boolean isHashEntryReadable(Object key, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, @Shared("containsKey") @Cached ContainsKeyNode containsKey) { - return isMap.execute(this) && containsKey.execute(this, key); + return isMap.execute(node, this) && containsKey.execute(node, this, key); } @ExportMessage @@ -1995,17 +2096,18 @@ abstract static class ReadHashValue { private static final Object UNDEFINED = new Object(); @SuppressWarnings("unchecked") - @Specialization(guards = "isMap.execute(receiver)", limit = "1") + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") protected static Object doMap(HostObject receiver, Object key, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, - @Shared("toHost") @Cached HostToTypeNode toHost, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) throws UnknownKeyException { + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHost, + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) throws UnknownKeyException { Object hostKey; try { - hostKey = toHost.execute(receiver.context, key, Object.class, null, true); + hostKey = toHost.execute(node, receiver.context, key, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnknownKeyException.create(key); @@ -2016,46 +2118,50 @@ protected static Object doMap(HostObject receiver, Object key, try { hostResult = GuestToHostCalls.getMapValue(receiver, hostKey, UNDEFINED); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } if (hostResult == UNDEFINED) { - error.enter(); + error.enter(node); throw UnknownKeyException.create(key); } - return toGuest.execute(receiver.context, hostResult); + return toGuest.execute(node, receiver.context, hostResult); } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static Object doNotMap(HostObject receiver, Object key, @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static Object doNotMap(HostObject receiver, Object key, + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @ExportMessage boolean isHashEntryInsertable(Object key, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, @Shared("containsKey") @Cached ContainsKeyNode containsKey) { - return isMap.execute(this) && !containsKey.execute(this, key); + return isMap.execute(node, this) && !containsKey.execute(node, this, key); } @ExportMessage abstract static class WriteHashEntry { @SuppressWarnings("unchecked") - @Specialization(guards = "isMap.execute(receiver)", limit = "1") + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") protected static void doMap(HostObject receiver, Object key, Object value, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, - @Shared("toHost") @Cached HostToTypeNode toHost, - @Shared("error") @Cached BranchProfile error) throws UnsupportedTypeException { + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHost, + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedTypeException { Object hostKey; Object hostValue; try { - hostKey = toHost.execute(receiver.context, key, Object.class, null, true); + hostKey = toHost.execute(node, receiver.context, key, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnsupportedTypeException.create(new Object[]{key}, getMessage(ee)); @@ -2064,9 +2170,9 @@ protected static void doMap(HostObject receiver, Object key, Object value, } try { - hostValue = toHost.execute(receiver.context, value, Object.class, null, true); + hostValue = toHost.execute(node, receiver.context, value, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnsupportedTypeException.create(new Object[]{value}, getMessage(ee)); @@ -2076,14 +2182,16 @@ protected static void doMap(HostObject receiver, Object key, Object value, try { GuestToHostCalls.putMapValue(receiver, hostKey, hostValue); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static void doNotMap(HostObject receiver, Object key, Object value, @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static void doNotMap(HostObject receiver, Object key, Object value, + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @@ -2092,16 +2200,17 @@ protected static void doNotMap(HostObject receiver, Object key, Object value, @S abstract static class RemoveHashEntry { @SuppressWarnings("unchecked") - @Specialization(guards = "isMap.execute(receiver)", limit = "1") + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") protected static void doMap(HostObject receiver, Object key, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, - @Shared("toHost") @Cached HostToTypeNode toHost, - @Shared("error") @Cached BranchProfile error) throws UnknownKeyException { + @Shared("toHost") @Cached(inline = true) HostToTypeNode toHost, + @Shared("error") @Cached InlinedBranchProfile error) throws UnknownKeyException { Object hostKey; try { - hostKey = toHost.execute(receiver.context, key, Object.class, null, true); + hostKey = toHost.execute(node, receiver.context, key, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { throw UnknownKeyException.create(key); @@ -2112,18 +2221,20 @@ protected static void doMap(HostObject receiver, Object key, try { removed = GuestToHostCalls.removeMapValue(receiver, hostKey); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } if (!removed) { - error.enter(); + error.enter(node); throw UnknownKeyException.create(key); } } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static void doNotMap(HostObject receiver, Object key, @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static void doNotMap(HostObject receiver, Object key, + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @@ -2132,24 +2243,27 @@ protected static void doNotMap(HostObject receiver, Object key, @Shared("isMap") abstract static class GetHashEntriesIterator { @SuppressWarnings("unchecked") - @Specialization(guards = "isMap.execute(receiver)", limit = "1") + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") protected static Object doMap(HostObject receiver, + @Bind("$node") Node node, @Shared("isMap") @Cached IsMapNode isMap, - @Shared("toGuest") @Cached ToGuestValueNode toGuest, - @Shared("error") @Cached BranchProfile error) { + @Shared("toGuest") @Cached(inline = true) ToGuestValueNode toGuest, + @Shared("error") @Cached InlinedBranchProfile error) { Object hostValue; try { hostValue = GuestToHostCalls.getEntriesIterator(receiver); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } - return toGuest.execute(receiver.context, hostValue); + return toGuest.execute(node, receiver.context, hostValue); } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static Object doNotMap(HostObject receiver, @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static Object doNotMap(HostObject receiver, + @Bind("$node") Node node, + @Shared("isMap") @Cached IsMapNode isMap) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } } @@ -2200,8 +2314,9 @@ Object getMetaSimpleName() throws UnsupportedMessageException { @ExportMessage @TruffleBoundary boolean isMetaInstance(Object other, + @Bind("$node") Node node, @CachedLibrary("this") InteropLibrary library, - @Shared("error") @Cached BranchProfile error) throws UnsupportedMessageException { + @Shared("error") @Cached InlinedBranchProfile error) throws UnsupportedMessageException { if (isClass()) { Class c = asClass(); HostLanguage language = context != null ? HostLanguage.get(library) : null; @@ -2216,7 +2331,7 @@ boolean isMetaInstance(Object other, Proxy otherHost = HostProxy.toProxyHostObject(language, other); return c.isInstance(otherHost); } else { - boolean canConvert = HostToTypeNode.canConvert(other, c, c, + boolean canConvert = HostToTypeNode.canConvert(null, other, c, c, HostToTypeNode.allowsImplementation(context, c), context, HostToTypeNode.LOWEST, InteropLibrary.getFactory().getUncached(other), @@ -2224,7 +2339,7 @@ boolean isMetaInstance(Object other, return canConvert; } } else { - error.enter(); + error.enter(node); throw UnsupportedMessageException.create(); } } @@ -2282,9 +2397,10 @@ boolean isArrayElementReadable(long idx) { @ExportMessage Object readArrayElement(long idx, - @Cached BranchProfile error) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(idx); } return types[(int) idx]; @@ -2366,9 +2482,11 @@ public String toString() { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class ArraySet extends Node { - protected abstract void execute(Object array, int index, Object value); + protected abstract void execute(Node node, Object array, int index, Object value); @Specialization static void doBoolean(boolean[] array, int index, boolean value) { @@ -2417,9 +2535,11 @@ static void doObject(Object[] array, int index, Object value) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class ArrayGet extends Node { - protected abstract Object execute(Object array, int index); + protected abstract Object execute(Node node, Object array, int index); @Specialization static boolean doBoolean(boolean[] array, int index) { @@ -2468,13 +2588,15 @@ static Object doObject(Object[] array, int index) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class LookupConstructorNode extends Node { static final int LIMIT = 3; LookupConstructorNode() { } - public abstract HostMethodDesc execute(HostObject receiver, Class clazz); + public abstract HostMethodDesc execute(Node node, HostObject receiver, Class clazz); @SuppressWarnings("unused") @Specialization(guards = {"clazz == cachedClazz"}, limit = "LIMIT") @@ -2493,13 +2615,15 @@ HostMethodDesc doUncached(HostObject receiver, Class clazz) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class LookupFieldNode extends Node { static final int LIMIT = 3; LookupFieldNode() { } - public abstract HostFieldDesc execute(HostObject receiver, Class clazz, String name, boolean onlyStatic); + public abstract HostFieldDesc execute(Node node, HostObject receiver, Class clazz, String name, boolean onlyStatic); @SuppressWarnings("unused") @Specialization(guards = {"onlyStatic == cachedStatic", "clazz == cachedClazz", "cachedName.equals(name)"}, limit = "LIMIT") @@ -2520,13 +2644,15 @@ HostFieldDesc doUncached(HostObject receiver, Class clazz, String name, boole } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class LookupFunctionalMethodNode extends Node { static final int LIMIT = 3; LookupFunctionalMethodNode() { } - public abstract HostMethodDesc execute(HostObject object, Class clazz); + public abstract HostMethodDesc execute(Node node, HostObject object, Class clazz); @SuppressWarnings("unused") @Specialization(guards = {"clazz == cachedClazz"}, limit = "LIMIT") @@ -2545,13 +2671,15 @@ static HostMethodDesc doUncached(HostObject object, Class clazz) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class LookupInnerClassNode extends Node { static final int LIMIT = 3; LookupInnerClassNode() { } - public abstract Class execute(Class outerclass, String name); + public abstract Class execute(Node node, Class outerclass, String name); @SuppressWarnings("unused") @Specialization(guards = {"clazz == cachedClazz", "cachedName.equals(name)"}, limit = "LIMIT") @@ -2571,13 +2699,15 @@ Class doUncached(Class clazz, String name) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class LookupMethodNode extends Node { static final int LIMIT = 3; LookupMethodNode() { } - public abstract HostMethodDesc execute(HostObject receiver, Class clazz, String name, boolean onlyStatic); + public abstract HostMethodDesc execute(Node node, HostObject receiver, Class clazz, String name, boolean onlyStatic); @SuppressWarnings("unused") @Specialization(guards = {"onlyStatic == cachedStatic", "clazz == cachedClazz", "cachedName.equals(name)"}, limit = "LIMIT") @@ -2598,56 +2728,59 @@ HostMethodDesc doUncached(HostObject receiver, Class clazz, String name, bool } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class ReadFieldNode extends Node { static final int LIMIT = 3; ReadFieldNode() { } - public abstract Object execute(HostFieldDesc field, HostObject object); + public abstract Object execute(Node node, HostFieldDesc field, HostObject object); @SuppressWarnings("unused") @Specialization(guards = {"field == cachedField"}, limit = "LIMIT") - static Object doCached(HostFieldDesc field, HostObject object, + static Object doCached(Node node, HostFieldDesc field, HostObject object, @Cached("field") HostFieldDesc cachedField, @Cached ToGuestValueNode toGuest) { Object val = cachedField.get(object.obj); - return toGuest.execute(object.context, val); + return toGuest.execute(node, object.context, val); } @Specialization(replaces = "doCached") @TruffleBoundary - static Object doUncached(HostFieldDesc field, HostObject object, - @Cached ToGuestValueNode toGuest) { + static Object doUncached(HostFieldDesc field, HostObject object) { Object val = field.get(object.obj); - return toGuest.execute(object.context, val); + return ToGuestValueNodeGen.getUncached().execute(null, object.context, val); } } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class WriteFieldNode extends Node { static final int LIMIT = 3; WriteFieldNode() { } - public abstract void execute(HostFieldDesc field, HostObject object, Object value) throws UnsupportedTypeException, UnknownIdentifierException; + public abstract void execute(Node node, HostFieldDesc field, HostObject object, Object value) throws UnsupportedTypeException, UnknownIdentifierException; @SuppressWarnings("unused") @Specialization(guards = {"field == cachedField"}, limit = "LIMIT") - static void doCached(HostFieldDesc field, HostObject object, Object rawValue, + static void doCached(Node node, HostFieldDesc field, HostObject object, Object rawValue, @Cached("field") HostFieldDesc cachedField, @Cached HostToTypeNode toHost, - @Cached BranchProfile error) throws UnsupportedTypeException, UnknownIdentifierException { + @Cached InlinedBranchProfile error) throws UnsupportedTypeException, UnknownIdentifierException { if (field.isFinal()) { - error.enter(); + error.enter(node); throw UnknownIdentifierException.create(field.getName()); } try { - Object value = toHost.execute(object.context, rawValue, cachedField.getType(), cachedField.getGenericType(), true); + Object value = toHost.execute(node, object.context, rawValue, cachedField.getType(), cachedField.getGenericType(), true); cachedField.set(object.obj, value); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(object, e); if (ee != null) { throw HostInteropErrors.unsupportedTypeException(rawValue, ee); @@ -2658,13 +2791,12 @@ static void doCached(HostFieldDesc field, HostObject object, Object rawValue, @Specialization(replaces = "doCached") @TruffleBoundary - static void doUncached(HostFieldDesc field, HostObject object, Object rawValue, - @Cached HostToTypeNode toHost) throws UnsupportedTypeException, UnknownIdentifierException { + static void doUncached(HostFieldDesc field, HostObject object, Object rawValue) throws UnsupportedTypeException, UnknownIdentifierException { if (field.isFinal()) { throw UnknownIdentifierException.create(field.getName()); } try { - Object val = toHost.execute(object.context, rawValue, field.getType(), field.getGenericType(), true); + Object val = HostToTypeNodeGen.getUncached().execute(null, object.context, rawValue, field.getType(), field.getGenericType(), true); field.set(object.obj, val); } catch (RuntimeException e) { RuntimeException ee = unboxEngineException(object, e); @@ -2677,9 +2809,11 @@ static void doUncached(HostFieldDesc field, HostObject object, Object rawValue, } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsListNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2688,7 +2822,7 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isListAccess()", allowUncached = true) boolean isListAccess) { + @Cached(value = "receiver.getHostClassCache().isListAccess()", allowUncached = true) Boolean isListAccess) { assert receiver.getHostClassCache().isListAccess() == isListAccess; return isListAccess && receiver.obj instanceof List; } @@ -2696,9 +2830,11 @@ public boolean doDefault(HostObject receiver, } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsArrayNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2707,7 +2843,7 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isArrayAccess()", allowUncached = true) boolean isArrayAccess) { + @Cached(value = "receiver.getHostClassCache().isArrayAccess()", allowUncached = true) Boolean isArrayAccess) { assert receiver.getHostClassCache().isArrayAccess() == isArrayAccess; return isArrayAccess && receiver.obj.getClass().isArray(); } @@ -2715,9 +2851,11 @@ public boolean doDefault(HostObject receiver, } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsBufferNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2726,7 +2864,7 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isBufferAccess()", allowUncached = true) boolean isBufferAccess) { + @Cached(value = "receiver.getHostClassCache().isBufferAccess()", allowUncached = true) Boolean isBufferAccess) { assert receiver.getHostClassCache().isBufferAccess() == isBufferAccess; return isBufferAccess && ByteBuffer.class.isAssignableFrom(receiver.obj.getClass()); } @@ -2734,9 +2872,11 @@ public boolean doDefault(HostObject receiver, } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsIterableNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2745,16 +2885,18 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isIterableAccess()", allowUncached = true) boolean isIterableAccess) { + @Cached(value = "receiver.getHostClassCache().isIterableAccess()", allowUncached = true) Boolean isIterableAccess) { assert receiver.getHostClassCache().isIterableAccess() == isIterableAccess; return isIterableAccess && receiver.obj instanceof Iterable; } } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsIteratorNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2763,16 +2905,18 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isIteratorAccess()", allowUncached = true) boolean isIteratorAccess) { + @Cached(value = "receiver.getHostClassCache().isIteratorAccess()", allowUncached = true) Boolean isIteratorAccess) { assert receiver.getHostClassCache().isIteratorAccess() == isIteratorAccess; return isIteratorAccess && receiver.obj instanceof Iterator; } } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsMapNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2781,27 +2925,29 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isMapAccess()", allowUncached = true) boolean isMapAccess) { + @Cached(value = "receiver.getHostClassCache().isMapAccess()", allowUncached = true) Boolean isMapAccess) { assert receiver.getHostClassCache().isMapAccess() == isMapAccess; return isMapAccess && receiver.obj instanceof Map; } } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class ContainsKeyNode extends Node { - public abstract boolean execute(HostObject receiver, Object key); + public abstract boolean execute(Node node, HostObject receiver, Object key); - @Specialization(guards = "isMap.execute(receiver)", limit = "1") - protected static boolean doMap(HostObject receiver, Object key, + @Specialization(guards = "isMap.execute(node, receiver)", limit = "1") + protected static boolean doMap(Node node, HostObject receiver, Object key, @Shared("isMap") @Cached IsMapNode isMap, @Cached HostToTypeNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { Object hostKey; try { - hostKey = toHost.execute(receiver.context, key, Object.class, null, true); + hostKey = toHost.execute(node, receiver.context, key, Object.class, null, true); } catch (RuntimeException e) { - error.enter(); + error.enter(node); RuntimeException ee = unboxEngineException(receiver, e); if (ee != null) { return false; @@ -2811,22 +2957,25 @@ protected static boolean doMap(HostObject receiver, Object key, try { return GuestToHostCalls.containsMapKey(receiver, hostKey); } catch (Throwable t) { - error.enter(); + error.enter(node); throw receiver.context.hostToGuestException(t); } } @SuppressWarnings("unused") - @Specialization(guards = "!isMap.execute(receiver)", limit = "1") - protected static boolean doNotMap(HostObject receiver, Object key, @Shared("isMap") @Cached IsMapNode isMap) { + @Specialization(guards = "!isMap.execute(node, receiver)", limit = "1") + protected static boolean doNotMap(Node node, HostObject receiver, Object key, + @Shared("isMap") @Cached IsMapNode isMap) { return false; } } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class IsMapEntryNode extends Node { - public abstract boolean execute(HostObject receiver); + public abstract boolean execute(Node node, HostObject receiver); @Specialization(guards = "receiver.obj == null") public boolean doNull(HostObject receiver) { @@ -2835,7 +2984,7 @@ public boolean doNull(HostObject receiver) { @Specialization(guards = "receiver.obj != null") public boolean doDefault(HostObject receiver, - @Cached(value = "receiver.getHostClassCache().isMapAccess()", allowUncached = true) boolean isMapAccess) { + @Cached(value = "receiver.getHostClassCache().isMapAccess()", allowUncached = true) Boolean isMapAccess) { assert receiver.getHostClassCache().isMapAccess() == isMapAccess; return isMapAccess && receiver.obj instanceof Map.Entry; } diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostTargetMappingNode.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostTargetMappingNode.java index ffd348a95936..94fec2a4a756 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostTargetMappingNode.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostTargetMappingNode.java @@ -45,28 +45,33 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.host.HostTargetMappingNodeGen.SingleMappingNodeGen; @GenerateUncached +@GenerateInline +@GenerateCached abstract class HostTargetMappingNode extends Node { public static final Object NO_RESULT = new Object(); - abstract Object execute(Object value, Class targetType, HostContext hostContext, InteropLibrary interop, boolean checkOnly, int startPriority, int endPriority); + abstract Object execute(Node node, Object value, Class targetType, HostContext hostContext, InteropLibrary interop, boolean checkOnly, int startPriority, int endPriority); @SuppressWarnings("unused") @Specialization(guards = "targetType != null") @ExplodeLoop protected Object doCached(Object operand, Class targetType, HostContext context, InteropLibrary interop, boolean checkOnly, int startPriority, int endPriority, - @Cached(value = "getMappings(context, targetType)", dimensions = 1) HostTargetMapping[] mappings, - @Cached(value = "createMappingNodes(mappings)") SingleMappingNode[] mappingNodes) { + @Cached(value = "getMappings(context, targetType)", dimensions = 1, neverDefault = true) HostTargetMapping[] mappings, + @Cached(value = "createMappingNodes(mappings)", neverDefault = true) SingleMappingNode[] mappingNodes) { assert startPriority <= endPriority; Object result = NO_RESULT; if (mappingNodes != null) { @@ -141,22 +146,24 @@ static HostTargetMappingNode getUncached() { @GenerateUncached @SuppressWarnings("unchecked") + @GenerateInline(false) // cannot be inlined abstract static class SingleMappingNode extends Node { abstract Object execute(Object receiver, HostTargetMapping targetMapping, HostContext context, InteropLibrary interop, boolean checkOnly); @Specialization - protected Object doDefault(Object receiver, @SuppressWarnings("unused") HostTargetMapping cachedMapping, + protected static Object doDefault(Object receiver, @SuppressWarnings("unused") HostTargetMapping cachedMapping, HostContext context, InteropLibrary interop, boolean checkOnly, - @Cached ConditionProfile acceptsProfile, - @Cached(value = "allowsImplementation(context, cachedMapping.sourceType)", allowUncached = true) boolean allowsImplementation, - @Cached HostToTypeNode toHostRecursive) { + @Bind("this") Node node, + @Cached InlinedConditionProfile acceptsProfile, + @Cached(value = "allowsImplementation(context, cachedMapping.sourceType)", allowUncached = true) Boolean allowsImplementation, + @Cached(inline = true) HostToTypeNode toHostRecursive) { CompilerAsserts.partialEvaluationConstant(checkOnly); Object convertedValue = NO_RESULT; - if (acceptsProfile.profile(HostToTypeNode.canConvert(receiver, cachedMapping.sourceType, cachedMapping.sourceType, + if (acceptsProfile.profile(node, HostToTypeNode.canConvert(node, receiver, cachedMapping.sourceType, cachedMapping.sourceType, allowsImplementation, context, HostToTypeNode.LOWEST, interop, null))) { if (!checkOnly || cachedMapping.accepts != null) { - convertedValue = toHostRecursive.execute(context, receiver, cachedMapping.sourceType, cachedMapping.sourceType, false); + convertedValue = toHostRecursive.execute(node, context, receiver, cachedMapping.sourceType, cachedMapping.sourceType, false); } } else { return NO_RESULT; diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostToTypeNode.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostToTypeNode.java index 61f3e1bb0c96..271fb2b56ba8 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostToTypeNode.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostToTypeNode.java @@ -60,15 +60,19 @@ import java.util.Objects; import java.util.function.Function; -import com.oracle.truffle.api.strings.TruffleString; - import org.graalvm.polyglot.HostAccess.MutableTargetMapping; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -76,9 +80,12 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.strings.TruffleString; @GenerateUncached +@GenerateInline +@GenerateCached abstract class HostToTypeNode extends Node { static final int LIMIT = 5; @@ -103,11 +110,11 @@ abstract class HostToTypeNode extends Node { static final int[] PRIORITIES = {HIGHEST, STRICT, LOOSE, COERCE, FUNCTION_PROXY, OBJECT_PROXY_IFACE, OBJECT_PROXY_CLASS, HOST_PROXY, LOWEST}; - public abstract Object execute(HostContext context, Object value, Class targetType, Type genericType, boolean useTargetMapping); + public abstract Object execute(Node node, HostContext context, Object value, Class targetType, Type genericType, boolean useTargetMapping); @SuppressWarnings("unused") @Specialization(guards = {"targetType == cachedTargetType"}, limit = "LIMIT") - protected Object doCached(HostContext context, + protected static Object doCached(Node node, HostContext context, Object operand, Class targetType, Type genericType, @@ -117,8 +124,8 @@ protected Object doCached(HostContext context, @Cached("isPrimitiveTarget(cachedTargetType)") boolean primitiveTarget, @Cached("allowsImplementation(context, targetType)") boolean allowsImplementation, @Cached HostTargetMappingNode targetMapping, - @Cached BranchProfile error) { - return convertImpl(operand, cachedTargetType, genericType, allowsImplementation, primitiveTarget, context, interop, useCustomTargetTypes, targetMapping, error); + @Cached InlinedBranchProfile error) { + return convertImpl(node, operand, cachedTargetType, genericType, allowsImplementation, primitiveTarget, context, interop, useCustomTargetTypes, targetMapping, error); } @TruffleBoundary @@ -136,16 +143,17 @@ static boolean allowsImplementation(HostContext hostContext, Class type) { @Specialization(replaces = "doCached") @TruffleBoundary protected static Object doGeneric( + Node node, HostContext context, Object operand, Class targetType, Type genericType, boolean useTargetMapping) { - return convertImpl(operand, targetType, genericType, allowsImplementation(context, targetType), + return convertImpl(node, operand, targetType, genericType, allowsImplementation(context, targetType), isPrimitiveTarget(targetType), context, InteropLibrary.getUncached(operand), useTargetMapping, HostTargetMappingNode.getUncached(), - BranchProfile.getUncached()); + InlinedBranchProfile.getUncached()); } @TruffleBoundary @@ -153,10 +161,10 @@ private static String toString(Object value) { return value.toString(); } - private static Object convertImpl(Object value, Class targetType, Type genericType, boolean allowsImplementation, boolean primitiveTargetType, - HostContext context, InteropLibrary interop, boolean useCustomTargetTypes, HostTargetMappingNode targetMapping, BranchProfile error) { + private static Object convertImpl(Node node, Object value, Class targetType, Type genericType, boolean allowsImplementation, boolean primitiveTargetType, + HostContext context, InteropLibrary interop, boolean useCustomTargetTypes, HostTargetMappingNode targetMapping, InlinedBranchProfile error) { if (useCustomTargetTypes) { - Object result = targetMapping.execute(value, targetType, context, interop, false, HIGHEST, STRICT); + Object result = targetMapping.execute(node, value, targetType, context, interop, false, HIGHEST, STRICT); if (result != HostTargetMappingNode.NO_RESULT) { return result; } @@ -174,7 +182,7 @@ private static Object convertImpl(Object value, Class targetType, Type generi } if (useCustomTargetTypes) { - convertedValue = targetMapping.execute(value, targetType, context, interop, false, STRICT + 1, LOOSE); + convertedValue = targetMapping.execute(node, value, targetType, context, interop, false, STRICT + 1, LOOSE); if (convertedValue != HostTargetMappingNode.NO_RESULT) { return convertedValue; } @@ -195,7 +203,7 @@ private static Object convertImpl(Object value, Class targetType, Type generi } return null; } else if (value instanceof TruffleObject) { - convertedValue = asJavaObject(context, (TruffleObject) value, targetType, genericType, allowsImplementation); + convertedValue = asJavaObject(node, context, (TruffleObject) value, targetType, genericType, allowsImplementation); if (convertedValue != null) { return convertedValue; } @@ -213,17 +221,17 @@ private static Object convertImpl(Object value, Class targetType, Type generi } if (useCustomTargetTypes) { - Object result = targetMapping.execute(value, targetType, context, interop, false, LOOSE + 1, LOWEST); + Object result = targetMapping.execute(node, value, targetType, context, interop, false, LOOSE + 1, LOWEST); if (result != HostTargetMappingNode.NO_RESULT) { return result; } } - error.enter(); + error.enter(node); throw HostInteropErrors.cannotConvertPrimitive(context, value, targetType); } @SuppressWarnings({"unused"}) - static boolean canConvert(Object value, Class targetType, Type genericType, Boolean allowsImplementation, + static boolean canConvert(Node node, Object value, Class targetType, Type genericType, Boolean allowsImplementation, HostContext hostContext, int priority, InteropLibrary interop, HostTargetMappingNode targetMapping) { @@ -232,7 +240,7 @@ static boolean canConvert(Object value, Class targetType, Type genericType, B * For canConvert the order of target type mappings does not really matter, as the * question is whether any conversion can be performed. */ - if (targetMapping.execute(value, targetType, hostContext, interop, true, HIGHEST, priority) == Boolean.TRUE) { + if (targetMapping.execute(node, value, targetType, hostContext, interop, true, HIGHEST, priority) == Boolean.TRUE) { return true; } } @@ -348,7 +356,7 @@ static boolean isPrimitiveTarget(Class clazz) { /** * See {@link Value#as(Class)} documentation. */ - static Object convertToObject(HostContext hostContext, Object value, InteropLibrary interop) { + static Object convertToObject(Node node, HostContext hostContext, Object value, InteropLibrary interop) { try { if (interop.isNull(value)) { return null; @@ -363,15 +371,15 @@ static Object convertToObject(HostContext hostContext, Object value, InteropLibr } // fallthrough } else if (interop.hasArrayElements(value)) { - return asJavaObject(hostContext, value, List.class, null, false); + return asJavaObject(node, hostContext, value, List.class, null, false); } else if (interop.hasHashEntries(value) || interop.hasMembers(value)) { - return asJavaObject(hostContext, value, Map.class, null, false); + return asJavaObject(node, hostContext, value, Map.class, null, false); } else if (interop.hasIterator(value)) { - return asJavaObject(hostContext, value, Iterable.class, null, false); + return asJavaObject(node, hostContext, value, Iterable.class, null, false); } else if (interop.isIterator(value)) { - return asJavaObject(hostContext, value, Iterator.class, null, false); + return asJavaObject(node, hostContext, value, Iterator.class, null, false); } else if (interop.isExecutable(value) || interop.isInstantiable(value)) { - return asJavaObject(hostContext, value, Function.class, null, false); + return asJavaObject(node, hostContext, value, Function.class, null, false); } return hostContext.language.access.toValue(hostContext.internalContext, value); } catch (UnsupportedMessageException e) { @@ -380,14 +388,14 @@ static Object convertToObject(HostContext hostContext, Object value, InteropLibr } @TruffleBoundary - private static T asJavaObject(HostContext hostContext, Object value, Class targetType, Type genericType, boolean allowsImplementation) { + private static T asJavaObject(Node node, HostContext hostContext, Object value, Class targetType, Type genericType, boolean allowsImplementation) { InteropLibrary interop = InteropLibrary.getFactory().getUncached(value); assert !interop.isNull(value); // already handled Object obj; if (HostObject.isJavaInstance(hostContext.language, targetType, value)) { obj = HostObject.valueOf(hostContext.language, value); } else if (targetType == Object.class) { - obj = convertToObject(hostContext, value, interop); + obj = convertToObject(node, hostContext, value, interop); } else if (targetType == List.class) { if (interop.hasArrayElements(value)) { if (!hostContext.getMutableTargetMappings().contains(MutableTargetMapping.ARRAY_TO_JAVA_LIST)) { @@ -582,7 +590,7 @@ private static T asJavaObject(HostContext hostContext, Object value, Class { static final TypeAndClass ANY = new TypeAndClass<>(null, Object.class); diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/FunctionExecuteNode.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/FunctionExecuteNode.java index 4ad5ee20004b..6bdcf0566376 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/FunctionExecuteNode.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/FunctionExecuteNode.java @@ -59,6 +59,8 @@ import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CachedSignatureInfo; import com.oracle.truffle.nfi.backend.libffi.LibFFIType.CachedTypeInfo; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @GenerateUncached @ImportStatic(LibFFILanguage.class) @GenerateAOT diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFILibrary.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFILibrary.java index 54605ef39b43..fce4ba3973e0 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFILibrary.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFILibrary.java @@ -52,6 +52,8 @@ import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.profiles.BranchProfile; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @ExportLibrary(InteropLibrary.class) final class LibFFILibrary implements TruffleObject { diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFISignature.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFISignature.java index abca1a6e8ef2..7ae61e00c90e 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFISignature.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/LibFFISignature.java @@ -83,6 +83,8 @@ * {@link CachedSignatureInfo}. Two {@link LibFFISignature} objects that have the same * {@link CachedSignatureInfo} are guaranteed to behave the same semantically. */ +// TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @ExportLibrary(value = NFIBackendSignatureLibrary.class, useForAOT = true, useForAOTPriority = 1) final class LibFFISignature { diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java index 697156b246f2..9bcf4c06b465 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java @@ -56,6 +56,8 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.nfi.api.SerializableLibrary; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) abstract class NativeBuffer implements TruffleObject { @ExportLibrary(value = SerializableLibrary.class, useForAOT = false) diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java index dddb764a2367..b70c717bd185 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java @@ -74,6 +74,8 @@ import com.oracle.truffle.nfi.backend.libffi.SerializeArgumentNodeFactory.GetLongArrayTagNodeGen; import com.oracle.truffle.nfi.backend.libffi.SerializeArgumentNodeFactory.GetShortArrayTagNodeGen; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) abstract class SerializeArgumentNode extends Node { final CachedTypeInfo type; diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java new file mode 100644 index 000000000000..c7a71401b3bf --- /dev/null +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +@SuppressPackageWarnings({"truffle-inlining", "truffle-neverdefault"}) +package com.oracle.truffle.nfi.test; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/CallSignatureNode.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/CallSignatureNode.java index 5ffe46dea696..4964d57ab366 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/CallSignatureNode.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/CallSignatureNode.java @@ -40,9 +40,12 @@ */ package com.oracle.truffle.nfi; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateAOT; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -55,7 +58,7 @@ import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.nfi.CallSignatureNodeFactory.OptimizedCallClosureNodeGen; import com.oracle.truffle.nfi.CallSignatureNodeFactory.OptimizedCallSignatureNodeGen; import com.oracle.truffle.nfi.ConvertTypeNode.ConvertFromNativeNode; @@ -72,9 +75,10 @@ abstract class CallSignatureNode extends Node { abstract Object execute(NFISignature signature, Object function, Object[] args) throws ArityException, UnsupportedTypeException, UnsupportedMessageException; @GenerateUncached + @GenerateInline(false) abstract static class CachedCallSignatureNode extends CallSignatureNode { - @Specialization(guards = {"cachedState != null", "signature.cachedState == cachedState"}) + @Specialization(guards = {"cachedState != null", "signature.cachedState == cachedState"}, limit = "3") Object doOptimizedDirect(NFISignature signature, Object function, Object[] args, @Cached("signature.cachedState") SignatureCachedState cachedState, @Cached("cachedState.createOptimizedSignatureCall()") CallSignatureNode call) throws ArityException, UnsupportedTypeException, UnsupportedMessageException { @@ -89,14 +93,15 @@ Object doOptimizedIndirect(NFISignature signature, Object function, Object[] arg } @Specialization(guards = "signature.cachedState == null") - Object doSlowPath(NFISignature signature, Object function, Object[] args, - @Cached BranchProfile exception, + static Object doSlowPath(NFISignature signature, Object function, Object[] args, + @Bind("this") Node node, + @Cached InlinedBranchProfile exception, @Cached ConvertToNativeNode convertArg, @Cached ConvertFromNativeNode convertRet, @CachedLibrary(limit = "3") NFIBackendSignatureLibrary nativeLibrary, @Cached BackendSymbolUnwrapNode backendSymbolUnwrapNode) throws ArityException, UnsupportedTypeException, UnsupportedMessageException { if (args.length != signature.managedArgCount) { - exception.enter(); + exception.enter(node); throw ArityException.create(signature.managedArgCount, signature.managedArgCount, args.length); } @@ -110,9 +115,10 @@ Object doSlowPath(NFISignature signature, Object function, Object[] args, preparedArgs[i] = convertArg.execute(signature.argTypes[i], input); } - Object ret = nativeLibrary.call(signature.nativeSignature, backendSymbolUnwrapNode.execute(function), preparedArgs); + Object ret = nativeLibrary.call(signature.nativeSignature, backendSymbolUnwrapNode.execute(node, function), preparedArgs); return convertRet.execute(signature.retType, ret); } + } static CallSignatureNode createOptimizedCall(TypeCachedState retType, ArgsCachedState argsState) { @@ -160,15 +166,15 @@ Object[] prepareArgs(NFISignature signature, Object[] args) throws UnsupportedTy @Specialization Object doCall(NFISignature signature, Object function, Object[] args, - @Cached BranchProfile exception, + @Cached InlinedBranchProfile exception, @CachedLibrary(limit = "1") NFIBackendSignatureLibrary backendLibrary, @Cached BackendSymbolUnwrapNode backendSymbolUnwrapNode) throws ArityException, UnsupportedTypeException, UnsupportedMessageException { if (args.length != managedArgCount) { - exception.enter(); + exception.enter(this); throw ArityException.create(managedArgCount, managedArgCount, args.length); } Object[] preparedArgs = prepareArgs(signature, args); - Object ret = backendLibrary.call(signature.nativeSignature, backendSymbolUnwrapNode.execute(function), preparedArgs); + Object ret = backendLibrary.call(signature.nativeSignature, backendSymbolUnwrapNode.execute(this, function), preparedArgs); return convertRet.execute(signature.retType, ret); } } @@ -209,10 +215,10 @@ Object[] prepareArgs(NFISignature signature, Object[] args) throws UnsupportedTy @Specialization(limit = "1") @GenerateAOT.Exclude Object doCall(NFISignature signature, Object function, Object[] args, - @Cached BranchProfile exception, + @Cached InlinedBranchProfile exception, @CachedLibrary("function") InteropLibrary interop) throws ArityException, UnsupportedTypeException, UnsupportedMessageException { if (args.length != convertArgs.length) { - exception.enter(); + exception.enter(this); throw ArityException.create(convertArgs.length, convertArgs.length, args.length); } Object[] preparedArgs = prepareArgs(signature, args); @@ -252,8 +258,10 @@ static RuntimeException silenceException(Class type, Ex @GenerateAOT @GenerateUncached + @GenerateCached(false) + @GenerateInline abstract static class BackendSymbolUnwrapNode extends Node { - abstract Object execute(Object symbol); + abstract Object execute(Node node, Object symbol); @Specialization Object unwrapNFISymbol(NFISymbol symbol) { diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/ConvertTypeNode.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/ConvertTypeNode.java index b803dd5c3a2c..271c9ec3015d 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/ConvertTypeNode.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/ConvertTypeNode.java @@ -48,6 +48,8 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.nfi.NFIType.TypeCachedState; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @GenerateAOT abstract class ConvertTypeNode extends Node { @@ -73,7 +75,7 @@ Object execute(NFIType type, Object value) throws UnsupportedTypeException { @GenerateUncached abstract static class ConvertToNativeNode extends ConvertTypeNode { - @Specialization(guards = "type.cachedState == convertImpl.typeState") + @Specialization(guards = "type.cachedState == convertImpl.typeState", limit = "3") Object doCached(NFIType type, Object value, @Cached("type.cachedState.createToNative()") OptimizedConvertTypeNode convertImpl) throws UnsupportedTypeException { return convertImpl.execute(type, value); @@ -88,7 +90,7 @@ Object doGeneric(NFIType type, Object value) throws UnsupportedTypeException { @GenerateUncached abstract static class ConvertFromNativeNode extends ConvertTypeNode { - @Specialization(guards = "type.cachedState == convertImpl.typeState") + @Specialization(guards = "type.cachedState == convertImpl.typeState", limit = "3") Object doCached(NFIType type, Object value, @Cached("type.cachedState.createFromNative()") OptimizedConvertTypeNode convertImpl) throws UnsupportedTypeException { return convertImpl.execute(type, value); diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java index 7f92f5cd9c86..68c570d7b212 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java @@ -58,6 +58,8 @@ import com.oracle.truffle.nfi.ConvertTypeNode.ConvertToNativeNode; import com.oracle.truffle.nfi.NFISignature.SignatureCachedState; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @ExportLibrary(InteropLibrary.class) final class NFIClosure implements TruffleObject { diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFILibrary.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFILibrary.java index 3060102a74f0..c7393b5d49e0 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFILibrary.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFILibrary.java @@ -40,9 +40,13 @@ */ package com.oracle.truffle.nfi; -import com.oracle.truffle.api.TruffleLanguage; +import java.util.HashMap; +import java.util.Map; + import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -54,9 +58,8 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; -import java.util.HashMap; -import java.util.Map; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) final class NFILibrary implements TruffleObject { @@ -122,11 +125,12 @@ boolean isMemberInvocable(@SuppressWarnings("unused") String symbol) { @ExportMessage Object invokeMember(String symbol, Object[] args, + @Bind("$node") Node node, @CachedLibrary(limit = "3") InteropLibrary executables, - @Cached BranchProfile exception) throws UnknownIdentifierException, ArityException, UnsupportedTypeException, UnsupportedMessageException { + @Cached InlinedBranchProfile exception) throws UnknownIdentifierException, ArityException, UnsupportedTypeException, UnsupportedMessageException { Object preBound = findSymbol(symbol); if (preBound == null) { - exception.enter(); + exception.enter(node); throw UnknownIdentifierException.create(symbol); } return executables.execute(preBound, args); @@ -192,9 +196,10 @@ boolean isArrayElementReadable(long index) { @ExportMessage Object readArrayElement(long idx, - @Cached BranchProfile exception) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(idx); } return keys[(int) idx]; diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISignature.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISignature.java index 0c295deb3f2c..3f40c82c02f7 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISignature.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISignature.java @@ -68,6 +68,8 @@ import com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureLibrary; import com.oracle.truffle.nfi.backend.spi.util.ProfiledArrayBuilder; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @ExportLibrary(InteropLibrary.class) @ExportLibrary(value = SignatureLibrary.class, useForAOT = true, useForAOTPriority = 1) final class NFISignature implements TruffleObject { diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISymbol.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISymbol.java index 6fdbb24f93a1..4e1f38abb8b6 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISymbol.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFISymbol.java @@ -54,6 +54,8 @@ import com.oracle.truffle.nfi.api.NativePointerLibrary; import com.oracle.truffle.nfi.backend.spi.BackendNativePointerLibrary; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) @ExportLibrary(InteropLibrary.class) @ExportLibrary(value = NativePointerLibrary.class, useForAOT = true, useForAOTPriority = 1) final class NFISymbol implements TruffleObject { diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureRootNode.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureRootNode.java index 0a563be6177b..fa4d732f1eb2 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureRootNode.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureRootNode.java @@ -54,6 +54,8 @@ import com.oracle.truffle.nfi.backend.spi.util.ProfiledArrayBuilder.ArrayBuilderFactory; import com.oracle.truffle.nfi.backend.spi.util.ProfiledArrayBuilder.ArrayFactory; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) final class SignatureRootNode extends RootNode { final String backendId; diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureTypeCachedState.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureTypeCachedState.java index 2183cbdac269..3585e6d0754b 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureTypeCachedState.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SignatureTypeCachedState.java @@ -52,6 +52,8 @@ import com.oracle.truffle.nfi.SignatureTypeCachedStateFactory.FunctionPtrFromNativeFactory; import com.oracle.truffle.nfi.api.SignatureLibrary; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) final class SignatureTypeCachedState { static final TypeCachedState INSTANCE = new TypeCachedState(1, ClosureToNativeFactory.getInstance(), FunctionPtrFromNativeFactory.getInstance()); diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SimpleTypeCachedState.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SimpleTypeCachedState.java index c9883f822ede..d8e0704fb30b 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SimpleTypeCachedState.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/SimpleTypeCachedState.java @@ -74,6 +74,8 @@ import com.oracle.truffle.nfi.backend.spi.BackendNativePointerLibrary; import com.oracle.truffle.nfi.backend.spi.types.NativeSimpleType; +//TODO GR-42818 fix warnings +@SuppressWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) final class SimpleTypeCachedState { private static final TypeCachedState nopCachedState; @@ -193,7 +195,7 @@ Object doLong(@SuppressWarnings("unused") NFIType type, long arg) { @Specialization(guards = "arg != null") Object doObject(@SuppressWarnings("unused") NFIType type, Object arg, @CachedLibrary(limit = "1") BackendNativePointerLibrary library, - @Cached("createBinaryProfile()") ConditionProfile isPointerProfile) { + @Cached ConditionProfile isPointerProfile) { try { return isPointerProfile.profile(library.isPointer(arg)) ? NFIPointer.create(library.asPointer(arg)) : arg; } catch (UnsupportedMessageException e) { diff --git a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedGetNode.java b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedGetNode.java index 27cd715ec9eb..1e27dd205e92 100644 --- a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedGetNode.java +++ b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedGetNode.java @@ -40,12 +40,14 @@ */ package com.oracle.truffle.object.basic.test; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; +@GenerateInline(false) abstract class CachedGetNode extends Node { public abstract Object execute(DynamicObject obj, Object key); diff --git a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedPutNode.java b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedPutNode.java index 355a9bf6dd2f..6eca4b2a2491 100644 --- a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedPutNode.java +++ b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/CachedPutNode.java @@ -40,12 +40,14 @@ */ package com.oracle.truffle.object.basic.test; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; +@GenerateInline(false) abstract class CachedPutNode extends Node { public abstract void execute(DynamicObject obj, Object key, Object value); diff --git a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/TestNestedDispatchNode.java b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/TestNestedDispatchNode.java index d58f469e8d23..29bbbf9ebbf4 100644 --- a/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/TestNestedDispatchNode.java +++ b/truffle/src/com.oracle.truffle.object.basic.test/src/com/oracle/truffle/object/basic/test/TestNestedDispatchNode.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.DynamicObjectLibrary; +@SuppressWarnings("truffle") public abstract class TestNestedDispatchNode extends Node { final Object key = "testKey"; diff --git a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectLibraryImpl.java b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectLibraryImpl.java index 3221f2fc2fcd..8cc603ebc7ec 100644 --- a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectLibraryImpl.java +++ b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectLibraryImpl.java @@ -60,9 +60,13 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; @@ -231,10 +235,12 @@ public static Object getDynamicType(@SuppressWarnings("unused") DynamicObject ob } @ExportMessage - public static boolean setDynamicType(DynamicObject object, @SuppressWarnings("unused") Object objectType, + @SuppressWarnings("unused") + public static boolean setDynamicType(DynamicObject object, Object objectType, + @Bind("$node") Node node, @Shared("cachedShape") @Cached(value = "object.getShape()", allowUncached = true) Shape cachedShape, @Cached SetDynamicTypeNode setCache) { - return setCache.execute(object, cachedShape, objectType); + return setCache.execute(node, object, cachedShape, objectType); } @ExportMessage @@ -245,9 +251,10 @@ public static int getShapeFlags(@SuppressWarnings("unused") DynamicObject object @ExportMessage public static boolean setShapeFlags(DynamicObject object, @SuppressWarnings("unused") int flags, + @Bind("$node") Node node, @Shared("cachedShape") @Cached(value = "object.getShape()", allowUncached = true) Shape cachedShape, @Cached SetFlagsNode setCache) { - return setCache.execute(object, cachedShape, flags); + return setCache.execute(node, object, cachedShape, flags); } @ExportMessage @@ -258,9 +265,10 @@ public static boolean isShared(@SuppressWarnings("unused") DynamicObject object, @ExportMessage public static void markShared(DynamicObject object, + @Bind("$node") Node node, @Shared("cachedShape") @Cached(value = "object.getShape()", allowUncached = true) Shape cachedShape, @Cached MakeSharedNode setCache) { - setCache.execute(object, cachedShape); + setCache.execute(node, object, cachedShape); } @ExportMessage @@ -280,9 +288,10 @@ static boolean updateShapeImpl(DynamicObject object) { @ExportMessage public static boolean resetShape(DynamicObject object, Shape otherShape, + @Bind("$node") Node node, @Shared("cachedShape") @Cached(value = "object.getShape()", allowUncached = true) Shape cachedShape, @Cached ResetShapeNode setCache) { - return setCache.execute(object, cachedShape, otherShape); + return setCache.execute(node, object, cachedShape, otherShape); } @ExportMessage @@ -540,6 +549,7 @@ boolean isIdentity() { return false; } + @NeverDefault static KeyCacheNode create(Shape cachedShape, Object key) { if (key == null) { return getUncached(); @@ -547,6 +557,7 @@ static KeyCacheNode create(Shape cachedShape, Object key) { return AnyKey.create(key, cachedShape); } + @NeverDefault static KeyCacheEntry getUncached() { return Generic.instance(); } @@ -1740,8 +1751,10 @@ protected MutateCacheData withNext(MutateCacheData newNext) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class SetFlagsNode extends Node { - abstract boolean execute(DynamicObject object, Shape cachedShape, int flags); + abstract boolean execute(Node node, DynamicObject object, Shape cachedShape, int flags); @Specialization(guards = {"flags == newFlags"}, limit = "3") static boolean doCached(DynamicObject object, Shape cachedShape, @SuppressWarnings("unused") int flags, @@ -1772,8 +1785,10 @@ static Shape shapeSetFlags(Shape shape, int newFlags) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class SetDynamicTypeNode extends Node { - abstract boolean execute(DynamicObject object, Shape cachedShape, Object objectType); + abstract boolean execute(Node node, DynamicObject object, Shape cachedShape, Object objectType); @Specialization(guards = {"objectType == newObjectType"}, limit = "3") static boolean doCached(DynamicObject object, Shape cachedShape, @SuppressWarnings("unused") Object objectType, @@ -1804,12 +1819,14 @@ static Shape shapeSetDynamicType(Shape shape, Object newType) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class MakeSharedNode extends Node { - abstract void execute(DynamicObject object, Shape cachedShape); + abstract void execute(Node node, DynamicObject object, Shape cachedShape); @Specialization static void doCached(DynamicObject object, Shape cachedShape, - @Cached(value = "makeSharedShape(cachedShape)", allowUncached = true) Shape newShape) { + @Cached(value = "makeSharedShape(cachedShape)", allowUncached = true, neverDefault = true) Shape newShape) { assert newShape != cachedShape && ((ShapeImpl) cachedShape).getObjectArrayCapacity() == ((ShapeImpl) newShape).getObjectArrayCapacity() && ((ShapeImpl) cachedShape).getPrimitiveArrayCapacity() == ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); @@ -1822,10 +1839,12 @@ static Shape makeSharedShape(Shape inputShape) { } @GenerateUncached + @GenerateInline + @GenerateCached(false) abstract static class ResetShapeNode extends Node { - abstract boolean execute(DynamicObject object, Shape cachedShape, Shape newShape); + abstract boolean execute(Node node, DynamicObject object, Shape cachedShape, Shape newShape); - @Specialization(guards = "otherShape == cachedOtherShape") + @Specialization(guards = "otherShape == cachedOtherShape", limit = "3") static boolean doCached(DynamicObject object, Shape cachedShape, @SuppressWarnings("unused") Shape otherShape, @Cached(value = "verifyResetShape(cachedShape, otherShape)", allowUncached = true) Shape cachedOtherShape) { if (cachedShape == cachedOtherShape) { diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/OtherContextGuestObject.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/OtherContextGuestObject.java index 1b632fa791ba..646cac33487c 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/OtherContextGuestObject.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/OtherContextGuestObject.java @@ -41,6 +41,7 @@ package com.oracle.truffle.polyglot; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; @@ -55,7 +56,7 @@ import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; /** * A guest TruffleObject that has been passed from one context to another. @@ -104,33 +105,34 @@ static class Send { @Specialization(guards = "canCache(cachedLayer, receiver.receiverContext, receiver.delegateContext)", limit = "1") static Object doCached(OtherContextGuestObject receiver, Message message, Object[] args, + @Bind("this") Node node, @SuppressWarnings("unused") @CachedLibrary("receiver") ReflectionLibrary receiverLibrary, - @Cached("getCachedLayer(receiverLibrary)") PolyglotSharingLayer cachedLayer, + @Cached(value = "getCachedLayer(receiverLibrary)", neverDefault = true) PolyglotSharingLayer cachedLayer, @CachedLibrary(limit = "CACHE_LIMIT") ReflectionLibrary delegateLibrary, - @Cached BranchProfile seenOther, - @Cached BranchProfile seenError) throws Exception { + @Cached InlinedBranchProfile seenOther, + @Cached InlinedBranchProfile seenError) throws Exception { assert cachedLayer != null; - return sendImpl(cachedLayer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, delegateLibrary, seenOther, seenError); + return sendImpl(node, cachedLayer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, delegateLibrary, seenOther, seenError); } @TruffleBoundary @Specialization(replaces = "doCached") - static Object doSlowPath(OtherContextGuestObject receiver, Message message, Object[] args) throws Exception { - return sendImpl(receiver.receiverContext.layer, receiver.delegate, message, args, receiver.receiverContext, + static Object doSlowPath(OtherContextGuestObject receiver, Message message, Object[] args, @Bind("this") Node node) throws Exception { + return sendImpl(node, receiver.receiverContext.layer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, ReflectionLibrary.getUncached(receiver.delegate), - BranchProfile.getUncached(), BranchProfile.getUncached()); + InlinedBranchProfile.getUncached(), InlinedBranchProfile.getUncached()); } } private static final Message IDENTICAL = Message.resolve(InteropLibrary.class, "isIdentical"); - static Object sendImpl(PolyglotSharingLayer layer, Object receiver, Message message, Object[] args, PolyglotContextImpl receiverContext, + static Object sendImpl(Node node, PolyglotSharingLayer layer, Object receiver, Message message, Object[] args, PolyglotContextImpl receiverContext, PolyglotContextImpl delegateContext, ReflectionLibrary delegateLibrary, - BranchProfile seenOther, - BranchProfile seenError) throws Exception { + InlinedBranchProfile seenOther, + InlinedBranchProfile seenError) throws Exception { if (message.getLibraryClass() == InteropLibrary.class) { try { Object[] prev = layer.engine.enter(delegateContext); @@ -156,17 +158,17 @@ static Object sendImpl(PolyglotSharingLayer layer, Object receiver, Message mess } return migrateReturn(returnValue, receiverContext, delegateContext); } catch (Throwable e) { - seenError.enter(); + seenError.enter(node); throw migrateException(receiverContext, e, delegateContext); } finally { layer.engine.leave(prev, delegateContext); } } catch (Throwable t) { - seenError.enter(); + seenError.enter(node); throw toHostOrInnerContextBoundaryException(receiverContext, t, delegateContext); } } else { - seenOther.enter(); + seenOther.enter(node); return fallbackSend(message, args); } } @@ -346,22 +348,24 @@ static class Send { @Specialization(guards = "canCache(cachedLayer, receiver.receiverContext, receiver.delegateContext)", limit = "1") static Object doCached(OtherContextException receiver, Message message, Object[] args, + @Bind("this") Node node, @SuppressWarnings("unused") @CachedLibrary("receiver") ReflectionLibrary receiverLibrary, - @Cached("getCachedLayer(receiverLibrary)") PolyglotSharingLayer cachedLayer, + @Cached(value = "getCachedLayer(receiverLibrary)", neverDefault = true) PolyglotSharingLayer cachedLayer, @CachedLibrary(limit = "CACHE_LIMIT") ReflectionLibrary delegateLibrary, - @Cached BranchProfile seenOther, - @Cached BranchProfile seenError) throws Exception { + @Cached InlinedBranchProfile seenOther, + @Cached InlinedBranchProfile seenError) throws Exception { assert cachedLayer != null; - return sendImpl(cachedLayer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, delegateLibrary, seenOther, seenError); + return sendImpl(node, cachedLayer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, delegateLibrary, seenOther, seenError); } @TruffleBoundary @Specialization(replaces = "doCached") - static Object doSlowPath(OtherContextException receiver, Message message, Object[] args) throws Exception { - return sendImpl(receiver.receiverContext.layer, receiver.delegate, message, args, receiver.receiverContext, + static Object doSlowPath(OtherContextException receiver, Message message, Object[] args, + @Bind("this") Node node) throws Exception { + return sendImpl(node, receiver.receiverContext.layer, receiver.delegate, message, args, receiver.receiverContext, receiver.delegateContext, ReflectionLibrary.getUncached(receiver.delegate), - BranchProfile.getUncached(), BranchProfile.getUncached()); + InlinedBranchProfile.getUncached(), InlinedBranchProfile.getUncached()); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotExecuteNode.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotExecuteNode.java index 9e0d7c5014e9..f7bedb536c32 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotExecuteNode.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotExecuteNode.java @@ -44,7 +44,9 @@ import java.lang.reflect.Type; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -52,16 +54,15 @@ import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValuesNode; +@GenerateInline(false) // not much improvement in current uses, but field duplication abstract class PolyglotExecuteNode extends Node { private static final Object[] EMPTY = new Object[0]; - @Child private ToGuestValuesNode toGuests = ToGuestValuesNode.create(); - public final Object execute(PolyglotLanguageContext languageContext, Object function, Object functionArgsObject) { return execute(languageContext, function, functionArgsObject, Object.class, Object.class, Object.class, null); } @@ -89,8 +90,7 @@ public final Object execute(PolyglotLanguageContext languageContext, Object func } } - Object[] functionArgs = toGuests.apply(languageContext, argsArray); - return executeImpl(languageContext, function, functionArgs, resultClass, resultType); + return executeImpl(languageContext, function, argsArray, resultClass, resultType); } @TruffleBoundary @@ -104,39 +104,41 @@ private static Object[] copyToObjectArray(Object functionArgs) { return copy; } - protected abstract Object executeImpl(PolyglotLanguageContext languageContext, Object function, Object[] functionArgsObject, + protected abstract Object executeImpl(PolyglotLanguageContext languageContext, Object function, Object[] argsArray, Class resultClass, Type resultType); @Specialization(limit = "5") - Object doCached(PolyglotLanguageContext languageContext, Object function, Object[] functionArgs, + static Object doCached(PolyglotLanguageContext languageContext, Object function, Object[] argsArray, Class resultClass, Type resultType, + @Bind("this") Node node, @CachedLibrary("function") InteropLibrary interop, + @Cached ToGuestValuesNode toGuests, @Cached PolyglotToHostNode toHost, - @Cached ConditionProfile executableCondition, - @Cached ConditionProfile instantiableCondition, - @Cached BranchProfile unsupportedError, - @Cached BranchProfile arityError, - @Cached BranchProfile unsupportedArgumentError) { - + @Cached InlinedConditionProfile executableCondition, + @Cached InlinedConditionProfile instantiableCondition, + @Cached InlinedBranchProfile unsupportedError, + @Cached InlinedBranchProfile arityError, + @Cached InlinedBranchProfile unsupportedArgumentError) { + Object[] functionArgs = toGuests.execute(node, languageContext, argsArray); Object result; - boolean executable = executableCondition.profile(interop.isExecutable(function)); + boolean executable = executableCondition.profile(node, interop.isExecutable(function)); try { if (executable) { result = interop.execute(function, functionArgs); - } else if (instantiableCondition.profile(interop.isInstantiable(function))) { + } else if (instantiableCondition.profile(node, interop.isInstantiable(function))) { result = interop.instantiate(function, functionArgs); } else { throw PolyglotInteropErrors.executeUnsupported(languageContext, function); } } catch (UnsupportedTypeException e) { - unsupportedArgumentError.enter(); + unsupportedArgumentError.enter(node); if (executable) { throw PolyglotInteropErrors.invalidExecuteArgumentType(languageContext, function, functionArgs); } else { throw PolyglotInteropErrors.invalidInstantiateArgumentType(languageContext, function, functionArgs); } } catch (ArityException e) { - arityError.enter(); + arityError.enter(node); if (executable) { throw PolyglotInteropErrors.invalidExecuteArity(languageContext, function, functionArgs, e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()); } else { @@ -144,10 +146,10 @@ Object doCached(PolyglotLanguageContext languageContext, Object function, Object e.getActualArity()); } } catch (UnsupportedMessageException e) { - unsupportedError.enter(); + unsupportedError.enter(node); throw PolyglotInteropErrors.executeUnsupported(languageContext, function); } - return toHost.execute(languageContext, result, resultClass, resultType); + return toHost.execute(node, languageContext, result, resultClass, resultType); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterable.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterable.java index 0cce030dcf9e..e257ef934477 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterable.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterable.java @@ -40,22 +40,24 @@ */ package com.oracle.truffle.polyglot; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.Objects; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.polyglot.PolyglotIterableFactory.CacheFactory.GetIteratorNodeGen; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.Objects; - class PolyglotIterable implements Iterable, PolyglotWrapper { final Object guestObject; @@ -210,15 +212,16 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary iterables, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { try { - return toHost.execute(languageContext, iterables.getIterator(receiver), Iterator.class, cache.iteratorType); + return toHost.execute(node, languageContext, iterables.getIterator(receiver), Iterator.class, cache.iteratorType); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.iterableUnsupported(languageContext, receiver, cache.valueType, "iterator()"); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterator.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterator.java index cd9af2c6dc39..9e3184807b2e 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterator.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotIterator.java @@ -40,8 +40,15 @@ */ package com.oracle.truffle.polyglot; +import java.lang.reflect.Type; +import java.util.ConcurrentModificationException; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Objects; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -49,17 +56,12 @@ import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.utilities.TriState; import com.oracle.truffle.polyglot.PolyglotIteratorFactory.CacheFactory.HasNextNodeGen; import com.oracle.truffle.polyglot.PolyglotIteratorFactory.CacheFactory.NextNodeGen; -import java.lang.reflect.Type; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Objects; - class PolyglotIterator implements Iterator, PolyglotWrapper { final Object guestObject; @@ -257,14 +259,15 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary iterators, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { try { return iterators.hasIteratorNextElement(receiver); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.iteratorUnsupported(languageContext, receiver, cache.valueType, "hasNext"); } } @@ -282,29 +285,30 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary iterators, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error, - @Cached BranchProfile stop) { + @Cached InlinedBranchProfile error, + @Cached InlinedBranchProfile stop) { TriState lastHasNext = (TriState) args[ARGUMENT_OFFSET]; try { Object next = iterators.getIteratorNextElement(receiver); if (lastHasNext == TriState.FALSE) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.iteratorConcurrentlyModified(languageContext, receiver, cache.valueType); } - return toHost.execute(languageContext, next, cache.valueClass, cache.valueType); + return toHost.execute(node, languageContext, next, cache.valueClass, cache.valueType); } catch (StopIterationException e) { - stop.enter(); + stop.enter(node); if (lastHasNext == TriState.TRUE) { throw PolyglotInteropErrors.iteratorConcurrentlyModified(languageContext, receiver, cache.valueType); } else { throw PolyglotInteropErrors.stopIteration(languageContext, receiver, cache.valueType); } } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.iteratorElementUnreadable(languageContext, receiver, cache.valueType); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java index 64c1cfeb0b8e..0288bfe25ff9 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java @@ -60,8 +60,6 @@ import org.graalvm.collections.UnmodifiableEconomicSet; import org.graalvm.polyglot.PolyglotAccess; import org.graalvm.polyglot.Value; -import org.graalvm.polyglot.impl.AbstractPolyglotImpl; -import org.graalvm.polyglot.impl.AbstractPolyglotImpl.APIAccess; import org.graalvm.polyglot.proxy.Proxy; import com.oracle.truffle.api.CallTarget; @@ -72,8 +70,12 @@ import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLogger; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.interop.InteropLibrary; @@ -83,6 +85,7 @@ import com.oracle.truffle.api.nodes.LanguageInfo; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.source.Source; final class PolyglotLanguageContext implements PolyglotImpl.VMObject { @@ -842,46 +845,28 @@ public Object toGuestValue(Node node, Object receiver) { return context.toGuestValue(node, receiver, false); } - static final class ToHostValueNode { - - final APIAccess apiAccess; - @CompilationFinal volatile Class cachedClass; - @CompilationFinal volatile PolyglotValueDispatch cachedValue; - - private ToHostValueNode(AbstractPolyglotImpl polyglot) { - this.apiAccess = polyglot.getAPIAccess(); - } - - Value execute(PolyglotLanguageContext languageContext, Object value) { - Object receiver = value; - Class cachedClassLocal = cachedClass; - PolyglotValueDispatch cache; - if (cachedClassLocal != Generic.class) { - if (cachedClassLocal == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - cachedClass = receiver.getClass(); - cachedValue = cache = languageContext.lazy.languageInstance.lookupValueCache(languageContext.context, receiver); - } else if (value.getClass() == cachedClassLocal) { - receiver = CompilerDirectives.inInterpreter() ? receiver : CompilerDirectives.castExact(receiver, cachedClassLocal); - cache = cachedValue; - if (cache == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // invalid state retry next time for now do generic - } else { - return apiAccess.newValue(cache, languageContext, receiver); - } - } else { - CompilerDirectives.transferToInterpreterAndInvalidate(); - cachedClass = Generic.class; // switch to generic - cachedValue = null; - // fall through to generic - } - } + @GenerateInline(true) + @GenerateCached(false) + abstract static class ToHostValueNode extends Node { + + abstract Value execute(Node node, PolyglotLanguageContext languageContext, Object value); + + @Specialization(guards = "value.getClass() == cachedClass", limit = "3") + Value doCached(PolyglotLanguageContext languageContext, Object value, + @Cached("value.getClass()") Class cachedClass, + @Cached("lookupDispatch(languageContext, value)") PolyglotValueDispatch cachedValue) { + Object receiver = CompilerDirectives.inInterpreter() ? value : CompilerDirectives.castExact(value, cachedClass); + return cachedValue.impl.getAPIAccess().newValue(cachedValue, languageContext, receiver); + } + + @Specialization(replaces = "doCached") + Value doGeneric(PolyglotLanguageContext languageContext, Object value) { return languageContext.asValue(value); } - public static ToHostValueNode create(AbstractPolyglotImpl polyglot) { - return new ToHostValueNode(polyglot); + @NeverDefault + static PolyglotValueDispatch lookupDispatch(PolyglotLanguageContext languageContext, Object value) { + return languageContext.lazy.languageInstance.lookupValueCache(languageContext.context, value); } } @@ -1018,118 +1003,99 @@ private static void validateLocationAndFrame(LanguageInfo viewLanguage, Node loc } @GenerateUncached + @GenerateInline abstract static class ToGuestValueNode extends Node { - abstract Object execute(PolyglotLanguageContext context, Object receiver); + abstract Object execute(Node node, PolyglotLanguageContext context, Object receiver); @Specialization(guards = "receiver == null") - Object doNull(PolyglotLanguageContext context, @SuppressWarnings("unused") Object receiver) { - return context.toGuestValue(this, receiver); + static Object doNull(Node node, PolyglotLanguageContext context, @SuppressWarnings("unused") Object receiver) { + return context.toGuestValue(node, receiver); } @Specialization(guards = {"receiver != null", "receiver.getClass() == cachedReceiver"}, limit = "3") - Object doCached(PolyglotLanguageContext context, Object receiver, @Cached("receiver.getClass()") Class cachedReceiver) { - return context.toGuestValue(this, cachedReceiver.cast(receiver)); + static Object doCached(Node node, PolyglotLanguageContext context, Object receiver, @Cached("receiver.getClass()") Class cachedReceiver) { + return context.toGuestValue(node, cachedReceiver.cast(receiver)); } @Specialization(replaces = "doCached") @TruffleBoundary - Object doUncached(PolyglotLanguageContext context, Object receiver) { - return context.toGuestValue(this, receiver); + static Object doUncached(Node node, PolyglotLanguageContext context, Object receiver) { + return context.toGuestValue(node, receiver); } } - static final class ToGuestValuesNode extends Node { + @GenerateInline + @GenerateCached(false) + abstract static class ToGuestValuesNode extends Node { - @Children private volatile ToGuestValueNode[] toGuestValue; - @CompilationFinal private volatile boolean needsCopy = false; - @CompilationFinal private volatile boolean generic = false; - - private ToGuestValuesNode() { - } + abstract Object[] execute(Node node, PolyglotLanguageContext context, Object[] args); - public Object[] apply(PolyglotLanguageContext context, Object[] args) { - ToGuestValueNode[] nodes = this.toGuestValue; - if (nodes == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - nodes = new ToGuestValueNode[args.length]; - for (int i = 0; i < nodes.length; i++) { - nodes[i] = insert(PolyglotLanguageContextFactory.ToGuestValueNodeGen.create()); - } - toGuestValue = nodes; - } - if (args.length == nodes.length) { - // fast path - if (nodes.length == 0) { - return args; - } else { - Object[] newArgs = fastToGuestValuesUnroll(nodes, context, args); - return newArgs; - } - } else { - if (!generic || nodes.length != 1) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - nodes = Arrays.copyOf(nodes, 1); - if (nodes[0] == null) { - nodes[0] = insert(PolyglotLanguageContextFactory.ToGuestValueNodeGen.create()); - } - this.toGuestValue = nodes; - this.generic = true; - } - if (args.length == 0) { - return args; - } - return fastToGuestValues(nodes[0], context, args); - } + @Specialization(guards = "args.length == 0") + @SuppressWarnings("unused") + static Object[] doZero(PolyglotLanguageContext context, Object[] args) { + return args; } /* * Specialization for constant number of arguments. Uses a profile for each argument. */ @ExplodeLoop - private Object[] fastToGuestValuesUnroll(ToGuestValueNode[] nodes, PolyglotLanguageContext context, Object[] args) { - Object[] newArgs = needsCopy ? new Object[nodes.length] : args; - for (int i = 0; i < nodes.length; i++) { + @Specialization(replaces = {"doZero"}, guards = "args.length == toGuestValues.length", limit = "1") + static Object[] doCached(Node node, PolyglotLanguageContext context, Object[] args, + @Cached("createArray(args.length)") ToGuestValueNode[] toGuestValues, + @Shared("needsCopy") @Cached InlinedBranchProfile needsCopyProfile) { + boolean needsCopy = needsCopyProfile.wasEntered(node); + Object[] newArgs = needsCopy ? new Object[toGuestValues.length] : args; + for (int i = 0; i < toGuestValues.length; i++) { Object arg = args[i]; - Object newArg = nodes[i].execute(context, arg); + Object newArg = toGuestValues[i].execute(toGuestValues[i], context, arg); if (needsCopy) { newArgs[i] = newArg; } else if (arg != newArg) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - newArgs = new Object[nodes.length]; + needsCopyProfile.enter(node); + needsCopy = true; + newArgs = new Object[toGuestValues.length]; System.arraycopy(args, 0, newArgs, 0, args.length); newArgs[i] = newArg; - needsCopy = true; } } return newArgs; } /* - * Specialization that supports multiple argument lengths but uses a single profile for all - * arguments. + * Specialization for constant number of arguments. Uses a profile for each argument. */ - private Object[] fastToGuestValues(ToGuestValueNode node, PolyglotLanguageContext context, Object[] args) { - assert toGuestValue[0] != null; + @Specialization(replaces = {"doZero", "doCached"}) + static Object[] doGeneric(Node node, PolyglotLanguageContext context, Object[] args, + @Cached ToGuestValueNode toGuest, + @Shared("needsCopy") @Cached InlinedBranchProfile needsCopyProfile) { + + boolean needsCopy = needsCopyProfile.wasEntered(node); Object[] newArgs = needsCopy ? new Object[args.length] : args; for (int i = 0; i < args.length; i++) { Object arg = args[i]; - Object newArg = node.execute(context, arg); + Object newArg = toGuest.execute(node, context, arg); if (needsCopy) { newArgs[i] = newArg; } else if (arg != newArg) { - CompilerDirectives.transferToInterpreterAndInvalidate(); + needsCopyProfile.enter(node); + needsCopy = true; newArgs = new Object[args.length]; System.arraycopy(args, 0, newArgs, 0, args.length); newArgs[i] = newArg; - needsCopy = true; } } return newArgs; } - public static ToGuestValuesNode create() { - return new ToGuestValuesNode(); + @NeverDefault + static ToGuestValueNode[] createArray(int length) { + ToGuestValueNode[] nodes = new ToGuestValueNode[length]; + for (int i = 0; i < nodes.length; i++) { + nodes[i] = PolyglotLanguageContextFactory.ToGuestValueNodeGen.create(); + } + return nodes; } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotList.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotList.java index e3dad61a6eba..91a6dd54d6f8 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotList.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotList.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleSafepoint; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -55,7 +56,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValueNode; import com.oracle.truffle.polyglot.PolyglotListFactory.CacheFactory.RemoveNodeGen; import com.oracle.truffle.polyglot.PolyglotListFactory.CacheFactory.SetNodeGen; @@ -282,22 +284,23 @@ abstract static class GetNode extends PolyglotListNode { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") - Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + final Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; Object result = null; assert key instanceof Integer; int index = (int) key; try { - return toHost.execute(languageContext, interop.readArrayElement(receiver, index), cache.valueClass, cache.valueType); + return toHost.execute(node, languageContext, interop.readArrayElement(receiver, index), cache.valueClass, cache.valueType); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, index); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "get()"); } } @@ -321,29 +324,30 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") - Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + final Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { - Object value = toGuest.execute(languageContext, args[ARGUMENT_OFFSET]); + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { + Object value = toGuest.execute(node, languageContext, args[ARGUMENT_OFFSET]); long size = 0; try { size = interop.getArraySize(receiver); if (interop.isArrayElementInsertable(receiver, size)) { interop.writeArrayElement(receiver, size, value); } else { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "add"); } } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "add"); } catch (UnsupportedTypeException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListValue(languageContext, receiver, cache.valueType, size, value); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, size); } return true; @@ -362,20 +366,21 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") - Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + final Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; assert key instanceof Integer; int index = (int) key; if (index < 0) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, index); } - Object value = toGuest.execute(languageContext, args[ARGUMENT_OFFSET + 1]); + Object value = toGuest.execute(node, languageContext, args[ARGUMENT_OFFSET + 1]); try { long size = interop.getArraySize(receiver); if (interop.isArrayElementInsertable(receiver, size)) { @@ -389,17 +394,17 @@ Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object // write new element to list interop.writeArrayElement(receiver, index, value); } else { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "add"); } } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "add"); } catch (UnsupportedTypeException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListValue(languageContext, receiver, cache.valueType, index, value); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, index); } return true; @@ -418,25 +423,26 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") - Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + final Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; assert key instanceof Integer; int index = (int) key; - Object value = toGuest.execute(languageContext, args[ARGUMENT_OFFSET + 1]); + Object value = toGuest.execute(node, languageContext, args[ARGUMENT_OFFSET + 1]); try { interop.writeArrayElement(receiver, index, value); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, index); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "set"); } catch (UnsupportedTypeException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListValue(languageContext, receiver, cache.valueType, (int) key, value); } return null; @@ -456,20 +462,21 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") - Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + final Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; assert key instanceof Integer; int index = (int) key; try { interop.removeArrayElement(receiver, index); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidListIndex(languageContext, receiver, cache.valueType, index); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.listUnsupported(languageContext, receiver, cache.valueType, "remove"); } return null; diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMap.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMap.java index ed3fbeefba99..96a9aecb0fb1 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMap.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMap.java @@ -56,6 +56,7 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropException; @@ -67,7 +68,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValueNode; import com.oracle.truffle.polyglot.PolyglotMapFactory.CacheFactory.EntrySetNodeGen; import com.oracle.truffle.polyglot.PolyglotMapFactory.CacheFactory.HashEntriesIteratorNodeGen; @@ -521,13 +523,14 @@ abstract static class ContainsKeyNode extends PolyglotMapNode { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest) { + @Cached(inline = true) ToGuestValueNode toGuest) { Object key = args[ARGUMENT_OFFSET]; if (interop.hasHashEntries(receiver)) { - return interop.isHashEntryReadable(receiver, toGuest.execute(languageContext, key)); + return interop.isHashEntryReadable(receiver, toGuest.execute(node, languageContext, key)); } if (cache.memberKey && interop.hasMembers(receiver)) { if (isObjectKey(key)) { @@ -556,11 +559,12 @@ abstract static class EntrySet extends PolyglotMapNode { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { PolyglotMap originalMap = (PolyglotMap) args[ARGUMENT_OFFSET]; if (interop.hasHashEntries(receiver)) { @@ -576,7 +580,7 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv try { truffleKeys = interop.getMembers(receiver); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); return Collections.emptySet(); } keys = PolyglotList.create(languageContext, truffleKeys, false, String.class, null); @@ -585,7 +589,7 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv try { elemSize = interop.getArraySize(receiver); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); elemSize = 0; } } @@ -611,17 +615,18 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unchecked", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, + @Cached(inline = true) ToGuestValueNode toGuest, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; Object result; try { if (interop.hasHashEntries(receiver)) { - result = interop.readHashValue(receiver, toGuest.execute(languageContext, key)); + result = interop.readHashValue(receiver, toGuest.execute(node, languageContext, key)); } else if (cache.memberKey && interop.hasMembers(receiver)) { if (isObjectKey(key)) { result = interop.readMember(receiver, ((String) key)); @@ -638,10 +643,10 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv return null; } } catch (UnknownIdentifierException | InvalidArrayIndexException | UnknownKeyException | UnsupportedMessageException e) { - error.enter(); + error.enter(node); return null; } - return toHost.execute(languageContext, result, cache.valueClass, cache.valueType); + return toHost.execute(node, languageContext, result, cache.valueClass, cache.valueType); } } @@ -657,17 +662,18 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; - Object guestValue = toGuest.execute(languageContext, args[ARGUMENT_OFFSET + 1]); + Object guestValue = toGuest.execute(node, languageContext, args[ARGUMENT_OFFSET + 1]); try { boolean supported = false; if (interop.hasHashEntries(receiver)) { - interop.writeHashEntry(receiver, toGuest.execute(languageContext, key), guestValue); + interop.writeHashEntry(receiver, toGuest.execute(node, languageContext, key), guestValue); return null; } else if (cache.memberKey && interop.hasMembers(receiver)) { supported = true; @@ -682,14 +688,14 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv return null; } } - error.enter(); + error.enter(node); if (!supported) { throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "put"); } else { throw PolyglotInteropErrors.invalidMapIdentifier(languageContext, receiver, getKeyType(), getValueType(), key); } } catch (UnknownIdentifierException | InvalidArrayIndexException | UnknownKeyException | UnsupportedMessageException | UnsupportedTypeException e) { - error.enter(); + error.enter(node); throw error(languageContext, receiver, e, key, guestValue); } } @@ -720,16 +726,17 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; try { boolean supported = false; if (interop.hasHashEntries(receiver)) { - interop.removeHashEntry(receiver, toGuest.execute(languageContext, key)); + interop.removeHashEntry(receiver, toGuest.execute(node, languageContext, key)); return null; } else if (cache.memberKey && interop.hasMembers(receiver)) { supported = true; @@ -745,17 +752,17 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv } } - error.enter(); + error.enter(node); if (!supported) { throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "remove"); } else { return null; } } catch (UnknownIdentifierException | InvalidArrayIndexException | UnknownKeyException e) { - error.enter(); + error.enter(node); return null; } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "remove"); } } @@ -774,18 +781,19 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile error) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile error) { Object key = args[ARGUMENT_OFFSET]; Object expectedValue = args[ARGUMENT_OFFSET + 1]; try { boolean supported = false; if (interop.hasHashEntries(receiver)) { - Object guestKey = toGuest.execute(languageContext, key); - Object guestExcpectedValue = toGuest.execute(languageContext, expectedValue); + Object guestKey = toGuest.execute(this, languageContext, key); + Object guestExcpectedValue = toGuest.execute(node, languageContext, expectedValue); Object readValue = interop.readHashValue(receiver, guestKey); if (!equalsBoundary(guestExcpectedValue, readValue)) { return false; @@ -797,7 +805,7 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv if (isObjectKey(key)) { String member = (String) key; Object readValue = interop.readMember(receiver, member); - Object guestExpectedValue = toGuest.execute(languageContext, expectedValue); + Object guestExpectedValue = toGuest.execute(node, languageContext, expectedValue); if (!equalsBoundary(guestExpectedValue, readValue)) { return false; } @@ -809,7 +817,7 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv if (isArrayKey(key)) { int index = intValue(key); Object readValue = interop.readArrayElement(receiver, index); - Object guestExpectedValue = toGuest.execute(languageContext, expectedValue); + Object guestExpectedValue = toGuest.execute(node, languageContext, expectedValue); if (!equalsBoundary(guestExpectedValue, readValue)) { return false; } @@ -817,17 +825,17 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv return true; } } - error.enter(); + error.enter(node); if (!supported) { throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "remove"); } else { return false; } } catch (UnknownIdentifierException | InvalidArrayIndexException | UnknownKeyException e) { - error.enter(); + error.enter(node); return false; } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "remove"); } } @@ -851,10 +859,12 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") + @SuppressWarnings({"unchecked", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, @SuppressWarnings("unused") Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { if (interop.hasHashEntries(receiver)) { try { Object iterator = interop.getHashEntriesIterator(receiver); @@ -862,13 +872,13 @@ protected Object doCached(PolyglotLanguageContext languageContext, Object receiv Type useKeyType = cache.keyType != null ? cache.keyType : Object.class; Type useValueType = cache.valueType != null ? cache.valueType : Object.class; genericType = new ParameterizedTypeImpl(Iterator.class, new ParameterizedTypeImpl(Map.Entry.class, useKeyType, useValueType)); - return toHost.execute(languageContext, iterator, Iterator.class, genericType); + return toHost.execute(node, languageContext, iterator, Iterator.class, genericType); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "iterator"); } } else { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "iterator"); } } @@ -886,18 +896,20 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, @SuppressWarnings("unused") Object[] args, + @SuppressWarnings({"unused", "truffle-static-method"}) + protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { if (interop.hasHashEntries(receiver)) { try { return interop.getHashSize(receiver); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "size"); } } else { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.mapUnsupported(languageContext, receiver, getKeyType(), getValueType(), "size"); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMapEntry.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMapEntry.java index 69eee42c46f3..be30599d0b55 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMapEntry.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotMapEntry.java @@ -40,7 +40,12 @@ */ package com.oracle.truffle.polyglot; +import java.lang.reflect.Type; +import java.util.Map; +import java.util.Objects; + import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -48,11 +53,8 @@ import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; - -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Objects; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; class PolyglotMapEntry implements Map.Entry, PolyglotWrapper { @@ -272,25 +274,26 @@ protected String getOperationName() { } @Specialization(limit = "LIMIT") - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCached(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary interop, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { + @Cached InlinedBranchProfile error) { if (interop.hasArrayElements(receiver)) { Object result; try { result = interop.readArrayElement(receiver, index); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw unsupported(languageContext, receiver); } catch (InvalidArrayIndexException e) { - error.enter(); + error.enter(node); throw invalidArrayIndex(languageContext, receiver, e.getInvalidIndex()); } - return toHost.execute(languageContext, result, elementClass, elementType); + return toHost.execute(node, languageContext, result, elementClass, elementType); } else { - error.enter(); + error.enter(node); throw unsupported(languageContext, receiver); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotObjectProxyHandler.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotObjectProxyHandler.java index 28101c58513c..f7fcc53cbc75 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotObjectProxyHandler.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotObjectProxyHandler.java @@ -51,7 +51,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -61,10 +63,10 @@ import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValuesNode; -import com.oracle.truffle.polyglot.PolyglotObjectProxyHandlerFactory.ProxyInvokeNodeGen; +import com.oracle.truffle.polyglot.PolyglotObjectProxyHandlerFactory.ObjectProxyNodeGen; final class PolyglotObjectProxyHandler implements InvocationHandler, PolyglotWrapper { @@ -116,14 +118,11 @@ static Object newProxyInstance(Class clazz, Object obj, PolyglotLanguageConte return Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new PolyglotObjectProxyHandler(obj, languageContext, clazz)); } - static final class ObjectProxyNode extends HostToGuestRootNode { + abstract static class ObjectProxyNode extends HostToGuestRootNode { final Class receiverClass; final Class interfaceType; - @Child private ProxyInvokeNode proxyInvoke = ProxyInvokeNodeGen.create(); - @Child private ToGuestValuesNode toGuests = ToGuestValuesNode.create(); - ObjectProxyNode(PolyglotLanguageInstance languageInstance, Class receiverType, Class interfaceType) { super(languageInstance); this.receiverClass = receiverType; @@ -141,10 +140,13 @@ public String getName() { return "InterfaceProxy<" + receiverClass + ">"; } - @Override - protected Object executeImpl(PolyglotLanguageContext languageContext, Object receiver, Object[] args) { + @Specialization + static Object doDefault(PolyglotLanguageContext languageContext, Object receiver, Object[] args, + @Bind("this") Node node, + @Cached ProxyInvokeNode proxyInvoke, + @Cached ToGuestValuesNode toGuests) { Method method = (Method) args[ARGUMENT_OFFSET]; - Object[] arguments = toGuests.apply(languageContext, (Object[]) args[ARGUMENT_OFFSET + 1]); + Object[] arguments = toGuests.execute(node, languageContext, (Object[]) args[ARGUMENT_OFFSET + 1]); return proxyInvoke.execute(languageContext, receiver, method, arguments); } @@ -166,7 +168,7 @@ public boolean equals(Object obj) { } static CallTarget lookup(PolyglotLanguageContext languageContext, Class receiverClass, Class interfaceClass) { - ObjectProxyNode node = new ObjectProxyNode(languageContext.getLanguageInstance(), receiverClass, interfaceClass); + ObjectProxyNode node = ObjectProxyNodeGen.create(languageContext.getLanguageInstance(), receiverClass, interfaceClass); CallTarget target = lookupHostCodeCache(languageContext, node, CallTarget.class); if (target == null) { target = installHostCodeCache(languageContext, node, node.getCallTarget(), CallTarget.class); @@ -192,21 +194,28 @@ abstract static class ProxyInvokeNode extends Node { * interned. */ @Specialization(guards = {"cachedMethod == method"}, limit = "LIMIT") - @SuppressWarnings("unused") + + /* + * One of the rare occurrences where we want to suppress truffle warnings, we can't make + * this method static even though it is recommended. + */ + @SuppressWarnings({"unused", "truffle-static-method"}) protected Object doCachedMethod(PolyglotLanguageContext languageContext, Object receiver, Method method, Object[] arguments, + @Bind("this") Node node, @Cached("method") Method cachedMethod, @Cached("method.getName()") String name, @Cached("getMethodReturnType(method)") Class returnClass, @Cached("getMethodGenericReturnType(method)") Type returnType, @CachedLibrary("receiver") InteropLibrary receivers, @CachedLibrary(limit = "LIMIT") InteropLibrary members, - @Cached ConditionProfile branchProfile, + @Cached InlinedConditionProfile branchProfile, @Cached PolyglotToHostNode toHost, - @Cached BranchProfile error) { - Object result = invokeOrExecute(languageContext, receiver, arguments, name, receivers, members, branchProfile, error); - return toHost.execute(languageContext, result, returnClass, returnType); + @Cached InlinedBranchProfile error) { + Object result = invokeOrExecute(node, languageContext, receiver, arguments, name, receivers, members, branchProfile, error); + return toHost.execute(node, languageContext, result, returnClass, returnType); } + @NeverDefault static Class getMethodReturnType(Method method) { if (method == null || method.getReturnType() == void.class) { return Object.class; @@ -214,6 +223,7 @@ static Class getMethodReturnType(Method method) { return method.getReturnType(); } + @NeverDefault static Type getMethodGenericReturnType(Method method) { if (method == null || method.getReturnType() == void.class) { return Object.class; @@ -221,9 +231,9 @@ static Type getMethodGenericReturnType(Method method) { return method.getGenericReturnType(); } - private Object invokeOrExecute(PolyglotLanguageContext polyglotContext, Object receiver, Object[] arguments, String member, InteropLibrary receivers, + private Object invokeOrExecute(Node node, PolyglotLanguageContext polyglotContext, Object receiver, Object[] arguments, String member, InteropLibrary receivers, InteropLibrary members, - ConditionProfile invokeProfile, BranchProfile error) { + InlinedConditionProfile invokeProfile, InlinedBranchProfile error) { try { boolean localInvokeFailed = this.invokeFailed; if (!localInvokeFailed) { @@ -236,7 +246,7 @@ private Object invokeOrExecute(PolyglotLanguageContext polyglotContext, Object r } } if (localInvokeFailed) { - if (invokeProfile.profile(receivers.isMemberInvocable(receiver, member))) { + if (invokeProfile.profile(node, receivers.isMemberInvocable(receiver, member))) { return receivers.invokeMember(receiver, member, arguments); } else if (receivers.isMemberReadable(receiver, member)) { Object readMember = receivers.readMember(receiver, member); @@ -247,19 +257,19 @@ private Object invokeOrExecute(PolyglotLanguageContext polyglotContext, Object r } } } - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invokeUnsupported(polyglotContext, receiver, member); } catch (UnknownIdentifierException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invokeUnsupported(polyglotContext, receiver, member); } catch (UnsupportedTypeException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidExecuteArgumentType(polyglotContext, receiver, e.getSuppliedValues()); } catch (ArityException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invalidExecuteArity(polyglotContext, receiver, arguments, e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { - error.enter(); + error.enter(node); throw PolyglotInteropErrors.invokeUnsupported(polyglotContext, receiver, member); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java index da2e49b6fbd3..87222a5c720e 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java @@ -40,27 +40,37 @@ */ package com.oracle.truffle.polyglot; -import static org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostLanguageService; - import java.lang.reflect.Type; +import org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostLanguageService; + import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; +import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField; +import com.oracle.truffle.api.dsl.InlineSupport.RequiredField; +import com.oracle.truffle.api.dsl.InlineSupport.StateField; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; +@GenerateInline +@GenerateCached(false) abstract class PolyglotToHostNode extends Node { - abstract Object execute(PolyglotLanguageContext languageContext, Object value, Class targetType, Type genericType); + abstract Object execute(Node node, PolyglotLanguageContext languageContext, Object value, Class targetType, Type genericType); @Specialization - static Object doDefault(PolyglotLanguageContext languageContext, Object value, Class targetType, Type genericType, - @Cached("languageContext.context.engine.host") AbstractHostLanguageService host, - @Cached("createToHostNode(host)") Node toHostNode) { - return host.toHostType(toHostNode, languageContext.context.getHostContextImpl(), value, targetType, genericType); + static Object doDefault(Node node, PolyglotLanguageContext languageContext, Object value, Class targetType, Type genericType, + @Cached(value = "languageContext.context.engine.host", neverDefault = true) AbstractHostLanguageService host, + @Cached(inlineMethod = "inlineToHost") Node toHostNode) { + return host.toHostType(toHostNode, node, languageContext.context.getHostContextImpl(), value, targetType, genericType); } - static Node createToHostNode(AbstractHostLanguageService host) { - return (Node) host.createToHostTypeNode(); + static Node inlineToHost( + @RequiredField(bits = 3, value = StateField.class) // + @RequiredField(type = Node.class, value = ReferenceField.class) InlineTarget target) { + return (Node) PolyglotContextImpl.requireContext().engine.host.inlineToHostTypeNode(target); } } diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotValueDispatch.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotValueDispatch.java index 0127796bf299..4d7af5868278 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotValueDispatch.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotValueDispatch.java @@ -67,7 +67,11 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -80,20 +84,27 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValueNode; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValuesNode; import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToHostValueNode; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsClassLiteralNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsDateNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsDurationNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsInstantNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsNativePointerNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsTimeNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsTimeZoneNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.AsTypeLiteralNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.CanExecuteNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.CanInstantiateNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.CanInvokeNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.ExecuteNoArgsNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.ExecuteNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.ExecuteVoidNoArgsNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.ExecuteVoidNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.GetArrayElementNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.GetArraySizeNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.GetBufferSizeNodeGen; @@ -116,6 +127,8 @@ import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.HasIteratorNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.HasMemberNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.HasMembersNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.InvokeNoArgsNodeGen; +import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.InvokeNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.IsBufferWritableNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.IsDateNodeGen; import com.oracle.truffle.polyglot.PolyglotValueDispatchFactory.InteropValueFactory.IsDurationNodeGen; @@ -1791,7 +1804,7 @@ public T as(Object languageContext, Object receiver, Class targetType) { Object prev = hostEnter(context); try { if (context != null) { - return language.engine.host.toHostType(null, context.context.getHostContextImpl(), receiver, targetType, targetType); + return language.engine.host.toHostType(null, null, context.context.getHostContextImpl(), receiver, targetType, targetType); } else { // disconnected primitive value T result = (T) EngineAccessor.HOST.convertPrimitiveLossy(receiver, targetType); @@ -1884,10 +1897,6 @@ protected Class getReceiverType() { return polyglot.receiverType; } - protected final ToHostValueNode createToHost() { - return ToHostValueNode.create(getImpl()); - } - @Override public final String getName() { return "org.graalvm.polyglot.Value<" + polyglot.receiverType.getSimpleName() + ">." + getOperationName(); @@ -2041,8 +2050,8 @@ static final class InteropValue extends PolyglotValueDispatch { InteropValue(PolyglotImpl polyglot, PolyglotLanguageInstance languageInstance, Object receiverObject, Class receiverType) { super(polyglot, languageInstance); this.receiverType = receiverType; - this.asClassLiteral = createTarget(new AsClassLiteralNode(this)); - this.asTypeLiteral = createTarget(new AsTypeLiteralNode(this)); + this.asClassLiteral = createTarget(AsClassLiteralNodeGen.create(this)); + this.asTypeLiteral = createTarget(AsTypeLiteralNodeGen.create(this)); this.isNativePointer = createTarget(IsNativePointerNodeGen.create(this)); this.asNativePointer = createTarget(AsNativePointerNodeGen.create(this)); this.hasArrayElements = createTarget(HasArrayElementsNodeGen.create(this)); @@ -2070,16 +2079,16 @@ static final class InteropValue extends PolyglotValueDispatch { this.putMember = createTarget(PutMemberNodeGen.create(this)); this.removeMember = createTarget(RemoveMemberNodeGen.create(this)); this.isNull = createTarget(IsNullNodeGen.create(this)); - this.execute = createTarget(new ExecuteNode(this)); - this.executeNoArgs = createTarget(new ExecuteNoArgsNode(this)); - this.executeVoid = createTarget(new ExecuteVoidNode(this)); - this.executeVoidNoArgs = createTarget(new ExecuteVoidNoArgsNode(this)); + this.execute = createTarget(ExecuteNodeGen.create(this)); + this.executeNoArgs = createTarget(ExecuteNoArgsNodeGen.create(this)); + this.executeVoid = createTarget(ExecuteVoidNodeGen.create(this)); + this.executeVoidNoArgs = createTarget(ExecuteVoidNoArgsNodeGen.create(this)); this.newInstance = createTarget(NewInstanceNodeGen.create(this)); this.canInstantiate = createTarget(CanInstantiateNodeGen.create(this)); this.canExecute = createTarget(CanExecuteNodeGen.create(this)); this.canInvoke = createTarget(CanInvokeNodeGen.create(this)); - this.invoke = createTarget(new InvokeNode(this)); - this.invokeNoArgs = createTarget(new InvokeNoArgsNode(this)); + this.invoke = createTarget(InvokeNodeGen.create(this)); + this.invokeNoArgs = createTarget(InvokeNoArgsNodeGen.create(this)); this.hasMembers = createTarget(HasMembersNodeGen.create(this)); this.getMemberKeys = createTarget(GetMemberKeysNodeGen.create(this)); this.isDate = createTarget(IsDateNodeGen.create(this)); @@ -2872,7 +2881,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { return objects.isDate(receiver); } @@ -2896,12 +2905,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return objects.asDate(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.isNull(receiver)) { return null; } else { @@ -2928,7 +2938,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { return objects.isTime(receiver); } @@ -2952,12 +2962,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return objects.asTime(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.isNull(receiver)) { return null; } else { @@ -2984,7 +2995,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { return objects.isTimeZone(receiver); } @@ -3008,12 +3019,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return objects.asTimeZone(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.isNull(receiver)) { return null; } else { @@ -3040,7 +3052,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { return objects.isDuration(receiver); } @@ -3064,12 +3076,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return objects.asDuration(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.isNull(receiver)) { return null; } else { @@ -3097,12 +3110,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return objects.asInstant(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.isNull(receiver)) { return null; } else { @@ -3112,9 +3126,7 @@ static Object doCached(PolyglotLanguageContext context, Object receiver, Object[ } } - private static class AsClassLiteralNode extends InteropNode { - - @Child PolyglotToHostNode toHost = PolyglotToHostNodeGen.create(); + abstract static class AsClassLiteralNode extends InteropNode { protected AsClassLiteralNode(InteropValue interop) { super(interop); @@ -3130,16 +3142,15 @@ protected String getOperationName() { return "as"; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { - return toHost.execute(context, receiver, (Class) args[ARGUMENT_OFFSET], null); + @Specialization + final Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached PolyglotToHostNode toHost) { + return toHost.execute(this, context, receiver, (Class) args[ARGUMENT_OFFSET], null); } } - private static class AsTypeLiteralNode extends InteropNode { - - @Child PolyglotToHostNode toHost = PolyglotToHostNodeGen.create(); + abstract static class AsTypeLiteralNode extends InteropNode { protected AsTypeLiteralNode(InteropValue interop) { super(interop); @@ -3155,10 +3166,11 @@ protected String getOperationName() { return "as"; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { + @Specialization + final Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached PolyglotToHostNode toHost) { TypeLiteral typeLiteral = (TypeLiteral) args[ARGUMENT_OFFSET]; - return toHost.execute(context, receiver, typeLiteral.getRawType(), typeLiteral.getType()); + return toHost.execute(this, context, receiver, typeLiteral.getRawType(), typeLiteral.getType()); } } @@ -3180,7 +3192,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary natives) { return natives.isPointer(receiver); } @@ -3205,12 +3217,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary natives, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return natives.asPointer(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw cannotConvert(context, receiver, long.class, "asNativePointer()", "isNativeObject()", "Value cannot be converted to a native pointer."); } } @@ -3234,7 +3247,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary arrays) { return arrays.hasArrayElements(receiver); } @@ -3259,12 +3272,14 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, objects.getMembers(receiver)); + return toHost.execute(node, context, objects.getMembers(receiver)); } catch (UnsupportedMessageException e) { + unsupported.enter(node); return null; } } @@ -3288,18 +3303,19 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary arrays, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { long index = (long) args[ARGUMENT_OFFSET]; try { - return toHost.execute(context, arrays.readArrayElement(receiver, index)); + return toHost.execute(node, context, arrays.readArrayElement(receiver, index)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); return getArrayElementUnsupported(context, receiver); } catch (InvalidArrayIndexException e) { - unknown.enter(); + unknown.enter(node); throw invalidArrayIndex(context, receiver, index); } } @@ -3322,23 +3338,24 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary arrays, - @Cached ToGuestValueNode toGuestValue, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached(inline = true) ToGuestValueNode toGuestValue, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { long index = (long) args[ARGUMENT_OFFSET]; - Object value = toGuestValue.execute(context, args[ARGUMENT_OFFSET + 1]); + Object value = toGuestValue.execute(node, context, args[ARGUMENT_OFFSET + 1]); try { arrays.writeArrayElement(receiver, index, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); setArrayElementUnsupported(context, receiver); } catch (UnsupportedTypeException e) { - invalidValue.enter(); + invalidValue.enter(node); throw invalidArrayValue(context, receiver, index, value); } catch (InvalidArrayIndexException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidArrayIndex(context, receiver, index); } return null; @@ -3363,19 +3380,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary arrays, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex) { long index = (long) args[ARGUMENT_OFFSET]; Object value; try { arrays.removeArrayElement(receiver, index); value = Boolean.TRUE; } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw removeArrayElementUnsupported(context, receiver); } catch (InvalidArrayIndexException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidArrayIndex(context, receiver, index); } return value; @@ -3401,12 +3419,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary arrays, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return arrays.getArraySize(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); return getArraySizeUnsupported(context, receiver); } } @@ -3432,7 +3451,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary buffers) { return buffers.hasBufferElements(receiver); } @@ -3457,12 +3476,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return buffers.isBufferWritable(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getBufferSizeUnsupported(context, receiver); } } @@ -3487,12 +3507,13 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return buffers.getBufferSize(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getBufferSizeUnsupported(context, receiver); } } @@ -3517,18 +3538,19 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final long byteOffset = (long) args[ARGUMENT_OFFSET]; try { return buffers.readBufferByte(receiver, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferByteUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3552,22 +3574,23 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { final long byteOffset = (long) args[ARGUMENT_OFFSET]; final byte value = (byte) args[ARGUMENT_OFFSET + 1]; try { buffers.writeBufferByte(receiver, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferByte()", "isBufferWritable()"); } throw writeBufferByteUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3593,19 +3616,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; try { return buffers.readBufferShort(receiver, order, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferShortUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3629,23 +3653,24 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; final short value = (short) args[ARGUMENT_OFFSET + 2]; try { buffers.writeBufferShort(receiver, order, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferShort()", "isBufferWritable()"); } throw writeBufferShortUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3671,19 +3696,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; try { return buffers.readBufferInt(receiver, order, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferIntUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3707,23 +3733,24 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; final int value = (int) args[ARGUMENT_OFFSET + 2]; try { buffers.writeBufferInt(receiver, order, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferInt()", "isBufferWritable()"); } throw writeBufferIntUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3749,19 +3776,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; try { return buffers.readBufferLong(receiver, order, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferLongUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3785,23 +3813,24 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; final long value = (long) args[ARGUMENT_OFFSET + 2]; try { buffers.writeBufferLong(receiver, order, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferLong()", "isBufferWritable()"); } throw writeBufferLongUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3827,19 +3856,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; try { return buffers.readBufferFloat(receiver, order, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferFloatUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3863,23 +3893,23 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; final float value = (float) args[ARGUMENT_OFFSET + 2]; try { buffers.writeBufferFloat(receiver, order, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferFloat()", "isBufferWritable()"); } throw writeBufferFloatUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3905,19 +3935,20 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary buffers, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; try { return buffers.readBufferDouble(receiver, order, byteOffset); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw readBufferDoubleUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - unknown.enter(); + unknown.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } } @@ -3940,24 +3971,24 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary buffers, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidIndex, - @Cached BranchProfile invalidValue) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidIndex, + @Cached InlinedBranchProfile invalidValue) { final ByteOrder order = (ByteOrder) args[ARGUMENT_OFFSET]; final long byteOffset = (long) args[ARGUMENT_OFFSET + 1]; final double value = (double) args[ARGUMENT_OFFSET + 2]; try { buffers.writeBufferDouble(receiver, order, byteOffset, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (buffers.hasBufferElements(receiver)) { throw unsupported(context, receiver, "writeBufferDouble()", "isBufferWritable()"); } throw writeBufferDoubleUnsupported(context, receiver); } catch (InvalidBufferOffsetException e) { - invalidIndex.enter(); + invalidIndex.enter(node); throw invalidBufferIndex(context, receiver, e.getByteOffset(), e.getLength()); } return null; @@ -3984,25 +4015,25 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { String key = (String) args[ARGUMENT_OFFSET]; Object value; try { assert key != null : "should be handled already"; - value = toHost.execute(context, objects.readMember(receiver, key)); + value = toHost.execute(node, context, objects.readMember(receiver, key)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (objects.hasMembers(receiver)) { value = null; } else { return getMemberUnsupported(context, receiver, key); } } catch (UnknownIdentifierException e) { - unknown.enter(); + unknown.enter(node); value = null; } return value; @@ -4027,26 +4058,27 @@ protected Class[] getArgumentTypes() { } @Specialization - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary(limit = "CACHE_LIMIT") InteropLibrary objects, - @Cached ToGuestValueNode toGuestValue, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidValue, - @Cached BranchProfile unknown) { + @Cached(inline = true) ToGuestValueNode toGuestValue, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidValue, + @Cached InlinedBranchProfile unknown) { String key = (String) args[ARGUMENT_OFFSET]; Object originalValue = args[ARGUMENT_OFFSET + 1]; - Object value = toGuestValue.execute(context, originalValue); + Object value = toGuestValue.execute(node, context, originalValue); assert key != null; try { objects.writeMember(receiver, key, value); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw putMemberUnsupported(context, receiver); } catch (UnknownIdentifierException e) { - unknown.enter(); + unknown.enter(node); throw nonWritableMemberKey(context, receiver, key); } catch (UnsupportedTypeException e) { - invalidValue.enter(); + invalidValue.enter(node); throw invalidMemberValue(context, receiver, key, value); } return null; @@ -4070,10 +4102,10 @@ protected Class[] getArgumentTypes() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported, - @Cached BranchProfile unknown) { + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknown) { String key = (String) args[ARGUMENT_OFFSET]; Object value; try { @@ -4081,7 +4113,7 @@ static Object doCached(PolyglotLanguageContext context, Object receiver, Object[ objects.removeMember(receiver, key); value = Boolean.TRUE; } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (!objects.hasMembers(receiver)) { throw removeMemberUnsupported(context, receiver); } else if (objects.isMemberExisting(receiver, key)) { @@ -4090,7 +4122,7 @@ static Object doCached(PolyglotLanguageContext context, Object receiver, Object[ value = Boolean.FALSE; } } catch (UnknownIdentifierException e) { - unknown.enter(); + unknown.enter(node); if (objects.isMemberExisting(receiver, key)) { throw nonRemovableMemberKey(context, receiver, key); } else { @@ -4119,7 +4151,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary values) { return values.isNull(receiver); } @@ -4143,7 +4175,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { return objects.hasMembers(receiver); } @@ -4175,7 +4207,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { String key = (String) args[ARGUMENT_OFFSET]; return objects.isMemberExisting(receiver, key); @@ -4194,7 +4226,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary objects) { String key = (String) args[ARGUMENT_OFFSET]; return objects.isMemberInvocable(receiver, key); @@ -4219,7 +4251,7 @@ protected Class[] getArgumentTypes() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary executables) { return executables.isExecutable(receiver); } @@ -4243,44 +4275,46 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary instantiables) { return instantiables.isInstantiable(receiver); } } - private abstract static class AbstractExecuteNode extends InteropNode { - - @Child private InteropLibrary executables = InteropLibrary.getFactory().createDispatched(CACHE_LIMIT); - @Child private ToGuestValuesNode toGuestValues = ToGuestValuesNode.create(); - private final BranchProfile invalidArgument = BranchProfile.create(); - private final BranchProfile arity = BranchProfile.create(); - private final BranchProfile unsupported = BranchProfile.create(); + @ImportStatic(InteropNode.class) + @GenerateInline(true) + @GenerateCached(false) + abstract static class SharedExecuteNode extends Node { - protected AbstractExecuteNode(InteropValue interop) { - super(interop); - } + protected abstract Object executeShared(Node node, PolyglotLanguageContext context, Object receiver, Object[] args); - protected final Object executeShared(PolyglotLanguageContext context, Object receiver, Object[] args) { - Object[] guestArguments = toGuestValues.apply(context, args); + @Specialization(limit = "CACHE_LIMIT") + protected static Object doDefault(Node node, PolyglotLanguageContext context, Object receiver, Object[] args, + @CachedLibrary("receiver") InteropLibrary executables, + @Cached ToGuestValuesNode toGuestValues, + @Cached ToHostValueNode toHostValue, + @Cached InlinedBranchProfile invalidArgument, + @Cached InlinedBranchProfile arity, + @Cached InlinedBranchProfile unsupported) { + Object[] guestArguments = toGuestValues.execute(node, context, args); try { return executables.execute(receiver, guestArguments); } catch (UnsupportedTypeException e) { - invalidArgument.enter(); + invalidArgument.enter(node); throw invalidExecuteArgumentType(context, receiver, e); } catch (ArityException e) { - arity.enter(); + arity.enter(node); throw invalidExecuteArity(context, receiver, guestArguments, e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw executeUnsupported(context, receiver); } } } - private static class ExecuteVoidNode extends AbstractExecuteNode { + abstract static class ExecuteVoidNode extends InteropNode { protected ExecuteVoidNode(InteropValue interop) { super(interop); @@ -4291,9 +4325,10 @@ protected Class[] getArgumentTypes() { return new Class[]{PolyglotLanguageContext.class, polyglot.receiverType, Object[].class}; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { - executeShared(context, receiver, (Object[]) args[ARGUMENT_OFFSET]); + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached SharedExecuteNode executeNode) { + executeNode.executeShared(this, context, receiver, (Object[]) args[ARGUMENT_OFFSET]); return null; } @@ -4304,7 +4339,7 @@ protected String getOperationName() { } - private static class ExecuteVoidNoArgsNode extends AbstractExecuteNode { + abstract static class ExecuteVoidNoArgsNode extends InteropNode { private static final Object[] NO_ARGS = new Object[0]; @@ -4317,9 +4352,10 @@ protected Class[] getArgumentTypes() { return new Class[]{PolyglotLanguageContext.class, polyglot.receiverType}; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { - executeShared(context, receiver, NO_ARGS); + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached SharedExecuteNode executeNode) { + executeNode.executeShared(this, context, receiver, NO_ARGS); return null; } @@ -4330,13 +4366,10 @@ protected String getOperationName() { } - private static class ExecuteNode extends AbstractExecuteNode { - - private final ToHostValueNode toHostValue; + abstract static class ExecuteNode extends InteropNode { protected ExecuteNode(InteropValue interop) { super(interop); - this.toHostValue = ToHostValueNode.create(interop.impl); } @Override @@ -4344,9 +4377,11 @@ protected Class[] getArgumentTypes() { return new Class[]{PolyglotLanguageContext.class, polyglot.receiverType, Object[].class}; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { - return toHostValue.execute(context, executeShared(context, receiver, (Object[]) args[ARGUMENT_OFFSET])); + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached ToHostValueNode toHostValue, + @Cached SharedExecuteNode executeNode) { + return toHostValue.execute(this, context, executeNode.executeShared(this, context, receiver, (Object[]) args[ARGUMENT_OFFSET])); } @Override @@ -4356,13 +4391,10 @@ protected String getOperationName() { } - private static class ExecuteNoArgsNode extends AbstractExecuteNode { - - private final ToHostValueNode toHostValue; + abstract static class ExecuteNoArgsNode extends InteropNode { protected ExecuteNoArgsNode(InteropValue interop) { super(interop); - this.toHostValue = ToHostValueNode.create(interop.impl); } @Override @@ -4370,9 +4402,11 @@ protected Class[] getArgumentTypes() { return new Class[]{PolyglotLanguageContext.class, polyglot.receiverType}; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { - return toHostValue.execute(context, executeShared(context, receiver, ExecuteVoidNoArgsNode.NO_ARGS)); + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached ToHostValueNode toHostValue, + @Cached SharedExecuteNode executeNode) { + return toHostValue.execute(this, context, executeNode.executeShared(this, context, receiver, ExecuteVoidNoArgsNode.NO_ARGS)); } @Override @@ -4384,12 +4418,8 @@ protected String getOperationName() { abstract static class NewInstanceNode extends InteropNode { - @Child private ToGuestValuesNode toGuestValues = ToGuestValuesNode.create(); - private final ToHostValueNode toHostValue; - protected NewInstanceNode(InteropValue interop) { super(interop); - this.toHostValue = ToHostValueNode.create(interop.impl); } @Override @@ -4398,24 +4428,24 @@ protected Class[] getArgumentTypes() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary instantiables, @Cached ToGuestValuesNode toGuestValues, - @Cached("createToHost()") ToHostValueNode toHostValue, - @Cached BranchProfile arity, - @Cached BranchProfile invalidArgument, - @Cached BranchProfile unsupported) { - Object[] instantiateArguments = toGuestValues.apply(context, (Object[]) args[ARGUMENT_OFFSET]); + @Cached ToHostValueNode toHostValue, + @Cached InlinedBranchProfile arity, + @Cached InlinedBranchProfile invalidArgument, + @Cached InlinedBranchProfile unsupported) { + Object[] instantiateArguments = toGuestValues.execute(node, context, (Object[]) args[ARGUMENT_OFFSET]); try { - return toHostValue.execute(context, instantiables.instantiate(receiver, instantiateArguments)); + return toHostValue.execute(node, context, instantiables.instantiate(receiver, instantiateArguments)); } catch (UnsupportedTypeException e) { - invalidArgument.enter(); + invalidArgument.enter(node); throw invalidInstantiateArgumentType(context, receiver, instantiateArguments); } catch (ArityException e) { - arity.enter(); + arity.enter(node); throw invalidInstantiateArity(context, receiver, instantiateArguments, e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); return newInstanceUnsupported(context, receiver); } } @@ -4427,43 +4457,41 @@ protected String getOperationName() { } - private abstract static class AbstractInvokeNode extends InteropNode { + @ImportStatic(InteropNode.class) + @GenerateInline(true) + @GenerateCached(false) + abstract static class SharedInvokeNode extends Node { - @Child private InteropLibrary objects = InteropLibrary.getFactory().createDispatched(CACHE_LIMIT); - private final ToHostValueNode toHostValue; - private final BranchProfile invalidArgument = BranchProfile.create(); - private final BranchProfile arity = BranchProfile.create(); - private final BranchProfile unsupported = BranchProfile.create(); - private final BranchProfile unknownIdentifier = BranchProfile.create(); + protected abstract Object executeShared(Node node, PolyglotLanguageContext context, Object receiver, String key, Object[] guestArguments); - protected AbstractInvokeNode(InteropValue interop) { - super(interop); - this.toHostValue = ToHostValueNode.create(interop.impl); - } - - protected final Object executeShared(PolyglotLanguageContext context, Object receiver, String key, Object[] guestArguments) { + @Specialization(limit = "CACHE_LIMIT") + protected static Object doDefault(Node node, PolyglotLanguageContext context, Object receiver, String key, Object[] guestArguments, + @CachedLibrary("receiver") InteropLibrary objects, + @Cached ToHostValueNode toHostValue, + @Cached InlinedBranchProfile invalidArgument, + @Cached InlinedBranchProfile arity, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile unknownIdentifier) { try { - return toHostValue.execute(context, objects.invokeMember(receiver, key, guestArguments)); + return toHostValue.execute(node, context, objects.invokeMember(receiver, key, guestArguments)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw invokeUnsupported(context, receiver, key); } catch (UnknownIdentifierException e) { - unknownIdentifier.enter(); + unknownIdentifier.enter(node); throw nonReadableMemberKey(context, receiver, key); } catch (UnsupportedTypeException e) { - invalidArgument.enter(); + invalidArgument.enter(node); throw invalidInvokeArgumentType(context, receiver, key, e); } catch (ArityException e) { - arity.enter(); + arity.enter(node); throw invalidInvokeArity(context, receiver, key, guestArguments, e.getExpectedMinArity(), e.getExpectedMaxArity(), e.getActualArity()); } } } - private static class InvokeNode extends AbstractInvokeNode { - - @Child private ToGuestValuesNode toGuestValues = ToGuestValuesNode.create(); + abstract static class InvokeNode extends InteropNode { protected InvokeNode(InteropValue interop) { super(interop); @@ -4479,16 +4507,18 @@ protected String getOperationName() { return "invoke"; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached SharedInvokeNode sharedInvoke, + @Cached ToGuestValuesNode toGuestValues) { String key = (String) args[ARGUMENT_OFFSET]; - Object[] guestArguments = toGuestValues.apply(context, (Object[]) args[ARGUMENT_OFFSET + 1]); - return executeShared(context, receiver, key, guestArguments); + Object[] guestArguments = toGuestValues.execute(this, context, (Object[]) args[ARGUMENT_OFFSET + 1]); + return sharedInvoke.executeShared(this, context, receiver, key, guestArguments); } } - private static class InvokeNoArgsNode extends AbstractInvokeNode { + abstract static class InvokeNoArgsNode extends InteropNode { protected InvokeNoArgsNode(InteropValue interop) { super(interop); @@ -4504,10 +4534,11 @@ protected String getOperationName() { return "invoke"; } - @Override - protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { + @Specialization + final Object doDefault(PolyglotLanguageContext context, Object receiver, Object[] args, + @Cached SharedInvokeNode sharedInvoke) { String key = (String) args[ARGUMENT_OFFSET]; - return executeShared(context, receiver, key, ExecuteVoidNoArgsNode.NO_ARGS); + return sharedInvoke.executeShared(this, context, receiver, key, ExecuteVoidNoArgsNode.NO_ARGS); } } @@ -4529,7 +4560,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects) { return objects.isException(receiver); } @@ -4552,13 +4583,13 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { throw objects.throwException(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw unsupported(context, receiver, "throwException()", "isException()"); } } @@ -4581,7 +4612,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static boolean doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static boolean doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects) { return objects.isMetaObject(receiver); } @@ -4604,14 +4635,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static String doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static String doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, @CachedLibrary(limit = "1") InteropLibrary toString, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return toString.asString(objects.getMetaQualifiedName(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw unsupported(context, receiver, "getMetaQualifiedName()", "isMetaObject()"); } } @@ -4634,14 +4665,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static String doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static String doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, @CachedLibrary(limit = "1") InteropLibrary toString, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return toString.asString(objects.getMetaSimpleName(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw unsupported(context, receiver, "getMetaSimpleName()", "isMetaObject()"); } } @@ -4665,13 +4696,14 @@ protected String getOperationName() { @Specialization(limit = "CACHE_LIMIT") static boolean doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached ToGuestValueNode toGuest, - @Cached BranchProfile unsupported) { + @Cached(inline = true) ToGuestValueNode toGuest, + @Cached InlinedBranchProfile unsupported) { try { - return objects.isMetaInstance(receiver, toGuest.execute(context, args[ARGUMENT_OFFSET])); + return objects.isMetaInstance(receiver, toGuest.execute(node, context, args[ARGUMENT_OFFSET])); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw unsupported(context, receiver, "isMetaInstance()", "isMetaObject()"); } } @@ -4694,9 +4726,9 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static boolean doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static boolean doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { return objects.hasMetaParents(receiver); } } @@ -4718,14 +4750,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, objects.getMetaParents(receiver)); + return toHost.execute(node, context, objects.getMetaParents(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw unsupported(context, receiver, "getMetaParents()", "hasMetaParents()"); } } @@ -4748,7 +4780,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary iterators) { return iterators.hasIterator(receiver); } @@ -4771,14 +4803,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary iterators, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, iterators.getIterator(receiver)); + return toHost.execute(node, context, iterators.getIterator(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); return getIteratorUnsupported(context, receiver); } } @@ -4801,7 +4833,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary iterators) { return iterators.isIterator(receiver); } @@ -4824,13 +4856,13 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary iterators, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return iterators.hasIteratorNextElement(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); return hasIteratorNextElementUnsupported(context, receiver); } } @@ -4853,18 +4885,18 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary iterators, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile stop) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile stop) { try { - return toHost.execute(context, iterators.getIteratorNextElement(receiver)); + return toHost.execute(node, context, iterators.getIteratorNextElement(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw nonReadableIteratorElement(); } catch (StopIterationException e) { - stop.enter(); + stop.enter(node); throw stopIteration(context, receiver); } } @@ -4887,7 +4919,7 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes) { return hashes.hasHashEntries(receiver); } @@ -4910,13 +4942,13 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached BranchProfile unsupported) { + @Cached InlinedBranchProfile unsupported) { try { return hashes.getHashSize(receiver); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashSizeUnsupported(context, receiver); } } @@ -4939,11 +4971,12 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary hashes, - @Cached ToGuestValueNode toGuestKey) { + @Cached(inline = true) ToGuestValueNode toGuestKey) { Object hostKey = args[ARGUMENT_OFFSET]; - Object key = toGuestKey.execute(context, hostKey); + Object key = toGuestKey.execute(node, context, hostKey); return hashes.isHashEntryExisting(receiver, key); } } @@ -4965,21 +4998,22 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary hashes, - @Cached ToGuestValueNode toGuestKey, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidKey) { + @Cached(inline = true) ToGuestValueNode toGuestKey, + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidKey) { Object hostKey = args[ARGUMENT_OFFSET]; - Object key = toGuestKey.execute(context, hostKey); + Object key = toGuestKey.execute(node, context, hostKey); try { - return toHost.execute(context, hashes.readHashValue(receiver, key)); + return toHost.execute(node, context, hashes.readHashValue(receiver, key)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashValueUnsupported(context, receiver, key); } catch (UnknownKeyException e) { - invalidKey.enter(); + invalidKey.enter(node); if (hashes.isHashEntryExisting(receiver, key)) { throw getHashValueUnsupported(context, receiver, key); } else { @@ -5006,21 +5040,21 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached ToGuestValueNode toGuestKey, - @Cached ToGuestValueNode toGuestDefaultValue, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidKey) { + @Cached(inline = true) ToGuestValueNode toGuestKey, + @Cached(inline = true) ToGuestValueNode toGuestDefaultValue, + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidKey) { Object hostKey = args[ARGUMENT_OFFSET]; Object hostDefaultValue = args[ARGUMENT_OFFSET + 1]; - Object key = toGuestKey.execute(context, hostKey); - Object defaultValue = toGuestDefaultValue.execute(context, hostDefaultValue); + Object key = toGuestKey.execute(node, context, hostKey); + Object defaultValue = toGuestDefaultValue.execute(node, context, hostDefaultValue); try { - return toHost.execute(context, hashes.readHashValueOrDefault(receiver, key, hostDefaultValue)); + return toHost.execute(node, context, hashes.readHashValueOrDefault(receiver, key, hostDefaultValue)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashValueUnsupported(context, receiver, key); } } @@ -5043,24 +5077,24 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached ToGuestValueNode toGuestKey, - @Cached ToGuestValueNode toGuestValue, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidKey, - @Cached BranchProfile invalidValue) { + @Cached(inline = true) ToGuestValueNode toGuestKey, + @Cached(inline = true) ToGuestValueNode toGuestValue, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidKey, + @Cached InlinedBranchProfile invalidValue) { Object hostKey = args[ARGUMENT_OFFSET]; Object hostValue = args[ARGUMENT_OFFSET + 1]; - Object key = toGuestKey.execute(context, hostKey); - Object value = toGuestValue.execute(context, hostValue); + Object key = toGuestKey.execute(node, context, hostKey); + Object value = toGuestValue.execute(node, context, hostValue); try { hashes.writeHashEntry(receiver, key, value); } catch (UnsupportedMessageException | UnknownKeyException e) { - unsupported.enter(); + unsupported.enter(node); throw putHashEntryUnsupported(context, receiver, key, value); } catch (UnsupportedTypeException e) { - invalidValue.enter(); + invalidValue.enter(node); throw invalidHashValue(context, receiver, key, value); } return null; @@ -5084,26 +5118,26 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached ToGuestValueNode toGuestKey, - @Cached BranchProfile unsupported, - @Cached BranchProfile invalidKey) { + @Cached(inline = true) ToGuestValueNode toGuestKey, + @Cached InlinedBranchProfile unsupported, + @Cached InlinedBranchProfile invalidKey) { Object hostKey = args[ARGUMENT_OFFSET]; - Object key = toGuestKey.execute(context, hostKey); + Object key = toGuestKey.execute(node, context, hostKey); Boolean result; try { hashes.removeHashEntry(receiver, key); result = Boolean.TRUE; } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); if (!hashes.hasHashEntries(receiver) || hashes.isHashEntryExisting(receiver, key)) { throw removeHashEntryUnsupported(context, receiver, key); } else { result = Boolean.FALSE; } } catch (UnknownKeyException e) { - invalidKey.enter(); + invalidKey.enter(node); result = Boolean.FALSE; } return result; @@ -5127,14 +5161,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, hashes.getHashEntriesIterator(receiver)); + return toHost.execute(node, context, hashes.getHashEntriesIterator(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashEntriesIteratorUnsupported(context, receiver); } } @@ -5157,14 +5191,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, hashes.getHashKeysIterator(receiver)); + return toHost.execute(node, context, hashes.getHashKeysIterator(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashEntriesIteratorUnsupported(context, receiver); } } @@ -5187,14 +5221,14 @@ protected String getOperationName() { } @Specialization(limit = "CACHE_LIMIT") - static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, // + static Object doCached(PolyglotLanguageContext context, Object receiver, Object[] args, @Bind("this") Node node, // @CachedLibrary("receiver") InteropLibrary hashes, - @Cached("createToHost()") ToHostValueNode toHost, - @Cached BranchProfile unsupported) { + @Cached ToHostValueNode toHost, + @Cached InlinedBranchProfile unsupported) { try { - return toHost.execute(context, hashes.getHashValuesIterator(receiver)); + return toHost.execute(node, context, hashes.getHashValuesIterator(receiver)); } catch (UnsupportedMessageException e) { - unsupported.enter(); + unsupported.enter(node); throw getHashEntriesIteratorUnsupported(context, receiver); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLAddToHostClassPathBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLAddToHostClassPathBuiltin.java index 198964e6548a..00c360dbff7d 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLAddToHostClassPathBuiltin.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLAddToHostClassPathBuiltin.java @@ -57,7 +57,7 @@ public abstract class SLAddToHostClassPathBuiltin extends SLBuiltinNode { @Specialization - protected Object execute(TruffleString classPath, + protected Object doDefault(TruffleString classPath, @Cached TruffleString.ToJavaStringNode toJavaStringNode) { addToHostClassPath(toJavaStringNode.execute(classPath)); return SLNull.SINGLETON; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLExitBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLExitBuiltin.java index 6ad5f108aa9d..ea3e835fc5d4 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLExitBuiltin.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLExitBuiltin.java @@ -52,7 +52,7 @@ public abstract class SLExitBuiltin extends SLBuiltinNode { @Specialization - protected Object execute(long exitCode) { + protected Object doDefault(long exitCode) { SLContext.get(this).getEnv().getContext().closeExited(this, (int) exitCode); return SLNull.SINGLETON; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java index 1cbdadc3fdf0..5ecbc1f0d0c1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLNewObjectBuiltin.java @@ -65,7 +65,7 @@ public abstract class SLNewObjectBuiltin extends SLBuiltinNode { @Specialization @SuppressWarnings("unused") public Object newObject(SLNull o, - @Cached("lookup()") AllocationReporter reporter) { + @Cached(value = "lookup()", neverDefault = true) AllocationReporter reporter) { return SLLanguage.get(this).createObject(reporter); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLRegisterShutdownHookBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLRegisterShutdownHookBuiltin.java index bc128c42d922..ca6463d552b8 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLRegisterShutdownHookBuiltin.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLRegisterShutdownHookBuiltin.java @@ -54,7 +54,7 @@ public abstract class SLRegisterShutdownHookBuiltin extends SLBuiltinNode { @Specialization - protected Object execute(SLFunction shutdownHook) { + protected Object doDefault(SLFunction shutdownHook) { SLContext.get(this).registerShutdownHook(shutdownHook); return SLNull.SINGLETON; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java index 34de0d20b22a..912093645f53 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java @@ -43,7 +43,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLExpressionNode; import com.oracle.truffle.sl.nodes.SLStatementNode; @@ -72,7 +72,7 @@ public final class SLIfNode extends SLStatementNode { * (as opposed to {@link BinaryConditionProfile} implementation) transmits the probability of * the condition to be true to the compiler. */ - private final ConditionProfile condition = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile condition = CountingConditionProfile.create(); public SLIfNode(SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) { this.conditionNode = SLUnboxNodeGen.create(conditionNode); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index 50731ac677fc..84309a2ece18 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -41,10 +41,12 @@ package com.oracle.truffle.sl.nodes.expression; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImplicitCast; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLException; @@ -115,11 +117,12 @@ protected SLBigNumber add(SLBigNumber left, SLBigNumber right) { */ @Specialization(guards = "isString(left, right)") @TruffleBoundary - protected TruffleString add(Object left, Object right, + protected static TruffleString add(Object left, Object right, + @Bind("this") Node node, @Cached SLToTruffleStringNode toTruffleStringNodeLeft, @Cached SLToTruffleStringNode toTruffleStringNodeRight, @Cached TruffleString.ConcatNode concatNode) { - return concatNode.execute(toTruffleStringNodeLeft.execute(left), toTruffleStringNodeRight.execute(right), SLLanguage.STRING_ENCODING, true); + return concatNode.execute(toTruffleStringNodeLeft.execute(node, left), toTruffleStringNodeRight.execute(node, right), SLLanguage.STRING_ENCODING, true); } /** diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index f05ca10da9c5..bd859002a9d5 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -48,6 +49,7 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.api.strings.TruffleString; @@ -85,27 +87,29 @@ protected Object readArray(Object receiver, Object index, } @Specialization(limit = "LIBRARY_LIMIT") - protected Object readSLObject(SLObject receiver, Object name, + protected static Object readSLObject(SLObject receiver, Object name, + @Bind("this") Node node, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { - TruffleString nameTS = toTruffleStringNode.execute(name); + TruffleString nameTS = toTruffleStringNode.execute(node, name); Object result = objectLibrary.getOrDefault(receiver, nameTS, null); if (result == null) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, nameTS); + throw SLUndefinedNameException.undefinedProperty(node, nameTS); } return result; } @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") - protected Object readObject(Object receiver, Object name, + protected static Object readObject(Object receiver, Object name, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, @Cached SLToMemberNode asMember) { try { - return objects.readMember(receiver, asMember.execute(name)); + return objects.readMember(receiver, asMember.execute(node, name)); } catch (UnsupportedMessageException | UnknownIdentifierException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, name); + throw SLUndefinedNameException.undefinedProperty(node, name); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java index a8310a2c4221..feac6932ab85 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLShortCircuitNode.java @@ -42,7 +42,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.UnexpectedResultException; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.sl.SLException; import com.oracle.truffle.sl.nodes.SLExpressionNode; @@ -60,7 +60,7 @@ public abstract class SLShortCircuitNode extends SLExpressionNode { * Short circuits might be used just like a conditional statement it makes sense to profile the * branch probability. */ - private final ConditionProfile evaluateRightProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile evaluateRightProfile = CountingConditionProfile.create(); public SLShortCircuitNode(SLExpressionNode left, SLExpressionNode right) { this.left = left; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index 2f4cd97f7c9e..90e65274eba7 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.expression; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; @@ -49,6 +50,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.object.DynamicObjectLibrary; import com.oracle.truffle.sl.nodes.SLExpressionNode; @@ -89,22 +91,24 @@ protected Object writeArray(Object receiver, Object index, Object value, } @Specialization(limit = "LIBRARY_LIMIT") - protected Object writeSLObject(SLObject receiver, Object name, Object value, + protected static Object writeSLObject(SLObject receiver, Object name, Object value, + @Bind("this") Node node, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { - objectLibrary.put(receiver, toTruffleStringNode.execute(name), value); + objectLibrary.put(receiver, toTruffleStringNode.execute(node, name), value); return value; } @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") - protected Object writeObject(Object receiver, Object name, Object value, + protected static Object writeObject(Object receiver, Object name, Object value, + @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { - objectLibrary.writeMember(receiver, asMember.execute(name), value); + objectLibrary.writeMember(receiver, asMember.execute(node, name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(this, name); + throw SLUndefinedNameException.undefinedProperty(node, name); } return value; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java index de4f60e25cb6..b1ceb72f42e1 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java @@ -113,7 +113,7 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { @Override @ExportMessage - Object readMember(String member, @Cached BranchProfile error) throws UnknownIdentifierException { + Object readMember(String member, @Cached(inline = false) BranchProfile error) throws UnknownIdentifierException { return super.readMember(member, error); } @@ -151,7 +151,7 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { @Override @ExportMessage - Object readMember(String member, @Cached BranchProfile error) throws UnknownIdentifierException { + Object readMember(String member, @Cached(inline = false) BranchProfile error) throws UnknownIdentifierException { super.readMember(member, error); // To verify readability return nameSymbol; } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptorKeys.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptorKeys.java index 7122b545a859..d0c27842946c 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptorKeys.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptorKeys.java @@ -40,13 +40,15 @@ */ package com.oracle.truffle.sl.nodes.interop; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; @ExportLibrary(InteropLibrary.class) @@ -77,9 +79,9 @@ long getArraySize() { } @ExportMessage - Object readArrayElement(long index, @Cached BranchProfile exception) throws InvalidArrayIndexException { + Object readArrayElement(long index, @Bind("$node") Node node, @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(index); } return keyName; diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLScopedNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLScopedNode.java index 066e3daf0f3f..55a4c4f1c388 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLScopedNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLScopedNode.java @@ -44,6 +44,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.Frame; @@ -162,6 +164,7 @@ private Object getRootInstanceSlowPath() throws UnsupportedMessageException { * * @return the block node, always non-null. Either SLBlockNode, or SLRootNode. */ + @NeverDefault public final Node findBlock() { Node parent = getParent(); while (parent != null) { @@ -319,7 +322,7 @@ static final class ExistsMember { @Specialization(limit = "LIMIT", guards = {"cachedMember.equals(member)"}) @SuppressWarnings("unused") static boolean doCached(ArgumentsObject receiver, String member, - @Cached("member") String cachedMember, + @Exclusive @Cached("member") String cachedMember, // We cache the member existence for fast-path access @Cached("doGeneric(receiver, member)") boolean cachedResult) { assert cachedResult == doGeneric(receiver, member); @@ -345,7 +348,7 @@ static final class ModifiableMember { @Specialization(limit = "LIMIT", guards = {"cachedMember.equals(member)"}) @SuppressWarnings("unused") static boolean doCached(ArgumentsObject receiver, String member, - @Cached("member") String cachedMember, + @Exclusive @Cached("member") String cachedMember, // We cache the member existence for fast-path access @Cached("receiver.hasArgumentIndex(member)") boolean cachedResult) { return cachedResult && receiver.frame != null; @@ -491,7 +494,8 @@ static final class VariablesObject implements TruffleObject { private final Frame frame; // the current frame protected final SLScopedNode node; // the current node final boolean nodeEnter; // whether the node was entered or is about to be exited - protected final SLBlockNode block; // the inner-most block of the current node + @NeverDefault protected final SLBlockNode block; // the inner-most block of the current + // node VariablesObject(Frame frame, SLScopedNode node, boolean nodeEnter, SLBlockNode blockNode) { this.frame = frame; @@ -763,9 +767,9 @@ private static void doWrite(VariablesObject receiver, String member, SLWriteLoca @ExportMessage @SuppressWarnings("static-method") Object getMembers(@SuppressWarnings("unused") boolean includeInternal, - @Cached(value = "this.block.getDeclaredLocalVariables()", adopt = false, dimensions = 1, allowUncached = true) SLWriteLocalVariableNode[] writeNodes, - @Cached(value = "this.getVisibleVariablesIndex()", allowUncached = true) int visibleVariablesIndex, - @Cached(value = "this.block.getParentBlockIndex()", allowUncached = true) int parentBlockIndex) { + @Cached(value = "this.block.getDeclaredLocalVariables()", adopt = false, neverDefault = false, dimensions = 1, allowUncached = true) SLWriteLocalVariableNode[] writeNodes, + @Cached(value = "this.getVisibleVariablesIndex()", allowUncached = true, neverDefault = false) int visibleVariablesIndex, + @Cached(value = "this.block.getParentBlockIndex()", allowUncached = true, neverDefault = false) int parentBlockIndex) { return new KeysArray(writeNodes, visibleVariablesIndex, parentBlockIndex); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java index e239fd51ace8..ef3b2bf3c055 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToMemberNode.java @@ -44,6 +44,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -62,11 +64,13 @@ */ @TypeSystemReference(SLTypes.class) @GenerateUncached +@GenerateInline // indicates that this node can get object inlined into the parent +@GenerateCached(false) // always inlined so we do not need to keep a cached version around public abstract class SLToMemberNode extends Node { static final int LIMIT = 5; - public abstract String execute(Object value) throws UnknownIdentifierException; + public abstract String execute(Node node, Object value) throws UnknownIdentifierException; @Specialization protected static String fromString(String value) { @@ -75,7 +79,8 @@ protected static String fromString(String value) { @Specialization protected static String fromTruffleString(TruffleString value, - @Cached TruffleString.ToJavaStringNode toJavaStringNode) { + // TruffleString nodes cannot be inlined yet + @Cached(inline = false) TruffleString.ToJavaStringNode toJavaStringNode) { return toJavaStringNode.execute(value); } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java index b9694b35961e..89cacda98713 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/util/SLToTruffleStringNode.java @@ -44,6 +44,9 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -65,6 +68,8 @@ */ @TypeSystemReference(SLTypes.class) @GenerateUncached +@GenerateInline +@GenerateCached(false) public abstract class SLToTruffleStringNode extends Node { static final int LIMIT = 5; @@ -73,7 +78,7 @@ public abstract class SLToTruffleStringNode extends Node { private static final TruffleString FALSE = SLStrings.constant("false"); private static final TruffleString FOREIGN_OBJECT = SLStrings.constant("[foreign object]"); - public abstract TruffleString execute(Object value); + public abstract TruffleString execute(Node node, Object value); @Specialization protected static TruffleString fromNull(@SuppressWarnings("unused") SLNull value) { @@ -82,7 +87,8 @@ protected static TruffleString fromNull(@SuppressWarnings("unused") SLNull value @Specialization protected static TruffleString fromString(String value, - @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { + // TruffleString nodes cannot be inlined yet + @Shared("fromJava") @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode) { return fromJavaStringNode.execute(value, SLLanguage.STRING_ENCODING); } @@ -99,14 +105,14 @@ protected static TruffleString fromBoolean(boolean value) { @Specialization @TruffleBoundary protected static TruffleString fromLong(long value, - @Cached TruffleString.FromLongNode fromLongNode) { + @Shared("fromLong") @Cached(inline = false) TruffleString.FromLongNode fromLongNode) { return fromLongNode.execute(value, SLLanguage.STRING_ENCODING, true); } @Specialization @TruffleBoundary protected static TruffleString fromBigNumber(SLBigNumber value, - @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { + @Shared("fromJava") @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode) { return fromJavaStringNode.execute(value.toString(), SLLanguage.STRING_ENCODING); } @@ -118,8 +124,8 @@ protected static TruffleString fromFunction(SLFunction value) { @Specialization(limit = "LIMIT") protected static TruffleString fromInterop(Object value, @CachedLibrary("value") InteropLibrary interop, - @Cached TruffleString.FromLongNode fromLongNode, - @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { + @Shared("fromLong") @Cached(inline = false) TruffleString.FromLongNode fromLongNode, + @Shared("fromJava") @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode) { try { if (interop.fitsInLong(value)) { return fromLongNode.execute(interop.asLong(value), SLLanguage.STRING_ENCODING, true); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/FunctionsObject.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/FunctionsObject.java index 8cca2baee31a..226c412d9493 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/FunctionsObject.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/FunctionsObject.java @@ -45,6 +45,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -52,7 +53,8 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.SLLanguage; @@ -152,9 +154,9 @@ long getArraySize() { } @ExportMessage - Object readArrayElement(long index, @Cached BranchProfile error) throws InvalidArrayIndexException { + Object readArrayElement(long index, @Bind("$node") Node node, @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } return names[(int) index]; diff --git a/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/nodes/MicrobenchRootNode.java b/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/nodes/MicrobenchRootNode.java index fbae0f5f6d9b..3faaafa15a31 100644 --- a/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/nodes/MicrobenchRootNode.java +++ b/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/nodes/MicrobenchRootNode.java @@ -37,7 +37,7 @@ public class MicrobenchRootNode extends RootNode { @Child Expression benchmark; - final LoopConditionProfile loopCondition = LoopConditionProfile.createCountingProfile(); + final LoopConditionProfile loopCondition = LoopConditionProfile.create(); private final int repeat; From 671a9c81d08d66dc8f64994ceb3edb2d5c818a27 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sat, 19 Nov 2022 18:17:44 +0100 Subject: [PATCH 191/312] Refactor TruffleString for node object inlining. --- ...StringOpsCalcStringAttributesUTF8Test.java | 9 +- .../bench/TStringTestDummyLanguage.java | 1 + .../api/strings/AbstractInternalNode.java | 56 + .../api/strings/AbstractPublicNode.java | 58 + .../api/strings/AbstractTruffleString.java | 46 +- .../truffle/api/strings/FastDoubleParser.java | 40 +- .../oracle/truffle/api/strings/JCodings.java | 16 +- .../truffle/api/strings/JCodingsDisabled.java | 12 +- .../truffle/api/strings/JCodingsImpl.java | 26 +- .../api/strings/MutableTruffleString.java | 139 +- .../truffle/api/strings/NumberConversion.java | 84 +- .../oracle/truffle/api/strings/Stride.java | 4 + .../truffle/api/strings/TStringAccessor.java | 2 + .../truffle/api/strings/TStringGuards.java | 5 +- .../api/strings/TStringInternalNodes.java | 983 +++++++------ .../truffle/api/strings/TStringOps.java | 6 +- .../truffle/api/strings/TStringOpsNodes.java | 159 ++- .../truffle/api/strings/TruffleString.java | 1234 +++++++---------- .../api/strings/TruffleStringBuilder.java | 283 ++-- .../api/strings/TruffleStringIterator.java | 247 ++-- 20 files changed, 1706 insertions(+), 1704 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractInternalNode.java create mode 100644 truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractPublicNode.java diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java index 036dace4a969..420218ba1812 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java @@ -29,12 +29,13 @@ import java.util.Arrays; import org.graalvm.compiler.replacements.nodes.CalcStringAttributesNode; +import org.graalvm.compiler.replacements.amd64.AMD64CalcStringAttributesNode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import jdk.vm.ci.meta.ResolvedJavaMethod; @@ -137,8 +138,8 @@ public TStringOpsCalcStringAttributesUTF8Test(byte[] array, int offset, int leng @Test public void testUtf8() { - ResolvedJavaMethod method = getTStringOpsMethod("calcStringAttributesUTF8", Object.class, int.class, int.class, boolean.class, boolean.class, ConditionProfile.class); - testWithNative(method, null, DUMMY_LOCATION, array, offset, length, true, false, ConditionProfile.getUncached()); - testWithNative(method, null, DUMMY_LOCATION, array, offset, length, false, false, ConditionProfile.getUncached()); + ResolvedJavaMethod method = getTStringOpsMethod("calcStringAttributesUTF8", Object.class, int.class, int.class, boolean.class, boolean.class, InlinedConditionProfile.class); + testWithNative(method, null, DUMMY_LOCATION, array, offset, length, true, false, InlinedConditionProfile.getUncached()); + testWithNative(method, null, DUMMY_LOCATION, array, offset, length, false, false, InlinedConditionProfile.getUncached()); } } diff --git a/truffle/src/com.oracle.truffle.api.strings.test/src/com/oracle/truffle/api/strings/bench/TStringTestDummyLanguage.java b/truffle/src/com.oracle.truffle.api.strings.test/src/com/oracle/truffle/api/strings/bench/TStringTestDummyLanguage.java index 9d56d35ae9aa..77e4eac92ec9 100644 --- a/truffle/src/com.oracle.truffle.api.strings.test/src/com/oracle/truffle/api/strings/bench/TStringTestDummyLanguage.java +++ b/truffle/src/com.oracle.truffle.api.strings.test/src/com/oracle/truffle/api/strings/bench/TStringTestDummyLanguage.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.strings.TruffleString; @TruffleLanguage.Registration(name = TStringTestDummyLanguage.NAME, id = TStringTestDummyLanguage.ID, characterMimeTypes = TStringTestDummyLanguage.MIME_TYPE, version = "0.1", needsAllEncodings = true) +@SuppressWarnings("truffle-inlining") public class TStringTestDummyLanguage extends TruffleLanguage { public static final String NAME = "TRUFFLE_STRING_DUMMY_LANG"; diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractInternalNode.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractInternalNode.java new file mode 100644 index 000000000000..0aa0da58a6ac --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractInternalNode.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.strings; + +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.strings.TruffleString.Encoding; + +@ImportStatic({TStringGuards.class, Encoding.class}) +@GenerateUncached(value = true, inherit = true) +@GenerateInline(value = true, inherit = true) +@GenerateCached(value = false, inherit = true) +abstract class AbstractInternalNode extends Node { + +} diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractPublicNode.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractPublicNode.java new file mode 100644 index 000000000000..66f092bbe1b2 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractPublicNode.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.strings; + +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GeneratePackagePrivate; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.strings.TruffleString.Encoding; + +@ImportStatic({TStringGuards.class, Encoding.class, TStringAccessor.class, TruffleStringBuilder.class}) +@GenerateUncached(value = true, inherit = true) +@GenerateInline(value = false, inherit = true) +@GenerateCached(value = true, inherit = true) +@GeneratePackagePrivate +abstract class AbstractPublicNode extends Node { + +} diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractTruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractTruffleString.java index 044519b640c6..c2467541eb04 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractTruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/AbstractTruffleString.java @@ -48,9 +48,10 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString.Encoding; +import com.oracle.truffle.api.strings.TruffleStringFactory.ToIndexableNodeGen; /** * Abstract base class for Truffle strings. Useful when a value can be both a {@link TruffleString} @@ -375,16 +376,16 @@ static int byteIndex(int rawIndex, TruffleString.Encoding expectedEncoding) { return rawIndex << expectedEncoding.naturalStride; } - final void boundsCheck(int index, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { - boundsCheckI(index, codePointLengthNode.execute(this)); + final void boundsCheck(Node node, int index, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { + boundsCheckI(index, codePointLengthNode.execute(node, this)); } - final void boundsCheck(int fromIndex, int toIndex, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { - boundsCheckI(fromIndex, toIndex, codePointLengthNode.execute(this)); + final void boundsCheck(Node node, int fromIndex, int toIndex, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { + boundsCheckI(fromIndex, toIndex, codePointLengthNode.execute(node, this)); } - final void boundsCheckRegion(int fromIndex, int regionLength, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { - boundsCheckRegionI(fromIndex, regionLength, codePointLengthNode.execute(this)); + final void boundsCheckRegion(Node node, int fromIndex, int regionLength, TStringInternalNodes.GetCodePointLengthNode codePointLengthNode) { + boundsCheckRegionI(fromIndex, regionLength, codePointLengthNode.execute(node, this)); } final void boundsCheckByteIndexS0(int byteIndex) { @@ -1149,8 +1150,8 @@ public final boolean equals(Object obj) { return false; } AbstractTruffleString b = (AbstractTruffleString) obj; - int codeRangeA = TStringInternalNodes.GetCodeRangeNode.getUncached().execute(this); - int codeRangeB = TStringInternalNodes.GetCodeRangeNode.getUncached().execute(b); + int codeRangeA = TStringInternalNodes.GetCodeRangeNode.getUncached().execute(null, this); + int codeRangeB = TStringInternalNodes.GetCodeRangeNode.getUncached().execute(null, b); int enc = encoding(); if (enc != b.encoding()) { if (!b.isLooselyCompatibleTo(enc, TruffleString.Encoding.getMaxCompatibleCodeRange(enc), codeRangeB)) { @@ -1160,13 +1161,12 @@ public final boolean equals(Object obj) { return false; } } - return TruffleString.EqualNode.checkContentEquals(this, codeRangeA, b, codeRangeB, - TruffleString.ToIndexableNode.getUncached(), - TruffleString.ToIndexableNode.getUncached(), - ConditionProfile.getUncached(), - BranchProfile.getUncached(), - ConditionProfile.getUncached(), - TruffleString.EqualNode.getUncached()); + return TruffleString.EqualNode.checkContentEquals(null, this, codeRangeA, b, codeRangeB, + ToIndexableNodeGen.getUncached(), + ToIndexableNodeGen.getUncached(), + InlinedConditionProfile.getUncached(), + InlinedBranchProfile.getUncached(), + InlinedConditionProfile.getUncached()); } /** @@ -1194,7 +1194,7 @@ public final int hashCode() { @TruffleBoundary @Override public final String toString() { - if (encoding == Encoding.BYTES.id && !is7Bit(TStringInternalNodes.GetCodeRangeNode.getUncached().execute(this))) { + if (encoding == Encoding.BYTES.id && !is7Bit(TStringInternalNodes.GetCodeRangeNode.getUncached().execute(null, this))) { StringBuilder sb = new StringBuilder(length); TruffleStringIterator it = createCodePointIteratorUncached(TruffleString.Encoding.BYTES); while (it.hasNext()) { @@ -1293,7 +1293,7 @@ private static void flatten(Node location, TruffleString src, int srcBegin, int @TruffleBoundary private static void copy(Node location, TruffleString src, byte[] dst, int dstFrom, int dstStride) { - Object arrayA = TruffleString.ToIndexableNode.getUncached().execute(src, src.data()); + Object arrayA = ToIndexableNodeGen.getUncached().execute(null, src, src.data()); TStringOps.arraycopyWithStride(location, arrayA, src.offset(), src.stride(), 0, dst, 0, dstStride, dstFrom, src.length()); @@ -1354,12 +1354,12 @@ byte[] getBytes() { return bytes; } - void materializeByteArray(AbstractTruffleString a, ConditionProfile profile) { - materializeByteArray(a.offset(), a.length() << a.stride(), profile); + void materializeByteArray(Node node, AbstractTruffleString a, InlinedConditionProfile profile) { + materializeByteArray(node, a.offset(), a.length() << a.stride(), profile); } - void materializeByteArray(int byteOffset, int byteLength, ConditionProfile profile) { - if (profile.profile(!byteArrayIsValid)) { + void materializeByteArray(Node node, int byteOffset, int byteLength, InlinedConditionProfile profile) { + if (profile.profile(node, !byteArrayIsValid)) { if (bytes == null) { bytes = new byte[byteLength]; } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/FastDoubleParser.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/FastDoubleParser.java index fe188a8c8eae..7bf07027a2fe 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/FastDoubleParser.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/FastDoubleParser.java @@ -42,14 +42,14 @@ import static com.oracle.truffle.api.strings.NumberConversion.numberFormatException; import static com.oracle.truffle.api.strings.TStringOps.readValue; -import static com.oracle.truffle.api.strings.TruffleString.NumberFormatException.Reason; import java.nio.charset.StandardCharsets; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.strings.TruffleString.NumberFormatException.Reason; /* * MIT License @@ -253,14 +253,14 @@ private static boolean isDigit(int c) { * @return the parsed double value * @throws NumberFormatException if the string can not be parsed */ - static double parseDouble(Node location, AbstractTruffleString a, Object arrayA, int strideA, int off, int len, BranchProfile errorProfile) throws TruffleString.NumberFormatException { + static double parseDouble(Node location, AbstractTruffleString a, Object arrayA, int strideA, int off, int len, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { final int endIndex = len + off; // Skip leading whitespace // ------------------- int index = skipWhitespace(a, arrayA, strideA, off, endIndex); if (index == endIndex) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, Reason.EMPTY); } int ch = readValue(a, arrayA, strideA, index); @@ -271,7 +271,7 @@ static double parseDouble(Node location, AbstractTruffleString a, Object arrayA, if (isNegative || ch == '+') { ch = ++index < endIndex ? readValue(a, arrayA, strideA, index) : 0; if (ch == 0) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, off, len, Reason.LONE_SIGN); } } @@ -316,34 +316,34 @@ private static int tryToParseEightDigits(long value) { return (int) (val); } - private static double parseInfinity(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int endIndex, boolean negative, int off, BranchProfile errorProfile) + private static double parseInfinity(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int endIndex, boolean negative, int off, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { int index = curIndex; if (index + 7 < endIndex && regionMatches(location, a, arrayA, strideA, index, TStringConstants.getInfinity(a.encoding()))) { index = skipWhitespace(a, arrayA, strideA, index + 8, endIndex); if (index < endIndex) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, off, endIndex - off, Reason.INVALID_CODEPOINT); } return negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; } else { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, off, endIndex - off, Reason.INVALID_CODEPOINT); } } - private static double parseNaN(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int endIndex, int off, BranchProfile errorProfile) + private static double parseNaN(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int endIndex, int off, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { int index = curIndex; if (index + 2 < endIndex && regionMatches(location, a, arrayA, strideA, index, TStringConstants.getNaN(a.encoding()))) { index = skipWhitespace(a, arrayA, strideA, index + 3, endIndex); if (index < endIndex) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, off, endIndex - off, Reason.INVALID_CODEPOINT); } return Double.NaN; } else { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, off, endIndex - off, Reason.INVALID_CODEPOINT); } } @@ -372,7 +372,7 @@ private static boolean regionMatches(Node location, AbstractTruffleString a, Obj * @return a double representation */ private static double parseRestOfDecimalFloatLiteral(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int startIndex, int endIndex, - boolean isNegative, boolean hasLeadingZero, BranchProfile errorProfile) throws TruffleString.NumberFormatException { + boolean isNegative, boolean hasLeadingZero, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { int index = curIndex; // Parse digits // ------------ @@ -392,7 +392,7 @@ private static double parseRestOfDecimalFloatLiteral(Node location, AbstractTruf digits = 10 * digits + ch - '0'; } else if (ch == '.') { if (virtualIndexOfPoint != -1) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.MULTIPLE_DECIMAL_POINTS); } virtualIndexOfPoint = index; @@ -433,7 +433,7 @@ private static double parseRestOfDecimalFloatLiteral(Node location, AbstractTruf ch = ++index < endIndex ? readValue(a, arrayA, strideA, index) : 0; } if (!isDigit(ch)) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.INVALID_CODEPOINT); } do { @@ -453,7 +453,7 @@ private static double parseRestOfDecimalFloatLiteral(Node location, AbstractTruf // ------------------------ index = skipWhitespace(a, arrayA, strideA, index, endIndex); if (index < endIndex || !hasLeadingZero && digitCount == 0) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.EMPTY); } @@ -536,11 +536,11 @@ private static double callJavaStringParseDouble(int len, byte[] arrayStr, int of * @return a double representation */ private static double parseRestOfHexFloatingPointLiteral(Node location, AbstractTruffleString a, Object arrayA, int strideA, int curIndex, int startIndex, int endIndex, boolean isNegative, - BranchProfile errorProfile) throws TruffleString.NumberFormatException { + InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { int index = curIndex; int len = endIndex - startIndex; if (index >= endIndex) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.MALFORMED_HEX_ESCAPE); } @@ -561,7 +561,7 @@ private static double parseRestOfHexFloatingPointLiteral(Node location, Abstract // later. } else if (hexValue == DECIMAL_POINT_CLASS) { if (virtualIndexOfPoint != -1) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.MULTIPLE_DECIMAL_POINTS); } virtualIndexOfPoint = index; @@ -589,7 +589,7 @@ private static double parseRestOfHexFloatingPointLiteral(Node location, Abstract ch = ++index < endIndex ? readValue(a, arrayA, strideA, index) : 0; } if (!isDigit(ch)) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.INVALID_CODEPOINT); } do { @@ -609,7 +609,7 @@ private static double parseRestOfHexFloatingPointLiteral(Node location, Abstract // ------------------------ index = skipWhitespace(a, arrayA, strideA, index, endIndex); if (index < endIndex || digitCount == 0 && readValue(a, arrayA, strideA, virtualIndexOfPoint) != '.' || !hasExponent) { - errorProfile.enter(); + errorProfile.enter(location); throw numberFormatException(a, startIndex, len, Reason.EMPTY); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java index 8498fe91ffbb..7eaf87d53744 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java @@ -40,12 +40,11 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; - +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; interface JCodings { @@ -112,11 +111,12 @@ static byte[] asByteArray(Object array) { int decode(AbstractTruffleString a, byte[] arrayA, int rawIndex, Encoding jCoding, TruffleString.ErrorHandling errorHandling); - long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, ConditionProfile validCharacterProfile, - ConditionProfile fixedWidthProfile); + long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, InlinedConditionProfile validCharacterProfile, + InlinedConditionProfile fixedWidthProfile); + TruffleString transcode(Node location, AbstractTruffleString a, Object arrayA, int codePointLengthA, TruffleString.Encoding targetEncoding, - BranchProfile outOfMemoryProfile, - ConditionProfile nativeProfile, + InlinedBranchProfile outOfMemoryProfile, + InlinedConditionProfile nativeProfile, TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsDisabled.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsDisabled.java index 5da58634bba0..38c3a4970337 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsDisabled.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsDisabled.java @@ -42,8 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; final class JCodingsDisabled implements JCodings { @@ -120,15 +120,15 @@ public int decode(AbstractTruffleString a, byte[] arrayA, int rawIndex, Encoding } @Override - public long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, ConditionProfile validCharacterProfile, - ConditionProfile fixedWidthProfile) { + public long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, InlinedConditionProfile validCharacterProfile, + InlinedConditionProfile fixedWidthProfile) { throw CompilerDirectives.shouldNotReachHere(MESSAGE); } @Override public TruffleString transcode(Node location, AbstractTruffleString a, Object arrayA, int codePointLengthA, TruffleString.Encoding targetEncoding, - BranchProfile outOfMemoryProfile, - ConditionProfile nativeProfile, + InlinedBranchProfile outOfMemoryProfile, + InlinedConditionProfile nativeProfile, TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { throw CompilerDirectives.shouldNotReachHere(MESSAGE); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsImpl.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsImpl.java index e0792913755e..4b376c98087b 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsImpl.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodingsImpl.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import static com.oracle.truffle.api.strings.AbstractTruffleString.checkArrayRange; import static com.oracle.truffle.api.strings.TStringGuards.isStride0; import static com.oracle.truffle.api.strings.TStringGuards.isStride1; @@ -48,7 +47,6 @@ import static com.oracle.truffle.api.strings.TStringGuards.isUTF16Or32; import static com.oracle.truffle.api.strings.TStringGuards.isUTF32; import static com.oracle.truffle.api.strings.TStringGuards.isUTF8; -import static com.oracle.truffle.api.strings.TruffleString.ErrorHandling; import java.util.Arrays; @@ -62,10 +60,12 @@ import org.graalvm.shadowed.org.jcodings.util.CaseInsensitiveBytesHash; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.strings.TruffleString.ErrorHandling; final class JCodingsImpl implements JCodings { @@ -213,8 +213,8 @@ public int decode(AbstractTruffleString a, byte[] arrayA, int rawIndex, Encoding } @Override - public long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, ConditionProfile validCharacterProfile, - ConditionProfile fixedWidthProfile) { + public long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, InlinedConditionProfile validCharacterProfile, + InlinedConditionProfile fixedWidthProfile) { if (TStringGuards.is7BitCompatible(encoding) && TStringOps.calcStringAttributesLatin1(location, array, offset + fromIndex, length) == TSCodeRange.get7Bit()) { return StringAttributes.create(length, TSCodeRange.get7Bit()); } @@ -228,13 +228,13 @@ public long calcStringAttributes(Node location, Object array, int offset, int le int loopCount = 0; for (; p < end; characters++) { final int lengthOfCurrentCharacter = getCodePointLength(enc, bytes, p, end); - if (validCharacterProfile.profile(lengthOfCurrentCharacter > 0 && p + lengthOfCurrentCharacter <= end)) { + if (validCharacterProfile.profile(location, lengthOfCurrentCharacter > 0 && p + lengthOfCurrentCharacter <= end)) { p += lengthOfCurrentCharacter; } else { codeRange = isSingleByte(enc) ? TSCodeRange.getBrokenFixedWidth() : TSCodeRange.getBrokenMultiByte(); // If a string is detected as broken, and we already know the character length // due to a fixed width encoding, there's no value in visiting any more ptr. - if (fixedWidthProfile.profile(isFixedWidth(enc))) { + if (fixedWidthProfile.profile(location, isFixedWidth(enc))) { characters = (length + minLength(enc) - 1) / minLength(enc); return StringAttributes.create(characters, codeRange); } else { @@ -268,8 +268,8 @@ private static EConvResult econvConvert(byte[] arrayA, byte[] buffer, EConv econ @Override public TruffleString transcode(Node location, AbstractTruffleString a, Object arrayA, int codePointLengthA, TruffleString.Encoding targetEncoding, - BranchProfile outOfMemoryProfile, - ConditionProfile nativeProfile, + InlinedBranchProfile outOfMemoryProfile, + InlinedConditionProfile nativeProfile, TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { final TruffleString.Encoding encoding = TruffleString.Encoding.get(a.encoding()); final JCodings.Encoding jCodingSrc; @@ -311,7 +311,7 @@ public TruffleString transcode(Node location, AbstractTruffleString a, Object ar dstPtr.p = 0; int inStop = a.byteArrayOffset() + (a.length() << a.stride()); if (arrayA instanceof AbstractTruffleString.NativePointer) { - ((AbstractTruffleString.NativePointer) arrayA).materializeByteArray(a, nativeProfile); + ((AbstractTruffleString.NativePointer) arrayA).materializeByteArray(location, a, nativeProfile); } byte[] bytes = JCodings.asByteArray(arrayA); EConvResult result = econvConvert(bytes, buffer, econv, srcPtr, dstPtr, inStop); @@ -321,7 +321,7 @@ public TruffleString transcode(Node location, AbstractTruffleString a, Object ar econvSetReplacement(jCodingDst, econv, replacement); } else if (result.isDestinationBufferFull()) { if (buffer.length == TStringConstants.MAX_ARRAY_SIZE) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(location); throw InternalErrors.outOfMemory(); } buffer = Arrays.copyOf(buffer, (int) Math.min(TStringConstants.MAX_ARRAY_SIZE, ((long) buffer.length) << 1)); @@ -333,7 +333,7 @@ public TruffleString transcode(Node location, AbstractTruffleString a, Object ar length = dstPtr.p; } checkArrayRange(buffer, 0, length); - return fromBufferWithStringCompactionNode.execute( + return fromBufferWithStringCompactionNode.execute(location, buffer, 0, length, targetEncoding, length != buffer.length || targetEncoding.isSupported(), undefinedConversion || a.isMutable()); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java index bccc097a8b32..4f2d08a12f23 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.api.strings.TStringGuards.isStride0; import static com.oracle.truffle.api.strings.TStringGuards.isStride1; import static com.oracle.truffle.api.strings.TStringGuards.isStride2; @@ -50,15 +49,16 @@ import java.util.Arrays; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GeneratePackagePrivate; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString.AsTruffleStringNode; import com.oracle.truffle.api.strings.TruffleString.Encoding; @@ -144,6 +144,7 @@ public void notifyExternalMutation() { @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class FromByteArrayNode extends Node { FromByteArrayNode() { @@ -216,6 +217,7 @@ public static MutableTruffleString fromByteArrayUncached(byte[] value, int byteO @ImportStatic({TStringGuards.class, TStringAccessor.class}) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class FromNativePointerNode extends Node { FromNativePointerNode() { @@ -308,6 +310,7 @@ public static MutableTruffleString fromNativePointerUncached(Object pointerObjec @ImportStatic({TStringGuards.class, TStringAccessor.class}) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class AsMutableTruffleStringNode extends Node { AsMutableTruffleStringNode() { @@ -364,6 +367,7 @@ public static AsMutableTruffleStringNode getUncached() { @ImportStatic({TStringGuards.class, TStringAccessor.class}) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class AsManagedNode extends Node { AsManagedNode() { @@ -417,6 +421,7 @@ public static AsManagedNode getUncached() { @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class WriteByteNode extends Node { WriteByteNode() { @@ -474,10 +479,7 @@ public void writeByteUncached(int byteIndex, byte value, Encoding expectedEncodi * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ConcatNode extends Node { + public abstract static class ConcatNode extends AbstractPublicNode { ConcatNode() { } @@ -491,16 +493,16 @@ public abstract static class ConcatNode extends Node { public abstract MutableTruffleString execute(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedEncoding); @Specialization - static MutableTruffleString concat(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedEncoding, + final MutableTruffleString concat(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedEncoding, @Cached TruffleString.ToIndexableNode toIndexableNodeA, @Cached TruffleString.ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.ConcatMaterializeBytesNode materializeBytesNode, - @Cached BranchProfile outOfMemoryProfile) { + @Cached InlinedBranchProfile outOfMemoryProfile) { a.checkEncoding(expectedEncoding); b.checkEncoding(expectedEncoding); - int length = TruffleString.ConcatNode.addByteLengths(a, b, expectedEncoding.naturalStride, outOfMemoryProfile); + int length = TruffleString.ConcatNode.addByteLengths(this, a, b, expectedEncoding.naturalStride, outOfMemoryProfile); int offset = 0; - byte[] array = materializeBytesNode.execute(a, toIndexableNodeA.execute(a, a.data()), b, toIndexableNodeB.execute(b, b.data()), expectedEncoding, length, + byte[] array = materializeBytesNode.execute(this, a, toIndexableNodeA.execute(this, a, a.data()), b, toIndexableNodeB.execute(this, b, b.data()), expectedEncoding, length, expectedEncoding.naturalStride); return MutableTruffleString.create(array, offset, length, expectedEncoding); } @@ -543,6 +545,7 @@ public MutableTruffleString concatUncached(AbstractTruffleString b, Encoding exp @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class SubstringNode extends Node { SubstringNode() { @@ -557,18 +560,18 @@ public abstract static class SubstringNode extends Node { public abstract MutableTruffleString execute(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding); @Specialization - static MutableTruffleString substring(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding, + MutableTruffleString substring(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding, @Cached TruffleString.ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.CodePointIndexToRawNode translateIndexNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode) { a.checkEncoding(expectedEncoding); - a.boundsCheckRegion(fromIndex, length, getCodePointLengthNode); - Object arrayA = toIndexableNode.execute(a, a.data()); - final int codeRangeA = getCodeRangeANode.execute(a); - int fromIndexRaw = translateIndexNode.execute(a, arrayA, codeRangeA, expectedEncoding, 0, fromIndex, length == 0); - int lengthRaw = translateIndexNode.execute(a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, length, true); + a.boundsCheckRegion(this, fromIndex, length, getCodePointLengthNode); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + final int codeRangeA = getCodeRangeANode.execute(this, a); + int fromIndexRaw = translateIndexNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, 0, fromIndex, length == 0); + int lengthRaw = translateIndexNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, length, true); int stride = expectedEncoding.naturalStride; return SubstringByteIndexNode.createSubstring(a, fromIndexRaw << stride, lengthRaw << stride, expectedEncoding, copyToByteArrayNode); } @@ -610,6 +613,7 @@ public MutableTruffleString substringUncached(int byteOffset, int byteLength, En @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class SubstringByteIndexNode extends Node { SubstringByteIndexNode() { @@ -676,6 +680,7 @@ public MutableTruffleString substringByteIndexUncached(int byteOffset, int byteL @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class SwitchEncodingNode extends Node { SwitchEncodingNode() { @@ -735,6 +740,7 @@ public static MutableTruffleString.SwitchEncodingNode getUncached() { @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached + @GenerateInline(false) public abstract static class ForceEncodingNode extends Node { ForceEncodingNode() { @@ -783,65 +789,96 @@ public static MutableTruffleString.ForceEncodingNode getUncached() { } } - @GenerateUncached - abstract static class CalcLazyAttributesNode extends Node { + abstract static class DataClassProfile extends AbstractInternalNode { + + abstract Object execute(Node node, Object a); + + @Specialization + static byte[] doByteArray(byte[] v) { + return v; + } + + @Specialization + static String doString(String v) { + return v; + } + + @Specialization + static NativePointer doNativePointer(NativePointer v) { + return v; + } + + @Specialization + static LazyLong doLazyLong(LazyLong v) { + return v; + } + + @Specialization + static LazyConcat doLazyConcat(LazyConcat v) { + return v; + } + + } + + abstract static class CalcLazyAttributesNode extends AbstractInternalNode { - abstract void execute(MutableTruffleString a); + abstract void execute(Node node, MutableTruffleString a); @Specialization - void calc(MutableTruffleString a, - @Cached("createClassProfile()") ValueProfile dataClassProfile, - @Cached ConditionProfile asciiBytesLatinProfile, - @Cached ConditionProfile utf8Profile, - @Cached ConditionProfile utf8BrokenProfile, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16S0Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32S0Profile, - @Cached ConditionProfile utf32S1Profile, - @Cached ConditionProfile exoticMaterializeNativeProfile, - @Cached ConditionProfile exoticValidProfile, - @Cached ConditionProfile exoticFixedWidthProfile) { - final Object data = dataClassProfile.profile(a.data()); + static void calc(Node node, MutableTruffleString a, + @Cached DataClassProfile dataClassProfile, + @Cached InlinedConditionProfile asciiBytesLatinProfile, + @Cached InlinedConditionProfile utf8Profile, + @Cached InlinedConditionProfile utf8BrokenProfile, + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16S0Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32S0Profile, + @Cached InlinedConditionProfile utf32S1Profile, + @Cached InlinedConditionProfile exoticMaterializeNativeProfile, + @Cached InlinedConditionProfile exoticValidProfile, + @Cached InlinedConditionProfile exoticFixedWidthProfile) { + + final Object data = dataClassProfile.execute(node, a.data()); final int encoding = a.encoding(); final int offset = a.offset(); final int length = a.length(); final int codePointLength; final int codeRange; - if (utf16Profile.profile(isUTF16(encoding))) { - if (utf16S0Profile.profile(isStride0(a))) { - codeRange = TStringOps.calcStringAttributesLatin1(this, data, offset, length); + if (utf16Profile.profile(node, isUTF16(encoding))) { + if (utf16S0Profile.profile(node, isStride0(a))) { + codeRange = TStringOps.calcStringAttributesLatin1(node, data, offset, length); codePointLength = length; } else { assert isStride1(a); - long attrs = TStringOps.calcStringAttributesUTF16(this, data, offset, length, false); + long attrs = TStringOps.calcStringAttributesUTF16(node, data, offset, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } - } else if (utf32Profile.profile(isUTF32(encoding))) { - if (utf32S0Profile.profile(isStride0(a))) { - codeRange = TStringOps.calcStringAttributesLatin1(this, data, offset, length); - } else if (utf32S1Profile.profile(isStride1(a))) { - codeRange = TStringOps.calcStringAttributesBMP(this, data, offset, length); + } else if (utf32Profile.profile(node, isUTF32(encoding))) { + if (utf32S0Profile.profile(node, isStride0(a))) { + codeRange = TStringOps.calcStringAttributesLatin1(node, data, offset, length); + } else if (utf32S1Profile.profile(node, isStride1(a))) { + codeRange = TStringOps.calcStringAttributesBMP(node, data, offset, length); } else { assert isStride2(a); - codeRange = TStringOps.calcStringAttributesUTF32(this, data, offset, length); + codeRange = TStringOps.calcStringAttributesUTF32(node, data, offset, length); } codePointLength = length; } else { - if (utf8Profile.profile(isUTF8(encoding))) { - long attrs = TStringOps.calcStringAttributesUTF8(this, data, offset, length, false, false, utf8BrokenProfile); + if (utf8Profile.profile(node, isUTF8(encoding))) { + long attrs = TStringOps.calcStringAttributesUTF8(node, data, offset, length, false, false, utf8BrokenProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); - } else if (asciiBytesLatinProfile.profile(TStringGuards.isAsciiBytesOrLatin1(encoding))) { - int cr = TStringOps.calcStringAttributesLatin1(this, data, offset, length); + } else if (asciiBytesLatinProfile.profile(node, TStringGuards.isAsciiBytesOrLatin1(encoding))) { + int cr = TStringOps.calcStringAttributesLatin1(node, data, offset, length); codeRange = TStringGuards.is8Bit(cr) ? TSCodeRange.asciiLatinBytesNonAsciiCodeRange(encoding) : cr; codePointLength = length; } else { if (data instanceof NativePointer) { - ((NativePointer) data).materializeByteArray(a, exoticMaterializeNativeProfile); + ((NativePointer) data).materializeByteArray(node, a, exoticMaterializeNativeProfile); } - long attrs = JCodings.getInstance().calcStringAttributes(this, data, offset, length, Encoding.get(encoding), 0, exoticValidProfile, exoticFixedWidthProfile); + long attrs = JCodings.getInstance().calcStringAttributes(node, data, offset, length, Encoding.get(encoding), 0, exoticValidProfile, exoticFixedWidthProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/NumberConversion.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/NumberConversion.java index 583d78bc5460..4ec789c6f4a1 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/NumberConversion.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/NumberConversion.java @@ -40,13 +40,12 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; - import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString.NumberFormatException.Reason; final class NumberConversion { @@ -91,52 +90,52 @@ final class NumberConversion { private static final long MAX_SAFE_INTEGER_LONG = (long) Math.pow(2, 53) - 1; private static final long MIN_SAFE_INTEGER_LONG = (long) MIN_SAFE_INTEGER; - static int parseInt(TruffleStringIterator it, int radix, BranchProfile errorProfile, - TruffleStringIterator.NextNode nextNode) throws TruffleString.NumberFormatException { - return (int) parseNum(it, radix, errorProfile, Integer.MIN_VALUE, Integer.MAX_VALUE, nextNode); + static int parseInt(Node node, TruffleStringIterator it, int radix, InlinedBranchProfile errorProfile, + TruffleStringIterator.InternalNextNode nextNode) throws TruffleString.NumberFormatException { + return (int) parseNum(node, it, radix, errorProfile, Integer.MIN_VALUE, Integer.MAX_VALUE, nextNode); } - static long parseLong(TruffleStringIterator it, int radix, BranchProfile errorProfile, - TruffleStringIterator.NextNode nextNode) throws TruffleString.NumberFormatException { - return parseNum(it, radix, errorProfile, Long.MIN_VALUE, Long.MAX_VALUE, nextNode); + static long parseLong(Node node, TruffleStringIterator it, int radix, InlinedBranchProfile errorProfile, + TruffleStringIterator.InternalNextNode nextNode) throws TruffleString.NumberFormatException { + return parseNum(node, it, radix, errorProfile, Long.MIN_VALUE, Long.MAX_VALUE, nextNode); } - static int parseInt7Bit(AbstractTruffleString a, Object ptrA, int stride, int radix, BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return (int) parseNum7Bit(a, ptrA, stride, radix, errorProfile, Integer.MIN_VALUE, Integer.MAX_VALUE); + static int parseInt7Bit(Node node, AbstractTruffleString a, Object ptrA, int stride, int radix, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return (int) parseNum7Bit(node, a, ptrA, stride, radix, errorProfile, Integer.MIN_VALUE, Integer.MAX_VALUE); } - static long parseLong7Bit(AbstractTruffleString a, Object ptrA, int stride, int radix, BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return parseNum7Bit(a, ptrA, stride, radix, errorProfile, Long.MIN_VALUE, Long.MAX_VALUE); + static long parseLong7Bit(Node node, AbstractTruffleString a, Object ptrA, int stride, int radix, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return parseNum7Bit(node, a, ptrA, stride, radix, errorProfile, Long.MIN_VALUE, Long.MAX_VALUE); } static boolean isSafeInteger(long value) { return MIN_SAFE_INTEGER_LONG <= value && value <= MAX_SAFE_INTEGER_LONG; } - private static long parseNum(TruffleStringIterator it, int radix, BranchProfile errorProfile, long min, long max, - TruffleStringIterator.NextNode nextNode) throws TruffleString.NumberFormatException { - checkArgs(it, radix, errorProfile); + private static long parseNum(Node node, TruffleStringIterator it, int radix, InlinedBranchProfile errorProfile, long min, long max, + TruffleStringIterator.InternalNextNode nextNode) throws TruffleString.NumberFormatException { + checkArgs(node, it, radix, errorProfile); long result = 0; boolean negative = false; long limit = -max; if (it.hasNext()) { - int firstChar = nextNode.execute(it); + int firstChar = nextNode.execute(node, it); if (firstChar < '0') { // Possible leading "+" or "-" if (firstChar == '-') { negative = true; limit = min; } else if (firstChar != '+') { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.INVALID_CODEPOINT); } if (!it.hasNext()) { // Cannot have lone "+" or "-" - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.LONE_SIGN); } } else { int digit = Character.digit(firstChar, radix); if (digit < 0) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.INVALID_CODEPOINT); } assert result >= limit + digit; @@ -145,34 +144,35 @@ private static long parseNum(TruffleStringIterator it, int radix, BranchProfile long multmin = limit / radix; while (it.hasNext()) { // Accumulating negatively avoids surprises near MAX_VALUE - int digit = Character.digit(nextNode.execute(it), radix); + int digit = Character.digit(nextNode.execute(node, it), radix); if (digit < 0) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.INVALID_CODEPOINT); } if (result < multmin) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.OVERFLOW); } result *= radix; if (result < limit + digit) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.OVERFLOW); } result -= digit; } } else { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(it, Reason.EMPTY); } return negative ? result : -result; } - private static long parseNum7Bit(AbstractTruffleString a, Object arrayA, int stride, int radix, BranchProfile errorProfile, long min, long max) throws TruffleString.NumberFormatException { + private static long parseNum7Bit(Node node, AbstractTruffleString a, Object arrayA, int stride, int radix, InlinedBranchProfile errorProfile, long min, long max) + throws TruffleString.NumberFormatException { CompilerAsserts.partialEvaluationConstant(stride); - assert TStringGuards.is7Bit(TStringInternalNodes.GetCodeRangeNode.getUncached().execute(a)); - checkRadix(a, radix, errorProfile); - checkEmptyStr(a, errorProfile); + assert TStringGuards.is7Bit(TStringInternalNodes.GetCodeRangeNode.getUncached().execute(null, a)); + checkRadix(node, a, radix, errorProfile); + checkEmptyStr(node, a, errorProfile); long result = 0; boolean negative = false; long limit = -max; @@ -183,11 +183,11 @@ private static long parseNum7Bit(AbstractTruffleString a, Object arrayA, int str negative = true; limit = min; } else if (firstChar != '+') { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, i, Reason.INVALID_CODEPOINT); } if (a.length() == 1) { // Cannot have lone "+" or "-" - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, i, Reason.LONE_SIGN); } i++; @@ -196,14 +196,14 @@ private static long parseNum7Bit(AbstractTruffleString a, Object arrayA, int str while (i < a.length()) { // Accumulating negatively avoids surprises near MAX_VALUE int c = TStringOps.readValue(a, arrayA, stride, i++); - final int digit = parseDigit7Bit(a, i, radix, errorProfile, c); + final int digit = parseDigit7Bit(node, a, i, radix, errorProfile, c); if (result < multmin) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, i, Reason.OVERFLOW); } result *= radix; if (result < limit + digit) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, i, Reason.OVERFLOW); } result -= digit; @@ -211,7 +211,7 @@ private static long parseNum7Bit(AbstractTruffleString a, Object arrayA, int str return negative ? result : -result; } - private static int parseDigit7Bit(AbstractTruffleString a, int i, int radix, BranchProfile errorProfile, int c) throws TruffleString.NumberFormatException { + private static int parseDigit7Bit(Node node, AbstractTruffleString a, int i, int radix, InlinedBranchProfile errorProfile, int c) throws TruffleString.NumberFormatException { if ('0' <= c && c <= Math.min((radix - 1) + '0', '9')) { return c & 0xf; } else if (radix > 10) { @@ -220,25 +220,25 @@ private static int parseDigit7Bit(AbstractTruffleString a, int i, int radix, Bra return lc - ('a' - 10); } } - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, i, Reason.INVALID_CODEPOINT); } - private static void checkArgs(TruffleStringIterator it, int radix, BranchProfile errorProfile) throws TruffleString.NumberFormatException { + private static void checkArgs(Node node, TruffleStringIterator it, int radix, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { assert it != null; - checkRadix(it.a, radix, errorProfile); + checkRadix(node, it.a, radix, errorProfile); } - private static void checkRadix(AbstractTruffleString a, int radix, BranchProfile errorProfile) throws TruffleString.NumberFormatException { + private static void checkRadix(Node node, AbstractTruffleString a, int radix, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, Reason.UNSUPPORTED_RADIX); } } - private static void checkEmptyStr(AbstractTruffleString a, BranchProfile errorProfile) throws TruffleString.NumberFormatException { + private static void checkEmptyStr(Node node, AbstractTruffleString a, InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { if (a.isEmpty()) { - errorProfile.enter(); + errorProfile.enter(node); throw numberFormatException(a, Reason.EMPTY); } } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/Stride.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/Stride.java index f625dc0584ef..8ae80bccc110 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/Stride.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/Stride.java @@ -45,6 +45,9 @@ final class Stride { + static final String STRIDE_CACHE_LIMIT = "3"; + static final int STRIDE_UNROLL = 3; + static boolean isStride(int stride) { return 0 <= stride && stride <= 2; } @@ -66,4 +69,5 @@ static int fromCodeRangeUTF16(int codeRange) { static int fromCodeRangeUTF32(int codeRange) { return TSCodeRange.toStrideUTF32(codeRange); } + } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringAccessor.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringAccessor.java index e93d9087b4b7..eae9896c2e24 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringAccessor.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringAccessor.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.api.strings; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.impl.Accessor; import com.oracle.truffle.api.nodes.Node; @@ -49,6 +50,7 @@ final class TStringAccessor extends Accessor { static final InteropSupport INTEROP = ACCESSOR.interopSupport(); static final EngineSupport ENGINE = ACCESSOR.engineSupport(); + @NeverDefault static Node createInteropLibrary() { return INTEROP.createDispatchedInteropLibrary(3); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringGuards.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringGuards.java index caa090f89cf4..351bcc16ef16 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringGuards.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringGuards.java @@ -42,6 +42,7 @@ import java.nio.ByteOrder; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString.Encoding; final class TStringGuards { @@ -114,8 +115,8 @@ static boolean isFixedWidth(int codeRangeA, int codeRangeB) { return isFixedWidth(codeRangeA) && isFixedWidth(codeRangeB); } - static boolean indexOfCannotMatch(int codeRangeA, AbstractTruffleString b, int codeRangeB, int regionLength, TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNodeB) { - return regionLength < getCodePointLengthNodeB.execute(b) || codeRangesCannotMatch(codeRangeA, codeRangeB, null); + static boolean indexOfCannotMatch(Node node, int codeRangeA, AbstractTruffleString b, int codeRangeB, int regionLength, TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNodeB) { + return regionLength < getCodePointLengthNodeB.execute(node, b) || codeRangesCannotMatch(codeRangeA, codeRangeB, null); } static boolean indexOfCannotMatch(int codeRangeA, AbstractTruffleString b, int codeRangeB, byte[] mask, int regionLength) { diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java index 492ed29effa6..99e19c9acfeb 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java @@ -40,8 +40,6 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import static com.oracle.truffle.api.dsl.Cached.Shared; import static com.oracle.truffle.api.strings.AbstractTruffleString.checkArrayRange; import static com.oracle.truffle.api.strings.AbstractTruffleString.checkByteLengthUTF16; import static com.oracle.truffle.api.strings.AbstractTruffleString.checkByteLengthUTF32; @@ -69,31 +67,31 @@ import static com.oracle.truffle.api.strings.TStringGuards.isValidMultiByte; import static com.oracle.truffle.api.strings.TStringOps.readS0; import static com.oracle.truffle.api.strings.TStringOps.writeToByteArray; -import static com.oracle.truffle.api.strings.TStringOpsNodes.RawIndexOfStringNode; -import static com.oracle.truffle.api.strings.TStringOpsNodes.RawLastIndexOfStringNode; import java.util.Arrays; import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GeneratePackagePrivate; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.AbstractTruffleString.NativePointer; +import com.oracle.truffle.api.strings.TStringOpsNodes.RawIndexOfStringNode; +import com.oracle.truffle.api.strings.TStringOpsNodes.RawLastIndexOfStringNode; +import com.oracle.truffle.api.strings.TruffleString.CompactionLevel; import com.oracle.truffle.api.strings.TruffleString.Encoding; import com.oracle.truffle.api.strings.TruffleString.ErrorHandling; final class TStringInternalNodes { - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class GetCodeRangeNode extends Node { + abstract static class GetCodeRangeNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a); + abstract int execute(Node node, AbstractTruffleString a); @Specialization int immutable(TruffleString a) { @@ -106,9 +104,9 @@ int mutableCacheHit(MutableTruffleString a) { } @Specialization(guards = "isUnknown(a.codeRange())") - int mutableCacheMiss(MutableTruffleString a, + static int mutableCacheMiss(Node node, MutableTruffleString a, @Cached MutableTruffleString.CalcLazyAttributesNode calcLazyAttributesNode) { - calcLazyAttributesNode.execute(a); + calcLazyAttributesNode.execute(node, a); return a.codeRange(); } @@ -117,11 +115,9 @@ static GetCodeRangeNode getUncached() { } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class GetCodePointLengthNode extends Node { + abstract static class GetCodePointLengthNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a); + abstract int execute(Node node, AbstractTruffleString a); @Specialization int immutable(TruffleString a) { @@ -134,9 +130,9 @@ int mutableCacheHit(MutableTruffleString a) { } @Specialization(guards = "a.codePointLength() < 0") - int mutableCacheMiss(MutableTruffleString a, + static int mutableCacheMiss(Node node, MutableTruffleString a, @Cached MutableTruffleString.CalcLazyAttributesNode calcLazyAttributesNode) { - calcLazyAttributesNode.execute(a); + calcLazyAttributesNode.execute(node, a); return a.codePointLength(); } @@ -145,64 +141,106 @@ static GetCodePointLengthNode getUncached() { } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class FromBufferWithStringCompactionNode extends Node { + abstract static class EncodingProfile extends AbstractInternalNode { - abstract TruffleString execute(Object arrayA, int offsetA, int byteLength, Encoding encoding, boolean copy, boolean isCacheHead); + abstract Encoding execute(Node node, Encoding encoding); + + @SuppressWarnings("unused") + @Specialization(guards = "encoding == cachedEncoding", limit = "1") + static Encoding doProfiled(Encoding encoding, @Cached("encoding") Encoding cachedEncoding) { + return cachedEncoding; + } + + @Specialization(replaces = "doProfiled") + static Encoding doGeneric(Encoding encoding) { + return encoding; + } + + } + + abstract static class CreateSubstringNode extends AbstractInternalNode { + + abstract TruffleString execute(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int codeRange); + + @SuppressWarnings("unused") + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static TruffleString doCached(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, + int codeRange, + @Bind("fromStride(stride)") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Cached EncodingProfile cachedEncoding, + @Cached CalcStringAttributesNode calcAttributesNode) { + return createString(node, a, array, offset, length, cachedCompaction.getStride(), cachedEncoding.execute(node, encoding), codeRange, calcAttributesNode); + } + + private static TruffleString createString(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int codeRange, + CalcStringAttributesNode calcAttributesNode) { + long attrs = calcAttributesNode.execute(node, a, array, offset, length, stride, encoding, 0, codeRange); + int newStride = Stride.fromCodeRange(StringAttributes.getCodeRange(attrs), encoding); + byte[] newBytes = new byte[length << newStride]; + TStringOps.arraycopyWithStride(node, + array, offset, stride, 0, + newBytes, 0, newStride, 0, length); + return TruffleString.createFromByteArray(newBytes, length, newStride, encoding, StringAttributes.getCodePointLength(attrs), StringAttributes.getCodeRange(attrs)); + } + } + + abstract static class FromBufferWithStringCompactionNode extends AbstractInternalNode { + + abstract TruffleString execute(Node node, Object arrayA, int offsetA, int byteLength, Encoding encoding, boolean copy, boolean isCacheHead); @Specialization - TruffleString fromBufferWithStringCompaction(Object arrayA, int offsetA, int byteLength, Encoding encoding, boolean copy, boolean isCacheHead, - @Cached ConditionProfile asciiLatinBytesProfile, - @Cached ConditionProfile utf8Profile, - @Cached ConditionProfile utf8BrokenProfile, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16CompactProfile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32Compact0Profile, - @Cached ConditionProfile utf32Compact1Profile, - @Cached ConditionProfile exoticValidProfile, - @Cached ConditionProfile exoticFixedWidthProfile) { + static TruffleString fromBufferWithStringCompaction(Node node, Object arrayA, int offsetA, int byteLength, Encoding encoding, boolean copy, boolean isCacheHead, + @Cached InlinedConditionProfile asciiLatinBytesProfile, + @Cached InlinedConditionProfile utf8Profile, + @Cached InlinedConditionProfile utf8BrokenProfile, + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16CompactProfile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32Compact0Profile, + @Cached InlinedConditionProfile utf32Compact1Profile, + @Cached InlinedConditionProfile exoticValidProfile, + @Cached InlinedConditionProfile exoticFixedWidthProfile) { final int offset; final int length; final int stride; final int codePointLength; final int codeRange; final Object array; - if (utf16Profile.profile(isUTF16(encoding))) { + if (utf16Profile.profile(node, isUTF16(encoding))) { checkByteLengthUTF16(byteLength); length = byteLength >> 1; - long attrs = TStringOps.calcStringAttributesUTF16(this, arrayA, offsetA, length, false); + long attrs = TStringOps.calcStringAttributesUTF16(node, arrayA, offsetA, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); stride = Stride.fromCodeRangeUTF16(codeRange); if (copy || stride == 0) { offset = 0; array = new byte[length << stride]; - if (utf16CompactProfile.profile(stride == 0)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 1, 0, array, offset, 0, 0, length); + if (utf16CompactProfile.profile(node, stride == 0)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 1, 0, array, offset, 0, 0, length); } else { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 1, 0, array, offset, 1, 0, length); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 1, 0, array, offset, 1, 0, length); } } else { offset = offsetA; array = arrayA; } - } else if (utf32Profile.profile(isUTF32(encoding))) { + } else if (utf32Profile.profile(node, isUTF32(encoding))) { checkByteLengthUTF32(byteLength); length = byteLength >> 2; - codeRange = TStringOps.calcStringAttributesUTF32(this, arrayA, offsetA, length); + codeRange = TStringOps.calcStringAttributesUTF32(node, arrayA, offsetA, length); codePointLength = length; stride = Stride.fromCodeRangeUTF32(codeRange); if (copy || stride < 2) { offset = 0; array = new byte[length << stride]; - if (utf32Compact0Profile.profile(stride == 0)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 2, 0, array, offset, 0, 0, length); - } else if (utf32Compact1Profile.profile(stride == 1)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 2, 0, array, offset, 1, 0, length); + if (utf32Compact0Profile.profile(node, stride == 0)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 2, 0, array, offset, 0, 0, length); + } else if (utf32Compact1Profile.profile(node, stride == 1)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 2, 0, array, offset, 1, 0, length); } else { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 2, 0, array, offset, 2, 0, length); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 2, 0, array, offset, 2, 0, length); } } else { offset = offsetA; @@ -211,25 +249,25 @@ TruffleString fromBufferWithStringCompaction(Object arrayA, int offsetA, int byt } else { length = byteLength; stride = 0; - if (utf8Profile.profile(isUTF8(encoding))) { - long attrs = TStringOps.calcStringAttributesUTF8(this, arrayA, offsetA, length, false, false, utf8BrokenProfile); + if (utf8Profile.profile(node, isUTF8(encoding))) { + long attrs = TStringOps.calcStringAttributesUTF8(node, arrayA, offsetA, length, false, false, utf8BrokenProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); - } else if (asciiLatinBytesProfile.profile(isAsciiBytesOrLatin1(encoding))) { - int cr = TStringOps.calcStringAttributesLatin1(this, arrayA, offsetA, length); + } else if (asciiLatinBytesProfile.profile(node, isAsciiBytesOrLatin1(encoding))) { + int cr = TStringOps.calcStringAttributesLatin1(node, arrayA, offsetA, length); codeRange = is8Bit(cr) ? TSCodeRange.asciiLatinBytesNonAsciiCodeRange(encoding) : cr; codePointLength = length; } else { if (arrayA instanceof NativePointer) { - ((NativePointer) arrayA).materializeByteArray(offsetA, length << stride, ConditionProfile.getUncached()); + ((NativePointer) arrayA).materializeByteArray(node, offsetA, length << stride, InlinedConditionProfile.getUncached()); } - long attrs = JCodings.getInstance().calcStringAttributes(this, arrayA, offsetA, length, encoding, 0, exoticValidProfile, exoticFixedWidthProfile); + long attrs = JCodings.getInstance().calcStringAttributes(node, arrayA, offsetA, length, encoding, 0, exoticValidProfile, exoticFixedWidthProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); } if (copy) { offset = 0; - array = TStringOps.arraycopyOfWithStride(this, arrayA, offsetA, length, 0, length, 0); + array = TStringOps.arraycopyOfWithStride(node, arrayA, offsetA, length, 0, length, 0); } else { offset = offsetA; array = arrayA; @@ -239,26 +277,24 @@ TruffleString fromBufferWithStringCompaction(Object arrayA, int offsetA, int byt } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class FromBufferWithStringCompactionKnownAttributesNode extends Node { + abstract static class FromBufferWithStringCompactionKnownAttributesNode extends AbstractInternalNode { - final TruffleString execute(AbstractTruffleString a, Encoding encoding) { - return execute(a, true, encoding); + final TruffleString execute(Node node, AbstractTruffleString a, Encoding encoding) { + return execute(node, a, true, encoding); } - abstract TruffleString execute(AbstractTruffleString a, boolean isCacheHead, Encoding encoding); + abstract TruffleString execute(Node node, AbstractTruffleString a, boolean isCacheHead, Encoding encoding); @Specialization - TruffleString fromBufferWithStringCompaction(AbstractTruffleString a, boolean isCacheHead, Encoding encoding, + static TruffleString fromBufferWithStringCompaction(Node node, AbstractTruffleString a, boolean isCacheHead, Encoding encoding, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16CompactProfile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32Compact0Profile, - @Cached ConditionProfile utf32Compact1Profile) { - final int codeRange = getCodeRangeNode.execute(a); + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16CompactProfile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32Compact0Profile, + @Cached InlinedConditionProfile utf32Compact1Profile) { + final int codeRange = getCodeRangeNode.execute(node, a); a.looseCheckEncoding(encoding, codeRange); final int length = a.length(); if (length == 0) { @@ -271,31 +307,31 @@ TruffleString fromBufferWithStringCompaction(AbstractTruffleString a, boolean is final int offset = 0; final int stride; final Object array; - if (utf16Profile.profile(isUTF16(encoding))) { + if (utf16Profile.profile(node, isUTF16(encoding))) { stride = Stride.fromCodeRangeUTF16(codeRange); array = new byte[length << stride]; - if (utf16CompactProfile.profile(strideA == 1 && stride == 0)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 1, 0, array, offset, 0, 0, length); + if (utf16CompactProfile.profile(node, strideA == 1 && stride == 0)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 1, 0, array, offset, 0, 0, length); } else { assert stride == strideA; - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 0, 0, array, offset, 0, 0, length << stride); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, 0, array, offset, 0, 0, length << stride); } - } else if (utf32Profile.profile(isUTF32(encoding))) { + } else if (utf32Profile.profile(node, isUTF32(encoding))) { stride = Stride.fromCodeRangeUTF32(codeRange); array = new byte[length << stride]; - if (utf32Compact0Profile.profile(strideA == 2 && stride == 0)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 2, 0, array, offset, 0, 0, length); - } else if (utf32Compact1Profile.profile(strideA == 2 && stride == 1)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 2, 0, array, offset, 1, 0, length); + if (utf32Compact0Profile.profile(node, strideA == 2 && stride == 0)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 2, 0, array, offset, 0, 0, length); + } else if (utf32Compact1Profile.profile(node, strideA == 2 && stride == 1)) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 2, 0, array, offset, 1, 0, length); } else { assert stride == strideA; - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 0, 0, array, offset, 0, 0, length << stride); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, 0, array, offset, 0, 0, length << stride); } } else { stride = 0; - array = TStringOps.arraycopyOfWithStride(this, arrayA, offsetA, length, 0, length, 0); + array = TStringOps.arraycopyOfWithStride(node, arrayA, offsetA, length, 0, length, 0); } - int codePointLength = getCodePointLengthNode.execute(a); + int codePointLength = getCodePointLengthNode.execute(node, a); return TruffleString.createFromArray(array, offset, length, stride, encoding, codePointLength, codeRange, isCacheHead); } @@ -304,52 +340,50 @@ static FromBufferWithStringCompactionKnownAttributesNode getUncached() { } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class FromNativePointerNode extends Node { + abstract static class FromNativePointerNode extends AbstractInternalNode { - abstract TruffleString execute(NativePointer pointer, int byteOffset, int byteLength, Encoding encoding, boolean isCacheHead); + abstract TruffleString execute(Node node, NativePointer pointer, int byteOffset, int byteLength, Encoding encoding, boolean isCacheHead); @Specialization - TruffleString fromNativePointerInternal(NativePointer pointer, int byteOffset, int byteLength, Encoding encoding, boolean isCacheHead, - @Cached ConditionProfile asciiLatinBytesProfile, - @Cached ConditionProfile utf8Profile, - @Cached ConditionProfile utf8BrokenProfile, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile exoticValidProfile, - @Cached ConditionProfile exoticFixedWidthProfile) { + static TruffleString fromNativePointerInternal(Node node, NativePointer pointer, int byteOffset, int byteLength, Encoding encoding, boolean isCacheHead, + @Cached InlinedConditionProfile asciiLatinBytesProfile, + @Cached InlinedConditionProfile utf8Profile, + @Cached InlinedConditionProfile utf8BrokenProfile, + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile exoticValidProfile, + @Cached InlinedConditionProfile exoticFixedWidthProfile) { final int length; final int stride; final int codePointLength; final int codeRange; - if (utf16Profile.profile(isUTF16(encoding))) { + if (utf16Profile.profile(node, isUTF16(encoding))) { checkByteLengthUTF16(byteLength); length = byteLength >> 1; - long attrs = TStringOps.calcStringAttributesUTF16(this, pointer, byteOffset, length, false); + long attrs = TStringOps.calcStringAttributesUTF16(node, pointer, byteOffset, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); stride = 1; - } else if (utf32Profile.profile(isUTF32(encoding))) { + } else if (utf32Profile.profile(node, isUTF32(encoding))) { checkByteLengthUTF32(byteLength); length = byteLength >> 2; - codeRange = TStringOps.calcStringAttributesUTF32(this, pointer, byteOffset, length); + codeRange = TStringOps.calcStringAttributesUTF32(node, pointer, byteOffset, length); codePointLength = length; stride = 2; } else { length = byteLength; stride = 0; - if (utf8Profile.profile(isUTF8(encoding))) { - long attrs = TStringOps.calcStringAttributesUTF8(this, pointer, byteOffset, length, false, false, utf8BrokenProfile); + if (utf8Profile.profile(node, isUTF8(encoding))) { + long attrs = TStringOps.calcStringAttributesUTF8(node, pointer, byteOffset, length, false, false, utf8BrokenProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); - } else if (asciiLatinBytesProfile.profile(isAsciiBytesOrLatin1(encoding))) { - int cr = TStringOps.calcStringAttributesLatin1(this, pointer, byteOffset, length); + } else if (asciiLatinBytesProfile.profile(node, isAsciiBytesOrLatin1(encoding))) { + int cr = TStringOps.calcStringAttributesLatin1(node, pointer, byteOffset, length); codeRange = is8Bit(cr) ? TSCodeRange.asciiLatinBytesNonAsciiCodeRange(encoding) : cr; codePointLength = length; } else { - pointer.materializeByteArray(byteOffset, byteLength, ConditionProfile.getUncached()); - long attrs = JCodings.getInstance().calcStringAttributes(this, pointer, byteOffset, length, encoding, 0, exoticValidProfile, exoticFixedWidthProfile); + pointer.materializeByteArray(node, byteOffset, byteLength, InlinedConditionProfile.getUncached()); + long attrs = JCodings.getInstance().calcStringAttributes(node, pointer, byteOffset, length, encoding, 0, exoticValidProfile, exoticFixedWidthProfile); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); } @@ -358,11 +392,9 @@ TruffleString fromNativePointerInternal(NativePointer pointer, int byteOffset, i } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ByteLengthOfCodePointNode extends Node { + abstract static class ByteLengthOfCodePointNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int index, ErrorHandling errorHandling); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int index, ErrorHandling errorHandling); @SuppressWarnings("unused") @Specialization(guards = {"isFixedWidth(codeRangeA)", "isBestEffort(errorHandling)"}) @@ -385,9 +417,9 @@ int doASCIIBrokenReturnNegative(AbstractTruffleString a, Object arrayA, int code @SuppressWarnings("unused") @Specialization(guards = {"isUTF32(encoding)", "isBrokenFixedWidth(codeRangeA)", "isReturnNegative(errorHandling)"}) - int doUTF32BrokenReturnNegative(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int index, ErrorHandling errorHandling, + static int doUTF32BrokenReturnNegative(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int index, ErrorHandling errorHandling, @Cached CodePointAtRawNode codePointAtRawNode) { - return codePointAtRawNode.execute(a, arrayA, codeRangeA, encoding, index, ErrorHandling.RETURN_NEGATIVE) < 0 ? -1 : 4; + return codePointAtRawNode.execute(node, a, arrayA, codeRangeA, encoding, index, ErrorHandling.RETURN_NEGATIVE) < 0 ? -1 : 4; } @SuppressWarnings("unused") @@ -444,11 +476,9 @@ int unsupported(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawIndexToCodePointIndexNode extends Node { + abstract static class RawIndexToCodePointIndexNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int byteOffset, int index); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int byteOffset, int index); @SuppressWarnings("unused") @Specialization(guards = "isFixedWidth(codeRangeA)") @@ -457,16 +487,17 @@ int doFixed(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding enc } @Specialization(guards = {"isUTF8(encoding)", "isValidMultiByte(codeRangeA)"}) - int utf8Valid(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int byteOffset, int index, - @Cached ConditionProfile brokenProfile) { - return StringAttributes.getCodePointLength(TStringOps.calcStringAttributesUTF8(this, arrayA, a.offset() + byteOffset, index, true, byteOffset + index == a.length(), brokenProfile)); + static int utf8Valid(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int byteOffset, int index, + @Shared("broken") @Cached InlinedConditionProfile brokenProfile) { + return StringAttributes.getCodePointLength(TStringOps.calcStringAttributesUTF8(node, arrayA, a.offset() + byteOffset, index, true, byteOffset + index == a.length(), brokenProfile)); } @Specialization(guards = {"isUTF8(encoding)", "isBrokenMultiByte(codeRangeA)"}) - int utf8Broken(@SuppressWarnings("unused") AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int byteOffset, + static int utf8Broken(Node node, @SuppressWarnings("unused") AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, + int byteOffset, int index, - @Cached ConditionProfile brokenProfile) { - return StringAttributes.getCodePointLength(TStringOps.calcStringAttributesUTF8(this, arrayA, a.offset() + byteOffset, index, false, false, brokenProfile)); + @Shared("broken") @Cached InlinedConditionProfile brokenProfile) { + return StringAttributes.getCodePointLength(TStringOps.calcStringAttributesUTF8(node, arrayA, a.offset() + byteOffset, index, false, false, brokenProfile)); } @Specialization(guards = {"isUTF16(encoding)", "isValidMultiByte(codeRangeA)"}) @@ -483,18 +514,16 @@ int utf16Broken(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unuse @TruffleBoundary @Specialization(guards = "isUnsupportedEncoding(encoding)") - int unsupported(@SuppressWarnings("unused") AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, Encoding encoding, int byteOffset, int index, - @Cached ConditionProfile validProfile, - @Cached ConditionProfile fixedWidthProfile) { - return StringAttributes.getCodePointLength(JCodings.getInstance().calcStringAttributes(this, arrayA, a.offset(), index, encoding, byteOffset, validProfile, fixedWidthProfile)); + static int unsupported(Node node, @SuppressWarnings("unused") AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, Encoding encoding, int byteOffset, int index, + @Exclusive @Cached InlinedConditionProfile validProfile, + @Shared("broken") @Cached InlinedConditionProfile fixedWidthProfile) { + return StringAttributes.getCodePointLength(JCodings.getInstance().calcStringAttributes(node, arrayA, a.offset(), index, encoding, byteOffset, validProfile, fixedWidthProfile)); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CodePointIndexToRawNode extends Node { + abstract static class CodePointIndexToRawNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int extraOffsetRaw, int index, boolean isLength); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int extraOffsetRaw, int index, boolean isLength); @SuppressWarnings("unused") @Specialization(guards = "isFixedWidth(codeRangeA)") @@ -575,18 +604,16 @@ static int atEnd(AbstractTruffleString a, int extraOffsetRaw, int index, boolean } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ReadByteNode extends Node { + abstract static class ReadByteNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int i, Encoding encoding); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int i, Encoding encoding); @Specialization(guards = "isUTF16(encoding)") - static int doUTF16(AbstractTruffleString a, Object arrayA, int i, @SuppressWarnings("unused") Encoding encoding, - @Cached ConditionProfile stride0Profile) { + static int doUTF16(Node node, AbstractTruffleString a, Object arrayA, int i, @SuppressWarnings("unused") Encoding encoding, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile) { a.boundsCheckByteIndexUTF16(i); final int index; - if (stride0Profile.profile(isStride0(a))) { + if (stride0Profile.profile(node, isStride0(a))) { // simplified from: // (TStringGuards.bigEndian() ? (i & 1) == 0 : (i & 1) != 0) if ((TStringGuards.bigEndian()) == ((i & 1) == 0)) { @@ -602,18 +629,18 @@ static int doUTF16(AbstractTruffleString a, Object arrayA, int i, @SuppressWarni } @Specialization(guards = "isUTF32(encoding)") - static int doUTF32(AbstractTruffleString a, Object arrayA, int i, @SuppressWarnings("unused") Encoding encoding, - @Cached ConditionProfile stride0Profile, - @Cached ConditionProfile stride1Profile) { + static int doUTF32(Node node, AbstractTruffleString a, Object arrayA, int i, @SuppressWarnings("unused") Encoding encoding, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile, + @Exclusive @Cached InlinedConditionProfile stride1Profile) { a.boundsCheckByteIndexUTF32(i); final int index; - if (stride0Profile.profile(isStride0(a))) { + if (stride0Profile.profile(node, isStride0(a))) { if ((i & 3) != (TStringGuards.bigEndian() ? 3 : 0)) { return 0; } else { index = i >> 2; } - } else if (stride1Profile.profile(isStride1(a))) { + } else if (stride1Profile.profile(node, isStride1(a))) { // simplified from: // (TStringGuards.bigEndian() ? (i & 2) == 0 : (i & 2) != 0) if ((TStringGuards.bigEndian()) == ((i & 2) == 0)) { @@ -639,50 +666,48 @@ static int doRest(AbstractTruffleString a, Object arrayA, int i, @SuppressWarnin } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CodePointAtNode extends Node { + abstract static class CodePointAtNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling); @Specialization(guards = "isUTF16(encoding)") - int utf16(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile fixedWidthProfile, - @Cached ConditionProfile stride0Profile, - @Cached ConditionProfile validProfile) { - if (fixedWidthProfile.profile(isFixedWidth(codeRangeA))) { - if (stride0Profile.profile(isStride0(a))) { + static int utf16(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, + @Cached InlinedConditionProfile fixedWidthProfile, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile, + @Shared("valid") @Cached InlinedConditionProfile validProfile) { + if (fixedWidthProfile.profile(node, isFixedWidth(codeRangeA))) { + if (stride0Profile.profile(node, isStride0(a))) { return TStringOps.readS0(a, arrayA, i); } else { assert isStride1(a); return TStringOps.readS1(a, arrayA, i); } - } else if (validProfile.profile(isValidMultiByte(codeRangeA))) { + } else if (validProfile.profile(node, isValidMultiByte(codeRangeA))) { assert isStride1(a); - return Encodings.utf16DecodeValid(a, arrayA, Encodings.utf16ValidCodePointToCharIndex(this, a, arrayA, i)); + return Encodings.utf16DecodeValid(a, arrayA, Encodings.utf16ValidCodePointToCharIndex(node, a, arrayA, i)); } else { assert isStride1(a); assert TStringGuards.isBrokenMultiByte(codeRangeA); - return Encodings.utf16DecodeBroken(a, arrayA, Encodings.utf16BrokenCodePointToCharIndex(this, a, arrayA, i), errorHandling); + return Encodings.utf16DecodeBroken(a, arrayA, Encodings.utf16BrokenCodePointToCharIndex(node, a, arrayA, i), errorHandling); } } @Specialization(guards = "isUTF32(encoding)") - static int utf32(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile stride0Profile, - @Cached ConditionProfile stride1Profile) { - return CodePointAtRawNode.utf32(a, arrayA, codeRangeA, encoding, i, errorHandling, stride0Profile, stride1Profile); + static int utf32(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile, + @Exclusive @Cached InlinedConditionProfile stride1Profile) { + return CodePointAtRawNode.utf32(node, a, arrayA, codeRangeA, encoding, i, errorHandling, stride0Profile, stride1Profile); } @Specialization(guards = "isUTF8(encoding)") - int utf8(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile fixedWidthProfile, - @Cached ConditionProfile validProfile) { - if (fixedWidthProfile.profile(is7Bit(codeRangeA))) { + static int utf8(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, + @Exclusive @Cached InlinedConditionProfile fixedWidthProfile, + @Shared("valid") @Cached InlinedConditionProfile validProfile) { + if (fixedWidthProfile.profile(node, is7Bit(codeRangeA))) { return TStringOps.readS0(a, arrayA, i); } else { - int byteIndex = Encodings.utf8CodePointToByteIndex(this, a, arrayA, i); - if (validProfile.profile(isValidMultiByte(codeRangeA))) { + int byteIndex = Encodings.utf8CodePointToByteIndex(node, a, arrayA, i); + if (validProfile.profile(node, isValidMultiByte(codeRangeA))) { return Encodings.utf8DecodeValid(a, arrayA, byteIndex); } else { assert TStringGuards.isBrokenMultiByte(codeRangeA); @@ -712,25 +737,23 @@ int unsupported(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unuse } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CodePointAtRawNode extends Node { + abstract static class CodePointAtRawNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int i, ErrorHandling errorHandling); @Specialization(guards = "isUTF16(encoding)") - static int utf16(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile fixedWidthProfile, - @Cached ConditionProfile validProfile, - @Cached ConditionProfile stride0Profile) { - if (fixedWidthProfile.profile(isFixedWidth(codeRangeA))) { - if (stride0Profile.profile(isStride0(a))) { + static int utf16(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, + @Cached InlinedConditionProfile fixedWidthProfile, + @Cached InlinedConditionProfile validProfile, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile) { + if (fixedWidthProfile.profile(node, isFixedWidth(codeRangeA))) { + if (stride0Profile.profile(node, isStride0(a))) { return TStringOps.readS0(a, arrayA, i); } else { assert isStride1(a); return TStringOps.readS1(a, arrayA, i); } - } else if (validProfile.profile(isValidMultiByte(codeRangeA))) { + } else if (validProfile.profile(node, isValidMultiByte(codeRangeA))) { return Encodings.utf16DecodeValid(a, arrayA, i); } else { assert TStringGuards.isBrokenMultiByte(codeRangeA); @@ -739,12 +762,13 @@ static int utf16(AbstractTruffleString a, Object arrayA, int codeRangeA, @Suppre } @Specialization(guards = "isUTF32(encoding)") - static int utf32(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile stride0Profile, - @Cached ConditionProfile stride1Profile) { - if (stride0Profile.profile(isStride0(a))) { + static int utf32(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, + ErrorHandling errorHandling, + @Shared("stride0") @Cached InlinedConditionProfile stride0Profile, + @Exclusive @Cached InlinedConditionProfile stride1Profile) { + if (stride0Profile.profile(node, isStride0(a))) { return TStringOps.readS0(a, arrayA, i); - } else if (stride1Profile.profile(isStride1(a))) { + } else if (stride1Profile.profile(node, isStride1(a))) { char c = TStringOps.readS1(a, arrayA, i); if (errorHandling == ErrorHandling.RETURN_NEGATIVE && Encodings.isUTF16Surrogate(c)) { return -1; @@ -761,12 +785,12 @@ static int utf32(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unus } @Specialization(guards = "isUTF8(encoding)") - static int utf8(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, - @Cached ConditionProfile fixedWidthProfile, - @Cached ConditionProfile validProfile) { - if (fixedWidthProfile.profile(is7Bit(codeRangeA))) { + static int utf8(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int i, ErrorHandling errorHandling, + @Exclusive @Cached InlinedConditionProfile fixedWidthProfile, + @Exclusive @Cached InlinedConditionProfile validProfile) { + if (fixedWidthProfile.profile(node, is7Bit(codeRangeA))) { return TStringOps.readS0(a, arrayA, i); - } else if (validProfile.profile(isValidMultiByte(codeRangeA))) { + } else if (validProfile.profile(node, isValidMultiByte(codeRangeA))) { return Encodings.utf8DecodeValid(a, arrayA, i); } else { assert TStringGuards.isBrokenMultiByte(codeRangeA); @@ -799,51 +823,47 @@ static int unsupported(AbstractTruffleString a, Object arrayA, @SuppressWarnings } } - static int indexOfFixedWidth(AbstractTruffleString a, Object arrayA, int codeRangeA, int codepoint, int fromIndex, int toIndex, + static int indexOfFixedWidth(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, int codepoint, int fromIndex, int toIndex, TStringOpsNodes.RawIndexOfCodePointNode indexOfNode) { if (fromIndex == toIndex || !TSCodeRange.isInCodeRange(codepoint, codeRangeA)) { return -1; } - return indexOfNode.execute(a, arrayA, codepoint, fromIndex, toIndex); + return indexOfNode.execute(node, a, arrayA, codepoint, fromIndex, toIndex); } - static int lastIndexOfFixedWidth(AbstractTruffleString a, Object arrayA, int codeRangeA, int codepoint, int fromIndex, int toIndex, + static int lastIndexOfFixedWidth(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, int codepoint, int fromIndex, int toIndex, TStringOpsNodes.RawLastIndexOfCodePointNode indexOfNode) { if (fromIndex == toIndex || !TSCodeRange.isInCodeRange(codepoint, codeRangeA)) { return -1; } - return indexOfNode.execute(a, arrayA, codepoint, fromIndex, toIndex); + return indexOfNode.execute(node, a, arrayA, codepoint, fromIndex, toIndex); } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfCodePointNode extends Node { + abstract static class IndexOfCodePointNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); @Specialization(guards = "isFixedWidth(codeRangeA)") - static int doFixedWidth(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int doFixedWidth(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached TStringOpsNodes.RawIndexOfCodePointNode indexOfNode) { - return indexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, indexOfNode); + return indexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, indexOfNode); } @Specialization(guards = "!isFixedWidth(codeRangeA)") - int decode(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, - @Cached TruffleStringIterator.NextNode nextNode) { - return TruffleStringIterator.indexOf(this, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), codepoint, fromIndex, toIndex, nextNode); + static int decode(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, + @Cached TruffleStringIterator.InternalNextNode nextNode) { + return TruffleStringIterator.indexOf(node, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), codepoint, fromIndex, toIndex, nextNode); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfCodePointRawNode extends Node { + abstract static class IndexOfCodePointRawNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); @Specialization(guards = {"isFixedWidth(codeRangeA)"}) - static int utf8Fixed(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int utf8Fixed(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached TStringOpsNodes.RawIndexOfCodePointNode indexOfNode) { - return indexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, indexOfNode); + return indexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, indexOfNode); } @Specialization(guards = {"isUTF8(encoding)", "!isFixedWidth(codeRangeA)"}) @@ -877,70 +897,66 @@ int utf16Variable(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unu } @Specialization(guards = {"isUnsupportedEncoding(encoding)", "!isFixedWidth(codeRangeA)"}) - int unsupported(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, - @Cached TruffleStringIterator.NextNode nextNode) { + static int unsupported(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, + @Cached TruffleStringIterator.InternalNextNode nextNode) { final TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); it.setRawIndex(fromIndex); int loopCount = 0; while (it.hasNext() && it.getRawIndex() < toIndex) { int ret = it.getRawIndex(); - if (nextNode.execute(it) == codepoint) { + if (nextNode.execute(node, it) == codepoint) { return ret; } - TStringConstants.truffleSafePointPoll(this, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } return -1; } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class LastIndexOfCodePointNode extends Node { + abstract static class LastIndexOfCodePointNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); @Specialization(guards = "isFixedWidth(codeRangeA)") - static int doFixedWidth(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int doFixedWidth(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached TStringOpsNodes.RawLastIndexOfCodePointNode lastIndexOfNode) { - return lastIndexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); + return lastIndexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); } @Specialization(guards = "!isFixedWidth(codeRangeA)") - int decode(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, - @Cached TruffleStringIterator.NextNode nextNode) { - return TruffleStringIterator.lastIndexOf(this, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), codepoint, fromIndex, toIndex, nextNode); + static int decode(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex, + @Cached TruffleStringIterator.InternalNextNode nextNode) { + return TruffleStringIterator.lastIndexOf(node, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), codepoint, fromIndex, toIndex, nextNode); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class LastIndexOfCodePointRawNode extends Node { + abstract static class LastIndexOfCodePointRawNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int codepoint, int fromIndex, int toIndex); @Specialization(guards = {"isFixedWidth(codeRangeA)"}) - static int utf8Fixed(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int utf8Fixed(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached @Shared("lastIndexOfNode") TStringOpsNodes.RawLastIndexOfCodePointNode lastIndexOfNode) { - return lastIndexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); + return lastIndexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); } @Specialization(guards = {"isUTF8(encoding)", "!isFixedWidth(codeRangeA)"}) - int utf8Variable(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int utf8Variable(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached @Shared("lastIndexOfNode") TStringOpsNodes.RawLastIndexOfCodePointNode lastIndexOfNode) { int encodedSize = Encodings.utf8EncodedSize(codepoint); if (encodedSize > fromIndex - toIndex) { return -1; } if (encodedSize == 1) { - return lastIndexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); + return lastIndexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); } byte[] encoded = Encodings.utf8EncodeNonAscii(codepoint, encodedSize); TruffleString b = TruffleString.createFromByteArray(encoded, encoded.length, 0, Encoding.UTF_8, 1, TSCodeRange.getValidMultiByte()); - return TStringOps.lastIndexOfStringWithOrMaskWithStride(this, a, arrayA, 0, b, encoded, 0, fromIndex, toIndex, null); + return TStringOps.lastIndexOfStringWithOrMaskWithStride(node, a, arrayA, 0, b, encoded, 0, fromIndex, toIndex, null); } @Specialization(guards = {"isUTF16(encoding)", "!isFixedWidth(codeRangeA)"}) - int utf16Variable(AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, + static int utf16Variable(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, @Cached @Shared("lastIndexOfNode") TStringOpsNodes.RawLastIndexOfCodePointNode lastIndexOfNode) { assert isStride1(a); int encodedSize = Encodings.utf16EncodedSize(codepoint); @@ -948,33 +964,32 @@ int utf16Variable(AbstractTruffleString a, Object arrayA, int codeRangeA, @Suppr return -1; } if (encodedSize == 1) { - return lastIndexOfFixedWidth(a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); + return lastIndexOfFixedWidth(node, a, arrayA, codeRangeA, codepoint, fromIndex, toIndex, lastIndexOfNode); } return TStringOps.lastIndexOf2ConsecutiveWithOrMaskWithStride( - this, a, arrayA, 1, fromIndex, toIndex, Character.highSurrogate(codepoint), Character.lowSurrogate(codepoint), 0, 0); + node, a, arrayA, 1, fromIndex, toIndex, Character.highSurrogate(codepoint), Character.lowSurrogate(codepoint), 0, 0); } @Specialization(guards = {"isUnsupportedEncoding(encoding)", "!isFixedWidth(codeRangeA)"}) - int unsupported(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, int fromIndex, int toIndex, - @Cached TruffleStringIterator.PreviousNode prevNode) { + static int unsupported(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int codepoint, + int fromIndex, int toIndex, + @Cached TruffleStringIterator.InternalPreviousNode prevNode) { final TruffleStringIterator it = TruffleString.backwardIterator(a, arrayA, codeRangeA, encoding); it.setRawIndex(fromIndex); int loopCount = 0; while (it.hasPrevious() && it.getRawIndex() >= toIndex) { - if (prevNode.execute(it) == codepoint) { + if (prevNode.execute(node, it) == codepoint) { return it.getRawIndex(); } - TStringConstants.truffleSafePointPoll(this, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } return -1; } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class SubstringNode extends Node { + abstract static class SubstringNode extends AbstractInternalNode { - abstract TruffleString execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, boolean lazy); + abstract TruffleString execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, boolean lazy); @SuppressWarnings("unused") @Specialization(guards = "length == 0") @@ -989,56 +1004,57 @@ static TruffleString sameStr(TruffleString a, Object arrayA, int codeRangeA, Enc } @Specialization(guards = {"length > 0", "length != length(a) || a.isMutable()", "!lazy"}) - TruffleString materializeSubstring(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, @SuppressWarnings("unused") boolean lazy, - @Cached CalcStringAttributesNode calcAttributesNode, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf32Profile) { + static TruffleString materializeSubstring(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, + @SuppressWarnings("unused") boolean lazy, + @Shared("attributes") @Cached CalcStringAttributesNode calcAttributesNode, + @Exclusive @Cached InlinedConditionProfile utf16Profile, + @Exclusive @Cached InlinedConditionProfile utf32Profile) { final long attrs; final int codeRange; final int stride; final int newStride; - if (utf16Profile.profile(isUTF16(encoding))) { + if (utf16Profile.profile(node, isUTF16(encoding))) { stride = a.stride(); - attrs = calcAttributesNode.execute(a, arrayA, a.offset(), length, stride, Encoding.UTF_16, fromIndex, codeRangeA); + attrs = calcAttributesNode.execute(node, a, arrayA, a.offset(), length, stride, Encoding.UTF_16, fromIndex, codeRangeA); codeRange = StringAttributes.getCodeRange(attrs); newStride = Stride.fromCodeRangeUTF16(codeRange); - } else if (utf32Profile.profile(isUTF32(encoding))) { + } else if (utf32Profile.profile(node, isUTF32(encoding))) { stride = a.stride(); - attrs = calcAttributesNode.execute(a, arrayA, a.offset(), length, stride, Encoding.UTF_32, fromIndex, codeRangeA); + attrs = calcAttributesNode.execute(node, a, arrayA, a.offset(), length, stride, Encoding.UTF_32, fromIndex, codeRangeA); codeRange = StringAttributes.getCodeRange(attrs); newStride = Stride.fromCodeRangeUTF32(codeRange); } else { stride = 0; - attrs = calcAttributesNode.execute(a, arrayA, a.offset(), length, stride, encoding, fromIndex, codeRangeA); + attrs = calcAttributesNode.execute(node, a, arrayA, a.offset(), length, stride, encoding, fromIndex, codeRangeA); codeRange = StringAttributes.getCodeRange(attrs); newStride = 0; } - byte[] newBytes = TStringOps.arraycopyOfWithStride(this, arrayA, a.offset() + (fromIndex << stride), length, stride, length, newStride); + byte[] newBytes = TStringOps.arraycopyOfWithStride(node, arrayA, a.offset() + (fromIndex << stride), length, stride, length, newStride); return TruffleString.createFromByteArray(newBytes, length, newStride, encoding, StringAttributes.getCodePointLength(attrs), codeRange); } @Specialization(guards = {"length > 0", "length != length(a)", "lazy"}) - TruffleString createLazySubstring(TruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, @SuppressWarnings("unused") boolean lazy, - @Cached CalcStringAttributesNode calcAttributesNode, - @Cached ConditionProfile stride1MustMaterializeProfile, - @Cached ConditionProfile stride2MustMaterializeProfile) { + static TruffleString createLazySubstring(Node node, TruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int fromIndex, int length, @SuppressWarnings("unused") boolean lazy, + @Shared("attributes") @Cached CalcStringAttributesNode calcAttributesNode, + @Exclusive @Cached InlinedConditionProfile stride1MustMaterializeProfile, + @Exclusive @Cached InlinedConditionProfile stride2MustMaterializeProfile) { int lazyOffset = a.offset() + (fromIndex << a.stride()); - long attrs = calcAttributesNode.execute(a, arrayA, a.offset(), length, a.stride(), encoding, fromIndex, codeRangeA); + long attrs = calcAttributesNode.execute(node, a, arrayA, a.offset(), length, a.stride(), encoding, fromIndex, codeRangeA); int codeRange = StringAttributes.getCodeRange(attrs); int codePointLength = StringAttributes.getCodePointLength(attrs); final Object array; final int offset; final int stride; - if (stride1MustMaterializeProfile.profile(a.stride() == 1 && TSCodeRange.isMoreRestrictiveOrEqual(codeRange, TSCodeRange.get8Bit()))) { + if (stride1MustMaterializeProfile.profile(node, a.stride() == 1 && TSCodeRange.isMoreRestrictiveOrEqual(codeRange, TSCodeRange.get8Bit()))) { assert isUTF16Or32(encoding); stride = 0; offset = 0; final byte[] newBytes = new byte[length]; - TStringOps.arraycopyWithStride(this, + TStringOps.arraycopyWithStride(node, arrayA, lazyOffset, 1, 0, newBytes, offset, 0, 0, length); array = newBytes; - } else if (stride2MustMaterializeProfile.profile(a.stride() == 2 && TSCodeRange.isMoreRestrictiveOrEqual(codeRange, TSCodeRange.get16Bit()))) { + } else if (stride2MustMaterializeProfile.profile(node, a.stride() == 2 && TSCodeRange.isMoreRestrictiveOrEqual(codeRange, TSCodeRange.get16Bit()))) { // Always materialize 4-byte UTF-32 strings when they can be compacted. Otherwise, // they could get re-interpreted as UTF-16 and break the assumption that all UTF-16 // strings are stride 0 or 1. @@ -1047,12 +1063,12 @@ TruffleString createLazySubstring(TruffleString a, Object arrayA, int codeRangeA offset = 0; final byte[] newBytes = new byte[length << stride]; if (stride == 0) { - TStringOps.arraycopyWithStride(this, + TStringOps.arraycopyWithStride(node, arrayA, lazyOffset, 2, 0, newBytes, offset, 0, 0, length); } else { assert stride == 1; - TStringOps.arraycopyWithStride(this, + TStringOps.arraycopyWithStride(node, arrayA, lazyOffset, 2, 0, newBytes, offset, 1, 0, length); } @@ -1071,41 +1087,38 @@ TruffleString createLazySubstring(TruffleString a, Object arrayA, int codeRangeA } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ConcatEagerNode extends Node { + abstract static class ConcatEagerNode extends AbstractInternalNode { - abstract TruffleString execute(AbstractTruffleString a, AbstractTruffleString b, Encoding encoding, int concatLength, int concatStride, int concatCodeRange); + abstract TruffleString execute(Node node, AbstractTruffleString a, AbstractTruffleString b, Encoding encoding, int concatLength, int concatStride, int concatCodeRange); @Specialization - static TruffleString concat(AbstractTruffleString a, AbstractTruffleString b, Encoding encoding, int concatLength, int concatStride, int concatCodeRange, + static TruffleString concat(Node node, AbstractTruffleString a, AbstractTruffleString b, Encoding encoding, int concatLength, int concatStride, int concatCodeRange, @Cached TruffleString.ToIndexableNode toIndexableNodeA, @Cached TruffleString.ToIndexableNode toIndexableNodeB, @Cached GetCodePointLengthNode getCodePointLengthANode, @Cached GetCodePointLengthNode getCodePointLengthBNode, @Cached ConcatMaterializeBytesNode materializeBytesNode, @Cached CalcStringAttributesNode calculateAttributesNode, - @Cached ConditionProfile brokenProfile) { - final byte[] bytes = materializeBytesNode.execute(a, toIndexableNodeA.execute(a, a.data()), b, toIndexableNodeB.execute(b, b.data()), encoding, concatLength, concatStride); + @Cached InlinedConditionProfile brokenProfile) { + final byte[] bytes = materializeBytesNode.execute(node, a, toIndexableNodeA.execute(node, a, a.data()), b, toIndexableNodeB.execute(node, b, b.data()), encoding, concatLength, + concatStride); final int codeRange; final int codePointLength; - if (brokenProfile.profile(isBrokenMultiByte(concatCodeRange))) { - final long attrs = calculateAttributesNode.execute(null, bytes, 0, concatLength, concatStride, encoding, 0, TSCodeRange.getUnknown()); + if (brokenProfile.profile(node, isBrokenMultiByte(concatCodeRange))) { + final long attrs = calculateAttributesNode.execute(node, null, bytes, 0, concatLength, concatStride, encoding, 0, TSCodeRange.getUnknown()); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } else { - codePointLength = getCodePointLengthANode.execute(a) + getCodePointLengthBNode.execute(b); + codePointLength = getCodePointLengthANode.execute(node, a) + getCodePointLengthBNode.execute(node, b); codeRange = concatCodeRange; } return TruffleString.createFromByteArray(bytes, concatLength, concatStride, encoding, codePointLength, codeRange); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ConcatMaterializeBytesNode extends Node { + abstract static class ConcatMaterializeBytesNode extends AbstractInternalNode { - abstract byte[] execute(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, Encoding encoding, int concatLength, int concatStride); + abstract byte[] execute(Node node, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, Encoding encoding, int concatLength, int concatStride); @Specialization(guards = "isUTF16(encoding) || isUTF32(encoding)") byte[] doWithCompression(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, @SuppressWarnings("unused") Encoding encoding, int concatLength, int concatStride) { @@ -1135,11 +1148,9 @@ byte[] doNoCompression(AbstractTruffleString a, Object arrayA, AbstractTruffleSt } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RegionEqualsNode extends Node { + abstract static class RegionEqualsNode extends AbstractInternalNode { - abstract boolean execute( + abstract boolean execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, int fromIndexA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndexB, int length, Encoding encoding); @@ -1151,166 +1162,156 @@ boolean direct( } @Specialization(guards = {"!isFixedWidth(codeRangeA, codeRangeB)"}) - boolean decode( + static boolean decode(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, int fromIndexA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndexB, int length, Encoding encoding, - @Cached TruffleStringIterator.NextNode nextNodeA, - @Cached TruffleStringIterator.NextNode nextNodeB) { + @Cached TruffleStringIterator.InternalNextNode nextNodeA, + @Cached TruffleStringIterator.InternalNextNode nextNodeB) { TruffleStringIterator aIt = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); TruffleStringIterator bIt = AbstractTruffleString.forwardIterator(b, arrayB, codeRangeB, encoding); for (int i = 0; i < fromIndexA; i++) { if (!aIt.hasNext()) { return false; } - nextNodeA.execute(aIt); - TStringConstants.truffleSafePointPoll(this, i + 1); + nextNodeA.execute(node, aIt); + TStringConstants.truffleSafePointPoll(node, i + 1); } for (int i = 0; i < fromIndexB; i++) { if (!bIt.hasNext()) { return false; } - nextNodeB.execute(bIt); - TStringConstants.truffleSafePointPoll(this, i + 1); + nextNodeB.execute(node, bIt); + TStringConstants.truffleSafePointPoll(node, i + 1); } for (int i = 0; i < length; i++) { - if (!(aIt.hasNext() && bIt.hasNext()) || nextNodeA.execute(aIt) != nextNodeB.execute(bIt)) { + if (!(aIt.hasNext() && bIt.hasNext()) || nextNodeA.execute(node, aIt) != nextNodeB.execute(node, bIt)) { return false; } - TStringConstants.truffleSafePointPoll(this, i + 1); + TStringConstants.truffleSafePointPoll(node, i + 1); } return true; } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfStringNode extends Node { + abstract static class InternalIndexOfStringNode extends AbstractInternalNode { - abstract int execute( + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, Encoding encoding); @Specialization(guards = {"isFixedWidth(codeRangeA, codeRangeB)"}) - static int direct( + static int direct(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, @SuppressWarnings("unused") Encoding encoding, @Cached RawIndexOfStringNode indexOfStringNode) { - assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, toIndex - fromIndex, GetCodePointLengthNode.getUncached()); - return indexOfStringNode.execute(a, arrayA, b, arrayB, fromIndex, toIndex, null); + assert !b.isEmpty() && !indexOfCannotMatch(node, codeRangeA, b, codeRangeB, toIndex - fromIndex, GetCodePointLengthNode.getUncached()); + return indexOfStringNode.execute(node, a, arrayA, b, arrayB, fromIndex, toIndex, null); } @Specialization(guards = {"!isFixedWidth(codeRangeA, codeRangeB)"}) - int decode( + static int decode(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, Encoding encoding, - @Cached TruffleStringIterator.NextNode nextNodeA, - @Cached TruffleStringIterator.NextNode nextNodeB) { - assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, toIndex - fromIndex, GetCodePointLengthNode.getUncached()); + @Cached TruffleStringIterator.InternalNextNode nextNodeA, + @Cached TruffleStringIterator.InternalNextNode nextNodeB) { + assert !b.isEmpty() && !indexOfCannotMatch(node, codeRangeA, b, codeRangeB, toIndex - fromIndex, GetCodePointLengthNode.getUncached()); TruffleStringIterator aIt = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); TruffleStringIterator bIt = AbstractTruffleString.forwardIterator(b, arrayB, codeRangeB, encoding); - return TruffleStringIterator.indexOfString(this, aIt, bIt, fromIndex, toIndex, nextNodeA, nextNodeB); + return TruffleStringIterator.indexOfString(node, aIt, bIt, fromIndex, toIndex, nextNodeA, nextNodeB); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfStringRawNode extends Node { + abstract static class IndexOfStringRawNode extends AbstractInternalNode { - abstract int execute( + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, byte[] mask, Encoding encoding); @Specialization(guards = {"isSupportedEncoding(encoding) || isFixedWidth(codeRangeA)"}) - static int supported( + static int supported(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, byte[] mask, @SuppressWarnings("unused") Encoding encoding, @Cached TStringOpsNodes.RawIndexOfStringNode indexOfStringNode) { assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, toIndex - fromIndex); - return indexOfStringNode.execute(a, arrayA, b, arrayB, fromIndex, toIndex, mask); + return indexOfStringNode.execute(node, a, arrayA, b, arrayB, fromIndex, toIndex, mask); } @Specialization(guards = {"isUnsupportedEncoding(encoding)", "!isFixedWidth(codeRangeA)"}) - int unsupported( + static int unsupported(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, @SuppressWarnings("unused") byte[] mask, Encoding encoding, - @Cached TruffleStringIterator.NextNode nextNodeA, - @Cached TruffleStringIterator.NextNode nextNodeB) { + @Cached TruffleStringIterator.InternalNextNode nextNodeA, + @Cached TruffleStringIterator.InternalNextNode nextNodeB) { assert mask == null; assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, toIndex - fromIndex); TruffleStringIterator aIt = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); TruffleStringIterator bIt = AbstractTruffleString.forwardIterator(b, arrayB, codeRangeB, encoding); - return TruffleStringIterator.byteIndexOfString(this, aIt, bIt, fromIndex, toIndex, nextNodeA, nextNodeB); + return TruffleStringIterator.byteIndexOfString(node, aIt, bIt, fromIndex, toIndex, nextNodeA, nextNodeB); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class LastIndexOfStringNode extends Node { + abstract static class LastIndexOfStringNode extends AbstractInternalNode { - abstract int execute( + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, Encoding encoding); @Specialization(guards = {"isFixedWidth(codeRangeA, codeRangeB)"}) - static int direct( + static int direct(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, @SuppressWarnings("unused") Encoding encoding, @Cached RawLastIndexOfStringNode indexOfStringNode) { - assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, fromIndex - toIndex, GetCodePointLengthNode.getUncached()); - return indexOfStringNode.execute(a, arrayA, b, arrayB, fromIndex, toIndex, null); + assert !b.isEmpty() && !indexOfCannotMatch(node, codeRangeA, b, codeRangeB, fromIndex - toIndex, GetCodePointLengthNode.getUncached()); + return indexOfStringNode.execute(node, a, arrayA, b, arrayB, fromIndex, toIndex, null); } @Specialization(guards = {"!isFixedWidth(codeRangeA, codeRangeB)"}) - int decode( + static int decode(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, Encoding encoding, - @Cached TruffleStringIterator.NextNode nextNodeA, - @Cached TruffleStringIterator.PreviousNode prevNodeA, - @Cached TruffleStringIterator.PreviousNode prevNodeB) { - assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, fromIndex - toIndex, GetCodePointLengthNode.getUncached()); + @Cached TruffleStringIterator.InternalNextNode nextNodeA, + @Cached TruffleStringIterator.InternalPreviousNode prevNodeA, + @Cached TruffleStringIterator.InternalPreviousNode prevNodeB) { + assert !b.isEmpty() && !indexOfCannotMatch(node, codeRangeA, b, codeRangeB, fromIndex - toIndex, GetCodePointLengthNode.getUncached()); TruffleStringIterator aIt = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); TruffleStringIterator bIt = AbstractTruffleString.backwardIterator(b, arrayB, codeRangeB, encoding); - return TruffleStringIterator.lastIndexOfString(this, aIt, bIt, fromIndex, toIndex, nextNodeA, prevNodeA, prevNodeB); + return TruffleStringIterator.lastIndexOfString(node, aIt, bIt, fromIndex, toIndex, nextNodeA, prevNodeA, prevNodeB); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class LastIndexOfStringRawNode extends Node { + abstract static class LastIndexOfStringRawNode extends AbstractInternalNode { - abstract int execute( + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, byte[] mask, Encoding encoding); @Specialization(guards = {"isSupportedEncoding(encoding) || isFixedWidth(codeRangeA)"}) - static int lios8SameEncoding( + static int lios8SameEncoding(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, byte[] mask, @SuppressWarnings("unused") Encoding encoding, @Cached TStringOpsNodes.RawLastIndexOfStringNode indexOfStringNode) { assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, fromIndex - toIndex); - return indexOfStringNode.execute(a, arrayA, b, arrayB, fromIndex, toIndex, mask); + return indexOfStringNode.execute(node, a, arrayA, b, arrayB, fromIndex, toIndex, mask); } @Specialization(guards = {"isUnsupportedEncoding(encoding)", "!isFixedWidth(codeRangeA)"}) - int unsupported( + static int unsupported(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, AbstractTruffleString b, Object arrayB, int codeRangeB, int fromIndex, int toIndex, @SuppressWarnings("unused") byte[] mask, Encoding encoding, - @Cached TruffleStringIterator.NextNode nextNodeA, - @Cached TruffleStringIterator.PreviousNode prevNodeA, - @Cached TruffleStringIterator.PreviousNode prevNodeB) { + @Cached TruffleStringIterator.InternalNextNode nextNodeA, + @Cached TruffleStringIterator.InternalPreviousNode prevNodeA, + @Cached TruffleStringIterator.InternalPreviousNode prevNodeB) { assert mask == null; assert !b.isEmpty() && !indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, fromIndex - toIndex); TruffleStringIterator aIt = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding); TruffleStringIterator bIt = AbstractTruffleString.backwardIterator(b, arrayB, codeRangeB, encoding); - return TruffleStringIterator.lastByteIndexOfString(this, aIt, bIt, fromIndex, toIndex, nextNodeA, prevNodeA, prevNodeB); + return TruffleStringIterator.lastByteIndexOfString(node, aIt, bIt, fromIndex, toIndex, nextNodeA, prevNodeA, prevNodeB); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class StrideFromCodeRangeNode extends Node { + abstract static class StrideFromCodeRangeNode extends AbstractInternalNode { - abstract int execute(int codeRange, Encoding encoding); + abstract int execute(Node node, int codeRange, Encoding encoding); @Specialization(guards = "isUTF16(encoding)") int doUTF16(int codeRange, @SuppressWarnings("unused") Encoding encoding) { @@ -1328,11 +1329,9 @@ int doOther(@SuppressWarnings("unused") int codeRange, @SuppressWarnings("unused } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CalcStringAttributesNode extends Node { + abstract static class CalcStringAttributesNode extends AbstractInternalNode { - abstract long execute(AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange); + abstract long execute(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange); @SuppressWarnings("unused") @Specialization(guards = "length == 0") @@ -1347,21 +1346,16 @@ long ascii(AbstractTruffleString a, Object array, int offset, int length, int st } @Specialization(guards = {"!is7Bit(knownCodeRange)", "length > 0"}) - long notAscii(AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange, + static long notAscii(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange, @Cached CalcStringAttributesInnerNode calcNode) { - return calcNode.execute(a, array, offset, length, stride, encoding, fromIndex, knownCodeRange); + return calcNode.execute(node, a, array, offset, length, stride, encoding, fromIndex, knownCodeRange); } - static CalcStringAttributesNode getUncached() { - return TStringInternalNodesFactory.CalcStringAttributesNodeGen.getUncached(); - } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CalcStringAttributesInnerNode extends Node { + abstract static class CalcStringAttributesInnerNode extends AbstractInternalNode { - abstract long execute(AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange); + abstract long execute(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, int knownCodeRange); @Specialization(guards = {"is8Bit(knownCodeRange) || isAsciiBytesOrLatin1(encoding)", "stride == 0"}) long doLatin1(@SuppressWarnings("unused") AbstractTruffleString a, Object array, int offset, int length, @SuppressWarnings("unused") int stride, Encoding encoding, int fromIndex, @@ -1377,14 +1371,14 @@ long doBMP(@SuppressWarnings("unused") AbstractTruffleString a, Object array, in } @Specialization(guards = {"isUTF8(encoding)", "!isFixedWidth(knownCodeRange)"}) - long doUTF8(AbstractTruffleString a, Object array, int offset, int length, int stride, @SuppressWarnings("unused") Encoding encoding, int fromIndex, int knownCodeRange, - @Cached ConditionProfile brokenProfile) { + static long doUTF8(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, @SuppressWarnings("unused") Encoding encoding, int fromIndex, int knownCodeRange, + @Exclusive @Cached InlinedConditionProfile brokenProfile) { assert stride == 0; int off = offset + fromIndex; if (isValidMultiByte(knownCodeRange) && a != null) { - return TStringOps.calcStringAttributesUTF8(this, array, off, length, true, off + length == a.offset() + a.length(), brokenProfile); + return TStringOps.calcStringAttributesUTF8(node, array, off, length, true, off + length == a.offset() + a.length(), brokenProfile); } else { - return TStringOps.calcStringAttributesUTF8(this, array, off, length, false, false, brokenProfile); + return TStringOps.calcStringAttributesUTF8(node, array, off, length, false, false, brokenProfile); } } @@ -1410,84 +1404,81 @@ long doUTF32(@SuppressWarnings("unused") AbstractTruffleString a, Object array, } @Specialization(guards = "isUnsupportedEncoding(encoding)") - long doGeneric(@SuppressWarnings("unused") AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, + static long doGeneric(Node node, @SuppressWarnings("unused") AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int fromIndex, @SuppressWarnings("unused") int knownCodeRange, - @Cached ConditionProfile validCharacterProfile, - @Cached ConditionProfile fixedWidthProfile) { + @Exclusive @Cached InlinedConditionProfile validCharacterProfile, + @Exclusive @Cached InlinedConditionProfile fixedWidthProfile) { assert stride == 0; - return JCodings.getInstance().calcStringAttributes(this, array, offset, length, encoding, fromIndex, validCharacterProfile, fixedWidthProfile); + return JCodings.getInstance().calcStringAttributes(node, array, offset, length, encoding, fromIndex, validCharacterProfile, fixedWidthProfile); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ParseIntNode extends Node { + abstract static class ParseIntNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix) throws TruffleString.NumberFormatException; + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix) throws TruffleString.NumberFormatException; - @Specialization(guards = {"is7Bit(codeRangeA)", "cachedStride == a.stride()"}) - static int do7Bit(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int radix, - @Cached(value = "a.stride()", allowUncached = true) int cachedStride, - @Cached BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return NumberConversion.parseInt7Bit(a, arrayA, cachedStride, radix, errorProfile); + @SuppressWarnings("unused") + @Specialization(guards = {"is7Bit(codeRangeA)", "compaction == cachedCompaction"}, limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static int do7Bit(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int radix, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Cached InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return NumberConversion.parseInt7Bit(node, a, arrayA, cachedCompaction.getStride(), radix, errorProfile); } @Specialization(guards = "!is7Bit(codeRangeA)") - static int doGeneric(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix, - @Cached TruffleStringIterator.NextNode nextNode, - @Cached BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return NumberConversion.parseInt(AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), radix, errorProfile, nextNode); + static int doGeneric(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix, + @Cached TruffleStringIterator.InternalNextNode nextNode, + @Cached InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return NumberConversion.parseInt(node, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), radix, errorProfile, nextNode); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ParseLongNode extends Node { + abstract static class ParseLongNode extends AbstractInternalNode { - abstract long execute(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix) throws TruffleString.NumberFormatException; + abstract long execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix) throws TruffleString.NumberFormatException; - @Specialization(guards = {"is7Bit(codeRangeA)", "cachedStride == a.stride()"}) - static long do7Bit(AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int radix, - @Cached(value = "a.stride()", allowUncached = true) int cachedStride, - @Cached BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return NumberConversion.parseLong7Bit(a, arrayA, cachedStride, radix, errorProfile); + @SuppressWarnings("unused") + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static long do7Bit(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int radix, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Cached InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return NumberConversion.parseLong7Bit(node, a, arrayA, cachedCompaction.getStride(), radix, errorProfile); } @Specialization(guards = "!is7Bit(codeRangeA)") - static long parseLong(AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix, - @Cached TruffleStringIterator.NextNode nextNode, - @Cached BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return NumberConversion.parseLong(AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), radix, errorProfile, nextNode); + static long parseLong(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix, + @Cached TruffleStringIterator.InternalNextNode nextNode, + @Cached InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return NumberConversion.parseLong(node, AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, encoding), radix, errorProfile, nextNode); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class ParseDoubleNode extends Node { + abstract static class ParseDoubleNode extends AbstractInternalNode { - abstract double execute(AbstractTruffleString a, Object arrayA) throws TruffleString.NumberFormatException; + abstract double execute(Node node, AbstractTruffleString a, Object arrayA) throws TruffleString.NumberFormatException; - @Specialization(guards = "cachedStride == a.stride()") - double doParse(AbstractTruffleString a, Object arrayA, - @Cached(value = "a.stride()", allowUncached = true) int cachedStride, - @Cached BranchProfile errorProfile) throws TruffleString.NumberFormatException { - return FastDoubleParser.parseDouble(this, a, arrayA, cachedStride, 0, a.length(), errorProfile); + @SuppressWarnings("unused") + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static double doParse(Node node, AbstractTruffleString a, Object arrayA, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Cached InlinedBranchProfile errorProfile) throws TruffleString.NumberFormatException { + return FastDoubleParser.parseDouble(node, a, arrayA, cachedCompaction.getStride(), 0, a.length(), errorProfile); } } - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - abstract static class FromJavaStringUTF16Node extends Node { + abstract static class FromJavaStringUTF16Node extends AbstractInternalNode { FromJavaStringUTF16Node() { } - abstract TruffleString execute(String value, int charOffset, int length, boolean copy); + abstract TruffleString execute(Node node, String value, int charOffset, int length, boolean copy); @Specialization - TruffleString doNonEmpty(String javaString, int charOffset, int length, final boolean copy, - @Cached ConditionProfile utf16CompactProfile) { + static TruffleString doNonEmpty(Node node, String javaString, int charOffset, int length, final boolean copy, + @Cached InlinedConditionProfile utf16CompactProfile) { checkArrayRange(javaString.length(), charOffset, length); CompilerAsserts.partialEvaluationConstant(copy); if (length == 0) { @@ -1501,18 +1492,18 @@ TruffleString doNonEmpty(String javaString, int charOffset, int length, final bo int strideJS = TStringUnsafe.getJavaStringStride(javaString); int offsetJS = charOffset << 1; byte[] arrayJS = TStringUnsafe.getJavaStringArray(javaString); - if (utf16CompactProfile.profile(strideJS == 0)) { + if (utf16CompactProfile.profile(node, strideJS == 0)) { if (length == 1) { return TStringConstants.getSingleByte(Encoding.UTF_16, Byte.toUnsignedInt(arrayJS[charOffset])); } - codeRange = TStringOps.calcStringAttributesLatin1(this, arrayJS, offsetJS, length); + codeRange = TStringOps.calcStringAttributesLatin1(node, arrayJS, offsetJS, length); codePointLength = length; } else { assert strideJS == 1; if (length == 1 && TStringOps.readFromByteArray(arrayJS, 1, charOffset) <= 0xff) { return TStringConstants.getSingleByte(Encoding.UTF_16, TStringOps.readFromByteArray(arrayJS, 1, charOffset)); } - final long attrs = TStringOps.calcStringAttributesUTF16(this, arrayJS, offsetJS, length, false); + final long attrs = TStringOps.calcStringAttributesUTF16(node, arrayJS, offsetJS, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } @@ -1525,10 +1516,10 @@ TruffleString doNonEmpty(String javaString, int charOffset, int length, final bo array = new byte[length << stride]; offset = 0; if (strideJS == 1 && stride == 0) { - TStringOps.arraycopyWithStride(this, arrayJS, offsetJS, 1, 0, array, offset, 0, 0, length); + TStringOps.arraycopyWithStride(node, arrayJS, offsetJS, 1, 0, array, offset, 0, 0, length); } else { assert strideJS == stride; - TStringOps.arraycopyWithStride(this, arrayJS, offsetJS, 0, 0, array, offset, 0, 0, length << stride); + TStringOps.arraycopyWithStride(node, arrayJS, offsetJS, 0, 0, array, offset, 0, 0, length << stride); } } TruffleString ret = TruffleString.createFromArray(array, offset, length, stride, Encoding.UTF_16, codePointLength, codeRange); @@ -1541,52 +1532,48 @@ TruffleString doNonEmpty(String javaString, int charOffset, int length, final bo } } - @ImportStatic({TStringGuards.class, Encoding.class}) - @GenerateUncached - abstract static class ToJavaStringNode extends Node { + abstract static class ToJavaStringNode extends AbstractInternalNode { - abstract TruffleString execute(TruffleString a, Object arrayA); + abstract TruffleString execute(Node node, TruffleString a, Object arrayA); @Specialization(guards = "a.isCompatibleTo(UTF_16)") - static TruffleString doUTF16(TruffleString a, Object arrayA, + static TruffleString doUTF16(Node node, TruffleString a, Object arrayA, @Cached @Shared("createStringNode") CreateJavaStringNode createStringNode) { - return TruffleString.createWrapJavaString(createStringNode.execute(a, arrayA), a.codePointLength(), a.codeRange()); + return TruffleString.createWrapJavaString(createStringNode.execute(node, a, arrayA), a.codePointLength(), a.codeRange()); } @Specialization(guards = "!a.isCompatibleTo(UTF_16)") - static TruffleString doGeneric(TruffleString a, Object arrayA, + static TruffleString doGeneric(Node node, TruffleString a, Object arrayA, @Cached GetCodePointLengthNode getCodePointLengthNode, @Cached GetCodeRangeNode getCodeRangeNode, @Cached TransCodeNode transCodeNode, @Cached @Shared("createStringNode") CreateJavaStringNode createStringNode) { - TruffleString utf16 = transCodeNode.execute(a, arrayA, getCodePointLengthNode.execute(a), getCodeRangeNode.execute(a), Encoding.UTF_16); + TruffleString utf16 = transCodeNode.execute(node, a, arrayA, getCodePointLengthNode.execute(node, a), getCodeRangeNode.execute(node, a), Encoding.UTF_16); if (!utf16.isCacheHead()) { a.cacheInsert(utf16); } - return TruffleString.createWrapJavaString(createStringNode.execute(utf16, utf16.data()), utf16.codePointLength(), utf16.codeRange()); + return TruffleString.createWrapJavaString(createStringNode.execute(node, utf16, utf16.data()), utf16.codePointLength(), utf16.codeRange()); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CreateJavaStringNode extends Node { + abstract static class CreateJavaStringNode extends AbstractInternalNode { - abstract String execute(AbstractTruffleString a, Object arrayA); + abstract String execute(Node node, AbstractTruffleString a, Object arrayA); @Specialization - String createJavaString(AbstractTruffleString a, Object arrayA, - @Cached ConditionProfile reuseProfile, + static String createJavaString(Node node, AbstractTruffleString a, Object arrayA, + @Cached InlinedConditionProfile reuseProfile, @Cached GetCodeRangeNode getCodeRangeNode) { assert isUTF16Compatible(a); - final int codeRange = getCodeRangeNode.execute(a); + final int codeRange = getCodeRangeNode.execute(node, a); final int stride = Stride.fromCodeRangeUTF16(codeRange); final byte[] bytes; - if (reuseProfile.profile(a instanceof TruffleString && arrayA instanceof byte[] && a.length() << a.stride() == ((byte[]) arrayA).length && a.stride() == stride)) { + if (reuseProfile.profile(node, a instanceof TruffleString && arrayA instanceof byte[] && a.length() << a.stride() == ((byte[]) arrayA).length && a.stride() == stride)) { assert a.offset() == 0; bytes = (byte[]) arrayA; } else { bytes = new byte[a.length() << stride]; - TStringOps.arraycopyWithStride(this, + TStringOps.arraycopyWithStride(node, arrayA, a.offset(), a.stride(), 0, bytes, 0, stride, 0, a.length()); } @@ -1598,105 +1585,103 @@ private static boolean isUTF16Compatible(AbstractTruffleString a) { } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class TransCodeNode extends Node { + abstract static class TransCodeNode extends AbstractInternalNode { - abstract TruffleString execute(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding targetEncoding); + abstract TruffleString execute(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding targetEncoding); @Specialization - TruffleString transcode(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding targetEncoding, - @Cached ConditionProfile asciiBytesInvalidProfile, + static TruffleString transcode(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding targetEncoding, + @Cached InlinedConditionProfile asciiBytesInvalidProfile, @Cached TransCodeIntlNode transCodeIntlNode) { if (AbstractTruffleString.DEBUG_STRICT_ENCODING_CHECKS && a.isImmutable() && codeRangeA < targetEncoding.maxCompatibleCodeRange) { if (a.stride() == 0) { return TruffleString.createFromArray(arrayA, a.offset(), a.length(), 0, targetEncoding, codePointLengthA, codeRangeA, false); } int targetStride = Stride.fromCodeRange(codeRangeA, targetEncoding); - Object array = TStringOps.arraycopyOfWithStride(this, arrayA, a.offset(), a.length(), a.stride(), a.length(), targetStride); + Object array = TStringOps.arraycopyOfWithStride(node, arrayA, a.offset(), a.length(), a.stride(), a.length(), targetStride); return TruffleString.createFromArray(array, 0, a.length(), targetStride, targetEncoding, codePointLengthA, codeRangeA, false); } assert a.length() > 0; - if (asciiBytesInvalidProfile.profile((isAscii(a.encoding()) || isBytes(a.encoding())) && isSupportedEncoding(targetEncoding))) { + if (asciiBytesInvalidProfile.profile(node, (isAscii(a.encoding()) || isBytes(a.encoding())) && isSupportedEncoding(targetEncoding))) { assert (isBrokenFixedWidth(codeRangeA) || isValidFixedWidth(codeRangeA)) && isStride0(a) && codePointLengthA == a.length(); byte[] buffer = new byte[codePointLengthA]; for (int i = 0; i < buffer.length; i++) { int c = readS0(a, arrayA, i); buffer[i] = (byte) (c > 0x7f ? '?' : c); - TStringConstants.truffleSafePointPoll(this, i + 1); + TStringConstants.truffleSafePointPoll(node, i + 1); } return TransCodeIntlNode.create(a, buffer, buffer.length, 0, targetEncoding, codePointLengthA, TSCodeRange.get7Bit(), true); } else { - return transCodeIntlNode.execute(a, arrayA, codePointLengthA, codeRangeA, Encoding.get(a.encoding()), targetEncoding); + return transCodeIntlNode.execute(node, a, arrayA, codePointLengthA, codeRangeA, Encoding.get(a.encoding()), targetEncoding); } } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class TransCodeIntlNode extends Node { + abstract static class TransCodeIntlNode extends AbstractInternalNode { - abstract TruffleString execute(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding); + abstract TruffleString execute(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding); @SuppressWarnings("unused") @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "isAscii(targetEncoding) || isBytes(targetEncoding)"}) - TruffleString targetAscii(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode) { + static TruffleString targetAscii(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode) { assert !is7Bit(codeRangeA); byte[] buffer = new byte[codePointLengthA]; TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); int i = 0; while (it.hasNext()) { - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); buffer[i++] = codepoint > 0x7f ? (byte) '?' : (byte) codepoint; - TStringConstants.truffleSafePointPoll(this, i); + TStringConstants.truffleSafePointPoll(node, i); } return create(a, buffer, buffer.length, 0, targetEncoding, codePointLengthA, TSCodeRange.get7Bit(), true); } @SuppressWarnings("unused") @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "isLatin1(targetEncoding)"}) - TruffleString latin1Transcode(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode) { + static TruffleString latin1Transcode(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode) { assert !is7Or8Bit(codeRangeA); byte[] buffer = new byte[codePointLengthA]; TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); int codeRange = TSCodeRange.get7Bit(); int i = 0; while (it.hasNext()) { - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); byte latin1 = codepoint > 0xff ? (byte) '?' : (byte) codepoint; buffer[i++] = latin1; if (latin1 < 0) { codeRange = TSCodeRange.get8Bit(); } - TStringConstants.truffleSafePointPoll(this, i); + TStringConstants.truffleSafePointPoll(node, i); } return create(a, buffer, codePointLengthA, 0, Encoding.ISO_8859_1, codePointLengthA, codeRange, true); } @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "!isLarge(codePointLengthA)", "isUTF8(targetEncoding)"}) - TruffleString utf8TranscodeRegular(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode, - @Cached @Shared("brokenProfile") ConditionProfile brokenProfile, - @Cached @Shared("outOfMemoryProfile") BranchProfile outOfMemoryProfile) { - return utf8Transcode(a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, false, brokenProfile, outOfMemoryProfile); + static TruffleString utf8TranscodeRegular(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode, + @Cached @Shared("brokenProfile") InlinedConditionProfile brokenProfile, + @Cached @Shared("outOfMemoryProfile") InlinedBranchProfile outOfMemoryProfile) { + return utf8Transcode(node, a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, false, brokenProfile, outOfMemoryProfile); } @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "isLarge(codePointLengthA)", "isUTF8(targetEncoding)"}) - TruffleString utf8TranscodeLarge(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode, - @Cached @Shared("brokenProfile") ConditionProfile brokenProfile, - @Cached @Shared("outOfMemoryProfile") BranchProfile outOfMemoryProfile) { - return utf8Transcode(a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, true, brokenProfile, outOfMemoryProfile); + static TruffleString utf8TranscodeLarge(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode, + @Cached @Shared("brokenProfile") InlinedConditionProfile brokenProfile, + @Cached @Shared("outOfMemoryProfile") InlinedBranchProfile outOfMemoryProfile) { + return utf8Transcode(node, a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, true, brokenProfile, outOfMemoryProfile); } static boolean isLarge(int codePointLengthA) { return codePointLengthA > TStringConstants.MAX_ARRAY_SIZE / 4; } - private TruffleString utf8Transcode(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, - TruffleStringIterator.NextNode iteratorNextNode, boolean isLarge, ConditionProfile brokenProfile, BranchProfile outOfMemoryProfile) { + private static TruffleString utf8Transcode(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + TruffleStringIterator.InternalNextNode iteratorNextNode, boolean isLarge, InlinedConditionProfile brokenProfile, InlinedBranchProfile outOfMemoryProfile) { assert !is7Bit(codeRangeA); TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); byte[] buffer = new byte[isLarge ? TStringConstants.MAX_ARRAY_SIZE : codePointLengthA * 4]; @@ -1704,7 +1689,7 @@ private TruffleString utf8Transcode(AbstractTruffleString a, Object arrayA, int int length = 0; int loopCount = 0; while (it.hasNext()) { - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); if (Encodings.isUTF16Surrogate(codepoint) || Integer.toUnsignedLong(codepoint) > Character.MAX_CODE_POINT) { codeRange = TSCodeRange.getBrokenMultiByte(); codepoint = Encodings.invalidCodepoint(); @@ -1712,16 +1697,16 @@ private TruffleString utf8Transcode(AbstractTruffleString a, Object arrayA, int int n = Encodings.utf8EncodedSize(codepoint); assert isLarge || length + n <= buffer.length; if (isLarge && length > TStringConstants.MAX_ARRAY_SIZE - n) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(node); throw InternalErrors.outOfMemory(); } Encodings.utf8Encode(codepoint, buffer, length, n); length += n; - TStringConstants.truffleSafePointPoll(this, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } final int codePointLength; if (isBrokenMultiByte(codeRange)) { - long attrs = TStringOps.calcStringAttributesUTF8(this, buffer, 0, length, false, false, brokenProfile); + long attrs = TStringOps.calcStringAttributesUTF8(node, buffer, 0, length, false, false, brokenProfile); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } else { @@ -1755,21 +1740,23 @@ TruffleString utf16Fixed32Bit(AbstractTruffleString a, Object arrayA, int codePo } @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "!isFixedWidth(codeRangeA)", "!isLarge(codePointLengthA)", "isUTF16(targetEncoding)"}) - TruffleString utf16TranscodeRegular(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode, - @Cached @Shared("outOfMemoryProfile") BranchProfile outOfMemoryProfile) { - return utf16Transcode(a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, false, outOfMemoryProfile); + static TruffleString utf16TranscodeRegular(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode, + @Cached @Shared("outOfMemoryProfile") InlinedBranchProfile outOfMemoryProfile) { + return utf16Transcode(node, a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, false, outOfMemoryProfile); } @Specialization(guards = {"isSupportedEncoding(sourceEncoding)", "!isFixedWidth(codeRangeA)", "isLarge(codePointLengthA)", "isUTF16(targetEncoding)"}) - TruffleString utf16TranscodeLarge(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode, - @Cached @Shared("outOfMemoryProfile") BranchProfile outOfMemoryProfile) { - return utf16Transcode(a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, true, outOfMemoryProfile); + static TruffleString utf16TranscodeLarge(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode, + @Cached @Shared("outOfMemoryProfile") InlinedBranchProfile outOfMemoryProfile) { + return utf16Transcode(node, a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode, true, outOfMemoryProfile); } - private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, - TruffleStringIterator.NextNode iteratorNextNode, boolean isLarge, BranchProfile outOfMemoryProfile) { + private static TruffleString utf16Transcode(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + TruffleStringIterator.InternalNextNode iteratorNextNode, boolean isLarge, InlinedBranchProfile outOfMemoryProfile) { assert TStringGuards.isValidBrokenOrUnknownMultiByte(codeRangeA); TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); byte[] buffer = new byte[codePointLengthA]; @@ -1778,9 +1765,9 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int int codeRange = TSCodeRange.get7Bit(); while (it.hasNext()) { int curIndex = it.getRawIndex(); - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); if (codepoint > 0xff) { - buffer = TStringOps.arraycopyOfWithStride(this, buffer, 0, length, 0, codePointLengthA, 1); + buffer = TStringOps.arraycopyOfWithStride(node, buffer, 0, length, 0, codePointLengthA, 1); codeRange = TSCodeRange.get16Bit(); it.setRawIndex(curIndex); break; @@ -1789,7 +1776,7 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int codeRange = TSCodeRange.get8Bit(); } buffer[length++] = (byte) codepoint; - TStringConstants.truffleSafePointPoll(this, length); + TStringConstants.truffleSafePointPoll(node, length); } if (!it.hasNext()) { assert length == codePointLengthA; @@ -1797,7 +1784,7 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int } while (it.hasNext()) { int curIndex = it.getRawIndex(); - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); if (codepoint > 0xffff) { buffer = Arrays.copyOf(buffer, isLarge ? TStringConstants.MAX_ARRAY_SIZE : buffer.length * 2); codeRange = TSCodeRange.commonCodeRange(codeRange, TSCodeRange.getValidMultiByte()); @@ -1808,12 +1795,12 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int codeRange = TSCodeRange.getBrokenMultiByte(); } writeToByteArray(buffer, 1, length++, codepoint); - TStringConstants.truffleSafePointPoll(this, length); + TStringConstants.truffleSafePointPoll(node, length); } if (!it.hasNext()) { assert length == codePointLengthA; if (isBrokenMultiByte(codeRange)) { - long attrs = TStringOps.calcStringAttributesUTF16(this, buffer, 0, length, false); + long attrs = TStringOps.calcStringAttributesUTF16(node, buffer, 0, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } @@ -1821,19 +1808,19 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int } int loopCount = 0; while (it.hasNext()) { - int codepoint = iteratorNextNode.execute(it); + int codepoint = iteratorNextNode.execute(node, it); if (Encodings.isUTF16Surrogate(codepoint) || Integer.toUnsignedLong(codepoint) > Character.MAX_CODE_POINT) { codeRange = TSCodeRange.getBrokenMultiByte(); } if (isLarge && length + Encodings.utf16EncodedSize(codepoint) > TStringConstants.MAX_ARRAY_SIZE_S1) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(node); throw InternalErrors.outOfMemory(); } length += Encodings.utf16Encode(codepoint, buffer, length); - TStringConstants.truffleSafePointPoll(this, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } if (isBrokenMultiByte(codeRange)) { - long attrs = TStringOps.calcStringAttributesUTF16(this, buffer, 0, length, false); + long attrs = TStringOps.calcStringAttributesUTF16(node, buffer, 0, length, false); codePointLength = StringAttributes.getCodePointLength(attrs); codeRange = StringAttributes.getCodeRange(attrs); } @@ -1841,9 +1828,10 @@ private TruffleString utf16Transcode(AbstractTruffleString a, Object arrayA, int } @Specialization(guards = {"!isUTF16(sourceEncoding)", "isSupportedEncoding(sourceEncoding)", "!isFixedWidth(codeRangeA)", "!isLarge(codePointLengthA)", "isUTF32(targetEncoding)"}) - TruffleString utf32TranscodeRegular(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode) { - return utf32Transcode(a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode); + static TruffleString utf32TranscodeRegular(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode) { + return utf32Transcode(node, a, arrayA, codePointLengthA, codeRangeA, sourceEncoding, iteratorNextNode); } @SuppressWarnings("unused") @@ -1853,22 +1841,24 @@ static TruffleString utf32TranscodeLarge(AbstractTruffleString a, Object arrayA, } @Specialization(guards = {"isUTF16(sourceEncoding)", "!isFixedWidth(codeRangeA)", "!isLarge(codePointLengthA)", "isUTF32(targetEncoding)"}) - TruffleString utf32TranscodeUTF16(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, @SuppressWarnings("unused") Encoding targetEncoding, - @Cached @Shared("iteratorNextNode") TruffleStringIterator.NextNode iteratorNextNode) { + static TruffleString utf32TranscodeUTF16(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + @SuppressWarnings("unused") Encoding targetEncoding, + @Cached @Shared("iteratorNextNode") TruffleStringIterator.InternalNextNode iteratorNextNode) { assert containsSurrogates(a); TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); byte[] buffer = new byte[codePointLengthA << 2]; int length = 0; while (it.hasNext()) { - writeToByteArray(buffer, 2, length++, iteratorNextNode.execute(it)); - TStringConstants.truffleSafePointPoll(this, length); + writeToByteArray(buffer, 2, length++, iteratorNextNode.execute(node, it)); + TStringConstants.truffleSafePointPoll(node, length); } assert length == codePointLengthA; boolean isBroken = isBrokenMultiByte(codeRangeA); return create(a, buffer, length, 2, Encoding.UTF_32, codePointLengthA, isBroken ? TSCodeRange.getBrokenFixedWidth() : TSCodeRange.getValidFixedWidth(), isBroken); } - private TruffleString utf32Transcode(AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, TruffleStringIterator.NextNode iteratorNextNode) { + private static TruffleString utf32Transcode(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, int codeRangeA, Encoding sourceEncoding, + TruffleStringIterator.InternalNextNode iteratorNextNode) { assert TStringGuards.isValidBrokenOrUnknownMultiByte(codeRangeA); TruffleStringIterator it = AbstractTruffleString.forwardIterator(a, arrayA, codeRangeA, sourceEncoding); byte[] buffer = new byte[codePointLengthA]; @@ -1877,13 +1867,13 @@ private TruffleString utf32Transcode(AbstractTruffleString a, Object arrayA, int int codepoint = 0; while (it.hasNext()) { int curIndex = it.getRawIndex(); - codepoint = iteratorNextNode.execute(it); + codepoint = iteratorNextNode.execute(node, it); if (codepoint > 0xff) { if (Encodings.isUTF16Surrogate(codepoint)) { - buffer = TStringOps.arraycopyOfWithStride(this, buffer, 0, length, 0, codePointLengthA, 2); + buffer = TStringOps.arraycopyOfWithStride(node, buffer, 0, length, 0, codePointLengthA, 2); codeRange = TSCodeRange.getBrokenFixedWidth(); } else { - buffer = TStringOps.arraycopyOfWithStride(this, buffer, 0, length, 0, codePointLengthA, 1); + buffer = TStringOps.arraycopyOfWithStride(node, buffer, 0, length, 0, codePointLengthA, 1); codeRange = TSCodeRange.get16Bit(); } it.setRawIndex(curIndex); @@ -1893,7 +1883,7 @@ private TruffleString utf32Transcode(AbstractTruffleString a, Object arrayA, int codeRange = TSCodeRange.get8Bit(); } buffer[length++] = (byte) codepoint; - TStringConstants.truffleSafePointPoll(this, length); + TStringConstants.truffleSafePointPoll(node, length); } if (!it.hasNext()) { assert length == codePointLengthA; @@ -1902,15 +1892,15 @@ private TruffleString utf32Transcode(AbstractTruffleString a, Object arrayA, int if (is16Bit(codeRange)) { while (it.hasNext()) { int curIndex = it.getRawIndex(); - codepoint = iteratorNextNode.execute(it); + codepoint = iteratorNextNode.execute(node, it); if (codepoint > 0xffff || Encodings.isUTF16Surrogate(codepoint)) { - buffer = TStringOps.arraycopyOfWithStride(this, buffer, 0, length, 1, codePointLengthA, 2); + buffer = TStringOps.arraycopyOfWithStride(node, buffer, 0, length, 1, codePointLengthA, 2); codeRange = Encodings.isValidUnicodeCodepoint(codepoint) ? TSCodeRange.getValidFixedWidth() : TSCodeRange.getBrokenFixedWidth(); it.setRawIndex(curIndex); break; } writeToByteArray(buffer, 1, length++, codepoint); - TStringConstants.truffleSafePointPoll(this, length); + TStringConstants.truffleSafePointPoll(node, length); } } if (!it.hasNext()) { @@ -1918,23 +1908,24 @@ private TruffleString utf32Transcode(AbstractTruffleString a, Object arrayA, int return create(a, buffer, length, 1, Encoding.UTF_32, codePointLengthA, codeRange, isBrokenFixedWidth(codeRange)); } while (it.hasNext()) { - codepoint = iteratorNextNode.execute(it); + codepoint = iteratorNextNode.execute(node, it); if (!Encodings.isValidUnicodeCodepoint(codepoint)) { codeRange = TSCodeRange.getBrokenFixedWidth(); } writeToByteArray(buffer, 2, length++, codepoint); - TStringConstants.truffleSafePointPoll(this, length); + TStringConstants.truffleSafePointPoll(node, length); } return create(a, buffer, length, 2, Encoding.UTF_32, codePointLengthA, codeRange, isBrokenFixedWidth(codeRange)); } @Specialization(guards = {"isUnsupportedEncoding(sourceEncoding) || isUnsupportedEncoding(targetEncoding)"}) - TruffleString unsupported(AbstractTruffleString a, Object arrayA, int codePointLengthA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding sourceEncoding, + static TruffleString unsupported(Node node, AbstractTruffleString a, Object arrayA, int codePointLengthA, @SuppressWarnings("unused") int codeRangeA, + @SuppressWarnings("unused") Encoding sourceEncoding, Encoding targetEncoding, - @Cached BranchProfile outOfMemoryProfile, - @Cached ConditionProfile nativeProfile, + @Shared("outOfMemoryProfile") @Cached InlinedBranchProfile outOfMemoryProfile, + @Exclusive @Cached InlinedConditionProfile nativeProfile, @Cached FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { - return JCodings.getInstance().transcode(this, a, arrayA, codePointLengthA, targetEncoding, outOfMemoryProfile, nativeProfile, fromBufferWithStringCompactionNode); + return JCodings.getInstance().transcode(node, a, arrayA, codePointLengthA, targetEncoding, outOfMemoryProfile, nativeProfile, fromBufferWithStringCompactionNode); } private static TruffleString create(AbstractTruffleString a, byte[] buffer, int length, int stride, Encoding encoding, int codePointLength, int codeRange, boolean isCacheHead) { diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOps.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOps.java index ed901f8c2856..26943827b693 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOps.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOps.java @@ -48,7 +48,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import sun.misc.Unsafe; @@ -732,7 +732,7 @@ static int calcStringAttributesBMP(Node location, Object array, int offset, int return runCalcStringAttributesBMP(location, stubArray, stubOffset, length, isNative); } - static long calcStringAttributesUTF8(Node location, Object array, int offset, int length, boolean assumeValid, boolean isAtEnd, ConditionProfile brokenProfile) { + static long calcStringAttributesUTF8(Node location, Object array, int offset, int length, boolean assumeValid, boolean isAtEnd, InlinedConditionProfile brokenProfile) { final boolean isNative = isNativePointer(array); final byte[] stubArray = stubArray(array, isNative); validateRegion(stubArray, offset, length, 0, isNative); @@ -741,7 +741,7 @@ static long calcStringAttributesUTF8(Node location, Object array, int offset, in return runCalcStringAttributesUTF8(location, stubArray, stubOffset, length, isNative, true); } else { long attrs = runCalcStringAttributesUTF8(location, stubArray, stubOffset, length, isNative, false); - if (brokenProfile.profile(TStringGuards.isBrokenMultiByte(StringAttributes.getCodeRange(attrs)))) { + if (brokenProfile.profile(location, TStringGuards.isBrokenMultiByte(StringAttributes.getCodeRange(attrs)))) { int codePointLength = 0; for (int i = 0; i < length; i += Encodings.utf8GetCodePointLength(array, offset, length, i, TruffleString.ErrorHandling.BEST_EFFORT)) { codePointLength++; diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOpsNodes.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOpsNodes.java index 20e1fbc37f54..89249b0330b7 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOpsNodes.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringOpsNodes.java @@ -40,11 +40,12 @@ */ package com.oracle.truffle.api.strings; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.strings.TruffleString.CompactionLevel; final class TStringOpsNodes { @@ -56,24 +57,24 @@ final class TStringOpsNodes { */ static final String LIMIT_STRIDE = "9"; - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawReadValueNode extends Node { + static final String SINGLE_LIMIT_STRIDE = "3"; - abstract int execute(AbstractTruffleString a, Object arrayA, int i); + abstract static class RawReadValueNode extends AbstractInternalNode { - @Specialization(guards = {"stride(a) == cachedStrideA"}, limit = LIMIT_STRIDE) - static int cached(AbstractTruffleString a, Object arrayA, int i, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA) { - return TStringOps.readValue(a, arrayA, cachedStrideA, i); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int i); + + @SuppressWarnings("unused") + @Specialization(guards = {"compaction == cachedCompaction"}, limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static int cached(Node node, AbstractTruffleString a, Object arrayA, int i, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction) { + return TStringOps.readValue(a, arrayA, cachedCompaction.getStride(), i); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfAnyCharNode extends Node { + abstract static class IndexOfAnyCharNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, char[] values); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, char[] values); @Specialization(guards = {"isStride0(a)", "values.length == 1"}) int stride0(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, char[] values) { @@ -111,11 +112,9 @@ int stride1(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class IndexOfAnyIntNode extends Node { + abstract static class IndexOfAnyIntNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, int[] values); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, int[] values); @Specialization(guards = {"isStride0(a)", "values.length == 1"}) int stride0(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, int[] values) { @@ -183,76 +182,76 @@ int stride2(AbstractTruffleString a, Object arrayA, int fromIndex, int maxIndex, } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawIndexOfCodePointNode extends Node { + abstract static class RawIndexOfCodePointNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex); - @Specialization(guards = {"stride(a) == cachedStrideA"}, limit = LIMIT_STRIDE) - int cached(AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA) { - return TStringOps.indexOfCodePointWithStride(this, a, arrayA, cachedStrideA, fromIndex, toIndex, codepoint); + @SuppressWarnings("unused") + @Specialization(guards = {"compaction == cachedCompaction"}, limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static int cached(Node node, AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction) { + return TStringOps.indexOfCodePointWithStride(node, a, arrayA, cachedCompaction.getStride(), fromIndex, toIndex, codepoint); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawLastIndexOfCodePointNode extends Node { + abstract static class RawLastIndexOfCodePointNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex); - @Specialization(guards = {"stride(a) == cachedStrideA"}, limit = LIMIT_STRIDE) - int cached(AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA) { - return TStringOps.lastIndexOfCodePointWithOrMaskWithStride(this, a, arrayA, cachedStrideA, fromIndex, toIndex, codepoint, 0); + @SuppressWarnings("unused") + @Specialization(guards = {"compaction == cachedCompaction"}, limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static int cached(Node node, AbstractTruffleString a, Object arrayA, int codepoint, int fromIndex, int toIndex, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction) { + return TStringOps.lastIndexOfCodePointWithOrMaskWithStride(node, a, arrayA, cachedCompaction.getStride(), fromIndex, toIndex, codepoint, 0); } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawIndexOfStringNode extends Node { - - abstract int execute(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask); - - @Specialization(guards = {"length(b) == 1", "stride(a) == cachedStrideA", "stride(b) == cachedStrideB"}, limit = LIMIT_STRIDE) - int cachedLen1(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA, - @Cached(value = "stride(b)", allowUncached = true) int cachedStrideB) { - final int b0 = TStringOps.readValue(b, arrayB, cachedStrideB, 0); - final int mask0 = mask == null ? 0 : TStringOps.readFromByteArray(mask, cachedStrideB, 0); - return TStringOps.indexOfCodePointWithOrMaskWithStride(this, a, arrayA, cachedStrideA, fromIndex, toIndex, b0, mask0); + abstract static class RawIndexOfStringNode extends AbstractInternalNode { + + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask); + + @SuppressWarnings("unused") + @Specialization(guards = {"compactionA == cachedCompactionA", "compactionB == cachedCompactionB"}, limit = LIMIT_STRIDE) + static int doCached(Node node, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, + @Bind("fromStride(a.stride())") CompactionLevel compactionA, + @Cached("compactionA") CompactionLevel cachedCompactionA, + @Bind("fromStride(b.stride())") CompactionLevel compactionB, + @Cached("compactionB") CompactionLevel cachedCompactionB, + @Cached InlinedConditionProfile oneLength) { + if (oneLength.profile(node, b.length() == 1)) { + final int b0 = TStringOps.readValue(b, arrayB, cachedCompactionB.getStride(), 0); + final int mask0 = mask == null ? 0 : TStringOps.readFromByteArray(mask, cachedCompactionB.getStride(), 0); + return TStringOps.indexOfCodePointWithOrMaskWithStride(node, a, arrayA, cachedCompactionA.getStride(), fromIndex, toIndex, b0, mask0); + } else { + return TStringOps.indexOfStringWithOrMaskWithStride(node, a, arrayA, cachedCompactionA.getStride(), b, arrayB, cachedCompactionB.getStride(), fromIndex, toIndex, mask); + } } - @Specialization(guards = {"length(b) > 1", "stride(a) == cachedStrideA", "stride(b) == cachedStrideB"}, limit = LIMIT_STRIDE) - int cached(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA, - @Cached(value = "stride(b)", allowUncached = true) int cachedStrideB) { - return TStringOps.indexOfStringWithOrMaskWithStride(this, a, arrayA, cachedStrideA, b, arrayB, cachedStrideB, fromIndex, toIndex, mask); - } } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class RawLastIndexOfStringNode extends Node { - - abstract int execute(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask); - - @Specialization(guards = {"length(b) == 1", "stride(a) == cachedStrideA", "stride(b) == cachedStrideB"}, limit = LIMIT_STRIDE) - int cachedLen1(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA, - @Cached(value = "stride(b)", allowUncached = true) int cachedStrideB) { - final int b0 = TStringOps.readValue(b, arrayB, cachedStrideB, 0); - final int mask0 = mask == null ? 0 : TStringOps.readFromByteArray(mask, cachedStrideB, 0); - return TStringOps.lastIndexOfCodePointWithOrMaskWithStride(this, a, arrayA, cachedStrideA, fromIndex, toIndex, b0, mask0); + abstract static class RawLastIndexOfStringNode extends AbstractInternalNode { + + abstract int execute(Node node, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask); + + @SuppressWarnings("unused") + @Specialization(guards = {"compactionA == cachedCompactionA", "compactionB == cachedCompactionB"}, limit = LIMIT_STRIDE) + static int cachedLen1(Node node, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, + @Bind("fromStride(a.stride())") CompactionLevel compactionA, + @Cached("compactionA") CompactionLevel cachedCompactionA, + @Bind("fromStride(b.stride())") CompactionLevel compactionB, + @Cached("compactionB") CompactionLevel cachedCompactionB, + @Cached InlinedConditionProfile oneLength) { + if (oneLength.profile(node, b.length() == 1)) { + final int b0 = TStringOps.readValue(b, arrayB, cachedCompactionB.getStride(), 0); + final int mask0 = mask == null ? 0 : TStringOps.readFromByteArray(mask, cachedCompactionB.getStride(), 0); + return TStringOps.lastIndexOfCodePointWithOrMaskWithStride(node, a, arrayA, cachedCompactionA.getStride(), fromIndex, toIndex, b0, mask0); + } else { + return TStringOps.lastIndexOfStringWithOrMaskWithStride(node, a, arrayA, cachedCompactionA.getStride(), b, arrayB, cachedCompactionB.getStride(), fromIndex, toIndex, mask); + } } - @Specialization(guards = {"length(b) > 1", "stride(a) == cachedStrideA", "stride(b) == cachedStrideB"}, limit = LIMIT_STRIDE) - int cached(AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB, int fromIndex, int toIndex, byte[] mask, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA, - @Cached(value = "stride(b)", allowUncached = true) int cachedStrideB) { - return TStringOps.lastIndexOfStringWithOrMaskWithStride(this, a, arrayA, cachedStrideA, b, arrayB, cachedStrideB, fromIndex, toIndex, mask); - } } static int memcmp(Node location, AbstractTruffleString a, Object arrayA, AbstractTruffleString b, Object arrayB) { @@ -269,16 +268,16 @@ static int memCmpTail(int cmp, int lengthA, int lengthB) { return cmp == 0 ? lengthA - lengthB : cmp; } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class CalculateHashCodeNode extends Node { + @SuppressWarnings("unused") + abstract static class CalculateHashCodeNode extends AbstractInternalNode { - abstract int execute(AbstractTruffleString a, Object arrayA); + abstract int execute(Node node, AbstractTruffleString a, Object arrayA); - @Specialization(guards = {"stride(a) == cachedStrideA"}, limit = LIMIT_STRIDE) - int cached(AbstractTruffleString a, Object arrayA, - @Cached(value = "stride(a)", allowUncached = true) int cachedStrideA) { - return TStringOps.hashCodeWithStride(this, a, arrayA, cachedStrideA); + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + static int cached(Node node, AbstractTruffleString a, Object arrayA, + @Bind("fromStride(a.stride())") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction) { + return TStringOps.hashCodeWithStride(node, a, arrayA, cachedCompaction.getStride()); } } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index a89b53b09632..370a0e539ec7 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.api.strings; -import static com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import static com.oracle.truffle.api.CompilerDirectives.isPartialEvaluationConstant; import static com.oracle.truffle.api.strings.TStringGuards.indexOfCannotMatch; import static com.oracle.truffle.api.strings.TStringGuards.is16Bit; @@ -77,20 +76,22 @@ import org.graalvm.collections.Equivalence; import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GeneratePackagePrivate; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.nodes.DenyReplace; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.IntValueProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.profiles.InlinedIntValueProfile; +import com.oracle.truffle.api.strings.TStringInternalNodesFactory.CalcStringAttributesNodeGen; /** * Represents a primitive String type, which can be reused across languages. Language implementers @@ -239,9 +240,9 @@ private static boolean attrsAreCorrect(Object bytes, Encoding encoding, int offs knownCodeRange = TSCodeRange.get16Bit(); } if (bytes instanceof NativePointer) { - ((NativePointer) bytes).materializeByteArray(offset, length << stride, ConditionProfile.getUncached()); + ((NativePointer) bytes).materializeByteArray(null, offset, length << stride, InlinedConditionProfile.getUncached()); } - long attrs = TStringInternalNodes.CalcStringAttributesNode.getUncached().execute(null, bytes, offset, length, stride, encoding, 0, knownCodeRange); + long attrs = CalcStringAttributesNodeGen.getUncached().execute(null, null, bytes, offset, length, stride, encoding, 0, knownCodeRange); int cpLengthCalc = StringAttributes.getCodePointLength(attrs); int codeRangeCalc = StringAttributes.getCodeRange(attrs); assert cpLengthCalc == codePointLength : "inconsistent codePointLength: " + cpLengthCalc + " != " + codePointLength; @@ -1328,10 +1329,7 @@ public static final class WithMask { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CreateNode extends Node { + public abstract static class CreateNode extends AbstractPublicNode { CreateNode() { } @@ -1390,10 +1388,7 @@ public static WithMask createUncached(AbstractTruffleString a, byte[] mask, Enco * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CreateUTF16Node extends Node { + public abstract static class CreateUTF16Node extends AbstractPublicNode { CreateUTF16Node() { } @@ -1453,10 +1448,7 @@ public static WithMask createUTF16Uncached(AbstractTruffleString a, char[] mask) * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CreateUTF32Node extends Node { + public abstract static class CreateUTF32Node extends AbstractPublicNode { CreateUTF32Node() { } @@ -1557,9 +1549,7 @@ public enum ErrorHandling { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromCodePointNode extends Node { + public abstract static class FromCodePointNode extends AbstractPublicNode { FromCodePointNode() { } @@ -1590,14 +1580,14 @@ public final TruffleString execute(int codepoint, Encoding encoding) { public abstract TruffleString execute(int codepoint, Encoding encoding, boolean allowUTF16Surrogates); @Specialization - static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrogates, - @Cached ConditionProfile bytesProfile, - @Cached ConditionProfile utf8Profile, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile exoticProfile, - @Cached ConditionProfile bmpProfile, - @Cached BranchProfile invalidCodePoint) { + final TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrogates, + @Cached InlinedConditionProfile bytesProfile, + @Cached InlinedConditionProfile utf8Profile, + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile exoticProfile, + @Cached InlinedConditionProfile bmpProfile, + @Cached InlinedBranchProfile invalidCodePoint) { assert !allowUTF16Surrogates || isUTF16Or32(enc) : "allowUTF16Surrogates is only supported on UTF-16 and UTF-32"; CompilerAsserts.partialEvaluationConstant(allowUTF16Surrogates); if (is7BitCompatible(enc) && Integer.compareUnsigned(c, 0x7f) <= 0) { @@ -1607,9 +1597,9 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog assert isSupportedEncoding(enc); return TStringConstants.getSingleByte(enc, c); } - if (bytesProfile.profile(isBytes(enc))) { + if (bytesProfile.profile(this, isBytes(enc))) { if (Integer.compareUnsigned(c, 0xff) > 0) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } return TStringConstants.getSingleByte(Encoding.BYTES, c); @@ -1618,9 +1608,9 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog final int length; final int stride; final int codeRange; - if (utf8Profile.profile(isUTF8(enc))) { + if (utf8Profile.profile(this, isUTF8(enc))) { if (!Encodings.isValidUnicodeCodepoint(c)) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } assert c > 0x7f; @@ -1628,21 +1618,21 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog length = bytes.length; stride = 0; codeRange = TSCodeRange.getValidMultiByte(); - } else if (utf16Profile.profile(isUTF16(enc))) { + } else if (utf16Profile.profile(this, isUTF16(enc))) { if (Integer.toUnsignedLong(c) > 0x10ffff) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } assert c > 0xff; bytes = new byte[c <= 0xffff ? 2 : 4]; stride = 1; - if (bmpProfile.profile(c <= 0xffff)) { + if (bmpProfile.profile(this, c <= 0xffff)) { length = 1; if (Encodings.isUTF16Surrogate(c)) { if (allowUTF16Surrogates) { codeRange = TSCodeRange.getBrokenMultiByte(); } else { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } } else { @@ -1654,9 +1644,9 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog codeRange = TSCodeRange.getValidMultiByte(); Encodings.utf16EncodeSurrogatePair(c, bytes, 0); } - } else if (utf32Profile.profile(isUTF32(enc))) { + } else if (utf32Profile.profile(this, isUTF32(enc))) { if (Integer.toUnsignedLong(c) > 0x10ffff) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } assert c > 0xff; @@ -1665,7 +1655,7 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog if (allowUTF16Surrogates) { codeRange = TSCodeRange.getBrokenFixedWidth(); } else { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } } else { @@ -1677,32 +1667,32 @@ static TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surrog final boolean compact1 = TSCodeRange.is16Bit(codeRange); bytes = new byte[compact1 ? 2 : 4]; length = 1; - if (bmpProfile.profile(compact1)) { + if (bmpProfile.profile(this, compact1)) { stride = 1; TStringOps.writeToByteArray(bytes, 1, 0, c); } else { stride = 2; TStringOps.writeToByteArray(bytes, 2, 0, c); } - } else if (exoticProfile.profile(!isSupportedEncoding(enc))) { + } else if (exoticProfile.profile(this, !isSupportedEncoding(enc))) { assert !isBytes(enc); JCodings.Encoding jCodingsEnc = JCodings.getInstance().get(enc); length = JCodings.getInstance().getCodePointLength(jCodingsEnc, c); stride = 0; codeRange = JCodings.getInstance().isSingleByte(jCodingsEnc) ? TSCodeRange.getValidFixedWidth() : TSCodeRange.getValidMultiByte(); if (length < 1) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } bytes = new byte[length]; int ret = JCodings.getInstance().writeCodePoint(jCodingsEnc, c, bytes, 0); if (ret != length || JCodings.getInstance().getCodePointLength(jCodingsEnc, bytes, 0, length) != ret || JCodings.getInstance().readCodePoint(jCodingsEnc, bytes, 0, length) != c) { - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } } else { assert isAscii(enc) && Integer.compareUnsigned(c, 0x7f) > 0 || (isLatin1(enc) && Integer.compareUnsigned(c, 0xff) > 0); - invalidCodePoint.enter(); + invalidCodePoint.enter(this); return null; } return TruffleString.createFromByteArray(bytes, length, stride, enc, 1, codeRange); @@ -1753,10 +1743,7 @@ public static TruffleString fromCodePointUncached(int codepoint, Encoding encodi * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromLongNode extends Node { + public abstract static class FromLongNode extends AbstractPublicNode { FromLongNode() { } @@ -1834,10 +1821,7 @@ public static TruffleString fromLongUncached(long value, Encoding encoding, bool * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromByteArrayNode extends Node { + public abstract static class FromByteArrayNode extends AbstractPublicNode { FromByteArrayNode() { } @@ -1874,10 +1858,10 @@ public final TruffleString execute(byte[] value, Encoding encoding, boolean copy public abstract TruffleString execute(byte[] value, int byteOffset, int byteLength, Encoding encoding, boolean copy); @Specialization - static TruffleString fromByteArray(byte[] value, int byteOffset, int byteLength, Encoding enc, boolean copy, + final TruffleString fromByteArray(byte[] value, int byteOffset, int byteLength, Encoding enc, boolean copy, @Cached TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { checkArrayRange(value, byteOffset, byteLength); - return fromBufferWithStringCompactionNode.execute(value, byteOffset, byteLength, enc, copy, true); + return fromBufferWithStringCompactionNode.execute(this, value, byteOffset, byteLength, enc, copy, true); } /** @@ -1937,7 +1921,8 @@ public static TruffleString fromByteArrayUncached(byte[] value, int byteOffset, @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached - public abstract static class FromCharArrayUTF16Node extends Node { + @GenerateInline(false) + public abstract static class FromCharArrayUTF16Node extends AbstractPublicNode { FromCharArrayUTF16Node() { } @@ -1959,9 +1944,9 @@ public final TruffleString execute(char[] value) { public abstract TruffleString execute(char[] value, int charOffset, int charLength); @Specialization - TruffleString doNonEmpty(char[] value, int charOffset, int charLength, - @Cached ConditionProfile utf16CompactProfile, - @Cached BranchProfile outOfMemoryProfile) { + final TruffleString doNonEmpty(char[] value, int charOffset, int charLength, + @Cached InlinedConditionProfile utf16CompactProfile, + @Cached InlinedBranchProfile outOfMemoryProfile) { checkArrayRange(value.length, charOffset, charLength); if (charLength == 0) { return Encoding.UTF_16.getEmpty(); @@ -1971,7 +1956,7 @@ TruffleString doNonEmpty(char[] value, int charOffset, int charLength, } int offsetV = charOffset << 1; if (value.length > TStringConstants.MAX_ARRAY_SIZE_S1 || offsetV < 0) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(this); throw InternalErrors.outOfMemory(); } long attrs = TStringOps.calcStringAttributesUTF16C(this, value, offsetV, charLength); @@ -1979,7 +1964,7 @@ TruffleString doNonEmpty(char[] value, int charOffset, int charLength, final int codeRange = StringAttributes.getCodeRange(attrs); final int stride = Stride.fromCodeRangeUTF16(codeRange); final byte[] array = new byte[charLength << stride]; - if (utf16CompactProfile.profile(stride == 0)) { + if (utf16CompactProfile.profile(this, stride == 0)) { TStringOps.arraycopyWithStrideCB(this, value, offsetV, array, 0, 0, charLength); } else { TStringOps.arraycopyWithStrideCB(this, value, offsetV, array, 0, 1, charLength); @@ -2032,10 +2017,7 @@ public static TruffleString fromCharArrayUTF16Uncached(char[] value, int charOff * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromJavaStringNode extends Node { + public abstract static class FromJavaStringNode extends AbstractPublicNode { FromJavaStringNode() { } @@ -2062,18 +2044,18 @@ public final TruffleString execute(String value, Encoding encoding) { public abstract TruffleString execute(String value, int charOffset, int length, Encoding encoding, boolean copy); @Specialization - static TruffleString doUTF16(String javaString, int charOffset, int length, Encoding encoding, final boolean copy, + final TruffleString doUTF16(String javaString, int charOffset, int length, Encoding encoding, final boolean copy, @Cached TStringInternalNodes.FromJavaStringUTF16Node fromJavaStringUTF16Node, - @Cached SwitchEncodingNode switchEncodingNode, - @Cached ConditionProfile utf16Profile) { + @Cached InternalSwitchEncodingNode switchEncodingNode, + @Cached InlinedConditionProfile utf16Profile) { if (javaString.isEmpty()) { return encoding.getEmpty(); } - TruffleString utf16String = fromJavaStringUTF16Node.execute(javaString, charOffset, length, copy); - if (utf16Profile.profile(encoding == Encoding.UTF_16)) { + TruffleString utf16String = fromJavaStringUTF16Node.execute(this, javaString, charOffset, length, copy); + if (utf16Profile.profile(this, encoding == Encoding.UTF_16)) { return utf16String; } - return switchEncodingNode.execute(utf16String, encoding); + return switchEncodingNode.execute(this, utf16String, encoding); } /** @@ -2120,10 +2102,7 @@ public static TruffleString fromJavaStringUncached(String s, int charOffset, int * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromIntArrayUTF32Node extends Node { + public abstract static class FromIntArrayUTF32Node extends AbstractPublicNode { FromIntArrayUTF32Node() { } @@ -2145,10 +2124,10 @@ public final TruffleString execute(int[] value) { public abstract TruffleString execute(int[] value, int intOffset, int intLength); @Specialization - TruffleString doNonEmpty(int[] value, int intOffset, int length, - @Cached ConditionProfile utf32Compact0Profile, - @Cached ConditionProfile utf32Compact1Profile, - @Cached BranchProfile outOfMemoryProfile) { + final TruffleString doNonEmpty(int[] value, int intOffset, int length, + @Cached InlinedConditionProfile utf32Compact0Profile, + @Cached InlinedConditionProfile utf32Compact1Profile, + @Cached InlinedBranchProfile outOfMemoryProfile) { checkArrayRange(value.length, intOffset, length); if (length == 0) { return Encoding.UTF_32.getEmpty(); @@ -2158,15 +2137,15 @@ TruffleString doNonEmpty(int[] value, int intOffset, int length, } int offsetV = intOffset << 2; if (length > TStringConstants.MAX_ARRAY_SIZE_S2 || offsetV < 0) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(this); throw InternalErrors.outOfMemory(); } final int codeRange = TStringOps.calcStringAttributesUTF32I(this, value, offsetV, length); final int stride = Stride.fromCodeRangeUTF32(codeRange); final byte[] array = new byte[length << stride]; - if (utf32Compact0Profile.profile(stride == 0)) { + if (utf32Compact0Profile.profile(this, stride == 0)) { TStringOps.arraycopyWithStrideIB(this, value, offsetV, array, 0, 0, length); - } else if (utf32Compact1Profile.profile(stride == 1)) { + } else if (utf32Compact1Profile.profile(this, stride == 1)) { TStringOps.arraycopyWithStrideIB(this, value, offsetV, array, 0, 1, length); } else { TStringOps.arraycopyWithStrideIB(this, value, offsetV, array, 0, 2, length); @@ -2219,10 +2198,7 @@ public static TruffleString fromIntArrayUTF32Uncached(int[] value, int intOffset * * @since 22.1 */ - @ImportStatic({TStringGuards.class, TStringAccessor.class}) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class FromNativePointerNode extends Node { + public abstract static class FromNativePointerNode extends AbstractPublicNode { FromNativePointerNode() { } @@ -2259,15 +2235,15 @@ public abstract static class FromNativePointerNode extends Node { public abstract TruffleString execute(Object pointerObject, int byteOffset, int byteLength, Encoding encoding, boolean copy); @Specialization - TruffleString fromNativePointer(Object pointerObject, int byteOffset, int byteLength, Encoding enc, boolean copy, + final TruffleString fromNativePointer(Object pointerObject, int byteOffset, int byteLength, Encoding enc, boolean copy, @Cached(value = "createInteropLibrary()", uncached = "getUncachedInteropLibrary()") Node interopLibrary, @Cached TStringInternalNodes.FromNativePointerNode fromNativePointerNode, @Cached TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { NativePointer pointer = NativePointer.create(this, pointerObject, interopLibrary); if (copy) { - return fromBufferWithStringCompactionNode.execute(pointer, byteOffset, byteLength, enc, true, true); + return fromBufferWithStringCompactionNode.execute(this, pointer, byteOffset, byteLength, enc, true, true); } - return fromNativePointerNode.execute(pointer, byteOffset, byteLength, enc, true); + return fromNativePointerNode.execute(this, pointer, byteOffset, byteLength, enc, true); } /** @@ -2305,10 +2281,7 @@ public static TruffleString fromNativePointerUncached(Object pointerObject, int * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AsTruffleStringNode extends Node { + public abstract static class AsTruffleStringNode extends AbstractPublicNode { AsTruffleStringNode() { } @@ -2323,15 +2296,8 @@ public abstract static class AsTruffleStringNode extends Node { public abstract TruffleString execute(AbstractTruffleString value, Encoding expectedEncoding); @Specialization - static TruffleString immutable(TruffleString a, Encoding expectedEncoding) { - a.checkEncoding(expectedEncoding); - return a; - } - - @Specialization - static TruffleString fromMutableString(MutableTruffleString a, Encoding expectedEncoding, - @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { - return fromBufferWithStringCompactionNode.execute(a, expectedEncoding); + final TruffleString doDefault(AbstractTruffleString value, Encoding expectedEncoding, @Cached InternalAsTruffleStringNode internalNode) { + return internalNode.execute(this, value, expectedEncoding); } /** @@ -2353,6 +2319,30 @@ public static AsTruffleStringNode getUncached() { } } + abstract static class InternalAsTruffleStringNode extends AbstractInternalNode { + + /** + * If the given string is already a {@link TruffleString}, return it. If it is a + * {@link MutableTruffleString}, create a new {@link TruffleString}, copying the mutable + * string's contents. + * + * @since 22.1 + */ + abstract TruffleString execute(Node node, AbstractTruffleString value, Encoding expectedEncoding); + + @Specialization + static TruffleString immutable(TruffleString a, Encoding expectedEncoding) { + a.checkEncoding(expectedEncoding); + return a; + } + + @Specialization + static TruffleString fromMutableString(Node node, MutableTruffleString a, Encoding expectedEncoding, + @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { + return fromBufferWithStringCompactionNode.execute(node, a, expectedEncoding); + } + } + /** * Node to get the given {@link AbstractTruffleString} as a managed {@link TruffleString}, * meaning that the resulting string's backing memory is not a native pointer. See @@ -2360,10 +2350,7 @@ public static AsTruffleStringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AsManagedNode extends Node { + public abstract static class AsManagedNode extends AbstractPublicNode { AsManagedNode() { } @@ -2405,9 +2392,9 @@ static TruffleString managedImmutable(TruffleString a, Encoding expectedEncoding } @Specialization(guards = "a.isNative()") - static TruffleString nativeImmutable(TruffleString a, Encoding encoding, boolean cacheResult, - @Cached ConditionProfile cacheHit, - @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { + TruffleString nativeImmutable(TruffleString a, Encoding encoding, boolean cacheResult, + @Cached InlinedConditionProfile cacheHit, + @Shared("attributesNode") @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode attributesNode) { CompilerAsserts.partialEvaluationConstant(cacheResult); a.checkEncoding(encoding); TruffleString cur = a.next; @@ -2416,12 +2403,12 @@ static TruffleString nativeImmutable(TruffleString a, Encoding encoding, boolean while (cur != a && (cur.isNative() || cur.isJavaString() || !cur.isCompatibleTo(encoding))) { cur = cur.next; } - if (cacheHit.profile(cur != a)) { + if (cacheHit.profile(this, cur != a)) { assert cur.isCompatibleTo(encoding) && cur.isManaged() && !cur.isJavaString(); return cur; } } - TruffleString managed = fromBufferWithStringCompactionNode.execute(a, !cacheResult, encoding); + TruffleString managed = attributesNode.execute(this, a, !cacheResult, encoding); if (cacheResult) { a.cacheInsert(managed); } @@ -2429,11 +2416,11 @@ static TruffleString nativeImmutable(TruffleString a, Encoding encoding, boolean } @Specialization - static TruffleString mutable(MutableTruffleString a, Encoding expectedEncoding, boolean cacheResult, - @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { + TruffleString mutable(MutableTruffleString a, Encoding expectedEncoding, boolean cacheResult, + @Shared("attributesNode") @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode attributesNode) { CompilerAsserts.partialEvaluationConstant(cacheResult); a.checkEncoding(expectedEncoding); - return fromBufferWithStringCompactionNode.execute(a, expectedEncoding); + return attributesNode.execute(this, a, expectedEncoding); } /** @@ -2455,102 +2442,56 @@ public static AsManagedNode getUncached() { } } - @ImportStatic(TStringGuards.class) - abstract static class ToIndexableNode extends Node { - - abstract Object execute(AbstractTruffleString a, Object data); - - abstract static class ToIndexableImplNode extends ToIndexableNode { + abstract static class ToIndexableNode extends AbstractInternalNode { - @Specialization - static byte[] doByteArray(@SuppressWarnings("unused") AbstractTruffleString a, byte[] data) { - return data; - } + abstract Object execute(Node node, AbstractTruffleString a, Object data); - @Specialization(guards = "isSupportedEncoding(a.encoding())") - static NativePointer doNativeSupported(@SuppressWarnings("unused") AbstractTruffleString a, NativePointer data) { - return data; - } - - @Specialization(guards = "!isSupportedEncoding(a.encoding())") - static NativePointer doNativeUnsupported(@SuppressWarnings("unused") AbstractTruffleString a, NativePointer data, - @Cached ConditionProfile materializeProfile) { - data.materializeByteArray(a, materializeProfile); - return data; - } - - @Specialization - byte[] doLazyConcat(AbstractTruffleString a, @SuppressWarnings("unused") LazyConcat data) { - return doLazyConcatIntl(this, a); - } - - private static byte[] doLazyConcatIntl(ToIndexableNode location, AbstractTruffleString a) { - // note: the write to a.data is racy, and we deliberately read it from the TString - // object again after the race to de-duplicate simultaneously generated arrays - a.setData(LazyConcat.flatten(location, (TruffleString) a)); - return (byte[]) a.data(); - } - - @Specialization - static byte[] doLazyLong(AbstractTruffleString a, LazyLong data, - @Cached ConditionProfile materializeProfile) { - // same pattern as in #doLazyConcat: racy write to data.bytes and read the result - // again to de-duplicate - if (materializeProfile.profile(data.bytes == null)) { - data.setBytes((TruffleString) a, NumberConversion.longToString(data.value, a.length())); - } - return data.bytes; - } + @SuppressWarnings("unused") + @Specialization(guards = "isByteArray(data)") + static byte[] doByteArray(AbstractTruffleString a, Object data) { + return (byte[]) data; } - @DenyReplace - private static final class Uncached extends ToIndexableNode { - - private static final Uncached INSTANCE = new Uncached(); - - @TruffleBoundary - @Override - Object execute(AbstractTruffleString a, Object data) { - if (data instanceof byte[]) { - return data; - } - return slowPath(a, data); - } + /* + * Workaround for DSL bug. + */ + static boolean isByteArray(Object value) { + return value instanceof byte[]; + } - private static Object slowPath(AbstractTruffleString a, Object data) { - if (data instanceof NativePointer) { - if (TStringGuards.isSupportedEncoding(a.encoding())) { - return ToIndexableImplNode.doNativeSupported(a, (NativePointer) data); - } else { - return ToIndexableImplNode.doNativeUnsupported(a, (NativePointer) data, ConditionProfile.getUncached()); - } - } - if (data instanceof LazyConcat) { - return ToIndexableImplNode.doLazyConcatIntl(INSTANCE, a); - } - if (data instanceof LazyLong) { - return ToIndexableImplNode.doLazyLong(a, (LazyLong) data, ConditionProfile.getUncached()); - } - throw new UnsupportedSpecializationException(INSTANCE, new Node[]{null, null}, a, data); - } + @Specialization(guards = "isSupportedEncoding(a.encoding())") + static NativePointer doNativeSupported(@SuppressWarnings("unused") AbstractTruffleString a, NativePointer data) { + return data; + } - @Override - public NodeCost getCost() { - return NodeCost.MEGAMORPHIC; - } + @Specialization(guards = "!isSupportedEncoding(a.encoding())") + static NativePointer doNativeUnsupported(Node node, @SuppressWarnings("unused") AbstractTruffleString a, NativePointer data, + @Shared("materializeProfile") @Cached InlinedConditionProfile materializeProfile) { + data.materializeByteArray(node, a, materializeProfile); + return data; + } - @Override - public boolean isAdoptable() { - return false; - } + @Specialization + byte[] doLazyConcat(AbstractTruffleString a, @SuppressWarnings("unused") LazyConcat data) { + return doLazyConcatIntl(this, a); } - static ToIndexableNode create() { - return TruffleStringFactory.ToIndexableNodeFactory.ToIndexableImplNodeGen.create(); + private static byte[] doLazyConcatIntl(ToIndexableNode location, AbstractTruffleString a) { + // note: the write to a.data is racy, and we deliberately read it from the TString + // object again after the race to de-duplicate simultaneously generated arrays + a.setData(LazyConcat.flatten(location, (TruffleString) a)); + return (byte[]) a.data(); } - static ToIndexableNode getUncached() { - return Uncached.INSTANCE; + @Specialization + static byte[] doLazyLong(Node node, AbstractTruffleString a, LazyLong data, + @Shared("materializeProfile") @Cached InlinedConditionProfile materializeProfile) { + // same pattern as in #doLazyConcat: racy write to data.bytes and read the result + // again to de-duplicate + if (materializeProfile.profile(node, data.bytes == null)) { + data.setBytes((TruffleString) a, NumberConversion.longToString(data.value, a.length())); + } + return data.bytes; } } @@ -2560,9 +2501,7 @@ static ToIndexableNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class MaterializeNode extends Node { + public abstract static class MaterializeNode extends AbstractPublicNode { MaterializeNode() { } @@ -2576,10 +2515,10 @@ public abstract static class MaterializeNode extends Node { public abstract void execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static void doMaterialize(AbstractTruffleString a, Encoding expectedEncoding, + final void doMaterialize(AbstractTruffleString a, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode) { a.checkEncoding(expectedEncoding); - toIndexableNode.execute(a, a.data()); + toIndexableNode.execute(this, a, a.data()); assert a.isMaterialized(expectedEncoding); } @@ -2607,9 +2546,7 @@ public static MaterializeNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class GetCodeRangeNode extends Node { + public abstract static class GetCodeRangeNode extends AbstractPublicNode { GetCodeRangeNode() { } @@ -2622,10 +2559,10 @@ public abstract static class GetCodeRangeNode extends Node { public abstract CodeRange execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, + final CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode) { a.checkEncoding(expectedEncoding); - return CodeRange.get(getCodeRangeNode.execute(a)); + return CodeRange.get(getCodeRangeNode.execute(this, a)); } /** @@ -2653,9 +2590,7 @@ public static GetCodeRangeNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class GetByteCodeRangeNode extends Node { + public abstract static class GetByteCodeRangeNode extends AbstractPublicNode { GetByteCodeRangeNode() { } @@ -2678,10 +2613,10 @@ public abstract static class GetByteCodeRangeNode extends Node { public abstract CodeRange execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, + final CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode) { a.checkEncoding(expectedEncoding); - return CodeRange.getByteCodeRange(getCodeRangeNode.execute(a), expectedEncoding); + return CodeRange.getByteCodeRange(getCodeRangeNode.execute(this, a), expectedEncoding); } /** @@ -2709,9 +2644,7 @@ public static GetByteCodeRangeNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CodeRangeEqualsNode extends Node { + public abstract static class CodeRangeEqualsNode extends AbstractPublicNode { CodeRangeEqualsNode() { } @@ -2724,10 +2657,10 @@ public abstract static class CodeRangeEqualsNode extends Node { * {@code * @Specialization(guards = "codeRangeEqualsNode.execute(a, cachedCodeRange)") * static void someOperation(TString a, - * @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, - * @Cached TruffleString.CodeRangeEqualsNode codeRangeEqualsNode, - * @Cached("getCodeRangeNode.execute(a)") CodeRange cachedCodeRange) { - * // ... + * @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, + * @Cached TruffleString.CodeRangeEqualsNode codeRangeEqualsNode, + * @Cached("getCodeRangeNode.execute(this, a)") CodeRange cachedCodeRange) { + * // ... * } * } * @@ -2737,9 +2670,9 @@ public abstract static class CodeRangeEqualsNode extends Node { public abstract boolean execute(AbstractTruffleString a, CodeRange codeRange); @Specialization - static boolean codeRangeEquals(AbstractTruffleString a, CodeRange codeRange, + final boolean codeRangeEquals(AbstractTruffleString a, CodeRange codeRange, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode) { - return CodeRange.equals(getCodeRangeNode.execute(a), codeRange); + return CodeRange.equals(getCodeRangeNode.execute(this, a), codeRange); } /** @@ -2766,9 +2699,7 @@ public static CodeRangeEqualsNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class IsValidNode extends Node { + public abstract static class IsValidNode extends AbstractPublicNode { IsValidNode() { } @@ -2781,10 +2712,10 @@ public abstract static class IsValidNode extends Node { public abstract boolean execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static boolean isValid(AbstractTruffleString a, Encoding expectedEncoding, + final boolean isValid(AbstractTruffleString a, Encoding expectedEncoding, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode) { a.checkEncoding(expectedEncoding); - int codeRange = getCodeRangeNode.execute(a); + int codeRange = getCodeRangeNode.execute(this, a); return !isBrokenMultiByte(codeRange) && !isBrokenFixedWidth(codeRange); } @@ -2811,13 +2742,13 @@ public static IsValidNode getUncached() { * Represents a string's compaction level, i.e. the internal number of bytes per array element. * This is relevant only for {@link Encoding#UTF_16} and {@link Encoding#UTF_32}, since * TruffleString doesn't support string compaction on any other encoding. - * + * * @since 23.0 */ public enum CompactionLevel { /** * One byte per array element. - * + * * @since 23.0 */ S1(1, 0), @@ -2842,6 +2773,10 @@ public enum CompactionLevel { this.log2 = log2; } + int getStride() { + return log2; + } + /** * Get the number of bytes per internal array element. * @@ -2860,7 +2795,7 @@ public final int getLog2() { return log2; } - private static CompactionLevel fromStride(int stride) { + static CompactionLevel fromStride(int stride) { assert Stride.isStride(stride); if (stride == 0) { return S1; @@ -2878,9 +2813,7 @@ private static CompactionLevel fromStride(int stride) { * * @since 23.0 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class GetStringCompactionLevelNode extends Node { + public abstract static class GetStringCompactionLevelNode extends AbstractPublicNode { GetStringCompactionLevelNode() { } @@ -2934,10 +2867,7 @@ public static GetStringCompactionLevelNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CodePointLengthNode extends Node { + public abstract static class CodePointLengthNode extends AbstractPublicNode { CodePointLengthNode() { } @@ -2954,10 +2884,10 @@ public abstract static class CodePointLengthNode extends Node { public abstract int execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static int get(AbstractTruffleString a, Encoding expectedEncoding, + final int get(AbstractTruffleString a, Encoding expectedEncoding, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode) { a.checkEncoding(expectedEncoding); - return getCodePointLengthNode.execute(a); + return getCodePointLengthNode.execute(this, a); } /** @@ -2986,9 +2916,7 @@ public static CodePointLengthNode getUncached() { * @see TruffleString#hashCode() * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class HashCodeNode extends Node { + public abstract static class HashCodeNode extends AbstractPublicNode { HashCodeNode() { } @@ -3002,14 +2930,14 @@ public abstract static class HashCodeNode extends Node { public abstract int execute(AbstractTruffleString a, Encoding expectedEncoding); @Specialization - static int calculateHash(AbstractTruffleString a, Encoding expectedEncoding, - @Cached ConditionProfile cacheMiss, + final int calculateHash(AbstractTruffleString a, Encoding expectedEncoding, + @Cached InlinedConditionProfile cacheMiss, @Cached ToIndexableNode toIndexableNode, @Cached TStringOpsNodes.CalculateHashCodeNode calculateHashCodeNode) { a.checkEncoding(expectedEncoding); int h = a.hashCode; - if (cacheMiss.profile(h == 0)) { - h = calculateHashCodeNode.execute(a, toIndexableNode.execute(a, a.data())); + if (cacheMiss.profile(this, h == 0)) { + h = calculateHashCodeNode.execute(this, a, toIndexableNode.execute(this, a, a.data())); if (h == 0) { h--; } @@ -3043,10 +2971,7 @@ public static HashCodeNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ReadByteNode extends Node { + public abstract static class ReadByteNode extends AbstractPublicNode { ReadByteNode() { } @@ -3060,12 +2985,12 @@ public abstract static class ReadByteNode extends Node { public abstract int execute(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding); @Specialization - static int doRead(AbstractTruffleString a, int i, Encoding expectedEncoding, + final int doRead(AbstractTruffleString a, int i, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.ReadByteNode readByteNode) { a.checkEncoding(expectedEncoding); - Object arrayA = toIndexableNode.execute(a, a.data()); - return readByteNode.execute(a, arrayA, i, expectedEncoding); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + return readByteNode.execute(this, a, arrayA, i, expectedEncoding); } /** @@ -3092,10 +3017,7 @@ public static ReadByteNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ReadCharUTF16Node extends Node { + public abstract static class ReadCharUTF16Node extends AbstractPublicNode { ReadCharUTF16Node() { } @@ -3108,13 +3030,13 @@ public abstract static class ReadCharUTF16Node extends Node { public abstract char execute(AbstractTruffleString a, int charIndex); @Specialization - static char doRead(AbstractTruffleString a, int i, + final char doRead(AbstractTruffleString a, int i, @Cached ToIndexableNode toIndexableNode, - @Cached ConditionProfile utf16S0Profile) { + @Cached InlinedConditionProfile utf16S0Profile) { a.checkEncoding(Encoding.UTF_16); a.boundsCheckRaw(i); - Object arrayA = toIndexableNode.execute(a, a.data()); - if (utf16S0Profile.profile(isStride0(a))) { + Object arrayA = toIndexableNode.execute(this, a, a.data()); + if (utf16S0Profile.profile(this, isStride0(a))) { return (char) TStringOps.readS0(a, arrayA, i); } else { assert isStride1(a); @@ -3147,10 +3069,7 @@ public static ReadCharUTF16Node getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ByteLengthOfCodePointNode extends Node { + public abstract static class ByteLengthOfCodePointNode extends AbstractPublicNode { ByteLengthOfCodePointNode() { } @@ -3184,7 +3103,7 @@ public final int execute(AbstractTruffleString a, int byteIndex, Encoding expect public abstract int execute(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding, ErrorHandling errorHandling); @Specialization - static int translate(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding, ErrorHandling errorHandling, + final int translate(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding, ErrorHandling errorHandling, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.ByteLengthOfCodePointNode byteLengthOfCodePointNode) { @@ -3192,9 +3111,9 @@ static int translate(AbstractTruffleString a, int byteIndex, Encoding expectedEn a.checkEncoding(expectedEncoding); int rawIndex = rawIndex(byteIndex, expectedEncoding); a.boundsCheckRaw(rawIndex); - Object arrayA = toIndexableNode.execute(a, a.data()); - int codeRangeA = getCodeRangeNode.execute(a); - return byteLengthOfCodePointNode.execute(a, arrayA, codeRangeA, expectedEncoding, rawIndex, errorHandling); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + int codeRangeA = getCodeRangeNode.execute(this, a); + return byteLengthOfCodePointNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, rawIndex, errorHandling); } /** @@ -3222,10 +3141,7 @@ public static ByteLengthOfCodePointNode getUncached() { * * @since 22.2 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ByteIndexToCodePointIndexNode extends Node { + public abstract static class ByteIndexToCodePointIndexNode extends AbstractPublicNode { ByteIndexToCodePointIndexNode() { } @@ -3239,7 +3155,7 @@ public abstract static class ByteIndexToCodePointIndexNode extends Node { public abstract int execute(AbstractTruffleString a, int byteOffset, int byteIndex, Encoding expectedEncoding); @Specialization - static int translate(AbstractTruffleString a, int byteOffset, int byteIndex, Encoding expectedEncoding, + final int translate(AbstractTruffleString a, int byteOffset, int byteIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.RawIndexToCodePointIndexNode rawIndexToCodePointIndexNode) { @@ -3250,9 +3166,9 @@ static int translate(AbstractTruffleString a, int byteOffset, int byteIndex, Enc if (byteIndex == 0) { return 0; } - Object arrayA = toIndexableNode.execute(a, a.data()); - int codeRangeA = getCodeRangeNode.execute(a); - return rawIndexToCodePointIndexNode.execute(a, arrayA, codeRangeA, expectedEncoding, byteOffset, rawIndex); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + int codeRangeA = getCodeRangeNode.execute(this, a); + return rawIndexToCodePointIndexNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, byteOffset, rawIndex); } /** @@ -3280,10 +3196,7 @@ public static ByteIndexToCodePointIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CodePointIndexToByteIndexNode extends Node { + public abstract static class CodePointIndexToByteIndexNode extends AbstractPublicNode { CodePointIndexToByteIndexNode() { } @@ -3297,21 +3210,21 @@ public abstract static class CodePointIndexToByteIndexNode extends Node { public abstract int execute(AbstractTruffleString a, int byteOffset, int codepointIndex, Encoding expectedEncoding); @Specialization - static int translate(AbstractTruffleString a, int byteOffset, int codepointIndex, Encoding expectedEncoding, + final int translate(AbstractTruffleString a, int byteOffset, int codepointIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.CodePointIndexToRawNode codePointIndexToRawNode) { a.checkEncoding(expectedEncoding); - a.boundsCheckRegion(0, codepointIndex, getCodePointLengthNode); + a.boundsCheckRegion(this, 0, codepointIndex, getCodePointLengthNode); int rawOffset = rawIndex(byteOffset, expectedEncoding); a.boundsCheckRawLength(rawOffset); if (codepointIndex == 0) { return 0; } - Object arrayA = toIndexableNode.execute(a, a.data()); - int codeRangeA = getCodeRangeNode.execute(a); - return codePointIndexToRawNode.execute(a, arrayA, codeRangeA, expectedEncoding, rawOffset, codepointIndex, true) << expectedEncoding.naturalStride; + Object arrayA = toIndexableNode.execute(this, a, a.data()); + int codeRangeA = getCodeRangeNode.execute(this, a); + return codePointIndexToRawNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, rawOffset, codepointIndex, true) << expectedEncoding.naturalStride; } /** @@ -3339,10 +3252,7 @@ public static CodePointIndexToByteIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CodePointAtIndexNode extends Node { + public abstract static class CodePointAtIndexNode extends AbstractPublicNode { CodePointAtIndexNode() { } @@ -3383,16 +3293,16 @@ public final int execute(AbstractTruffleString a, int i, Encoding expectedEncodi public abstract int execute(AbstractTruffleString a, int i, Encoding expectedEncoding, ErrorHandling errorHandling); @Specialization - static int readCodePoint(AbstractTruffleString a, int i, Encoding expectedEncoding, ErrorHandling errorHandling, + final int readCodePoint(AbstractTruffleString a, int i, Encoding expectedEncoding, ErrorHandling errorHandling, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.CodePointAtNode readCodePointNode) { CompilerAsserts.partialEvaluationConstant(errorHandling); a.checkEncoding(expectedEncoding); - a.boundsCheck(i, getCodePointLengthNode); - Object arrayA = toIndexableNode.execute(a, a.data()); - return readCodePointNode.execute(a, arrayA, getCodeRangeNode.execute(a), expectedEncoding, i, errorHandling); + a.boundsCheck(this, i, getCodePointLengthNode); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + return readCodePointNode.execute(this, a, arrayA, getCodeRangeNode.execute(this, a), expectedEncoding, i, errorHandling); } /** @@ -3420,10 +3330,7 @@ public static CodePointAtIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CodePointAtByteIndexNode extends Node { + public abstract static class CodePointAtByteIndexNode extends AbstractPublicNode { CodePointAtByteIndexNode() { } @@ -3448,7 +3355,7 @@ public final int execute(AbstractTruffleString a, int i, Encoding expectedEncodi public abstract int execute(AbstractTruffleString a, int i, Encoding expectedEncoding, ErrorHandling errorHandling); @Specialization - static int readCodePoint(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding, ErrorHandling errorHandling, + final int readCodePoint(AbstractTruffleString a, int byteIndex, Encoding expectedEncoding, ErrorHandling errorHandling, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.CodePointAtRawNode readCodePointNode) { @@ -3456,7 +3363,7 @@ static int readCodePoint(AbstractTruffleString a, int byteIndex, Encoding expect final int i = rawIndex(byteIndex, expectedEncoding); a.checkEncoding(expectedEncoding); a.boundsCheckRaw(i); - return readCodePointNode.execute(a, toIndexableNode.execute(a, a.data()), getCodeRangeNode.execute(a), expectedEncoding, i, errorHandling); + return readCodePointNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), getCodeRangeNode.execute(this, a), expectedEncoding, i, errorHandling); } /** @@ -3485,10 +3392,7 @@ public static CodePointAtByteIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ByteIndexOfAnyByteNode extends Node { + public abstract static class ByteIndexOfAnyByteNode extends AbstractPublicNode { ByteIndexOfAnyByteNode() { } @@ -3515,11 +3419,11 @@ int indexOfRaw(AbstractTruffleString a, int fromByteIndex, int maxByteIndex, byt return -1; } a.boundsCheckRaw(fromByteIndex, maxByteIndex); - if (fromByteIndex == maxByteIndex || TSCodeRange.is7Bit(getCodeRangeNode.execute(a)) && noneIsAscii(this, values)) { + if (fromByteIndex == maxByteIndex || TSCodeRange.is7Bit(getCodeRangeNode.execute(this, a)) && noneIsAscii(this, values)) { return -1; } assert isStride0(a); - Object arrayA = toIndexableNode.execute(a, a.data()); + Object arrayA = toIndexableNode.execute(this, a, a.data()); return TStringOps.indexOfAnyByte(this, a, arrayA, fromByteIndex, maxByteIndex, values); } @@ -3558,10 +3462,7 @@ public static ByteIndexOfAnyByteNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CharIndexOfAnyCharUTF16Node extends Node { + public abstract static class CharIndexOfAnyCharUTF16Node extends AbstractPublicNode { CharIndexOfAnyCharUTF16Node() { } @@ -3577,7 +3478,7 @@ public abstract static class CharIndexOfAnyCharUTF16Node extends Node { public abstract int execute(AbstractTruffleString a, int fromCharIndex, int maxCharIndex, char[] values); @Specialization - int indexOfRaw(AbstractTruffleString a, int fromCharIndex, int maxCharIndex, char[] values, + final int indexOfRaw(AbstractTruffleString a, int fromCharIndex, int maxCharIndex, char[] values, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringOpsNodes.IndexOfAnyCharNode indexOfNode) { @@ -3586,11 +3487,11 @@ int indexOfRaw(AbstractTruffleString a, int fromCharIndex, int maxCharIndex, cha return -1; } a.boundsCheckRaw(fromCharIndex, maxCharIndex); - int codeRangeA = getCodeRangeNode.execute(a); + int codeRangeA = getCodeRangeNode.execute(this, a); if (fromCharIndex == maxCharIndex || TSCodeRange.isFixedWidth(codeRangeA) && noneInCodeRange(this, codeRangeA, values)) { return -1; } - return indexOfNode.execute(a, toIndexableNode.execute(a, a.data()), fromCharIndex, maxCharIndex, values); + return indexOfNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), fromCharIndex, maxCharIndex, values); } private static boolean noneInCodeRange(Node location, int codeRange, char[] values) { @@ -3628,10 +3529,7 @@ public static CharIndexOfAnyCharUTF16Node getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class IntIndexOfAnyIntUTF32Node extends Node { + public abstract static class IntIndexOfAnyIntUTF32Node extends AbstractPublicNode { IntIndexOfAnyIntUTF32Node() { } @@ -3656,10 +3554,10 @@ int indexOfRaw(AbstractTruffleString a, int fromIntIndex, int maxIntIndex, int[] return -1; } a.boundsCheckRaw(fromIntIndex, maxIntIndex); - if (fromIntIndex == maxIntIndex || noneInCodeRange(this, getCodeRangeNode.execute(a), values)) { + if (fromIntIndex == maxIntIndex || noneInCodeRange(this, getCodeRangeNode.execute(this, a), values)) { return -1; } - return indexOfNode.execute(a, toIndexableNode.execute(a, a.data()), fromIntIndex, maxIntIndex, values); + return indexOfNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), fromIntIndex, maxIntIndex, values); } private static boolean noneInCodeRange(Node location, int codeRange, int[] values) { @@ -3697,10 +3595,7 @@ public static IntIndexOfAnyIntUTF32Node getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class IndexOfCodePointNode extends Node { + public abstract static class IndexOfCodePointNode extends AbstractPublicNode { IndexOfCodePointNode() { } @@ -3715,7 +3610,7 @@ public abstract static class IndexOfCodePointNode extends Node { public abstract int execute(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding); @Specialization - static int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding, + final int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @@ -3724,9 +3619,9 @@ static int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int if (a.isEmpty()) { return -1; } - a.boundsCheck(fromIndex, toIndex, getCodePointLengthNode); - Object arrayA = toIndexableNode.execute(a, a.data()); - return indexOfNode.execute(a, arrayA, getCodeRangeNode.execute(a), expectedEncoding, codepoint, fromIndex, toIndex); + a.boundsCheck(this, fromIndex, toIndex, getCodePointLengthNode); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + return indexOfNode.execute(this, a, arrayA, getCodeRangeNode.execute(this, a), expectedEncoding, codepoint, fromIndex, toIndex); } /** @@ -3753,10 +3648,7 @@ public static IndexOfCodePointNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ByteIndexOfCodePointNode extends Node { + public abstract static class ByteIndexOfCodePointNode extends AbstractPublicNode { ByteIndexOfCodePointNode() { } @@ -3769,7 +3661,7 @@ public abstract static class ByteIndexOfCodePointNode extends Node { public abstract int execute(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding); @Specialization - static int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding, + final int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.IndexOfCodePointRawNode indexOfNode) { @@ -3780,7 +3672,7 @@ static int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, final int fromIndex = rawIndex(fromByteIndex, expectedEncoding); final int toIndex = rawIndex(toByteIndex, expectedEncoding); a.boundsCheckRaw(fromIndex, toIndex); - return byteIndex(indexOfNode.execute(a, toIndexableNode.execute(a, a.data()), getCodeRangeNode.execute(a), expectedEncoding, codepoint, fromIndex, toIndex), + return byteIndex(indexOfNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), getCodeRangeNode.execute(this, a), expectedEncoding, codepoint, fromIndex, toIndex), expectedEncoding); } @@ -3809,10 +3701,7 @@ public static ByteIndexOfCodePointNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class LastIndexOfCodePointNode extends Node { + public abstract static class LastIndexOfCodePointNode extends AbstractPublicNode { LastIndexOfCodePointNode() { } @@ -3827,7 +3716,7 @@ public abstract static class LastIndexOfCodePointNode extends Node { public abstract int execute(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding); @Specialization - static int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding, + final int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int toIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @@ -3836,9 +3725,9 @@ static int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int if (a.isEmpty()) { return -1; } - a.boundsCheck(toIndex, fromIndex, getCodePointLengthNode); - Object arrayA = toIndexableNode.execute(a, a.data()); - return lastIndexOfNode.execute(a, arrayA, getCodeRangeNode.execute(a), expectedEncoding, codepoint, fromIndex, toIndex); + a.boundsCheck(this, toIndex, fromIndex, getCodePointLengthNode); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + return lastIndexOfNode.execute(this, a, arrayA, getCodeRangeNode.execute(this, a), expectedEncoding, codepoint, fromIndex, toIndex); } /** @@ -3865,10 +3754,7 @@ public static LastIndexOfCodePointNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class LastByteIndexOfCodePointNode extends Node { + public abstract static class LastByteIndexOfCodePointNode extends AbstractPublicNode { LastByteIndexOfCodePointNode() { } @@ -3881,7 +3767,7 @@ public abstract static class LastByteIndexOfCodePointNode extends Node { public abstract int execute(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding); @Specialization - static int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding, + final int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, int toByteIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.LastIndexOfCodePointRawNode lastIndexOfNode) { @@ -3892,7 +3778,7 @@ static int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, final int fromIndex = rawIndex(fromByteIndex, expectedEncoding); final int toIndex = rawIndex(toByteIndex, expectedEncoding); a.boundsCheckRaw(toIndex, fromIndex); - return byteIndex(lastIndexOfNode.execute(a, toIndexableNode.execute(a, a.data()), getCodeRangeNode.execute(a), expectedEncoding, codepoint, fromIndex, toIndex), + return byteIndex(lastIndexOfNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), getCodeRangeNode.execute(this, a), expectedEncoding, codepoint, fromIndex, toIndex), expectedEncoding); } @@ -3922,10 +3808,7 @@ public static LastByteIndexOfCodePointNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class IndexOfStringNode extends Node { + public abstract static class IndexOfStringNode extends AbstractPublicNode { IndexOfStringNode() { } @@ -3940,16 +3823,16 @@ public abstract static class IndexOfStringNode extends Node { public abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding); @Specialization - static int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding, + final int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthANode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthBNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, - @Cached TStringInternalNodes.IndexOfStringNode indexOfStringNode) { - int codeRangeA = getCodeRangeANode.execute(a); - int codeRangeB = getCodeRangeBNode.execute(b); + @Cached TStringInternalNodes.InternalIndexOfStringNode indexOfStringNode) { + int codeRangeA = getCodeRangeANode.execute(this, a); + int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); if (b.isEmpty()) { @@ -3958,13 +3841,13 @@ static int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int f if (a.isEmpty()) { return -1; } - a.boundsCheck(fromIndex, toIndex, getCodePointLengthANode); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); - if (indexOfCannotMatch(codeRangeA, b, codeRangeB, toIndex - fromIndex, getCodePointLengthBNode)) { + a.boundsCheck(this, fromIndex, toIndex, getCodePointLengthANode); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); + if (indexOfCannotMatch(this, codeRangeA, b, codeRangeB, toIndex - fromIndex, getCodePointLengthBNode)) { return -1; } - return indexOfStringNode.execute(a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, expectedEncoding); + return indexOfStringNode.execute(this, a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, expectedEncoding); } /** @@ -3991,10 +3874,7 @@ public static IndexOfStringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ByteIndexOfStringNode extends Node { + public abstract static class ByteIndexOfStringNode extends AbstractPublicNode { ByteIndexOfStringNode() { } @@ -4031,14 +3911,14 @@ public final int execute(AbstractTruffleString a, WithMask b, int fromByteIndex, abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromByteIndex, int toByteIndex, byte[] mask, Encoding expectedEncoding); @Specialization - static int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromByteIndex, int toByteIndex, byte[] mask, Encoding expectedEncoding, + final int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromByteIndex, int toByteIndex, byte[] mask, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, @Cached TStringInternalNodes.IndexOfStringRawNode indexOfStringNode) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); if (mask != null && isUnsupportedEncoding(expectedEncoding) && !isFixedWidth(codeRangeA)) { @@ -4053,12 +3933,12 @@ static int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int f final int fromIndex = rawIndex(fromByteIndex, expectedEncoding); final int toIndex = rawIndex(toByteIndex, expectedEncoding); a.boundsCheckRaw(fromIndex, toIndex); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); if (indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, toIndex - fromIndex)) { return -1; } - return byteIndex(indexOfStringNode.execute(a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, mask, expectedEncoding), expectedEncoding); + return byteIndex(indexOfStringNode.execute(this, a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, mask, expectedEncoding), expectedEncoding); } /** @@ -4087,10 +3967,7 @@ public static ByteIndexOfStringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class LastIndexOfStringNode extends Node { + public abstract static class LastIndexOfStringNode extends AbstractPublicNode { LastIndexOfStringNode() { } @@ -4105,7 +3982,7 @@ public abstract static class LastIndexOfStringNode extends Node { public abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding); @Specialization - static int lastIndexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding, + final int lastIndexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthANode, @@ -4113,8 +3990,8 @@ static int lastIndexOfString(AbstractTruffleString a, AbstractTruffleString b, i @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, @Cached TStringInternalNodes.LastIndexOfStringNode indexOfStringNode) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); if (b.isEmpty()) { @@ -4123,13 +4000,13 @@ static int lastIndexOfString(AbstractTruffleString a, AbstractTruffleString b, i if (a.isEmpty()) { return -1; } - a.boundsCheck(toIndex, fromIndex, getCodePointLengthANode); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); - if (indexOfCannotMatch(codeRangeA, b, codeRangeB, fromIndex - toIndex, getCodePointLengthBNode)) { + a.boundsCheck(this, toIndex, fromIndex, getCodePointLengthANode); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); + if (indexOfCannotMatch(this, codeRangeA, b, codeRangeB, fromIndex - toIndex, getCodePointLengthBNode)) { return -1; } - return indexOfStringNode.execute(a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, expectedEncoding); + return indexOfStringNode.execute(this, a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, expectedEncoding); } /** @@ -4156,10 +4033,7 @@ public static LastIndexOfStringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class LastByteIndexOfStringNode extends Node { + public abstract static class LastByteIndexOfStringNode extends AbstractPublicNode { LastByteIndexOfStringNode() { } @@ -4196,14 +4070,14 @@ public final int execute(AbstractTruffleString a, WithMask b, int fromIndex, int abstract int execute(AbstractTruffleString a, AbstractTruffleString b, int fromIndex, int toIndex, byte[] mask, Encoding expectedEncoding); @Specialization - static int lastByteIndexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndexB, int toIndexB, byte[] mask, Encoding expectedEncoding, + final int lastByteIndexOfString(AbstractTruffleString a, AbstractTruffleString b, int fromIndexB, int toIndexB, byte[] mask, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, @Cached TStringInternalNodes.LastIndexOfStringRawNode indexOfStringNode) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); if (mask != null && isUnsupportedEncoding(expectedEncoding) && !isFixedWidth(codeRangeA)) { @@ -4218,12 +4092,12 @@ static int lastByteIndexOfString(AbstractTruffleString a, AbstractTruffleString final int fromIndex = rawIndex(fromIndexB, expectedEncoding); final int toIndex = rawIndex(toIndexB, expectedEncoding); a.boundsCheckRaw(toIndex, fromIndex); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); if (indexOfCannotMatch(codeRangeA, b, codeRangeB, mask, fromIndex - toIndex)) { return -1; } - return byteIndex(indexOfStringNode.execute(a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, mask, expectedEncoding), expectedEncoding); + return byteIndex(indexOfStringNode.execute(this, a, arrayA, codeRangeA, b, arrayB, codeRangeB, fromIndex, toIndex, mask, expectedEncoding), expectedEncoding); } /** @@ -4252,10 +4126,7 @@ public static LastByteIndexOfStringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CompareBytesNode extends Node { + public abstract static class CompareBytesNode extends AbstractPublicNode { CompareBytesNode() { } @@ -4279,12 +4150,12 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedE @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode) { nullCheck(expectedEncoding); - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); - Object aData = toIndexableNodeA.execute(a, a.data()); - Object bData = toIndexableNodeB.execute(b, b.data()); + Object aData = toIndexableNodeA.execute(this, a, a.data()); + Object bData = toIndexableNodeB.execute(this, b, b.data()); if (aData instanceof byte[] && bData instanceof byte[] && (a.stride() | b.stride()) == 0 && a.length() != 0 && b.length() != 0) { int cmp = Byte.compareUnsigned(((byte[]) aData)[a.offset()], ((byte[]) bData)[b.offset()]); if (cmp != 0) { @@ -4322,10 +4193,7 @@ public static CompareBytesNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CompareCharsUTF16Node extends Node { + public abstract static class CompareCharsUTF16Node extends AbstractPublicNode { CompareCharsUTF16Node() { } @@ -4348,12 +4216,12 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(Encoding.UTF_16, codeRangeA); b.looseCheckEncoding(Encoding.UTF_16, codeRangeB); - Object aData = toIndexableNodeA.execute(a, a.data()); - Object bData = toIndexableNodeB.execute(b, b.data()); + Object aData = toIndexableNodeA.execute(this, a, a.data()); + Object bData = toIndexableNodeB.execute(this, b, b.data()); if (aData instanceof byte[] && bData instanceof byte[] && (a.stride() | b.stride()) == 0 && a.length() != 0 && b.length() != 0) { int cmp = Byte.compareUnsigned(((byte[]) aData)[a.offset()], ((byte[]) bData)[b.offset()]); if (cmp != 0) { @@ -4391,10 +4259,7 @@ public static CompareCharsUTF16Node getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CompareIntsUTF32Node extends Node { + public abstract static class CompareIntsUTF32Node extends AbstractPublicNode { CompareIntsUTF32Node() { } @@ -4417,12 +4282,12 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(Encoding.UTF_32, codeRangeA); b.looseCheckEncoding(Encoding.UTF_32, codeRangeB); - Object aData = toIndexableNodeA.execute(a, a.data()); - Object bData = toIndexableNodeB.execute(b, b.data()); + Object aData = toIndexableNodeA.execute(this, a, a.data()); + Object bData = toIndexableNodeB.execute(this, b, b.data()); if (aData instanceof byte[] && bData instanceof byte[] && (a.stride() | b.stride()) == 0 && a.length() != 0 && b.length() != 0) { int cmp = Byte.compareUnsigned(((byte[]) aData)[a.offset()], ((byte[]) bData)[b.offset()]); if (cmp != 0) { @@ -4460,10 +4325,7 @@ public static CompareIntsUTF32Node getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class RegionEqualNode extends Node { + public abstract static class RegionEqualNode extends AbstractPublicNode { RegionEqualNode() { } @@ -4488,7 +4350,7 @@ public abstract static class RegionEqualNode extends Node { public abstract boolean execute(AbstractTruffleString a, int fromIndexA, AbstractTruffleString b, int fromIndexB, int length, Encoding expectedEncoding); @Specialization - static boolean regionEquals(AbstractTruffleString a, int fromIndexA, AbstractTruffleString b, int fromIndexB, int length, Encoding expectedEncoding, + final boolean regionEquals(AbstractTruffleString a, int fromIndexA, AbstractTruffleString b, int fromIndexB, int length, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthANode, @@ -4499,15 +4361,15 @@ static boolean regionEquals(AbstractTruffleString a, int fromIndexA, AbstractTru if (length == 0) { return true; } - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); - a.boundsCheckRegion(fromIndexA, length, getCodePointLengthANode); - b.boundsCheckRegion(fromIndexB, length, getCodePointLengthBNode); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); - return regionEqualsNode.execute(a, arrayA, codeRangeA, fromIndexA, b, arrayB, codeRangeB, fromIndexB, length, expectedEncoding); + a.boundsCheckRegion(this, fromIndexA, length, getCodePointLengthANode); + b.boundsCheckRegion(this, fromIndexB, length, getCodePointLengthBNode); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); + return regionEqualsNode.execute(this, a, arrayA, codeRangeA, fromIndexA, b, arrayB, codeRangeB, fromIndexB, length, expectedEncoding); } /** @@ -4538,10 +4400,7 @@ public static RegionEqualNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class RegionEqualByteIndexNode extends Node { + public abstract static class RegionEqualByteIndexNode extends AbstractPublicNode { RegionEqualByteIndexNode() { } @@ -4586,8 +4445,8 @@ boolean regionEquals(AbstractTruffleString a, int byteFromIndexA, AbstractTruffl if (byteLength == 0) { return true; } - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); final int fromIndexA = rawIndex(byteFromIndexA, expectedEncoding); @@ -4595,8 +4454,8 @@ boolean regionEquals(AbstractTruffleString a, int byteFromIndexA, AbstractTruffl final int length = rawIndex(byteLength, expectedEncoding); a.boundsCheckRegionRaw(fromIndexA, length); b.boundsCheckRegionRaw(fromIndexB, length); - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); + Object arrayA = toIndexableNodeA.execute(this, a, a.data()); + Object arrayB = toIndexableNodeB.execute(this, b, b.data()); return TStringOps.regionEqualsWithOrMaskWithStride(this, a, arrayA, a.stride(), fromIndexA, b, arrayB, b.stride(), fromIndexB, mask, length); } @@ -4626,10 +4485,7 @@ public static RegionEqualByteIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ConcatNode extends Node { + public abstract static class ConcatNode extends AbstractPublicNode { ConcatNode() { } @@ -4657,14 +4513,14 @@ static TruffleString aEmpty(@SuppressWarnings("unused") AbstractTruffleString a, } @Specialization(guards = "isEmpty(a)") - static TruffleString aEmptyMutable(@SuppressWarnings("unused") AbstractTruffleString a, MutableTruffleString b, Encoding expectedEncoding, boolean lazy, - @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { + TruffleString aEmptyMutable(@SuppressWarnings("unused") AbstractTruffleString a, MutableTruffleString b, Encoding expectedEncoding, boolean lazy, + @Shared("attributesNode") @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode attributesNode) { CompilerAsserts.partialEvaluationConstant(lazy); if (AbstractTruffleString.DEBUG_STRICT_ENCODING_CHECKS) { - b.looseCheckEncoding(expectedEncoding, TStringInternalNodes.GetCodeRangeNode.getUncached().execute(b)); + b.looseCheckEncoding(expectedEncoding, TStringInternalNodes.GetCodeRangeNode.getUncached().execute(this, b)); return b.switchEncodingUncached(expectedEncoding); } - return fromBufferWithStringCompactionNode.execute(b, expectedEncoding); + return attributesNode.execute(this, b, expectedEncoding); } @Specialization(guards = "isEmpty(b)") @@ -4680,49 +4536,51 @@ static TruffleString bEmpty(TruffleString a, @SuppressWarnings("unused") Abstrac @Specialization(guards = "isEmpty(b)") static TruffleString bEmptyMutable(MutableTruffleString a, @SuppressWarnings("unused") AbstractTruffleString b, Encoding expectedEncoding, boolean lazy, - @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode fromBufferWithStringCompactionNode) { + @Bind("this") Node node, + @Shared("attributesNode") @Cached TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode attributesNode) { CompilerAsserts.partialEvaluationConstant(lazy); if (AbstractTruffleString.DEBUG_STRICT_ENCODING_CHECKS) { - a.looseCheckEncoding(expectedEncoding, TStringInternalNodes.GetCodeRangeNode.getUncached().execute(a)); + a.looseCheckEncoding(expectedEncoding, TStringInternalNodes.GetCodeRangeNode.getUncached().execute(node, a)); return a.switchEncodingUncached(expectedEncoding); } - return fromBufferWithStringCompactionNode.execute(a, expectedEncoding); + return attributesNode.execute(node, a, expectedEncoding); } @Specialization(guards = {"!isEmpty(a)", "!isEmpty(b)"}) static TruffleString doConcat(AbstractTruffleString a, AbstractTruffleString b, Encoding encoding, boolean lazy, + @Bind("this") Node node, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, @Cached TStringInternalNodes.StrideFromCodeRangeNode getStrideNode, @Cached TStringInternalNodes.ConcatEagerNode concatEagerNode, @Cached AsTruffleStringNode asTruffleStringANode, @Cached AsTruffleStringNode asTruffleStringBNode, - @Cached BranchProfile outOfMemoryProfile, - @Cached ConditionProfile lazyProfile) { + @Cached InlinedBranchProfile outOfMemoryProfile, + @Cached InlinedConditionProfile lazyProfile) { CompilerAsserts.partialEvaluationConstant(lazy); - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + final int codeRangeA = getCodeRangeANode.execute(node, a); + final int codeRangeB = getCodeRangeBNode.execute(node, b); a.looseCheckEncoding(encoding, codeRangeA); b.looseCheckEncoding(encoding, codeRangeB); int commonCodeRange = TSCodeRange.commonCodeRange(codeRangeA, codeRangeB); assert !(isBrokenMultiByte(codeRangeA) || isBrokenMultiByte(codeRangeB)) || isBrokenMultiByte(commonCodeRange); - int targetStride = getStrideNode.execute(commonCodeRange, encoding); - int length = addByteLengths(a, b, targetStride, outOfMemoryProfile); + int targetStride = getStrideNode.execute(node, commonCodeRange, encoding); + int length = addByteLengths(node, a, b, targetStride, outOfMemoryProfile); boolean valid = !isBrokenMultiByte(commonCodeRange); - if (lazyProfile.profile(lazy && valid && (a.isImmutable() || b.isImmutable()) && (length << targetStride) >= TStringConstants.LAZY_CONCAT_MIN_LENGTH)) { + if (lazyProfile.profile(node, lazy && valid && (a.isImmutable() || b.isImmutable()) && (length << targetStride) >= TStringConstants.LAZY_CONCAT_MIN_LENGTH)) { if (AbstractTruffleString.DEBUG_STRICT_ENCODING_CHECKS) { return TruffleString.createLazyConcat(asTruffleStringLoose(a, encoding), asTruffleStringLoose(b, encoding), encoding, length, targetStride); } else { return TruffleString.createLazyConcat(asTruffleStringANode.execute(a, encoding), asTruffleStringBNode.execute(b, encoding), encoding, length, targetStride); } } - return concatEagerNode.execute(a, b, encoding, length, targetStride, commonCodeRange); + return concatEagerNode.execute(node, a, b, encoding, length, targetStride, commonCodeRange); } - static int addByteLengths(AbstractTruffleString a, AbstractTruffleString b, int targetStride, BranchProfile outOfMemoryProfile) { + static int addByteLengths(Node node, AbstractTruffleString a, AbstractTruffleString b, int targetStride, InlinedBranchProfile outOfMemoryProfile) { long length = (long) a.length() + (long) b.length(); if (length << targetStride > TStringConstants.MAX_ARRAY_SIZE) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(node); throw InternalErrors.outOfMemory(); } return (int) length; @@ -4732,7 +4590,7 @@ private static TruffleString asTruffleStringLoose(AbstractTruffleString a, Encod if (a.isImmutable()) { return (TruffleString) a; } - return TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode.getUncached().execute(a, encoding); + return TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode.getUncached().execute(null, a, encoding); } /** @@ -4760,10 +4618,7 @@ public static ConcatNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class RepeatNode extends Node { + public abstract static class RepeatNode extends AbstractPublicNode { RepeatNode() { } @@ -4776,14 +4631,14 @@ public abstract static class RepeatNode extends Node { public abstract TruffleString execute(AbstractTruffleString a, int n, Encoding expectedEncoding); @Specialization - TruffleString repeat(AbstractTruffleString a, int n, Encoding expectedEncoding, + final TruffleString repeat(AbstractTruffleString a, int n, Encoding expectedEncoding, @Cached AsTruffleStringNode asTruffleStringNode, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.CalcStringAttributesNode calcStringAttributesNode, - @Cached ConditionProfile brokenProfile, - @Cached BranchProfile outOfMemoryProfile) { + @Cached InlinedConditionProfile brokenProfile, + @Cached InlinedBranchProfile outOfMemoryProfile) { a.checkEncoding(expectedEncoding); if (n < 0) { throw InternalErrors.illegalArgument("n must be positive"); @@ -4794,13 +4649,13 @@ TruffleString repeat(AbstractTruffleString a, int n, Encoding expectedEncoding, if (n == 1) { return asTruffleStringNode.execute(a, expectedEncoding); } - Object arrayA = toIndexableNode.execute(a, a.data()); - int codeRangeA = getCodeRangeNode.execute(a); - int codePointLengthA = getCodePointLengthNode.execute(a); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + int codeRangeA = getCodeRangeNode.execute(this, a); + int codePointLengthA = getCodePointLengthNode.execute(this, a); int byteLengthA = (a.length()) << a.stride(); long byteLength = ((long) byteLengthA) * n; if (Long.compareUnsigned(byteLength, TStringConstants.MAX_ARRAY_SIZE) > 0) { - outOfMemoryProfile.enter(); + outOfMemoryProfile.enter(this); throw InternalErrors.outOfMemory(); } byte[] array = new byte[(int) byteLength]; @@ -4811,8 +4666,8 @@ TruffleString repeat(AbstractTruffleString a, int n, Encoding expectedEncoding, TStringConstants.truffleSafePointPoll(this, i + 1); } int length = (int) (byteLength >> a.stride()); - if (brokenProfile.profile(isBrokenFixedWidth(codeRangeA) || isBrokenMultiByte(codeRangeA))) { - long attrs = calcStringAttributesNode.execute(null, array, 0, length, a.stride(), expectedEncoding, 0, TSCodeRange.getUnknown()); + if (brokenProfile.profile(this, isBrokenFixedWidth(codeRangeA) || isBrokenMultiByte(codeRangeA))) { + long attrs = calcStringAttributesNode.execute(this, null, array, 0, length, a.stride(), expectedEncoding, 0, TSCodeRange.getUnknown()); codeRangeA = StringAttributes.getCodeRange(attrs); codePointLengthA = StringAttributes.getCodePointLength(attrs); } else { @@ -4847,10 +4702,7 @@ public static RepeatNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class SubstringNode extends Node { + public abstract static class SubstringNode extends AbstractPublicNode { SubstringNode() { } @@ -4869,22 +4721,22 @@ public abstract static class SubstringNode extends Node { public abstract TruffleString execute(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding, boolean lazy); @Specialization - static TruffleString substring(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding, boolean lazy, + final TruffleString substring(AbstractTruffleString a, int fromIndex, int length, Encoding expectedEncoding, boolean lazy, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.CodePointIndexToRawNode translateIndexNode, @Cached TStringInternalNodes.SubstringNode substringNode) { a.checkEncoding(expectedEncoding); - a.boundsCheckRegion(fromIndex, length, getCodePointLengthNode); + a.boundsCheckRegion(this, fromIndex, length, getCodePointLengthNode); if (length == 0) { return expectedEncoding.getEmpty(); } - Object arrayA = toIndexableNode.execute(a, a.data()); - final int codeRangeA = getCodeRangeANode.execute(a); - int fromIndexRaw = translateIndexNode.execute(a, arrayA, codeRangeA, expectedEncoding, 0, fromIndex, false); - int lengthRaw = translateIndexNode.execute(a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, length, true); - return substringNode.execute(a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, lengthRaw, lazy && a.isImmutable()); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + final int codeRangeA = getCodeRangeANode.execute(this, a); + int fromIndexRaw = translateIndexNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, 0, fromIndex, false); + int lengthRaw = translateIndexNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, length, true); + return substringNode.execute(this, a, arrayA, codeRangeA, expectedEncoding, fromIndexRaw, lengthRaw, lazy && a.isImmutable()); } /** @@ -4911,10 +4763,7 @@ public static SubstringNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class SubstringByteIndexNode extends Node { + public abstract static class SubstringByteIndexNode extends AbstractPublicNode { SubstringByteIndexNode() { } @@ -4940,16 +4789,16 @@ static TruffleString substringEmpty(AbstractTruffleString a, int fromByteIndex, } @Specialization(guards = "byteLength != 0") - static TruffleString substringRaw(AbstractTruffleString a, int fromByteIndex, int byteLength, Encoding expectedEncoding, boolean lazy, + final TruffleString substringRaw(AbstractTruffleString a, int fromByteIndex, int byteLength, Encoding expectedEncoding, boolean lazy, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.SubstringNode substringNode) { a.checkEncoding(expectedEncoding); - final int codeRangeA = getCodeRangeANode.execute(a); + final int codeRangeA = getCodeRangeANode.execute(this, a); final int fromIndex = rawIndex(fromByteIndex, expectedEncoding); final int length = rawIndex(byteLength, expectedEncoding); a.boundsCheckRegionRaw(fromIndex, length); - return substringNode.execute(a, toIndexableNode.execute(a, a.data()), codeRangeA, expectedEncoding, fromIndex, length, lazy && a.isImmutable()); + return substringNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), codeRangeA, expectedEncoding, fromIndex, length, lazy && a.isImmutable()); } /** @@ -4978,10 +4827,7 @@ public static SubstringByteIndexNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class EqualNode extends Node { + public abstract static class EqualNode extends AbstractPublicNode { EqualNode() { } @@ -5006,37 +4852,37 @@ static boolean sameObject(AbstractTruffleString a, AbstractTruffleString b, Enco } @Specialization(guards = "!identical(a, b)") - boolean check(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedEncoding, + final boolean check(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNodeA, @Cached ToIndexableNode toIndexableNodeB, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeBNode, - @Cached ConditionProfile lengthAndCodeRangeCheckProfile, - @Cached BranchProfile compareHashProfile, - @Cached ConditionProfile checkFirstByteProfile) { - final int codeRangeA = getCodeRangeANode.execute(a); - final int codeRangeB = getCodeRangeBNode.execute(b); + @Cached InlinedConditionProfile lengthAndCodeRangeCheckProfile, + @Cached InlinedBranchProfile compareHashProfile, + @Cached InlinedConditionProfile checkFirstByteProfile) { + final int codeRangeA = getCodeRangeANode.execute(this, a); + final int codeRangeB = getCodeRangeBNode.execute(this, b); a.looseCheckEncoding(expectedEncoding, codeRangeA); b.looseCheckEncoding(expectedEncoding, codeRangeB); - return checkContentEquals(a, codeRangeA, b, codeRangeB, toIndexableNodeA, toIndexableNodeB, lengthAndCodeRangeCheckProfile, compareHashProfile, checkFirstByteProfile, this); + return checkContentEquals(this, a, codeRangeA, b, codeRangeB, toIndexableNodeA, toIndexableNodeB, lengthAndCodeRangeCheckProfile, compareHashProfile, checkFirstByteProfile); } static boolean checkContentEquals( + Node node, AbstractTruffleString a, int codeRangeA, AbstractTruffleString b, int codeRangeB, ToIndexableNode toIndexableNodeA, ToIndexableNode toIndexableNodeB, - ConditionProfile lengthAndCodeRangeCheckProfile, - BranchProfile compareHashProfile, - ConditionProfile checkFirstByteProfile, - EqualNode equalNode) { + InlinedConditionProfile lengthAndCodeRangeCheckProfile, + InlinedBranchProfile compareHashProfile, + InlinedConditionProfile checkFirstByteProfile) { assert TSCodeRange.isKnown(codeRangeA, codeRangeB); int lengthCMP = a.length(); - if (lengthAndCodeRangeCheckProfile.profile(lengthCMP != b.length() || codeRangeA != codeRangeB)) { + if (lengthAndCodeRangeCheckProfile.profile(node, lengthCMP != b.length() || codeRangeA != codeRangeB)) { return false; } if (a.isHashCodeCalculated() && b.isHashCodeCalculated()) { - compareHashProfile.enter(); + compareHashProfile.enter(node); if (a.getHashCodeUnsafe() != b.getHashCodeUnsafe()) { return false; } @@ -5044,11 +4890,11 @@ static boolean checkContentEquals( if (lengthCMP == 0) { return true; } - Object arrayA = toIndexableNodeA.execute(a, a.data()); - Object arrayB = toIndexableNodeB.execute(b, b.data()); + Object arrayA = toIndexableNodeA.execute(node, a, a.data()); + Object arrayB = toIndexableNodeB.execute(node, b, b.data()); int strideA = a.stride(); int strideB = b.stride(); - if (checkFirstByteProfile.profile(arrayA instanceof byte[] && arrayB instanceof byte[] && (strideA | strideB) == 0)) { + if (checkFirstByteProfile.profile(node, arrayA instanceof byte[] && arrayB instanceof byte[] && (strideA | strideB) == 0)) { // fast path: check first byte if (((byte[]) arrayA)[a.offset()] != ((byte[]) arrayB)[b.offset()]) { return false; @@ -5056,7 +4902,7 @@ static boolean checkContentEquals( return true; } } - return TStringOps.regionEqualsWithOrMaskWithStride(equalNode, + return TStringOps.regionEqualsWithOrMaskWithStride(node, a, arrayA, strideA, 0, b, arrayB, strideB, 0, null, lengthCMP); } @@ -5250,10 +5096,7 @@ public static final class IllegalByteArrayLengthException extends IllegalArgumen * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ParseIntNode extends Node { + public abstract static class ParseIntNode extends AbstractPublicNode { ParseIntNode() { } @@ -5266,24 +5109,24 @@ public abstract static class ParseIntNode extends Node { public abstract int execute(AbstractTruffleString a, int radix) throws NumberFormatException; @Specialization(guards = {"a.isLazyLong()", "radix == 10"}) - static int doLazyLong(AbstractTruffleString a, @SuppressWarnings("unused") int radix, - @Cached BranchProfile errorProfile) throws NumberFormatException { + final int doLazyLong(AbstractTruffleString a, @SuppressWarnings("unused") int radix, + @Cached InlinedBranchProfile errorProfile) throws NumberFormatException { long value = ((LazyLong) a.data()).value; if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { - errorProfile.enter(); + errorProfile.enter(this); throw NumberConversion.numberFormatException(a, NumberFormatException.Reason.OVERFLOW); } return (int) value; } @Specialization(guards = {"!a.isLazyLong() || radix != 10"}) - static int doParse(AbstractTruffleString a, int radix, + final int doParse(AbstractTruffleString a, int radix, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.ParseIntNode parseIntNode, - @Cached("createIdentityProfile()") IntValueProfile radixProfile) throws NumberFormatException { - final int codeRangeA = getCodeRangeANode.execute(a); - return parseIntNode.execute(a, toIndexableNode.execute(a, a.data()), codeRangeA, Encoding.get(a.encoding()), radixProfile.profile(radix)); + @Cached InlinedIntValueProfile radixProfile) throws NumberFormatException { + final int codeRangeA = getCodeRangeANode.execute(this, a); + return parseIntNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), codeRangeA, Encoding.get(a.encoding()), radixProfile.profile(this, radix)); } /** @@ -5310,10 +5153,7 @@ public static ParseIntNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ParseLongNode extends Node { + public abstract static class ParseLongNode extends AbstractPublicNode { ParseLongNode() { } @@ -5331,13 +5171,13 @@ static long doLazyLong(AbstractTruffleString a, @SuppressWarnings("unused") int } @Specialization(guards = {"!a.isLazyLong() || radix != 10"}) - static long doParse(AbstractTruffleString a, int radix, + final long doParse(AbstractTruffleString a, int radix, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode, @Cached TStringInternalNodes.ParseLongNode parseLongNode, - @Cached("createIdentityProfile()") IntValueProfile radixProfile) throws NumberFormatException { - final int codeRangeA = getCodeRangeANode.execute(a); - return parseLongNode.execute(a, toIndexableNode.execute(a, a.data()), codeRangeA, Encoding.get(a.encoding()), radixProfile.profile(radix)); + @Cached InlinedIntValueProfile radixProfile) throws NumberFormatException { + final int codeRangeA = getCodeRangeANode.execute(this, a); + return parseLongNode.execute(this, a, toIndexableNode.execute(this, a, a.data()), codeRangeA, Encoding.get(a.encoding()), radixProfile.profile(this, radix)); } /** @@ -5364,10 +5204,7 @@ public static ParseLongNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ParseDoubleNode extends Node { + public abstract static class ParseDoubleNode extends AbstractPublicNode { ParseDoubleNode() { } @@ -5385,10 +5222,10 @@ static double doLazyLong(AbstractTruffleString a) { } @Specialization(guards = "!isLazyLongSafeInteger(a)") - static double parseDouble(AbstractTruffleString a, + final double parseDouble(AbstractTruffleString a, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.ParseDoubleNode parseDoubleNode) throws NumberFormatException { - return parseDoubleNode.execute(a, toIndexableNode.execute(a, a.data())); + return parseDoubleNode.execute(this, a, toIndexableNode.execute(this, a, a.data())); } static boolean isLazyLongSafeInteger(AbstractTruffleString a) { @@ -5420,9 +5257,7 @@ public static ParseDoubleNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class GetInternalByteArrayNode extends Node { + public abstract static class GetInternalByteArrayNode extends AbstractPublicNode { GetInternalByteArrayNode() { } @@ -5447,31 +5282,31 @@ public abstract static class GetInternalByteArrayNode extends Node { @Specialization InternalByteArray getInternalByteArray(AbstractTruffleString a, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16S0Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32S0Profile, - @Cached ConditionProfile utf32S1Profile, - @Cached ConditionProfile isByteArrayProfile) { + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16S0Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32S0Profile, + @Cached InlinedConditionProfile utf32S1Profile, + @Cached InlinedConditionProfile isByteArrayProfile) { if (a.isEmpty()) { return InternalByteArray.EMPTY; } a.checkEncoding(expectedEncoding); - Object arrayA = toIndexableNode.execute(a, a.data()); - if (utf16Profile.profile(isUTF16(expectedEncoding))) { - if (utf16S0Profile.profile(isStride0(a))) { + Object arrayA = toIndexableNode.execute(this, a, a.data()); + if (utf16Profile.profile(this, isUTF16(expectedEncoding))) { + if (utf16S0Profile.profile(this, isStride0(a))) { return inflate(a, arrayA, 0, 1); } - } else if (utf32Profile.profile(isUTF32(expectedEncoding))) { - if (utf32S0Profile.profile(isStride0(a))) { + } else if (utf32Profile.profile(this, isUTF32(expectedEncoding))) { + if (utf32S0Profile.profile(this, isStride0(a))) { return inflate(a, arrayA, 0, 2); } - if (utf32S1Profile.profile(isStride1(a))) { + if (utf32S1Profile.profile(this, isStride1(a))) { return inflate(a, arrayA, 1, 2); } } int byteLength = a.length() << a.stride(); - if (isByteArrayProfile.profile(arrayA instanceof byte[])) { + if (isByteArrayProfile.profile(this, arrayA instanceof byte[])) { return new InternalByteArray((byte[]) arrayA, a.offset(), byteLength); } else { return new InternalByteArray(TStringOps.arraycopyOfWithStride(this, arrayA, a.offset(), byteLength, 0, byteLength, 0), 0, byteLength); @@ -5510,9 +5345,7 @@ public static GetInternalByteArrayNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class GetInternalNativePointerNode extends Node { + public abstract static class GetInternalNativePointerNode extends AbstractPublicNode { GetInternalNativePointerNode() { } @@ -5564,9 +5397,7 @@ public static GetInternalNativePointerNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CopyToByteArrayNode extends Node { + public abstract static class CopyToByteArrayNode extends AbstractPublicNode { CopyToByteArrayNode() { } @@ -5593,60 +5424,89 @@ public final byte[] execute(AbstractTruffleString string, Encoding expectedEncod public abstract void execute(AbstractTruffleString a, int byteFromIndexA, byte[] dst, int byteFromIndexDst, int byteLength, Encoding expectedEncoding); @Specialization - void doCopy(AbstractTruffleString a, int byteFromIndexA, byte[] arrayB, int byteFromIndexB, int byteLength, Encoding expectedEncoding, + final void doCopy(AbstractTruffleString a, int byteFromIndexA, byte[] dst, int byteFromIndexDst, int byteLength, Encoding expectedEncoding, + @Cached InternalCopyToByteArrayNode internalNode) { + internalNode.execute(this, a, byteFromIndexA, dst, byteFromIndexDst, byteLength, expectedEncoding); + } + + /** + * Create a new {@link CopyToByteArrayNode}. + * + * @since 22.1 + */ + public static CopyToByteArrayNode create() { + return TruffleStringFactory.CopyToByteArrayNodeGen.create(); + } + + /** + * Get the uncached version of {@link CopyToByteArrayNode}. + * + * @since 22.1 + */ + public static CopyToByteArrayNode getUncached() { + return TruffleStringFactory.CopyToByteArrayNodeGen.getUncached(); + } + } + + abstract static class InternalCopyToByteArrayNode extends AbstractInternalNode { + + abstract void execute(Node node, AbstractTruffleString a, int byteFromIndexA, byte[] dst, int byteFromIndexDst, int byteLength, Encoding expectedEncoding); + + @Specialization + static void doCopy(Node node, AbstractTruffleString a, int byteFromIndexA, byte[] arrayB, int byteFromIndexB, int byteLength, Encoding expectedEncoding, @Cached ToIndexableNode toIndexableNode, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16S0Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32S0Profile, - @Cached ConditionProfile utf32S1Profile) { + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16S0Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32S0Profile, + @Cached InlinedConditionProfile utf32S1Profile) { boundsCheckRegionI(byteFromIndexB, byteLength, arrayB.length); - doCopyInternal(this, a, byteFromIndexA, arrayB, byteFromIndexB, byteLength, expectedEncoding, + doCopyInternal(node, a, byteFromIndexA, arrayB, byteFromIndexB, byteLength, expectedEncoding, toIndexableNode, utf16Profile, utf16S0Profile, utf32Profile, utf32S0Profile, utf32S1Profile); } - private static void doCopyInternal(Node location, AbstractTruffleString a, int byteFromIndexA, Object arrayB, int byteFromIndexB, int byteLength, Encoding expectedEncoding, + private static void doCopyInternal(Node node, AbstractTruffleString a, int byteFromIndexA, Object arrayB, int byteFromIndexB, int byteLength, Encoding expectedEncoding, ToIndexableNode toIndexableNode, - ConditionProfile utf16Profile, - ConditionProfile utf16S0Profile, - ConditionProfile utf32Profile, - ConditionProfile utf32S0Profile, - ConditionProfile utf32S1Profile) { + InlinedConditionProfile utf16Profile, + InlinedConditionProfile utf16S0Profile, + InlinedConditionProfile utf32Profile, + InlinedConditionProfile utf32S0Profile, + InlinedConditionProfile utf32S1Profile) { if (byteLength == 0) { return; } a.checkEncoding(expectedEncoding); final int offsetA = a.offset(); final int offsetB = 0; - Object arrayA = toIndexableNode.execute(a, a.data()); - if (utf16Profile.profile(isUTF16(expectedEncoding))) { + Object arrayA = toIndexableNode.execute(node, a, a.data()); + if (utf16Profile.profile(node, isUTF16(expectedEncoding))) { a.boundsCheckByteIndexUTF16(byteFromIndexA); checkByteLengthUTF16(byteLength); final int fromIndexA = rawIndex(byteFromIndexA, expectedEncoding); final int fromIndexB = rawIndex(byteFromIndexB, expectedEncoding); final int length = rawIndex(byteLength, expectedEncoding); a.boundsCheckRegionRaw(fromIndexA, length); - if (utf16S0Profile.profile(isStride0(a))) { - TStringOps.arraycopyWithStride(location, + if (utf16S0Profile.profile(node, isStride0(a))) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, fromIndexA, arrayB, offsetB, 1, fromIndexB, length); return; } - } else if (utf32Profile.profile(isUTF32(expectedEncoding))) { + } else if (utf32Profile.profile(node, isUTF32(expectedEncoding))) { a.boundsCheckByteIndexUTF32(byteFromIndexA); checkByteLengthUTF32(byteLength); final int fromIndexA = rawIndex(byteFromIndexA, expectedEncoding); final int fromIndexB = rawIndex(byteFromIndexB, expectedEncoding); final int length = rawIndex(byteLength, expectedEncoding); a.boundsCheckRegionRaw(fromIndexA, length); - if (utf32S0Profile.profile(isStride0(a))) { - TStringOps.arraycopyWithStride(location, + if (utf32S0Profile.profile(node, isStride0(a))) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, fromIndexA, arrayB, offsetB, 2, fromIndexB, length); return; } - if (utf32S1Profile.profile(isStride1(a))) { - TStringOps.arraycopyWithStride(location, + if (utf32S1Profile.profile(node, isStride1(a))) { + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 1, fromIndexA, arrayB, offsetB, 2, fromIndexB, length); return; @@ -5654,28 +5514,11 @@ private static void doCopyInternal(Node location, AbstractTruffleString a, int b } final int byteLengthA = a.length() << a.stride(); boundsCheckRegionI(byteFromIndexA, byteLength, byteLengthA); - TStringOps.arraycopyWithStride(location, + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, byteFromIndexA, arrayB, offsetB, 0, byteFromIndexB, byteLength); } - /** - * Create a new {@link CopyToByteArrayNode}. - * - * @since 22.1 - */ - public static CopyToByteArrayNode create() { - return TruffleStringFactory.CopyToByteArrayNodeGen.create(); - } - - /** - * Get the uncached version of {@link CopyToByteArrayNode}. - * - * @since 22.1 - */ - public static CopyToByteArrayNode getUncached() { - return TruffleStringFactory.CopyToByteArrayNodeGen.getUncached(); - } } /** @@ -5685,10 +5528,7 @@ public static CopyToByteArrayNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringAccessor.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CopyToNativeMemoryNode extends Node { + public abstract static class CopyToNativeMemoryNode extends AbstractPublicNode { CopyToNativeMemoryNode() { } @@ -5710,12 +5550,12 @@ public abstract static class CopyToNativeMemoryNode extends Node { void doCopy(AbstractTruffleString a, int byteFromIndexA, Object pointerObject, int byteFromIndexB, int byteLength, Encoding expectedEncoding, @Cached(value = "createInteropLibrary()", uncached = "getUncachedInteropLibrary()") Node interopLibrary, @Cached ToIndexableNode toIndexableNode, - @Cached ConditionProfile utf16Profile, - @Cached ConditionProfile utf16S0Profile, - @Cached ConditionProfile utf32Profile, - @Cached ConditionProfile utf32S0Profile, - @Cached ConditionProfile utf32S1Profile) { - CopyToByteArrayNode.doCopyInternal(this, a, byteFromIndexA, NativePointer.create(this, pointerObject, interopLibrary), byteFromIndexB, + @Cached InlinedConditionProfile utf16Profile, + @Cached InlinedConditionProfile utf16S0Profile, + @Cached InlinedConditionProfile utf32Profile, + @Cached InlinedConditionProfile utf32S0Profile, + @Cached InlinedConditionProfile utf32S1Profile) { + InternalCopyToByteArrayNode.doCopyInternal(this, a, byteFromIndexA, NativePointer.create(this, pointerObject, interopLibrary), byteFromIndexB, byteLength, expectedEncoding, toIndexableNode, utf16Profile, utf16S0Profile, utf32Profile, utf32S0Profile, utf32S1Profile); } @@ -5744,9 +5584,7 @@ public static CopyToNativeMemoryNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ToJavaStringNode extends Node { + public abstract static class ToJavaStringNode extends AbstractPublicNode { ToJavaStringNode() { } @@ -5759,8 +5597,8 @@ public abstract static class ToJavaStringNode extends Node { public abstract String execute(AbstractTruffleString a); @Specialization - static String doUTF16(TruffleString a, - @Cached ConditionProfile cacheHit, + final String doUTF16(TruffleString a, + @Cached InlinedConditionProfile cacheHit, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.ToJavaStringNode toJavaStringNode) { if (a.isEmpty()) { @@ -5771,7 +5609,7 @@ static String doUTF16(TruffleString a, while (cur != a && !cur.isJavaString()) { cur = cur.next; } - if (cacheHit.profile(cur.isJavaString())) { + if (cacheHit.profile(this, cur.isJavaString())) { return (String) cur.data(); } } @@ -5787,13 +5625,14 @@ static String doUTF16(TruffleString a, // java string was inserted in parallel return (String) cur.data(); } - TruffleString s = toJavaStringNode.execute(cur, toIndexableNode.execute(cur, cur.data())); + TruffleString s = toJavaStringNode.execute(this, cur, toIndexableNode.execute(this, cur, cur.data())); a.cacheInsert(s); return (String) s.data(); } @Specialization static String doMutable(MutableTruffleString a, + @Bind("this") Node node, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached TStringInternalNodes.TransCodeNode transCodeNode, @@ -5803,12 +5642,12 @@ static String doMutable(MutableTruffleString a, } final AbstractTruffleString utf16String; final int codeRangeA; - if (isUTF16(a.encoding()) || (codeRangeA = getCodeRangeNode.execute(a)) < Encoding.UTF_16.maxCompatibleCodeRange) { + if (isUTF16(a.encoding()) || (codeRangeA = getCodeRangeNode.execute(node, a)) < Encoding.UTF_16.maxCompatibleCodeRange) { utf16String = a; } else { - utf16String = transCodeNode.execute(a, a.data(), getCodePointLengthNode.execute(a), codeRangeA, Encoding.UTF_16); + utf16String = transCodeNode.execute(node, a, a.data(), getCodePointLengthNode.execute(node, a), codeRangeA, Encoding.UTF_16); } - return createJavaStringNode.execute(utf16String, utf16String.data()); + return createJavaStringNode.execute(node, utf16String, utf16String.data()); } /** @@ -5836,10 +5675,7 @@ public static ToJavaStringNode getUncached() { * * @since 23.0 */ - @ImportStatic(TStringAccessor.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AsNativeNode extends Node { + public abstract static class AsNativeNode extends AbstractPublicNode { private static final int NULL_TERMINATION_BYTES = 4; @@ -5854,7 +5690,7 @@ public abstract static class AsNativeNode extends Node { * internal transcoding cache, such that subsequent calls on the same string will return the * same native string. This operation requires native access permissions * ({@code TruffleLanguage.Env#isNativeAccessAllowed()}). - * + * * @param allocator a function implementing {@link NativeAllocator}. This parameter is * expected to be {@link CompilerAsserts#partialEvaluationConstant(Object) * partial evaluation constant}. @@ -5877,18 +5713,19 @@ public abstract static class AsNativeNode extends Node { public abstract TruffleString execute(TruffleString a, NativeAllocator allocator, Encoding expectedEncoding, boolean useCompaction, boolean cacheResult); @Specialization - TruffleString asNative(TruffleString a, NativeAllocator allocator, Encoding encoding, boolean useCompaction, boolean cacheResult, + static TruffleString asNative(TruffleString a, NativeAllocator allocator, Encoding encoding, boolean useCompaction, boolean cacheResult, + @Bind("this") Node node, @Cached(value = "createInteropLibrary()", uncached = "getUncachedInteropLibrary()") Node interopLibrary, - @Cached ConditionProfile isNativeProfile, - @Cached ConditionProfile cacheHit, - @Cached IntValueProfile inflateStrideProfile, + @Cached InlinedConditionProfile isNativeProfile, + @Cached InlinedConditionProfile cacheHit, + @Cached InlinedIntValueProfile inflateStrideProfile, @Cached ToIndexableNode toIndexableNode) { a.checkEncoding(encoding); CompilerAsserts.partialEvaluationConstant(allocator); CompilerAsserts.partialEvaluationConstant(useCompaction); CompilerAsserts.partialEvaluationConstant(cacheResult); - int strideA = inflateStrideProfile.profile(a.stride()); - if (isNativeProfile.profile(a.isNative() && strideA == (useCompaction ? Stride.fromCodeRange(a.codeRange(), encoding) : encoding.naturalStride))) { + int strideA = inflateStrideProfile.profile(node, a.stride()); + if (isNativeProfile.profile(node, a.isNative() && strideA == (useCompaction ? Stride.fromCodeRange(a.codeRange(), encoding) : encoding.naturalStride))) { return a; } TruffleString cur = a.next; @@ -5897,7 +5734,7 @@ TruffleString asNative(TruffleString a, NativeAllocator allocator, Encoding enco while (cur != a && (!cur.isNative() || !cur.isCompatibleTo(encoding) || cur.stride() != (useCompaction ? strideA : encoding.naturalStride))) { cur = cur.next; } - if (cacheHit.profile(cur != a)) { + if (cacheHit.profile(node, cur != a)) { assert cur.isCompatibleTo(encoding) && cur.isNative() && !cur.isJavaString() && cur.stride() == (useCompaction ? strideA : encoding.naturalStride); return cur; } @@ -5906,18 +5743,18 @@ TruffleString asNative(TruffleString a, NativeAllocator allocator, Encoding enco int stride = useCompaction ? Stride.fromCodeRange(a.codeRange(), encoding) : encoding.naturalStride; int byteSize = length << stride; Object buffer = allocator.allocate(byteSize + NULL_TERMINATION_BYTES); - NativePointer nativePointer = NativePointer.create(this, buffer, interopLibrary); - Object arrayA = toIndexableNode.execute(a, a.data()); + NativePointer nativePointer = NativePointer.create(node, buffer, interopLibrary); + Object arrayA = toIndexableNode.execute(node, a, a.data()); int offsetA = a.offset(); if (useCompaction) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, strideA, 0, nativePointer, 0, stride, 0, length); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, strideA, 0, nativePointer, 0, stride, 0, length); } else { if (isUTF16(encoding)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, strideA, 0, nativePointer, 0, 1, 0, length); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, strideA, 0, nativePointer, 0, 1, 0, length); } else if (isUTF32(encoding)) { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, strideA, 0, nativePointer, 0, 2, 0, length); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, strideA, 0, nativePointer, 0, 2, 0, length); } else { - TStringOps.arraycopyWithStride(this, arrayA, offsetA, 0, 0, nativePointer, 0, 0, 0, byteSize); + TStringOps.arraycopyWithStride(node, arrayA, offsetA, 0, 0, nativePointer, 0, 0, 0, byteSize); } } // Zero-terminate the string with four zero bytes, to make absolutely sure any @@ -5972,9 +5809,7 @@ public TruffleString asNativeUncached(NativeAllocator allocator, Encoding expect * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class SwitchEncodingNode extends Node { + public abstract static class SwitchEncodingNode extends AbstractPublicNode { SwitchEncodingNode() { } @@ -5993,6 +5828,34 @@ public abstract static class SwitchEncodingNode extends Node { */ public abstract TruffleString execute(AbstractTruffleString a, Encoding encoding); + @Specialization + final TruffleString compatibleImmutable(AbstractTruffleString a, Encoding encoding, @Cached InternalSwitchEncodingNode internalNode) { + return internalNode.execute(this, a, encoding); + } + + /** + * Create a new {@link SwitchEncodingNode}. + * + * @since 22.1 + */ + public static SwitchEncodingNode create() { + return TruffleStringFactory.SwitchEncodingNodeGen.create(); + } + + /** + * Get the uncached version of {@link SwitchEncodingNode}. + * + * @since 22.1 + */ + public static SwitchEncodingNode getUncached() { + return TruffleStringFactory.SwitchEncodingNodeGen.getUncached(); + } + } + + abstract static class InternalSwitchEncodingNode extends AbstractInternalNode { + + public abstract TruffleString execute(Node node, AbstractTruffleString a, Encoding encoding); + @Specialization(guards = "a.isCompatibleTo(encoding)") static TruffleString compatibleImmutable(TruffleString a, @SuppressWarnings("unused") Encoding encoding) { assert !a.isJavaString(); @@ -6000,14 +5863,14 @@ static TruffleString compatibleImmutable(TruffleString a, @SuppressWarnings("unu } @Specialization(guards = "a.isCompatibleTo(encoding)") - static TruffleString compatibleMutable(MutableTruffleString a, Encoding encoding, - @Cached AsTruffleStringNode asTruffleStringNode) { - return asTruffleStringNode.execute(a, encoding); + static TruffleString compatibleMutable(Node node, MutableTruffleString a, Encoding encoding, + @Cached InternalAsTruffleStringNode asTruffleStringNode) { + return asTruffleStringNode.execute(node, a, encoding); } @Specialization(guards = "!a.isCompatibleTo(encoding)") - static TruffleString transCode(TruffleString a, Encoding encoding, - @Cached ConditionProfile cacheHit, + static TruffleString transCode(Node node, TruffleString a, Encoding encoding, + @Exclusive @Cached InlinedConditionProfile cacheHit, @Cached ToIndexableNode toIndexableNode, @Cached @Shared("transCodeNode") TStringInternalNodes.TransCodeNode transCodeNode) { if (a.isEmpty()) { @@ -6019,12 +5882,12 @@ static TruffleString transCode(TruffleString a, Encoding encoding, while (cur != a && cur.encoding() != encoding.id || (isUTF16(encoding) && cur.isJavaString())) { cur = cur.next; } - if (cacheHit.profile(cur.encoding() == encoding.id)) { + if (cacheHit.profile(node, cur.encoding() == encoding.id)) { assert !cur.isJavaString(); return cur; } } - TruffleString transCoded = transCodeNode.execute(a, toIndexableNode.execute(a, a.data()), a.codePointLength(), a.codeRange(), encoding); + TruffleString transCoded = transCodeNode.execute(node, a, toIndexableNode.execute(node, a, a.data()), a.codePointLength(), a.codeRange(), encoding); if (!transCoded.isCacheHead()) { a.cacheInsert(transCoded); } @@ -6032,45 +5895,28 @@ static TruffleString transCode(TruffleString a, Encoding encoding, } @Specialization(guards = "!a.isCompatibleTo(encoding)") - TruffleString transCodeMutable(MutableTruffleString a, Encoding encoding, + static TruffleString transCodeMutable(Node node, MutableTruffleString a, Encoding encoding, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached @Shared("transCodeNode") TStringInternalNodes.TransCodeNode transCodeNode, - @Cached ConditionProfile isCompatibleProfile) { + @Exclusive @Cached InlinedConditionProfile isCompatibleProfile) { if (a.isEmpty()) { return encoding.getEmpty(); } - final int codePointLengthA = getCodePointLengthNode.execute(a); - final int codeRangeA = getCodeRangeNode.execute(a); - if (isCompatibleProfile.profile(codeRangeA < encoding.maxCompatibleCodeRange)) { + final int codePointLengthA = getCodePointLengthNode.execute(node, a); + final int codeRangeA = getCodeRangeNode.execute(node, a); + if (isCompatibleProfile.profile(node, codeRangeA < encoding.maxCompatibleCodeRange)) { int strideDst = Stride.fromCodeRange(codeRangeA, encoding); byte[] arrayDst = new byte[a.length() << strideDst]; - TStringOps.arraycopyWithStride(this, + TStringOps.arraycopyWithStride(node, a.data(), a.offset(), a.stride(), 0, arrayDst, 0, strideDst, 0, a.length()); return createFromByteArray(arrayDst, a.length(), strideDst, encoding, codePointLengthA, codeRangeA); } else { - return transCodeNode.execute(a, a.data(), codePointLengthA, codeRangeA, encoding); + return transCodeNode.execute(node, a, a.data(), codePointLengthA, codeRangeA, encoding); } } - /** - * Create a new {@link SwitchEncodingNode}. - * - * @since 22.1 - */ - public static SwitchEncodingNode create() { - return TruffleStringFactory.SwitchEncodingNodeGen.create(); - } - - /** - * Get the uncached version of {@link SwitchEncodingNode}. - * - * @since 22.1 - */ - public static SwitchEncodingNode getUncached() { - return TruffleStringFactory.SwitchEncodingNodeGen.getUncached(); - } } /** @@ -6080,9 +5926,7 @@ public static SwitchEncodingNode getUncached() { * * @since 22.1 */ - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ForceEncodingNode extends Node { + public abstract static class ForceEncodingNode extends AbstractPublicNode { ForceEncodingNode() { } @@ -6107,31 +5951,31 @@ static TruffleString compatibleImmutable(TruffleString a, @SuppressWarnings("unu } @Specialization(guards = "isCompatibleAndNotCompacted(a, expectedEncoding, targetEncoding)") - static TruffleString compatibleMutable(MutableTruffleString a, @SuppressWarnings("unused") Encoding expectedEncoding, Encoding targetEncoding, - @Cached AsTruffleStringNode asTruffleStringNode) { - return asTruffleStringNode.execute(a, targetEncoding); + final TruffleString compatibleMutable(MutableTruffleString a, @SuppressWarnings("unused") Encoding expectedEncoding, Encoding targetEncoding, + @Cached InternalAsTruffleStringNode asTruffleStringNode) { + return asTruffleStringNode.execute(this, a, targetEncoding); } @Specialization(guards = "!isCompatibleAndNotCompacted(a, expectedEncoding, targetEncoding)") - static TruffleString reinterpret(AbstractTruffleString a, Encoding expectedEncoding, Encoding targetEncoding, + final TruffleString reinterpret(AbstractTruffleString a, Encoding expectedEncoding, Encoding targetEncoding, @Cached ToIndexableNode toIndexableNode, - @Cached ConditionProfile inflateProfile, - @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, + @Cached InlinedConditionProfile inflateProfile, + @Cached TruffleString.InternalCopyToByteArrayNode copyToByteArrayNode, @Cached TStringInternalNodes.FromBufferWithStringCompactionNode fromBufferWithStringCompactionNode) { - Object arrayA = toIndexableNode.execute(a, a.data()); + Object arrayA = toIndexableNode.execute(this, a, a.data()); int byteLength = a.length() << expectedEncoding.naturalStride; final Object arrayNoCompaction; final int offset; - if (inflateProfile.profile(isUTF16Or32(expectedEncoding) && a.stride() != expectedEncoding.naturalStride)) { + if (inflateProfile.profile(this, isUTF16Or32(expectedEncoding) && a.stride() != expectedEncoding.naturalStride)) { byte[] inflated = new byte[byteLength]; - copyToByteArrayNode.execute(a, 0, inflated, 0, byteLength, expectedEncoding); + copyToByteArrayNode.execute(this, a, 0, inflated, 0, byteLength, expectedEncoding); arrayNoCompaction = inflated; offset = 0; } else { arrayNoCompaction = arrayA; offset = a.offset(); } - return fromBufferWithStringCompactionNode.execute(arrayNoCompaction, offset, byteLength, targetEncoding, a.isMutable(), true); + return fromBufferWithStringCompactionNode.execute(this, arrayNoCompaction, offset, byteLength, targetEncoding, a.isMutable(), true); } static boolean isCompatibleAndNotCompacted(AbstractTruffleString a, Encoding expectedEncoding, Encoding targetEncoding) { @@ -6164,10 +6008,7 @@ public static ForceEncodingNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CreateCodePointIteratorNode extends Node { + public abstract static class CreateCodePointIteratorNode extends AbstractPublicNode { CreateCodePointIteratorNode() { } @@ -6194,12 +6035,12 @@ public final TruffleStringIterator execute(AbstractTruffleString a, Encoding exp public abstract TruffleStringIterator execute(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling); @Specialization - static TruffleStringIterator createIterator(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling, + final TruffleStringIterator createIterator(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode) { CompilerAsserts.partialEvaluationConstant(errorHandling); a.checkEncoding(expectedEncoding); - return forwardIterator(a, toIndexableNode.execute(a, a.data()), getCodeRangeANode.execute(a), expectedEncoding, errorHandling); + return forwardIterator(a, toIndexableNode.execute(this, a, a.data()), getCodeRangeANode.execute(this, a), expectedEncoding, errorHandling); } /** @@ -6227,10 +6068,7 @@ public static CreateCodePointIteratorNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class CreateBackwardCodePointIteratorNode extends Node { + public abstract static class CreateBackwardCodePointIteratorNode extends AbstractPublicNode { CreateBackwardCodePointIteratorNode() { } @@ -6257,12 +6095,12 @@ public final TruffleStringIterator execute(AbstractTruffleString a, Encoding exp public abstract TruffleStringIterator execute(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling); @Specialization - static TruffleStringIterator createIterator(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling, + final TruffleStringIterator createIterator(AbstractTruffleString a, Encoding expectedEncoding, ErrorHandling errorHandling, @Cached ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeANode) { CompilerAsserts.partialEvaluationConstant(errorHandling); a.checkEncoding(expectedEncoding); - return backwardIterator(a, toIndexableNode.execute(a, a.data()), getCodeRangeANode.execute(a), expectedEncoding, errorHandling); + return backwardIterator(a, toIndexableNode.execute(this, a, a.data()), getCodeRangeANode.execute(this, a), expectedEncoding, errorHandling); } /** diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java index a10e0b1b3287..649733034d6b 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java @@ -52,14 +52,16 @@ import java.util.Arrays; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GeneratePackagePrivate; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.strings.TruffleString.CompactionLevel; import com.oracle.truffle.api.strings.TruffleString.Encoding; /** @@ -159,10 +161,7 @@ public static TruffleStringBuilder create(Encoding encoding, int initialCapacity * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendByteNode extends Node { + public abstract static class AppendByteNode extends AbstractPublicNode { AppendByteNode() { } @@ -176,13 +175,13 @@ public abstract static class AppendByteNode extends Node { public abstract void execute(TruffleStringBuilder sb, byte value); @Specialization - static void append(TruffleStringBuilder sb, byte value, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { + final void append(TruffleStringBuilder sb, byte value, + @Cached InlinedConditionProfile bufferGrowProfile, + @Cached InlinedBranchProfile errorProfile) { if (isUTF16Or32(sb.encoding)) { throw InternalErrors.unsupportedOperation("appendByte is not supported for UTF-16 and UTF-32, use appendChar and appendInt instead"); } - sb.ensureCapacityS0(1, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(this, 1, bufferGrowProfile, errorProfile); sb.buf[sb.length++] = value; if (value < 0) { sb.codeRange = TSCodeRange.asciiLatinBytesNonAsciiCodeRange(sb.encoding); @@ -224,10 +223,7 @@ public void appendByteUncached(byte value) { * * @since 22.1 */ - @ImportStatic({TStringGuards.class, TruffleStringBuilder.class}) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendCharUTF16Node extends Node { + public abstract static class AppendCharUTF16Node extends AbstractPublicNode { AppendCharUTF16Node() { } @@ -239,27 +235,29 @@ public abstract static class AppendCharUTF16Node extends Node { */ public abstract void execute(TruffleStringBuilder sb, char value); - @Specialization(guards = {"cachedCurStride == sb.stride", "cachedNewStride == utf16Stride(sb, value)"}, limit = TStringOpsNodes.LIMIT_STRIDE) - void doCached(TruffleStringBuilder sb, char value, - @Cached(value = "sb.stride") int cachedCurStride, - @Cached(value = "utf16Stride(sb, value)") int cachedNewStride, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { - doAppend(sb, value, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); + @Specialization(guards = {"cachedCurCompaction.getStride() == sb.stride", "cachedNewCompaction.getStride() == utf16Stride(sb, value)"}, limit = TStringOpsNodes.LIMIT_STRIDE) + static void doCached(TruffleStringBuilder sb, char value, + @Bind("this") Node node, + @Cached("fromStride(sb.stride)") CompactionLevel cachedCurCompaction, + @Cached("fromStride(utf16Stride(sb, value))") CompactionLevel cachedNewCompaction, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + doAppend(node, sb, value, cachedCurCompaction.getStride(), cachedNewCompaction.getStride(), bufferGrowProfile, errorProfile); } @Specialization(replaces = "doCached") void doUncached(TruffleStringBuilder sb, char value, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { - doAppend(sb, value, sb.stride, utf16Stride(sb, value), bufferGrowProfile, errorProfile); + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + doAppend(this, sb, value, sb.stride, utf16Stride(sb, value), bufferGrowProfile, errorProfile); } - private void doAppend(TruffleStringBuilder sb, char value, int cachedCurStride, int cachedNewStride, ConditionProfile bufferGrowProfile, BranchProfile errorProfile) { + private static void doAppend(Node node, TruffleStringBuilder sb, char value, int cachedCurStride, int cachedNewStride, InlinedConditionProfile bufferGrowProfile, + InlinedBranchProfile errorProfile) { if (!isUTF16(sb.encoding)) { throw InternalErrors.unsupportedOperation("appendChar is meant for UTF-16 strings only"); } - sb.ensureCapacity(this, 1, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); + sb.ensureCapacity(node, 1, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); sb.updateCodeRange(utf16CodeRange(value)); TStringOps.writeToByteArray(sb.buf, cachedNewStride, sb.length, value); sb.appendLength(1); @@ -339,10 +337,7 @@ static int utf32CodeRange(int value) { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendCodePointNode extends Node { + public abstract static class AppendCodePointNode extends AbstractPublicNode { AppendCodePointNode() { } @@ -367,7 +362,7 @@ public final void execute(TruffleStringBuilder sb, int codepoint, int repeat) { /** * Append a codepoint to the string builder, {@code repeat} times. - * + * * If {@code allowUTF16Surrogates} is {@code true}, {@link Character#isSurrogate(char) * UTF-16 surrogate values} passed as {@code codepoint} will not cause an * {@link IllegalArgumentException}, but instead be encoded on a best-effort basis. This @@ -379,9 +374,7 @@ public final void execute(TruffleStringBuilder sb, int codepoint, int repeat) { @Specialization static void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF16Surrogates, - @Cached AppendCodePointIntlNode appendCodePointIntlNode, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { + @Cached AppendCodePointIntlNode appendCodePointIntlNode) { assert !allowUTF16Surrogates || isUTF16Or32(sb.encoding) : "allowUTF16Surrogates is only supported on UTF-16 and UTF-32"; if (c < 0 || c > 0x10ffff) { throw InternalErrors.invalidCodePoint(c); @@ -389,7 +382,7 @@ static void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF1 if (repeat < 1) { throw InternalErrors.illegalArgument("number of repetitions must be at least 1"); } - appendCodePointIntlNode.execute(sb, c, sb.encoding, repeat, allowUTF16Surrogates, bufferGrowProfile, errorProfile); + appendCodePointIntlNode.execute(sb, c, sb.encoding, repeat, allowUTF16Surrogates); sb.codePointLength += repeat; } @@ -414,20 +407,18 @@ public static AppendCodePointNode getUncached() { @ImportStatic({TStringGuards.class, TruffleStringBuilder.class}) @GenerateUncached - abstract static class AppendCodePointIntlNode extends Node { + abstract static class AppendCodePointIntlNode extends AbstractPublicNode { - abstract void execute(TruffleStringBuilder sb, int c, Encoding encoding, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile); + abstract void execute(TruffleStringBuilder sb, int c, Encoding encoding, int n, boolean allowUTF16Surrogates); @Specialization(guards = "isAsciiBytesOrLatin1(enc)") - static void bytes(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile) { + final void bytes(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { if (c > 0xff) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacityS0(n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(this, n, bufferGrowProfile, errorProfile); if (c > 0x7f) { sb.updateCodeRange(TSCodeRange.asciiLatinBytesNonAsciiCodeRange(sb.encoding)); } @@ -436,14 +427,14 @@ static void bytes(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") En } @Specialization(guards = "isUTF8(enc)") - static void utf8(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile) { + final void utf8(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { if (Encodings.isUTF16Surrogate(c)) { throw InternalErrors.invalidCodePoint(c); } int length = Encodings.utf8EncodedSize(c); - sb.ensureCapacityS0(length * n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(this, length * n, bufferGrowProfile, errorProfile); for (int i = 0; i < n; i++) { Encodings.utf8Encode(c, sb.buf, sb.length, length); sb.length += length; @@ -454,31 +445,32 @@ static void utf8(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Enc } @Specialization(guards = {"isUTF16(enc)", "cachedCurStride == sb.stride", "cachedNewStride == utf16Stride(sb, c)"}, limit = TStringOpsNodes.LIMIT_STRIDE) - void utf16Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile, - @Cached(value = "sb.stride") int cachedCurStride, - @Cached(value = "utf16Stride(sb, c)") int cachedNewStride, - @Cached ConditionProfile bmpProfile) { - doUTF16(sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, cachedCurStride, cachedNewStride, bmpProfile); + static void utf16Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, + @Bind("this") Node node, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile, + @Cached("sb.stride") int cachedCurStride, + @Cached("utf16Stride(sb, c)") int cachedNewStride, + @Shared("bmp") @Cached InlinedConditionProfile bmpProfile) { + doUTF16(node, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, cachedCurStride, cachedNewStride, bmpProfile); } @Specialization(guards = "isUTF16(enc)", replaces = "utf16Cached") void utf16Uncached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile, - @Cached ConditionProfile bmpProfile) { - doUTF16(sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf16Stride(sb, c), bmpProfile); + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile, + @Shared("bmp") @Cached InlinedConditionProfile bmpProfile) { + doUTF16(this, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf16Stride(sb, c), bmpProfile); } - private void doUTF16(TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, BranchProfile errorProfile, int cachedCurStride, int cachedNewStride, ConditionProfile bmpProfile) { + private static void doUTF16(Node node, TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, + InlinedConditionProfile bufferGrowProfile, InlinedBranchProfile errorProfile, int cachedCurStride, int cachedNewStride, InlinedConditionProfile bmpProfile) { if (!allowUTF16Surrogates && Encodings.isUTF16Surrogate(c)) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacity(this, c <= 0xffff ? n : n << 1, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); + sb.ensureCapacity(node, c <= 0xffff ? n : n << 1, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); sb.updateCodeRange(utf16CodeRange(c)); - if (bmpProfile.profile(c <= 0xffff)) { + if (bmpProfile.profile(node, c <= 0xffff)) { arrayFill(sb, c, n, cachedNewStride); } else { for (int i = 0; i < n; i++) { @@ -489,34 +481,37 @@ private void doUTF16(TruffleStringBuilder sb, int c, int n, boolean allowUTF16Su } @Specialization(guards = {"isUTF32(enc)", "cachedCurStride == sb.stride", "cachedNewStride == utf32Stride(sb, c)"}, limit = TStringOpsNodes.LIMIT_STRIDE) - void utf32Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile, + static void utf32Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, + @Bind("this") Node node, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile, @Cached(value = "sb.stride") int cachedCurStride, @Cached(value = "utf32Stride(sb, c)") int cachedNewStride) { - doUTF32(sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, cachedCurStride, cachedNewStride); + doUTF32(node, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, cachedCurStride, cachedNewStride); } @Specialization(guards = "isUTF32(enc)", replaces = "utf32Cached") void utf32Uncached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile) { - doUTF32(sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf32Stride(sb, c)); + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + doUTF32(this, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf32Stride(sb, c)); } - void doUTF32(TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, ConditionProfile bufferGrowProfile, BranchProfile errorProfile, int cachedCurStride, int cachedNewStride) { + static void doUTF32(Node node, TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, InlinedConditionProfile bufferGrowProfile, InlinedBranchProfile errorProfile, + int cachedCurStride, + int cachedNewStride) { if (!allowUTF16Surrogates && Encodings.isUTF16Surrogate(c)) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacity(this, n, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); + sb.ensureCapacity(node, n, cachedCurStride, cachedNewStride, bufferGrowProfile, errorProfile); sb.updateCodeRange(utf32CodeRange(c)); arrayFill(sb, c, n, cachedNewStride); } @Specialization(guards = "isUnsupportedEncoding(enc)") - static void unsupported(TruffleStringBuilder sb, int c, Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile) { + final void unsupported(TruffleStringBuilder sb, int c, Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { JCodings.Encoding jCodingsEnc = JCodings.getInstance().get(enc); int length = JCodings.getInstance().getCodePointLength(jCodingsEnc, c); if (!(enc.is7BitCompatible() && c <= 0x7f)) { @@ -525,7 +520,7 @@ static void unsupported(TruffleStringBuilder sb, int c, Encoding enc, int n, @Su if (length < 1) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacityS0(length * n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(this, length * n, bufferGrowProfile, errorProfile); for (int i = 0; i < n; i++) { int ret = JCodings.getInstance().writeCodePoint(jCodingsEnc, c, sb.buf, sb.length); if (ret != length || JCodings.getInstance().getCodePointLength(jCodingsEnc, sb.buf, sb.length, sb.length + length) != ret || @@ -583,10 +578,7 @@ public void appendCodePointUncached(int codepoint, int repeat, boolean allowUTF1 * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendIntNumberNode extends Node { + public abstract static class AppendIntNumberNode extends AbstractPublicNode { AppendIntNumberNode() { } @@ -599,15 +591,18 @@ public abstract static class AppendIntNumberNode extends Node { */ public abstract void execute(TruffleStringBuilder sb, int value); - @Specialization(guards = "cachedStride == sb.stride") + @SuppressWarnings("unused") + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) void doAppend(TruffleStringBuilder sb, int value, - @Cached(value = "sb.stride", allowUncached = true) int cachedStride, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { + @Bind("fromStride(sb.stride)") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { if (!is7BitCompatible(sb.encoding)) { throw InternalErrors.unsupportedOperation("appendIntNumber is supported on ASCII-compatible encodings only"); } int len = NumberConversion.stringLengthInt(value); + int cachedStride = cachedCompaction.getStride(); sb.ensureCapacity(this, len, cachedStride, cachedStride, bufferGrowProfile, errorProfile); NumberConversion.writeIntToBytes(this, value, sb.buf, cachedStride, sb.length, len); sb.appendLength(len); @@ -648,10 +643,7 @@ public void appendIntNumberUncached(int value) { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendLongNumberNode extends Node { + public abstract static class AppendLongNumberNode extends AbstractPublicNode { AppendLongNumberNode() { } @@ -664,14 +656,17 @@ public abstract static class AppendLongNumberNode extends Node { */ public abstract void execute(TruffleStringBuilder sb, long value); - @Specialization(guards = "cachedStride == sb.stride") + @SuppressWarnings("unused") + @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) void doAppend(TruffleStringBuilder sb, long value, - @Cached(value = "sb.stride", allowUncached = true) int cachedStride, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { + @Bind("fromStride(sb.stride)") CompactionLevel compaction, + @Cached("compaction") CompactionLevel cachedCompaction, + @Cached InlinedConditionProfile bufferGrowProfile, + @Cached InlinedBranchProfile errorProfile) { if (!is7BitCompatible(sb.encoding)) { throw InternalErrors.unsupportedOperation("appendIntNumber is supported on ASCII-compatible encodings only"); } + int cachedStride = cachedCompaction.getStride(); int len = NumberConversion.stringLengthLong(value); sb.ensureCapacity(this, len, cachedStride, cachedStride, bufferGrowProfile, errorProfile); NumberConversion.writeLongToBytes(this, value, sb.buf, cachedStride, sb.length, len); @@ -712,10 +707,7 @@ public void appendLongNumberUncached(long value) { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendStringNode extends Node { + public abstract static class AppendStringNode extends AbstractPublicNode { AppendStringNode() { } @@ -728,7 +720,7 @@ public abstract static class AppendStringNode extends Node { public abstract void execute(TruffleStringBuilder sb, AbstractTruffleString a); @Specialization - static void append(TruffleStringBuilder sb, AbstractTruffleString a, + void append(TruffleStringBuilder sb, AbstractTruffleString a, @Cached TruffleString.ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @@ -737,12 +729,12 @@ static void append(TruffleStringBuilder sb, AbstractTruffleString a, return; } a.checkEncoding(sb.encoding); - Object arrayA = toIndexableNode.execute(a, a.data()); - int codeRangeA = getCodeRangeNode.execute(a); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + int codeRangeA = getCodeRangeNode.execute(this, a); sb.updateCodeRange(codeRangeA); int newStride = Math.max(sb.stride, Stride.fromCodeRange(codeRangeA, sb.encoding)); - appendArrayIntlNode.execute(sb, arrayA, a.offset(), a.length(), a.stride(), newStride); - sb.appendLength(a.length(), getCodePointLengthNode.execute(a)); + appendArrayIntlNode.execute(this, sb, arrayA, a.offset(), a.length(), a.stride(), newStride); + sb.appendLength(a.length(), getCodePointLengthNode.execute(this, a)); } /** @@ -780,10 +772,7 @@ public void appendStringUncached(TruffleString a) { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendSubstringByteIndexNode extends Node { + public abstract static class AppendSubstringByteIndexNode extends AbstractPublicNode { AppendSubstringByteIndexNode() { } @@ -798,13 +787,13 @@ public abstract static class AppendSubstringByteIndexNode extends Node { public abstract void execute(TruffleStringBuilder sb, AbstractTruffleString a, int fromByteIndex, int byteLength); @Specialization - static void append(TruffleStringBuilder sb, AbstractTruffleString a, int fromByteIndex, int byteLength, + final void append(TruffleStringBuilder sb, AbstractTruffleString a, int fromByteIndex, int byteLength, @Cached TruffleString.ToIndexableNode toIndexableNode, @Cached TStringInternalNodes.GetCodePointLengthNode getCodePointLengthNode, @Cached TStringInternalNodes.GetCodeRangeNode getCodeRangeNode, @Cached AppendArrayIntlNode appendArrayIntlNode, @Cached TStringInternalNodes.CalcStringAttributesNode calcAttributesNode, - @Cached ConditionProfile calcAttrsProfile) { + @Cached InlinedConditionProfile calcAttrsProfile) { if (byteLength == 0) { return; } @@ -812,18 +801,18 @@ static void append(TruffleStringBuilder sb, AbstractTruffleString a, int fromByt final int fromIndex = TruffleString.rawIndex(fromByteIndex, sb.encoding); final int length = TruffleString.rawIndex(byteLength, sb.encoding); a.boundsCheckRegionRaw(fromIndex, length); - Object arrayA = toIndexableNode.execute(a, a.data()); - final int codeRangeA = getCodeRangeNode.execute(a); + Object arrayA = toIndexableNode.execute(this, a, a.data()); + final int codeRangeA = getCodeRangeNode.execute(this, a); final int codeRange; final int codePointLength; if (fromIndex == 0 && length == a.length()) { codeRange = codeRangeA; - codePointLength = getCodePointLengthNode.execute(a); + codePointLength = getCodePointLengthNode.execute(this, a); } else if (isFixedWidth(codeRangeA) && !TSCodeRange.isMoreGeneralThan(codeRangeA, sb.codeRange)) { codeRange = codeRangeA; codePointLength = length; - } else if (calcAttrsProfile.profile(!(isBrokenMultiByteOrUnknown(sb.codeRange) || isBrokenFixedWidth(sb.codeRange)))) { - long attrs = calcAttributesNode.execute(a, arrayA, a.offset(), length, a.stride(), sb.encoding, fromIndex, codeRangeA); + } else if (calcAttrsProfile.profile(this, !(isBrokenMultiByteOrUnknown(sb.codeRange) || isBrokenFixedWidth(sb.codeRange)))) { + long attrs = calcAttributesNode.execute(this, a, arrayA, a.offset(), length, a.stride(), sb.encoding, fromIndex, codeRangeA); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); } else { @@ -831,7 +820,7 @@ static void append(TruffleStringBuilder sb, AbstractTruffleString a, int fromByt codePointLength = 0; } sb.updateCodeRange(codeRange); - appendArrayIntlNode.execute(sb, arrayA, a.offset() + (fromIndex << a.stride()), length, a.stride(), Stride.fromCodeRange(sb.codeRange, sb.encoding)); + appendArrayIntlNode.execute(this, sb, arrayA, a.offset() + (fromIndex << a.stride()), length, a.stride(), Stride.fromCodeRange(sb.codeRange, sb.encoding)); sb.appendLength(length, codePointLength); } @@ -870,10 +859,7 @@ public void appendSubstringByteIndexUncached(TruffleString a, int fromByteIndex, * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class AppendJavaStringUTF16Node extends Node { + public abstract static class AppendJavaStringUTF16Node extends AbstractPublicNode { AppendJavaStringUTF16Node() { } @@ -898,9 +884,9 @@ public final void execute(TruffleStringBuilder sb, String a) { public abstract void execute(TruffleStringBuilder sb, String a, int fromCharIndex, int charLength); @Specialization - void append(TruffleStringBuilder sb, String javaString, int fromIndex, int lengthStr, + final void append(TruffleStringBuilder sb, String javaString, int fromIndex, int lengthStr, @Cached AppendArrayIntlNode appendArrayIntlNode, - @Cached ConditionProfile stride0Profile) { + @Cached InlinedConditionProfile stride0Profile) { if (!isUTF16(sb)) { throw InternalErrors.unsupportedOperation("appendJavaString is supported on UTF-16 only, use appendString for other encodings"); } @@ -912,7 +898,7 @@ void append(TruffleStringBuilder sb, String javaString, int fromIndex, int lengt final byte[] arrayStr = TStringUnsafe.getJavaStringArray(javaString); final int strideStr = TStringUnsafe.getJavaStringStride(javaString); final int offsetStr = fromIndex << strideStr; - if (stride0Profile.profile(strideStr == 0)) { + if (stride0Profile.profile(this, strideStr == 0)) { if (is7Bit(sb.codeRange)) { sb.updateCodeRange(TStringOps.calcStringAttributesLatin1(this, arrayStr, offsetStr, lengthStr)); } @@ -926,7 +912,7 @@ void append(TruffleStringBuilder sb, String javaString, int fromIndex, int lengt appendCodePointLength = 0; } } - appendArrayIntlNode.execute(sb, arrayStr, offsetStr, lengthStr, strideStr, Stride.fromCodeRangeUTF16(sb.codeRange)); + appendArrayIntlNode.execute(this, sb, arrayStr, offsetStr, lengthStr, strideStr, Stride.fromCodeRangeUTF16(sb.codeRange)); sb.appendLength(lengthStr, appendCodePointLength); } @@ -974,10 +960,7 @@ public void appendJavaStringUTF16Uncached(String a, int fromCharIndex, int charL * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class ToStringNode extends Node { + public abstract static class ToStringNode extends AbstractPublicNode { ToStringNode() { } @@ -993,28 +976,28 @@ public final TruffleString execute(TruffleStringBuilder sb) { /** * Materialize this string builder to a {@link TruffleString}. - * + * * If {@code lazy} is {@code true}, {@code sb}'s internal storage will be re-used even if * there are unused bytes. Since the resulting string will have a reference to {@code sb}'s * internal storage, and {@link TruffleString} currently does not resize/trim the * substring's internal storage at any point, the {@code lazy} variant effectively creates a * memory leak! The caller is responsible for deciding whether this is acceptable or not. - * + * * @since 22.1 */ public abstract TruffleString execute(TruffleStringBuilder sb, boolean lazy); @Specialization - static TruffleString createString(TruffleStringBuilder sb, boolean lazy, - @Cached ConditionProfile calcAttributesProfile, + final TruffleString createString(TruffleStringBuilder sb, boolean lazy, + @Cached InlinedConditionProfile calcAttributesProfile, @Cached TStringInternalNodes.CalcStringAttributesNode calcAttributesNode) { if (sb.length == 0) { return sb.encoding.getEmpty(); } final int codeRange; final int codePointLength; - if (calcAttributesProfile.profile(isBrokenMultiByteOrUnknown(sb.codeRange))) { - long attrs = calcAttributesNode.execute(null, sb.buf, 0, sb.length, sb.stride, sb.encoding, 0, TSCodeRange.getUnknown()); + if (calcAttributesProfile.profile(this, isBrokenMultiByteOrUnknown(sb.codeRange))) { + long attrs = calcAttributesNode.execute(this, null, sb.buf, 0, sb.length, sb.stride, sb.encoding, 0, TSCodeRange.getUnknown()); codeRange = StringAttributes.getCodeRange(attrs); codePointLength = StringAttributes.getCodePointLength(attrs); } else { @@ -1055,32 +1038,30 @@ public TruffleString toStringUncached() { return ToStringNode.getUncached().execute(this); } - @ImportStatic(TStringGuards.class) - @GenerateUncached - abstract static class AppendArrayIntlNode extends Node { + abstract static class AppendArrayIntlNode extends AbstractInternalNode { - abstract void execute(TruffleStringBuilder sb, Object array, int offsetA, int lengthA, int strideA, int strideNew); + abstract void execute(Node node, TruffleStringBuilder sb, Object array, int offsetA, int lengthA, int strideA, int strideNew); @Specialization(guards = {"sb.stride == cachedStrideSB", "strideA == cachedStrideA", "strideNew == cachedStrideNew"}, limit = TStringOpsNodes.LIMIT_STRIDE) - void doCached(TruffleStringBuilder sb, Object array, int offsetA, int lengthA, @SuppressWarnings("unused") int strideA, @SuppressWarnings("unused") int strideNew, + static void doCached(Node node, TruffleStringBuilder sb, Object array, int offsetA, int lengthA, @SuppressWarnings("unused") int strideA, @SuppressWarnings("unused") int strideNew, @Cached(value = "sb.stride") int cachedStrideSB, @Cached(value = "strideA") int cachedStrideA, @Cached(value = "strideNew") int cachedStrideNew, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { - doAppend(this, sb, array, offsetA, lengthA, cachedStrideSB, cachedStrideA, cachedStrideNew, bufferGrowProfile, errorProfile); + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + doAppend(node, sb, array, offsetA, lengthA, cachedStrideSB, cachedStrideA, cachedStrideNew, bufferGrowProfile, errorProfile); } @Specialization(replaces = "doCached") - void doUncached(TruffleStringBuilder sb, Object array, int offsetA, int lengthA, int strideA, int strideNew, - @Cached ConditionProfile bufferGrowProfile, - @Cached BranchProfile errorProfile) { - doAppend(this, sb, array, offsetA, lengthA, sb.stride, strideA, strideNew, bufferGrowProfile, errorProfile); + static void doUncached(Node node, TruffleStringBuilder sb, Object array, int offsetA, int lengthA, int strideA, int strideNew, + @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, + @Shared("error") @Cached InlinedBranchProfile errorProfile) { + doAppend(node, sb, array, offsetA, lengthA, sb.stride, strideA, strideNew, bufferGrowProfile, errorProfile); } private static void doAppend(Node location, TruffleStringBuilder sb, Object array, int offsetA, int lengthA, int cachedStrideSB, int cachedStrideA, int cachedStrideNew, - ConditionProfile bufferGrowProfile, - BranchProfile errorProfile) { + InlinedConditionProfile bufferGrowProfile, + InlinedBranchProfile errorProfile) { sb.ensureCapacity(location, lengthA, cachedStrideSB, cachedStrideNew, bufferGrowProfile, errorProfile); assert sb.stride == cachedStrideNew; TStringOps.arraycopyWithStride(location, @@ -1089,15 +1070,15 @@ private static void doAppend(Node location, TruffleStringBuilder sb, Object arra } } - void ensureCapacityS0(int appendLength, ConditionProfile bufferGrowProfile, BranchProfile errorProfile) { + void ensureCapacityS0(Node node, int appendLength, InlinedConditionProfile bufferGrowProfile, InlinedBranchProfile errorProfile) { assert stride == 0; final long newLength = (long) length + appendLength; - if (bufferGrowProfile.profile(newLength > bufferLength())) { + if (bufferGrowProfile.profile(node, newLength > bufferLength())) { long newBufferLength = ((long) bufferLength() << 1) + 2; assert newLength >= 0; final int maxLength = TStringConstants.MAX_ARRAY_SIZE; if (newLength > maxLength) { - errorProfile.enter(); + errorProfile.enter(node); throw InternalErrors.outOfMemory(); } newBufferLength = Math.min(newBufferLength, maxLength); @@ -1106,16 +1087,16 @@ void ensureCapacityS0(int appendLength, ConditionProfile bufferGrowProfile, Bran } } - void ensureCapacity(Node location, int appendLength, int curStride, int newStride, ConditionProfile bufferGrowProfile, BranchProfile errorProfile) { + void ensureCapacity(Node location, int appendLength, int curStride, int newStride, InlinedConditionProfile bufferGrowProfile, InlinedBranchProfile errorProfile) { assert curStride == stride; assert newStride >= stride; final long newLength = (long) length + appendLength; - if (bufferGrowProfile.profile(curStride != newStride || newLength > bufferLength())) { + if (bufferGrowProfile.profile(location, curStride != newStride || newLength > bufferLength())) { long newBufferLength = newLength > bufferLength() ? ((long) bufferLength() << 1) + 2 : bufferLength(); assert newLength >= 0; final int maxLength = TStringConstants.MAX_ARRAY_SIZE >> newStride; if (newLength > maxLength) { - errorProfile.enter(); + errorProfile.enter(location); throw InternalErrors.outOfMemory(); } newBufferLength = Math.min(newBufferLength, maxLength); diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java index a8759bc7fc78..b0de548ac386 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GeneratePackagePrivate; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; @@ -84,7 +86,8 @@ * // suboptimal variant: using CodePointAtIndexNode in a loop * int codePointLength = codePointLengthNode.execute(string, Encoding.UTF_8); * for (int i = 0; i < codePointLength; i++) { - * // performance problem: codePointAtIndexNode may have to calculate the byte index corresponding + * // performance problem: codePointAtIndexNode may have to calculate the byte index + * // corresponding * // to codepoint index i for every loop iteration * System.out.printf("%x%n", codePointAtIndexNode.execute(string, i, Encoding.UTF_8)); * } @@ -138,63 +141,47 @@ public boolean hasPrevious() { * Returns the next codepoint's byte index, where "byte index" refers the codepoint's first byte * in forward mode, while in backward mode it refers to the first byte after the * codepoint. - * + * * @since 22.3 */ public int getByteIndex() { return rawIndex << encoding.naturalStride; } - /** - * Returns the next codepoint in the string. - * - * @since 22.1 - */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - public abstract static class NextNode extends Node { - - NextNode() { - } + abstract static class InternalNextNode extends AbstractInternalNode { - /** - * Returns the next codepoint in the string. - * - * @since 22.1 - */ - public final int execute(TruffleStringIterator it) { + public final int execute(Node node, TruffleStringIterator it) { if (!it.hasNext()) { throw InternalErrors.illegalState("end of string has been reached already"); } - return executeInternal(it); + return executeInternal(node, it); } - abstract int executeInternal(TruffleStringIterator it); + abstract int executeInternal(Node node, TruffleStringIterator it); @Specialization(guards = {"isFixedWidth(it.codeRangeA)", "isBestEffort(it.errorHandling)"}) - static int fixed(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - return readAndInc(it, readNode); + static int fixed(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + return readAndInc(node, it, readNode); } @Specialization(guards = {"isUpToValidFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int fixedValid(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - return readAndInc(it, readNode); + static int fixedValid(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + return readAndInc(node, it, readNode); } @Specialization(guards = {"isAscii(it.encoding)", "isBrokenFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int brokenAscii(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - int codepoint = readAndInc(it, readNode); + static int brokenAscii(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + int codepoint = readAndInc(node, it, readNode); return codepoint < 0x80 ? codepoint : -1; } @Specialization(guards = {"isUTF32(it.encoding)", "isBrokenFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int brokenUTF32(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - int codepoint = readAndInc(it, readNode); + static int brokenUTF32(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + int codepoint = readAndInc(node, it, readNode); return Encodings.isValidUnicodeCodepoint(codepoint) ? codepoint : -1; } @@ -324,6 +311,35 @@ static int unsupported(TruffleStringIterator it) { return JCodings.getInstance().readCodePoint(jCoding, bytes, p, end); } + } + + /** + * Returns the next codepoint in the string. + * + * @since 22.1 + */ + @ImportStatic(TStringGuards.class) + @GeneratePackagePrivate + @GenerateUncached + @GenerateInline(false) + public abstract static class NextNode extends AbstractPublicNode { + + NextNode() { + } + + /** + * Returns the next codepoint in the string. + * + * @since 22.1 + */ + public abstract int execute(TruffleStringIterator it); + + @Specialization + final int doDefault(TruffleStringIterator it, + @Cached InternalNextNode nextNode) { + return nextNode.execute(this, it); + } + /** * Create a new {@link NextNode}. * @@ -361,7 +377,8 @@ public int nextUncached() { @ImportStatic(TStringGuards.class) @GeneratePackagePrivate @GenerateUncached - public abstract static class PreviousNode extends Node { + @GenerateInline(false) + public abstract static class PreviousNode extends AbstractPublicNode { PreviousNode() { } @@ -371,38 +388,70 @@ public abstract static class PreviousNode extends Node { * * @since 22.1 */ - public final int execute(TruffleStringIterator it) { + public abstract int execute(TruffleStringIterator it); + + @Specialization + final int doDefault(TruffleStringIterator it, + @Cached InternalPreviousNode previousNode) { + return previousNode.execute(this, it); + } + + /** + * Create a new {@link PreviousNode}. + * + * @since 22.1 + */ + public static PreviousNode create() { + return TruffleStringIteratorFactory.PreviousNodeGen.create(); + } + + /** + * Get the uncached version of {@link PreviousNode}. + * + * @since 22.1 + */ + public static PreviousNode getUncached() { + return TruffleStringIteratorFactory.PreviousNodeGen.getUncached(); + } + } + + abstract static class InternalPreviousNode extends AbstractInternalNode { + + InternalPreviousNode() { + } + + public final int execute(Node node, TruffleStringIterator it) { if (!it.hasPrevious()) { throw InternalErrors.illegalState("beginning of string has been reached already"); } - return executeInternal(it); + return executeInternal(node, it); } - abstract int executeInternal(TruffleStringIterator it); + abstract int executeInternal(Node node, TruffleStringIterator it); @Specialization(guards = {"isFixedWidth(it.codeRangeA)", "isBestEffort(it.errorHandling)"}) - static int fixed(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - return readAndDec(it, readNode); + static int fixed(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + return readAndDec(node, it, readNode); } @Specialization(guards = {"isUpToValidFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int fixedValid(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - return readAndDec(it, readNode); + static int fixedValid(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + return readAndDec(node, it, readNode); } @Specialization(guards = {"isAscii(it.encoding)", "isBrokenFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int brokenAscii(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - int codepoint = readAndDec(it, readNode); + static int brokenAscii(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + int codepoint = readAndDec(node, it, readNode); return codepoint < 0x80 ? codepoint : -1; } @Specialization(guards = {"isUTF32(it.encoding)", "isBrokenFixedWidth(it.codeRangeA)", "isReturnNegative(it.errorHandling)"}) - static int brokenUTF32(TruffleStringIterator it, - @Cached TStringOpsNodes.RawReadValueNode readNode) { - int codepoint = readAndDec(it, readNode); + static int brokenUTF32(Node node, TruffleStringIterator it, + @Shared("readRaw") @Cached TStringOpsNodes.RawReadValueNode readNode) { + int codepoint = readAndDec(node, it, readNode); return Encodings.isValidUnicodeCodepoint(codepoint) ? codepoint : -1; } @@ -510,23 +559,6 @@ static int unsupported(TruffleStringIterator it) { return JCodings.getInstance().readCodePoint(jCoding, bytes, prevIndex, end); } - /** - * Create a new {@link PreviousNode}. - * - * @since 22.1 - */ - public static PreviousNode create() { - return TruffleStringIteratorFactory.PreviousNodeGen.create(); - } - - /** - * Get the uncached version of {@link PreviousNode}. - * - * @since 22.1 - */ - public static PreviousNode getUncached() { - return TruffleStringIteratorFactory.PreviousNodeGen.getUncached(); - } } /** @@ -565,9 +597,9 @@ private int readBckS1() { return TStringOps.readS1(a, arrayA, rawIndex - 1); } - private static int readAndInc(TruffleStringIterator it, TStringOpsNodes.RawReadValueNode readNode) { + private static int readAndInc(Node node, TruffleStringIterator it, TStringOpsNodes.RawReadValueNode readNode) { assert it.hasNext(); - return readNode.execute(it.a, it.arrayA, it.rawIndex++); + return readNode.execute(node, it.a, it.arrayA, it.rawIndex++); } private int readAndIncS0() { @@ -582,9 +614,9 @@ private int readAndIncS1() { return TStringOps.readS1(a, arrayA, rawIndex++); } - private static int readAndDec(TruffleStringIterator it, TStringOpsNodes.RawReadValueNode readNode) { + private static int readAndDec(Node node, TruffleStringIterator it, TStringOpsNodes.RawReadValueNode readNode) { assert it.hasPrevious(); - return readNode.execute(it.a, it.arrayA, --it.rawIndex); + return readNode.execute(node, it.a, it.arrayA, --it.rawIndex); } private int readAndDecS0() { @@ -603,10 +635,10 @@ private boolean curIsUtf8ContinuationByte() { return Encodings.isUTF8ContinuationByte(readFwdS0()); } - static int indexOf(Node location, TruffleStringIterator it, int codepoint, int fromIndex, int toIndex, NextNode nextNode) { + static int indexOf(Node location, TruffleStringIterator it, int codepoint, int fromIndex, int toIndex, InternalNextNode nextNode) { int aCodepointIndex = 0; while (aCodepointIndex < fromIndex && it.hasNext()) { - nextNode.execute(it); + nextNode.execute(location, it); aCodepointIndex++; TStringConstants.truffleSafePointPoll(location, aCodepointIndex); } @@ -614,7 +646,7 @@ static int indexOf(Node location, TruffleStringIterator it, int codepoint, int f return -1; } while (it.hasNext() && aCodepointIndex < toIndex) { - if (nextNode.execute(it) == codepoint) { + if (nextNode.execute(location, it) == codepoint) { return aCodepointIndex; } aCodepointIndex++; @@ -623,13 +655,13 @@ static int indexOf(Node location, TruffleStringIterator it, int codepoint, int f return -1; } - static int lastIndexOf(Node location, TruffleStringIterator it, int codepoint, int fromIndex, int toIndex, NextNode nextNode) { + static int lastIndexOf(Node location, TruffleStringIterator it, int codepoint, int fromIndex, int toIndex, InternalNextNode nextNode) { int aCodepointIndex = 0; int result = -1; // the code point index is based on the beginning of the string, so we have to count // from there while (aCodepointIndex < fromIndex && it.hasNext()) { - if (nextNode.execute(it) == codepoint) { + if (nextNode.execute(location, it) == codepoint) { result = aCodepointIndex; } aCodepointIndex++; @@ -642,23 +674,23 @@ static int lastIndexOf(Node location, TruffleStringIterator it, int codepoint, i return result; } - static int indexOfString(Node location, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromIndex, int toIndex, NextNode nextNodeA, NextNode nextNodeB) { + static int indexOfString(Node node, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromIndex, int toIndex, InternalNextNode nextNodeA, InternalNextNode nextNodeB) { if (!bIt.hasNext()) { return fromIndex; } int aCodepointIndex = 0; while (aCodepointIndex < fromIndex && aIt.hasNext()) { - nextNodeA.execute(aIt); + nextNodeA.execute(node, aIt); aCodepointIndex++; - TStringConstants.truffleSafePointPoll(location, aCodepointIndex); + TStringConstants.truffleSafePointPoll(node, aCodepointIndex); } if (aCodepointIndex < fromIndex) { return -1; } - int bFirst = nextNodeB.execute(bIt); + int bFirst = nextNodeB.execute(node, bIt); int bSecondIndex = bIt.getRawIndex(); while (aIt.hasNext() && aCodepointIndex < toIndex) { - if (nextNodeA.execute(aIt) == bFirst) { + if (nextNodeA.execute(node, aIt) == bFirst) { if (!bIt.hasNext()) { return aCodepointIndex; } @@ -668,34 +700,34 @@ static int indexOfString(Node location, TruffleStringIterator aIt, TruffleString if (!aIt.hasNext()) { return -1; } - if (nextNodeA.execute(aIt) != nextNodeB.execute(bIt)) { + if (nextNodeA.execute(node, aIt) != nextNodeB.execute(node, bIt)) { break; } if (!bIt.hasNext()) { return aCodepointIndex; } - TStringConstants.truffleSafePointPoll(location, ++innerLoopCount); + TStringConstants.truffleSafePointPoll(node, ++innerLoopCount); } aIt.setRawIndex(aCurIndex); bIt.setRawIndex(bSecondIndex); } aCodepointIndex++; - TStringConstants.truffleSafePointPoll(location, aCodepointIndex); + TStringConstants.truffleSafePointPoll(node, aCodepointIndex); } return -1; } - static int byteIndexOfString(Node location, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromByteIndex, int toByteIndex, NextNode nextNodeA, NextNode nextNodeB) { + static int byteIndexOfString(Node node, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromByteIndex, int toByteIndex, InternalNextNode nextNodeA, InternalNextNode nextNodeB) { if (!bIt.hasNext()) { return fromByteIndex; } aIt.setRawIndex(fromByteIndex); - int bFirst = nextNodeB.execute(bIt); + int bFirst = nextNodeB.execute(node, bIt); int bSecondIndex = bIt.getRawIndex(); int loopCount = 0; while (aIt.hasNext() && aIt.getRawIndex() < toByteIndex) { int ret = aIt.getRawIndex(); - if (nextNodeA.execute(aIt) == bFirst) { + if (nextNodeA.execute(node, aIt) == bFirst) { if (!bIt.hasNext()) { return ret; } @@ -704,37 +736,38 @@ static int byteIndexOfString(Node location, TruffleStringIterator aIt, TruffleSt if (!aIt.hasNext()) { return -1; } - if (nextNodeA.execute(aIt) != nextNodeB.execute(bIt)) { + if (nextNodeA.execute(node, aIt) != nextNodeB.execute(node, bIt)) { break; } if (!bIt.hasNext()) { return ret; } - TStringConstants.truffleSafePointPoll(location, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } aIt.setRawIndex(aCurIndex); bIt.setRawIndex(bSecondIndex); } - TStringConstants.truffleSafePointPoll(location, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } return -1; } - static int lastIndexOfString(Node location, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromIndex, int toIndex, NextNode nextNodeA, PreviousNode prevNodeA, PreviousNode prevNodeB) { + static int lastIndexOfString(Node node, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromIndex, int toIndex, InternalNextNode nextNodeA, InternalPreviousNode prevNodeA, + InternalPreviousNode prevNodeB) { if (!bIt.hasPrevious()) { return fromIndex; } - int bFirstCodePoint = prevNodeB.execute(bIt); + int bFirstCodePoint = prevNodeB.execute(node, bIt); int lastMatchIndex = -1; int lastMatchByteIndex = -1; int aCodepointIndex = 0; while (aCodepointIndex < fromIndex && aIt.hasNext()) { - if (nextNodeA.execute(aIt) == bFirstCodePoint) { + if (nextNodeA.execute(node, aIt) == bFirstCodePoint) { lastMatchIndex = aCodepointIndex; lastMatchByteIndex = aIt.getRawIndex(); } aCodepointIndex++; - TStringConstants.truffleSafePointPoll(location, aCodepointIndex); + TStringConstants.truffleSafePointPoll(node, aCodepointIndex); } if (aCodepointIndex < fromIndex || lastMatchIndex < 0) { return -1; @@ -743,7 +776,7 @@ static int lastIndexOfString(Node location, TruffleStringIterator aIt, TruffleSt aIt.setRawIndex(lastMatchByteIndex); int bSecondIndex = bIt.getRawIndex(); while (aIt.hasPrevious() && aCodepointIndex >= toIndex) { - if (prevNodeA.execute(aIt) == bFirstCodePoint) { + if (prevNodeA.execute(node, aIt) == bFirstCodePoint) { if (!bIt.hasPrevious()) { return aCodepointIndex; } @@ -753,37 +786,37 @@ static int lastIndexOfString(Node location, TruffleStringIterator aIt, TruffleSt if (!aIt.hasPrevious()) { return -1; } - if (prevNodeA.execute(aIt) != prevNodeB.execute(bIt)) { + if (prevNodeA.execute(node, aIt) != prevNodeB.execute(node, bIt)) { break; } aCurCodePointIndex--; if (!bIt.hasPrevious() && aCurCodePointIndex >= toIndex) { return aCurCodePointIndex; } - TStringConstants.truffleSafePointPoll(location, aCurCodePointIndex); + TStringConstants.truffleSafePointPoll(node, aCurCodePointIndex); } aIt.setRawIndex(aCurIndex); bIt.setRawIndex(bSecondIndex); } aCodepointIndex--; - TStringConstants.truffleSafePointPoll(location, aCodepointIndex); + TStringConstants.truffleSafePointPoll(node, aCodepointIndex); } return -1; } - static int lastByteIndexOfString(Node location, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromByteIndex, int toByteIndex, NextNode nextNodeA, PreviousNode prevNodeA, - PreviousNode prevNodeB) { + static int lastByteIndexOfString(Node node, TruffleStringIterator aIt, TruffleStringIterator bIt, int fromByteIndex, int toByteIndex, InternalNextNode nextNodeA, InternalPreviousNode prevNodeA, + InternalPreviousNode prevNodeB) { if (!bIt.hasPrevious()) { return fromByteIndex; } - int bFirstCodePoint = prevNodeB.execute(bIt); + int bFirstCodePoint = prevNodeB.execute(node, bIt); int lastMatchByteIndex = -1; int loopCount = 0; while (aIt.getRawIndex() < fromByteIndex && aIt.hasNext()) { - if (nextNodeA.execute(aIt) == bFirstCodePoint) { + if (nextNodeA.execute(node, aIt) == bFirstCodePoint) { lastMatchByteIndex = aIt.getRawIndex(); } - TStringConstants.truffleSafePointPoll(location, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } if (aIt.getRawIndex() < fromByteIndex || lastMatchByteIndex < 0) { return -1; @@ -791,7 +824,7 @@ static int lastByteIndexOfString(Node location, TruffleStringIterator aIt, Truff aIt.setRawIndex(lastMatchByteIndex); int bSecondIndex = bIt.getRawIndex(); while (aIt.hasPrevious() && aIt.getRawIndex() > toByteIndex) { - if (prevNodeA.execute(aIt) == bFirstCodePoint) { + if (prevNodeA.execute(node, aIt) == bFirstCodePoint) { if (!bIt.hasPrevious()) { return aIt.getRawIndex(); } @@ -800,18 +833,18 @@ static int lastByteIndexOfString(Node location, TruffleStringIterator aIt, Truff if (!aIt.hasPrevious()) { return -1; } - if (prevNodeA.execute(aIt) != prevNodeB.execute(bIt)) { + if (prevNodeA.execute(node, aIt) != prevNodeB.execute(node, bIt)) { break; } if (!bIt.hasPrevious() && aIt.getRawIndex() >= toByteIndex) { return aIt.getRawIndex(); } - TStringConstants.truffleSafePointPoll(location, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } aIt.setRawIndex(aCurIndex); bIt.setRawIndex(bSecondIndex); } - TStringConstants.truffleSafePointPoll(location, ++loopCount); + TStringConstants.truffleSafePointPoll(node, ++loopCount); } return -1; } From 069fda6c9d01f36fa0eb0384373185f063695f0d Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sat, 3 Dec 2022 23:03:12 +0100 Subject: [PATCH 192/312] Disable selected DSL warnings for Sulong. (GR-42838) --- .../llvm/nativemode/runtime/package-info.java | 34 ++++++++++ .../truffle/llvm/nfi/SulongNFIRootNode.java | 2 +- .../DebugExprShortCircuitEvaluationNode.java | 2 +- .../debugexpr/nodes/DebugExprTernaryNode.java | 2 +- .../debug/debugexpr/nodes/package-info.java | 34 ++++++++++ .../llvm/runtime/debug/package-info.java | 34 ++++++++++ .../runtime/debug/scope/package-info.java | 34 ++++++++++ .../llvm/runtime/debug/type/package-info.java | 34 ++++++++++ .../runtime/debug/value/package-info.java | 34 ++++++++++ .../llvm/runtime/floating/package-info.java | 34 ++++++++++ .../runtime/interop/access/package-info.java | 34 ++++++++++ .../runtime/interop/convert/package-info.java | 34 ++++++++++ .../runtime/interop/export/package-info.java | 34 ++++++++++ .../runtime/interop/nfi/package-info.java | 34 ++++++++++ .../llvm/runtime/interop/package-info.java | 34 ++++++++++ .../library/internal/package-info.java | 34 ++++++++++ .../llvm/runtime/memory/package-info.java | 34 ++++++++++ .../llvm/runtime/nodes/api/package-info.java | 34 ++++++++++ .../runtime/nodes/asm/LLVMAMD64AdcNode.java | 10 +-- .../runtime/nodes/asm/LLVMAMD64BsfNode.java | 8 +-- .../runtime/nodes/asm/LLVMAMD64BsrNode.java | 8 +-- .../nodes/asm/LLVMAMD64CmpXchgNode.java | 10 +-- .../runtime/nodes/asm/LLVMAMD64LoadFlags.java | 26 ++++---- .../llvm/runtime/nodes/asm/package-info.java | 34 ++++++++++ .../nodes/asm/support/package-info.java | 34 ++++++++++ .../asm/syscall/LLVMAMD64SyscallMmapNode.java | 4 +- .../nodes/asm/syscall/package-info.java | 34 ++++++++++ .../nodes/asm/syscall/posix/package-info.java | 34 ++++++++++ .../llvm/runtime/nodes/cast/package-info.java | 34 ++++++++++ .../runtime/nodes/control/LLVMSwitchNode.java | 6 +- .../runtime/nodes/func/LLVMDispatchNode.java | 32 ++++++---- .../llvm/runtime/nodes/func/package-info.java | 34 ++++++++++ .../nodes/intrinsics/c/package-info.java | 34 ++++++++++ .../intrinsics/handles/package-info.java | 34 ++++++++++ .../interop/LLVMPolyglotBufferInfo.java | 4 +- .../LLVMPolyglotInstantFromTimeNode.java | 2 +- .../interop/LLVMPolyglotNativeBufferInfo.java | 8 +-- .../LLVMPolyglotTimeZoneFromIdNode.java | 2 +- .../LLVMPolyglotTimeZoneGetIdNode.java | 2 +- .../intrinsics/interop/package-info.java | 34 ++++++++++ .../interop/typed/package-info.java | 34 ++++++++++ .../llvm/aarch64/darwin/package-info.java | 34 ++++++++++ .../linux/LLVMLinuxAarch64VaListStorage.java | 2 +- .../llvm/aarch64/linux/package-info.java | 34 ++++++++++ .../intrinsics/llvm/arith/package-info.java | 34 ++++++++++ .../intrinsics/llvm/debug/package-info.java | 34 ++++++++++ .../nodes/intrinsics/llvm/package-info.java | 34 ++++++++++ .../intrinsics/llvm/va/LLVMVaListStorage.java | 64 +++++++++---------- .../intrinsics/llvm/va/package-info.java | 34 ++++++++++ .../llvm/x86/LLVMX86_64VaListStorage.java | 2 +- .../intrinsics/llvm/x86/package-info.java | 34 ++++++++++ .../intrinsics/llvm/x86_win/package-info.java | 34 ++++++++++ .../multithreading/package-info.java | 34 ++++++++++ .../nodes/intrinsics/rust/package-info.java | 34 ++++++++++ .../nodes/intrinsics/sulong/package-info.java | 34 ++++++++++ .../runtime/nodes/literals/package-info.java | 34 ++++++++++ .../memory/AllocateGlobalsBlockNode.java | 2 +- .../nodes/memory/LLVMFenceExpressionNode.java | 2 +- .../memory/ManagedMemMoveHelperNode.java | 2 +- .../nodes/memory/NativeProfiledMemMove.java | 6 +- .../nodes/memory/load/package-info.java | 34 ++++++++++ .../nodes/memory/move/package-info.java | 34 ++++++++++ .../runtime/nodes/memory/package-info.java | 34 ++++++++++ .../nodes/memory/rmw/package-info.java | 34 ++++++++++ .../nodes/memory/store/package-info.java | 34 ++++++++++ .../llvm/runtime/nodes/op/package-info.java | 34 ++++++++++ .../runtime/nodes/others/LLVMSelectNode.java | 20 +++--- .../nodes/others/LLVMVectorSelectNode.java | 24 +++---- .../runtime/nodes/others/package-info.java | 34 ++++++++++ .../llvm/runtime/nodes/util/package-info.java | 34 ++++++++++ .../llvm/runtime/nodes/vars/package-info.java | 34 ++++++++++ .../nodes/vector/LLVMShuffleVectorNode.java | 22 +++---- .../runtime/nodes/vector/package-info.java | 34 ++++++++++ .../truffle/llvm/runtime/package-info.java | 34 ++++++++++ .../llvm/runtime/pointer/package-info.java | 34 ++++++++++ 75 files changed, 1807 insertions(+), 133 deletions(-) create mode 100644 sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/scope/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/type/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/value/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/floating/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/access/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/export/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/nfi/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/library/internal/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/memory/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/support/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/posix/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/cast/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/c/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/handles/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/typed/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/darwin/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/arith/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/debug/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86_win/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/multithreading/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/rust/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/sulong/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/literals/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/load/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/move/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/rmw/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/store/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/op/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/package-info.java create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/package-info.java diff --git a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/package-info.java b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/package-info.java new file mode 100644 index 000000000000..297e3285bb94 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.nativemode.runtime; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java b/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java index a158f3a7a2ed..c0dcc6bfd9b2 100644 --- a/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java @@ -69,7 +69,7 @@ CallTarget execute() { this.parseSource = new ParseSourceNode(sulongSource); } - @Specialization(guards = "call.getCallTarget() == parsedSource") + @Specialization(guards = "call.getCallTarget() == parsedSource", limit = "3") Object doCached(CallTarget parsedSource, @Cached(parameters = "parsedSource") DirectCallNode call) { assert call.getCallTarget() == parsedSource; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java index 76569121686d..d174d76c55b8 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java @@ -44,7 +44,7 @@ public abstract class DebugExprShortCircuitEvaluationNode extends LLVMExpression @Child private ShortCircuitOpNode op; - private final ConditionProfile evaluateRightProfile = ConditionProfile.createCountingProfile(); + private final ConditionProfile evaluateRightProfile = ConditionProfile.create(); public DebugExprShortCircuitEvaluationNode(LLVMExpressionNode leftNode, LLVMExpressionNode rightNode, ShortCircuitOpNode op) { this.leftNode = leftNode; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java index 013a2c437a41..207b07d3164a 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java @@ -49,7 +49,7 @@ public abstract class DebugExprTernaryNode extends LLVMExpressionNode { public DebugExprTernaryNode(LLVMExpressionNode thenNode, LLVMExpressionNode elseNode) { this.thenNode = thenNode; this.elseNode = elseNode; - this.conditionProfile = ConditionProfile.createCountingProfile(); + this.conditionProfile = ConditionProfile.create(); } @Specialization diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/package-info.java new file mode 100644 index 000000000000..6e241042fad9 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.debug.debugexpr.nodes; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/package-info.java new file mode 100644 index 000000000000..468a0aaa0255 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.debug; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/scope/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/scope/package-info.java new file mode 100644 index 000000000000..8ca011b2a0ec --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/scope/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.debug.scope; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/type/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/type/package-info.java new file mode 100644 index 000000000000..5df480519b08 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/type/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.debug.type; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/value/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/value/package-info.java new file mode 100644 index 000000000000..3b7a21e35dc7 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/value/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.debug.value; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/floating/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/floating/package-info.java new file mode 100644 index 000000000000..7e4b5fb590e5 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/floating/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.floating; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/access/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/access/package-info.java new file mode 100644 index 000000000000..b38ec130721f --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/access/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.interop.access; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/package-info.java new file mode 100644 index 000000000000..f14ad0474735 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/convert/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.interop.convert; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/export/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/export/package-info.java new file mode 100644 index 000000000000..95b2867fa9ff --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/export/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.interop.export; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/nfi/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/nfi/package-info.java new file mode 100644 index 000000000000..69b04a9a93fa --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/nfi/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.interop.nfi; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/package-info.java new file mode 100644 index 000000000000..ef8e70b8d3dc --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.interop; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/library/internal/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/library/internal/package-info.java new file mode 100644 index 000000000000..f55205a50bd4 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/library/internal/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.library.internal; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/memory/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/memory/package-info.java new file mode 100644 index 000000000000..536ed0add7ff --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/memory/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.memory; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/package-info.java new file mode 100644 index 000000000000..e11ee05e8b89 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.api; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java index 3b52c09e6b0d..653d788de996 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java @@ -32,9 +32,9 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64UpdateFlagsNode.LLVMAMD64UpdateCPZSOFlagsNode; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; +import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64UpdateFlagsNode.LLVMAMD64UpdateCPZSOFlagsNode; @NodeChild("left") @NodeChild("right") @@ -42,9 +42,9 @@ public abstract class LLVMAMD64AdcNode extends LLVMExpressionNode { @Child protected LLVMAMD64UpdateCPZSOFlagsNode flags; - protected final ConditionProfile noCfProfile = ConditionProfile.createCountingProfile(); - protected final ConditionProfile smallLeftProfile = ConditionProfile.createCountingProfile(); - protected final ConditionProfile smallRightProfile = ConditionProfile.createCountingProfile(); + protected final CountingConditionProfile noCfProfile = CountingConditionProfile.create(); + protected final CountingConditionProfile smallLeftProfile = CountingConditionProfile.create(); + protected final CountingConditionProfile smallRightProfile = CountingConditionProfile.create(); private static boolean carry(byte left, byte right) { byte result = (byte) (left + right); diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java index 414e3864e242..98ad25a7acda 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java @@ -32,19 +32,19 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64WriteBooleanNode; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; +import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64WriteBooleanNode; @NodeChild("src") @NodeChild("dst") public abstract class LLVMAMD64BsfNode extends LLVMExpressionNode { @Child protected LLVMAMD64WriteBooleanNode writeZFNode; - protected final ConditionProfile profile; + protected final CountingConditionProfile profile; public LLVMAMD64BsfNode(LLVMAMD64WriteBooleanNode writeZFNode) { this.writeZFNode = writeZFNode; - profile = ConditionProfile.createCountingProfile(); + profile = CountingConditionProfile.create(); } public abstract static class LLVMAMD64BsfwNode extends LLVMAMD64BsfNode { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java index b8c8d97b2d34..9274e8e1ba41 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java @@ -32,19 +32,19 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64WriteBooleanNode; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; +import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64WriteBooleanNode; @NodeChild("src") @NodeChild("dst") public abstract class LLVMAMD64BsrNode extends LLVMExpressionNode { @Child protected LLVMAMD64WriteBooleanNode writeZFNode; - protected final ConditionProfile profile; + protected final CountingConditionProfile profile; public LLVMAMD64BsrNode(LLVMAMD64WriteBooleanNode writeZFNode) { this.writeZFNode = writeZFNode; - profile = ConditionProfile.createCountingProfile(); + profile = CountingConditionProfile.create(); } public abstract static class LLVMAMD64BsrwNode extends LLVMAMD64BsrNode { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java index 0046be07c71e..18a71e5d591f 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java @@ -34,12 +34,12 @@ import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; +import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; +import com.oracle.truffle.llvm.runtime.nodes.api.LLVMStatementNode; import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64UpdateFlagsNode.LLVMAMD64UpdateCPAZSOFlagsNode; import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64WriteValueNode; import com.oracle.truffle.llvm.runtime.nodes.op.ToComparableValue; -import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; -import com.oracle.truffle.llvm.runtime.nodes.api.LLVMStatementNode; import com.oracle.truffle.llvm.runtime.nodes.op.ToComparableValueNodeGen; import com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; @@ -53,13 +53,13 @@ public abstract class LLVMAMD64CmpXchgNode extends LLVMStatementNode { @Child protected LLVMAMD64WriteValueNode out1; @Child protected LLVMAMD64WriteValueNode out2; - protected final ConditionProfile profile; + protected final CountingConditionProfile profile; private LLVMAMD64CmpXchgNode(LLVMAMD64UpdateCPAZSOFlagsNode flags, LLVMAMD64WriteValueNode out1, LLVMAMD64WriteValueNode out2) { this.flags = flags; this.out1 = out1; this.out2 = out2; - profile = ConditionProfile.createCountingProfile(); + profile = CountingConditionProfile.create(); } public abstract static class LLVMAMD64CmpXchgbNode extends LLVMAMD64CmpXchgNode { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java index 7917c226da8a..f288f54afebc 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java @@ -32,9 +32,9 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64Flags; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; +import com.oracle.truffle.llvm.runtime.nodes.asm.support.LLVMAMD64Flags; public abstract class LLVMAMD64LoadFlags extends LLVMExpressionNode { @NodeChild(value = "cf", type = LLVMExpressionNode.class) @@ -45,11 +45,11 @@ public abstract class LLVMAMD64LoadFlags extends LLVMExpressionNode { public abstract static class LLVMAMD64LahfNode extends LLVMAMD64LoadFlags { @Specialization protected byte doI8(boolean cf, boolean pf, boolean af, boolean zf, boolean sf, - @Cached("createCountingProfile()") ConditionProfile profileCF, - @Cached("createCountingProfile()") ConditionProfile profilePF, - @Cached("createCountingProfile()") ConditionProfile profileAF, - @Cached("createCountingProfile()") ConditionProfile profileZF, - @Cached("createCountingProfile()") ConditionProfile profileSF) { + @Cached CountingConditionProfile profileCF, + @Cached CountingConditionProfile profilePF, + @Cached CountingConditionProfile profileAF, + @Cached CountingConditionProfile profileZF, + @Cached CountingConditionProfile profileSF) { byte flags = 0; if (profileCF.profile(cf)) { flags |= (byte) (1 << LLVMAMD64Flags.CF); @@ -77,15 +77,15 @@ protected byte doI8(boolean cf, boolean pf, boolean af, boolean zf, boolean sf, @NodeChild(value = "sf", type = LLVMExpressionNode.class) @NodeChild(value = "of", type = LLVMExpressionNode.class) public abstract static class LLVMAMD64ReadFlagswNode extends LLVMAMD64LoadFlags { - private final ConditionProfile profileOF = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profileOF = CountingConditionProfile.create(); @Specialization protected short doI16(boolean cf, boolean pf, boolean af, boolean zf, boolean sf, boolean of, - @Cached("createCountingProfile()") ConditionProfile profileCF, - @Cached("createCountingProfile()") ConditionProfile profilePF, - @Cached("createCountingProfile()") ConditionProfile profileAF, - @Cached("createCountingProfile()") ConditionProfile profileZF, - @Cached("createCountingProfile()") ConditionProfile profileSF) { + @Cached CountingConditionProfile profileCF, + @Cached CountingConditionProfile profilePF, + @Cached CountingConditionProfile profileAF, + @Cached CountingConditionProfile profileZF, + @Cached CountingConditionProfile profileSF) { short flags = 0; if (profileCF.profile(cf)) { flags |= (short) (1 << LLVMAMD64Flags.CF); diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/package-info.java new file mode 100644 index 000000000000..29b6d84a6f10 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.asm; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/support/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/support/package-info.java new file mode 100644 index 000000000000..ca1a8c9d1f24 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/support/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.asm.support; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java index 346fa7727f6d..9ba99c2983ae 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java @@ -30,7 +30,7 @@ package com.oracle.truffle.llvm.runtime.nodes.asm.syscall; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.memory.LLVMSyscallOperationNode; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; @@ -41,7 +41,7 @@ public final String getName() { return "mmap"; } - private final ConditionProfile mapAnonymousProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile mapAnonymousProfile = CountingConditionProfile.create(); /** * @param addr diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/package-info.java new file mode 100644 index 000000000000..01a0393e0790 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.asm.syscall; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/posix/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/posix/package-info.java new file mode 100644 index 000000000000..20f9d5fd7977 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/posix/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.asm.syscall.posix; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/cast/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/cast/package-info.java new file mode 100644 index 000000000000..3ccaaadd2df3 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/cast/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.cast; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java index 3600666cb573..9aa7bab75f69 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java @@ -36,7 +36,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.GenerateWrapper; import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.api.profiles.InlinedExactClassProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMControlFlowNode; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMStatementNode; @@ -79,8 +79,8 @@ public LLVMSwitchNodeImpl(int[] successors, LLVMStatementNode[] phiNodes, LLVMEx } @Specialization - public Object doCondition(Object cond, @Cached("createClassProfile()") ValueProfile conditionValueClass) { - return conditionValueClass.profile(cond); + public Object doCondition(Object cond, @Cached InlinedExactClassProfile conditionValueClass) { + return conditionValueClass.profile(this, cond); } @Override diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java index 6b4b47863c52..884bcaa57d47 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java @@ -33,6 +33,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; @@ -46,6 +47,7 @@ import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.llvm.runtime.CommonNodeFactory; @@ -99,17 +101,20 @@ protected LLVMDispatchNode(FunctionType type, LLVMFunction llvmFunction) { // llvmFunction.getFixedCode() to return the intrinsic. // Therefore, the pre-initialization must be postponed to the AOT preparation stage // using the AOTInitHelper. - aotInitHelper = new AOTInitHelper((language, root) -> { - if (llvmFunction != null) { - if (llvmFunction.getFixedCode() != null && llvmFunction.getFixedCode().isIntrinsicFunctionSlowPath()) { - LLVMDispatchNode.this.aotFixedIntrinsicFunction = llvmFunction; - llvmFunction.getFixedCode().getIntrinsicSlowPath().cachedCallTarget(type); + aotInitHelper = new AOTInitHelper(new GenerateAOT.Provider() { + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + if (llvmFunction != null) { + if (llvmFunction.getFixedCode() != null && llvmFunction.getFixedCode().isIntrinsicFunctionSlowPath()) { + LLVMDispatchNode.this.aotFixedIntrinsicFunction = llvmFunction; + llvmFunction.getFixedCode().getIntrinsicSlowPath().cachedCallTarget(type); + } } + aot = true; + // Throw the helper AOT init node away as it is used during the AOT preparation + // stage only + aotInitHelper = null; } - aot = true; - // Throw the helper AOT init node away as it is used during the AOT preparation - // stage only - aotInitHelper = null; }); // Early parsing of the function's signature for the sake of the AOT preparation @@ -129,9 +134,12 @@ protected LLVMDispatchNode(FunctionType type, LLVMFunction llvmFunction) { throw new RuntimeException(e); } } else { - aotInitHelper = new AOTInitHelper((language, root) -> { - aot = true; - aotInitHelper = null; + aotInitHelper = new AOTInitHelper(new GenerateAOT.Provider() { + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + aot = true; + aotInitHelper = null; + } }); } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/package-info.java new file mode 100644 index 000000000000..1a0364a16e77 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.func; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/c/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/c/package-info.java new file mode 100644 index 000000000000..0c1d741974d1 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/c/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.c; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/handles/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/handles/package-info.java new file mode 100644 index 000000000000..da4559cd8905 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/handles/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.handles; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotBufferInfo.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotBufferInfo.java index 83662acf43ae..d7d3fe315806 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotBufferInfo.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotBufferInfo.java @@ -61,7 +61,7 @@ public abstract static class HasBufferElements extends LLVMPolyglotBufferInfo { @GenerateAOT.Exclude @Specialization - public boolean executeNative(LLVMNativePointer pointer, + public boolean doNative(LLVMNativePointer pointer, @CachedLibrary(limit = "3") InteropLibrary interop) { return interop.hasBufferElements(pointer); } @@ -76,7 +76,7 @@ public boolean nonForeignHasElements(LLVMManagedPointer pointer, @GenerateAOT.Exclude @Specialization(guards = "foreignsLib.isForeign(pointer)", limit = "3") - public boolean executeManaged(LLVMManagedPointer pointer, + public boolean doManaged(LLVMManagedPointer pointer, @Cached LLVMAsForeignNode foreign, @SuppressWarnings("unused") @CachedLibrary("pointer") LLVMAsForeignLibrary foreignsLib, @CachedLibrary(limit = "3") InteropLibrary interop) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotInstantFromTimeNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotInstantFromTimeNode.java index 5dada0e67ee3..dfaaf06c8545 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotInstantFromTimeNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotInstantFromTimeNode.java @@ -55,7 +55,7 @@ private Object instantOfEpochSecond(long epochSecond) { } @Specialization - public Object executeLong(long epochSecond) { + public Object doLong(long epochSecond) { return LLVMManagedPointer.create(instantOfEpochSecond(epochSecond)); } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotNativeBufferInfo.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotNativeBufferInfo.java index 280150254c27..a7b66662d993 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotNativeBufferInfo.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotNativeBufferInfo.java @@ -56,12 +56,12 @@ public abstract static class HasBufferElements extends LLVMPolyglotNativeBufferI public abstract boolean execute(LLVMPointer pointer); @Specialization - public boolean executeNative(LLVMNativePointer pointer) { + public boolean doNative(LLVMNativePointer pointer) { return isNativeBuffer(pointer); } @Specialization(guards = "!foreignsLib.isForeign(pointer)") - public boolean executeNonForeign(LLVMManagedPointer pointer, + public boolean doNonForeign(LLVMManagedPointer pointer, @SuppressWarnings("unused") @CachedLibrary(limit = "3") LLVMAsForeignLibrary foreignsLib) { return isNativeBuffer(pointer); } @@ -83,7 +83,7 @@ public boolean isNativeBufferWritable(LLVMNativePointer impl) { } @Specialization(guards = {"!foreignsLib.isForeign(pointer)", "isNativeBuffer(pointer)"}) - public boolean executeNonForeign(LLVMManagedPointer pointer, + public boolean doNonForeign(LLVMManagedPointer pointer, @SuppressWarnings("unused") @CachedLibrary(limit = "3") LLVMAsForeignLibrary foreignsLib) { return asBufferType(pointer).isWritable(); } @@ -105,7 +105,7 @@ public long getNativeBufferSize(LLVMNativePointer impl) { } @Specialization(guards = {"!foreignsLib.isForeign(pointer)", "isNativeBuffer(pointer)"}) - public long executeNonForeign(LLVMManagedPointer pointer, + public long doNonForeign(LLVMManagedPointer pointer, @SuppressWarnings("unused") @CachedLibrary(limit = "3") LLVMAsForeignLibrary foreignsLib) { return asBufferType(pointer).getSize(); } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneFromIdNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneFromIdNode.java index 2ba52a51cecd..e608ed2a41e6 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneFromIdNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneFromIdNode.java @@ -60,7 +60,7 @@ private LLVMTimeZoneValue timeZoneOfString(String timeZone) { @Specialization @GenerateAOT.Exclude - public Object execute(LLVMManagedPointer pointer, + public Object doDefault(LLVMManagedPointer pointer, @Cached LLVMAsForeignNode foreign, @Cached BranchProfile exception, @CachedLibrary(limit = "3") InteropLibrary library) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneGetIdNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneGetIdNode.java index 27b07ac41bb1..718a0c6c00d1 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneGetIdNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/LLVMPolyglotTimeZoneGetIdNode.java @@ -49,7 +49,7 @@ public abstract class LLVMPolyglotTimeZoneGetIdNode extends LLVMExpressionNode { @Specialization @GenerateAOT.Exclude - public LLVMManagedPointer executeForeign(LLVMManagedPointer object, + public LLVMManagedPointer doForeign(LLVMManagedPointer object, @Cached LLVMAsForeignNode foreign, @Cached BranchProfile profile, @CachedLibrary(limit = "3") InteropLibrary interop) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/package-info.java new file mode 100644 index 000000000000..b5c287755e4c --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.interop; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/typed/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/typed/package-info.java new file mode 100644 index 000000000000..6e0e8f02e37e --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/interop/typed/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.interop.typed; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/darwin/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/darwin/package-info.java new file mode 100644 index 000000000000..b75e5c1099a4 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/darwin/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.aarch64.darwin; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/LLVMLinuxAarch64VaListStorage.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/LLVMLinuxAarch64VaListStorage.java index 0627339af790..d20b2e4b4aae 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/LLVMLinuxAarch64VaListStorage.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/LLVMLinuxAarch64VaListStorage.java @@ -765,7 +765,7 @@ Object shift(Type type, @SuppressWarnings("unused") Frame frame, @CachedLibrary(limit = "1") LLVMManagedReadLibrary readLib, @CachedLibrary(limit = "1") LLVMManagedWriteLibrary writeLib, @Cached BranchProfile regAreaProfile, - @Cached("createBinaryProfile()") ConditionProfile isNativizedProfile) { + @Cached ConditionProfile isNativizedProfile) { int regSaveOffs = 0; int regSaveStep = 0; boolean lookIntoRegSaveArea = true; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/package-info.java new file mode 100644 index 000000000000..e2206c26d9d4 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/linux/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.aarch64.linux; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/arith/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/arith/package-info.java new file mode 100644 index 000000000000..36fc7505f9b4 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/arith/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.arith; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/debug/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/debug/package-info.java new file mode 100644 index 000000000000..dfa2f849b771 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/debug/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.debug; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/package-info.java new file mode 100644 index 000000000000..9513f357f6e2 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/LLVMVaListStorage.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/LLVMVaListStorage.java index 350f783fc2f6..507e23d296dc 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/LLVMVaListStorage.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/LLVMVaListStorage.java @@ -827,7 +827,7 @@ byte byteConversion(Byte x, @SuppressWarnings("unused") int offset) { } @Specialization - byte shortConversion(Short x, int offset, @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + byte shortConversion(Short x, int offset, @Cached ConditionProfile conditionProfile) { if (conditionProfile.profile(offset == 0)) { return x.byteValue(); } else { @@ -838,8 +838,8 @@ byte shortConversion(Short x, int offset, @Cached("createBinaryProfile()") Condi @Specialization byte intConversion(Integer x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { if (conditionProfile1.profile(offset < 2)) { return shortConversion(x.shortValue(), offset, conditionProfile2); } else { @@ -849,9 +849,9 @@ byte intConversion(Integer x, int offset, @Specialization byte longConversion(Long x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile3) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2, + @Cached ConditionProfile conditionProfile3) { if (conditionProfile1.profile(offset < 4)) { return intConversion(x.intValue(), offset, conditionProfile2, conditionProfile3); } else { @@ -861,9 +861,9 @@ byte longConversion(Long x, int offset, @Specialization byte doubleConversion(Double x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile3) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2, + @Cached ConditionProfile conditionProfile3) { return longConversion(Double.doubleToLongBits(x), offset, conditionProfile1, conditionProfile2, conditionProfile3); } @@ -875,8 +875,8 @@ byte float80Conversion(LLVM80BitFloat x, int offset) { @Specialization byte floatVectorConversion(LLVMFloatVector x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { int index = offset / 4; assert index < x.getLength(); int fi = Float.floatToIntBits((Float) x.getElement(index)); @@ -897,18 +897,18 @@ byte compoundObjectConversionManaged(LLVMVarArgCompoundValue x, int offset, @Cac @Specialization(guards = "isNativePointer(x)") byte nativePointerObjectConversion(LLVMNativePointer x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile3) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2, + @Cached ConditionProfile conditionProfile3) { return longConversion(x.asNative(), offset, conditionProfile1, conditionProfile2, conditionProfile3); } @Specialization(guards = "!isNativePointer(x)") byte managedPointerObjectConversion(LLVMManagedPointer x, int offset, @Cached ToNativePointerNode toNativePointer, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile3) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2, + @Cached ConditionProfile conditionProfile3) { LLVMNativePointer nativePointer = toNativePointer.execute(x.getObject()); return nativePointerObjectConversion(nativePointer, offset, conditionProfile1, conditionProfile2, conditionProfile3); } @@ -935,7 +935,7 @@ short shortConversion(Short x, @SuppressWarnings("unused") int offset) { } @Specialization - short intConversion(Integer x, int offset, @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + short intConversion(Integer x, int offset, @Cached ConditionProfile conditionProfile) { if (conditionProfile.profile(offset == 0)) { return x.shortValue(); } else { @@ -946,8 +946,8 @@ short intConversion(Integer x, int offset, @Cached("createBinaryProfile()") Cond @Specialization short longConversion(Long x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { if (conditionProfile1.profile(offset < 4)) { return intConversion(x.intValue(), offset, conditionProfile2); @@ -958,14 +958,14 @@ short longConversion(Long x, int offset, @Specialization short doubleConversion(Double x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { return longConversion(Double.doubleToLongBits(x), offset, conditionProfile1, conditionProfile2); } @Specialization short floatVectorConversion(LLVMFloatVector x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + @Cached ConditionProfile conditionProfile) { int index = offset / 4; assert index < x.getLength(); int fi = Float.floatToIntBits((Float) x.getElement(index)); @@ -985,16 +985,16 @@ short compoundObjectConversionManaged(LLVMVarArgCompoundValue x, int offset, @Ca @Specialization(guards = "isNativePointer(x)") short nativePointerObjectConversion(LLVMNativePointer x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { return longConversion(x.asNative(), offset, conditionProfile1, conditionProfile2); } @Specialization(guards = "!isNativePointer(x)") short managedPointerObjectConversion(LLVMManagedPointer x, int offset, @Cached ToNativePointerNode toNativePointer, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile1, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile2) { + @Cached ConditionProfile conditionProfile1, + @Cached ConditionProfile conditionProfile2) { LLVMNativePointer nativePointer = toNativePointer.execute(x.getObject()); return nativePointerObjectConversion(nativePointer, offset, conditionProfile1, conditionProfile2); } @@ -1034,7 +1034,7 @@ int floatConversion(Float x, @SuppressWarnings("unused") int offset) { } @Specialization - int longConversion(Long x, int offset, @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + int longConversion(Long x, int offset, @Cached ConditionProfile conditionProfile) { if (conditionProfile.profile(offset == 0)) { return x.intValue(); } else { @@ -1045,7 +1045,7 @@ int longConversion(Long x, int offset, @Cached("createBinaryProfile()") Conditio @Specialization int doubleConversion(Double x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + @Cached ConditionProfile conditionProfile) { return longConversion(Double.doubleToLongBits(x), offset, conditionProfile); } @@ -1070,14 +1070,14 @@ int compoundObjectConversionManaged(LLVMVarArgCompoundValue x, int offset, @Cach @Specialization(guards = "isNativePointer(x)") int nativePointerObjectConversion(LLVMNativePointer x, int offset, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + @Cached ConditionProfile conditionProfile) { return longConversion(LLVMNativePointer.cast(x).asNative(), offset, conditionProfile); } @Specialization(guards = "!isNativePointer(x)") int managedPointerObjectConversion(LLVMManagedPointer x, int offset, @Cached ToNativePointerNode toNativePointer, - @Cached("createBinaryProfile()") ConditionProfile conditionProfile) { + @Cached ConditionProfile conditionProfile) { LLVMNativePointer nativePointer = toNativePointer.execute(x.getObject()); return nativePointerObjectConversion(nativePointer, offset, conditionProfile); } @@ -1230,7 +1230,7 @@ public static final class ArgumentListExpander extends LLVMNode { private ArgumentListExpander(boolean cached, boolean unpack32) { expansionBranchProfile = cached ? BranchProfile.create() : BranchProfile.getUncached(); - noExpansionProfile = cached ? ConditionProfile.createBinaryProfile() : ConditionProfile.getUncached(); + noExpansionProfile = cached ? ConditionProfile.create() : ConditionProfile.getUncached(); if (cached) { expander = unpack32 ? Unpack32ArgumentExpanderNodeGen.create() : ArgumentExpanderNodeGen.create(); } else { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/package-info.java new file mode 100644 index 000000000000..c7711c23cb89 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/va/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.va; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/LLVMX86_64VaListStorage.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/LLVMX86_64VaListStorage.java index 3ee10dd7eb92..124715330e19 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/LLVMX86_64VaListStorage.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/LLVMX86_64VaListStorage.java @@ -587,7 +587,7 @@ Object shift(Type type, @SuppressWarnings("unused") Frame frame, @Cached LLVMPointerOffsetLoadNode load1, @Exclusive @Cached LLVMPointerOffsetStoreNode store1, @Cached LLVMPointerOffsetLoadNode regSaveAreaLoad, - @Cached("createBinaryProfile()") ConditionProfile isNativizedProfile) { + @Cached ConditionProfile isNativizedProfile) { int regSaveOffs = 0; int regSaveStep = 0; int regSaveLimit = 0; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/package-info.java new file mode 100644 index 000000000000..b1c19eda51f0 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.x86; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86_win/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86_win/package-info.java new file mode 100644 index 000000000000..ea6a72ccd850 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/x86_win/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.x86_win; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/multithreading/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/multithreading/package-info.java new file mode 100644 index 000000000000..e888cf4c7d8e --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/multithreading/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.multithreading; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/rust/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/rust/package-info.java new file mode 100644 index 000000000000..476c8337c077 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/rust/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.rust; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/sulong/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/sulong/package-info.java new file mode 100644 index 000000000000..ce7d8c0c4756 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/sulong/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.sulong; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/literals/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/literals/package-info.java new file mode 100644 index 000000000000..d074df477f37 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/literals/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.literals; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/AllocateGlobalsBlockNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/AllocateGlobalsBlockNode.java index eea35637357f..125edde7b3c0 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/AllocateGlobalsBlockNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/AllocateGlobalsBlockNode.java @@ -52,7 +52,7 @@ protected AllocateGlobalsBlockNode(long size) { @Specialization @GenerateAOT.Exclude - public LLVMPointer executeWithTarget(@Bind("getContext().getAllocateGlobalsBlockFunction()") Object allocateGlobalsBlock, + public LLVMPointer doDefault(@Bind("getContext().getAllocateGlobalsBlockFunction()") Object allocateGlobalsBlock, @CachedLibrary("allocateGlobalsBlock") InteropLibrary interop) { try { Object ret = interop.execute(allocateGlobalsBlock, size); diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/LLVMFenceExpressionNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/LLVMFenceExpressionNode.java index d787e8b084df..90b65a4e57d8 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/LLVMFenceExpressionNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/LLVMFenceExpressionNode.java @@ -37,7 +37,7 @@ public abstract class LLVMFenceExpressionNode extends LLVMExpressionNode { @Specialization - protected long execute() { + protected long doDefault() { VarHandle.fullFence(); return 0; } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/ManagedMemMoveHelperNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/ManagedMemMoveHelperNode.java index 011702877df8..76da792381e3 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/ManagedMemMoveHelperNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/ManagedMemMoveHelperNode.java @@ -319,7 +319,7 @@ int getAccessSize() { @Specialization @ExplodeLoop - long execute(LLVMManagedPointer source, int unitSize) { + long doDefault(LLVMManagedPointer source, int unitSize) { int shift = 0; long ret = 0; for (int i = 0; i < unitSize; i++) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java index 245fdc23c4d3..27f8a07b2c28 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java @@ -35,7 +35,7 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.library.internal.LLVMCopyTargetLibrary; import com.oracle.truffle.llvm.runtime.memory.LLVMMemMoveNode; import com.oracle.truffle.llvm.runtime.memory.LLVMMemory; @@ -93,7 +93,7 @@ protected void doManagedNonAliasing(LLVMManagedPointer target, LLVMManagedPointe protected void doManagedAliasing(LLVMManagedPointer target, LLVMManagedPointer source, long length, @Cached("create(target, source)") ManagedMemMoveHelperNode helper, @Cached UnitSizeNode unitSizeNode, - @Cached("createCountingProfile()") ConditionProfile canCopyForward, + @Cached CountingConditionProfile canCopyForward, @SuppressWarnings("unused") @CachedLibrary("target.getObject()") LLVMCopyTargetLibrary copyTargetLib) { if (canCopyForward.profile(Long.compareUnsigned(target.getOffset() - source.getOffset(), length) >= 0)) { copyForward(target, source, length, helper, unitSizeNode); @@ -136,7 +136,7 @@ protected void doManagedSlowPath(LLVMPointer target, LLVMPointer source, long le LLVMCopyTargetLibrary copyTargetLib = LLVMCopyTargetLibrary.getFactory().getUncached(); if (LLVMManagedPointer.isInstance(target) && LLVMManagedPointer.isInstance(source)) { // potentially aliasing - doManagedAliasing(LLVMManagedPointer.cast(target), LLVMManagedPointer.cast(source), length, helper, unitSizeNode, ConditionProfile.getUncached(), copyTargetLib); + doManagedAliasing(LLVMManagedPointer.cast(target), LLVMManagedPointer.cast(source), length, helper, unitSizeNode, CountingConditionProfile.getUncached(), copyTargetLib); } else if (LLVMManagedPointer.isInstance(target) && LLVMManagedPointer.isInstance(source) && doCustomCopy(LLVMManagedPointer.cast(target), LLVMManagedPointer.cast(source), length, copyTargetLib)) { copyTargetLib.copyFrom(LLVMManagedPointer.cast(target).getObject(), LLVMManagedPointer.cast(source).getObject(), length); diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/load/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/load/package-info.java new file mode 100644 index 000000000000..56bdbe14b64c --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/load/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.memory.load; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/move/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/move/package-info.java new file mode 100644 index 000000000000..96cf62a42090 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/move/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.memory.move; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/package-info.java new file mode 100644 index 000000000000..5101b46b94aa --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.memory; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/rmw/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/rmw/package-info.java new file mode 100644 index 000000000000..fee73b2edd09 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/rmw/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.memory.rmw; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/store/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/store/package-info.java new file mode 100644 index 000000000000..55b596c039c3 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/store/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.memory.store; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/op/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/op/package-info.java new file mode 100644 index 000000000000..61df76b5928e --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/op/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.op; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java index 0472259ca39d..37b7b918dd44 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java @@ -32,7 +32,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.floating.LLVM80BitFloat; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; @@ -44,7 +44,7 @@ public abstract class LLVMSelectNode extends LLVMExpressionNode { public abstract static class LLVMI1SelectNode extends LLVMSelectNode { @Specialization - protected boolean doOp(boolean cond, boolean trueBranch, boolean elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected boolean doOp(boolean cond, boolean trueBranch, boolean elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -52,7 +52,7 @@ protected boolean doOp(boolean cond, boolean trueBranch, boolean elseBranch, @Ca public abstract static class LLVMI8SelectNode extends LLVMSelectNode { @Specialization - protected byte doOp(boolean cond, byte trueBranch, byte elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected byte doOp(boolean cond, byte trueBranch, byte elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -60,7 +60,7 @@ protected byte doOp(boolean cond, byte trueBranch, byte elseBranch, @Cached("cre public abstract static class LLVMI16SelectNode extends LLVMSelectNode { @Specialization - protected short doOp(boolean cond, short trueBranch, short elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected short doOp(boolean cond, short trueBranch, short elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -68,7 +68,7 @@ protected short doOp(boolean cond, short trueBranch, short elseBranch, @Cached(" public abstract static class LLVMI32SelectNode extends LLVMSelectNode { @Specialization - protected int doOp(boolean cond, int trueBranch, int elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected int doOp(boolean cond, int trueBranch, int elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -76,7 +76,7 @@ protected int doOp(boolean cond, int trueBranch, int elseBranch, @Cached("create public abstract static class LLVMI64SelectNode extends LLVMSelectNode { @Specialization - protected Object doOp(boolean cond, Object trueBranch, Object elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected Object doOp(boolean cond, Object trueBranch, Object elseBranch, @Cached CountingConditionProfile conditionProfile) { assert trueBranch instanceof Long || LLVMPointer.isInstance(trueBranch); assert elseBranch instanceof Long || LLVMPointer.isInstance(elseBranch); return conditionProfile.profile(cond) ? trueBranch : elseBranch; @@ -86,7 +86,7 @@ protected Object doOp(boolean cond, Object trueBranch, Object elseBranch, @Cache public abstract static class LLVMFloatSelectNode extends LLVMSelectNode { @Specialization - protected float doOp(boolean cond, float trueBranch, float elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected float doOp(boolean cond, float trueBranch, float elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -94,7 +94,7 @@ protected float doOp(boolean cond, float trueBranch, float elseBranch, @Cached(" public abstract static class LLVMDoubleSelectNode extends LLVMSelectNode { @Specialization - protected double doOp(boolean cond, double trueBranch, double elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected double doOp(boolean cond, double trueBranch, double elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -102,7 +102,7 @@ protected double doOp(boolean cond, double trueBranch, double elseBranch, @Cache public abstract static class LLVM80BitFloatSelectNode extends LLVMSelectNode { @Specialization - protected LLVM80BitFloat doOp(boolean cond, LLVM80BitFloat trueBranch, LLVM80BitFloat elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected LLVM80BitFloat doOp(boolean cond, LLVM80BitFloat trueBranch, LLVM80BitFloat elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } @@ -110,7 +110,7 @@ protected LLVM80BitFloat doOp(boolean cond, LLVM80BitFloat trueBranch, LLVM80Bit public abstract static class LLVMGenericSelectNode extends LLVMSelectNode { @Specialization - protected Object doOp(boolean cond, Object trueBranch, Object elseBranch, @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + protected Object doOp(boolean cond, Object trueBranch, Object elseBranch, @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(cond) ? trueBranch : elseBranch; } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMVectorSelectNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMVectorSelectNode.java index eac2f614dfaf..8a8ba7301ef4 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMVectorSelectNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMVectorSelectNode.java @@ -34,7 +34,7 @@ import com.oracle.truffle.api.dsl.NodeField; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; @@ -57,7 +57,7 @@ public abstract class LLVMVectorSelectNode extends LLVMExpressionNode { @Specialization protected Object doOp(boolean condition, Object trueValue, Object elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { return conditionProfile.profile(condition) ? trueValue : elseValue; } @@ -65,7 +65,7 @@ public abstract static class LLVMI1VectorSelectNode extends LLVMVectorSelectNode @Specialization @ExplodeLoop protected LLVMI1Vector doOp(LLVMI1Vector condition, LLVMI1Vector trueValue, LLVMI1Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); boolean[] values = new boolean[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -79,7 +79,7 @@ public abstract static class LLVMI8VectorSelectNode extends LLVMVectorSelectNode @Specialization @ExplodeLoop protected LLVMI8Vector doOp(LLVMI1Vector condition, LLVMI8Vector trueValue, LLVMI8Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); byte[] values = new byte[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -93,7 +93,7 @@ public abstract static class LLVMI16VectorSelectNode extends LLVMVectorSelectNod @Specialization @ExplodeLoop protected LLVMI16Vector doOp(LLVMI1Vector condition, LLVMI16Vector trueValue, LLVMI16Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); short[] values = new short[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -107,7 +107,7 @@ public abstract static class LLVMI32VectorSelectNode extends LLVMVectorSelectNod @Specialization @ExplodeLoop protected LLVMI32Vector doOp(LLVMI1Vector condition, LLVMI32Vector trueValue, LLVMI32Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); int[] values = new int[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -121,7 +121,7 @@ public abstract static class LLVMI64VectorSelectNode extends LLVMVectorSelectNod @Specialization @ExplodeLoop protected LLVMI64Vector doOp(LLVMI1Vector condition, LLVMI64Vector trueValue, LLVMI64Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); long[] values = new long[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -133,7 +133,7 @@ protected LLVMI64Vector doOp(LLVMI1Vector condition, LLVMI64Vector trueValue, LL @Specialization @ExplodeLoop protected LLVMPointerVector doOp(LLVMI1Vector condition, LLVMI64Vector trueValue, LLVMPointerVector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); LLVMPointer[] values = new LLVMPointer[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -145,7 +145,7 @@ protected LLVMPointerVector doOp(LLVMI1Vector condition, LLVMI64Vector trueValue @Specialization @ExplodeLoop protected LLVMPointerVector doOp(LLVMI1Vector condition, LLVMPointerVector trueValue, LLVMI64Vector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); LLVMPointer[] values = new LLVMPointer[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -157,7 +157,7 @@ protected LLVMPointerVector doOp(LLVMI1Vector condition, LLVMPointerVector trueV @Specialization @ExplodeLoop protected LLVMPointerVector doOp(LLVMI1Vector condition, LLVMPointerVector trueValue, LLVMPointerVector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); LLVMPointer[] values = new LLVMPointer[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -171,7 +171,7 @@ public abstract static class LLVMFloatVectorSelectNode extends LLVMVectorSelectN @Specialization @ExplodeLoop protected LLVMFloatVector doOp(LLVMI1Vector condition, LLVMFloatVector trueValue, LLVMFloatVector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); float[] values = new float[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { @@ -185,7 +185,7 @@ public abstract static class LLVMDoubleVectorSelectNode extends LLVMVectorSelect @Specialization @ExplodeLoop protected LLVMDoubleVector doOp(LLVMI1Vector condition, LLVMDoubleVector trueValue, LLVMDoubleVector elseValue, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert condition.getLength() == getVectorLength(); double[] values = new double[getVectorLength()]; for (int i = 0; i < getVectorLength(); i++) { diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/package-info.java new file mode 100644 index 000000000000..9b0311014bab --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.others; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/package-info.java new file mode 100644 index 000000000000..b8445fbc64e1 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/util/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.util; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/package-info.java new file mode 100644 index 000000000000..f79d8a3ef1ad --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vars/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.vars; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java index 08007b255244..388cc7f6e1de 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java @@ -34,7 +34,7 @@ import com.oracle.truffle.api.dsl.NodeField; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; @@ -59,7 +59,7 @@ public abstract static class LLVMShuffleI1VectorNode extends LLVMShuffleVectorNo @Specialization @ExplodeLoop protected LLVMI1Vector doI1Vector(LLVMI1Vector leftVector, LLVMI1Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); boolean[] newValues = new boolean[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -75,7 +75,7 @@ public abstract static class LLVMShuffleI8VectorNode extends LLVMShuffleVectorNo @Specialization @ExplodeLoop protected LLVMI8Vector doI8Vector(LLVMI8Vector leftVector, LLVMI8Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); byte[] newValues = new byte[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -91,7 +91,7 @@ public abstract static class LLVMShuffleI16VectorNode extends LLVMShuffleVectorN @Specialization @ExplodeLoop protected LLVMI16Vector doI8Vector(LLVMI16Vector leftVector, LLVMI16Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); short[] newValues = new short[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -107,7 +107,7 @@ public abstract static class LLVMShuffleI32VectorNode extends LLVMShuffleVectorN @Specialization @ExplodeLoop protected LLVMI32Vector doI32Vector(LLVMI32Vector leftVector, LLVMI32Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); int[] newValues = new int[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -123,7 +123,7 @@ public abstract static class LLVMShuffleI64VectorNode extends LLVMShuffleVectorN @Specialization @ExplodeLoop protected LLVMI64Vector doI64Vector(LLVMI64Vector leftVector, LLVMI64Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); long[] newValues = new long[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -137,7 +137,7 @@ protected LLVMI64Vector doI64Vector(LLVMI64Vector leftVector, LLVMI64Vector righ @Specialization @ExplodeLoop protected LLVMPointerVector doPointerVector(LLVMPointerVector leftVector, LLVMI64Vector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); LLVMPointer[] newValues = new LLVMPointer[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -151,7 +151,7 @@ protected LLVMPointerVector doPointerVector(LLVMPointerVector leftVector, LLVMI6 @Specialization @ExplodeLoop protected LLVMPointerVector doPointerVector(LLVMI64Vector leftVector, LLVMPointerVector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); LLVMPointer[] newValues = new LLVMPointer[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -165,7 +165,7 @@ protected LLVMPointerVector doPointerVector(LLVMI64Vector leftVector, LLVMPointe @Specialization @ExplodeLoop protected LLVMPointerVector doPointerVector(LLVMPointerVector leftVector, LLVMPointerVector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); LLVMPointer[] newValues = new LLVMPointer[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -181,7 +181,7 @@ public abstract static class LLVMShuffleFloatVectorNode extends LLVMShuffleVecto @Specialization @ExplodeLoop protected LLVMFloatVector doOp(LLVMFloatVector leftVector, LLVMFloatVector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); float[] newValues = new float[getVectorLength()]; int leftVectorLength = leftVector.getLength(); @@ -197,7 +197,7 @@ public abstract static class LLVMShuffleDoubleVectorNode extends LLVMShuffleVect @Specialization @ExplodeLoop protected LLVMDoubleVector doOp(LLVMDoubleVector leftVector, LLVMDoubleVector rightVector, LLVMI32Vector maskVector, - @Cached("createCountingProfile()") ConditionProfile conditionProfile) { + @Cached CountingConditionProfile conditionProfile) { assert maskVector.getLength() == getVectorLength(); double[] newValues = new double[getVectorLength()]; int leftVectorLength = leftVector.getLength(); diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/package-info.java new file mode 100644 index 000000000000..bca17d31bd5f --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.vector; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/package-info.java new file mode 100644 index 000000000000..38fe130446d1 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/package-info.java new file mode 100644 index 000000000000..f16d0ae883d3 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/pointer/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.pointer; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; From bc9a5cad09424cd4d570eeff085e98f0ef4d0b07 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sat, 3 Dec 2022 19:50:20 +0100 Subject: [PATCH 193/312] Disable selected DSL warnings for TRegex (GR-42839) --- .../com/oracle/truffle/regex/RegexObject.java | 6 +-- .../truffle/regex/literal/package-info.java | 45 +++++++++++++++++++ .../oracle/truffle/regex/package-info.java | 45 +++++++++++++++++++ .../truffle/regex/result/package-info.java | 45 +++++++++++++++++++ .../regex/runtime/nodes/DispatchNode.java | 6 +-- .../regex/runtime/nodes/package-info.java | 45 +++++++++++++++++++ .../tregex/nodes/input/package-info.java | 45 +++++++++++++++++++ .../regex/tregex/nodes/package-info.java | 45 +++++++++++++++++++ 8 files changed, 276 insertions(+), 6 deletions(-) create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java create mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java index 23b1672280eb..cb8ae442392d 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java @@ -438,15 +438,15 @@ abstract static class ExecCompiledRegexNode extends Node { @SuppressWarnings("unused") @Specialization(guards = "receiver == cachedCallTarget", limit = "4") - static Object executeDirectCall(CallTarget receiver, Object input, int fromIndex, + static Object doDirectCall(CallTarget receiver, Object input, int fromIndex, @Cached("receiver") CallTarget cachedCallTarget, @Cached("create(cachedCallTarget)") DirectCallNode directCallNode) { return directCallNode.call(input, fromIndex); } @ReportPolymorphism.Megamorphic - @Specialization(replaces = "executeDirectCall") - static Object executeIndirectCall(CallTarget receiver, Object input, int fromIndex, + @Specialization(replaces = "doDirectCall") + static Object doIndirectCall(CallTarget receiver, Object input, int fromIndex, @Cached IndirectCallNode indirectCallNode) { return indirectCallNode.call(receiver, input, fromIndex); } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java new file mode 100644 index 000000000000..d7f750b69c0f --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex.literal; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java new file mode 100644 index 000000000000..96724d2e95ea --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java new file mode 100644 index 000000000000..2f67873c98ab --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex.result; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java index 06bf4085ea72..0317ab1716f9 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java @@ -56,14 +56,14 @@ public abstract class DispatchNode extends Node { @SuppressWarnings("unused") @Specialization(guards = {"target == cachedTarget"}) - static Object executeDirect(CallTarget target, RegexResult result, + static Object doDirect(CallTarget target, RegexResult result, @Cached("target") CallTarget cachedTarget, @Cached("create(cachedTarget)") DirectCallNode callNode) { return callNode.call(result); } - @Specialization(replaces = "executeDirect") - static Object executeIndirect(CallTarget target, RegexResult result, + @Specialization(replaces = "doDirect") + static Object doIndirect(CallTarget target, RegexResult result, @Cached IndirectCallNode callNode) { return callNode.call(target, result); } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java new file mode 100644 index 000000000000..9027ed06d7fc --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex.runtime.nodes; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java new file mode 100644 index 000000000000..a20a30af5cf6 --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex.tregex.nodes.input; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java new file mode 100644 index 000000000000..080020fc85af --- /dev/null +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +//TODO GR-42839 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.regex.tregex.nodes; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; From ea0d1da13d540e0f84081c66ed6839507011cae0 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 16:48:38 +0100 Subject: [PATCH 194/312] Disable selected DSL warnings in NFI (GR-42818) --- .../truffle/api/profiles/SealedProfile.java | 54 ------------------- .../nfi/backend/libffi/NativeBuffer.java | 2 + .../backend/libffi/SerializeArgumentNode.java | 4 ++ .../truffle/nfi/test/KeyInfoNFITest.java | 1 + .../nfi/test/RegisterPackageNFITest.java | 1 + .../nfi/test/SignatureExecuteNFITest.java | 1 + .../truffle/nfi/test/VarargsNFITest.java | 1 + .../nfi/test/parser/ParseSignatureTest.java | 2 + .../nfi/test/{ => parser}/package-info.java | 5 +- .../com/oracle/truffle/nfi/NFIClosure.java | 2 +- 10 files changed, 16 insertions(+), 57 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java rename truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/{ => parser}/package-info.java (56%) diff --git a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java b/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java deleted file mode 100644 index 6d7ae6ad29b5..000000000000 --- a/truffle/src/com.oracle.truffle.api.profiles/src/com/oracle/truffle/api/profiles/SealedProfile.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.oracle.truffle.api.profiles; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface SealedProfile { - - Class[] value(); - -} diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java index 9bcf4c06b465..458c0df0f029 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/NativeBuffer.java @@ -70,6 +70,7 @@ static final class Array extends NativeBuffer { this.content = content; } + @SuppressWarnings("static-method") @ExportMessage boolean isSerializable() { return true; @@ -87,6 +88,7 @@ void serialize(Object buffer, } } + @SuppressWarnings("static-method") @ExportMessage boolean hasBufferElements() { return true; diff --git a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java index b70c717bd185..8a14e50c3c2d 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.libffi/src/com/oracle/truffle/nfi/backend/libffi/SerializeArgumentNode.java @@ -305,11 +305,13 @@ private void setPosition(long offset, int size) throws InvalidBufferOffsetExcept } } + @SuppressWarnings("static-method") @ExportMessage boolean hasBufferElements() { return true; } + @SuppressWarnings("static-method") @ExportMessage boolean isBufferWritable() { return true; @@ -361,11 +363,13 @@ void writeBufferDouble(ByteOrder order, long offset, double value) throws Invali buffer.putDouble(value); } + @SuppressWarnings({"static-method", "unused"}) @ExportMessage byte readBufferByte(long offset) throws UnsupportedMessageException { throw UnsupportedMessageException.create(); } + @SuppressWarnings({"static-method", "unused"}) @ExportMessage(name = "readBufferShort") @ExportMessage(name = "readBufferInt") @ExportMessage(name = "readBufferLong") diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/KeyInfoNFITest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/KeyInfoNFITest.java index f2f027b61640..09065a153908 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/KeyInfoNFITest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/KeyInfoNFITest.java @@ -67,6 +67,7 @@ @RunWith(Parameterized.class) @Parameterized.UseParametersRunnerFactory(TruffleRunner.ParametersFactory.class) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class KeyInfoNFITest extends NFITest { private static void addTest(List ret, String symbol, Supplier object, String description, boolean read, boolean invoke, boolean optional) { diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/RegisterPackageNFITest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/RegisterPackageNFITest.java index 1418d95f0865..281be67bbd25 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/RegisterPackageNFITest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/RegisterPackageNFITest.java @@ -71,6 +71,7 @@ import com.oracle.truffle.tck.TruffleRunner.Inject; @RunWith(TruffleRunner.class) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class RegisterPackageNFITest extends NFITest { private static final FunctionRegistry REGISTRY = new FunctionRegistry(); diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/SignatureExecuteNFITest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/SignatureExecuteNFITest.java index b29c600cfa2c..a2b9e7291c26 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/SignatureExecuteNFITest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/SignatureExecuteNFITest.java @@ -60,6 +60,7 @@ import com.oracle.truffle.tck.TruffleRunner.Inject; @RunWith(TruffleRunner.class) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class SignatureExecuteNFITest extends NFITest { abstract static class DoDirectExecute extends Node { diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/VarargsNFITest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/VarargsNFITest.java index 5e649ce9ee17..7540461dcdc7 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/VarargsNFITest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/VarargsNFITest.java @@ -66,6 +66,7 @@ import com.oracle.truffle.tck.TruffleRunner.Inject; @RunWith(TruffleRunner.class) +@SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) public class VarargsNFITest extends NFITest { abstract static class FormatNode extends Node { diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java index a22c3a7a3e20..0bd70dab4637 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java @@ -43,6 +43,7 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropException; @@ -84,6 +85,7 @@ abstract static class InlineCacheNode extends Node { abstract Object execute(CallTarget callTarget); + @NeverDefault static DirectCallNode createInlined(CallTarget callTarget) { DirectCallNode ret = DirectCallNode.create(callTarget); ret.forceInlining(); diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java similarity index 56% rename from truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java rename to truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java index c7a71401b3bf..549f4be286aa 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/package-info.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java @@ -3,7 +3,8 @@ * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ -@SuppressPackageWarnings({"truffle-inlining", "truffle-neverdefault"}) -package com.oracle.truffle.nfi.test; +// TODO GR-42818 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault"}) +package com.oracle.truffle.nfi.test.parser; import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java index 68c570d7b212..43d82822607e 100644 --- a/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java +++ b/truffle/src/com.oracle.truffle.nfi/src/com/oracle/truffle/nfi/NFIClosure.java @@ -85,7 +85,7 @@ static DirectCallNode createDirectCall(CallTarget target) { return ret; } - @Specialization(guards = {"receiver.signature.cachedState != null", "receiver.signature.cachedState == cachedState"}) + @Specialization(guards = {"receiver.signature.cachedState != null", "receiver.signature.cachedState == cachedState"}, limit = "3") static Object doOptimizedDirect(NFIClosure receiver, Object[] args, @Cached("receiver.signature.cachedState") SignatureCachedState cachedState, @Cached("cachedState.createOptimizedClosureCall()") CallSignatureNode call) throws ArityException, UnsupportedTypeException, UnsupportedMessageException { From a173e7e656a1a3c637b6df91e4b6696b22ea03c8 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sat, 3 Dec 2022 19:51:46 +0100 Subject: [PATCH 195/312] Fix DSL warnings for wasm. --- .../src/org/graalvm/wasm/WasmInstance.java | 13 +-- .../src/org/graalvm/wasm/WasmScope.java | 14 ++-- .../org/graalvm/wasm/api/ByteArrayBuffer.java | 9 ++- .../org/graalvm/wasm/memory/WasmMemory.java | 79 +++++++++++-------- .../wasm/nodes/WasmIndirectCallNode.java | 2 + 5 files changed, 66 insertions(+), 51 deletions(-) diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmInstance.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmInstance.java index 79bca82a55c2..a5dd5f6c0e54 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmInstance.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmInstance.java @@ -48,15 +48,12 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; /** * Represents an instantiated WebAssembly module. @@ -114,8 +111,7 @@ boolean hasMembers() { @ExportMessage @TruffleBoundary - public Object readMember(String member, - @Shared("error") @Cached BranchProfile errorBranch) throws UnknownIdentifierException { + public Object readMember(String member) throws UnknownIdentifierException { ensureLinked(); final SymbolTable symbolTable = symbolTable(); final WasmFunction function = symbolTable.exportedFunctions().get(member); @@ -134,31 +130,26 @@ public Object readMember(String member, if (globalIndex != null) { return readGlobal(this, symbolTable, globalIndex); } - errorBranch.enter(); throw UnknownIdentifierException.create(member); } @ExportMessage @TruffleBoundary - public void writeMember(String member, Object value, - @Shared("error") @Cached BranchProfile errorBranch) throws UnknownIdentifierException, UnsupportedMessageException { + public void writeMember(String member, Object value) throws UnknownIdentifierException, UnsupportedMessageException { ensureLinked(); // This method works only for mutable globals. final SymbolTable symbolTable = symbolTable(); final Integer index = symbolTable.exportedGlobals().get(member); if (index == null) { - errorBranch.enter(); throw UnknownIdentifierException.create(member); } final int address = globalAddress(index); if (!(value instanceof Number)) { - errorBranch.enter(); throw UnsupportedMessageException.create(); } final boolean mutable = symbolTable.globalMutability(index) == GlobalModifier.MUTABLE; if (module().isParsed() && !mutable) { // Constant variables cannot be modified after linking. - errorBranch.enter(); throw UnsupportedMessageException.create(); } long longValue = ((Number) value).longValue(); diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmScope.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmScope.java index 477c03395e14..8732d3b5e7f4 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmScope.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/WasmScope.java @@ -40,8 +40,11 @@ */ package org.graalvm.wasm; +import java.util.Map; + import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -49,9 +52,8 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; - -import java.util.Map; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) @SuppressWarnings({"unused", "static-method"}) @@ -135,9 +137,11 @@ long getArraySize() { } @ExportMessage - Object readArrayElement(long index, @Cached BranchProfile error) throws InvalidArrayIndexException { + Object readArrayElement(long index, + @Bind("$node") Node node, + @Cached InlinedBranchProfile error) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { - error.enter(); + error.enter(node); throw InvalidArrayIndexException.create(index); } return names[(int) index]; diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/api/ByteArrayBuffer.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/api/ByteArrayBuffer.java index 3e135696a4ba..6c0700bee837 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/api/ByteArrayBuffer.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/api/ByteArrayBuffer.java @@ -41,6 +41,7 @@ package org.graalvm.wasm.api; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -48,7 +49,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) public class ByteArrayBuffer implements TruffleObject { @@ -98,9 +100,10 @@ final boolean isArrayElementInsertable(long index) { @SuppressWarnings({"unused"}) @ExportMessage public Object readArrayElement(long index, - @Cached BranchProfile errorBranch) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile errorBranch) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { - errorBranch.enter(); + errorBranch.enter(node); throw InvalidArrayIndexException.create(index); } return data[offset + (int) index]; diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/memory/WasmMemory.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/memory/WasmMemory.java index 2e705555d308..65da092b5515 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/memory/WasmMemory.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/memory/WasmMemory.java @@ -60,6 +60,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.interop.InteropLibrary; @@ -72,7 +73,7 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) public abstract class WasmMemory extends EmbedderDataHolder implements TruffleObject { @@ -440,24 +441,26 @@ final long getBufferSize() { return byteSize(); } - private void checkOffset(long byteOffset, int opLength, BranchProfile errorBranch) throws InvalidBufferOffsetException { + private void checkOffset(Node node, long byteOffset, int opLength, InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { if (byteOffset < 0 || getBufferSize() - opLength < byteOffset) { - errorBranch.enter(); + errorBranch.enter(node); throw InvalidBufferOffsetException.create(byteOffset, opLength); } } @ExportMessage final byte readBufferByte(long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Byte.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Byte.BYTES, errorBranch); return (byte) load_i32_8s(null, byteOffset); } @ExportMessage final short readBufferShort(ByteOrder order, long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Short.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Short.BYTES, errorBranch); short result = (short) load_i32_16s(null, byteOffset); if (order == ByteOrder.BIG_ENDIAN) { result = Short.reverseBytes(result); @@ -467,8 +470,9 @@ final short readBufferShort(ByteOrder order, long byteOffset, @ExportMessage final int readBufferInt(ByteOrder order, long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Integer.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Integer.BYTES, errorBranch); int result = load_i32(null, byteOffset); if (order == ByteOrder.BIG_ENDIAN) { result = Integer.reverseBytes(result); @@ -478,8 +482,9 @@ final int readBufferInt(ByteOrder order, long byteOffset, @ExportMessage final long readBufferLong(ByteOrder order, long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Long.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Long.BYTES, errorBranch); long result = load_i64(null, byteOffset); if (order == ByteOrder.BIG_ENDIAN) { result = Long.reverseBytes(result); @@ -489,8 +494,9 @@ final long readBufferLong(ByteOrder order, long byteOffset, @ExportMessage final float readBufferFloat(ByteOrder order, long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Float.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Float.BYTES, errorBranch); float result = load_f32(null, byteOffset); if (order == ByteOrder.BIG_ENDIAN) { result = Float.intBitsToFloat(Integer.reverseBytes(Float.floatToRawIntBits(result))); @@ -500,8 +506,9 @@ final float readBufferFloat(ByteOrder order, long byteOffset, @ExportMessage final double readBufferDouble(ByteOrder order, long byteOffset, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Double.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Double.BYTES, errorBranch); double result = load_f64(null, byteOffset); if (order == ByteOrder.BIG_ENDIAN) { result = Double.longBitsToDouble(Long.reverseBytes(Double.doubleToRawLongBits(result))); @@ -517,47 +524,53 @@ final boolean isBufferWritable() { @ExportMessage final void writeBufferByte(long byteOffset, byte value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Byte.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Byte.BYTES, errorBranch); store_i32_8(null, byteOffset, value); } @ExportMessage final void writeBufferShort(ByteOrder order, long byteOffset, short value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Short.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Short.BYTES, errorBranch); short actualValue = (order == ByteOrder.LITTLE_ENDIAN) ? value : Short.reverseBytes(value); store_i32_16(null, byteOffset, actualValue); } @ExportMessage final void writeBufferInt(ByteOrder order, long byteOffset, int value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Integer.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Integer.BYTES, errorBranch); int actualValue = (order == ByteOrder.LITTLE_ENDIAN) ? value : Integer.reverseBytes(value); store_i32(null, byteOffset, actualValue); } @ExportMessage final void writeBufferLong(ByteOrder order, long byteOffset, long value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Long.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Long.BYTES, errorBranch); long actualValue = (order == ByteOrder.LITTLE_ENDIAN) ? value : Long.reverseBytes(value); store_i64(null, byteOffset, actualValue); } @ExportMessage final void writeBufferFloat(ByteOrder order, long byteOffset, float value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Float.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Float.BYTES, errorBranch); float actualValue = (order == ByteOrder.LITTLE_ENDIAN) ? value : Float.intBitsToFloat(Integer.reverseBytes(Float.floatToRawIntBits(value))); store_f32(null, byteOffset, actualValue); } @ExportMessage final void writeBufferDouble(ByteOrder order, long byteOffset, double value, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidBufferOffsetException { - checkOffset(byteOffset, Double.BYTES, errorBranch); + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidBufferOffsetException { + checkOffset(node, byteOffset, Double.BYTES, errorBranch); double actualValue = (order == ByteOrder.LITTLE_ENDIAN) ? value : Double.longBitsToDouble(Long.reverseBytes(Double.doubleToRawLongBits(value))); store_f64(null, byteOffset, actualValue); } @@ -590,9 +603,10 @@ final boolean isArrayElementInsertable(long address) { @ExportMessage public Object readArrayElement(long address, - @Shared("errorBranch") @Cached BranchProfile errorBranch) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidArrayIndexException { if (!isArrayElementReadable(address)) { - errorBranch.enter(); + errorBranch.enter(node); throw InvalidArrayIndexException.create(address); } return load_i32_8u(null, address); @@ -600,18 +614,19 @@ public Object readArrayElement(long address, @ExportMessage public void writeArrayElement(long address, Object value, + @Bind("$node") Node node, @CachedLibrary(limit = "3") InteropLibrary valueLib, - @Shared("errorBranch") @Cached BranchProfile errorBranch) + @Shared("errorBranch") @Cached InlinedBranchProfile errorBranch) throws InvalidArrayIndexException, UnsupportedMessageException, UnsupportedTypeException { if (!isArrayElementModifiable(address)) { - errorBranch.enter(); + errorBranch.enter(node); throw InvalidArrayIndexException.create(address); } byte rawValue; if (valueLib.fitsInByte(value)) { rawValue = valueLib.asByte(value); } else { - errorBranch.enter(); + errorBranch.enter(node); throw UnsupportedTypeException.create(new Object[]{value}, "Only bytes can be stored into WebAssembly memory."); } store_i32_8(null, address, rawValue); diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java index 2ac00c4e0bdf..e7807b77227b 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.DirectCallNode; @@ -49,6 +50,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateUncached +@GenerateInline(false) public abstract class WasmIndirectCallNode extends Node { static final int INLINE_CACHE_LIMIT = 5; From eac39a165c0bf29ce25835474330fb0392762d86 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 18:24:46 +0000 Subject: [PATCH 196/312] Improve changelog entry. --- truffle/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 0678328c222a..4996997f1351 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -19,7 +19,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-42674 It has been documented that methods `TruffleLanguage.Env#getPublicTruffleFile`, `TruffleLanguage.Env#getInternalTruffleFile`, `TruffleLanguage.Env#getTruffleFileInternal` and `TruffleInstrument.Env#getPublicTruffleFile` can throw `IllegalArgumentException` when the path string cannot be converted to a `Path` or uri preconditions required by the `FileSystem` do not hold. * GR-31342 Implemented several new features for Truffle DSL and improved its performance: * Added an `@GenerateInline` annotation that allows Truffle nodes to be object-inlined automatically. Object-inlined Truffle nodes become singletons and therefore reduce memory footprint. Please see the [tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/DSLNodeObjectInlining.md) for further details. - * Added an `@GenerateCached` annotation that allows to disable the generation of cached nodes. This is useful if all usages of nodes are object inlined to save code footprint. + * Added an `@GenerateCached` annotation that allows users to control the generation of cached nodes. Use `@GenerateCached(false)` to disable cached node generation when all usages of nodes are object-inlined to save code footprint. * Updated Truffle DSL nodes no longer require the node lock during specialization, resulting in improved first execution performance. CAS-style inline cache updates are now used to avoid deadlocks when calling CallTarget.call(...) in guards. Inline caches continue to guarantee no duplicate values and are not affected by race conditions. Language implementations should be aware that the reduced contention may reveal other thread-safety issues in the language. * Improved Truffle DSL node memory footprint by merging generated fields for state and exclude bit sets and improving specialization data class generation to consider activation probability. Specializations should be ordered by activation probability for optimal results. * Improved memory footprint by automatically inlining cached parameter values of enum types into the state bitset From 45cccdbc5aae3665c45b14a427fd101414dacbf5 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 19:32:15 +0100 Subject: [PATCH 197/312] Improve documentation. --- .../src/com/oracle/truffle/api/dsl/Cached.java | 11 ++++++----- .../com/oracle/truffle/api/dsl/GenerateInline.java | 9 ++++++++- .../oracle/truffle/api/impl/FrameWithoutBoxing.java | 5 ++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java index f781252d4ff2..582a57a14f89 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Cached.java @@ -318,11 +318,12 @@ boolean inline() default false; /** - * Instead of looking up the the inline method from the receiver type use an accessible - * enclosing method of a name instead. The method must have a single parameter - * {@link InlineTarget} and return a type compatible to the cached type. This can be useful if - * you want to route calls to the inline method through an abstraction that does not allow - * direct type access to the node classes. + * Specifies an alternative method name for node object inlining. Instead of looking up the + * inline method from the receiver type use an accessible enclosing method of the given name + * instead. The method must have a single parameter {@link InlineTarget} and return a type + * compatible to the cached type. This can be useful if you want to route calls to the inline + * method through an abstraction that does not allow direct type access to the node classes. It + * is expected that this property is only needed rarely. * * @since 23.0 */ diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java index 1f60b921d888..ad8c1dfc9cb5 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateInline.java @@ -55,15 +55,22 @@ * A node subclass must fullfill the following requirements in order to be inlinable: *
    *
  • All execute methods of a the node must have a {@link Node node} as first parameter type. - *
  • The node has no instance fields. + *
  • The node has no instance fields and must not use {@link NodeChild} or {@link NodeField}. *
  • The cached node types must not be recursive. *
* + * Truffle DSL emits warnings if the use of this annotation is recommended. In addition to inlining + * nodes automatically using this annotation, manually written nodes can also be written to become + * inlinable. See {@link InlineSupport} for details. * + * Please see the + * node + * object inlining tutorial for details on how to use this annotation. * * @see GenerateCached * @see GenerateUncached * @see GenerateAOT + * @see InlineSupport * @since 23.0 */ @Retention(RetentionPolicy.CLASS) diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java index f3f468fe0d01..c38fe0319dbe 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/FrameWithoutBoxing.java @@ -123,12 +123,11 @@ public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame assert BYTE_TAG == FrameSlotKind.Byte.tag; assert STATIC_TAG == FrameSlotKind.Static.tag; - // Check if assertions are enabled - ASSERTIONS_ENABLED = areAsseritonsEnabled(); + ASSERTIONS_ENABLED = areAssertionsEnabled(); } @SuppressWarnings("all") - private static boolean areAsseritonsEnabled() { + private static boolean areAssertionsEnabled() { boolean enabled = false; assert enabled = true; return enabled; From a8e6fe3ae695c303b8fefdb4ae297b6e5a6490ef Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 20:07:05 +0100 Subject: [PATCH 198/312] Fix project canonicalization. --- truffle/mx.truffle/suite.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 562fc163c504..f1e205e2407f 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -646,8 +646,7 @@ "com.oracle.truffle.api.profiles" : { "subDir" : "src", "sourceDirs" : ["src"], - "dependencies" : ["com.oracle.truffle.api", - "com.oracle.truffle.api.dsl"], + "dependencies" : ["com.oracle.truffle.api.dsl"], "checkstyle" : "com.oracle.truffle.api", "javaCompliance" : "11+", "workingSets" : "API,Truffle", From 06caf79a429b55eab62630fc668be6aa113c68ca Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 20:22:23 +0100 Subject: [PATCH 199/312] Fix deprecation warning. --- .../com/oracle/truffle/api/dsl/InlineSupport.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java index 90aa2115c390..9ecec51f89e0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -58,8 +58,6 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.nodes.Node; -import sun.misc.Unsafe; - /** * Contains classes to support node object inlining in Truffle. These classes are only needed if * manual node inlining is implemented. Typically Truffle DSL's {@link GenerateInline} takes care of @@ -1142,7 +1140,7 @@ public static DoubleField create(Lookup nodeClass, String field) { /** * Unsafe base class for fields. */ - @SuppressWarnings("unused") + @SuppressWarnings({"unused", "deprecation"}) abstract static class UnsafeField { // used for TruffleBaseFeature substitution @@ -1414,21 +1412,21 @@ final boolean compareAndSetObject(Object node, Object expect, Object update) { return U.compareAndSwapObject(useNode, offset, expect, update); } - private static Unsafe getUnsafe() { + private static sun.misc.Unsafe getUnsafe() { try { - return Unsafe.getUnsafe(); + return sun.misc.Unsafe.getUnsafe(); } catch (SecurityException e) { } try { - Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe"); + Field theUnsafeInstance = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); theUnsafeInstance.setAccessible(true); - return (Unsafe) theUnsafeInstance.get(Unsafe.class); + return (sun.misc.Unsafe) theUnsafeInstance.get(sun.misc.Unsafe.class); } catch (Exception e) { throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e); } } - static final Unsafe U = getUnsafe(); + static final sun.misc.Unsafe U = getUnsafe(); } /* From da1e320760cac9cde1d3be6d96c72d13ae462e07 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 5 Dec 2022 20:22:28 +0100 Subject: [PATCH 200/312] Fix formatting. --- .../src/com/oracle/truffle/api/strings/JCodings.java | 1 - 1 file changed, 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java index 7eaf87d53744..92a46813272a 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/JCodings.java @@ -114,7 +114,6 @@ static byte[] asByteArray(Object array) { long calcStringAttributes(Node location, Object array, int offset, int length, TruffleString.Encoding encoding, int fromIndex, InlinedConditionProfile validCharacterProfile, InlinedConditionProfile fixedWidthProfile); - TruffleString transcode(Node location, AbstractTruffleString a, Object arrayA, int codePointLengthA, TruffleString.Encoding targetEncoding, InlinedBranchProfile outOfMemoryProfile, InlinedConditionProfile nativeProfile, From cd4c209c7eae3e45664d83037b6e6b61e7cb19b3 Mon Sep 17 00:00:00 2001 From: Josef Haider Date: Tue, 6 Dec 2022 11:54:33 +0100 Subject: [PATCH 201/312] TruffleStrings: remove redundant node annotations --- .../api/strings/MutableTruffleString.java | 58 +++---------------- .../truffle/api/strings/TruffleString.java | 8 --- .../api/strings/TruffleStringBuilder.java | 38 ++++++------ .../api/strings/TruffleStringIterator.java | 12 ---- 4 files changed, 26 insertions(+), 90 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java index 4f2d08a12f23..d94a45bb051f 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java @@ -51,10 +51,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GeneratePackagePrivate; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @@ -141,11 +137,7 @@ public void notifyExternalMutation() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class FromByteArrayNode extends Node { + public abstract static class FromByteArrayNode extends AbstractPublicNode { FromByteArrayNode() { } @@ -214,11 +206,7 @@ public static MutableTruffleString fromByteArrayUncached(byte[] value, int byteO * * @since 22.1 */ - @ImportStatic({TStringGuards.class, TStringAccessor.class}) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class FromNativePointerNode extends Node { + public abstract static class FromNativePointerNode extends AbstractPublicNode { FromNativePointerNode() { } @@ -307,11 +295,7 @@ public static MutableTruffleString fromNativePointerUncached(Object pointerObjec * * @since 22.1 */ - @ImportStatic({TStringGuards.class, TStringAccessor.class}) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class AsMutableTruffleStringNode extends Node { + public abstract static class AsMutableTruffleStringNode extends AbstractPublicNode { AsMutableTruffleStringNode() { } @@ -364,11 +348,7 @@ public static AsMutableTruffleStringNode getUncached() { * * @since 22.1 */ - @ImportStatic({TStringGuards.class, TStringAccessor.class}) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class AsManagedNode extends Node { + public abstract static class AsManagedNode extends AbstractPublicNode { AsManagedNode() { } @@ -418,11 +398,7 @@ public static AsManagedNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class WriteByteNode extends Node { + public abstract static class WriteByteNode extends AbstractPublicNode { WriteByteNode() { } @@ -542,11 +518,7 @@ public MutableTruffleString concatUncached(AbstractTruffleString b, Encoding exp * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class SubstringNode extends Node { + public abstract static class SubstringNode extends AbstractPublicNode { SubstringNode() { } @@ -610,11 +582,7 @@ public MutableTruffleString substringUncached(int byteOffset, int byteLength, En * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class SubstringByteIndexNode extends Node { + public abstract static class SubstringByteIndexNode extends AbstractPublicNode { SubstringByteIndexNode() { } @@ -677,11 +645,7 @@ public MutableTruffleString substringByteIndexUncached(int byteOffset, int byteL * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class SwitchEncodingNode extends Node { + public abstract static class SwitchEncodingNode extends AbstractPublicNode { SwitchEncodingNode() { } @@ -737,11 +701,7 @@ public static MutableTruffleString.SwitchEncodingNode getUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) - public abstract static class ForceEncodingNode extends Node { + public abstract static class ForceEncodingNode extends AbstractPublicNode { ForceEncodingNode() { } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index 370a0e539ec7..25ce0196c41f 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -82,10 +82,6 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GeneratePackagePrivate; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @@ -1918,10 +1914,6 @@ public static TruffleString fromByteArrayUncached(byte[] value, int byteOffset, * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) public abstract static class FromCharArrayUTF16Node extends AbstractPublicNode { FromCharArrayUTF16Node() { diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java index 649733034d6b..fbea6c01db95 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java @@ -55,7 +55,6 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -373,7 +372,7 @@ public final void execute(TruffleStringBuilder sb, int codepoint, int repeat) { public abstract void execute(TruffleStringBuilder sb, int codepoint, int repeat, boolean allowUTF16Surrogates); @Specialization - static void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF16Surrogates, + final void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF16Surrogates, @Cached AppendCodePointIntlNode appendCodePointIntlNode) { assert !allowUTF16Surrogates || isUTF16Or32(sb.encoding) : "allowUTF16Surrogates is only supported on UTF-16 and UTF-32"; if (c < 0 || c > 0x10ffff) { @@ -382,7 +381,7 @@ static void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF1 if (repeat < 1) { throw InternalErrors.illegalArgument("number of repetitions must be at least 1"); } - appendCodePointIntlNode.execute(sb, c, sb.encoding, repeat, allowUTF16Surrogates); + appendCodePointIntlNode.execute(this, sb, c, sb.encoding, repeat, allowUTF16Surrogates); sb.codePointLength += repeat; } @@ -405,20 +404,19 @@ public static AppendCodePointNode getUncached() { } } - @ImportStatic({TStringGuards.class, TruffleStringBuilder.class}) - @GenerateUncached - abstract static class AppendCodePointIntlNode extends AbstractPublicNode { + @ImportStatic(TruffleStringBuilder.class) + abstract static class AppendCodePointIntlNode extends AbstractInternalNode { - abstract void execute(TruffleStringBuilder sb, int c, Encoding encoding, int n, boolean allowUTF16Surrogates); + abstract void execute(Node node, TruffleStringBuilder sb, int c, Encoding encoding, int n, boolean allowUTF16Surrogates); @Specialization(guards = "isAsciiBytesOrLatin1(enc)") - final void bytes(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + static void bytes(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile) { if (c > 0xff) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacityS0(this, n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(node, n, bufferGrowProfile, errorProfile); if (c > 0x7f) { sb.updateCodeRange(TSCodeRange.asciiLatinBytesNonAsciiCodeRange(sb.encoding)); } @@ -427,14 +425,14 @@ final void bytes(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Enc } @Specialization(guards = "isUTF8(enc)") - final void utf8(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + static void utf8(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile) { if (Encodings.isUTF16Surrogate(c)) { throw InternalErrors.invalidCodePoint(c); } int length = Encodings.utf8EncodedSize(c); - sb.ensureCapacityS0(this, length * n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(node, length * n, bufferGrowProfile, errorProfile); for (int i = 0; i < n; i++) { Encodings.utf8Encode(c, sb.buf, sb.length, length); sb.length += length; @@ -445,8 +443,7 @@ final void utf8(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Enco } @Specialization(guards = {"isUTF16(enc)", "cachedCurStride == sb.stride", "cachedNewStride == utf16Stride(sb, c)"}, limit = TStringOpsNodes.LIMIT_STRIDE) - static void utf16Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - @Bind("this") Node node, + static void utf16Cached(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile, @Cached("sb.stride") int cachedCurStride, @@ -456,11 +453,11 @@ static void utf16Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unuse } @Specialization(guards = "isUTF16(enc)", replaces = "utf16Cached") - void utf16Uncached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, + static void utf16Uncached(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile, @Shared("bmp") @Cached InlinedConditionProfile bmpProfile) { - doUTF16(this, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf16Stride(sb, c), bmpProfile); + doUTF16(node, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf16Stride(sb, c), bmpProfile); } private static void doUTF16(Node node, TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, @@ -481,8 +478,7 @@ private static void doUTF16(Node node, TruffleStringBuilder sb, int c, int n, bo } @Specialization(guards = {"isUTF32(enc)", "cachedCurStride == sb.stride", "cachedNewStride == utf32Stride(sb, c)"}, limit = TStringOpsNodes.LIMIT_STRIDE) - static void utf32Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, - @Bind("this") Node node, + static void utf32Cached(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile, @Cached(value = "sb.stride") int cachedCurStride, @@ -491,10 +487,10 @@ static void utf32Cached(TruffleStringBuilder sb, int c, @SuppressWarnings("unuse } @Specialization(guards = "isUTF32(enc)", replaces = "utf32Cached") - void utf32Uncached(TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, + static void utf32Uncached(Node node, TruffleStringBuilder sb, int c, @SuppressWarnings("unused") Encoding enc, int n, boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile) { - doUTF32(this, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf32Stride(sb, c)); + doUTF32(node, sb, c, n, allowUTF16Surrogates, bufferGrowProfile, errorProfile, sb.stride, utf32Stride(sb, c)); } static void doUTF32(Node node, TruffleStringBuilder sb, int c, int n, boolean allowUTF16Surrogates, InlinedConditionProfile bufferGrowProfile, InlinedBranchProfile errorProfile, @@ -509,7 +505,7 @@ static void doUTF32(Node node, TruffleStringBuilder sb, int c, int n, boolean al } @Specialization(guards = "isUnsupportedEncoding(enc)") - final void unsupported(TruffleStringBuilder sb, int c, Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, + static void unsupported(Node node, TruffleStringBuilder sb, int c, Encoding enc, int n, @SuppressWarnings("unused") boolean allowUTF16Surrogates, @Shared("bufferGrow") @Cached InlinedConditionProfile bufferGrowProfile, @Shared("error") @Cached InlinedBranchProfile errorProfile) { JCodings.Encoding jCodingsEnc = JCodings.getInstance().get(enc); @@ -520,7 +516,7 @@ final void unsupported(TruffleStringBuilder sb, int c, Encoding enc, int n, @Sup if (length < 1) { throw InternalErrors.invalidCodePoint(c); } - sb.ensureCapacityS0(this, length * n, bufferGrowProfile, errorProfile); + sb.ensureCapacityS0(node, length * n, bufferGrowProfile, errorProfile); for (int i = 0; i < n; i++) { int ret = JCodings.getInstance().writeCodePoint(jCodingsEnc, c, sb.buf, sb.length); if (ret != length || JCodings.getInstance().getCodePointLength(jCodingsEnc, sb.buf, sb.length, sb.length + length) != ret || diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java index b0de548ac386..f69716d97c69 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java @@ -43,10 +43,6 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GeneratePackagePrivate; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString.Encoding; @@ -318,10 +314,6 @@ static int unsupported(TruffleStringIterator it) { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) public abstract static class NextNode extends AbstractPublicNode { NextNode() { @@ -374,10 +366,6 @@ public int nextUncached() { * * @since 22.1 */ - @ImportStatic(TStringGuards.class) - @GeneratePackagePrivate - @GenerateUncached - @GenerateInline(false) public abstract static class PreviousNode extends AbstractPublicNode { PreviousNode() { From 442052827c3a975ff6886e90834b472d7fd7ba45 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 12:24:47 +0100 Subject: [PATCH 202/312] Fix -Atruffle.dsl.GenerateSlowPathOnly=true. --- .../api/dsl/test/ProfileInliningTest.java | 4 +- .../dsl/processor/library/ExportsParser.java | 2 +- .../dsl/processor/model/CacheExpression.java | 27 +++++----- .../dsl/processor/parser/NodeParser.java | 49 ++++++++++++++++--- 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java index 2270a8a327a5..389e220b313a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ProfileInliningTest.java @@ -237,7 +237,7 @@ public abstract static class TestInlineMessage4 extends BaseNode { // give a reasonable error that the branch profile type needs to be updated @Specialization int s0(@ExpectError("Invalid return type com.oracle.truffle.api.profiles.InlinedBranchProfile found but expected com.oracle.truffle.api.profiles.BranchProfile. " + - "This is a common error if a different type is required for inlining. %") // + "This is a common error if a different type is required for inlining.") // @Cached(inline = true) BranchProfile p0) { return 0; } @@ -286,7 +286,7 @@ public abstract static class TestInlineMessage8 extends BaseNode { @Specialization static int s0( @ExpectError("Invalid return type com.oracle.truffle.api.profiles.InlinedBranchProfile found but expected com.oracle.truffle.api.profiles.BranchProfile. " + - "This is a common error if a different type is required for inlining. Signature inline(InlineTarget).") // + "This is a common error if a different type is required for inlining.") // @Cached BranchProfile p0) { return 0; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java index c40f27d59022..f107cf98282a 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsParser.java @@ -479,7 +479,7 @@ protected ExportsData parse(Element element, List elementMirro for (ExportsLibrary libraryExports : model.getExportedLibraries().values()) { for (ExportMessageData export : libraryExports.getExportedMessages().values()) { if (export.isClass() && export.getSpecializedNode() != null) { - NodeParser.removeFastPathSpecializations(export.getSpecializedNode()); + NodeParser.removeFastPathSpecializations(export.getSpecializedNode(), libraryExports.getSharedExpressions()); } } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java index ea7b110465f3..9c2aa1bfa374 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/CacheExpression.java @@ -82,9 +82,16 @@ public final class CacheExpression extends MessageContainer { private LibraryData cachedlibrary; private boolean usedInGuard; + private AnnotationMirror sharedGroupMirror; + private AnnotationValue sharedGroupValue; + private String sharedGroup; + public CacheExpression(Parameter sourceParameter, AnnotationMirror sourceAnnotationMirror) { this.sourceParameter = sourceParameter; this.sourceAnnotationMirror = sourceAnnotationMirror; + this.sharedGroupMirror = ElementUtils.findAnnotationMirror(sourceParameter.getVariableElement(), types.Cached_Shared); + this.sharedGroupValue = sharedGroupMirror != null ? getAnnotationValue(sharedGroupMirror, "value") : null; + this.sharedGroup = sharedGroupMirror != null ? getAnnotationValue(String.class, sharedGroupMirror, "value") : null; } public CacheExpression copy() { @@ -147,8 +154,14 @@ public void setEagerInitialize(boolean alreadyInitialized) { this.eagerInitialize = alreadyInitialized; } + public void clearSharing() { + this.sharedGroup = null; + this.sharedGroupMirror = null; + this.sharedGroupValue = null; + } + public AnnotationMirror getSharedGroupMirror() { - return ElementUtils.findAnnotationMirror(sourceParameter.getVariableElement(), types.Cached_Shared); + return sharedGroupMirror; } public boolean isEncodedEnum() { @@ -159,19 +172,11 @@ public boolean isEncodedEnum() { } public AnnotationValue getSharedGroupValue() { - AnnotationMirror sharedAnnotation = getSharedGroupMirror(); - if (sharedAnnotation != null) { - return getAnnotationValue(sharedAnnotation, "value"); - } - return null; + return sharedGroupValue; } public String getSharedGroup() { - AnnotationMirror sharedAnnotation = getSharedGroupMirror(); - if (sharedAnnotation != null) { - return getAnnotationValue(String.class, sharedAnnotation, "value"); - } - return null; + return sharedGroup; } public void setDefaultExpression(DSLExpression expression) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 01300af1e11e..c9ef94eefea3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -79,6 +79,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; @@ -429,8 +430,9 @@ public NodeData parseNode(TypeElement originalTemplateType) { verifyConstructors(node); verifySpecializationThrows(node); verifyFrame(node); + if (isGenerateSlowPathOnly(node)) { - removeFastPathSpecializations(node); + removeFastPathSpecializations(node, node.getSharedCaches()); } verifyRecommendationWarnings(node, recommendInline); @@ -2826,18 +2828,50 @@ private static void initializeReachability(final NodeData node) { node.setReachableSpecializations(node.getReachableSpecializations()); } - public static void removeFastPathSpecializations(NodeData node) { + public static void removeFastPathSpecializations(NodeData node, Map sharing) { List specializations = node.getSpecializations(); List toRemove = new ArrayList<>(); for (SpecializationData cur : specializations) { - for (SpecializationData contained : cur.getReplaces()) { - if (contained != cur && contained.getUncachedSpecialization() != cur) { - toRemove.add(contained); + if (cur.getReplaces() != null) { + for (SpecializationData contained : cur.getReplaces()) { + if (contained != cur && contained.getUncachedSpecialization() != cur) { + toRemove.add(contained); + + for (CacheExpression cache : contained.getCaches()) { + sharing.remove(cache); + } + } } } } + + // group sharing by key + Map> newCaches = new HashMap<>(); + for (Entry entry : sharing.entrySet()) { + newCaches.computeIfAbsent(entry.getValue(), (s) -> new ArrayList<>()).add(entry.getKey()); + } + + // remove sharing with a single shared cache + for (Entry> entry : newCaches.entrySet()) { + if (entry.getValue().size() <= 1) { + for (CacheExpression cache : entry.getValue()) { + sharing.remove(cache); + } + } + } + + // clear sharing info in cache to be consistent in node generation + for (SpecializationData specialization : specializations) { + for (CacheExpression cache : specialization.getCaches()) { + if (cache.getSharedGroup() != null && !sharing.containsKey(cache)) { + cache.clearSharing(); + } + } + } + specializations.removeAll(toRemove); node.getReachableSpecializations().removeAll(toRemove); + } private static void initializeSpecializationIdsWithMethodNames(List specializations) { @@ -3452,10 +3486,9 @@ private void parseCached(CacheExpression cache, SpecializationData specializatio if (inlineMethod != null) { fields = parseInlineMethod(cache, null, inlineMethod); if (!cache.hasErrors() && !typeEquals(inlineMethod.getReturnType(), cache.getParameter().getType())) { - cache.addError("Invalid return type %s found but expected %s. This is a common error if a different type is required for inlining. Signature %s.", + cache.addError("Invalid return type %s found but expected %s. This is a common error if a different type is required for inlining.", getQualifiedName(inlineMethod.getReturnType()), - getQualifiedName(cache.getParameter().getType()), - ElementUtils.getReadableSignature(inlineMethod)); + getQualifiedName(cache.getParameter().getType())); } } else { /* From 4da0877ded8762260615b7dd5eb629f6efa95545 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 12:48:48 +0100 Subject: [PATCH 203/312] Fix -Atruffle.dsl.StateBitWidth=1. --- ...a => DisableStateBitWidthModfication.java} | 4 +--- .../api/dsl/test/GenerateInlineTest.java | 5 +++++ .../api/dsl/test/SuppressWarningTest.java | 2 +- .../processor/TruffleProcessorOptions.java | 11 ++++++++-- .../processor/TruffleSuppressedWarnings.java | 17 ---------------- .../truffle/dsl/processor/TruffleTypes.java | 4 ++-- .../generator/FlatNodeGenFactory.java | 20 ++++++++++--------- 7 files changed, 29 insertions(+), 34 deletions(-) rename truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/{DisableWarningSuppression.java => DisableStateBitWidthModfication.java} (96%) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java similarity index 96% rename from truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java rename to truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java index 9693c013fd50..fff357ebdf7a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableWarningSuppression.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java @@ -44,8 +44,6 @@ import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) -public @interface DisableWarningSuppression { - - String[] value() default {}; +public @interface DisableStateBitWidthModfication { } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index 0f0d29fdbd12..c0523c2785aa 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -618,6 +618,7 @@ static String s1(Node node, int arg, @Cached InnerNode innerNode) { @GenerateInline @GeneratePackagePrivate + @DisableStateBitWidthModfication public abstract static class CustomInline1Node extends Node { abstract int execute(Node node, int value); @@ -640,6 +641,7 @@ public static CustomInline1Node inline(@RequiredField(value = StateField.class, @GenerateInline @GeneratePackagePrivate + @DisableStateBitWidthModfication public abstract static class CustomInline2Node extends Node { abstract int execute(Node node, int value); @@ -661,6 +663,7 @@ public static CustomInline2Node inline(@RequiredField(value = StateField.class, } @SuppressWarnings({"truffle", "unused"}) + @DisableStateBitWidthModfication public abstract static class UseCustomInlineNode extends Node { abstract Object execute(int value); @@ -2070,6 +2073,7 @@ static Object s1(int value) { @GenerateInline @GeneratePackagePrivate + @DisableStateBitWidthModfication public abstract static class ErrorNodeWithCustomInlineNode extends Node { abstract long execute(Node node, long value); @@ -2095,6 +2099,7 @@ public static ErrorNodeWithCustomInlineNode inline(@RequiredField(value = StateF @GenerateInline @GeneratePackagePrivate + @DisableStateBitWidthModfication public abstract static class ErrorNodeWithCustomInline2Node extends Node { abstract long execute(Node node, long value); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java index a184af27b0a9..6505e346a1d9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java @@ -43,7 +43,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -@DisableWarningSuppression +@DisableStateBitWidthModfication public class SuppressWarningTest { @SuppressWarnings({"unused", "truffle-inlining"}) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java index a1ad60e003a9..9c136f7d1e62 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java @@ -46,6 +46,8 @@ import javax.annotation.processing.ProcessingEnvironment; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; +import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.model.NodeData; /** * Aggregates all options recognized by {@link TruffleProcessor}. @@ -102,8 +104,13 @@ public static boolean cacheSharingWarningsEnabled(ProcessingEnvironment env) { return Boolean.parseBoolean(s); } - public static int stateBitWidth(ProcessingEnvironment env) { - String value = env.getOptions().get(OptionsPrefix + StateBitWidth); + public static int stateBitWidth(NodeData node) { + ProcessorContext context = ProcessorContext.getInstance(); + if (ElementUtils.findAnnotationMirror(node.getTemplateType(), context.getTypes().DisableStateBitWidthModification) != null) { + return FlatNodeGenFactory.DEFAULT_MAX_BIT_WIDTH; + } + + String value = context.getEnvironment().getOptions().get(OptionsPrefix + StateBitWidth); if (value == null) { return FlatNodeGenFactory.DEFAULT_MAX_BIT_WIDTH; } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java index 692f9e8936e6..c7751a676ab8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleSuppressedWarnings.java @@ -98,25 +98,8 @@ public static Set getWarnings(Element element) { } public static boolean isSuppressed(Element element, String... warningKind) { - final TruffleTypes types = ProcessorContext.getInstance().getTypes(); Element e = element; do { - if (types.DisableWarningSuppression != null) { - AnnotationMirror disabled = ElementUtils.findAnnotationMirror(e, types.DisableWarningSuppression); - if (disabled != null) { - List elements = ElementUtils.getAnnotationValueList(String.class, disabled, "value"); - if (elements.isEmpty()) { - return false; - } else { - for (String warning : warningKind) { - if (elements.contains(warning)) { - return false; - } - } - } - } - } - Set warnings = getWarnings(e); if (warnings.contains(ALL) || warnings.contains(TRUFFLE) || // warnings.stream().anyMatch((s) -> (Arrays.asList(warningKind).contains(s)))) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 498efb93417c..9936611f414c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -55,7 +55,7 @@ public class TruffleTypes { // Testing API private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2}; public static final String ALWAYS_SLOW_PATH_MODE_NAME = "com.oracle.truffle.api.dsl.test.AlwaysGenerateOnlySlowPath"; - public static final String DISABLE_WARNING_SUPRESSION = "com.oracle.truffle.api.dsl.test.DisableWarningSuppression"; + public static final String DISABLE_STATE_BITWIDTH_MODIFICATION = "com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication"; public static final String EXPECT_ERROR_CLASS_NAME1 = "com.oracle.truffle.api.dsl.test.ExpectError"; public static final String EXPECT_ERROR_CLASS_NAME2 = "com.oracle.truffle.api.test.ExpectError"; public static final List TEST_PACKAGES = List.of("com.oracle.truffle.api.test", "com.oracle.truffle.api.instrumentation.test"); @@ -63,7 +63,7 @@ public class TruffleTypes { public static final String SlowPathListener_Name = "com.oracle.truffle.api.dsl.test.SlowPathListener"; public final DeclaredType SlowPathListener = c.getDeclaredTypeOptional(SlowPathListener_Name); public final DeclaredType AlwaysSlowPath = c.getDeclaredTypeOptional(ALWAYS_SLOW_PATH_MODE_NAME); - public final DeclaredType DisableWarningSuppression = c.getDeclaredTypeOptional(DISABLE_WARNING_SUPRESSION); + public final DeclaredType DisableStateBitWidthModification = c.getDeclaredTypeOptional(DISABLE_STATE_BITWIDTH_MODIFICATION); public final List ExpectErrorTypes; { List types = new ArrayList<>(EXPECT_ERROR_TYPES.length); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index e6aa404961a9..caeaf15d4e65 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -487,8 +487,7 @@ NodeStateResult createNodeState() { } private static MultiStateBitSet createMultiStateBitset(String namePrefix, NodeData activeNode, BitStateList objects) { - ProcessorContext context = ProcessorContext.getInstance(); - int maxBits = TruffleProcessorOptions.stateBitWidth(context.getEnvironment()); + int maxBits = TruffleProcessorOptions.stateBitWidth(activeNode); return objects.splitBitSets(namePrefix, activeNode, maxBits); } @@ -1579,8 +1578,9 @@ private void generateAOT(CodeTypeElement clazz, boolean inlined) { } StateTransaction transaction = new StateTransaction(); builder.tree(multiState.createForceLoad(frameState, - AOT_PREPARED, StateQuery.create(SpecializationActive.class, filteredSpecializations), + AOT_PREPARED, StateQuery.create(GuardActive.class, bulkStateSetGuards), StateQuery.create(ImplicitCastState.class, implicitCasts))); + builder.tree(multiState.createSet(frameState, transaction, AOT_PREPARED, true, false)); builder.tree(multiState.createSet(frameState, transaction, StateQuery.create(GuardActive.class, bulkStateSetGuards), true, false)); builder.tree(multiState.createSet(frameState, transaction, StateQuery.create(ImplicitCastState.class, implicitCasts), true, false)); @@ -3111,7 +3111,7 @@ private Element createCheckForPolymorphicSpecialize(ReportPolymorphismAction rep if (reportPolymorphismAction.polymorphism) { String sep = ""; - for (BitSet s : multiState.getSets()) { + for (BitSet s : relevantSets) { builder.string(sep); builder.string("((", getSetOldName(s), " ^ ", getSetNewName(s), ") != 0)"); sep = " || "; @@ -3197,12 +3197,16 @@ private Element createCountCaches(boolean inlined) { } private void generateCheckNewPolymorphismState(CodeTreeBuilder builder, FrameState frameState, ReportPolymorphismAction reportPolymorphismAction) { + SpecializationData[] relevantSpecializations = getSpecalizationsForReportAction(reportPolymorphismAction); + StateQuery query = StateQuery.create(SpecializationActive.class, relevantSpecializations); builder.startIf(); String sep = ""; for (BitSet s : multiState.getSets()) { - builder.string(sep); - builder.string(getSetOldName(s), " != 0"); - sep = " || "; + if (s.contains(query)) { + builder.string(sep); + builder.string(getSetOldName(s), " != 0"); + sep = " || "; + } } builder.end(); @@ -3213,8 +3217,6 @@ private void generateCheckNewPolymorphismState(CodeTreeBuilder builder, FrameSta if (frameState.isInlinedNode()) { builder.tree(frameState.getValue(INLINED_NODE_INDEX).createReference()); } - SpecializationData[] relevantSpecializations = getSpecalizationsForReportAction(reportPolymorphismAction); - StateQuery query = StateQuery.create(SpecializationActive.class, relevantSpecializations); for (BitSet s : multiState.getSets()) { if (s.contains(query)) { builder.string(getSetOldName(s)); From 29714dc8a7b49248305afa292b4923e1d43d28df Mon Sep 17 00:00:00 2001 From: Josef Haider Date: Tue, 6 Dec 2022 13:45:54 +0100 Subject: [PATCH 204/312] TruffleStrings: remove unused code --- .../api/strings/MutableTruffleString.java | 15 ------- .../api/strings/TStringInternalNodes.java | 44 ------------------- 2 files changed, 59 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java index d94a45bb051f..fc6090f63f62 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java @@ -758,26 +758,11 @@ static byte[] doByteArray(byte[] v) { return v; } - @Specialization - static String doString(String v) { - return v; - } - @Specialization static NativePointer doNativePointer(NativePointer v) { return v; } - @Specialization - static LazyLong doLazyLong(LazyLong v) { - return v; - } - - @Specialization - static LazyConcat doLazyConcat(LazyConcat v) { - return v; - } - } abstract static class CalcLazyAttributesNode extends AbstractInternalNode { diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java index 99e19c9acfeb..03820c8e090e 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java @@ -141,50 +141,6 @@ static GetCodePointLengthNode getUncached() { } } - abstract static class EncodingProfile extends AbstractInternalNode { - - abstract Encoding execute(Node node, Encoding encoding); - - @SuppressWarnings("unused") - @Specialization(guards = "encoding == cachedEncoding", limit = "1") - static Encoding doProfiled(Encoding encoding, @Cached("encoding") Encoding cachedEncoding) { - return cachedEncoding; - } - - @Specialization(replaces = "doProfiled") - static Encoding doGeneric(Encoding encoding) { - return encoding; - } - - } - - abstract static class CreateSubstringNode extends AbstractInternalNode { - - abstract TruffleString execute(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int codeRange); - - @SuppressWarnings("unused") - @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) - static TruffleString doCached(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, - int codeRange, - @Bind("fromStride(stride)") CompactionLevel compaction, - @Cached("compaction") CompactionLevel cachedCompaction, - @Cached EncodingProfile cachedEncoding, - @Cached CalcStringAttributesNode calcAttributesNode) { - return createString(node, a, array, offset, length, cachedCompaction.getStride(), cachedEncoding.execute(node, encoding), codeRange, calcAttributesNode); - } - - private static TruffleString createString(Node node, AbstractTruffleString a, Object array, int offset, int length, int stride, Encoding encoding, int codeRange, - CalcStringAttributesNode calcAttributesNode) { - long attrs = calcAttributesNode.execute(node, a, array, offset, length, stride, encoding, 0, codeRange); - int newStride = Stride.fromCodeRange(StringAttributes.getCodeRange(attrs), encoding); - byte[] newBytes = new byte[length << newStride]; - TStringOps.arraycopyWithStride(node, - array, offset, stride, 0, - newBytes, 0, newStride, 0, length); - return TruffleString.createFromByteArray(newBytes, length, newStride, encoding, StringAttributes.getCodePointLength(attrs), StringAttributes.getCodeRange(attrs)); - } - } - abstract static class FromBufferWithStringCompactionNode extends AbstractInternalNode { abstract TruffleString execute(Node node, Object arrayA, int offsetA, int byteLength, Encoding encoding, boolean copy, boolean isCacheHead); From 5a2dc7df3c42be85eb6a531bcb504df3776c22d9 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 13:58:29 +0100 Subject: [PATCH 205/312] Fix import. --- .../test/strings/TStringOpsCalcStringAttributesUTF8Test.java | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java index 420218ba1812..8a1796c29486 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/strings/TStringOpsCalcStringAttributesUTF8Test.java @@ -29,7 +29,6 @@ import java.util.Arrays; import org.graalvm.compiler.replacements.nodes.CalcStringAttributesNode; -import org.graalvm.compiler.replacements.amd64.AMD64CalcStringAttributesNode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; From ab6d11147295f331fd612a05e96ea0501c384774 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 14:05:52 +0100 Subject: [PATCH 206/312] Remove DSL workaround. --- .../oracle/truffle/api/strings/TruffleString.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index 25ce0196c41f..867537e95e38 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -2438,17 +2438,10 @@ abstract static class ToIndexableNode extends AbstractInternalNode { abstract Object execute(Node node, AbstractTruffleString a, Object data); + @Specialization @SuppressWarnings("unused") - @Specialization(guards = "isByteArray(data)") - static byte[] doByteArray(AbstractTruffleString a, Object data) { - return (byte[]) data; - } - - /* - * Workaround for DSL bug. - */ - static boolean isByteArray(Object value) { - return value instanceof byte[]; + static byte[] doByteArray(AbstractTruffleString a, byte[] data) { + return data; } @Specialization(guards = "isSupportedEncoding(a.encoding())") From 2492a52bd23e9de3e16cd99ecc815e771fe402a7 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 15:49:40 +0100 Subject: [PATCH 207/312] Fix host interop test that fails differently JDT vs javac. (GR-42882) --- .../truffle/api/test/polyglot/HostAccessTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java index 665ea48aa03b..9805cd9b6d59 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostAccessTest.java @@ -968,8 +968,18 @@ public void testOverloadedFunctionalMethod() throws Exception { function.execute("ok"); // when calling a functional interface implementation, only dispatch to implementations of // the single abstract method and not other methods with the same name in the subclass. - assertFails(() -> function.execute(42), IllegalArgumentException.class, e -> { - assertTrue(e.getMessage(), e.getMessage().contains("Cannot convert '42'(language: Java, type: java.lang.Integer)")); + assertFails(() -> function.execute(42), Exception.class, e -> { + // TODO GR-42882 investigate why this fails differently depending on Java compiler + if (e instanceof PolyglotException) { + // javac + PolyglotException p = (PolyglotException) e; + assertTrue(p.toString(), p.isHostException()); + assertTrue(p.asHostException().toString(), p.asHostException() instanceof ClassCastException); + } else { + // jdt + assertTrue(e instanceof IllegalArgumentException); + assertTrue(e.getMessage(), e.getMessage().contains("Cannot convert '42'(language: Java, type: java.lang.Integer)")); + } }); assertFails(() -> function.execute("ok", "not ok"), IllegalArgumentException.class); From 753f1726471b16bd977ea95f907c3349f5b7c1a0 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 6 Dec 2022 16:50:48 +0100 Subject: [PATCH 208/312] Findbugs fixes. --- .../oracle/truffle/api/dsl/InlineSupport.java | 13 +++++++----- .../generator/FlatNodeGenFactory.java | 20 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java index 9ecec51f89e0..fc4e53d1ba8e 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -390,16 +390,19 @@ public final boolean validate(Node node) { static RuntimeException invalidAccessError(Class expectedClass, Object node) { CompilerDirectives.transferToInterpreterAndInvalidate(); - String message = String.format("Invalid parameter type passed to updater. Instance of type '%s' expected but was '%s'. " + // - "Did you pass the wrong node to an execute method of an inlined cached node?", - getEnclosingSimpleName(expectedClass), node != null ? getEnclosingSimpleName(node.getClass()) : "null"); if (node == null) { - throw new NullPointerException(message); + throw new NullPointerException(formatInvalidAccessError(expectedClass, node)); } else { - throw new ClassCastException(message); + throw new ClassCastException(formatInvalidAccessError(expectedClass, node)); } } + private static String formatInvalidAccessError(Class expectedClass, Object node) { + return String.format("Invalid parameter type passed to updater. Instance of type '%s' expected but was '%s'. " + // + "Did you pass the wrong node to an execute method of an inlined cached node?", + getEnclosingSimpleName(expectedClass), node != null ? getEnclosingSimpleName(node.getClass()) : "null"); + } + static RuntimeException invalidValue(Class expectedClass, Object value) { CompilerDirectives.transferToInterpreterAndInvalidate(); String message = String.format("Invalid parameter type passed to set. Instance of type '%s' expected but was '%s'. ", diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index caeaf15d4e65..05da400a076b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6206,11 +6206,13 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.end(); } else { - if (cache.isEncodedEnum()) { - IfTriple triple = createNeverDefaultGuard(frameState, specialization, cache, " == "); - builder.startIf().tree(triple.condition).end().startBlock(); - } else { - builder.startIf().tree(createCacheAccess(frameState, specialization, cache, null)).string(" == ").string(defaultValue).end().startBlock(); + if (!cache.isEagerInitialize()) { + if (cache.isEncodedEnum()) { + IfTriple triple = createNeverDefaultGuard(frameState, specialization, cache, " == "); + builder.startIf().tree(triple.condition).end().startBlock(); + } else { + builder.startIf().tree(createCacheAccess(frameState, specialization, cache, null)).string(" == ").string(defaultValue).end().startBlock(); + } } if (!cacheInitialized) { @@ -6221,7 +6223,9 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); builder.end(); - builder.end(); + if (!cache.isEagerInitialize()) { + builder.end(); + } } builder.end(); builder.end(); @@ -6429,6 +6433,10 @@ private void checkSharedCacheNull(CodeTreeBuilder builder, String refName, Speci // no shared check needed. return; } + if (cache.isEagerInitialize()) { + // always default for eager initialization + return; + } builder.startIf().string(refName).string(" == ").string(ElementUtils.defaultValue(cache.getParameter().getType())).end().startBlock(); String message = String.format("Specialization '%s' contains a shared cache with name '%s' that returned a default value for the cached initializer. " + "Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.", From 455e28f32f71cdb5462148060076f403942250ca Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 7 Dec 2022 12:31:06 +0100 Subject: [PATCH 209/312] Fix spotbugs problems. --- .../generator/FlatNodeGenFactory.java | 24 ++-- .../dsl/processor/model/GuardExpression.java | 135 ++++++++++-------- 2 files changed, 83 insertions(+), 76 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 05da400a076b..7b7f4370f2d4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5172,14 +5172,10 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt CodeExecutableElement parentMethod = (CodeExecutableElement) builder.findMethod(); String boundaryMethodName; - if (specialization != null) { - if (generatorMode.equals(GeneratorMode.EXPORTED_MESSAGE)) { - boundaryMethodName = String.format("%s_%sBoundary", node.getNodeId(), specialization.getId()); - } else { - boundaryMethodName = String.format("%sBoundary", specialization.getId()); - } + if (generatorMode.equals(GeneratorMode.EXPORTED_MESSAGE)) { + boundaryMethodName = String.format("%s_%sBoundary", node.getNodeId(), specialization.getId()); } else { - boundaryMethodName = "specializationBoundary"; + boundaryMethodName = String.format("%sBoundary", specialization.getId()); } boundaryMethodName = firstLetterLowerCase(boundaryMethodName); @@ -5189,7 +5185,7 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt usedBoundaryNames.add(boundaryMethodName); String includeFrameParameter = null; - if (specialization != null && specialization.getFrame() != null) { + if (specialization.getFrame() != null) { if (ElementUtils.typeEquals(types.MaterializedFrame, specialization.getFrame().getType())) { includeFrameParameter = FRAME_VALUE; } else { @@ -6035,7 +6031,7 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, NodeExecutionMode mode, SpecializationGroup group, GuardExpression guard) { SpecializationData specialization = group.getSpecialization(); boolean guardStateBit = guardNeedsStateBit(specialization, guard); - if (!guardStateBit && guard.isConstantTrueInSlowPath(context, mode.isUncached())) { + if (!guardStateBit && guard.isConstantTrueInSlowPath(mode.isUncached())) { return Collections.emptyList(); } @@ -6647,7 +6643,7 @@ private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationDat } } else if (mode.isSlowPath() || mode.isUncached()) { CodeTree guardExpression = writeExpression(frameState, specialization, expression); - if (guard.isConstantTrueInSlowPath(context, mode.isUncached())) { + if (guard.isConstantTrueInSlowPath(mode.isUncached())) { assertion = CodeTreeBuilder.createBuilder().startStatement().string("// assert ").tree(guardExpression).end().build(); } else { condition.tree(guardExpression); @@ -7049,14 +7045,12 @@ static CodeTree createInlinedAccess(FrameState frameState, SpecializationData sp builder.tree(reference); if (frameState != null && frameState.isInlinedNode()) { if (value == null) { - builder.startCall(".get").tree(nodeReference).end().build(); + builder.startCall(".get").tree(nodeReference).end(); } else { - builder.startCall(".set").tree(nodeReference).tree(value).end().build(); + builder.startCall(".set").tree(nodeReference).tree(value).end(); } } else { - if (value == null) { - return builder.build(); - } else { + if (value != null) { builder.string(" = ").tree(value); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java index b883637ddbce..cb24c3c6fbbd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/GuardExpression.java @@ -122,80 +122,93 @@ public String toString() { return "Guard[" + (expression != null ? expression.asString() : "null") + "]"; } - public boolean isConstantTrueInSlowPath(ProcessorContext context, boolean uncached) { - if (libraryAcceptsGuard) { - return true; + private class TrueInSlowPathGuardDetector extends AbstractDSLExpressionReducer { + + private final boolean uncached; + private final boolean followBindings; + + TrueInSlowPathGuardDetector(boolean uncached, boolean followBindings) { + this.uncached = uncached; + this.followBindings = followBindings; } - DSLExpression reducedExpression = getExpression().reduce(new AbstractDSLExpressionReducer() { - - @Override - public DSLExpression visitVariable(Variable binary) { - // on the slow path we can assume all cache expressions inlined. - for (CacheExpression cache : source.getCaches()) { - if (cache.getSharedGroup() != null) { - // with sharing we cannot inline cache expressions. - continue; - } - if (ElementUtils.variableEquals(cache.getParameter().getVariableElement(), binary.getResolvedVariable())) { - return uncached ? cache.getUncachedExpression() : cache.getDefaultExpression(); - } - } - return super.visitVariable(binary); - } - @Override - public DSLExpression visitCall(Call binary) { - ExecutableElement method = binary.getResolvedMethod(); - if (!method.getSimpleName().toString().equals("equals")) { - return binary; + @Override + public DSLExpression visitVariable(Variable binary) { + // on the slow path we can assume all cache expressions inlined. + for (CacheExpression cache : source.getCaches()) { + if (cache.getSharedGroup() != null) { + // with sharing we cannot inline cache expressions. + continue; } - if (method.getModifiers().contains(Modifier.STATIC)) { - return binary; + if ((followBindings || !cache.isBind()) && ElementUtils.variableEquals(cache.getParameter().getVariableElement(), binary.getResolvedVariable())) { + return uncached ? cache.getUncachedExpression() : cache.getDefaultExpression(); } - if (!ElementUtils.typeEquals(method.getReturnType(), context.getType(boolean.class))) { - return binary; - } - if (method.getParameters().size() != 1) { - return binary; - } - // signature: receiver.equals(receiver) can be folded to true - DSLExpression receiver = binary.getReceiver(); - DSLExpression firstArg = binary.getParameters().get(0); - if (receiver instanceof Variable && firstArg instanceof Variable) { - if (receiver.equals(firstArg)) { - return new BooleanLiteral(true); - } + } + return super.visitVariable(binary); + } + + @Override + public DSLExpression visitCall(Call binary) { + ExecutableElement method = binary.getResolvedMethod(); + if (!method.getSimpleName().toString().equals("equals")) { + return binary; + } + if (method.getModifiers().contains(Modifier.STATIC)) { + return binary; + } + ProcessorContext context = ProcessorContext.getInstance(); + if (!ElementUtils.typeEquals(method.getReturnType(), context.getType(boolean.class))) { + return binary; + } + if (method.getParameters().size() != 1) { + return binary; + } + // signature: receiver.equals(receiver) can be folded to true + DSLExpression receiver = binary.getReceiver(); + DSLExpression firstArg = binary.getParameters().get(0); + if (receiver instanceof Variable && firstArg instanceof Variable) { + if (receiver.equals(firstArg)) { + return new BooleanLiteral(true); } - return super.visitCall(binary); } + return super.visitCall(binary); + } - @Override - public DSLExpression visitBinary(Binary binary) { - // signature: value == value can be folded to true - if (IDENTITY_FOLD_OPERATORS.contains(binary.getOperator())) { - if (binary.getLeft() instanceof Variable && binary.getRight() instanceof Variable) { - Variable leftVar = ((Variable) binary.getLeft()); - Variable rightVar = ((Variable) binary.getRight()); - if (leftVar.equals(rightVar)) { - // double and float cannot be folded as NaN is never identity equal - if (!ElementUtils.typeEquals(leftVar.getResolvedType(), context.getType(float.class)) && - !ElementUtils.typeEquals(leftVar.getResolvedType(), context.getType(double.class))) { - return new BooleanLiteral(true); - } + @Override + public DSLExpression visitBinary(Binary binary) { + // signature: value == value can be folded to true + if (IDENTITY_FOLD_OPERATORS.contains(binary.getOperator())) { + if (binary.getLeft() instanceof Variable && binary.getRight() instanceof Variable) { + Variable leftVar = ((Variable) binary.getLeft()); + Variable rightVar = ((Variable) binary.getRight()); + if (leftVar.equals(rightVar)) { + // double and float cannot be folded as NaN is never identity equal + ProcessorContext context = ProcessorContext.getInstance(); + if (!ElementUtils.typeEquals(leftVar.getResolvedType(), context.getType(float.class)) && + !ElementUtils.typeEquals(leftVar.getResolvedType(), context.getType(double.class))) { + return new BooleanLiteral(true); } } } - return super.visitBinary(binary); - } - }); + return super.visitBinary(binary); - Object o = reducedExpression.resolveConstant(); - if (o instanceof Boolean) { - if (((Boolean) o).booleanValue()) { - return true; - } } + } + + public boolean isConstantTrueInSlowPath(boolean uncached) { + if (libraryAcceptsGuard) { + return true; + } + Object o = getExpression().reduce(new TrueInSlowPathGuardDetector(uncached, true)).resolveConstant(); + if (o instanceof Boolean && (boolean) o) { + return true; + } + o = getExpression().reduce(new TrueInSlowPathGuardDetector(uncached, false)).resolveConstant(); + if (o instanceof Boolean && (boolean) o) { + return true; + } + return false; } From 51c098545df30afcc32f89ac50b5560e406c35ad Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 7 Dec 2022 12:50:32 +0100 Subject: [PATCH 210/312] Remove commented code. --- .../api/dsl/test/SharedCachedTest.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index 6e19f066a70f..4728f958c3da 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -59,6 +59,7 @@ import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundSharedObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UseGenerateInlineSharedNodeGen; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "unused"}) @@ -201,25 +202,6 @@ public void testUseGenerateInlineSharedNode() { AbstractPolyglotTest.assertFails(() -> node.execute(""), UnsupportedSpecializationException.class); } -// abstract static class InlineCacheSharingNode extends Node { -// -// abstract Object execute(Object arg); -// -// @Specialization(guards = "cachedArg == arg") -// Object s0(int arg, -// @Cached("arg") int cachedArg, -// @Shared("group") @Cached InlinedBranchProfile node) { -// return arg; -// } -// -// @Specialization(guards = "cachedArg == arg") -// Object s1(int arg, -// @Cached("arg") int cachedArg, -// @Shared("group") @Cached InlinedBranchProfile node) { -// return arg; -// } -// } - abstract static class UnboundCachedNodeNode extends Node { abstract Object execute(Object arg); From 35ab24385e434a37add9e59e4ff9ea72ee6bded5 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 7 Dec 2022 15:17:24 +0100 Subject: [PATCH 211/312] Add error for libraries that do not use @Bind("$node"). Add some more documentation for this behavior. --- truffle/docs/DSLNodeObjectInlining.md | 105 +++++++++++++++++- .../api/dsl/test/GenerateInlineTest.java | 40 +++++++ .../api/dsl/test/SharedCachedTest.java | 1 - .../dsl/processor/parser/NodeParser.java | 35 +++--- 4 files changed, 157 insertions(+), 24 deletions(-) diff --git a/truffle/docs/DSLNodeObjectInlining.md b/truffle/docs/DSLNodeObjectInlining.md index 7ef60aee8157..9c0b5b286a8a 100644 --- a/truffle/docs/DSLNodeObjectInlining.md +++ b/truffle/docs/DSLNodeObjectInlining.md @@ -72,7 +72,7 @@ This node is a candidate for node object inlining. The memory footprint is estim Following the recommendation of this warning, we modify our example as follows by adding the `@GenerateInline` annotation: -``` +```java @GenerateInline public abstract class AbsNode extends Node { @@ -104,7 +104,7 @@ This is necessary as inlined nodes become singletons and no longer have their ow Again, we follow the error and modify our example as follows: -``` +```java @GenerateInline public abstract class AbsNode extends Node { @@ -151,7 +151,7 @@ The cached type 'AbsNode' supports object-inlining. The footprint is estimated t We follow the recommendation in this message and enable object inlining: -``` +```java public abstract static class AddAbsNode extends Node { abstract long execute(long left, long right); @@ -189,7 +189,7 @@ This node is a candidate for node object inlining. The memory footprint is estim Again, we follow the guide and add a `@GenerateInline` annotation to `AddAbsNode`. Just like before, we also add a `Node` parameter to the execute method: -``` +```java @GenerateInline public abstract static class AddAbsNode extends Node { @@ -213,7 +213,7 @@ In addition, the DSL complained about the `inline=true` attribute, which is now To measure the overhead of our new inlinable `AddAbsNode` node, we declare a new operation called `Add4AbsNode` that adds four numbers using our `AddAbsNode` operation: -``` +```java @GenerateCached(alwaysInlineCached = true) public abstract static class Add4AbsNode extends Node { @@ -266,7 +266,7 @@ There is a last thing we should do. Since our `AddAbsNode` and `AbsNode` are no This is the final example: -``` +```java @GenerateInline @GenerateCached(false) public abstract static class AbsNode extends Node { @@ -339,6 +339,99 @@ Examples: * [NodeInliningExample2_3.java](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java) shows an example with full inlining. +### Passing along Nodes correctly + +The usage of inlined nodes requires to access and pass the correct node to execute methods of the respective inlined nodes. +It is a common mistake to pass the wrong node to execute methods. +Typically such mistakes fail with an error at runtime, the DSL emits warnings and errors depending on the situation. + + +_Inlined Nodes_ + +For inlined nodes that use themselves inlined nodes it is sufficient to pass a long the `Node` dynamic parameter. +For example. in the previous section we used `AddAbsNode` with a similar pattern: + +```java +@GenerateInline +@GenerateCached(false) +public abstract static class AddAbsNode extends Node { + + abstract long execute(Node node, long left, long right); + + @Specialization + static long add(Node node, long left, long right, + @Cached AbsNode leftAbs, + @Cached AbsNode rightAbs) { + return leftAbs.execute(node, left) + rightAbs.execute(node, right); + } + // ... +} +``` + +_Cached Nodes with Multiple Instances_ + +For nodes with specializations that may have multiple instances a `@Bind("this") Node node` parameter must be used to access the inline target node. +This is simliar to the `SumArrayNode` node in the advanced usage example. + +```java +@ImportStatic(AbstractArray.class) +public abstract static class SumArrayNode extends Node { + + abstract int execute(Object v0); + + @Specialization(guards = {"kind != null", "kind.type == array.getClass()"}, limit = "2", unroll = 2) + static int doDefault(Object array, + @Bind("this") Node node, + @Cached("resolve(array)") ArrayKind kind, + @Cached GetStoreNode getStore) { + Object castStore = kind.type.cast(array); + int[] store = getStore.execute(node, castStore); + int sum = 0; + for (int element : store) { + sum += element; + TruffleSafepoint.poll(node); + } + return sum; + } + + static Class getCachedClass(Object array) { + if (array instanceof AbstractArray) { + return array.getClass(); + } + return null; + } +} +``` + +_Exported Library Messages_ + +For exported library messages the `this` keyword is already reserved for the receiver value, so `$node` can be used instead. + +For example: + +```java + @ExportLibrary(ExampleArithmeticLibrary.class) + static class ExampleNumber { + + final long value; + + /* ... */ + + @ExportMessage + final long abs(@Bind("$node") Node node, + @Cached InlinedConditionProfile profile) { + if (profile.profile(node, this.value >= 0)) { + return this.value; + } else { + return -this.value; + } + } + + } +``` + + + ### Limitations Node object inlining supports arbitrary deep nestings. However, there are some limitations to using `@GenerateInline`. diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index c0523c2785aa..658473fc5595 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -109,7 +109,10 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; import com.oracle.truffle.api.nodes.ExecutableNode; import com.oracle.truffle.api.nodes.Node; @@ -2192,4 +2195,41 @@ static String s0(Node node, int value, } + @ExportLibrary(InteropLibrary.class) + @SuppressWarnings({"static-method", "unused"}) + static class ErrorUseBindParamterInLibraryExport1 implements TruffleObject { + + @ExportMessage + final boolean isPointer() { + return false; + } + + @ExpectError("For this specialization with inlined cache parameters a '@Bind(\"$node\") Node node' parameter must be declared.%") + @ExportMessage + long asPointer(@Cached InlinedBranchProfile profile) { + return 0L; + } + + } + + @ExportLibrary(InteropLibrary.class) + @SuppressWarnings({"static-method", "unused"}) + static class ErrorUseBindParamterInLibraryExport2 implements TruffleObject { + + @ExportMessage + final boolean isPointer() { + return false; + } + + @ExportMessage + static class AsPointer { + @ExpectError("For this specialization with inlined cache parameters a '@Bind(\"$node\") Node node' parameter must be declared.%") + @Specialization + static long asPointer(ErrorUseBindParamterInLibraryExport2 receiver, @Cached InlinedBranchProfile profile) { + return 0L; + } + } + + } + } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index 4728f958c3da..11816c140326 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -59,7 +59,6 @@ import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundSharedObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UseGenerateInlineSharedNodeGen; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "unused"}) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index c9ef94eefea3..8472564eb312 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -567,14 +567,13 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline } } if (usesInlinedNodes) { - boolean firstParameterNode = false; - for (Parameter p : specialization.getSignatureParameters()) { - firstParameterNode = p.isDeclared(); - break; - } - boolean isStatic = element.getModifiers().contains(Modifier.STATIC); if (node.isGenerateInline()) { + boolean firstParameterNode = false; + for (Parameter p : specialization.getSignatureParameters()) { + firstParameterNode = p.isDeclared(); + break; + } if (!isStatic || !firstParameterNode) { specialization.addError("For @%s annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. " + "When using inlinable nodes it is a common mistake to pass the wrong inline target node to inlined cached values. " + @@ -583,7 +582,7 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline "Use the first node parameter and pass it along to inlined caches. ", getSimpleName(types.GenerateInline)); } - } else if (FlatNodeGenFactory.useSpecializationClass(specialization)) { + } else if (FlatNodeGenFactory.useSpecializationClass(specialization) || mode == ParseMode.EXPORTED_MESSAGE) { boolean hasNodeParameter = false; for (CacheExpression cache : specialization.getCaches()) { @@ -595,25 +594,27 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline if (!isStatic || !hasNodeParameter) { if (!hasNodeParameter) { + String nodeParameter; + if (mode == ParseMode.EXPORTED_MESSAGE) { + nodeParameter = String.format("@%s(\"$node\") Node node", getSimpleName(types.Bind)); + } else { + nodeParameter = String.format("@%s(\"this\") Node node", getSimpleName(types.Bind)); + } + String message = String.format( - "For this specialization with inlined cache parameters a '@%s(\"this\") Node node' parameter must be declared. " + // + "For this specialization with inlined cache parameters a '%s' parameter must be declared. " + // "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + - "To resolve this add a '@%s(\"this\") Node node' parameter to the specialization method. " + + "To resolve this add a '%s' parameter to the specialization method. " + "Use the new node parameter and pass it along to cached inlined nodes or profiles. ", - getSimpleName(types.Bind), - getSimpleName(types.Bind), - getSimpleName(types.Bind)); + nodeParameter, nodeParameter); specialization.addError(message); - } else { + } else if (mode != ParseMode.EXPORTED_MESSAGE) { String message = String.format( "For this specialization with inlined cache parameters it is recommended to use the static modifier. " + // "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + "To resolve this add the static keyword to the method and fix potential misuses of the 'this' reference. " + - "If a node needs to access instance fields it is recommended to suppress this warning.", - getSimpleName(types.Bind), - getSimpleName(types.Bind), - getSimpleName(types.Bind)); + "If a node needs to access instance fields it is recommended to suppress this warning."); specialization.addSuppressableWarning(TruffleSuppressedWarnings.STATIC_METHOD, message); } From 1e36f260b56a72f930cf001a07f403a6faae8aeb Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 7 Dec 2022 15:48:25 +0100 Subject: [PATCH 212/312] Improve documentation. --- truffle/docs/DSLNodeObjectInlining.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/truffle/docs/DSLNodeObjectInlining.md b/truffle/docs/DSLNodeObjectInlining.md index 9c0b5b286a8a..fd05cc93f4bb 100644 --- a/truffle/docs/DSLNodeObjectInlining.md +++ b/truffle/docs/DSLNodeObjectInlining.md @@ -263,6 +263,7 @@ In addition to the memory footprint advantages, interpreter-only execution may b After compilation using partial evaluation, both cached and uncached versions are expected to perform the same. There is a last thing we should do. Since our `AddAbsNode` and `AbsNode` are no longer used in their cached version, we can turn off cached generation using `@GenerateCached(false)` to save Java code footprint. +After doing this we can omit the `alwaysInlineCached` property in the `@GenerateCached` annotation as nodes are automatically inlined if only an inlined version is available. This is the final example: @@ -343,7 +344,7 @@ Examples: The usage of inlined nodes requires to access and pass the correct node to execute methods of the respective inlined nodes. It is a common mistake to pass the wrong node to execute methods. -Typically such mistakes fail with an error at runtime, the DSL emits warnings and errors depending on the situation. +Typically such mistakes fail with an error at runtime, but the DSL also emits warnings and errors depending on the situation at compile time. _Inlined Nodes_ From 23af9d95a19d024def0c9eac4ad1c39f774ebb23 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 7 Dec 2022 17:48:05 +0100 Subject: [PATCH 213/312] Fix node object descriptor can use inlined profiles. --- .../sl/nodes/interop/NodeObjectDescriptor.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java index b1ceb72f42e1..73ca62ecc0dc 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/interop/NodeObjectDescriptor.java @@ -40,6 +40,7 @@ */ package com.oracle.truffle.sl.nodes.interop; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.interop.InteropLibrary; @@ -48,7 +49,8 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.sl.runtime.SLStrings; @@ -73,11 +75,11 @@ public static NodeObjectDescriptor writeVariable(TruffleString name, SourceSecti return new WriteDescriptor(name, sourceSection); } - Object readMember(String member, @Cached BranchProfile error) throws UnknownIdentifierException { + Object readMember(String member, @Bind("$node") Node node, @Cached InlinedBranchProfile error) throws UnknownIdentifierException { if (isMemberReadable(member)) { return name; } else { - error.enter(); + error.enter(node); throw UnknownIdentifierException.create(member); } } @@ -113,8 +115,8 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { @Override @ExportMessage - Object readMember(String member, @Cached(inline = false) BranchProfile error) throws UnknownIdentifierException { - return super.readMember(member, error); + Object readMember(String member, @Bind("$node") Node node, @Cached InlinedBranchProfile error) throws UnknownIdentifierException { + return super.readMember(member, node, error); } } @@ -151,8 +153,8 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { @Override @ExportMessage - Object readMember(String member, @Cached(inline = false) BranchProfile error) throws UnknownIdentifierException { - super.readMember(member, error); // To verify readability + Object readMember(String member, @Bind("$node") Node node, @Cached InlinedBranchProfile error) throws UnknownIdentifierException { + super.readMember(member, node, error); // To verify readability return nameSymbol; } } From 14d932473d6be7cb58ce1fc4431a068647c90ff2 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 8 Dec 2022 13:11:48 +0100 Subject: [PATCH 214/312] Fix guard expressions must not be folded on the fast-path if they reach fallback (need state bit). --- .../api/dsl/test/NeverDefaultTest.java | 40 +++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 31 +++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index b309a13d2a07..ae3c65e45769 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -51,6 +51,7 @@ import org.junit.Test; import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -64,6 +65,7 @@ import com.oracle.truffle.api.dsl.test.CachedReachableFallbackTest.GuardNode; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.CachedGuardAndFallbackNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.FallbackManyCachesNodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.FallbackWithCacheClassNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.GuardCacheNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.MultiInstanceCacheNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.MultiInstanceNodeCacheNodeGen; @@ -820,6 +822,44 @@ public void testFallbackManyCachesNode() throws InterruptedException { }); } + abstract static class FallbackWithCacheClass extends Node { + abstract boolean execute(Object obj); + + static boolean myGuard(Object obj) { + return !(obj instanceof Integer); + } + + @Specialization(guards = {"obj.getClass() == cachedClass", "myGuard(cachedClass)"}, limit = "1") + static boolean doItCached(Object obj, + @Cached("obj.getClass()") @SuppressWarnings("unused") Class cachedClass) { + return myGuard(cachedClass); + } + + @Fallback + @SuppressWarnings("unused") + protected static boolean fromObjectGeneric(Object value) { + return true; + } + } + + @Test + public void testFallbackWithCacheClass() throws InterruptedException { + assertInParallel(FallbackWithCacheClassNodeGen::create, (node, threadIndex, objectIndex) -> { + Object arg; + switch (threadIndex % 2) { + case 0: + arg = ""; + break; + case 1: + arg = 42; + break; + default: + throw CompilerDirectives.shouldNotReachHere(); + } + assertTrue(node.execute(arg)); + }); + } + @SuppressWarnings("unused") public abstract static class InnerGuardNode extends Node { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 7b7f4370f2d4..5effbfa4fe22 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6036,7 +6036,6 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, } CodeTreeBuilder builder = new CodeTreeBuilder(null); - List triples = new ArrayList<>(); StateQuery query = StateQuery.create(GuardActive.class, guard); SpecializationStateReference stateRef = null; if (guardStateBit) { @@ -6047,11 +6046,14 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, stateRef = createStateReference(frameState, specialization, query); } - boolean store = !guardStateBit; - Set boundCaches = group.getSpecialization().getBoundCaches(guard.getExpression(), true); - triples.addAll(initializeCaches(frameState, mode, group, boundCaches, store, guardStateBit)); + List triples = new ArrayList<>(); + + /* + * Initialize but not yet persist caches. + */ + triples.addAll(initializeCaches(frameState, mode, group, boundCaches, true, false)); triples.addAll(initializeCasts(frameState, group, guard.getExpression(), mode)); IfTriple.materialize(builder, triples, true); @@ -6063,6 +6065,14 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, builder.startIf().tree(stateRef.bitSet.createNotContains(stateRef.reference, StateQuery.create(GuardActive.class, guard))).end().startBlock(); + /* + * Persist caches now, Only if the guard bit has not yet been set. + */ + triples = new ArrayList<>(); + triples.addAll(initializeCaches(innerFrameState, mode, group, boundCaches, false, true)); + triples.addAll(initializeCasts(innerFrameState, group, guard.getExpression(), mode)); + IfTriple.materialize(builder, triples, true); + builder.startStatement(); builder.tree(stateRef.reference).string(" = "); builder.tree(stateRef.bitSet.createSetExpression(stateRef.reference, query, true)); @@ -6636,7 +6646,18 @@ private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationDat CodeTree assertion = null; // overrule with assertion if (mode.isFastPath()) { CodeTree guardExpression = writeExpression(frameState, specialization, expression); - if (!specialization.isDynamicParameterBound(expression, true) && !guard.isWeakReferenceGuard()) { + + /* + * We do not need to invoke a guard on the fast-path if: + * + * (1) the guard does not bind any dynamic parameter, only cached valuees. + * + * (2) The guard is not a weak reference. Weak references do not bind dynamic + * parameters, but need to be checked each time. + * + * (3) The guard needs a state bit and may be partially initialized. + */ + if (!specialization.isDynamicParameterBound(expression, true) && !guard.isWeakReferenceGuard() && !guardNeedsNodeStateBit(specialization, guard)) { assertion = CodeTreeBuilder.createBuilder().startAssert().tree(guardExpression).end().build(); } else { condition.tree(guardExpression); From 34fa78895ee53eedfdd5673d607e675045f4b6f9 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 8 Dec 2022 13:21:58 +0100 Subject: [PATCH 215/312] Fix invalid test modification. --- .../oracle/truffle/api/test/polyglot/HostClassLoadingTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java index 9b111057d8ee..b7ebb21b4c03 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/HostClassLoadingTest.java @@ -337,7 +337,7 @@ public void testMultipleJarStreams() throws IOException, InteropException { long bytes = HostClassLoadingTestClass3.countBytes(stream); // weird behavior on osx that sometimes countBytes returns Integer.MAX_VALUE if (bytes != Integer.MAX_VALUE) { - assertEquals(HostClassLoadingTestClass3.countBytes(stream), result); + assertEquals(bytes, result); } } } finally { From d2b21648d95cdf34b482717eee05fd9cdf9e7ecf Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 8 Dec 2022 13:44:50 +0100 Subject: [PATCH 216/312] Improve validation of specializations that use cached inlined nodes. --- .../api/dsl/test/GenerateInlineTest.java | 4 +- .../api/dsl/test/NeverDefaultTest.java | 2 +- .../dsl/processor/parser/NodeParser.java | 66 ++++++++++--------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index 658473fc5595..452f7f99a5e2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -1635,7 +1635,7 @@ public abstract static class ErrorGenerateInlineNeedsStaticNode extends Node { abstract Object execute(Node node, Object arg); - @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. %") + @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must be static%") @Specialization Object doInt(Node node, int arg, @Cached SimpleNode simpleNode) { @@ -1649,7 +1649,7 @@ public abstract static class ErrorGenerateInlineNeedsNeedsParameterNode extends abstract Object execute(Node node, Object arg); - @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. %") + @ExpectError("For @GenerateInline annotated nodes all specialization methods with inlined cached values must declare 'Node node' dynamic parameter.%") @Specialization static Object doInt(int arg, @Cached SimpleNode simpleNode) { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index ae3c65e45769..848f6442d0da 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -830,7 +830,7 @@ static boolean myGuard(Object obj) { } @Specialization(guards = {"obj.getClass() == cachedClass", "myGuard(cachedClass)"}, limit = "1") - static boolean doItCached(Object obj, + static boolean doItCached(@SuppressWarnings("unused") Object obj, @Cached("obj.getClass()") @SuppressWarnings("unused") Class cachedClass) { return myGuard(cachedClass); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 8472564eb312..7056492a5f29 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -574,12 +574,15 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline firstParameterNode = p.isDeclared(); break; } - if (!isStatic || !firstParameterNode) { - specialization.addError("For @%s annotated nodes all specialization methods with inlined cached values must be static and declare the a 'Node node' parameter. " + - "When using inlinable nodes it is a common mistake to pass the wrong inline target node to inlined cached values. " + - "Making the method static avoids this mistake as the invalid receiver node can no longer be accessed. " + // - "To resolve this add the static keyword and the 'Node node' parameter as first parameter to the specialization method. " + // - "Use the first node parameter and pass it along to inlined caches. ", + if (!firstParameterNode) { + specialization.addError("For @%s annotated nodes all specialization methods with inlined cached values must declare 'Node node' dynamic parameter. " + + "This parameter must be passed along to inlined cached values. " + + "To resolve this add the 'Node node' parameter as first parameter to the specialization method and pass the value along to inlined cached values.", + getSimpleName(types.GenerateInline)); + } else if (!isStatic) { + specialization.addError("For @%s annotated nodes all specialization methods with inlined cached values must be static. " + + "The method must be static to avoid accidently passing the wrong node parameter to inlined cached nodes. " + + "To resolve this add the static keyword to the specialization method. ", getSimpleName(types.GenerateInline)); } } else if (FlatNodeGenFactory.useSpecializationClass(specialization) || mode == ParseMode.EXPORTED_MESSAGE) { @@ -592,33 +595,34 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline } } - if (!isStatic || !hasNodeParameter) { - if (!hasNodeParameter) { - String nodeParameter; - if (mode == ParseMode.EXPORTED_MESSAGE) { - nodeParameter = String.format("@%s(\"$node\") Node node", getSimpleName(types.Bind)); - } else { - nodeParameter = String.format("@%s(\"this\") Node node", getSimpleName(types.Bind)); - } - - String message = String.format( - "For this specialization with inlined cache parameters a '%s' parameter must be declared. " + // - "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + - "To resolve this add a '%s' parameter to the specialization method. " + - "Use the new node parameter and pass it along to cached inlined nodes or profiles. ", - nodeParameter, nodeParameter); - - specialization.addError(message); - } else if (mode != ParseMode.EXPORTED_MESSAGE) { - String message = String.format( - "For this specialization with inlined cache parameters it is recommended to use the static modifier. " + // - "With inlined caches it is a common mistake to pass the wrong inline target node to inlined cached nodes or profiles. " + - "To resolve this add the static keyword to the method and fix potential misuses of the 'this' reference. " + - "If a node needs to access instance fields it is recommended to suppress this warning."); - - specialization.addSuppressableWarning(TruffleSuppressedWarnings.STATIC_METHOD, message); + if (!hasNodeParameter) { + String nodeParameter; + if (mode == ParseMode.EXPORTED_MESSAGE) { + nodeParameter = String.format("@%s(\"$node\") Node node", getSimpleName(types.Bind)); + } else { + nodeParameter = String.format("@%s(\"this\") Node node", getSimpleName(types.Bind)); } + + String message = String.format( + "For this specialization with inlined cache parameters a '%s' parameter must be declared. " + // + "This parameter must be passed along to inlined cached values. " + + "To resolve this add a '%s' parameter to the specialization method and pass the value along to inlined cached values.", + nodeParameter, nodeParameter); + + specialization.addError(message); + + } else if (!isStatic && mode != ParseMode.EXPORTED_MESSAGE) { + // The static keyword does not make sense for exported messages, where the + // receiver would be incompatible anyway. + + String message = String.format( + "For this specialization with inlined cache parameters it is recommended to use the static modifier. " + // + "The method should be static to avoid accidently passing the wrong node parameter to inlined cached nodes. " + + "To resolve this add the static keyword to the specialization method. "); + + specialization.addSuppressableWarning(TruffleSuppressedWarnings.STATIC_METHOD, message); } + } } From 70cd994ceb2c19afc2e136d6195516aa95c467a4 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 11:13:46 +0100 Subject: [PATCH 217/312] Remove debug output. --- .../truffle/dsl/processor/java/transform/OrganizedImports.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java index a3e523b894ce..557976047fbd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @@ -168,9 +168,6 @@ private String createDeclaredTypeName(Element enclosedElement, DeclaredType type } } if (raw) { - if (name.equals("com.oracle.truffle.api.dsl.test.Cached")) { - System.out.println(); - } return name; } From 77180595396aedf5ca363eaa81c3f65198e89e7f Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 11:58:55 +0100 Subject: [PATCH 218/312] Add @NeverDefault to create methods of nodes of TruffleString. --- .../api/strings/MutableTruffleString.java | 11 ++++ .../truffle/api/strings/TruffleString.java | 62 +++++++++++++++++++ .../api/strings/TruffleStringBuilder.java | 10 +++ .../api/strings/TruffleStringIterator.java | 3 + 4 files changed, 86 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java index fc6090f63f62..c1bd1ddd6fe0 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/MutableTruffleString.java @@ -51,6 +51,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @@ -175,6 +176,7 @@ static MutableTruffleString fromByteArray(byte[] value, int byteOffset, int byte * * @since 22.1 */ + @NeverDefault public static FromByteArrayNode create() { return MutableTruffleStringFactory.FromByteArrayNodeGen.create(); } @@ -265,6 +267,7 @@ MutableTruffleString fromNativePointer(Object pointerObject, int byteOffset, int * * @since 22.1 */ + @NeverDefault public static FromNativePointerNode create() { return MutableTruffleStringFactory.FromNativePointerNodeGen.create(); } @@ -326,6 +329,7 @@ static MutableTruffleString fromTruffleString(TruffleString a, Encoding expected * * @since 22.1 */ + @NeverDefault public static AsMutableTruffleStringNode create() { return MutableTruffleStringFactory.AsMutableTruffleStringNodeGen.create(); } @@ -379,6 +383,7 @@ static MutableTruffleString fromTruffleString(AbstractTruffleString a, Encoding * * @since 22.1 */ + @NeverDefault public static AsManagedNode create() { return MutableTruffleStringFactory.AsManagedNodeGen.create(); } @@ -426,6 +431,7 @@ static void writeByte(MutableTruffleString a, int byteIndex, byte value, Encodin * * @since 22.1 */ + @NeverDefault public static WriteByteNode create() { return MutableTruffleStringFactory.WriteByteNodeGen.create(); } @@ -488,6 +494,7 @@ final MutableTruffleString concat(AbstractTruffleString a, AbstractTruffleString * * @since 22.1 */ + @NeverDefault public static ConcatNode create() { return MutableTruffleStringFactory.ConcatNodeGen.create(); } @@ -553,6 +560,7 @@ MutableTruffleString substring(AbstractTruffleString a, int fromIndex, int lengt * * @since 22.1 */ + @NeverDefault public static SubstringNode create() { return MutableTruffleStringFactory.SubstringNodeGen.create(); } @@ -615,6 +623,7 @@ static MutableTruffleString createSubstring(AbstractTruffleString a, int byteOff * * @since 22.1 */ + @NeverDefault public static SubstringByteIndexNode create() { return MutableTruffleStringFactory.SubstringByteIndexNodeGen.create(); } @@ -680,6 +689,7 @@ static MutableTruffleString transcodeAndCopy(AbstractTruffleString a, Encoding e * * @since 22.1 */ + @NeverDefault public static MutableTruffleString.SwitchEncodingNode create() { return MutableTruffleStringFactory.SwitchEncodingNodeGen.create(); } @@ -735,6 +745,7 @@ static MutableTruffleString reinterpret(AbstractTruffleString a, Encoding expect * * @since 22.1 */ + @NeverDefault public static MutableTruffleString.ForceEncodingNode create() { return MutableTruffleStringFactory.ForceEncodingNodeGen.create(); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index 867537e95e38..ed15ab147785 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -80,6 +80,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; @@ -1355,6 +1356,7 @@ WithMask doCreate(AbstractTruffleString a, byte[] mask, Encoding expectedEncodin * * @since 22.1 */ + @NeverDefault public static TruffleString.WithMask.CreateNode create() { return TruffleStringFactory.WithMaskFactory.CreateNodeGen.create(); } @@ -1415,6 +1417,7 @@ WithMask doCreate(AbstractTruffleString a, char[] mask) { * * @since 22.1 */ + @NeverDefault public static TruffleString.WithMask.CreateUTF16Node create() { return TruffleStringFactory.WithMaskFactory.CreateUTF16NodeGen.create(); } @@ -1477,6 +1480,7 @@ WithMask doCreate(AbstractTruffleString a, int[] mask) { * * @since 22.1 */ + @NeverDefault public static TruffleString.WithMask.CreateUTF32Node create() { return TruffleStringFactory.WithMaskFactory.CreateUTF32NodeGen.create(); } @@ -1699,6 +1703,7 @@ final TruffleString fromCodePoint(int c, Encoding enc, boolean allowUTF16Surroga * * @since 22.1 */ + @NeverDefault public static FromCodePointNode create() { return TruffleStringFactory.FromCodePointNodeGen.create(); } @@ -1787,6 +1792,7 @@ private static String nonAsciiCompatibleMessage(Encoding enc) { * * @since 22.1 */ + @NeverDefault public static FromLongNode create() { return TruffleStringFactory.FromLongNodeGen.create(); } @@ -1865,6 +1871,7 @@ final TruffleString fromByteArray(byte[] value, int byteOffset, int byteLength, * * @since 22.1 */ + @NeverDefault public static FromByteArrayNode create() { return TruffleStringFactory.FromByteArrayNodeGen.create(); } @@ -1969,6 +1976,7 @@ final TruffleString doNonEmpty(char[] value, int charOffset, int charLength, * * @since 22.1 */ + @NeverDefault public static FromCharArrayUTF16Node create() { return TruffleStringFactory.FromCharArrayUTF16NodeGen.create(); } @@ -2055,6 +2063,7 @@ final TruffleString doUTF16(String javaString, int charOffset, int length, Encod * * @since 22.1 */ + @NeverDefault public static FromJavaStringNode create() { return TruffleStringFactory.FromJavaStringNodeGen.create(); } @@ -2150,6 +2159,7 @@ final TruffleString doNonEmpty(int[] value, int intOffset, int length, * * @since 22.1 */ + @NeverDefault public static FromIntArrayUTF32Node create() { return TruffleStringFactory.FromIntArrayUTF32NodeGen.create(); } @@ -2243,6 +2253,7 @@ final TruffleString fromNativePointer(Object pointerObject, int byteOffset, int * * @since 22.1 */ + @NeverDefault public static FromNativePointerNode create() { return TruffleStringFactory.FromNativePointerNodeGen.create(); } @@ -2297,6 +2308,7 @@ final TruffleString doDefault(AbstractTruffleString value, Encoding expectedEnco * * @since 22.1 */ + @NeverDefault public static AsTruffleStringNode create() { return TruffleStringFactory.AsTruffleStringNodeGen.create(); } @@ -2420,6 +2432,7 @@ TruffleString mutable(MutableTruffleString a, Encoding expectedEncoding, boolean * * @since 22.1 */ + @NeverDefault public static AsManagedNode create() { return TruffleStringFactory.AsManagedNodeGen.create(); } @@ -2512,6 +2525,7 @@ final void doMaterialize(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static MaterializeNode create() { return TruffleStringFactory.MaterializeNodeGen.create(); } @@ -2555,6 +2569,7 @@ final CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static GetCodeRangeNode create() { return TruffleStringFactory.GetCodeRangeNodeGen.create(); } @@ -2609,6 +2624,7 @@ final CodeRange getCodeRange(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static GetByteCodeRangeNode create() { return TruffleStringFactory.GetByteCodeRangeNodeGen.create(); } @@ -2665,6 +2681,7 @@ final boolean codeRangeEquals(AbstractTruffleString a, CodeRange codeRange, * * @since 22.1 */ + @NeverDefault public static CodeRangeEqualsNode create() { return TruffleStringFactory.CodeRangeEqualsNodeGen.create(); } @@ -2709,6 +2726,7 @@ final boolean isValid(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static IsValidNode create() { return TruffleStringFactory.IsValidNodeGen.create(); } @@ -2833,6 +2851,7 @@ static CompactionLevel getStringCompactionLevel(AbstractTruffleString a, Encodin * * @since 23.0 */ + @NeverDefault public static GetStringCompactionLevelNode create() { return TruffleStringFactory.GetStringCompactionLevelNodeGen.create(); } @@ -2880,6 +2899,7 @@ final int get(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static CodePointLengthNode create() { return TruffleStringFactory.CodePointLengthNodeGen.create(); } @@ -2936,6 +2956,7 @@ final int calculateHash(AbstractTruffleString a, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static HashCodeNode create() { return TruffleStringFactory.HashCodeNodeGen.create(); } @@ -2983,6 +3004,7 @@ final int doRead(AbstractTruffleString a, int i, Encoding expectedEncoding, * * @since 22.1 */ + @NeverDefault public static ReadByteNode create() { return TruffleStringFactory.ReadByteNodeGen.create(); } @@ -3034,6 +3056,7 @@ final char doRead(AbstractTruffleString a, int i, * * @since 22.1 */ + @NeverDefault public static ReadCharUTF16Node create() { return TruffleStringFactory.ReadCharUTF16NodeGen.create(); } @@ -3106,6 +3129,7 @@ final int translate(AbstractTruffleString a, int byteIndex, Encoding expectedEnc * * @since 22.1 */ + @NeverDefault public static ByteLengthOfCodePointNode create() { return TruffleStringFactory.ByteLengthOfCodePointNodeGen.create(); } @@ -3161,6 +3185,7 @@ final int translate(AbstractTruffleString a, int byteOffset, int byteIndex, Enco * * @since 22.2 */ + @NeverDefault public static ByteIndexToCodePointIndexNode create() { return TruffleStringFactory.ByteIndexToCodePointIndexNodeGen.create(); } @@ -3217,6 +3242,7 @@ final int translate(AbstractTruffleString a, int byteOffset, int codepointIndex, * * @since 22.1 */ + @NeverDefault public static CodePointIndexToByteIndexNode create() { return TruffleStringFactory.CodePointIndexToByteIndexNodeGen.create(); } @@ -3295,6 +3321,7 @@ final int readCodePoint(AbstractTruffleString a, int i, Encoding expectedEncodin * * @since 22.1 */ + @NeverDefault public static CodePointAtIndexNode create() { return TruffleStringFactory.CodePointAtIndexNodeGen.create(); } @@ -3356,6 +3383,7 @@ final int readCodePoint(AbstractTruffleString a, int byteIndex, Encoding expecte * * @since 22.1 */ + @NeverDefault public static CodePointAtByteIndexNode create() { return TruffleStringFactory.CodePointAtByteIndexNodeGen.create(); } @@ -3427,6 +3455,7 @@ private static boolean noneIsAscii(Node location, byte[] values) { * * @since 22.1 */ + @NeverDefault public static ByteIndexOfAnyByteNode create() { return TruffleStringFactory.ByteIndexOfAnyByteNodeGen.create(); } @@ -3494,6 +3523,7 @@ private static boolean noneInCodeRange(Node location, int codeRange, char[] valu * * @since 22.1 */ + @NeverDefault public static CharIndexOfAnyCharUTF16Node create() { return TruffleStringFactory.CharIndexOfAnyCharUTF16NodeGen.create(); } @@ -3560,6 +3590,7 @@ private static boolean noneInCodeRange(Node location, int codeRange, int[] value * * @since 22.1 */ + @NeverDefault public static IntIndexOfAnyIntUTF32Node create() { return TruffleStringFactory.IntIndexOfAnyIntUTF32NodeGen.create(); } @@ -3614,6 +3645,7 @@ final int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int t * * @since 22.1 */ + @NeverDefault public static IndexOfCodePointNode create() { return TruffleStringFactory.IndexOfCodePointNodeGen.create(); } @@ -3666,6 +3698,7 @@ final int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, i * * @since 22.1 */ + @NeverDefault public static ByteIndexOfCodePointNode create() { return TruffleStringFactory.ByteIndexOfCodePointNodeGen.create(); } @@ -3720,6 +3753,7 @@ final int doIndexOf(AbstractTruffleString a, int codepoint, int fromIndex, int t * * @since 22.1 */ + @NeverDefault public static LastIndexOfCodePointNode create() { return TruffleStringFactory.LastIndexOfCodePointNodeGen.create(); } @@ -3772,6 +3806,7 @@ final int doIndexOf(AbstractTruffleString a, int codepoint, int fromByteIndex, i * * @since 22.1 */ + @NeverDefault public static LastByteIndexOfCodePointNode create() { return TruffleStringFactory.LastByteIndexOfCodePointNodeGen.create(); } @@ -3840,6 +3875,7 @@ final int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fr * * @since 22.1 */ + @NeverDefault public static IndexOfStringNode create() { return TruffleStringFactory.IndexOfStringNodeGen.create(); } @@ -3931,6 +3967,7 @@ final int indexOfString(AbstractTruffleString a, AbstractTruffleString b, int fr * * @since 22.1 */ + @NeverDefault public static ByteIndexOfStringNode create() { return TruffleStringFactory.ByteIndexOfStringNodeGen.create(); } @@ -3999,6 +4036,7 @@ final int lastIndexOfString(AbstractTruffleString a, AbstractTruffleString b, in * * @since 22.1 */ + @NeverDefault public static LastIndexOfStringNode create() { return TruffleStringFactory.LastIndexOfStringNodeGen.create(); } @@ -4090,6 +4128,7 @@ final int lastByteIndexOfString(AbstractTruffleString a, AbstractTruffleString b * * @since 22.1 */ + @NeverDefault public static LastByteIndexOfStringNode create() { return TruffleStringFactory.LastByteIndexOfStringNodeGen.create(); } @@ -4158,6 +4197,7 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, Encoding expectedE * * @since 22.1 */ + @NeverDefault public static CompareBytesNode create() { return TruffleStringFactory.CompareBytesNodeGen.create(); } @@ -4224,6 +4264,7 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, * * @since 22.1 */ + @NeverDefault public static CompareCharsUTF16Node create() { return TruffleStringFactory.CompareCharsUTF16NodeGen.create(); } @@ -4290,6 +4331,7 @@ int compare(AbstractTruffleString a, AbstractTruffleString b, * * @since 22.1 */ + @NeverDefault public static CompareIntsUTF32Node create() { return TruffleStringFactory.CompareIntsUTF32NodeGen.create(); } @@ -4362,6 +4404,7 @@ final boolean regionEquals(AbstractTruffleString a, int fromIndexA, AbstractTruf * * @since 22.1 */ + @NeverDefault public static RegionEqualNode create() { return TruffleStringFactory.RegionEqualNodeGen.create(); } @@ -4449,6 +4492,7 @@ boolean regionEquals(AbstractTruffleString a, int byteFromIndexA, AbstractTruffl * * @since 22.1 */ + @NeverDefault public static RegionEqualByteIndexNode create() { return TruffleStringFactory.RegionEqualByteIndexNodeGen.create(); } @@ -4583,6 +4627,7 @@ private static TruffleString asTruffleStringLoose(AbstractTruffleString a, Encod * * @since 22.1 */ + @NeverDefault public static ConcatNode create() { return TruffleStringFactory.ConcatNodeGen.create(); } @@ -4666,6 +4711,7 @@ final TruffleString repeat(AbstractTruffleString a, int n, Encoding expectedEnco * * @since 22.1 */ + @NeverDefault public static RepeatNode create() { return TruffleStringFactory.RepeatNodeGen.create(); } @@ -4729,6 +4775,7 @@ final TruffleString substring(AbstractTruffleString a, int fromIndex, int length * * @since 22.1 */ + @NeverDefault public static SubstringNode create() { return TruffleStringFactory.SubstringNodeGen.create(); } @@ -4791,6 +4838,7 @@ final TruffleString substringRaw(AbstractTruffleString a, int fromByteIndex, int * * @since 22.1 */ + @NeverDefault public static SubstringByteIndexNode create() { return TruffleStringFactory.SubstringByteIndexNodeGen.create(); } @@ -4897,6 +4945,7 @@ static boolean checkContentEquals( * * @since 22.1 */ + @NeverDefault public static EqualNode create() { return TruffleStringFactory.EqualNodeGen.create(); } @@ -5119,6 +5168,7 @@ final int doParse(AbstractTruffleString a, int radix, * * @since 22.1 */ + @NeverDefault public static ParseIntNode create() { return TruffleStringFactory.ParseIntNodeGen.create(); } @@ -5170,6 +5220,7 @@ final long doParse(AbstractTruffleString a, int radix, * * @since 22.1 */ + @NeverDefault public static ParseLongNode create() { return TruffleStringFactory.ParseLongNodeGen.create(); } @@ -5222,6 +5273,7 @@ static boolean isLazyLongSafeInteger(AbstractTruffleString a) { * * @since 22.1 */ + @NeverDefault public static ParseDoubleNode create() { return TruffleStringFactory.ParseDoubleNodeGen.create(); } @@ -5310,6 +5362,7 @@ private InternalByteArray inflate(AbstractTruffleString a, Object arrayA, int st * * @since 22.1 */ + @NeverDefault public static GetInternalByteArrayNode create() { return TruffleStringFactory.GetInternalByteArrayNodeGen.create(); } @@ -5361,6 +5414,7 @@ static Object getNativePointer(AbstractTruffleString a, Encoding expectedEncodin * * @since 22.1 */ + @NeverDefault public static GetInternalNativePointerNode create() { return TruffleStringFactory.GetInternalNativePointerNodeGen.create(); } @@ -5419,6 +5473,7 @@ final void doCopy(AbstractTruffleString a, int byteFromIndexA, byte[] dst, int b * * @since 22.1 */ + @NeverDefault public static CopyToByteArrayNode create() { return TruffleStringFactory.CopyToByteArrayNodeGen.create(); } @@ -5550,6 +5605,7 @@ void doCopy(AbstractTruffleString a, int byteFromIndexA, Object pointerObject, i * * @since 22.1 */ + @NeverDefault public static CopyToNativeMemoryNode create() { return TruffleStringFactory.CopyToNativeMemoryNodeGen.create(); } @@ -5640,6 +5696,7 @@ static String doMutable(MutableTruffleString a, * * @since 22.1 */ + @NeverDefault public static ToJavaStringNode create() { return TruffleStringFactory.ToJavaStringNodeGen.create(); } @@ -5765,6 +5822,7 @@ private static void checkIntSize() { * * @since 23.0 */ + @NeverDefault public static AsNativeNode create() { return TruffleStringFactory.AsNativeNodeGen.create(); } @@ -5823,6 +5881,7 @@ final TruffleString compatibleImmutable(AbstractTruffleString a, Encoding encodi * * @since 22.1 */ + @NeverDefault public static SwitchEncodingNode create() { return TruffleStringFactory.SwitchEncodingNodeGen.create(); } @@ -5973,6 +6032,7 @@ static boolean isCompatibleAndNotCompacted(AbstractTruffleString a, Encoding exp * * @since 22.1 */ + @NeverDefault public static ForceEncodingNode create() { return TruffleStringFactory.ForceEncodingNodeGen.create(); } @@ -6033,6 +6093,7 @@ final TruffleStringIterator createIterator(AbstractTruffleString a, Encoding exp * * @since 22.1 */ + @NeverDefault public static CreateCodePointIteratorNode create() { return TruffleStringFactory.CreateCodePointIteratorNodeGen.create(); } @@ -6093,6 +6154,7 @@ final TruffleStringIterator createIterator(AbstractTruffleString a, Encoding exp * * @since 22.1 */ + @NeverDefault public static CreateBackwardCodePointIteratorNode create() { return TruffleStringFactory.CreateBackwardCodePointIteratorNodeGen.create(); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java index fbea6c01db95..cab8f8921892 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringBuilder.java @@ -56,6 +56,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @@ -193,6 +194,7 @@ final void append(TruffleStringBuilder sb, byte value, * * @since 22.1 */ + @NeverDefault public static AppendByteNode create() { return TruffleStringBuilderFactory.AppendByteNodeGen.create(); } @@ -267,6 +269,7 @@ private static void doAppend(Node node, TruffleStringBuilder sb, char value, int * * @since 22.1 */ + @NeverDefault public static AppendCharUTF16Node create() { return TruffleStringBuilderFactory.AppendCharUTF16NodeGen.create(); } @@ -390,6 +393,7 @@ final void append(TruffleStringBuilder sb, int c, int repeat, boolean allowUTF16 * * @since 22.1 */ + @NeverDefault public static AppendCodePointNode create() { return TruffleStringBuilderFactory.AppendCodePointNodeGen.create(); } @@ -609,6 +613,7 @@ void doAppend(TruffleStringBuilder sb, int value, * * @since 22.1 */ + @NeverDefault public static AppendIntNumberNode create() { return TruffleStringBuilderFactory.AppendIntNumberNodeGen.create(); } @@ -674,6 +679,7 @@ void doAppend(TruffleStringBuilder sb, long value, * * @since 22.1 */ + @NeverDefault public static AppendLongNumberNode create() { return TruffleStringBuilderFactory.AppendLongNumberNodeGen.create(); } @@ -738,6 +744,7 @@ void append(TruffleStringBuilder sb, AbstractTruffleString a, * * @since 22.1 */ + @NeverDefault public static AppendStringNode create() { return TruffleStringBuilderFactory.AppendStringNodeGen.create(); } @@ -825,6 +832,7 @@ final void append(TruffleStringBuilder sb, AbstractTruffleString a, int fromByte * * @since 22.1 */ + @NeverDefault public static AppendSubstringByteIndexNode create() { return TruffleStringBuilderFactory.AppendSubstringByteIndexNodeGen.create(); } @@ -917,6 +925,7 @@ final void append(TruffleStringBuilder sb, String javaString, int fromIndex, int * * @since 22.1 */ + @NeverDefault public static AppendJavaStringUTF16Node create() { return TruffleStringBuilderFactory.AppendJavaStringUTF16NodeGen.create(); } @@ -1010,6 +1019,7 @@ final TruffleString createString(TruffleStringBuilder sb, boolean lazy, * * @since 22.1 */ + @NeverDefault public static ToStringNode create() { return TruffleStringBuilderFactory.ToStringNodeGen.create(); } diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java index f69716d97c69..cc9db5354841 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleStringIterator.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -337,6 +338,7 @@ final int doDefault(TruffleStringIterator it, * * @since 22.1 */ + @NeverDefault public static NextNode create() { return TruffleStringIteratorFactory.NextNodeGen.create(); } @@ -389,6 +391,7 @@ final int doDefault(TruffleStringIterator it, * * @since 22.1 */ + @NeverDefault public static PreviousNode create() { return TruffleStringIteratorFactory.PreviousNodeGen.create(); } From b12602551b1fee923ee9a679bed12d3a917455d3 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 12:04:27 +0100 Subject: [PATCH 219/312] ECJ warning fix. --- .../polyglot/RegisterJDK17TestClassesForReflectionFeature.java | 1 + 1 file changed, 1 insertion(+) diff --git a/truffle/src/com.oracle.truffle.api.test.jdk17/src/com/oracle/truffle/api/test/polyglot/RegisterJDK17TestClassesForReflectionFeature.java b/truffle/src/com.oracle.truffle.api.test.jdk17/src/com/oracle/truffle/api/test/polyglot/RegisterJDK17TestClassesForReflectionFeature.java index 671d5d345aa4..94e41c231a2d 100644 --- a/truffle/src/com.oracle.truffle.api.test.jdk17/src/com/oracle/truffle/api/test/polyglot/RegisterJDK17TestClassesForReflectionFeature.java +++ b/truffle/src/com.oracle.truffle.api.test.jdk17/src/com/oracle/truffle/api/test/polyglot/RegisterJDK17TestClassesForReflectionFeature.java @@ -51,6 +51,7 @@ public class RegisterJDK17TestClassesForReflectionFeature extends RegisterTestCl private static final List> TEST_CLASSES = List.of(HostRecordAccessTest.class); + @Override public void beforeAnalysis(BeforeAnalysisAccess access) { for (Class testClass : TEST_CLASSES) { for (Class innerClass : testClass.getDeclaredClasses()) { From 010c38a3e7f0d47513ea840d77a6ff378e8e65fc Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 12:09:47 +0100 Subject: [PATCH 220/312] Fix user defined static create method should not imply never-default. --- .../truffle/api/dsl/test/NeverDefaultTest.java | 2 +- .../truffle/dsl/processor/TruffleTypes.java | 2 ++ .../dsl/processor/parser/NodeParser.java | 17 ++++++++--------- .../truffle/host/HostAdapterSuperMembers.java | 2 ++ .../backend/spi/util/ProfiledArrayBuilder.java | 3 +++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 848f6442d0da..cc2c85dc39ad 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -691,13 +691,13 @@ boolean s0(int value) { static volatile boolean returnNull = false; + @NeverDefault static GuardCacheNode create() { if (returnNull) { return null; } return GuardCacheNodeGen.create(); } - } @GenerateInline diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 9936611f414c..5b3db9d2a189 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -114,6 +114,7 @@ public class TruffleTypes { public static final String Option_Group_Name = "com.oracle.truffle.api.Option.Group"; public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; + public static final String IndirectCallNode_Name = "com.oracle.truffle.api.nodes.IndirectCallNode"; public static final String InlinedProfile_Name = "com.oracle.truffle.api.profiles.InlinedProfile"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; public static final String SourceSection_Name = "com.oracle.truffle.api.source.SourceSection"; @@ -148,6 +149,7 @@ public class TruffleTypes { public final DeclaredType NodeInterface = c.getDeclaredType(NodeInterface_Name); public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); + public final DeclaredType IndirectCallNode = c.getDeclaredType(IndirectCallNode_Name); public final DeclaredType InlinedProfile = c.getDeclaredTypeOptional(InlinedProfile_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); public final DeclaredType SourceSection = c.getDeclaredType(SourceSection_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 7056492a5f29..4a87f6e3ca11 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -3604,11 +3604,6 @@ private boolean isNeverDefaultImplied(CacheExpression cache) { return true; } - String initializer = getAnnotationValue(String.class, cache.getMessageAnnotation(), "value", false); - if (initializer == null || initializer.equals("create()")) { - return true; - } - if (cache.isEncodedEnum()) { return true; } @@ -3629,11 +3624,15 @@ private boolean isNeverDefaultImpliedByAnnotation(CacheExpression cache) { } Element enclosing = executable.getEnclosingElement(); - if (enclosing != null && typeEquals(enclosing.asType(), types.DirectCallNode)) { - // cannot use NeverDefault annotation in certain TruffleTypes - return true; + if (enclosing != null) { + if (typeEquals(enclosing.asType(), types.DirectCallNode)) { + // cannot use NeverDefault annotation in certain TruffleTypes + return executable.getSimpleName().toString().equals("create"); + } else if (typeEquals(enclosing.asType(), types.IndirectCallNode)) { + // cannot use NeverDefault annotation in certain TruffleTypes + return executable.getSimpleName().toString().equals("create"); + } } - } VariableElement var = cache.getDefaultExpression().resolveVariable(); if (var != null) { diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAdapterSuperMembers.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAdapterSuperMembers.java index ecb8ec101117..852d5644f1ad 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAdapterSuperMembers.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAdapterSuperMembers.java @@ -51,6 +51,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; @@ -108,6 +109,7 @@ String getSuperMethodName(String name) { } } + @NeverDefault static NameCache create() { return new NameCache(); } diff --git a/truffle/src/com.oracle.truffle.nfi.backend.spi/src/com/oracle/truffle/nfi/backend/spi/util/ProfiledArrayBuilder.java b/truffle/src/com.oracle.truffle.nfi.backend.spi/src/com/oracle/truffle/nfi/backend/spi/util/ProfiledArrayBuilder.java index bf7f8673639f..3dc2844cbf90 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.spi/src/com/oracle/truffle/nfi/backend/spi/util/ProfiledArrayBuilder.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.spi/src/com/oracle/truffle/nfi/backend/spi/util/ProfiledArrayBuilder.java @@ -44,6 +44,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.dsl.NeverDefault; + import java.util.Arrays; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; @@ -95,6 +97,7 @@ public interface ArrayFactory { public abstract static class ArrayBuilderFactory { + @NeverDefault public static ArrayBuilderFactory create() { return new ProfiledArrayBuilderFactory(); } From f2103420da1da4d6d65c627e141a1592d9ffa5aa Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 12:22:39 +0100 Subject: [PATCH 221/312] Fix invalid estimated size for char primitive types. --- .../src/com/oracle/truffle/dsl/processor/java/ElementUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java index 017ad5292a98..9333168bbb0b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @@ -1803,10 +1803,10 @@ public static int getCompressedReferenceSize(TypeMirror mirror) { case BYTE: return 1; case SHORT: + case CHAR: return 2; case INT: case FLOAT: - case CHAR: return 4; case DOUBLE: case LONG: From 8b7018e553ca30f4a75bd1630d410fd0afea5d5a Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 13:32:09 +0100 Subject: [PATCH 222/312] Fix signatures. --- sdk/src/org.graalvm.options/snapshot.sigtest | 6 ++++++ sdk/src/org.graalvm.polyglot/snapshot.sigtest | 6 ++++++ .../src/com.oracle.truffle.api.debug/snapshot.sigtest | 6 ++++++ .../com.oracle.truffle.api.interop/snapshot.sigtest | 6 ++++++ .../src/com.oracle.truffle.api.object/snapshot.sigtest | 6 ++++++ .../com.oracle.truffle.api.strings/snapshot.sigtest | 6 ++++++ truffle/src/com.oracle.truffle.api/snapshot.sigtest | 6 ++++++ .../oracle/truffle/nfi/test/parser/package-info.java | 10 ---------- 8 files changed, 42 insertions(+), 10 deletions(-) delete mode 100644 truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java diff --git a/sdk/src/org.graalvm.options/snapshot.sigtest b/sdk/src/org.graalvm.options/snapshot.sigtest index 8518d320fa5e..3917f9c0993a 100644 --- a/sdk/src/org.graalvm.options/snapshot.sigtest +++ b/sdk/src/org.graalvm.options/snapshot.sigtest @@ -8,8 +8,10 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -18,6 +20,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -43,6 +46,9 @@ meth public final void wait(long,int) throws java.lang.InterruptedException meth public int hashCode() meth public java.lang.String toString() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + CLSS public final !enum org.graalvm.options.OptionCategory fld public final static org.graalvm.options.OptionCategory EXPERT fld public final static org.graalvm.options.OptionCategory INTERNAL diff --git a/sdk/src/org.graalvm.polyglot/snapshot.sigtest b/sdk/src/org.graalvm.polyglot/snapshot.sigtest index 7dc39e19c9a4..1302a27a85ae 100644 --- a/sdk/src/org.graalvm.polyglot/snapshot.sigtest +++ b/sdk/src/org.graalvm.polyglot/snapshot.sigtest @@ -11,8 +11,10 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -21,6 +23,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -115,6 +118,9 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + CLSS public final org.graalvm.polyglot.Context innr public final Builder intf java.lang.AutoCloseable diff --git a/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest index 39e2b3d55d64..0f155c58c9a9 100644 --- a/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.debug/snapshot.sigtest @@ -400,8 +400,10 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -410,6 +412,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -472,3 +475,6 @@ supr java.lang.Object hfds CAUSE_CAPTION,EMPTY_THROWABLE_ARRAY,NULL_CAUSE_MESSAGE,SELF_SUPPRESSION_MESSAGE,SUPPRESSED_CAPTION,SUPPRESSED_SENTINEL,UNASSIGNED_STACK,backtrace,cause,depth,detailMessage,serialVersionUID,stackTrace,suppressedExceptions hcls PrintStreamOrWriter,SentinelHolder,WrappedPrintStream,WrappedPrintWriter +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + diff --git a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest index 20ef78c8cec3..b268dba90ae9 100644 --- a/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest @@ -326,8 +326,10 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -336,6 +338,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -422,3 +425,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + diff --git a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest index 5b8f90f3cc2b..f0503a5c825d 100644 --- a/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.object/snapshot.sigtest @@ -520,8 +520,10 @@ meth public abstract !hasdefault java.lang.String since() CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -530,6 +532,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -616,3 +619,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + diff --git a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest index f9ac389dd0d2..b4db2e0f136b 100644 --- a/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.strings/snapshot.sigtest @@ -1120,8 +1120,10 @@ meth public abstract int compareTo({java.lang.Comparable%0}) CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -1130,6 +1132,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -1232,3 +1235,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + diff --git a/truffle/src/com.oracle.truffle.api/snapshot.sigtest b/truffle/src/com.oracle.truffle.api/snapshot.sigtest index 1e7263b5a5d5..d2014f606fcb 100644 --- a/truffle/src/com.oracle.truffle.api/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api/snapshot.sigtest @@ -1362,8 +1362,10 @@ meth public abstract !hasdefault java.lang.String since() CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>> cons protected init(java.lang.String,int) +innr public final static EnumDesc intf java.io.Serializable intf java.lang.Comparable<{java.lang.Enum%0}> +intf java.lang.constant.Constable meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException meth protected final void finalize() meth public final boolean equals(java.lang.Object) @@ -1372,6 +1374,7 @@ meth public final int hashCode() meth public final int ordinal() meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass() meth public final java.lang.String name() +meth public final java.util.Optional> describeConstable() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object @@ -1480,3 +1483,6 @@ CLSS public abstract interface !annotation java.lang.annotation.Target intf java.lang.annotation.Annotation meth public abstract java.lang.annotation.ElementType[] value() +CLSS public abstract interface java.lang.constant.Constable +meth public abstract java.util.Optional describeConstable() + diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java deleted file mode 100644 index 549f4be286aa..000000000000 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -// TODO GR-42818 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault"}) -package com.oracle.truffle.nfi.test.parser; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; From 7abd6bb3506bedbe3890bdba2887311733f98af2 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 15:09:03 +0100 Subject: [PATCH 223/312] Fix unit test failures with state bit width set to one. --- .../test/DisableStateBitWidthModfication.java | 4 +++ .../api/dsl/test/EnumEncodingTest.java | 1 - .../api/dsl/test/GenerateInlineTest.java | 4 +++ .../api/dsl/test/ImplicitCastTest.java | 1 + .../dsl/test/MergeSpecializationsTest.java | 1 + .../truffle/api/dsl/test/StateBitTest.java | 1 + .../api/dsl/test/StatePackingTest.java | 1 + .../test/examples/NodeInliningExample1_1.java | 2 ++ .../test/examples/NodeInliningExample1_2.java | 2 ++ .../test/examples/NodeInliningExample1_3.java | 2 ++ .../test/examples/NodeInliningExample2_1.java | 2 ++ .../test/examples/NodeInliningExample2_2.java | 3 +++ .../test/examples/NodeInliningExample2_3.java | 2 ++ .../processor/TruffleProcessorOptions.java | 13 ++++++++-- .../dsl/processor/generator/BitSet.java | 6 ++--- .../generator/FlatNodeGenFactory.java | 26 +++++++++++++++++-- .../dsl/processor/generator/MultiBitSet.java | 4 +++ 17 files changed, 67 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java index fff357ebdf7a..27affabeb3bb 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/DisableStateBitWidthModfication.java @@ -43,6 +43,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +/** + * Disables all state bit width modification in the DSL processor. This is useful if for example the + * internal state of a node needs to be asserted. + */ @Retention(RetentionPolicy.RUNTIME) public @interface DisableStateBitWidthModfication { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java index 418d8ffa9e17..0f483393a0bd 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java @@ -187,7 +187,6 @@ Enum2 s0(Enum2 value, @Shared("cache") @Cached(value = "value", neverDefault = f Enum2 s1(Enum2 value, @Shared("cache") @Cached(value = "value", neverDefault = false) Enum2 enumValue) { return enumValue; } - } @Test diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index 452f7f99a5e2..648af02d1955 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -221,6 +221,7 @@ public abstract static class UseStateNode extends Node { @GenerateInline @SuppressWarnings("unused") + @DisableStateBitWidthModfication public abstract static class Use32BitsNode extends UseStateNode { @Specialization @@ -252,6 +253,7 @@ static int doInt(Node node, @GenerateInline @SuppressWarnings("unused") + @DisableStateBitWidthModfication public abstract static class Use128BitsNode extends UseStateNode { @Specialization @@ -271,6 +273,7 @@ static int doInt(Node node, @GenerateInline @SuppressWarnings("unused") + @DisableStateBitWidthModfication public abstract static class Use512BitsNode extends UseStateNode { @Specialization @@ -290,6 +293,7 @@ static int doInt(Node node, @GenerateInline @SuppressWarnings("unused") + @DisableStateBitWidthModfication public abstract static class Use2048BitsNode extends UseStateNode { @Specialization diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java index f02ed93b32f9..abf8cd6b50da 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java @@ -81,6 +81,7 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException; @SuppressWarnings("truffle") +@DisableStateBitWidthModfication public class ImplicitCastTest { @TypeSystem({int.class, String.class, boolean.class}) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java index 791b58957803..f9b0555cec05 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MergeSpecializationsTest.java @@ -63,6 +63,7 @@ import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.nodes.Node; +@DisableStateBitWidthModfication public class MergeSpecializationsTest { private static final int THREADS = 25; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java index 52328dcee4c2..dab62027dbc2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java @@ -58,6 +58,7 @@ import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) +@DisableStateBitWidthModfication public class StateBitTest { /* diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java index 4ed74eebff3f..0d963257194f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StatePackingTest.java @@ -55,6 +55,7 @@ import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) +@DisableStateBitWidthModfication public class StatePackingTest extends AbstractPolyglotTest { @GenerateInline diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java index 20155efd305e..5c1df3c366cd 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_1.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_1Factory.Add4AbsNodeGen; import com.oracle.truffle.api.nodes.Node; @@ -55,6 +56,7 @@ * See the tutorial description here. */ +@DisableStateBitWidthModfication public class NodeInliningExample1_1 { @GenerateInline(false) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java index 4fe4d37f45f2..33ca3d84d916 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_2.java @@ -47,6 +47,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_2Factory.Add4AbsNodeGen; import com.oracle.truffle.api.nodes.Node; @@ -55,6 +56,7 @@ * See the tutorial description here. */ +@DisableStateBitWidthModfication public class NodeInliningExample1_2 { @GenerateInline diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java index 8cc289d6f974..7bd582a8867c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample1_3.java @@ -48,6 +48,7 @@ import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample1_3Factory.Add4AbsNodeGen; import com.oracle.truffle.api.nodes.Node; @@ -56,6 +57,7 @@ * See the tutorial description here. */ +@DisableStateBitWidthModfication public class NodeInliningExample1_3 { @GenerateInline diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java index 64b9aaa06c31..18a51cd41759 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_1.java @@ -49,10 +49,12 @@ import com.oracle.truffle.api.TruffleSafepoint; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_1Factory.SumArrayNodeGen; import com.oracle.truffle.api.nodes.Node; +@DisableStateBitWidthModfication public class NodeInliningExample2_1 { abstract static class AbstractArray { diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java index e074d4d10921..01daf3edfe4d 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_2.java @@ -52,10 +52,12 @@ import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_2Factory.SumArrayNodeGen; import com.oracle.truffle.api.nodes.Node; +@DisableStateBitWidthModfication public class NodeInliningExample2_2 { abstract static class AbstractArray { @@ -112,6 +114,7 @@ int[] doMaterialized(MaterializedArray array) { } @SuppressWarnings("truffle-inlining") + @DisableStateBitWidthModfication public abstract static class SumArrayNode extends Node { abstract int execute(Object v0); diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java index 574db66b1cf0..a295d6680dd0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/NodeInliningExample2_3.java @@ -53,10 +53,12 @@ import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication; import com.oracle.truffle.api.dsl.test.ObjectSizeEstimate; import com.oracle.truffle.api.dsl.test.examples.NodeInliningExample2_3Factory.SumArrayNodeGen; import com.oracle.truffle.api.nodes.Node; +@DisableStateBitWidthModfication public class NodeInliningExample2_3 { abstract static class AbstractArray { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java index 9c136f7d1e62..2f4193e1bd09 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java @@ -44,6 +44,8 @@ import java.util.Set; import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.type.DeclaredType; import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -106,8 +108,15 @@ public static boolean cacheSharingWarningsEnabled(ProcessingEnvironment env) { public static int stateBitWidth(NodeData node) { ProcessorContext context = ProcessorContext.getInstance(); - if (ElementUtils.findAnnotationMirror(node.getTemplateType(), context.getTypes().DisableStateBitWidthModification) != null) { - return FlatNodeGenFactory.DEFAULT_MAX_BIT_WIDTH; + DeclaredType disableStateWidth = context.getTypes().DisableStateBitWidthModification; + if (disableStateWidth != null) { + Element element = node.getTemplateType(); + while (element != null) { + if (ElementUtils.findAnnotationMirror(element, disableStateWidth) != null) { + return FlatNodeGenFactory.DEFAULT_MAX_BIT_WIDTH; + } + element = element.getEnclosingElement(); + } } String value = context.getEnvironment().getOptions().get(OptionsPrefix + StateBitWidth); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java index af8d6ea7ff3b..72c437d06797 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitSet.java @@ -289,7 +289,7 @@ public CodeTree createExtractInteger(FrameState frameState, StateQuery query) { } public CodeTree createSetZero(FrameState frameState, boolean persist) { - return createSet(frameState, persist, CodeTreeBuilder.singleString("0"), false); + return createPersist(frameState, persist, CodeTreeBuilder.singleString("0"), false); } public CodeTree createSetExpression(CodeTree receiver, StateQuery elements, Boolean value) { @@ -316,10 +316,10 @@ public CodeTree createSet(FrameState frameState, StateQuery elements, Boolean va return valueBuilder.build(); } valueBuilder.tree(createSetExpression(createReference(frameState), elements, value)); - return createSet(frameState, persist, valueBuilder.build(), !isEmpty); + return createPersist(frameState, persist, valueBuilder.build(), !isEmpty); } - private CodeTree createSet(FrameState frameState, boolean persist, CodeTree valueTree, boolean update) { + private CodeTree createPersist(FrameState frameState, boolean persist, CodeTree valueTree, boolean update) { CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startStatement(); if (persist) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 5effbfa4fe22..92aca2772c68 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -4962,6 +4962,17 @@ private boolean buildSpecializationSlowPath(final CodeTreeBuilder builder, Frame if (updateImplicitCast != null) { builder.tree(updateImplicitCast); } + + for (CacheExpression cache : specialization.getCaches()) { + if (cache.isEncodedEnum() && cache.getSharedGroup() == null) { + BitSet bitSet = multiState.findSet(EncodedEnumState.class, cache); + if (bitSet != null) { + builder.tree(bitSet.createLoad(innerFrameState)); + stateTransaction.markModified(bitSet); + } + } + } + builder.tree(multiState.createSet(innerFrameState, stateTransaction, StateQuery.create(SpecializationActive.class, specialization), true, false)); builder.tree(multiState.persistTransaction(innerFrameState, stateTransaction)); @@ -5452,6 +5463,7 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, b.end(); triples.add(new IfTriple(null, null, b.build())); } + } } @@ -6227,6 +6239,9 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.startStatement(); builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); + if (cache.isEncodedEnum()) { + + } builder.end(); if (!cache.isEagerInitialize()) { @@ -6943,7 +6958,14 @@ private CodeTree createEncodeEnum(FrameState frameState, SpecializationData spec CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); StateQuery query = StateQuery.create(EncodedEnumState.class, lookupSharedCacheKey(cache)); SpecializationStateReference ref = createStateReference(frameState, specialization, query); - builder.tree(ref.bitSet.createSetInteger(ref.reference, query, innerValue.build())); + + if (cache.getSharedGroup() != null) { + CodeTree stateRef = CodeTreeBuilder.createBuilder().string("this.", ref.bitSet.getName(), "_").build(); + builder.tree(createInlinedAccess(frameState, specialization, stateRef, ref.bitSet.createSetInteger(ref.reference, query, innerValue.build()))); + } else { + builder.tree(ref.bitSet.createSetInteger(ref.reference, query, innerValue.build())); + // persisted later when specialization is committed + } return builder.build(); } @@ -7548,7 +7570,7 @@ static boolean isRelevantForSlowPath(BitSet bitSet, Collection modified = new LinkedHashSet<>(); + void markModified(BitSet bitSet) { + modified.add(bitSet); + } + } public CodeTree persistTransaction(FrameState frameState, StateTransaction transaction) { From 505eacbe4a7da6148b386ce215d32d3fbaf09dbd Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 15:14:49 +0100 Subject: [PATCH 224/312] Fix recursion error. --- .../src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index 648af02d1955..2ad7ad87d7c5 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -1756,7 +1756,7 @@ public abstract static class ErrorIndirectRecursionNode1 extends Node { @Specialization static int doDefault(Node node, - @ExpectError("Message redirected from element GenerateInlineTest.ErrorIndirectRecursionNode2.doDefault(..., ErrorIndirectRecursionNode1 cachedNode):%")// + @ExpectError("%")// @Cached ErrorIndirectRecursionNode2 cachedNode) { return 42; } From 55d9afdde44af828667383b7d04aba7c7e0ca87e Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 15:18:53 +0100 Subject: [PATCH 225/312] Show inclusive ranges instead of exclusive ranges in state javadoc. --- .../truffle/dsl/processor/generator/FlatNodeGenFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 92aca2772c68..92df4a4e1271 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1321,7 +1321,7 @@ static void addStateDoc(CodeTreeBuilder docBuilder, BitSet set) { docBuilder.string(String.valueOf(range.offset)); if (range.length != 1) { - docBuilder.string("-").string(String.valueOf(range.offset + range.length)); + docBuilder.string("-").string(String.valueOf(range.offset + range.length - 1)); } docBuilder.string(": "); value.state.addStateDoc(docBuilder); From 18e7e1632c49f9e4cab045a362c6a0d927559a40 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 15:39:42 +0100 Subject: [PATCH 226/312] Fix cache class was not passed for boundary extraction. --- .../api/dsl/test/NeverDefaultTest.java | 28 +++++++++++++++++++ .../api/dsl/test/SharedCachedTest.java | 7 +++++ .../generator/FlatNodeGenFactory.java | 26 ++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index cc2c85dc39ad..41693ac6146c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -88,6 +88,8 @@ import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseMultiInstanceNodeCacheNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseSharedDefaultInlinedNodeNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.UseSharedNeverDefaultInlinedNodeNodeGen; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.ControlFlowException; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @@ -922,6 +924,32 @@ public void testCachedGuardAndFallbackNode() throws InterruptedException { }); } + /* + * Compilation only test. + */ + @SuppressWarnings({"unused", "truffle-unused"}) + public abstract static class SharedWrapperWithBoundaryNode extends Node { + + public abstract Object execute(Object arg0); + + @Specialization + protected Object oneArg(int arg0, + @Cached(neverDefault = false) @Shared("shared") GuardCacheNode sharedNode) { + return arg0; + } + + /* + * This specialization forces a boundary method in combination with a shared wrapper. + */ + @Specialization(limit = "3") + protected Object twoArgs(double arg0, + @CachedLibrary("arg0") InteropLibrary interop, + @Cached(neverDefault = false) @Shared("shared") GuardCacheNode sharedNode) { + return arg0; + } + + } + static final int NODES = 10; static final int THREADS = 10; diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index 11816c140326..7beb7c24e4e7 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -45,6 +45,7 @@ import org.junit.Test; +import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -53,12 +54,18 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.dsl.test.EnumEncodingTest.TestSharedWrapper; import com.oracle.truffle.api.dsl.test.GenerateInlineTest.SimpleNode; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.SharedStringInGuardNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundExclusiveObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundSharedObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UseGenerateInlineSharedNodeGen; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "unused"}) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 92df4a4e1271..e170c4a5eab7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5229,6 +5229,12 @@ private CodeTreeBuilder extractInBoundaryMethod(CodeTreeBuilder builder, FrameSt v.setName(createCacheLocalName(cache)); boundaryMethod.addParameter(v); builder.tree(var.createReference()); + } else { + var = frameState.getCacheClassInitialized(cache); + if (var != null) { + boundaryMethod.addParameter(var.createParameter()); + builder.tree(var.createReference()); + } } } @@ -6239,9 +6245,6 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.startStatement(); builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); - if (cache.isEncodedEnum()) { - - } builder.end(); if (!cache.isEagerInitialize()) { @@ -6872,19 +6875,18 @@ private LocalVariable createCacheClassAccess(FrameState frameState, return null; } - String name = createFieldName(null, cache); - String key = name + "$wrapper"; - LocalVariable var = frameState.get(key); + LocalVariable var = frameState.getCacheClassInitialized(cache); if (var != null) { // already initialized return var; } if (builder != null) { TypeMirror type = createCacheClassType(cache); + String name = createFieldName(null, cache); String localName = name + "_wrapper"; builder.declaration(type, localName, createInlinedAccess(frameState, null, CodeTreeBuilder.singleString("this." + name), null)); var = new LocalVariable(type, localName, CodeTreeBuilder.singleString(localName)); - frameState.set(key, var); + frameState.set(frameState.createCacheClassInitializedKey(cache), var); } return var; @@ -7750,6 +7752,16 @@ public LocalVariable getCacheInitialized(SpecializationData specialization, Cach return get(name); } + public LocalVariable getCacheClassInitialized(CacheExpression cache) { + return get(createCacheClassInitializedKey(cache)); + } + + private String createCacheClassInitializedKey(CacheExpression cache) { + String name = factory.createFieldName(null, cache); + String key = name + "$wrapper"; + return key; + } + public LocalVariable get(String id) { return values.get(id); } From efd2b96d1b9ea1537cd7c43855f49c98a9e166e4 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 12 Dec 2022 16:29:39 +0100 Subject: [PATCH 227/312] Fix warnings. --- .../com/oracle/truffle/api/dsl/test/SharedCachedTest.java | 7 ------- .../dsl/processor/generator/FlatNodeGenFactory.java | 6 +++++- .../oracle/truffle/nfi/test/parser/ParseSignatureTest.java | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java index 7beb7c24e4e7..11816c140326 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SharedCachedTest.java @@ -45,7 +45,6 @@ import org.junit.Test; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -54,18 +53,12 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; -import com.oracle.truffle.api.dsl.test.EnumEncodingTest.TestSharedWrapper; import com.oracle.truffle.api.dsl.test.GenerateInlineTest.SimpleNode; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.SharedStringInGuardNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundExclusiveObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UnboundSharedObjectNodeGen; import com.oracle.truffle.api.dsl.test.SharedCachedTestFactory.UseGenerateInlineSharedNodeGen; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "unused"}) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index e170c4a5eab7..573d804f2005 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6961,7 +6961,7 @@ private CodeTree createEncodeEnum(FrameState frameState, SpecializationData spec StateQuery query = StateQuery.create(EncodedEnumState.class, lookupSharedCacheKey(cache)); SpecializationStateReference ref = createStateReference(frameState, specialization, query); - if (cache.getSharedGroup() != null) { + if (cache.getSharedGroup() != null && !cache.isEagerInitialize()) { CodeTree stateRef = CodeTreeBuilder.createBuilder().string("this.", ref.bitSet.getName(), "_").build(); builder.tree(createInlinedAccess(frameState, specialization, stateRef, ref.bitSet.createSetInteger(ref.reference, query, innerValue.build()))); } else { @@ -7753,6 +7753,10 @@ public LocalVariable getCacheInitialized(SpecializationData specialization, Cach } public LocalVariable getCacheClassInitialized(CacheExpression cache) { + if (cache.getSharedGroup() == null) { + // only used for shared caches + return null; + } return get(createCacheClassInitializedKey(cache)); } diff --git a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java index 0bd70dab4637..c2a38387d925 100644 --- a/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java +++ b/truffle/src/com.oracle.truffle.nfi.test/src/com/oracle/truffle/nfi/test/parser/ParseSignatureTest.java @@ -81,6 +81,7 @@ public static void loadTestSymbol() throws InteropException { testSymbol = INTEROP.readMember(library, "testSymbol"); } + @SuppressWarnings("truffle-inlining") abstract static class InlineCacheNode extends Node { abstract Object execute(CallTarget callTarget); From fecab7e9d520a9aba9b2907d344c6548484ca1b9 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 13 Dec 2022 11:47:16 +0100 Subject: [PATCH 228/312] Fix compile error when cache wrappers were used in fallback guards. --- .../api/dsl/test/NeverDefaultTest.java | 27 ++++++++++++++ .../generator/FlatNodeGenFactory.java | 35 ++++++++++++------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 41693ac6146c..a33ba3cf684c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -950,6 +950,33 @@ protected Object twoArgs(double arg0, } + @SuppressWarnings({"unused", "truffle-unused"}) + public abstract static class SharedWrapperInFallbackNode extends Node { + + public abstract Object execute(Object arg0); + + @Specialization(guards = {"arg0 == 2", "guardNode.execute(arg0)"}, limit = "1") + protected Object oneArg(int arg0, + @Shared("guard") @Cached(neverDefault = false) GuardCacheNode guardNode) { + return arg0; + } + + @Specialization(guards = {"arg0 == 1", "guardNode.execute(arg0)"}, limit = "1") + protected Object twoArg(int arg0, + @Shared("guard") @Cached(neverDefault = false) GuardCacheNode guardNode) { + return arg0; + } + + /* + * This specialization forces a boundary method in combination with a shared wrapper. + */ + @Fallback + protected Object twoArgs(Object arg0) { + return arg0; + } + + } + static final int NODES = 10; static final int THREADS = 10; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 573d804f2005..91aa2e7a6bb5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6630,23 +6630,32 @@ private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationDat for (CacheExpression cache : getNullCachesDueToFallback(specialization, guard)) { String localName = createCacheLocalName(cache); - if (!isCacheInitialized(frameState, specialization, cache)) { - init.startStatement(); - init.type(cache.getParameter().getType()); - init.string(" ", localName, " = "); - - if (useSpecializationClass(specialization) && cache.getSharedGroup() == null) { - init.tree(createGetSpecializationClass(frameState, specialization, true)); - init.string(" == null ? null : "); + LocalVariable cacheWrapper = createCacheClassAccess(frameState, init, cache); + if (cacheWrapper == null) { + + if (!isCacheInitialized(frameState, specialization, cache)) { + init.startStatement(); + init.type(cache.getParameter().getType()); + init.string(" ", localName, " = "); + + if (useSpecializationClass(specialization) && cache.getSharedGroup() == null) { + init.tree(createGetSpecializationClass(frameState, specialization, true)); + init.string(" == null ? null : "); + } + + init.tree(createCacheAccess(frameState, specialization, cache, null)); + init.end(); + setCacheInitialized(frameState, specialization, cache, true); } - init.tree(createCacheAccess(frameState, specialization, cache, null)); - init.end(); - setCacheInitialized(frameState, specialization, cache, true); + condition.string(localName).string(" == ").defaultValue(cache.getParameter().getType()); + condition.string(" || "); + + } else { + condition.tree(cacheWrapper.createReference()).string(" == null"); + condition.string(" || "); } - condition.string(localName).string(" == ").defaultValue(cache.getParameter().getType()); - condition.string(" || "); } condition.tree(writeExpression(frameState, specialization, expression)); From 5fea6044f94ad0e74eab2aa43f40c72842b54d01 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 13 Dec 2022 12:11:04 +0100 Subject: [PATCH 229/312] Fix enum encoding should not imply never default, but instead just not emit warnings. --- .../api/dsl/test/EnumEncodingTest.java | 29 +++++++++++++++++++ .../dsl/processor/parser/NodeParser.java | 18 ++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java index 0f483393a0bd..16a0b2d5f05d 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/EnumEncodingTest.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Introspectable; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.DefaultHandlingTestNodeGen; import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.GuaranteedNeverDefaultNodeGen; import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.NeverDefaultNodeGen; import com.oracle.truffle.api.dsl.test.EnumEncodingTestFactory.SpecializationClassNodeGen; @@ -254,4 +255,32 @@ int s0(Enum1 value, } + @SuppressWarnings("unused") + @ImportStatic(Enum2.class) + abstract static class DefaultHandlingTestNode extends BaseNode { + + abstract Enum8 execute(Node node, Enum8 value); + + @Specialization + Enum8 s0(Enum8 value, @Cached("value") Enum8 cachedValue) { + return cachedValue; + } + + } + + @Test + public void testDefaultHandlingTestNode() { + BaseNode.specializeCounter = 0; + DefaultHandlingTestNode node = DefaultHandlingTestNodeGen.create(); + assertEquals(Enum8.E0, node.execute(null, Enum8.E0)); + assertEquals(Enum8.E0, node.execute(null, Enum8.E1)); + assertEquals(1, BaseNode.specializeCounter); + + BaseNode.specializeCounter = 0; + node = DefaultHandlingTestNodeGen.create(); + assertEquals(null, node.execute(null, null)); + assertEquals(null, node.execute(null, Enum8.E1)); + assertEquals(1, BaseNode.specializeCounter); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 4a87f6e3ca11..e7418f046077 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -664,7 +664,8 @@ private void verifyRecommendationWarnings(NodeData node, boolean recommendInline getSimpleName(types.NeverDefault)); } } else { - if (!cache.isEagerInitialize() && (cache.getSharedGroup() != null || isLayoutBenefittingFromNeverDefault) && !isNeverDefaultImplied(cache)) { + if (!cache.isEagerInitialize() && (cache.getSharedGroup() != null || isLayoutBenefittingFromNeverDefault) && !isNeverDefaultImplied(cache) && + !isNeverDefaultEasilySupported(cache)) { /* * The exports parser adds a suppress warning when calling into the node * parser for accepts messages. Normally suppression is calculated later, @@ -3582,6 +3583,17 @@ private void parseCached(CacheExpression cache, SpecializationData specializatio } + private static boolean isNeverDefaultEasilySupported(CacheExpression cache) { + if (cache.isEncodedEnum()) { + /* + * Encoded enums can just encode the never default state in a special bit so does not + * need to cause a warning for never default. + */ + return true; + } + return false; + } + private boolean isNeverDefaultImplied(CacheExpression cache) { /* * Never default is implied if there is no custom initializer expression set. Default @@ -3604,10 +3616,6 @@ private boolean isNeverDefaultImplied(CacheExpression cache) { return true; } - if (cache.isEncodedEnum()) { - return true; - } - if (isNeverDefaultImpliedByAnnotation(cache)) { return true; } From 145a7ec4ab63375b265439a16c171442a33fa4bc Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 13 Dec 2022 16:48:19 +0100 Subject: [PATCH 230/312] Fix gate problems. --- .../com/oracle/truffle/api/dsl/test/GenerateInlineTest.java | 4 +--- .../src/com/oracle/truffle/api/dsl/test/StateBitTest.java | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java index 2ad7ad87d7c5..c7db960c726a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GenerateInlineTest.java @@ -1771,9 +1771,7 @@ public abstract static class ErrorIndirectRecursionNode2 extends Node { @Specialization static int doDefault(Node node, - @ExpectError("Message redirected from element GenerateInlineTest.ErrorIndirectRecursionNode1.doDefault(..., ErrorIndirectRecursionNode2 cachedNode):\n" + - "Detected recursive inlined cache with type 'ErrorIndirectRecursionNode2'. Recursive inlining cannot be supported. " + - "Remove the recursive declaration or disable inlining with @Cached(..., inline=false) to resolve this.") // + @ExpectError("%") // @Cached ErrorIndirectRecursionNode1 cachedNode) { return 42; } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java index dab62027dbc2..0ca8fc5a1c51 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/StateBitTest.java @@ -517,8 +517,7 @@ public static BitSet assertStateFields(Node node, int expectedWidth) { } public static int getStateBitWidth() { - Integer width = Integer.getInteger("truffle.dsl.StateBitWidth"); - int stateBitWidth = width == null ? DEFAULT_MAX_BIT_WIDTH : width; + int stateBitWidth = DEFAULT_MAX_BIT_WIDTH; return stateBitWidth; } From de61f2a9856a79f93b8673e660b36f9830507166 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 14 Dec 2022 23:21:24 +0100 Subject: [PATCH 231/312] Fix thread-safety for replaces of specializations from different state bitsets. --- .../dsl/test/ReplacesThreadSafetyTest.java | 285 ++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 42 ++- 2 files changed, 323 insertions(+), 4 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java new file mode 100644 index 000000000000..f0d1518bf039 --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.dsl.test; + +import static org.junit.Assert.assertFalse; + +import java.util.List; +import java.util.function.Supplier; + +import org.junit.Test; + +import com.oracle.truffle.api.dsl.Introspectable; +import com.oracle.truffle.api.dsl.Introspection; +import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.test.ReplacesThreadSafetyTestFactory.ReplaceAcrossStateBitsetsNodeGen; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; + +public class ReplacesThreadSafetyTest extends AbstractPolyglotTest { + + @SuppressWarnings({"unused", "truffle-inlining"}) + @Introspectable + abstract static class ReplaceAcrossStateBitsetsNode extends Node { + + abstract int execute(int v); + + @Specialization(guards = "a == 0") + int s0(int a) { + return 0; + } + + @Specialization(guards = "a == 1") + int s1(int a) { + return 1; + } + + @Specialization(guards = "a == 2") + int s2(int a) { + return 2; + } + + @Specialization(guards = "a == 3") + int s3(int a) { + return 3; + } + + @Specialization(guards = "a == 4") + int s4(int a) { + return 4; + } + + @Specialization(guards = "a == 5") + int s5(int a) { + return 5; + } + + @Specialization(guards = "a == 6") + int s6(int a) { + return 6; + } + + @Specialization(guards = "a ==7") + int s7(int a) { + return 7; + } + + @Specialization(guards = "a == 8") + int s8(int a) { + return 8; + } + + @Specialization(guards = "a == 9") + int s9(int a) { + return 9; + } + + @Specialization(guards = "a == 10") + int s10(int a) { + return 10; + } + + @Specialization(guards = "a == 11") + int s11(int a) { + return 11; + } + + @Specialization(guards = "a == 12") + int s12(int a) { + return 12; + } + + @Specialization(guards = "a == 13") + int s13(int a) { + return 13; + } + + @Specialization(guards = "a == 14") + int s14(int a) { + return 14; + } + + @Specialization(guards = "a == 15") + int s15(int a) { + return 15; + } + + @Specialization(guards = "a == 16") + int s16(int a) { + return 16; + } + + @Specialization(guards = "a == 17") + int s17(int a) { + return 17; + } + + @Specialization(guards = "a == 18") + int s18(int a) { + return 18; + } + + @Specialization(guards = "a == 19") + int s19(int a) { + return 19; + } + + @Specialization(guards = "a == 20") + int s20(int a) { + return 20; + } + + @Specialization(guards = "a == 21") + int s21(int a) { + return 21; + } + + @Specialization(guards = "a == 22") + int s22(int a) { + return 22; + } + + @Specialization(guards = "a == 23") + int s23(int a) { + return 23; + } + + @Specialization(guards = "a == 24") + int s24(int a) { + return 24; + } + + @Specialization(guards = "a == 25") + int s25(int a) { + return 25; + } + + @Specialization(guards = "a == 26") + int s26(int a) { + return 26; + } + + @Specialization(guards = "a == 27") + int s27(int a) { + return 27; + } + + @Specialization(guards = "a == 28") + int s28(int a) { + return 28; + } + + @Specialization(guards = "a == 29") + int s29(int a) { + return 29; + } + + @Specialization(guards = "a == 30") + int s30(int a) { + return 30; + } + + @Specialization(guards = "a == 31") + int s31(int a) { + return 31; + } + + @Specialization(guards = "a <= 32", replaces = {"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", // + "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", // + "s20", "s21", "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", // + "s30", "s31", + }) + int s32(int a) { + return 32; + } + + @Specialization(guards = "a <= 33", replaces = "s32") + int s33(int a) { + return 33; + } + } + + @Test + public void testReplacesConsistent() throws InterruptedException { + for (int i = 0; i < 1000; i++) { + List nodes = assertInParallel(ReplaceAcrossStateBitsetsNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex); + }); + + // verify that we ultimately end up in consistent states in all the nodes + + for (ReplaceAcrossStateBitsetsNode node : nodes) { + List infos = Introspection.getSpecializations(node); + SpecializationInfo s32 = infos.get(32); + SpecializationInfo s33 = infos.get(33); + if (s32.isActive()) { + for (int j = 0; j < 32; j++) { + assertFalse(String.valueOf(j), infos.get(j).isActive()); + } + } + if (s33.isActive()) { + for (int j = 0; j < 33; j++) { + assertFalse(String.valueOf(j), infos.get(j).isActive()); + } + } + } + } + + } + + static final int NODES = 100; + static final int THREADS = 33; + + private List assertInParallel(Supplier nodeFactory, ParallelObjectConsumer assertions) throws InterruptedException { + final int threads = THREADS; + final int threadPools = 1; + final int iterations = 1; + /* + * We create multiple nodes and run the assertions in a loop to avoid implicit + * synchronization through the synchronization primitives when running the assertions just + * for a single node. + */ + final int nodesCount = NODES; + return assertNodeInParallel(nodeFactory, assertions, threadPools, threads, iterations, nodesCount); + } + +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 91aa2e7a6bb5..78cdc2eab1f7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1744,7 +1744,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz, boolean inlined) { BlockState blocks = BlockState.NONE; if (needsRewrites) { - builder.startIf().tree(multiState.createContains(innerFrameState, StateQuery.create(SpecializationActive.class, specialization))).end().startBlock(); + builder.startIf().tree(createSpecializationActiveCheck(frameState, Arrays.asList(specialization))).end().startBlock(); List tripples = createFastPathNeverDefaultGuards(innerFrameState, specialization); blocks = IfTriple.materialize(builder, tripples, false); } @@ -4840,9 +4840,11 @@ private List createSpecializationActive(FrameState frameState, Special final boolean stateGuaranteed = group.isLast() && allowedSpecializations != null && allowedSpecializations.size() == 1 && group.getAllSpecializations().size() == allowedSpecializations.size(); if (needsRewrites()) { - CodeTree stateCheck = multiState.createContains(frameState, StateQuery.create(SpecializationActive.class, specializations)); - CodeTree stateGuard = null; + + CodeTree stateCheck = createSpecializationActiveCheck(frameState, specializations); + CodeTree assertCheck = null; + CodeTree stateGuard = null; if (stateGuaranteed) { assertCheck = CodeTreeBuilder.createBuilder().startAssert().tree(stateCheck).end().build(); } else { @@ -4853,6 +4855,38 @@ private List createSpecializationActive(FrameState frameState, Special return Collections.emptyList(); } + private CodeTree createSpecializationActiveCheck(FrameState frameState, List specializations) { + StateQuery query = StateQuery.create(SpecializationActive.class, specializations); + CodeTree stateCheck = multiState.createContains(frameState, query); + + if (specializations.size() == 1) { + Set replacedBy = specializations.get(0).getReplacedBy(); + if (!replacedBy.isEmpty()) { + BitSet set = multiState.findSet(query); + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.tree(stateCheck); + Set checkBitSets = new LinkedHashSet<>(); + + for (SpecializationData replaced : replacedBy) { + StateQuery replacedQuery = StateQuery.create(SpecializationActive.class, replaced); + BitSet bitSet = multiState.findSet(replacedQuery); + if (!bitSet.equals(set)) { + checkBitSets.add(bitSet); + } + } + StateQuery replacedQuery = StateQuery.create(SpecializationActive.class, replacedBy); + for (BitSet bitSet : checkBitSets) { + b.string(" && "); + b.tree(bitSet.createNotContains(frameState, replacedQuery)); + } + + stateCheck = b.build(); + } + + } + return stateCheck; + } + private boolean buildSpecializationSlowPath(final CodeTreeBuilder builder, FrameState frameState, SpecializationGroup group, NodeExecutionMode mode, List outerTriples, List guardExpressions) throws AssertionError { SpecializationData specialization = group.getSpecialization(); @@ -5379,7 +5413,7 @@ private CodeTree createDuplicationCheck(CodeTreeBuilder parent, FrameState frame if (useSpecializationClass) { builder.startWhile().string(specializationLocalName, " != null").end().startBlock(); } else { - duplicationTriples.add(new IfTriple(null, state.activeState.createContains(innerFrameState, StateQuery.create(SpecializationActive.class, specialization)), null)); + duplicationTriples.add(new IfTriple(null, createSpecializationActiveCheck(innerFrameState, Arrays.asList(specialization)), null)); } duplicationTriples.addAll(createFastPathNeverDefaultGuards(innerFrameState, group.getSpecialization())); From 4b28e33c5cbdc055dc341cc000881e5da6cd8899 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 00:21:41 +0100 Subject: [PATCH 232/312] Fix always use blocks for prepareForAOT(). --- .../dsl/processor/generator/FlatNodeGenFactory.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 78cdc2eab1f7..94eb56d1d3b5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1467,9 +1467,7 @@ private void generateAOT(CodeTypeElement clazz, boolean inlined) { for (SpecializationData specialization : filteredSpecializations) { - if (hasMultipleNodes()) { - builder.startBlock(); // local can overlap between nodes - } + builder.startBlock(); // local can overlap between nodes // we need to copy otherwise local variables of caches may conflict. FrameState innerFrameState = frameState.copy(); @@ -1572,9 +1570,7 @@ private void generateAOT(CodeTypeElement clazz, boolean inlined) { builder.tree(multiState.createSet(innerFrameState, null, StateQuery.create(SpecializationActive.class, specialization), true, true)); builder.end(blockState.blockCount); - if (hasMultipleNodes()) { - builder.end(); - } + builder.end(); } StateTransaction transaction = new StateTransaction(); builder.tree(multiState.createForceLoad(frameState, From b2a10733a3e9fe8f3b533e6c106f57f9715f1bfd Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 00:21:52 +0100 Subject: [PATCH 233/312] Ignore more warnings in Sulong. --- .../intrinsics/llvm/aarch64/package-info.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/package-info.java diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/package-info.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/package-info.java new file mode 100644 index 000000000000..066b04dd0f12 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/aarch64/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-42838 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.llvm.runtime.nodes.intrinsics.llvm.aarch64; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; From 477ee6665a08f60869d1b2468292bd99ae549bbc Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 11:46:30 +0100 Subject: [PATCH 234/312] Fix missing never default in wasm. --- .../src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java index e7807b77227b..385c356171f7 100644 --- a/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java +++ b/wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/nodes/WasmIndirectCallNode.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; @@ -70,6 +71,7 @@ static Object doIndirect(CallTarget target, Object[] args, return indirectCall.call(target, args); } + @NeverDefault public static WasmIndirectCallNode create() { return WasmIndirectCallNodeGen.create(); } From f8f0a53a3dec3bd7b26697251b1872f2756e9e76 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 11:55:22 +0100 Subject: [PATCH 235/312] Fix migrate profile in nfi. --- .../src/com/oracle/svm/truffle/nfi/ErrnoMirror.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/ErrnoMirror.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/ErrnoMirror.java index 753c717d03a3..f35970bdb608 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/ErrnoMirror.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/ErrnoMirror.java @@ -30,6 +30,7 @@ import com.oracle.svm.core.threadlocal.FastThreadLocalBytes; import com.oracle.svm.core.threadlocal.FastThreadLocalFactory; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -37,7 +38,8 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @ExportLibrary(InteropLibrary.class) @SuppressWarnings("static-method") @@ -107,9 +109,10 @@ boolean isArrayElementReadable(long idx) { @ExportMessage String readArrayElement(long idx, - @Cached BranchProfile exception) throws InvalidArrayIndexException { + @Bind("$node") Node node, + @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(idx)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(idx); } return keys[(int) idx]; From 0bf817b2622db2db348e62e8f337604f1e392c14 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 12:01:44 +0100 Subject: [PATCH 236/312] Fix use accessor to inline to host node. --- .../org/graalvm/polyglot/impl/AbstractPolyglotImpl.java | 2 -- .../api/test/wrapper/GuestToHostLanguageService.java | 5 ----- .../src/com/oracle/truffle/api/impl/Accessor.java | 3 +++ .../src/com/oracle/truffle/host/HostAccessor.java | 7 +++++++ .../src/com/oracle/truffle/host/HostLanguageService.java | 6 ------ .../com/oracle/truffle/polyglot/PolyglotToHostNode.java | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java index c53b5e031d99..33424ef467b0 100644 --- a/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java +++ b/sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java @@ -796,8 +796,6 @@ public abstract void initializeHostContext(Object internalContext, Object contex public abstract Object findStaticClass(Object context, String classValue); - public abstract Object inlineToHostTypeNode(Object inlineTarget); - public abstract T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType); public abstract boolean isHostValue(Object value); diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java index 63f879b57a52..53033ded7070 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/wrapper/GuestToHostLanguageService.java @@ -100,11 +100,6 @@ public Object findStaticClass(Object context, String classValue) { throw new UnsupportedOperationException(); } - @Override - public Object inlineToHostTypeNode(Object inlineTarget) { - throw new UnsupportedOperationException(); - } - @Override public T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType) { throw new UnsupportedOperationException(); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java index 463153ad29d3..f34cba341c0b 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java @@ -106,6 +106,7 @@ import com.oracle.truffle.api.TruffleLogger; import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.TruffleStackTraceElement; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.MaterializedFrame; @@ -303,6 +304,8 @@ protected HostSupport() { public abstract boolean isHostLanguage(Class languageClass); + public abstract Node inlineToHostNode(Object target); + } public abstract static class EngineSupport extends Support { diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAccessor.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAccessor.java index a447afb9aa4a..a092016d65de 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAccessor.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostAccessor.java @@ -49,8 +49,10 @@ import org.graalvm.polyglot.proxy.Proxy; import com.oracle.truffle.api.TruffleLanguage; +import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; import com.oracle.truffle.api.impl.Accessor; import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; final class HostAccessor extends Accessor { @@ -158,6 +160,11 @@ public boolean isGuestToHostRootNode(RootNode root) { public boolean isHostLanguage(Class languageClass) { return languageClass == HostLanguage.class; } + + @Override + public Node inlineToHostNode(Object target) { + return HostToTypeNodeGen.inline((InlineTarget) target); + } } } diff --git a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java index 614d0622b039..5b38df4fd464 100644 --- a/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java +++ b/truffle/src/com.oracle.truffle.host/src/com/oracle/truffle/host/HostLanguageService.java @@ -53,7 +53,6 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleOptions; -import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.nodes.Node; @@ -120,11 +119,6 @@ public Object findStaticClass(Object receiver, String classValue) { return HostObject.forStaticClass(found, context); } - @Override - public Object inlineToHostTypeNode(Object inlineTarget) { - return HostToTypeNodeGen.inline((InlineTarget) inlineTarget); - } - @SuppressWarnings("unchecked") @Override public T toHostType(Object hostNode, Object targetNode, Object hostContext, Object value, Class targetType, Type genericType) { diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java index 87222a5c720e..0fd8c705e0c7 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotToHostNode.java @@ -70,7 +70,7 @@ static Object doDefault(Node node, PolyglotLanguageContext languageContext, Obje static Node inlineToHost( @RequiredField(bits = 3, value = StateField.class) // @RequiredField(type = Node.class, value = ReferenceField.class) InlineTarget target) { - return (Node) PolyglotContextImpl.requireContext().engine.host.inlineToHostTypeNode(target); + return EngineAccessor.HOST.inlineToHostNode(target); } } From 570216b7499e6818026e9fedd031f872d6437ac9 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 14:49:47 +0100 Subject: [PATCH 237/312] Fix non-determinism in code generation. --- .../truffle/api/dsl/test/FallbackTest.java | 43 +++++++++++ .../dsl/test/ReplacesThreadSafetyTest.java | 2 +- .../com/oracle/truffle/api/impl/Accessor.java | 3 +- .../dsl/processor/generator/BitStateList.java | 4 +- .../generator/FlatNodeGenFactory.java | 75 ++++++++++--------- .../processor/model/SpecializationData.java | 3 +- .../dsl/processor/parser/NodeParser.java | 2 +- 7 files changed, 90 insertions(+), 42 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java index 34b2c7e0e0aa..ad9a5e0f41f7 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java @@ -54,6 +54,7 @@ import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.ImplicitCast; @@ -74,6 +75,7 @@ import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithAssumptionArrayNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithAssumptionNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithCachedNodeGen; +import com.oracle.truffle.api.dsl.test.FallbackTestFactory.GuardNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.ImplicitCastInFallbackNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.InvertedGuardNodeGen; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; @@ -798,4 +800,45 @@ protected String f(Object arg0) { } + abstract static class GuardNode extends Node { + + public abstract boolean execute(Object left); + + @Specialization + protected boolean s0(@SuppressWarnings("unused") int arg0) { + return true; + } + + @Fallback + protected boolean s0(@SuppressWarnings("unused") Object arg0) { + return false; + } + + // intentionally no never default + static GuardNode create() { + return GuardNodeGen.create(); + } + + } + + @SuppressWarnings("unused") + public abstract static class SharedGuardReachesFallback extends Node { + + public abstract String execute(Object left); + + @Specialization(guards = {"shared.execute(arg0)", "notShared.execute(arg0)"}, limit = "1") + protected String s0(Object arg0, + @Cached(neverDefault = false) GuardNode notShared, + @Shared("shared") @Cached(neverDefault = false) GuardNode shared) { + return "s0"; + } + + @Fallback + protected String f0(Object arg0, + @Shared("shared") @Cached(neverDefault = false) GuardNode shared) { + return "f0"; + } + + } + } diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java index f0d1518bf039..76bf6d636381 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.dsl.Introspection; import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.test.ReplacesThreadSafetyTestFactory.ReplaceAcrossStateBitsetsNodeGen; +import com.oracle.truffle.api.dsl.test.ReplacesThreadSafetyTestFactory2.ReplaceAcrossStateBitsetsNodeGen; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java index f34cba341c0b..63640cd146dd 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java @@ -79,9 +79,9 @@ import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; import org.graalvm.polyglot.impl.AbstractPolyglotImpl; -import org.graalvm.polyglot.impl.AbstractPolyglotImpl.LogHandler; import org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostAccess; import org.graalvm.polyglot.impl.AbstractPolyglotImpl.AbstractHostLanguageService; +import org.graalvm.polyglot.impl.AbstractPolyglotImpl.LogHandler; import org.graalvm.polyglot.io.FileSystem; import org.graalvm.polyglot.io.MessageTransport; import org.graalvm.polyglot.io.ProcessHandler; @@ -106,7 +106,6 @@ import com.oracle.truffle.api.TruffleLogger; import com.oracle.truffle.api.TruffleRuntime; import com.oracle.truffle.api.TruffleStackTraceElement; -import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.MaterializedFrame; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java index c1cd523c7732..bcb49ffe1bf0 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java @@ -44,7 +44,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -370,7 +369,7 @@ private static boolean canBeInSameBitSet(List states, StateGroup gro private static List groupByDependentSpecializations(List states) { List groups = new ArrayList<>(); - Map specializationGroups = new HashMap<>(); + Map specializationGroups = new LinkedHashMap<>(); for (BitRangedState state : states) { SpecializationData dependentSpecialization = state.state.getDependentSpecialization(); @@ -389,6 +388,7 @@ private static List groupByDependentSpecializations(List(), null, dependentSpecialization); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 94eb56d1d3b5..db7e29226d44 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5154,7 +5154,14 @@ private static Collection getNullCachesDueToFallback(Specializa } Set boundCaches = specialization.getBoundCaches(guard.getExpression(), false); if (useSpecializationClass(specialization)) { - return Collections.emptyList(); + // with a specialization class only shared guards may be null. + Set filteredCaches = new LinkedHashSet<>(); + for (CacheExpression cache : boundCaches) { + if (cache.getSharedGroup() != null) { + filteredCaches.add(cache); + } + } + return filteredCaches; } else { return boundCaches; } @@ -6643,7 +6650,39 @@ private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationDat CodeTreeBuilder condition = CodeTreeBuilder.createBuilder(); DSLExpression expression = optimizeExpression(guard.getExpression()); - if (mode.isGuardFallback()) { + CodeTree assertion = null; // overrule with assertion + if (mode.isFastPath()) { + CodeTree guardExpression = writeExpression(frameState, specialization, expression); + + /* + * We do not need to invoke a guard on the fast-path if: + * + * (1) the guard does not bind any dynamic parameter, only cached valuees. + * + * (2) The guard is not a weak reference. Weak references do not bind dynamic + * parameters, but need to be checked each time. + * + * (3) The guard needs a state bit and may be partially initialized. + */ + if (!specialization.isDynamicParameterBound(expression, true) && !guard.isWeakReferenceGuard() && !guardNeedsNodeStateBit(specialization, guard)) { + assertion = CodeTreeBuilder.createBuilder().startAssert().tree(guardExpression).end().build(); + } else { + condition.tree(guardExpression); + } + } else if (mode.isSlowPath() || mode.isUncached()) { + + if (mode.isSlowPath() && specialization.isNodeReceiverBound(expression) && substituteNodeWithSpecializationClass(specialization)) { + init.tree(initializeSpecializationClass(frameState, specialization, false)); + } + + CodeTree guardExpression = writeExpression(frameState, specialization, expression); + if (guard.isConstantTrueInSlowPath(mode.isUncached())) { + assertion = CodeTreeBuilder.createBuilder().startStatement().string("// assert ").tree(guardExpression).end().build(); + } else { + condition.tree(guardExpression); + } + } else if (mode.isGuardFallback()) { + GuardExpression guardWithBit = getGuardThatNeedsStateBit(specialization, guard); if (guardWithBit != null) { condition.string("("); @@ -6696,38 +6735,6 @@ private IfTriple createMethodGuardCheck(FrameState frameState, SpecializationDat } } - if (mode.isSlowPath() && specialization.isNodeReceiverBound(expression) && substituteNodeWithSpecializationClass(specialization)) { - init.tree(initializeSpecializationClass(frameState, specialization, false)); - } - - CodeTree assertion = null; // overrule with assertion - if (mode.isFastPath()) { - CodeTree guardExpression = writeExpression(frameState, specialization, expression); - - /* - * We do not need to invoke a guard on the fast-path if: - * - * (1) the guard does not bind any dynamic parameter, only cached valuees. - * - * (2) The guard is not a weak reference. Weak references do not bind dynamic - * parameters, but need to be checked each time. - * - * (3) The guard needs a state bit and may be partially initialized. - */ - if (!specialization.isDynamicParameterBound(expression, true) && !guard.isWeakReferenceGuard() && !guardNeedsNodeStateBit(specialization, guard)) { - assertion = CodeTreeBuilder.createBuilder().startAssert().tree(guardExpression).end().build(); - } else { - condition.tree(guardExpression); - } - } else if (mode.isSlowPath() || mode.isUncached()) { - CodeTree guardExpression = writeExpression(frameState, specialization, expression); - if (guard.isConstantTrueInSlowPath(mode.isUncached())) { - assertion = CodeTreeBuilder.createBuilder().startStatement().string("// assert ").tree(guardExpression).end().build(); - } else { - condition.tree(guardExpression); - } - } - return new IfTriple(init.build(), condition.build(), assertion); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java index d8bf86d64e78..10c657238e24 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/SpecializationData.java @@ -43,7 +43,6 @@ import java.lang.ref.Reference; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -390,7 +389,7 @@ public boolean isGuardBoundWithCache(GuardExpression guardExpression) { } public Set getBoundCaches(DSLExpression guardExpression, boolean transitiveCached) { - return getBoundCachesImpl(new HashSet<>(), guardExpression, transitiveCached); + return getBoundCachesImpl(new LinkedHashSet<>(), guardExpression, transitiveCached); } private Set getBoundCachesImpl(Set visitedExpressions, DSLExpression guardExpression, boolean transitiveCached) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index e7418f046077..1c1a9b5a0ec2 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -2758,7 +2758,7 @@ private void resolveReplaces(NodeData node) { } // transitively resolve includes - Set foundSpecializations = new HashSet<>(); + Set foundSpecializations = new LinkedHashSet<>(); collectIncludes(specialization, foundSpecializations, new HashSet()); specialization.getReplaces().addAll(foundSpecializations); } From 5f51eff6a3c41259a4be90409f1e01ac16384dd7 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 14:58:06 +0100 Subject: [PATCH 238/312] Fix warning in MemoryDump class. --- .../insight/heap/instrument/MemoryDump.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tools/src/org.graalvm.tools.insight.heap/src/org/graalvm/tools/insight/heap/instrument/MemoryDump.java b/tools/src/org.graalvm.tools.insight.heap/src/org/graalvm/tools/insight/heap/instrument/MemoryDump.java index a990e6f5d1a0..26ee5de6ca09 100644 --- a/tools/src/org.graalvm.tools.insight.heap/src/org/graalvm/tools/insight/heap/instrument/MemoryDump.java +++ b/tools/src/org.graalvm.tools.insight.heap/src/org/graalvm/tools/insight/heap/instrument/MemoryDump.java @@ -24,19 +24,8 @@ */ package org.graalvm.tools.insight.heap.instrument; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.InvalidArrayIndexException; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnknownIdentifierException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.profiles.BranchProfile; +import static org.graalvm.tools.insight.heap.instrument.HeapGenerator.asIntOrNull; +import static org.graalvm.tools.insight.heap.instrument.HeapGenerator.asStringOrNull; import java.util.ArrayList; import java.util.Arrays; @@ -49,8 +38,22 @@ import org.graalvm.collections.EconomicMap; import org.graalvm.tools.insight.heap.HeapDump; -import static org.graalvm.tools.insight.heap.instrument.HeapGenerator.asIntOrNull; -import static org.graalvm.tools.insight.heap.instrument.HeapGenerator.asStringOrNull; + +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.InvalidArrayIndexException; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.UnknownIdentifierException; +import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; +import com.oracle.truffle.api.library.ExportLibrary; +import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; /** * Dump of heap memory. This object accumulates memory dump events. @@ -383,9 +386,11 @@ boolean isArrayElementReadable(long index) { } @ExportMessage - Object readArrayElement(long index, @Cached BranchProfile exception) throws InvalidArrayIndexException { + Object readArrayElement(long index, + @Bind("$node") Node node, + @Cached InlinedBranchProfile exception) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { - exception.enter(); + exception.enter(node); throw InvalidArrayIndexException.create(index); } return members[(int) index]; From 0c4a1dbdc016023b595f918aa1a64b9c93381ebd Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 16:54:44 +0100 Subject: [PATCH 239/312] Fix import. --- .../oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java index 76bf6d636381..f0d1518bf039 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReplacesThreadSafetyTest.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.dsl.Introspection; import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.test.ReplacesThreadSafetyTestFactory2.ReplaceAcrossStateBitsetsNodeGen; +import com.oracle.truffle.api.dsl.test.ReplacesThreadSafetyTestFactory.ReplaceAcrossStateBitsetsNodeGen; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; From 83bf2ee783d83d3069e59b17859bc794174314be Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 19:07:08 +0100 Subject: [PATCH 240/312] Fix unused implicit casts should not be loaded on the slow-path and also not require state space. --- .../api/dsl/test/ImplicitCastTest.java | 45 +++++++++++++++ .../generator/FlatNodeGenFactory.java | 20 ++++++- .../dsl/processor/model/TemplateMethod.java | 56 +++++++------------ .../dsl/processor/parser/NodeParser.java | 2 +- 4 files changed, 83 insertions(+), 40 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java index abf8cd6b50da..7adf7500db97 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java @@ -43,6 +43,8 @@ import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; import static org.junit.Assert.assertEquals; +import java.lang.reflect.Field; + import org.junit.Assert; import org.junit.Assume; import org.junit.Test; @@ -69,6 +71,8 @@ import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.StringEquals2NodeGen; import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.StringEquals3NodeGen; import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.TestImplicitCastWithCacheNodeGen; +import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.TestUnusedImplicitCast1NodeGen; +import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.TestUnusedImplicitCast2NodeGen; import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.ThirtyThreeBitsNodeGen; import com.oracle.truffle.api.dsl.test.ImplicitCastTestFactory.ThirtyTwoBitsNodeGen; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; @@ -744,4 +748,45 @@ static long do11(double v) { } } + @TypeSystemReference(ImplicitCastOrder.class) + public abstract static class TestUnusedImplicitCast1Node extends Node { + + public abstract long execute(long a0, long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, long a9); + + @Specialization + protected long doDefault(long a0, long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, long a9) { + return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9; + } + } + + @TypeSystemReference(ImplicitCastOrder.class) + public abstract static class TestUnusedImplicitCast2Node extends Node { + + public abstract long execute(long a0, long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, Object a9); + + @Specialization + protected long doDefault(long a0, long a1, long a2, long a3, long a4, + long a5, long a6, long a7, long a8, long a9) { + return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9; + } + } + + @Test + public void testUnusedImplicitCast() { + Field[] fields = TestUnusedImplicitCast1NodeGen.class.getDeclaredFields(); + + // no fields for unused implicit casts + assertEquals(0, fields.length); + + fields = TestUnusedImplicitCast2NodeGen.class.getDeclaredFields(); + + // single state field expected. unused states are filtered otherwise + // there would be two fields. + assertEquals(1, fields.length); + + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index db7e29226d44..5b0faf82a2f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -328,6 +328,18 @@ private List createInlineFields(boolean pruneInternalClasses) { } + private static boolean isImplicitCastUsed(ExecutableTypeData executable, Collection usedSpecializations, TypeGuard guard) { + int signatureIndex = guard.getSignatureIndex(); + TypeMirror polymorphicParameter = executable.getSignatureParameters().get(signatureIndex); + for (SpecializationData specialization : usedSpecializations) { + TypeMirror specializationType = specialization.getSignatureParameters().get(signatureIndex).getType(); + if (ElementUtils.needsCastTo(polymorphicParameter, specializationType)) { + return true; + } + } + return false; + } + BitStateList computeNodeState() { List> stateObjects = new ArrayList<>(); boolean aotStateAdded = false; @@ -385,7 +397,9 @@ BitStateList computeNodeState() { } } for (TypeGuard cast : implicitCasts) { - stateObjects.add(new ImplicitCastState(stateNode, cast)); + if (isImplicitCastUsed(stateNode.getPolymorphicExecutable(), specializations, cast)) { + stateObjects.add(new ImplicitCastState(stateNode, cast)); + } } } @@ -7623,7 +7637,9 @@ static boolean isRelevantForSlowPath(BitSet bitSet, Collection parameters; + private final List signatureParmeters; private final Map parameterCache = new HashMap<>(); public TemplateMethod(String id, int naturalOrder, Template template, MethodSpec specification, ExecutableElement method, AnnotationMirror markerAnnotation, Parameter returnType, @@ -84,12 +85,17 @@ public TemplateMethod(String id, int naturalOrder, Template template, MethodSpec this.markerAnnotation = markerAnnotation; this.returnType = returnType; this.parameters = new ArrayList<>(parameters); + this.signatureParmeters = new ArrayList<>(parameters.size()); for (Parameter param : parameters) { parameterCache.put(param.getLocalName(), param); + if (param.getSpecification().isSignature()) { + signatureParmeters.add(param); + } } if (returnType != null) { parameterCache.put(returnType.getLocalName(), returnType); } + this.id = id; } @@ -97,9 +103,12 @@ public final Parameter getFrame() { return findParameter(FRAME_NAME); } - public void addParameter(int index, Parameter p) { - this.parameters.add(index, p); + public void addParameter(Parameter p) { + this.parameters.add(p); this.parameterCache.put(p.getLocalName(), p); + if (p.getSpecification().isSignature()) { + signatureParmeters.add(p); + } } public String createReferenceName() { @@ -162,17 +171,6 @@ public Parameter getReturnType() { return returnType; } - public void replaceParameter(String localName, Parameter newParameter) { - if (returnType.getLocalName().equals(localName)) { - returnType = newParameter; - } else { - Parameter local = findParameter(localName); - int index = parameters.indexOf(local); - parameters.set(index, newParameter); - } - parameterCache.put(newParameter.getLocalName(), newParameter); - } - public Iterable getDynamicParameters() { return new FilteredIterable<>(getParameters(), new Predicate() { public boolean evaluate(Parameter value) { @@ -181,12 +179,8 @@ public boolean evaluate(Parameter value) { }); } - public Iterable getSignatureParameters() { - return new FilteredIterable<>(getParameters(), new Predicate() { - public boolean evaluate(Parameter value) { - return value.getSpecification().isSignature(); - } - }); + public List getSignatureParameters() { + return signatureParmeters; } public List getParameters() { @@ -194,34 +188,22 @@ public List getParameters() { } public Parameter findParameterOrDie(NodeExecutionData execution) { - for (Parameter parameter : parameters) { - if (parameter.getSpecification().isSignature() && parameter.getSpecification().getExecution() == execution) { - return parameter; - } + Parameter p = findParameter(execution); + if (p == null) { + throw new AssertionError("Could not find parameter for execution"); } - throw new AssertionError("Could not find parameter for execution"); + return p; } public Parameter findParameter(NodeExecutionData execution) { - for (Parameter parameter : parameters) { - if (parameter.getSpecification().isSignature() && parameter.getSpecification().getExecution() == execution) { + for (Parameter parameter : signatureParmeters) { + if (parameter.getSpecification().getExecution() == execution) { return parameter; } } return null; } - public List findByExecutionData(NodeExecutionData execution) { - List foundParameters = new ArrayList<>(); - for (Parameter parameter : getParameters()) { - ParameterSpec spec = parameter.getSpecification(); - if (spec != null && spec.getExecution() != null && spec.getExecution().equals(execution) && parameter.getSpecification().isSignature()) { - foundParameters.add(parameter); - } - } - return foundParameters; - } - public Parameter findParameter(String valueName) { return parameterCache.get(valueName); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 1c1a9b5a0ec2..6ffd0172c4ed 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -3105,7 +3105,7 @@ private SpecializationData initializeCaches(SpecializationData specialization, D DSLExpressionResolver weakResolver = resolver.copy(Arrays.asList()); weakResolver.addVariable(weakName, weakVariable); - specialization.addParameter(specialization.getParameters().size(), weakParameter); + specialization.addParameter(weakParameter); DSLExpression parsedDefaultExpression = parseCachedExpression(weakResolver, cache, parameter.getType(), weakName + ".get()"); cache.setDefaultExpression(parsedDefaultExpression); From 37655bd44a411bd98073035d7ee9b65074457d91 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 15 Dec 2022 19:15:19 +0100 Subject: [PATCH 241/312] Fix aot helper in sulong. --- .../llvm/runtime/nodes/api/LLVMNode.java | 12 +++++-- .../runtime/nodes/func/LLVMDispatchNode.java | 32 +++++++------------ .../intrinsics/llvm/LLVMStackBuiltin.java | 10 ++---- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java index 0b2e18c28703..728f08789a82 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicLong; +import java.util.function.BiConsumer; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerAsserts; @@ -284,8 +285,15 @@ public static final class AOTInitHelper extends Node implements GenerateAOT.Prov private final GenerateAOT.Provider delegate; - public AOTInitHelper(GenerateAOT.Provider delegate) { - this.delegate = delegate; + public AOTInitHelper(BiConsumer, RootNode> delegate) { + this.delegate = new GenerateAOT.Provider() { + + @Override + public void prepareForAOT(TruffleLanguage language, RootNode root) { + delegate.accept(language, root); + } + + }; } @Override diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java index 884bcaa57d47..6b4b47863c52 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMDispatchNode.java @@ -33,7 +33,6 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; @@ -47,7 +46,6 @@ import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.IndirectCallNode; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.llvm.runtime.CommonNodeFactory; @@ -101,20 +99,17 @@ protected LLVMDispatchNode(FunctionType type, LLVMFunction llvmFunction) { // llvmFunction.getFixedCode() to return the intrinsic. // Therefore, the pre-initialization must be postponed to the AOT preparation stage // using the AOTInitHelper. - aotInitHelper = new AOTInitHelper(new GenerateAOT.Provider() { - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - if (llvmFunction != null) { - if (llvmFunction.getFixedCode() != null && llvmFunction.getFixedCode().isIntrinsicFunctionSlowPath()) { - LLVMDispatchNode.this.aotFixedIntrinsicFunction = llvmFunction; - llvmFunction.getFixedCode().getIntrinsicSlowPath().cachedCallTarget(type); - } + aotInitHelper = new AOTInitHelper((language, root) -> { + if (llvmFunction != null) { + if (llvmFunction.getFixedCode() != null && llvmFunction.getFixedCode().isIntrinsicFunctionSlowPath()) { + LLVMDispatchNode.this.aotFixedIntrinsicFunction = llvmFunction; + llvmFunction.getFixedCode().getIntrinsicSlowPath().cachedCallTarget(type); } - aot = true; - // Throw the helper AOT init node away as it is used during the AOT preparation - // stage only - aotInitHelper = null; } + aot = true; + // Throw the helper AOT init node away as it is used during the AOT preparation + // stage only + aotInitHelper = null; }); // Early parsing of the function's signature for the sake of the AOT preparation @@ -134,12 +129,9 @@ public void prepareForAOT(TruffleLanguage language, RootNode root) { throw new RuntimeException(e); } } else { - aotInitHelper = new AOTInitHelper(new GenerateAOT.Provider() { - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - aot = true; - aotInitHelper = null; - } + aotInitHelper = new AOTInitHelper((language, root) -> { + aot = true; + aotInitHelper = null; }); } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java index 3d414e38811b..3c9534ee21c7 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java @@ -31,9 +31,6 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.dsl.GenerateAOT; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.llvm.runtime.memory.LLVMStack.LLVMStackAccess; import com.oracle.truffle.llvm.runtime.nodes.func.LLVMRootNode; @@ -44,11 +41,8 @@ abstract class LLVMStackBuiltin extends LLVMBuiltin { /** * Eager initialization of stackAccess during AOT preparation. */ - @Child private AOTInitHelper aotInitHelper = new AOTInitHelper(new GenerateAOT.Provider() { - @Override - public void prepareForAOT(TruffleLanguage language, RootNode root) { - stackAccess = ((LLVMRootNode) root).getStackAccess(); - } + @Child private AOTInitHelper aotInitHelper = new AOTInitHelper((language, root) -> { + stackAccess = ((LLVMRootNode) root).getStackAccess(); }); protected LLVMStackAccess ensureStackAccess() { From 2fe5e76f6bdd8d0abb3104b837650c5ee75e2a89 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 12:17:34 +0100 Subject: [PATCH 242/312] Fix compilation error. --- .../compiler/truffle/test/GenerateInlineCompilationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java index ea5e2487aa65..977f915bbe8d 100644 --- a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GenerateInlineCompilationTest.java @@ -135,7 +135,7 @@ public Object execute(VirtualFrame frame) { @Override protected ExecutionSignature prepareForAOT() { AOTSupport.prepareForAOT(this); - return ExecutionSignature.create(Integer.class, new Class[0]); + return ExecutionSignature.create(Integer.class, new Class[0]); } @Override From e1f9ba1c3c9e5ddf58630aa69f903bb33ddc618c Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 12:17:46 +0100 Subject: [PATCH 243/312] Fix sulong copyrights. --- .../src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java | 2 +- .../debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java | 2 +- .../runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java | 2 +- .../src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java | 2 +- .../oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java | 2 +- .../oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java | 2 +- .../oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java | 2 +- .../truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java | 2 +- .../truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java | 2 +- .../runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java | 2 +- .../truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java | 2 +- .../llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java | 2 +- .../llvm/runtime/nodes/memory/NativeProfiledMemMove.java | 2 +- .../truffle/llvm/runtime/nodes/others/LLVMSelectNode.java | 2 +- .../llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java b/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java index c0dcc6bfd9b2..96d0ab0a4f2b 100644 --- a/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.nfi/src/com/oracle/truffle/llvm/nfi/SulongNFIRootNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java index d174d76c55b8..c2438d6e14d9 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprShortCircuitEvaluationNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java index 207b07d3164a..d8f580fa8922 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/debug/debugexpr/nodes/DebugExprTernaryNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java index 728f08789a82..eb448b1637e2 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/api/LLVMNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java index 653d788de996..0b736fd50576 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64AdcNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java index 98ad25a7acda..02dccbc78407 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsfNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java index 9274e8e1ba41..1087c3f9c230 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64BsrNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java index 18a71e5d591f..a0981cab3aff 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64CmpXchgNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java index f288f54afebc..aa097757039f 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/LLVMAMD64LoadFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java index 9ba99c2983ae..3afbc2055be8 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/asm/syscall/LLVMAMD64SyscallMmapNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java index 9aa7bab75f69..ff50e528b006 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/control/LLVMSwitchNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java index 3c9534ee21c7..893788cbf0f6 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/intrinsics/llvm/LLVMStackBuiltin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java index 27f8a07b2c28..aaa46a64be0b 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/memory/NativeProfiledMemMove.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java index 37b7b918dd44..db7262b6b063 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/others/LLVMSelectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java index 388cc7f6e1de..85576d2e0ec0 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/vector/LLVMShuffleVectorNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. * * All rights reserved. * From 59536d353d6ddff8917e1481ac89b5bdac38c3a1 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 12:24:26 +0100 Subject: [PATCH 244/312] Fix warning in runner. --- .../src/org/graalvm/polybench/micro/Runner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/Runner.java b/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/Runner.java index e6b256d6f005..f2954227a7ab 100644 --- a/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/Runner.java +++ b/vm/src/org.graalvm.polybench.micro/src/org/graalvm/polybench/micro/Runner.java @@ -68,7 +68,7 @@ boolean isExecutable() { @ExportMessage static final class Execute { - @Specialization(guards = "callNode.getCallTarget() == self.workload") + @Specialization(guards = "callNode.getCallTarget() == self.workload", limit = "3") static Object doCached(Workload self, Object[] args, @Cached("create(self.workload)") DirectCallNode callNode) { assert args.length == 0; From 013970d5b8953896873048e6df53053bceca9bea Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 16:42:04 +0100 Subject: [PATCH 245/312] Fix parallel node tests should not trigger compilation. --- .../truffle/api/test/polyglot/AbstractPolyglotTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java index 7b579ac454e4..79a95e7629ee 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/AbstractPolyglotTest.java @@ -254,7 +254,11 @@ protected final List assertNodeInParallel(Supplier object int threads, int iterations, int objectCount) throws InterruptedException { - return assertInParallel(() -> adoptNode(objectFactory.get()).get(), assertions, threadPools, threads, iterations, objectCount); + return assertInParallel(() -> { + T node = objectFactory.get(); + new TestRootNode(language, node).getCallTarget(); + return node; + }, assertions, threadPools, threads, iterations, objectCount); } /** From ac5aab3d3765396cd6d6efd9e63f6ff83d5aa7ea Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 17:20:34 +0100 Subject: [PATCH 246/312] Fix decoding of inlined parent lookups is broken. --- .../src/org/graalvm/compiler/replacements/PEGraphDecoder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java index 645374ad9e6b..6cfb264f1998 100644 --- a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java +++ b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java @@ -1480,6 +1480,7 @@ protected Node canonicalizeFixedNode(MethodScope s, Node originalNode) { * node plugins trigger for them reliably during PE. */ node = ((UnsafeAccessNode) node).canonical(canonicalizerTool); + replacedNode = node; } if (node instanceof LoadFieldNode) { From fcd10e99b1ff03573c160619b47789daf4392c6d Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 17:31:08 +0100 Subject: [PATCH 247/312] Fix no need to run state bit width tests with 64 bits anymore. --- truffle/mx.truffle/mx_truffle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 64948deebf32..f6b50e944985 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -266,7 +266,7 @@ def _truffle_gate_runner(args, tasks): # force using multiple state fields for the tests. This makes sure the tests # do not break for rarely used combination of features and bit widths. def _truffle_gate_state_bitwidth_tests(): - runs = [1, 2, 4, 8, 16, 64] + runs = [1, 2, 4, 8, 16] for run_bits in runs: build_args = ['-f', '-p', '--dependencies', 'TRUFFLE_TEST', '--force-javac', '-A-Atruffle.dsl.StateBitWidth={0}'.format(run_bits)] From b6f066f3e71de79ad3d0850da0b1caf8652930a8 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 17:32:36 +0100 Subject: [PATCH 248/312] Fix typo. --- .../truffle/dsl/processor/generator/FlatNodeGenFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 5b0faf82a2f3..45355f68e254 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5684,7 +5684,7 @@ private CodeTree initializeSpecializationClass(FrameState frameState, Specializa if (!frameState.isSpecializationClassInitialized(specialization)) { if (frameState.getMode().isFastPath()) { - throw new AssertionError("Must never initilization the specialization cache on the fast-path."); + throw new AssertionError("Must never initialize the specialization cache on the fast-path."); } TypeMirror type = createSpecializationClassReferenceType(specialization); From d6f7c1dcad1a9af002fa26c0e94d2e50c50b069b Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 18:08:41 +0100 Subject: [PATCH 249/312] Remove strict compliance from regex downstream gate. --- regex/ci/ci.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex/ci/ci.jsonnet b/regex/ci/ci.jsonnet index a400fe86d2f4..4bf3b94184c6 100644 --- a/regex/ci/ci.jsonnet +++ b/regex/ci/ci.jsonnet @@ -27,7 +27,7 @@ local regex_downstream_js = regex_common + { name: 'gate-regex-downstream-js-oraclejdk' + self.jdk_version, run: [ - ["mx", "testdownstream", "-R", ['mx', 'urlrewrite', 'https://github.com/graalvm/js-tests.git'], "--mx-command", "--strict-compliance gate --strict-mode --all-suites --tags build,Test262-default,TestV8-default,regex"] + ["mx", "testdownstream", "-R", ['mx', 'urlrewrite', 'https://github.com/graalvm/js-tests.git'], "--mx-command", " gate --all-suites --tags build,Test262-default,TestV8-default,regex"] ], targets: ["gate"], }, From f920bbb4cbe4cda0009bb1de67a9208d99c43eb1 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 16 Dec 2022 18:20:04 +0100 Subject: [PATCH 250/312] Ignore and fix some warnings for Espresso. (GR-43114) --- .../espresso/ffi/nfi/package-info.java | 34 +++++++++++++++++++ .../truffle/espresso/ffi/package-info.java | 34 +++++++++++++++++++ .../truffle/espresso/impl/package-info.java | 34 +++++++++++++++++++ .../nodes/bytecodes/BooleanArrayLoad.java | 2 +- .../nodes/bytecodes/BooleanArrayStore.java | 2 +- .../nodes/bytecodes/ByteArrayLoad.java | 2 +- .../nodes/bytecodes/ByteArrayStore.java | 2 +- .../nodes/bytecodes/CharArrayLoad.java | 2 +- .../nodes/bytecodes/CharArrayStore.java | 2 +- .../nodes/bytecodes/DoubleArrayLoad.java | 2 +- .../nodes/bytecodes/DoubleArrayStore.java | 2 +- .../nodes/bytecodes/FloatArrayLoad.java | 2 +- .../nodes/bytecodes/FloatArrayStore.java | 2 +- .../nodes/bytecodes/IntArrayLoad.java | 2 +- .../nodes/bytecodes/IntArrayStore.java | 2 +- .../nodes/bytecodes/InvokeInterface.java | 4 +-- .../nodes/bytecodes/InvokeSpecial.java | 4 +-- .../nodes/bytecodes/InvokeVirtual.java | 4 +-- .../nodes/bytecodes/LongArrayLoad.java | 2 +- .../nodes/bytecodes/LongArrayStore.java | 2 +- .../espresso/nodes/bytecodes/NullCheck.java | 2 +- .../nodes/bytecodes/ReferenceArrayLoad.java | 2 +- .../nodes/bytecodes/ReferenceArrayStore.java | 2 +- .../nodes/bytecodes/ShortArrayLoad.java | 2 +- .../nodes/bytecodes/ShortArrayStore.java | 2 +- .../nodes/bytecodes/package-info.java | 6 +++- .../espresso/nodes/helper/package-info.java | 34 +++++++++++++++++++ .../espresso/nodes/interop/package-info.java | 34 +++++++++++++++++++ .../nodes/methodhandle/MHInvokeBasicNode.java | 6 ++-- .../nodes/methodhandle/MHLinkToNode.java | 8 ++--- .../nodes/methodhandle/package-info.java | 34 +++++++++++++++++++ .../oracle/truffle/espresso/package-info.java | 34 +++++++++++++++++++ .../runtime/dispatch/package-info.java | 34 +++++++++++++++++++ .../Target_java_lang_Thread.java | 2 +- ...t_jdk_internal_module_ModuleLoaderMap.java | 2 +- ...k_internal_module_SystemModuleFinders.java | 4 +-- .../espresso/substitutions/package-info.java | 34 +++++++++++++++++++ 37 files changed, 347 insertions(+), 37 deletions(-) create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java create mode 100644 espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java new file mode 100644 index 000000000000..29152364e522 --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.ffi.nfi; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java new file mode 100644 index 000000000000..f3d3a7b2b10d --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.ffi; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java new file mode 100644 index 000000000000..a42db9e12d21 --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.impl; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayLoad.java index edbddd532744..ba04baea934e 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayLoad.java @@ -59,7 +59,7 @@ public abstract class BooleanArrayLoad extends EspressoNode { public abstract boolean execute(StaticObject receiver, int index); @Specialization - boolean executeWithNullCheck(StaticObject array, int index, + boolean doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck booleanArrayLoad) { return booleanArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayStore.java index 3267b3187913..7b7ea6d8f656 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/BooleanArrayStore.java @@ -66,7 +66,7 @@ public abstract class BooleanArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, byte value); @Specialization - void executeWithNullCheck(StaticObject array, int index, byte value, + void doWithNullCheck(StaticObject array, int index, byte value, @Cached NullCheck nullCheck, @Cached ByteArrayStore.WithoutNullCheck byteArrayStore) { byteArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayLoad.java index fb995d327c33..6a299619778e 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayLoad.java @@ -72,7 +72,7 @@ public abstract class ByteArrayLoad extends EspressoNode { public abstract byte execute(StaticObject receiver, int index); @Specialization - byte executeWithNullCheck(StaticObject array, int index, + byte doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck byteArrayLoad) { return byteArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayStore.java index b0b838dc03c9..2e53f69d8d2f 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ByteArrayStore.java @@ -72,7 +72,7 @@ public abstract class ByteArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, byte value); @Specialization - void executeWithNullCheck(StaticObject array, int index, byte value, + void doWithNullCheck(StaticObject array, int index, byte value, @Cached NullCheck nullCheck, @Cached ByteArrayStore.WithoutNullCheck byteArrayStore) { byteArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayLoad.java index 360470322005..9dbeca9dd75c 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayLoad.java @@ -57,7 +57,7 @@ public abstract class CharArrayLoad extends EspressoNode { public abstract char execute(StaticObject receiver, int index); @Specialization - char executeWithNullCheck(StaticObject array, int index, + char doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck charArrayLoad) { return charArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayStore.java index a17ac43b2fa7..ed1b2338720e 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/CharArrayStore.java @@ -57,7 +57,7 @@ public abstract class CharArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, char value); @Specialization - void executeWithNullCheck(StaticObject array, int index, char value, + void doWithNullCheck(StaticObject array, int index, char value, @Cached NullCheck nullCheck, @Cached CharArrayStore.WithoutNullCheck charArrayStore) { charArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayLoad.java index 2d3f5e743c87..1ce37e04aa07 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayLoad.java @@ -57,7 +57,7 @@ public abstract class DoubleArrayLoad extends EspressoNode { public abstract double execute(StaticObject receiver, int index); @Specialization - double executeWithNullCheck(StaticObject array, int index, + double doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck doubleArrayLoad) { return doubleArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayStore.java index ec5ea24018dd..52d4ef39cc54 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/DoubleArrayStore.java @@ -57,7 +57,7 @@ public abstract class DoubleArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, double value); @Specialization - void executeWithNullCheck(StaticObject array, int index, double value, + void doWithNullCheck(StaticObject array, int index, double value, @Cached NullCheck nullCheck, @Cached WithoutNullCheck doubleArrayStore) { doubleArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayLoad.java index cb9526df25b4..1729df161908 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayLoad.java @@ -57,7 +57,7 @@ public abstract class FloatArrayLoad extends EspressoNode { public abstract float execute(StaticObject receiver, int index); @Specialization - float executeWithNullCheck(StaticObject array, int index, + float doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck floatArrayLoad) { return floatArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayStore.java index 9f218f3f475f..75fa73310ea4 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/FloatArrayStore.java @@ -57,7 +57,7 @@ public abstract class FloatArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, float value); @Specialization - void executeWithNullCheck(StaticObject array, int index, float value, + void doWithNullCheck(StaticObject array, int index, float value, @Cached NullCheck nullCheck, @Cached WithoutNullCheck floatArrayStore) { floatArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayLoad.java index fb450ccbbcc2..921dfe735554 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayLoad.java @@ -57,7 +57,7 @@ public abstract class IntArrayLoad extends EspressoNode { public abstract int execute(StaticObject receiver, int index); @Specialization - int executeWithNullCheck(StaticObject array, int index, + int doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck intArrayLoad) { return intArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayStore.java index 522dd069e158..019da6070aed 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/IntArrayStore.java @@ -57,7 +57,7 @@ public abstract class IntArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, int value); @Specialization - void executeWithNullCheck(StaticObject array, int index, int value, + void doWithNullCheck(StaticObject array, int index, int value, @Cached NullCheck nullCheck, @Cached IntArrayStore.WithoutNullCheck intArrayStore) { intArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeInterface.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeInterface.java index 10d22dbeac01..672a28615783 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeInterface.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeInterface.java @@ -69,7 +69,7 @@ public abstract class InvokeInterface extends EspressoNode { public abstract Object execute(Object[] args); @Specialization - Object executeWithNullCheck(Object[] args, + Object doWithNullCheck(Object[] args, @Cached NullCheck nullCheck, @Cached("create(resolutionSeed)") WithoutNullCheck invokeInterface) { StaticObject receiver = (StaticObject) args[0]; @@ -190,7 +190,7 @@ public abstract static class Dynamic extends EspressoNode { public abstract Object execute(Method resolutionSeed, Object[] args); @Specialization - Object executeWithNullCheck(Method resolutionSeed, Object[] args, + Object doWithNullCheck(Method resolutionSeed, Object[] args, @Cached NullCheck nullCheck, @Cached WithoutNullCheck invokeInterface) { StaticObject receiver = (StaticObject) args[0]; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeSpecial.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeSpecial.java index 1430d390188a..e304214779ee 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeSpecial.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeSpecial.java @@ -59,7 +59,7 @@ public abstract class InvokeSpecial extends EspressoNode { public abstract Object execute(Object[] args); @Specialization - Object executeWithNullCheck(Object[] args, + Object doWithNullCheck(Object[] args, @Cached NullCheck nullCheck, @Cached("create(method)") WithoutNullCheck invokeSpecial) { StaticObject receiver = (StaticObject) args[0]; @@ -124,7 +124,7 @@ public abstract static class Dynamic extends EspressoNode { public abstract Object execute(Method method, Object[] args); @Specialization - Object executeWithNullCheck(Method method, Object[] args, + Object doWithNullCheck(Method method, Object[] args, @Cached NullCheck nullCheck, @Cached WithoutNullCheck invokeSpecial) { StaticObject receiver = (StaticObject) args[0]; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeVirtual.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeVirtual.java index 2bf5689211fa..bccbdebf5557 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeVirtual.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/InvokeVirtual.java @@ -72,7 +72,7 @@ public abstract class InvokeVirtual extends EspressoNode { protected abstract Object execute(Object[] args); @Specialization - Object executeWithNullCheck(Object[] args, + Object doWithNullCheck(Object[] args, @Cached NullCheck nullCheck, @Cached("create(resolutionSeed)") WithoutNullCheck invokeVirtual) { StaticObject receiver = (StaticObject) args[0]; @@ -224,7 +224,7 @@ public abstract static class Dynamic extends EspressoNode { public abstract Object execute(Method resolutionSeed, Object[] args); @Specialization - Object executeWithNullCheck(Method resolutionSeed, Object[] args, + Object doWithNullCheck(Method resolutionSeed, Object[] args, @Cached NullCheck nullCheck, @Cached WithoutNullCheck invokeVirtual) { StaticObject receiver = (StaticObject) args[0]; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayLoad.java index 1268810a2ec9..14296019b52a 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayLoad.java @@ -57,7 +57,7 @@ public abstract class LongArrayLoad extends EspressoNode { public abstract long execute(StaticObject receiver, int index); @Specialization - long executeWithNullCheck(StaticObject array, int index, + long doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck longArrayLoad) { return longArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayStore.java index 9cf99d34976f..e6889525760c 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/LongArrayStore.java @@ -58,7 +58,7 @@ public abstract class LongArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, long value); @Specialization - void executeWithNullCheck(StaticObject array, int index, long value, + void doWithNullCheck(StaticObject array, int index, long value, @Cached NullCheck nullCheck, @Cached WithoutNullCheck longArrayStore) { longArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/NullCheck.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/NullCheck.java index 662d956ea397..a07d882c9530 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/NullCheck.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/NullCheck.java @@ -37,7 +37,7 @@ public abstract class NullCheck extends EspressoNode { abstract StaticObject execute(StaticObject receiver); @Specialization - StaticObject execute(StaticObject receiver, @Cached BranchProfile exceptionProfile) { + StaticObject doNullCheck(StaticObject receiver, @Cached BranchProfile exceptionProfile) { if (StaticObject.isNull(receiver)) { exceptionProfile.enter(); throw getMeta().throwNullPointerException(); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayLoad.java index de0e0df3b896..0d9d3e59a3e8 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayLoad.java @@ -60,7 +60,7 @@ public abstract class ReferenceArrayLoad extends EspressoNode { public abstract StaticObject execute(StaticObject receiver, int index); @Specialization - StaticObject executeWithNullCheck(StaticObject array, int index, + StaticObject doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck objectArrayLoad) { return objectArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayStore.java index 1da40d4e6544..bd03869c67ea 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ReferenceArrayStore.java @@ -58,7 +58,7 @@ public abstract class ReferenceArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, StaticObject value); @Specialization - void executeWithNullCheck(StaticObject array, int index, StaticObject value, + void doWithNullCheck(StaticObject array, int index, StaticObject value, @Cached NullCheck nullCheck, @Cached WithoutNullCheck objectArrayStore) { objectArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayLoad.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayLoad.java index 4c2765122266..9b765c53d23a 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayLoad.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayLoad.java @@ -57,7 +57,7 @@ public abstract class ShortArrayLoad extends EspressoNode { public abstract short execute(StaticObject receiver, int index); @Specialization - short executeWithNullCheck(StaticObject array, int index, + short doWithNullCheck(StaticObject array, int index, @Cached NullCheck nullCheck, @Cached WithoutNullCheck shortArrayLoad) { return shortArrayLoad.execute(nullCheck.execute(array), index); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayStore.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayStore.java index 5f3dec7a298e..df977b1ece3a 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayStore.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/ShortArrayStore.java @@ -57,7 +57,7 @@ public abstract class ShortArrayStore extends EspressoNode { public abstract void execute(StaticObject receiver, int index, short value); @Specialization - void executeWithNullCheck(StaticObject array, int index, short value, + void doWithNullCheck(StaticObject array, int index, short value, @Cached NullCheck nullCheck, @Cached WithoutNullCheck shortArrayStore) { shortArrayStore.execute(nullCheck.execute(array), index, value); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/package-info.java index 58f566bb5c85..eb72f1006ac3 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/bytecodes/package-info.java @@ -34,11 +34,15 @@ * access checks, the caller is responsible for access checks and sanity checks required for * correct/legal execution. *

- * + * *

* Nodes in this package always offer un-cached versions e.g. * {@link com.oracle.truffle.espresso.nodes.bytecodes.InstanceOf.Dynamic} that can be used anywhere, * at the expense of performance. *

*/ +// TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) package com.oracle.truffle.espresso.nodes.bytecodes; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java new file mode 100644 index 000000000000..590c1b0b2c7f --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.nodes.helper; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java new file mode 100644 index 000000000000..413a854d6c98 --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.nodes.interop; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHInvokeBasicNode.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHInvokeBasicNode.java index aae764484974..99aaf432a3a5 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHInvokeBasicNode.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHInvokeBasicNode.java @@ -57,15 +57,15 @@ private void sanitizeSignature(Method payload) { @SuppressWarnings("unused") @Specialization(limit = "INLINE_CACHE_SIZE_LIMIT", guards = {"inliningEnabled()", "canInline(target, cachedTarget)"}) - Object executeCallDirect(Object[] args, Method target, + Object doCallDirect(Object[] args, Method target, @Cached("target") Method cachedTarget, @Cached("create(target.getCallTarget())") DirectCallNode directCallNode) { sanitizeSignature(cachedTarget); return directCallNode.call(args); } - @Specialization(replaces = "executeCallDirect") - Object executeCallIndirect(Object[] args, Method target, + @Specialization(replaces = "doCallDirect") + Object doCallIndirect(Object[] args, Method target, @Cached("create()") IndirectCallNode callNode) { sanitizeSignature(target); return callNode.call(target.getCallTarget(), args); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHLinkToNode.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHLinkToNode.java index f6732d13bf29..481da6822f6f 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHLinkToNode.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/MHLinkToNode.java @@ -50,7 +50,7 @@ *
  • Obtain the trailing MemberName from the arguments, and extract its payload. *
  • Perform method lookup if needed on the given receiver. *
  • Execute the payload on the given arguments, stripped from the given MemberName - * + * * Note that there is a small overhead, as the method invoked is usually the actual payload (in * opposition to the other MH nodes, who usually either calls the type checkers, or performs type * checks on erased primitives), whose signature is not sub-workd erased. Unfortunately, the @@ -101,15 +101,15 @@ public static boolean canInline(Method.MethodVersion target, Method.MethodVersio @SuppressWarnings("unused") @Specialization(limit = "INLINE_CACHE_SIZE_LIMIT", guards = {"inliningEnabled()", "canInline(target, cachedTarget)"}) - Object executeCallDirect(Object[] args, Method.MethodVersion target, + Object doCallDirect(Object[] args, Method.MethodVersion target, @Cached("target") Method.MethodVersion cachedTarget, @Cached("create(target.getCallTarget())") DirectCallNode directCallNode) { hits.inc(); return directCallNode.call(args); } - @Specialization(replaces = "executeCallDirect") - Object executeCallIndirect(Object[] args, Method.MethodVersion target, + @Specialization(replaces = "doCallDirect") + Object doCallIndirect(Object[] args, Method.MethodVersion target, @Cached("create()") IndirectCallNode callNode) { miss.inc(); return callNode.call(target.getCallTarget(), args); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java new file mode 100644 index 000000000000..de44b8319f6a --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.nodes.methodhandle; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java new file mode 100644 index 000000000000..80826d0fc69a --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java new file mode 100644 index 000000000000..94b62abd3dea --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.runtime.dispatch; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_java_lang_Thread.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_java_lang_Thread.java index 3ce9aa37fc34..8b0fffade5f6 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_java_lang_Thread.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_java_lang_Thread.java @@ -191,7 +191,7 @@ abstract static class GetState extends SubstitutionNode { @Specialization @JavaType(internalName = "Ljava/lang/Thread$State;") - StaticObject execute(@JavaType(Thread.class) StaticObject self, + StaticObject doDefault(@JavaType(Thread.class) StaticObject self, @Bind("getContext()") EspressoContext context, @Cached("create(context.getMeta().sun_misc_VM_toThreadState.getCallTarget())") DirectCallNode toThreadState) { return (StaticObject) toThreadState.call(context.getThreadAccess().getState(self)); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_ModuleLoaderMap.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_ModuleLoaderMap.java index d0c3861e6926..85d2d5692b4b 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_ModuleLoaderMap.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_ModuleLoaderMap.java @@ -50,7 +50,7 @@ abstract static class BootModules extends SubstitutionNode { @Specialization @JavaType(Set.class) - StaticObject executeImpl( + StaticObject doDefault( @Bind("getContext()") EspressoContext context, @Cached("create(context.getMeta().jdk_internal_module_ModuleLoaderMap_bootModules.getCallTargetNoSubstitution())") DirectCallNode original) { Meta meta = context.getMeta(); diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_SystemModuleFinders.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_SystemModuleFinders.java index 899d4dc6418c..aae3534a241d 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_SystemModuleFinders.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_jdk_internal_module_SystemModuleFinders.java @@ -48,7 +48,7 @@ abstract static class Of extends SubstitutionNode { @Specialization @JavaType(internalName = "Ljava/lang/module/ModuleFinder;") - StaticObject executeImpl( + StaticObject doDefault( @JavaType(internalName = "Ljdk/internal/module/SystemModules;") StaticObject systemModules, @Bind("getMeta()") Meta meta, @Cached("create(meta.jdk_internal_module_SystemModuleFinders_of.getCallTargetNoSubstitution())") DirectCallNode original) { @@ -70,7 +70,7 @@ abstract static class OfSystem extends SubstitutionNode { @Specialization @JavaType(internalName = "Ljava/lang/module/ModuleFinder;") - StaticObject executeImpl( + StaticObject doDefault( @Bind("getMeta()") Meta meta, @Cached("create(meta.jdk_internal_module_SystemModuleFinders_ofSystem.getCallTargetNoSubstitution())") DirectCallNode original) { // construct ModuleFinders that can locate our Espresso-specific platform modules diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java new file mode 100644 index 000000000000..8633c33df4fc --- /dev/null +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +//TODO GR-43114 fix warnings +@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) +package com.oracle.truffle.espresso.substitutions; + +import com.oracle.truffle.api.dsl.SuppressPackageWarnings; From cdad0650869338de62ab8cd43d8751c35f0c1554 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 11:22:34 +0100 Subject: [PATCH 251/312] Fix license headers in Espresso. --- .../espresso/ffi/nfi/package-info.java | 39 ++++++++----------- .../truffle/espresso/ffi/package-info.java | 39 ++++++++----------- .../truffle/espresso/impl/package-info.java | 39 ++++++++----------- .../espresso/nodes/helper/package-info.java | 39 ++++++++----------- .../espresso/nodes/interop/package-info.java | 39 ++++++++----------- .../nodes/methodhandle/package-info.java | 39 ++++++++----------- .../oracle/truffle/espresso/package-info.java | 39 ++++++++----------- .../runtime/dispatch/package-info.java | 39 ++++++++----------- .../espresso/substitutions/package-info.java | 39 ++++++++----------- 9 files changed, 144 insertions(+), 207 deletions(-) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java index 29152364e522..0161129ccffa 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/nfi/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java index f3d3a7b2b10d..c214b4c14e53 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ffi/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java index a42db9e12d21..8361d2062fac 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java index 590c1b0b2c7f..96a3f5144ea7 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/helper/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java index 413a854d6c98..1a570b251365 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java index de44b8319f6a..7175d1249ca8 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/methodhandle/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java index 80826d0fc69a..4182498f4b63 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java index 94b62abd3dea..98c84ce3889e 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/dispatch/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java index 8633c33df4fc..f89916aa0c29 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/package-info.java @@ -1,31 +1,24 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ //TODO GR-43114 fix warnings @SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) From c44bef73cc6718572f077f0aaa325e738540f982 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 19:14:53 +0100 Subject: [PATCH 252/312] Improve SpecializationInfo.toString(). --- .../oracle/truffle/api/dsl/Introspection.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java index c8dc0705a4e3..c318d6d6455b 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java @@ -248,7 +248,25 @@ public List getCachedData(int instanceIndex) { */ @Override public String toString() { - return "SpecializationInfo[name=" + methodName + ", active=" + isActive() + ", excluded" + isExcluded() + ", instances=" + getInstances() + "]"; + StringBuilder cacheInfo = new StringBuilder(); + for (int i = 0; i < getInstances(); i++) { + List cacheData = getCachedData(i); + cacheInfo.append(", cache[").append(i).append("] = {"); + String sep = ""; + for (Object object : cacheData) { + cacheInfo.append(sep); + if (object == null) { + cacheInfo.append("null"); + } else if (object instanceof Number) { + cacheInfo.append(object); + } else { + cacheInfo.append(object.getClass().getSimpleName() + "@" + Integer.toHexString(hashCode())); + } + sep = ", "; + } + cacheInfo.append("}"); + } + return "SpecializationInfo[name=" + methodName + ", active=" + isActive() + ", excluded=" + isExcluded() + ", instances=" + getInstances() + cacheInfo + "]"; } } From cc2c4617093413872179f8f737e0a113f749bba8 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 19:15:13 +0100 Subject: [PATCH 253/312] Register unsafe fields as unsafe accessed. --- .../svm/truffle/TruffleBaseFeature.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java index 39b6baed9fcc..5984ff149f7e 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java @@ -52,9 +52,11 @@ import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; import java.util.function.BooleanSupplier; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Stream; @@ -124,6 +126,7 @@ import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleRuntime; +import com.oracle.truffle.api.dsl.InlineSupport; import com.oracle.truffle.api.dsl.InlineSupport.InlinableField; import com.oracle.truffle.api.impl.DefaultTruffleRuntime; import com.oracle.truffle.api.instrumentation.TruffleInstrument; @@ -205,6 +208,9 @@ public boolean getAsBoolean() { private static final Method NODE_CLASS_getAccesssedFields = ReflectionUtil.lookupMethod(NodeClass.class, "getAccessedFields"); + private static final Field UNSAFE_FIELD_name = ReflectionUtil.lookupField(InlineSupport.InlinableField.class.getSuperclass(), "name"); + private static final Field UNSAFE_FIELD_declaringClass = ReflectionUtil.lookupField(InlineSupport.InlinableField.class.getSuperclass(), "declaringClass"); + private ClassLoader imageClassLoader; private AnalysisMetaAccess metaAccess; private GraalGraphObjectReplacer graalGraphObjectReplacer; @@ -219,6 +225,9 @@ public boolean getAsBoolean() { private Map languageHomesToCopy; + private Consumer markAsUnsafeAccessed; + private final ConcurrentMap processedInlinedFields = new ConcurrentHashMap<>(); + private static void initializeTruffleReflectively(ClassLoader imageClassLoader) { invokeStaticMethod("com.oracle.truffle.api.impl.Accessor", "getTVMCI", Collections.emptyList()); invokeStaticMethod("com.oracle.truffle.polyglot.LanguageCache", "initializeNativeImageState", @@ -253,6 +262,24 @@ static T invokeStaticMethod(String className, String methodName, Collection< } } + /** + * Register all fields accessed by a InlinedField for an instance field or a static field as + * unsafe accessed, which is necessary for correctness of the static analysis. + */ + private Object processInlinedField(Object obj) { + if (obj instanceof InlineSupport.InlinableField && processedInlinedFields.putIfAbsent(obj, true) == null) { + VMError.guarantee(markAsUnsafeAccessed != null, "New InlinedField found after static analysis"); + try { + String name = (String) UNSAFE_FIELD_name.get(obj); + Class declaringClass = (Class) UNSAFE_FIELD_declaringClass.get(obj); + markAsUnsafeAccessed.accept(declaringClass.getDeclaredField(name)); + } catch (ReflectiveOperationException ex) { + throw VMError.shouldNotReachHere(ex); + } + } + return obj; + } + @Override public void afterRegistration(AfterRegistrationAccess a) { imageClassLoader = a.getApplicationClassLoader(); @@ -354,6 +381,7 @@ public void duringSetup(DuringSetupAccess access) { if (!ImageSingletons.contains(TruffleFeature.class) && (Truffle.getRuntime() instanceof SubstrateTruffleRuntime)) { VMError.shouldNotReachHere("TruffleFeature is required for SubstrateTruffleRuntime."); } + access.registerObjectReplacer(this::processInlinedField); HomeFinder hf = HomeFinder.getInstance(); if (Options.CopyLanguageResources.getValue()) { @@ -411,6 +439,7 @@ public void duringSetup(DuringSetupAccess access) { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { StaticObjectSupport.beforeAnalysis(access); + markAsUnsafeAccessed = access::registerAsUnsafeAccessed; BeforeAnalysisAccessImpl config = (BeforeAnalysisAccessImpl) access; @@ -434,6 +463,12 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { new ArrayBasedShapeGeneratorOffsetTransformer("object")); access.registerFieldValueTransformer(ReflectionUtil.lookupField(ArrayBasedShapeGeneratorOffsetTransformer.SHAPE_GENERATOR, "shapeOffset"), new ArrayBasedShapeGeneratorOffsetTransformer("shape")); + + } + + @Override + public void afterAnalysis(AfterAnalysisAccess access) { + markAsUnsafeAccessed = null; } public static void preInitializeEngine() { From 8f223db10555a7ed121d1b575a1dbc65cd90bc8d Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 19:43:38 +0100 Subject: [PATCH 254/312] Improve generated code by using Objects.requireNonNull for reference types. --- .../oracle/truffle/api/dsl/test/NeverDefaultTest.java | 4 ++-- .../dsl/processor/generator/FlatNodeGenFactory.java | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index a33ba3cf684c..8828a40d8254 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -674,7 +674,7 @@ public void testSingleInstancePrimitiveCacheNode() throws InterruptedException { }); SingleInstancePrimitiveCacheNode node = adoptNode(SingleInstancePrimitiveCacheNodeGen.create()).get(); - assertFails(() -> node.execute(null, 0), IllegalStateException.class, (e) -> { + assertFails(() -> node.execute(null, 0), NullPointerException.class, (e) -> { assertEquals("Specialization 's0(int, int)' cache 'cachedValue' returned a '0' default value. The cache initializer must never return a default value for this cache. " + "Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns '0'.", e.getMessage()); @@ -726,7 +726,7 @@ public void testSingleInstanceNodeCacheNode() throws InterruptedException { SingleInstanceNodeCacheNode returnNull = adoptNode(SingleInstanceNodeCacheNodeGen.create()).get(); GuardCacheNode.returnNull = true; - assertFails(() -> returnNull.execute(null, 1), IllegalStateException.class, (e) -> { + assertFails(() -> returnNull.execute(null, 1), NullPointerException.class, (e) -> { assertEquals("Specialization 's0(int, GuardCacheNode)' cache 'cachedNode' returned a 'null' default value. " + "The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns 'null'.", e.getMessage()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 45355f68e254..83fc153f7453 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6312,8 +6312,6 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.declaration(cache.getParameter().getType(), localName, value); value = CodeTreeBuilder.singleString(localName); } - builder.startIf().tree(value).string(" == ").string(defaultValue).end().startBlock(); - String message = String.format( "Specialization '%s' cache '%s' returned a '%s' default value. The cache initializer must never return a default value for this cache. " + "Use @%s(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns '%s'.", @@ -6323,8 +6321,13 @@ private Collection persistCache(FrameState frameState, SpecializationD getSimpleName(types.Cached), defaultValue); - builder.startThrow().startNew(context.getType(IllegalStateException.class)).doubleQuote(message).end().end(); - builder.end(); + if (ElementUtils.isPrimitive(cache.getParameter().getType())) { + builder.startIf().tree(value).string(" == ").string(defaultValue).end().startBlock(); + builder.startThrow().startNew(context.getType(NullPointerException.class)).doubleQuote(message).end().end(); + builder.end(); + } else { + builder.startStatement().startStaticCall(context.getType(Objects.class), "requireNonNull").tree(value).doubleQuote(message).end().end(); + } builder.end(); builder.startStatement().tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))).end(); From 1d88753ab1ec18575a35c79c4a8e7eb32cf3e096 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 19:56:12 +0100 Subject: [PATCH 255/312] Fix Espresso warnings. --- .../substitutions/Target_sun_misc_Unsafe.java | 206 +++++++++--------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_sun_misc_Unsafe.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_sun_misc_Unsafe.java index 69e2b5b89750..e2dcb68501c8 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_sun_misc_Unsafe.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/substitutions/Target_sun_misc_Unsafe.java @@ -787,16 +787,16 @@ abstract static class GetFieldFromIndexNode extends EspressoNode { abstract Field execute(StaticObject holder, long slot); @Specialization(guards = {"slot == cachedSlot", "holder.isStaticStorage() == cachedIsStaticStorage", "holder.getKlass() == cachedKlass"}, limit = "LIMIT") - protected Field executeCached(@SuppressWarnings("unused") StaticObject holder, @SuppressWarnings("unused") long slot, + protected Field doCached(@SuppressWarnings("unused") StaticObject holder, @SuppressWarnings("unused") long slot, @SuppressWarnings("unused") @Cached("slot") long cachedSlot, @SuppressWarnings("unused") @Cached("holder.getKlass()") Klass cachedKlass, @SuppressWarnings("unused") @Cached("holder.isStaticStorage()") boolean cachedIsStaticStorage, - @Cached("executeGeneric(holder, slot)") Field cachedField) { + @Cached("doGeneric(holder, slot)") Field cachedField) { return cachedField; } - @Specialization(replaces = "executeCached") - protected Field executeGeneric(StaticObject holder, long slot) { + @Specialization(replaces = "doCached") + protected Field doGeneric(StaticObject holder, long slot) { return resolveUnsafeAccessField(holder, slot, getMeta()); } @@ -921,12 +921,12 @@ public abstract static class PutByteWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value) { UnsafeAccess.getIfAllowed(getMeta()).putByte(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -943,13 +943,13 @@ abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Objec @JavaType(Object.class) StaticObject value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value) { UnsafeAccess.getIfAllowed(getMeta()).putObject(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -965,12 +965,12 @@ public abstract static class PutBooleanWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value) { UnsafeAccess.getIfAllowed(getMeta()).putBoolean(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -986,12 +986,12 @@ public abstract static class PutCharWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value) { UnsafeAccess.getIfAllowed(getMeta()).putChar(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1007,12 +1007,12 @@ public abstract static class PutShortWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value) { UnsafeAccess.getIfAllowed(getMeta()).putShort(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1028,12 +1028,12 @@ public abstract static class PutIntWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { UnsafeAccess.getIfAllowed(getMeta()).putInt(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1049,12 +1049,12 @@ public abstract static class PutFloatWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value) { UnsafeAccess.getIfAllowed(getMeta()).putFloat(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1070,12 +1070,12 @@ public abstract static class PutDoubleWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value) { UnsafeAccess.getIfAllowed(getMeta()).putDouble(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1091,12 +1091,12 @@ public abstract static class PutLongWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { UnsafeAccess.getIfAllowed(getMeta()).putLong(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1118,12 +1118,12 @@ public abstract static class PutOrderedInt extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { UnsafeAccess.getIfAllowed(getMeta()).putOrderedInt(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1139,12 +1139,12 @@ public abstract static class PutOrderedLong extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { UnsafeAccess.getIfAllowed(getMeta()).putOrderedLong(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1161,13 +1161,13 @@ abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Objec @JavaType(Object.class) StaticObject value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value) { UnsafeAccess.getIfAllowed(getMeta()).putOrderedObject(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -1194,12 +1194,12 @@ public abstract static class GetByteWithBase extends UnsafeAccessNode { abstract byte execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected byte executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected byte doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getByte(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected byte executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected byte doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1218,13 +1218,13 @@ public abstract static class GetObjectWithBase extends UnsafeAccessNode { abstract @JavaType(Object.class) StaticObject execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, + protected @JavaType(Object.class) StaticObject doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return (StaticObject) UnsafeAccess.getIfAllowed(getMeta()).getObject(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected @JavaType(Object.class) StaticObject doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1243,12 +1243,12 @@ public abstract static class GetBooleanWithBase extends UnsafeAccessNode { abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected boolean executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected boolean doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getBoolean(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected boolean executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1267,12 +1267,12 @@ public abstract static class GetCharWithBase extends UnsafeAccessNode { abstract char execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected char executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected char doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getChar(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected char executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected char doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1291,12 +1291,12 @@ public abstract static class GetShortWithBase extends UnsafeAccessNode { abstract short execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected short executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected short doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getShort(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected short executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected short doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1315,12 +1315,12 @@ public abstract static class GetIntWithBase extends UnsafeAccessNode { abstract int execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected int executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected int doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getInt(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected int executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected int doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1339,12 +1339,12 @@ public abstract static class GetFloatWithBase extends UnsafeAccessNode { abstract float execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected float executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected float doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getFloat(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected float executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected float doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1363,12 +1363,12 @@ public abstract static class GetDoubleWithBase extends UnsafeAccessNode { abstract double execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected double executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected double doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getDouble(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected double executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected double doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1387,12 +1387,12 @@ public abstract static class GetLongWithBase extends UnsafeAccessNode { abstract long execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected long executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected long doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getLong(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected long executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected long doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1415,12 +1415,12 @@ public abstract static class GetByteVolatileWithBase extends UnsafeAccessNode { abstract byte execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected byte executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected byte doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getByteVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected byte executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected byte doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1439,13 +1439,13 @@ public abstract static class GetObjectVolatileWithBase extends UnsafeAccessNode abstract @JavaType(Object.class) StaticObject execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, + protected @JavaType(Object.class) StaticObject doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return (StaticObject) UnsafeAccess.getIfAllowed(getMeta()).getObjectVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected @JavaType(Object.class) StaticObject doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1464,12 +1464,12 @@ public abstract static class GetBooleanVolatileWithBase extends UnsafeAccessNode abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected boolean executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected boolean doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getBooleanVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected boolean executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1488,12 +1488,12 @@ public abstract static class GetCharVolatileWithBase extends UnsafeAccessNode { abstract char execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected char executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected char doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getCharVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected char executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected char doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1512,12 +1512,12 @@ public abstract static class GetShortVolatileWithBase extends UnsafeAccessNode { abstract short execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected short executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected short doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getShortVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected short executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected short doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1536,12 +1536,12 @@ public abstract static class GetIntVolatileWithBase extends UnsafeAccessNode { abstract int execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected int executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected int doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getIntVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected int executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected int doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1560,12 +1560,12 @@ public abstract static class GetFloatVolatileWithBase extends UnsafeAccessNode { abstract float execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected float executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected float doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getFloatVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected float executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected float doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1584,12 +1584,12 @@ public abstract static class GetDoubleVolatileWithBase extends UnsafeAccessNode abstract double execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected double executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected double doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getDoubleVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected double executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected double doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1608,12 +1608,12 @@ public abstract static class GetLongVolatileWithBase extends UnsafeAccessNode { abstract long execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset); @Specialization(guards = "isNullOrArray(holder)") - protected long executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { + protected long doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset) { return UnsafeAccess.getIfAllowed(getMeta()).getLongVolatile(unwrapNullOrArray(getLanguage(), holder), offset); } @Specialization(guards = "!isNullOrArray(holder)") - protected long executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected long doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1718,12 +1718,12 @@ public abstract static class PutByteVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value) { UnsafeAccess.getIfAllowed(getMeta()).putByteVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1740,13 +1740,13 @@ abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Objec @JavaType(Object.class) StaticObject value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value) { UnsafeAccess.getIfAllowed(getMeta()).putObjectVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1762,12 +1762,12 @@ public abstract static class PutBooleanVolatileWithBase extends UnsafeAccessNode abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value) { UnsafeAccess.getIfAllowed(getMeta()).putBooleanVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1783,12 +1783,12 @@ public abstract static class PutCharVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value) { UnsafeAccess.getIfAllowed(getMeta()).putCharVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1804,12 +1804,12 @@ public abstract static class PutShortVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value) { UnsafeAccess.getIfAllowed(getMeta()).putShortVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1825,12 +1825,12 @@ public abstract static class PutIntVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value) { UnsafeAccess.getIfAllowed(getMeta()).putIntVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1846,12 +1846,12 @@ public abstract static class PutFloatVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value) { UnsafeAccess.getIfAllowed(getMeta()).putFloatVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1867,12 +1867,12 @@ public abstract static class PutDoubleVolatileWithBase extends UnsafeAccessNode abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value) { UnsafeAccess.getIfAllowed(getMeta()).putDoubleVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1888,12 +1888,12 @@ public abstract static class PutLongVolatileWithBase extends UnsafeAccessNode { abstract void execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value); @Specialization(guards = "isNullOrArray(holder)") - protected void executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { + protected void doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value) { UnsafeAccess.getIfAllowed(getMeta()).putLongVolatile(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected void executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, + protected void doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -1914,13 +1914,13 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after); @Specialization(guards = "isNullOrArray(holder)") - protected boolean executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after) { return UnsafeAccess.getIfAllowed(getMeta()).compareAndSwapObject(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected boolean executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -1938,13 +1938,13 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob int before, int after); @Specialization(guards = "isNullOrArray(holder)") - protected boolean executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int before, int after) { return UnsafeAccess.getIfAllowed(getMeta()).compareAndSwapInt(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected boolean executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int before, int after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -1970,13 +1970,13 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob long before, long after); @Specialization(guards = "isNullOrArray(holder)") - protected boolean executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long before, long after) { return UnsafeAccess.getIfAllowed(getMeta()).compareAndSwapLong(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected boolean executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long before, long after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2017,7 +2017,7 @@ public abstract static class CompareAndExchangeObject extends UnsafeAccessNode { @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after); @Specialization(guards = "isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, + protected @JavaType(Object.class) StaticObject doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after) { UnsafeAccess.checkAllowed(getMeta()); @@ -2025,7 +2025,7 @@ public abstract static class CompareAndExchangeObject extends UnsafeAccessNode { } @Specialization(guards = "!isNullOrArray(holder)") - protected @JavaType(Object.class) StaticObject executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected @JavaType(Object.class) StaticObject doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2047,14 +2047,14 @@ abstract int execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Object int before, int after); @Specialization(guards = "isNullOrArray(holder)") - protected int executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected int doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int before, int after) { UnsafeAccess.checkAllowed(getMeta()); return UnsafeSupport.compareAndExchangeInt(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected int executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected int doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int before, int after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2079,14 +2079,14 @@ abstract byte execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Objec byte before, byte after); @Specialization(guards = "isNullOrArray(holder)") - protected byte executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected byte doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte before, byte after) { UnsafeAccess.checkAllowed(getMeta()); return UnsafeSupport.compareAndExchangeByte(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected byte executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected byte doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte before, byte after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2111,14 +2111,14 @@ abstract short execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Obje short before, short after); @Specialization(guards = "isNullOrArray(holder)") - protected short executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected short doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short before, short after) { UnsafeAccess.checkAllowed(getMeta()); return UnsafeSupport.compareAndExchangeShort(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected short executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected short doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short before, short after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2143,14 +2143,14 @@ abstract long execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Objec long before, long after); @Specialization(guards = "isNullOrArray(holder)") - protected long executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected long doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long before, long after) { UnsafeAccess.checkAllowed(getMeta()); return UnsafeSupport.compareAndExchangeLong(unwrapNullOrArray(getLanguage(), holder), offset, before, after); } @Specialization(guards = "!isNullOrArray(holder)") - protected long executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected long doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long before, long after, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); @@ -2180,14 +2180,14 @@ public abstract static class GetAndSetObject extends UnsafeAccessNode { @JavaType(Object.class) StaticObject value); @Specialization(guards = "isNullOrArray(holder)") - protected @JavaType(Unsafe.class) StaticObject executeNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, + protected @JavaType(Unsafe.class) StaticObject doNullOrArray(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value) { return (StaticObject) UnsafeAccess.getIfAllowed(getMeta()).getAndSetObject(unwrapNullOrArray(getLanguage(), holder), offset, value); } @Specialization(guards = "!isNullOrArray(holder)") - protected @JavaType(Unsafe.class) StaticObject executeGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected @JavaType(Unsafe.class) StaticObject doGeneric(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value, @Cached GetFieldFromIndexNode getField) { Field f = getField.execute(holder, offset); if (f == null) { @@ -2204,7 +2204,7 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after); @Specialization - protected boolean executeCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject before, @JavaType(Object.class) StaticObject after, @Cached CompareAndSwapObject cas) { return cas.execute(self, holder, offset, before, after); @@ -2218,7 +2218,7 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob int before, int after); @Specialization - protected boolean executeCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int before, int after, @Cached CompareAndSwapInt cas) { return cas.execute(self, holder, offset, before, after); @@ -2232,7 +2232,7 @@ abstract boolean execute(@JavaType(Unsafe.class) StaticObject self, @JavaType(Ob long before, long after); @Specialization - protected boolean executeCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, + protected boolean doCached(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long before, long after, @Cached CompareAndSwapLong cas) { return cas.execute(self, holder, offset, before, after); From c27878160612ee471f3bdf9710cbfa8142cb02f2 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Tue, 3 Jan 2023 20:40:59 +0100 Subject: [PATCH 256/312] Simplify code layout for optional casts. --- .../snapshot.sigtest | 2 + .../oracle/truffle/api/dsl/DSLSupport.java | 29 +++++++++++++ .../generator/FlatNodeGenFactory.java | 42 +++++++------------ 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest index d1c5fcb75373..94a4bca385dc 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest @@ -48,6 +48,8 @@ intf java.lang.annotation.Annotation meth public abstract java.lang.String[] value() CLSS public abstract com.oracle.truffle.api.dsl.DSLSupport +meth public static <%0 extends com.oracle.truffle.api.nodes.NodeInterface> {%%0} maybeInsert(com.oracle.truffle.api.nodes.Node,{%%0}) +meth public static <%0 extends com.oracle.truffle.api.nodes.NodeInterface> {%%0}[] maybeInsert(com.oracle.truffle.api.nodes.Node,{%%0}[]) meth public static <%0 extends java.lang.Enum> {%%0}[] lookupEnumConstants(java.lang.Class<{%%0}>) supr java.lang.Object hfds ENUM_CONSTANTS diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java index 7016d0bbe14f..d17677edc22c 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/DSLSupport.java @@ -40,6 +40,9 @@ */ package com.oracle.truffle.api.dsl; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeInterface; + /** * APIs to support share code in generated code. APIs in this class are aggressively deprecated and * removed in this class. @@ -73,4 +76,30 @@ public static > T[] lookupEnumConstants(Class c) { return (T[]) ENUM_CONSTANTS.get(c); } + /** + * Inserts a node if a {@link NodeInterface} dynamically implements {@link Node}. Intended for + * generated code only. + * + * @since 23.0 + */ + public static T maybeInsert(Node node, T o) { + if (o instanceof Node) { + node.insert((Node) o); + } + return o; + } + + /** + * Inserts a node array if a {@link NodeInterface}[] dynamically implements {@link Node}[]. + * Intended for generated code only. + * + * @since 23.0 + */ + public static T[] maybeInsert(Node node, T[] o) { + if (o instanceof Node[]) { + node.insert((Node[]) o); + } + return o; + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 83fc153f7453..f0b428d6effc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -6242,7 +6242,7 @@ private Collection persistCache(FrameState frameState, SpecializationD } CodeTreeBuilder builder = new CodeTreeBuilder(null); - value = createInsertNode(builder, frameState, specialization, cache, value); + value = createInsertNode(frameState, specialization, cache, value); boolean sharedCheck = sharedCaches.containsKey(cache); boolean defaultCheck = !cache.isWeakReference() && cache.isNeverDefault() && !cache.isNeverDefaultGuaranteed(); @@ -6263,7 +6263,7 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.startStatement(); builder.string(cacheClass.getName(), " = "); - builder.tree(createInsertNode(builder, frameState, specialization, cache, builder.create().startNew(createCacheClassType(cache)).end().build())); + builder.tree(createInsertNode(frameState, specialization, cache, builder.create().startNew(createCacheClassType(cache)).end().build())); builder.end(); builder.startStatement(); @@ -6345,17 +6345,19 @@ private Collection persistCache(FrameState frameState, SpecializationD } - private CodeTree createInsertNode(CodeTreeBuilder builder, FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { + private CodeTree createInsertNode(FrameState frameState, SpecializationData specialization, CacheExpression cache, CodeTree value) { if (cache.isAlwaysInitialized()) { return value; } else if (cache.isBind()) { return value; + } else if (!cache.isAdopt()) { + return value; } Parameter parameter = cache.getParameter(); + TypeMirror type = parameter.getType(); TypeMirror nodeType = types.Node; TypeMirror nodeArrayType = new ArrayCodeTypeMirror(types.Node); - TypeMirror type = parameter.getType(); boolean isNode = isAssignable(parameter.getType(), nodeType); boolean isNodeInterface = isNode || isAssignable(type, types.NodeInterface); boolean isNodeArray = isAssignable(type, nodeArrayType); @@ -6363,7 +6365,6 @@ private CodeTree createInsertNode(CodeTreeBuilder builder, FrameState frameState if (isNodeInterface || isNodeInterfaceArray) { CodeTree insertTarget; - if (frameState.isSpecializationClassInitialized(specialization) && specializationClassIsNode(specialization)) { insertTarget = singleString(createSpecializationLocalName(specialization)); } else { @@ -6384,29 +6385,17 @@ private CodeTree createInsertNode(CodeTreeBuilder builder, FrameState frameState castType = nodeArrayType; } } + + CodeTreeBuilder noCast = new CodeTreeBuilder(null); if (castType == null) { - CodeTreeBuilder noCast = new CodeTreeBuilder(null); - if (cache.isAdopt()) { - noCast.startCall(insertTarget, "insert"); - } - noCast.tree(value); - if (cache.isAdopt()) { - noCast.end(); - } - return noCast.build(); + noCast.startCall(insertTarget, "insert"); } else { - String fieldName = createFieldName(specialization, cache) + "__"; - builder.declaration(cache.getDefaultExpression().getResolvedType(), fieldName, value); - if (cache.isAdopt()) { - builder.startIf().string(fieldName).instanceOf(castType).end().startBlock(); - builder.startStatement(); - builder.startCall(insertTarget, "insert"); - builder.startGroup().cast(castType).string(fieldName).end(); - builder.end().end(); - } - builder.end(); - return CodeTreeBuilder.singleString(fieldName); + noCast.startStaticCall(types.DSLSupport, "maybeInsert"); + noCast.tree(insertTarget); } + noCast.tree(value); + noCast.end(); + return noCast.build(); } return value; } @@ -6446,7 +6435,7 @@ private Collection storeCache(FrameState frameState, NodeExecutionMode builder.tree(initializeSpecializationClass(frameState, specialization, false)); } - CodeTree useValue = createInsertNode(builder, frameState, specialization, cache, value); + CodeTree useValue = createInsertNode(frameState, specialization, cache, value); if (sharedCaches.containsKey(cache)) { builder.declaration(type, refName, (CodeTree) null); @@ -6474,7 +6463,6 @@ private Collection storeCache(FrameState frameState, NodeExecutionMode builder.end(); checkSharedCacheNull(builder, refName, specialization, cache); } - builder.end(); builder.end(); From fa5459e46189e16f65cad7291160c41bc8c0fff9 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 12:51:44 +0100 Subject: [PATCH 257/312] Fix missing guard in TruffleString.parseLong. --- .../com/oracle/truffle/api/strings/TStringInternalNodes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java index 03820c8e090e..8d7d7a04a0a3 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringInternalNodes.java @@ -1395,7 +1395,7 @@ abstract static class ParseLongNode extends AbstractInternalNode { abstract long execute(Node node, AbstractTruffleString a, Object arrayA, int codeRangeA, Encoding encoding, int radix) throws TruffleString.NumberFormatException; @SuppressWarnings("unused") - @Specialization(guards = "compaction == cachedCompaction", limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) + @Specialization(guards = {"is7Bit(codeRangeA)", "compaction == cachedCompaction"}, limit = Stride.STRIDE_CACHE_LIMIT, unroll = Stride.STRIDE_UNROLL) static long do7Bit(Node node, AbstractTruffleString a, Object arrayA, @SuppressWarnings("unused") int codeRangeA, @SuppressWarnings("unused") Encoding encoding, int radix, @Bind("fromStride(a.stride())") CompactionLevel compaction, @Cached("compaction") CompactionLevel cachedCompaction, From b8d72608bd1b1d9ec53ef06180463ee33c5eab4f Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 12:54:29 +0100 Subject: [PATCH 258/312] Slightly bump Truffle required runtime compiled methods due to TruffleString changes. --- truffle/mx.truffle/macro-truffle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/mx.truffle/macro-truffle.properties b/truffle/mx.truffle/macro-truffle.properties index 4c864fae72bc..11e205d3dc17 100644 --- a/truffle/mx.truffle/macro-truffle.properties +++ b/truffle/mx.truffle/macro-truffle.properties @@ -1,7 +1,7 @@ # This file contains support for building truffle images BuilderOnClasspath = true Args = -H:Features=com.oracle.svm.truffle.TruffleFeature,com.oracle.svm.truffle.TruffleBaseFeature,org.graalvm.home.HomeFinderFeature \ - -H:MaxRuntimeCompileMethods=2225 \ + -H:MaxRuntimeCompileMethods=2500 \ --initialize-at-build-time=com.oracle.truffle \ --initialize-at-build-time=org.graalvm.shadowed.org.jcodings \ --initialize-at-build-time=com.oracle.truffle.tools.utils.json \ From 7f66e4a58ca100eed40eacdc1743b9dd10d122d7 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 14:52:31 +0100 Subject: [PATCH 259/312] Fix state active bit might not be set in introspection data. --- .../truffle/dsl/processor/generator/FlatNodeGenFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index f0b428d6effc..621970252b22 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1825,7 +1825,7 @@ private void generateIntrospectionInfo(CodeTypeElement clazz, boolean inlined) { } BlockState excludeBlocks = BlockState.NONE; if (!excludeTripples.isEmpty()) { - excludeBlocks = IfTriple.materialize(builder, excludeTripples, false); + excludeBlocks = IfTriple.materialize(builder, IfTriple.optimize(excludeTripples), false); builder.startStatement().string("s[1] = (byte)0b10 /* excluded */").end(); builder.end(excludeBlocks.blockCount); builder.startElseBlock(); From 6b2915da84402ccae5587989afd5ca711e78f7f2 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 14:52:48 +0100 Subject: [PATCH 260/312] Better error handling if introspection data is invalid. --- .../oracle/truffle/api/dsl/Introspection.java | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java index c318d6d6455b..e5d71bf3b1a9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Introspection.java @@ -44,6 +44,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; import com.oracle.truffle.api.dsl.Introspection.SpecializationInfo; import com.oracle.truffle.api.nodes.Node; @@ -106,7 +107,11 @@ public static boolean isIntrospectable(Node node) { * @since 0.22 */ public static SpecializationInfo getSpecialization(Node node, String methodName) { - return getIntrospectionData(node).getSpecialization(methodName); + try { + return getIntrospectionData(node).getSpecialization(methodName); + } catch (IllegalStateException e) { + throw new IllegalStateException("Failed to provide introspection data for node class " + node.getClass() + " and method " + methodName + ".", e); + } } /** @@ -121,7 +126,13 @@ public static SpecializationInfo getSpecialization(Node node, String methodName) * @since 23.0 */ public static SpecializationInfo getSpecialization(Node inlineParent, Node node, String methodName) { - return getIntrospectionData(inlineParent, node).getSpecialization(methodName); + try { + return getIntrospectionData(inlineParent, node).getSpecialization(methodName); + } catch (IllegalStateException e) { + throw new IllegalStateException( + "Failed to provide introspection data for node class " + node.getClass() + " and inlinig parent " + inlineParent.getClass().getName() + " and method " + methodName + ".", + e); + } } /** @@ -140,7 +151,11 @@ public static SpecializationInfo getSpecialization(Node inlineParent, Node node, * @since 0.22 */ public static List getSpecializations(Node node) { - return getIntrospectionData(node).getSpecializations(); + try { + return getIntrospectionData(node).getSpecializations(); + } catch (IllegalStateException e) { + throw new IllegalStateException("Failed to provide introspection data for node class " + node.getClass() + ".", e); + } } /** @@ -153,10 +168,16 @@ public static List getSpecializations(Node node) { * @since 23.0 */ public static List getSpecializations(Node inlineParent, Node node) { - return getIntrospectionData(inlineParent, node).getSpecializations(); + try { + return getIntrospectionData(inlineParent, node).getSpecializations(); + } catch (IllegalStateException e) { + throw new IllegalStateException( + "Failed to provide introspection data for node class " + node.getClass() + " and inlinig parent " + inlineParent.getClass().getName() + ".", e); + } } private static Introspection getIntrospectionData(Node node) { + Objects.requireNonNull(node); if (!(node instanceof Provider)) { throw new IllegalArgumentException(String.format("Provided node is not introspectable. Annotate with @%s to make a node introspectable.", Introspectable.class.getSimpleName())); } @@ -164,6 +185,8 @@ private static Introspection getIntrospectionData(Node node) { } private static Introspection getIntrospectionData(Node inlineParent, Node node) { + Objects.requireNonNull(inlineParent); + Objects.requireNonNull(node); if (!(node instanceof Provider)) { throw new IllegalArgumentException(String.format("Provided node is not introspectable. Annotate with @%s to make a node introspectable.", Introspectable.class.getSimpleName())); } @@ -351,13 +374,17 @@ private void checkVersion() { private static Object[] getIntrospectionData(Object specializationData) { if (!(specializationData instanceof Object[])) { - throw new IllegalStateException("Invalid introspection data."); + throw new IllegalStateException("Invalid introspection data: expected object array"); } Object[] fieldData = (Object[]) specializationData; - if (fieldData.length < 3 || !(fieldData[0] instanceof String) // - || !(fieldData[1] instanceof Byte) // - || (fieldData[2] != null && !(fieldData[2] instanceof List))) { - throw new IllegalStateException("Invalid introspection data."); + if (fieldData.length < 3) { + throw new IllegalStateException("Invalid introspection data: invalid array length"); + } else if (!(fieldData[0] instanceof String)) { + throw new IllegalStateException("Invalid introspection data: expected string at index 0"); + } else if (!(fieldData[1] instanceof Byte)) { + throw new IllegalStateException("Invalid introspection data: expected byte at index 1"); + } else if ((fieldData[2] != null && !(fieldData[2] instanceof List))) { + throw new IllegalStateException("Invalid introspection data: expected list or null at index 2"); } return fieldData; } From 818d949eec2863abb6f6e0f242fb2cf5e2c6de7d Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 18:00:14 +0100 Subject: [PATCH 261/312] Move unsafe canoncialization into SimplifyingGraphDecoder. --- .../nodes/SimplifyingGraphDecoder.java | 14 ++- .../compiler/replacements/PEGraphDecoder.java | 11 --- .../StringNodeInliningCompilationTest.java | 85 +++++++++++++++++++ 3 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/StringNodeInliningCompilationTest.java diff --git a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java index d1490d6f59f1..6723faf5aaf2 100644 --- a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java +++ b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java @@ -44,6 +44,7 @@ import org.graalvm.compiler.nodes.extended.AnchoringNode; import org.graalvm.compiler.nodes.extended.GuardingNode; import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; +import org.graalvm.compiler.nodes.extended.UnsafeAccessNode; import org.graalvm.compiler.nodes.java.ArrayLengthNode; import org.graalvm.compiler.nodes.java.LoadFieldNode; import org.graalvm.compiler.nodes.java.LoadIndexedNode; @@ -202,9 +203,18 @@ protected void handleFixedNode(MethodScope methodScope, LoopScope loopScope, int * canonicalized (and therefore be a non-fixed node). * * @param methodScope The current method. - * @param node The node to be canonicalized. + * @param originalNode The node to be canonicalized. */ - protected Node canonicalizeFixedNode(MethodScope methodScope, Node node) { + protected Node canonicalizeFixedNode(MethodScope methodScope, Node originalNode) { + Node node = originalNode; + if (originalNode instanceof UnsafeAccessNode) { + /* + * Ensure that raw stores and loads are eventually transformed to fields to make node + * plugins trigger for them reliably during PE. + */ + node = ((UnsafeAccessNode) node).canonical(canonicalizerTool); + } + /* * Duplicate cases for frequent classes (LoadFieldNode, LoadIndexedNode and ArrayLengthNode) * to improve performance (Haeubl, 2017). diff --git a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java index 6cfb264f1998..48ace90ab1ae 100644 --- a/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java +++ b/compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java @@ -98,7 +98,6 @@ import org.graalvm.compiler.nodes.extended.BytecodeExceptionNode; import org.graalvm.compiler.nodes.extended.GuardingNode; import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; -import org.graalvm.compiler.nodes.extended.UnsafeAccessNode; import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin; import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin; @@ -1473,16 +1472,6 @@ protected Node canonicalizeFixedNode(MethodScope s, Node originalNode) { Node node = originalNode; Node replacedNode = node; if (nodePlugins != null && nodePlugins.length > 0) { - - if (originalNode instanceof UnsafeAccessNode) { - /* - * Ensure that raw stores and loads are eventually transformed to fields to make - * node plugins trigger for them reliably during PE. - */ - node = ((UnsafeAccessNode) node).canonical(canonicalizerTool); - replacedNode = node; - } - if (node instanceof LoadFieldNode) { LoadFieldNode loadFieldNode = (LoadFieldNode) node; PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadFieldNode); diff --git a/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/StringNodeInliningCompilationTest.java b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/StringNodeInliningCompilationTest.java new file mode 100644 index 000000000000..c749b81819bd --- /dev/null +++ b/compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/StringNodeInliningCompilationTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.graalvm.compiler.truffle.test; + +import static org.junit.Assume.assumeFalse; + +import org.graalvm.compiler.truffle.runtime.OptimizedCallTarget; +import org.graalvm.polyglot.Context; +import org.junit.Test; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleString.Encoding; +import com.oracle.truffle.api.test.CompileImmediatelyCheck; + +/** + * Basic smoke test to ensure TruffleString inlined nodes compile cleanly. + */ +public class StringNodeInliningCompilationTest { + + static class StringTestRootNode extends RootNode { + + protected StringTestRootNode() { + super(null); + } + + @Child TruffleString.ByteIndexOfStringNode node = TruffleString.ByteIndexOfStringNode.create(); + + TruffleString v0 = TruffleString.fromJavaStringUncached("testtest", Encoding.UTF_16); + TruffleString v1 = TruffleString.fromJavaStringUncached("test", Encoding.UTF_16); + int offset = 1; + + @Override + public Object execute(VirtualFrame frame) { + int fromIndexPos = Math.max(offset, 0); + if (length(v1) == 0) { + return fromIndexPos; + } + return length(v0) - fromIndexPos >= length(v1) ? node.execute(v0, v1, fromIndexPos << 1, length(v0) << 1, TruffleString.Encoding.UTF_16) >> 1 : -1; + } + + static int length(TruffleString s) { + return s.byteLength(TruffleString.Encoding.UTF_16) >> 1; + } + } + + @Test + public void test() { + assumeFalse(CompileImmediatelyCheck.isCompileImmediately()); + Context c = Context.newBuilder().allowExperimentalOptions(true).option("engine.BackgroundCompilation", "false").option( + "engine.CompilationFailureAction", "Throw").option("engine.MaximumGraalGraphSize", "1000").build(); + c.enter(); + try { + OptimizedCallTarget callTarget = (OptimizedCallTarget) new StringTestRootNode().getCallTarget(); + callTarget.call(); + callTarget.compile(true); + } finally { + c.leave(); + } + } + +} From 613899dd2468a72aa43a83433a2ef36769324ec1 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Wed, 4 Jan 2023 19:20:13 +0100 Subject: [PATCH 262/312] Mark unsafe accessed fields for easier obfuscator detection. --- .../snapshot.sigtest | 7 ++++ .../oracle/truffle/api/dsl/InlineSupport.java | 11 +++++ .../truffle/dsl/processor/TruffleTypes.java | 2 + .../dsl/processor/generator/BitStateList.java | 40 +++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 13 ++++++ .../processor/generator/GeneratorUtils.java | 7 ++++ 6 files changed, 80 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest index 94a4bca385dc..be3d91672825 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest +++ b/truffle/src/com.oracle.truffle.api.dsl/snapshot.sigtest @@ -144,6 +144,7 @@ meth public abstract java.lang.Class[] value() CLSS public final com.oracle.truffle.api.dsl.InlineSupport innr public abstract interface static !annotation RequiredField innr public abstract interface static !annotation RequiredFields +innr public abstract interface static !annotation UnsafeAccessedField innr public abstract static InlinableField innr public final static BooleanField innr public final static ByteField @@ -280,6 +281,12 @@ meth public void set(com.oracle.truffle.api.nodes.Node,int) supr com.oracle.truffle.api.dsl.InlineSupport$InlinableField hfds bitLength,bitMask,bitOffset +CLSS public abstract interface static !annotation com.oracle.truffle.api.dsl.InlineSupport$UnsafeAccessedField + outer com.oracle.truffle.api.dsl.InlineSupport + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[FIELD]) +intf java.lang.annotation.Annotation + CLSS public abstract interface !annotation com.oracle.truffle.api.dsl.Introspectable anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=CLASS) anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE]) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java index fc4e53d1ba8e..d46cdcbf132a 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -155,6 +155,17 @@ public static boolean validate(Node node, InlinableField field0) { int dimensions() default 0; } + /** + * Marks a field to be accessed with unsafe. This annotation is useful to communicate fields + * that must not e rewritten by code obfuscation tools like Proguard. + * + * @since 23.0 + */ + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.FIELD}) + public @interface UnsafeAccessedField { + } + /** * Used to specify multiple {@link RequiredField}. * diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 5b3db9d2a189..3ce95d2c0c82 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -201,6 +201,7 @@ public class TruffleTypes { public static final String InlineSupport_LongField_Name = "com.oracle.truffle.api.dsl.InlineSupport.LongField"; public static final String InlineSupport_DoubleField_Name = "com.oracle.truffle.api.dsl.InlineSupport.DoubleField"; public static final String InlineSupport_ReferenceField_Name = "com.oracle.truffle.api.dsl.InlineSupport.ReferenceField"; + public static final String InlineSupport_UnsafeAccessedField_Name = "com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField"; public static final String NodeChild_Name = "com.oracle.truffle.api.dsl.NodeChild"; public static final String NodeChildren_Name = "com.oracle.truffle.api.dsl.NodeChildren"; public static final String NeverDefault_Name = "com.oracle.truffle.api.dsl.NeverDefault"; @@ -258,6 +259,7 @@ public class TruffleTypes { public final DeclaredType InlineSupport_IntField = c.getDeclaredType(InlineSupport_IntField_Name); public final DeclaredType InlineSupport_LongField = c.getDeclaredType(InlineSupport_LongField_Name); public final DeclaredType InlineSupport_DoubleField = c.getDeclaredType(InlineSupport_DoubleField_Name); + public final DeclaredType InlineSupport_UnsafeAccessedField = c.getDeclaredType(InlineSupport_UnsafeAccessedField_Name); public final DeclaredType NodeChild = c.getDeclaredType(NodeChild_Name); public final DeclaredType NodeChildren = c.getDeclaredType(NodeChildren_Name); public final DeclaredType NeverDefault = c.getDeclaredType(NeverDefault_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java index bcb49ffe1bf0..ddc96c574c6d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/BitStateList.java @@ -502,6 +502,11 @@ void addStateDoc(CodeTreeBuilder docBuilder) { docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); } + @Override + boolean isInlined() { + return false; + } + } static final class SpecializationExcluded extends State { @@ -532,6 +537,11 @@ void addStateDoc(CodeTreeBuilder docBuilder) { docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); } + @Override + boolean isInlined() { + return false; + } + } static final class SpecializationCachesInitialized extends State { @@ -559,6 +569,11 @@ void addStateDoc(CodeTreeBuilder docBuilder) { docBuilder.string("SpecializationCachesInitialized "); docBuilder.javadocLink(specialization.getMethod(), null); } + + @Override + boolean isInlined() { + return false; + } } static final class GuardActive extends State { @@ -594,6 +609,10 @@ void addStateDoc(CodeTreeBuilder docBuilder) { docBuilder.javadocLink(getDependentSpecialization().getMethod(), null); } + @Override + boolean isInlined() { + return false; + } } static final class ImplicitCastState extends State { @@ -619,6 +638,11 @@ public String toString() { key.getSignatureIndex()); } + @Override + boolean isInlined() { + return false; + } + } static final class EncodedEnumState extends State { @@ -649,6 +673,11 @@ public String toString() { ElementUtils.getReadableReference(node.getMessageElement(), cache.getParameter().getVariableElement())); } + + @Override + boolean isInlined() { + return false; + } } static final class InlinedNodeState extends State { @@ -684,6 +713,11 @@ void addStateDoc(CodeTreeBuilder docBuilder) { FlatNodeGenFactory.addCacheInfo(docBuilder, " ", getDependentSpecialization(), cache, key); } + @Override + boolean isInlined() { + return true; + } + } static final class AOTPreparedState extends State { @@ -702,6 +736,10 @@ public String toString() { return "AOTPrepared"; } + @Override + boolean isInlined() { + return false; + } } abstract static class State { @@ -747,6 +785,8 @@ public boolean equals(Object obj) { void addStateDoc(CodeTreeBuilder docBuilder) { docBuilder.string(toString()); } + + abstract boolean isInlined(); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 621970252b22..c0ad12619fc8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -1915,6 +1915,10 @@ private List createCachedFields(CodeTypeElement baseType) { CodeVariableElement specializationClassVar = createNodeField(PRIVATE, createSpecializationClassReferenceType(specialization), createSpecializationFieldName(specialization), null); + if (needsUpdater(specialization) && baseType != null) { + GeneratorUtils.markUnsafeAccessed(specializationClassVar); + } + if (specializationClassIsNode(specialization)) { specializationClassVar.getAnnotationMirrors().add(new CodeAnnotationMirror(types().Node_Child)); } else { @@ -2173,6 +2177,8 @@ private void createCachedFieldsImpl( nodeElements.add(inlinedCacheField); } + GeneratorUtils.markUnsafeAccessed(inlinedCacheField); + CodeTreeBuilder javadoc = inlinedCacheField.createDocBuilder(); javadoc.startJavadoc(); addSourceDoc(javadoc, specialization, cache, field); @@ -7506,6 +7512,13 @@ static CodeVariableElement createCachedField(BitSet bitSet) { CodeVariableElement var = FlatNodeGenFactory.createNodeField(PRIVATE, bitSet.getType(), bitSet.getName() + "_", ProcessorContext.getInstance().getTypes().CompilerDirectives_CompilationFinal); CodeTreeBuilder docBuilder = var.createDocBuilder(); + + for (BitRangedState state : bitSet.getStates().getEntries()) { + if (state.state.isInlined()) { + GeneratorUtils.markUnsafeAccessed(var); + } + } + docBuilder.startJavadoc(); FlatNodeGenFactory.addStateDoc(docBuilder, bitSet); docBuilder.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 7f854df48030..525ad2c4131d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -163,6 +163,13 @@ public static void addOverride(CodeExecutableElement method) { method.addAnnotationMirror(new CodeAnnotationMirror(override)); } + public static void markUnsafeAccessed(CodeElement element) { + DeclaredType unsafeAccessed = ProcessorContext.types().InlineSupport_UnsafeAccessedField; + if (ElementUtils.findAnnotationMirror(element, unsafeAccessed) == null) { + element.getAnnotationMirrors().add(new CodeAnnotationMirror(unsafeAccessed)); + } + } + public static void mergeSuppressWarnings(CodeElement element, String... addWarnings) { List mergedWarnings = Arrays.asList(addWarnings); AnnotationMirror currentWarnings = ElementUtils.findAnnotationMirror(element, SuppressWarnings.class); From 5b177e7894b7f7f621cdf5eafd6153bc90e0a337 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 00:19:16 +0100 Subject: [PATCH 263/312] Avoid passing null to uncached nodes in TruffleString. --- .../src/com/oracle/truffle/api/strings/TruffleString.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index ed15ab147785..fd1229c612fa 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -239,7 +239,7 @@ private static boolean attrsAreCorrect(Object bytes, Encoding encoding, int offs if (bytes instanceof NativePointer) { ((NativePointer) bytes).materializeByteArray(null, offset, length << stride, InlinedConditionProfile.getUncached()); } - long attrs = CalcStringAttributesNodeGen.getUncached().execute(null, null, bytes, offset, length, stride, encoding, 0, knownCodeRange); + long attrs = CalcStringAttributesNodeGen.getUncached().execute(CalcStringAttributesNodeGen.getUncached(), null, bytes, offset, length, stride, encoding, 0, knownCodeRange); int cpLengthCalc = StringAttributes.getCodePointLength(attrs); int codeRangeCalc = StringAttributes.getCodeRange(attrs); assert cpLengthCalc == codePointLength : "inconsistent codePointLength: " + cpLengthCalc + " != " + codePointLength; @@ -4619,7 +4619,8 @@ private static TruffleString asTruffleStringLoose(AbstractTruffleString a, Encod if (a.isImmutable()) { return (TruffleString) a; } - return TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode.getUncached().execute(null, a, encoding); + return TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode.getUncached().execute(TStringInternalNodes.FromBufferWithStringCompactionKnownAttributesNode.getUncached(), a, + encoding); } /** From 91cde679118faed7d3386604010c0d57140e904e Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 01:19:22 +0100 Subject: [PATCH 264/312] Add no warning as error to the regex down stream gate. --- regex/ci/ci.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex/ci/ci.jsonnet b/regex/ci/ci.jsonnet index 4bf3b94184c6..9e59871281ba 100644 --- a/regex/ci/ci.jsonnet +++ b/regex/ci/ci.jsonnet @@ -27,7 +27,7 @@ local regex_downstream_js = regex_common + { name: 'gate-regex-downstream-js-oraclejdk' + self.jdk_version, run: [ - ["mx", "testdownstream", "-R", ['mx', 'urlrewrite', 'https://github.com/graalvm/js-tests.git'], "--mx-command", " gate --all-suites --tags build,Test262-default,TestV8-default,regex"] + ["mx", "testdownstream", "-R", ['mx', 'urlrewrite', 'https://github.com/graalvm/js-tests.git'], "--mx-command", " gate --no-warning-as-error --all-suites --tags build,Test262-default,TestV8-default,regex"] ], targets: ["gate"], }, From 042955838fb0d4b915693a502c913516500b100b Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 01:23:15 +0100 Subject: [PATCH 265/312] Update overlay --- graal-common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graal-common.json b/graal-common.json index 8de40a2f68b7..2936c55c8e41 100644 --- a/graal-common.json +++ b/graal-common.json @@ -1,6 +1,6 @@ { "README": "This file contains definitions that are useful for the jsonnet CI files of the graal and graal-enterprise repositories.", "ci": { - "overlay": "5c0d0224f71123bac2ec0742e8906f179ec68caf" + "overlay": "9978c9dcda93e3c348a52bd9f5ebe11511540a6f" } } From 673e78ae124f7d171858fa01e60c17c8f5d2db14 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 22:55:08 +0100 Subject: [PATCH 266/312] Fix always pass down -ea for tck runs. --- truffle/mx.truffle/tck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/mx.truffle/tck.py b/truffle/mx.truffle/tck.py index e061fd4c8508..c7da97cee8b9 100644 --- a/truffle/mx.truffle/tck.py +++ b/truffle/mx.truffle/tck.py @@ -325,7 +325,7 @@ def execute_tck(graalvm_home, mode=Mode.default(), language_filter=None, values_ # On JDK9+ this does not work as one of the dependencies is Graal SDK which is in Java module org.graalvm.sdk, so instead # we patch the org.graalvm.sdk module to include the truffle-tck-common.jar and also its other dependency polyglot-tck.jar. # GR-35018 was filed to resolve this inconvenience. - additional_vm_arguments = [] + additional_vm_arguments = ['-ea'] jarsToPatch = [] for jarPath in cp: if 'polyglot-tck.jar' in jarPath: From 2087a0cc17b2ee66dd54f73ebff2f3bb09e693f1 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 22:56:22 +0100 Subject: [PATCH 267/312] Fix race condition in fallback guards with caches; Force specialization classes for specializations that bind guards that access instance fields. --- .../generator/FlatNodeGenFactory.java | 116 +++++++++++++++--- .../processor/generator/GeneratorUtils.java | 43 +++++++ 2 files changed, 145 insertions(+), 14 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index c0ad12619fc8..66186d481dc4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -749,6 +749,14 @@ public static boolean useSpecializationClass(SpecializationData specialization) // we need a place to store the next pointer. return true; } + if (specialization.isGuardBindsCache() && guardUseInstanceField(specialization)) { + /* + * For specializations that bind cached values in guards that use instance fields we + * need to use specialization classes because the duplication check is not reliable + * otherwise. + */ + return true; + } for (CacheExpression cache : specialization.getCaches()) { if (cache.isEncodedEnum()) { continue; @@ -769,6 +777,26 @@ public static boolean useSpecializationClass(SpecializationData specialization) } } + private static boolean guardUseInstanceField(SpecializationData s) { + for (GuardExpression guard : s.getGuards()) { + if (guard.isLibraryAcceptsGuard()) { + continue; + } + for (CacheExpression cache : s.getBoundCaches(guard.getExpression(), false)) { + if (!canCacheBeStoredInSpecialializationClass(cache)) { + continue; + } else if (cache.isEncodedEnum()) { + continue; + } else if (cache.getInlinedNode() != null) { + continue; + } + return true; + } + } + return false; + + } + public static boolean shouldUseSpecializationClassBySize(SpecializationData specialization) { SpecializationClassSizeEstimate result = computeSpecializationClassSizeEstimate(specialization); return result.sizeWithClass < result.sizeWithoutClass; @@ -2045,8 +2073,9 @@ private void createSpecializationClass(CodeTypeElement enclosingType, Specializa annotationType = types.CompilerDirectives_CompilationFinal; } + String nextName = "next_"; if (specialization.getMaximumNumberOfInstances() > 1) { - CodeVariableElement var = createNodeField(null, referenceType, "next_", annotationType); + CodeVariableElement var = createNodeField(null, referenceType, nextName, annotationType); if (annotationType != types.Node_Child) { var.getModifiers().add(Modifier.FINAL); } @@ -2061,6 +2090,13 @@ private void createSpecializationClass(CodeTypeElement enclosingType, Specializa specializationClass.getEnclosedElements().addAll(specializationClassElements); + if (specializationClassNeedsCopyConstructor(specialization)) { + if (specialization.getMaximumNumberOfInstances() > 1) { + throw new AssertionError("Copy constructor with next_ field is dangerous."); + } + specializationClass.add(GeneratorUtils.createCopyConstructorUsingFields(modifiers(), specializationClass, Collections.emptySet())); + } + if (specialization.hasMultipleInstances() && !specialization.getAssumptionExpressions().isEmpty()) { CodeExecutableElement remove = specializationClass.add(new CodeExecutableElement(referenceType, "remove")); remove.addParameter(new CodeVariableElement(referenceType, "search")); @@ -4933,7 +4969,7 @@ private boolean buildSpecializationSlowPath(final CodeTreeBuilder builder, Frame String countName = specialization != null ? "count" + specialization.getIndex() + "_" : null; final boolean useSpecializationClass = useSpecializationClass(specialization); final boolean multipleInstances = specialization.hasMultipleInstances(); - final boolean needsDuplicationCheck = specialization.isGuardBindsCache() || multipleInstances; + final boolean needsDuplicationCheck = needsDuplicationCheck(specialization); final boolean useDuplicateFlag = specialization.isGuardBindsCache() && !useSpecializationClass; final String duplicateFoundName = specialization.getId() + "_duplicateFound_"; @@ -5640,15 +5676,12 @@ private Collection persistSpecializationClass(FrameState frameState, S CodeTree ref = var.createReference(); CodeTreeBuilder builder = new CodeTreeBuilder(null); - // We need to insert memory fence if there are cached values and those are stored in a - // linked list. Another thread may be traversing the linked list while we are updating it - // here: we must ensure that the item that is being appended to the list is fully - // initialized. - builder.startStatement(); - builder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence").end(); - builder.end(); if (!aotSpecialize && needsDuplicationCheck(specialization)) { + /* + * No storeStore fence in this branch as we always use compareAndSet which has implicit + * storeStoreFence semantics. + */ builder.startIf(); if (frameState.isInlinedNode()) { String fieldName = createSpecializationFieldName(specialization); @@ -5669,6 +5702,14 @@ private Collection persistSpecializationClass(FrameState frameState, S builder.statement("continue"); builder.end(); } else { + // We need to insert memory fence if there are cached values and those are stored in a + // linked list. Another thread may be traversing the linked list while we are updating + // it here: we must ensure that the item that is being appended to the list is fully + // initialized. + builder.startStatement(); + builder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence").end(); + builder.end(); + builder.startStatement(); builder.tree(createSpecializationFieldAccess(frameState, specialization, true, true, null, ref)); builder.end(); @@ -6155,13 +6196,41 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, innerTriples.addAll(persistSpecializationClass(innerFrameState, group.getSpecialization(), false)); - if (useSpecializationClass(specialization) && needsDuplicationCheck(specialization)) { - CodeTreeBuilder b = builder.create(); + if (useSpecializationClass(specialization)) { + CodeTreeBuilder b; + if (needsDuplicationCheck(specialization)) { + b = builder.create(); + b.startStatement(); + b.string(createSpecializationLocalOriginalName(specialization)); + b.string(" = "); + b.tree(createGetSpecializationClass(frameState, specialization, true)); + b.end(); + innerTriples.add(new IfTriple(null, null, b.build())); + } + + b = builder.create(); b.startStatement(); - b.string(createSpecializationLocalOriginalName(specialization)); - b.string(" = "); - b.tree(createGetSpecializationClass(frameState, specialization, true)); + String localName = createSpecializationLocalName(specialization); + b.string(localName).string(" = "); + boolean isNode = specializationClassIsNode(specialization); + if (isNode) { + if (frameState.isInlinedNode()) { + b.startCall(frameState.getValue(INLINED_NODE_INDEX).createReference(), "insert"); + } else { + b.startCall("this.insert"); + } + } + if (!specializationClassNeedsCopyConstructor(specialization)) { + throw new AssertionError("Inconsistent copy constructor condition."); + } + b.startNew(createSpecializationClassReferenceType(specialization)); + b.string(localName); + b.end(); + if (isNode) { + b.end(); + } b.end(); + innerTriples.add(new IfTriple(null, null, b.build())); } @@ -6173,6 +6242,25 @@ private List initializeCachesForSlowPathGuard(FrameState frameState, return Arrays.asList(new IfTriple(builder.build(), null, null)); } + private static boolean specializationClassNeedsCopyConstructor(SpecializationData specialization) { + if (!useSpecializationClass(specialization)) { + return false; + } + + if (!specialization.isReachesFallback()) { + return false; + } + + for (GuardExpression guard : specialization.getGuards()) { + boolean guardStateBit = guardNeedsStateBit(specialization, guard); + if (guardStateBit) { + return true; + } + } + + return false; + } + private List initializeCaches(FrameState frameState, NodeExecutionMode mode, SpecializationGroup group, Collection caches, boolean store, boolean forcePersist) { if (group.getSpecialization() == null || caches.isEmpty()) { return Collections.emptyList(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index 525ad2c4131d..b31b431048ff 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -77,6 +77,7 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedElement; +import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; import com.oracle.truffle.dsl.processor.model.Template; import com.oracle.truffle.dsl.processor.model.TemplateMethod; @@ -236,6 +237,48 @@ public static CodeExecutableElement createConstructorUsingFields(Set m return method; } + public static CodeExecutableElement createCopyConstructorUsingFields(Set modifiers, CodeTypeElement clazz, Set ignoreFields) { + TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); + ExecutableElement constructor = findConstructor(superClass); + return createCopyConstructorUsingFields(modifiers, clazz, constructor, ignoreFields); + } + + public static CodeExecutableElement createCopyConstructorUsingFields(Set modifiers, CodeTypeElement clazz, ExecutableElement superConstructor, + Set ignoreFields) { + CodeExecutableElement method = new CodeExecutableElement(modifiers, null, clazz.getSimpleName().toString()); + CodeTreeBuilder builder = method.createBuilder(); + if (superConstructor != null && superConstructor.getParameters().size() > 0) { + builder.startStatement(); + builder.startSuperCall(); + for (VariableElement parameter : superConstructor.getParameters()) { + method.addParameter(CodeVariableElement.clone(parameter)); + builder.string(parameter.getSimpleName().toString()); + } + builder.end(); // super + builder.end(); // statement + } + + GeneratedTypeMirror typeMirror = new GeneratedTypeMirror("", clazz.getSimpleName().toString(), clazz.asType()); + method.addParameter(new CodeVariableElement(typeMirror, "delegate")); + for (VariableElement field : clazz.getFields()) { + if (field.getModifiers().contains(STATIC)) { + continue; + } + if (ignoreFields.contains(field.getSimpleName().toString())) { + continue; + } + String fieldName = field.getSimpleName().toString(); + builder.startStatement(); + builder.string("this."); + builder.string(fieldName); + builder.string(" = delegate."); + builder.string(fieldName); + builder.end(); // statement + } + + return method; + } + private static ExecutableElement findConstructor(TypeElement clazz) { List constructors = ElementFilter.constructorsIn(clazz.getEnclosedElements()); if (constructors.isEmpty()) { From 03c37905b149b0558c53fe931e249e477b3b1010 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Thu, 5 Jan 2023 23:29:42 +0100 Subject: [PATCH 268/312] Better debug output for errors. --- .../src/com/oracle/truffle/tck/tests/ErrorTypeTest.java | 4 ++-- .../src/com/oracle/truffle/tck/tests/ExpressionTest.java | 9 ++++++--- .../oracle/truffle/tck/tests/IdentityFunctionTest.java | 9 ++++++--- .../oracle/truffle/tck/tests/InlineExecutionTest.java | 9 ++++++--- .../src/com/oracle/truffle/tck/tests/StatementTest.java | 9 ++++++--- .../src/com/oracle/truffle/tck/tests/TestUtil.java | 7 ++++++- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ErrorTypeTest.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ErrorTypeTest.java index 99175176a7f8..54363ecec2ee 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ErrorTypeTest.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ErrorTypeTest.java @@ -258,7 +258,7 @@ public void testErrorType() { TestUtil.formatErrorMessage( "Unexpected Exception: " + e.getMessage() + ", expected: " + polyglotException.getMessage(), testRun, - context), + context, null, polyglotException), e); } } @@ -267,7 +267,7 @@ public void testErrorType() { throw new AssertionError(TestUtil.formatErrorMessage( "Expected PolyglotException, but executed successfully.", testRun, - context)); + context, null, polyglotException)); } } finally { TEST_RESULT_MATCHER.accept(new AbstractMap.SimpleImmutableEntry<>(testRun, passed)); diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ExpressionTest.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ExpressionTest.java index e6084a31d300..97c79f6e61dc 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ExpressionTest.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/ExpressionTest.java @@ -95,14 +95,17 @@ public ExpressionTest(final TestRun testRun) { public void testExpression() { Assume.assumeThat(testRun, TEST_RESULT_MATCHER); boolean success = false; + Value result = null; + PolyglotException ex = null; try { - Value result = null; try { result = testRun.getSnippet().getExecutableValue().execute(testRun.getActualParameters().toArray()); } catch (IllegalArgumentException e) { - TestUtil.validateResult(testRun, context.getContext().asValue(e).as(PolyglotException.class)); + ex = context.getContext().asValue(e).as(PolyglotException.class); + TestUtil.validateResult(testRun, ex); success = true; } catch (PolyglotException e) { + ex = e; TestUtil.validateResult(testRun, e); success = true; } @@ -115,7 +118,7 @@ public void testExpression() { TestUtil.formatErrorMessage( "Unexpected Exception: " + e.getMessage(), testRun, - context), + context, result, ex), e); } finally { TEST_RESULT_MATCHER.accept(new AbstractMap.SimpleImmutableEntry<>(testRun, success)); diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/IdentityFunctionTest.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/IdentityFunctionTest.java index 6cd769bb3cb1..1417869abfe3 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/IdentityFunctionTest.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/IdentityFunctionTest.java @@ -104,14 +104,17 @@ public IdentityFunctionTest(final TestRun testRun) { public void testIdentityFunction() { Assume.assumeThat(testRun, TEST_RESULT_MATCHER); boolean success = false; + Value result = null; + PolyglotException ex = null; try { - Value result = null; try { result = testRun.getSnippet().getExecutableValue().execute(testRun.getActualParameters().toArray()); } catch (IllegalArgumentException e) { - TestUtil.validateResult(testRun, context.getContext().asValue(e).as(PolyglotException.class)); + ex = context.getContext().asValue(e).as(PolyglotException.class); + TestUtil.validateResult(testRun, ex); success = true; } catch (PolyglotException e) { + ex = e; TestUtil.validateResult(testRun, e); success = true; } @@ -124,7 +127,7 @@ public void testIdentityFunction() { TestUtil.formatErrorMessage( "Unexpected Exception: " + e.getMessage(), testRun, - context), + context, result, ex), e); } finally { TEST_RESULT_MATCHER.accept(new AbstractMap.SimpleImmutableEntry<>(testRun, success)); diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/InlineExecutionTest.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/InlineExecutionTest.java index 0bdf56e86e27..31ff830d37b4 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/InlineExecutionTest.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/InlineExecutionTest.java @@ -110,14 +110,17 @@ public void testInline() throws Exception { } context.getContext().initialize(testRun.getID()); context.setInlineSnippet(testRun.getID(), inlineSnippet, verifier); + Value result = null; + PolyglotException ex = null; try { - Value result = null; try { result = testRun.getSnippet().getExecutableValue().execute(testRun.getActualParameters().toArray()); } catch (IllegalArgumentException e) { - TestUtil.validateResult(testRun, context.getContext().asValue(e).as(PolyglotException.class)); + ex = context.getContext().asValue(e).as(PolyglotException.class); + TestUtil.validateResult(testRun, ex); success = true; } catch (PolyglotException e) { + ex = e; TestUtil.validateResult(testRun, e); success = true; } @@ -134,7 +137,7 @@ public void testInline() throws Exception { TestUtil.formatErrorMessage( "Unexpected Exception: " + e.getMessage(), testRun, - context), + context, result, ex), e); } finally { context.setInlineSnippet(null, null, null); diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/StatementTest.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/StatementTest.java index 504886df1488..a03482ae0125 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/StatementTest.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/StatementTest.java @@ -95,14 +95,17 @@ public StatementTest(final TestRun testRun) { public void testStatement() { Assume.assumeThat(testRun, TEST_RESULT_MATCHER); boolean success = false; + Value result = null; + PolyglotException ex = null; try { - Value result = null; try { result = testRun.getSnippet().getExecutableValue().execute(testRun.getActualParameters().toArray()); } catch (IllegalArgumentException e) { - TestUtil.validateResult(testRun, context.getContext().asValue(e).as(PolyglotException.class)); + ex = context.getContext().asValue(e).as(PolyglotException.class); + TestUtil.validateResult(testRun, ex); success = true; } catch (PolyglotException e) { + ex = e; TestUtil.validateResult(testRun, e); success = true; } @@ -115,7 +118,7 @@ public void testStatement() { TestUtil.formatErrorMessage( "Unexpected Exception: " + e.getMessage(), testRun, - context), + context, result, ex), e); } finally { TEST_RESULT_MATCHER.accept(new AbstractMap.SimpleImmutableEntry<>(testRun, success)); diff --git a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TestUtil.java b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TestUtil.java index 2eb2fd83d28f..4b697372f791 100644 --- a/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TestUtil.java +++ b/truffle/src/com.oracle.truffle.tck.tests/src/com/oracle/truffle/tck/tests/TestUtil.java @@ -202,7 +202,9 @@ static void computeAllPermutations( static String formatErrorMessage( final String errorMessage, final TestRun testRun, - final TestContext testContext) { + final TestContext testContext, + final Value resultValue, + final PolyglotException exception) { final String language = testRun.getID(); final Snippet snippet = testRun.getSnippet(); final StringBuilder message = new StringBuilder(); @@ -226,12 +228,15 @@ static String formatErrorMessage( message.append("failed:\n"); message.append(errorMessage); message.append('\n'); + message.append("Result: ").append(resultValue).append('\n'); + message.append("Exception: ").append(exception).append('\n'); message.append("Snippet: ").append(getSource(snippet.getExecutableValue())).append('\n'); int i = 0; for (Map.Entry langAndparamSnippet : testRun.getActualParameterSnippets()) { final Snippet paramSnippet = langAndparamSnippet.getValue(); message.append(String.format("Parameter %d Snippet: ", i++)).append(getSource(paramSnippet.getExecutableValue())).append('\n'); } + return message.toString(); } From 14aaf2e9c42231aca49fd1e0dc360b5deda1cb26 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 13:24:36 +0100 Subject: [PATCH 269/312] Fix active check; Add fallback test. --- .../truffle/api/dsl/test/FallbackTest.java | 128 ++++++++++++++++++ .../generator/FlatNodeGenFactory.java | 18 ++- 2 files changed, 142 insertions(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java index ad9a5e0f41f7..fb0abe45ed50 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java @@ -45,6 +45,7 @@ import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Assert; import org.junit.Test; @@ -72,6 +73,7 @@ import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback7Factory; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback8NodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.Fallback9NodeGen; +import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackGuardWithCachesNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithAssumptionArrayNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithAssumptionNodeGen; import com.oracle.truffle.api.dsl.test.FallbackTestFactory.FallbackWithCachedNodeGen; @@ -86,6 +88,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeUtil; +import com.oracle.truffle.api.test.common.TestUtils; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) @@ -841,4 +844,129 @@ protected String f0(Object arg0, } + abstract static class GuardIntNode extends Node { + + public abstract boolean execute(int left, int comparison); + + @Specialization + protected boolean s0(@SuppressWarnings("unused") int arg0, int comparison) { + return arg0 == comparison; + } + + } + + abstract static class FallbackGuardWithCachesNode extends SlowPathListenerNode { + + abstract int execute(int left); + + @Specialization(guards = {"guard0.execute(v, 0)"}, limit = "1") + int s0(int v, + @Cached GuardIntNode guard0, + @Cached GuardIntNode guard1) { + assertNotNull(guard1); + return 0; + } + + @Specialization(guards = {"guard0.execute(v, 1)", "!guard1.execute(v, 2)"}, limit = "1") + int s1(int v, + @Cached GuardIntNode guard0, + @Cached GuardIntNode guard1, + @Cached GuardIntNode guard2) { + assertNotNull(guard2); + return 1; + } + + @Specialization(guards = {"guard0.execute(v, 3)", "!guard1.execute(v, 4)"}, limit = "1") + int s1(int v, + @Cached GuardIntNode guard0, + @Cached GuardIntNode guard1, + @Cached GuardIntNode guard2, + @Cached GuardIntNode guard3) { + assertNotNull(guard3); + return 2; + } + + @SuppressWarnings("unused") + @Fallback + public static int doGeneric(int v) { + return -1; + } + } + + /* + * Test for GR-33857. + */ + @Test + public void testFallbackGuardWithCachesNode() { + FallbackGuardWithCachesNode node; + + int[] values = new int[]{0, 1, 3}; + int[] fallback = new int[]{2, 4, 5}; + + for (int f0 = 0; f0 < 3; f0++) { + for (int f1 = 0; f1 < 3; f1++) { + for (int v0 = 0; v0 < 3; v0++) { + for (int v1 = 0; v1 < 3; v1++) { + node = FallbackGuardWithCachesNodeGen.create(); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(v1, node.execute(values[v1])); + + // must be stable now + int slowPathCount = node.specializeCount; + assertEquals(v1, node.execute(values[v1])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(slowPathCount, node.specializeCount); + + node = FallbackGuardWithCachesNodeGen.create(); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(v1, node.execute(values[v1])); + + // must be stable now + slowPathCount = node.specializeCount; + assertEquals(v1, node.execute(values[v1])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(slowPathCount, node.specializeCount); + + node = FallbackGuardWithCachesNodeGen.create(); + assertEquals(v0, node.execute(values[v0])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(v1, node.execute(values[v1])); + + // must be stable now + slowPathCount = node.specializeCount; + assertEquals(v1, node.execute(values[v1])); + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(slowPathCount, node.specializeCount); + + node = FallbackGuardWithCachesNodeGen.create(); + assertEquals(v0, node.execute(values[v0])); + assertEquals(v1, node.execute(values[v1])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(-1, node.execute(fallback[f1])); + + // must be stable now + slowPathCount = node.specializeCount; + assertEquals(-1, node.execute(fallback[f1])); + assertEquals(-1, node.execute(fallback[f0])); + assertEquals(v1, node.execute(values[v1])); + assertEquals(v0, node.execute(values[v0])); + assertEquals(slowPathCount, node.specializeCount); + + } + } + } + } + + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 66186d481dc4..5bcf0f7fcb51 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -67,6 +67,7 @@ import static javax.lang.model.element.Modifier.PUBLIC; import static javax.lang.model.element.Modifier.STATIC; +import java.awt.desktop.SystemEventListener; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.VarHandle; @@ -4691,8 +4692,13 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization BlockState innerIfCount = BlockState.NONE; if (useSpecializationClass) { - if (specialization.isGuardBindsCache()) { - cachedTriples.add(new IfTriple(loadSpecializationClass(frameState, specialization, false), null, null)); + outer: for (GuardExpression guard : specialization.getGuards()) { + for (CacheExpression cache : specialization.getBoundCaches(guard.getExpression(), true)) { + if (canCacheBeStoredInSpecialializationClass(cache)) { + cachedTriples.add(new IfTriple(loadSpecializationClass(frameState, specialization, false), null, null)); + break outer; + } + } } } cachedTriples.addAll(createMethodGuardChecks(frameState, group, remainingGuards, mode)); @@ -4707,8 +4713,11 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization } if (singleCondition != null) { int index = cachedTriples.indexOf(singleCondition); - CodeTree stateCheck = multiState.createNotContains(frameState, StateQuery.create(SpecializationActive.class, specialization)); - cachedTriples.set(index, new IfTriple(singleCondition.prepare, combineTrees(" && ", stateCheck, singleCondition.condition), singleCondition.statements)); + CodeTreeBuilder b = new CodeTreeBuilder(parent); + b.string("!("); + b.tree(createSpecializationActiveCheck(frameState, Arrays.asList(specialization))); + b.string(")"); + cachedTriples.set(index, new IfTriple(singleCondition.prepare, combineTrees(" && ", b.build(), singleCondition.condition), singleCondition.statements)); fallbackNeedsState = true; } } @@ -5635,6 +5644,7 @@ private CodeTree loadSpecializationClass(FrameState frameState, SpecializationDa builder.string(typeName); builder.string(" "); } + builder.string(localName); builder.string(" = "); if (useUpdater) { From dd9984ffff25e9bf875567ecba68cd9c1bd92477 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 14:02:51 +0100 Subject: [PATCH 270/312] Fix import. --- .../truffle/dsl/processor/generator/FlatNodeGenFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 5bcf0f7fcb51..48af6ae8768e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -67,7 +67,6 @@ import static javax.lang.model.element.Modifier.PUBLIC; import static javax.lang.model.element.Modifier.STATIC; -import java.awt.desktop.SystemEventListener; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.VarHandle; From 798c7b6c173068169503bcd5086a696e2764831a Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 14:05:50 +0100 Subject: [PATCH 271/312] Fix fallback test. --- .../src/com/oracle/truffle/api/dsl/test/FallbackTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java index fb0abe45ed50..2ff6539dcba2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/FallbackTest.java @@ -88,7 +88,6 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeUtil; -import com.oracle.truffle.api.test.common.TestUtils; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; @SuppressWarnings({"truffle-inlining", "truffle-neverdefault", "truffle-sharing"}) @@ -855,6 +854,7 @@ protected boolean s0(@SuppressWarnings("unused") int arg0, int comparison) { } + @SuppressWarnings("unused") abstract static class FallbackGuardWithCachesNode extends SlowPathListenerNode { abstract int execute(int left); @@ -893,9 +893,6 @@ public static int doGeneric(int v) { } } - /* - * Test for GR-33857. - */ @Test public void testFallbackGuardWithCachesNode() { FallbackGuardWithCachesNode node; From 35a7c933cff86bd289ec7eabd3df70511bdc5d84 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 14:31:28 +0100 Subject: [PATCH 272/312] More consistent naming in InlineSupport. --- .../oracle/truffle/api/dsl/InlineSupport.java | 94 +++++++++---------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java index d46cdcbf132a..a660d0b212c2 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -345,12 +345,8 @@ public abstract static class InlinableField extends UnsafeField { final ReferenceField parentField; - InlinableField(Lookup tclass, String fieldName, Class valueClass) { - this(tclass.lookupClass(), tclass.lookupClass(), tclass, fieldName, valueClass); - } - - InlinableField(Class receiverClass, Class lookupClass, Lookup fieldClass, String fieldName, Class valueClass) { - super(receiverClass, lookupClass, fieldClass, fieldName, valueClass); + InlinableField(Class receiverClass, Class declaringClass, Lookup declaringLookup, String fieldName, Class valueClass) { + super(receiverClass, declaringClass, declaringLookup, fieldName, valueClass); this.parentField = null; } @@ -434,8 +430,8 @@ public static final class StateField extends InlinableField { final int bitLength; final int bitMask; - StateField(Lookup tclass, String fieldName, int offset, int length) { - super(tclass, fieldName, int.class); + StateField(Lookup declaringLookup, String fieldName, int offset, int length) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, int.class); this.bitOffset = offset; this.bitLength = length; this.bitMask = computeMask(offset, length); @@ -542,8 +538,8 @@ private boolean noBitsLost(int providedBits) { * * @since 23.0 */ - public static StateField create(Lookup lookup, String field) { - return new StateField(lookup, field, 0, 32); + public static StateField create(Lookup declaringLookup, String field) { + return new StateField(declaringLookup, field, 0, 32); } } @@ -555,8 +551,8 @@ public static StateField create(Lookup lookup, String field) { */ public static final class ReferenceField extends InlinableField { - ReferenceField(Class receiverClass, Class lookupFieldClass, Lookup lookup, String fieldName, Class valueClass) { - super(receiverClass, lookupFieldClass, lookup, fieldName, valueClass); + ReferenceField(Class receiverClass, Class lookupFieldClass, Lookup declaringLookup, String fieldName, Class valueClass) { + super(receiverClass, lookupFieldClass, declaringLookup, fieldName, valueClass); } ReferenceField(ReferenceField prev, Class pclass) { @@ -633,9 +629,9 @@ public boolean compareAndSet(Node node, T expect, T update) { * * @since 23.0 */ - public static ReferenceField create(Lookup nodeClass, String field, Class valueClass) { - Class lookupClass = nodeClass.lookupClass(); - return new ReferenceField<>(lookupClass, lookupClass, nodeClass, field, valueClass); + public static ReferenceField create(Lookup declaringLookup, String field, Class valueClass) { + Class lookupClass = declaringLookup.lookupClass(); + return new ReferenceField<>(lookupClass, lookupClass, declaringLookup, field, valueClass); } } @@ -646,8 +642,8 @@ public static ReferenceField create(Lookup nodeClass, String field, Class */ public static final class BooleanField extends InlinableField { - BooleanField(Lookup tclass, String fieldName) { - super(tclass, fieldName, boolean.class); + BooleanField(Lookup lookup, String fieldName) { + super(lookup.lookupClass(), lookup.lookupClass(), lookup, fieldName, boolean.class); } BooleanField(BooleanField prev, Class parentClass) { @@ -698,8 +694,8 @@ public void set(Node node, boolean value) { * * @since 23.0 */ - public static BooleanField create(Lookup nodeClass, String field) { - return new BooleanField(nodeClass, field); + public static BooleanField create(Lookup declaringLookup, String field) { + return new BooleanField(declaringLookup, field); } } @@ -710,8 +706,8 @@ public static BooleanField create(Lookup nodeClass, String field) { */ public static final class ByteField extends InlinableField { - ByteField(Lookup tclass, String fieldName) { - super(tclass, fieldName, byte.class); + ByteField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, byte.class); } ByteField(ByteField prev, Class parentClass) { @@ -762,8 +758,8 @@ public void set(Node node, byte value) { * * @since 23.0 */ - public static ByteField create(Lookup nodeClass, String field) { - return new ByteField(nodeClass, field); + public static ByteField create(Lookup declaringLookup, String field) { + return new ByteField(declaringLookup, field); } } @@ -774,8 +770,8 @@ public static ByteField create(Lookup nodeClass, String field) { */ public static final class ShortField extends InlinableField { - ShortField(Lookup tclass, String fieldName) { - super(tclass, fieldName, short.class); + ShortField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, short.class); } ShortField(ShortField prev, Class parentClass) { @@ -826,8 +822,8 @@ public void set(Node node, short value) { * * @since 23.0 */ - public static ShortField create(Lookup nodeClass, String field) { - return new ShortField(nodeClass, field); + public static ShortField create(Lookup declaringLookup, String field) { + return new ShortField(declaringLookup, field); } } @@ -838,8 +834,8 @@ public static ShortField create(Lookup nodeClass, String field) { */ public static final class CharField extends InlinableField { - CharField(Lookup tclass, String fieldName) { - super(tclass, fieldName, char.class); + CharField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, char.class); } CharField(CharField prev, Class parentClass) { @@ -890,8 +886,8 @@ public void set(Node node, char value) { * * @since 23.0 */ - public static CharField create(Lookup nodeClass, String field) { - return new CharField(nodeClass, field); + public static CharField create(Lookup declaringLookup, String field) { + return new CharField(declaringLookup, field); } } @@ -902,8 +898,8 @@ public static CharField create(Lookup nodeClass, String field) { */ public static final class FloatField extends InlinableField { - FloatField(Lookup tclass, String fieldName) { - super(tclass, fieldName, float.class); + FloatField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, float.class); } FloatField(FloatField prev, Class parentClass) { @@ -954,8 +950,8 @@ public void set(Node node, float value) { * * @since 23.0 */ - public static FloatField create(Lookup nodeClass, String field) { - return new FloatField(nodeClass, field); + public static FloatField create(Lookup declaringLookup, String field) { + return new FloatField(declaringLookup, field); } } @@ -966,8 +962,8 @@ public static FloatField create(Lookup nodeClass, String field) { */ public static final class IntField extends InlinableField { - IntField(Lookup tclass, String fieldName) { - super(tclass, fieldName, int.class); + IntField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, int.class); } IntField(IntField prev, Class parentClass) { @@ -1018,8 +1014,8 @@ public void set(Node node, int value) { * * @since 23.0 */ - public static IntField create(Lookup nodeClass, String field) { - return new IntField(nodeClass, field); + public static IntField create(Lookup declaringLookup, String field) { + return new IntField(declaringLookup, field); } } @@ -1030,8 +1026,8 @@ public static IntField create(Lookup nodeClass, String field) { */ public static final class LongField extends InlinableField { - LongField(Lookup tclass, String fieldName) { - super(tclass, fieldName, long.class); + LongField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, long.class); } LongField(LongField prev, Class parentClass) { @@ -1082,8 +1078,8 @@ public void set(Node node, long value) { * * @since 23.0 */ - public static LongField create(Lookup nodeClass, String field) { - return new LongField(nodeClass, field); + public static LongField create(Lookup declaringLookup, String field) { + return new LongField(declaringLookup, field); } } @@ -1094,8 +1090,8 @@ public static LongField create(Lookup nodeClass, String field) { */ public static final class DoubleField extends InlinableField { - DoubleField(Lookup tclass, String fieldName) { - super(tclass, fieldName, double.class); + DoubleField(Lookup declaringLookup, String fieldName) { + super(declaringLookup.lookupClass(), declaringLookup.lookupClass(), declaringLookup, fieldName, double.class); } DoubleField(DoubleField prev, Class parentClass) { @@ -1146,8 +1142,8 @@ public void set(Node node, double value) { * * @since 23.0 */ - public static DoubleField create(Lookup nodeClass, String field) { - return new DoubleField(nodeClass, field); + public static DoubleField create(Lookup declaringLookup, String field) { + return new DoubleField(declaringLookup, field); } } @@ -1453,10 +1449,10 @@ abstract static class VarHandleField { private final VarHandle handle; @SuppressWarnings("unused") - VarHandleField(Class receiverClass, Class lookupClass, Lookup fieldClass, String fieldName, Class valueClass) { + VarHandleField(Class receiverClass, Class lookupClass, Lookup declaringLookup, String fieldName, Class valueClass) { try { this.receiverClass = receiverClass; - this.handle = fieldClass.findVarHandle(lookupClass, fieldName, valueClass); + this.handle = declaringLookup.findVarHandle(lookupClass, fieldName, valueClass); } catch (NoSuchFieldException | IllegalAccessException e) { throw new IllegalArgumentException(e); } From b8af0c2c8635d1df2db4faf20b3a4bf79711a2bb Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 15:39:51 +0100 Subject: [PATCH 273/312] Update ci-overlay. --- graal-common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graal-common.json b/graal-common.json index 2936c55c8e41..970246a81f4e 100644 --- a/graal-common.json +++ b/graal-common.json @@ -1,6 +1,6 @@ { "README": "This file contains definitions that are useful for the jsonnet CI files of the graal and graal-enterprise repositories.", "ci": { - "overlay": "9978c9dcda93e3c348a52bd9f5ebe11511540a6f" + "overlay": "8c61a7696bd278b4d22f1f03d87f7cdf32b919dc" } } From 1802bd2a5f4096d85830f7fc88176fa34ea1e8d4 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 15:45:40 +0100 Subject: [PATCH 274/312] Fix reviewer comment. --- truffle/docs/DSLNodeObjectInlining.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/docs/DSLNodeObjectInlining.md b/truffle/docs/DSLNodeObjectInlining.md index fd05cc93f4bb..f7e11086cf66 100644 --- a/truffle/docs/DSLNodeObjectInlining.md +++ b/truffle/docs/DSLNodeObjectInlining.md @@ -64,7 +64,7 @@ Footprint = 3 * 12 + 5 * 4 + 12 = 68 bytes Therefore, we use `68` bytes to represent a single operation with nodes. -The Truffle DSL annotation processor will now produce the following warning for the `AbsNode` class: +With 23.0, the Truffle DSL annotation processor will produce the following warning for the `AbsNode` class: ``` This node is a candidate for node object inlining. The memory footprint is estimated to be reduced from 20 to 1 byte(s). Add @GenerateInline(true) to enable object inlining for this node or @GenerateInline(false) to disable this warning. Also, consider disabling cached node generation with @GenerateCached(false) if all usages will be inlined. This warning may be suppressed using @SuppressWarnings("truffle-inlining"). From 3ed943665a031e5de0f51695b975ec5532022dd4 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 15:48:59 +0100 Subject: [PATCH 275/312] Fix reviewer comment. --- truffle/docs/DSLNodeObjectInlining.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/docs/DSLNodeObjectInlining.md b/truffle/docs/DSLNodeObjectInlining.md index f7e11086cf66..e47c6ffb762f 100644 --- a/truffle/docs/DSLNodeObjectInlining.md +++ b/truffle/docs/DSLNodeObjectInlining.md @@ -239,7 +239,7 @@ Depending on the use case, it can hinder readability to repeat individual inlini Computing the overhead now becomes more tricky. We need to understand how many state bits each node requires to keep track of active specializations. That computation is generally implementation specific and subject to change. However, a good rule of thumb is that the DSL requires one bit per declared specialization. -Implicit casts and `@Fallback` annotations may further increase that requirement. +Implicit casts, replace rules, `@Fallback` and specializations with multiple instances may further increase the number of required state bits. For this example, each `AddAbsNode` requires 5 bits. 2 bits for each of the `AbsNode` usages and one bit for the `AddAbsNode` specializations. The `Add4AbsNode` uses three instances of `AddAbsNode`, has one specialization, and therefore needs `3 * 5 + 1` state bits in total. From a3ddff95a67021c7ebd5f3fd85509b0f973ceb8e Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 15:53:05 +0100 Subject: [PATCH 276/312] Fix typo in changelog. --- truffle/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 4996997f1351..e38a6cd9d400 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -27,7 +27,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan * `@Shared` cached values may now use primitive values. Also, `@Shared` can now be used for caches contained in specializations with multiple instances. This means that the shared cache will be used across all instances of a specialization. * Truffle DSL now generates many more Javadoc comments in the generated code that try to explain the decisions of the code generator. * Added inlined variants for all Truffle profiles in `com.oracle.truffle.api.profiles`. The DSL now emits recommendation warnings when inlined profiles should be used instead of the allocated ones. - * Truffle DSL now emits many more warnings for recommendations. For example, it emits warnings for inlining opportunities, cached sharing or when a cache initializer should be designated as `@NeverDefault`. To ease migration work, we added several new ways to suppress the warnings temporarily for the Java package. For a list of possible warnings and further usage instructions, see the new [warnings page](https://github.com/oracle/graal/blob/master/truffle/docs/DSLWarnings.md) in the docs. + * Truffle DSL now emits many more warnings for recommendations. For example, it emits warnings for inlining opportunities, cached sharing or when a cache initializer should be designated as `@NeverDefault`. To ease migration work, we added several new ways to suppress the warnings temporarily for a Java package. For a list of possible warnings and further usage instructions, see the new [warnings page](https://github.com/oracle/graal/blob/master/truffle/docs/DSLWarnings.md) in the docs. * The DSL now produces warnings for specializations with multiple instances but an unspecified limit. The new warning can be resolved by specifying the desired limit (previously, default `"3"` was assumed) * Added the capability to unroll specializations with multiple instances. Unrolling in combination with node object inlining may further reduce the memory footprint of a Truffle node. In particular, if all cached states can be encoded into the state bit set of the generated node. See `@Specialization(...unroll=2)` for further details From c7d86895dac450619b2784a8e8ae10d16fb4edcd Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 15:57:59 +0100 Subject: [PATCH 277/312] Strengthen checks for UnsafeField. --- .../src/com/oracle/truffle/api/dsl/InlineSupport.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java index a660d0b212c2..087336f99dd8 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java @@ -1173,6 +1173,12 @@ abstract static class UnsafeField { } UnsafeField(Class receiverClass, Class declaringClass, Lookup declaringLookup, String fieldName, Class valueClass) { + Objects.requireNonNull(receiverClass); + Objects.requireNonNull(declaringClass); + Objects.requireNonNull(declaringLookup); + Objects.requireNonNull(fieldName); + Objects.requireNonNull(valueClass); + Field field; try { this.declaringClass = declaringClass; @@ -1197,6 +1203,10 @@ public Field run() throws NoSuchFieldException { throw new IllegalArgumentException(String.format("Expected field type %s, but got %s. ", valueClass.getName(), fieldClass.getName())); } + if (!declaringClass.isAssignableFrom(receiverClass)) { + throw new AssertionError(String.format("Receiver class is not assignable to declaring class.", declaringClass.getName(), receiverClass.getName())); + } + final int modifiers = field.getModifiers(); if (Modifier.isFinal(modifiers)) { throw new IllegalArgumentException("Must not be final field"); From b184789725153e740e907423374cd08b14179ab6 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 16:43:25 +0100 Subject: [PATCH 278/312] Add storeStore fences for cache initializers if there is no specialization class and no duplication check. --- .../api/dsl/test/NeverDefaultTest.java | 43 ++++++++++++++++++- .../generator/FlatNodeGenFactory.java | 40 ++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 8828a40d8254..9d21758098f9 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -72,6 +72,7 @@ import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt1NodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt2NodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.NeverDefaultInt3NodeGen; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.ObjectInitializationInCachedValueNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.ReplaceThisNoCacheNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.ReplaceThisNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.SharedDefaultInlinedNodeNodeGen; @@ -977,12 +978,52 @@ protected Object twoArgs(Object arg0) { } + public abstract static class ObjectInitializationInCachedValue extends Node { + abstract boolean execute(Object obj1); + + static final class Cache { + public /* not final! */ Integer value; + + public boolean guard(int other) { + return value.intValue() == other; + } + } + + static Cache getCache(int val) { + Cache c = new Cache(); + c.value = val; + return c; + } + + @Specialization(guards = "value == 0") + static boolean doItInt(int value, + @Cached(value = "getCache(value)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return value >= 0; + } + + @Specialization(guards = "value == 1") + static boolean doItWithGuard(int value, + @Cached(value = "getCache(value)", neverDefault = false) Cache cache) { + assertNotNull(cache.value); + return value >= 0; + } + + } + + @Test + public void testObjectInitializationInCachedValue() throws InterruptedException { + assertInParallel(ObjectInitializationInCachedValueNodeGen::create, (node, threadIndex, objectIndex) -> { + node.execute(threadIndex % 2); + }); + } + static final int NODES = 10; static final int THREADS = 10; private void assertInParallel(Supplier nodeFactory, ParallelObjectConsumer assertions) throws InterruptedException { final int threads = THREADS; - final int threadPools = 2; + final int threadPools = 4; final int iterations = 1000; /* * We create multiple nodes and run the assertions in a loop to avoid implicit diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 48af6ae8768e..34806f8970d8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -753,7 +753,8 @@ public static boolean useSpecializationClass(SpecializationData specialization) /* * For specializations that bind cached values in guards that use instance fields we * need to use specialization classes because the duplication check is not reliable - * otherwise. + * otherwise. E.g. NeverDefaultTest#testSingleInstancePrimitiveCacheNode fails + * without this check. */ return true; } @@ -6344,6 +6345,31 @@ private Collection persistCache(FrameState frameState, SpecializationD frameState.setBoolean(frameStateInitialized, true); } + CodeTree storeFence = null; + + /* + * Make sure cached values are initialized before publishing it to other threads. + * + * This is needed for non-final fields in the cached value to be guaranteed to be + * initialized. + * + * We can avoid the storeStore fence if there is a duplication check performed. With a + * duplication check there is an implicit storeStore fence with the volatile write to + * publish the specialization class. + * + * With a specialization class that is not bound in guards we have an explicit storeStore + * fence already, so we do not do it for each cache. + */ + if (!ElementUtils.isPrimitive(cache.getParameter().getType()) && // + !needsDuplicationCheck(specialization) && // + !useSpecializationClass(specialization)) { + CodeTreeBuilder storeFenceBuilder = CodeTreeBuilder.createBuilder(); + storeFenceBuilder.startStatement(); + storeFenceBuilder.startStaticCall(context.getType(VarHandle.class), "storeStoreFence").end(); + storeFenceBuilder.end(); + storeFence = storeFenceBuilder.build(); + } + CodeTreeBuilder builder = new CodeTreeBuilder(null); value = createInsertNode(frameState, specialization, cache, value); @@ -6370,6 +6396,9 @@ private Collection persistCache(FrameState frameState, SpecializationD builder.end(); builder.startStatement(); + if (storeFence != null) { + builder.tree(storeFence); + } builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); builder.end(); @@ -6397,6 +6426,9 @@ private Collection persistCache(FrameState frameState, SpecializationD checkSharedCacheNull(builder, localName, specialization, cache); } + if (storeFence != null) { + builder.tree(storeFence); + } builder.startStatement(); builder.tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))); builder.end(); @@ -6433,6 +6465,9 @@ private Collection persistCache(FrameState frameState, SpecializationD } builder.end(); + if (storeFence != null) { + builder.tree(storeFence); + } builder.startStatement().tree(createCacheAccess(frameState, specialization, cache, CodeTreeBuilder.singleString(localName))).end(); } else { throw new AssertionError(); @@ -6440,6 +6475,9 @@ private Collection persistCache(FrameState frameState, SpecializationD setCacheInitialized(frameState, specialization, cache, true); } else { + if (storeFence != null) { + builder.tree(storeFence); + } builder.startStatement().tree(createCacheAccess(frameState, specialization, cache, value)).end(); } From 630d390032ec5a3feeed5f0144d2b1582684a7ab Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 17:49:50 +0100 Subject: [PATCH 279/312] Clear all caches and specialization classes when replaced. --- .../api/dsl/test/NeverDefaultTest.java | 121 ++++++++++++++++-- .../generator/FlatNodeGenFactory.java | 51 ++++++++ 2 files changed, 162 insertions(+), 10 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java index 9d21758098f9..d4cc6e402d3f 100644 --- a/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java +++ b/truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NeverDefaultTest.java @@ -43,8 +43,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.lang.reflect.Field; import java.util.List; import java.util.function.Supplier; @@ -63,6 +65,7 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.test.CachedReachableFallbackTest.GuardNode; +import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.CacheCleanupNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.CachedGuardAndFallbackNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.FallbackManyCachesNodeGen; import com.oracle.truffle.api.dsl.test.NeverDefaultTestFactory.FallbackWithCacheClassNodeGen; @@ -93,6 +96,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.ControlFlowException; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.test.ReflectionUtils; import com.oracle.truffle.api.test.polyglot.AbstractPolyglotTest; /** @@ -981,14 +985,6 @@ protected Object twoArgs(Object arg0) { public abstract static class ObjectInitializationInCachedValue extends Node { abstract boolean execute(Object obj1); - static final class Cache { - public /* not final! */ Integer value; - - public boolean guard(int other) { - return value.intValue() == other; - } - } - static Cache getCache(int val) { Cache c = new Cache(); c.value = val; @@ -996,14 +992,14 @@ static Cache getCache(int val) { } @Specialization(guards = "value == 0") - static boolean doItInt(int value, + static boolean s0(int value, @Cached(value = "getCache(value)", neverDefault = true) Cache cache) { assertNotNull(cache.value); return value >= 0; } @Specialization(guards = "value == 1") - static boolean doItWithGuard(int value, + static boolean s1(int value, @Cached(value = "getCache(value)", neverDefault = false) Cache cache) { assertNotNull(cache.value); return value >= 0; @@ -1018,6 +1014,111 @@ public void testObjectInitializationInCachedValue() throws InterruptedException }); } + static final class Cache { + public /* not final! */ Integer value; + + public boolean guard(int other) { + return value.intValue() == other; + } + } + + public abstract static class CacheCleanupNode extends Node { + abstract boolean execute(int v); + + static Cache getCache(int v) { + Cache c = new Cache(); + c.value = v; + return c; + } + + @Specialization(guards = "v == 0") + static boolean s0(int v, + @Cached(value = "getCache(v)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 1") + static boolean s1(int v, + @Cached(value = "getCache(v)", neverDefault = false) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 2") + static boolean s2(int v, + @Shared("cacheDefault") @Cached(value = "getCache(2)", neverDefault = false) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 3") + static boolean s3(int v, + @Shared("cacheDefault") @Cached(value = "getCache(2)", neverDefault = false) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 4") + static boolean s4(int v, + @Shared("cacheNeverDefault") @Cached(value = "getCache(3)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 5") + static boolean s5(int v, + @Shared("cacheNeverDefault") @Cached(value = "getCache(3)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 6") + static boolean s6(int v, + @Shared("cacheSharedNonReplaced") @Cached(value = "getCache(3)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + @Specialization(guards = "v == 7") + static boolean s7(int v, + @Shared("cacheSharedNonReplaced") @Cached(value = "getCache(3)", neverDefault = true) Cache cache) { + assertNotNull(cache.value); + return v >= 0; + } + + /* + * Deliberately not replacing s7 to test that shared are not cleaned in that case. + */ + @Specialization(guards = "v == 8", replaces = {"s0", "s1", "s2", "s3", "s4", "s5", "s6"}) + static boolean s8(int v) { + return v >= 0; + } + + } + + @Test + public void testCacheCleanupNode() throws IllegalArgumentException, IllegalAccessException { + CacheCleanupNode node = CacheCleanupNodeGen.create(); + for (int i = 0; i < 9; i++) { + node.execute(i); + } + + int fieldCount = 0; + for (Field f : node.getClass().getDeclaredFields()) { + ReflectionUtils.setAccessible(f, true); + if (f.getType() != int.class) { + fieldCount++; + if (f.getName().equals("cacheSharedNonReplaced")) { + assertNotNull(f.get(node)); + } else { + assertNull(f.get(node)); + } + } + } + assertEquals(5, fieldCount); + } + static final int NODES = 10; static final int THREADS = 10; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 34806f8970d8..91a1b417cf1e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -5600,11 +5600,44 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, } if (!excludesSpecializations.isEmpty()) { + Set clearedGroups = new HashSet<>(); + for (SpecializationData excludes : excludesSpecializations) { if (useSpecializationClass(excludes)) { builder.startStatement(); builder.tree(createSpecializationFieldAccess(frameState, excludes, true, true, null, CodeTreeBuilder.singleString("null"))); builder.end(); + } else { + for (CacheExpression cache : excludes.getCaches()) { + if (cache.isEncodedEnum()) { + // encoded enums do not need to be cleared + continue; + } else if (cache.getInlinedNode() != null) { + // inlined nodes do not need to be clared + continue; + } else if (cache.isAlwaysInitialized()) { + continue; + } else if (cache.isMergedLibrary()) { + continue; + } else if (ElementUtils.isPrimitive(cache.getParameter().getType())) { + // no need to clear primitives + continue; + } + String sharedGroup = cache.getSharedGroup(); + if (sharedGroup != null) { + if (clearedGroups.contains(sharedGroup)) { + continue; + } + clearedGroups.add(sharedGroup); + if (!isSharedExclusivelyIn(sharedGroup, excludesSpecializations)) { + // do not clear a cache if other specializations use it. + continue; + } + } + builder.startStatement(); + builder.tree(createSpecializationFieldAccess(frameState, excludes, true, true, createFieldName(excludes, cache), CodeTreeBuilder.singleString("null"))); + builder.end(); + } } } builder.tree((multiState.createSet(frameState, transaction, StateQuery.create(SpecializationActive.class, excludesSpecializations), false, false))); @@ -5613,6 +5646,24 @@ private CodeTree createSpecialize(CodeTreeBuilder parent, FrameState frameState, return builder.build(); } + private boolean isSharedExclusivelyIn(String sharedKey, List specializations) { + Set specializationSet = new HashSet<>(specializations); + for (NodeData n : sharingNodes) { + for (SpecializationData otherSpecialization : n.getReachableSpecializations()) { + if (specializationSet.contains(otherSpecialization)) { + // only interested in other specializations + continue; + } + for (CacheExpression cache : otherSpecialization.getCaches()) { + if (cache.getSharedGroup() != null && cache.getSharedGroup().equals(sharedKey)) { + return false; + } + } + } + } + return true; + } + private List persistAssumptions(FrameState frameState, SpecializationData specialization) { List triples = new ArrayList<>(); for (AssumptionExpression assumption : specialization.getAssumptionExpressions()) { From da608fd3db8250ef2fb658b5d17470578cb72aa5 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 6 Jan 2023 18:04:49 +0100 Subject: [PATCH 280/312] Update overlay. --- graal-common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graal-common.json b/graal-common.json index 970246a81f4e..675eb0d550dd 100644 --- a/graal-common.json +++ b/graal-common.json @@ -1,6 +1,6 @@ { "README": "This file contains definitions that are useful for the jsonnet CI files of the graal and graal-enterprise repositories.", "ci": { - "overlay": "8c61a7696bd278b4d22f1f03d87f7cdf32b919dc" + "overlay": "5dd42b605ba7fbb89718788d4bb1de49ebee85c9" } } From 4ac9f6234993529002d8b4d495cd53081e2145ef Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Sun, 8 Jan 2023 17:26:48 +0100 Subject: [PATCH 281/312] Revert "Fix always pass down -ea for tck runs." This reverts commit 673e78ae124f7d171858fa01e60c17c8f5d2db14. --- truffle/mx.truffle/tck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/mx.truffle/tck.py b/truffle/mx.truffle/tck.py index c7da97cee8b9..e061fd4c8508 100644 --- a/truffle/mx.truffle/tck.py +++ b/truffle/mx.truffle/tck.py @@ -325,7 +325,7 @@ def execute_tck(graalvm_home, mode=Mode.default(), language_filter=None, values_ # On JDK9+ this does not work as one of the dependencies is Graal SDK which is in Java module org.graalvm.sdk, so instead # we patch the org.graalvm.sdk module to include the truffle-tck-common.jar and also its other dependency polyglot-tck.jar. # GR-35018 was filed to resolve this inconvenience. - additional_vm_arguments = ['-ea'] + additional_vm_arguments = [] jarsToPatch = [] for jarPath in cp: if 'polyglot-tck.jar' in jarPath: From ad0541cfe595ec8c2c8edb7c4a0b24f2af6cd377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 9 Jan 2023 14:51:16 +0100 Subject: [PATCH 282/312] [wip] Fixing BE & scope checking --- .../test/example/BoxingOperationsTest.java | 46 ++-- .../generator/FlatNodeGenFactory.java | 13 +- .../generator/NodeGeneratorPlugs.java | 4 + .../generator/TypeSystemCodeGenerator.java | 6 +- .../OperationNodeGeneratorPlugs.java | 39 ++- .../generator/OperationsNodeFactory.java | 255 +++++++++++------- .../operations/model/OperationsModel.java | 7 +- 7 files changed, 244 insertions(+), 126 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java index 600dd8857baa..f5d4d1422a72 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java @@ -67,7 +67,7 @@ public class BoxingOperationsTest { private static final BoxingLanguage LANGUAGE = null; - private static final int NUM_ITERATIONS = 10_000; + private static final int NUM_ITERATIONS = 10; private static BoxingOperations parse(OperationParser parser) { OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser); @@ -78,8 +78,8 @@ private static BoxingOperations parse(OperationParser { b.beginRoot(LANGUAGE); @@ -196,9 +196,10 @@ public void testCastsChangePrim() { for (int i = 0; i < NUM_ITERATIONS; i++) { Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_INT)); } - for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_B)); - } + // for (int i = 0; i < NUM_ITERATIONS; i++) { + // Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, + // callTarget.call(ObjectProducer.PRODUCE_REF_B)); + // } try { callTarget.call(ObjectProducer.PRODUCE_BOOLEAN); Assert.fail(); @@ -265,9 +266,10 @@ public void testCastsChangeSpecPrim() { Assert.assertEquals(BoxingTypeSystem.INT_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_INT)); } - for (int i = 0; i < NUM_ITERATIONS; i++) { - Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, callTarget.call(ObjectProducer.PRODUCE_REF_B)); - } + // for (int i = 0; i < NUM_ITERATIONS; i++) { + // Assert.assertEquals(BoxingTypeSystem.REF_B_AS_LONG_VALUE, + // callTarget.call(ObjectProducer.PRODUCE_REF_B)); + // } try { callTarget.call(ObjectProducer.PRODUCE_BOOLEAN); @@ -386,20 +388,32 @@ static long castLong(int i) { return INT_AS_LONG_VALUE; } - @ImplicitCast - static long castLong(ReferenceTypeB b) { - return REF_B_AS_LONG_VALUE; - } +// @ImplicitCast +// static long castLong(ReferenceTypeB b) { +// return REF_B_AS_LONG_VALUE; +// } } @GenerateOperations(// languageClass = BoxingLanguage.class, // boxingEliminationTypes = {boolean.class, int.class, long.class}) +@TypeSystemReference(BoxingTypeSystem.class) @SuppressWarnings("unused") abstract class BoxingOperations extends RootNode implements OperationRootNode { - static final boolean __magic_LogInvalidations = false; - int __magic_CountInvalidations = 0; + private static final boolean LOG = true; + int totalInvalidations = 0; + + protected void transferToInterpreterAndInvalidate() { + this.totalInvalidations++; + if (LOG) { + System.err.println("[INVAL] --------------------"); + StackWalker.getInstance().forEach(sf -> { + System.err.println(" " + sf); + }); + } + CompilerDirectives.transferToInterpreterAndInvalidate(); + } protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) { super(language, frameDescriptor.build()); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 26043d46469d..5225b901995b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -40,7 +40,6 @@ */ package com.oracle.truffle.dsl.processor.generator; -import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; import static com.oracle.truffle.dsl.processor.java.ElementUtils.boxType; import static com.oracle.truffle.dsl.processor.java.ElementUtils.executableEquals; import static com.oracle.truffle.dsl.processor.java.ElementUtils.findAnnotationMirror; @@ -1974,7 +1973,7 @@ private ExecuteDelegationResult createExecuteDelegation(CodeTreeBuilder parent, builder.startTryBlock(); builder.tree(delegateBuilder.build()); builder.end().startCatchBlock(types.UnexpectedResultException, "ex"); - builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(plugs.createTransferToInterpreterAndInvalidate()); if (isVoid(type.getReturnType())) { builder.returnStatement(); @@ -2443,7 +2442,7 @@ private CodeTree executeFastPathGroup(final CodeTreeBuilder parent, FrameState f builder.tree(visitSpecializationGroup(builder, null, group, currentType, frameState, allowedSpecializations)); if (group.hasFallthrough()) { - builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(plugs.createTransferToInterpreterAndInvalidate()); builder.tree(createCallExecuteAndSpecialize(currentType, originalFrameState)); } generateTraceOnExceptionEnd(builder); @@ -2627,7 +2626,7 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt builder.end(); if (executeChild.throwsUnexpectedResult) { builder.startCatchBlock(types.UnexpectedResultException, "ex"); - builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(plugs.createTransferToInterpreterAndInvalidate()); FrameState slowPathFrameState = originalFrameState.copy(); slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(CodeTreeBuilder.singleString("ex.getResult()"))); @@ -2960,7 +2959,7 @@ static CodeVariableElement createNodeField(Modifier visibility, TypeMirror type, return childField; } - private CodeTree callMethod(FrameState frameState, CodeTree receiver, ExecutableElement method, CodeTree... boundValues) { + private static CodeTree callMethod(FrameState frameState, CodeTree receiver, ExecutableElement method, CodeTree... boundValues) { if (frameState != null) { frameState.addThrownExceptions(method); } @@ -3579,7 +3578,7 @@ private CodeTree visitSpecializationGroup(CodeTreeBuilder parent, Specialization if (specialization != null && !specialization.getAssumptionExpressions().isEmpty()) { BlockState state = IfTriple.materialize(builder, createAssumptionCheck(frameState, specialization, NodeExecutionMode.FAST_PATH, false), false); - builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(plugs.createTransferToInterpreterAndInvalidate()); builder.tree(createRemoveThis(builder, frameState, forType, specialization)); builder.end(state.blockCount); } @@ -4416,7 +4415,7 @@ private CodeTree createCatchRewriteException(CodeTreeBuilder parent, Specializat exceptionTypes[i] = type; } builder.end().startCatchBlock(exceptionTypes, "ex"); - builder.tree(createTransferToInterpreterAndInvalidate()); + builder.tree(plugs.createTransferToInterpreterAndInvalidate()); builder.tree(createExcludeThis(builder, frameState, forType, specialization)); builder.end(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java index bb4d48b010fb..1f89d0add58d 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGeneratorPlugs.java @@ -70,4 +70,8 @@ default void createNodeChildReferenceForException(FlatNodeGenFactory flatNodeGen flatNodeGenFactory.createNodeChildReferenceForException(frameState, builder, values, execution, child, var); } + default CodeTree createTransferToInterpreterAndInvalidate() { + return GeneratorUtils.createTransferToInterpreterAndInvalidate(); + } + } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java index d2eb9bf244ef..8baed69959e8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @@ -106,7 +106,7 @@ static CodeTree implicitExpectFlat(TypeSystemData typeSystem, TypeMirror type, C return callImplictMethodFlat(typeSystem, type, expectImplicitTypeMethodName(typeSystem, type), value, state); } - static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, String content) { + public static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, String content) { return cast(typeSystem, type, CodeTreeBuilder.singleString(content)); } @@ -129,7 +129,7 @@ static CodeTree cast(TypeSystemData typeSystem, TypeMirror type, CodeTree conten return builder.build(); } - static CodeTree expect(TypeSystemData typeSystem, TypeMirror type, CodeTree content) { + public static CodeTree expect(TypeSystemData typeSystem, TypeMirror type, CodeTree content) { if (ElementUtils.isObject(type) || ElementUtils.isVoid(type)) { return content; } @@ -168,7 +168,7 @@ private static CodeTypeMirror createTypeSystemGen(TypeSystemData typeSystem) { return new GeneratedTypeMirror(ElementUtils.getPackageName(typeSystem.getTemplateType()), typeName(typeSystem)); } - private static CodeTree check(TypeSystemData typeSystem, TypeMirror type, String content) { + public static CodeTree check(TypeSystemData typeSystem, TypeMirror type, String content) { return check(typeSystem, type, CodeTreeBuilder.singleString(content)); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java index 3f996c7b1664..9eaf05dc6a58 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java @@ -27,12 +27,15 @@ public class OperationNodeGeneratorPlugs implements NodeGeneratorPlugs { private final TruffleTypes types; private final TypeMirror nodeType; private final InstructionModel instr; + private final boolean isBoxingOperations; public OperationNodeGeneratorPlugs(ProcessorContext context, TypeMirror nodeType, InstructionModel instr) { this.context = context; this.types = context.getTypes(); this.nodeType = nodeType; this.instr = instr; + + this.isBoxingOperations = nodeType.toString().endsWith("BoxingOperationsGen"); } public List additionalArguments() { @@ -69,19 +72,30 @@ private boolean buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx, slotString += " - this.op_variadicCount_"; } - if (ElementUtils.isObject(resultType)) { - b.startCall(frame, "getObject"); - b.string(slotString); - b.end(); - return false; - } else { - b.startCall("doPopPrimitive" + ElementUtils.firstLetterUpperCase(resultType.toString())); + boolean canThrow; + + if (instr.signature.valueBoxingElimination[index]) { + if (ElementUtils.isObject(resultType)) { + b.startCall("doPopObject"); + canThrow = false; + } else { + b.startCall("doPopPrimitive" + ElementUtils.firstLetterUpperCase(resultType.toString())); + canThrow = true; + } + b.tree(frame); + b.string("$root"); b.string(slotString); b.string("this.op_childValue" + index + "_boxing_"); b.string("$objs"); b.end(); - return true; + + return canThrow; + } else { + b.startCall(frame, "getObject"); + b.string(slotString); + b.end(); + return false; } } @@ -117,4 +131,13 @@ public void createNodeChildReferenceForException(FlatNodeGenFactory flatNodeGenF NodeChildData child, LocalVariable var) { builder.string("null"); } + + public CodeTree createTransferToInterpreterAndInvalidate() { + if (isBoxingOperations) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.statement("$root.transferToInterpreterAndInvalidate()"); + return b.build(); + } + return NodeGeneratorPlugs.super.createTransferToInterpreterAndInvalidate(); + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 847527a12f7d..401e08b6b42c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -43,7 +43,6 @@ import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createConstructorUsingFields; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createNeverPartOfCompilation; import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createShouldNotReachHere; -import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createTransferToInterpreterAndInvalidate; import static com.oracle.truffle.dsl.processor.java.ElementUtils.boxType; import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase; import static javax.lang.model.element.Modifier.ABSTRACT; @@ -383,7 +382,7 @@ private CodeExecutableElement createExecute() { b.startIf().string("(state & 0xffff) == 0xffff").end().startBlock(); b.statement("break"); b.end().startElseBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("this")); b.end(); b.end(); @@ -517,6 +516,7 @@ private CodeExecutableElement createReadVariadic() { private CodeExecutableElement createDoPopObject() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object.class), "doPopObject"); ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(operationNodeGen.asType(), "$this")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "boxing")); ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); @@ -527,7 +527,7 @@ private CodeExecutableElement createDoPopObject() { b.startReturn().string("frame.getObject(slot)").end(); b.end(); // } - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("$this")); b.statement("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) -1)"); b.startReturn().string("frame.getValue(slot)").end(); @@ -538,6 +538,7 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { String typeName = firstLetterUpperCase(resultType.toString()); CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), resultType, "doPopPrimitive" + typeName); ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame")); + ex.addParameter(new CodeVariableElement(operationNodeGen.asType(), "$this")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "slot")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "boxing")); ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); @@ -552,7 +553,8 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { b.startReturn().cast(resultType).string("result").end(); b.end().startElseBlock(); // } { - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("System.err.printf(\" [**] expected " + resultType + " but got %s %s [no BE]%n\", result == null ? \"null\" : result.getClass(), result)"); b.startThrow().startNew(types.UnexpectedResultException).string("result").end(2); b.end(); // } @@ -561,17 +563,21 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.startIf().string("frame.is" + typeName + "(slot)").end().startBlock(); b.startReturn().string("frame.get" + typeName + "(slot)").end(); b.end().startElseBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); + + b.tree(createTransferToInterpreterAndInvalidate("$this")); + + b.statement("Object result = frame.getValue(slot)"); + b.startStatement(); b.string("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) ").tree(boxingTypeToInt(resultType)).string(")"); b.end(); - b.statement("Object result = frame.getValue(slot)"); + b.statement("System.err.printf(\" [**] expected " + resultType + + " but got %s %s (%08x %s) [BE faul]%n\", result == null ? \"null\" : result.getClass(), result, boxing, objs[boxing & 0xffff].getClass())"); b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { b.startReturn().cast(resultType).string("result").end(); b.end().startElseBlock(); // } { - b.tree(createTransferToInterpreterAndInvalidate()); b.startThrow().startNew(types.UnexpectedResultException).string("result").end(2); b.end(); @@ -666,6 +672,8 @@ class BuilderFactory { CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState"); + // this is per-function state that needs to be stored/restored when going into/out of + // functions CodeVariableElement[] builderState = new CodeVariableElement[]{ new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "bci"), @@ -673,6 +681,7 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "operationData"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationChildCount"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "opSeqNumStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "operationSp"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "maxStack"), @@ -685,6 +694,7 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceIndexSp"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceLocationStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceLocationSp"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "opSeqNum"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceInfo"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceInfoIndex"), @@ -741,6 +751,7 @@ private CodeTypeElement create() { operationBuilder.add(createEmitInstruction()); operationBuilder.add(createdoEmitSourceInfo()); operationBuilder.add(createFinish()); + operationBuilder.add(createDoEmitLeaves()); return operationBuilder; } @@ -773,7 +784,17 @@ private CodeExecutableElement createCreateLabel() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationLabel, "createLabel"); CodeTreeBuilder b = ex.createBuilder(); - b.startReturn().startNew(operationLabelImpl.asType()).startNew(intRef.asType()).string("-1").end(3); + b.startIf().string( + "operationSp == 0 || (", + "operationStack[operationSp - 1] != " + model.blockOperation.id + " /* Block */ ", + " && operationStack[operationSp - 1] != " + model.rootOperation.id + " /* Root */)").end().startBlock(); + buildThrowIllegalStateException(b, "\"Labels must be created inside either Block or Root operations.\""); + b.end(); + + b.startReturn().startNew(operationLabelImpl.asType()); + b.startNew(intRef.asType()).string("-1").end(); + b.string("opSeqNumStack[operationSp - 1]"); + b.end(2); return ex; } @@ -788,7 +809,7 @@ private CodeVariableElement createOperationNames() { int i = 1; for (OperationModel op : model.getOperations()) { if (op.id != i) { - throw new AssertionError("e"); + throw new AssertionError(); } i++; @@ -826,11 +847,16 @@ private CodeExecutableElement createBeginHelper() { b.string("operationData"); b.string("operationData.length * 2"); b.end(2); + b.startAssign("opSeqNumStack").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("opSeqNumStack"); + b.string("opSeqNumStack.length * 2"); + b.end(2); b.end(); // } b.statement("operationStack[operationSp] = id"); b.statement("operationChildCount[operationSp] = 0"); - b.statement("operationData[operationSp++] = data"); + b.statement("operationData[operationSp] = data"); + b.statement("opSeqNumStack[operationSp++] = opSeqNum++"); return ex; } @@ -867,6 +893,8 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("operationStack = new int[8]"); b.statement("operationData = new Object[8]"); b.statement("operationChildCount = new int[8]"); + b.statement("opSeqNumStack = new int[8]"); + b.statement("opSeqNum = 0"); b.statement("operationSp = 0"); b.statement("numLocals = 0"); b.statement("curStack = 0"); @@ -941,6 +969,7 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("sourceLocationStack[sourceLocationSp++] = arg1"); b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp - 1], arg0, arg1)"); + break; } return ex; @@ -1229,13 +1258,40 @@ private CodeExecutableElement createEmit(OperationModel operation) { b.startStatement().startCall("beforeChild").end(2); b.startStatement().startCall("emitOperationBegin").end(2); - if (operation.kind == OperationKind.LABEL) { - // todo: scope check - b.startIf().string("((OperationLabelImpl) arg0).index.value != -1").end().startBlock(); - buildThrowIllegalStateException(b, "\"OperationLabel already emitted. Each label must be emitted exactly once.\""); - b.end(); + switch (operation.kind) { + case LABEL: + b.startAssign("OperationLabelImpl lbl").string("(OperationLabelImpl) arg0").end(); + + b.startIf().string("lbl.index.value != -1").end().startBlock(); + buildThrowIllegalStateException(b, "\"OperationLabel already emitted. Each label must be emitted exactly once.\""); + b.end(); + + b.startIf().string("lbl.declaringOp != opSeqNumStack[operationSp - 1]").end().startBlock(); + buildThrowIllegalStateException(b, "\"OperationLabel must be emitted inside the same operation it was created in.\""); + b.end(); + + b.statement("((OperationLabelImpl) arg0).index.value = bci"); + break; + case BRANCH: + b.startAssign("OperationLabelImpl lbl").string("(OperationLabelImpl) arg0").end(); + + b.statement("boolean isFound = false"); + b.startFor().string("int i = 0; i < operationSp; i++").end().startBlock(); + b.startIf().string("opSeqNumStack[i] == lbl.declaringOp").end().startBlock(); + b.statement("isFound = true"); + b.statement("break"); + b.end(); + b.end(); - b.statement("((OperationLabelImpl) arg0).index.value = bci"); + b.startIf().string("!isFound").end().startBlock(); + buildThrowIllegalStateException(b, "\"Branch must be targeting a label that is declared in an enclosing operation. Jumps into other operations are not permitted.\""); + b.end(); + + b.statement("doEmitLeave(lbl.declaringOp)"); + break; + case RETURN: + b.statement("doEmitLeave(-1)"); + break; } if (operation.instruction != null) { @@ -1626,6 +1682,32 @@ private CodeExecutableElement createdoEmitSourceInfo() { return ex; } + private CodeExecutableElement createDoEmitLeaves() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitLeaves"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "targetSeq")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startFor().string("int i = operationSp - 1; i >= 0; i++").end().startBlock(); + + b.startIf().string("opSeqNumStack[i] == targetSeq").end().startBlock(); + b.returnStatement(); + b.end(); + + b.startSwitch().string("operationStack[i]").end().startBlock(); + + for (OperationModel op : model.getOperations()) { + switch (op.kind) { + } + } + + b.end(); + + b.end(); + + return ex; + } + private CodeExecutableElement createConstructor() { CodeExecutableElement ctor = new CodeExecutableElement(Set.of(PRIVATE), null, "Builder"); ctor.addParameter(new CodeVariableElement(operationNodes.asType(), "nodes")); @@ -1782,7 +1864,7 @@ private CodeExecutableElement createContinueAt() { b.startIf().string("nextBci <= bci").end().startBlock(); b.startIf().string("uncachedExecuteCount-- <= 0").end().startBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("$this")); b.statement("$this.changeInterpreters(CACHED_INTERPRETER)"); b.statement("return (sp << 16) | nextBci"); b.end(); @@ -1855,8 +1937,8 @@ private CodeExecutableElement createContinueAt() { b.startCase().string("0").end().startCaseBlock(); // uninitialized - b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, true)"); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, true)"); b.statement("break"); b.end(); @@ -1865,8 +1947,10 @@ private CodeExecutableElement createContinueAt() { b.startIf().string("frame.isObject(curIndex)").end().startBlock(); b.statement("frame.copyObject(curIndex, sp)"); b.end().startElseBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("frame.setObject(sp, frame.getValue(curIndex))"); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("Object value = frame.getValue(curIndex)"); + b.statement("frame.setObject(curIndex, value)"); + b.statement("frame.setObject(sp, value)"); b.end(); b.statement("break"); b.end(); @@ -1878,8 +1962,8 @@ private CodeExecutableElement createContinueAt() { b.startIf().string("frame.is" + frameName + "(curIndex)").end().startBlock(); b.statement("frame.copyPrimitive(curIndex, sp)"); b.end().startElseBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, false)"); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, false)"); b.end(); b.statement("break"); b.end(); @@ -1888,8 +1972,8 @@ private CodeExecutableElement createContinueAt() { b.startIf().string("frame.is" + frameName + "(curIndex)").end().startBlock(); b.statement("frame.setObject(sp, frame.get" + frameName + "(curIndex))"); b.end().startElseBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, false)"); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, false)"); b.end(); b.statement("break"); b.end(); @@ -1914,7 +1998,7 @@ private CodeExecutableElement createContinueAt() { case RETURN: if (isUncached) { b.startIf().string("uncachedExecuteCount-- <= 0").end().startBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("$this")); b.statement("$this.changeInterpreters(CACHED_INTERPRETER)"); b.end().startElseBlock(); b.statement("$this.uncachedExecuteCount = uncachedExecuteCount"); @@ -1935,13 +2019,13 @@ private CodeExecutableElement createContinueAt() { b.startSwitch().string("localBoxingState[curIndex]").end().startBlock(); b.startCase().string("0").end().startBlock(); - b.tree(createTransferToInterpreterAndInvalidate()); + b.tree(createTransferToInterpreterAndInvalidate("$this")); b.statement("doStoreLocalInitialize(frame, sp, localBoxingState, curIndex)"); b.statement("break"); b.end(); b.startCase().string("-1").end().startBlock(); - b.statement("frame.setObject(curIndex, doPopObject(frame, sp - 1, curData.s_childIndex, objs))"); + b.statement("frame.setObject(curIndex, doPopObject(frame, $this, sp - 1, curData.s_childIndex, objs))"); b.statement("break"); b.end(); @@ -1952,7 +2036,7 @@ private CodeExecutableElement createContinueAt() { b.startCase().tree(boxingTypeToInt(mir)).end().startBlock(); b.startTryBlock(); - b.statement("frame.set" + frameName + "(curIndex, doPopPrimitive" + frameName + "(frame, sp - 1, curData.s_childIndex, objs))"); + b.statement("frame.set" + frameName + "(curIndex, doPopPrimitive" + frameName + "(frame, $this, sp - 1, curData.s_childIndex, objs))"); b.end().startCatchBlock(types.UnexpectedResultException, "ex"); b.statement("localBoxingState[curIndex] = -1"); b.statement("frame.setObject(curIndex, ex.getResult())"); @@ -2089,35 +2173,44 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i b.statement("break"); b.end(); - Set mirs = signature.possibleBoxingResults; - if (mirs == null) { - mirs = model.boxingEliminatedTypes; - } + for (TypeMirror mir : model.boxingEliminatedTypes) { + String frameName = firstLetterUpperCase(mir.toString()); - for (TypeMirror mir : mirs) { - if (ElementUtils.isObject(mir)) { - continue; - } + b.startCase().tree(boxingTypeToInt(mir)).end().startBlock(); - b.startCase().tree(boxingTypeToInt(mir)).end().startCaseBlock(); + if (signature.possibleBoxingResults != null && signature.possibleBoxingResults.contains(mir)) { + b.startTryBlock(); - b.startTryBlock(); - b.startStatement().startCall("frame.set" + firstLetterUpperCase(mir.toString())); - b.string("resultSp - 1"); - b.startCall("nObj.execute" + firstLetterUpperCase(mir.toString())); - b.string("frame").string(extraArguments); - b.end(3); + b.startStatement().startCall("frame.set" + frameName); + b.string("resultSp - 1"); + b.startCall("nObj.execute" + frameName); + b.string("frame").string(extraArguments); + b.end(3); - b.end().startCatchBlock(types.UnexpectedResultException, "ex"); + b.end().startCatchBlock(types.UnexpectedResultException, "ex"); - b.tree(createTransferToInterpreterAndInvalidate()); - b.statement("nObj.op_resultType_ = -1"); - b.statement("frame.setObject(resultSp - 1, ex.getResult())"); + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("nObj.op_resultType_ = -1"); + b.statement("frame.setObject(resultSp - 1, ex.getResult())"); - b.end(); + b.end(); + } else { + b.statement("Object result = nObj.executeObject(frame, " + extraArguments + ")"); - b.statement("break"); + b.startIf().string("result").instanceOf(boxType(mir)).end().startBlock(); + + b.statement("frame.set" + frameName + "(resultSp - 1, (" + mir + ") result)"); + + b.end().startElseBlock(); + + b.tree(createTransferToInterpreterAndInvalidate("$this")); + b.statement("nObj.op_resultType_ = -1"); + b.statement("frame.setObject(resultSp - 1, result)"); + + b.end(); + } + b.statement("break"); b.end(); } @@ -2152,17 +2245,24 @@ private CodeExecutableElement createDoLoadLocalInitialize() { ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp")); ex.addParameter(new CodeVariableElement(loadLocalData.asType(), "curData")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "curIndex")); + ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localBoxingState")); ex.addParameter(new CodeVariableElement(context.getType(boolean.class), "prim")); CodeTreeBuilder b = ex.createBuilder(); b.statement("Object value = frame.getValue(curIndex)"); b.statement("frame.setObject(sp, value)"); - b.startIf().string("prim").end().startBlock(); + b.statement("byte lbs = localBoxingState[curIndex]"); + + b.startIf().string("prim && lbs != -1").end().startBlock(); for (TypeMirror mir : model.boxingEliminatedTypes) { - b.startIf().string("value").instanceOf(boxType(mir)).end().startBlock(); + String frameName = firstLetterUpperCase(mir.toString()); + + b.startIf().string("(lbs == 0 || lbs == ").tree(boxingTypeToInt(mir)).string(") && value").instanceOf(boxType(mir)).end().startBlock(); b.startAssign("curData.v_kind").tree(boxingTypeToInt(mir)).string(" | 0x40 /* (boxed) */").end(); + b.statement("frame.set" + frameName + "(curIndex, (" + mir + ") value)"); + b.startAssign("localBoxingState[curIndex]").tree(boxingTypeToInt(mir)).end(); b.returnStatement(); b.end(); } @@ -2170,6 +2270,8 @@ private CodeExecutableElement createDoLoadLocalInitialize() { b.end(); b.startAssign("curData.v_kind").string("-1").end(); + b.statement("frame.setObject(curIndex, value)"); + b.statement("localBoxingState[curIndex] = -1"); return ex; } @@ -2223,6 +2325,7 @@ private CodeTypeElement create() { operationLabelImpl.setEnclosingElement(operationNodeGen); operationLabelImpl.add(new CodeVariableElement(intRef.asType(), "index")); + operationLabelImpl.add(new CodeVariableElement(context.getType(int.class), "declaringOp")); operationLabelImpl.add(createConstructorUsingFields(Set.of(), operationLabelImpl, null)); @@ -2260,20 +2363,9 @@ private CodeTypeElement create() { private CodeExecutableElement createSetBoxing() { CodeExecutableElement ex = GeneratorUtils.overrideImplement((DeclaredType) boxableInterface.asType(), "setBoxing"); CodeTreeBuilder b = ex.createBuilder(); - b.tree(createNeverPartOfCompilation()); - b.startAssert().string("index == 0").end(); - - b.startIf().string("v_kind == kind || v_kind == -1").end().startBlock(); - b.returnStatement(); - b.end(); - - b.startIf().string("v_kind == 0").end().startBlock(); b.statement("v_kind = kind"); - b.end(); - - b.statement("v_kind = -1"); return ex; } } @@ -2351,34 +2443,7 @@ private CodeExecutableElement creatSetBoxing(InstructionModel instr) { b.tree(createNeverPartOfCompilation()); b.startAssert().string("index == 0").end(); - - b.startIf().string("this.op_resultType_ == kind").end().startBlock(); - b.returnStatement(); - b.end(); - - b.startIf().string("this.op_resultType_ == 0 && ("); - Set mirs = instr.signature.possibleBoxingResults; - if (mirs == null) { - mirs = model.boxingEliminatedTypes; - } - boolean first = true; - for (TypeMirror mir : mirs) { - if (!ElementUtils.isPrimitive(mir)) { - continue; - } - if (first) { - first = false; - } else { - b.string(" || "); - } - b.string("kind == ").tree(boxingTypeToInt(mir)); - } - b.string(")").end().startBlock(); b.statement("this.op_resultType_ = kind"); - b.returnStatement(); - b.end(); - - b.statement("this.op_resultType_ = -1"); return setBoxing; } } @@ -2426,4 +2491,14 @@ private CodeVariableElement compFinal(int dims, CodeVariableElement fld) { fld.addAnnotationMirror(mir); return fld; } + + private CodeTree createTransferToInterpreterAndInvalidate(String root) { + if (model.templateType.getSimpleName().toString().equals("BoxingOperations")) { + CodeTreeBuilder b = CodeTreeBuilder.createBuilder(); + b.statement(root + ".transferToInterpreterAndInvalidate()"); + return b.build(); + } else { + return GeneratorUtils.createTransferToInterpreterAndInvalidate(); + } + } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index e54d49ded504..ea6dc547cf39 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -92,6 +92,9 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot public TypeSystemData typeSystem; public Set boxingEliminatedTypes; + public OperationModel blockOperation; + public OperationModel rootOperation; + public InstructionModel popInstruction; public InstructionModel branchInstruction; public InstructionModel branchFalseInstruction; @@ -102,11 +105,11 @@ public void addDefault() { branchInstruction = instruction(InstructionKind.BRANCH, "branch"); branchFalseInstruction = instruction(InstructionKind.BRANCH_FALSE, "branch.false"); - operation(OperationKind.BLOCK, "Block") // + blockOperation = operation(OperationKind.BLOCK, "Block") // .setTransparent(true) // .setVariadic(0) // .setChildrenMustBeValues(false); - operation(OperationKind.ROOT, "Root") // + rootOperation = operation(OperationKind.ROOT, "Root") // .setVariadic(0) // .setVoid(true) // .setChildrenMustBeValues(false) // From c48e0ad4731af77fb0102f3ec5f4688c92b0da9a Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 9 Jan 2023 18:29:45 +0100 Subject: [PATCH 283/312] Fix missing license header. --- .../OperationNodeGeneratorPlugs.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java index 9eaf05dc6a58..ccd836abb957 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java @@ -1,3 +1,43 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package com.oracle.truffle.dsl.processor.operations.generator; import java.util.List; From 912e1ca7d7ee0ce0b466aba0e0eb53920e05ce34 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Mon, 9 Jan 2023 18:31:07 +0100 Subject: [PATCH 284/312] Fix formatting. --- .../SimpleLanguageOperationsBaseVisitor.java | 488 +++++++++++------- .../SimpleLanguageOperationsVisitor.java | 359 +++++++------ 2 files changed, 518 insertions(+), 329 deletions(-) diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java index 77a03c4d3613..80caa0248638 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsBaseVisitor.java @@ -6,180 +6,322 @@ import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** - * This class provides an empty implementation of {@link SimpleLanguageOperationsVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. + * This class provides an empty implementation of {@link SimpleLanguageOperationsVisitor}, which can + * be extended to create a visitor which only needs to handle a subset of the available methods. * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. + * @param The return type of the visit operation. Use {@link Void} for operations with no return + * type. */ public class SimpleLanguageOperationsBaseVisitor extends AbstractParseTreeVisitor implements SimpleLanguageOperationsVisitor { - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitTerm(SimpleLanguageOperationsParser.TermContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

    The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

    - */ - @Override public T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitTerm(SimpleLanguageOperationsParser.TermContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

    + * The default implementation returns the result of calling {@link #visitChildren} on + * {@code ctx}. + *

    + */ + @Override + public T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx) { + return visitChildren(ctx); + } } \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java index 7b8d3543ea25..5a04731f1e8e 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguageOperationsVisitor.java @@ -6,163 +6,210 @@ import org.antlr.v4.runtime.tree.ParseTreeVisitor; /** - * This interface defines a complete generic visitor for a parse tree produced - * by {@link SimpleLanguageOperationsParser}. + * This interface defines a complete generic visitor for a parse tree produced by + * {@link SimpleLanguageOperationsParser}. * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. + * @param The return type of the visit operation. Use {@link Void} for operations with no return + * type. */ public interface SimpleLanguageOperationsVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#simplelanguage}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#function}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#block}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#break_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#continue_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#debugger_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#while_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#if_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#return_statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_term}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_factor}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#arithmetic}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx); - /** - * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#term}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTerm(SimpleLanguageOperationsParser.TermContext ctx); - /** - * Visit a parse tree produced by the {@code NameAccess} - * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx); - /** - * Visit a parse tree produced by the {@code StringLiteral} - * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code NumericLiteral} - * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code ParenExpression} - * labeled alternative in {@link SimpleLanguageOperationsParser#factor}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code MemberCall} - * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx); - /** - * Visit a parse tree produced by the {@code MemberAssign} - * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx); - /** - * Visit a parse tree produced by the {@code MemberField} - * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx); - /** - * Visit a parse tree produced by the {@code MemberIndex} - * labeled alternative in {@link SimpleLanguageOperationsParser#member_expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx); + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#simplelanguage}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimplelanguage(SimpleLanguageOperationsParser.SimplelanguageContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#function}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction(SimpleLanguageOperationsParser.FunctionContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#block}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(SimpleLanguageOperationsParser.BlockContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(SimpleLanguageOperationsParser.StatementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#break_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitBreak_statement(SimpleLanguageOperationsParser.Break_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#continue_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitContinue_statement(SimpleLanguageOperationsParser.Continue_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression_statement(SimpleLanguageOperationsParser.Expression_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#debugger_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitDebugger_statement(SimpleLanguageOperationsParser.Debugger_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#while_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhile_statement(SimpleLanguageOperationsParser.While_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#if_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitIf_statement(SimpleLanguageOperationsParser.If_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#return_statement}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturn_statement(SimpleLanguageOperationsParser.Return_statementContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#expression}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(SimpleLanguageOperationsParser.ExpressionContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_term}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogic_term(SimpleLanguageOperationsParser.Logic_termContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#logic_factor}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogic_factor(SimpleLanguageOperationsParser.Logic_factorContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#arithmetic}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitArithmetic(SimpleLanguageOperationsParser.ArithmeticContext ctx); + + /** + * Visit a parse tree produced by {@link SimpleLanguageOperationsParser#term}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitTerm(SimpleLanguageOperationsParser.TermContext ctx); + + /** + * Visit a parse tree produced by the {@code NameAccess} labeled alternative in + * {@link SimpleLanguageOperationsParser#factor}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitNameAccess(SimpleLanguageOperationsParser.NameAccessContext ctx); + + /** + * Visit a parse tree produced by the {@code StringLiteral} labeled alternative in + * {@link SimpleLanguageOperationsParser#factor}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitStringLiteral(SimpleLanguageOperationsParser.StringLiteralContext ctx); + + /** + * Visit a parse tree produced by the {@code NumericLiteral} labeled alternative in + * {@link SimpleLanguageOperationsParser#factor}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitNumericLiteral(SimpleLanguageOperationsParser.NumericLiteralContext ctx); + + /** + * Visit a parse tree produced by the {@code ParenExpression} labeled alternative in + * {@link SimpleLanguageOperationsParser#factor}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitParenExpression(SimpleLanguageOperationsParser.ParenExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code MemberCall} labeled alternative in + * {@link SimpleLanguageOperationsParser#member_expression}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberCall(SimpleLanguageOperationsParser.MemberCallContext ctx); + + /** + * Visit a parse tree produced by the {@code MemberAssign} labeled alternative in + * {@link SimpleLanguageOperationsParser#member_expression}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberAssign(SimpleLanguageOperationsParser.MemberAssignContext ctx); + + /** + * Visit a parse tree produced by the {@code MemberField} labeled alternative in + * {@link SimpleLanguageOperationsParser#member_expression}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberField(SimpleLanguageOperationsParser.MemberFieldContext ctx); + + /** + * Visit a parse tree produced by the {@code MemberIndex} labeled alternative in + * {@link SimpleLanguageOperationsParser#member_expression}. + * + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberIndex(SimpleLanguageOperationsParser.MemberIndexContext ctx); } \ No newline at end of file From 80e3fece3a6a2733436d5ac7f630f86b996784c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 10 Jan 2023 10:48:21 +0100 Subject: [PATCH 285/312] [wip] Fix typo --- .../processor/operations/generator/OperationsNodeFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 401e08b6b42c..f828311e2dcd 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -1287,7 +1287,7 @@ private CodeExecutableElement createEmit(OperationModel operation) { buildThrowIllegalStateException(b, "\"Branch must be targeting a label that is declared in an enclosing operation. Jumps into other operations are not permitted.\""); b.end(); - b.statement("doEmitLeave(lbl.declaringOp)"); + b.statement("doEmitLeaves(lbl.declaringOp)"); break; case RETURN: b.statement("doEmitLeave(-1)"); From fc529952890a1c577c29eb6734ceea973e016c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 11 Jan 2023 16:35:12 +0100 Subject: [PATCH 286/312] Add Operation DSL documentation --- truffle/docs/OperationDSL.md | 523 +++++++++++++++++++++++++++++++++++ 1 file changed, 523 insertions(+) create mode 100644 truffle/docs/OperationDSL.md diff --git a/truffle/docs/OperationDSL.md b/truffle/docs/OperationDSL.md new file mode 100644 index 000000000000..fa9f53a6df5f --- /dev/null +++ b/truffle/docs/OperationDSL.md @@ -0,0 +1,523 @@ +# Operation DSL + +Operation DSL is a DSL and runtime support component of Truffle that allows simpler implementation of bytecode-based interpreters in Truffle. Similarly to how Truffle DSL simplified the logic of node specialization by abstracting away the precondition checks into typechecks and guards, the main idea of Operation DSL is to simplify the creation of bytecode-based interpreters by abstracting away the bytecode format, control flow, etc. and leaving only the language-speciffic semantics up to the language to implement. + +[ bytecode vs AST pros and cons ] + +## What is an Operation? + +An operation in Operation DSL is an atomic unit of language semantics. Each operation can be executed, performing some operation, and optionally returning a value. The operations can then be nested together, to form the program. As an example, the following pseudocode +```python +if 1 == 2: + print("what") +``` +could be represented as an `if-then` operation, that has two nested "children": an `equals` operation, and a `call function` operation. The `equals` operation then has as children two `load constant` operations, with different constant values attributed to each. If we represent our operations as S-expressions, the program can be translated fully: +```lisp +(IfThen + (Equals + (LoadConstant 1) + (LoadConstant 2)) + (CallFunction + (LoadGlobal (LoadConstant "print")) + (LoadConstant "what"))) +``` + +Each of these operations can then be individually defined. For example, the `if-then` operation simply executes the first child, and if that returns true, executes the second child. + +## Built-in vs custom operations + +The operations in Operaiton DSL are divided into two groups: built-in and custom. Built-in operations come with the DSL itself, and their semantics cannot be changed. They model behaviour that is common accross languages, such as flow control (`IfThen`, `While`, ...), constants (`LoadConstant`) and local variable manipulation (`LoadLocal`, `StoreLocal`). Semantics of each operation are defined later. + +Custom operations are the ones that each language is responsible to implement. They are supposed to model language-speciffic behaviour, such as the semantics of operators, value conversions, calls, etc. In our previous example, `Equals`, `CallFunction` and `LoadGlobal` would be custom operations. Custom operations further come in two types: regular and short-circuiting. + +## Operation DSL walkthrough + +As an example on how to implement a Operation DSL language, we will use a simple example language that can only add integers and concatenate strings, using its singular operatior `+`. Some "code" examples, and their results are given below: + +``` +1 + 2 +=> 3 + +"a" + "b" +=> "ab" + +1 + "a" +=> throws exception +``` + +### Defining the Operations class + +The entry-point into Operation DSL is the `@GenerateOperations` annotation. This annotation must be attached to a subclass of `RootNode` and implementation of `OperationRootNode`, along with some other requirements: + +```java +@GenerateOperations +public abstract class ExampleOperationRootNode extends RootNode implements OperationRootNode { + // super-constructor ommitted +} +``` + +Inside this class, we can stard defining our custom operations. Each operation is structured similarly to a Truffle DSL Node, just it's not a Node subclass, and needs to have all its specializations `static`. In our example language, our addition could be expressed as the following operation: + +```java +// place inside ExampleOperationRootNode +@Operation +public static final class Add { + @Specialization + public static int doInt(int lhs, int rhs) { + return lhs + rhs; + } + + @Specialization + public static String doString(String lhs, String rhs) { + return lhs.toString() + rhs.toString(); + } + + // fallback omitted +} +``` + +Within operations, we can use most of the Truffle DSL, including `@Cached` and `@Bind` parameters, guards, specialization limits, etc. We cannot use features that require node instances, such as `@NodeChild`, `@NodeField`, nor any instance fields or methods. + +One limitation for custom operations is that they are restricted in terms of flow control. They can only model eager functions (exceptions are the short-circuiting operations). They cannot perform conditional execution, loops, etc. For those, we have to use the built-in operations, or "desugaring". + +From this simple description, the DSL will generate a `ExampleOperationRootNodeGen` class, that will contain the bytecode interpreter definition. + +### Converting our program into operations + +For this example, lets assume our program is in a parsed AST structure as follows: + +```java +class Expr { } +class AddExpr extends Expr { Expr left; Expr right; } +class IntExpr extends Expr { int value; } +class StringExpr extends Expr { String value; } +``` +Lets also assume there is a simple visitor pattern implemented over the AST. + +The process of converting your langauge's program structure to a OperationRootNode is referred to as "parsing". This is performed by invoking the functions on the `Builder` that correspond to the structure of your program when represented in terms of operations. For example, the program `1 + 2` can be expressed as operations `(Add (LoadConstant 1) (LoadConstant 2))` and thus expressed as the following sequence of builder calls: + +```java +b.beginAdd(); +b.emitLoadConstant(1); +b.emitLoadConstant(2); +b.endAdd(); +``` + +You can think of the `beginX` and `endX` as opening and closing `` and `` XML tags, while the `emitX` are the empty tag `` used when the operation does not take children (all operations have either the begin/end calls, or the emit call). + +We can then write our Visitor that will convert the AST structure into operations: + +```java +class ExprOperationVisitor implements ExprVisitor { + ExprOperationRootNodeGen.Builder b; + + public ExprOperationVisitor(ExprOperationRootNodeGen.Builder b) { + this.b = b; + } + + public void visitAdd(AddExpr ex) { + b.beginAdd(); + ex.left.accept(this); // visitor pattern `accept` + ex.right.accept(this); + b.endAdd(); + } + + public void visitInt(IntExpr ex) { + b.emitLoadConstant(ex.value); + } + + public void visitString(StringExpr ex) { + b.emitLoadConstant(ex.value); + } +} +``` + +Now, we can invoke the `ExprOperationRootNodeGen#create` function, which is the entry-point for parsing. It takes the `OperationConfig` which just defines what we want to parse (see "Reparsing"). + +The second argument is the parser itself. The parser is an implementation of the `OperationParser<>` functional interface that takes the builder instance, and is expected to perform the builder calls as explained above. It is required that the parser be deterministic, and always perform the same sequence of builder calls if called multiple times. The parser can be called multiple times, even after the `create` function returns, in order to support reparsing (see "Reparsing"). + +The result is the `OperationNodes<>` instance which acts as a wrapper, grouping together all the individual `OperationRootNode` instances, along with other shared information. The nodes can be extracted using the `getNodes()` method. + +We can pack this into the following function: + +```java +public static ExprOperationRootNode parseExample(ExampleLanguage language, Expr program) { + var nodes = ExprOperationRootNodeGen.create( + OperationConfig.DEFAULT, + builder -> { + // Root operation must enclose each function. It is further explained later. + builder.beginRoot(language); + + // Furthermore, our language returns the result of executing the expression, + // so we are wrapping it in a Return operation. + builder.beginReturn(); + + // Invoke the visitor + program.accept(new ExprOperationVisitor(builder)); + + // End the Return and Root operations + builder.endReturn(); + builder.endRoot(); + } + ); + + // Return the first and only Node. If there were multiple Root operations, each would result in one Node here. + return nodes.getNodes().get(0); +} +``` + +This method can then be invoked by the language runtime, to obtain the executable RootNode after parsing. + +## The Built-in operations explained + +In this section, all the built-in operations are explained. Each operation has its arity (how many child operations it must have), and if it returns a value as result. + +**Root** +* Arity: 0+ +* Returns value: N/A +* `begin` arguments: (TruffleLanguage) + +Each Root operation defines one function (i.e. a RootNode). All other operations must be enclosed inside a Root operation. The control flow must never reach the end of the Root operation. The `beginRoot` function takes the language instance as a parameter, which will be used when constructing the RootNode. The `endRoot` function returns the resulting RootNode instance, for use in e.g. nested functions. + +**Block** +* Arity: 0+ +* Returns value: Only if the last child returns a value itself. + +Block is a utility operation that executes all of its children in order, returning the result of the last child (if any). It can be used to group multiple operations together in order to count them as one child, both in value-returning, and non-value-returning contexts. It has a similar role to brace blocks `{ ... }` in Java, but with the addition that they can appear inside "expressions". + +**IfThen** +* Arity: 2 +* Returns value: no +* First child must return a value + +IfThen implements the `if (x) { y }` Java language construct. On execution, it evaluates the first child, and if it results in a `true`, it executes the second child. It does not return a result. Note that only Java booleans are accepted as results of the first operation, and all other values have undefined results. + +**IfThenElse** +* Arity: 3 +* Returns value: no +* First child must return a value + +IfThenElse implements the `if (x) { y } else { z }` Java language construct. On execution, it evaluates the first child, and if it results in `true` it executes the second child, otherwise it executes the third. No value is returned in either case. Note that only Java booleans are accepted as results of the first operation, and all other values have undefined results. + +**Conditional** +* Arity: 3 +* Returns value: yes +* All children must return a value + +Conditional implements the `x ? y : z` Java language construct. On execution, it evaluates the first child, and if it results in `true` it executes the second child and returns its result, otherwise it executes the third child and returns its result. Note that only Java booleans are accepted as results of the first operation, and all other values have undefined results. + +**While** +* Arity: 2 +* Returns value: no +* First child must return a value + +While implements the `while (x) { y }` Java language construct. On execution it evaluates the first child, and if that results in `true` it evaluates the second child and starts from the beginning. No value is returned as the result of the operation. Note that only Java booleans are accepted as results of the first operation, and all other values have undefined results. + +**Label** +* Arity: 0 +* Returns value: no +* `emit` arguments: (OperationLabel) + +Label operation defines the location referenced to by the passed label (see "Defining locals and labels"). It serves a smilar purpose to the label statement in C and similar languages. Each OperationLabel instance must be passed to a Label operation exactly once. The Label operation must be scoped directly inside the same operation the label is created in. + +**Branch** +* Arity: 0 +* Returns value: no (but N/A) +* `emit` arguments: (OperationLabel) + +Branch operation performs an unconditional branch to the passed label. It serves a similar purpose to a `goto` statement in C and similar languages. It is treated as not returning a value, but it does not conform to the regular control-flow rules. + +**LoadConstant** +* Arity: 0 +* Returns value: yes +* `emit` arguments: (Object) + +LoadConstant operation returns the runtime constant value that is provided as its build-time argument. The argument must be immutable, as the value may be shared. On execution, it returns the value provided. + +**LoadArgument** +* Arity: 0 +* Returns value: yes +* `emit` arguments: (int) + +LoadArgument returns the indexed argument from the arguments passed to current Truffle function. + +**LoadLocal** +* Arity: 0 +* Returns value: yes +* `emit` arguments: (OperationLocal) + +LoadLocal reads from the supplied local (see "Defining locals and labels") and returns the currently stored value. Reading from a local that has not been written to yet results in the frame default value being read (which by default is `null`). + +**StoreLocal** +* Arity: 1 +* Returns value: no +* `begin` arguments: (OperationLocal) + +StoreLocal executes its child operation, and stores the resulting value in the provided local. During the child execution, the previous value of the local is still available. + +**LoadLocalMaterialized** +* Arity: 1 +* Returns value: yes +* Child must return value +* `begin` arguments: (OperationLocal) + +LoadLocalMaterialized executes its first child, and then performs the similar operation to LoadLocal, except it reads the value from the frame instance that is the result of executing the child, instead from the current frame. This can be used to read locals from materialized frames, including from frames of enclosing functions (e.g. in nested functions / lambdas). + +**StoreLocalMaterialized** +* Arity: 2 +* Returns value: no +* All children must return values +* `begin` arguments: (OperationLocal) + +StoreLocalMaterialized executes its first and second child, and then performs the similar operation to StoreLocal, except it stores the result of the second child to the frame instance that is the result of the first child. This can be used to store locals to materialized frames, including to frames of enclosing functions (e.g. in nested functions / lambdas). + +**Return** +* Arity: 1 +* Returns value: yes (but N/A) +* Child must return value + +Return operation executes its child, and then returns from the currently executing function with that value as the result. It is treated as returning a value, but it does not conform to the regular control-flow rules. + +**Yield** +* Arity: 1 +* Returns value: yes +* Child must return value +* Requires `enableYield` feature + +Yield operation executes its child, and then returns from the currently executing function with a ContinuationResult containing that value as the result. Upon continuing the continuation, the control continues from Yield operation, with the Yield returning the value passed to the continuation (see "Yielding and coroutines") + +**Source** +* Arity: 1 +* Returns value: Only if the child returns a value +* `begin` arguments: (Source) + +Source is the operation used to declare that the enclosed operation is found in the given Source (see "Source information"). Together with SourceSection, it allows for source locations to be preserved in Operation DSL. On execution it just executes its child and returns the result (if any). + +**SourceSection** +* Arity: 1 +* Returns value: Only if the child returns a value +* `begin` arguments: (int, int) + +SourceSection is the operation used to declare that the enclosed operation is found at given offset, and has the given length in the source code. It must be (directly or indirectly) enclosed within the Source operation. On execution it just executes its child and returns the result (if any). + +**Tag** +* Arity: 1 +* Returns value: Only if the child returns a value +* `begin` arguments: (Class) + +Tag is the operation used to declare that the enclosed operation should be represented as having the given tag when instrumented (see "Instrumentation"). On execution it just executes its child and returns the result (if any). + +## Defining locals and labels + +Locals and labels are the abstractions that encapsulate the data storage and control-flow locations. Apart from operations that manipulate them, additional `createLocal` and `createLabel` operations are exposed on the builder that provide you with a unique `OperationLocal` and `OperationLabel` instance. + +The location where you call the `create` functions is important, as the construct is considered to be scoped to the operation it is created in. For labels, that operation is further required to be either a Root or a Block operation. + +For locals, all loads and stores must be (directly or indirectly) nested within the same operation the local is declared in. Few examples (indented for readability): + +```java +// this is allowed +b.beginBlock(); + var local = b.createLocal(); + b.beginStoreLocal(local); + /* ... */ + b.endStoreLocal(); + + b.emitLoadLocal(local); +b.endBlock(); + +// this is also allowed (arbitrarily nesting) +b.beginSomeOperation(); + var local = b.createLocal(); + b.beginOtherOperation(); + b.emitLoadLocal(local); // or StoreLocal + b.endOtherOperation(); +b.endSomeOperation(); + +// this is not allowed +b.beginSomething(); + var local = b.createLocal(); +b.endSomething(); +b.emitLoadLocal(local); +``` + +In order to use the local with Load/StoreLocalMaterialized operations, the local must be created directly scoped to the Root operation of the function. + +For labels, similar rules apply for Branch operations. The Branch must be (directly or indirectly) nested in the same Block or Root operation. However the Label operation must be directly nested. For eample: + +```java +// this is allowed +b.beginBlock(); + var label = b.createLabel(); + b.emitLabel(label); +b.endBlock(); + +// this is not allowed (nested Label operation) +b.beginBlock(); + var label = b.createLabel(); + b.beginSomething(); + b.emitLabel(label); + b.endSomething(); +b.endBlock(); + +// this is not allowed (multiple Label operations for same OperationLabel) +b.beginBlock(); + var label = b.createLabel(); + b.emitLabel(label); + // ... + b.emitLabel(label); +b.endBlock(); +``` + +Furthermore, reading/writing to locals, as well as branching to labels defined within other RootNodes is not allowed: + +```java +b.beginRoot(/* ... */); + var local = b.createLocal(); + // ... + + b.beginRoot(/* ... */); + b.emitLoadLocal(local); // not allowed + b.endRoot(); +b.endRoot(); +``` + +### Using materialized local reads and writes + +If you need to read/write to locals of other functions, Load/StoreLocalMaterialized can be used. Still, nesting must be respected, and the local must be directly nested inside the Root operation. + +```java +b.beginRoot(/* ... */); + var topLevelLocal = b.createLocal(); + // ... + + b.beginBlock(); + var nonTopLevelLocal = b.createLocal(); + + b.beginRoot(/* ... */); + // allowed + b.beginLoadLocalMaterialized(topLevelLocal); + b.emitProvideMaterializedFrame(); // custom operation + b.endLoadLocalMaterialized(); + + // not allowed, the local is not top-level, even if it is in scope + b.beginLoadLocalMaterialized(nonTopLevelLocal); + b.emitProvideMaterializedFrame(); + b.endLoadLocalMaterialized(); + b.endRoot(); + b.endBlock(); +b.endRoot(); + +b.beginRoot(); + // not allowed, not in scope + b.beginLoadLocalMaterialized(topLevelLocal); + b.emitProvideMaterializedFrame(); + b.endLoadLocalMaterialized(); +b.endRoot(); +``` + +In order to properly implement this, your language needs to implement closure calls, which materialize and pass the caller function Frame into the callee (e.g. by passing it as an additional argument), and the operation that returns that materialized frame for use with the materialized load and store operations (here named `ProvideMaterializedFrame`, e.g. by extracting it from the arguments array). + +## Source information + +The Operation DSL has the option of keeping track of source locations within the code. This is done using Source and SourceSection operations. Source operation defines the source in which the nested operations are found, while the SourceSection, toghether with the nearest enclosing Source operation defines the exact source location. + +The source information will only be kept if the OperationConfig includes the corresponding option. This can be achieved by passing the `OperationConfig` that contains `withSource` feature to the initial `create` call, or later by calling `OperationNodes#updateConfiguration`. + +The RootNode itself will report as its location the first largest enclosing SourceSection that is defined within it. The source location at any particular point in the code can be extracted by calling the `getSourceSectionAtBci(int)` function of the root node, which for a given bytecode index returns the nearest enclosing source section. The bytecode index can be obtained using the `$bci` pseudovariable in DSL expressions, e.g. by adding a `@Bind("$bci") int bci` parameter to a specialization. + +## Instrumentation + +The Operation DSL has the option of creating instrumentable nodes, with arbitrary instrumentation tags attached. This is achieved using the Tag operations. Each Tag operation will appear in the instrumentation framework as an instrumentable node, and will properly emit instruemntation events when executed. + +Instrumentation can be enabled eagerly by passing an `OperationConfig` that contains the `withInstrumentation` feature to the initial `create` call, or later by calling `OperationNodes#updateConfiguration`. It will otherwise be automatically enabled if requested by the Truffle instrumentation framework. + +## Reparsing + +In order to lower the memory footprint and speed up parsing, certain features of the Operation DSL (e.g source information and instrumentation) are not eagerly enabled. Instead, they can be *reparsed* when needed. This can be done automatically (e.g. on instrumentation), or manually by calling `OperationNodes#updateConfiguration` with the new expected configuration. The method will then optionally perform the parsing process again, adding all the missing data into the node instances. In order to support this, the parser function must be deterministic, and callable multiple times. + +Since parsing and reparsing is slower than just parsing once, features to be included in the initial parse can also be specified. For example, the language may eagerly choose to enable source information for its functions by passing `OperationConfig.WITH_SOURCE` to the `create` call. + +## Defining custom operations + +Custom operations are defined using Java classes. They can be defined in two ways: by placing them inside the operations class and annotating them with `@Operation`, or by proxying them by annotating the operations class itself with `@OperationProxy` and referencing the operation specification class. + +In both cases, the operation class can be one of two things: a Truffle DSL Node that will be converted into an Operation, or an operation implemented from scratch. The first approach is useful if the language is migrating from an AST based to Operation DSL based interpreter, while the second is useful if the language is writing the Operation DSL implementation from scratch. + +In case of the Node implementation, semantics equivalent to Truffle DSL can be expected, with the restriction of having all specialization be declared static. In case of the non-Node operation definition, the class must not have instance members, must be non-nested and `final`, must only extend `Object` and must not have explicit constructors. + +The semantics of the operation are then defined using the @Specialization annotated methods. Note that in the Node case, any `execute` methods are ignored, and the semantics is purely derived from the specializations. Aditionally, any existing NodeChild annotations are ignored, and instead the semantics of nesting operations explained above is used. + +### Specialization parameters + +Each specialization method has parameters that define the semantics of it, as well as the operation as a whole. They must be in the following order: + +* An optional `Frame` or `VirtualFrame` parameter. +* The value parameters. All specializations within an operation must have the same number of value parameters, but their types can change. +* An optional `@Variadic`-annotated parameter, with the type `Object[]`. Either all or none of the specializations must have this parameter. If present, the operation is considered variadic. +* Optional `LocalSetter` parameters. All specializations within an operation must have the same number of `LocalSetter` parameters (see "Multiple results with LocalSetter") +* Optional `LocalSetterRange` parameters. Similar to `LocalSetter`. +* Any Truffle DSL parameters, annotated with `@Cached` or `@Bind`. Each specialization can have a different number of these. + +Furthermore, either all or none of the specializations must be declared as returning `void`. This will define if the custom operation is considere to be returning a value or not. + +If the operation is non-variadic and has no value parameters, the `emit` method will be defined for it in the Builder. Otherwise, a pair of `begin` and `end` methods will be defined. + +The `begin` or `emit` methods will require one `OperationLocal` argument for each `LocalSetter`, and one `OperationLocal[]` for each `LocalSetterRange` parameter defined on the operation's specializations. + +### Variadic operations + +Custom operations can be made variadic by adding a `@Variadic`-annotated parameter to all their specializations, after the regular value parameters. + +The number of regular value parameters defines the minimum number of children for the operation, while all the remaining ones will be collected into one `Object[]` and passed to the variadic parameter. The length of that array will always be a compilation-time constant. + +### Multiple results with LocalSetter + +Some custom operations require returning multiple values, or just want to be able to modify local variables as part of their execution. To do this, operations can define `LocalSetter` and `LocalSetterRange` parameters. `LocalSetter` represents one local variable, that can be set from the operation. `LocalSetterRange` represents a range of variables, all of which will be settable from the operation, using an index. This is similar to by-reference parameter semantics of languages such as `C++`, however reading is now allowed (the current value can still be obtained by passing it as a regular value parameter). + +## Defining short-circuiting custom operations + +One common pattern of language operations is the short-circuiting operations. These include logical short-circuiting operations (e.g. `&&` and `||` in Java, but also null-coalescing operators in some languages, etc.). + +Regular custom operations in Operation DSL cannot influence the execution of their children, since they are always eagerly executed. For this reason Operation DSL allows creation of short-circuiting custom operations. The short-circuiting custom operation is defined using a "boolean converter" operation and a "contiue when" value. + +The boolean converter operation is another operation (which may or may not be its own operation as well) that converts a language value into a `boolean` result. In addition to all the requirements outlined above for operations, it must also satisfy the following constraints: + +* It must have exactly 1 value parameter, and not be variadic +* It must not have any LocalSetter or LocalSetterRange parameters +* All its specializations must return `boolean`. + +Then the short-circuiting operation can be derived: the new operation will be variadic, with minimum of 1 parameter, and return the first value that does **not** satisfy the `continueWhen` condition when converted to boolean using the converter operation. If the execution reaches the last child, it is executed and returned without checking. In pseudocode: + +```python +value_1 = child_1.execute() +if BooleanConverter(value_1) != continueWhen: + return value_1 + +value_2 = child_2.execute() +if BooleanConverter(value_2) != continueWhen: + return value_2 + +# ... + +return child_n.execute() +``` + +The short-circuiting operation is defined by annotating the operations class with `@ShortCircuitOperation` and specifying the name of the operation, the boolean converter definition, and the continueWhen argument. + +With this, we can define some common short-circuiting operations: + +```java +@ShortCircuitOperation( + name = "BoolAnd", + booleanConverter = ToBoolean.class, + continueWhen = true) +@ShortCircuitOperation( + name = "BoolOr", + booleanConverter = ToBoolean.class, + continueWhen = false) +@ShortCircuitOperation( + name = "NullCoalesce", + booleanConverter = IsNull.class, + continueWhen = true) +``` \ No newline at end of file From 0e471a6d035576b7f2d5740165a21f441f859589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 12 Jan 2023 13:54:15 +0100 Subject: [PATCH 287/312] FIx after-merge errors --- .../truffle/dsl/processor/TruffleTypes.java | 2 ++ .../processor/generator/FlatNodeGenFactory.java | 16 +++++++--------- .../dsl/processor/generator/GeneratorUtils.java | 13 ++++++++++++- .../processor/generator/NodeCodeGenerator.java | 2 +- .../dsl/processor/generator/StaticConstants.java | 3 ++- .../dsl/processor/java/model/CodeElement.java | 10 ++++++++++ .../dsl/processor/library/ExportsGenerator.java | 7 ++++--- .../dsl/processor/model/CacheExpression.java | 5 ----- .../dsl/processor/model/MessageContainer.java | 2 +- .../generator/OperationsNodeFactory.java | 8 +++++--- .../operations/parser/OperationsParser.java | 10 +++++++++- 11 files changed, 53 insertions(+), 25 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index 53b2bb9c473b..1fecb2fdbdf5 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -120,6 +120,7 @@ public class TruffleTypes { public static final String Option_Group_Name = "com.oracle.truffle.api.Option.Group"; public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; + public static final String RootNode_Name = "com.oracle.truffle.api.nodes.RootNode"; public static final String IndirectCallNode_Name = "com.oracle.truffle.api.nodes.IndirectCallNode"; public static final String InlinedProfile_Name = "com.oracle.truffle.api.profiles.InlinedProfile"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; @@ -161,6 +162,7 @@ public class TruffleTypes { public final DeclaredType NodeInterface = c.getDeclaredType(NodeInterface_Name); public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); + public final DeclaredType RootNode = c.getDeclaredType(RootNode_Name); public final DeclaredType IndirectCallNode = c.getDeclaredType(IndirectCallNode_Name); public final DeclaredType InlinedProfile = c.getDeclaredTypeOptional(InlinedProfile_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index e8ae1c667b96..75cd080e8164 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -206,6 +206,8 @@ public class FlatNodeGenFactory { private final StaticConstants constants; private NodeConstants nodeConstants; + private final NodeGeneratorPlugs plugs; + private final GeneratorMode generatorMode; private final NodeStateResult state; @@ -215,20 +217,16 @@ public enum GeneratorMode { } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants, NodeConstants nodeConstants) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, nodeConstants); - } - - public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants, NodeGeneratorPlugs plugs) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, plugs); + StaticConstants constants, NodeConstants nodeConstants, NodeGeneratorPlugs plugs) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, nodeConstants, plugs); } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, StaticConstants constants, - NodeConstants nodeConstants) { + NodeConstants nodeConstants, + NodeGeneratorPlugs plugs) { Objects.requireNonNull(node); this.plugs = plugs; this.generatorMode = mode; @@ -270,7 +268,7 @@ private static final class NodeStateResult { } public static List createInlinedFields(NodeData node) { - FlatNodeGenFactory factory = new FlatNodeGenFactory(ProcessorContext.getInstance(), GeneratorMode.DEFAULT, node, new StaticConstants(), new NodeConstants()); + FlatNodeGenFactory factory = new FlatNodeGenFactory(ProcessorContext.getInstance(), GeneratorMode.DEFAULT, node, new StaticConstants(), new NodeConstants(), NodeGeneratorPlugs.DEFAULT); return factory.createInlineFields(true); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index d3be0afb5dec..2b93cf352f62 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -157,6 +157,18 @@ public static CodeTree createShouldNotReachHere(CodeTree causeExpression) { return builder.build(); } + public static CodeExecutableElement createSuperConstructor(TypeElement targetElement, ExecutableElement superConstructor) { + CodeExecutableElement ctor = new CodeExecutableElement(null, targetElement.getSimpleName().toString()); + ctor.getParameters().addAll(superConstructor.getParameters()); + + CodeTreeBuilder b = ctor.createBuilder(); + b.startStatement().startCall("super"); + b.variables(ctor.getParameters()); + b.end(2); + + return ctor; + } + public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) { TypeElement superClass = fromTypeMirror(clazz.getSuperclass()); ExecutableElement constructor = findConstructor(superClass); @@ -465,5 +477,4 @@ public static void addThrownExceptions(CodeExecutableElement executable, List generateNodes(ProcessorContext context, Nod NodeConstants nodeConstants = new NodeConstants(); try { - type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, nodeConstants).create(type); + type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, nodeConstants, NodeGeneratorPlugs.DEFAULT).create(type); } catch (Throwable t) { Exception e = new Exception("Generating node " + node.getNodeId()); e.setStackTrace(new StackTraceElement[0]); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java index 60e21d782dfc..ea33a3f16498 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java @@ -46,6 +46,7 @@ import java.util.Map; import javax.lang.model.element.Element; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import com.oracle.truffle.dsl.processor.java.ElementUtils; @@ -109,7 +110,7 @@ public String reserveSymbol(TypeMirror type, String name) { } public boolean contains(VariableElement ve) { - return libraries.containsValue(ve) || contextReferences.containsValue(ve) || languageReferences.containsValue(ve); + return libraries.containsValue(ve) || contextReferences.containsValue(ve) || languageReferences.containsValue(ve) || enumValues.containsValue(ve); } public List elements() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java index 8fb8efae79c8..14b134c41c3c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java @@ -72,6 +72,8 @@ public abstract class CodeElement implements Element, Generat private AnnotationMirror generatorAnnotationMirror; private CodeTree docTree; + private boolean highPriority; + public CodeElement(Set modifiers) { this.modifiers = new LinkedHashSet<>(modifiers); } @@ -224,6 +226,14 @@ public String toString() { return s; } + public boolean isHighPriority() { + return highPriority; + } + + public void setHighPriority(boolean highPriority) { + this.highPriority = highPriority; + } + private static class StringBuilderCodeWriter extends AbstractCodeWriter { private final CharArrayWriter charWriter; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 8ee8926c9e47..d892d9379cbe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -87,6 +87,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeConstants; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; @@ -633,7 +634,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map caches = new ArrayList<>(); for (CacheKey key : eagerCaches.keySet()) { caches.add(key.cache); @@ -813,7 +814,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map { @@ -144,7 +145,14 @@ protected OperationsModel parse(Element element, List mirror) AnnotationMirror typeSystemRefMirror = ElementUtils.findAnnotationMirror(typeElement, types.TypeSystemReference); if (typeSystemRefMirror != null) { TypeMirror typeSystemType = getAnnotationValue(TypeMirror.class, typeSystemRefMirror, "value"); - TypeSystemData typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true); + + TypeSystemData typeSystem = null; + if (typeSystemType instanceof DeclaredType) { + typeSystem = context.parseIfAbsent((TypeElement) ((DeclaredType) typeSystemType).asElement(), TypeSystemParser.class, (e) -> { + TypeSystemParser parser = new TypeSystemParser(); + return parser.parse(e, false); + }); + } if (typeSystem == null) { model.addError("The used type system '%s' is invalid. Fix errors in the type system first.", getQualifiedName(typeSystemType)); return model; From 8c7c1d1bbb2e3ad1e05560e8cc495146ce624bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 12 Jan 2023 14:16:33 +0100 Subject: [PATCH 288/312] Fix merge errors again --- .../processor/TruffleProcessorOptions.java | 1 + .../truffle/dsl/processor/TruffleTypes.java | 6 ++++++ .../generator/FlatNodeGenFactory.java | 12 ++++++----- .../processor/generator/GeneratorUtils.java | 12 +++++++++++ .../generator/NodeCodeGenerator.java | 2 +- .../processor/generator/StaticConstants.java | 2 -- .../dsl/processor/java/model/CodeElement.java | 9 +++++++++ .../processor/library/ExportsGenerator.java | 7 ++++--- .../generator/OperationsNodeFactory.java | 2 +- .../dsl/processor/parser/NodeParser.java | 20 ------------------- 10 files changed, 41 insertions(+), 32 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java index fc69aa9842e9..01c3d7ad1755 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessorOptions.java @@ -71,6 +71,7 @@ public class TruffleProcessorOptions { private static final String GenerateSpecializationStatisticsOptionName = "GenerateSpecializationStatistics"; private static final String GenerateSlowPathOnlyOptionName = "GenerateSlowPathOnly"; private static final String GenerateSlowPathOnlyFilterOptionName = "GenerateSlowPathOnlyFilter"; + private static final String OperationsEnableTracingOptionName = "OperationsEnableTracing"; private static final String SuppressAllWarnings = "SuppressAllWarnings"; private static final String CacheSharingWarningsEnabledOptionName = "cacheSharingWarningsEnabled"; private static final String StateBitWidth = "StateBitWidth"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index fbc9c08d6af7..a88c05178c86 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -104,6 +104,8 @@ public class TruffleTypes { public static final String ExplodeLoop_Name = "com.oracle.truffle.api.nodes.ExplodeLoop"; public static final String Frame_Name = "com.oracle.truffle.api.frame.Frame"; public static final String FrameDescriptor_Name = "com.oracle.truffle.api.frame.FrameDescriptor"; + public static final String FrameDescriptor_Builder_Name = "com.oracle.truffle.api.frame.FrameDescriptor.Builder"; + public static final String FrameSlotKind_Name = "com.oracle.truffle.api.frame.FrameSlotKind"; public static final String FinalBitSet_Name = "com.oracle.truffle.api.utilities.FinalBitSet"; public static final String InvalidAssumptionException_Name = "com.oracle.truffle.api.nodes.InvalidAssumptionException"; public static final String MaterializedFrame_Name = "com.oracle.truffle.api.frame.MaterializedFrame"; @@ -117,6 +119,7 @@ public class TruffleTypes { public static final String Option_Group_Name = "com.oracle.truffle.api.Option.Group"; public static final String Option_Name = "com.oracle.truffle.api.Option"; public static final String Profile_Name = "com.oracle.truffle.api.profiles.Profile"; + public static final String RootNode_Name = "com.oracle.truffle.api.nodes.RootNode"; public static final String IndirectCallNode_Name = "com.oracle.truffle.api.nodes.IndirectCallNode"; public static final String InlinedProfile_Name = "com.oracle.truffle.api.profiles.InlinedProfile"; public static final String SlowPathException_Name = "com.oracle.truffle.api.nodes.SlowPathException"; @@ -144,6 +147,8 @@ public class TruffleTypes { public final DeclaredType ExplodeLoop = c.getDeclaredType(ExplodeLoop_Name); public final DeclaredType Frame = c.getDeclaredType(Frame_Name); public final DeclaredType FrameDescriptor = c.getDeclaredType(FrameDescriptor_Name); + public final DeclaredType FrameDescriptor_Builder = c.getDeclaredType(FrameDescriptor_Builder_Name); + public final DeclaredType FrameSlotKind = c.getDeclaredType(FrameSlotKind_Name); public final DeclaredType FinalBitSet = c.getDeclaredType(FinalBitSet_Name); public final DeclaredType InvalidAssumptionException = c.getDeclaredType(InvalidAssumptionException_Name); public final DeclaredType MaterializedFrame = c.getDeclaredType(MaterializedFrame_Name); @@ -155,6 +160,7 @@ public class TruffleTypes { public final DeclaredType NodeInterface = c.getDeclaredType(NodeInterface_Name); public final DeclaredType NodeUtil = c.getDeclaredType(NodeUtil_Name); public final DeclaredType Profile = c.getDeclaredTypeOptional(Profile_Name); + public final DeclaredType RootNode = c.getDeclaredType(RootNode_Name); public final DeclaredType IndirectCallNode = c.getDeclaredType(IndirectCallNode_Name); public final DeclaredType InlinedProfile = c.getDeclaredTypeOptional(InlinedProfile_Name); public final DeclaredType SlowPathException = c.getDeclaredType(SlowPathException_Name); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index a76b2caea090..2c73673e2c41 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -204,6 +204,7 @@ public class FlatNodeGenFactory { private final Map> substitutions = new LinkedHashMap<>(); private final StaticConstants constants; private NodeConstants nodeConstants; + private final NodeGeneratorPlugs plugs; private final GeneratorMode generatorMode; private final NodeStateResult state; @@ -214,15 +215,16 @@ public enum GeneratorMode { } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, - StaticConstants constants, NodeConstants nodeConstants) { - this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, nodeConstants); + StaticConstants constants, NodeConstants nodeConstants, NodeGeneratorPlugs plugs) { + this(context, mode, node, Arrays.asList(node), node.getSharedCaches(), constants, nodeConstants, plugs); } public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData node, Collection stateSharingNodes, Map sharedCaches, StaticConstants constants, - NodeConstants nodeConstants) { + NodeConstants nodeConstants, + NodeGeneratorPlugs plugs) { Objects.requireNonNull(node); this.plugs = plugs; this.generatorMode = mode; @@ -264,7 +266,7 @@ private static final class NodeStateResult { } public static List createInlinedFields(NodeData node) { - FlatNodeGenFactory factory = new FlatNodeGenFactory(ProcessorContext.getInstance(), GeneratorMode.DEFAULT, node, new StaticConstants(), new NodeConstants()); + FlatNodeGenFactory factory = new FlatNodeGenFactory(ProcessorContext.getInstance(), GeneratorMode.DEFAULT, node, new StaticConstants(), new NodeConstants(), NodeGeneratorPlugs.DEFAULT); return factory.createInlineFields(true); } @@ -7790,7 +7792,7 @@ static boolean isRelevantForSlowPath(BitSet bitSet, Collection values = new HashMap<>(); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java index d7f4f954c979..2976765b4ec4 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java @@ -230,6 +230,18 @@ public static void mergeSuppressWarnings(CodeElement element, String... addWa } } + public static CodeExecutableElement createSuperConstructor(CodeTypeElement clazz, ExecutableElement superConstructor) { + CodeExecutableElement method = new CodeExecutableElement(superConstructor.getModifiers(), null, clazz.getSimpleName().toString()); + + for (VariableElement parameter : superConstructor.getParameters()) { + method.addParameter(CodeVariableElement.clone(parameter)); + } + + method.createBuilder().startStatement().startCall("super").variables(method.getParameters()).end(2); + + return method; + } + public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz, ExecutableElement superConstructor) { return createConstructorUsingFields(modifiers, clazz, superConstructor, Collections.emptySet()); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java index 1e0c29476fbd..ab501e14f3f3 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @@ -288,7 +288,7 @@ private static List generateNodes(ProcessorContext context, Nod NodeConstants nodeConstants = new NodeConstants(); try { - type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, nodeConstants).create(type); + type = new FlatNodeGenFactory(context, GeneratorMode.DEFAULT, node, constants, nodeConstants, NodeGeneratorPlugs.DEFAULT).create(type); } catch (Throwable t) { Exception e = new Exception("Generating node " + node.getNodeId()); e.setStackTrace(new StackTraceElement[0]); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java index c3504489d79f..cd7b210bb6cf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/StaticConstants.java @@ -40,9 +40,7 @@ */ package com.oracle.truffle.dsl.processor.generator; -import java.util.ArrayList; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import javax.lang.model.element.Element; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java index 8fb8efae79c8..5e7404212a6c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeElement.java @@ -71,6 +71,7 @@ public abstract class CodeElement implements Element, Generat private Element generatorElement; private AnnotationMirror generatorAnnotationMirror; private CodeTree docTree; + private boolean highPriority; public CodeElement(Set modifiers) { this.modifiers = new LinkedHashSet<>(modifiers); @@ -224,6 +225,14 @@ public String toString() { return s; } + public boolean isHighPriority() { + return highPriority; + } + + public void setHighPriority(boolean highPriority) { + this.highPriority = highPriority; + } + private static class StringBuilderCodeWriter extends AbstractCodeWriter { private final CharArrayWriter charWriter; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java index 8ee8926c9e47..d892d9379cbe 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/library/ExportsGenerator.java @@ -87,6 +87,7 @@ import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.GeneratorMode; import com.oracle.truffle.dsl.processor.generator.GeneratorUtils; import com.oracle.truffle.dsl.processor.generator.NodeConstants; +import com.oracle.truffle.dsl.processor.generator.NodeGeneratorPlugs; import com.oracle.truffle.dsl.processor.generator.StaticConstants; import com.oracle.truffle.dsl.processor.java.ElementUtils; import com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror; @@ -633,7 +634,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map caches = new ArrayList<>(); for (CacheKey key : eagerCaches.keySet()) { caches.add(key.cache); @@ -813,7 +814,7 @@ CodeTypeElement createCached(ExportsLibrary libraryExports, Map Date: Thu, 12 Jan 2023 15:02:40 +0100 Subject: [PATCH 289/312] More merge fixes --- .../generator/OperationsNodeFactory.java | 4 +++- .../truffle/sl/nodes/expression/SLAddNode.java | 2 +- .../sl/nodes/expression/SLReadPropertyNode.java | 14 ++++++++------ .../sl/nodes/expression/SLWritePropertyNode.java | 7 ++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 93b5a0785ace..12219b0a937c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -213,6 +213,8 @@ public CodeTypeElement create() { el.setSuperClass(types.Node); factory.create(el); new CustomInstructionNodeFactory().processNodeType(el, instr); + + nodeConsts.prependToClass(el); operationNodeGen.add(el); } @@ -1690,7 +1692,7 @@ private CodeExecutableElement createDoEmitLeaves() { CodeTreeBuilder b = ex.createBuilder(); - b.startFor().string("int i = operationSp - 1; i >= 0; i++").end().startBlock(); + b.startFor().string("int i = operationSp - 1; i >= 0; i--").end().startBlock(); b.startIf().string("opSeqNumStack[i] == targetSeq").end().startBlock(); b.returnStatement(); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java index 656f6f8d8562..915e68237549 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @@ -117,7 +117,7 @@ public static SLBigNumber add(SLBigNumber left, SLBigNumber right) { */ @Specialization(guards = "isString(left, right)") @TruffleBoundary - protected static TruffleString add(Object left, Object right, + public static TruffleString add(Object left, Object right, @Bind("this") Node node, @Cached SLToTruffleStringNode toTruffleStringNodeLeft, @Cached SLToTruffleStringNode toTruffleStringNodeRight, diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java index 6eadbff39530..a35d39dbc266 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLReadPropertyNode.java @@ -89,29 +89,31 @@ public static Object readArray(Object receiver, Object index, } @Specialization(limit = "LIBRARY_LIMIT") - protected static Object readSLObject(SLObject receiver, Object name, + public static Object readSLObject(SLObject receiver, Object name, @Bind("this") Node node, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, - @Cached SLToTruffleStringNode toTruffleStringNode) { + @Cached SLToTruffleStringNode toTruffleStringNode, + @Bind("$bci") int bci) { TruffleString nameTS = toTruffleStringNode.execute(node, name); Object result = objectLibrary.getOrDefault(receiver, nameTS, null); if (result == null) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(node, nameTS); + throw SLUndefinedNameException.undefinedProperty(node, bci, nameTS); } return result; } @Specialization(guards = {"!isSLObject(receiver)", "objects.hasMembers(receiver)"}, limit = "LIBRARY_LIMIT") - protected static Object readObject(Object receiver, Object name, + public static Object readObject(Object receiver, Object name, @Bind("this") Node node, @CachedLibrary("receiver") InteropLibrary objects, - @Cached SLToMemberNode asMember) { + @Cached SLToMemberNode asMember, + @Bind("$bci") int bci) { try { return objects.readMember(receiver, asMember.execute(node, name)); } catch (UnsupportedMessageException | UnknownIdentifierException e) { // read was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(node, name); + throw SLUndefinedNameException.undefinedProperty(node, bci, name); } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java index f53e874d3eb5..b8073a493ef0 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLWritePropertyNode.java @@ -93,7 +93,7 @@ public static Object writeArray(Object receiver, Object index, Object value, } @Specialization(limit = "LIBRARY_LIMIT") - protected static Object writeSLObject(SLObject receiver, Object name, Object value, + public static Object writeSLObject(SLObject receiver, Object name, Object value, @Bind("this") Node node, @CachedLibrary("receiver") DynamicObjectLibrary objectLibrary, @Cached SLToTruffleStringNode toTruffleStringNode) { @@ -102,15 +102,16 @@ protected static Object writeSLObject(SLObject receiver, Object name, Object val } @Specialization(guards = "!isSLObject(receiver)", limit = "LIBRARY_LIMIT") - protected static Object writeObject(Object receiver, Object name, Object value, + public static Object writeObject(Object receiver, Object name, Object value, @Bind("this") Node node, + @Bind("$bci") int bci, @CachedLibrary("receiver") InteropLibrary objectLibrary, @Cached SLToMemberNode asMember) { try { objectLibrary.writeMember(receiver, asMember.execute(node, name), value); } catch (UnsupportedMessageException | UnknownIdentifierException | UnsupportedTypeException e) { // write was not successful. In SL we only have basic support for errors. - throw SLUndefinedNameException.undefinedProperty(node, name); + throw SLUndefinedNameException.undefinedProperty(node, bci, name); } return value; } From ca7a8dd6251ed61fa96416356bdf712d99ebdb66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Mon, 16 Jan 2023 15:45:50 +0100 Subject: [PATCH 290/312] Fixes to generator --- .../operation/test/dsl_tests/ErrorTests.java | 39 ++++------ .../test/example/TestOperationsSerTest.java | 16 ++--- .../docs/OpDSL_BoxingElimination.md | 59 +++++++++++++++ .../truffle/dsl/processor/TruffleTypes.java | 6 +- .../expression/DSLExpressionResolver.java | 1 + .../generator/FlatNodeGenFactory.java | 4 +- .../generator/OperationsNodeFactory.java | 72 +++++++++++++++++-- .../parser/CustomOperationParser.java | 4 +- .../operations/parser/OperationsParser.java | 2 +- .../dsl/processor/parser/NodeParser.java | 18 ++--- .../operations/SLOperationSerialization.java | 57 +++++++-------- 11 files changed, 197 insertions(+), 81 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/docs/OpDSL_BoxingElimination.md diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java index c2c7265be8ad..a90f5b1d001a 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java @@ -50,11 +50,9 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode; import com.oracle.truffle.api.instrumentation.Tag; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.GenerateOperations; import com.oracle.truffle.api.operation.LocalSetter; -import com.oracle.truffle.api.operation.LocalSetterRange; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.OperationRootNode; @@ -62,7 +60,7 @@ import com.oracle.truffle.api.operation.test.ExpectError; import com.oracle.truffle.api.source.SourceSection; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "static-method", "truffle"}) public class ErrorTests { @ExpectError("Operations class must be declared abstract.") @GenerateOperations(languageClass = ErrorLanguage.class) @@ -104,7 +102,7 @@ protected MustImplementOperationRootNode(TruffleLanguage language, FrameDescr } } - @ExpectError("Operations class requires a (TruffleLanguage, FrameDescriptor) constructor.") + @ExpectError("Operations class requires a (TruffleLanguage, FrameDescriptor) constructor.") @GenerateOperations(languageClass = ErrorLanguage.class) public abstract class MustHaveFDConstructor extends RootNode implements OperationRootNode { protected MustHaveFDConstructor(TruffleLanguage language, FrameDescriptor.Builder builder) { @@ -112,13 +110,13 @@ protected MustHaveFDConstructor(TruffleLanguage language, FrameDescriptor.Bui } } - @ExpectError("Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder). Remove this constructor.") @GenerateOperations(languageClass = ErrorLanguage.class) public abstract class InvalidConstructor extends RootNode implements OperationRootNode { protected InvalidConstructor(TruffleLanguage language, FrameDescriptor builder) { super(language, builder); } + @ExpectError("Invalid constructor declaration, expected (TruffleLanguage, FrameDescriptor) or (TruffleLanguage, FrameDescriptor.Builder). Remove this constructor.") protected InvalidConstructor(TruffleLanguage language) { super(language); } @@ -141,7 +139,7 @@ protected BadBoxingElimination(TruffleLanguage language, FrameDescriptor buil } } - @ExpectError({"Type referenced by @OperationProxy must be a class, not int.", "Error generating operation. Fix issues on the referenced class first."}) + @ExpectError({"Could not proxy operation: the proxied type must be a class, not int."}) @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(int.class) public abstract class BadProxyType extends RootNode implements OperationRootNode { @@ -150,7 +148,6 @@ protected BadProxyType(TruffleLanguage language, FrameDescriptor builder) { } } - @ExpectError("Class referenced by @OperationProxy must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") @GenerateOperations(languageClass = ErrorLanguage.class) @OperationProxy(TestNode.class) public abstract static class OperationErrorTests extends RootNode implements OperationRootNode { @@ -178,50 +175,39 @@ private static final class TestOperation2 { public static final class TestOperation3 implements Cloneable { } - @ExpectError("@Operation annotated class must not contain non-static members.") @Operation public static final class TestOperation4 { + @ExpectError("@Operation annotated class must not contain non-static members.") public void doSomething() { } } - @ExpectError("Multiple @Variadic arguments are not supported.") @Operation public static final class TestOperation5 { @Specialization - public static void spec(@Variadic Object[] a, @Variadic Object[] b) { + public static void spec(@Variadic Object[] a, + @ExpectError("Multiple variadic arguments not allowed to an operation. Split up the operation if such behaviour is required.") @Variadic Object[] b) { } } - @ExpectError("Value arguments after LocalSetter are not supported.") @Operation public static final class TestOperation6 { @Specialization - public static void spec(LocalSetter a, Object b) { + public static void spec(LocalSetter a, @ExpectError("Value parameters must precede LocalSetter and LocalSetterRange parameters.") Object b) { } } - @ExpectError("Mixing regular and range local setters is not supported.") - @Operation - public static final class TestOperation7 { - @Specialization - public static void spec(LocalSetter a, LocalSetterRange b) { - } - } - - @ExpectError("Value arguments after @Variadic are not supported.") @Operation public static final class TestOperation8 { @Specialization - public static void spec(@Variadic Object[] a, Object b) { + public static void spec(@Variadic Object[] a, @ExpectError("Non-variadic value parameters must precede variadic ones.") Object b) { } } - @ExpectError("Value arguments after LocalSetter are not supported.") @Operation public static final class TestOperation9 { @Specialization - public static void spec(LocalSetter a, Object b) { + public static void spec(LocalSetter a, @ExpectError("Value parameters must precede LocalSetter and LocalSetterRange parameters.") Object b) { } } } @@ -238,10 +224,11 @@ public static void doStuff() { } } - public abstract static class TestNode extends Node { - public abstract int execute(int x, int y); + @ExpectError("Operation specification must have all its specializations static. Use @Bind(\"this\") parameter if you need a Node instance.") + public static final class TestNode { @Specialization + @ExpectError("@Operation annotated class must not contain non-static members.") public int add(int x, int y) { return x + y; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 37705345a117..38d3b6c03126 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -43,7 +43,6 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.nio.ByteBuffer; import org.junit.Assert; import org.junit.Test; @@ -63,13 +62,14 @@ public void testSer() { private static TestOperations deserialize(byte[] byteArray) { OperationNodes nodes2 = null; - try { - nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), (ctx, buf2) -> { - return buf2.readLong(); - }); - } catch (IOException e) { - Assert.fail(); - } +// try { +// nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), +// (ctx, buf2) -> { +// return buf2.readLong(); +// }); +// } catch (IOException e) { +// Assert.fail(); +// } return nodes2.getNodes().get(0); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/docs/OpDSL_BoxingElimination.md b/truffle/src/com.oracle.truffle.dsl.processor/docs/OpDSL_BoxingElimination.md new file mode 100644 index 000000000000..0c2cb38cf9d7 --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/docs/OpDSL_BoxingElimination.md @@ -0,0 +1,59 @@ +# Notes on BE implementation + +* Each instruction can decide if it participates in boxing elimination, but then must be consistent. +* Each instruction has a role of producer (if it pushes values) and consumer (if it pops). Each instruction can produce multiple values, and also consume multiple values. These can have differing BE behaviours (e.g. first consumed value is BE'd, but the second one isn't). + +* If an instruction has at least one *produced* value that does BE, its object needs to implemebt `BoxableInterface`. + +* During building + * When emitting a producer, for each its produced value: + * If it does BE, the value `(valueIndex << 16) | bci` is pushed on a value-tracking stack. + * If it does not do BE, value `0xffff0000` is pushed instead. (`-1` may be a better choice) + * When emitting a consumer, for each its consumed value: + * If it does BE, pop from the value-tracking stack, and store this value somewhere + * If it does not do BE, pop and discard a value from the value-tracking stack. + +* During execution: + * When popping a value: + * If the value should be BE'd: + * If you are expecting a primitive: (thi is implemented with `doPopPrimitiveXYZ`) + * If your producer is BEing (value != 0xffff) + * Speculatively read the primitive off the stack + * If mispredicted, deopt and call `BoxableInterface#setBoxing(valueIndex, expectedKind)` on the `objs[bci]` + * Else, pop an object, and try to cast it as the primitive + * If you are expecting an object: (this is implemented with `doPopObject`) + * If your producer is BEing (value != 0xffff) + * Speculatively read the object off the stack + * If mispredicted, deopt and call `setBoxing(valueIndex, -1)` to turn the producer generic. + * Else, pop an object (it will always be object) + * If the value should not be BE'd: + * Just read as object, since nothing can BE the producer except you + * When pushing a value: + * If the value should not be BE'd: + * Just push it as object + * If the value should be BE'd: + * Inspect the boxingState for the corresponding valueIndex. You **must** act in accordance to that, even if that means preemptively unboxing something. + + + +Problems: + * If a consumer first exec races with another first exec + a primitive exec, the producer may get stuck in the generic state, even though it should remain in primitive state (the first first exec will expect an object, but if the primitive exec already turned it into a primitive, it will instead go into generic). + * The boxing elimination updates need 2 executions to propagate (since they only propagate on a *fault*, never in advance). Moving the `setBoxing` calls into E&S would help this. + + +# The problem of Object + +The issue is with an operation like (assume we BE ints and longs): + +``` +@Spec int soPrimitive() { return 0; } +@Spec Object doBoxed() { return (long) 0L; } +``` + +Even though this operation can't produce a primitive `long`, it can still produce a *boxed* one. To solve this, we have 3 cases of custom instructions: + +* Have only non-primitive (including `Object`) return values: they don't participate in BE (`resultBoxingElimination == false`) +* Have only primitive and non-`Object` return values: they participate in BE normally. We know they can never produce unexpected primitives. (`resultBoxingElimination == true`, the set of possible return values is in `possibleBoxingResults` with `Object` standing in for anything non-primitive) + * During execution we don't have to check the non-existant types in boxingState since we can never produce them in the first place. +* Have a primitive and an `Object` return value: they can *potentially* return any primitive value. For this we use (`resultBoxingElimination == true` and `possibleBoxingResults == null`). + * During execution check all BE'd types in boxingState, and corresponding `execute` method. \ No newline at end of file diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java index a88c05178c86..9a8113e34e8c 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java @@ -53,7 +53,11 @@ public class TruffleTypes { // Checkstyle: stop // Testing API - private static final String[] EXPECT_ERROR_TYPES = new String[]{TruffleTypes.EXPECT_ERROR_CLASS_NAME1, TruffleTypes.EXPECT_ERROR_CLASS_NAME2}; + private static final String[] EXPECT_ERROR_TYPES = new String[]{ + TruffleTypes.EXPECT_ERROR_CLASS_NAME1, + TruffleTypes.EXPECT_ERROR_CLASS_NAME2, + TruffleTypes.EXPECT_ERROR_CLASS_NAME3 + }; public static final String ALWAYS_SLOW_PATH_MODE_NAME = "com.oracle.truffle.api.dsl.test.AlwaysGenerateOnlySlowPath"; public static final String DISABLE_STATE_BITWIDTH_MODIFICATION = "com.oracle.truffle.api.dsl.test.DisableStateBitWidthModfication"; public static final String EXPECT_ERROR_CLASS_NAME1 = "com.oracle.truffle.api.dsl.test.ExpectError"; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java index c3437ae30b91..7c61b9e8c861 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpressionResolver.java @@ -265,6 +265,7 @@ private VariableElement resolveVariable(Variable variable) { return parent.resolveVariable(variable); } + // should have more specific type if (name.equals("this") || name.equals("$root")) { return new CodeVariableElement(ProcessorContext.getInstance().getTypes().Node, "this"); } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java index 2c73673e2c41..1484871e5875 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java @@ -577,7 +577,7 @@ private String createFieldName(SpecializationData specialization, CacheExpressio } if (specialization == null) { - throw new AssertionError("if specialization is null it must be shared cache"); + throw new AssertionError("if specialization is null it must be shared cache: " + specialization + " " + cache + " " + sharedCaches); } Parameter parameter = cache.getParameter(); @@ -3647,7 +3647,7 @@ private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameSt boolean found = false; for (NodeExecutionData otherExecution : node.getChildExecutions()) { if (found) { - LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericType); + LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, node.getGenericType(otherExecution)); builder.tree(createAssignExecuteChild(slowPathFrameState.copy(), slowPathFrameState, builder, otherExecution, delegateType, childEvaluatedValue)); slowPathFrameState.setValue(otherExecution, childEvaluatedValue); } else { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 12219b0a937c..bf6db9dac017 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -164,6 +164,7 @@ public CodeTypeElement create() { operationNodeGen.add(createCreate()); operationNodeGen.add(createExecute()); + operationNodeGen.add(createSneakyThrow()); operationNodeGen.add(createGetIntrospectionData()); @@ -182,7 +183,7 @@ public CodeTypeElement create() { operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numLocals"))); operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"))); if (model.hasBoxingElimination()) { - operationNodeGen.add(compFinal(new CodeVariableElement(Set.of(PRIVATE), context.getType(byte[].class), "localBoxingState"))); + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(byte[].class), "localBoxingState"))); } if (model.generateUncached) { operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "uncachedExecuteCount")).createInitBuilder().string("16"); @@ -307,10 +308,11 @@ private CodeExecutableElement createCloneUninitialized() { b.statement("newData." + field.name + " = curData." + field.name); } - b.statement("clone.objs[bci] = newData"); + b.statement("clone.objs[bci] = clone.insert(newData)"); break; default: + b.statement("assert !(this.objs[bci] instanceof Node)"); b.statement("clone.objs[bci] = this.objs[bci]"); break; } @@ -374,6 +376,15 @@ private CodeExecutableElement createExecute() { CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute"); CodeTreeBuilder b = ex.createBuilder(); + // todo: only generate executeProlog/Epilog calls and the try/finally if they are overridden + + b.statement("Throwable throwable = null"); + b.statement("Object returnValue = null"); + + b.statement("this.executeProlog(frame)"); + + b.startTryBlock(); + b.statement("int state = numLocals << 16"); b.startWhile().string("true").end().startBlock(); @@ -390,7 +401,23 @@ private CodeExecutableElement createExecute() { b.end(); b.end(); - b.startReturn().string("frame.getObject((state >> 16) & 0xffff)").end(); + b.startAssign("returnValue").string("frame.getObject((state >> 16) & 0xffff)").end(); + b.statement("return returnValue"); + + b.end().startCatchBlock(context.getType(Throwable.class), "th"); + b.statement("throw sneakyThrow(throwable = th)"); + b.end().startFinallyBlock(); + b.statement("this.executeEpilog(frame, returnValue, throwable)"); + b.end(); + + return ex; + } + + private CodeExecutableElement createSneakyThrow() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), null, " RuntimeException sneakyThrow(Throwable e) throws E { //"); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("throw (E) e"); return ex; } @@ -457,8 +484,18 @@ private CodeExecutableElement createGetIntrospectionData() { buildIntrospectionArgument(b, "ARGUMENT", "data"); break; case LOAD_LOCAL: - case LOAD_LOCAL_MATERIALIZED: + if (model.hasBoxingElimination()) { + buildIntrospectionArgument(b, "LOCAL", "(int) ((LoadLocalData) data).v_index"); + break; + } + // fall-through case STORE_LOCAL: + if (model.hasBoxingElimination()) { + buildIntrospectionArgument(b, "LOCAL", "(int) ((StoreLocalData) data).s_index"); + break; + } + // fall-through + case LOAD_LOCAL_MATERIALIZED: case STORE_LOCAL_MATERIALIZED: buildIntrospectionArgument(b, "LOCAL", "((IntRef) data).value"); break; @@ -1101,6 +1138,11 @@ private Element createEnd(OperationModel operation) { b.startAssign("result.nodes").string("nodes").end(); b.startAssign("result.bc").string("Arrays.copyOf(bc, bci)").end(); b.startAssign("result.objs").string("Arrays.copyOf(objs, bci)").end(); + b.startFor().string("int i = 0; i < bci; i++").end().startBlock(); + b.startIf().string("objs[i] instanceof Node").end().startBlock(); + b.statement("result.insert((Node) objs[i])"); + b.end(); + b.end(); b.startAssign("result.handlers").string("Arrays.copyOf(exHandlers, exHandlerCount)").end(); b.startAssign("result.numLocals").string("numLocals").end(); b.startAssign("result.buildIndex").string("buildIndex").end(); @@ -1339,10 +1381,30 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, b.startStaticCall(types.LocalSetter, "create"); b.string("((IntRef)((OperationLocalImpl)((Object[]) operationData[operationSp])[" + (argBase + i) + "]).index).value"); b.end(2); + } argBase += instruction.signature.localSetterCount; + for (int i = 0; i < instruction.signature.localSetterRangeCount; i++) { + b.startBlock(); + b.statement("OperationLocal[] argg = (OperationLocal[]) ((Object[]) operationData[operationSp])[" + (argBase + i) + "]"); + b.statement("int[] indices = new int[argg.length]"); + + b.startFor().string("int ix = 0; ix < indices.length; ix++").end().startBlock(); + b.startAssign("indices[ix]").string("((IntRef) ((OperationLocalImpl) argg[ix]).index).value").end(); + b.end(); + + b.startAssign("argument.op_localSetterRange" + i + "_"); + b.startStaticCall(types.LocalSetterRange, "create"); + b.string("indices"); + b.end(2); + + b.end(); + } + + argBase += instruction.signature.localSetterRangeCount; + } private CodeExecutableElement createBeforeChild() { @@ -2182,7 +2244,7 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i b.startCase().tree(boxingTypeToInt(mir)).end().startBlock(); - if (signature.possibleBoxingResults != null && signature.possibleBoxingResults.contains(mir)) { + if (signature.possibleBoxingResults == null || signature.possibleBoxingResults.contains(mir)) { b.startTryBlock(); b.startStatement().startCall("frame.set" + frameName); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 2113f5fc440e..7742ddf5f697 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -120,7 +120,7 @@ protected OperationModel parse(Element element, List ignored) } if (mirror != null) { - AnnotationValue nameValue = ElementUtils.getAnnotationValue(mirror, "name", false); + AnnotationValue nameValue = ElementUtils.getAnnotationValue(mirror, isShortCircuit ? "name" : "operationName", false); if (nameValue != null) { name = (String) nameValue.getValue(); } @@ -390,7 +390,7 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl for (int i = 0; i < signature.valueBoxingElimination.length; i++) { if (signature.valueBoxingElimination[i]) { // we could move these to cached-only fields, but then we need more processing - // once we go uncached -> cached + // once we go uncached -> cached (recalculating the value offsets and child indices) instr.addField(context.getType(int.class), "op_childValue" + i + "_boxing_", true); } } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index e368e03c9432..a97a659e67de 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -194,7 +194,7 @@ protected OperationsModel parse(Element element, List mirror) TypeMirror proxiedType = getTypeMirror(ElementUtils.getAnnotationValue(mir, "value")); if (proxiedType.getKind() != TypeKind.DECLARED) { - model.addError("Could not proxy operation: the proxied type must be a class, not %s", proxiedType); + model.addError("Could not proxy operation: the proxied type must be a class, not %s.", proxiedType); continue; } diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java index 479221fe7b0b..e5ae6f05529e 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/NodeParser.java @@ -427,7 +427,7 @@ public NodeData parseNode(TypeElement originalTemplateType) { initializeAOT(node); boolean recommendInline = initializeInlinable(resolver, node); - if (mode == ParseMode.DEFAULT) { + if (mode == ParseMode.DEFAULT || mode == ParseMode.OPERATION) { boolean emitWarnings = TruffleProcessorOptions.cacheSharingWarningsEnabled(processingEnv) && // !TruffleProcessorOptions.generateSlowPathOnly(processingEnv); node.setSharedCaches(computeSharing(node.getTemplateType(), Arrays.asList(node), emitWarnings)); @@ -462,6 +462,9 @@ private DSLExpressionResolver createBaseResolver(NodeData node, List me globalMembers.addAll(members); globalMembers.add(new CodeVariableElement(types.Node, "this")); globalMembers.add(new CodeVariableElement(types.Node, NODE_KEYWORD)); + if (mode == ParseMode.OPERATION) { + globalMembers.add(new CodeVariableElement(types.Node, "$root")); + } return new DSLExpressionResolver(context, node.getTemplateType(), globalMembers); } @@ -1156,7 +1159,10 @@ public static Map computeSharing(Element templateType, declaringElement = node.getTemplateType().getEnclosingElement(); if (!declaringElement.getKind().isClass() && !declaringElement.getKind().isInterface()) { - throw new AssertionError("Unexpected declared element for generated element: " + declaringElement.toString()); + // throw new AssertionError("Unexpected declared element for generated + // element: " + declaringElement.toString()); + + declaringElement = node.getTemplateType(); } } else { declaringElement = node.getTemplateType(); @@ -2228,10 +2234,6 @@ private List parseExecutableTypeData(NodeData node, List foundTypes = child.findGenericExecutableTypes(); if (foundTypes.isEmpty()) { AnnotationValue executeWithValue = child.getExecuteWithValue(); - child.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s and frame types %s. Found: %s", child.getExecuteWith().size(), - getSimpleName(nodeType), getUniqueIdentifiers(createAllowedChildFrameTypes(node)), child.getNodeData().getExecutableTypes(-1)); + child.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s and frame types %s.", child.getExecuteWith().size(), + getSimpleName(nodeType), getUniqueIdentifiers(createAllowedChildFrameTypes(node))); } } } diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java index 1e7a574d2dac..7c79ac085df2 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java @@ -45,7 +45,6 @@ import java.io.DataOutput; import java.io.DataOutputStream; import java.io.IOException; -import java.math.BigInteger; import java.nio.ByteBuffer; import com.oracle.truffle.api.operation.OperationConfig; @@ -112,33 +111,35 @@ private static void writeByteArray(DataOutput buffer, byte[] data) throws IOExce public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException { ByteBuffer buf = ByteBuffer.wrap(inputData); + return null; - return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, (context, buffer) -> { - byte tag; - switch (tag = buffer.readByte()) { - case CODE_SL_NULL: - return SLNull.SINGLETON; - case CODE_STRING: - return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); - case CODE_LONG: - return buffer.readLong(); - case CODE_BIG_INT: - return new SLBigNumber(new BigInteger(readByteArray(buffer))); - case CODE_SOURCE: { - String name = new String(readByteArray(buffer)); - return Source.newBuilder(SLLanguage.ID, "", name).build(); - } - case CODE_CLASS: { - String name = new String(readByteArray(buffer)); - try { - return Class.forName(name); - } catch (ClassNotFoundException ex) { - throw new UnsupportedOperationException("could not load class: " + name); - } - } - default: - throw new UnsupportedOperationException("unsupported tag: " + tag); - } - }); +// return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, (context, +// buffer) -> { +// byte tag; +// switch (tag = buffer.readByte()) { +// case CODE_SL_NULL: +// return SLNull.SINGLETON; +// case CODE_STRING: +// return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING); +// case CODE_LONG: +// return buffer.readLong(); +// case CODE_BIG_INT: +// return new SLBigNumber(new BigInteger(readByteArray(buffer))); +// case CODE_SOURCE: { +// String name = new String(readByteArray(buffer)); +// return Source.newBuilder(SLLanguage.ID, "", name).build(); +// } +// case CODE_CLASS: { +// String name = new String(readByteArray(buffer)); +// try { +// return Class.forName(name); +// } catch (ClassNotFoundException ex) { +// throw new UnsupportedOperationException("could not load class: " + name); +// } +// } +// default: +// throw new UnsupportedOperationException("unsupported tag: " + tag); +// } +// }); } } From 34d57fad57c7b37bb1495ec3d32ebc68ca26c41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Tue, 17 Jan 2023 12:38:19 +0100 Subject: [PATCH 291/312] Fix leaf operations that have LocalSetters --- .../generator/OperationsNodeFactory.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index bf6db9dac017..cffab8e81c83 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -595,7 +595,8 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.startReturn().cast(resultType).string("result").end(); b.end().startElseBlock(); // } { b.tree(createTransferToInterpreterAndInvalidate("$this")); - b.statement("System.err.printf(\" [**] expected " + resultType + " but got %s %s [no BE]%n\", result == null ? \"null\" : result.getClass(), result)"); +// b.statement("System.err.printf(\" [**] expected " + resultType + " but got %s %s [no BE]%n\", +// result == null ? \"null\" : result.getClass(), result)"); b.startThrow().startNew(types.UnexpectedResultException).string("result").end(2); b.end(); // } @@ -613,8 +614,9 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { b.string("((BoxableInterface) objs[boxing & 0xffff]).setBoxing((boxing >> 16) & 0xffff, (byte) ").tree(boxingTypeToInt(resultType)).string(")"); b.end(); - b.statement("System.err.printf(\" [**] expected " + resultType + - " but got %s %s (%08x %s) [BE faul]%n\", result == null ? \"null\" : result.getClass(), result, boxing, objs[boxing & 0xffff].getClass())"); +// b.statement("System.err.printf(\" [**] expected " + resultType + +// " but got %s %s (%08x %s) [BE faul]%n\", result == null ? \"null\" : result.getClass(), result, +// boxing, objs[boxing & 0xffff].getClass())"); b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { b.startReturn().cast(resultType).string("result").end(); @@ -1364,6 +1366,8 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, b.statement(instruction.getInternalName() + "Gen argument = new " + instruction.getInternalName() + "Gen()"); } + boolean inEmit = !operation.isVariadic && operation.numChildren == 0; + if (instruction.signature.isVariadic) { b.statement("argument.op_variadicCount_ = operationChildCount[operationSp] - " + instruction.signature.valueCount); } @@ -1379,7 +1383,11 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, for (int i = 0; i < instruction.signature.localSetterCount; i++) { b.startAssign("argument.op_localSetter" + i + "_"); b.startStaticCall(types.LocalSetter, "create"); - b.string("((IntRef)((OperationLocalImpl)((Object[]) operationData[operationSp])[" + (argBase + i) + "]).index).value"); + if (inEmit) { + b.string("((OperationLocalImpl)arg" + (argBase + i) + ").index.value"); + } else { + b.string("((IntRef)((OperationLocalImpl)((Object[]) operationData[operationSp])[" + (argBase + i) + "]).index).value"); + } b.end(2); } @@ -1388,11 +1396,15 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, for (int i = 0; i < instruction.signature.localSetterRangeCount; i++) { b.startBlock(); - b.statement("OperationLocal[] argg = (OperationLocal[]) ((Object[]) operationData[operationSp])[" + (argBase + i) + "]"); + if (inEmit) { + b.statement("OperationLocal[] argg = arg" + (argBase + i)); + } else { + b.statement("OperationLocal[] argg = (OperationLocal[]) ((Object[]) operationData[operationSp])[" + (argBase + i) + "]"); + } b.statement("int[] indices = new int[argg.length]"); b.startFor().string("int ix = 0; ix < indices.length; ix++").end().startBlock(); - b.startAssign("indices[ix]").string("((IntRef) ((OperationLocalImpl) argg[ix]).index).value").end(); + b.startAssign("indices[ix]").string("((OperationLocalImpl) argg[ix]).index.value").end(); b.end(); b.startAssign("argument.op_localSetterRange" + i + "_"); From 107a2476303e3a1665330d8ae2cd6bd974d51f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Wed, 18 Jan 2023 10:47:04 +0100 Subject: [PATCH 292/312] Implement tracing collection --- .../generator/OperationsNodeFactory.java | 148 ++++++- .../operations/model/OperationsModel.java | 4 + .../operations/parser/OperationsParser.java | 34 ++ .../sl/operations/SLOperationRootNode.java | 7 +- .../truffle/sl/operations/decisions.json | 369 +++++++++--------- 5 files changed, 368 insertions(+), 194 deletions(-) diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index cffab8e81c83..307ceb45b5cf 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -86,8 +86,10 @@ import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror; import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement; import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror; +import com.oracle.truffle.dsl.processor.model.SpecializationData; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel; import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionField; +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind; import com.oracle.truffle.dsl.processor.operations.model.OperationModel; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.CustomSignature; import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind; @@ -158,6 +160,7 @@ public CodeTypeElement create() { operationNodeGen.add(new StoreLocalDataFactory().create()); } + operationNodeGen.add(createStaticConstructor()); operationNodeGen.add(createFrameDescriptorConstructor()); operationNodeGen.add(createFrameDescriptorBuliderConstructor()); @@ -188,6 +191,9 @@ public CodeTypeElement create() { if (model.generateUncached) { operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "uncachedExecuteCount")).createInitBuilder().string("16"); } + if (model.enableTracing) { + operationNodeGen.add(compFinal(1, new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean[].class), "basicBlockBoundary"))); + } operationNodeGen.add(createInterpreterField()); operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()")); @@ -349,6 +355,43 @@ private CodeVariableElement createInterpreterSwitch(CodeTypeElement interpreterT return fld; } + private CodeExecutableElement createStaticConstructor() { + CodeExecutableElement ctor = new CodeExecutableElement(Set.of(STATIC), null, ""); + CodeTreeBuilder b = ctor.createBuilder(); + + if (model.enableTracing) { + b.startStatement().startStaticCall(types.ExecutionTracer, "initialize"); + b.typeLiteral(model.templateType.asType()); + b.doubleQuote(model.decisionsFilePath); + + b.startNewArray(arrayOf(context.getType(String.class)), null); + b.string("null"); + for (InstructionModel instruction : model.getInstructions()) { + b.doubleQuote(instruction.name); + } + b.end(); + + b.startNewArray(arrayOf(context.getType(String[].class)), null); + b.string("null"); + for (InstructionModel instruction : model.getInstructions()) { + if (instruction.kind == InstructionKind.CUSTOM || instruction.kind == InstructionKind.CUSTOM_SHORT_CIRCUIT) { + b.startNewArray(arrayOf(context.getType(String.class)), null); + for (SpecializationData spec : instruction.nodeData.getSpecializations()) { + b.doubleQuote(spec.getId()); + } + b.end(); + } else { + b.string("null"); + } + } + b.end(); + + b.end(2); + } + + return ctor; + } + private CodeExecutableElement createFrameDescriptorConstructor() { CodeExecutableElement ctor = GeneratorUtils.createSuperConstructor(operationNodeGen, model.fdConstructor); ctor.getModifiers().clear(); @@ -717,7 +760,7 @@ class BuilderFactory { // this is per-function state that needs to be stored/restored when going into/out of // functions - CodeVariableElement[] builderState = new CodeVariableElement[]{ + List builderState = new ArrayList<>(List.of(new CodeVariableElement[]{ new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "bci"), new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"), @@ -743,11 +786,17 @@ class BuilderFactory { // must be last new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"), - }; + })); + + { + if (model.enableTracing) { + builderState.add(0, new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean[].class), "basicBlockBoundary")); + } + } class SavedStateFactory { private CodeTypeElement create() { - savedState.addAll(List.of(builderState)); + savedState.addAll(builderState); savedState.add(createConstructorUsingFields(Set.of(), savedState, null)); return savedState; @@ -772,7 +821,7 @@ private CodeTypeElement create() { operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex")); operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), types.Source), "sources")); - operationBuilder.addAll(List.of(builderState)); + operationBuilder.addAll(builderState); operationBuilder.add(createCreateLocal()); operationBuilder.add(createCreateLabel()); @@ -926,13 +975,16 @@ private CodeExecutableElement createBegin(OperationModel operation) { if (operation.kind == OperationKind.ROOT) { b.startIf().string("bc != null").end().startBlock(); // { b.startAssign("savedState").startNew(savedState.asType()); - b.variables(List.of(builderState)); + b.variables(builderState); b.end(2); b.end(); // } b.statement("bc = new short[32]"); b.statement("bci = 0"); b.statement("objs = new Object[32]"); + if (model.enableTracing) { + b.statement("basicBlockBoundary = new boolean[33]"); + } b.statement("operationStack = new int[8]"); b.statement("operationData = new Object[8]"); b.statement("operationChildCount = new int[8]"); @@ -1013,6 +1065,10 @@ private CodeExecutableElement createBegin(OperationModel operation) { b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp - 1], arg0, arg1)"); break; + case WHILE: + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } } return ex; @@ -1140,6 +1196,9 @@ private Element createEnd(OperationModel operation) { b.startAssign("result.nodes").string("nodes").end(); b.startAssign("result.bc").string("Arrays.copyOf(bc, bci)").end(); b.startAssign("result.objs").string("Arrays.copyOf(objs, bci)").end(); + if (model.enableTracing) { + b.startAssign("result.basicBlockBoundary").string("Arrays.copyOf(basicBlockBoundary, bci)").end(); + } b.startFor().string("int i = 0; i < bci; i++").end().startBlock(); b.startIf().string("objs[i] instanceof Node").end().startBlock(); b.statement("result.insert((Node) objs[i])"); @@ -1169,7 +1228,9 @@ private Element createEnd(OperationModel operation) { b.statement("bc = null"); b.end().startElseBlock(); // } { for (CodeVariableElement state : builderState) { - b.startAssign("this." + state.getName()).string("savedState." + state.getName()).end(); + if (state != null) { + b.startAssign("this." + state.getName()).string("savedState." + state.getName()).end(); + } } b.end(); @@ -1196,6 +1257,9 @@ private Element createEnd(OperationModel operation) { b.end(); break; case CUSTOM_SHORT_CIRCUIT: + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } b.statement("((IntRef) ((Object[]) operationData[operationSp])[0]).value = bci"); break; case SOURCE_SECTION: @@ -1213,6 +1277,14 @@ private Element createEnd(OperationModel operation) { b.statement("sourceIndexSp -= 1"); b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp], -1, -1)"); break; + case IF_THEN: + case IF_THEN_ELSE: + case CONDITIONAL: + case WHILE: + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } + break; default: if (operation.instruction != null) { buildEmitOperationInstruction(b, operation); @@ -1505,6 +1577,9 @@ private CodeExecutableElement createAfterChild() { b.end().startElseBlock(); b.statement("((IntRef) data).value = bci"); b.end(); + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } break; case CONDITIONAL: case IF_THEN_ELSE: @@ -1516,6 +1591,9 @@ private CodeExecutableElement createAfterChild() { b.end().startElseBlock(); b.statement("((IntRef[]) data)[1].value = bci"); b.end(); + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } break; case WHILE: b.startIf().string("childIndex == 0").end().startBlock(); @@ -1524,6 +1602,9 @@ private CodeExecutableElement createAfterChild() { buildEmitInstruction(b, model.branchInstruction, "((IntRef[]) data)[0]"); b.statement("((IntRef[]) data)[1].value = bci"); b.end(); + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } break; case TRY_CATCH: b.startIf().string("childIndex == 0").end().startBlock(); @@ -1533,6 +1614,9 @@ private CodeExecutableElement createAfterChild() { buildEmitInstruction(b, model.branchInstruction, "dArray[5]"); b.statement("dArray[2] = bci"); b.end(); + if (model.enableTracing) { + b.statement("basicBlockBoundary[bci] = true"); + } break; } @@ -1569,8 +1653,17 @@ private CodeExecutableElement createEmitInstruction() { b.end(2); b.startAssign("objs").startStaticCall(context.getType(Arrays.class), "copyOf"); b.string("objs"); - b.string("objs.length * 2"); + b.string("bc.length * 2"); b.end(2); + if (model.enableTracing) { + // since we can mark a start of the BB before it's first instruction is emitted, + // basicBlockBoundary must always be at least 1 longer than `bc` array to prevent + // ArrayIndexOutOfBoundsException + b.startAssign("basicBlockBoundary").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("basicBlockBoundary"); + b.string("(bc.length * 2) + 1"); + b.end(2); + } b.end(); // } b.statement("bc[bci] = (short) instr"); @@ -1913,13 +2006,33 @@ private CodeExecutableElement createContinueAt() { b.statement("int bci = startState & 0xffff"); b.statement("int sp = (startState >> 16) & 0xffff"); + if (model.enableTracing) { + b.declaration(context.getType(boolean[].class), "basicBlockBoundary", "$this.basicBlockBoundary"); + + b.declaration(types.ExecutionTracer, "tracer"); + + b.startAssign("tracer").startStaticCall(types.ExecutionTracer, "get"); + b.typeLiteral(model.templateType.asType()); + b.end(2); + + b.statement("tracer.startFunction($this)"); + + b.startTryBlock(); + } + + if (isUncached) { + b.statement("int uncachedExecuteCount = $this.uncachedExecuteCount"); + } + b.string("loop: ").startWhile().string("true").end().startBlock(); b.statement("int curOpcode = bc[bci]"); b.statement("Object curObj = objs[bci]"); - if (isUncached) { - b.statement("int uncachedExecuteCount = $this.uncachedExecuteCount"); + if (model.enableTracing) { + b.startIf().string("basicBlockBoundary[bci]").end().startBlock(); + b.statement("tracer.traceStartBasicBlock(bci)"); + b.end(); } b.startTryBlock(); @@ -1934,6 +2047,15 @@ private CodeExecutableElement createContinueAt() { b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock(); + if (model.enableTracing) { + b.startStatement().startCall("tracer.traceInstruction"); + b.string("bci"); + b.string(instr.id); + b.string(instr.isControlFlow() ? "1" : "0"); + b.string((instr.signature != null && instr.signature.isVariadic) ? "1" : "0"); + b.end(2); + } + switch (instr.kind) { case BRANCH: b.statement("int nextBci = ((IntRef) curObj).value"); @@ -2171,6 +2293,12 @@ private CodeExecutableElement createContinueAt() { b.end(); // while (true) + if (model.enableTracing) { + b.end().startFinallyBlock(); + b.statement("tracer.endFunction($this)"); + b.end(); + } + return ex; } @@ -2181,6 +2309,8 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i String extraArguments = "$this, objs, bci, sp"; + // todo: trace active specializations + if (signature.isVariadic) { b.startAssign("int variadicCount"); b.startParantheses().cast(uncachedType).string("curObj").end().string(".op_variadicCount_"); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index ea6dc547cf39..e41202f86a50 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -92,6 +92,10 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot public TypeSystemData typeSystem; public Set boxingEliminatedTypes; + public boolean enableTracing; + public String decisionsFilePath; + public boolean enableOptimizations; + public OperationModel blockOperation; public OperationModel rootOperation; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index a97a659e67de..223fd6d077de 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -44,6 +44,8 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getQualifiedName; import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; +import java.io.File; +import java.nio.file.Path; import java.util.EnumSet; import java.util.HashSet; import java.util.List; @@ -60,7 +62,9 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; +import com.oracle.truffle.dsl.processor.TruffleProcessorOptions; import com.oracle.truffle.dsl.processor.java.ElementUtils; +import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; import com.oracle.truffle.dsl.processor.parser.AbstractParser; @@ -216,9 +220,39 @@ protected OperationsModel parse(Element element, List mirror) new CustomOperationParser(model, mir, true).parse(te); } + AnnotationValue decisionsFilePathValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false); + if (decisionsFilePathValue != null) { + model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFilePathValue.getValue()); + } + + // todo: find and bind decisionOverrideFiles + + if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) { + model.enableTracing = true; + } else if ((boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true).getValue()) { + model.addWarning("Operation DSL execution tracing is forced on. Use this only during development."); + model.enableTracing = true; + } + + if (model.enableTracing && decisionsFilePathValue == null) { + model.addError(generateOperationsMirror, null, + "Tracing Operation DSL execution is not supported without specifying decisionsFile path. Add 'decisionsFile=\"...\"' to @GenerateOperations annotation to fix this error."); + } + + model.enableOptimizations = decisionsFilePathValue != null && !model.enableTracing; + + if (model.enableOptimizations) { + // todo: read from decisions file path and apply optimizations + } + return model; } + private String resolveElementRelativePath(Element element, String relativePath) { + File filePath = CompilerFactory.getCompiler(element).getEnclosingSourceFile(processingEnv, element); + return Path.of(filePath.getPath()).getParent().resolve(relativePath).toAbsolutePath().toString(); + } + private TypeMirror getTypeMirror(AnnotationValue value) throws AssertionError { if (value.getValue() instanceof Class) { return context.getType((Class) value.getValue()); diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java index dc866f3c7888..4b04e66561f9 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java @@ -88,7 +88,8 @@ @GenerateOperations(// languageClass = SLLanguage.class, // decisionsFile = "decisions.json", // - boxingEliminationTypes = {long.class, boolean.class}) + boxingEliminationTypes = {long.class, boolean.class}, // + forceTracing = true) @GenerateUncached @TypeSystemReference(SLTypes.class) @OperationProxy(SLAddNode.class) @@ -131,10 +132,6 @@ public void setTSName(TruffleString tsName) { this.tsName = tsName; } -// @GenerateOperations.Metadata // -// public static final MetadataKey MethodName = new -// MetadataKey<>(SLStrings.EMPTY_STRING); - private TruffleString tsName; @Operation diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json index 99f39281b7cc..8cbfac3333aa 100644 --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json @@ -3,29 +3,23 @@ "Do not modify, as it will be overwritten when running with tracing support.", "Use the overrides file to alter the optimisation decisions.", { - "specializations": ["FromBigNumber"], - "_comment": "value: 1.0", - "id": "quicken:c.SLUnbox:FromBigNumber", - "type": "Quicken", - "operation": "SLUnbox" - }, - { - "specializations": [ - "FromLong", - "FromBigNumber" + "instructions": [ + "load.local", + "c.SLUnbox" ], - "_comment": "value: 0.6024272640873358", - "id": "quicken:c.SLUnbox:FromLong,FromBigNumber", - "type": "Quicken", - "operation": "SLUnbox" + "_comment": "value: 1.0", + "id": "si:load.local,c.SLUnbox", + "type": "SuperInstruction" }, { "instructions": [ + "load.local", + "c.SLUnbox", "load.local", "c.SLUnbox" ], - "_comment": "value: 0.5521547287171192", - "id": "si:load.local,c.SLUnbox", + "_comment": "value: 0.7745428067984501", + "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox", "type": "SuperInstruction" }, { @@ -37,7 +31,7 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.46205691923330927", + "_comment": "value: 0.7517738155317384", "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, @@ -52,38 +46,38 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 0.4248610082583593", + "_comment": "value: 0.7230805583830159", "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ + "store.local", "load.argument", "store.local", "load.local", "c.SLUnbox", "load.local", "c.SLUnbox", - "c.SLAdd", - "c.SLUnbox" + "c.SLAdd" ], - "_comment": "value: 0.424851928069918", - "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", + "_comment": "value: 0.7230670863663191", + "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, { "instructions": [ - "store.local", "load.argument", "store.local", "load.local", "c.SLUnbox", "load.local", "c.SLUnbox", - "c.SLAdd" + "c.SLAdd", + "c.SLUnbox" ], - "_comment": "value: 0.424851928069918", - "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd", + "_comment": "value: 0.7230670863663191", + "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { @@ -93,20 +87,20 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 0.38144358277139456", + "_comment": "value: 0.565936968069182", "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ "c.SLUnbox", - "load.local.boxed", + "load.local", "c.SLUnbox", "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 0.34597939344917733", - "id": "si:c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "_comment": "value: 0.5389884440034557", + "id": "si:c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, { @@ -118,70 +112,60 @@ "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 0.3178368627401241", + "_comment": "value: 0.47156549110846896", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, - { - "specializations": ["FromLong"], - "_comment": "value: 0.31598897232733303", - "id": "quicken:c.SLUnbox:FromLong", - "type": "Quicken", - "operation": "SLUnbox" - }, { "instructions": [ + "load.local", "c.SLUnbox", - "load.constant", + "load.local", "c.SLUnbox", - "c.SLAdd", + "c.SLLessOrEqual", "c.SLUnbox" ], - "_comment": "value: 0.2912716904803016", - "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", + "_comment": "value: 0.4491570366695464", + "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ - "load.local", "c.SLUnbox", - "load.local.boxed", + "load.constant", "c.SLUnbox", - "c.SLLessOrEqual", + "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.28831616120764775", - "id": "si:load.local,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "_comment": "value: 0.4321703205056925", + "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ - "load.local", - "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", - "load.constant", - "c.SLUnbox" + "load.local" ], - "_comment": "value: 0.23307935709959757", - "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", + "_comment": "value: 0.37728831826463316", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local", "type": "SuperInstruction" }, { "instructions": [ + "load.local", + "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", "load.constant", - "c.SLUnbox", - "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.23307935709959757", - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", + "_comment": "value: 0.34581319658879983", + "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox", "type": "SuperInstruction" }, { @@ -195,45 +179,38 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 0.23307935709959757", + "_comment": "value: 0.34581319658879983", "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, - { - "specializations": ["FromBoolean"], - "_comment": "value: 0.22454902451391445", - "id": "quicken:c.SLUnbox:FromBoolean", - "type": "Quicken", - "operation": "SLUnbox" - }, { "instructions": [ "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", - "load.local", "load.constant", - "c.SLReadProperty", + "c.SLUnbox", + "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.21189225073657625", - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", + "_comment": "value: 0.34581319658879983", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ - "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", "load.local", - "load.constant", - "c.SLReadProperty" + "c.SLUnbox", + "c.SLLessOrEqual", + "c.SLUnbox" ], - "_comment": "value: 0.21189225073657625", - "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", + "_comment": "value: 0.3144099256686825", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", "type": "SuperInstruction" }, { @@ -247,7 +224,7 @@ "c.SLUnbox", "c.SLAdd" ], - "_comment": "value: 0.21189225073657625", + "_comment": "value: 0.31437849096305676", "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd", "type": "SuperInstruction" }, @@ -262,7 +239,7 @@ "load.local", "load.constant" ], - "_comment": "value: 0.21189225073657625", + "_comment": "value: 0.31437849096305676", "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant", "type": "SuperInstruction" }, @@ -277,7 +254,7 @@ "c.SLUnbox", "load.constant" ], - "_comment": "value: 0.21189225073657625", + "_comment": "value: 0.31437849096305676", "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant", "type": "SuperInstruction" }, @@ -292,41 +269,49 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.21189225073657625", + "_comment": "value: 0.31437849096305676", "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, { "instructions": [ + "load.local", "load.constant", - "c.SLFunctionLiteral", + "c.SLReadProperty", + "c.SLUnbox", "load.local", + "load.constant", + "c.SLReadProperty", "c.SLUnbox" ], - "_comment": "value: 0.2089087602487222", - "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", + "_comment": "value: 0.31437849096305676", + "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox", "type": "SuperInstruction" }, - { - "specializations": ["Add0"], - "_comment": "value: 0.20565560257715926", - "id": "quicken:c.SLAdd:Add0", - "type": "Quicken", - "operation": "SLAdd" - }, { "instructions": [ + "load.constant", "load.local", "load.constant", "c.SLReadProperty", "c.SLUnbox", - "load.local.boxed", - "c.SLUnbox", - "c.SLLessOrEqual", + "load.local", + "load.constant", + "c.SLReadProperty" + ], + "_comment": "value: 0.31437849096305676", + "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.constant", + "c.SLFunctionLiteral", + "load.local", "c.SLUnbox" ], - "_comment": "value: 0.20182131284535343", - "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local.boxed,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox", + "_comment": "value: 0.3099590279619191", + "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, { @@ -339,17 +324,10 @@ "c.SLAdd", "c.SLUnbox" ], - "_comment": "value: 0.19911210170041663", + "_comment": "value: 0.29544260920887183", "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox", "type": "SuperInstruction" }, - { - "specializations": ["ReadSLObject0"], - "_comment": "value: 0.13318633036723454", - "id": "quicken:c.SLReadProperty:ReadSLObject0", - "type": "Quicken", - "operation": "SLReadProperty" - }, { "instructions": [ "pop", @@ -358,7 +336,7 @@ "load.local", "c.SLUnbox" ], - "_comment": "value: 0.12109108697350401", + "_comment": "value: 0.17966024856940013", "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox", "type": "SuperInstruction" }, @@ -367,10 +345,53 @@ "c.SLToBoolean", "branch.false" ], - "_comment": "value: 0.1123275520878524", + "_comment": "value: 0.1666730106322011", "id": "si:c.SLToBoolean,branch.false", "type": "SuperInstruction" }, + { + "instructions": [ + "pop", + "branch" + ], + "_comment": "value: 0.16642281603640438", + "id": "si:pop,branch", + "type": "SuperInstruction" + }, + { + "instructions": [ + "c.SLUnbox", + "load.local", + "c.SLUnbox", + "c.SLLessThan", + "c.SLUnbox" + ], + "_comment": "value: 0.10793181021136097", + "id": "si:c.SLUnbox,load.local,c.SLUnbox,c.SLLessThan,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "c.SLWriteProperty", + "c.SLUnbox" + ], + "_comment": "value: 0.09882772070584814", + "id": "si:c.SLWriteProperty,c.SLUnbox", + "type": "SuperInstruction" + }, + { + "instructions": [ + "load.local", + "c.SLUnbox", + "load.local", + "c.SLUnbox", + "c.SLLessThan", + "c.SLUnbox" + ], + "_comment": "value: 0.08996313371938859", + "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLLessThan,c.SLUnbox", + "type": "SuperInstruction" + }, { "_comment": "value: 3.596216E7", "instruction": "c.SLUnbox", @@ -431,12 +452,6 @@ "id": "c:branch", "type": "CommonInstruction" }, - { - "_comment": "value: 2.9327091E7", - "instruction": "load.local.boxed", - "id": "c:load.local.boxed", - "type": "CommonInstruction" - }, { "_comment": "value: 2.5546216E7", "instruction": "c.SLLessOrEqual", @@ -499,14 +514,14 @@ }, { "_comment": "value: 9241911.0", - "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", - "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", + "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", "type": "CommonInstruction" }, { "_comment": "value: 9241911.0", - "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", - "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant", + "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", + "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", "type": "CommonInstruction" }, { @@ -523,26 +538,20 @@ }, { "_comment": "value: 9241911.0", - "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", - "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "instruction": "si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", "type": "CommonInstruction" }, { "_comment": "value: 9241911.0", - "instruction": "si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", - "id": "c:si.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 8821533.0", - "instruction": "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", - "id": "c:si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", - "type": "CommonInstruction" - }, - { - "_comment": "value: 8821533.0", - "instruction": "si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", - "id": "c:si.load.local.c.SLUnbox.load.local.boxed.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "_comment": "value: 7141365.0", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox", "type": "CommonInstruction" }, { @@ -552,33 +561,33 @@ "type": "CommonInstruction" }, { - "_comment": "value: 799160.0", - "instruction": "c.SLUnbox.q.FromLong", - "id": "c:c.SLUnbox.q.FromLong", + "_comment": "value: 799136.0", + "instruction": "si.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 799160.0", - "instruction": "c.SLUnbox.q.FromBigNumber", - "id": "c:c.SLUnbox.q.FromBigNumber", + "_comment": "value: 798495.0", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 799136.0", - "instruction": "si.load.local.c.SLUnbox", - "id": "c:si.load.local.c.SLUnbox", + "_comment": "value: 567798.0", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", "type": "CommonInstruction" }, { "_comment": "value: 567798.0", - "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", - "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "instruction": "si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local", + "id": "c:si.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local", "type": "CommonInstruction" }, { "_comment": "value: 567798.0", - "instruction": "c.SLReadProperty.q.ReadSLObject0", - "id": "c:c.SLReadProperty.q.ReadSLObject0", + "instruction": "si.c.SLWriteProperty.c.SLUnbox", + "id": "c:si.c.SLWriteProperty.c.SLUnbox", "type": "CommonInstruction" }, { @@ -589,8 +598,14 @@ }, { "_comment": "value: 567798.0", - "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", - "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd", + "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox", + "type": "CommonInstruction" + }, + { + "_comment": "value: 547148.0", + "instruction": "si.pop.branch", + "id": "c:si.pop.branch", "type": "CommonInstruction" }, { @@ -600,27 +615,27 @@ "type": "CommonInstruction" }, { - "_comment": "value: 547136.0", - "instruction": "c.SLUnbox.q.FromBoolean", - "id": "c:c.SLUnbox.q.FromBoolean", + "_comment": "value: 546483.0", + "instruction": "si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox", "type": "CommonInstruction" }, { "_comment": "value: 546483.0", - "instruction": "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", - "id": "c:si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 340063.0", - "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", - "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "_comment": "value: 546483.0", + "instruction": "si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "id": "c:si.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", "type": "CommonInstruction" }, { - "_comment": "value: 340063.0", - "instruction": "c.SLUnbox.q.FromLong", - "id": "c:c.SLUnbox.q.FromLong", + "_comment": "value: 360029.0", + "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", "type": "CommonInstruction" }, { @@ -631,26 +646,26 @@ }, { "_comment": "value: 340063.0", - "instruction": "si.load.local.c.SLUnbox", - "id": "c:si.load.local.c.SLUnbox", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox", "type": "CommonInstruction" }, { "_comment": "value: 340063.0", - "instruction": "c.SLAdd.q.Add0", - "id": "c:c.SLAdd.q.Add0", + "instruction": "si.pop.branch", + "id": "c:si.pop.branch", "type": "CommonInstruction" }, { "_comment": "value: 340063.0", - "instruction": "c.SLUnbox.q.FromBoolean", - "id": "c:c.SLUnbox.q.FromBoolean", + "instruction": "si.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox", "type": "CommonInstruction" }, { "_comment": "value: 340063.0", - "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", - "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox", + "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox", "type": "CommonInstruction" }, { @@ -661,14 +676,8 @@ }, { "_comment": "value: 340063.0", - "instruction": "c.SLUnbox.q.FromBigNumber", - "id": "c:c.SLUnbox.q.FromBigNumber", - "type": "CommonInstruction" - }, - { - "_comment": "value: 252677.0", - "instruction": "c.SLAdd.q.Add0", - "id": "c:c.SLAdd.q.Add0", + "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", + "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", "type": "CommonInstruction" }, { @@ -689,12 +698,6 @@ "id": "c:si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox", "type": "CommonInstruction" }, - { - "_comment": "value: 252000.0", - "instruction": "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", - "id": "c:si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", - "type": "CommonInstruction" - }, { "_comment": "value: 31367.0", "instruction": "c.SLLogicalNot", @@ -725,6 +728,12 @@ "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", "type": "CommonInstruction" }, + { + "_comment": "value: 219.0", + "instruction": "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "id": "c:si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox", + "type": "CommonInstruction" + }, { "_comment": "value: 203.0", "instruction": "sc.SLOr", @@ -737,16 +746,16 @@ "id": "c:sc.SLAnd", "type": "CommonInstruction" }, - { - "_comment": "value: 93.0", - "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", - "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox", - "type": "CommonInstruction" - }, { "_comment": "value: 54.0", "instruction": "c.SLDiv", "id": "c:c.SLDiv", "type": "CommonInstruction" + }, + { + "_comment": "value: 12.0", + "instruction": "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", + "id": "c:si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd", + "type": "CommonInstruction" } ] \ No newline at end of file From d2ef780fe83b584d62d35ecbff6256e7fe7ac8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 Jan 2023 12:19:47 +0100 Subject: [PATCH 293/312] Implement FinallyTry --- .../introspection/ExceptionHandler.java | 6 +- .../introspection/OperationIntrospection.java | 2 +- .../generator/OperationsNodeFactory.java | 397 ++++++++++++++++-- .../operations/model/InstructionModel.java | 8 +- .../operations/model/OperationsModel.java | 2 + .../parser/CustomOperationParser.java | 12 +- 6 files changed, 388 insertions(+), 39 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java index 6876debfd454..082519745a10 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/ExceptionHandler.java @@ -60,8 +60,12 @@ public int getHandlerIndex() { return (int) data[2]; } + public int getExceptionVariableIndex() { + return (int) data[3]; + } + @Override public String toString() { - return String.format("[%04x : %04x] -> %04x", getStartIndex(), getEndIndex(), getHandlerIndex()); + return String.format("[%04x : %04x] -> %04x ex: local(%d)", getStartIndex(), getEndIndex(), getHandlerIndex(), getExceptionVariableIndex()); } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java index 083574b413d1..aaa0365b4d5c 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/introspection/OperationIntrospection.java @@ -61,7 +61,7 @@ static OperationIntrospection create(Object... data) { // format: [int 0, Object[] instructions, Object[] exHandlers, Object[] sourceInfo or null] // instruction: [int index, String name, short[] bytes, Object[] argumentValues] // argumentValue: [ArgumentKind kind, Object value] - // exHandler: [int startIndex, int endIndex, int handlerIndex] + // exHandler: [int startIndex, int endIndex, int handlerIndex, int exVariable] // sourceInfo: [int startIndex, int endIndex, SourceSection ss] private OperationIntrospection(Object[] data) { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java index 307ceb45b5cf..f20f95c109fc 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java @@ -53,6 +53,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -251,6 +252,7 @@ private CodeExecutableElement createGetSourceSection() { private CodeExecutableElement createGetSourceSectionAtBci() { CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationRootNode, "getSourceSectionAtBci"); + ex.renameArguments("bci"); CodeTreeBuilder b = ex.createBuilder(); b.startIf().string("sourceInfo == null || sourceInfo.length == 0").end().startBlock(); @@ -417,6 +419,7 @@ private CodeExecutableElement createFrameDescriptorBuliderConstructor() { private CodeExecutableElement createExecute() { CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute"); + ex.renameArguments("frame"); CodeTreeBuilder b = ex.createBuilder(); // todo: only generate executeProlog/Epilog calls and the try/finally if they are overridden @@ -432,7 +435,7 @@ private CodeExecutableElement createExecute() { b.startWhile().string("true").end().startBlock(); b.startAssign("state").startCall("interpreter.continueAt"); - b.string("this, frame, bc, objs, handlers, state"); + b.string("this, frame, bc, objs, handlers, state, numLocals"); if (model.hasBoxingElimination()) { b.string("localBoxingState"); } @@ -540,6 +543,7 @@ private CodeExecutableElement createGetIntrospectionData() { // fall-through case LOAD_LOCAL_MATERIALIZED: case STORE_LOCAL_MATERIALIZED: + case THROW: buildIntrospectionArgument(b, "LOCAL", "((IntRef) data).value"); break; case CUSTOM_SHORT_CIRCUIT: @@ -558,8 +562,16 @@ private CodeExecutableElement createGetIntrospectionData() { b.end(); + b.statement("Object[] exHandlersInfo = new Object[handlers.length / 5]"); + + b.startFor().string("int idx = 0; idx < exHandlersInfo.length; idx++").end().startBlock(); + b.statement("exHandlersInfo[idx] = new Object[]{ handlers[idx*5], handlers[idx*5 + 1], handlers[idx*5 + 2], handlers[idx*5 + 4] }"); + b.end(); + + // todo: source info + b.startReturn().startStaticCall(types.OperationIntrospection_Provider, "create"); - b.string("new Object[]{0, instructions, new Object[0], null}"); + b.string("new Object[]{0, instructions, exHandlersInfo, null}"); b.end(2); return ex; @@ -607,7 +619,7 @@ private CodeExecutableElement createDoPopObject() { CodeTreeBuilder b = ex.createBuilder(); - b.startIf().string("boxing == 0xffff0000 || frame.isObject(slot)").end().startBlock(); // { + b.startIf().string("(boxing & 0xffff000) == 0xffff0000 || frame.isObject(slot)").end().startBlock(); // { b.startReturn().string("frame.getObject(slot)").end(); b.end(); // } @@ -631,7 +643,7 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) { CodeTreeBuilder b = ex.createBuilder(); - b.startIf().string("boxing == 0xffff0000").end().startBlock(); // { + b.startIf().string("(boxing & 0xffff000) == 0xffff0000").end().startBlock(); // { b.statement("Object result = frame.getObject(slot)"); b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // { @@ -757,14 +769,16 @@ private CodeExecutableElement createChangeInterpreters() { class BuilderFactory { CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState"); + CodeTypeElement finallyTryContext = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "FinallyTryContext"); // this is per-function state that needs to be stored/restored when going into/out of // functions - List builderState = new ArrayList<>(List.of(new CodeVariableElement[]{ + List builderState = new ArrayList<>(List.of( new CodeVariableElement(Set.of(PRIVATE), context.getType(short[].class), "bc"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "bci"), new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "objs"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationStack"), + new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationStartSpStack"), new CodeVariableElement(Set.of(PRIVATE), context.getType(Object[].class), "operationData"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "operationChildCount"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "opSeqNumStack"), @@ -783,10 +797,10 @@ class BuilderFactory { new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "opSeqNum"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int[].class), "sourceInfo"), new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "sourceInfoIndex"), + new CodeVariableElement(Set.of(PRIVATE), finallyTryContext.asType(), "finallyTryContext"), // must be last - new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"), - })); + new CodeVariableElement(Set.of(PRIVATE), savedState.asType(), "savedState"))); { if (model.enableTracing) { @@ -803,11 +817,49 @@ private CodeTypeElement create() { } } + class FinallyTryContextFactory { + private CodeTypeElement create() { + if (model.enableTracing) { + finallyTryContext.add(new CodeVariableElement(context.getType(boolean[].class), "basicBlockBoundary")); + } + finallyTryContext.addAll(List.of( + new CodeVariableElement(context.getType(short[].class), "bc"), + new CodeVariableElement(context.getType(int.class), "bci"), + new CodeVariableElement(context.getType(Object[].class), "objs"), + new CodeVariableElement(context.getType(int.class), "curStack"), + new CodeVariableElement(context.getType(int.class), "maxStack"), + new CodeVariableElement(context.getType(int[].class), "sourceInfo"), + new CodeVariableElement(context.getType(int.class), "sourceInfoIndex"), + new CodeVariableElement(context.getType(int[].class), "exHandlers"), + new CodeVariableElement(context.getType(int.class), "exHandlerCount"), + new CodeVariableElement(context.getType(int.class), "finallyTrySequenceNumber"), + new CodeVariableElement(generic(context.getDeclaredType(HashSet.class), intRef.asType()), "outerReferences"), + new CodeVariableElement(finallyTryContext.asType(), "finallyTryContext"))); + + finallyTryContext.add(GeneratorUtils.createConstructorUsingFields(Set.of(), finallyTryContext, null)); + + // these could be merged with their counterparts above + finallyTryContext.addAll(List.of( + new CodeVariableElement(context.getType(short[].class), "handlerBc"), + new CodeVariableElement(context.getType(Object[].class), "handlerObjs"), + new CodeVariableElement(context.getType(int.class), "handlerMaxStack"), + new CodeVariableElement(context.getType(int[].class), "handlerSourceInfo"), + new CodeVariableElement(context.getType(int[].class), "handlerExHandlers"))); + + if (model.enableTracing) { + finallyTryContext.add(new CodeVariableElement(context.getType(boolean[].class), "handlerBasicBlockBoundary")); + } + + return finallyTryContext; + } + } + private CodeTypeElement create() { operationBuilder.setSuperClass(types.OperationBuilder); operationBuilder.setEnclosingElement(operationNodeGen); operationBuilder.add(new SavedStateFactory().create()); + operationBuilder.add(new FinallyTryContextFactory().create()); operationBuilder.add(createConstructor()); @@ -840,8 +892,10 @@ private CodeTypeElement create() { operationBuilder.add(createEmitHelperBegin()); operationBuilder.add(createBeforeChild()); operationBuilder.add(createAfterChild()); - operationBuilder.add(createEmitInstruction()); - operationBuilder.add(createdoEmitSourceInfo()); + operationBuilder.add(createDoEmitFinallyHandler()); + operationBuilder.add(createDoEmitInstruction()); + operationBuilder.add(createDoCreateExceptionHandler()); + operationBuilder.add(createDoEmitSourceInfo()); operationBuilder.add(createFinish()); operationBuilder.add(createDoEmitLeaves()); @@ -886,6 +940,7 @@ private CodeExecutableElement createCreateLabel() { b.startReturn().startNew(operationLabelImpl.asType()); b.startNew(intRef.asType()).string("-1").end(); b.string("opSeqNumStack[operationSp - 1]"); + b.string("finallyTryContext == null ? -1 : finallyTryContext.finallyTrySequenceNumber"); b.end(2); return ex; @@ -931,6 +986,10 @@ private CodeExecutableElement createBeginHelper() { b.string("operationStack"); b.string("operationStack.length * 2"); b.end(2); + b.startAssign("operationStartSpStack").startStaticCall(context.getType(Arrays.class), "copyOf"); + b.string("operationStartSpStack"); + b.string("operationStartSpStack.length * 2"); + b.end(2); b.startAssign("operationChildCount").startStaticCall(context.getType(Arrays.class), "copyOf"); b.string("operationChildCount"); b.string("operationChildCount.length * 2"); @@ -948,6 +1007,7 @@ private CodeExecutableElement createBeginHelper() { b.statement("operationStack[operationSp] = id"); b.statement("operationChildCount[operationSp] = 0"); b.statement("operationData[operationSp] = data"); + b.statement("operationStartSpStack[operationSp] = curStack"); b.statement("opSeqNumStack[operationSp++] = opSeqNum++"); return ex; @@ -987,6 +1047,7 @@ private CodeExecutableElement createBegin(OperationModel operation) { } b.statement("operationStack = new int[8]"); b.statement("operationData = new Object[8]"); + b.statement("operationStartSpStack = new int[8]"); b.statement("operationChildCount = new int[8]"); b.statement("opSeqNumStack = new int[8]"); b.statement("opSeqNum = 0"); @@ -1069,6 +1130,46 @@ private CodeExecutableElement createBegin(OperationModel operation) { if (model.enableTracing) { b.statement("basicBlockBoundary[bci] = true"); } + break; + case FINALLY_TRY: + case FINALLY_TRY_NO_EXCEPT: + b.startAssign("finallyTryContext").startNew(finallyTryContext.asType()); + if (model.enableTracing) { + b.string("basicBlockBoundary"); + } + b.string("bc"); + b.string("bci"); + b.string("objs"); + b.string("curStack"); + b.string("maxStack"); + b.string("sourceInfo"); + b.string("sourceInfoIndex"); + b.string("exHandlers"); + b.string("exHandlerCount"); + b.string("opSeqNum - 1"); + b.string("new HashSet<>()"); + b.string("finallyTryContext"); + b.end(2); + + b.statement("bc = new short[16]"); + b.statement("bci = 0"); + b.statement("objs = new Object[16]"); + b.statement("curStack = 0"); + b.statement("maxStack = 0"); + if (model.enableTracing) { + b.statement("basicBlockBoundary = new boolean[17]"); + b.statement("basicBlockBoundary[0] = true"); + } + + b.startIf().string("withSource").end().startBlock(); + b.statement("sourceInfo = new int[15]"); + b.statement("sourceInfoIndex = 0"); + b.end(); + + b.statement("exHandlers = new int[10]"); + b.statement("exHandlerCount = 0"); + + break; } return ex; @@ -1244,16 +1345,8 @@ private Element createEnd(OperationModel operation) { b.statement("Object[] data = (Object[])operationData[operationSp]"); b.statement("((IntRef) data[5]).value = bci"); - b.startIf().string("exHandlers.length <= exHandlerCount + 5").end().startBlock(); - b.statement("exHandlers = Arrays.copyOf(exHandlers, exHandlers.length * 2)"); - b.end(); - - b.statement("exHandlers[exHandlerCount++] = (int) data[0]"); - b.statement("exHandlers[exHandlerCount++] = (int) data[1]"); - b.statement("exHandlers[exHandlerCount++] = (int) data[2]"); - b.statement("exHandlers[exHandlerCount++] = (int) data[3]"); - b.statement("exHandlers[exHandlerCount++] = ((OperationLocalImpl) data[4]).index.value"); - + // todo: ordering is bad, this should be moved to after the first child + b.statement("doCreateExceptionHandler((int) data[0], (int) data[1], (int) data[2], (int) data[3], ((OperationLocalImpl) data[4]).index.value)"); b.end(); break; case CUSTOM_SHORT_CIRCUIT: @@ -1285,6 +1378,34 @@ private Element createEnd(OperationModel operation) { b.statement("basicBlockBoundary[bci] = true"); } break; + case FINALLY_TRY: + b.statement("FinallyTryContext ctx = (FinallyTryContext) operationData[operationSp]"); + b.statement("int exceptionLocal = numLocals++"); + b.statement("int exHandlerIndex = doCreateExceptionHandler(ctx.bci, bci, -1, curStack, exceptionLocal)"); + + b.statement("doEmitFinallyHandler(ctx)"); + + b.statement("IntRef endBranch = new IntRef(-1)"); + buildEmitInstruction(b, model.branchInstruction, "endBranch"); + + // set handlerBci for the exception handler + b.statement("exHandlers[exHandlerIndex + 2] = bci"); + + b.statement("doEmitFinallyHandler(ctx)"); + + buildEmitInstruction(b, model.throwInstruction, "new IntRef(exceptionLocal)"); + + b.statement("endBranch.value = bci"); + + break; + case FINALLY_TRY_NO_EXCEPT: + b.statement("FinallyTryContext ctx = (FinallyTryContext) operationData[operationSp]"); + b.statement("doEmitFinallyHandler(ctx)"); + break; + case RETURN: + b.statement("doEmitLeaves(-1)"); + buildEmitOperationInstruction(b, operation); + break; default: if (operation.instruction != null) { buildEmitOperationInstruction(b, operation); @@ -1407,11 +1528,12 @@ private CodeExecutableElement createEmit(OperationModel operation) { buildThrowIllegalStateException(b, "\"Branch must be targeting a label that is declared in an enclosing operation. Jumps into other operations are not permitted.\""); b.end(); + b.startIf().string("finallyTryContext != null && lbl.finallyTryOp != finallyTryContext.finallyTrySequenceNumber").end().startBlock(); + b.statement("finallyTryContext.outerReferences.add(lbl.index)"); + b.end(); + b.statement("doEmitLeaves(lbl.declaringOp)"); break; - case RETURN: - b.statement("doEmitLeave(-1)"); - break; } if (operation.instruction != null) { @@ -1618,6 +1740,36 @@ private CodeExecutableElement createAfterChild() { b.statement("basicBlockBoundary[bci] = true"); } break; + case FINALLY_TRY: + case FINALLY_TRY_NO_EXCEPT: + b.startIf().string("childIndex == 0").end().startBlock(); + b.statement("finallyTryContext.handlerBc = Arrays.copyOf(bc, bci)"); + b.statement("finallyTryContext.handlerObjs = Arrays.copyOf(objs, bci)"); + b.statement("finallyTryContext.handlerMaxStack = maxStack"); + if (model.enableTracing) { + b.statement("finallyTryContext.handlerBasicBlockBoundary = Arrays.copyOf(basicBlockBoundary, bci + 1)"); + } + b.startIf().string("withSource").end().startBlock(); + b.statement("finallyTryContext.handlerSourceInfo = Arrays.copyOf(sourceInfo, sourceInfoIndex)"); + b.end(); + b.statement("finallyTryContext.handlerExHandlers = Arrays.copyOf(exHandlers, exHandlerCount)"); + + b.statement("operationData[operationSp - 1] = finallyTryContext"); + b.statement("bc = finallyTryContext.bc"); + b.statement("bci = finallyTryContext.bci"); + b.statement("objs = finallyTryContext.objs"); + b.statement("curStack = finallyTryContext.curStack"); + b.statement("maxStack = finallyTryContext.maxStack"); + if (model.enableTracing) { + b.statement("basicBlockBoundary = finallyTryContext.basicBlockBoundary"); + } + b.statement("sourceInfo = finallyTryContext.sourceInfo"); + b.statement("sourceInfoIndex = finallyTryContext.sourceInfoIndex"); + b.statement("exHandlers = finallyTryContext.exHandlers"); + b.statement("exHandlerCount = finallyTryContext.exHandlerCount"); + b.statement("finallyTryContext = finallyTryContext.finallyTryContext"); + b.end(); + break; } b.statement("break"); @@ -1639,7 +1791,145 @@ private void buildThrowIllegalStateException(CodeTreeBuilder b, String reasonCod b.end(2); } - private CodeExecutableElement createEmitInstruction() { + private void buildCalculateNewLengthOfArray(CodeTreeBuilder b, String start, String target) { + b.statement("int resultLength = " + start); + + b.startWhile().string(target, " > resultLength").end().startBlock(); + b.statement("resultLength *= 2"); + b.end(); + } + + private CodeExecutableElement createDoEmitFinallyHandler() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitFinallyHandler"); + ex.addParameter(new CodeVariableElement(finallyTryContext.asType(), "context")); + CodeTreeBuilder b = ex.createBuilder(); + + b.statement("int offsetBci = bci"); + b.statement("short[] handlerBc = context.handlerBc"); + b.statement("Object[] handlerObjs = context.handlerObjs"); + + // b.statement("System.err.println(Arrays.toString(handlerBc))"); + + // resize all arrays + b.startIf().string("bci + handlerBc.length > bc.length").end().startBlock(); + buildCalculateNewLengthOfArray(b, "bc.length", "bci + handlerBc.length"); + + b.statement("bc = Arrays.copyOf(bc, resultLength)"); + b.statement("objs = Arrays.copyOf(objs, resultLength)"); + if (model.enableTracing) { + b.statement("basicBlockBoundary = Arrays.copyOf(basicBlockBoundary, resultLength + 1)"); + } + b.end(); + + b.startIf().string("withSource && sourceInfoIndex + context.handlerSourceInfo.length > sourceInfo.length").end().startBlock(); + buildCalculateNewLengthOfArray(b, "sourceInfo.length", "sourceInfoIndex + context.handlerSourceInfo.length "); + b.statement("sourceInfo = Arrays.copyOf(sourceInfo, resultLength)"); + b.end(); + + b.startIf().string("exHandlerCount + context.handlerExHandlers.length > exHandlers.length").end().startBlock(); + buildCalculateNewLengthOfArray(b, "exHandlers.length", "exHandlerCount + context.handlerExHandlers.length"); + b.statement("exHandlers = Arrays.copyOf(exHandlers, resultLength)"); + b.end(); + + b.statement("System.arraycopy(context.handlerBc, 0, bc, bci, context.handlerBc.length)"); + if (model.enableTracing) { + b.statement("System.arraycopy(context.handlerBasicBlockBoundary, 0, basicBlockBoundary, bci, context.handlerBasicBlockBoundary.length)"); + } + + b.startFor().string("int idx = 0; idx < handlerBc.length; idx++").end().startBlock(); + b.startSwitch().string("handlerBc[idx]").end().startBlock(); + + for (InstructionModel instr : model.getInstructions()) { + switch (instr.kind) { + case BRANCH: + case BRANCH_FALSE: + b.startCase().string("" + instr.id + " /* " + instr.name + " */").end().startBlock(); + + b.startIf().string("context.outerReferences.contains(handlerObjs[idx])").end().startBlock(); + b.statement("objs[offsetBci + idx] = handlerObjs[idx]"); + b.end().startElseBlock(); + b.startAssert().string("((IntRef) handlerObjs[idx]).value != -1").end(); + b.statement("objs[offsetBci + idx] = new IntRef(((IntRef) handlerObjs[idx]).value + offsetBci)"); + b.end(); + + b.statement("break"); + b.end(); + break; + case CUSTOM: + case CUSTOM_SHORT_CIRCUIT: + b.startCase().string("" + instr.id + " /* " + instr.name + " */").end().startBlock(); + + if (model.generateUncached && !instr.needsUncachedData()) { + b.startAssert().string("handlerObjs[idx] == EPSILON").end(); + b.statement("objs[offsetBci + idx] = EPSILON"); + } else { + String dataClassName = instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : ""); + + b.statement(dataClassName + " curObj = (" + dataClassName + ") handlerObjs[idx]"); + b.statement(dataClassName + " newObj = new " + dataClassName + "()"); + b.statement("objs[offsetBci + idx] = newObj"); + + for (InstructionField field : instr.getUncachedFields()) { + b.startAssign("newObj." + field.name); + if (field.needLocationFixup) { + if (ElementUtils.typeEquals(field.type, context.getType(int.class))) { + b.string("curObj.", field.name, " + offsetBci"); + } else if (ElementUtils.typeEquals(field.type, new GeneratedTypeMirror("", "IntRef"))) { + b.string("new IntRef(curObj.", field.name, ".value + offsetBci)"); + } else { + throw new UnsupportedOperationException("how?"); + } + } else { + b.string("curObj.", field.name); + } + b.end(); + } + } + + b.statement("break"); + b.end(); + break; + } + } + + b.caseDefault().startBlock(); + b.statement("objs[offsetBci + idx] = handlerObjs[idx]"); + b.statement("break"); + b.end(); + + b.end(); + b.end(); + + b.statement("bci += handlerBc.length"); + + b.startIf().string("curStack + context.handlerMaxStack > maxStack").end().startBlock(); + b.statement("maxStack = curStack + context.handlerMaxStack"); + b.end(); + + b.startIf().string("withSource").end().startBlock(); + b.startFor().string("int idx = 0; idx < context.handlerSourceInfo.length; idx += 3").end().startBlock(); + b.statement("sourceInfo[sourceInfoIndex + idx] = context.handlerSourceInfo[idx] + offsetBci"); + b.statement("sourceInfo[sourceInfoIndex + idx + 1] = context.handlerSourceInfo[idx + 1]"); + b.statement("sourceInfo[sourceInfoIndex + idx + 2] = context.handlerSourceInfo[idx + 2]"); + b.end(); + + b.statement("sourceInfoIndex += context.handlerSourceInfo.length"); + b.end(); + + b.startFor().string("int idx = 0; idx < context.handlerExHandlers.length; idx += 5").end().startBlock(); + b.statement("exHandlers[exHandlerCount + idx] = context.handlerExHandlers[idx] + offsetBci"); + b.statement("exHandlers[exHandlerCount + idx + 1] = context.handlerExHandlers[idx + 1] + offsetBci"); + b.statement("exHandlers[exHandlerCount + idx + 2] = context.handlerExHandlers[idx + 2] + offsetBci"); + b.statement("exHandlers[exHandlerCount + idx + 3] = context.handlerExHandlers[idx + 3]"); + b.statement("exHandlers[exHandlerCount + idx + 4] = context.handlerExHandlers[idx + 4]"); + b.end(); + + b.statement("exHandlerCount += context.handlerExHandlers.length"); + + return ex; + } + + private CodeExecutableElement createDoEmitInstruction() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitInstruction"); ex.addParameter(new CodeVariableElement(context.getType(int.class), "instr")); ex.addParameter(new CodeVariableElement(context.getType(Object.class), "data")); @@ -1692,7 +1982,6 @@ private void buildPushStackIndex(CodeTreeBuilder b, String index, boolean perfor } private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, String argument) { - if (model.hasBoxingElimination()) { switch (instr.kind) { case BRANCH: @@ -1768,10 +2057,10 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str case LOAD_LOCAL_MATERIALIZED: case THROW: case YIELD: + case RETURN: break; case BRANCH_FALSE: case CUSTOM_SHORT_CIRCUIT: - case RETURN: case POP: case STORE_LOCAL: b.statement("curStack -= 1"); @@ -1821,7 +2110,7 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str b.end(2); } - private CodeExecutableElement createdoEmitSourceInfo() { + private CodeExecutableElement createDoEmitSourceInfo() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitSourceInfo"); ex.addParameter(new CodeVariableElement(context.getType(int.class), "sourceIndex")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "start")); @@ -1853,6 +2142,33 @@ private CodeExecutableElement createdoEmitSourceInfo() { return ex; } + private CodeExecutableElement createDoCreateExceptionHandler() { + CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(int.class), "doCreateExceptionHandler"); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "startBci")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "endBci")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "handlerBci")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "spStart")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "exceptionLocal")); + + CodeTreeBuilder b = ex.createBuilder(); + + b.startIf().string("exHandlers.length <= exHandlerCount + 5").end().startBlock(); + b.statement("exHandlers = Arrays.copyOf(exHandlers, exHandlers.length * 2)"); + b.end(); + + b.statement("int result = exHandlerCount"); + + b.statement("exHandlers[exHandlerCount++] = startBci"); + b.statement("exHandlers[exHandlerCount++] = endBci"); + b.statement("exHandlers[exHandlerCount++] = handlerBci"); + b.statement("exHandlers[exHandlerCount++] = spStart"); + b.statement("exHandlers[exHandlerCount++] = exceptionLocal"); + + b.statement("return result"); + + return ex; + } + private CodeExecutableElement createDoEmitLeaves() { CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitLeaves"); ex.addParameter(new CodeVariableElement(context.getType(int.class), "targetSeq")); @@ -1869,6 +2185,17 @@ private CodeExecutableElement createDoEmitLeaves() { for (OperationModel op : model.getOperations()) { switch (op.kind) { + case FINALLY_TRY: + case FINALLY_TRY_NO_EXCEPT: + b.startCase().string(op.id + " /* " + op.name + " */").end().startBlock(); + + b.startIf().string("operationData[i] != null").end().startBlock(); + b.statement("doEmitFinallyHandler((FinallyTryContext) operationData[i])"); + b.end(); + + b.statement("break"); + b.end(); + break; } } @@ -1924,6 +2251,7 @@ private CodeExecutableElement createConstructor() { private CodeExecutableElement createReparseImpl() { CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationNodes, "reparseImpl"); + ex.renameArguments("config", "parse", "nodes"); CodeTreeBuilder b = ex.createBuilder(); b.statement("Builder builder = new Builder(this, true, config)"); @@ -1966,6 +2294,7 @@ private CodeExecutableElement createContinueAt() { ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs")); ex.addParameter(new CodeVariableElement(context.getType(int[].class), "handlers")); ex.addParameter(new CodeVariableElement(context.getType(int.class), "startState")); + ex.addParameter(new CodeVariableElement(context.getType(int.class), "numLocals")); if (model.hasBoxingElimination()) { ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localBoxingState")); } @@ -2035,6 +2364,8 @@ private CodeExecutableElement createContinueAt() { b.end(); } + // b.statement("System.err.printf(\"Trace: @%04x %04x%n\", bci, curOpcode)"); + b.startTryBlock(); b.startSwitch().string("curOpcode").end().startBlock(); @@ -2255,6 +2586,7 @@ private CodeExecutableElement createContinueAt() { b.statement("sp -= 2"); break; case THROW: + b.statement("throw sneakyThrow((Throwable) frame.getObject(((IntRef) curObj).value))"); break; case YIELD: break; @@ -2275,18 +2607,26 @@ private CodeExecutableElement createContinueAt() { b.end().startCatchBlock(context.getDeclaredType("com.oracle.truffle.api.exception.AbstractTruffleException"), "ex"); + // b.statement("System.err.printf(\" Caught %s @ %04x ... \", ex, bci)"); + b.startFor().string("int idx = 0; idx < handlers.length; idx += 5").end().startBlock(); + // todo: this could get improved b.startIf().string("handlers[idx] > bci").end().startBlock().statement("continue").end(); - b.startIf().string("handlers[idx + 1] <= bci").end().startBlock().statement("break").end(); + b.startIf().string("handlers[idx + 1] <= bci").end().startBlock().statement("continue").end(); b.statement("bci = handlers[idx + 2]"); - b.statement("sp = handlers[idx + 3]"); + b.statement("sp = handlers[idx + 3] + numLocals"); b.statement("frame.setObject(handlers[idx + 4], ex)"); + + // b.statement("System.err.printf(\"going to %04x%n\", bci)"); + b.statement("continue loop"); b.end(); // for + // b.statement("System.err.printf(\"rethrowing%n\")"); + b.statement("throw ex"); b.end(); // catch @@ -2534,6 +2874,7 @@ private CodeTypeElement create() { operationLabelImpl.add(new CodeVariableElement(intRef.asType(), "index")); operationLabelImpl.add(new CodeVariableElement(context.getType(int.class), "declaringOp")); + operationLabelImpl.add(new CodeVariableElement(context.getType(int.class), "finallyTryOp")); operationLabelImpl.add(createConstructorUsingFields(Set.of(), operationLabelImpl, null)); diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java index bc53c0b3a22f..9348dd18f160 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java @@ -79,11 +79,13 @@ public static class InstructionField { public final TypeMirror type; public final String name; public final boolean needInUncached; + public final boolean needLocationFixup; - public InstructionField(TypeMirror type, String name, boolean needInUncached) { + public InstructionField(TypeMirror type, String name, boolean needInUncached, boolean needLocationFixup) { this.type = type; this.name = name; this.needInUncached = needInUncached; + this.needLocationFixup = needLocationFixup; } } @@ -147,8 +149,8 @@ public boolean needsUncachedData() { return false; } - public void addField(TypeMirror type, String fieldName, boolean needInUncached) { - fields.add(new InstructionField(type, fieldName, needInUncached)); + public void addField(TypeMirror type, String fieldName, boolean needInUncached, boolean needLocationFixup) { + fields.add(new InstructionField(type, fieldName, needInUncached, needLocationFixup)); } public List getUncachedFields() { diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index e41202f86a50..df25833d61db 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -102,12 +102,14 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot public InstructionModel popInstruction; public InstructionModel branchInstruction; public InstructionModel branchFalseInstruction; + public InstructionModel throwInstruction; public void addDefault() { popInstruction = instruction(InstructionKind.POP, "pop"); branchInstruction = instruction(InstructionKind.BRANCH, "branch"); branchFalseInstruction = instruction(InstructionKind.BRANCH_FALSE, "branch.false"); + throwInstruction = instruction(InstructionKind.THROW, "throw"); blockOperation = operation(OperationKind.BLOCK, "Block") // .setTransparent(true) // diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java index 7742ddf5f697..a1aa6f8801d7 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java @@ -384,32 +384,32 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl instr.nodeData.redirectMessagesOnGeneratedElements(parent); if (signature.resultBoxingElimination) { - instr.addField(context.getType(byte.class), "op_resultType_", false); + instr.addField(context.getType(byte.class), "op_resultType_", false, false); } for (int i = 0; i < signature.valueBoxingElimination.length; i++) { if (signature.valueBoxingElimination[i]) { // we could move these to cached-only fields, but then we need more processing // once we go uncached -> cached (recalculating the value offsets and child indices) - instr.addField(context.getType(int.class), "op_childValue" + i + "_boxing_", true); + instr.addField(context.getType(int.class), "op_childValue" + i + "_boxing_", true, true); } } if (signature.isVariadic) { - instr.addField(context.getType(int.class), "op_variadicCount_", true); + instr.addField(context.getType(int.class), "op_variadicCount_", true, false); } for (int i = 0; i < signature.localSetterCount; i++) { - instr.addField(types.LocalSetter, "op_localSetter" + i + "_", true); + instr.addField(types.LocalSetter, "op_localSetter" + i + "_", true, false); } for (int i = 0; i < signature.localSetterRangeCount; i++) { - instr.addField(types.LocalSetterRange, "op_localSetterRange" + i + "_", true); + instr.addField(types.LocalSetterRange, "op_localSetterRange" + i + "_", true, false); } if (isShortCircuit) { instr.continueWhen = (boolean) ElementUtils.getAnnotationValue(mirror, "continueWhen").getValue(); - instr.addField(new GeneratedTypeMirror("", "IntRef"), "op_branchTarget_", true); + instr.addField(new GeneratedTypeMirror("", "IntRef"), "op_branchTarget_", true, true); } return instr; From 2c04612c9b7463e6adb5d267bb29d0562a8b9dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 Jan 2023 13:02:31 +0100 Subject: [PATCH 294/312] Document decisions and tracing --- truffle/docs/OperationDSL.md | 59 ++++++++++++++++++- .../operations/parser/OperationsParser.java | 19 +++--- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/truffle/docs/OperationDSL.md b/truffle/docs/OperationDSL.md index fa9f53a6df5f..9900fe5374f6 100644 --- a/truffle/docs/OperationDSL.md +++ b/truffle/docs/OperationDSL.md @@ -520,4 +520,61 @@ With this, we can define some common short-circuiting operations: name = "NullCoalesce", booleanConverter = IsNull.class, continueWhen = true) -``` \ No newline at end of file +``` + +## Tracing and optimizations + +A large benefit of Operation DSL is that automated optimizations, that would otherwise need manual maintenance, can be automatically generated. To help with determining which optimizations are worth implementing (since most optimizations has some drawbacks that need to be considered), an automated system of *tracing* and *decision derivation* is implemented. + +### Preparing the interpreter + +First step in preparing your Operation DSL interpreter for tracing is to specify a *decisions file path*, i.e. a place where to store the generated decisions. In general, this file should be committed to version control, and updated only when significant changes to the interpreter specification are made. + +To specify it, you must add a `decisionsFile = "..."` attribute to the `@GenerateOperations` annotation. The value should be a path to the decisions file, relative to the source file in which it is found. It is recommended to always use the value `"decisions.json"`. + +Then we must recompile the Operation DSL interpreter for *tracing*. This will create a modified version of the interpreter, which includes calls to the tracing runtime. To do this, the project must be recompiled with `truffle.dsl.OperationsEnableTracing=true` annotation processor flag. For example, this can be done using `mx` as: + +```sh +mx build -f -A-Atruffle.dsl.OperationsEnableTracing=true +``` + +### Creating the corpus + +To properly excercise the interpreter, a representative body of code, known as *corpus* must be executed. A few guidelines when compiling the corpus are: + +* The corpus should be representative of the entire body of code written and ran in that language. The corpus should not be a suite of micro-benchmarks, but should instead be composed of real-world applications. +* The Operation DSL will try to optimize for speciffic patterns of use found in the corpus. For this reson, the corpus should cover as much as possible of the styles and paradigms. +* In general, Operation DSL will try to make *the corpus* run as best as it can. It is up to the language to make sure that the benefits can be transfered to all other applications. +* You should use external benchmarks to validate that the speedups are not localized to the corpus. Using a benchmark or applications that is also part of the corpus is not advised. + +### Running the corpus + +To run the corpus with tracing enabled, you must first create a *state file*. This file is used internally by the tracing runtime, to store data between executions. Here, we will store it in `/tmp`. + +``` +touch /tmp/state.json +``` + +Now, you must run the corpus, passing the path to the file as `engine.OperationsTracingState` Polyglot option. You can run multiple programs as a part of your corpus, but they must be run serially (locking the state file is used to prevent concurrent runs). The corpus internally may use multithreading, but any non-determinism is discouraged, as it may make the optimization decisions non-deterministic as well. + +If you want to see a summary of optimization decisions, you may set the `engine.OperationsDumpDecisions` Polyglot option to `true`. This will print the resulting decisions to the Polyglot log. + +After each corpus execution, the decisions file specified with `decisionsFile` is automatically updated. + +### Applying the decisions + +To apply the optimization decisions, simply recompile the interpreter without the tracing enabled. For example, with `mx`, just run: + +```sh +mx build -f +``` + +This will regenerate the interpreter without the tracing calls, including taking the generated decisions into account. + +### Manually overriding the decisions + +If you want to manually modify the decisions generated by the Operation DSL, **do not edit the generated file**. Instead, write a second `json` file in the same format, and reference it in the `decisionOverrideFiles` annotation attribute. + +### Decisions file format + +TODO diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index 223fd6d077de..82702d156db8 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -223,20 +223,15 @@ protected OperationsModel parse(Element element, List mirror) AnnotationValue decisionsFilePathValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false); if (decisionsFilePathValue != null) { model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFilePathValue.getValue()); - } - - // todo: find and bind decisionOverrideFiles - if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) { - model.enableTracing = true; - } else if ((boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true).getValue()) { - model.addWarning("Operation DSL execution tracing is forced on. Use this only during development."); - model.enableTracing = true; - } + // todo: find and bind decisionOverrideFiles - if (model.enableTracing && decisionsFilePathValue == null) { - model.addError(generateOperationsMirror, null, - "Tracing Operation DSL execution is not supported without specifying decisionsFile path. Add 'decisionsFile=\"...\"' to @GenerateOperations annotation to fix this error."); + if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) { + model.enableTracing = true; + } else if ((boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true).getValue()) { + model.addWarning("Operation DSL execution tracing is forced on. Use this only during development."); + model.enableTracing = true; + } } model.enableOptimizations = decisionsFilePathValue != null && !model.enableTracing; From 43dcdcbfa462d7bc31a9071061220c6c55b0ebc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 Jan 2023 13:17:51 +0100 Subject: [PATCH 295/312] Document exception handling operations --- truffle/docs/OperationDSL.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/truffle/docs/OperationDSL.md b/truffle/docs/OperationDSL.md index 9900fe5374f6..576ae128c846 100644 --- a/truffle/docs/OperationDSL.md +++ b/truffle/docs/OperationDSL.md @@ -286,6 +286,25 @@ Return operation executes its child, and then returns from the currently executi Yield operation executes its child, and then returns from the currently executing function with a ContinuationResult containing that value as the result. Upon continuing the continuation, the control continues from Yield operation, with the Yield returning the value passed to the continuation (see "Yielding and coroutines") +**TryExcept** +* Arity: 2 +* Returns value: no +* `begin` arguments: (OperationLocal) + +TryExcept executes its first child. If any Truffle exception occurrs during that execution, the exception is stored in the local provided, and the second child is executed. This operation models the behavior of `try ... catch` construct in the Java language, but without the option to filter exceptions based on type. It does not return a value in either case. + +**FinallyTry** +* Arity: 2 +* Returns value: no + +FinallyTry executes its second child. When that execution finished (either normally, through an explicit control flow transfer (Return, Branch, ...), or an exception), the first child is executed. This operation models the `try ... finally` construct in the Java language, but the order of children is flipped. If the first child finishes execution normally, the control flow resumes where it would after executing the second child. Otherwise, the control flow continues where it would continue after executing the first child. + +**FinallyTryNoExcept** +* Arity: 2 +* Returns value: no + +FinallyTryNoExcept executes its second child. If that execution finished without an exception (either normally, or through an explicit control flow transfer (Return, Branch, ...)), the first child is executed. This is similar to FinallyTry, but does not handle exceptions. + **Source** * Arity: 1 * Returns value: Only if the child returns a value From 4632ed06d517d0d9c79cc8fb3d9194c3418d8b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 Jan 2023 14:53:00 +0100 Subject: [PATCH 296/312] Write desugaring example --- truffle/docs/OperationDSL.md | 93 ++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/truffle/docs/OperationDSL.md b/truffle/docs/OperationDSL.md index 576ae128c846..d2a8c6665d7a 100644 --- a/truffle/docs/OperationDSL.md +++ b/truffle/docs/OperationDSL.md @@ -541,6 +541,99 @@ With this, we can define some common short-circuiting operations: continueWhen = true) ``` +## Translating your language into operations + +When writing the Operation DSL parser for a language, your task is to translate the semantics of your language into individual operations. This is a process called "desugaring", as it can be thought as a similar process to removing syntax sugar from a language - translating higher level language constructs into lower, more verbose level. As an example of this process, lets take a simple iterator-style `for` loop (we use `«...»` as metaqotes): + +```python +for x in «iterable»: + «body» +``` + +The semantics of this language construct can be expressed as follows: +* Evaluate the iterable +* Get the iterator from `«iterable»` +* As long as you can get a value from the iterator: + * Bind the value to the variable `x` + * Evaluate the `«body»` + +Now we need to express this in terms of operations. In general, you can think of Operation DSL's operations as Java with some additional features: +* Custom operations are similar to functions, except they can also take "output" parameters (similar to by-reference C++ parameters, or `out` parameters in C#). + * Short-circuiting operations are the exception, as different execution order rules apply to them. +* Blocks can appear anywhere in the expression, allowing you to insert statements in the middle of otherwise "expression" contexts (similar to blocks in Rust). +* Currently there are no static types - everything is an `Object`. +* TryExcept does not allow filtering exceptions based on type. + +Now we can write the previous semantics in this pseudo-Java language. To help us, we will introduce a temporary local, `tmpIterator`. + +```csharp +var tmpIterator = GetIterator(«iterable»); +var x; +while (GetNextFromIterator(tmpIterator, out x)) { + «body» +} +``` + +To implement this, we need 2 custom operations: + +* `GetIterator(iterable)` whilch will take an iterable, and produce the iterator from it. +* `GetNextFromIterator(iterator, out value)` which will take an iterator and then either: + * Set the `value` to the next element of the iterator, and return `true`, or + * Return `false` once we reach the end of the iterator. + +These operations can easily be implemented using Operation DSL. For example: + + +```java +@Operation +public static final class GetIterator { + @Specialization + public MyIterator perform(MyIterable iterable) { + return iterable.createIterator(); + } +} + +@Operation +public static final class GetNextFromIterator { + @Specialization + public boolean perform(MyIterator iterator, LocalSetter value) { + if (iterator.hasNext()) { + value.setObject(iterator.getNext()); + return true; + } else { + return false; + } + } +} +``` + +Then, we need to transform the previously written "desugared" form into individual builder calls in our parser. If we are using a visitor pattern parser, this would look something like this (indented for readability): + +```java +// in our ast visitor +public void visit(ForNode node) { + OperationLocal tmpIterator = b.createLocal(); + + b.beginStoreLocal(tmpIterator); + b.beginGetIterator(); + node.iterator.accept(this); + b.endGetIterator(); + b.endStoreLocal(); + + b.beginWhile(); + b.beginGetNextFromIterator(valueLocal); + b.emitLoadLocal(tmpIterator); + b.endGetNextFromIterator(); + + b.beginBlock(); + // if your language supports destructuring (e.g. `for x, y in ...`) + // you would do that here as well + node.body.accept(this); + b.endBlock(); + b.endWhile(); +} +``` + ## Tracing and optimizations A large benefit of Operation DSL is that automated optimizations, that would otherwise need manual maintenance, can be automatically generated. To help with determining which optimizations are worth implementing (since most optimizations has some drawbacks that need to be considered), an automated system of *tracing* and *decision derivation* is implemented. From e335298739ca2da6e407511cce62f92faf1ff7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87?= Date: Thu, 19 Jan 2023 16:07:42 +0100 Subject: [PATCH 297/312] Reading of decisions --- .../operations/model/OperationsModel.java | 1 + .../model/OptimizationDecisionsModel.java | 75 +++++++++++++++ .../operations/parser/OperationsParser.java | 96 +++++++++++++++++-- 3 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java index df25833d61db..6ad02ad9c36b 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java @@ -95,6 +95,7 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot public boolean enableTracing; public String decisionsFilePath; public boolean enableOptimizations; + public OptimizationDecisionsModel optimizationDecisions; public OperationModel blockOperation; public OperationModel rootOperation; diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java new file mode 100644 index 000000000000..8e2e64af937e --- /dev/null +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.dsl.processor.operations.model; + +import java.util.ArrayList; +import java.util.List; + +public class OptimizationDecisionsModel implements InfoDumpable { + + public static class QuickenDecision { + public String id; + public String instruction; + public String[] specializations; + } + + public static class SuperInstructionDecision { + public String id; + public String[] instructions; + } + + public static class CommonInstructionDecision { + public String id; + public String instruction; + } + + public String decisionsFilePath; + public String[] decisionsOverrideFilePaths; + public List quickenDecisions = new ArrayList<>(); + public List superInstructionDecisions = new ArrayList<>(); + public List commonInstructionDecisions = new ArrayList<>(); + + public void dump(Dumper dumper) { + dumper.field("quickens", quickenDecisions); + dumper.field("superInstructions", superInstructionDecisions); + dumper.field("commonInstructions", commonInstructionDecisions); + } +} diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java index 82702d156db8..ad40e3664e42 100644 --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java @@ -45,6 +45,8 @@ import static com.oracle.truffle.dsl.processor.java.ElementUtils.getSimpleName; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.nio.file.Path; import java.util.EnumSet; import java.util.HashSet; @@ -67,8 +69,16 @@ import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory; import com.oracle.truffle.dsl.processor.model.TypeSystemData; import com.oracle.truffle.dsl.processor.operations.model.OperationsModel; +import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel; +import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel.CommonInstructionDecision; +import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel.QuickenDecision; +import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel.SuperInstructionDecision; import com.oracle.truffle.dsl.processor.parser.AbstractParser; import com.oracle.truffle.dsl.processor.parser.TypeSystemParser; +import com.oracle.truffle.tools.utils.json.JSONArray; +import com.oracle.truffle.tools.utils.json.JSONException; +import com.oracle.truffle.tools.utils.json.JSONObject; +import com.oracle.truffle.tools.utils.json.JSONTokener; public class OperationsParser extends AbstractParser { @@ -220,11 +230,13 @@ protected OperationsModel parse(Element element, List mirror) new CustomOperationParser(model, mir, true).parse(te); } - AnnotationValue decisionsFilePathValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false); - if (decisionsFilePathValue != null) { - model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFilePathValue.getValue()); + AnnotationValue decisionsFileValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false); + AnnotationValue decisionsOverrideFilesValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsOverrideFiles", false); + String decisionsFilePath = null; + String[] decisionsOverrideFilesPath = new String[0]; - // todo: find and bind decisionOverrideFiles + if (decisionsFileValue != null) { + model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFileValue.getValue()); if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) { model.enableTracing = true; @@ -234,10 +246,14 @@ protected OperationsModel parse(Element element, List mirror) } } - model.enableOptimizations = decisionsFilePathValue != null && !model.enableTracing; + if (decisionsOverrideFilesValue != null) { + decisionsOverrideFilesPath = ((List) decisionsOverrideFilesValue.getValue()).stream().map(x -> (String) x.getValue()).toArray(String[]::new); + } + + model.enableOptimizations = (decisionsFileValue != null || decisionsOverrideFilesValue != null) && !model.enableTracing; if (model.enableOptimizations) { - // todo: read from decisions file path and apply optimizations + model.optimizationDecisions = parseDecisions(model, model.decisionsFilePath, decisionsOverrideFilesPath); } return model; @@ -248,6 +264,74 @@ private String resolveElementRelativePath(Element element, String relativePath) return Path.of(filePath.getPath()).getParent().resolve(relativePath).toAbsolutePath().toString(); } + private static OptimizationDecisionsModel parseDecisions(OperationsModel model, String decisionsFile, String[] decisionOverrideFiles) { + OptimizationDecisionsModel result = new OptimizationDecisionsModel(); + result.decisionsFilePath = decisionsFile; + result.decisionsOverrideFilePaths = decisionOverrideFiles; + + if (decisionsFile != null) { + parseDecisionsFile(model, result, decisionsFile, true); + } + + return result; + } + + private static void parseDecisionsFile(OperationsModel model, OptimizationDecisionsModel result, String filePath, boolean isMain) { + try { + FileInputStream fi = new FileInputStream(filePath); + JSONArray o = new JSONArray(new JSONTokener(fi)); + for (int i = 0; i < o.length(); i++) { + if (o.get(i) instanceof String) { + // strings are treated as comments + continue; + } else { + parseDecision(model, result, filePath, o.getJSONObject(i)); + } + } + } catch (FileNotFoundException ex) { + if (isMain) { + model.addError("Decisions file '%s' not found. Build & run with tracing enabled to generate it.", filePath); + } else { + model.addError("Decisions file '%s' not found. Create it, or remove it from decisionOverrideFiles to resolve this error.", filePath); + } + } catch (JSONException ex) { + model.addError("Decisions file '%s' is invalid: %s", filePath, ex); + } + } + + private static void parseDecision(OperationsModel model, OptimizationDecisionsModel result, String filePath, JSONObject decision) { + switch (decision.getString("type")) { + case "SuperInstruction": { + SuperInstructionDecision m = new SuperInstructionDecision(); + m.id = decision.getString("id"); + m.instructions = jsonGetStringArray(decision, "instructions"); + result.superInstructionDecisions.add(m); + break; + } + case "CommonInstruction": { + CommonInstructionDecision m = new CommonInstructionDecision(); + m.id = decision.getString("id"); + result.commonInstructionDecisions.add(m); + break; + } + case "Quicken": { + QuickenDecision m = new QuickenDecision(); + m.id = decision.getString("id"); + m.instruction = decision.getString("instruction"); + m.specializations = jsonGetStringArray(decision, "specializations"); + result.quickenDecisions.add(m); + break; + } + default: + model.addError("Unknown optimization decision type: '%s'.", decision.getString("type")); + break; + } + } + + private static String[] jsonGetStringArray(JSONObject obj, String key) { + return ((List) obj.getJSONArray(key).toList()).toArray(String[]::new); + } + private TypeMirror getTypeMirror(AnnotationValue value) throws AssertionError { if (value.getValue() instanceof Class) { return context.getType((Class) value.getValue()); From 503682964fc5fc32b747d3916e6321e2fcf3f573 Mon Sep 17 00:00:00 2001 From: Christian Humer Date: Fri, 20 Jan 2023 00:51:26 +0100 Subject: [PATCH 298/312] Implement serialization. --- .../api/dsl/BoundaryCallFailedException.java | 1 + .../test/example/TestOperations.java | 13 +- .../test/example/TestOperationsSerTest.java | 79 +- .../api/operation/ContinuationLocation.java | 1 + .../api/operation/ContinuationResult.java | 2 + .../api/operation/GenerateOperations.java | 7 +- .../truffle/api/operation/OperationNodes.java | 13 +- .../api/operation/OperationRootNode.java | 8 - .../serialization/ByteBufferDataInput.java | 219 +++++ .../serialization/OperationDeserializer.java | 7 +- .../serialization/OperationSerializer.java | 7 +- .../serialization/SerializationUtils.java | 175 ---- .../operation/tracing/ExecutionTracer.java | 10 +- .../tracing/OperationsStatistics.java | 4 + .../oracle/truffle/api/nodes/RootNode.java | 13 +- .../truffle/dsl/processor/TruffleTypes.java | 14 +- .../generator/FlatNodeGenFactory.java | 6 +- .../processor/generator/GeneratorUtils.java | 9 +- .../dsl/processor/java/ElementUtils.java | 11 + .../dsl/processor/java/model/CodeTree.java | 31 - .../processor/java/model/CodeTreeBuilder.java | 4 + .../operations/generator/ElementHelpers.java | 161 ++++ .../OperationNodeGeneratorPlugs.java | 3 - .../generator/OperationsCodeGenerator.java | 2 +- .../generator/OperationsNodeFactory.java | 775 ++++++++++++++++-- .../operations/model/OperationModel.java | 8 +- .../operations/model/OperationsModel.java | 22 +- .../operations/parser/OperationsParser.java | 48 ++ .../sl/builtins/SLStackTraceBuiltin.java | 4 +- .../oracle/truffle/sl/nodes/SLRootNode.java | 4 +- .../sl/nodes/controlflow/SLIfNode.java | 2 - .../sl/operations/SLOperationRootNode.java | 21 +- .../operations/SLOperationSerialization.java | 87 +- .../sl/parser/SLOperationsVisitor.java | 15 +- 34 files changed, 1373 insertions(+), 413 deletions(-) create mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java create mode 100644 truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/ElementHelpers.java diff --git a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java index 04e9f069061b..a60d251fcff0 100644 --- a/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java +++ b/truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/BoundaryCallFailedException.java @@ -42,6 +42,7 @@ import com.oracle.truffle.api.nodes.ControlFlowException; +//TODO delete public final class BoundaryCallFailedException extends ControlFlowException { private static final long serialVersionUID = 4967477438708874100L; diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java index cb9913ae8db8..06e35a4e9bc6 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java @@ -43,29 +43,31 @@ import java.util.List; import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateAOT; import com.oracle.truffle.api.dsl.GenerateNodeFactory; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.ProvidedTags; +import com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.operation.AbstractOperationsTruffleException; import com.oracle.truffle.api.operation.GenerateOperations; -import com.oracle.truffle.api.operation.GenerateOperations.Metadata; import com.oracle.truffle.api.operation.LocalSetter; -import com.oracle.truffle.api.operation.MetadataKey; import com.oracle.truffle.api.operation.Operation; import com.oracle.truffle.api.operation.OperationProxy; import com.oracle.truffle.api.operation.OperationRootNode; import com.oracle.truffle.api.operation.Variadic; -@GenerateOperations(languageClass = TestLanguage.class, enableYield = true) +@GenerateOperations(languageClass = TestLanguage.class, enableYield = true, enableSerialization = true) @GenerateAOT @OperationProxy(SomeOperationNode.class) public abstract class TestOperations extends RootNode implements OperationRootNode { @@ -78,7 +80,7 @@ protected TestOperations(TruffleLanguage language, FrameDescriptor frameDescr super(language, frameDescriptor); } - @Metadata public static final MetadataKey TestData = new MetadataKey<>("default value"); + protected String testData; private static class TestException extends AbstractOperationsTruffleException { private static final long serialVersionUID = -9143719084054578413L; @@ -141,6 +143,7 @@ public static Object perform(Object value) { static final class AppenderOperation { @SuppressWarnings("unchecked") @Specialization + @TruffleBoundary public static void perform(List list, Object value) { ((List) list).add(value); } @@ -215,6 +218,7 @@ public Object call() { } } +@ProvidedTags(ExpressionTag.class) class TestLanguage extends TruffleLanguage { @Override protected Object createContext(Env env) { @@ -228,6 +232,7 @@ public Object getValue() { return new Object(); } + @NeverDefault public Assumption getAssumption() { return Assumption.ALWAYS_VALID; } diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java index 38d3b6c03126..28229ad1545d 100644 --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsSerTest.java @@ -41,19 +41,23 @@ package com.oracle.truffle.api.operation.test.example; import java.io.ByteArrayOutputStream; +import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.function.Supplier; import org.junit.Assert; import org.junit.Test; import com.oracle.truffle.api.operation.OperationConfig; import com.oracle.truffle.api.operation.OperationNodes; +import com.oracle.truffle.api.operation.serialization.SerializationUtils; public class TestOperationsSerTest { @Test - public void testSer() { + public void testSerialization() { byte[] byteArray = createByteArray(); TestOperations root = deserialize(byteArray); @@ -62,45 +66,60 @@ public void testSer() { private static TestOperations deserialize(byte[] byteArray) { OperationNodes nodes2 = null; -// try { -// nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, ByteBuffer.wrap(byteArray), -// (ctx, buf2) -> { -// return buf2.readLong(); -// }); -// } catch (IOException e) { -// Assert.fail(); -// } + try { + Supplier input = () -> SerializationUtils.createDataInput(ByteBuffer.wrap(byteArray)); + nodes2 = TestOperationsGen.deserialize(null, OperationConfig.DEFAULT, input, + (context, buffer) -> { + switch (buffer.readByte()) { + case 0: + return buffer.readLong(); + case 1: + return buffer.readUTF(); + case 2: + return null; + default: + throw new AssertionError(); + } + }); + } catch (IOException e) { + Assert.fail(); + } return nodes2.getNodes().get(0); } private static byte[] createByteArray() { - OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, b -> { - b.beginRoot(null); - - b.beginReturn(); - b.beginAddOperation(); - b.emitLoadConstant(1L); - b.emitLoadConstant(2L); - b.endAddOperation(); - b.endReturn(); - - b.endRoot(); - }); - boolean[] haveConsts = new boolean[2]; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { - nodes.serialize(OperationConfig.DEFAULT, new DataOutputStream(output), (ctx, buf2, obj) -> { - if (obj instanceof Long) { - haveConsts[(int) (long) obj - 1] = true; - buf2.writeLong((long) obj); - } else { - assert false; - } - }); + TestOperationsGen.serialize(OperationConfig.DEFAULT, new DataOutputStream(output), + (context, buffer, object) -> { + if (object instanceof Long) { + buffer.writeByte(0); + haveConsts[(int) (long) object - 1] = true; + buffer.writeLong((long) object); + } else if (object instanceof String) { + buffer.writeByte(1); + buffer.writeUTF((String) object); + } else if (object == null) { + buffer.writeByte(2); + } else { + assert false; + } + }, b -> { + b.beginRoot(null); + + b.beginReturn(); + b.beginAddOperation(); + b.emitLoadConstant(1L); + b.emitLoadConstant(2L); + b.endAddOperation(); + b.endReturn(); + + b.endRoot(); + }); } catch (IOException e) { assert false; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java index 1faf2b488681..7fa61232986b 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationLocation.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.nodes.RootNode; public abstract class ContinuationLocation { + public abstract RootNode getRootNode(); // todo: create accessor diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java index 6aa92363892c..fda0953bd307 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java @@ -49,6 +49,7 @@ import com.oracle.truffle.api.nodes.RootNode; public final class ContinuationResult { + final ContinuationLocation location; final MaterializedFrame frame; private final Object result; @@ -68,6 +69,7 @@ public Object getResult() { } public abstract static class ContinueNode extends Node { + public abstract Object execute(ContinuationResult result, Object value); public static final int LIMIT = 3; diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java index 8273dc28405a..32fc25f568cf 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/GenerateOperations.java @@ -63,9 +63,6 @@ boolean enableYield() default false; - @Retention(RetentionPolicy.SOURCE) - @Target({ElementType.FIELD}) - @interface Metadata { - String name() default ""; - } + boolean enableSerialization() default false; + } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java index 61baa07ef202..4f2ac890cd5a 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationNodes.java @@ -40,8 +40,6 @@ */ package com.oracle.truffle.api.operation; -import java.io.DataOutputStream; -import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -49,12 +47,11 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.operation.serialization.OperationSerializer; import com.oracle.truffle.api.source.Source; -public abstract class OperationNodes { +public abstract class OperationNodes { protected final OperationParser parse; - @CompilationFinal(dimensions = 1) protected NodeType[] nodes; + @CompilationFinal(dimensions = 1) protected T[] nodes; @CompilationFinal(dimensions = 1) protected Source[] sources; @CompilationFinal private boolean hasInstrumentation; @@ -68,7 +65,7 @@ public String toString() { } @SuppressWarnings({"unchecked", "cast", "rawtypes"}) - public List getNodes() { + public List getNodes() { return List.of(nodes); } @@ -125,8 +122,4 @@ protected final void ensureInstrumentation() { } } - @SuppressWarnings("unused") - public void serialize(OperationConfig config, DataOutputStream buffer, OperationSerializer callback) throws IOException { - throw new UnsupportedOperationException("Serialization not supported"); - } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java index 70ef4e9e3732..8ca7e0434b99 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/OperationRootNode.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Set; -import java.util.function.Function; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.InstrumentableNode; @@ -54,13 +53,6 @@ import com.oracle.truffle.api.source.SourceSection; public interface OperationRootNode extends NodeInterface, OperationIntrospection.Provider { - default T getMetadata(MetadataKey key) { - return key.getValue(this); - } - - static void setMetadataAccessor(MetadataKey key, Function getter) { - key.setGetter(getter); - } default String dump() { StringBuilder sb = new StringBuilder(); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java new file mode 100644 index 000000000000..0f0181b8c53f --- /dev/null +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/ByteBufferDataInput.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.oracle.truffle.api.operation.serialization; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.nio.BufferUnderflowException; +import java.nio.ByteBuffer; + +final class ByteBufferDataInput implements DataInput { + + private final ByteBuffer buffer; + private char[] lineBuffer; + + ByteBufferDataInput(ByteBuffer buffer) { + this.buffer = buffer; + } + + private static EOFException wrap(BufferUnderflowException ex) { + EOFException eof = new EOFException(); + eof.addSuppressed(ex); + return eof; + } + + public void readFully(byte[] b) throws IOException { + readFully(b, 0, b.length); + } + + public void readFully(byte[] b, int off, int len) throws IOException { + try { + buffer.get(b, 0, b.length); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int skipBytes(int n) throws IOException { + int skip = buffer.remaining() > n ? buffer.remaining() : n; + buffer.position(buffer.position() + skip); + return skip; + } + + public boolean readBoolean() throws IOException { + try { + return buffer.get() != 0; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public byte readByte() throws IOException { + try { + return buffer.get(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readUnsignedByte() throws IOException { + try { + return buffer.get() & 0xff; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public short readShort() throws IOException { + try { + return buffer.getShort(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readUnsignedShort() throws IOException { + try { + return buffer.getShort() & 0xffff; + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public char readChar() throws IOException { + try { + return buffer.getChar(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public int readInt() throws IOException { + try { + return buffer.getInt(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public long readLong() throws IOException { + try { + return buffer.getLong(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public float readFloat() throws IOException { + try { + return buffer.getFloat(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + public double readDouble() throws IOException { + try { + return buffer.getDouble(); + } catch (BufferUnderflowException ex) { + throw wrap(ex); + } + } + + private static int get(ByteBuffer buf) { + if (buf.position() >= buf.limit()) { + return -1; + } else { + return buf.get(); + } + } + + /** + * Modified from {@link DataInputStream#readLine()}. + */ + @Deprecated + public String readLine() throws IOException { + char[] buf = lineBuffer; + + if (buf == null) { + buf = lineBuffer = new char[128]; + } + + int room = buf.length; + int offset = 0; + int c; + + loop: while (true) { + switch (c = get(buffer)) { + case -1: + case '\n': + break loop; + + case '\r': + int c2 = get(buffer); + if ((c2 != '\n') && (c2 != -1)) { + buffer.position(buffer.position() - 1); + } + break loop; + + default: + if (--room < 0) { + buf = new char[offset + 128]; + room = buf.length - offset - 1; + System.arraycopy(lineBuffer, 0, buf, 0, offset); + lineBuffer = buf; + } + buf[offset++] = (char) c; + break; + } + } + if ((c == -1) && (offset == 0)) { + return null; + } + return String.copyValueOf(buf, 0, offset); + } + + public String readUTF() throws IOException { + return DataInputStream.readUTF(this); + } +} diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java index 5a2b4eaef343..6a9cf2033ce0 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationDeserializer.java @@ -46,9 +46,14 @@ import com.oracle.truffle.api.operation.OperationRootNode; public interface OperationDeserializer { + interface DeserializerContext { - OperationRootNode deserializeOperationNode(DataInput buffer) throws IOException; + + OperationRootNode readOperationNode(DataInput buffer) throws IOException; } + /** + * Must not be dependent on any side-effects of the language. + */ Object deserialize(DeserializerContext context, DataInput buffer) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java index c0492e7fc88c..35f0cb819fcd 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/OperationSerializer.java @@ -48,8 +48,13 @@ @FunctionalInterface public interface OperationSerializer { interface SerializerContext { - void serializeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException; + + void writeOperationNode(DataOutput buffer, OperationRootNode node) throws IOException; + } + /** + * Must not be dependent on any side-effects of the language. + */ void serialize(SerializerContext context, DataOutput buffer, Object object) throws IOException; } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java index ab7ee381d6e3..51286250e522 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/serialization/SerializationUtils.java @@ -41,10 +41,6 @@ package com.oracle.truffle.api.operation.serialization; import java.io.DataInput; -import java.io.DataInputStream; -import java.io.EOFException; -import java.io.IOException; -import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; public final class SerializationUtils { @@ -55,175 +51,4 @@ private SerializationUtils() { public static DataInput createDataInput(ByteBuffer buffer) { return new ByteBufferDataInput(buffer); } - - private static final class ByteBufferDataInput implements DataInput { - - private final ByteBuffer buffer; - private char[] lineBuffer; - - private ByteBufferDataInput(ByteBuffer buffer) { - this.buffer = buffer; - } - - private static EOFException wrap(BufferUnderflowException ex) { - EOFException eof = new EOFException(); - eof.addSuppressed(ex); - return eof; - } - - public void readFully(byte[] b) throws IOException { - readFully(b, 0, b.length); - } - - public void readFully(byte[] b, int off, int len) throws IOException { - try { - buffer.get(b, 0, b.length); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public int skipBytes(int n) throws IOException { - int skip = buffer.remaining() > n ? buffer.remaining() : n; - buffer.position(buffer.position() + skip); - return skip; - } - - public boolean readBoolean() throws IOException { - try { - return buffer.get() != 0; - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public byte readByte() throws IOException { - try { - return buffer.get(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public int readUnsignedByte() throws IOException { - try { - return buffer.get() & 0xff; - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public short readShort() throws IOException { - try { - return buffer.getShort(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public int readUnsignedShort() throws IOException { - try { - return buffer.getShort() & 0xffff; - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public char readChar() throws IOException { - try { - return buffer.getChar(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public int readInt() throws IOException { - try { - return buffer.getInt(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public long readLong() throws IOException { - try { - return buffer.getLong(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public float readFloat() throws IOException { - try { - return buffer.getFloat(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - public double readDouble() throws IOException { - try { - return buffer.getDouble(); - } catch (BufferUnderflowException ex) { - throw wrap(ex); - } - } - - private static int get(ByteBuffer buf) { - if (buf.position() >= buf.limit()) { - return -1; - } else { - return buf.get(); - } - } - - /** - * Modified from {@link DataInputStream#readLine()}. - */ - @Deprecated - public String readLine() throws IOException { - char[] buf = lineBuffer; - - if (buf == null) { - buf = lineBuffer = new char[128]; - } - - int room = buf.length; - int offset = 0; - int c; - - loop: while (true) { - switch (c = get(buffer)) { - case -1: - case '\n': - break loop; - - case '\r': - int c2 = get(buffer); - if ((c2 != '\n') && (c2 != -1)) { - buffer.position(buffer.position() - 1); - } - break loop; - - default: - if (--room < 0) { - buf = new char[offset + 128]; - room = buf.length - offset - 1; - System.arraycopy(lineBuffer, 0, buf, 0, offset); - lineBuffer = buf; - } - buf[offset++] = (char) c; - break; - } - } - if ((c == -1) && (offset == 0)) { - return null; - } - return String.copyValueOf(buf, 0, offset); - } - - public String readUTF() throws IOException { - return DataInputStream.readUTF(this); - } - } } diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java index 51ab65cf09c7..aae3c4126aaa 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java @@ -48,8 +48,14 @@ // per-context per-ops per-thread public abstract class ExecutionTracer { + + // TODO refactor this to store everything in a class + // TODO refactor using an annotation instead of a static class. + // target file name static final Map, String> DECISIONS_FILE_MAP = new HashMap<>(); + // operation class -> static final Map, String[]> INSTR_NAMES_MAP = new HashMap<>(); + // operation class -> instruction -> specialization static final Map, String[][]> SPECIALIZATION_NAMES_MAP = new HashMap<>(); public static ExecutionTracer get(Class operationsClass) { @@ -61,18 +67,20 @@ public static ExecutionTracer get(Class operationsClass) { } } - public static void initialize(Class opsClass, String decisionsFile, String[] instrNames, String[][] specNames) { + public static synchronized void initialize(Class opsClass, String decisionsFile, String[] instrNames, String[][] specNames) { DECISIONS_FILE_MAP.put(opsClass, decisionsFile); INSTR_NAMES_MAP.put(opsClass, instrNames); SPECIALIZATION_NAMES_MAP.put(opsClass, specNames); } + // TODO rename startRoot public abstract void startFunction(Node node); public abstract void endFunction(Node node); public abstract void traceInstruction(int bci, int id, int... arguments); + // TODO needs implementation. probably using introspection. public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations); public abstract void traceSpecialization(int bci, int id, int specializationId, Object... values); diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java index 234017c9239a..9f73e195f5a2 100644 --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/OperationsStatistics.java @@ -726,6 +726,10 @@ public JSONArray serializeDecisions(GlobalOperationStatistics stats, PrintWriter decisions.add(new Decision.SuperInstruction(e.getKey().instructions, e.getValue())); }); + // TODO implement weighting + // currently weighting execution count + // divide execution counts by the total number of instructions. + // sort decisions.sort(Decision.COMPARATOR); List acceptedDecisions = new ArrayList<>(); diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java index 06276080d3bb..73cde9aedd2c 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java @@ -165,15 +165,6 @@ protected RootNode(TruffleLanguage language, FrameDescriptor frameDescriptor) this.frameDescriptor = frameDescriptor == null ? new FrameDescriptor() : frameDescriptor; } - /** @since 0.8 or earlier */ - @Override - public Node copy() { - RootNode root = (RootNode) super.copy(); - root.frameDescriptor = frameDescriptor; - resetFieldsAfterCopy(root); - return root; - } - private static void resetFieldsAfterCopy(RootNode root) { root.callTarget = null; root.instrumentationBits = 0; @@ -553,9 +544,9 @@ public static RootNode createConstantNode(Object constant) { /** * If this root node has a lexical scope parent, this method returns its frame descriptor. - * + * * As an example, consider the following pseudocode: - * + * *
          * def m {
          *   # For the "m" root node:
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    index 9a8113e34e8c..f3b9eb639be6 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    @@ -302,7 +302,6 @@ public class TruffleTypes {
         // Operation DSL API
         public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo";
         public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations";
    -    public static final String GenerateOperations_Metadata_Name = "com.oracle.truffle.api.operation.GenerateOperations.Metadata";
         public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal";
         public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey";
         public static final String LocalSetter_Name = "com.oracle.truffle.api.operation.LocalSetter";
    @@ -319,6 +318,12 @@ public class TruffleTypes {
         public static final String OperationNodes_Name = "com.oracle.truffle.api.operation.OperationNodes";
         public static final String OperationProxy_Name = "com.oracle.truffle.api.operation.OperationProxy";
         public static final String OperationBuilder_Name = "com.oracle.truffle.api.operation.OperationBuilder";
    +    public static final String OperationSerializer_Name = "com.oracle.truffle.api.operation.serialization.OperationSerializer";
    +    public static final String OperationSerializer_SerializerContext_Name = "com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext";
    +    public static final String OperationDeserializer_Name = "com.oracle.truffle.api.operation.serialization.OperationDeserializer";
    +    public static final String OperationDeserializer_DeserializerContext_Name = "com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext";
    +
    +    public static final String SerializationUtils_Name = "com.oracle.truffle.api.operation.serialization.SerializationUtils";
         public static final String OperationsConstantPool_Name = "com.oracle.truffle.api.operation.OperationsConstantPool";
         public static final String OperationsInstrumentTreeNode_Name = "com.oracle.truffle.api.operation.OperationsInstrumentTreeNode";
         public static final String Variadic_Name = "com.oracle.truffle.api.operation.Variadic";
    @@ -329,7 +334,6 @@ public class TruffleTypes {
     
         public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name);
         public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name);
    -    public final DeclaredType GenerateOperations_Metadata = c.getDeclaredTypeOptional(GenerateOperations_Metadata_Name);
         public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name);
         public final DeclaredType LocalSetter = c.getDeclaredTypeOptional(LocalSetter_Name);
         public final DeclaredType LocalSetterRange = c.getDeclaredTypeOptional(LocalSetterRange_Name);
    @@ -346,6 +350,10 @@ public class TruffleTypes {
         public final DeclaredType OperationNodes = c.getDeclaredTypeOptional(OperationNodes_Name);
         public final DeclaredType OperationProxy = c.getDeclaredTypeOptional(OperationProxy_Name);
         public final DeclaredType OperationBuilder = c.getDeclaredTypeOptional(OperationBuilder_Name);
    +    public final DeclaredType OperationSerializer = c.getDeclaredTypeOptional(OperationSerializer_Name);
    +    public final DeclaredType OperationSerializer_SerializerContext = c.getDeclaredTypeOptional(OperationSerializer_SerializerContext_Name);
    +    public final DeclaredType OperationDeserializer = c.getDeclaredTypeOptional(OperationDeserializer_Name);
    +    public final DeclaredType OperationDeserializer_DeserializerContext = c.getDeclaredTypeOptional(OperationDeserializer_DeserializerContext_Name);
         public final DeclaredType OperationsConstantPool = c.getDeclaredTypeOptional(OperationsConstantPool_Name);
         public final DeclaredType OperationsInstrumentTreeNode = c.getDeclaredTypeOptional(OperationsInstrumentTreeNode_Name);
         public final DeclaredType ShortCircuitOperation = c.getDeclaredTypeOptional(ShortCircuitOperation_Name);
    @@ -402,6 +410,7 @@ public class TruffleTypes {
         public static final String InstrumentableNode_WrapperNode_Name = "com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode";
         public static final String ProbeNode_Name = "com.oracle.truffle.api.instrumentation.ProbeNode";
         public static final String ProvidedTags_Name = "com.oracle.truffle.api.instrumentation.ProvidedTags";
    +    public static final String Tag_Name = "com.oracle.truffle.api.instrumentation.Tag";
         public static final String TruffleInstrument_Name = "com.oracle.truffle.api.instrumentation.TruffleInstrument";
         public static final String TruffleInstrument_Provider_Name = "com.oracle.truffle.api.instrumentation.TruffleInstrument.Provider";
         public static final String TruffleInstrument_Registration_Name = "com.oracle.truffle.api.instrumentation.TruffleInstrument.Registration";
    @@ -417,6 +426,7 @@ public class TruffleTypes {
         public final DeclaredType InstrumentableNode_WrapperNode = c.getDeclaredTypeOptional(InstrumentableNode_WrapperNode_Name);
         public final DeclaredType ProbeNode = c.getDeclaredTypeOptional(ProbeNode_Name);
         public final DeclaredType ProvidedTags = c.getDeclaredTypeOptional(ProvidedTags_Name);
    +    public final DeclaredType Tag = c.getDeclaredTypeOptional(Tag_Name);
         public final DeclaredType TruffleInstrument = c.getDeclaredTypeOptional(TruffleInstrument_Name);
         public final DeclaredType TruffleInstrument_Provider = c.getDeclaredTypeOptional(TruffleInstrument_Provider_Name);
         public final DeclaredType TruffleInstrument_Registration = c.getDeclaredTypeOptional(TruffleInstrument_Registration_Name);
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java
    index 1484871e5875..81d0d7333c1a 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/FlatNodeGenFactory.java
    @@ -182,7 +182,6 @@ public class FlatNodeGenFactory {
         private final TruffleTypes types = ProcessorContext.getInstance().getTypes();
         private final NodeData node;
         private final TypeSystemData typeSystem;
    -    private final TypeMirror genericType;
         private final Set expectedTypes = new HashSet<>();
         private final Collection sharingNodes;
     
    @@ -232,7 +231,6 @@ public FlatNodeGenFactory(ProcessorContext context, GeneratorMode mode, NodeData
             this.sharingNodes = stateSharingNodes;
             this.node = node;
             this.typeSystem = node.getTypeSystem();
    -        this.genericType = context.getType(Object.class);
             this.boxingEliminationEnabled = !TruffleProcessorOptions.generateSlowPathOnly(context.getEnvironment());
             this.primaryNode = stateSharingNodes.iterator().next() == node;
             this.sharedCaches = sharedCaches;
    @@ -3278,7 +3276,9 @@ private CodeTree createThrowUnsupported(final CodeTreeBuilder parent, final Fram
     
         }
     
    -    void createNodeChildReferenceForException(final FrameState frameState, CodeTreeBuilder builder, List values, NodeExecutionData execution, NodeChildData child, LocalVariable var) {
    +    @SuppressWarnings("unused")
    +    void createNodeChildReferenceForException(final FrameState frameState, CodeTreeBuilder builder, List values, NodeExecutionData execution, NodeChildData child,
    +                    LocalVariable var) {
             if (child != null && !frameState.getMode().isUncached()) {
                 builder.string(accessNodeField(execution));
             } else {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java
    index 2976765b4ec4..186849a719f8 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/GeneratorUtils.java
    @@ -158,9 +158,12 @@ public static CodeTree createShouldNotReachHere(CodeTree causeExpression) {
         }
     
         public static CodeExecutableElement createConstructorUsingFields(Set modifiers, CodeTypeElement clazz) {
    -        TypeElement superClass = fromTypeMirror(clazz.getSuperclass());
    -        ExecutableElement constructor = findConstructor(superClass);
    -        return createConstructorUsingFields(modifiers, clazz, constructor);
    +        ExecutableElement superConstructor = null;
    +        if (clazz.getSuperclass() != null) {
    +            TypeElement superClass = fromTypeMirror(clazz.getSuperclass());
    +            superConstructor = findConstructor(superClass);
    +        }
    +        return createConstructorUsingFields(modifiers, clazz, superConstructor);
         }
     
         public static void addBoundaryOrTransferToInterpreter(CodeExecutableElement method, CodeTreeBuilder builder) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java
    index c995fb483f23..d07328fc00d1 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java
    @@ -994,7 +994,18 @@ public static String getPackageName(TypeMirror mirror) {
     
         public static String createConstantName(String simpleName) {
             StringBuilder b = new StringBuilder(simpleName);
    +
             int i = 0;
    +        while (i < b.length()) {
    +            char c = b.charAt(i);
    +            if (Character.isUpperCase(c) && i != 0 &&
    +                            Character.isUpperCase(b.charAt(i - 1))) {
    +                b.setCharAt(i, Character.toLowerCase(c));
    +            }
    +            i++;
    +        }
    +
    +        i = 0;
             while (i < b.length()) {
                 char c = b.charAt(i);
                 if (Character.isUpperCase(c) && i != 0) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java
    index 84cfd930900b..a05ded8c3f6a 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTree.java
    @@ -42,7 +42,6 @@
     
     import java.util.ArrayList;
     import java.util.List;
    -import java.util.Objects;
     
     import javax.lang.model.type.TypeMirror;
     
    @@ -122,34 +121,4 @@ public boolean isSingleLine() {
             return !containsKind(CodeTreeKind.NEW_LINE);
         }
     
    -    public boolean isEqualTo(CodeTree other) {
    -        if (kind != other.kind) {
    -            return false;
    -        }
    -
    -        if (!Objects.equals(string, other.string)) {
    -            return false;
    -        }
    -
    -        if (children == null && other.children == null) {
    -            return true;
    -        }
    -
    -        if (children == null || other.children == null) {
    -            return false;
    -        }
    -
    -        if (children.size() != other.children.size()) {
    -            return false;
    -        }
    -
    -        for (int i = 0; i < children.size(); i++) {
    -            if (!children.get(i).isEqualTo(other.children.get(i))) {
    -                return false;
    -            }
    -        }
    -
    -        return true;
    -    }
    -
     }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java
    index ea122d8352a1..ee7b6850e326 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/CodeTreeBuilder.java
    @@ -802,6 +802,10 @@ public CodeTreeBuilder maybeCast(TypeMirror sourceType, TypeMirror targetType, S
             return this;
         }
     
    +    public CodeTreeBuilder cast(TypeMirror type, String content) {
    +        return cast(type, CodeTreeBuilder.singleString(content));
    +    }
    +
         public CodeTreeBuilder cast(TypeMirror type, CodeTree content) {
             if (ElementUtils.isVoid(type)) {
                 tree(content);
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/ElementHelpers.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/ElementHelpers.java
    new file mode 100644
    index 000000000000..229961c21c7b
    --- /dev/null
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/ElementHelpers.java
    @@ -0,0 +1,161 @@
    +/*
    + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
    + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    + *
    + * The Universal Permissive License (UPL), Version 1.0
    + *
    + * Subject to the condition set forth below, permission is hereby granted to any
    + * person obtaining a copy of this software, associated documentation and/or
    + * data (collectively the "Software"), free of charge and under any and all
    + * copyright rights in the Software, and any and all patent rights owned or
    + * freely licensable by each licensor hereunder covering either (i) the
    + * unmodified Software as contributed to or provided by such licensor, or (ii)
    + * the Larger Works (as defined below), to deal in both
    + *
    + * (a) the Software, and
    + *
    + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
    + * one is included with the Software each a "Larger Work" to which the Software
    + * is contributed by such licensors),
    + *
    + * without restriction, including without limitation the rights to copy, create
    + * derivative works of, display, perform, and distribute the Software and make,
    + * use, sell, offer for sale, import, export, have made, and have sold the
    + * Software and the Larger Work(s), and to sublicense the foregoing rights on
    + * either these or other terms.
    + *
    + * This license is subject to the following condition:
    + *
    + * The above copyright notice and either this complete permission notice or at a
    + * minimum a reference to the UPL must be included in all copies or substantial
    + * portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    + * SOFTWARE.
    + */
    +package com.oracle.truffle.dsl.processor.operations.generator;
    +
    +import java.util.List;
    +import java.util.Set;
    +
    +import javax.lang.model.element.Element;
    +import javax.lang.model.element.Modifier;
    +import javax.lang.model.element.TypeElement;
    +import javax.lang.model.type.ArrayType;
    +import javax.lang.model.type.DeclaredType;
    +import javax.lang.model.type.TypeMirror;
    +
    +import com.oracle.truffle.dsl.processor.ProcessorContext;
    +import com.oracle.truffle.dsl.processor.java.ElementUtils;
    +import com.oracle.truffle.dsl.processor.java.model.CodeElement;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTree;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror;
    +import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement;
    +
    +interface ElementHelpers {
    +
    +    static TypeMirror type(Class t) {
    +        return ProcessorContext.getInstance().getType(t);
    +    }
    +
    +    static DeclaredType declaredType(Class t) {
    +        return ProcessorContext.getInstance().getDeclaredType(t);
    +    }
    +
    +    static DeclaredType declaredType(TypeMirror t) {
    +        return (DeclaredType) t;
    +    }
    +
    +    static TypeElement element(Class t) {
    +        TypeElement type = ElementUtils.castTypeElement(ProcessorContext.getInstance().getDeclaredType(t));
    +        if (type == null) {
    +            throw new NullPointerException("Cannot cast to type element " + t);
    +        }
    +        return type;
    +    }
    +
    +    static ArrayType arrayOf(TypeMirror t) {
    +        return new CodeTypeMirror.ArrayCodeTypeMirror(t);
    +    }
    +
    +    static ArrayType arrayOf(Class t) {
    +        return arrayOf(type(t));
    +    }
    +
    +    static TypeElement element(TypeMirror t) {
    +        TypeElement type = ElementUtils.castTypeElement(t);
    +        if (type == null) {
    +            throw new NullPointerException("Cannot cast to type element " + t);
    +        }
    +        return type;
    +    }
    +
    +    static TypeMirror[] types(Class... types) {
    +        TypeMirror[] array = new TypeMirror[types.length];
    +        for (int i = 0; i < types.length; i++) {
    +            array[i] = type(types[i]);
    +        }
    +        return array;
    +    }
    +
    +    static CodeTree tree(String s) {
    +        return CodeTreeBuilder.singleString(s);
    +    }
    +
    +    static DeclaredType generic(TypeMirror type, TypeMirror genericType1) {
    +        return new CodeTypeMirror.DeclaredCodeTypeMirror(element(type), List.of(genericType1));
    +    }
    +
    +    static DeclaredType generic(Class type, TypeMirror genericType1) {
    +        return new CodeTypeMirror.DeclaredCodeTypeMirror(element(type), List.of(genericType1));
    +    }
    +
    +    static DeclaredType generic(Class type, TypeMirror... genericType1) {
    +        return new CodeTypeMirror.DeclaredCodeTypeMirror(element(type), List.of(genericType1));
    +    }
    +
    +    static DeclaredType generic(Class type, Class... genericTypes) {
    +        return new CodeTypeMirror.DeclaredCodeTypeMirror(element(type), List.of(types(genericTypes)));
    +    }
    +
    +    static CodeTree tree(Class type, String s) {
    +        return new CodeTreeBuilder(null).type(type(type)).string(s).build();
    +    }
    +
    +    static CodeTree tree(TypeMirror type, String s) {
    +        return new CodeTreeBuilder(null).type(type).string(s).build();
    +    }
    +
    +    static CodeTree tree(String s1, String s2) {
    +        return CodeTreeBuilder.createBuilder().string(s1).string(s2).build();
    +    }
    +
    +    static CodeVariableElement addField(CodeElement e, Set modifiers, TypeMirror type, String name) {
    +        CodeVariableElement var = new CodeVariableElement(modifiers, type, name);
    +        e.getEnclosedElements().add(var);
    +        return var;
    +    }
    +
    +    static CodeVariableElement addField(CodeElement e, Set modifiers, Class type, String name) {
    +        return addField(e, modifiers, type(type), name);
    +    }
    +
    +    static CodeVariableElement addField(CodeElement e, Set modifiers, Class type, String name, CodeTree init) {
    +        CodeVariableElement var = e.add(new CodeVariableElement(modifiers, ProcessorContext.getInstance().getType(type), name));
    +        if (init != null) {
    +            var.createInitBuilder().tree(init);
    +        }
    +        return var;
    +    }
    +
    +    static CodeVariableElement addField(CodeElement e, Set modifiers, Class type, String name, String init) {
    +        return addField(e, modifiers, type, name, CodeTreeBuilder.singleString(init));
    +    }
    +
    +}
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    index ccd836abb957..21c6cc0ca4cf 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    @@ -46,7 +46,6 @@
     import javax.lang.model.type.TypeMirror;
     
     import com.oracle.truffle.dsl.processor.ProcessorContext;
    -import com.oracle.truffle.dsl.processor.TruffleTypes;
     import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory;
     import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.ChildExecutionResult;
     import com.oracle.truffle.dsl.processor.generator.FlatNodeGenFactory.FrameState;
    @@ -64,14 +63,12 @@
     public class OperationNodeGeneratorPlugs implements NodeGeneratorPlugs {
     
         private final ProcessorContext context;
    -    private final TruffleTypes types;
         private final TypeMirror nodeType;
         private final InstructionModel instr;
         private final boolean isBoxingOperations;
     
         public OperationNodeGeneratorPlugs(ProcessorContext context, TypeMirror nodeType, InstructionModel instr) {
             this.context = context;
    -        this.types = context.getTypes();
             this.nodeType = nodeType;
             this.instr = instr;
     
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java
    index cfd381adfa31..3ab514b0da1f 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsCodeGenerator.java
    @@ -52,7 +52,7 @@ public class OperationsCodeGenerator extends CodeTypeElementFactory create(ProcessorContext context, AnnotationProcessor processor, OperationsModel m) {
    -        return List.of(new OperationsNodeFactory(context, m).create());
    +        return List.of(new OperationsNodeFactory(m).create());
         }
     
     }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index f20f95c109fc..95d40c45743e 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -45,23 +45,32 @@
     import static com.oracle.truffle.dsl.processor.generator.GeneratorUtils.createShouldNotReachHere;
     import static com.oracle.truffle.dsl.processor.java.ElementUtils.boxType;
     import static com.oracle.truffle.dsl.processor.java.ElementUtils.firstLetterUpperCase;
    +import static com.oracle.truffle.dsl.processor.operations.generator.ElementHelpers.addField;
    +import static com.oracle.truffle.dsl.processor.operations.generator.ElementHelpers.arrayOf;
    +import static com.oracle.truffle.dsl.processor.operations.generator.ElementHelpers.generic;
    +import static com.oracle.truffle.dsl.processor.operations.generator.ElementHelpers.type;
     import static javax.lang.model.element.Modifier.ABSTRACT;
     import static javax.lang.model.element.Modifier.FINAL;
     import static javax.lang.model.element.Modifier.PRIVATE;
     import static javax.lang.model.element.Modifier.PUBLIC;
     import static javax.lang.model.element.Modifier.STATIC;
     
    +import java.io.DataInput;
    +import java.io.DataOutput;
    +import java.io.IOError;
    +import java.io.IOException;
     import java.util.ArrayList;
     import java.util.Arrays;
    +import java.util.HashMap;
     import java.util.HashSet;
     import java.util.List;
     import java.util.Set;
    +import java.util.function.Supplier;
     
     import javax.lang.model.element.Element;
     import javax.lang.model.element.ElementKind;
     import javax.lang.model.element.ExecutableElement;
     import javax.lang.model.element.Name;
    -import javax.lang.model.element.TypeElement;
     import javax.lang.model.element.VariableElement;
     import javax.lang.model.type.ArrayType;
     import javax.lang.model.type.DeclaredType;
    @@ -83,8 +92,7 @@
     import com.oracle.truffle.dsl.processor.java.model.CodeTree;
     import com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder;
     import com.oracle.truffle.dsl.processor.java.model.CodeTypeElement;
    -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror;
    -import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror;
     import com.oracle.truffle.dsl.processor.java.model.CodeVariableElement;
     import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror;
     import com.oracle.truffle.dsl.processor.model.SpecializationData;
    @@ -96,13 +104,15 @@
     import com.oracle.truffle.dsl.processor.operations.model.OperationModel.OperationKind;
     import com.oracle.truffle.dsl.processor.operations.model.OperationsModel;
     
    -public class OperationsNodeFactory {
    -    private final ProcessorContext context;
    -    private final TruffleTypes types;
    +public class OperationsNodeFactory implements ElementHelpers {
    +    private final ProcessorContext context = ProcessorContext.getInstance();
    +    private final TruffleTypes types = context.getTypes();
         private final OperationsModel model;
     
         private CodeTypeElement operationNodeGen;
    -    private CodeTypeElement operationBuilder = new CodeTypeElement(Set.of(PUBLIC, STATIC, FINAL), ElementKind.CLASS, null, "Builder");
    +    private CodeTypeElement builder = new CodeTypeElement(Set.of(PUBLIC, STATIC, FINAL), ElementKind.CLASS, null, "Builder");
    +    private DeclaredType operationBuilderType = new GeneratedTypeMirror("", builder.getSimpleName().toString(), builder.asType());
    +    private TypeMirror parserType = generic(types.OperationParser, operationBuilderType);
         private CodeTypeElement operationNodes = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationNodesImpl");
     
         private CodeTypeElement intRef = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "IntRef");
    @@ -119,9 +129,9 @@ public class OperationsNodeFactory {
     
         private static final Name Uncached_Name = CodeNames.of("Uncached");
     
    -    public OperationsNodeFactory(ProcessorContext context, OperationsModel model) {
    -        this.context = context;
    -        this.types = context.getTypes();
    +    private BuilderElements builderElements;
    +
    +    public OperationsNodeFactory(OperationsModel model) {
             this.model = model;
         }
     
    @@ -150,7 +160,9 @@ public CodeTypeElement create() {
             operationNodeGen.add(createInterpreterSwitch(cachedInterpreter, "CACHED"));
             operationNodeGen.add(createInterpreterSwitch(instrumentableInterpreter, "INSTRUMENTABLE"));
     
    -        operationNodeGen.add(new BuilderFactory().create());
    +        this.builderElements = new BuilderElements();
    +        operationNodeGen.add(builderElements.getElement());
    +
             operationNodeGen.add(new OperationNodesImplFactory().create());
             operationNodeGen.add(new IntRefFactory().create());
             operationNodeGen.add(new OperationLocalImplFactory().create());
    @@ -170,6 +182,26 @@ public CodeTypeElement create() {
             operationNodeGen.add(createExecute());
             operationNodeGen.add(createSneakyThrow());
     
    +        if (model.enableSerialization) {
    +
    +            if (!model.getProvidedTags().isEmpty()) {
    +                CodeExecutableElement initializeClassToTagIndex = operationNodeGen.add(createInitializeClassToTagIndex());
    +                CodeVariableElement classToTag = compFinal(1,
    +                                new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), arrayOf(generic(context.getDeclaredType(Class.class), types.Tag)), "TAG_INDEX_TO_CLASS"));
    +                classToTag.createInitBuilder().startStaticCall(initializeClassToTagIndex).end();
    +                operationNodeGen.add(classToTag);
    +
    +                CodeExecutableElement initializeTagIndexToClass = operationNodeGen.add(createInitializeTagIndexToClass());
    +                CodeVariableElement tagToClass = new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), generic(context.getDeclaredType(ClassValue.class), context.getType(Short.class)),
    +                                "CLASS_TO_TAG_INDEX");
    +                tagToClass.createInitBuilder().startStaticCall(initializeTagIndexToClass).end();
    +                operationNodeGen.add(tagToClass);
    +            }
    +
    +            operationNodeGen.add(createSerialize());
    +            operationNodeGen.add(createDeserialize());
    +        }
    +
             operationNodeGen.add(createGetIntrospectionData());
     
             operationNodeGen.add(createChangeInterpreters());
    @@ -351,7 +383,7 @@ private CodeVariableElement createInterpreterField() {
             return fld;
         }
     
    -    private CodeVariableElement createInterpreterSwitch(CodeTypeElement interpreterType, String name) {
    +    private static CodeVariableElement createInterpreterSwitch(CodeTypeElement interpreterType, String name) {
             CodeVariableElement fld = new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), interpreterType.asType(), name + "_INTERPRETER");
             fld.createInitBuilder().startNew(interpreterType.asType()).end();
             return fld;
    @@ -459,7 +491,7 @@ private CodeExecutableElement createExecute() {
             return ex;
         }
     
    -    private CodeExecutableElement createSneakyThrow() {
    +    private static CodeExecutableElement createSneakyThrow() {
             CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), null, " RuntimeException sneakyThrow(Throwable e) throws E { //");
             CodeTreeBuilder b = ex.createBuilder();
     
    @@ -471,12 +503,12 @@ private CodeExecutableElement createSneakyThrow() {
         private CodeExecutableElement createCreate() {
             CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC, STATIC), generic(types.OperationNodes, model.templateType.asType()), "create");
             ex.addParameter(new CodeVariableElement(types.OperationConfig, "config"));
    -        ex.addParameter(new CodeVariableElement(generic(types.OperationParser, operationBuilder.asType()), "generator"));
    +        ex.addParameter(new CodeVariableElement(generic(types.OperationParser, builder.asType()), "generator"));
     
             CodeTreeBuilder b = ex.getBuilder();
     
             b.declaration("OperationNodesImpl", "nodes", "new OperationNodesImpl(generator)");
    -        b.startAssign("Builder builder").startNew(operationBuilder.asType());
    +        b.startAssign("Builder builder").startNew(builder.asType());
             b.string("nodes");
             b.string("false");
             b.string("config");
    @@ -493,6 +525,114 @@ private CodeExecutableElement createCreate() {
             return ex;
         }
     
    +    private CodeExecutableElement createInitializeClassToTagIndex() {
    +        ArrayType rawArray = arrayOf(context.getType(Class.class));
    +        ArrayType genericArray = arrayOf(generic(context.getDeclaredType(Class.class), types.Tag));
    +        CodeExecutableElement method = new CodeExecutableElement(Set.of(PRIVATE, STATIC), genericArray, "initializeClassToTagIndex");
    +        CodeTreeBuilder b = method.createBuilder();
    +
    +        b.startReturn();
    +        b.cast(genericArray);
    +        b.startNewArray(rawArray, null);
    +
    +        for (TypeMirror tagClass : model.getProvidedTags()) {
    +            b.typeLiteral(tagClass);
    +        }
    +
    +        b.end();
    +        b.end();
    +
    +        return method;
    +    }
    +
    +    private CodeExecutableElement createInitializeTagIndexToClass() {
    +        DeclaredType classValue = context.getDeclaredType(ClassValue.class);
    +        TypeMirror classValueType = generic(classValue, context.getType(Short.class));
    +
    +        CodeExecutableElement method = new CodeExecutableElement(Set.of(PRIVATE, STATIC), classValueType,
    +                        "initializeTagIndexToClass");
    +        CodeTreeBuilder b = method.createBuilder();
    +
    +        b.startStatement();
    +        b.string("return new ClassValue<>()").startBlock();
    +        b.string("protected Short computeValue(Class type) ").startBlock();
    +
    +        boolean elseIf = false;
    +        int index = 0;
    +        for (TypeMirror tagClass : model.getProvidedTags()) {
    +            elseIf = b.startIf(elseIf);
    +            b.string("type == ").typeLiteral(tagClass);
    +            b.end().startBlock();
    +            b.startReturn().string(index).end();
    +            b.end();
    +            index++;
    +        }
    +        b.startReturn().string(-1).end();
    +
    +        b.end();
    +
    +        b.end();
    +        b.end();
    +
    +        return method;
    +    }
    +
    +    private CodeExecutableElement createSerialize() {
    +        CodeExecutableElement method = new CodeExecutableElement(Set.of(PUBLIC, STATIC), context.getType(void.class), "serialize");
    +        method.addParameter(new CodeVariableElement(types.OperationConfig, "config"));
    +        method.addParameter(new CodeVariableElement(context.getType(DataOutput.class), "buffer"));
    +        method.addParameter(new CodeVariableElement(types.OperationSerializer, "callback"));
    +        method.addParameter(new CodeVariableElement(parserType, "parser"));
    +        method.addThrownType(context.getType(IOException.class));
    +
    +        CodeTreeBuilder init = CodeTreeBuilder.createBuilder();
    +        init.startNew(operationBuilderType);
    +        init.startGroup();
    +        init.cast(operationNodes.asType());
    +        init.string("create(config, parser)");
    +        init.end();
    +        init.string("false");
    +        init.string("config");
    +        init.end();
    +
    +        CodeTreeBuilder b = method.createBuilder();
    +        b.declaration(operationBuilderType, "builder", init.build());
    +
    +        b.startTryBlock();
    +
    +        b.startStatement().startCall("builder", "serialize");
    +        b.string("buffer");
    +        b.string("callback");
    +        b.end().end();
    +
    +        b.end().startCatchBlock(context.getType(IOError.class), "e");
    +        b.startThrow().cast(context.getType(IOException.class), "e.getCause()").end();
    +        b.end();
    +
    +        return method;
    +    }
    +
    +    private CodeExecutableElement createDeserialize() {
    +        CodeExecutableElement method = new CodeExecutableElement(Set.of(PUBLIC, STATIC),
    +                        generic(types.OperationNodes, model.getTemplateType().asType()), "deserialize");
    +
    +        method.addParameter(new CodeVariableElement(types.TruffleLanguage, "language"));
    +        method.addParameter(new CodeVariableElement(types.OperationConfig, "config"));
    +        method.addParameter(new CodeVariableElement(generic(Supplier.class, DataInput.class), "input"));
    +        method.addParameter(new CodeVariableElement(types.OperationDeserializer, "callback"));
    +        method.addThrownType(context.getType(IOException.class));
    +        CodeTreeBuilder b = method.createBuilder();
    +
    +        b.startTryBlock();
    +
    +        b.statement("return create(config, (b) -> b.deserialize(language, input, callback))");
    +        b.end().startCatchBlock(type(IOError.class), "e");
    +        b.startThrow().cast(type(IOException.class), "e.getCause()").end();
    +        b.end();
    +
    +        return method;
    +    }
    +
         private CodeExecutableElement createGetIntrospectionData() {
             CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationIntrospection, "getIntrospectionData");
             CodeTreeBuilder b = ex.createBuilder();
    @@ -686,6 +826,14 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) {
             return ex;
         }
     
    +    private void serializationWrapException(CodeTreeBuilder b, Runnable r) {
    +        b.startTryBlock();
    +        r.run();
    +        b.end().startCatchBlock(context.getType(IOException.class), "ex");
    +        b.startThrow().startNew(context.getType(IOError.class)).string("ex").end(2);
    +        b.end();
    +    }
    +
         private CodeExecutableElement createChangeInterpreters() {
             CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "changeInterpreters");
     
    @@ -766,7 +914,120 @@ private CodeExecutableElement createChangeInterpreters() {
             return ex;
         }
     
    -    class BuilderFactory {
    +    final class SerializationStateElements implements ElementHelpers {
    +
    +        final CodeTypeElement serializationState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SerializationState");
    +
    +        final CodeVariableElement codeCreateLabel = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class, "CODE_$CREATE_LABEL", "-2");
    +        final CodeVariableElement codeCreateLocal = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class, "CODE_$CREATE_LOCAL", "-3");
    +        final CodeVariableElement codeCreateObject = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class, "CODE_$CREATE_OBJECT", "-4");
    +        final CodeVariableElement codeEndSerialize = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class, "CODE_$END", "-5");
    +
    +        final CodeVariableElement builtNodes = addField(serializationState, Set.of(PRIVATE, FINAL), generic(ArrayList.class, operationNodeGen.asType()), "builtNodes");
    +        final CodeVariableElement buffer = addField(serializationState, Set.of(PRIVATE, FINAL), DataOutput.class, "buffer");
    +        final CodeVariableElement callback = addField(serializationState, Set.of(PRIVATE, FINAL), types.OperationSerializer, "callback");
    +        final CodeExecutableElement constructor = serializationState.add(createConstructorUsingFields(Set.of(), serializationState, null));
    +        final CodeVariableElement language = addField(serializationState, Set.of(PRIVATE), types.TruffleLanguage, "language");
    +
    +        final CodeVariableElement labelCount = addField(serializationState, Set.of(PRIVATE), int.class, "labelCount");
    +        final CodeVariableElement objects = addField(serializationState, Set.of(PRIVATE, FINAL),
    +                        generic(HashMap.class, Object.class, Short.class), "objects");
    +
    +        final CodeVariableElement[] codeBegin;
    +        final CodeVariableElement[] codeEnd;
    +
    +        SerializationStateElements() {
    +            serializationState.getImplements().add(types.OperationSerializer_SerializerContext);
    +
    +            objects.createInitBuilder().startNew("HashMap<>").end();
    +
    +            codeBegin = new CodeVariableElement[model.getOperations().size() + 1];
    +            codeEnd = new CodeVariableElement[model.getOperations().size() + 1];
    +
    +            for (OperationModel o : model.getOperations()) {
    +                if (o.hasChildren()) {
    +                    codeBegin[o.id] = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class,
    +                                    "CODE_BEGIN_" + ElementUtils.createConstantName(o.name), String.valueOf(o.id) + " << 1");
    +                    codeEnd[o.id] = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class,
    +                                    "CODE_END_" + ElementUtils.createConstantName(o.name), "(" + String.valueOf(o.id) + " << 1) | 0b1");
    +                } else {
    +                    codeBegin[o.id] = addField(serializationState, Set.of(PRIVATE, STATIC, FINAL), short.class,
    +                                    "CODE_EMIT_" + ElementUtils.createConstantName(o.name), String.valueOf(o.id) + " << 1");
    +                }
    +            }
    +
    +            serializationState.add(createSerializeObject());
    +            serializationState.add(createWriteOperationNode());
    +
    +        }
    +
    +        private CodeExecutableElement createWriteOperationNode() {
    +            CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationSerializer_SerializerContext, "writeOperationNode");
    +            ex.renameArguments("buffer", "node");
    +            CodeTreeBuilder b = ex.createBuilder();
    +            b.startStatement();
    +            b.string("buffer.writeChar((");
    +            b.cast(operationNodeGen.asType()).string("node).buildIndex)");
    +            b.end();
    +
    +            return ex;
    +        }
    +
    +        private CodeExecutableElement createSerializeObject() {
    +            CodeExecutableElement method = new CodeExecutableElement(Set.of(PRIVATE), type(short.class), "serializeObject");
    +            method.addParameter(new CodeVariableElement(type(Object.class), "object"));
    +            method.addThrownType(type(IOException.class));
    +            CodeTreeBuilder b = method.createBuilder();
    +
    +            String argumentName = "object";
    +            String index = "index";
    +
    +            b.startAssign("Short " + index).startCall("objects.get").string(argumentName).end(2);
    +            b.startIf().string(index + " == null").end().startBlock();
    +            b.startAssign(index).startCall("(short) objects.size").end(2);
    +            b.startStatement().startCall("objects.put").string(argumentName).string(index).end(2);
    +
    +            b.startStatement();
    +            b.string(buffer.getName(), ".").startCall("writeShort").string(codeCreateObject.getName()).end();
    +            b.end();
    +            b.statement("callback.serialize(this, buffer, object)");
    +            b.end();
    +            b.statement("return ", index);
    +            return method;
    +
    +        }
    +
    +        public void writeShort(CodeTreeBuilder b, CodeVariableElement label) {
    +            writeShort(b, b.create().staticReference(label).build());
    +        }
    +
    +        public void writeShort(CodeTreeBuilder b, String value) {
    +            writeShort(b, CodeTreeBuilder.singleString(value));
    +        }
    +
    +        public void writeShort(CodeTreeBuilder b, CodeTree value) {
    +            b.startStatement();
    +            b.string("serialization.", buffer.getName(), ".").startCall("writeShort");
    +            b.tree(value).end();
    +            b.end();
    +        }
    +
    +        public void writeInt(CodeTreeBuilder b, String value) {
    +            writeInt(b, CodeTreeBuilder.singleString(value));
    +        }
    +
    +        public void writeInt(CodeTreeBuilder b, CodeTree value) {
    +            b.startStatement();
    +            b.string("serialization.", buffer.getName(), ".").startCall("writeInt");
    +            b.tree(value).end();
    +            b.end();
    +        }
    +
    +    }
    +
    +    class BuilderElements {
    +
    +        private CodeTypeElement deserializerContextImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "DeserializerContextImpl");
     
             CodeTypeElement savedState = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "SavedState");
             CodeTypeElement finallyTryContext = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "FinallyTryContext");
    @@ -854,52 +1115,310 @@ private CodeTypeElement create() {
                 }
             }
     
    -        private CodeTypeElement create() {
    -            operationBuilder.setSuperClass(types.OperationBuilder);
    -            operationBuilder.setEnclosingElement(operationNodeGen);
    +        class DeserializerContextImplFactory {
    +            private CodeTypeElement create() {
    +                deserializerContextImpl.setEnclosingElement(operationNodeGen);
    +                deserializerContextImpl.getImplements().add(types.OperationDeserializer_DeserializerContext);
    +
    +                deserializerContextImpl.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes"));
    +                deserializerContextImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(PRIVATE), deserializerContextImpl));
    +
    +                deserializerContextImpl.add(createDeserializeOperationNode());
    +
    +                return deserializerContextImpl;
    +            }
     
    -            operationBuilder.add(new SavedStateFactory().create());
    -            operationBuilder.add(new FinallyTryContextFactory().create());
    +            private CodeExecutableElement createDeserializeOperationNode() {
    +                CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.OperationDeserializer_DeserializerContext, "readOperationNode");
    +                ex.renameArguments("buffer");
    +                CodeTreeBuilder b = ex.createBuilder();
    +                b.statement("return this.builtNodes.get(buffer.readChar())");
    +                return ex;
    +            }
    +        }
     
    -            operationBuilder.add(createConstructor());
    +        private SerializationStateElements serializationElements;
    +        private CodeVariableElement serialization;
     
    -            operationBuilder.add(createOperationNames());
    +        BuilderElements() {
    +            builder.setSuperClass(types.OperationBuilder);
    +            builder.setEnclosingElement(operationNodeGen);
     
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), operationNodes.asType(), "nodes"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), context.getType(boolean.class), "isReparse"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withSource"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withInstrumentation"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"));
    -            operationBuilder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), types.Source), "sources"));
    +            builder.add(new SavedStateFactory().create());
    +            builder.add(new FinallyTryContextFactory().create());
     
    -            operationBuilder.addAll(builderState);
    +            builder.add(createOperationNames());
     
    -            operationBuilder.add(createCreateLocal());
    -            operationBuilder.add(createCreateLabel());
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), operationNodes.asType(), "nodes"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), context.getType(boolean.class), "isReparse"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withSource"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean.class), "withInstrumentation"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "buildIndex"));
    +            builder.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), types.Source), "sources"));
    +
    +            if (model.enableSerialization) {
    +                serializationElements = new SerializationStateElements();
    +                builder.add(serializationElements.serializationState);
    +                serialization = builder.add(new CodeVariableElement(Set.of(PRIVATE),
    +                                serializationElements.serializationState.asType(), "serialization"));
    +                builder.add(new DeserializerContextImplFactory().create());
    +            }
    +
    +            builder.add(createConstructor());
    +
    +            builder.addAll(builderState);
    +
    +            builder.add(createCreateLocal());
    +            builder.add(createCreateLabel());
     
                 for (OperationModel operation : model.getOperations()) {
    -                if (operation.isVariadic || operation.numChildren > 0) {
    -                    operationBuilder.add(createBegin(operation));
    -                    operationBuilder.add(createEnd(operation));
    +                if (operation.hasChildren()) {
    +                    builder.add(createBegin(operation));
    +                    builder.add(createEnd(operation));
                     } else {
    -                    operationBuilder.add(createEmit(operation));
    +                    builder.add(createEmit(operation));
                     }
                 }
     
    -            operationBuilder.add(createBeginHelper());
    -            operationBuilder.add(createEndHelper());
    -            operationBuilder.add(createEmitHelperBegin());
    -            operationBuilder.add(createBeforeChild());
    -            operationBuilder.add(createAfterChild());
    -            operationBuilder.add(createDoEmitFinallyHandler());
    -            operationBuilder.add(createDoEmitInstruction());
    -            operationBuilder.add(createDoCreateExceptionHandler());
    -            operationBuilder.add(createDoEmitSourceInfo());
    -            operationBuilder.add(createFinish());
    -            operationBuilder.add(createDoEmitLeaves());
    +            builder.add(createBeginHelper());
    +            builder.add(createEndHelper());
    +            builder.add(createEmitHelperBegin());
    +            builder.add(createBeforeChild());
    +            builder.add(createAfterChild());
    +            builder.add(createDoEmitFinallyHandler());
    +            builder.add(createDoEmitInstruction());
    +            builder.add(createDoCreateExceptionHandler());
    +            builder.add(createDoEmitSourceInfo());
    +            builder.add(createFinish());
    +            builder.add(createDoEmitLeaves());
    +            if (model.enableSerialization) {
    +                builder.add(createSerialize());
    +                builder.add(createDeserialize());
    +            }
    +        }
    +
    +        private CodeTypeElement getElement() {
    +            return builder;
    +        }
    +
    +        private CodeExecutableElement createSerialize() {
    +            CodeExecutableElement method = new CodeExecutableElement(Set.of(PRIVATE),
    +                            context.getType(void.class), "serialize");
    +            method.addParameter(new CodeVariableElement(type(DataOutput.class), "buffer"));
    +            method.addParameter(new CodeVariableElement(types.OperationSerializer, "callback"));
    +
    +            method.addThrownType(context.getType(IOException.class));
    +            CodeTreeBuilder b = method.createBuilder();
    +            b.statement("this.serialization = new SerializationState(builtNodes, buffer, callback)");
    +
    +            b.startTryBlock();
    +            b.statement("nodes.getParser().parse(this)");
    +
    +            b.statement("short[][] nodeIndices = new short[builtNodes.size()][]");
    +            b.startFor().string("int i = 0; i < nodeIndices.length; i ++").end().startBlock();
    +
    +            b.declaration(operationNodeGen.asType(), "node", "builtNodes.get(i)");
    +
    +            b.statement("short[] indices = nodeIndices[i] = new short[" + model.serializedFields.size() + "]");
    +
    +            for (int i = 0; i < model.serializedFields.size(); i++) {
    +                VariableElement var = model.serializedFields.get(i);
    +                b.startStatement();
    +                b.string("indices[").string(i).string("] = ");
    +                b.startCall("serialization.serializeObject");
    +                b.startGroup();
    +                b.string("node.").string(var.getSimpleName().toString());
    +                b.end();
    +                b.end();
    +                b.end();
    +            }
    +
    +            b.end(); // node for
    +
    +            serializationElements.writeShort(b, serializationElements.codeEndSerialize);
    +
    +            b.startFor().string("int i = 0; i < nodeIndices.length; i++").end().startBlock();
    +            b.statement("short[] indices = nodeIndices[i]");
    +
    +            for (int i = 0; i < model.serializedFields.size(); i++) {
    +                serializationElements.writeShort(b, "indices[" + i + "]");
    +            }
    +            b.end();
    +
    +            b.end().startFinallyBlock();
    +            b.statement("this.serialization = null");
    +            b.end();
    +
    +            return method;
    +
    +        }
    +
    +        private CodeExecutableElement createDeserialize() {
    +            CodeExecutableElement method = new CodeExecutableElement(Set.of(PRIVATE),
    +                            context.getType(void.class), "deserialize");
    +
    +            method.addParameter(new CodeVariableElement(types.TruffleLanguage, "language"));
    +            method.addParameter(new CodeVariableElement(generic(Supplier.class, DataInput.class), "bufferSupplier"));
    +            method.addParameter(new CodeVariableElement(types.OperationDeserializer, "callback"));
    +
    +            CodeTreeBuilder b = method.createBuilder();
    +
    +            b.startTryBlock();
    +
    +            b.statement("ArrayList consts = new ArrayList<>()");
    +            b.statement("ArrayList locals = new ArrayList<>()");
    +            b.statement("ArrayList labels = new ArrayList<>()");
    +            b.startStatement().type(type(DataInput.class)).string(" buffer = bufferSupplier.get()").end();
    +
    +            b.startStatement();
    +            b.type(generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()));
    +            b.string("builtNodes = new ArrayList<>()");
    +            b.end();
    +
    +            b.startStatement();
    +            b.type(types.OperationDeserializer_DeserializerContext);
    +            b.string(" context = ").startNew(deserializerContextImpl.getSimpleName().toString()).string("builtNodes").end();
    +            b.end();
    +
    +            b.startWhile().string("true").end().startBlock();
    +
    +            b.declaration(type(short.class), "code", "buffer.readShort()");
    +
    +            b.startSwitch().string("code").end().startBlock();
    +
    +            b.startCase().staticReference(serializationElements.codeCreateLabel).end().startBlock();
    +            b.statement("labels.add(createLabel())");
    +            b.statement("break");
    +            b.end();
    +
    +            b.startCase().staticReference(serializationElements.codeCreateLocal).end().startBlock();
    +            b.statement("locals.add(createLocal())");
    +            b.statement("break");
    +            b.end();
    +
    +            b.startCase().staticReference(serializationElements.codeCreateObject).end().startBlock();
    +            b.statement("consts.add(callback.deserialize(context, buffer))");
    +            b.statement("break");
    +            b.end();
    +
    +            b.startCase().staticReference(serializationElements.codeEndSerialize).end().startBlock();
    +
    +            b.startFor().string("int i = 0; i < builtNodes.size(); i++").end().startBlock();
    +            b.declaration(operationNodeGen.asType(), "node", "builtNodes.get(i)");
    +
    +            for (int i = 0; i < model.serializedFields.size(); i++) {
    +                VariableElement var = model.serializedFields.get(i);
    +                b.startStatement();
    +                b.string("node.").string(var.getSimpleName().toString());
    +                b.string(" = ");
    +                if (ElementUtils.needsCastTo(type(Object.class), var.asType())) {
    +                    b.cast(var.asType());
    +                }
    +                b.string("consts.get(buffer.readShort())");
    +                b.end();
    +            }
    +            b.end();
    +
    +            b.returnStatement();
    +            b.end();
    +
    +            final boolean hasTags = !model.getProvidedTags().isEmpty();
    +            for (OperationModel op : model.getOperations()) {
    +
    +                // create begin/emit code
    +                b.startCase().staticReference(serializationElements.codeBegin[op.id]).end().startBlock();
    +
    +                if (op.kind == OperationKind.INSTRUMENT_TAG && !hasTags) {
    +                    b.startThrow().startNew(context.getType(IllegalStateException.class));
    +                    b.doubleQuote(String.format("Cannot deserialize instrument tag. The language does not specify any tags with a @%s annotation.",
    +                                    ElementUtils.getSimpleName(types.ProvidedTags)));
    +                    b.end().end();
    +                    b.end(); // switch block
    +                    continue;
    +                }
    +
    +                int i = 0;
    +                for (TypeMirror argType : op.operationArguments) {
    +                    String argumentName = "arg" + i;
    +                    if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) {
    +                        b.declaration(types.TruffleLanguage, argumentName, "language");
    +                    } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) {
    +                        b.statement("OperationLocal ", argumentName, " = locals.get(buffer.readShort())");
    +                    } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) {
    +                        b.statement("OperationLocal[] ", argumentName, " = new OperationLocal[buffer.readShort()]");
    +                        b.startFor().string("int i = 0; i < ", argumentName, ".length; i++").end().startBlock();
    +                        // this can be optimized since they are consecutive
    +                        b.statement(argumentName, "[i] = locals.get(buffer.readShort());");
    +                        b.end();
    +                    } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) {
    +                        b.statement("OperationLabel ", argumentName, " = labels.get(buffer.readShort())");
    +                    } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) {
    +                        b.statement("int ", argumentName, " = buffer.readInt()");
    +                    } else if (op.kind == OperationKind.INSTRUMENT_TAG && i == 0) {
    +                        b.startStatement().type(argType).string(" ", argumentName, " = TAG_INDEX_TO_CLASS[buffer.readShort()]").end();
    +                    } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source)) {
    +                        b.startStatement().type(argType).string(" ", argumentName, " = ").cast(argType).string("consts.get(buffer.readShort())").end();
    +                    } else {
    +                        throw new UnsupportedOperationException("cannot deserialize: " + argType);
    +                    }
    +                    i++;
    +                }
    +
    +                b.startStatement();
    +                if (op.hasChildren()) {
    +                    b.startCall("begin" + op.name);
    +                } else {
    +                    b.startCall("emit" + op.name);
    +                }
    +
    +                for (int j = 0; j < i; j++) {
    +                    b.string("arg" + j);
    +                }
    +
    +                b.end(2); // statement, call
    +
    +                b.statement("break");
    +
    +                b.end(); // case block
    +
    +                if (op.hasChildren()) {
    +                    b.startCase().staticReference(serializationElements.codeEnd[op.id]).end().startBlock();
    +
    +                    if (op.kind == OperationKind.ROOT) {
    +                        b.startStatement();
    +                        b.type(model.getTemplateType().asType()).string(" node = ").string("end" + op.name + "()");
    +                        b.end();
    +                        b.startStatement().startCall("builtNodes.add").startGroup().cast(operationNodeGen.asType()).string("node").end().end().end();
    +                    } else {
    +                        b.statement("end", op.name, "()");
    +                    }
    +
    +                    b.statement("break");
    +
    +                    b.end();
    +                }
    +            }
    +
    +            b.caseDefault().startBlock();
    +            b.startThrow().startNew(context.getType(IllegalStateException.class));
    +            b.startGroup();
    +            b.doubleQuote("Unknown operation code ").string(" + code");
    +            b.end();
    +            b.end().end();
    +
    +            b.end(); // switch block
    +            b.end();
    +
    +            b.end(); // switch
    +            b.end(); // while block
    +
    +            b.end().startCatchBlock(context.getType(IOException.class), "ex");
    +            b.startThrow().startNew(context.getType(IOError.class)).string("ex").end(2);
    +            b.end();
    +
    +            return method;
     
    -            return operationBuilder;
             }
     
             private CodeExecutableElement createFinish() {
    @@ -921,6 +1440,14 @@ private CodeExecutableElement createCreateLocal() {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationLocal, "createLocal");
                 CodeTreeBuilder b = ex.createBuilder();
     
    +            if (model.enableSerialization) {
    +                b.startIf().string("serialization != null").end().startBlock();
    +                serializationWrapException(b, () -> {
    +                    serializationElements.writeShort(b, serializationElements.codeCreateLocal);
    +                });
    +                b.end();
    +            }
    +
                 b.startReturn().startNew(operationLocalImpl.asType()).startNew(intRef.asType()).string("numLocals++").end(3);
     
                 return ex;
    @@ -930,6 +1457,20 @@ private CodeExecutableElement createCreateLabel() {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), types.OperationLabel, "createLabel");
                 CodeTreeBuilder b = ex.createBuilder();
     
    +            if (model.enableSerialization) {
    +                b.startIf().string("serialization != null").end().startBlock();
    +                serializationWrapException(b, () -> {
    +                    serializationElements.writeShort(b, serializationElements.codeCreateLabel);
    +                });
    +
    +                b.startReturn().startNew(operationLabelImpl.asType());
    +                b.startNew(intRef.asType()).string("-1").end();
    +                b.string(serialization.getName(), ".", serializationElements.labelCount.getName(), "++");
    +                b.string("0");
    +                b.end(2);
    +                b.end();
    +            }
    +
                 b.startIf().string(
                                 "operationSp == 0 || (",
                                 "operationStack[operationSp - 1] != " + model.blockOperation.id + " /* Block */ ",
    @@ -1016,15 +1557,29 @@ private CodeExecutableElement createBeginHelper() {
             private CodeExecutableElement createBegin(OperationModel operation) {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "begin" + operation.name);
     
    -            if (operation.operationArguments != null) {
    -                int argIndex = 0;
    -                for (TypeMirror argument : operation.operationArguments) {
    -                    ex.addParameter(new CodeVariableElement(argument, "arg" + argIndex));
    -                    argIndex++;
    +            int argIndex = 0;
    +            for (TypeMirror argument : operation.operationArguments) {
    +                ex.addParameter(new CodeVariableElement(argument, "arg" + argIndex));
    +                argIndex++;
    +            }
    +            CodeTreeBuilder b = ex.createBuilder();
    +
    +            if (operation.kind == OperationKind.INSTRUMENT_TAG) {
    +                if (model.getProvidedTags().isEmpty()) {
    +                    b.startThrow().startNew(context.getType(IllegalArgumentException.class));
    +                    b.doubleQuote(String.format("Given tag is not provided by the language. Add a @%s annotation to the %s class.",
    +                                    ElementUtils.getSimpleName(types.ProvidedTags), ElementUtils.getSimpleName(model.languageClass)));
    +                    b.end().end();
    +                    return ex;
                     }
                 }
     
    -            CodeTreeBuilder b = ex.createBuilder();
    +            if (model.enableSerialization) {
    +                b.startIf().string("serialization != null").end().startBlock();
    +                createSerializeBegin(operation, b);
    +                b.statement("return");
    +                b.end();
    +            }
     
                 if (operation.isSourceOnly()) {
                     b.startIf().string("!withSource").end().startBlock();
    @@ -1077,6 +1632,7 @@ private CodeExecutableElement createBegin(OperationModel operation) {
     
                 b.startStatement().startCall("beginOperation");
                 b.string("" + operation.id);
    +
                 buildOperationBeginData(b, operation);
                 b.end(2);
     
    @@ -1175,6 +1731,53 @@ private CodeExecutableElement createBegin(OperationModel operation) {
                 return ex;
             }
     
    +        private void createSerializeBegin(OperationModel operation, CodeTreeBuilder b) {
    +            serializationWrapException(b, () -> {
    +
    +                CodeTreeBuilder after = CodeTreeBuilder.createBuilder();
    +                int i = 0;
    +                for (TypeMirror argType : operation.operationArguments) {
    +                    if (ElementUtils.typeEquals(argType, types.TruffleLanguage)) {
    +                        b.statement("serialization.language = arg" + i);
    +                    } else if (ElementUtils.typeEquals(argType, types.OperationLocal)) {
    +
    +                        serializationElements.writeShort(after, "(short) ((OperationLocalImpl) arg" + i + ").index.value");
    +
    +                    } else if (ElementUtils.typeEquals(argType, new ArrayCodeTypeMirror(types.OperationLocal))) {
    +
    +                        serializationElements.writeShort(after, "(short) arg" + i + ".length");
    +                        after.startFor().string("int i = 0; i < arg" + i + ".length; i++").end().startBlock();
    +                        serializationElements.writeShort(after, "(short) ((OperationLocalImpl) arg" + i + "[i]).index");
    +                        after.end();
    +
    +                    } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) {
    +
    +                        serializationElements.writeShort(after, "(short) ((OperationLabelImpl) arg" + i + ").declaringOp");
    +
    +                    } else if (ElementUtils.typeEquals(argType, context.getType(int.class))) {
    +
    +                        serializationElements.writeInt(after, "arg" + i);
    +
    +                    } else if (operation.kind == OperationKind.INSTRUMENT_TAG && i == 0) {
    +
    +                        serializationElements.writeShort(after, "(short) CLASS_TO_TAG_INDEX.get(arg0)");
    +
    +                    } else if (ElementUtils.isObject(argType) || ElementUtils.typeEquals(argType, types.Source)) {
    +                        String argumentName = "arg" + i;
    +                        String index = argumentName + "_index";
    +                        b.statement("short ", index, " = ", "serialization.serializeObject(", argumentName, ")");
    +                        serializationElements.writeShort(after, index);
    +                    } else {
    +                        throw new UnsupportedOperationException("cannot serialize: " + argType);
    +                    }
    +                    i++;
    +                }
    +                serializationElements.writeShort(b, serializationElements.codeBegin[operation.id]);
    +
    +                b.tree(after.build());
    +            });
    +        }
    +
             private void buildOperationBeginData(CodeTreeBuilder b, OperationModel operation) {
                 switch (operation.kind) {
                     case ROOT:
    @@ -1248,6 +1851,29 @@ private Element createEnd(OperationModel operation) {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PUBLIC), context.getType(void.class), "end" + operation.name);
                 CodeTreeBuilder b = ex.createBuilder();
     
    +            if (model.enableSerialization) {
    +                b.startIf().string("serialization != null").end().startBlock();
    +                serializationWrapException(b, () -> {
    +
    +                    if (operation.kind == OperationKind.ROOT) {
    +                        b.startStatement();
    +                        b.type(operationNodeGen.asType()).string(" node = ").startNew(operationNodeGen.asType()).string("serialization.language").string("FrameDescriptor.newBuilder()").end();
    +                        b.end();
    +                        b.statement("node.buildIndex = buildIndex++");
    +                        serializationElements.writeShort(b, serializationElements.codeEnd[operation.id]);
    +                        b.statement("builtNodes.add(node)");
    +                        b.statement("return node");
    +                    } else {
    +
    +                        serializationElements.writeShort(b, serializationElements.codeEnd[operation.id]);
    +
    +                        b.statement("return");
    +                    }
    +
    +                });
    +                b.end();
    +            }
    +
                 if (operation.isSourceOnly()) {
                     b.startIf().string("!withSource").end().startBlock();
                     b.returnStatement();
    @@ -1496,6 +2122,13 @@ private CodeExecutableElement createEmit(OperationModel operation) {
     
                 CodeTreeBuilder b = ex.createBuilder();
     
    +            if (model.enableSerialization) {
    +                b.startIf().string("serialization != null").end().startBlock();
    +                createSerializeBegin(operation, b);
    +                b.statement("return");
    +                b.end();
    +            }
    +
                 b.startStatement().startCall("beforeChild").end(2);
                 b.startStatement().startCall("emitOperationBegin").end(2);
     
    @@ -1623,7 +2256,7 @@ private CodeExecutableElement createBeforeChild() {
                 b.startSwitch().string("operationStack[operationSp - 1]").end().startBlock();
     
                 for (OperationModel op : model.getOperations()) {
    -                if (!op.isVariadic && op.numChildren == 0) {
    +                if (!op.hasChildren()) {
                         continue;
                     }
     
    @@ -1662,7 +2295,7 @@ private CodeExecutableElement createAfterChild() {
                 b.startSwitch().string("operationStack[operationSp - 1]").end().startBlock();
     
                 for (OperationModel op : model.getOperations()) {
    -                if (!op.isVariadic && op.numChildren == 0) {
    +                if (!op.hasChildren()) {
                         continue;
                     }
     
    @@ -2238,12 +2871,14 @@ private CodeTypeElement create() {
                 operationNodes.add(createSetSources());
                 operationNodes.add(createGetSources());
     
    +            operationNodes.add(createGetParser());
    +
                 return operationNodes;
             }
     
             private CodeExecutableElement createConstructor() {
                 CodeExecutableElement ctor = new CodeExecutableElement(null, "OperationNodesImpl");
    -            ctor.addParameter(new CodeVariableElement(generic(types.OperationParser, operationBuilder.asType()), "generator"));
    +            ctor.addParameter(new CodeVariableElement(parserType, "generator"));
     
                 ctor.createBuilder().statement("super(generator)");
                 return ctor;
    @@ -2254,8 +2889,8 @@ private CodeExecutableElement createReparseImpl() {
                 ex.renameArguments("config", "parse", "nodes");
                 CodeTreeBuilder b = ex.createBuilder();
     
    -            b.statement("Builder builder = new Builder(this, true, config)");
    -
    +            b.declaration(builder.asType(), "builder",
    +                            b.create().startNew(builder.asType()).string("this").string("true").string("config").end().build());
                 b.startStatement().startCall("builder.builtNodes.addAll");
                 b.startGroup().string("(List) ");
                 b.startStaticCall(context.getType(List.class), "of").string("nodes").end();
    @@ -2265,6 +2900,16 @@ private CodeExecutableElement createReparseImpl() {
                 return ex;
             }
     
    +        private CodeExecutableElement createGetParser() {
    +            CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE),
    +                            parserType, "getParser");
    +            CodeTreeBuilder b = ex.createBuilder();
    +            b.startReturn();
    +            b.cast(parserType).string("parse");
    +            b.end();
    +            return ex;
    +        }
    +
             private CodeExecutableElement createSetNodes() {
                 return GeneratorUtils.createSetter(Set.of(), new CodeVariableElement(arrayOf(operationNodeGen.asType()), "nodes"));
             }
    @@ -2985,7 +3630,7 @@ private void processNodeType(CodeTypeElement el, InstructionModel instr) {
                 }
             }
     
    -        private CodeExecutableElement creatSetBoxing(InstructionModel instr) {
    +        private CodeExecutableElement creatSetBoxing(@SuppressWarnings("unused") InstructionModel instr) {
                 CodeExecutableElement setBoxing = GeneratorUtils.overrideImplement((DeclaredType) boxableInterface.asType(), "setBoxing");
                 CodeTreeBuilder b = setBoxing.createBuilder();
     
    @@ -3012,14 +3657,6 @@ private CodeExecutableElement createSetBoxing() {
             }
         }
     
    -    private static TypeMirror generic(DeclaredType el, TypeMirror... args) {
    -        return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args));
    -    }
    -
    -    private static ArrayType arrayOf(TypeMirror component) {
    -        return new CodeTypeMirror.ArrayCodeTypeMirror(component);
    -    }
    -
         private CodeVariableElement compFinal(CodeVariableElement fld) {
             return compFinal(-1, fld);
         }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    index 418ab246647b..15a8c7c4d3ec 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    @@ -138,6 +138,8 @@ public String toString() {
             }
         }
     
    +    private static final TypeMirror[] EMPTY_ARGUMENTS = new TypeMirror[0];
    +
         public final OperationsModel parent;
         public final int id;
         public final OperationKind kind;
    @@ -154,7 +156,7 @@ public String toString() {
         public int numChildren;
     
         public InstructionModel instruction;
    -    public TypeMirror[] operationArguments;
    +    public TypeMirror[] operationArguments = EMPTY_ARGUMENTS;
     
         public CustomSignature signature;
     
    @@ -166,6 +168,10 @@ public OperationModel(OperationsModel parent, TypeElement templateType, int id,
             this.name = name;
         }
     
    +    public boolean hasChildren() {
    +        return isVariadic || numChildren > 0;
    +    }
    +
         public OperationModel setTransparent(boolean isTransparent) {
             this.isTransparent = isTransparent;
             return this;
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    index 6ad02ad9c36b..8cf0a803c97e 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    @@ -54,11 +54,14 @@
     import javax.lang.model.element.Element;
     import javax.lang.model.element.ExecutableElement;
     import javax.lang.model.element.TypeElement;
    +import javax.lang.model.element.VariableElement;
     import javax.lang.model.type.DeclaredType;
     import javax.lang.model.type.TypeMirror;
     
     import com.oracle.truffle.dsl.processor.ProcessorContext;
    -import com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror;
    +import com.oracle.truffle.dsl.processor.java.ElementUtils;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror;
    +import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.WildcardTypeMirror;
     import com.oracle.truffle.dsl.processor.model.MessageContainer;
     import com.oracle.truffle.dsl.processor.model.Template;
     import com.oracle.truffle.dsl.processor.model.TypeSystemData;
    @@ -85,12 +88,14 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot
         private final Map operationNames = new HashMap<>();
     
         public boolean enableYield;
    +    public boolean enableSerialization = true;
         public DeclaredType languageClass;
         public ExecutableElement fdConstructor;
         public ExecutableElement fdBuilderConstructor;
         public boolean generateUncached;
         public TypeSystemData typeSystem;
         public Set boxingEliminatedTypes;
    +    public List serializedFields;
     
         public boolean enableTracing;
         public String decisionsFilePath;
    @@ -105,8 +110,15 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot
         public InstructionModel branchFalseInstruction;
         public InstructionModel throwInstruction;
     
    -    public void addDefault() {
    +    public List getProvidedTags() {
    +        AnnotationMirror providedTags = ElementUtils.findAnnotationMirror(ElementUtils.castTypeElement(languageClass), types.ProvidedTags);
    +        if (providedTags == null) {
    +            return Collections.emptyList();
    +        }
    +        return ElementUtils.getAnnotationValueList(TypeMirror.class, providedTags, "value");
    +    }
     
    +    public void addDefault() {
             popInstruction = instruction(InstructionKind.POP, "pop");
             branchInstruction = instruction(InstructionKind.BRANCH, "branch");
             branchFalseInstruction = instruction(InstructionKind.BRANCH_FALSE, "branch.false");
    @@ -208,8 +220,12 @@ public void addDefault() {
             operation(OperationKind.INSTRUMENT_TAG, "Tag") //
                             .setNumChildren(1) //
                             .setTransparent(true) //
    -                        .setOperationArguments(new GeneratedTypeMirror("java.lang", "Class"));
    +                        .setOperationArguments(generic(context.getDeclaredType(Class.class), new WildcardTypeMirror(types.Tag, null)));
    +
    +    }
     
    +    private static TypeMirror generic(DeclaredType el, TypeMirror... args) {
    +        return new DeclaredCodeTypeMirror((TypeElement) el.asElement(), List.of(args));
         }
     
         public OperationModel operation(OperationKind kind, String name) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    index ad40e3664e42..5e9ce9e1aa1f 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    @@ -48,6 +48,7 @@
     import java.io.FileInputStream;
     import java.io.FileNotFoundException;
     import java.nio.file.Path;
    +import java.util.ArrayList;
     import java.util.EnumSet;
     import java.util.HashSet;
     import java.util.List;
    @@ -59,6 +60,7 @@
     import javax.lang.model.element.ExecutableElement;
     import javax.lang.model.element.Modifier;
     import javax.lang.model.element.TypeElement;
    +import javax.lang.model.element.VariableElement;
     import javax.lang.model.type.DeclaredType;
     import javax.lang.model.type.TypeKind;
     import javax.lang.model.type.TypeMirror;
    @@ -93,6 +95,7 @@ protected OperationsModel parse(Element element, List mirror)
             OperationsModel model = new OperationsModel(context, typeElement, generateOperationsMirror);
             model.languageClass = (DeclaredType) ElementUtils.getAnnotationValue(generateOperationsMirror, "languageClass").getValue();
             model.enableYield = (boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "enableYield", true).getValue();
    +        model.enableSerialization = (boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "enableSerialization", true).getValue();
     
             model.addDefault();
     
    @@ -256,9 +259,54 @@ protected OperationsModel parse(Element element, List mirror)
                 model.optimizationDecisions = parseDecisions(model, model.decisionsFilePath, decisionsOverrideFilesPath);
             }
     
    +        // error sync
    +        if (model.hasErrors()) {
    +            return model;
    +        }
    +
    +        if (model.enableSerialization) {
    +            List serializedFields = new ArrayList<>();
    +            TypeElement type = model.getTemplateType();
    +            while (type != null) {
    +                if (ElementUtils.typeEquals(types.RootNode, type.asType())) {
    +                    break;
    +                }
    +                for (VariableElement field : ElementFilter.fieldsIn(type.getEnclosedElements())) {
    +                    if (field.getModifiers().contains(Modifier.STATIC) || field.getModifiers().contains(Modifier.TRANSIENT) || field.getModifiers().contains(Modifier.FINAL)) {
    +                        continue;
    +                    }
    +
    +                    boolean visible = model.getTemplateType() == type && !field.getModifiers().contains(Modifier.PRIVATE);
    +                    boolean inTemplateType = model.getTemplateType() == type;
    +                    if (inTemplateType) {
    +                        visible = !field.getModifiers().contains(Modifier.PRIVATE);
    +                    } else {
    +                        visible = ElementUtils.isVisible(model.getTemplateType(), field);
    +                    }
    +
    +                    if (!visible) {
    +                        model.addError(inTemplateType ? field : null, errorPrefix() +
    +                                        "The field '%s' is not accessible to generated code. The field must be accessible for serialization. Add the transient modifier to the field or make it accessible to resolve this problem.",
    +                                        ElementUtils.getReadableReference(model.getTemplateType(), field));
    +                        continue;
    +                    }
    +
    +                    serializedFields.add(field);
    +                }
    +
    +                type = ElementUtils.castTypeElement(type.getSuperclass());
    +            }
    +
    +            model.serializedFields = serializedFields;
    +        }
    +
             return model;
         }
     
    +    private String errorPrefix() {
    +        return String.format("Failed to generate code for @%s: ", getSimpleName(types.GenerateOperations));
    +    }
    +
         private String resolveElementRelativePath(Element element, String relativePath) {
             File filePath = CompilerFactory.getCompiler(element).getEnclosingSourceFile(processingEnv, element);
             return Path.of(filePath.getPath()).getParent().resolve(relativePath).toAbsolutePath().toString();
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLStackTraceBuiltin.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLStackTraceBuiltin.java
    index dcd1b609ce2a..c5e965b1fbde 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLStackTraceBuiltin.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLStackTraceBuiltin.java
    @@ -69,6 +69,7 @@ public abstract class SLStackTraceBuiltin extends SLBuiltinNode {
         public static final TruffleString FRAME = SLStrings.constant("Frame: root ");
         public static final TruffleString SEPARATOR = SLStrings.constant(", ");
         public static final TruffleString EQUALS = SLStrings.constant("=");
    +    public static final TruffleString UNKNOWN = SLStrings.constant("Unknown");
     
         @Specialization
         public TruffleString trace() {
    @@ -104,7 +105,8 @@ public Integer visitFrame(FrameInstance frameInstance) {
                     int count = frameDescriptor.getNumberOfSlots();
                     for (int i = 0; i < count; i++) {
                         str.appendStringUncached(SEPARATOR);
    -                    str.appendStringUncached((TruffleString) frameDescriptor.getSlotName(i));
    +                    TruffleString slotName = (TruffleString) frameDescriptor.getSlotName(i);
    +                    str.appendStringUncached(slotName == null ? UNKNOWN : slotName);
                         str.appendStringUncached(EQUALS);
                         str.appendStringUncached(SLStrings.fromObject(frame.getValue(i)));
                     }
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java
    index 20fbffdd8f43..7901eb413cc3 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java
    @@ -70,9 +70,9 @@
     @NodeInfo(language = "SL", description = "The root of all SL execution trees")
     public abstract class SLRootNode extends RootNode {
     
    -    private boolean isCloningAllowed;
    +    protected boolean isCloningAllowed;
     
    -    @CompilationFinal(dimensions = 1) private SLWriteLocalVariableNode[] argumentNodesCache;
    +    @CompilationFinal(dimensions = 1) private transient SLWriteLocalVariableNode[] argumentNodesCache;
     
         public SLRootNode(SLLanguage language, FrameDescriptor frameDescriptor) {
             super(language, frameDescriptor);
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java
    index e25bf4de9bb6..1ee87f598fca 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java
    @@ -42,9 +42,7 @@
     
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.NodeInfo;
    -import com.oracle.truffle.api.nodes.UnexpectedResultException;
     import com.oracle.truffle.api.profiles.CountingConditionProfile;
    -import com.oracle.truffle.sl.SLException;
     import com.oracle.truffle.sl.nodes.SLExpressionNode;
     import com.oracle.truffle.sl.nodes.SLStatementNode;
     import com.oracle.truffle.sl.nodes.util.SLToBooleanNode;
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    index 4b04e66561f9..419b398f8693 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    @@ -40,6 +40,11 @@
      */
     package com.oracle.truffle.sl.operations;
     
    +import java.io.DataInput;
    +import java.io.DataOutput;
    +import java.io.IOException;
    +import java.util.List;
    +
     import com.oracle.truffle.api.Assumption;
     import com.oracle.truffle.api.RootCallTarget;
     import com.oracle.truffle.api.TruffleLanguage;
    @@ -63,6 +68,9 @@
     import com.oracle.truffle.api.operation.OperationRootNode;
     import com.oracle.truffle.api.operation.ShortCircuitOperation;
     import com.oracle.truffle.api.operation.Variadic;
    +import com.oracle.truffle.api.operation.serialization.OperationDeserializer;
    +import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext;
    +import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext;
     import com.oracle.truffle.api.source.SourceSection;
     import com.oracle.truffle.api.strings.TruffleString;
     import com.oracle.truffle.sl.SLLanguage;
    @@ -89,7 +97,7 @@
                     languageClass = SLLanguage.class, //
                     decisionsFile = "decisions.json", //
                     boxingEliminationTypes = {long.class, boolean.class}, //
    -                forceTracing = true)
    +                enableSerialization = true)
     @GenerateUncached
     @TypeSystemReference(SLTypes.class)
     @OperationProxy(SLAddNode.class)
    @@ -113,6 +121,8 @@ protected SLOperationRootNode(TruffleLanguage language, FrameDescriptor frame
             super((SLLanguage) language, frameDescriptor);
         }
     
    +    protected TruffleString tsName;
    +
         @Override
         public SLExpressionNode getBodyNode() {
             return null;
    @@ -132,7 +142,13 @@ public void setTSName(TruffleString tsName) {
             this.tsName = tsName;
         }
     
    -    private TruffleString tsName;
    +    public List decompose() {
    +        return List.of(getTSName());
    +    }
    +
    +    public void recompose(List objects) {
    +        setTSName((TruffleString) objects.get(0));
    +    }
     
         @Operation
         @TypeSystemReference(SLTypes.class)
    @@ -142,6 +158,7 @@ public static final class SLInvoke {
                             assumptions = "callTargetStable")
             @SuppressWarnings("unused")
             protected static Object doDirect(SLFunction function, @Variadic Object[] arguments,
    +                        @Bind("this") Node node,
                             @Cached("function.getCallTargetStable()") Assumption callTargetStable,
                             @Cached("function.getCallTarget()") RootCallTarget cachedTarget,
                             @Cached("create(cachedTarget)") DirectCallNode callNode) {
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java
    index 7c79ac085df2..2b6f250606a5 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationSerialization.java
    @@ -45,39 +45,50 @@
     import java.io.DataOutput;
     import java.io.DataOutputStream;
     import java.io.IOException;
    +import java.math.BigInteger;
     import java.nio.ByteBuffer;
    +import java.util.function.Supplier;
     
     import com.oracle.truffle.api.operation.OperationConfig;
     import com.oracle.truffle.api.operation.OperationNodes;
    +import com.oracle.truffle.api.operation.OperationParser;
    +import com.oracle.truffle.api.operation.serialization.SerializationUtils;
     import com.oracle.truffle.api.source.Source;
     import com.oracle.truffle.api.strings.TruffleString;
     import com.oracle.truffle.sl.SLLanguage;
     import com.oracle.truffle.sl.runtime.SLBigNumber;
     import com.oracle.truffle.sl.runtime.SLNull;
     
    -public class SLOperationSerialization {
    +public final class SLOperationSerialization {
     
         private static final byte CODE_SL_NULL = 0;
         private static final byte CODE_STRING = 1;
         private static final byte CODE_LONG = 2;
         private static final byte CODE_SOURCE = 3;
    -    private static final byte CODE_CLASS = 4;
         private static final byte CODE_BIG_INT = 5;
    +    private static final byte CODE_BOOLEAN_TRUE = 6;
    +    private static final byte CODE_BOOLEAN_FALSE = 7;
     
    -    public static byte[] serializeNodes(OperationNodes nodes) throws IOException {
    +    private SLOperationSerialization() {
    +        // no instances
    +    }
    +
    +    public static byte[] serializeNodes(OperationParser parser) throws IOException {
             ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
             DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream);
     
    -        nodes.serialize(OperationConfig.COMPLETE, outputStream, (context, buffer, object) -> {
    +        SLOperationRootNodeGen.serialize(OperationConfig.COMPLETE, outputStream, (context, buffer, object) -> {
                 if (object instanceof SLNull) {
                     buffer.writeByte(CODE_SL_NULL);
                 } else if (object instanceof TruffleString) {
                     TruffleString str = (TruffleString) object;
                     buffer.writeByte(CODE_STRING);
    -                writeByteArray(buffer, str.getInternalByteArrayUncached(SLLanguage.STRING_ENCODING).getArray());
    +                writeString(buffer, str);
                 } else if (object instanceof Long) {
                     buffer.writeByte(CODE_LONG);
                     buffer.writeLong((long) object);
    +            } else if (object instanceof Boolean) {
    +                buffer.writeByte(((boolean) object) ? CODE_BOOLEAN_TRUE : CODE_BOOLEAN_FALSE);
                 } else if (object instanceof SLBigNumber) {
                     SLBigNumber num = (SLBigNumber) object;
                     buffer.writeByte(CODE_BIG_INT);
    @@ -86,17 +97,18 @@ public static byte[] serializeNodes(OperationNodes nodes) t
                     Source s = (Source) object;
                     buffer.writeByte(CODE_SOURCE);
                     writeByteArray(buffer, s.getName().getBytes());
    -            } else if (object instanceof Class) {
    -                buffer.writeByte(CODE_CLASS);
    -                writeByteArray(buffer, ((Class) object).getName().getBytes());
                 } else {
                     throw new UnsupportedOperationException("unsupported constant: " + object.getClass().getSimpleName() + " " + object);
                 }
    -        });
    +        }, parser);
     
             return byteArrayOutputStream.toByteArray();
         }
     
    +    static void writeString(DataOutput buffer, TruffleString str) throws IOException {
    +        writeByteArray(buffer, str.getInternalByteArrayUncached(SLLanguage.STRING_ENCODING).getArray());
    +    }
    +
         private static byte[] readByteArray(DataInput buffer) throws IOException {
             int len = buffer.readInt();
             byte[] dest = new byte[len];
    @@ -110,36 +122,33 @@ private static void writeByteArray(DataOutput buffer, byte[] data) throws IOExce
         }
     
         public static OperationNodes deserializeNodes(SLLanguage language, byte[] inputData) throws IOException {
    -        ByteBuffer buf = ByteBuffer.wrap(inputData);
    -        return null;
    +        Supplier input = () -> SerializationUtils.createDataInput(ByteBuffer.wrap(inputData));
    +        return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, input, (context, buffer) -> {
    +            byte tag;
    +            switch (tag = buffer.readByte()) {
    +                case CODE_SL_NULL:
    +                    return SLNull.SINGLETON;
    +                case CODE_STRING:
    +                    return readString(buffer);
    +                case CODE_LONG:
    +                    return buffer.readLong();
    +                case CODE_BOOLEAN_TRUE:
    +                    return Boolean.TRUE;
    +                case CODE_BOOLEAN_FALSE:
    +                    return Boolean.FALSE;
    +                case CODE_BIG_INT:
    +                    return new SLBigNumber(new BigInteger(readByteArray(buffer)));
    +                case CODE_SOURCE: {
    +                    String name = new String(readByteArray(buffer));
    +                    return Source.newBuilder(SLLanguage.ID, "", name).build();
    +                }
    +                default:
    +                    throw new UnsupportedOperationException("unsupported tag: " + tag);
    +            }
    +        });
    +    }
     
    -// return SLOperationRootNodeGen.deserialize(language, OperationConfig.DEFAULT, buf, (context,
    -// buffer) -> {
    -// byte tag;
    -// switch (tag = buffer.readByte()) {
    -// case CODE_SL_NULL:
    -// return SLNull.SINGLETON;
    -// case CODE_STRING:
    -// return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING);
    -// case CODE_LONG:
    -// return buffer.readLong();
    -// case CODE_BIG_INT:
    -// return new SLBigNumber(new BigInteger(readByteArray(buffer)));
    -// case CODE_SOURCE: {
    -// String name = new String(readByteArray(buffer));
    -// return Source.newBuilder(SLLanguage.ID, "", name).build();
    -// }
    -// case CODE_CLASS: {
    -// String name = new String(readByteArray(buffer));
    -// try {
    -// return Class.forName(name);
    -// } catch (ClassNotFoundException ex) {
    -// throw new UnsupportedOperationException("could not load class: " + name);
    -// }
    -// }
    -// default:
    -// throw new UnsupportedOperationException("unsupported tag: " + tag);
    -// }
    -// });
    +    static TruffleString readString(DataInput buffer) throws IOException {
    +        return TruffleString.fromByteArrayUncached(readByteArray(buffer), SLLanguage.STRING_ENCODING);
         }
     }
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java
    index f6dec9fcbb98..1353ee0e240c 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SLOperationsVisitor.java
    @@ -58,6 +58,8 @@
     import com.oracle.truffle.api.operation.OperationConfig;
     import com.oracle.truffle.api.operation.OperationLabel;
     import com.oracle.truffle.api.operation.OperationLocal;
    +import com.oracle.truffle.api.operation.OperationNodes;
    +import com.oracle.truffle.api.operation.OperationParser;
     import com.oracle.truffle.api.source.Source;
     import com.oracle.truffle.api.strings.TruffleString;
     import com.oracle.truffle.sl.SLLanguage;
    @@ -95,21 +97,24 @@
     public final class SLOperationsVisitor extends SLBaseVisitor {
     
         private static final boolean DO_LOG_NODE_CREATION = false;
    -    private static final boolean FORCE_SERIALIZE = false;
    +    private static final boolean FORCE_SERIALIZE = true;
     
         public static void parseSL(SLLanguage language, Source source, Map functions) {
    -        var nodes = SLOperationRootNodeGen.create(OperationConfig.WITH_SOURCE, builder -> {
    -            SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, builder);
    +        OperationParser slParser = (b) -> {
    +            SLOperationsVisitor visitor = new SLOperationsVisitor(language, source, b);
                 parseSLImpl(source, visitor);
    -        });
    +        };
     
    +        OperationNodes nodes;
             if (FORCE_SERIALIZE) {
                 try {
    -                byte[] serializedData = SLOperationSerialization.serializeNodes(nodes);
    +                byte[] serializedData = SLOperationSerialization.serializeNodes(slParser);
                     nodes = SLOperationSerialization.deserializeNodes(language, serializedData);
                 } catch (IOException ex) {
                     throw new RuntimeException(ex);
                 }
    +        } else {
    +            nodes = SLOperationRootNodeGen.create(OperationConfig.WITH_SOURCE, slParser);
             }
     
             for (SLOperationRootNode node : nodes.getNodes()) {
    
    From e8695ff946c9723f794a0a664ff24e236e00bc2d Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 11:38:51 +0100
    Subject: [PATCH 299/312] Fix bitmask issue
    
    ---
     .../processor/operations/generator/OperationsNodeFactory.java | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index f20f95c109fc..0513e3fec40b 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -619,7 +619,7 @@ private CodeExecutableElement createDoPopObject() {
     
             CodeTreeBuilder b = ex.createBuilder();
     
    -        b.startIf().string("(boxing & 0xffff000) == 0xffff0000 || frame.isObject(slot)").end().startBlock(); // {
    +        b.startIf().string("(boxing & 0xffff0000) == 0xffff0000 || frame.isObject(slot)").end().startBlock(); // {
             b.startReturn().string("frame.getObject(slot)").end();
             b.end(); // }
     
    @@ -643,7 +643,7 @@ private CodeExecutableElement createDoPopPrimitive(TypeMirror resultType) {
     
             CodeTreeBuilder b = ex.createBuilder();
     
    -        b.startIf().string("(boxing & 0xffff000) == 0xffff0000").end().startBlock(); // {
    +        b.startIf().string("(boxing & 0xffff0000) == 0xffff0000").end().startBlock(); // {
             b.statement("Object result = frame.getObject(slot)");
     
             b.startIf().string("result").instanceOf(boxType(resultType)).end().startBlock(); // {
    
    From a3371443549238c98cd83011e858ed4481205b7a Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 12:14:14 +0100
    Subject: [PATCH 300/312] Fix bug in decision deserialization, add required
     fields
    
    ---
     .../oracle/truffle/api/operation/test/bml/decisions.json    | 6 ++++--
     .../operations/model/OptimizationDecisionsModel.java        | 2 +-
     .../dsl/processor/operations/parser/OperationsParser.java   | 2 +-
     .../oracle/truffle/sl/operations/SLOperationRootNode.java   | 6 ------
     4 files changed, 6 insertions(+), 10 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    index cb0565c9d27a..d6b4efaf77c0 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    @@ -2,11 +2,13 @@
     	{
     		"type": "Quicken",
     		"operation": "AddQuickened",
    -		"specializations": ["Ints"]
    +		"specializations": ["Ints"],
    +		"id": "foo"
     	},
     	{
     		"type": "Quicken",
     		"operation": "ModQuickened",
    -		"specializations": ["Ints"]
    +		"specializations": ["Ints"],
    +		"id": "bar"
     	}
     ]
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java
    index 8e2e64af937e..e7b88ab10d3c 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OptimizationDecisionsModel.java
    @@ -47,7 +47,7 @@ public class OptimizationDecisionsModel implements InfoDumpable {
     
         public static class QuickenDecision {
             public String id;
    -        public String instruction;
    +        public String operation;
             public String[] specializations;
         }
     
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    index 5e9ce9e1aa1f..24d31d773349 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    @@ -365,7 +365,7 @@ private static void parseDecision(OperationsModel model, OptimizationDecisionsMo
                 case "Quicken": {
                     QuickenDecision m = new QuickenDecision();
                     m.id = decision.getString("id");
    -                m.instruction = decision.getString("instruction");
    +                m.operation = decision.getString("operation");
                     m.specializations = jsonGetStringArray(decision, "specializations");
                     result.quickenDecisions.add(m);
                     break;
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    index 419b398f8693..a18665de9063 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    @@ -40,9 +40,6 @@
      */
     package com.oracle.truffle.sl.operations;
     
    -import java.io.DataInput;
    -import java.io.DataOutput;
    -import java.io.IOException;
     import java.util.List;
     
     import com.oracle.truffle.api.Assumption;
    @@ -68,9 +65,6 @@
     import com.oracle.truffle.api.operation.OperationRootNode;
     import com.oracle.truffle.api.operation.ShortCircuitOperation;
     import com.oracle.truffle.api.operation.Variadic;
    -import com.oracle.truffle.api.operation.serialization.OperationDeserializer;
    -import com.oracle.truffle.api.operation.serialization.OperationDeserializer.DeserializerContext;
    -import com.oracle.truffle.api.operation.serialization.OperationSerializer.SerializerContext;
     import com.oracle.truffle.api.source.SourceSection;
     import com.oracle.truffle.api.strings.TruffleString;
     import com.oracle.truffle.sl.SLLanguage;
    
    From 5e572c50dad6ace51b5752d40e2590c5ee2d9124 Mon Sep 17 00:00:00 2001
    From: Christian Humer 
    Date: Fri, 20 Jan 2023 12:16:05 +0100
    Subject: [PATCH 301/312] Fix missing check for builder usage.
    
    ---
     .../generator/OperationsNodeFactory.java         | 16 +++++++++++-----
     .../sl/operations/SLOperationRootNode.java       | 10 ----------
     2 files changed, 11 insertions(+), 15 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index add39b72a5f2..65789a74b0e2 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -1516,11 +1516,7 @@ private CodeExecutableElement createBeginHelper() {
     
                 CodeTreeBuilder b = ex.createBuilder();
     
    -            b.startIf().string("operationStack == null").end().startBlock(); // {
    -            b.startThrow().startNew(context.getType(IllegalStateException.class));
    -            b.string("\"Unexpected operation begin - no root operation present. Did you forget a beginRoot()?\"").end();
    -            b.end(2);
    -            b.end(); // }
    +            createCheckRoot(b);
     
                 b.startIf().string("operationSp == operationStack.length").end().startBlock(); // {
                 b.startAssign("operationStack").startStaticCall(context.getType(Arrays.class), "copyOf");
    @@ -2250,6 +2246,8 @@ private CodeExecutableElement createBeforeChild() {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "beforeChild");
                 CodeTreeBuilder b = ex.createBuilder();
     
    +            createCheckRoot(b);
    +
                 b.statement("Object data = operationData[operationSp - 1]");
                 b.statement("int childIndex = operationChildCount[operationSp - 1]");
     
    @@ -2284,6 +2282,14 @@ private CodeExecutableElement createBeforeChild() {
                 return ex;
             }
     
    +        private void createCheckRoot(CodeTreeBuilder b) {
    +            b.startIf().string("operationStack == null").end().startBlock(); // {
    +            b.startThrow().startNew(context.getType(IllegalStateException.class));
    +            b.string("\"Unexpected operation begin - no root operation present. Did you forget a beginRoot()?\"").end();
    +            b.end(2);
    +            b.end(); // }
    +        }
    +
             private CodeExecutableElement createAfterChild() {
                 CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "afterChild");
                 ex.addParameter(new CodeVariableElement(context.getType(boolean.class), "producedValue"));
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    index a18665de9063..6017b8e3d9a4 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/SLOperationRootNode.java
    @@ -40,8 +40,6 @@
      */
     package com.oracle.truffle.sl.operations;
     
    -import java.util.List;
    -
     import com.oracle.truffle.api.Assumption;
     import com.oracle.truffle.api.RootCallTarget;
     import com.oracle.truffle.api.TruffleLanguage;
    @@ -136,14 +134,6 @@ public void setTSName(TruffleString tsName) {
             this.tsName = tsName;
         }
     
    -    public List decompose() {
    -        return List.of(getTSName());
    -    }
    -
    -    public void recompose(List objects) {
    -        setTSName((TruffleString) objects.get(0));
    -    }
    -
         @Operation
         @TypeSystemReference(SLTypes.class)
         public static final class SLInvoke {
    
    From 66aceda817f6041bd9096fb33005e6c3b5bff333 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 12:36:02 +0100
    Subject: [PATCH 302/312] Decision parsing and boxing elimination
    
    ---
     .../oracle/truffle/api/operation/test/bml/decisions.json  | 6 ++----
     .../api/operation/test/example/BoxingOperationsTest.java  | 8 ++++----
     .../operations/generator/OperationsNodeFactory.java       | 7 +++++++
     .../dsl/processor/operations/parser/OperationsParser.java | 8 ++++----
     4 files changed, 17 insertions(+), 12 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    index d6b4efaf77c0..cb0565c9d27a 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/bml/decisions.json
    @@ -2,13 +2,11 @@
     	{
     		"type": "Quicken",
     		"operation": "AddQuickened",
    -		"specializations": ["Ints"],
    -		"id": "foo"
    +		"specializations": ["Ints"]
     	},
     	{
     		"type": "Quicken",
     		"operation": "ModQuickened",
    -		"specializations": ["Ints"],
    -		"id": "bar"
    +		"specializations": ["Ints"]
     	}
     ]
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java
    index f5d4d1422a72..0e4a0545ef5c 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/BoxingOperationsTest.java
    @@ -67,7 +67,7 @@ public class BoxingOperationsTest {
     
         private static final BoxingLanguage LANGUAGE = null;
     
    -    private static final int NUM_ITERATIONS = 10;
    +    private static final int NUM_ITERATIONS = 10_000;
     
         private static BoxingOperations parse(OperationParser parser) {
             OperationNodes nodes = BoxingOperationsGen.create(OperationConfig.DEFAULT, parser);
    @@ -336,7 +336,7 @@ public void testLBEMultipleLoads() {
     
             RootCallTarget callTarget = root.getCallTarget();
     
    -        testInvalidations(root, 3, () -> {
    +        testInvalidations(root, 5, () -> {
                 for (int i = 0; i < NUM_ITERATIONS; i++) {
                     Assert.assertEquals(1L, callTarget.call());
                 }
    @@ -401,10 +401,11 @@ static long castLong(int i) {
     @SuppressWarnings("unused")
     abstract class BoxingOperations extends RootNode implements OperationRootNode {
     
    -    private static final boolean LOG = true;
    +    private static final boolean LOG = false;
         int totalInvalidations = 0;
     
         protected void transferToInterpreterAndInvalidate() {
    +        CompilerDirectives.transferToInterpreterAndInvalidate();
             this.totalInvalidations++;
             if (LOG) {
                 System.err.println("[INVAL] --------------------");
    @@ -412,7 +413,6 @@ protected void transferToInterpreterAndInvalidate() {
                     System.err.println("   " + sf);
                 });
             }
    -        CompilerDirectives.transferToInterpreterAndInvalidate();
         }
     
         protected BoxingOperations(TruffleLanguage language, Builder frameDescriptor) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index add39b72a5f2..7d28471addfe 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -2342,6 +2342,13 @@ private CodeExecutableElement createAfterChild() {
                             buildEmitInstruction(b, model.branchFalseInstruction, "((IntRef[]) data)[0]");
                             b.end().startElseIf().string("childIndex == 1").end().startBlock();
                             buildEmitInstruction(b, model.branchInstruction, "((IntRef[]) data)[1]");
    +                        if (op.kind == OperationKind.CONDITIONAL) {
    +                            // we have to adjust the stack for the third child
    +                            b.statement("curStack -= 1");
    +                            if (model.hasBoxingElimination()) {
    +                                b.statement("stackValueBciSp -= 1");
    +                            }
    +                        }
                             b.statement("((IntRef[]) data)[0].value = bci");
                             b.end().startElseBlock();
                             b.statement("((IntRef[]) data)[1].value = bci");
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    index 24d31d773349..ae98a048e0d1 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    @@ -235,7 +235,6 @@ protected OperationsModel parse(Element element, List mirror)
     
             AnnotationValue decisionsFileValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false);
             AnnotationValue decisionsOverrideFilesValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsOverrideFiles", false);
    -        String decisionsFilePath = null;
             String[] decisionsOverrideFilesPath = new String[0];
     
             if (decisionsFileValue != null) {
    @@ -326,6 +325,7 @@ private static OptimizationDecisionsModel parseDecisions(OperationsModel model,
     
         private static void parseDecisionsFile(OperationsModel model, OptimizationDecisionsModel result, String filePath, boolean isMain) {
             try {
    +            // this parsing is very fragile, and error reporting is very useless
                 FileInputStream fi = new FileInputStream(filePath);
                 JSONArray o = new JSONArray(new JSONTokener(fi));
                 for (int i = 0; i < o.length(); i++) {
    @@ -351,20 +351,20 @@ private static void parseDecision(OperationsModel model, OptimizationDecisionsMo
             switch (decision.getString("type")) {
                 case "SuperInstruction": {
                     SuperInstructionDecision m = new SuperInstructionDecision();
    -                m.id = decision.getString("id");
    +                m.id = decision.optString("id");
                     m.instructions = jsonGetStringArray(decision, "instructions");
                     result.superInstructionDecisions.add(m);
                     break;
                 }
                 case "CommonInstruction": {
                     CommonInstructionDecision m = new CommonInstructionDecision();
    -                m.id = decision.getString("id");
    +                m.id = decision.optString("id");
                     result.commonInstructionDecisions.add(m);
                     break;
                 }
                 case "Quicken": {
                     QuickenDecision m = new QuickenDecision();
    -                m.id = decision.getString("id");
    +                m.id = decision.optString("id");
                     m.operation = decision.getString("operation");
                     m.specializations = jsonGetStringArray(decision, "specializations");
                     result.quickenDecisions.add(m);
    
    From 86e9c3377c6622937b187f8d6a0f785d59a0c1b5 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 12:50:16 +0100
    Subject: [PATCH 303/312] Fix LocalSetters in uncached
    
    ---
     .../generator/OperationsNodeFactory.java           | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
    
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index 7d28471addfe..b120098e1789 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -3315,6 +3315,12 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
                 }
     
                 if (isUncached) {
    +
    +                if (instr.needsUncachedData()) {
    +                    b.declaration(uncachedType, "opUncachedData");
    +                    b.startAssign("opUncachedData").cast(uncachedType).string("curObj").end();
    +                }
    +
                     if (signature.isVoid) {
                         b.startStatement();
                     } else {
    @@ -3338,6 +3344,14 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
                         b.string("readVariadic(frame, sp, variadicCount)");
                     }
     
    +                for (int i = 0; i < instr.signature.localSetterCount; i++) {
    +                    b.string("opUncachedData.op_localSetter" + i + "_");
    +                }
    +
    +                for (int i = 0; i < instr.signature.localSetterRangeCount; i++) {
    +                    b.string("opUncachedData.op_localSetterRange" + i + "_");
    +                }
    +
                     b.string(extraArguments);
                     b.end(2);
     
    
    From adeec983213601ded8cf1e2e2aa2971d59ca08c0 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 13:22:49 +0100
    Subject: [PATCH 304/312] Add test for LocalSetterRange and fix serialization
    
    ---
     .../test/example/TestOperations.java          | 23 ++++++++++++++++++
     .../example/TestOperationsParserTest.java     | 24 +++++++++++++++++++
     .../generator/OperationsNodeFactory.java      |  2 +-
     3 files changed, 48 insertions(+), 1 deletion(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    index 06e35a4e9bc6..bc0b0ca55ee9 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    @@ -57,11 +57,13 @@
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.instrumentation.ProvidedTags;
     import com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag;
    +import com.oracle.truffle.api.nodes.ExplodeLoop;
     import com.oracle.truffle.api.nodes.Node;
     import com.oracle.truffle.api.nodes.RootNode;
     import com.oracle.truffle.api.operation.AbstractOperationsTruffleException;
     import com.oracle.truffle.api.operation.GenerateOperations;
     import com.oracle.truffle.api.operation.LocalSetter;
    +import com.oracle.truffle.api.operation.LocalSetterRange;
     import com.oracle.truffle.api.operation.Operation;
     import com.oracle.truffle.api.operation.OperationProxy;
     import com.oracle.truffle.api.operation.OperationRootNode;
    @@ -164,6 +166,27 @@ public static Object doGeneric(VirtualFrame frame, Object value, LocalSetter set
             }
         }
     
    +    @Operation
    +    static final class TeeLocalRange {
    +        @Specialization
    +        @ExplodeLoop
    +        public static Object doLong(VirtualFrame frame, long[] value, LocalSetterRange setter) {
    +            for (int i = 0; i < value.length; i++) {
    +                setter.setLong(frame, i, value[i]);
    +            }
    +            return value;
    +        }
    +
    +        @Specialization
    +        @ExplodeLoop
    +        public static Object doGeneric(VirtualFrame frame, Object[] value, LocalSetterRange setter) {
    +            for (int i = 0; i < value.length; i++) {
    +                setter.setObject(frame, i, value[i]);
    +            }
    +            return value;
    +        }
    +    }
    +
         @Operation
         public static final class GlobalCachedReadOp {
             @Specialization(assumptions = "cachedAssumption")
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    index b0158e7ebd66..5161a953c389 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    @@ -895,6 +895,30 @@ public void testTeeLocal() {
             Assert.assertEquals(1L, root.call());
         }
     
    +    @Test
    +    public void testTeeLocalRange() {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            OperationLocal local1 = b.createLocal();
    +            OperationLocal local2 = b.createLocal();
    +
    +            b.beginTeeLocalRange(new OperationLocal[] {local1, local2});
    +            b.emitLoadConstant(new long[] {1L, 2L});
    +            b.endTeeLocalRange();
    +
    +            b.beginReturn();
    +            b.emitLoadLocal(local2);
    +            b.endReturn();
    +
    +
    +            b.endRoot();
    +        });
    +
    +        Assert.assertEquals(2L, root.call());
    +
    +    }
    +
         @Test
         public void testYield() {
             RootCallTarget root = parse(b -> {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index 8a19148517f3..4421f5a6f5e7 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -1743,7 +1743,7 @@ private void createSerializeBegin(OperationModel operation, CodeTreeBuilder b) {
     
                             serializationElements.writeShort(after, "(short) arg" + i + ".length");
                             after.startFor().string("int i = 0; i < arg" + i + ".length; i++").end().startBlock();
    -                        serializationElements.writeShort(after, "(short) ((OperationLocalImpl) arg" + i + "[i]).index");
    +                        serializationElements.writeShort(after, "(short) ((OperationLocalImpl) arg" + i + "[i]).index.value");
                             after.end();
     
                         } else if (ElementUtils.typeEquals(argType, types.OperationLabel)) {
    
    From 0d7e46e024af06d76af4afb30250b04093c2cbb1 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 14:10:28 +0100
    Subject: [PATCH 305/312] Implement quickening tracing
    
    ---
     .../example/TestOperationsParserTest.java     |   1 -
     .../operation/tracing/ExecutionTracer.java    |   1 -
     .../generator/OperationsNodeFactory.java      |  36 +-
     .../operations/model/InstructionModel.java    |   2 +
     .../operations/model/OperationsModel.java     |   9 +
     .../parser/CustomOperationParser.java         |   6 +-
     .../operations/parser/OperationsParser.java   |  76 ++--
     .../truffle/sl/operations/decisions.json      | 333 +++++++++---------
     8 files changed, 257 insertions(+), 207 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    index 5161a953c389..8953247e256e 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    @@ -916,7 +916,6 @@ public void testTeeLocalRange() {
             });
     
             Assert.assertEquals(2L, root.call());
    -
         }
     
         @Test
    diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java
    index aae3c4126aaa..124ce3304842 100644
    --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java
    +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/tracing/ExecutionTracer.java
    @@ -80,7 +80,6 @@ public static synchronized void initialize(Class opsClass, String decisionsFi
     
         public abstract void traceInstruction(int bci, int id, int... arguments);
     
    -    // TODO needs implementation. probably using introspection.
         public abstract void traceActiveSpecializations(int bci, int id, boolean[] activeSpecializations);
     
         public abstract void traceSpecialization(int bci, int id, int specializationId, Object... values);
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index 4421f5a6f5e7..548492b7928e 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -2678,9 +2678,6 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                         case STORE_LOCAL_MATERIALIZED:
                             b.statement("stackValueBciSp -= 2");
                             break;
    -                    case SUPERINSTRUCTION:
    -                        // todo
    -                        break;
                         case THROW:
                             break;
                         case YIELD:
    @@ -2731,9 +2728,6 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                     case STORE_LOCAL_MATERIALIZED:
                         b.statement("curStack -= 2");
                         break;
    -                case SUPERINSTRUCTION:
    -                    // todo
    -                    break;
                     default:
                         throw new UnsupportedOperationException();
                 }
    @@ -2754,6 +2748,8 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                 }
                 b.end();
                 b.end(2);
    +
    +            // todo: check for superinstructions
             }
     
             private CodeExecutableElement createDoEmitSourceInfo() {
    @@ -3248,6 +3244,9 @@ private CodeExecutableElement createContinueAt() {
                             break;
                         case YIELD:
                             break;
    +                    case SUPERINSTRUCTION:
    +                        // todo: implement superinstructions
    +                        break;
                         default:
                             throw new UnsupportedOperationException("not implemented");
                     }
    @@ -3305,9 +3304,30 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
                 TypeMirror uncachedType = new GeneratedTypeMirror("", instr.getInternalName() + "Gen_UncachedData");
                 CustomSignature signature = instr.signature;
     
    -            String extraArguments = "$this, objs, bci, sp";
    +            if (!isUncached && model.enableTracing) {
    +                b.startBlock();
    +
    +                b.startAssign("var specInfo").startStaticCall(types.Introspection, "getSpecializations");
    +                b.startGroup().cast(genType).string("curObj").end();
    +                b.end(2);
     
    -            // todo: trace active specializations
    +                b.startStatement().startCall("tracer.traceActiveSpecializations");
    +                b.string("bci");
    +                b.string(instr.id);
    +                b.startNewArray(arrayOf(context.getType(boolean.class)), null);
    +                for (int i = 0; i < instr.nodeData.getSpecializations().size(); i++) {
    +                    if (instr.nodeData.getSpecializations().get(i).isFallback()) {
    +                        break;
    +                    }
    +                    b.string("specInfo.get(" + i + ").isActive()");
    +                }
    +                b.end();
    +                b.end(2);
    +
    +                b.end();
    +            }
    +
    +            String extraArguments = "$this, objs, bci, sp";
     
                 if (signature.isVariadic) {
                     b.startAssign("int variadicCount");
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    index 9348dd18f160..7493ca1c8312 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    @@ -99,6 +99,8 @@ public InstructionField(TypeMirror type, String name, boolean needInUncached, bo
         public final List fields = new ArrayList<>();
         public boolean continueWhen;
     
    +    public List subInstructions;
    +
         public InstructionModel(int id, InstructionKind kind, String name) {
             this.id = id;
             this.kind = kind;
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    index 8cf0a803c97e..7915ca4bd7f7 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    @@ -277,6 +277,15 @@ public List getInstructions() {
             return Collections.unmodifiableList(instructions);
         }
     
    +    public InstructionModel getInstructionByName(String name) {
    +        for (InstructionModel instr : instructions) {
    +            if (instr.name.equals(name)) {
    +                return instr;
    +            }
    +        }
    +        return null;
    +    }
    +
         public void dump(Dumper dumper) {
             dumper.field("operations", operations);
             dumper.field("instructions", instructions);
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    index a1aa6f8801d7..75ab0682fe85 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    @@ -217,6 +217,10 @@ protected OperationModel parse(Element element, List ignored)
             nodeChildrenAnnotation.setElementValue("value", new CodeAnnotationValue(createNodeChildAnnotations(signature).stream().map(CodeAnnotationValue::new).collect(Collectors.toList())));
             nodeType.addAnnotationMirror(nodeChildrenAnnotation);
     
    +        if (parent.enableTracing) {
    +            nodeType.addAnnotationMirror(new CodeAnnotationMirror(types.Introspectable));
    +        }
    +
             data.signature = signature;
             data.numChildren = signature.valueCount;
             data.isVariadic = signature.isVariadic || isShortCircuit;
    @@ -227,7 +231,7 @@ protected OperationModel parse(Element element, List ignored)
                 data.operationArguments[i] = types.OperationLocal;
             }
             for (int i = 0; i < signature.localSetterRangeCount; i++) {
    -            // we might want to migrate this to a special type that validates order
    +            // todo: we might want to migrate this to a special type that validates order
                 // e.g. OperationLocalRange
                 data.operationArguments[signature.localSetterCount + i] = new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal);
             }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    index ae98a048e0d1..78837070f6ad 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/OperationsParser.java
    @@ -70,6 +70,8 @@
     import com.oracle.truffle.dsl.processor.java.ElementUtils;
     import com.oracle.truffle.dsl.processor.java.compiler.CompilerFactory;
     import com.oracle.truffle.dsl.processor.model.TypeSystemData;
    +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel;
    +import com.oracle.truffle.dsl.processor.operations.model.InstructionModel.InstructionKind;
     import com.oracle.truffle.dsl.processor.operations.model.OperationsModel;
     import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel;
     import com.oracle.truffle.dsl.processor.operations.model.OptimizationDecisionsModel.CommonInstructionDecision;
    @@ -195,9 +197,38 @@ protected OperationsModel parse(Element element, List mirror)
                                     mir);
                 }
             }
    -
             model.boxingEliminatedTypes = beTypes;
     
    +        // optimization decisions & tracing
    +
    +        AnnotationValue decisionsFileValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false);
    +        AnnotationValue decisionsOverrideFilesValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsOverrideFiles", false);
    +        String[] decisionsOverrideFilesPath = new String[0];
    +
    +        if (decisionsFileValue != null) {
    +            model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFileValue.getValue());
    +
    +            if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) {
    +                model.enableTracing = true;
    +            } else if ((boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true).getValue()) {
    +                model.addWarning("Operation DSL execution tracing is forced on. Use this only during development.");
    +                model.enableTracing = true;
    +            }
    +        }
    +
    +        if (decisionsOverrideFilesValue != null) {
    +            decisionsOverrideFilesPath = ((List) decisionsOverrideFilesValue.getValue()).stream().map(x -> (String) x.getValue()).toArray(String[]::new);
    +        }
    +
    +        model.enableOptimizations = (decisionsFileValue != null || decisionsOverrideFilesValue != null) && !model.enableTracing;
    +
    +        // error sync
    +        if (model.hasErrors()) {
    +            return model;
    +        }
    +
    +        // custom operations
    +
             for (TypeElement te : ElementFilter.typesIn(typeElement.getEnclosedElements())) {
                 AnnotationMirror op = ElementUtils.findAnnotationMirror(te, types.Operation);
                 if (op == null) {
    @@ -233,36 +264,35 @@ protected OperationsModel parse(Element element, List mirror)
                 new CustomOperationParser(model, mir, true).parse(te);
             }
     
    -        AnnotationValue decisionsFileValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsFile", false);
    -        AnnotationValue decisionsOverrideFilesValue = ElementUtils.getAnnotationValue(generateOperationsMirror, "decisionsOverrideFiles", false);
    -        String[] decisionsOverrideFilesPath = new String[0];
    -
    -        if (decisionsFileValue != null) {
    -            model.decisionsFilePath = resolveElementRelativePath(typeElement, (String) decisionsFileValue.getValue());
    -
    -            if (TruffleProcessorOptions.operationsEnableTracing(processingEnv)) {
    -                model.enableTracing = true;
    -            } else if ((boolean) ElementUtils.getAnnotationValue(generateOperationsMirror, "forceTracing", true).getValue()) {
    -                model.addWarning("Operation DSL execution tracing is forced on. Use this only during development.");
    -                model.enableTracing = true;
    -            }
    -        }
    -
    -        if (decisionsOverrideFilesValue != null) {
    -            decisionsOverrideFilesPath = ((List) decisionsOverrideFilesValue.getValue()).stream().map(x -> (String) x.getValue()).toArray(String[]::new);
    +        // error sync
    +        if (model.hasErrors()) {
    +            return model;
             }
     
    -        model.enableOptimizations = (decisionsFileValue != null || decisionsOverrideFilesValue != null) && !model.enableTracing;
    +        // apply optimization decisions
     
             if (model.enableOptimizations) {
                 model.optimizationDecisions = parseDecisions(model, model.decisionsFilePath, decisionsOverrideFilesPath);
    -        }
     
    -        // error sync
    -        if (model.hasErrors()) {
    -            return model;
    +            for (SuperInstructionDecision decision : model.optimizationDecisions.superInstructionDecisions) {
    +                String resultingInstructionName = "si." + String.join(".", decision.instructions);
    +                InstructionModel instr = model.instruction(InstructionKind.SUPERINSTRUCTION, resultingInstructionName);
    +                instr.subInstructions = new ArrayList<>();
    +
    +                for (String instrName : decision.instructions) {
    +                    InstructionModel subInstruction = model.getInstructionByName(instrName);
    +                    if (subInstruction == null) {
    +                        model.addError("Error reading optimization decisions: Super-instruction '%s' defines a sub-instruction '%s' which does not exist.", resultingInstructionName, instrName);
    +                    } else if (subInstruction.kind == InstructionKind.SUPERINSTRUCTION) {
    +                        model.addError("Error reading optimization decisions: Super-instruction '%s' cannot contain another super-instruction '%s'.", resultingInstructionName, instrName);
    +                    }
    +                    instr.subInstructions.add(subInstruction);
    +                }
    +            }
             }
     
    +        // serialization fields
    +
             if (model.enableSerialization) {
                 List serializedFields = new ArrayList<>();
                 TypeElement type = model.getTemplateType();
    diff --git a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json
    index 8cbfac3333aa..5832d6364ad9 100644
    --- a/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json
    +++ b/truffle/src/com.oracle.truffle.sl/src/com/oracle/truffle/sl/operations/decisions.json
    @@ -2,15 +2,32 @@
         "This file is autogenerated by the Operations DSL.",
         "Do not modify, as it will be overwritten when running with tracing support.",
         "Use the overrides file to alter the optimisation decisions.",
    +    {
    +        "specializations": ["FromBigNumber"],
    +        "_comment": "value: 1.0",
    +        "id": "quicken:c.SLUnbox:FromBigNumber",
    +        "type": "Quicken",
    +        "operation": "SLUnbox"
    +    },
         {
             "instructions": [
                 "load.local",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 1.0",
    +        "_comment": "value: 0.6740247790202488",
             "id": "si:load.local,c.SLUnbox",
             "type": "SuperInstruction"
         },
    +    {
    +        "specializations": [
    +            "FromLong",
    +            "FromBigNumber"
    +        ],
    +        "_comment": "value: 0.6024454429439406",
    +        "id": "quicken:c.SLUnbox:FromLong,FromBigNumber",
    +        "type": "Quicken",
    +        "operation": "SLUnbox"
    +    },
         {
             "instructions": [
                 "load.local",
    @@ -18,7 +35,7 @@
                 "load.local",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.7745428067984501",
    +        "_comment": "value: 0.5220609325557375",
             "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -31,7 +48,7 @@
                 "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.7517738155317384",
    +        "_comment": "value: 0.5067140715304745",
             "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -46,7 +63,7 @@
                 "load.local",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.7230805583830159",
    +        "_comment": "value: 0.48737410935712283",
             "id": "si:load.argument,store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -61,7 +78,7 @@
                 "c.SLUnbox",
                 "c.SLAdd"
             ],
    -        "_comment": "value: 0.7230670863663191",
    +        "_comment": "value: 0.48736502888598765",
             "id": "si:store.local,load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd",
             "type": "SuperInstruction"
         },
    @@ -76,7 +93,7 @@
                 "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.7230670863663191",
    +        "_comment": "value: 0.48736502888598765",
             "id": "si:load.argument,store.local,load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -87,7 +104,7 @@
                 "c.SLReadProperty",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.565936968069182",
    +        "_comment": "value: 0.38145545827119937",
             "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -99,7 +116,7 @@
                 "c.SLLessOrEqual",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.5389884440034557",
    +        "_comment": "value: 0.36329148917708737",
             "id": "si:c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -112,10 +129,17 @@
                 "c.SLReadProperty",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.47156549110846896",
    +        "_comment": "value: 0.3178467579691224",
             "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox",
             "type": "SuperInstruction"
         },
    +    {
    +        "specializations": ["FromLong"],
    +        "_comment": "value: 0.31598598205871864",
    +        "id": "quicken:c.SLUnbox:FromLong",
    +        "type": "Quicken",
    +        "operation": "SLUnbox"
    +    },
         {
             "instructions": [
                 "load.local",
    @@ -125,7 +149,7 @@
                 "c.SLLessOrEqual",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.4491570366695464",
    +        "_comment": "value: 0.3027429076475728",
             "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -137,7 +161,7 @@
                 "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.4321703205056925",
    +        "_comment": "value: 0.29129344248732264",
             "id": "si:c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -149,7 +173,7 @@
                 "c.SLUnbox",
                 "load.local"
             ],
    -        "_comment": "value: 0.37728831826463316",
    +        "_comment": "value: 0.25430162096499176",
             "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local",
             "type": "SuperInstruction"
         },
    @@ -164,7 +188,7 @@
                 "load.constant",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.34581319658879983",
    +        "_comment": "value: 0.23308661356945248",
             "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox",
             "type": "SuperInstruction"
         },
    @@ -179,7 +203,7 @@
                 "c.SLUnbox",
                 "c.SLAdd"
             ],
    -        "_comment": "value: 0.34581319658879983",
    +        "_comment": "value: 0.23308661356945248",
             "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd",
             "type": "SuperInstruction"
         },
    @@ -194,10 +218,17 @@
                 "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.34581319658879983",
    +        "_comment": "value: 0.23308661356945248",
             "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
    +    {
    +        "specializations": ["FromBoolean"],
    +        "_comment": "value: 0.22454909695435232",
    +        "id": "quicken:c.SLUnbox:FromBoolean",
    +        "type": "Quicken",
    +        "operation": "SLUnbox"
    +    },
         {
             "instructions": [
                 "load.local",
    @@ -209,98 +240,98 @@
                 "c.SLLessOrEqual",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.3144099256686825",
    +        "_comment": "value: 0.21192003535330095",
             "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,c.SLUnbox,c.SLLessOrEqual,c.SLUnbox",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    +            "load.local",
                 "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
                 "load.local",
                 "load.constant",
                 "c.SLReadProperty",
    -            "c.SLUnbox",
    -            "c.SLAdd"
    +            "c.SLUnbox"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    +            "pop",
                 "load.local",
                 "load.constant",
                 "load.local",
                 "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
    -            "load.local",
                 "load.constant"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    -            "pop",
    -            "load.local",
                 "load.constant",
                 "load.local",
                 "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
    -            "load.constant"
    +            "load.local",
    +            "load.constant",
    +            "c.SLReadProperty"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:pop,load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.constant",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    -            "c.SLReadProperty",
    -            "c.SLUnbox",
    +            "load.local",
    +            "load.constant",
                 "load.local",
                 "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
    -            "c.SLAdd",
    -            "c.SLUnbox"
    +            "load.local",
    +            "load.constant"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:load.local,load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    -            "load.local",
    -            "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
                 "load.local",
                 "load.constant",
                 "c.SLReadProperty",
    +            "c.SLUnbox",
    +            "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
         {
             "instructions": [
    -            "load.constant",
    -            "load.local",
                 "load.constant",
                 "c.SLReadProperty",
                 "c.SLUnbox",
                 "load.local",
                 "load.constant",
    -            "c.SLReadProperty"
    +            "c.SLReadProperty",
    +            "c.SLUnbox",
    +            "c.SLAdd"
             ],
    -        "_comment": "value: 0.31437849096305676",
    -        "id": "si:load.constant,load.local,load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty",
    +        "_comment": "value: 0.2118988475873188",
    +        "id": "si:load.constant,c.SLReadProperty,c.SLUnbox,load.local,load.constant,c.SLReadProperty,c.SLUnbox,c.SLAdd",
             "type": "SuperInstruction"
         },
         {
    @@ -310,10 +341,17 @@
                 "load.local",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.3099590279619191",
    +        "_comment": "value: 0.20892002065158577",
             "id": "si:load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox",
             "type": "SuperInstruction"
         },
    +    {
    +        "specializations": ["Add0"],
    +        "_comment": "value: 0.205657969497112",
    +        "id": "quicken:c.SLAdd:Add0",
    +        "type": "Quicken",
    +        "operation": "SLAdd"
    +    },
         {
             "instructions": [
                 "pop",
    @@ -324,76 +362,19 @@
                 "c.SLAdd",
                 "c.SLUnbox"
             ],
    -        "_comment": "value: 0.29544260920887183",
    +        "_comment": "value: 0.19913559680171394",
             "id": "si:pop,load.local,c.SLUnbox,load.constant,c.SLUnbox,c.SLAdd,c.SLUnbox",
             "type": "SuperInstruction"
         },
         {
    -        "instructions": [
    -            "pop",
    -            "load.constant",
    -            "c.SLFunctionLiteral",
    -            "load.local",
    -            "c.SLUnbox"
    -        ],
    -        "_comment": "value: 0.17966024856940013",
    -        "id": "si:pop,load.constant,c.SLFunctionLiteral,load.local,c.SLUnbox",
    -        "type": "SuperInstruction"
    +        "specializations": ["ReadSLObject0"],
    +        "_comment": "value: 0.13318932378740397",
    +        "id": "quicken:c.SLReadProperty:ReadSLObject0",
    +        "type": "Quicken",
    +        "operation": "SLReadProperty"
         },
         {
    -        "instructions": [
    -            "c.SLToBoolean",
    -            "branch.false"
    -        ],
    -        "_comment": "value: 0.1666730106322011",
    -        "id": "si:c.SLToBoolean,branch.false",
    -        "type": "SuperInstruction"
    -    },
    -    {
    -        "instructions": [
    -            "pop",
    -            "branch"
    -        ],
    -        "_comment": "value: 0.16642281603640438",
    -        "id": "si:pop,branch",
    -        "type": "SuperInstruction"
    -    },
    -    {
    -        "instructions": [
    -            "c.SLUnbox",
    -            "load.local",
    -            "c.SLUnbox",
    -            "c.SLLessThan",
    -            "c.SLUnbox"
    -        ],
    -        "_comment": "value: 0.10793181021136097",
    -        "id": "si:c.SLUnbox,load.local,c.SLUnbox,c.SLLessThan,c.SLUnbox",
    -        "type": "SuperInstruction"
    -    },
    -    {
    -        "instructions": [
    -            "c.SLWriteProperty",
    -            "c.SLUnbox"
    -        ],
    -        "_comment": "value: 0.09882772070584814",
    -        "id": "si:c.SLWriteProperty,c.SLUnbox",
    -        "type": "SuperInstruction"
    -    },
    -    {
    -        "instructions": [
    -            "load.local",
    -            "c.SLUnbox",
    -            "load.local",
    -            "c.SLUnbox",
    -            "c.SLLessThan",
    -            "c.SLUnbox"
    -        ],
    -        "_comment": "value: 0.08996313371938859",
    -        "id": "si:load.local,c.SLUnbox,load.local,c.SLUnbox,c.SLLessThan,c.SLUnbox",
    -        "type": "SuperInstruction"
    -    },
    -    {
    -        "_comment": "value: 3.596216E7",
    +        "_comment": "value: 3.5962197E7",
             "instruction": "c.SLUnbox",
             "id": "c:c.SLUnbox",
             "type": "CommonInstruction"
    @@ -405,31 +386,31 @@
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 3.5130023E7",
    +        "_comment": "value: 3.513006E7",
             "instruction": "store.local",
             "id": "c:store.local",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 3.5130007E7",
    +        "_comment": "value: 3.513006E7",
             "instruction": "load.local",
             "id": "c:load.local",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 3.4369647E7",
    +        "_comment": "value: 3.4369684E7",
             "instruction": "load.argument",
             "id": "c:load.argument",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 3.0165142E7",
    +        "_comment": "value: 3.0165179E7",
             "instruction": "load.constant",
             "id": "c:load.constant",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 2.9334879E7",
    +        "_comment": "value: 2.9334916E7",
             "instruction": "pop",
             "id": "c:pop",
             "type": "CommonInstruction"
    @@ -465,13 +446,13 @@
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 2.1352295E7",
    +        "_comment": "value: 2.1352332E7",
             "instruction": "c.SLInvoke",
             "id": "c:c.SLInvoke",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 2.1352147E7",
    +        "_comment": "value: 2.1352184E7",
             "instruction": "c.SLFunctionLiteral",
             "id": "c:c.SLFunctionLiteral",
             "type": "CommonInstruction"
    @@ -518,12 +499,6 @@
             "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.local.load.constant",
             "type": "CommonInstruction"
         },
    -    {
    -        "_comment": "value: 9241911.0",
    -        "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd",
    -        "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd",
    -        "type": "CommonInstruction"
    -    },
         {
             "_comment": "value: 9241911.0",
             "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox",
    @@ -549,17 +524,41 @@
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 7141365.0",
    +        "_comment": "value: 9241911.0",
    +        "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox",
    +        "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox",
    +        "type": "CommonInstruction"
    +    },
    +    {
    +        "_comment": "value: 8821533.0",
             "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox",
             "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessOrEqual.c.SLUnbox",
             "type": "CommonInstruction"
         },
    +    {
    +        "_comment": "value: 5040504.0",
    +        "instruction": "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd",
    +        "id": "c:si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd",
    +        "type": "CommonInstruction"
    +    },
         {
             "_comment": "value: 3786254.0",
             "instruction": "c.SLLessThan",
             "id": "c:c.SLLessThan",
             "type": "CommonInstruction"
         },
    +    {
    +        "_comment": "value: 799160.0",
    +        "instruction": "c.SLUnbox.q.FromLong",
    +        "id": "c:c.SLUnbox.q.FromLong",
    +        "type": "CommonInstruction"
    +    },
    +    {
    +        "_comment": "value: 799160.0",
    +        "instruction": "c.SLUnbox.q.FromBigNumber",
    +        "id": "c:c.SLUnbox.q.FromBigNumber",
    +        "type": "CommonInstruction"
    +    },
         {
             "_comment": "value: 799136.0",
             "instruction": "si.load.local.c.SLUnbox",
    @@ -586,8 +585,8 @@
         },
         {
             "_comment": "value: 567798.0",
    -        "instruction": "si.c.SLWriteProperty.c.SLUnbox",
    -        "id": "c:si.c.SLWriteProperty.c.SLUnbox",
    +        "instruction": "c.SLReadProperty.q.ReadSLObject0",
    +        "id": "c:c.SLReadProperty.q.ReadSLObject0",
             "type": "CommonInstruction"
         },
         {
    @@ -598,32 +597,14 @@
         },
         {
             "_comment": "value: 567798.0",
    -        "instruction": "si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox",
    -        "id": "c:si.load.local.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox",
    -        "type": "CommonInstruction"
    -    },
    -    {
    -        "_comment": "value: 547148.0",
    -        "instruction": "si.pop.branch",
    -        "id": "c:si.pop.branch",
    -        "type": "CommonInstruction"
    -    },
    -    {
    -        "_comment": "value: 547148.0",
    -        "instruction": "si.c.SLToBoolean.branch.false",
    -        "id": "c:si.c.SLToBoolean.branch.false",
    +        "instruction": "si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd",
    +        "id": "c:si.load.constant.load.local.load.constant.c.SLReadProperty.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 546483.0",
    -        "instruction": "si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox",
    -        "id": "c:si.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox",
    -        "type": "CommonInstruction"
    -    },
    -    {
    -        "_comment": "value: 546483.0",
    -        "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox",
    -        "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLLessThan.c.SLUnbox",
    +        "_comment": "value: 547136.0",
    +        "instruction": "c.SLUnbox.q.FromBoolean",
    +        "id": "c:c.SLUnbox.q.FromBoolean",
             "type": "CommonInstruction"
         },
         {
    @@ -640,20 +621,20 @@
         },
         {
             "_comment": "value: 340063.0",
    -        "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    -        "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
             "type": "CommonInstruction"
         },
         {
             "_comment": "value: 340063.0",
    -        "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    -        "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "instruction": "si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "id": "c:si.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
             "type": "CommonInstruction"
         },
         {
             "_comment": "value: 340063.0",
    -        "instruction": "si.pop.branch",
    -        "id": "c:si.pop.branch",
    +        "instruction": "c.SLUnbox.q.FromLong",
    +        "id": "c:c.SLUnbox.q.FromLong",
             "type": "CommonInstruction"
         },
         {
    @@ -662,6 +643,12 @@
             "id": "c:si.load.local.c.SLUnbox",
             "type": "CommonInstruction"
         },
    +    {
    +        "_comment": "value: 340063.0",
    +        "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "type": "CommonInstruction"
    +    },
         {
             "_comment": "value: 340063.0",
             "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox",
    @@ -670,20 +657,26 @@
         },
         {
             "_comment": "value: 340063.0",
    -        "instruction": "si.c.SLToBoolean.branch.false",
    -        "id": "c:si.c.SLToBoolean.branch.false",
    +        "instruction": "c.SLUnbox.q.FromBoolean",
    +        "id": "c:c.SLUnbox.q.FromBoolean",
             "type": "CommonInstruction"
         },
         {
             "_comment": "value: 340063.0",
    -        "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    -        "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "instruction": "c.SLAdd.q.Add0",
    +        "id": "c:c.SLAdd.q.Add0",
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 252012.0",
    -        "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    -        "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "_comment": "value: 340063.0",
    +        "instruction": "c.SLUnbox.q.FromBigNumber",
    +        "id": "c:c.SLUnbox.q.FromBigNumber",
    +        "type": "CommonInstruction"
    +    },
    +    {
    +        "_comment": "value: 252677.0",
    +        "instruction": "c.SLAdd.q.Add0",
    +        "id": "c:c.SLAdd.q.Add0",
             "type": "CommonInstruction"
         },
         {
    @@ -698,6 +691,12 @@
             "id": "c:si.load.argument.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox",
             "type": "CommonInstruction"
         },
    +    {
    +        "_comment": "value: 252000.0",
    +        "instruction": "si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "id": "c:si.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd.c.SLUnbox",
    +        "type": "CommonInstruction"
    +    },
         {
             "_comment": "value: 31367.0",
             "instruction": "c.SLLogicalNot",
    @@ -723,17 +722,11 @@
             "type": "CommonInstruction"
         },
         {
    -        "_comment": "value: 665.0",
    +        "_comment": "value: 653.0",
             "instruction": "si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
             "id": "c:si.pop.load.local.c.SLUnbox.load.constant.c.SLUnbox.c.SLAdd.c.SLUnbox",
             "type": "CommonInstruction"
         },
    -    {
    -        "_comment": "value: 219.0",
    -        "instruction": "si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox",
    -        "id": "c:si.pop.load.constant.c.SLFunctionLiteral.load.local.c.SLUnbox",
    -        "type": "CommonInstruction"
    -    },
         {
             "_comment": "value: 203.0",
             "instruction": "sc.SLOr",
    @@ -751,11 +744,5 @@
             "instruction": "c.SLDiv",
             "id": "c:c.SLDiv",
             "type": "CommonInstruction"
    -    },
    -    {
    -        "_comment": "value: 12.0",
    -        "instruction": "si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd",
    -        "id": "c:si.store.local.load.argument.store.local.load.local.c.SLUnbox.load.local.c.SLUnbox.c.SLAdd",
    -        "type": "CommonInstruction"
         }
     ]
    \ No newline at end of file
    
    From 8a94b130b14901f5bff154252a1885e02bdab147 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 17:33:28 +0100
    Subject: [PATCH 306/312] Implement yield
    
    ---
     .../test/example/TestOperations.java          |   2 +-
     .../example/TestOperationsParserTest.java     |  63 +++++
     .../api/operation/ContinuationResult.java     |  19 +-
     .../truffle/dsl/processor/TruffleTypes.java   |   4 +
     .../generator/OperationsNodeFactory.java      | 215 +++++++++++++++---
     .../operations/model/OperationsModel.java     |   4 +-
     6 files changed, 275 insertions(+), 32 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    index bc0b0ca55ee9..3bb4e28001d5 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    @@ -69,7 +69,7 @@
     import com.oracle.truffle.api.operation.OperationRootNode;
     import com.oracle.truffle.api.operation.Variadic;
     
    -@GenerateOperations(languageClass = TestLanguage.class, enableYield = true, enableSerialization = true)
    +@GenerateOperations(languageClass = TestLanguage.class, enableYield = true, enableSerialization = true, boxingEliminationTypes = {long.class})
     @GenerateAOT
     @OperationProxy(SomeOperationNode.class)
     public abstract class TestOperations extends RootNode implements OperationRootNode {
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    index 8953247e256e..af8efa618c7c 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    @@ -1036,6 +1036,63 @@ public void testYieldStack() {
             Assert.assertEquals(7L, r2.continueWith(4L));
         }
     
    +    @Test
    +    public void testYieldFromFinally() {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            // try {
    +            //   yield 1;
    +            //   if (false) {
    +            //     return 2;
    +            //   } else {
    +            //     return 3;
    +            //   }
    +            // } finally {
    +            //   yield 4;
    +            // }
    +
    +            b.beginFinallyTry();
    +
    +            b.beginYield();
    +            b.emitLoadConstant(4L);
    +            b.endYield();
    +
    +                b.beginBlock();
    +
    +                    b.beginYield();
    +                    b.emitLoadConstant(1L);
    +                    b.endYield();
    +
    +                    b.beginIfThenElse();
    +
    +                        b.emitLoadConstant(false);
    +
    +                        b.beginReturn();
    +                        b.emitLoadConstant(2L);
    +                        b.endReturn();
    +
    +                        b.beginReturn();
    +                        b.emitLoadConstant(3L);
    +                        b.endReturn();
    +
    +                    b.endIfThenElse();
    +
    +                b.endBlock();
    +            b.endFinallyTry();
    +
    +            b.endRoot();
    +        });
    +
    +        ContinuationResult r1 = (ContinuationResult) root.call();
    +        Assert.assertEquals(1L, r1.getResult());
    +
    +        ContinuationResult r2 = (ContinuationResult) r1.continueWith(3L);
    +        Assert.assertEquals(4L, r2.getResult());
    +
    +        Assert.assertEquals(3L, r2.continueWith(4L));
    +    }
    +
         @Test
         public void testNestedFunctions() {
             RootCallTarget root = parse(b -> {
    @@ -1068,6 +1125,12 @@ public void testNestedFunctions() {
     
         @Test
         public void testNonlocalRead() {
    +        // todo: this test fails when boxing elimination is enabled
    +        // locals accessed non-locally must have boxing elimination disabled
    +        // since non-local reads do not do boxing elimination
    +
    +        // this can be done automatically, or by
    +        // having `createLocal(boolean accessedFromClosure)` or similar
             RootCallTarget root = parse(b -> {
                 // x = 1
                 // return (lambda: x)()
    diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java
    index fda0953bd307..844ac26244e5 100644
    --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java
    +++ b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/ContinuationResult.java
    @@ -41,6 +41,7 @@
     package com.oracle.truffle.api.operation;
     
     import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.MaterializedFrame;
     import com.oracle.truffle.api.nodes.DirectCallNode;
    @@ -68,23 +69,33 @@ public Object getResult() {
             return result;
         }
     
    +    @Override
    +    public String toString() {
    +        return String.format("ContinuationResult [location=%s, result=%s]", location, result);
    +    }
    +
    +    @GenerateInline(true)
         public abstract static class ContinueNode extends Node {
     
    -        public abstract Object execute(ContinuationResult result, Object value);
    +        public final Object execute(ContinuationResult result, Object value) {
    +            return execute(null, result, value);
    +        }
    +
    +        public abstract Object execute(Node node, ContinuationResult result, Object value);
     
             public static final int LIMIT = 3;
     
             @SuppressWarnings("unused")
             @Specialization(guards = {"result.location.getRootNode() == rootNode"}, limit = "LIMIT")
             public static Object invokeDirect(ContinuationResult result, Object value,
    -                        @Cached("result.location.getRootNode()") RootNode rootNode,
    -                        @Cached("create(rootNode.getCallTarget())") DirectCallNode callNode) {
    +                        @Cached(value = "result.location.getRootNode()", inline = false) RootNode rootNode,
    +                        @Cached(value = "create(rootNode.getCallTarget())", inline = false) DirectCallNode callNode) {
                 return callNode.call(result.frame, value);
             }
     
             @Specialization(replaces = "invokeDirect")
             public static Object invokeIndirect(ContinuationResult result, Object value,
    -                        @Cached IndirectCallNode callNode) {
    +                        @Cached(inline = false) IndirectCallNode callNode) {
                 return callNode.call(result.location.getRootNode().getCallTarget(), result.frame, value);
             }
         }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    index f3b9eb639be6..02ee3240315a 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java
    @@ -301,6 +301,8 @@ public class TruffleTypes {
     
         // Operation DSL API
         public static final String BuilderSourceInfo_Name = "com.oracle.truffle.api.operation.BuilderSourceInfo";
    +    public static final String ContinuationLocation_Name = "com.oracle.truffle.api.operation.ContinuationLocation";
    +    public static final String ContinuationResult_Name = "com.oracle.truffle.api.operation.ContinuationResult";
         public static final String GenerateOperations_Name = "com.oracle.truffle.api.operation.GenerateOperations";
         public static final String InterpreterLocal_Name = "com.oracle.truffle.api.operation.InterpreterLocal";
         public static final String MetadataKey_Name = "com.oracle.truffle.api.operation.MetadataKey";
    @@ -333,6 +335,8 @@ public class TruffleTypes {
         public static final String ExecutionTracer_Name = "com.oracle.truffle.api.operation.tracing.ExecutionTracer";
     
         public final DeclaredType BuilderSourceInfo = c.getDeclaredTypeOptional(BuilderSourceInfo_Name);
    +    public final DeclaredType ContinuationLocation = c.getDeclaredTypeOptional(ContinuationLocation_Name);
    +    public final DeclaredType ContinuationResult = c.getDeclaredTypeOptional(ContinuationResult_Name);
         public final DeclaredType GenerateOperations = c.getDeclaredTypeOptional(GenerateOperations_Name);
         public final DeclaredType InterpreterLocal = c.getDeclaredTypeOptional(InterpreterLocal_Name);
         public final DeclaredType LocalSetter = c.getDeclaredTypeOptional(LocalSetter_Name);
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index 548492b7928e..fa6c08be97ae 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -71,6 +71,7 @@
     import javax.lang.model.element.ElementKind;
     import javax.lang.model.element.ExecutableElement;
     import javax.lang.model.element.Name;
    +import javax.lang.model.element.TypeElement;
     import javax.lang.model.element.VariableElement;
     import javax.lang.model.type.ArrayType;
     import javax.lang.model.type.DeclaredType;
    @@ -120,6 +121,8 @@ public class OperationsNodeFactory implements ElementHelpers {
         private CodeTypeElement storeLocalData = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "StoreLocalData");
         private CodeTypeElement operationLocalImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLocalImpl");
         private CodeTypeElement operationLabelImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "OperationLabelImpl");
    +    private CodeTypeElement continuationRoot;
    +    private CodeTypeElement continuationLocationImpl;
     
         private CodeTypeElement baseInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC, ABSTRACT), ElementKind.CLASS, null, "BaseInterpreter");
         private CodeTypeElement uncachedInterpreter;
    @@ -168,11 +171,17 @@ public CodeTypeElement create() {
             operationNodeGen.add(new OperationLocalImplFactory().create());
             operationNodeGen.add(new OperationLabelImplFactory().create());
             operationNodeGen.add(new BoxableInterfaceFactory().create());
    +
             if (model.hasBoxingElimination()) {
                 operationNodeGen.add(new LoadLocalDataFactory().create());
                 operationNodeGen.add(new StoreLocalDataFactory().create());
             }
     
    +        if (model.enableYield) {
    +            operationNodeGen.add(new ContinuationRootFactory().create());
    +            operationNodeGen.add(new ContinuationLocationImplFactory().create());
    +        }
    +
             operationNodeGen.add(createStaticConstructor());
             operationNodeGen.add(createFrameDescriptorConstructor());
             operationNodeGen.add(createFrameDescriptorBuliderConstructor());
    @@ -180,6 +189,7 @@ public CodeTypeElement create() {
             operationNodeGen.add(createCreate());
     
             operationNodeGen.add(createExecute());
    +        operationNodeGen.add(createContinueAt());
             operationNodeGen.add(createSneakyThrow());
     
             if (model.enableSerialization) {
    @@ -452,6 +462,28 @@ private CodeExecutableElement createFrameDescriptorBuliderConstructor() {
         private CodeExecutableElement createExecute() {
             CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute");
             ex.renameArguments("frame");
    +
    +        CodeTreeBuilder b = ex.createBuilder();
    +
    +        b.startReturn().startCall("continueAt");
    +        b.string("frame");
    +        if (model.enableYield) {
    +            b.string("frame");
    +        }
    +        b.string("numLocals << 16");
    +        b.end(2);
    +
    +        return ex;
    +    }
    +
    +    private CodeExecutableElement createContinueAt() {
    +        CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(Object.class), "continueAt");
    +        ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame"));
    +        if (model.enableYield) {
    +            ex.addParameter(new CodeVariableElement(types.VirtualFrame, "generatorFrame"));
    +        }
    +        ex.addParameter(new CodeVariableElement(context.getType(int.class), "startState"));
    +
             CodeTreeBuilder b = ex.createBuilder();
     
             // todo: only generate executeProlog/Epilog calls and the try/finally if they are overridden
    @@ -463,11 +495,15 @@ private CodeExecutableElement createExecute() {
     
             b.startTryBlock();
     
    -        b.statement("int state = numLocals << 16");
    +        b.statement("int state = startState");
     
             b.startWhile().string("true").end().startBlock();
             b.startAssign("state").startCall("interpreter.continueAt");
    -        b.string("this, frame, bc, objs, handlers, state, numLocals");
    +        b.string("this, frame");
    +        if (model.enableYield) {
    +            b.string("generatorFrame");
    +        }
    +        b.string("bc, objs, handlers, state, numLocals");
             if (model.hasBoxingElimination()) {
                 b.string("localBoxingState");
             }
    @@ -1067,6 +1103,10 @@ class BuilderElements {
                 if (model.enableTracing) {
                     builderState.add(0, new CodeVariableElement(Set.of(PRIVATE), context.getType(boolean[].class), "basicBlockBoundary"));
                 }
    +
    +            if (model.enableYield) {
    +                builderState.add(0, new CodeVariableElement(Set.of(PRIVATE), context.getType(int.class), "numYields"));
    +            }
             }
     
             class SavedStateFactory {
    @@ -1097,7 +1137,7 @@ private CodeTypeElement create() {
                                     new CodeVariableElement(generic(context.getDeclaredType(HashSet.class), intRef.asType()), "outerReferences"),
                                     new CodeVariableElement(finallyTryContext.asType(), "finallyTryContext")));
     
    -                finallyTryContext.add(GeneratorUtils.createConstructorUsingFields(Set.of(), finallyTryContext, null));
    +                finallyTryContext.add(createConstructorUsingFields(Set.of(), finallyTryContext, null));
     
                     // these could be merged with their counterparts above
                     finallyTryContext.addAll(List.of(
    @@ -1121,7 +1161,7 @@ private CodeTypeElement create() {
                     deserializerContextImpl.getImplements().add(types.OperationDeserializer_DeserializerContext);
     
                     deserializerContextImpl.add(new CodeVariableElement(Set.of(PRIVATE, FINAL), generic(context.getDeclaredType(ArrayList.class), operationNodeGen.asType()), "builtNodes"));
    -                deserializerContextImpl.add(GeneratorUtils.createConstructorUsingFields(Set.of(PRIVATE), deserializerContextImpl));
    +                deserializerContextImpl.add(createConstructorUsingFields(Set.of(PRIVATE), deserializerContextImpl));
     
                     deserializerContextImpl.add(createDeserializeOperationNode());
     
    @@ -1922,11 +1962,22 @@ private Element createEnd(OperationModel operation) {
                     if (model.enableTracing) {
                         b.startAssign("result.basicBlockBoundary").string("Arrays.copyOf(basicBlockBoundary, bci)").end();
                     }
    +
                     b.startFor().string("int i = 0; i < bci; i++").end().startBlock();
    +
                     b.startIf().string("objs[i] instanceof Node").end().startBlock();
                     b.statement("result.insert((Node) objs[i])");
                     b.end();
    +
    +                if (model.enableYield) {
    +                    b.startElseIf().string("objs[i] instanceof ContinuationLocationImpl").end().startBlock();
    +                    b.statement("ContinuationLocationImpl cl = (ContinuationLocationImpl) objs[i]");
    +                    b.statement("cl.rootNode = new ContinuationRoot(language, result.getFrameDescriptor(), result, cl.target)");
    +                    b.end();
    +                }
    +
                     b.end();
    +
                     b.startAssign("result.handlers").string("Arrays.copyOf(exHandlers, exHandlerCount)").end();
                     b.startAssign("result.numLocals").string("numLocals").end();
                     b.startAssign("result.buildIndex").string("buildIndex").end();
    @@ -2061,7 +2112,6 @@ private void buildEmitOperationInstruction(CodeTreeBuilder b, OperationModel ope
                         b.statement("IntRef argument = ((OperationLocalImpl) operationData[operationSp]).index");
                         break;
                     case RETURN:
    -                case YIELD:
                         b.statement("Object argument = EPSILON");
                         break;
                     case LOAD_ARGUMENT:
    @@ -2082,6 +2132,9 @@ private void buildEmitOperationInstruction(CodeTreeBuilder b, OperationModel ope
                     case CUSTOM_SHORT_CIRCUIT:
                         buildCustomInitializer(b, operation, operation.instruction);
                         break;
    +                case YIELD:
    +                    b.statement("ContinuationLocationImpl argument = new ContinuationLocationImpl(numYields++, (curStack << 16) | (bci + 1))");
    +                    break;
                     default:
                         b.statement("/* TODO: NOT IMPLEMENTED */");
                         break;
    @@ -2498,6 +2551,16 @@ private CodeExecutableElement createDoEmitFinallyHandler() {
                             b.statement("objs[offsetBci + idx] = new IntRef(((IntRef) handlerObjs[idx]).value + offsetBci)");
                             b.end();
     
    +                        b.statement("break");
    +                        b.end();
    +                        break;
    +                    case YIELD:
    +                        b.startCase().string("" + instr.id + " /* " + instr.name + " */").end().startBlock();
    +
    +                        b.statement("ContinuationLocationImpl cl = (ContinuationLocationImpl) handlerObjs[idx];");
    +                        b.statement("assert (cl.target & 0xffff) == (idx + 1)");
    +                        b.statement("objs[offsetBci + idx] = new ContinuationLocationImpl(numYields++, cl.target + ((curStack << 16) | offsetBci))");
    +
                             b.statement("break");
                             b.end();
                             break;
    @@ -2944,6 +3007,9 @@ private CodeExecutableElement createContinueAt() {
     
                 ex.addParameter(new CodeVariableElement(operationNodeGen.asType(), "$this"));
                 ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame"));
    +            if (model.enableYield) {
    +                ex.addParameter(new CodeVariableElement(types.VirtualFrame, "generatorFrame"));
    +            }
                 ex.addParameter(new CodeVariableElement(context.getType(short[].class), "bc"));
                 ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "objs"));
                 ex.addParameter(new CodeVariableElement(context.getType(int[].class), "handlers"));
    @@ -3109,11 +3175,12 @@ private CodeExecutableElement createContinueAt() {
                             b.statement("frame.setObject(sp, curObj)");
                             b.statement("sp += 1");
                             break;
    -                    case LOAD_LOCAL:
    +                    case LOAD_LOCAL: {
    +                        String localFrame = model.enableYield ? "generatorFrame" : "frame";
                             if (!model.hasBoxingElimination()) {
    -                            b.statement("frame.setObject(sp, frame.getObject(((IntRef) curObj).value))");
    +                            b.statement("frame.setObject(sp, " + localFrame + ".getObject(((IntRef) curObj).value))");
                             } else if (isUncached) {
    -                            b.statement("frame.setObject(sp, frame.getObject(((LoadLocalData) curObj).v_index))");
    +                            b.statement("frame.setObject(sp, " + localFrame + ".getObject(((LoadLocalData) curObj).v_index))");
                             } else {
                                 b.statement("LoadLocalData curData = (LoadLocalData) curObj");
                                 b.statement("int curIndex = curData.v_index");
    @@ -3123,18 +3190,22 @@ private CodeExecutableElement createContinueAt() {
                                 b.startCase().string("0").end().startCaseBlock();
                                 // uninitialized
                                 b.tree(createTransferToInterpreterAndInvalidate("$this"));
    -                            b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, true)");
    +                            b.statement("doLoadLocalInitialize(frame, " + localFrame + ", sp, curData, curIndex, localBoxingState, true)");
                                 b.statement("break");
                                 b.end();
     
                                 b.startCase().string("-1").end().startCaseBlock();
                                 // generic
                                 b.startIf().string("frame.isObject(curIndex)").end().startBlock();
    -                            b.statement("frame.copyObject(curIndex, sp)");
    +                            if (!model.enableYield) {
    +                                b.statement("frame.copyObject(curIndex, sp)");
    +                            } else {
    +                                b.statement("frame.setObject(sp, generatorFrame.getObject(curIndex))");
    +                            }
                                 b.end().startElseBlock();
                                 b.tree(createTransferToInterpreterAndInvalidate("$this"));
    -                            b.statement("Object value = frame.getValue(curIndex)");
    -                            b.statement("frame.setObject(curIndex, value)");
    +                            b.statement("Object value = " + localFrame + ".getValue(curIndex)");
    +                            b.statement(localFrame + ".setObject(curIndex, value)");
                                 b.statement("frame.setObject(sp, value)");
                                 b.end();
                                 b.statement("break");
    @@ -3148,7 +3219,7 @@ private CodeExecutableElement createContinueAt() {
                                     b.statement("frame.copyPrimitive(curIndex, sp)");
                                     b.end().startElseBlock();
                                     b.tree(createTransferToInterpreterAndInvalidate("$this"));
    -                                b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, false)");
    +                                b.statement("doLoadLocalInitialize(frame, " + localFrame + ", sp, curData, curIndex, localBoxingState, false)");
                                     b.end();
                                     b.statement("break");
                                     b.end();
    @@ -3158,7 +3229,7 @@ private CodeExecutableElement createContinueAt() {
                                     b.statement("frame.setObject(sp, frame.get" + frameName + "(curIndex))");
                                     b.end().startElseBlock();
                                     b.tree(createTransferToInterpreterAndInvalidate("$this"));
    -                                b.statement("doLoadLocalInitialize(frame, sp, curData, curIndex, localBoxingState, false)");
    +                                b.statement("doLoadLocalInitialize(frame, " + localFrame + ", sp, curData, curIndex, localBoxingState, false)");
                                     b.end();
                                     b.statement("break");
                                     b.end();
    @@ -3172,6 +3243,7 @@ private CodeExecutableElement createContinueAt() {
                             }
                             b.statement("sp += 1");
                             break;
    +                    }
                         case LOAD_LOCAL_MATERIALIZED:
                             b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 1)");
                             b.statement("frame.setObject(sp - 1, matFrame.getObject(((IntRef) curObj).value))");
    @@ -3192,11 +3264,12 @@ private CodeExecutableElement createContinueAt() {
     
                             b.statement("return ((sp - 1) << 16) | 0xffff");
                             break;
    -                    case STORE_LOCAL:
    +                    case STORE_LOCAL: {
    +                        String localFrame = model.enableYield ? "generatorFrame" : "frame";
                             if (!model.hasBoxingElimination()) {
    -                            b.statement("frame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))");
    +                            b.statement(localFrame + ".setObject(((IntRef) curObj).value, frame.getObject(sp - 1))");
                             } else if (isUncached) {
    -                            b.statement("frame.setObject(((StoreLocalData) curObj).s_index, frame.getObject(sp - 1))");
    +                            b.statement(localFrame + ".setObject(((StoreLocalData) curObj).s_index, frame.getObject(sp - 1))");
                             } else {
                                 b.statement("StoreLocalData curData = (StoreLocalData) curObj");
                                 b.statement("int curIndex = curData.s_index");
    @@ -3205,12 +3278,12 @@ private CodeExecutableElement createContinueAt() {
     
                                 b.startCase().string("0").end().startBlock();
                                 b.tree(createTransferToInterpreterAndInvalidate("$this"));
    -                            b.statement("doStoreLocalInitialize(frame, sp, localBoxingState, curIndex)");
    +                            b.statement("doStoreLocalInitialize(frame, " + localFrame + ", sp, localBoxingState, curIndex)");
                                 b.statement("break");
                                 b.end();
     
                                 b.startCase().string("-1").end().startBlock();
    -                            b.statement("frame.setObject(curIndex, doPopObject(frame, $this, sp - 1, curData.s_childIndex, objs))");
    +                            b.statement(localFrame + ".setObject(curIndex, doPopObject(frame, $this, sp - 1, curData.s_childIndex, objs))");
                                 b.statement("break");
                                 b.end();
     
    @@ -3221,10 +3294,10 @@ private CodeExecutableElement createContinueAt() {
                                     b.startCase().tree(boxingTypeToInt(mir)).end().startBlock();
     
                                     b.startTryBlock();
    -                                b.statement("frame.set" + frameName + "(curIndex, doPopPrimitive" + frameName + "(frame, $this, sp - 1, curData.s_childIndex, objs))");
    +                                b.statement(localFrame + ".set" + frameName + "(curIndex, doPopPrimitive" + frameName + "(frame, $this, sp - 1, curData.s_childIndex, objs))");
                                     b.end().startCatchBlock(types.UnexpectedResultException, "ex");
                                     b.statement("localBoxingState[curIndex] = -1");
    -                                b.statement("frame.setObject(curIndex, ex.getResult())");
    +                                b.statement(localFrame + ".setObject(curIndex, ex.getResult())");
                                     b.end();
                                     b.statement("break");
                                     b.end();
    @@ -3234,6 +3307,7 @@ private CodeExecutableElement createContinueAt() {
                             }
                             b.statement("sp -= 1");
                             break;
    +                    }
                         case STORE_LOCAL_MATERIALIZED:
                             b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 2)");
                             b.statement("matFrame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))");
    @@ -3243,6 +3317,9 @@ private CodeExecutableElement createContinueAt() {
                             b.statement("throw sneakyThrow((Throwable) frame.getObject(((IntRef) curObj).value))");
                             break;
                         case YIELD:
    +                        b.statement("frame.copyTo(numLocals, generatorFrame, numLocals, (sp - 1 - numLocals))");
    +                        b.statement("frame.setObject(sp - 1, ((ContinuationLocation) curObj).createResult(generatorFrame, frame.getObject(sp - 1)))");
    +                        b.statement("return (((sp - 1) << 16) | 0xffff)");
                             break;
                         case SUPERINSTRUCTION:
                             // todo: implement superinstructions
    @@ -3482,6 +3559,7 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
             private CodeExecutableElement createDoLoadLocalInitialize() {
                 CodeExecutableElement ex = new CodeExecutableElement(context.getType(void.class), "doLoadLocalInitialize");
                 ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame"));
    +            ex.addParameter(new CodeVariableElement(types.VirtualFrame, "localFrame"));
                 ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp"));
                 ex.addParameter(new CodeVariableElement(loadLocalData.asType(), "curData"));
                 ex.addParameter(new CodeVariableElement(context.getType(int.class), "curIndex"));
    @@ -3489,7 +3567,7 @@ private CodeExecutableElement createDoLoadLocalInitialize() {
                 ex.addParameter(new CodeVariableElement(context.getType(boolean.class), "prim"));
                 CodeTreeBuilder b = ex.createBuilder();
     
    -            b.statement("Object value = frame.getValue(curIndex)");
    +            b.statement("Object value = localFrame.getValue(curIndex)");
                 b.statement("frame.setObject(sp, value)");
     
                 b.statement("byte lbs = localBoxingState[curIndex]");
    @@ -3501,7 +3579,7 @@ private CodeExecutableElement createDoLoadLocalInitialize() {
     
                     b.startIf().string("(lbs == 0 || lbs == ").tree(boxingTypeToInt(mir)).string(") && value").instanceOf(boxType(mir)).end().startBlock();
                     b.startAssign("curData.v_kind").tree(boxingTypeToInt(mir)).string(" | 0x40 /* (boxed) */").end();
    -                b.statement("frame.set" + frameName + "(curIndex, (" + mir + ") value)");
    +                b.statement("localFrame.set" + frameName + "(curIndex, (" + mir + ") value)");
                     b.startAssign("localBoxingState[curIndex]").tree(boxingTypeToInt(mir)).end();
                     b.returnStatement();
                     b.end();
    @@ -3510,7 +3588,7 @@ private CodeExecutableElement createDoLoadLocalInitialize() {
                 b.end();
     
                 b.startAssign("curData.v_kind").string("-1").end();
    -            b.statement("frame.setObject(curIndex, value)");
    +            b.statement("localFrame.setObject(curIndex, value)");
                 b.statement("localBoxingState[curIndex] = -1");
     
                 return ex;
    @@ -3519,6 +3597,7 @@ private CodeExecutableElement createDoLoadLocalInitialize() {
             private CodeExecutableElement createDoStoreLocalInitialize() {
                 CodeExecutableElement ex = new CodeExecutableElement(context.getType(void.class), "doStoreLocalInitialize");
                 ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame"));
    +            ex.addParameter(new CodeVariableElement(types.VirtualFrame, "localFrame"));
                 ex.addParameter(new CodeVariableElement(context.getType(int.class), "sp"));
                 ex.addParameter(new CodeVariableElement(context.getType(byte[].class), "localBoxingState"));
                 ex.addParameter(new CodeVariableElement(context.getType(int.class), "curIndex"));
    @@ -3534,13 +3613,13 @@ private CodeExecutableElement createDoStoreLocalInitialize() {
     
                     b.startIf().string("value").instanceOf(boxType(mir)).end().startBlock();
                     b.startAssign("localBoxingState[curIndex]").tree(boxingTypeToInt(mir)).end();
    -                b.statement("frame.set" + frameName + "(curIndex, (" + mir + ") value)");
    +                b.statement("localFrame.set" + frameName + "(curIndex, (" + mir + ") value)");
                     b.returnStatement();
                     b.end();
                 }
     
                 b.startAssign("localBoxingState[curIndex]").string("-1").end();
    -            b.statement("frame.setObject(curIndex, value)");
    +            b.statement("localFrame.setObject(curIndex, value)");
     
                 return ex;
             }
    @@ -3623,6 +3702,90 @@ private CodeTypeElement create() {
             }
         }
     
    +    // todo: the next two classes could probably be merged into one
    +    class ContinuationRootFactory {
    +        private CodeTypeElement create() {
    +            continuationRoot = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "ContinuationRoot");
    +            continuationRoot.setEnclosingElement(operationNodeGen);
    +            continuationRoot.setSuperClass(types.RootNode);
    +
    +            continuationRoot.add(new CodeVariableElement(Set.of(FINAL), operationNodeGen.asType(), "root"));
    +            continuationRoot.add(new CodeVariableElement(Set.of(FINAL), context.getType(int.class), "target"));
    +            continuationRoot.add(GeneratorUtils.createConstructorUsingFields(
    +                            Set.of(), continuationRoot,
    +                            ElementFilter.constructorsIn(((TypeElement) types.RootNode.asElement()).getEnclosedElements()).stream().filter(x -> x.getParameters().size() == 2).findFirst().get()));
    +
    +            continuationRoot.add(createExecute());
    +
    +            return continuationRoot;
    +        }
    +
    +        private CodeExecutableElement createExecute() {
    +            CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.RootNode, "execute");
    +            ex.renameArguments("frame");
    +
    +            CodeTreeBuilder b = ex.createBuilder();
    +
    +            b.statement("Object[] args = frame.getArguments()");
    +            b.startIf().string("args.length != 2").end().startBlock();
    +            b.tree(GeneratorUtils.createShouldNotReachHere("Expected 2 arguments: (parentFrame, inputValue)"));
    +            b.end();
    +
    +            b.declaration(types.MaterializedFrame, "parentFrame", "(MaterializedFrame) args[0]");
    +            b.declaration(context.getType(Object.class), "inputValue", "args[1]");
    +
    +            b.startIf().string("parentFrame.getFrameDescriptor() != frame.getFrameDescriptor()").end().startBlock();
    +            b.tree(GeneratorUtils.createShouldNotReachHere("Invalid continuation parent frame passed"));
    +            b.end();
    +
    +            b.declaration("int", "sp", "((target >> 16) & 0xffff) + root.numLocals");
    +            b.statement("parentFrame.copyTo(root.numLocals, frame, root.numLocals, sp - 1 - root.numLocals)");
    +            b.statement("frame.setObject(sp - 1, inputValue)");
    +
    +            b.statement("return root.continueAt(frame, parentFrame, (sp << 16) | (target & 0xffff))");
    +
    +            return ex;
    +        }
    +    }
    +
    +    class ContinuationLocationImplFactory {
    +        private CodeTypeElement create() {
    +            continuationLocationImpl = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "ContinuationLocationImpl");
    +            continuationLocationImpl.setEnclosingElement(operationNodeGen);
    +            continuationLocationImpl.setSuperClass(types.ContinuationLocation);
    +
    +            continuationLocationImpl.add(new CodeVariableElement(Set.of(FINAL), context.getType(int.class), "entry"));
    +            continuationLocationImpl.add(new CodeVariableElement(Set.of(FINAL), context.getType(int.class), "target"));
    +
    +            continuationLocationImpl.add(createConstructorUsingFields(Set.of(), continuationLocationImpl, null));
    +
    +            continuationLocationImpl.add(new CodeVariableElement(types.RootNode, "rootNode"));
    +
    +            continuationLocationImpl.add(createGetRootNode());
    +            continuationLocationImpl.add(createToString());
    +
    +            return continuationLocationImpl;
    +        }
    +
    +        private CodeExecutableElement createGetRootNode() {
    +            CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.ContinuationLocation, "getRootNode");
    +            CodeTreeBuilder b = ex.createBuilder();
    +
    +            b.startReturn().string("rootNode").end();
    +
    +            return ex;
    +        }
    +
    +        private CodeExecutableElement createToString() {
    +            CodeExecutableElement ex = GeneratorUtils.overrideImplement(context.getDeclaredType(Object.class), "toString");
    +            CodeTreeBuilder b = ex.createBuilder();
    +
    +            b.statement("return String.format(\"ContinuationLocation [index=%d, sp=%d, bci=%04x]\", entry, (target >> 16) & 0xffff, target & 0xffff)");
    +
    +            return ex;
    +        }
    +    }
    +
         private static final Set EXECUTE_NAMES = Set.of("executeBoolean", "executeLong", "executeInt", "executeByte", "executeDouble", "executeFloat");
     
         private class CustomInstructionNodeFactory {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    index 7915ca4bd7f7..33d723bd477d 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    @@ -109,6 +109,7 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot
         public InstructionModel branchInstruction;
         public InstructionModel branchFalseInstruction;
         public InstructionModel throwInstruction;
    +    public InstructionModel yieldInstruction;
     
         public List getProvidedTags() {
             AnnotationMirror providedTags = ElementUtils.findAnnotationMirror(ElementUtils.castTypeElement(languageClass), types.ProvidedTags);
    @@ -204,10 +205,11 @@ public void addDefault() {
                             .setChildrenMustBeValues(true) //
                             .setInstruction(instruction(InstructionKind.RETURN, "return"));
             if (enableYield) {
    +            yieldInstruction = instruction(InstructionKind.YIELD, "yield");
                 operation(OperationKind.YIELD, "Yield") //
                                 .setNumChildren(1) //
                                 .setChildrenMustBeValues(true) //
    -                            .setInstruction(instruction(InstructionKind.YIELD, "yield"));
    +                            .setInstruction(yieldInstruction);
             }
             operation(OperationKind.SOURCE, "Source") //
                             .setNumChildren(1) //
    
    From cedb066ae41cf260534b901c81d1b57db8478fc7 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Fri, 20 Jan 2023 17:52:25 +0100
    Subject: [PATCH 307/312] Implement stack cleanup
    
    ---
     .../generator/OperationsNodeFactory.java          | 15 ++++++++++++++-
     1 file changed, 14 insertions(+), 1 deletion(-)
    
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index fa6c08be97ae..07d9f363bce1 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -3096,6 +3096,10 @@ private CodeExecutableElement createContinueAt() {
                         continue;
                     }
     
    +                b.startDoc();
    +                b.lines(instr.infodump());
    +                b.end();
    +
                     b.startCase().string(instr.id + " /* " + instr.name + " */").end().startBlock();
     
                     if (model.enableTracing) {
    @@ -3127,7 +3131,9 @@ private CodeExecutableElement createContinueAt() {
                             b.statement("continue loop");
                             break;
                         case BRANCH_FALSE:
    -                        b.startIf().string("frame.getObject(sp - 1) == Boolean.TRUE").end().startBlock();
    +                        b.statement("Object operand = frame.getObject(sp - 1)");
    +                        b.statement("assert operand instanceof Boolean");
    +                        b.startIf().string("operand == Boolean.TRUE").end().startBlock();
                             b.statement("sp -= 1");
                             b.statement("bci += 1");
                             b.statement("continue loop");
    @@ -3305,12 +3311,15 @@ private CodeExecutableElement createContinueAt() {
     
                                 b.end();
                             }
    +                        b.statement("frame.clear(sp - 1)");
                             b.statement("sp -= 1");
                             break;
                         }
                         case STORE_LOCAL_MATERIALIZED:
                             b.statement("VirtualFrame matFrame = (VirtualFrame) frame.getObject(sp - 2)");
                             b.statement("matFrame.setObject(((IntRef) curObj).value, frame.getObject(sp - 1))");
    +                        b.statement("frame.clear(sp - 1)");
    +                        b.statement("frame.clear(sp - 2)");
                             b.statement("sp -= 2");
                             break;
                         case THROW:
    @@ -3551,6 +3560,10 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
                     }
                 }
     
    +            for (int i = 0; i < instr.signature.valueCount - (instr.signature.isVoid ? 0 : 1); i++) {
    +                b.statement("frame.clear(resultSp + " + i + ")");
    +            }
    +
                 if (doPush) {
                     b.statement("sp = resultSp");
                 }
    
    From 417cdf330d1bd6b1f8f1031cb5f40e26704ccc8e Mon Sep 17 00:00:00 2001
    From: Christian Humer 
    Date: Fri, 20 Jan 2023 16:07:51 +0100
    Subject: [PATCH 308/312] Remove metadata key.
    
    ---
     .../truffle/api/operation/MetadataKey.java    | 76 -------------------
     1 file changed, 76 deletions(-)
     delete mode 100644 truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java b/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java
    deleted file mode 100644
    index d19e1e28af20..000000000000
    --- a/truffle/src/com.oracle.truffle.api.operation/src/com/oracle/truffle/api/operation/MetadataKey.java
    +++ /dev/null
    @@ -1,76 +0,0 @@
    -/*
    - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
    - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    - *
    - * The Universal Permissive License (UPL), Version 1.0
    - *
    - * Subject to the condition set forth below, permission is hereby granted to any
    - * person obtaining a copy of this software, associated documentation and/or
    - * data (collectively the "Software"), free of charge and under any and all
    - * copyright rights in the Software, and any and all patent rights owned or
    - * freely licensable by each licensor hereunder covering either (i) the
    - * unmodified Software as contributed to or provided by such licensor, or (ii)
    - * the Larger Works (as defined below), to deal in both
    - *
    - * (a) the Software, and
    - *
    - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
    - * one is included with the Software each a "Larger Work" to which the Software
    - * is contributed by such licensors),
    - *
    - * without restriction, including without limitation the rights to copy, create
    - * derivative works of, display, perform, and distribute the Software and make,
    - * use, sell, offer for sale, import, export, have made, and have sold the
    - * Software and the Larger Work(s), and to sublicense the foregoing rights on
    - * either these or other terms.
    - *
    - * This license is subject to the following condition:
    - *
    - * The above copyright notice and either this complete permission notice or at a
    - * minimum a reference to the UPL must be included in all copies or substantial
    - * portions of the Software.
    - *
    - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    - * SOFTWARE.
    - */
    -package com.oracle.truffle.api.operation;
    -
    -import java.util.Objects;
    -import java.util.function.Function;
    -
    -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
    -
    -public class MetadataKey {
    -    private final T defaultValue;
    -    @CompilationFinal private Function getter;
    -
    -    public MetadataKey(T defaultValue) {
    -        this.defaultValue = Objects.requireNonNull(defaultValue);
    -    }
    -
    -    void setGetter(Function getter) {
    -        this.getter = getter;
    -    }
    -
    -    public T getDefaultValue() {
    -        return defaultValue;
    -    }
    -
    -    public T getValue(OperationRootNode node) {
    -        if (getter == null) {
    -            throw new ClassCastException();
    -        }
    -
    -        T value = getter.apply(node);
    -        if (value == null) {
    -            return defaultValue;
    -        } else {
    -            return value;
    -        }
    -    }
    -}
    
    From d24510113829831a224934d02e517af3e2ef3097 Mon Sep 17 00:00:00 2001
    From: Christian Humer 
    Date: Fri, 20 Jan 2023 16:08:16 +0100
    Subject: [PATCH 309/312] Add object size estimate class.
    
    ---
     .../operation/test/ObjectSizeEstimate.java    | 281 ++++++++++++++++++
     1 file changed, 281 insertions(+)
     create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ObjectSizeEstimate.java
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ObjectSizeEstimate.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ObjectSizeEstimate.java
    new file mode 100644
    index 000000000000..4370aa485df9
    --- /dev/null
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/ObjectSizeEstimate.java
    @@ -0,0 +1,281 @@
    +/*
    + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
    + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    + *
    + * The Universal Permissive License (UPL), Version 1.0
    + *
    + * Subject to the condition set forth below, permission is hereby granted to any
    + * person obtaining a copy of this software, associated documentation and/or
    + * data (collectively the "Software"), free of charge and under any and all
    + * copyright rights in the Software, and any and all patent rights owned or
    + * freely licensable by each licensor hereunder covering either (i) the
    + * unmodified Software as contributed to or provided by such licensor, or (ii)
    + * the Larger Works (as defined below), to deal in both
    + *
    + * (a) the Software, and
    + *
    + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
    + * one is included with the Software each a "Larger Work" to which the Software
    + * is contributed by such licensors),
    + *
    + * without restriction, including without limitation the rights to copy, create
    + * derivative works of, display, perform, and distribute the Software and make,
    + * use, sell, offer for sale, import, export, have made, and have sold the
    + * Software and the Larger Work(s), and to sublicense the foregoing rights on
    + * either these or other terms.
    + *
    + * This license is subject to the following condition:
    + *
    + * The above copyright notice and either this complete permission notice or at a
    + * minimum a reference to the UPL must be included in all copies or substantial
    + * portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    + * SOFTWARE.
    + */
    +package com.oracle.truffle.api.operation.test;
    +
    +import java.lang.reflect.Field;
    +import java.lang.reflect.Modifier;
    +import java.util.ArrayList;
    +
    +import org.graalvm.collections.EconomicMap;
    +import org.graalvm.collections.Equivalence;
    +
    +/**
    + * Calculates approximate estimates of the size of an object graph.
    + *
    + * The result contains number of object headers {@link #getHeaderCount()}, number of pointers
    + * {@link #getPointerCount()} and size of the primitive data {@link #getPrimitiveByteSize()}.
    + *
    + * The methods {@link #getTotalBytes()} and {@link #getCompressedTotalBytes()} estimate the total
    + * number of bytes occupied. The real number of bytes occupied may vary due to different alignment
    + * or different header sizes on different virtual machines.
    + *
    + * This utility uses reflection and relies on {@link Modules} to open up classes. As such, the
    + * caller must ensure this class has access to {@link Modules} (e.g.,
    + * {@code --add-exports=java.base/jdk.internal.module=jdk.internal.vm.compiler}).
    + */
    +public final class ObjectSizeEstimate {
    +
    +    private static final int UNCOMPRESSED_POINTER_SIZE = 8;
    +    private static final int UNCOMPRESSED_HEADER_SIZE = 16;
    +    private static final int COMPRESSED_POINTER_SIZE = 4;
    +    private static final int COMPRESSED_HEADER_SIZE = 12;
    +
    +    /**
    +     * Collect the size occupied by the object graph reachable from the given root object.
    +     *
    +     * @param root the starting point of the object graph traversal
    +     */
    +    public static ObjectSizeEstimate forObject(Object root) {
    +        return forObject(root, Integer.MAX_VALUE);
    +    }
    +
    +    /**
    +     * Collect the size occupied by the object graph reachable from the given root object.
    +     *
    +     * @param root the starting point of the object graph traversal
    +     * @param maxDepth the maximum depth of the traversal
    +     */
    +    public static ObjectSizeEstimate forObject(Object root, int maxDepth) {
    +        return forObjectHelper(root, maxDepth);
    +    }
    +
    +    private int headerCount;
    +    private int pointerCount;
    +    private int primitiveByteSize;
    +
    +    private ObjectSizeEstimate() {
    +    }
    +
    +    public ObjectSizeEstimate add(ObjectSizeEstimate other) {
    +        ObjectSizeEstimate result = new ObjectSizeEstimate();
    +        result.headerCount = headerCount + other.headerCount;
    +        result.primitiveByteSize = primitiveByteSize + other.primitiveByteSize;
    +        result.pointerCount = pointerCount + other.pointerCount;
    +        return result;
    +    }
    +
    +    public ObjectSizeEstimate subtract(ObjectSizeEstimate other) {
    +        ObjectSizeEstimate result = new ObjectSizeEstimate();
    +        result.headerCount = headerCount - other.headerCount;
    +        result.primitiveByteSize = primitiveByteSize - other.primitiveByteSize;
    +        result.pointerCount = pointerCount - other.pointerCount;
    +        return result;
    +    }
    +
    +    public int getHeaderCount() {
    +        return headerCount;
    +    }
    +
    +    public int getPointerCount() {
    +        return pointerCount;
    +    }
    +
    +    public int getPrimitiveByteSize() {
    +        return primitiveByteSize;
    +    }
    +
    +    @Override
    +    public String toString() {
    +        return String.format("(#headers=%s, #pointers=%s, #primitiveBytes=%s, totalCompressed=%s, totalNonCompressed=%s)", headerCount, pointerCount, primitiveByteSize,
    +                        getCompressedTotalBytes(), getTotalBytes());
    +    }
    +
    +    public int getCompressedTotalBytes() {
    +        return headerCount * COMPRESSED_HEADER_SIZE + pointerCount * COMPRESSED_POINTER_SIZE + primitiveByteSize;
    +    }
    +
    +    public int getTotalBytes() {
    +        return headerCount * UNCOMPRESSED_HEADER_SIZE + pointerCount * UNCOMPRESSED_POINTER_SIZE + primitiveByteSize;
    +    }
    +
    +    private void recordHeader() {
    +        headerCount++;
    +    }
    +
    +    private void recordPointer() {
    +        pointerCount++;
    +    }
    +
    +    private void recordPrimitiveBytes(int size) {
    +        primitiveByteSize += size;
    +    }
    +
    +    private static ObjectSizeEstimate forObjectHelper(Object object, int maxDepth) {
    +        EconomicMap identityHashMap = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE);
    +        EconomicMap, Field[]> fieldsMap = EconomicMap.create();
    +        ObjectSizeEstimate size = new ObjectSizeEstimate();
    +
    +        ArrayList stack = new ArrayList<>();
    +        ArrayList depthStack = new ArrayList<>();
    +        stack.add(object);
    +        depthStack.add(0);
    +        identityHashMap.put(object, object);
    +
    +        while (!stack.isEmpty()) {
    +            Object o = stack.remove(stack.size() - 1);
    +            int depth = depthStack.remove(depthStack.size() - 1);
    +            size.recordHeader();
    +            Class c = o.getClass();
    +            if (c.isArray()) {
    +                size.recordPrimitiveBytes(Integer.BYTES);
    +                if (o instanceof byte[]) {
    +                    size.recordPrimitiveBytes(Byte.BYTES * ((byte[]) o).length);
    +                } else if (o instanceof boolean[]) {
    +                    size.recordPrimitiveBytes(Byte.BYTES * ((boolean[]) o).length);
    +                } else if (o instanceof char[]) {
    +                    size.recordPrimitiveBytes(Character.BYTES * ((char[]) o).length);
    +                } else if (o instanceof short[]) {
    +                    size.recordPrimitiveBytes(Short.BYTES * ((short[]) o).length);
    +                } else if (o instanceof int[]) {
    +                    size.recordPrimitiveBytes(Integer.BYTES * ((int[]) o).length);
    +                } else if (o instanceof long[]) {
    +                    size.recordPrimitiveBytes(Long.BYTES * ((long[]) o).length);
    +                } else if (o instanceof float[]) {
    +                    size.recordPrimitiveBytes(Float.BYTES * ((float[]) o).length);
    +                } else if (o instanceof double[]) {
    +                    size.recordPrimitiveBytes(Byte.BYTES * ((double[]) o).length);
    +                } else {
    +                    for (Object element : (Object[]) o) {
    +                        size.recordPointer();
    +                        if (element != null) {
    +                            if (depth < maxDepth && !identityHashMap.containsKey(element)) {
    +                                identityHashMap.put(element, null);
    +                                stack.add(element);
    +                                depthStack.add(depth + 1);
    +                            }
    +                        }
    +                    }
    +                }
    +            } else {
    +                while (c != null) {
    +
    +                    Field[] fields = fieldsMap.get(c);
    +                    if (fields == null) {
    +                        fields = c.getDeclaredFields();
    +                        fieldsMap.put(c, fields);
    +                    }
    +                    for (Field f : fields) {
    +                        if (!Modifier.isStatic(f.getModifiers())) {
    +                            Class type = f.getType();
    +                            if (type == Byte.TYPE) {
    +                                size.recordPrimitiveBytes(Byte.BYTES);
    +                            } else if (type == Boolean.TYPE) {
    +                                size.recordPrimitiveBytes(Byte.BYTES);
    +                            } else if (type == Character.TYPE) {
    +                                size.recordPrimitiveBytes(Character.BYTES);
    +                            } else if (type == Short.TYPE) {
    +                                size.recordPrimitiveBytes(Short.BYTES);
    +                            } else if (type == Integer.TYPE) {
    +                                size.recordPrimitiveBytes(Integer.BYTES);
    +                            } else if (type == Long.TYPE) {
    +                                size.recordPrimitiveBytes(Long.BYTES);
    +                            } else if (type == Float.TYPE) {
    +                                size.recordPrimitiveBytes(Float.BYTES);
    +                            } else if (type == Double.TYPE) {
    +                                size.recordPrimitiveBytes(Double.BYTES);
    +                            } else {
    +                                size.recordPointer();
    +                                if (maxDepth > 1 && type != Class.class) {
    +                                    try {
    +                                        if (!f.canAccess(o)) {
    +                                            f.setAccessible(true);
    +                                        }
    +                                        Object inner = f.get(o);
    +                                        if (inner != null) {
    +                                            if (depth < maxDepth && !identityHashMap.containsKey(inner)) {
    +                                                identityHashMap.put(inner, null);
    +                                                stack.add(inner);
    +                                                depthStack.add(depth + 1);
    +                                            }
    +                                        }
    +                                    } catch (IllegalArgumentException | IllegalAccessException e) {
    +                                        throw new UnsupportedOperationException("Must have access privileges to traverse object graph");
    +                                    } catch (RuntimeException e) {
    +                                        if ("java.lang.reflect.InaccessibleObjectException".equals(e.getClass().getName())) {
    +                                            // This is a newly introduced exception in JDK9 and thus
    +                                            // cannot be declared in the catch clause.
    +                                            throw new UnsupportedOperationException("Target class is not exported to the current module.", e);
    +                                        } else {
    +                                            throw e;
    +                                        }
    +                                    }
    +                                }
    +                            }
    +                        }
    +                    }
    +                    c = c.getSuperclass();
    +                }
    +            }
    +        }
    +        return size;
    +    }
    +
    +    public static ObjectSizeEstimate zero() {
    +        return new ObjectSizeEstimate();
    +    }
    +
    +    @Override
    +    public int hashCode() {
    +        final int prime = 31;
    +        return headerCount + prime * (pointerCount + prime * primitiveByteSize);
    +    }
    +
    +    @Override
    +    public boolean equals(Object obj) {
    +        if (this == obj) {
    +            return true;
    +        } else if (obj instanceof ObjectSizeEstimate) {
    +            ObjectSizeEstimate other = (ObjectSizeEstimate) obj;
    +            return headerCount == other.headerCount && pointerCount == other.pointerCount && primitiveByteSize == other.primitiveByteSize;
    +        }
    +        return false;
    +    }
    +}
    
    From 4efe4010f3a349d98f9b799b6b21fdd10d83aea1 Mon Sep 17 00:00:00 2001
    From: Christian Humer 
    Date: Sat, 21 Jan 2023 01:07:05 +0100
    Subject: [PATCH 310/312] Implement new variadic layout.
    
    ---
     .../api/operation/test/VariadicTest.java      | 176 +++++++++++++++++
     .../OperationNodeGeneratorPlugs.java          |  19 +-
     .../generator/OperationsNodeFactory.java      | 187 ++++++++++++++----
     .../operations/model/InstructionModel.java    |   4 +
     .../operations/model/OperationModel.java      |   1 +
     .../operations/model/OperationsModel.java     |  11 ++
     .../parser/CustomOperationParser.java         |  23 +--
     7 files changed, 359 insertions(+), 62 deletions(-)
     create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/VariadicTest.java
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/VariadicTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/VariadicTest.java
    new file mode 100644
    index 000000000000..1e8a3dde46ab
    --- /dev/null
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/VariadicTest.java
    @@ -0,0 +1,176 @@
    +/*
    + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
    + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    + *
    + * The Universal Permissive License (UPL), Version 1.0
    + *
    + * Subject to the condition set forth below, permission is hereby granted to any
    + * person obtaining a copy of this software, associated documentation and/or
    + * data (collectively the "Software"), free of charge and under any and all
    + * copyright rights in the Software, and any and all patent rights owned or
    + * freely licensable by each licensor hereunder covering either (i) the
    + * unmodified Software as contributed to or provided by such licensor, or (ii)
    + * the Larger Works (as defined below), to deal in both
    + *
    + * (a) the Software, and
    + *
    + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
    + * one is included with the Software each a "Larger Work" to which the Software
    + * is contributed by such licensors),
    + *
    + * without restriction, including without limitation the rights to copy, create
    + * derivative works of, display, perform, and distribute the Software and make,
    + * use, sell, offer for sale, import, export, have made, and have sold the
    + * Software and the Larger Work(s), and to sublicense the foregoing rights on
    + * either these or other terms.
    + *
    + * This license is subject to the following condition:
    + *
    + * The above copyright notice and either this complete permission notice or at a
    + * minimum a reference to the UPL must be included in all copies or substantial
    + * portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    + * SOFTWARE.
    + */
    +package com.oracle.truffle.api.operation.test;
    +
    +import static org.junit.Assert.assertArrayEquals;
    +
    +import java.util.Arrays;
    +
    +import org.junit.Test;
    +
    +import com.oracle.truffle.api.TruffleLanguage;
    +import com.oracle.truffle.api.TruffleLanguage.Env;
    +import com.oracle.truffle.api.dsl.GenerateAOT;
    +import com.oracle.truffle.api.dsl.GenerateUncached;
    +import com.oracle.truffle.api.dsl.Specialization;
    +import com.oracle.truffle.api.frame.FrameDescriptor;
    +import com.oracle.truffle.api.frame.VirtualFrame;
    +import com.oracle.truffle.api.instrumentation.ProvidedTags;
    +import com.oracle.truffle.api.instrumentation.StandardTags.ExpressionTag;
    +import com.oracle.truffle.api.nodes.RootNode;
    +import com.oracle.truffle.api.operation.GenerateOperations;
    +import com.oracle.truffle.api.operation.Operation;
    +import com.oracle.truffle.api.operation.OperationConfig;
    +import com.oracle.truffle.api.operation.OperationParser;
    +import com.oracle.truffle.api.operation.OperationRootNode;
    +import com.oracle.truffle.api.operation.Variadic;
    +
    +public class VariadicTest {
    +
    +    private static boolean TRACE = false;
    +
    +    private static final ObjectSizeEstimate ROOT_OVERHEAD = ObjectSizeEstimate.forObject(new RootNode(null) {
    +        @Override
    +        public Object execute(VirtualFrame frame) {
    +            return null;
    +        }
    +    });
    +
    +    @Test
    +    public void testVariadic0Arguments() {
    +        for (int i = 0; i < 32; i++) {
    +            final int variadicCount = i;
    +
    +            Object[] args = new Object[variadicCount];
    +            for (int j = 0; j < variadicCount; j++) {
    +                args[j] = j;
    +            }
    +
    +            var root = parse((b) -> {
    +                b.beginRoot(null);
    +                b.beginReturn();
    +                b.beginVariadic0Operation();
    +                for (int j = 0; j < variadicCount; j++) {
    +                    b.emitLoadArgument(j);
    +                }
    +                b.endVariadic0Operation();
    +                b.endReturn();
    +                b.endRoot();
    +            });
    +
    +            Object[] result = (Object[]) root.getCallTarget().call(args);
    +            assertArrayEquals(args, result);
    +        }
    +    }
    +
    +    @Test
    +    public void testVariadic1Arguments() {
    +        for (int i = 1; i < 32; i++) {
    +            final int variadicCount = i;
    +
    +            Object[] args = new Object[variadicCount];
    +            for (int j = 0; j < variadicCount; j++) {
    +                args[j] = (long) j;
    +            }
    +
    +            var root = parse((b) -> {
    +                b.beginRoot(null);
    +                b.beginReturn();
    +                b.beginVariadic1Operation();
    +                for (int j = 0; j < variadicCount; j++) {
    +                    b.emitLoadArgument(j);
    +                }
    +                b.endVariadic1Operation();
    +                b.endReturn();
    +                b.endRoot();
    +            });
    +
    +            Object[] result = (Object[]) root.getCallTarget().call(args);
    +            assertArrayEquals(Arrays.copyOfRange(args, 1, args.length), result);
    +        }
    +    }
    +
    +    VariadicOperationsNode parse(OperationParser builder) {
    +        VariadicOperationsNode root = VariadicOperationsNodeGen.create(OperationConfig.COMPLETE, builder).getNodes().get(0);
    +        if (TRACE) {
    +            System.out.println(root.dump());
    +            System.out.println(ROOT_OVERHEAD);
    +            System.out.println(ObjectSizeEstimate.forObject(root).subtract(ROOT_OVERHEAD));
    +        }
    +        return root;
    +    }
    +
    +    @ProvidedTags(ExpressionTag.class)
    +    class TestLanguage extends TruffleLanguage {
    +        @Override
    +        protected Env createContext(Env env) {
    +            return env;
    +        }
    +    }
    +
    +    @GenerateOperations(boxingEliminationTypes = {long.class}, languageClass = TestLanguage.class, enableYield = true, enableSerialization = true)
    +    @GenerateAOT
    +    @GenerateUncached
    +    public abstract static class VariadicOperationsNode extends RootNode implements OperationRootNode {
    +
    +        protected VariadicOperationsNode(TruffleLanguage language, FrameDescriptor frameDescriptor) {
    +            super(language, frameDescriptor);
    +        }
    +
    +        @Operation
    +        static final class Variadic0Operation {
    +            @Specialization
    +            public static Object[] variadic(@Variadic Object[] args) {
    +                return args;
    +            }
    +        }
    +
    +        @Operation
    +        static final class Variadic1Operation {
    +            @Specialization
    +            public static Object[] variadic(long arg0, @Variadic Object[] args) {
    +                return args;
    +            }
    +        }
    +
    +    }
    +
    +}
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    index 21c6cc0ca4cf..45c5853cb4f6 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationNodeGeneratorPlugs.java
    @@ -105,10 +105,6 @@ private boolean buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx,
     
                 String slotString = "$sp - " + (instr.signature.valueCount - index);
     
    -            if (instr.signature.isVariadic) {
    -                slotString += " - this.op_variadicCount_";
    -            }
    -
                 boolean canThrow;
     
                 if (instr.signature.valueBoxingElimination[index]) {
    @@ -129,6 +125,10 @@ private boolean buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx,
     
                     return canThrow;
                 } else {
    +                TypeMirror targetType = instr.signature.valueTypes[index];
    +                if (!ElementUtils.isObject(targetType)) {
    +                    b.cast(targetType);
    +                }
                     b.startCall(frame, "getObject");
                     b.string(slotString);
                     b.end();
    @@ -137,17 +137,6 @@ private boolean buildChildExecution(CodeTreeBuilder b, CodeTree frame, int idx,
             }
     
             index -= instr.signature.valueCount;
    -        if (instr.signature.isVariadic) {
    -            if (index == 0) {
    -                b.startCall("readVariadic");
    -                b.tree(frame);
    -                b.string("$sp");
    -                b.string("this.op_variadicCount_");
    -                b.end();
    -                return false;
    -            }
    -            index -= 1;
    -        }
     
             if (index < instr.signature.localSetterCount) {
                 b.string("this.op_localSetter" + index + "_");
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index 07d9f363bce1..bebd2320342b 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -130,6 +130,8 @@ public class OperationsNodeFactory implements ElementHelpers {
         private CodeTypeElement instrumentableInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC), ElementKind.CLASS, null, "InstrumentableInterpreter");
         private CodeTypeElement boxableInterface = new CodeTypeElement(Set.of(PRIVATE), ElementKind.INTERFACE, null, "BoxableInterface");
     
    +    private CodeVariableElement emptyObjectArray;
    +
         private static final Name Uncached_Name = CodeNames.of("Uncached");
     
         private BuilderElements builderElements;
    @@ -140,7 +142,8 @@ public OperationsNodeFactory(OperationsModel model) {
     
         public CodeTypeElement create() {
             operationNodeGen = GeneratorUtils.createClass(model.templateType, null, Set.of(PUBLIC, FINAL), model.templateType.getSimpleName() + "Gen", model.templateType.asType());
    -        GeneratorUtils.addSuppressWarnings(context, operationNodeGen, "all");
    +
    +        emptyObjectArray = addField(operationNodeGen, Set.of(PRIVATE, STATIC, FINAL), Object[].class, "EMPTY_ARRRAY", "new Object[0]");
     
             if (model.generateUncached) {
                 uncachedInterpreter = new CodeTypeElement(Set.of(PRIVATE, STATIC, FINAL), ElementKind.CLASS, null, "UncachedInterpreter");
    @@ -242,6 +245,7 @@ public CodeTypeElement create() {
             operationNodeGen.add(new CodeVariableElement(Set.of(PRIVATE, STATIC, FINAL), context.getType(Object.class), "EPSILON = new Object()"));
     
             operationNodeGen.add(createReadVariadic());
    +        operationNodeGen.add(createMergeVariadic());
             if (model.hasBoxingElimination()) {
                 operationNodeGen.add(createDoPopObject());
                 for (TypeMirror type : model.boxingEliminatedTypes) {
    @@ -695,9 +699,6 @@ private CodeExecutableElement createGetIntrospectionData() {
                         buildIntrospectionArgument(b, "BRANCH_OFFSET", "((IntRef) data).value");
                         break;
                     case CUSTOM:
    -                    if (instr.signature.isVariadic) {
    -                        buildIntrospectionArgument(b, "VARIADIC", "((" + instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : "") + ") data).op_variadicCount_");
    -                    }
                         break;
                     case LOAD_CONSTANT:
                         buildIntrospectionArgument(b, "CONSTANT", "data");
    @@ -775,9 +776,10 @@ private CodeExecutableElement createReadVariadic() {
             CodeTreeBuilder b = ex.createBuilder();
     
             b.statement("Object[] result = new Object[variadicCount]");
    -
             b.startFor().string("int i = 0; i < variadicCount; i++").end().startBlock();
    -        b.statement("result[i] = frame.getObject(sp - variadicCount + i)");
    +        b.statement("int index = sp - variadicCount + i");
    +        b.statement("result[i] = frame.getObject(index)");
    +        b.statement("frame.clear(index)");
             b.end();
     
             b.statement("return result");
    @@ -785,6 +787,61 @@ private CodeExecutableElement createReadVariadic() {
             return ex;
         }
     
    +    private CodeExecutableElement createMergeVariadic() {
    +        CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object[].class), "mergeVariadic");
    +
    +// ex.addParameter(new CodeVariableElement(type(Object[].class), "array0"));
    +// ex.addParameter(new CodeVariableElement(type(Object[].class), "array1"));
    +//
    +// CodeTreeBuilder b = ex.createBuilder();
    +// b.startAssert().string("array0.length >= ").string(model.popVariadicInstruction.length -
    +// 1).end();
    +// b.startAssert().string("array1.length > 0").end();
    +//
    +// b.statement("Object[] newArray = new Object[array0.length + array1.length]");
    +// b.statement("System.arraycopy(array0, 0, newArray, 0, array0.length)");
    +// b.statement("System.arraycopy(array1, 0, newArray, array0.length, array1.length)");
    +//
    +// b.startReturn().string("newArray").end();
    +//
    +        ex.addParameter(new CodeVariableElement(type(Object[].class), "array"));
    +
    +        CodeTreeBuilder b = ex.createBuilder();
    +
    +        b.statement("Object[] current = array");
    +        b.statement("int length = 0");
    +        b.startDoBlock();
    +        b.statement("int currentLength = current.length - 1");
    +        b.statement("length += currentLength");
    +        b.statement("current = (Object[]) current[currentLength]");
    +        b.end().startDoWhile().string("current != null").end();
    +
    +        b.statement("Object[] newArray = new Object[length]");
    +        b.statement("current = array");
    +        b.statement("int index = 0");
    +
    +        b.startDoBlock();
    +        b.statement("int currentLength = current.length - 1");
    +        b.statement("System.arraycopy(current, 0, newArray, index, currentLength)");
    +        b.statement("index += currentLength");
    +        b.statement("current = (Object[]) current[currentLength]");
    +        b.end().startDoWhile().string("current != null").end();
    +
    +        b.startReturn().string("newArray").end();
    +
    +        return ex;
    +    }
    +
    +    static Object[] merge(Object[] array0, Object[] array1) {
    +        assert array0.length >= 8;
    +        assert array1.length > 0;
    +
    +        Object[] newArray = new Object[array0.length + array1.length];
    +        System.arraycopy(array0, 0, newArray, 0, array0.length);
    +        System.arraycopy(array1, 0, newArray, array0.length, array0.length);
    +        return newArray;
    +    }
    +
         private CodeExecutableElement createDoPopObject() {
             CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE, STATIC), context.getType(Object.class), "doPopObject");
             ex.addParameter(new CodeVariableElement(types.VirtualFrame, "frame"));
    @@ -1228,6 +1285,7 @@ private CodeExecutableElement createDeserializeOperationNode() {
                 builder.add(createAfterChild());
                 builder.add(createDoEmitFinallyHandler());
                 builder.add(createDoEmitInstruction());
    +            builder.add(createDoEmitVariadic());
                 builder.add(createDoCreateExceptionHandler());
                 builder.add(createDoEmitSourceInfo());
                 builder.add(createFinish());
    @@ -1900,9 +1958,7 @@ private Element createEnd(OperationModel operation) {
                             b.statement("builtNodes.add(node)");
                             b.statement("return node");
                         } else {
    -
                             serializationElements.writeShort(b, serializationElements.codeEnd[operation.id]);
    -
                             b.statement("return");
                         }
     
    @@ -1920,8 +1976,8 @@ private Element createEnd(OperationModel operation) {
                 b.string("" + operation.id);
                 b.end(2);
     
    -            if (operation.isVariadic && operation.numChildren > 0) {
    -                b.startIf().string("operationChildCount[operationSp] < " + operation.numChildren).end().startBlock();
    +            if (operation.isVariadic && operation.numChildren > 1) {
    +                b.startIf().string("operationChildCount[operationSp] < " + (operation.numChildren - 1)).end().startBlock();
                     buildThrowIllegalStateException(b, "\"Operation " + operation.name + " expected at least " + operation.numChildren +
                                     " children, but \" + operationChildCount[operationSp] + \" provided. This is probably a bug in the parser.\"");
                     b.end();
    @@ -2230,6 +2286,10 @@ private CodeExecutableElement createEmit(OperationModel operation) {
             }
     
             private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation, InstructionModel instruction) {
    +            if (instruction.signature.isVariadic) {
    +                b.statement("doEmitVariadic(operationChildCount[operationSp] - " + (instruction.signature.valueCount - 1) + ")");
    +            }
    +
                 if (model.generateUncached) {
                     if (!instruction.needsUncachedData()) {
                         b.statement("Object argument = EPSILON");
    @@ -2242,11 +2302,7 @@ private void buildCustomInitializer(CodeTreeBuilder b, OperationModel operation,
                     b.statement(instruction.getInternalName() + "Gen argument = new " + instruction.getInternalName() + "Gen()");
                 }
     
    -            boolean inEmit = !operation.isVariadic && operation.numChildren == 0;
    -
    -            if (instruction.signature.isVariadic) {
    -                b.statement("argument.op_variadicCount_ = operationChildCount[operationSp] - " + instruction.signature.valueCount);
    -            }
    +            boolean inEmit = operation.numChildren == 0;
     
                 int argBase;
                 if (operation.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) {
    @@ -2671,6 +2727,42 @@ private CodeExecutableElement createDoEmitInstruction() {
                 return ex;
             }
     
    +        private CodeExecutableElement createDoEmitVariadic() {
    +            CodeExecutableElement ex = new CodeExecutableElement(Set.of(PRIVATE), context.getType(void.class), "doEmitVariadic");
    +            ex.addParameter(new CodeVariableElement(context.getType(int.class), "count"));
    +            CodeTreeBuilder b = ex.createBuilder();
    +
    +            int variadicCount = model.popVariadicInstruction.length - 1;
    +
    +            b.startIf().string("count <= ").string(variadicCount).end().startBlock();
    +            b.statement("doEmitInstruction(" + model.popVariadicInstruction[0].id + " + count, EPSILON)");
    +            b.end().startElseBlock();
    +
    +            b.startIf().string("curStack + 1 > maxStack").end().startBlock();
    +            b.statement("maxStack = curStack + 1");
    +            b.end();
    +            b.statement("int elementCount = count + 1");
    +            b.statement("doEmitInstruction(" + model.storeNullInstruction.id + ", EPSILON)");
    +
    +            b.startWhile().string("elementCount > 8").end().startBlock();
    +            b.statement("doEmitInstruction(" + model.popVariadicInstruction[variadicCount].id + ", EPSILON)");
    +            b.statement("elementCount -= 7");
    +            b.end();
    +
    +            b.startIf().string("elementCount > 0").end().startBlock();
    +            b.statement("doEmitInstruction(" + model.popVariadicInstruction[0].id + " + elementCount, EPSILON)");
    +            b.end();
    +            b.statement("doEmitInstruction(" + model.mergeVariadicInstruction.id + ", EPSILON)");
    +            b.end();
    +
    +            b.statement("curStack -= count - 1");
    +            b.startIf().string("count == 0 && curStack > maxStack").end().startBlock();
    +            b.statement("maxStack = curStack");
    +            b.end();
    +
    +            return ex;
    +        }
    +
             private void buildPushStackIndex(CodeTreeBuilder b, String index, boolean performCheck) {
                 if (performCheck) {
                     b.startIf().string("stackValueBciStack.length == stackValueBciSp").end().startBlock();
    @@ -2706,10 +2798,15 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                             break;
                         case CUSTOM:
                         case CUSTOM_QUICKENED:
    +                        int effect;
                             if (instr.signature.isVariadic) {
    -                            b.statement("stackValueBciSp -= " + argument + ".op_variadicCount_");
    +                            b.statement("stackValueBciSp -= operationChildCount[operationSp] - " + (instr.signature.valueCount - 1));
    +                            effect = instr.signature.valueCount - 2;
    +                        } else {
    +                            effect = instr.signature.valueCount - 1;
                             }
    -                        for (int i = instr.signature.valueCount - 1; i >= 0; i--) {
    +
    +                        for (int i = effect - 1; i >= 0; i--) {
                                 if (instr.signature.valueBoxingElimination[i]) {
                                     b.statement(argument + ".op_childValue" + i + "_boxing_ = stackValueBciStack[--stackValueBciSp]");
                                 } else {
    @@ -2773,9 +2870,6 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                         break;
                     case CUSTOM:
                     case CUSTOM_QUICKENED:
    -                    if (instr.signature.isVariadic) {
    -                        b.statement("curStack -= " + argument + ".op_variadicCount_");
    -                    }
                         int delta = (instr.signature.isVoid ? 0 : 1) - instr.signature.valueCount;
                         if (delta != 0) {
                             b.statement("curStack += " + delta);
    @@ -3333,6 +3427,38 @@ private CodeExecutableElement createContinueAt() {
                         case SUPERINSTRUCTION:
                             // todo: implement superinstructions
                             break;
    +                    case STORE_NULL:
    +                        b.statement("frame.setObject(sp, null)");
    +                        b.statement("sp += 1");
    +                        break;
    +                    case LOAD_VARIADIC:
    +                        int effect = -instr.variadicPopCount + 1;
    +                        b.startStatement();
    +                        b.string("frame.setObject(sp");
    +                        if (instr.variadicPopCount != 0) {
    +                            b.string(" - ").string(instr.variadicPopCount);
    +                        }
    +                        b.string(", ");
    +                        if (instr.variadicPopCount == 0) {
    +                            b.staticReference(emptyObjectArray);
    +                        } else {
    +                            b.string("readVariadic(frame, sp, ").string(instr.variadicPopCount).string(")");
    +                        }
    +                        b.string(")");
    +                        b.end();
    +
    +                        if (effect != 0) {
    +                            if (effect > 0) {
    +                                b.statement("sp += " + effect);
    +                            } else {
    +                                b.statement("sp -= " + -effect);
    +                            }
    +                        }
    +                        break;
    +                    case MERGE_VARIADIC:
    +                        b.statement("frame.setObject(sp - 1, mergeVariadic((Object[])frame.getObject(sp - 1)))");
    +                        break;
    +
                         default:
                             throw new UnsupportedOperationException("not implemented");
                     }
    @@ -3415,15 +3541,9 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
     
                 String extraArguments = "$this, objs, bci, sp";
     
    -            if (signature.isVariadic) {
    -                b.startAssign("int variadicCount");
    -                b.startParantheses().cast(uncachedType).string("curObj").end().string(".op_variadicCount_");
    -                b.end();
    -            }
    -
                 if (doPush) {
                     int stackOffset = -instr.signature.valueCount + (instr.signature.isVoid ? 0 : 1);
    -                b.statement("int resultSp = sp + " + stackOffset + (instr.signature.isVariadic ? " - variadicCount" : ""));
    +                b.statement("int resultSp = sp + " + stackOffset);
                 }
     
                 if (isUncached) {
    @@ -3443,17 +3563,16 @@ private void buildCustomInstructionExecute(CodeTreeBuilder b, InstructionModel i
                     b.string("frame");
     
                     for (int i = 0; i < instr.signature.valueCount; i++) {
    +                    TypeMirror targetType = instr.signature.valueTypes[i];
    +                    b.startGroup();
    +                    if (!ElementUtils.isObject(targetType)) {
    +                        b.cast(targetType);
    +                    }
                         b.startCall("frame.getObject").startGroup();
                         b.string("sp");
    -                    if (signature.isVariadic) {
    -                        b.string(" - variadicCount");
    -                    }
                         b.string(" - " + (instr.signature.valueCount - i));
                         b.end(2);
    -                }
    -
    -                if (instr.signature.isVariadic) {
    -                    b.string("readVariadic(frame, sp, variadicCount)");
    +                    b.end();
                     }
     
                     for (int i = 0; i < instr.signature.localSetterCount; i++) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    index 7493ca1c8312..6dbc9b1d1c76 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/InstructionModel.java
    @@ -64,6 +64,9 @@ public enum InstructionKind {
             LOAD_LOCAL_MATERIALIZED,
             STORE_LOCAL,
             STORE_LOCAL_MATERIALIZED,
    +        LOAD_VARIADIC,
    +        MERGE_VARIADIC,
    +        STORE_NULL,
     
             RETURN,
             YIELD,
    @@ -95,6 +98,7 @@ public InstructionField(TypeMirror type, String name, boolean needInUncached, bo
         public CodeTypeElement nodeType;
         public CustomSignature signature;
         public NodeData nodeData;
    +    public int variadicPopCount = -1;
     
         public final List fields = new ArrayList<>();
         public boolean continueWhen;
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    index 15a8c7c4d3ec..43ea0c3637d3 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    @@ -89,6 +89,7 @@ public static class CustomSignature {
             public boolean resultBoxingElimination;
             public Set possibleBoxingResults;
             public boolean isVoid;
    +        public TypeMirror[] valueTypes;
     
             public int localSetterCount;
             public int localSetterRangeCount;
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    index 33d723bd477d..16c9ec9d6da7 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationsModel.java
    @@ -110,6 +110,9 @@ public OperationsModel(ProcessorContext context, TypeElement templateType, Annot
         public InstructionModel branchFalseInstruction;
         public InstructionModel throwInstruction;
         public InstructionModel yieldInstruction;
    +    public InstructionModel[] popVariadicInstruction;
    +    public InstructionModel mergeVariadicInstruction;
    +    public InstructionModel storeNullInstruction;
     
         public List getProvidedTags() {
             AnnotationMirror providedTags = ElementUtils.findAnnotationMirror(ElementUtils.castTypeElement(languageClass), types.ProvidedTags);
    @@ -211,6 +214,7 @@ public void addDefault() {
                                 .setChildrenMustBeValues(true) //
                                 .setInstruction(yieldInstruction);
             }
    +
             operation(OperationKind.SOURCE, "Source") //
                             .setNumChildren(1) //
                             .setTransparent(true) //
    @@ -224,6 +228,13 @@ public void addDefault() {
                             .setTransparent(true) //
                             .setOperationArguments(generic(context.getDeclaredType(Class.class), new WildcardTypeMirror(types.Tag, null)));
     
    +        popVariadicInstruction = new InstructionModel[9];
    +        for (int i = 0; i <= 8; i++) {
    +            popVariadicInstruction[i] = instruction(InstructionKind.LOAD_VARIADIC, "store.variadic[" + i + "]");
    +            popVariadicInstruction[i].variadicPopCount = i;
    +        }
    +        mergeVariadicInstruction = instruction(InstructionKind.MERGE_VARIADIC, "merge.variadic");
    +        storeNullInstruction = instruction(InstructionKind.STORE_NULL, "store.variadic-end");
         }
     
         private static TypeMirror generic(DeclaredType el, TypeMirror... args) {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    index 75ab0682fe85..46f4d63e3df2 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/parser/CustomOperationParser.java
    @@ -236,7 +236,7 @@ protected OperationModel parse(Element element, List ignored)
                 data.operationArguments[signature.localSetterCount + i] = new CodeTypeMirror.ArrayCodeTypeMirror(types.OperationLocal);
             }
     
    -        data.childrenMustBeValues = new boolean[signature.valueCount + (signature.isVariadic ? 1 : 0)];
    +        data.childrenMustBeValues = new boolean[signature.valueCount];
             Arrays.fill(data.childrenMustBeValues, true);
     
             data.instruction = createCustomInstruction(data, nodeType, signature, name);
    @@ -250,10 +250,7 @@ private List createNodeChildAnnotations(CustomSignature signat
             TypeMirror[] boxingEliminated = parent.boxingEliminatedTypes.toArray(new TypeMirror[0]);
     
             for (int i = 0; i < signature.valueCount; i++) {
    -            result.add(createNodeChildAnnotation("child" + i, context.getType(Object.class), boxingEliminated));
    -        }
    -        if (signature.isVariadic) {
    -            result.add(createNodeChildAnnotation("variadicChild", context.getType(Object[].class)));
    +            result.add(createNodeChildAnnotation("child" + i, signature.valueTypes[i], boxingEliminated));
             }
             for (int i = 0; i < signature.localSetterCount; i++) {
                 result.add(createNodeChildAnnotation("localSetter" + i, types.LocalSetter));
    @@ -342,10 +339,7 @@ private CodeExecutableElement createExecuteMethod(CustomSignature signature, Str
     
             if (uncached) {
                 for (int i = 0; i < signature.valueCount; i++) {
    -                ex.addParameter(new CodeVariableElement(context.getType(Object.class), "child" + i + "Value"));
    -            }
    -            if (signature.isVariadic) {
    -                ex.addParameter(new CodeVariableElement(context.getType(Object[].class), "variadicChildValue"));
    +                ex.addParameter(new CodeVariableElement(signature.valueTypes[i], "child" + i + "Value"));
                 }
                 for (int i = 0; i < signature.localSetterCount; i++) {
                     ex.addParameter(new CodeVariableElement(types.LocalSetter, "localSetter" + i + "Value"));
    @@ -399,10 +393,6 @@ private InstructionModel createCustomInstruction(OperationModel data, CodeTypeEl
                 }
             }
     
    -        if (signature.isVariadic) {
    -            instr.addField(context.getType(int.class), "op_variadicCount_", true, false);
    -        }
    -
             for (int i = 0; i < signature.localSetterCount; i++) {
                 instr.addField(types.LocalSetter, "op_localSetter" + i + "_", true, false);
             }
    @@ -507,6 +497,7 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen
     
             List canBeBoxingEliminated = new ArrayList<>();
     
    +        List genericTypes = new ArrayList<>();
             int numValues = 0;
             boolean hasVariadic = false;
     
    @@ -556,6 +547,9 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen
                                         getSimpleName(types.LocalSetterRange));
                         isValid = false;
                     }
    +                genericTypes.add(context.getType(Object[].class));
    +                canBeBoxingEliminated.add(false);
    +                numValues++;
                     hasVariadic = true;
                 } else if (isDSLParameter(param)) {
                     // nothing, we ignore these
    @@ -568,6 +562,7 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen
                         data.addError(param, "Value parameters must precede LocalSetter and LocalSetterRange parameters.");
                         isValid = false;
                     }
    +                genericTypes.add(context.getType(Object.class));
                     canBeBoxingEliminated.add(parent.isBoxingEliminated(param.asType()));
                     numValues++;
                 }
    @@ -583,6 +578,8 @@ private CustomSignature determineSignature(OperationModel data, ExecutableElemen
             signature.localSetterCount = numLocalSetters;
             signature.localSetterRangeCount = numLocalSetterRanges;
             signature.valueBoxingElimination = new boolean[numValues];
    +        signature.valueTypes = genericTypes.toArray(new TypeMirror[genericTypes.size()]);
    +
             for (int i = 0; i < numValues; i++) {
                 signature.valueBoxingElimination[i] = canBeBoxingEliminated.get(i);
             }
    
    From 9e4a76ae10894a8b0c88031612114a2fbe2ec3d5 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Mon, 23 Jan 2023 13:22:03 +0100
    Subject: [PATCH 311/312] Add a few tests, fix a few bugs
    
    ---
     .../test/example/TestOperations.java          |  28 +
     .../example/TestOperationsParserTest.java     | 691 +++++++++++++++++-
     .../generator/OperationsNodeFactory.java      |  20 +-
     .../operations/model/OperationModel.java      |   2 +
     4 files changed, 695 insertions(+), 46 deletions(-)
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    index 3bb4e28001d5..61ac2a16a60c 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    @@ -67,11 +67,14 @@
     import com.oracle.truffle.api.operation.Operation;
     import com.oracle.truffle.api.operation.OperationProxy;
     import com.oracle.truffle.api.operation.OperationRootNode;
    +import com.oracle.truffle.api.operation.ShortCircuitOperation;
     import com.oracle.truffle.api.operation.Variadic;
     
     @GenerateOperations(languageClass = TestLanguage.class, enableYield = true, enableSerialization = true, boxingEliminationTypes = {long.class})
     @GenerateAOT
     @OperationProxy(SomeOperationNode.class)
    +@ShortCircuitOperation(booleanConverter = TestOperations.ToBoolean.class, name = "ScAnd", continueWhen = true)
    +@ShortCircuitOperation(booleanConverter = TestOperations.ToBoolean.class, name = "ScOr", continueWhen = false)
     public abstract class TestOperations extends RootNode implements OperationRootNode {
     
         protected TestOperations(TruffleLanguage language, FrameDescriptor.Builder frameDescriptor) {
    @@ -225,6 +228,30 @@ public static TestClosure materialize(VirtualFrame frame, TestOperations root) {
                 return new TestClosure(frame.materialize(), root);
             }
         }
    +
    +    @Operation
    +    public static final class VoidOperation {
    +        @Specialization
    +        public static void doNothing() {
    +        }
    +    }
    +
    +    public static final class ToBoolean {
    +        @Specialization
    +        public static boolean doLong(long l) {
    +            return l != 0;
    +        }
    +
    +        @Specialization
    +        public static boolean doBoolean(boolean b) {
    +            return b;
    +        }
    +
    +        @Specialization
    +        public static boolean doString(String s) {
    +            return s != null;
    +        }
    +    }
     }
     
     class TestClosure {
    @@ -242,6 +269,7 @@ public Object call() {
     }
     
     @ProvidedTags(ExpressionTag.class)
    +@TruffleLanguage.Registration(id = "test")
     class TestLanguage extends TruffleLanguage {
         @Override
         protected Object createContext(Env env) {
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    index af8efa618c7c..77efd2748e94 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    @@ -40,12 +40,17 @@
      */
     package com.oracle.truffle.api.operation.test.example;
     
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNotNull;
    +
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.List;
     
     import org.junit.Assert;
    +import org.junit.Rule;
     import org.junit.Test;
    +import org.junit.rules.ExpectedException;
     
     import com.oracle.truffle.api.RootCallTarget;
     import com.oracle.truffle.api.exception.AbstractTruffleException;
    @@ -56,6 +61,9 @@
     import com.oracle.truffle.api.operation.OperationLocal;
     import com.oracle.truffle.api.operation.OperationNodes;
     import com.oracle.truffle.api.operation.OperationRootNode;
    +import com.oracle.truffle.api.operation.introspection.Instruction;
    +import com.oracle.truffle.api.operation.introspection.OperationIntrospection;
    +import com.oracle.truffle.api.source.Source;
     import com.oracle.truffle.api.operation.OperationParser;
     
     public class TestOperationsParserTest {
    @@ -63,20 +71,29 @@ public class TestOperationsParserTest {
     
         private static final TestLanguage LANGUAGE = null;
     
    +    @Rule
    +    public ExpectedException thrown = ExpectedException.none();
    +
         private static RootCallTarget parse(OperationParser builder) {
             OperationRootNode operationsNode = parseNode(builder);
             return ((RootNode) operationsNode).getCallTarget();
         }
     
    -    private static OperationRootNode parseNode(OperationParser builder) {
    +    private static TestOperations parseNode(OperationParser builder) {
             OperationNodes nodes = TestOperationsGen.create(OperationConfig.DEFAULT, builder);
             TestOperations op = nodes.getNodes().get(nodes.getNodes().size() - 1);
             System.out.println(op.dump());
             return op;
         }
    +    private static TestOperations parseNodeWithSource(OperationParser builder) {
    +        OperationNodes nodes = TestOperationsGen.create(OperationConfig.WITH_SOURCE, builder);
    +        TestOperations op = nodes.getNodes().get(nodes.getNodes().size() - 1);
    +        System.out.println(op.dump());
    +        return op;
    +    }
     
         @Test
    -    public void testAdd() {
    +    public void testExampleAdd() {
             RootCallTarget root = parse(b -> {
                 b.beginRoot(LANGUAGE);
     
    @@ -90,13 +107,13 @@ public void testAdd() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(42L, root.call(20L, 22L));
    -        Assert.assertEquals("foobar", root.call("foo", "bar"));
    -        Assert.assertEquals(100L, root.call(120L, -20L));
    +        assertEquals(42L, root.call(20L, 22L));
    +        assertEquals("foobar", root.call("foo", "bar"));
    +        assertEquals(100L, root.call(120L, -20L));
         }
     
         @Test
    -    public void testMax() {
    +    public void testExampleMax() {
             RootCallTarget root = parse(b -> {
                 b.beginRoot(LANGUAGE);
                 b.beginIfThenElse();
    @@ -119,10 +136,10 @@ public void testMax() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(42L, root.call(42L, 13L));
    -        Assert.assertEquals(42L, root.call(42L, 13L));
    -        Assert.assertEquals(42L, root.call(42L, 13L));
    -        Assert.assertEquals(42L, root.call(13L, 42L));
    +        assertEquals(42L, root.call(42L, 13L));
    +        assertEquals(42L, root.call(42L, 13L));
    +        assertEquals(42L, root.call(42L, 13L));
    +        assertEquals(42L, root.call(13L, 42L));
         }
     
         @Test
    @@ -149,15 +166,50 @@ public void testIfThen() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(0L, root.call(-2L));
    -        Assert.assertEquals(0L, root.call(-1L));
    -        Assert.assertEquals(0L, root.call(0L));
    -        Assert.assertEquals(1L, root.call(1L));
    -        Assert.assertEquals(2L, root.call(2L));
    +        assertEquals(0L, root.call(-2L));
    +        assertEquals(0L, root.call(-1L));
    +        assertEquals(0L, root.call(0L));
    +        assertEquals(1L, root.call(1L));
    +        assertEquals(2L, root.call(2L));
         }
     
         @Test
    -    public void testSumLoop() {
    +    public void testConditional() {
    +        // return arg0 < 0 ? 0 : arg0;
    +
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +
    +            b.beginConditional();
    +
    +            b.beginLessThanOperation();
    +            b.emitLoadArgument(0);
    +            b.emitLoadConstant(0L);
    +            b.endLessThanOperation();
    +
    +            b.emitLoadConstant(0L);
    +
    +            b.emitLoadArgument(0);
    +
    +            b.endConditional();
    +
    +            b.endReturn();
    +
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(0L, root.call(-2L));
    +        assertEquals(0L, root.call(-1L));
    +        assertEquals(0L, root.call(0L));
    +        assertEquals(1L, root.call(1L));
    +        assertEquals(2L, root.call(2L));
    +    }
    +
    +    @Test
    +    public void testExampleSumLoop() {
     
             // i = 0;j = 0;
             // while ( i < arg0 ) { j = j + i;i = i + 1;}
    @@ -207,7 +259,7 @@ public void testSumLoop() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(45L, root.call(10L));
    +        assertEquals(45L, root.call(10L));
         }
     
         @Test
    @@ -241,8 +293,8 @@ public void testTryCatch() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(1L, root.call(-1L));
    -        Assert.assertEquals(0L, root.call(1L));
    +        assertEquals(1L, root.call(-1L));
    +        assertEquals(0L, root.call(1L));
         }
     
         @Test
    @@ -298,7 +350,7 @@ public void testVariableBoxingElim() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(4950L, root.call());
    +        assertEquals(4950L, root.call());
         }
     
         private static void testOrdering(boolean expectException, RootCallTarget root, Long... order) {
    @@ -892,7 +944,7 @@ public void testTeeLocal() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(1L, root.call());
    +        assertEquals(1L, root.call());
         }
     
         @Test
    @@ -915,7 +967,7 @@ public void testTeeLocalRange() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(2L, root.call());
    +        assertEquals(2L, root.call());
         }
     
         @Test
    @@ -939,12 +991,12 @@ public void testYield() {
             });
     
             ContinuationResult r1 = (ContinuationResult) root.call();
    -        Assert.assertEquals(1L, r1.getResult());
    +        assertEquals(1L, r1.getResult());
     
             ContinuationResult r2 = (ContinuationResult) r1.continueWith(null);
    -        Assert.assertEquals(2L, r2.getResult());
    +        assertEquals(2L, r2.getResult());
     
    -        Assert.assertEquals(3L, r2.continueWith(null));
    +        assertEquals(3L, r2.continueWith(null));
         }
     
     
    @@ -996,12 +1048,12 @@ public void testYieldLocal() {
             });
     
             ContinuationResult r1 = (ContinuationResult) root.call();
    -        Assert.assertEquals(0L, r1.getResult());
    +        assertEquals(0L, r1.getResult());
     
             ContinuationResult r2 = (ContinuationResult) r1.continueWith(null);
    -        Assert.assertEquals(1L, r2.getResult());
    +        assertEquals(1L, r2.getResult());
     
    -        Assert.assertEquals(2L, r2.continueWith(null));
    +        assertEquals(2L, r2.continueWith(null));
         }
         @Test
         public void testYieldStack() {
    @@ -1028,12 +1080,12 @@ public void testYieldStack() {
             });
     
             ContinuationResult r1 = (ContinuationResult) root.call();
    -        Assert.assertEquals(1L, r1.getResult());
    +        assertEquals(1L, r1.getResult());
     
             ContinuationResult r2 = (ContinuationResult) r1.continueWith(3L);
    -        Assert.assertEquals(2L, r2.getResult());
    +        assertEquals(2L, r2.getResult());
     
    -        Assert.assertEquals(7L, r2.continueWith(4L));
    +        assertEquals(7L, r2.continueWith(4L));
         }
     
         @Test
    @@ -1085,16 +1137,16 @@ public void testYieldFromFinally() {
             });
     
             ContinuationResult r1 = (ContinuationResult) root.call();
    -        Assert.assertEquals(1L, r1.getResult());
    +        assertEquals(1L, r1.getResult());
     
             ContinuationResult r2 = (ContinuationResult) r1.continueWith(3L);
    -        Assert.assertEquals(4L, r2.getResult());
    +        assertEquals(4L, r2.getResult());
     
    -        Assert.assertEquals(3L, r2.continueWith(4L));
    +        assertEquals(3L, r2.continueWith(4L));
         }
     
         @Test
    -    public void testNestedFunctions() {
    +    public void testExampleNestedFunctions() {
             RootCallTarget root = parse(b -> {
                 // this simulates following in python:
                 // return (lambda: 1)()
    @@ -1120,11 +1172,11 @@ public void testNestedFunctions() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(1L, root.call());
    +        assertEquals(1L, root.call());
         }
     
         @Test
    -    public void testNonlocalRead() {
    +    public void testLocalsNonlocalRead() {
             // todo: this test fails when boxing elimination is enabled
             // locals accessed non-locally must have boxing elimination disabled
             // since non-local reads do not do boxing elimination
    @@ -1164,11 +1216,11 @@ public void testNonlocalRead() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(1L, root.call());
    +        assertEquals(1L, root.call());
         }
     
         @Test
    -    public void testNonlocalWrite() {
    +    public void testLocalsNonlocalWrite() {
             RootCallTarget root = parse(b -> {
                 // x = 1
                 // (lambda: x = 2)()
    @@ -1210,6 +1262,565 @@ public void testNonlocalWrite() {
                 b.endRoot();
             });
     
    -        Assert.assertEquals(2L, root.call());
    +        assertEquals(2L, root.call());
    +    }
    +
    +    @Test
    +    public void testBranchForward() {
    +        RootCallTarget root = parse(b -> {
    +            // goto lbl;
    +            // return 0;
    +            // lbl: return 1;
    +            b.beginRoot(LANGUAGE);
    +
    +            OperationLabel lbl = b.createLabel();
    +
    +            b.emitBranch(lbl);
    +
    +            b.beginReturn();
    +            b.emitLoadConstant(0L);
    +            b.endReturn();
    +
    +            b.emitLabel(lbl);
    +
    +            b.beginReturn();
    +            b.emitLoadConstant(1L);
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(1L, root.call());
    +    }
    +
    +
    +    @Test
    +    public void testBranchBackwards() {
    +        RootCallTarget root = parse(b -> {
    +            // x = 0
    +            // lbl:
    +            // if (5 < x) return x;
    +            // x = x + 1;
    +            // goto lbl;
    +            b.beginRoot(LANGUAGE);
    +
    +            OperationLabel lbl = b.createLabel();
    +            OperationLocal loc = b.createLocal();
    +
    +            b.beginStoreLocal(loc);
    +            b.emitLoadConstant(0L);
    +            b.endStoreLocal();
    +
    +            b.emitLabel(lbl);
    +
    +            b.beginIfThen();
    +
    +            b.beginLessThanOperation();
    +            b.emitLoadConstant(5L);
    +            b.emitLoadLocal(loc);
    +            b.endLessThanOperation();
    +
    +            b.beginReturn();
    +            b.emitLoadLocal(loc);
    +            b.endReturn();
    +
    +            b.endIfThen();
    +
    +            b.beginStoreLocal(loc);
    +            b.beginAddOperation();
    +            b.emitLoadLocal(loc);
    +            b.emitLoadConstant(1L);
    +            b.endAddOperation();
    +            b.endStoreLocal();
    +
    +            b.emitBranch(lbl);
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(6L, root.call());
    +    }
    +
    +    @Test
    +    public void testBranchOutwards() {
    +        RootCallTarget root = parse(b -> {
    +            // return 1 + { goto lbl; 2 }
    +            // lbl:
    +            // return 0;
    +            b.beginRoot(LANGUAGE);
    +
    +            OperationLabel lbl = b.createLabel();
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadConstant(1L);
    +            b.beginBlock();
    +              b.emitBranch(lbl);
    +              b.emitLoadConstant(2L);
    +            b.endBlock();
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.emitLabel(lbl);
    +
    +            b.beginReturn();
    +            b.emitLoadConstant(0L);
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(0L, root.call());
    +    }
    +
    +    @Test
    +    public void testBranchInwards() {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("OperationLabel must be emitted inside the same operation it was created in.");
    +        parse(b -> {
    +            // goto lbl;
    +            // return 1 + { lbl: 2 }
    +            b.beginRoot(LANGUAGE);
    +
    +            OperationLabel lbl = b.createLabel();
    +            b.emitBranch(lbl);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadConstant(1L);
    +            b.beginBlock();
    +              b.emitLabel(lbl);
    +              b.emitLoadConstant(2L);
    +            b.endBlock();
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testVariadicZeroVarargs()  {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginVeryComplexOperation();
    +            b.emitLoadConstant(7L);
    +            b.endVeryComplexOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(7L, root.call());
    +    }
    +
    +    @Test
    +    public void testVariadicOneVarargs()  {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginVeryComplexOperation();
    +            b.emitLoadConstant(7L);
    +            b.emitLoadConstant("foo");
    +            b.endVeryComplexOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(8L, root.call());
    +    }
    +
    +    @Test
    +    public void testVariadicFewVarargs()  {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginVeryComplexOperation();
    +            b.emitLoadConstant(7L);
    +            b.emitLoadConstant("foo");
    +            b.emitLoadConstant("bar");
    +            b.emitLoadConstant("baz");
    +            b.endVeryComplexOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(10L, root.call());
    +    }
    +
    +    @Test
    +    public void testVariadicManyVarargs()  {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginVeryComplexOperation();
    +            b.emitLoadConstant(7L);
    +            for (int i = 0; i < 1330; i++) {
    +                b.emitLoadConstant("test");
    +            }
    +            b.endVeryComplexOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(1337L, root.call());
    +    }
    +
    +    @Test
    +    public void testVariadicTooFewArguments()  {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation VeryComplexOperation expected at least 1 children, but 0 provided. This is probably a bug in the parser.");
    +
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginVeryComplexOperation();
    +            b.endVeryComplexOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testValidationTooFewArguments() {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation AddOperation expected exactly 2 children, but 1 provided. This is probably a bug in the parser.");
    +
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadConstant(1L);
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testValidationTooManyArguments() {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation AddOperation expected exactly 2 children, but 3 provided. This is probably a bug in the parser.");
    +
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadConstant(1L);
    +            b.emitLoadConstant(2L);
    +            b.emitLoadConstant(3L);
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testValidationNotValueArgument() {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation AddOperation expected a value-producing child at position 0, but a void one was provided. This likely indicates a bug in the parser.");
    +
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitVoidOperation();
    +            b.emitLoadConstant(2L);
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testSource() {
    +        Source source = Source.newBuilder("test", "return 1", "test.test").build();
    +        TestOperations node = parseNodeWithSource(b -> {
    +            b.beginRoot(LANGUAGE);
    +            b.beginSource(source);
    +            b.beginSourceSection(0, 8);
    +
    +            b.beginReturn();
    +
    +            b.beginSourceSection(7, 1);
    +            b.emitLoadConstant(1L);
    +            b.endSourceSection();
    +
    +            b.endReturn();
    +
    +            b.endSourceSection();
    +            b.endSource();
    +            b.endRoot();
    +        });
    +
    +        assertEquals(node.getSourceSection().getSource(), source);
    +        assertEquals(node.getSourceSection().getCharIndex(), 0);
    +        assertEquals(node.getSourceSection().getCharLength(), 8);
    +
    +        assertEquals(node.getSourceSectionAtBci(0).getSource(), source);
    +        assertEquals(node.getSourceSectionAtBci(0).getCharIndex(), 7);
    +        assertEquals(node.getSourceSectionAtBci(0).getCharLength(), 1);
    +
    +        assertEquals(node.getSourceSectionAtBci(1).getSource(), source);
    +        assertEquals(node.getSourceSectionAtBci(1).getCharIndex(), 0);
    +        assertEquals(node.getSourceSectionAtBci(1).getCharLength(), 8);
    +    }
    +
    +    @Test
    +    public void testSourceNoSourceSet() {
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("No enclosing Source operation found - each SourceSection must be enclosed in a Source operation.");
    +        parseNodeWithSource(b -> {
    +            b.beginRoot(LANGUAGE);
    +            b.beginSourceSection(0, 8);
    +
    +            b.beginReturn();
    +
    +            b.beginSourceSection(7, 1);
    +            b.emitLoadConstant(1L);
    +            b.endSourceSection();
    +
    +            b.endReturn();
    +
    +            b.endSourceSection();
    +            b.endRoot();
    +        });
    +    }
    +
    +
    +
    +    @Test
    +    public void testSourceMultipleSources() {
    +        Source source1 = Source.newBuilder("test", "This is just a piece of test source.", "test1.test").build();
    +        Source source2 = Source.newBuilder("test", "This is another test source.", "test2.test").build();
    +        TestOperations root = parseNodeWithSource(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.beginSource(source1);
    +            b.beginBlock();
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.beginSourceSection(1, 2);
    +            b.beginBlock();
    +
    +            b.emitVoidOperation(); // source1, 1, 2
    +
    +            b.beginSource(source2);
    +            b.beginBlock();
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.beginSourceSection(3,  4);
    +            b.beginBlock();
    +
    +            b.emitVoidOperation(); // source2, 3, 4
    +
    +            b.beginSourceSection(5, 1);
    +            b.beginBlock();
    +
    +            b.emitVoidOperation(); // source2, 5, 1
    +
    +            b.endBlock();
    +            b.endSourceSection();
    +
    +            b.emitVoidOperation(); // source2, 3, 4
    +
    +            b.endBlock();
    +            b.endSourceSection();
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.endBlock();
    +            b.endSource();
    +
    +            b.emitVoidOperation(); // source1, 1, 2
    +
    +            b.endBlock();
    +            b.endSourceSection();
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.endBlock();
    +            b.endSource();
    +
    +            b.emitVoidOperation(); // no source
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(root.getSourceSection().getSource(), source1);
    +        assertEquals(root.getSourceSection().getCharIndex(), 1);
    +        assertEquals(root.getSourceSection().getCharLength(), 2);
    +
    +        Source[] sources = {null, source1, source2};
    +
    +        int[][] expected = {
    +                        null,
    +                        null,
    +                        {1, 1, 2},
    +                        null,
    +                        {2, 3, 4},
    +                        {2, 5, 1},
    +                        {2, 3, 4},
    +                        null,
    +                        {1, 1, 2},
    +                        null,
    +                        null,
    +        };
    +
    +        for (int i = 0; i < expected.length; i++) {
    +            if (expected[i] == null) {
    +                assertEquals("Mismatch at bci " + i, root.getSourceSectionAtBci(i), null);
    +            } else {
    +                assertNotNull("Mismatch at bci " + i, root.getSourceSectionAtBci(i));
    +                assertEquals("Mismatch at bci " + i, root.getSourceSectionAtBci(i).getSource(), sources[expected[i][0]]);
    +                assertEquals("Mismatch at bci " + i, root.getSourceSectionAtBci(i).getCharIndex(), expected[i][1]);
    +                assertEquals("Mismatch at bci " + i, root.getSourceSectionAtBci(i).getCharLength(), expected[i][2]);
    +            }
    +        }
    +    }
    +
    +    @Test
    +    public void testShortCircuitingAllPass() {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginScAnd();
    +            b.emitLoadConstant(1L);
    +            b.emitLoadConstant(true);
    +            b.emitLoadConstant("test");
    +            b.endScAnd();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals("test", root.call());
    +    }
    +
    +    @Test
    +    public void testShortCircuitingLastFail() {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginScAnd();
    +            b.emitLoadConstant(1L);
    +            b.emitLoadConstant("test");
    +            b.emitLoadConstant(0L);
    +            b.endScAnd();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(0L, root.call());
    +    }
    +
    +    @Test
    +    public void testShortCircuitingFirstFail() {
    +        RootCallTarget root = parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginScAnd();
    +            b.emitLoadConstant(0L);
    +            b.emitLoadConstant("test");
    +            b.emitLoadConstant(1L);
    +            b.endScAnd();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        assertEquals(0L, root.call());
    +    }
    +
    +    @Test
    +    public void testShortCircuitingNoChildren() {
    +        // todo: this fails since there is no check, since sc is considered as taking 0 (only variadic) args
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation ScAnd expected at least 1 children, but 0 provided. This is probably a bug in the parser.");
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginScAnd();
    +            b.endScAnd();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    @Test
    +    public void testShortCircuitingNonValueChild() {
    +        // todo: this message should be improved, since all variadic children are treated as the same position (e.g. message should be "at position 1".
    +        thrown.expect(IllegalStateException.class);
    +        thrown.expectMessage("Operation ScAnd expected a value-producing child at position 0, but a void one was provided. This likely indicates a bug in the parser.");
    +        parse(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginScAnd();
    +            b.emitLoadConstant("test");
    +            b.emitVoidOperation();
    +            b.emitLoadConstant("tost");
    +            b.endScAnd();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +    }
    +
    +    private static void assertInstructionEquals(Instruction instr, int index, String name) {
    +        assertEquals(instr.getIndex(), index);
    +        assertEquals(instr.getName(), name);
    +    }
    +
    +    @Test
    +    public void testIntrospectionData() {
    +        TestOperations node = parseNode(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadArgument(0);
    +            b.emitLoadArgument(1);
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        OperationIntrospection data = node.getIntrospectionData();
    +
    +        assertEquals(data.getInstructions().size(), 5);
    +        assertInstructionEquals(data.getInstructions().get(0), 0, "load.argument");
    +        assertInstructionEquals(data.getInstructions().get(1), 1, "load.argument");
    +        assertInstructionEquals(data.getInstructions().get(2), 2, "c.AddOperation");
    +        assertInstructionEquals(data.getInstructions().get(3), 3, "return");
    +        // todo: with DCE, this pop will go away (since return is considered as returning a value)
    +        assertInstructionEquals(data.getInstructions().get(4), 4, "pop");
         }
     }
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    index bebd2320342b..acc55e5ee841 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/generator/OperationsNodeFactory.java
    @@ -323,6 +323,10 @@ private CodeExecutableElement createGetSourceSectionAtBci() {
     
             b.statement("i -= 3");
     
    +        b.startIf().string("sourceInfo[i + 1] == -1").end().startBlock();
    +        b.returnNull();
    +        b.end();
    +
             b.statement("return sources[(sourceInfo[i] >> 16) & 0xffff].createSection(sourceInfo[i + 1], sourceInfo[i + 2])");
     
             return ex;
    @@ -698,8 +702,6 @@ private CodeExecutableElement createGetIntrospectionData() {
                     case BRANCH_FALSE:
                         buildIntrospectionArgument(b, "BRANCH_OFFSET", "((IntRef) data).value");
                         break;
    -                case CUSTOM:
    -                    break;
                     case LOAD_CONSTANT:
                         buildIntrospectionArgument(b, "CONSTANT", "data");
                         break;
    @@ -723,8 +725,10 @@ private CodeExecutableElement createGetIntrospectionData() {
                     case THROW:
                         buildIntrospectionArgument(b, "LOCAL", "((IntRef) data).value");
                         break;
    +                case CUSTOM:
    +                    break;
                     case CUSTOM_SHORT_CIRCUIT:
    -                    buildIntrospectionArgument(b, "BRANCH_OFFSET", "((" + instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : "") + " ) data).op_branchTarget_");
    +                    buildIntrospectionArgument(b, "BRANCH_OFFSET", "((" + instr.getInternalName() + "Gen" + (model.generateUncached ? "_UncachedData" : "") + " ) data).op_branchTarget_.value");
                         break;
                 }
     
    @@ -2089,15 +2093,19 @@ private Element createEnd(OperationModel operation) {
     
                         b.startStatement().startCall("doEmitSourceInfo");
                         b.string("sourceIndexStack[sourceIndexSp - 1]");
    -                    b.string("sourceLocationStack[sourceLocationSp]");
    -                    b.string("sourceLocationStack[sourceLocationSp + 1]");
    +                    b.string("sourceLocationStack[sourceLocationSp - 2]");
    +                    b.string("sourceLocationStack[sourceLocationSp - 1]");
                         b.end(2);
                         break;
     
                     case SOURCE:
                         b.statement("sourceLocationSp -= 2");
                         b.statement("sourceIndexSp -= 1");
    +                    b.startIf().string("sourceIndexSp > 0").end().startBlock();
    +                    b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp - 1], sourceLocationStack[sourceLocationSp - 2], sourceLocationStack[sourceLocationSp - 1])");
    +                    b.end().startElseBlock();
                         b.statement("doEmitSourceInfo(sourceIndexStack[sourceIndexSp], -1, -1)");
    +                    b.end();
                         break;
                     case IF_THEN:
                     case IF_THEN_ELSE:
    @@ -2806,7 +2814,7 @@ private void buildEmitInstruction(CodeTreeBuilder b, InstructionModel instr, Str
                                 effect = instr.signature.valueCount - 1;
                             }
     
    -                        for (int i = effect - 1; i >= 0; i--) {
    +                        for (int i = effect; i >= 0; i--) {
                                 if (instr.signature.valueBoxingElimination[i]) {
                                     b.statement(argument + ".op_childValue" + i + "_boxing_ = stackValueBciStack[--stackValueBciSp]");
                                 } else {
    diff --git a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    index 43ea0c3637d3..e45e6f302053 100644
    --- a/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    +++ b/truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/operations/model/OperationModel.java
    @@ -81,6 +81,8 @@ public enum OperationKind {
             CUSTOM_SHORT_CIRCUIT
         }
     
    +    // todo: this is wrongly here, it is only relevant to instructions
    +    // operations have no concept of signatures (yet)
         public static class CustomSignature {
             public int valueCount;
             public boolean isVariadic;
    
    From 2c57e16e4fbdfb8b6b194ef776baedb99cfe4f50 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Nikola=20Bebi=C4=87?= 
    Date: Mon, 23 Jan 2023 16:10:27 +0100
    Subject: [PATCH 312/312] Add decision tests
    
    ---
     .../operation/test/dsl_tests/ErrorTests.java  | 21 ++++++++
     .../test/dsl_tests/bad_decisions.json         |  5 ++
     .../test/example/TestOperations.java          |  9 +++-
     .../example/TestOperationsParserTest.java     | 54 +++++++++++++++++--
     .../api/operation/test/example/decisions.json | 16 ++++++
     5 files changed, 100 insertions(+), 5 deletions(-)
     create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/bad_decisions.json
     create mode 100644 truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/decisions.json
    
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java
    index a90f5b1d001a..93b94cef5996 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/ErrorTests.java
    @@ -210,6 +210,27 @@ public static final class TestOperation9 {
                 public static void spec(LocalSetter a, @ExpectError("Value parameters must precede LocalSetter and LocalSetterRange parameters.") Object b) {
                 }
             }
    +    } 
    +
    +    // todo: more tests when parsing becomes more robust (right now messages are pretty useless, and
    +    // also contain full filepath, making the tests non-portable)
    +    // todo: test for bad quicken decision when we parse those
    +    @ExpectError({
    +                    "Unknown optimization decision type: 'MadeUpType'.",
    +                    "Error reading optimization decisions: Super-instruction 'si.made.up.instruction' defines a sub-instruction 'made.up.instruction' which does not exist.",
    +    })
    +    @GenerateOperations(languageClass = ErrorLanguage.class, decisionsFile = "bad_decisions.json")
    +    public abstract static class OperationDecisionErrorTests extends RootNode implements OperationRootNode {
    +        protected OperationDecisionErrorTests(TruffleLanguage language, FrameDescriptor builder) {
    +            super(language, builder);
    +        }
    +
    +        @Operation
    +        public static final class TestOperation {
    +            @Specialization
    +            public static void doStuff() {
    +            }
    +        }
         }
     
         @ExpectError("%")
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/bad_decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/bad_decisions.json
    new file mode 100644
    index 000000000000..b6bd30b7d961
    --- /dev/null
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/dsl_tests/bad_decisions.json
    @@ -0,0 +1,5 @@
    +[
    +	{ "type": "MadeUpType" },
    +	{ "type": "SuperInstruction", "instructions": [ "made.up.instruction" ]},
    +	{ "type": "Quicken", "operation": "MadeUpOperation", "specializations": [ "NonExistant" ]}
    +]
    \ No newline at end of file
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    index 61ac2a16a60c..a891cab2b38e 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperations.java
    @@ -70,7 +70,12 @@
     import com.oracle.truffle.api.operation.ShortCircuitOperation;
     import com.oracle.truffle.api.operation.Variadic;
     
    -@GenerateOperations(languageClass = TestLanguage.class, enableYield = true, enableSerialization = true, boxingEliminationTypes = {long.class})
    +@GenerateOperations(//
    +                languageClass = TestLanguage.class, //
    +                enableYield = true, //
    +                enableSerialization = true, //
    +                boxingEliminationTypes = {long.class}, //
    +                decisionsFile = "decisions.json")
     @GenerateAOT
     @OperationProxy(SomeOperationNode.class)
     @ShortCircuitOperation(booleanConverter = TestOperations.ToBoolean.class, name = "ScAnd", continueWhen = true)
    @@ -99,7 +104,7 @@ private static class TestException extends AbstractOperationsTruffleException {
         @GenerateAOT
         static final class AddOperation {
             @Specialization
    -        public static long add(long lhs, long rhs) {
    +        public static long addLongs(long lhs, long rhs) {
                 return lhs + rhs;
             }
     
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    index 77efd2748e94..003d947ed74a 100644
    --- a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/TestOperationsParserTest.java
    @@ -1794,8 +1794,8 @@ public void testShortCircuitingNonValueChild() {
         }
     
         private static void assertInstructionEquals(Instruction instr, int index, String name) {
    -        assertEquals(instr.getIndex(), index);
    -        assertEquals(instr.getName(), name);
    +        assertEquals(index, instr.getIndex());
    +        assertEquals(name, instr.getName());
         }
     
         @Test
    @@ -1815,7 +1815,7 @@ public void testIntrospectionData() {
     
             OperationIntrospection data = node.getIntrospectionData();
     
    -        assertEquals(data.getInstructions().size(), 5);
    +        assertEquals(5, data.getInstructions().size());
             assertInstructionEquals(data.getInstructions().get(0), 0, "load.argument");
             assertInstructionEquals(data.getInstructions().get(1), 1, "load.argument");
             assertInstructionEquals(data.getInstructions().get(2), 2, "c.AddOperation");
    @@ -1823,4 +1823,52 @@ public void testIntrospectionData() {
             // todo: with DCE, this pop will go away (since return is considered as returning a value)
             assertInstructionEquals(data.getInstructions().get(4), 4, "pop");
         }
    +
    +    @Test
    +    public void testDecisionQuicken() {
    +        TestOperations node = parseNode(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginAddOperation();
    +            b.emitLoadArgument(0);
    +            b.emitLoadArgument(1);
    +            b.endAddOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        // todo: these tests do not pass, since quickening is not implemented yet properly
    +
    +        assertInstructionEquals(node.getIntrospectionData().getInstructions().get(2), 2, "c.AddOperation");
    +
    +        assertEquals(3L, node.getCallTarget().call(1L, 2L));
    +
    +        assertInstructionEquals(node.getIntrospectionData().getInstructions().get(2), 2, "c.AddOperation.q.AddLongs");
    +
    +        assertEquals("foobar", node.getCallTarget().call("foo", "bar"));
    +
    +        assertInstructionEquals(node.getIntrospectionData().getInstructions().get(2), 2, "c.AddOperation");
    +    }
    +
    +    @Test
    +    public void testDecisionSuperInstruction() {
    +        TestOperations node = parseNode(b -> {
    +            b.beginRoot(LANGUAGE);
    +
    +            b.beginReturn();
    +            b.beginLessThanOperation();
    +            b.emitLoadArgument(0);
    +            b.emitLoadArgument(1);
    +            b.endLessThanOperation();
    +            b.endReturn();
    +
    +            b.endRoot();
    +        });
    +
    +        // todo: these tests do not pass, since quickening is not implemented yet properly
    +
    +        assertInstructionEquals(node.getIntrospectionData().getInstructions().get(1), 1, "si.load.argument.c.LessThanOperation");
    +    }
     }
    diff --git a/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/decisions.json b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/decisions.json
    new file mode 100644
    index 000000000000..dda20a980dc8
    --- /dev/null
    +++ b/truffle/src/com.oracle.truffle.api.operation.test/src/com/oracle/truffle/api/operation/test/example/decisions.json
    @@ -0,0 +1,16 @@
    +[
    +	{
    +		"id": "test1",
    +		"type": "Quicken",
    +		"operation": "AddOperation",
    +		"specializations": ["AddLongs"]
    +	},
    +	{
    +        "id": "test2",
    +        "type": "SuperInstruction",
    +        "instructions": [
    +            "load.argument",
    +            "c.LessThanOperation"
    +        ]
    +    }
    +]
    \ No newline at end of file